claude-smart 0.2.42 → 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.
- package/.claude-plugin/marketplace.json +3 -3
- package/README.md +1 -1
- package/package.json +9 -3
- package/plugin/.claude-plugin/plugin.json +9 -3
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/README.md +2 -2
- package/plugin/pyproject.toml +2 -2
- package/plugin/scripts/_lib.sh +91 -0
- package/plugin/scripts/backend-service.sh +1 -0
- package/plugin/scripts/cli.sh +1 -0
- package/plugin/scripts/codex-hook.js +72 -4
- package/plugin/scripts/dashboard-build.sh +1 -0
- package/plugin/scripts/dashboard-service.sh +1 -0
- package/plugin/scripts/hook_entry.sh +1 -0
- package/plugin/scripts/smart-install.sh +1 -0
- package/plugin/src/claude_smart/context_format.py +11 -12
- package/plugin/src/claude_smart/cs_cite.py +26 -12
- package/plugin/src/claude_smart/ids.py +13 -5
- package/plugin/uv.lock +1 -1
- package/plugin/vendor/reflexio/.env.example +53 -0
- package/plugin/vendor/reflexio/LICENSE +201 -0
- package/plugin/vendor/reflexio/README.md +338 -0
- package/plugin/vendor/reflexio/pyproject.toml +271 -0
- package/plugin/vendor/reflexio/reflexio/README.md +184 -0
- package/plugin/vendor/reflexio/reflexio/__init__.py +166 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/README.md +109 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/backends.py +175 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/bench.py +642 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/embed_cache.py +330 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/report.py +317 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/results/report.md +43 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/results/results.json +4478 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/scenarios.py +134 -0
- package/plugin/vendor/reflexio/reflexio/benchmarks/retrieval_latency/seed.py +255 -0
- package/plugin/vendor/reflexio/reflexio/cli/README.md +287 -0
- package/plugin/vendor/reflexio/reflexio/cli/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/cli/__main__.py +56 -0
- package/plugin/vendor/reflexio/reflexio/cli/_client.py +86 -0
- package/plugin/vendor/reflexio/reflexio/cli/app.py +127 -0
- package/plugin/vendor/reflexio/reflexio/cli/bootstrap_config.py +266 -0
- package/plugin/vendor/reflexio/reflexio/cli/codex_auth.py +503 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/admin_cmd.py +65 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/agent_playbooks.py +503 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/api.py +114 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/auth.py +109 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/config_cmd.py +511 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/doctor.py +127 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/embeddings.py +53 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/interactions.py +478 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/profiles.py +303 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/services.py +289 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/setup_cmd.py +961 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/shortcuts.py +285 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/status_cmd.py +143 -0
- package/plugin/vendor/reflexio/reflexio/cli/commands/user_playbooks.py +373 -0
- package/plugin/vendor/reflexio/reflexio/cli/env_loader.py +284 -0
- package/plugin/vendor/reflexio/reflexio/cli/errors.py +217 -0
- package/plugin/vendor/reflexio/reflexio/cli/log_format.py +247 -0
- package/plugin/vendor/reflexio/reflexio/cli/output.py +867 -0
- package/plugin/vendor/reflexio/reflexio/cli/paths.py +41 -0
- package/plugin/vendor/reflexio/reflexio/cli/run_services.py +391 -0
- package/plugin/vendor/reflexio/reflexio/cli/state.py +204 -0
- package/plugin/vendor/reflexio/reflexio/cli/stop_services.py +96 -0
- package/plugin/vendor/reflexio/reflexio/cli/utils.py +329 -0
- package/plugin/vendor/reflexio/reflexio/client/__init__.py +3 -0
- package/plugin/vendor/reflexio/reflexio/client/cache.py +150 -0
- package/plugin/vendor/reflexio/reflexio/client/client.py +2613 -0
- package/plugin/vendor/reflexio/reflexio/defaults.py +23 -0
- package/plugin/vendor/reflexio/reflexio/integrations/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/.clawhubignore +7 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/README.md +274 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/TESTING.md +517 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/hook/handler.js +473 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package-lock.json +2156 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package.json +18 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/handler.ts +241 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/setup.ts +140 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/index.ts +130 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/publish.ts +113 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/search.ts +52 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/server.ts +103 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/sqlite-buffer.ts +156 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/user-id.ts +134 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/openclaw.plugin.json +41 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/package.json +17 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/rules/reflexio.md +24 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/reflexio/SKILL.md +48 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/publish_clawhub.sh +278 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/references/HOOK.md +164 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/install.sh +36 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/uninstall.sh +35 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/publish.test.ts +27 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/search.test.ts +31 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/server.test.ts +42 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/setup.test.ts +49 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/sqlite-buffer.test.ts +91 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/user-id.test.ts +50 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tsconfig.json +16 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/types/openclaw.d.ts +230 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/vitest.config.ts +13 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/README.md +120 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/TESTING.md +168 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/package-lock.json +1657 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/package.json +16 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/HEARTBEAT.md +6 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/README.md +84 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/SKILL.md +194 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/_meta.json +6 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/agents/reflexio-extractor.md +45 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/hook/handler.ts +214 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/hook/setup.ts +55 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/index.ts +327 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/consolidate.ts +233 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/dedup.ts +80 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/io.ts +155 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/openclaw-cli.ts +67 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/search.ts +33 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/write-playbook.ts +76 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/lib/write-profile.ts +79 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/openclaw.plugin.json +46 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/package.json +18 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/README.md +36 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/full_consolidation.md +56 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/playbook_extraction.md +217 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/prompts/profile_extraction.md +132 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/skills/reflexio-consolidate/SKILL.md +33 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/plugin/skills/reflexio-embedded/SKILL.md +194 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/HOOK.md +18 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/architecture.md +49 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/comparison.md +31 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/future-work.md +47 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/references/porting-notes.md +52 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/scripts/install.sh +52 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/scripts/uninstall.sh +36 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/consolidate.test.ts +135 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/dedup.test.ts +104 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/io.test.ts +175 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/search.test.ts +66 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/smoke-test.ts +140 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/write-playbook.test.ts +93 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tests/write-profile.test.ts +174 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/tsconfig.json +16 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/types/openclaw.d.ts +230 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw-embedded/vitest.config.ts +7 -0
- package/plugin/vendor/reflexio/reflexio/lib/__init__.py +23 -0
- package/plugin/vendor/reflexio/reflexio/lib/_agent_playbook.py +310 -0
- package/plugin/vendor/reflexio/reflexio/lib/_base.py +225 -0
- package/plugin/vendor/reflexio/reflexio/lib/_config.py +83 -0
- package/plugin/vendor/reflexio/reflexio/lib/_dashboard.py +266 -0
- package/plugin/vendor/reflexio/reflexio/lib/_generation.py +176 -0
- package/plugin/vendor/reflexio/reflexio/lib/_interactions.py +334 -0
- package/plugin/vendor/reflexio/reflexio/lib/_operations.py +153 -0
- package/plugin/vendor/reflexio/reflexio/lib/_profiles.py +545 -0
- package/plugin/vendor/reflexio/reflexio/lib/_reflection.py +52 -0
- package/plugin/vendor/reflexio/reflexio/lib/_search.py +167 -0
- package/plugin/vendor/reflexio/reflexio/lib/_storage_labels.py +103 -0
- package/plugin/vendor/reflexio/reflexio/lib/_user_playbook.py +288 -0
- package/plugin/vendor/reflexio/reflexio/lib/reflexio_lib.py +27 -0
- package/plugin/vendor/reflexio/reflexio/models/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/braintrust_schema.py +141 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/common.py +41 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/__init__.py +3 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/entities.py +1103 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/enums.py +63 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/eval_overview_schema.py +487 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/internal_schema.py +28 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/pending_tool_call_schema.py +83 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/retriever_schema.py +766 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/service_schemas.py +9 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/stall_state_schema.py +32 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/__init__.py +3 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/converters.py +177 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/entities.py +129 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/enums.py +25 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/validators.py +280 -0
- package/plugin/vendor/reflexio/reflexio/models/config_schema.py +908 -0
- package/plugin/vendor/reflexio/reflexio/models/py.typed +0 -0
- package/plugin/vendor/reflexio/reflexio/server/OVERVIEW.md +90 -0
- package/plugin/vendor/reflexio/reflexio/server/README.md +616 -0
- package/plugin/vendor/reflexio/reflexio/server/__init__.py +210 -0
- package/plugin/vendor/reflexio/reflexio/server/__main__.py +132 -0
- package/plugin/vendor/reflexio/reflexio/server/_auth.py +25 -0
- package/plugin/vendor/reflexio/reflexio/server/api.py +2714 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/account_api.py +143 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/health_api.py +91 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/pending_tool_call_api.py +572 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/precondition_checks.py +66 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/publisher_api.py +540 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/request_context.py +50 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/stall_state_api.py +100 -0
- package/plugin/vendor/reflexio/reflexio/server/cache/__init__.py +15 -0
- package/plugin/vendor/reflexio/reflexio/server/cache/reflexio_cache.py +208 -0
- package/plugin/vendor/reflexio/reflexio/server/correlation.py +46 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/__init__.py +30 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/embedding_service.py +110 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/image_utils.py +55 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/litellm_client.py +1595 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/llm_utils.py +112 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/model_defaults.py +469 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/claude_code_provider.py +1122 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/claude_code_stream_parser.py +197 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/embedding_service_provider.py +210 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/local_embedding_provider.py +213 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/nomic_embedding_provider.py +255 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/rerank/__init__.py +6 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/rerank/cross_encoder_reranker.py +177 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/rerank/llm_reranker.py +148 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/tools.py +699 -0
- package/plugin/vendor/reflexio/reflexio/server/operation_limiter.py +179 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/_dispatchers.py +54 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/README.md +121 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/agent_success_evaluation/v1.0.0.prompt.md +58 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/agent_success_evaluation_with_comparison/v1.0.0.prompt.md +76 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/answer_synthesis/v1.5.2.prompt.md +88 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/compress_session_for_query/v1.3.0.prompt.md +31 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/document_expansion/v1.0.0.prompt.md +20 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.0.0.prompt.md +53 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.1.0.prompt.md +57 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.2.0.prompt.md +68 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.3.0.prompt.md +70 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.4.0.prompt.md +77 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.5.0.prompt.md +82 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.6.0.prompt.md +83 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.1.0.prompt.md +193 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.2.0.prompt.md +206 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v1.0.0-deprecated.prompt.md +66 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v1.0.0.prompt.md +43 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v1.1.0.prompt.md +46 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.0.0-deprecated.prompt.md +64 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.0.0.prompt.md +39 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.1.0.prompt.md +39 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.2.0.prompt.md +47 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.0.prompt.md +58 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.0.2.prompt.md +254 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.1.0.prompt.md +274 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.0.prompt.md +279 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v1.0.0.prompt.md +73 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v2.0.0.prompt.md +86 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.0.0.prompt.md +97 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.1.0.prompt.md +119 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.2.0.prompt.md +123 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.3.0.prompt.md +127 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.0.0.prompt.md +14 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.1.0.prompt.md +24 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.2.0.prompt.md +29 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.0.0.prompt.md +11 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.1.0.prompt.md +21 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main_expert/v1.2.0.prompt.md +25 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.0.0.prompt.md +37 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.1.0.prompt.md +40 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_optimizer_judge/v1.2.0.prompt.md +36 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v1.0.0.prompt.md +45 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v2.0.0.prompt.md +81 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate/v3.0.0.prompt.md +80 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_should_generate_expert/v1.0.0.prompt.md +34 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_deduplication/v1.0.0.prompt.md +116 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_should_generate/v1.0.0.prompt.md +33 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_should_generate_override/v1.0.0.prompt.md +16 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.0.0.prompt.md +140 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.1.0.prompt.md +160 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_main/v1.0.0.prompt.md +14 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/query_reformulation/v1.0.0.prompt.md +19 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/rerank_relevance/v1.1.0.prompt.md +44 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/shadow_comparison/v1.0.0.prompt.md +43 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/shadow_content_evaluation/v1.0.0.prompt.md +33 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_evaluation/prompt_evaluation_dataset/feedback_extraction_main_v1.jsonl +10 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_evaluation/prompt_evaluation_dataset/profile_update_main_v1.jsonl +10 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_manager.py +280 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_schema.py +11 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/_eval_health.py +131 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_constants.py +60 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_service.py +228 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_utils.py +87 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluator.py +372 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/delayed_group_evaluator.py +156 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/group_evaluation_runner.py +340 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/regen_jobs.py +471 -0
- package/plugin/vendor/reflexio/reflexio/server/services/base_generation_service.py +1626 -0
- package/plugin/vendor/reflexio/reflexio/server/services/braintrust/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/braintrust/_cron.py +196 -0
- package/plugin/vendor/reflexio/reflexio/server/services/braintrust/_encryption.py +101 -0
- package/plugin/vendor/reflexio/reflexio/server/services/braintrust/client.py +167 -0
- package/plugin/vendor/reflexio/reflexio/server/services/braintrust/service.py +281 -0
- package/plugin/vendor/reflexio/reflexio/server/services/configurator/base_configurator.py +179 -0
- package/plugin/vendor/reflexio/reflexio/server/services/configurator/config_storage.py +62 -0
- package/plugin/vendor/reflexio/reflexio/server/services/configurator/configurator.py +87 -0
- package/plugin/vendor/reflexio/reflexio/server/services/configurator/local_file_config_storage.py +187 -0
- package/plugin/vendor/reflexio/reflexio/server/services/configurator/test_config_storage.py +162 -0
- package/plugin/vendor/reflexio/reflexio/server/services/deduplication_utils.py +112 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/distribution.py +33 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/eval_sampler.py +126 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/group_aggregation.py +192 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/hero_state.py +75 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/rule_attribution.py +97 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/service.py +515 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/shadow_aggregation.py +90 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/agent_run_records.py +91 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/invariants.py +303 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/outcome.py +25 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/pending_tool_call_dispatch.py +351 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/plan.py +138 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/prior_answer_search.py +217 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/resumable_agent.py +468 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_scheduler.py +171 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_worker.py +777 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/tools.py +1125 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extractor_config_utils.py +91 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extractor_interaction_utils.py +251 -0
- package/plugin/vendor/reflexio/reflexio/server/services/generation_service.py +689 -0
- package/plugin/vendor/reflexio/reflexio/server/services/operation_state_utils.py +835 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/README.md +89 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_aggregator.py +1388 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_consolidator.py +960 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_extractor.py +436 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_generation_service.py +808 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_constants.py +28 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_utils.py +362 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/__init__.py +24 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/assistant_webhook.py +246 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/gepa_adapter.py +291 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/judge.py +97 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/models.py +96 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/optimizer.py +645 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/rollout.py +35 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/scenario_resolver.py +93 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/scheduler.py +174 -0
- package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/__init__.py +26 -0
- package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/_document_expander.py +179 -0
- package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/_query_reformulator.py +297 -0
- package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_deduplicator.py +741 -0
- package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_extractor.py +462 -0
- package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service.py +734 -0
- package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service_utils.py +290 -0
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/__init__.py +17 -0
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_extractor.py +247 -0
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service.py +800 -0
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service_utils.py +146 -0
- package/plugin/vendor/reflexio/reflexio/server/services/retrieval/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/retrieval/relevance_floor.py +70 -0
- package/plugin/vendor/reflexio/reflexio/server/services/search/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/service_utils.py +671 -0
- package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/judge.py +184 -0
- package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/outcome.py +81 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/constants.py +2 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/error.py +11 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/retention.py +154 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/retention_mixin.py +155 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/__init__.py +59 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_agent_run.py +1253 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_base.py +1945 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_extras.py +600 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_operations.py +346 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_playbook.py +1378 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_profiles.py +747 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_requests.py +263 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_shadow_verdicts.py +193 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_share_links.py +166 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_stall_state.py +217 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/__init__.py +153 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_agent_run.py +372 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_base.py +71 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_extras.py +235 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_operations.py +170 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_playbook.py +677 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_profiles.py +250 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_requests.py +154 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_shadow_verdicts.py +130 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_share_links.py +93 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_stall_state.py +76 -0
- package/plugin/vendor/reflexio/reflexio/server/services/unified_search_service.py +568 -0
- package/plugin/vendor/reflexio/reflexio/server/site_var/README.md +77 -0
- package/plugin/vendor/reflexio/reflexio/server/site_var/feature_flags.py +116 -0
- package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_manager.py +263 -0
- package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/feature_flags.json +13 -0
- package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/llm_model_setting.json +7 -0
- package/plugin/vendor/reflexio/reflexio/server/tracing.py +158 -0
- package/plugin/vendor/reflexio/reflexio/server/usage_metrics.py +113 -0
- package/plugin/vendor/reflexio/reflexio/server/uvicorn_logging.py +76 -0
- package/plugin/vendor/reflexio/reflexio/test_support/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/test_support/llm_fixtures.py +62 -0
- package/plugin/vendor/reflexio/reflexio/test_support/llm_mock.py +242 -0
- package/plugin/vendor/reflexio/reflexio/test_support/llm_model_registry.py +129 -0
- package/plugin/vendor/reflexio/reflexio/test_support/skip_decorators.py +43 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"""Request CRUD methods for SQLite storage."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import sqlite3
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from reflexio.models.api_schema.internal_schema import (
|
|
8
|
+
RequestInteractionDataModel,
|
|
9
|
+
SessionDescriptor,
|
|
10
|
+
)
|
|
11
|
+
from reflexio.models.api_schema.service_schemas import (
|
|
12
|
+
Request,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from ._base import (
|
|
16
|
+
SQLiteStorageBase,
|
|
17
|
+
_epoch_to_iso,
|
|
18
|
+
_row_to_interaction,
|
|
19
|
+
_row_to_request,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class RequestMixin:
|
|
24
|
+
"""Mixin providing request CRUD operations."""
|
|
25
|
+
|
|
26
|
+
# Type hints for instance attributes/methods provided by SQLiteStorageBase via MRO
|
|
27
|
+
_lock: Any
|
|
28
|
+
conn: sqlite3.Connection
|
|
29
|
+
_execute: Any
|
|
30
|
+
_fetchone: Any
|
|
31
|
+
_fetchall: Any
|
|
32
|
+
|
|
33
|
+
# ------------------------------------------------------------------
|
|
34
|
+
# Request methods
|
|
35
|
+
# ------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
@SQLiteStorageBase.handle_exceptions
|
|
38
|
+
def add_request(self, request: Request) -> None:
|
|
39
|
+
created_at_iso = _epoch_to_iso(request.created_at)
|
|
40
|
+
self._execute(
|
|
41
|
+
"""INSERT OR REPLACE INTO requests
|
|
42
|
+
(request_id, user_id, created_at, source, agent_version, session_id, metadata)
|
|
43
|
+
VALUES (?,?,?,?,?,?,?)""",
|
|
44
|
+
(
|
|
45
|
+
request.request_id,
|
|
46
|
+
request.user_id,
|
|
47
|
+
created_at_iso,
|
|
48
|
+
request.source,
|
|
49
|
+
request.agent_version,
|
|
50
|
+
request.session_id,
|
|
51
|
+
json.dumps(request.metadata, sort_keys=True),
|
|
52
|
+
),
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
@SQLiteStorageBase.handle_exceptions
|
|
56
|
+
def get_request(self, request_id: str) -> Request | None:
|
|
57
|
+
row = self._fetchone(
|
|
58
|
+
"SELECT * FROM requests WHERE request_id = ?", (request_id,)
|
|
59
|
+
)
|
|
60
|
+
return _row_to_request(row) if row else None
|
|
61
|
+
|
|
62
|
+
@SQLiteStorageBase.handle_exceptions
|
|
63
|
+
def delete_request(self, request_id: str) -> None:
|
|
64
|
+
# Delete FTS entries for interactions of this request
|
|
65
|
+
ids = [
|
|
66
|
+
r["interaction_id"]
|
|
67
|
+
for r in self._fetchall(
|
|
68
|
+
"SELECT interaction_id FROM interactions WHERE request_id = ?",
|
|
69
|
+
(request_id,),
|
|
70
|
+
)
|
|
71
|
+
]
|
|
72
|
+
if ids:
|
|
73
|
+
placeholders = ",".join("?" for _ in ids)
|
|
74
|
+
with self._lock:
|
|
75
|
+
self.conn.execute(
|
|
76
|
+
f"DELETE FROM interactions_fts WHERE rowid IN ({placeholders})", ids
|
|
77
|
+
)
|
|
78
|
+
self.conn.commit()
|
|
79
|
+
self._execute("DELETE FROM interactions WHERE request_id = ?", (request_id,))
|
|
80
|
+
self._execute("DELETE FROM requests WHERE request_id = ?", (request_id,))
|
|
81
|
+
|
|
82
|
+
@SQLiteStorageBase.handle_exceptions
|
|
83
|
+
def delete_session(self, session_id: str) -> int:
|
|
84
|
+
rows = self._fetchall(
|
|
85
|
+
"SELECT request_id FROM requests WHERE session_id = ?", (session_id,)
|
|
86
|
+
)
|
|
87
|
+
if not rows:
|
|
88
|
+
return 0
|
|
89
|
+
request_ids = [r["request_id"] for r in rows]
|
|
90
|
+
for rid in request_ids:
|
|
91
|
+
# Delete FTS for interactions
|
|
92
|
+
iids = [
|
|
93
|
+
r["interaction_id"]
|
|
94
|
+
for r in self._fetchall(
|
|
95
|
+
"SELECT interaction_id FROM interactions WHERE request_id = ?",
|
|
96
|
+
(rid,),
|
|
97
|
+
)
|
|
98
|
+
]
|
|
99
|
+
if iids:
|
|
100
|
+
ph = ",".join("?" for _ in iids)
|
|
101
|
+
with self._lock:
|
|
102
|
+
self.conn.execute(
|
|
103
|
+
f"DELETE FROM interactions_fts WHERE rowid IN ({ph})", iids
|
|
104
|
+
)
|
|
105
|
+
self.conn.commit()
|
|
106
|
+
self._execute("DELETE FROM interactions WHERE request_id = ?", (rid,))
|
|
107
|
+
self._execute("DELETE FROM requests WHERE session_id = ?", (session_id,))
|
|
108
|
+
return len(request_ids)
|
|
109
|
+
|
|
110
|
+
@SQLiteStorageBase.handle_exceptions
|
|
111
|
+
def delete_all_requests(self) -> None:
|
|
112
|
+
with self._lock:
|
|
113
|
+
self.conn.execute("DELETE FROM interactions_fts")
|
|
114
|
+
self.conn.execute("DELETE FROM interactions")
|
|
115
|
+
self.conn.execute("DELETE FROM requests")
|
|
116
|
+
self.conn.commit()
|
|
117
|
+
|
|
118
|
+
@SQLiteStorageBase.handle_exceptions
|
|
119
|
+
def delete_requests_by_ids(self, request_ids: list[str]) -> int:
|
|
120
|
+
if not request_ids:
|
|
121
|
+
return 0
|
|
122
|
+
# Delete FTS entries for interactions of these requests
|
|
123
|
+
ph = ",".join("?" for _ in request_ids)
|
|
124
|
+
interaction_ids = [
|
|
125
|
+
r["interaction_id"]
|
|
126
|
+
for r in self._fetchall(
|
|
127
|
+
f"SELECT interaction_id FROM interactions WHERE request_id IN ({ph})",
|
|
128
|
+
request_ids,
|
|
129
|
+
)
|
|
130
|
+
]
|
|
131
|
+
if interaction_ids:
|
|
132
|
+
iph = ",".join("?" for _ in interaction_ids)
|
|
133
|
+
with self._lock:
|
|
134
|
+
self.conn.execute(
|
|
135
|
+
f"DELETE FROM interactions_fts WHERE rowid IN ({iph})",
|
|
136
|
+
interaction_ids,
|
|
137
|
+
)
|
|
138
|
+
self.conn.commit()
|
|
139
|
+
self._execute(
|
|
140
|
+
f"DELETE FROM interactions WHERE request_id IN ({ph})", request_ids
|
|
141
|
+
)
|
|
142
|
+
cur = self._execute(
|
|
143
|
+
f"DELETE FROM requests WHERE request_id IN ({ph})", request_ids
|
|
144
|
+
)
|
|
145
|
+
return cur.rowcount
|
|
146
|
+
|
|
147
|
+
@SQLiteStorageBase.handle_exceptions
|
|
148
|
+
def get_sessions(
|
|
149
|
+
self,
|
|
150
|
+
user_id: str | None = None,
|
|
151
|
+
request_id: str | None = None,
|
|
152
|
+
session_id: str | None = None,
|
|
153
|
+
start_time: int | None = None,
|
|
154
|
+
end_time: int | None = None,
|
|
155
|
+
top_k: int | None = 30,
|
|
156
|
+
offset: int = 0,
|
|
157
|
+
) -> dict[str, list[RequestInteractionDataModel]]:
|
|
158
|
+
sql = "SELECT * FROM requests WHERE 1=1"
|
|
159
|
+
params: list[Any] = []
|
|
160
|
+
|
|
161
|
+
if user_id:
|
|
162
|
+
sql += " AND user_id = ?"
|
|
163
|
+
params.append(user_id)
|
|
164
|
+
if request_id:
|
|
165
|
+
sql += " AND request_id = ?"
|
|
166
|
+
params.append(request_id)
|
|
167
|
+
if session_id:
|
|
168
|
+
sql += " AND session_id = ?"
|
|
169
|
+
params.append(session_id)
|
|
170
|
+
if start_time:
|
|
171
|
+
sql += " AND created_at >= ?"
|
|
172
|
+
params.append(_epoch_to_iso(start_time))
|
|
173
|
+
if end_time:
|
|
174
|
+
sql += " AND created_at <= ?"
|
|
175
|
+
params.append(_epoch_to_iso(end_time))
|
|
176
|
+
|
|
177
|
+
effective_limit = top_k or 100
|
|
178
|
+
sql += " ORDER BY created_at DESC LIMIT ? OFFSET ?"
|
|
179
|
+
params.extend([effective_limit, offset])
|
|
180
|
+
|
|
181
|
+
req_rows = self._fetchall(sql, params)
|
|
182
|
+
if not req_rows:
|
|
183
|
+
return {}
|
|
184
|
+
|
|
185
|
+
grouped: dict[str, list[RequestInteractionDataModel]] = {}
|
|
186
|
+
for rr in req_rows:
|
|
187
|
+
req = _row_to_request(rr)
|
|
188
|
+
group_name = req.session_id or ""
|
|
189
|
+
int_rows = self._fetchall(
|
|
190
|
+
"SELECT * FROM interactions WHERE request_id = ? ORDER BY created_at ASC",
|
|
191
|
+
(req.request_id,),
|
|
192
|
+
)
|
|
193
|
+
interactions = [_row_to_interaction(ir) for ir in int_rows]
|
|
194
|
+
grouped.setdefault(group_name, []).append(
|
|
195
|
+
RequestInteractionDataModel(
|
|
196
|
+
session_id=group_name,
|
|
197
|
+
request=req,
|
|
198
|
+
interactions=interactions,
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
return grouped
|
|
202
|
+
|
|
203
|
+
@SQLiteStorageBase.handle_exceptions
|
|
204
|
+
def get_rerun_user_ids(
|
|
205
|
+
self,
|
|
206
|
+
user_id: str | None = None,
|
|
207
|
+
start_time: int | None = None,
|
|
208
|
+
end_time: int | None = None,
|
|
209
|
+
source: str | None = None,
|
|
210
|
+
agent_version: str | None = None,
|
|
211
|
+
) -> list[str]:
|
|
212
|
+
sql = "SELECT DISTINCT user_id FROM requests WHERE 1=1"
|
|
213
|
+
params: list[Any] = []
|
|
214
|
+
if user_id:
|
|
215
|
+
sql += " AND user_id = ?"
|
|
216
|
+
params.append(user_id)
|
|
217
|
+
if start_time:
|
|
218
|
+
sql += " AND created_at >= ?"
|
|
219
|
+
params.append(_epoch_to_iso(start_time))
|
|
220
|
+
if end_time:
|
|
221
|
+
sql += " AND created_at <= ?"
|
|
222
|
+
params.append(_epoch_to_iso(end_time))
|
|
223
|
+
if source:
|
|
224
|
+
sql += " AND source = ?"
|
|
225
|
+
params.append(source)
|
|
226
|
+
if agent_version:
|
|
227
|
+
sql += " AND agent_version = ?"
|
|
228
|
+
params.append(agent_version)
|
|
229
|
+
|
|
230
|
+
rows = self._fetchall(sql, params)
|
|
231
|
+
return sorted(r["user_id"] for r in rows)
|
|
232
|
+
|
|
233
|
+
@SQLiteStorageBase.handle_exceptions
|
|
234
|
+
def get_requests_by_session(self, user_id: str, session_id: str) -> list[Request]:
|
|
235
|
+
rows = self._fetchall(
|
|
236
|
+
"SELECT * FROM requests WHERE user_id = ? AND session_id = ?",
|
|
237
|
+
(user_id, session_id),
|
|
238
|
+
)
|
|
239
|
+
return [_row_to_request(r) for r in rows]
|
|
240
|
+
|
|
241
|
+
@SQLiteStorageBase.handle_exceptions
|
|
242
|
+
def get_session_ids_in_window(
|
|
243
|
+
self, from_ts: int, to_ts: int
|
|
244
|
+
) -> list[SessionDescriptor]:
|
|
245
|
+
from_iso = _epoch_to_iso(from_ts)
|
|
246
|
+
to_iso = _epoch_to_iso(to_ts)
|
|
247
|
+
rows = self._fetchall(
|
|
248
|
+
"""SELECT DISTINCT user_id, session_id, agent_version, source
|
|
249
|
+
FROM requests
|
|
250
|
+
WHERE session_id IS NOT NULL
|
|
251
|
+
AND created_at BETWEEN ? AND ?
|
|
252
|
+
ORDER BY session_id, user_id, agent_version""",
|
|
253
|
+
(from_iso, to_iso),
|
|
254
|
+
)
|
|
255
|
+
return [
|
|
256
|
+
SessionDescriptor(
|
|
257
|
+
user_id=r["user_id"],
|
|
258
|
+
session_id=r["session_id"],
|
|
259
|
+
agent_version=r["agent_version"],
|
|
260
|
+
source=r["source"],
|
|
261
|
+
)
|
|
262
|
+
for r in rows
|
|
263
|
+
]
|
package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_shadow_verdicts.py
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"""SQLite CRUD for ``shadow_comparison_verdicts`` (F1)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sqlite3
|
|
6
|
+
from datetime import UTC, datetime
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from reflexio.models.api_schema.eval_overview_schema import (
|
|
10
|
+
ShadowComparisonOutput,
|
|
11
|
+
ShadowComparisonVerdict,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from ._base import SQLiteStorageBase, _epoch_to_iso
|
|
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
|
+
|
|
24
|
+
def _parse_dt(value: str) -> datetime:
|
|
25
|
+
"""
|
|
26
|
+
Parse a stored ISO timestamp into a tz-aware ``datetime``.
|
|
27
|
+
|
|
28
|
+
Rows inserted with a model-provided ``created_at`` carry an explicit
|
|
29
|
+
offset (``...+00:00``). Rows that fell back to the ``CURRENT_TIMESTAMP``
|
|
30
|
+
default are tz-naive (SQLite stores ``YYYY-MM-DD HH:MM:SS``); tag those
|
|
31
|
+
as UTC to keep the dashboard math correct.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
value (str): Stored timestamp text.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
datetime: A tz-aware ``datetime`` in UTC.
|
|
38
|
+
"""
|
|
39
|
+
if value.endswith("Z") or "+" in value or "-" in value[10:]:
|
|
40
|
+
return datetime.fromisoformat(value)
|
|
41
|
+
# CURRENT_TIMESTAMP default — "YYYY-MM-DD HH:MM:SS" with a space, not "T".
|
|
42
|
+
iso = value.replace(" ", "T")
|
|
43
|
+
return datetime.fromisoformat(iso).replace(tzinfo=UTC)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _row_to_verdict(row: sqlite3.Row) -> ShadowComparisonVerdict:
|
|
47
|
+
"""
|
|
48
|
+
Hydrate a ``ShadowComparisonVerdict`` from a SQLite row.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
row (sqlite3.Row): Row from ``shadow_comparison_verdicts``.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
ShadowComparisonVerdict: Reconstructed verdict including the nested
|
|
55
|
+
:class:`ShadowComparisonOutput`.
|
|
56
|
+
"""
|
|
57
|
+
d = dict(row)
|
|
58
|
+
return ShadowComparisonVerdict(
|
|
59
|
+
verdict_id=d["verdict_id"],
|
|
60
|
+
interaction_id=d["interaction_id"],
|
|
61
|
+
session_id=d["session_id"],
|
|
62
|
+
agent_version=d["agent_version"],
|
|
63
|
+
reflexio_is_request_1=bool(d["reflexio_is_request_1"]),
|
|
64
|
+
output=ShadowComparisonOutput(
|
|
65
|
+
better_request=d["better_request"],
|
|
66
|
+
is_significantly_better=bool(d["is_significantly_better"]),
|
|
67
|
+
comparison_reason=d.get("comparison_reason"),
|
|
68
|
+
),
|
|
69
|
+
judge_prompt_version=d["judge_prompt_version"],
|
|
70
|
+
created_at=_parse_dt(d["created_at"]),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class ShadowVerdictsMixin:
|
|
75
|
+
"""SQLite implementation of the shadow_comparison_verdicts contract."""
|
|
76
|
+
|
|
77
|
+
# Attributes provided by SQLiteStorageBase via MRO; declared here for
|
|
78
|
+
# pyright so the @handle_exceptions decorator sees correct types.
|
|
79
|
+
conn: sqlite3.Connection
|
|
80
|
+
_execute: Any
|
|
81
|
+
_fetchone: Any
|
|
82
|
+
_fetchall: Any
|
|
83
|
+
|
|
84
|
+
@SQLiteStorageBase.handle_exceptions
|
|
85
|
+
def save_shadow_comparison_verdict(
|
|
86
|
+
self, verdict: ShadowComparisonVerdict
|
|
87
|
+
) -> ShadowComparisonVerdict:
|
|
88
|
+
"""
|
|
89
|
+
Insert a verdict and return the persisted row.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
verdict (ShadowComparisonVerdict): Verdict to persist. The
|
|
93
|
+
``verdict_id`` field is ignored; storage assigns the
|
|
94
|
+
autoincrement primary key.
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
ShadowComparisonVerdict: The verdict with ``verdict_id``
|
|
98
|
+
populated from the autoincrement.
|
|
99
|
+
"""
|
|
100
|
+
cur = self._execute(
|
|
101
|
+
"""INSERT INTO shadow_comparison_verdicts
|
|
102
|
+
(interaction_id, session_id, agent_version,
|
|
103
|
+
reflexio_is_request_1, better_request,
|
|
104
|
+
is_significantly_better, comparison_reason,
|
|
105
|
+
judge_prompt_version, created_at)
|
|
106
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
|
107
|
+
(
|
|
108
|
+
verdict.interaction_id,
|
|
109
|
+
verdict.session_id,
|
|
110
|
+
verdict.agent_version,
|
|
111
|
+
1 if verdict.reflexio_is_request_1 else 0,
|
|
112
|
+
verdict.output.better_request,
|
|
113
|
+
1 if verdict.output.is_significantly_better else 0,
|
|
114
|
+
verdict.output.comparison_reason,
|
|
115
|
+
verdict.judge_prompt_version,
|
|
116
|
+
verdict.created_at.isoformat(),
|
|
117
|
+
),
|
|
118
|
+
)
|
|
119
|
+
verdict_id = cur.lastrowid
|
|
120
|
+
return verdict.model_copy(update={"verdict_id": verdict_id})
|
|
121
|
+
|
|
122
|
+
@SQLiteStorageBase.handle_exceptions
|
|
123
|
+
def get_shadow_comparison_verdict(
|
|
124
|
+
self, verdict_id: int
|
|
125
|
+
) -> ShadowComparisonVerdict | None:
|
|
126
|
+
"""
|
|
127
|
+
Fetch a verdict by its autoincrement primary key.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
verdict_id (int): The verdict's storage-assigned key.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
ShadowComparisonVerdict | None: The verdict if found, else
|
|
134
|
+
``None``.
|
|
135
|
+
"""
|
|
136
|
+
row = self._fetchone(
|
|
137
|
+
"SELECT * FROM shadow_comparison_verdicts WHERE verdict_id = ?",
|
|
138
|
+
(verdict_id,),
|
|
139
|
+
)
|
|
140
|
+
return _row_to_verdict(row) if row else None
|
|
141
|
+
|
|
142
|
+
@SQLiteStorageBase.handle_exceptions
|
|
143
|
+
def get_shadow_comparison_verdicts(
|
|
144
|
+
self,
|
|
145
|
+
from_ts: int,
|
|
146
|
+
to_ts: int,
|
|
147
|
+
judge_prompt_version: str,
|
|
148
|
+
) -> list[ShadowComparisonVerdict]:
|
|
149
|
+
"""
|
|
150
|
+
Fetch verdicts in ``[from_ts, to_ts]`` for one pinned prompt version.
|
|
151
|
+
|
|
152
|
+
Comparisons happen against stored ISO timestamps, which are
|
|
153
|
+
lexicographically orderable when expressed in UTC — see
|
|
154
|
+
:func:`_epoch_to_iso`.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
from_ts (int): Inclusive lower bound, Unix epoch seconds (UTC).
|
|
158
|
+
to_ts (int): Inclusive upper bound, Unix epoch seconds (UTC).
|
|
159
|
+
judge_prompt_version (str): Pinned ``shadow_comparison`` prompt
|
|
160
|
+
version. Filtering by this prevents rubric-mixing in the
|
|
161
|
+
dashboard headline.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
list[ShadowComparisonVerdict]: Verdicts in chronological order
|
|
165
|
+
(ascending ``created_at``).
|
|
166
|
+
"""
|
|
167
|
+
from_iso = _epoch_to_iso(max(0, min(from_ts, _MAX_SAFE_EPOCH_TS)))
|
|
168
|
+
to_iso = _epoch_to_iso(max(0, min(to_ts, _MAX_SAFE_EPOCH_TS)))
|
|
169
|
+
rows = self._fetchall(
|
|
170
|
+
"""SELECT * FROM shadow_comparison_verdicts
|
|
171
|
+
WHERE created_at >= ? AND created_at <= ?
|
|
172
|
+
AND judge_prompt_version = ?
|
|
173
|
+
ORDER BY created_at ASC""",
|
|
174
|
+
(from_iso, to_iso, judge_prompt_version),
|
|
175
|
+
)
|
|
176
|
+
return [_row_to_verdict(r) for r in rows]
|
|
177
|
+
|
|
178
|
+
@SQLiteStorageBase.handle_exceptions
|
|
179
|
+
def delete_shadow_comparison_verdicts_by_session(self, session_id: str) -> int:
|
|
180
|
+
"""
|
|
181
|
+
Delete all verdicts for one session.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
session_id (str): The session whose verdicts should be removed.
|
|
185
|
+
|
|
186
|
+
Returns:
|
|
187
|
+
int: Number of rows deleted.
|
|
188
|
+
"""
|
|
189
|
+
cur = self._execute(
|
|
190
|
+
"DELETE FROM shadow_comparison_verdicts WHERE session_id = ?",
|
|
191
|
+
(session_id,),
|
|
192
|
+
)
|
|
193
|
+
return cur.rowcount
|
package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_share_links.py
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""SQLite implementation of ShareLinkMixin."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from reflexio.models.api_schema.domain import ShareLink
|
|
6
|
+
|
|
7
|
+
from ._base import (
|
|
8
|
+
SQLiteStorageBase,
|
|
9
|
+
_epoch_now,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _row_to_share_link(row: Any) -> ShareLink:
|
|
14
|
+
"""Convert a sqlite3.Row to a ShareLink model.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
row: A sqlite3.Row from the share_links table.
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
ShareLink: The populated model.
|
|
21
|
+
"""
|
|
22
|
+
d = dict(row)
|
|
23
|
+
return ShareLink(
|
|
24
|
+
id=d["id"],
|
|
25
|
+
org_id=d["org_id"],
|
|
26
|
+
token=d["token"],
|
|
27
|
+
resource_type=d["resource_type"],
|
|
28
|
+
resource_id=d["resource_id"],
|
|
29
|
+
created_at=d["created_at"],
|
|
30
|
+
expires_at=d["expires_at"],
|
|
31
|
+
created_by_email=d["created_by_email"],
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class SQLiteShareLinkMixin:
|
|
36
|
+
"""SQLite-backed share link operations."""
|
|
37
|
+
|
|
38
|
+
# Type hints for instance attributes/methods provided by SQLiteStorageBase via MRO
|
|
39
|
+
org_id: str
|
|
40
|
+
_execute: Any
|
|
41
|
+
_fetchone: Any
|
|
42
|
+
_fetchall: Any
|
|
43
|
+
|
|
44
|
+
@SQLiteStorageBase.handle_exceptions
|
|
45
|
+
def create_share_link(
|
|
46
|
+
self,
|
|
47
|
+
token: str,
|
|
48
|
+
resource_type: str,
|
|
49
|
+
resource_id: str,
|
|
50
|
+
expires_at: int | None,
|
|
51
|
+
created_by_email: str | None,
|
|
52
|
+
) -> ShareLink:
|
|
53
|
+
"""Create a new share link.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
token (str): The share token (unique).
|
|
57
|
+
resource_type (str): Type of resource (e.g., "profile", "user_playbook").
|
|
58
|
+
resource_id (str): ID of the resource being shared.
|
|
59
|
+
expires_at (int | None): Optional Unix timestamp of expiration.
|
|
60
|
+
created_by_email (str | None): Optional email of creator.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
ShareLink: The created share link with id and created_at populated.
|
|
64
|
+
"""
|
|
65
|
+
now = _epoch_now()
|
|
66
|
+
cur = self._execute(
|
|
67
|
+
"""INSERT INTO share_links
|
|
68
|
+
(org_id, token, resource_type, resource_id, created_at, expires_at, created_by_email)
|
|
69
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)""",
|
|
70
|
+
(
|
|
71
|
+
self.org_id,
|
|
72
|
+
token,
|
|
73
|
+
resource_type,
|
|
74
|
+
resource_id,
|
|
75
|
+
now,
|
|
76
|
+
expires_at,
|
|
77
|
+
created_by_email,
|
|
78
|
+
),
|
|
79
|
+
)
|
|
80
|
+
return ShareLink(
|
|
81
|
+
id=cur.lastrowid,
|
|
82
|
+
org_id=self.org_id,
|
|
83
|
+
token=token,
|
|
84
|
+
resource_type=resource_type,
|
|
85
|
+
resource_id=resource_id,
|
|
86
|
+
created_at=now,
|
|
87
|
+
expires_at=expires_at,
|
|
88
|
+
created_by_email=created_by_email,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
@SQLiteStorageBase.handle_exceptions
|
|
92
|
+
def get_share_link_by_token(self, token: str) -> ShareLink | None:
|
|
93
|
+
"""Look up a share link by its token.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
token (str): The share token.
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
ShareLink | None: The share link if found, else None.
|
|
100
|
+
"""
|
|
101
|
+
row = self._fetchone(
|
|
102
|
+
"SELECT * FROM share_links WHERE org_id = ? AND token = ?",
|
|
103
|
+
(self.org_id, token),
|
|
104
|
+
)
|
|
105
|
+
return _row_to_share_link(row) if row else None
|
|
106
|
+
|
|
107
|
+
@SQLiteStorageBase.handle_exceptions
|
|
108
|
+
def get_share_link_by_resource(
|
|
109
|
+
self, resource_type: str, resource_id: str
|
|
110
|
+
) -> ShareLink | None:
|
|
111
|
+
"""Look up an existing share link for a specific resource.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
resource_type (str): Type of resource.
|
|
115
|
+
resource_id (str): ID of the resource.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
ShareLink | None: The existing share link if any, else None.
|
|
119
|
+
"""
|
|
120
|
+
row = self._fetchone(
|
|
121
|
+
"SELECT * FROM share_links WHERE org_id = ? AND resource_type = ? AND resource_id = ?",
|
|
122
|
+
(self.org_id, resource_type, resource_id),
|
|
123
|
+
)
|
|
124
|
+
return _row_to_share_link(row) if row else None
|
|
125
|
+
|
|
126
|
+
@SQLiteStorageBase.handle_exceptions
|
|
127
|
+
def get_share_links(self) -> list[ShareLink]:
|
|
128
|
+
"""Return all share links for this org.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
list[ShareLink]: All share links, ordered by created_at ascending.
|
|
132
|
+
"""
|
|
133
|
+
rows = self._fetchall(
|
|
134
|
+
"SELECT * FROM share_links WHERE org_id = ? ORDER BY created_at ASC",
|
|
135
|
+
(self.org_id,),
|
|
136
|
+
)
|
|
137
|
+
return [_row_to_share_link(row) for row in rows]
|
|
138
|
+
|
|
139
|
+
@SQLiteStorageBase.handle_exceptions
|
|
140
|
+
def delete_share_link(self, link_id: int) -> bool:
|
|
141
|
+
"""Delete a share link by ID.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
link_id (int): The share link ID.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
bool: True if deleted, False if not found.
|
|
148
|
+
"""
|
|
149
|
+
cur = self._execute(
|
|
150
|
+
"DELETE FROM share_links WHERE org_id = ? AND id = ?",
|
|
151
|
+
(self.org_id, link_id),
|
|
152
|
+
)
|
|
153
|
+
return cur.rowcount > 0
|
|
154
|
+
|
|
155
|
+
@SQLiteStorageBase.handle_exceptions
|
|
156
|
+
def delete_all_share_links(self) -> int:
|
|
157
|
+
"""Delete all share links for this org.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
int: Number of links deleted.
|
|
161
|
+
"""
|
|
162
|
+
cur = self._execute(
|
|
163
|
+
"DELETE FROM share_links WHERE org_id = ?",
|
|
164
|
+
(self.org_id,),
|
|
165
|
+
)
|
|
166
|
+
return cur.rowcount
|