claude-smart 0.2.45 → 0.2.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +3 -3
- package/README.md +47 -10
- package/bin/claude-smart.js +535 -23
- package/package.json +22 -3
- package/plugin/.claude-plugin/plugin.json +4 -2
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/README.md +27 -6
- package/plugin/commands/clear-all.md +1 -0
- package/plugin/commands/dashboard.md +1 -0
- package/plugin/commands/learn.md +1 -0
- package/plugin/commands/restart.md +1 -0
- package/plugin/commands/show.md +1 -0
- package/plugin/dashboard/app/configure/env/page.tsx +40 -14
- package/plugin/dashboard/app/configure/server/page.tsx +51 -1
- package/plugin/dashboard/app/layout.tsx +20 -0
- package/plugin/dashboard/app/preferences/[id]/page.tsx +8 -8
- package/plugin/dashboard/app/skills/project/[id]/page.tsx +7 -3
- package/plugin/dashboard/app/skills/shared/[id]/page.tsx +10 -3
- package/plugin/dashboard/lib/claude-settings-file.ts +20 -10
- package/plugin/dashboard/lib/reflexio-client.ts +16 -0
- package/plugin/dashboard/lib/status.ts +10 -3
- package/plugin/dashboard/lib/types.ts +18 -6
- package/plugin/hooks/codex-hooks.json +0 -1
- package/plugin/opencode/assistant-buffer.ts +108 -0
- package/plugin/opencode/dist/assistant-buffer.js +96 -0
- package/plugin/opencode/dist/internal.js +12 -0
- package/plugin/opencode/dist/payload.js +85 -0
- package/plugin/opencode/dist/server.mjs +232 -0
- package/plugin/opencode/internal.ts +18 -0
- package/plugin/opencode/package.json +3 -0
- package/plugin/opencode/payload.ts +90 -0
- package/plugin/opencode/server.mts +251 -0
- package/plugin/opencode/tsconfig.json +13 -0
- package/plugin/pyproject.toml +25 -4
- package/plugin/scripts/_lib.sh +5 -1
- package/plugin/scripts/backend-service.sh +22 -2
- package/plugin/scripts/ensure-plugin-root.sh +4 -4
- package/plugin/scripts/hook_entry.sh +1 -1
- package/plugin/scripts/opencode-claude-compat +4 -0
- package/plugin/scripts/opencode-claude-compat.cmd +3 -0
- package/plugin/scripts/opencode-claude-compat.js +225 -0
- package/plugin/scripts/smart-install.sh +17 -9
- package/plugin/src/README.md +1 -1
- package/plugin/src/claude_smart/cli.py +498 -12
- package/plugin/src/claude_smart/context_format.py +9 -9
- package/plugin/src/claude_smart/cs_cite.py +66 -19
- package/plugin/src/claude_smart/env_config.py +12 -4
- package/plugin/src/claude_smart/events/session_start.py +26 -7
- package/plugin/src/claude_smart/events/stop.py +1 -1
- package/plugin/src/claude_smart/ids.py +1 -1
- package/plugin/src/claude_smart/reflexio_adapter.py +5 -5
- package/plugin/src/claude_smart/runtime.py +7 -1
- package/plugin/uv.lock +5 -5
- package/plugin/vendor/reflexio/.env.example +54 -30
- package/plugin/vendor/reflexio/README.md +17 -11
- package/plugin/vendor/reflexio/pyproject.toml +13 -1
- package/plugin/vendor/reflexio/reflexio/README.md +4 -1
- package/plugin/vendor/reflexio/reflexio/cli/README.md +9 -7
- package/plugin/vendor/reflexio/reflexio/cli/__main__.py +10 -1
- package/plugin/vendor/reflexio/reflexio/cli/bootstrap_config.py +22 -5
- package/plugin/vendor/reflexio/reflexio/cli/commands/interactions.py +34 -4
- package/plugin/vendor/reflexio/reflexio/cli/commands/profiles.py +12 -7
- package/plugin/vendor/reflexio/reflexio/cli/commands/services.py +13 -6
- package/plugin/vendor/reflexio/reflexio/cli/commands/setup_cmd.py +212 -52
- package/plugin/vendor/reflexio/reflexio/cli/commands/shortcuts.py +15 -2
- package/plugin/vendor/reflexio/reflexio/cli/env_loader.py +292 -22
- package/plugin/vendor/reflexio/reflexio/cli/log_format.py +29 -4
- package/plugin/vendor/reflexio/reflexio/cli/run_services.py +17 -8
- package/plugin/vendor/reflexio/reflexio/cli/stop_services.py +13 -10
- package/plugin/vendor/reflexio/reflexio/cli/utils.py +44 -1
- package/plugin/vendor/reflexio/reflexio/client/client.py +154 -13
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/README.md +135 -257
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/npm/openclaw-smart/bin/openclaw-smart.js +13 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/npm/openclaw-smart/package.json +15 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/README.md +38 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/index.ts +151 -110
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/openclaw.plugin.json +20 -10
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/package.json +28 -6
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/pyproject.toml +42 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/_lib.sh +371 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/backend-log-runner.sh +33 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/backend-service.sh +271 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/cli.sh +68 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/dashboard-open.sh +15 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/ensure-plugin-root.sh +84 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/hook_entry.sh +106 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/npm-cli.js +219 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/smart-install.sh +269 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/clear-all/SKILL.md +8 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/dashboard/SKILL.md +8 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/learn/SKILL.md +10 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/reflexio/SKILL.md +15 -44
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/restart/SKILL.md +6 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/show/SKILL.md +8 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/cli.py +634 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/context_format.py +224 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/context_inject.py +79 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/after_tool_call.py +160 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/agent_end.py +187 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/before_prompt_build.py +69 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/before_tool_call.py +30 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/session_end.py +36 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/session_start.py +130 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/hook.py +131 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/ids.py +94 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/internal_call.py +75 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/oc_cite.py +196 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/optimizer_assistant.py +272 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/publish.py +96 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/query_compose.py +66 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/reflexio_adapter.py +336 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/runtime.py +47 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/stall_banner.py +61 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/state.py +323 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_e2e_session_loop.py +190 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_publish_to_local_reflexio_integration.py +112 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_recursion_guard_integration.py +86 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_search_inject_integration.py +144 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_cli.py +184 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_after_tool_call.py +142 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_agent_end.py +233 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_before_prompt_build.py +116 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_before_tool_call.py +35 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_session_end.py +47 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_session_start.py +109 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_hook_dispatch.py +117 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_ids.py +41 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_internal_call.py +50 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_oc_cite.py +88 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_publish.py +48 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_query_compose.py +48 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_reflexio_adapter.py +188 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_runtime.py +41 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_state.py +235 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/__mocks__/plugin-entry-stub.ts +6 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/test_npm_cli.test.ts +56 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/test_shim_dispatch.test.ts +171 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tsconfig.build.json +18 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/{tsconfig.json → plugin/tsconfig.json} +2 -2
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/uv.lock +3835 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/vitest.config.ts +18 -0
- package/plugin/vendor/reflexio/reflexio/lib/_agent_playbook.py +246 -10
- package/plugin/vendor/reflexio/reflexio/lib/_base.py +15 -0
- package/plugin/vendor/reflexio/reflexio/lib/_config.py +11 -4
- package/plugin/vendor/reflexio/reflexio/lib/_generation.py +17 -5
- package/plugin/vendor/reflexio/reflexio/lib/_lineage_parity_readers.py +187 -0
- package/plugin/vendor/reflexio/reflexio/lib/_profiles.py +224 -21
- package/plugin/vendor/reflexio/reflexio/lib/_reflection.py +1 -1
- package/plugin/vendor/reflexio/reflexio/lib/_search.py +52 -25
- package/plugin/vendor/reflexio/reflexio/lib/_user_playbook.py +11 -1
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/entities.py +127 -38
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/enums.py +4 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/governance.py +117 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/eval_overview_schema.py +64 -41
- package/plugin/vendor/reflexio/reflexio/models/api_schema/internal_schema.py +19 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/pending_tool_call_schema.py +12 -5
- package/plugin/vendor/reflexio/reflexio/models/api_schema/retriever_schema.py +97 -3
- package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/converters.py +5 -1
- package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/entities.py +5 -1
- package/plugin/vendor/reflexio/reflexio/models/config_schema.py +104 -7
- package/plugin/vendor/reflexio/reflexio/models/structured_output.py +148 -0
- package/plugin/vendor/reflexio/reflexio/server/OVERVIEW.md +3 -3
- package/plugin/vendor/reflexio/reflexio/server/README.md +58 -33
- package/plugin/vendor/reflexio/reflexio/server/__init__.py +29 -5
- package/plugin/vendor/reflexio/reflexio/server/__main__.py +2 -2
- package/plugin/vendor/reflexio/reflexio/server/api.py +899 -103
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/precondition_checks.py +7 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/request_context.py +4 -2
- package/plugin/vendor/reflexio/reflexio/server/auth.py +90 -0
- package/plugin/vendor/reflexio/reflexio/server/billing_meter.py +173 -0
- package/plugin/vendor/reflexio/reflexio/server/billing_signals.py +64 -0
- package/plugin/vendor/reflexio/reflexio/server/cache/reflexio_cache.py +46 -16
- package/plugin/vendor/reflexio/reflexio/server/env_utils.py +65 -0
- package/plugin/vendor/reflexio/reflexio/server/extensions.py +213 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/embedding_service.py +19 -4
- package/plugin/vendor/reflexio/reflexio/server/llm/litellm_client.py +264 -77
- package/plugin/vendor/reflexio/reflexio/server/llm/llm_utils.py +69 -7
- package/plugin/vendor/reflexio/reflexio/server/llm/model_defaults.py +4 -4
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/claude_code_provider.py +1 -1
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/embedding_service_provider.py +75 -16
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/openclaw_provider.py +280 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/rerank/cross_encoder_reranker.py +12 -1
- package/plugin/vendor/reflexio/reflexio/server/llm/token_accounting.py +48 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/tools.py +107 -17
- package/plugin/vendor/reflexio/reflexio/server/operation_limiter.py +360 -4
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.6.0.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.7.0.prompt.md +85 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.2.0.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.3.0.prompt.md +253 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.2.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.3.prompt.md +74 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.3.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.3.0.prompt.md +266 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.4.0.prompt.md +278 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.3.0.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.4.0.prompt.md +137 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.2.0.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.3.0.prompt.md +34 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.0.0.prompt.md +5 -12
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.1.0.prompt.md +5 -12
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.2.0.prompt.md +155 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/tagging/v1.0.0.prompt.md +23 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_manager.py +89 -32
- package/plugin/vendor/reflexio/reflexio/server/services/README.md +28 -11
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/README.md +22 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_constants.py +4 -2
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_utils.py +1 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/components/__init__.py +7 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{agent_success_evaluator.py → components/evaluator.py} +3 -16
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/regen_jobs.py +28 -72
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{group_evaluation_runner.py → runner.py} +12 -10
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{delayed_group_evaluator.py → scheduler.py} +10 -2
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{agent_success_evaluation_service.py → service.py} +36 -1
- package/plugin/vendor/reflexio/reflexio/server/services/base_generation_service.py +160 -0
- package/plugin/vendor/reflexio/reflexio/server/services/configurator/base_configurator.py +5 -0
- package/plugin/vendor/reflexio/reflexio/server/services/deduplication_utils.py +1 -1
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/README.md +9 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/components/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{rule_attribution.py → components/rule_attribution.py} +10 -9
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/eval_sampler.py +15 -24
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/service.py +238 -164
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/README.md +31 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/outcome.py +13 -3
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/pending_tool_call_dispatch.py +3 -2
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/resumable_agent.py +32 -118
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_worker.py +47 -16
- package/plugin/vendor/reflexio/reflexio/server/services/generation_service.py +105 -23
- package/plugin/vendor/reflexio/reflexio/server/services/governance/config.py +52 -0
- package/plugin/vendor/reflexio/reflexio/server/services/governance/service.py +378 -0
- package/plugin/vendor/reflexio/reflexio/server/services/governance/subject_refs.py +34 -0
- package/plugin/vendor/reflexio/reflexio/server/services/lineage/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/lineage/gc_scheduler.py +219 -0
- package/plugin/vendor/reflexio/reflexio/server/services/lineage/resolve.py +98 -0
- package/plugin/vendor/reflexio/reflexio/server/services/operation_state_utils.py +26 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/README.md +18 -11
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/aggregation_prompt_processing.py +100 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/components/__init__.py +5 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_aggregator.py → components/aggregator.py} +334 -178
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_consolidator.py → components/consolidator.py} +168 -62
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_extractor.py → components/extractor.py} +5 -1
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_edit_apply.py +74 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_utils.py +33 -3
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_generation_service.py → service.py} +121 -19
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/README.md +10 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/models.py +2 -1
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/optimizer.py +178 -30
- package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/README.md +9 -0
- package/plugin/vendor/reflexio/reflexio/server/services/profile/components/__init__.py +17 -0
- package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_deduplicator.py → components/consolidator.py} +7 -6
- package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_extractor.py → components/extractor.py} +31 -22
- package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service_utils.py +6 -13
- package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_generation_service.py → service.py} +32 -50
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/__init__.py +4 -8
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/components/__init__.py +7 -0
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service_utils.py +12 -1
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/{reflection_service.py → service.py} +36 -16
- package/plugin/vendor/reflexio/reflexio/server/services/retrieval/recency.py +211 -0
- package/plugin/vendor/reflexio/reflexio/server/services/retrieval/relevance_floor.py +99 -6
- package/plugin/vendor/reflexio/reflexio/server/services/service_utils.py +36 -1
- package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/README.md +8 -0
- package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/outcome.py +1 -2
- package/plugin/vendor/reflexio/reflexio/server/services/storage/error.py +31 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/governance_validation.py +681 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/retention.py +9 -9
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/__init__.py +16 -2
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_agent_run.py +4 -1
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_base.py +644 -197
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_extras.py +106 -119
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_governance.py +1965 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_lineage.py +630 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_operations.py +38 -6
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_playbook.py +31 -1369
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_profiles.py +756 -210
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_requests.py +148 -34
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_shadow_verdicts.py +23 -9
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_stall_state.py +5 -2
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/__init__.py +13 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_agent.py +952 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_eval_results.py +189 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_optimization.py +247 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_source_linkage.py +145 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_user.py +838 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/__init__.py +150 -23
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_agent_run.py +2 -8
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_base.py +5 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_extras.py +40 -57
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_governance.py +148 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_lineage.py +215 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_operations.py +20 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_playbook.py +4 -677
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_profiles.py +134 -1
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_requests.py +62 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_retrieval_log.py +51 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_shadow_verdicts.py +17 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/__init__.py +13 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_agent.py +365 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_eval_results.py +124 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_optimization.py +85 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_source_linkage.py +47 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_user.py +333 -0
- package/plugin/vendor/reflexio/reflexio/server/services/tagging/README.md +8 -0
- package/plugin/vendor/reflexio/reflexio/server/services/tagging/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/server/services/tagging/service.py +200 -0
- package/plugin/vendor/reflexio/reflexio/server/services/tagging/tagging_scheduler.py +149 -0
- package/plugin/vendor/reflexio/reflexio/server/services/unified_search_service.py +372 -34
- package/plugin/vendor/reflexio/reflexio/server/site_var/README.md +2 -1
- package/plugin/vendor/reflexio/reflexio/server/site_var/feature_flags.py +120 -1
- package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/feature_flags.json +4 -0
- package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/search_settings.json +5 -0
- package/plugin/vendor/reflexio/reflexio/server/tracing.py +30 -0
- package/plugin/vendor/reflexio/reflexio/server/usage_metrics.py +18 -0
- package/plugin/vendor/reflexio/reflexio/test_support/llm_mock.py +61 -26
- package/plugin/vendor/reflexio/reflexio/test_support/llm_model_registry.py +41 -4
- package/scripts/setup-claude-smart.sh +8 -3
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/TESTING.md +0 -517
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/hook/handler.js +0 -473
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package-lock.json +0 -2156
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package.json +0 -18
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/handler.ts +0 -241
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/setup.ts +0 -140
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/publish.ts +0 -113
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/search.ts +0 -52
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/server.ts +0 -103
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/sqlite-buffer.ts +0 -156
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/user-id.ts +0 -134
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/rules/reflexio.md +0 -24
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/publish_clawhub.sh +0 -278
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/references/HOOK.md +0 -164
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/install.sh +0 -36
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/uninstall.sh +0 -35
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/publish.test.ts +0 -27
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/search.test.ts +0 -31
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/server.test.ts +0 -42
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/setup.test.ts +0 -49
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/sqlite-buffer.test.ts +0 -91
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/user-id.test.ts +0 -50
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/vitest.config.ts +0 -13
- package/plugin/vendor/reflexio/reflexio/server/_auth.py +0 -25
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/group_aggregation.py +0 -192
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/invariants.py +0 -303
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/plan.py +0 -138
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/tools.py +0 -1125
- /package/plugin/vendor/reflexio/reflexio/integrations/{__init__.py → openclaw/plugin/src/openclaw_smart/__init__.py} +0 -0
- /package/plugin/vendor/reflexio/reflexio/integrations/openclaw/{types → plugin/types}/openclaw.d.ts +0 -0
- /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{distribution.py → components/distribution.py} +0 -0
- /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{hero_state.py → components/hero_state.py} +0 -0
- /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{shadow_aggregation.py → components/shadow_aggregation.py} +0 -0
- /package/plugin/vendor/reflexio/reflexio/server/services/reflection/{reflection_extractor.py → components/extractor.py} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"""Request CRUD methods for SQLite storage."""
|
|
2
2
|
|
|
3
|
-
import json
|
|
4
3
|
import sqlite3
|
|
5
4
|
from typing import Any
|
|
6
5
|
|
|
7
6
|
from reflexio.models.api_schema.internal_schema import (
|
|
8
7
|
RequestInteractionDataModel,
|
|
9
8
|
SessionDescriptor,
|
|
9
|
+
SessionFirstRequest,
|
|
10
10
|
)
|
|
11
11
|
from reflexio.models.api_schema.service_schemas import (
|
|
12
12
|
Request,
|
|
@@ -15,6 +15,7 @@ from reflexio.models.api_schema.service_schemas import (
|
|
|
15
15
|
from ._base import (
|
|
16
16
|
SQLiteStorageBase,
|
|
17
17
|
_epoch_to_iso,
|
|
18
|
+
_iso_to_epoch,
|
|
18
19
|
_row_to_interaction,
|
|
19
20
|
_row_to_request,
|
|
20
21
|
)
|
|
@@ -29,6 +30,8 @@ class RequestMixin:
|
|
|
29
30
|
_execute: Any
|
|
30
31
|
_fetchone: Any
|
|
31
32
|
_fetchall: Any
|
|
33
|
+
_subject_ref_for_user_id: Any
|
|
34
|
+
_assert_subject_writable_locked: Any
|
|
32
35
|
|
|
33
36
|
# ------------------------------------------------------------------
|
|
34
37
|
# Request methods
|
|
@@ -37,20 +40,31 @@ class RequestMixin:
|
|
|
37
40
|
@SQLiteStorageBase.handle_exceptions
|
|
38
41
|
def add_request(self, request: Request) -> None:
|
|
39
42
|
created_at_iso = _epoch_to_iso(request.created_at)
|
|
40
|
-
self.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
subject_ref = self._subject_ref_for_user_id(request.user_id)
|
|
44
|
+
with self._lock:
|
|
45
|
+
try:
|
|
46
|
+
self.conn.execute("BEGIN IMMEDIATE")
|
|
47
|
+
self._assert_subject_writable_locked(subject_ref)
|
|
48
|
+
self.conn.execute(
|
|
49
|
+
"""INSERT OR REPLACE INTO requests
|
|
50
|
+
(request_id, user_id, created_at, source, agent_version, session_id,
|
|
51
|
+
evaluation_only, governance_subject_ref)
|
|
52
|
+
VALUES (?,?,?,?,?,?,?,?)""",
|
|
53
|
+
(
|
|
54
|
+
request.request_id,
|
|
55
|
+
request.user_id,
|
|
56
|
+
created_at_iso,
|
|
57
|
+
request.source,
|
|
58
|
+
request.agent_version,
|
|
59
|
+
request.session_id,
|
|
60
|
+
1 if request.evaluation_only else 0,
|
|
61
|
+
subject_ref,
|
|
62
|
+
),
|
|
63
|
+
)
|
|
64
|
+
self.conn.commit()
|
|
65
|
+
except Exception:
|
|
66
|
+
self.conn.rollback()
|
|
67
|
+
raise
|
|
54
68
|
|
|
55
69
|
@SQLiteStorageBase.handle_exceptions
|
|
56
70
|
def get_request(self, request_id: str) -> Request | None:
|
|
@@ -154,35 +168,62 @@ class RequestMixin:
|
|
|
154
168
|
end_time: int | None = None,
|
|
155
169
|
top_k: int | None = 30,
|
|
156
170
|
offset: int = 0,
|
|
171
|
+
source: str | None = None,
|
|
157
172
|
) -> dict[str, list[RequestInteractionDataModel]]:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
173
|
+
# Request-level filters shared by both the session-page query and the
|
|
174
|
+
# request-fetch query. Pagination is applied at the SESSION level
|
|
175
|
+
# (top_k/offset count sessions, not request rows) so a session with many
|
|
176
|
+
# requests is never truncated to a subset of its rows.
|
|
177
|
+
filter_sql = ""
|
|
178
|
+
filter_params: list[Any] = []
|
|
161
179
|
if user_id:
|
|
162
|
-
|
|
163
|
-
|
|
180
|
+
filter_sql += " AND user_id = ?"
|
|
181
|
+
filter_params.append(user_id)
|
|
164
182
|
if request_id:
|
|
165
|
-
|
|
166
|
-
|
|
183
|
+
filter_sql += " AND request_id = ?"
|
|
184
|
+
filter_params.append(request_id)
|
|
167
185
|
if session_id:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
filter_sql += " AND session_id = ?"
|
|
187
|
+
filter_params.append(session_id)
|
|
188
|
+
if source is not None:
|
|
189
|
+
filter_sql += " AND source = ?"
|
|
190
|
+
filter_params.append(source)
|
|
191
|
+
if start_time is not None:
|
|
192
|
+
filter_sql += " AND created_at >= ?"
|
|
193
|
+
filter_params.append(_epoch_to_iso(start_time))
|
|
194
|
+
if end_time is not None:
|
|
195
|
+
filter_sql += " AND created_at <= ?"
|
|
196
|
+
filter_params.append(_epoch_to_iso(end_time))
|
|
176
197
|
|
|
198
|
+
# Step 1: select the page of session_ids, ordered by each session's most
|
|
199
|
+
# recent matching request (latest-first), with session_id as a stable
|
|
200
|
+
# tiebreak so pages don't overlap or skip.
|
|
177
201
|
effective_limit = top_k or 100
|
|
178
|
-
|
|
179
|
-
|
|
202
|
+
page_rows = self._fetchall(
|
|
203
|
+
f"SELECT session_id, MAX(created_at) AS latest FROM requests "
|
|
204
|
+
f"WHERE 1=1{filter_sql} "
|
|
205
|
+
f"GROUP BY session_id ORDER BY latest DESC, session_id DESC "
|
|
206
|
+
f"LIMIT ? OFFSET ?",
|
|
207
|
+
[*filter_params, effective_limit, offset],
|
|
208
|
+
)
|
|
209
|
+
if not page_rows:
|
|
210
|
+
return {}
|
|
211
|
+
page_session_ids = [r["session_id"] for r in page_rows]
|
|
180
212
|
|
|
181
|
-
|
|
213
|
+
# Step 2: fetch ALL matching requests for the sessions in this page.
|
|
214
|
+
placeholders = ",".join("?" for _ in page_session_ids)
|
|
215
|
+
req_rows = self._fetchall(
|
|
216
|
+
f"SELECT * FROM requests WHERE 1=1{filter_sql} "
|
|
217
|
+
f"AND session_id IN ({placeholders}) ORDER BY created_at DESC",
|
|
218
|
+
[*filter_params, *page_session_ids],
|
|
219
|
+
)
|
|
182
220
|
if not req_rows:
|
|
183
221
|
return {}
|
|
184
222
|
|
|
185
|
-
|
|
223
|
+
# Preserve the latest-first session ordering from step 1.
|
|
224
|
+
grouped: dict[str, list[RequestInteractionDataModel]] = {
|
|
225
|
+
(sid or ""): [] for sid in page_session_ids
|
|
226
|
+
}
|
|
186
227
|
for rr in req_rows:
|
|
187
228
|
req = _row_to_request(rr)
|
|
188
229
|
group_name = req.session_id or ""
|
|
@@ -261,3 +302,76 @@ class RequestMixin:
|
|
|
261
302
|
)
|
|
262
303
|
for r in rows
|
|
263
304
|
]
|
|
305
|
+
|
|
306
|
+
@SQLiteStorageBase.handle_exceptions
|
|
307
|
+
def get_first_requests_by_session_ids(
|
|
308
|
+
self, session_ids: list[str]
|
|
309
|
+
) -> dict[str, SessionFirstRequest]:
|
|
310
|
+
if not session_ids:
|
|
311
|
+
return {}
|
|
312
|
+
out: dict[str, SessionFirstRequest] = {}
|
|
313
|
+
ids = sorted(set(session_ids))
|
|
314
|
+
chunk_size = 500
|
|
315
|
+
for i in range(0, len(ids), chunk_size):
|
|
316
|
+
chunk = ids[i : i + chunk_size]
|
|
317
|
+
ph = ",".join("?" for _ in chunk)
|
|
318
|
+
rows = self._fetchall(
|
|
319
|
+
f"""SELECT session_id, user_id, source, created_at
|
|
320
|
+
FROM (
|
|
321
|
+
SELECT session_id, user_id, source, created_at,
|
|
322
|
+
ROW_NUMBER() OVER (
|
|
323
|
+
PARTITION BY session_id
|
|
324
|
+
ORDER BY created_at ASC, request_id ASC
|
|
325
|
+
) AS rn
|
|
326
|
+
FROM requests
|
|
327
|
+
WHERE session_id IN ({ph})
|
|
328
|
+
)
|
|
329
|
+
WHERE rn = 1""", # noqa: S608
|
|
330
|
+
chunk,
|
|
331
|
+
)
|
|
332
|
+
for row in rows:
|
|
333
|
+
session_id = row["session_id"]
|
|
334
|
+
out[session_id] = SessionFirstRequest(
|
|
335
|
+
session_id=session_id,
|
|
336
|
+
user_id=row["user_id"],
|
|
337
|
+
source=row["source"] or "",
|
|
338
|
+
created_at=_iso_to_epoch(row["created_at"]),
|
|
339
|
+
)
|
|
340
|
+
return out
|
|
341
|
+
|
|
342
|
+
@SQLiteStorageBase.handle_exceptions
|
|
343
|
+
def get_first_requests_by_user_session_pairs(
|
|
344
|
+
self, pairs: list[tuple[str, str]]
|
|
345
|
+
) -> dict[tuple[str, str], SessionFirstRequest]:
|
|
346
|
+
if not pairs:
|
|
347
|
+
return {}
|
|
348
|
+
out: dict[tuple[str, str], SessionFirstRequest] = {}
|
|
349
|
+
pair_list = sorted(set(pairs))
|
|
350
|
+
chunk_size = 300
|
|
351
|
+
for i in range(0, len(pair_list), chunk_size):
|
|
352
|
+
chunk = pair_list[i : i + chunk_size]
|
|
353
|
+
values = ",".join("(?, ?)" for _ in chunk)
|
|
354
|
+
params = [value for pair in chunk for value in pair]
|
|
355
|
+
rows = self._fetchall(
|
|
356
|
+
f"""SELECT session_id, user_id, source, created_at
|
|
357
|
+
FROM (
|
|
358
|
+
SELECT session_id, user_id, source, created_at,
|
|
359
|
+
ROW_NUMBER() OVER (
|
|
360
|
+
PARTITION BY user_id, session_id
|
|
361
|
+
ORDER BY created_at ASC, request_id ASC
|
|
362
|
+
) AS rn
|
|
363
|
+
FROM requests
|
|
364
|
+
WHERE (user_id, session_id) IN ({values})
|
|
365
|
+
)
|
|
366
|
+
WHERE rn = 1""", # noqa: S608
|
|
367
|
+
params,
|
|
368
|
+
)
|
|
369
|
+
for row in rows:
|
|
370
|
+
key = (row["user_id"], row["session_id"])
|
|
371
|
+
out[key] = SessionFirstRequest(
|
|
372
|
+
session_id=row["session_id"],
|
|
373
|
+
user_id=row["user_id"],
|
|
374
|
+
source=row["source"] or "",
|
|
375
|
+
created_at=_iso_to_epoch(row["created_at"]),
|
|
376
|
+
)
|
|
377
|
+
return out
|
package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_shadow_verdicts.py
CHANGED
|
@@ -13,13 +13,6 @@ from reflexio.models.api_schema.eval_overview_schema import (
|
|
|
13
13
|
|
|
14
14
|
from ._base import SQLiteStorageBase, _epoch_to_iso
|
|
15
15
|
|
|
16
|
-
# Maximum epoch seconds that ``datetime.fromtimestamp`` can represent (year
|
|
17
|
-
# 9999-12-31). Callers passing sentinel "open" upper bounds like
|
|
18
|
-
# ``sys.maxsize`` or ``10**12`` would otherwise overflow ``_epoch_to_iso``;
|
|
19
|
-
# clamping to this value yields the same query semantics (≥ everything) with
|
|
20
|
-
# a valid ISO string.
|
|
21
|
-
_MAX_SAFE_EPOCH_TS = 253_402_300_799 # 9999-12-31T23:59:59Z
|
|
22
|
-
|
|
23
16
|
|
|
24
17
|
def _parse_dt(value: str) -> datetime:
|
|
25
18
|
"""
|
|
@@ -164,8 +157,8 @@ class ShadowVerdictsMixin:
|
|
|
164
157
|
list[ShadowComparisonVerdict]: Verdicts in chronological order
|
|
165
158
|
(ascending ``created_at``).
|
|
166
159
|
"""
|
|
167
|
-
from_iso = _epoch_to_iso(
|
|
168
|
-
to_iso = _epoch_to_iso(
|
|
160
|
+
from_iso = _epoch_to_iso(from_ts)
|
|
161
|
+
to_iso = _epoch_to_iso(to_ts)
|
|
169
162
|
rows = self._fetchall(
|
|
170
163
|
"""SELECT * FROM shadow_comparison_verdicts
|
|
171
164
|
WHERE created_at >= ? AND created_at <= ?
|
|
@@ -175,6 +168,27 @@ class ShadowVerdictsMixin:
|
|
|
175
168
|
)
|
|
176
169
|
return [_row_to_verdict(r) for r in rows]
|
|
177
170
|
|
|
171
|
+
@SQLiteStorageBase.handle_exceptions
|
|
172
|
+
def get_recent_shadow_comparison_verdicts(
|
|
173
|
+
self,
|
|
174
|
+
from_ts: int,
|
|
175
|
+
to_ts: int,
|
|
176
|
+
judge_prompt_version: str,
|
|
177
|
+
limit: int,
|
|
178
|
+
) -> list[ShadowComparisonVerdict]:
|
|
179
|
+
from_iso = _epoch_to_iso(from_ts)
|
|
180
|
+
to_iso = _epoch_to_iso(to_ts)
|
|
181
|
+
safe_limit = max(0, limit)
|
|
182
|
+
rows = self._fetchall(
|
|
183
|
+
"""SELECT * FROM shadow_comparison_verdicts
|
|
184
|
+
WHERE created_at >= ? AND created_at <= ?
|
|
185
|
+
AND judge_prompt_version = ?
|
|
186
|
+
ORDER BY created_at DESC
|
|
187
|
+
LIMIT ?""",
|
|
188
|
+
(from_iso, to_iso, judge_prompt_version, safe_limit),
|
|
189
|
+
)
|
|
190
|
+
return [_row_to_verdict(r) for r in rows]
|
|
191
|
+
|
|
178
192
|
@SQLiteStorageBase.handle_exceptions
|
|
179
193
|
def delete_shadow_comparison_verdicts_by_session(self, session_id: str) -> int:
|
|
180
194
|
"""
|
package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_stall_state.py
CHANGED
|
@@ -11,7 +11,7 @@ from __future__ import annotations
|
|
|
11
11
|
import logging
|
|
12
12
|
import sqlite3
|
|
13
13
|
from dataclasses import dataclass
|
|
14
|
-
from datetime import datetime
|
|
14
|
+
from datetime import UTC, datetime
|
|
15
15
|
from typing import Any
|
|
16
16
|
|
|
17
17
|
from reflexio.models.api_schema.stall_state_schema import StallReason
|
|
@@ -163,10 +163,13 @@ def _parse_ts(raw: str | None) -> datetime | None:
|
|
|
163
163
|
if raw is None:
|
|
164
164
|
return None
|
|
165
165
|
try:
|
|
166
|
-
|
|
166
|
+
parsed = datetime.fromisoformat(raw)
|
|
167
167
|
except ValueError:
|
|
168
168
|
_LOGGER.warning("Malformed timestamp in stall_state: %r", raw)
|
|
169
169
|
return None
|
|
170
|
+
if parsed.tzinfo is None:
|
|
171
|
+
parsed = parsed.replace(tzinfo=UTC)
|
|
172
|
+
return parsed
|
|
170
173
|
|
|
171
174
|
|
|
172
175
|
class SQLiteStallStateMixin:
|
package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from ._agent import AgentPlaybookStoreMixin
|
|
2
|
+
from ._eval_results import AgentEvaluationResultStoreMixin
|
|
3
|
+
from ._optimization import OptimizationJobStoreMixin
|
|
4
|
+
from ._source_linkage import PlaybookSourceLinkageMixin
|
|
5
|
+
from ._user import UserPlaybookStoreMixin
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"AgentEvaluationResultStoreMixin",
|
|
9
|
+
"AgentPlaybookStoreMixin",
|
|
10
|
+
"OptimizationJobStoreMixin",
|
|
11
|
+
"PlaybookSourceLinkageMixin",
|
|
12
|
+
"UserPlaybookStoreMixin",
|
|
13
|
+
]
|