claude-smart 0.2.41 → 0.2.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +17 -0
- package/README.md +1 -1
- package/bin/claude-smart.js +86 -48
- package/package.json +10 -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/dashboard/next.config.ts +9 -1
- package/plugin/pyproject.toml +2 -2
- package/plugin/scripts/_lib.sh +91 -0
- package/plugin/scripts/backend-service.sh +46 -15
- package/plugin/scripts/cli.sh +29 -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 +7 -14
- package/plugin/scripts/hook_entry.sh +1 -0
- package/plugin/scripts/smart-install.sh +18 -2
- package/plugin/src/claude_smart/cli.py +72 -38
- 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,503 @@
|
|
|
1
|
+
"""Agent playbook management commands (list, search, delete, aggregate)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Annotated
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
|
|
9
|
+
from reflexio.cli.errors import (
|
|
10
|
+
EXIT_VALIDATION,
|
|
11
|
+
CliError,
|
|
12
|
+
handle_errors,
|
|
13
|
+
raise_if_failed,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from reflexio.models.api_schema.service_schemas import PlaybookStatus
|
|
18
|
+
from reflexio.cli.output import (
|
|
19
|
+
pagination_meta,
|
|
20
|
+
print_agent_playbooks,
|
|
21
|
+
print_info,
|
|
22
|
+
render,
|
|
23
|
+
)
|
|
24
|
+
from reflexio.cli.state import get_client
|
|
25
|
+
from reflexio.models.config_schema import SINGLETON_USER_PLAYBOOK_NAME
|
|
26
|
+
|
|
27
|
+
app = typer.Typer(help="Manage agent playbooks.")
|
|
28
|
+
|
|
29
|
+
_PLAYBOOK_STATUS_MAP = {
|
|
30
|
+
"pending": "pending",
|
|
31
|
+
"approved": "approved",
|
|
32
|
+
"rejected": "rejected",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _validate_playbook_status(value: str | None) -> PlaybookStatus | None:
|
|
37
|
+
"""Validate and convert a playbook status string to PlaybookStatus enum.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
value (str | None): Raw status string from CLI input
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
PlaybookStatus | None: Parsed enum value, or None if input is None
|
|
44
|
+
|
|
45
|
+
Raises:
|
|
46
|
+
CliError: If the value is not a valid playbook status
|
|
47
|
+
"""
|
|
48
|
+
from reflexio.models.api_schema.service_schemas import PlaybookStatus
|
|
49
|
+
|
|
50
|
+
if not value:
|
|
51
|
+
return None
|
|
52
|
+
if value not in _PLAYBOOK_STATUS_MAP:
|
|
53
|
+
raise CliError(
|
|
54
|
+
error_type="validation",
|
|
55
|
+
message=f"Invalid playbook status: {value}. Must be pending, approved, or rejected.",
|
|
56
|
+
exit_code=EXIT_VALIDATION,
|
|
57
|
+
)
|
|
58
|
+
return PlaybookStatus(value)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@app.command(name="list")
|
|
62
|
+
@handle_errors
|
|
63
|
+
def list_agent_playbooks(
|
|
64
|
+
ctx: typer.Context,
|
|
65
|
+
limit: Annotated[
|
|
66
|
+
int,
|
|
67
|
+
typer.Option("--limit", help="Maximum number of playbooks to return"),
|
|
68
|
+
] = 20,
|
|
69
|
+
playbook_name: Annotated[
|
|
70
|
+
str | None,
|
|
71
|
+
typer.Option("--playbook-name", help="Filter by playbook name"),
|
|
72
|
+
] = None,
|
|
73
|
+
agent_version: Annotated[
|
|
74
|
+
str | None,
|
|
75
|
+
typer.Option("--agent-version", help="Filter by agent version"),
|
|
76
|
+
] = None,
|
|
77
|
+
playbook_status: Annotated[
|
|
78
|
+
str | None,
|
|
79
|
+
typer.Option(
|
|
80
|
+
"--playbook-status",
|
|
81
|
+
help="Filter by approval status (pending/approved/rejected)",
|
|
82
|
+
),
|
|
83
|
+
] = None,
|
|
84
|
+
) -> None:
|
|
85
|
+
"""List agent playbooks.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
ctx: Typer context with CliState in ctx.obj
|
|
89
|
+
limit: Maximum number of playbooks to return
|
|
90
|
+
playbook_name: Optional playbook name filter
|
|
91
|
+
agent_version: Optional agent version filter
|
|
92
|
+
playbook_status: Optional approval status filter
|
|
93
|
+
"""
|
|
94
|
+
pb_status_filter = _validate_playbook_status(playbook_status)
|
|
95
|
+
|
|
96
|
+
client = get_client(ctx)
|
|
97
|
+
resp = client.get_agent_playbooks(
|
|
98
|
+
limit=limit,
|
|
99
|
+
playbook_name=playbook_name,
|
|
100
|
+
agent_version=agent_version,
|
|
101
|
+
playbook_status_filter=pb_status_filter,
|
|
102
|
+
)
|
|
103
|
+
playbooks = resp.agent_playbooks or []
|
|
104
|
+
|
|
105
|
+
json_mode: bool = ctx.obj.json_mode
|
|
106
|
+
if json_mode:
|
|
107
|
+
render(playbooks, json_mode=True, meta=pagination_meta(playbooks, limit))
|
|
108
|
+
else:
|
|
109
|
+
print_info(f"Found {len(playbooks)} agent playbook(s)")
|
|
110
|
+
if playbooks:
|
|
111
|
+
print_agent_playbooks(playbooks)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@app.command()
|
|
115
|
+
@handle_errors
|
|
116
|
+
def search(
|
|
117
|
+
ctx: typer.Context,
|
|
118
|
+
query: Annotated[
|
|
119
|
+
str,
|
|
120
|
+
typer.Argument(help="Semantic search query for agent playbooks"),
|
|
121
|
+
],
|
|
122
|
+
limit: Annotated[
|
|
123
|
+
int,
|
|
124
|
+
typer.Option("--limit", help="Maximum number of results"),
|
|
125
|
+
] = 10,
|
|
126
|
+
agent_version: Annotated[
|
|
127
|
+
str | None,
|
|
128
|
+
typer.Option("--agent-version", help="Agent version to filter by"),
|
|
129
|
+
] = None,
|
|
130
|
+
playbook_status: Annotated[
|
|
131
|
+
str | None,
|
|
132
|
+
typer.Option(
|
|
133
|
+
"--playbook-status",
|
|
134
|
+
help="Filter by approval status (pending/approved/rejected)",
|
|
135
|
+
),
|
|
136
|
+
] = None,
|
|
137
|
+
) -> None:
|
|
138
|
+
"""Search agent playbooks by semantic query.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
ctx: Typer context with CliState in ctx.obj
|
|
142
|
+
query: Search query string
|
|
143
|
+
limit: Maximum number of results
|
|
144
|
+
agent_version: Optional agent version filter
|
|
145
|
+
playbook_status: Optional approval status filter
|
|
146
|
+
"""
|
|
147
|
+
pb_status_filter = _validate_playbook_status(playbook_status)
|
|
148
|
+
|
|
149
|
+
client = get_client(ctx)
|
|
150
|
+
|
|
151
|
+
resp = client.search_agent_playbooks(
|
|
152
|
+
query=query,
|
|
153
|
+
agent_version=agent_version,
|
|
154
|
+
playbook_status_filter=pb_status_filter,
|
|
155
|
+
top_k=limit,
|
|
156
|
+
)
|
|
157
|
+
playbooks = resp.agent_playbooks or []
|
|
158
|
+
|
|
159
|
+
json_mode: bool = ctx.obj.json_mode
|
|
160
|
+
if json_mode:
|
|
161
|
+
render(playbooks, json_mode=True, meta=pagination_meta(playbooks, limit))
|
|
162
|
+
else:
|
|
163
|
+
print_info(f"Found {len(playbooks)} agent playbook(s)")
|
|
164
|
+
if playbooks:
|
|
165
|
+
print_agent_playbooks(playbooks)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@app.command()
|
|
169
|
+
@handle_errors
|
|
170
|
+
def add(
|
|
171
|
+
ctx: typer.Context,
|
|
172
|
+
content: Annotated[
|
|
173
|
+
str,
|
|
174
|
+
typer.Option("--content", help="Playbook content text"),
|
|
175
|
+
],
|
|
176
|
+
agent_version: Annotated[
|
|
177
|
+
str,
|
|
178
|
+
typer.Option(
|
|
179
|
+
"--agent-version",
|
|
180
|
+
help="Agent version this playbook applies to",
|
|
181
|
+
),
|
|
182
|
+
],
|
|
183
|
+
playbook_name: Annotated[
|
|
184
|
+
str,
|
|
185
|
+
typer.Option("--playbook-name", help="Playbook category name"),
|
|
186
|
+
] = "agent_corrections",
|
|
187
|
+
playbook_status: Annotated[
|
|
188
|
+
str,
|
|
189
|
+
typer.Option(
|
|
190
|
+
"--playbook-status",
|
|
191
|
+
help="Approval status (pending/approved/rejected)",
|
|
192
|
+
),
|
|
193
|
+
] = "pending",
|
|
194
|
+
trigger: Annotated[
|
|
195
|
+
str | None,
|
|
196
|
+
typer.Option("--trigger", help="When this playbook applies"),
|
|
197
|
+
] = None,
|
|
198
|
+
rationale: Annotated[
|
|
199
|
+
str | None,
|
|
200
|
+
typer.Option("--rationale", help="Why this playbook matters"),
|
|
201
|
+
] = None,
|
|
202
|
+
) -> None:
|
|
203
|
+
"""Add an agent playbook directly, bypassing the aggregation pipeline.
|
|
204
|
+
|
|
205
|
+
Mirrors ``reflexio user-playbooks add`` but for the agent
|
|
206
|
+
(post-aggregation) playbook layer. Useful for seeding rules
|
|
207
|
+
that you want the agent to follow without first producing
|
|
208
|
+
sample user playbooks for the aggregator to cluster.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
ctx: Typer context with CliState in ctx.obj
|
|
212
|
+
content: Playbook content text
|
|
213
|
+
agent_version: Agent version this playbook applies to
|
|
214
|
+
playbook_name: Playbook category name
|
|
215
|
+
playbook_status: Initial approval status
|
|
216
|
+
trigger: When this playbook applies
|
|
217
|
+
rationale: Why this playbook matters
|
|
218
|
+
"""
|
|
219
|
+
# --playbook-status has a non-empty default ("pending"), so
|
|
220
|
+
# _validate_playbook_status always returns a PlaybookStatus here.
|
|
221
|
+
# The cast narrows the Optional return type without the runtime
|
|
222
|
+
# overhead (or lint noise) of an ``assert``.
|
|
223
|
+
from typing import cast
|
|
224
|
+
|
|
225
|
+
from reflexio.models.api_schema.service_schemas import (
|
|
226
|
+
AgentPlaybook,
|
|
227
|
+
PlaybookStatus,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
pb_status = cast(PlaybookStatus, _validate_playbook_status(playbook_status))
|
|
231
|
+
|
|
232
|
+
playbook = AgentPlaybook(
|
|
233
|
+
agent_version=agent_version,
|
|
234
|
+
playbook_name=playbook_name,
|
|
235
|
+
content=content,
|
|
236
|
+
trigger=trigger,
|
|
237
|
+
rationale=rationale,
|
|
238
|
+
playbook_status=pb_status,
|
|
239
|
+
playbook_metadata='{"source": "cli-manual"}',
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
client = get_client(ctx)
|
|
243
|
+
resp = client.add_agent_playbooks([playbook])
|
|
244
|
+
|
|
245
|
+
json_mode: bool = ctx.obj.json_mode
|
|
246
|
+
if json_mode:
|
|
247
|
+
render(resp, json_mode=True)
|
|
248
|
+
else:
|
|
249
|
+
raise_if_failed(resp, default="Failed to add agent playbook")
|
|
250
|
+
print_info(f"Agent playbook added: {content[:80]}")
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
@app.command()
|
|
254
|
+
@handle_errors
|
|
255
|
+
def update(
|
|
256
|
+
ctx: typer.Context,
|
|
257
|
+
playbook_id: Annotated[
|
|
258
|
+
int,
|
|
259
|
+
typer.Option("--playbook-id", help="Agent playbook ID to update"),
|
|
260
|
+
],
|
|
261
|
+
content: Annotated[
|
|
262
|
+
str | None,
|
|
263
|
+
typer.Option("--content", help="New content text"),
|
|
264
|
+
] = None,
|
|
265
|
+
playbook_name: Annotated[
|
|
266
|
+
str | None,
|
|
267
|
+
typer.Option("--playbook-name", help="New playbook category name"),
|
|
268
|
+
] = None,
|
|
269
|
+
) -> None:
|
|
270
|
+
"""Update editable fields of an agent playbook.
|
|
271
|
+
|
|
272
|
+
Pass only the fields you want to change. Currently supports
|
|
273
|
+
``--content`` and ``--playbook-name``.
|
|
274
|
+
|
|
275
|
+
To change the approval status, use ``update-status`` instead.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
ctx: Typer context with CliState in ctx.obj
|
|
279
|
+
playbook_id: Agent playbook ID to update
|
|
280
|
+
content: New content text
|
|
281
|
+
playbook_name: New playbook category name
|
|
282
|
+
"""
|
|
283
|
+
if content is None and playbook_name is None:
|
|
284
|
+
raise CliError(
|
|
285
|
+
error_type="validation",
|
|
286
|
+
message=("Pass at least one of --content/--playbook-name to update."),
|
|
287
|
+
exit_code=EXIT_VALIDATION,
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
client = get_client(ctx)
|
|
291
|
+
resp = client.update_agent_playbook(
|
|
292
|
+
agent_playbook_id=playbook_id,
|
|
293
|
+
content=content,
|
|
294
|
+
playbook_name=playbook_name,
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
json_mode: bool = ctx.obj.json_mode
|
|
298
|
+
if json_mode:
|
|
299
|
+
render(resp, json_mode=True)
|
|
300
|
+
else:
|
|
301
|
+
raise_if_failed(resp, default="Failed to update agent playbook")
|
|
302
|
+
print_info(f"Agent playbook {playbook_id} updated")
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
@app.command(name="update-status")
|
|
306
|
+
@handle_errors
|
|
307
|
+
def update_status(
|
|
308
|
+
ctx: typer.Context,
|
|
309
|
+
playbook_id: Annotated[
|
|
310
|
+
int,
|
|
311
|
+
typer.Option("--playbook-id", help="Agent playbook ID"),
|
|
312
|
+
],
|
|
313
|
+
status: Annotated[
|
|
314
|
+
str,
|
|
315
|
+
typer.Option(
|
|
316
|
+
"--status",
|
|
317
|
+
help="New approval status (pending/approved/rejected)",
|
|
318
|
+
),
|
|
319
|
+
],
|
|
320
|
+
) -> None:
|
|
321
|
+
"""Approve, reject, or mark pending an agent playbook.
|
|
322
|
+
|
|
323
|
+
The dedicated approval-workflow command. Use this rather than
|
|
324
|
+
``update --status`` because the server has a single-purpose
|
|
325
|
+
endpoint for status changes that writes a smaller change log
|
|
326
|
+
and enforces tighter validation.
|
|
327
|
+
|
|
328
|
+
Args:
|
|
329
|
+
ctx: Typer context with CliState in ctx.obj
|
|
330
|
+
playbook_id: Agent playbook ID
|
|
331
|
+
status: New approval status (pending/approved/rejected)
|
|
332
|
+
"""
|
|
333
|
+
pb_status = _validate_playbook_status(status)
|
|
334
|
+
if pb_status is None:
|
|
335
|
+
raise CliError(
|
|
336
|
+
error_type="validation",
|
|
337
|
+
message=(
|
|
338
|
+
f"Invalid status: {status}. Must be pending, approved, or rejected."
|
|
339
|
+
),
|
|
340
|
+
exit_code=EXIT_VALIDATION,
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
client = get_client(ctx)
|
|
344
|
+
resp = client.update_agent_playbook_status(
|
|
345
|
+
agent_playbook_id=playbook_id,
|
|
346
|
+
playbook_status=pb_status,
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
json_mode: bool = ctx.obj.json_mode
|
|
350
|
+
if json_mode:
|
|
351
|
+
render(resp, json_mode=True)
|
|
352
|
+
else:
|
|
353
|
+
raise_if_failed(resp, default="Failed to update agent playbook status")
|
|
354
|
+
print_info(f"Agent playbook {playbook_id} status set to {pb_status.value}")
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
@app.command()
|
|
358
|
+
@handle_errors
|
|
359
|
+
def delete(
|
|
360
|
+
ctx: typer.Context,
|
|
361
|
+
playbook_id: Annotated[
|
|
362
|
+
str,
|
|
363
|
+
typer.Option("--playbook-id", help="Agent playbook ID"),
|
|
364
|
+
],
|
|
365
|
+
) -> None:
|
|
366
|
+
"""Delete an agent playbook by ID.
|
|
367
|
+
|
|
368
|
+
Args:
|
|
369
|
+
ctx: Typer context with CliState in ctx.obj
|
|
370
|
+
playbook_id: Agent playbook ID to delete
|
|
371
|
+
"""
|
|
372
|
+
client = get_client(ctx)
|
|
373
|
+
resp = client.delete_agent_playbook(
|
|
374
|
+
agent_playbook_id=int(playbook_id),
|
|
375
|
+
wait_for_response=True,
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
json_mode: bool = ctx.obj.json_mode
|
|
379
|
+
if json_mode:
|
|
380
|
+
render(resp, json_mode=True)
|
|
381
|
+
else:
|
|
382
|
+
print_info(f"Deleted agent playbook {playbook_id}")
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
@app.command(name="delete-all")
|
|
386
|
+
@handle_errors
|
|
387
|
+
def delete_all(
|
|
388
|
+
ctx: typer.Context,
|
|
389
|
+
yes: Annotated[
|
|
390
|
+
bool,
|
|
391
|
+
typer.Option("--yes", "-y", help="Skip confirmation prompt"),
|
|
392
|
+
] = False,
|
|
393
|
+
) -> None:
|
|
394
|
+
"""Delete all agent playbooks (agent only, not user playbooks).
|
|
395
|
+
|
|
396
|
+
Uses the dedicated ``DELETE /api/delete_all_agent_playbooks`` endpoint,
|
|
397
|
+
which is scoped strictly to agent playbooks. To also wipe user
|
|
398
|
+
playbooks, run ``reflexio user-playbooks delete-all`` separately.
|
|
399
|
+
|
|
400
|
+
Args:
|
|
401
|
+
ctx: Typer context with CliState in ctx.obj
|
|
402
|
+
yes: If True, skip confirmation prompt
|
|
403
|
+
"""
|
|
404
|
+
if not yes:
|
|
405
|
+
confirmed = typer.confirm(
|
|
406
|
+
"Are you sure you want to delete all agent playbooks?"
|
|
407
|
+
)
|
|
408
|
+
if not confirmed:
|
|
409
|
+
raise typer.Abort()
|
|
410
|
+
|
|
411
|
+
client = get_client(ctx)
|
|
412
|
+
resp = client.delete_all_agent_playbooks()
|
|
413
|
+
|
|
414
|
+
json_mode: bool = ctx.obj.json_mode
|
|
415
|
+
if json_mode:
|
|
416
|
+
render(resp, json_mode=True)
|
|
417
|
+
else:
|
|
418
|
+
print_info("All agent playbooks deleted")
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
@app.command()
|
|
422
|
+
@handle_errors
|
|
423
|
+
def aggregate(
|
|
424
|
+
ctx: typer.Context,
|
|
425
|
+
wait: Annotated[
|
|
426
|
+
bool,
|
|
427
|
+
typer.Option("--wait", help="Wait for aggregation to complete"),
|
|
428
|
+
] = False,
|
|
429
|
+
agent_version: Annotated[
|
|
430
|
+
str | None,
|
|
431
|
+
typer.Option(
|
|
432
|
+
"--agent-version",
|
|
433
|
+
help="Agent version to aggregate. If omitted, aggregates all versions.",
|
|
434
|
+
),
|
|
435
|
+
] = None,
|
|
436
|
+
playbook_name: Annotated[
|
|
437
|
+
str | None,
|
|
438
|
+
typer.Option("--playbook-name", help="Playbook name to aggregate"),
|
|
439
|
+
] = None,
|
|
440
|
+
) -> None:
|
|
441
|
+
"""Run playbook aggregation to cluster similar user playbooks.
|
|
442
|
+
|
|
443
|
+
Without --agent-version, discovers all agent versions that have user
|
|
444
|
+
playbooks and aggregates each one separately.
|
|
445
|
+
|
|
446
|
+
Args:
|
|
447
|
+
ctx: Typer context with CliState in ctx.obj
|
|
448
|
+
wait: If True, wait for aggregation to complete
|
|
449
|
+
agent_version: Agent version to aggregate (omit to aggregate all)
|
|
450
|
+
playbook_name: Playbook name to aggregate (defaults to first configured playbook)
|
|
451
|
+
"""
|
|
452
|
+
client = get_client(ctx)
|
|
453
|
+
|
|
454
|
+
if not playbook_name:
|
|
455
|
+
playbook_name = SINGLETON_USER_PLAYBOOK_NAME
|
|
456
|
+
|
|
457
|
+
json_mode: bool = ctx.obj.json_mode
|
|
458
|
+
|
|
459
|
+
# Determine which agent versions to aggregate
|
|
460
|
+
if agent_version:
|
|
461
|
+
versions = [agent_version]
|
|
462
|
+
else:
|
|
463
|
+
# Discover all agent versions from existing user playbooks
|
|
464
|
+
resp = client.get_user_playbooks(playbook_name=playbook_name, limit=10000)
|
|
465
|
+
versions = sorted(
|
|
466
|
+
{pb.agent_version for pb in (resp.user_playbooks or []) if pb.agent_version}
|
|
467
|
+
)
|
|
468
|
+
if not versions:
|
|
469
|
+
if json_mode:
|
|
470
|
+
render(
|
|
471
|
+
{"message": "No user playbooks found to aggregate"}, json_mode=True
|
|
472
|
+
)
|
|
473
|
+
else:
|
|
474
|
+
print_info("No user playbooks found to aggregate")
|
|
475
|
+
return
|
|
476
|
+
print_info(
|
|
477
|
+
f"Found {len(versions)} agent version(s) to aggregate: {', '.join(versions)}"
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
# Aggregate each version
|
|
481
|
+
for version in versions:
|
|
482
|
+
print_info(
|
|
483
|
+
f"Aggregating user playbooks for '{playbook_name}' (agent_version={version})..."
|
|
484
|
+
)
|
|
485
|
+
resp = client.run_playbook_aggregation(
|
|
486
|
+
agent_version=version,
|
|
487
|
+
playbook_name=playbook_name,
|
|
488
|
+
wait_for_response=wait,
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
if json_mode:
|
|
492
|
+
render(resp, json_mode=True)
|
|
493
|
+
else:
|
|
494
|
+
success = getattr(resp, "success", None)
|
|
495
|
+
message = getattr(resp, "message", "")
|
|
496
|
+
if success is False:
|
|
497
|
+
print_info(f" Failed: {message}")
|
|
498
|
+
elif message:
|
|
499
|
+
print_info(f" {message}")
|
|
500
|
+
elif wait:
|
|
501
|
+
print_info(" Done")
|
|
502
|
+
else:
|
|
503
|
+
print_info(" Started")
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""Raw API command for calling any Reflexio endpoint directly."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Annotated
|
|
8
|
+
|
|
9
|
+
import requests
|
|
10
|
+
import typer
|
|
11
|
+
|
|
12
|
+
from reflexio.cli.errors import EXIT_VALIDATION, CliError, handle_errors
|
|
13
|
+
from reflexio.cli.output import render
|
|
14
|
+
from reflexio.cli.state import resolve_api_key, resolve_url
|
|
15
|
+
|
|
16
|
+
app = typer.Typer(help="Call any Reflexio API endpoint directly.")
|
|
17
|
+
|
|
18
|
+
_VALID_METHODS = {"GET", "POST", "DELETE"}
|
|
19
|
+
|
|
20
|
+
_METHOD_DISPATCH = {
|
|
21
|
+
"GET": requests.get,
|
|
22
|
+
"POST": requests.post,
|
|
23
|
+
"DELETE": requests.delete,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@app.callback(invoke_without_command=True)
|
|
28
|
+
@handle_errors
|
|
29
|
+
def call(
|
|
30
|
+
ctx: typer.Context,
|
|
31
|
+
method: Annotated[
|
|
32
|
+
str,
|
|
33
|
+
typer.Argument(help="HTTP method (GET, POST, DELETE)"),
|
|
34
|
+
],
|
|
35
|
+
path: Annotated[
|
|
36
|
+
str,
|
|
37
|
+
typer.Argument(help="API path (e.g. /api/get_agent_playbooks)"),
|
|
38
|
+
],
|
|
39
|
+
data: Annotated[
|
|
40
|
+
str | None,
|
|
41
|
+
typer.Option("--data", help="JSON body string or @filepath"),
|
|
42
|
+
] = None,
|
|
43
|
+
) -> None:
|
|
44
|
+
"""Make a raw HTTP request to a Reflexio API endpoint.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
ctx: Typer context with CliState in ctx.obj
|
|
48
|
+
method: HTTP method (GET, POST, DELETE)
|
|
49
|
+
path: API endpoint path
|
|
50
|
+
data: Optional JSON body as string or @filepath
|
|
51
|
+
"""
|
|
52
|
+
method_upper = method.upper()
|
|
53
|
+
if method_upper not in _VALID_METHODS:
|
|
54
|
+
raise CliError(
|
|
55
|
+
error_type="validation",
|
|
56
|
+
message=f"Invalid method: {method}. Must be one of GET, POST, DELETE.",
|
|
57
|
+
exit_code=EXIT_VALIDATION,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
state = ctx.obj
|
|
61
|
+
|
|
62
|
+
url = resolve_url(state.server_url)
|
|
63
|
+
api_key = resolve_api_key(state.api_key)
|
|
64
|
+
headers: dict[str, str] = {}
|
|
65
|
+
if api_key:
|
|
66
|
+
headers["Authorization"] = f"Bearer {api_key}"
|
|
67
|
+
|
|
68
|
+
body = _parse_data(data) if data else None
|
|
69
|
+
|
|
70
|
+
request_fn = _METHOD_DISPATCH[method_upper]
|
|
71
|
+
kwargs: dict[str, object] = {"headers": headers}
|
|
72
|
+
if body is not None:
|
|
73
|
+
kwargs["json"] = body
|
|
74
|
+
|
|
75
|
+
resp = request_fn(f"{url}{path}", **kwargs) # type: ignore[arg-type]
|
|
76
|
+
resp.raise_for_status()
|
|
77
|
+
|
|
78
|
+
json_mode: bool = state.json_mode
|
|
79
|
+
render(resp.json(), json_mode=json_mode)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _parse_data(data: str) -> object:
|
|
83
|
+
"""Parse a --data value as JSON string or @filepath.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
data: JSON string or @filepath reference
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
object: Parsed JSON data
|
|
90
|
+
|
|
91
|
+
Raises:
|
|
92
|
+
CliError: If the JSON is invalid or file cannot be read
|
|
93
|
+
"""
|
|
94
|
+
if data.startswith("@"):
|
|
95
|
+
file_path = Path(data[1:])
|
|
96
|
+
try:
|
|
97
|
+
raw = file_path.read_text()
|
|
98
|
+
except OSError as exc:
|
|
99
|
+
raise CliError(
|
|
100
|
+
error_type="validation",
|
|
101
|
+
message=f"Cannot read data file: {exc}",
|
|
102
|
+
exit_code=EXIT_VALIDATION,
|
|
103
|
+
) from exc
|
|
104
|
+
else:
|
|
105
|
+
raw = data
|
|
106
|
+
|
|
107
|
+
try:
|
|
108
|
+
return json.loads(raw)
|
|
109
|
+
except json.JSONDecodeError as exc:
|
|
110
|
+
raise CliError(
|
|
111
|
+
error_type="validation",
|
|
112
|
+
message=f"Invalid JSON in --data: {exc}",
|
|
113
|
+
exit_code=EXIT_VALIDATION,
|
|
114
|
+
) from exc
|