claude-smart 0.2.42 → 0.2.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +3 -3
- package/README.md +1 -1
- package/bin/claude-smart.js +2 -2
- 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 +23 -3
- package/plugin/pyproject.toml +3 -3
- package/plugin/scripts/_lib.sh +91 -0
- package/plugin/scripts/backend-service.sh +51 -4
- package/plugin/scripts/cli.sh +3 -1
- 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/ensure-plugin-root.sh +1 -0
- package/plugin/scripts/hook_entry.sh +6 -3
- package/plugin/scripts/smart-install.sh +3 -2
- package/plugin/src/README.md +57 -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 +126 -5
- package/plugin/vendor/reflexio/.env.example +62 -0
- package/plugin/vendor/reflexio/LICENSE +201 -0
- package/plugin/vendor/reflexio/README.md +338 -0
- package/plugin/vendor/reflexio/pyproject.toml +274 -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 +265 -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 +964 -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 +1112 -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 +768 -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 +333 -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 +622 -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 +2868 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/README.md +34 -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 +562 -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 +359 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/image_utils.py +55 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/litellm_client.py +1871 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/llm_utils.py +140 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/model_defaults.py +479 -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 +338 -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 +288 -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 +187 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/rerank/llm_reranker.py +148 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/tools.py +716 -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_consolidation/v2.3.1.prompt.md +69 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.2.prompt.md +71 -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 +283 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.2.prompt.md +234 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.3.prompt.md +244 -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 +137 -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/README.md +58 -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 +336 -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 +1668 -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/embedding_text.py +62 -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 +358 -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 +535 -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 +779 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/tools.py +1125 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extractor_config_utils.py +94 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extractor_interaction_utils.py +251 -0
- package/plugin/vendor/reflexio/reflexio/server/services/generation_service.py +702 -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 +1045 -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 +772 -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 +737 -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 +803 -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 +80 -0
- package/plugin/vendor/reflexio/reflexio/server/services/search/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/service_utils.py +756 -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 +1298 -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 +384 -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 +572 -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,1112 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import UTC, datetime
|
|
4
|
+
from typing import Any, Literal, Self
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field, field_validator, model_validator
|
|
7
|
+
|
|
8
|
+
from reflexio.defaults import DEFAULT_AGENT_VERSION
|
|
9
|
+
|
|
10
|
+
from ..common import (
|
|
11
|
+
NEVER_EXPIRES_TIMESTAMP,
|
|
12
|
+
BlockingIssue,
|
|
13
|
+
BlockingIssueKind,
|
|
14
|
+
ToolUsed,
|
|
15
|
+
)
|
|
16
|
+
from ..validators import (
|
|
17
|
+
EmbeddingVector,
|
|
18
|
+
NonEmptyStr,
|
|
19
|
+
TimeRangeValidatorMixin,
|
|
20
|
+
_validate_image_url,
|
|
21
|
+
)
|
|
22
|
+
from .enums import (
|
|
23
|
+
OperationStatus,
|
|
24
|
+
PlaybookStatus,
|
|
25
|
+
ProfileTimeToLive,
|
|
26
|
+
RegularVsShadow,
|
|
27
|
+
Status,
|
|
28
|
+
UserActionType,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"NEVER_EXPIRES_TIMESTAMP",
|
|
33
|
+
"BlockingIssue",
|
|
34
|
+
"BlockingIssueKind",
|
|
35
|
+
"ToolUsed",
|
|
36
|
+
"Citation",
|
|
37
|
+
"Interaction",
|
|
38
|
+
"Request",
|
|
39
|
+
"UserProfile",
|
|
40
|
+
"UserPlaybook",
|
|
41
|
+
"ProfileChangeLog",
|
|
42
|
+
"AgentPlaybook",
|
|
43
|
+
"AgentSuccessEvaluationResult",
|
|
44
|
+
"DeleteUserProfileRequest",
|
|
45
|
+
"DeleteUserProfileResponse",
|
|
46
|
+
"DeleteUserInteractionRequest",
|
|
47
|
+
"DeleteUserInteractionResponse",
|
|
48
|
+
"DeleteRequestRequest",
|
|
49
|
+
"DeleteRequestResponse",
|
|
50
|
+
"DeleteSessionRequest",
|
|
51
|
+
"DeleteSessionResponse",
|
|
52
|
+
"DeleteAgentPlaybookRequest",
|
|
53
|
+
"DeleteAgentPlaybookResponse",
|
|
54
|
+
"DeleteUserPlaybookRequest",
|
|
55
|
+
"DeleteUserPlaybookResponse",
|
|
56
|
+
"BulkDeleteResponse",
|
|
57
|
+
"DeleteRequestsByIdsRequest",
|
|
58
|
+
"DeleteProfilesByIdsRequest",
|
|
59
|
+
"DeleteAgentPlaybooksByIdsRequest",
|
|
60
|
+
"DeleteUserPlaybooksByIdsRequest",
|
|
61
|
+
"ClearUserDataRequest",
|
|
62
|
+
"ClearUserDataResponse",
|
|
63
|
+
"InteractionData",
|
|
64
|
+
"PublishUserInteractionRequest",
|
|
65
|
+
"PublishUserInteractionResponse",
|
|
66
|
+
"WhoamiResponse",
|
|
67
|
+
"MyConfigResponse",
|
|
68
|
+
"AddUserPlaybookRequest",
|
|
69
|
+
"AddUserPlaybookResponse",
|
|
70
|
+
"AddAgentPlaybookRequest",
|
|
71
|
+
"AddAgentPlaybookResponse",
|
|
72
|
+
"AddUserProfileRequest",
|
|
73
|
+
"AddUserProfileResponse",
|
|
74
|
+
"ProfileChangeLogResponse",
|
|
75
|
+
"PublicStructuredData",
|
|
76
|
+
"PublicUserPlaybook",
|
|
77
|
+
"PublicAgentPlaybook",
|
|
78
|
+
"user_playbook_to_public",
|
|
79
|
+
"agent_playbook_to_public",
|
|
80
|
+
"PublicGetUserPlaybooksResponse",
|
|
81
|
+
"PublicGetAgentPlaybooksResponse",
|
|
82
|
+
"PublicSearchUserPlaybookResponse",
|
|
83
|
+
"PublicSearchAgentPlaybookResponse",
|
|
84
|
+
"PublicUnifiedSearchResponse",
|
|
85
|
+
"AgentPlaybookSnapshot",
|
|
86
|
+
"AgentPlaybookUpdateEntry",
|
|
87
|
+
"PlaybookAggregationChangeLog",
|
|
88
|
+
"PlaybookAggregationChangeLogResponse",
|
|
89
|
+
"PlaybookOptimizationJob",
|
|
90
|
+
"PlaybookOptimizationCandidate",
|
|
91
|
+
"PlaybookOptimizationEvaluation",
|
|
92
|
+
"PlaybookOptimizationEvent",
|
|
93
|
+
"AgentPlaybookSourceWindow",
|
|
94
|
+
"agent_playbook_to_snapshot",
|
|
95
|
+
"RunPlaybookAggregationRequest",
|
|
96
|
+
"RunPlaybookAggregationResponse",
|
|
97
|
+
"RerunProfileGenerationRequest",
|
|
98
|
+
"RerunProfileGenerationResponse",
|
|
99
|
+
"ManualProfileGenerationRequest",
|
|
100
|
+
"ManualProfileGenerationResponse",
|
|
101
|
+
"ManualPlaybookGenerationRequest",
|
|
102
|
+
"ManualPlaybookGenerationResponse",
|
|
103
|
+
"RerunPlaybookGenerationRequest",
|
|
104
|
+
"RerunPlaybookGenerationResponse",
|
|
105
|
+
"UpgradeProfilesRequest",
|
|
106
|
+
"UpgradeProfilesResponse",
|
|
107
|
+
"DowngradeProfilesRequest",
|
|
108
|
+
"DowngradeProfilesResponse",
|
|
109
|
+
"UpgradeUserPlaybooksRequest",
|
|
110
|
+
"UpgradeUserPlaybooksResponse",
|
|
111
|
+
"DowngradeUserPlaybooksRequest",
|
|
112
|
+
"DowngradeUserPlaybooksResponse",
|
|
113
|
+
"OperationStatusInfo",
|
|
114
|
+
"GetOperationStatusRequest",
|
|
115
|
+
"GetOperationStatusResponse",
|
|
116
|
+
"CancelOperationRequest",
|
|
117
|
+
"CancelOperationResponse",
|
|
118
|
+
"ShareLink",
|
|
119
|
+
"AdminInvalidateCacheRequest",
|
|
120
|
+
"AdminInvalidateCacheResponse",
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
# ===============================
|
|
124
|
+
# Data Models
|
|
125
|
+
# ===============================
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class Citation(BaseModel):
|
|
129
|
+
"""A playbook or profile item the agent cited as influential.
|
|
130
|
+
|
|
131
|
+
Carried inline on an Assistant ``InteractionData`` row to mark
|
|
132
|
+
which previously-injected playbook rule or user-profile row
|
|
133
|
+
materially shaped that response. The server uses these to drive
|
|
134
|
+
reflection (does the cited rule still look right after seeing how
|
|
135
|
+
it was applied?).
|
|
136
|
+
|
|
137
|
+
Attributes:
|
|
138
|
+
kind (Literal["playbook", "profile"]): Which kind of cited
|
|
139
|
+
item this references.
|
|
140
|
+
real_id (str): Stable storage id — ``user_playbook_id`` for
|
|
141
|
+
playbooks, ``profile_id`` for profiles.
|
|
142
|
+
tag (str): Injection-time rank tag (e.g. ``"r1-301"``,
|
|
143
|
+
``"p1-0f37"``). Per-injection, not stable across sessions;
|
|
144
|
+
kept as a debug aid.
|
|
145
|
+
title (str): Short human-readable label for logs and UI.
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
kind: Literal["playbook", "profile"]
|
|
149
|
+
real_id: str
|
|
150
|
+
tag: str = ""
|
|
151
|
+
title: str = ""
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# information about the user interaction sent by the client
|
|
155
|
+
class Interaction(BaseModel):
|
|
156
|
+
interaction_id: int = 0 # 0 = placeholder for DB auto-increment
|
|
157
|
+
user_id: str
|
|
158
|
+
request_id: str
|
|
159
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
160
|
+
role: str = "User"
|
|
161
|
+
content: str = ""
|
|
162
|
+
user_action: UserActionType = UserActionType.NONE
|
|
163
|
+
user_action_description: str = ""
|
|
164
|
+
interacted_image_url: str = ""
|
|
165
|
+
image_encoding: str = "" # base64 encoded image
|
|
166
|
+
shadow_content: str = ""
|
|
167
|
+
expert_content: str = ""
|
|
168
|
+
tools_used: list[ToolUsed] = Field(default_factory=list)
|
|
169
|
+
citations: list[Citation] = Field(default_factory=list)
|
|
170
|
+
embedding: EmbeddingVector = []
|
|
171
|
+
|
|
172
|
+
@field_validator("interacted_image_url", mode="after")
|
|
173
|
+
@classmethod
|
|
174
|
+
def validate_image_url(cls, v: str) -> str:
|
|
175
|
+
return _validate_image_url(v)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class Request(BaseModel):
|
|
179
|
+
"""A user-issued request that begins or continues a session.
|
|
180
|
+
|
|
181
|
+
A Request is the unit of work the agent reacts to. Multiple Requests
|
|
182
|
+
share a ``session_id`` to form a multi-turn session. The optional
|
|
183
|
+
``metadata`` dict carries per-request key/value annotations stamped by
|
|
184
|
+
customer integration code — distinct from ``playbook_metadata`` (a
|
|
185
|
+
JSON-encoded string) used by ``Playbook``-family entities elsewhere in
|
|
186
|
+
this module.
|
|
187
|
+
|
|
188
|
+
Attributes:
|
|
189
|
+
request_id (str): Unique identifier for this request.
|
|
190
|
+
user_id (str): Owner of the request.
|
|
191
|
+
created_at (int): Unix epoch seconds at request creation. Defaults
|
|
192
|
+
to the current UTC time.
|
|
193
|
+
source (str): Free-form origin tag (integration name, etc.).
|
|
194
|
+
agent_version (str): The agent version that handled this request.
|
|
195
|
+
session_id (str | None): Session this request belongs to, or None
|
|
196
|
+
if the request is not part of a multi-turn session.
|
|
197
|
+
metadata (dict[str, Any]): Free-form per-request annotations.
|
|
198
|
+
Always a dict — never None. Conventional keys:
|
|
199
|
+
|
|
200
|
+
- ``reflexio_retrieval_enabled`` (bool): F2 group-by signal;
|
|
201
|
+
customer integration code stamps this to indicate whether
|
|
202
|
+
Reflexio retrieval was active for the session. Read by the
|
|
203
|
+
``/api/get_evaluation_overview`` aggregator from the FIRST
|
|
204
|
+
request of each session for sticky group assignment.
|
|
205
|
+
|
|
206
|
+
Distinct from ``playbook_metadata`` on ``Playbook``-family
|
|
207
|
+
entities (which is a JSON-encoded string, not a dict).
|
|
208
|
+
On-the-wire serialization assumes JSON-encodable values;
|
|
209
|
+
non-JSON values like ``datetime`` or ``set`` will fail at
|
|
210
|
+
the storage / API boundary.
|
|
211
|
+
"""
|
|
212
|
+
|
|
213
|
+
request_id: str
|
|
214
|
+
user_id: str
|
|
215
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
216
|
+
source: str = ""
|
|
217
|
+
agent_version: str = ""
|
|
218
|
+
session_id: str | None = None
|
|
219
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
# information about the user profile generated from the user interaction
|
|
223
|
+
# output of the profile generation service send back to the client
|
|
224
|
+
class UserProfile(BaseModel):
|
|
225
|
+
profile_id: str
|
|
226
|
+
user_id: str
|
|
227
|
+
content: str
|
|
228
|
+
last_modified_timestamp: int
|
|
229
|
+
generated_from_request_id: str
|
|
230
|
+
profile_time_to_live: ProfileTimeToLive = ProfileTimeToLive.INFINITY
|
|
231
|
+
# this is the expiration date calculated based on last modified timestamp and profile time to live instead of generated timestamp
|
|
232
|
+
expiration_timestamp: int = NEVER_EXPIRES_TIMESTAMP
|
|
233
|
+
custom_features: dict | None = None
|
|
234
|
+
source: str | None = None
|
|
235
|
+
status: Status | None = None # indicates the status of the profile
|
|
236
|
+
extractor_names: list[str] | None = (
|
|
237
|
+
None # Retained provenance data column (merged on dedup); new profiles write None.
|
|
238
|
+
)
|
|
239
|
+
expanded_terms: str | None = None
|
|
240
|
+
embedding: EmbeddingVector = []
|
|
241
|
+
source_span: str | None = None
|
|
242
|
+
notes: str | None = None
|
|
243
|
+
reader_angle: str | None = None
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
# user playbook for agents
|
|
247
|
+
class UserPlaybook(BaseModel):
|
|
248
|
+
user_playbook_id: int = 0
|
|
249
|
+
user_id: str | None = None # optional for backward compatibility
|
|
250
|
+
agent_version: str
|
|
251
|
+
request_id: str
|
|
252
|
+
playbook_name: str = ""
|
|
253
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
254
|
+
content: str = ""
|
|
255
|
+
trigger: str | None = None
|
|
256
|
+
rationale: str | None = None
|
|
257
|
+
blocking_issue: BlockingIssue | None = None
|
|
258
|
+
status: Status | None = (
|
|
259
|
+
None # Status.PENDING (from rerun), None (current), Status.ARCHIVED (old)
|
|
260
|
+
)
|
|
261
|
+
source: str | None = None # source of the interaction that generated this playbook
|
|
262
|
+
source_interaction_ids: list[int] = Field(default_factory=list)
|
|
263
|
+
expanded_terms: str | None = None
|
|
264
|
+
embedding: EmbeddingVector = []
|
|
265
|
+
source_span: str | None = None
|
|
266
|
+
notes: str | None = None
|
|
267
|
+
reader_angle: str | None = None
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class ProfileChangeLog(BaseModel):
|
|
271
|
+
id: int
|
|
272
|
+
user_id: str
|
|
273
|
+
request_id: str
|
|
274
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
275
|
+
added_profiles: list[UserProfile]
|
|
276
|
+
removed_profiles: list[UserProfile]
|
|
277
|
+
mentioned_profiles: list[UserProfile]
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
class AgentPlaybook(BaseModel):
|
|
281
|
+
agent_playbook_id: int = 0
|
|
282
|
+
playbook_name: str = ""
|
|
283
|
+
agent_version: str
|
|
284
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
285
|
+
content: str
|
|
286
|
+
trigger: str | None = None
|
|
287
|
+
rationale: str | None = None
|
|
288
|
+
blocking_issue: BlockingIssue | None = None
|
|
289
|
+
playbook_status: PlaybookStatus = PlaybookStatus.PENDING
|
|
290
|
+
playbook_metadata: str = ""
|
|
291
|
+
expanded_terms: str | None = None
|
|
292
|
+
embedding: EmbeddingVector = []
|
|
293
|
+
status: Status | None = (
|
|
294
|
+
None # used for tracking intermediate states during playbook aggregation. Status.ARCHIVED for playbooks during aggregation process, None for current playbooks
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
class PlaybookOptimizationJob(BaseModel):
|
|
299
|
+
"""One end-to-end optimizer run for a single playbook target.
|
|
300
|
+
|
|
301
|
+
Lifecycle: ``pending`` → ``running`` → ``completed`` | ``failed`` |
|
|
302
|
+
``skipped``. ``best_candidate_id`` and ``successor_target_id`` are set
|
|
303
|
+
when the run produces a winner or commits a successor playbook.
|
|
304
|
+
"""
|
|
305
|
+
|
|
306
|
+
job_id: int = 0
|
|
307
|
+
target_kind: Literal["agent_playbook", "user_playbook"]
|
|
308
|
+
target_id: int
|
|
309
|
+
status: Literal["pending", "running", "completed", "skipped", "failed"] = "pending"
|
|
310
|
+
best_candidate_id: int | None = None
|
|
311
|
+
successor_target_id: int | None = None
|
|
312
|
+
decision_reason: str = ""
|
|
313
|
+
metadata_json: str = "{}"
|
|
314
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
315
|
+
updated_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
class PlaybookOptimizationCandidate(BaseModel):
|
|
319
|
+
"""A playbook content variant proposed by GEPA during a job.
|
|
320
|
+
|
|
321
|
+
Multiple proposals with identical content collapse to one row (deduped
|
|
322
|
+
by ``content`` inside the GEPA adapter). ``aggregate_score`` and
|
|
323
|
+
``is_winner`` are populated only for the run's chosen winner.
|
|
324
|
+
"""
|
|
325
|
+
|
|
326
|
+
candidate_id: int = 0
|
|
327
|
+
job_id: int
|
|
328
|
+
candidate_index: int = 0
|
|
329
|
+
content: str
|
|
330
|
+
parent_candidate_ids: list[int] = Field(default_factory=list)
|
|
331
|
+
aggregate_score: float | None = None
|
|
332
|
+
is_winner: bool = False
|
|
333
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
class PlaybookOptimizationEvaluation(BaseModel):
|
|
337
|
+
"""Pairwise judgement of one candidate vs. the incumbent on one window.
|
|
338
|
+
|
|
339
|
+
Both rollouts are stored as JSON for offline reproducibility.
|
|
340
|
+
``verdict='aborted'`` means the assistant backend failed and the row
|
|
341
|
+
carries no useful signal — the optimizer treats any aborted evaluation
|
|
342
|
+
as fatal for the run.
|
|
343
|
+
"""
|
|
344
|
+
|
|
345
|
+
evaluation_id: int = 0
|
|
346
|
+
job_id: int
|
|
347
|
+
candidate_id: int
|
|
348
|
+
target_kind: Literal["agent_playbook", "user_playbook"]
|
|
349
|
+
target_id: int
|
|
350
|
+
scenario_user_playbook_id: int | None = None
|
|
351
|
+
source_interaction_ids: list[int] = Field(default_factory=list)
|
|
352
|
+
score: float = 0.0
|
|
353
|
+
verdict: Literal["candidate", "incumbent", "tie", "aborted"] = "tie"
|
|
354
|
+
likert: int = Field(default=0, ge=0, le=5)
|
|
355
|
+
rationale: str = ""
|
|
356
|
+
asi_json: str = "{}"
|
|
357
|
+
incumbent_rollout_json: str = "[]"
|
|
358
|
+
candidate_rollout_json: str = "[]"
|
|
359
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
class PlaybookOptimizationEvent(BaseModel):
|
|
363
|
+
"""One GEPA callback (``on_*``) event captured for offline inspection.
|
|
364
|
+
|
|
365
|
+
The optimizer's ``_GEPAStorageCallback`` forwards every dispatched
|
|
366
|
+
callback into a row of this type. ``event_type`` is the callback name
|
|
367
|
+
minus the ``on_`` prefix; ``payload_json`` is a depth-bounded
|
|
368
|
+
serialization of the callback's argument.
|
|
369
|
+
"""
|
|
370
|
+
|
|
371
|
+
event_id: int = 0
|
|
372
|
+
job_id: int
|
|
373
|
+
event_type: str
|
|
374
|
+
payload_json: str = "{}"
|
|
375
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
class AgentPlaybookSourceWindow(BaseModel):
|
|
379
|
+
"""Replayable source window snapshotted when an agent playbook is generated."""
|
|
380
|
+
|
|
381
|
+
user_playbook_id: int
|
|
382
|
+
source_interaction_ids: list[int] = Field(default_factory=list)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
class AgentSuccessEvaluationResult(BaseModel):
|
|
386
|
+
result_id: int = 0
|
|
387
|
+
agent_version: str
|
|
388
|
+
session_id: str
|
|
389
|
+
is_success: bool
|
|
390
|
+
failure_type: str | None = None
|
|
391
|
+
failure_reason: str | None = None
|
|
392
|
+
evaluation_name: str | None = None
|
|
393
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
394
|
+
regular_vs_shadow: RegularVsShadow | None = None
|
|
395
|
+
number_of_correction_per_session: int = 0
|
|
396
|
+
user_turns_to_resolution: int | None = None
|
|
397
|
+
is_escalated: bool = False
|
|
398
|
+
embedding: EmbeddingVector = []
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
class ShareLink(BaseModel):
|
|
402
|
+
"""A shareable public link that maps a token to a resource within an org.
|
|
403
|
+
|
|
404
|
+
Args:
|
|
405
|
+
id (int): Primary key assigned by the storage layer.
|
|
406
|
+
org_id (str): The organization that owns the share link.
|
|
407
|
+
token (str): The share token (unique). Format: shr_<org_id_b64>.<random>.
|
|
408
|
+
resource_type (str): One of "profile", "request", "session", "user_playbook", "agent_playbook".
|
|
409
|
+
resource_id (str): The ID of the resource being shared.
|
|
410
|
+
created_at (int | None): Unix timestamp of creation.
|
|
411
|
+
expires_at (int | None): Optional Unix timestamp of expiration. None means never expires.
|
|
412
|
+
created_by_email (str | None): Optional email of the user who created the link.
|
|
413
|
+
"""
|
|
414
|
+
|
|
415
|
+
id: int
|
|
416
|
+
org_id: str
|
|
417
|
+
token: str
|
|
418
|
+
resource_type: str
|
|
419
|
+
resource_id: str
|
|
420
|
+
created_at: int | None = None
|
|
421
|
+
expires_at: int | None = None
|
|
422
|
+
created_by_email: str | None = None
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
# ===============================
|
|
426
|
+
# Request Models
|
|
427
|
+
# ===============================
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
# delete user profile request
|
|
431
|
+
class DeleteUserProfileRequest(BaseModel):
|
|
432
|
+
user_id: NonEmptyStr
|
|
433
|
+
profile_id: str = ""
|
|
434
|
+
search_query: str = ""
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
# delete user profile response
|
|
438
|
+
class DeleteUserProfileResponse(BaseModel):
|
|
439
|
+
success: bool
|
|
440
|
+
message: str = ""
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
# delete user interaction request
|
|
444
|
+
class DeleteUserInteractionRequest(BaseModel):
|
|
445
|
+
user_id: NonEmptyStr
|
|
446
|
+
interaction_id: int = Field(gt=0)
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
# delete user interaction response
|
|
450
|
+
class DeleteUserInteractionResponse(BaseModel):
|
|
451
|
+
success: bool
|
|
452
|
+
message: str = ""
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
# delete request request
|
|
456
|
+
class DeleteRequestRequest(BaseModel):
|
|
457
|
+
request_id: NonEmptyStr
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
# delete request response
|
|
461
|
+
class DeleteRequestResponse(BaseModel):
|
|
462
|
+
success: bool
|
|
463
|
+
message: str = ""
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
# delete session request
|
|
467
|
+
class DeleteSessionRequest(BaseModel):
|
|
468
|
+
session_id: NonEmptyStr
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
# delete session response
|
|
472
|
+
class DeleteSessionResponse(BaseModel):
|
|
473
|
+
success: bool
|
|
474
|
+
message: str = ""
|
|
475
|
+
deleted_requests_count: int = 0
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
# delete agent playbook request
|
|
479
|
+
class DeleteAgentPlaybookRequest(BaseModel):
|
|
480
|
+
agent_playbook_id: int = Field(gt=0)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
# delete agent playbook response
|
|
484
|
+
class DeleteAgentPlaybookResponse(BaseModel):
|
|
485
|
+
success: bool
|
|
486
|
+
message: str = ""
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
# delete user playbook request
|
|
490
|
+
class DeleteUserPlaybookRequest(BaseModel):
|
|
491
|
+
user_playbook_id: int = Field(gt=0)
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
# delete user playbook response
|
|
495
|
+
class DeleteUserPlaybookResponse(BaseModel):
|
|
496
|
+
success: bool
|
|
497
|
+
message: str = ""
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
class BulkDeleteResponse(BaseModel):
|
|
501
|
+
success: bool
|
|
502
|
+
deleted_count: int = 0
|
|
503
|
+
message: str = ""
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
class DeleteRequestsByIdsRequest(BaseModel):
|
|
507
|
+
request_ids: list[str] = Field(min_length=1)
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
class DeleteProfilesByIdsRequest(BaseModel):
|
|
511
|
+
profile_ids: list[str] = Field(min_length=1)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
class DeleteAgentPlaybooksByIdsRequest(BaseModel):
|
|
515
|
+
agent_playbook_ids: list[int] = Field(min_length=1)
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
class DeleteUserPlaybooksByIdsRequest(BaseModel):
|
|
519
|
+
user_playbook_ids: list[int] = Field(min_length=1)
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
# Clear all data scoped to a single user_id (interactions, requests, user
|
|
523
|
+
# playbooks, profiles). Used by paired-protocol harnesses (e.g. SWE-bench) to
|
|
524
|
+
# isolate per-task data on a shared storage backend without nuking sibling
|
|
525
|
+
# tasks' rows. Intentionally does NOT touch agent_playbooks — they are the
|
|
526
|
+
# cross-project rollup of skills and have no user_id column.
|
|
527
|
+
class ClearUserDataRequest(BaseModel):
|
|
528
|
+
user_id: NonEmptyStr
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
class ClearUserDataResponse(BaseModel):
|
|
532
|
+
success: bool
|
|
533
|
+
deleted_counts: dict[str, int] = Field(default_factory=dict)
|
|
534
|
+
message: str | None = None
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
# user provided interaction data from the request
|
|
538
|
+
class InteractionData(BaseModel):
|
|
539
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
540
|
+
role: str = "User"
|
|
541
|
+
content: str = ""
|
|
542
|
+
shadow_content: str = ""
|
|
543
|
+
expert_content: str = ""
|
|
544
|
+
user_action: UserActionType = UserActionType.NONE
|
|
545
|
+
user_action_description: str = ""
|
|
546
|
+
interacted_image_url: str = ""
|
|
547
|
+
image_encoding: str = "" # base64 encoded image
|
|
548
|
+
tools_used: list[ToolUsed] = Field(default_factory=list)
|
|
549
|
+
citations: list[Citation] = Field(default_factory=list)
|
|
550
|
+
|
|
551
|
+
@field_validator("interacted_image_url", mode="after")
|
|
552
|
+
@classmethod
|
|
553
|
+
def validate_image_url(cls, v: str) -> str:
|
|
554
|
+
return _validate_image_url(v)
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
# publish user interaction request
|
|
558
|
+
class PublishUserInteractionRequest(BaseModel):
|
|
559
|
+
request_id: NonEmptyStr | None = None
|
|
560
|
+
user_id: NonEmptyStr
|
|
561
|
+
interaction_data_list: list[InteractionData] = Field(min_length=1)
|
|
562
|
+
source: str = ""
|
|
563
|
+
agent_version: str = (
|
|
564
|
+
"" # this is used for aggregating interactions for generating agent playbooks
|
|
565
|
+
)
|
|
566
|
+
session_id: str | None = None # used for grouping requests together
|
|
567
|
+
skip_aggregation: bool = (
|
|
568
|
+
False # when True, extract profiles/playbooks but skip aggregation
|
|
569
|
+
)
|
|
570
|
+
force_extraction: bool = False # when True, bypass all extraction gates (stride_size, cheap pre-filter, LLM should_run) and always run extractors
|
|
571
|
+
override_learning_stall: bool = False # when True, run extraction even if a provider auth/billing stall is recorded
|
|
572
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
573
|
+
"""Per-request annotations stamped by customer integration code.
|
|
574
|
+
|
|
575
|
+
Mirrors ``Request.metadata`` — the publish path copies this dict
|
|
576
|
+
onto the ``Request`` row it creates so the eval pipeline (and the
|
|
577
|
+
F2 sticky-group aggregator in particular) can read it back from
|
|
578
|
+
the first request of each session.
|
|
579
|
+
|
|
580
|
+
Conventional keys:
|
|
581
|
+
- ``reflexio_retrieval_enabled`` (bool): F2 group assignment signal.
|
|
582
|
+
|
|
583
|
+
Defaults to ``{}`` (never None) for backward compatibility — existing
|
|
584
|
+
callers that don't pass ``metadata`` keep working unchanged.
|
|
585
|
+
"""
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
# publish user interaction response
|
|
589
|
+
class PublishUserInteractionResponse(BaseModel):
|
|
590
|
+
success: bool
|
|
591
|
+
message: str = ""
|
|
592
|
+
warnings: list[str] = Field(default_factory=list)
|
|
593
|
+
# Diagnostics (populated only when wait_for_response=True; None otherwise).
|
|
594
|
+
# Exposed so the CLI can tell users *where* their publish landed.
|
|
595
|
+
request_id: str | None = None
|
|
596
|
+
endpoint_url: str | None = None
|
|
597
|
+
storage_type: str | None = None
|
|
598
|
+
storage_label: str | None = None
|
|
599
|
+
profiles_added: int | None = None
|
|
600
|
+
profiles_updated: int | None = None
|
|
601
|
+
playbooks_added: int | None = None
|
|
602
|
+
playbooks_updated: int | None = None
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
# whoami response — caller identity + resolved storage routing (masked)
|
|
606
|
+
class WhoamiResponse(BaseModel):
|
|
607
|
+
success: bool
|
|
608
|
+
org_id: str
|
|
609
|
+
storage_type: str | None = None
|
|
610
|
+
storage_label: str | None = None # always masked — never contains raw keys
|
|
611
|
+
storage_configured: bool = False
|
|
612
|
+
message: str = ""
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
# my_config response — caller's raw storage credentials (token-gated)
|
|
616
|
+
class MyConfigResponse(BaseModel):
|
|
617
|
+
success: bool
|
|
618
|
+
# serialized StorageConfig — may contain secrets
|
|
619
|
+
storage_config: dict[str, Any] | None = None
|
|
620
|
+
storage_type: str | None = None
|
|
621
|
+
message: str = ""
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
# add user playbook request/response
|
|
625
|
+
class AddUserPlaybookRequest(BaseModel):
|
|
626
|
+
user_playbooks: list[UserPlaybook] = Field(min_length=1)
|
|
627
|
+
|
|
628
|
+
@model_validator(mode="after")
|
|
629
|
+
def check_content_fields(self) -> Self:
|
|
630
|
+
"""Ensure each user playbook has content for embedding."""
|
|
631
|
+
for i, rf in enumerate(self.user_playbooks):
|
|
632
|
+
if not any((rf.trigger, rf.content)):
|
|
633
|
+
raise ValueError(
|
|
634
|
+
f"user_playbooks[{i}]: at least one of content "
|
|
635
|
+
"or trigger must be provided"
|
|
636
|
+
)
|
|
637
|
+
return self
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
class AddUserPlaybookResponse(BaseModel):
|
|
641
|
+
success: bool
|
|
642
|
+
message: str | None = None
|
|
643
|
+
added_count: int = 0
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
# add agent playbook request/response (for aggregated playbooks)
|
|
647
|
+
class AddAgentPlaybookRequest(BaseModel):
|
|
648
|
+
agent_playbooks: list[AgentPlaybook] = Field(min_length=1)
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
class AddAgentPlaybookResponse(BaseModel):
|
|
652
|
+
success: bool
|
|
653
|
+
message: str | None = None
|
|
654
|
+
added_count: int = 0
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
# add user profile request/response (manual profile injection,
|
|
658
|
+
# bypassing the inference pipeline)
|
|
659
|
+
class AddUserProfileRequest(BaseModel):
|
|
660
|
+
user_profiles: list[UserProfile] = Field(min_length=1)
|
|
661
|
+
|
|
662
|
+
@model_validator(mode="after")
|
|
663
|
+
def check_content(self) -> Self:
|
|
664
|
+
"""Ensure each profile has non-empty content for embedding."""
|
|
665
|
+
for i, p in enumerate(self.user_profiles):
|
|
666
|
+
if not p.content:
|
|
667
|
+
raise ValueError(
|
|
668
|
+
f"user_profiles[{i}].content is required for embedding"
|
|
669
|
+
)
|
|
670
|
+
return self
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
class AddUserProfileResponse(BaseModel):
|
|
674
|
+
success: bool
|
|
675
|
+
message: str | None = None
|
|
676
|
+
added_count: int = 0
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
class ProfileChangeLogResponse(BaseModel):
|
|
680
|
+
success: bool
|
|
681
|
+
profile_change_logs: list[ProfileChangeLog]
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
class PublicStructuredData(BaseModel):
|
|
685
|
+
"""Deprecated: kept for backward compatibility with deprecated Public* models."""
|
|
686
|
+
|
|
687
|
+
trigger: str | None = None
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
class PublicUserPlaybook(BaseModel):
|
|
691
|
+
"""Deprecated: use UserPlaybookView from api_schema.ui instead."""
|
|
692
|
+
|
|
693
|
+
user_playbook_id: int = 0
|
|
694
|
+
user_id: str | None = None
|
|
695
|
+
agent_version: str
|
|
696
|
+
request_id: str
|
|
697
|
+
playbook_name: str = ""
|
|
698
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
699
|
+
content: str = ""
|
|
700
|
+
trigger: str | None = None
|
|
701
|
+
rationale: str | None = None
|
|
702
|
+
status: Status | None = None
|
|
703
|
+
source: str | None = None
|
|
704
|
+
source_interaction_ids: list[int] = Field(default_factory=list)
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
class PublicAgentPlaybook(BaseModel):
|
|
708
|
+
"""Deprecated: use AgentPlaybookView from api_schema.ui instead."""
|
|
709
|
+
|
|
710
|
+
agent_playbook_id: int = 0
|
|
711
|
+
playbook_name: str = ""
|
|
712
|
+
agent_version: str
|
|
713
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
714
|
+
content: str
|
|
715
|
+
trigger: str | None = None
|
|
716
|
+
rationale: str | None = None
|
|
717
|
+
playbook_status: PlaybookStatus = PlaybookStatus.PENDING
|
|
718
|
+
playbook_metadata: str = ""
|
|
719
|
+
status: Status | None = None
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
def user_playbook_to_public(rf: UserPlaybook) -> PublicUserPlaybook:
|
|
723
|
+
"""Deprecated: use to_user_playbook_view from api_schema.ui instead."""
|
|
724
|
+
return PublicUserPlaybook(
|
|
725
|
+
user_playbook_id=rf.user_playbook_id,
|
|
726
|
+
user_id=rf.user_id,
|
|
727
|
+
agent_version=rf.agent_version,
|
|
728
|
+
request_id=rf.request_id,
|
|
729
|
+
playbook_name=rf.playbook_name,
|
|
730
|
+
created_at=rf.created_at,
|
|
731
|
+
content=rf.content,
|
|
732
|
+
trigger=rf.trigger,
|
|
733
|
+
rationale=rf.rationale,
|
|
734
|
+
status=rf.status,
|
|
735
|
+
source=rf.source,
|
|
736
|
+
source_interaction_ids=rf.source_interaction_ids,
|
|
737
|
+
)
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
def agent_playbook_to_public(fb: AgentPlaybook) -> PublicAgentPlaybook:
|
|
741
|
+
"""Deprecated: use to_agent_playbook_view from api_schema.ui instead."""
|
|
742
|
+
return PublicAgentPlaybook(
|
|
743
|
+
agent_playbook_id=fb.agent_playbook_id,
|
|
744
|
+
playbook_name=fb.playbook_name,
|
|
745
|
+
agent_version=fb.agent_version,
|
|
746
|
+
created_at=fb.created_at,
|
|
747
|
+
content=fb.content,
|
|
748
|
+
trigger=fb.trigger,
|
|
749
|
+
rationale=fb.rationale,
|
|
750
|
+
playbook_status=fb.playbook_status,
|
|
751
|
+
playbook_metadata=fb.playbook_metadata,
|
|
752
|
+
status=fb.status,
|
|
753
|
+
)
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
class PublicGetUserPlaybooksResponse(BaseModel):
|
|
757
|
+
"""Deprecated: use GetUserPlaybooksViewResponse from api_schema.retriever_schema instead.
|
|
758
|
+
|
|
759
|
+
API response for get_user_playbooks — uses public types.
|
|
760
|
+
"""
|
|
761
|
+
|
|
762
|
+
success: bool
|
|
763
|
+
user_playbooks: list[PublicUserPlaybook]
|
|
764
|
+
msg: str | None = None
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
class PublicGetAgentPlaybooksResponse(BaseModel):
|
|
768
|
+
"""Deprecated: use GetAgentPlaybooksViewResponse from api_schema.retriever_schema instead.
|
|
769
|
+
|
|
770
|
+
API response for get_agent_playbooks — uses public types.
|
|
771
|
+
"""
|
|
772
|
+
|
|
773
|
+
success: bool
|
|
774
|
+
agent_playbooks: list[PublicAgentPlaybook]
|
|
775
|
+
msg: str | None = None
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
class PublicSearchUserPlaybookResponse(BaseModel):
|
|
779
|
+
"""Deprecated: use SearchUserPlaybooksViewResponse from api_schema.retriever_schema instead.
|
|
780
|
+
|
|
781
|
+
API response for search_user_playbooks — uses public types.
|
|
782
|
+
"""
|
|
783
|
+
|
|
784
|
+
success: bool
|
|
785
|
+
user_playbooks: list[PublicUserPlaybook]
|
|
786
|
+
msg: str | None = None
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
class PublicSearchAgentPlaybookResponse(BaseModel):
|
|
790
|
+
"""Deprecated: use SearchAgentPlaybooksViewResponse from api_schema.retriever_schema instead.
|
|
791
|
+
|
|
792
|
+
API response for search_agent_playbooks — uses public types.
|
|
793
|
+
"""
|
|
794
|
+
|
|
795
|
+
success: bool
|
|
796
|
+
agent_playbooks: list[PublicAgentPlaybook]
|
|
797
|
+
msg: str | None = None
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
class PublicUnifiedSearchResponse(BaseModel):
|
|
801
|
+
"""Deprecated: use UnifiedSearchViewResponse from api_schema.retriever_schema instead.
|
|
802
|
+
|
|
803
|
+
API response for unified search — uses public types for playbooks.
|
|
804
|
+
"""
|
|
805
|
+
|
|
806
|
+
success: bool
|
|
807
|
+
profiles: list[UserProfile] = []
|
|
808
|
+
agent_playbooks: list[PublicAgentPlaybook] = []
|
|
809
|
+
user_playbooks: list[PublicUserPlaybook] = []
|
|
810
|
+
reformulated_query: str | None = None
|
|
811
|
+
msg: str | None = None
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
class AgentPlaybookSnapshot(BaseModel):
|
|
815
|
+
"""Lightweight agent playbook snapshot for change log JSONB payloads (excludes embedding and internal status)."""
|
|
816
|
+
|
|
817
|
+
agent_playbook_id: int = 0
|
|
818
|
+
playbook_name: str = ""
|
|
819
|
+
agent_version: str = ""
|
|
820
|
+
content: str = ""
|
|
821
|
+
trigger: str | None = None
|
|
822
|
+
rationale: str | None = None
|
|
823
|
+
blocking_issue: BlockingIssue | None = None
|
|
824
|
+
playbook_status: PlaybookStatus = PlaybookStatus.PENDING
|
|
825
|
+
playbook_metadata: str = ""
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
class AgentPlaybookUpdateEntry(BaseModel):
|
|
829
|
+
"""Before/after pair for an updated agent playbook."""
|
|
830
|
+
|
|
831
|
+
before: AgentPlaybookSnapshot
|
|
832
|
+
after: AgentPlaybookSnapshot
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
class PlaybookAggregationChangeLog(BaseModel):
|
|
836
|
+
"""Tracks changes from a single playbook aggregation run."""
|
|
837
|
+
|
|
838
|
+
id: int = 0
|
|
839
|
+
created_at: int = Field(default_factory=lambda: int(datetime.now(UTC).timestamp()))
|
|
840
|
+
playbook_name: str
|
|
841
|
+
agent_version: str
|
|
842
|
+
run_mode: Literal["full_archive", "incremental"]
|
|
843
|
+
added_agent_playbooks: list[AgentPlaybookSnapshot] = Field(default_factory=list)
|
|
844
|
+
removed_agent_playbooks: list[AgentPlaybookSnapshot] = Field(default_factory=list)
|
|
845
|
+
updated_agent_playbooks: list[AgentPlaybookUpdateEntry] = Field(
|
|
846
|
+
default_factory=list
|
|
847
|
+
)
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
class PlaybookAggregationChangeLogResponse(BaseModel):
|
|
851
|
+
success: bool
|
|
852
|
+
change_logs: list[PlaybookAggregationChangeLog]
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
def agent_playbook_to_snapshot(playbook: AgentPlaybook) -> AgentPlaybookSnapshot:
|
|
856
|
+
"""Convert an AgentPlaybook to a lightweight AgentPlaybookSnapshot (excludes embedding and internal status).
|
|
857
|
+
|
|
858
|
+
Args:
|
|
859
|
+
playbook (AgentPlaybook): Full agent playbook object
|
|
860
|
+
|
|
861
|
+
Returns:
|
|
862
|
+
AgentPlaybookSnapshot: Lightweight snapshot for change log storage
|
|
863
|
+
"""
|
|
864
|
+
return AgentPlaybookSnapshot(
|
|
865
|
+
agent_playbook_id=playbook.agent_playbook_id,
|
|
866
|
+
playbook_name=playbook.playbook_name,
|
|
867
|
+
agent_version=playbook.agent_version,
|
|
868
|
+
content=playbook.content,
|
|
869
|
+
trigger=playbook.trigger,
|
|
870
|
+
rationale=playbook.rationale,
|
|
871
|
+
blocking_issue=playbook.blocking_issue,
|
|
872
|
+
playbook_status=playbook.playbook_status,
|
|
873
|
+
playbook_metadata=playbook.playbook_metadata,
|
|
874
|
+
)
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
class RunPlaybookAggregationRequest(BaseModel):
|
|
878
|
+
agent_version: str = DEFAULT_AGENT_VERSION
|
|
879
|
+
playbook_name: NonEmptyStr = "playbook"
|
|
880
|
+
|
|
881
|
+
@field_validator("agent_version")
|
|
882
|
+
@classmethod
|
|
883
|
+
def resolve_version(cls, v: str) -> str:
|
|
884
|
+
return v or DEFAULT_AGENT_VERSION
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
class RunPlaybookAggregationResponse(BaseModel):
|
|
888
|
+
success: bool
|
|
889
|
+
message: str = ""
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
class RerunProfileGenerationRequest(BaseModel):
|
|
893
|
+
user_id: str | None = None
|
|
894
|
+
start_time: datetime | None = None
|
|
895
|
+
end_time: datetime | None = None
|
|
896
|
+
source: str | None = None
|
|
897
|
+
extractor_names: list[str] | None = (
|
|
898
|
+
None # Deprecated compatibility field; ignored for selection.
|
|
899
|
+
)
|
|
900
|
+
|
|
901
|
+
@model_validator(mode="after")
|
|
902
|
+
def check_time_range(self) -> Self:
|
|
903
|
+
"""Validate that end_time is after start_time."""
|
|
904
|
+
TimeRangeValidatorMixin.validate_time_range(self.start_time, self.end_time)
|
|
905
|
+
return self
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
class RerunProfileGenerationResponse(BaseModel):
|
|
909
|
+
success: bool
|
|
910
|
+
msg: str | None = None
|
|
911
|
+
profiles_generated: int | None = None
|
|
912
|
+
operation_id: str = "rerun_profile_generation"
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
class ManualProfileGenerationRequest(BaseModel):
|
|
916
|
+
"""Request for manual trigger of regular profile generation.
|
|
917
|
+
|
|
918
|
+
Uses window-sized interactions (from config) instead of all interactions.
|
|
919
|
+
Outputs profiles with CURRENT status (not PENDING like rerun).
|
|
920
|
+
"""
|
|
921
|
+
|
|
922
|
+
user_id: str | None = None
|
|
923
|
+
source: str | None = None
|
|
924
|
+
extractor_names: list[str] | None = None
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
class ManualProfileGenerationResponse(BaseModel):
|
|
928
|
+
"""Response for manual profile generation."""
|
|
929
|
+
|
|
930
|
+
success: bool
|
|
931
|
+
msg: str | None = None
|
|
932
|
+
profiles_generated: int | None = None
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
class ManualPlaybookGenerationRequest(BaseModel):
|
|
936
|
+
"""Request for manual trigger of regular playbook generation.
|
|
937
|
+
|
|
938
|
+
Uses window-sized interactions (from config) instead of all interactions.
|
|
939
|
+
Outputs playbooks with CURRENT status (not PENDING like rerun).
|
|
940
|
+
"""
|
|
941
|
+
|
|
942
|
+
agent_version: str = DEFAULT_AGENT_VERSION
|
|
943
|
+
source: str | None = None
|
|
944
|
+
playbook_name: str | None = (
|
|
945
|
+
None # Deprecated compatibility field; ignored for selection.
|
|
946
|
+
)
|
|
947
|
+
|
|
948
|
+
@field_validator("agent_version")
|
|
949
|
+
@classmethod
|
|
950
|
+
def resolve_version(cls, v: str) -> str:
|
|
951
|
+
return v or DEFAULT_AGENT_VERSION
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
class ManualPlaybookGenerationResponse(BaseModel):
|
|
955
|
+
"""Response for manual playbook generation."""
|
|
956
|
+
|
|
957
|
+
success: bool
|
|
958
|
+
msg: str | None = None
|
|
959
|
+
playbooks_generated: int | None = None
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
class RerunPlaybookGenerationRequest(BaseModel):
|
|
963
|
+
agent_version: str = DEFAULT_AGENT_VERSION
|
|
964
|
+
start_time: datetime | None = None
|
|
965
|
+
end_time: datetime | None = None
|
|
966
|
+
playbook_name: str | None = (
|
|
967
|
+
None # Deprecated compatibility field; ignored for selection.
|
|
968
|
+
)
|
|
969
|
+
source: str | None = None
|
|
970
|
+
|
|
971
|
+
@field_validator("agent_version")
|
|
972
|
+
@classmethod
|
|
973
|
+
def resolve_version(cls, v: str) -> str:
|
|
974
|
+
return v or DEFAULT_AGENT_VERSION
|
|
975
|
+
|
|
976
|
+
@model_validator(mode="after")
|
|
977
|
+
def check_time_range(self) -> Self:
|
|
978
|
+
"""Validate that end_time is after start_time."""
|
|
979
|
+
TimeRangeValidatorMixin.validate_time_range(self.start_time, self.end_time)
|
|
980
|
+
return self
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
class RerunPlaybookGenerationResponse(BaseModel):
|
|
984
|
+
success: bool
|
|
985
|
+
msg: str | None = None
|
|
986
|
+
playbooks_generated: int | None = None
|
|
987
|
+
operation_id: str = "rerun_playbook_generation"
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
class UpgradeProfilesRequest(BaseModel):
|
|
991
|
+
user_id: str | None = None # None means "all users"
|
|
992
|
+
profile_ids: list[str] | None = None
|
|
993
|
+
only_affected_users: bool = (
|
|
994
|
+
False # If True, only upgrade users who have pending profiles
|
|
995
|
+
)
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
class UpgradeProfilesResponse(BaseModel):
|
|
999
|
+
success: bool
|
|
1000
|
+
profiles_archived: int = 0
|
|
1001
|
+
profiles_promoted: int = 0
|
|
1002
|
+
profiles_deleted: int = 0
|
|
1003
|
+
message: str = ""
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
class DowngradeProfilesRequest(BaseModel):
|
|
1007
|
+
user_id: str | None = None # None means "all users"
|
|
1008
|
+
profile_ids: list[str] | None = None
|
|
1009
|
+
only_affected_users: bool = (
|
|
1010
|
+
False # If True, only downgrade users who have archived profiles
|
|
1011
|
+
)
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
class DowngradeProfilesResponse(BaseModel):
|
|
1015
|
+
success: bool
|
|
1016
|
+
profiles_demoted: int = 0
|
|
1017
|
+
profiles_restored: int = 0
|
|
1018
|
+
message: str = ""
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
class UpgradeUserPlaybooksRequest(BaseModel):
|
|
1022
|
+
agent_version: str | None = None
|
|
1023
|
+
playbook_name: str | None = None
|
|
1024
|
+
archive_current: bool = True
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
class UpgradeUserPlaybooksResponse(BaseModel):
|
|
1028
|
+
success: bool
|
|
1029
|
+
user_playbooks_deleted: int = 0
|
|
1030
|
+
user_playbooks_archived: int = 0
|
|
1031
|
+
user_playbooks_promoted: int = 0
|
|
1032
|
+
message: str = ""
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
class DowngradeUserPlaybooksRequest(BaseModel):
|
|
1036
|
+
agent_version: str | None = None
|
|
1037
|
+
playbook_name: str | None = None
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
class DowngradeUserPlaybooksResponse(BaseModel):
|
|
1041
|
+
success: bool
|
|
1042
|
+
user_playbooks_demoted: int = 0
|
|
1043
|
+
user_playbooks_restored: int = 0
|
|
1044
|
+
message: str = ""
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
# ===============================
|
|
1048
|
+
# Operation Status Models
|
|
1049
|
+
# ===============================
|
|
1050
|
+
class OperationStatusInfo(BaseModel):
|
|
1051
|
+
service_name: str
|
|
1052
|
+
status: OperationStatus
|
|
1053
|
+
started_at: int
|
|
1054
|
+
completed_at: int | None = None
|
|
1055
|
+
total_users: int = 0
|
|
1056
|
+
processed_users: int = 0
|
|
1057
|
+
failed_users: int = 0
|
|
1058
|
+
current_user_id: str | None = None
|
|
1059
|
+
processed_user_ids: list[str] = []
|
|
1060
|
+
failed_user_ids: list[dict] = [] # [{"user_id": "...", "error": "..."}]
|
|
1061
|
+
request_params: dict = {}
|
|
1062
|
+
stats: dict = {}
|
|
1063
|
+
error_message: str | None = None
|
|
1064
|
+
progress_percentage: float = Field(default=0.0, ge=0.0, le=100.0)
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
class GetOperationStatusRequest(BaseModel):
|
|
1068
|
+
service_name: str = "profile_generation"
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
class GetOperationStatusResponse(BaseModel):
|
|
1072
|
+
success: bool
|
|
1073
|
+
operation_status: OperationStatusInfo | None = None
|
|
1074
|
+
msg: str | None = None
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
class CancelOperationRequest(BaseModel):
|
|
1078
|
+
service_name: str | None = None # None cancels both services
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
class CancelOperationResponse(BaseModel):
|
|
1082
|
+
success: bool
|
|
1083
|
+
cancelled_services: list[str] = []
|
|
1084
|
+
msg: str | None = None
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
# Admin cache invalidation — explicit eviction of the per-org Reflexio cache.
|
|
1088
|
+
class AdminInvalidateCacheRequest(BaseModel):
|
|
1089
|
+
"""Request body for ``POST /api/admin/cache/invalidate``.
|
|
1090
|
+
|
|
1091
|
+
The optional ``org_id`` is a verification token: when supplied it
|
|
1092
|
+
must match the caller's resolved org_id, otherwise the server
|
|
1093
|
+
rejects with 403. This guards against a misconfigured client
|
|
1094
|
+
accidentally invalidating someone else's cache. Cross-org admin
|
|
1095
|
+
invalidation is intentionally out of scope for this endpoint.
|
|
1096
|
+
"""
|
|
1097
|
+
|
|
1098
|
+
org_id: str | None = None
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
class AdminInvalidateCacheResponse(BaseModel):
|
|
1102
|
+
"""Result of an admin cache invalidation call.
|
|
1103
|
+
|
|
1104
|
+
Attributes:
|
|
1105
|
+
invalidated (bool): True when an entry was evicted, False when
|
|
1106
|
+
no entry was cached for the org (still a successful no-op).
|
|
1107
|
+
org_id (str): The org_id that was targeted (always the caller's
|
|
1108
|
+
own org).
|
|
1109
|
+
"""
|
|
1110
|
+
|
|
1111
|
+
invalidated: bool
|
|
1112
|
+
org_id: str
|