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,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "reflexio",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "vitest run",
|
|
8
|
+
"test:watch": "vitest",
|
|
9
|
+
"typecheck": "tsc --noEmit"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/node": "^20.0.0",
|
|
13
|
+
"typescript": "^5.0.0",
|
|
14
|
+
"vitest": "^3.0.0"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Reflexio Embedded
|
|
2
|
+
|
|
3
|
+
Openclaw plugin for user profile and playbook extraction — learns your preferences, corrections, and workflows across sessions using Openclaw's native memory engine, hooks, and sub-agents. No Reflexio server required.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- [Openclaw CLI](https://docs.openclaw.ai) (>= 2026.3.24)
|
|
8
|
+
- Node.js
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# 1. Install and enable the plugin
|
|
14
|
+
openclaw plugins install /path/to/this/directory
|
|
15
|
+
openclaw plugins enable reflexio-embedded
|
|
16
|
+
|
|
17
|
+
# 2. Enable the active-memory plugin (required for memory search)
|
|
18
|
+
openclaw plugins enable active-memory
|
|
19
|
+
openclaw config set plugins.entries.active-memory.config.agents '["*"]'
|
|
20
|
+
|
|
21
|
+
# 3. Register .reflexio/ as a memory search path
|
|
22
|
+
openclaw config set agents.defaults.memorySearch.extraPaths '[".reflexio/"]' --strict-json
|
|
23
|
+
|
|
24
|
+
# 4. Restart the gateway to pick up changes
|
|
25
|
+
openclaw gateway restart
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Verify it loaded:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
openclaw plugins inspect reflexio-embedded
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Uninstall
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# 1. Remove the plugin
|
|
38
|
+
openclaw plugins disable reflexio-embedded
|
|
39
|
+
openclaw plugins uninstall --force reflexio-embedded
|
|
40
|
+
|
|
41
|
+
# 2. Clean up state files
|
|
42
|
+
rm -f ~/.openclaw/reflexio-consolidation-state.json
|
|
43
|
+
|
|
44
|
+
# 3. Restart the gateway
|
|
45
|
+
openclaw gateway restart
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Your `.reflexio/` user data (profiles and playbooks) is preserved by default. To remove it:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
rm -rf .reflexio/
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## What it does
|
|
55
|
+
|
|
56
|
+
- **Profile extraction** — automatically captures user preferences, facts, and corrections from conversations into `.reflexio/profiles/`
|
|
57
|
+
- **Playbook capture** — records recurring workflows and patterns into `.reflexio/playbooks/`
|
|
58
|
+
- **Dedup and contradiction resolution** — new entries are compared against existing ones via LLM; overlapping content is merged, contradictions resolved (new wins), and non-contradicted facts preserved
|
|
59
|
+
- **Consolidation** — periodic heartbeat-triggered sweep that clusters similar entries and merges duplicates
|
|
60
|
+
- **TTL management** — profiles can have time-to-live values; expired entries are swept automatically
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
Override defaults in your `openclaw.json`:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"plugins": {
|
|
69
|
+
"entries": {
|
|
70
|
+
"reflexio-embedded": {
|
|
71
|
+
"config": {
|
|
72
|
+
"dedup": { "shallow_threshold": 0.4, "top_k": 5 },
|
|
73
|
+
"consolidation": { "threshold_hours": 24 }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Learn more
|
|
82
|
+
|
|
83
|
+
Full project source, design docs, and development setup:
|
|
84
|
+
https://github.com/ReflexioAI/reflexio/tree/main/reflexio/integrations/openclaw-embedded
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reflexio-embedded
|
|
3
|
+
description: "Captures user facts and procedural corrections into .reflexio/ so the agent learns across sessions. Use when: (1) user states a preference, fact, config, or constraint; (2) user corrects the agent and confirms the fix with an explicit 'good'/'perfect' or by moving on without re-correcting for 1-2 turns; (3) at start of a user turn, to retrieve relevant facts and playbooks from past sessions."
|
|
4
|
+
metadata:
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Reflexio Embedded Skill
|
|
8
|
+
|
|
9
|
+
Captures user facts (profiles) and procedural corrections (playbooks) into `.reflexio/`, so the agent learns across sessions. All memory lives in Openclaw's native primitives — no external service required.
|
|
10
|
+
|
|
11
|
+
## First-time setup per agent
|
|
12
|
+
|
|
13
|
+
If `.reflexio/.setup_complete_<agentId>` does NOT exist (where `<agentId>` is your current agent id), perform this one-time check. The setup step runs probing commands via `exec` and asks for approval before making changes.
|
|
14
|
+
|
|
15
|
+
**Steps:**
|
|
16
|
+
|
|
17
|
+
1. Probe current config:
|
|
18
|
+
- `openclaw config get plugins.entries.active-memory.config.agents`
|
|
19
|
+
- `openclaw config get agents.defaults.memorySearch.extraPaths`
|
|
20
|
+
- `openclaw memory status --deep`
|
|
21
|
+
|
|
22
|
+
2. If active-memory is not targeting this agent:
|
|
23
|
+
Ask user: *"To auto-inject relevant facts into each turn, I can enable active-memory for this agent. OK if I run `openclaw config set plugins.entries.active-memory.config.agents '[\"<agentId>\"]' --strict-json`?"*
|
|
24
|
+
On approval, run the command.
|
|
25
|
+
|
|
26
|
+
3. If `.reflexio/` is not registered as an extraPath:
|
|
27
|
+
Ask user: *"I need to register .reflexio/ as a memory path. OK if I run `openclaw config set agents.defaults.memorySearch.extraPaths '[\".reflexio/\"]' --strict-json`?"*
|
|
28
|
+
On approval, run the command.
|
|
29
|
+
|
|
30
|
+
4. If no embedding provider is configured (FTS-only mode):
|
|
31
|
+
Tell user: *"Vector search requires an embedding API key (OpenAI, Gemini, Voyage, or Mistral). The plugin works without one but retrieval quality drops. Would you like guidance on adding one?"*
|
|
32
|
+
If yes, guide them through `openclaw config set` or `openclaw configure`.
|
|
33
|
+
|
|
34
|
+
5. On each decline, note the degraded mode but do not block:
|
|
35
|
+
- No active-memory → you must run `openclaw memory search` via exec at turn start (see "Retrieval" section below).
|
|
36
|
+
- No extraPath → WARN the user the plugin cannot function without this step.
|
|
37
|
+
- No embedding → continue with FTS-only.
|
|
38
|
+
|
|
39
|
+
6. When all checks resolved (approved or accepted with warning): create the marker:
|
|
40
|
+
```bash
|
|
41
|
+
mkdir -p .reflexio
|
|
42
|
+
touch .reflexio/.setup_complete_<agentId>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**If exec is not available** (strict admin policy): fall back to telling the user the exact commands to run manually.
|
|
46
|
+
|
|
47
|
+
## First-Use Initialisation
|
|
48
|
+
|
|
49
|
+
Before any write, ensure `.reflexio/` and its subdirectories exist. This is idempotent — safe to run every session:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
mkdir -p .reflexio/profiles .reflexio/playbooks
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Never overwrite existing files. Never write secrets, tokens, private keys, environment variables, or credentials into `.reflexio/` files. When capturing a fact involves a user-pasted snippet that contains credentials, redact first.
|
|
56
|
+
|
|
57
|
+
## Quick Reference
|
|
58
|
+
|
|
59
|
+
| Situation | Action |
|
|
60
|
+
|-----------------------------------------------------------|--------------------------------------------|
|
|
61
|
+
| User states preference, fact, config, or constraint | `reflexio_write_profile` tool |
|
|
62
|
+
| User correction → you adjust → user confirms | `reflexio_write_playbook` tool |
|
|
63
|
+
| Start of user turn, need context | `reflexio_search` tool |
|
|
64
|
+
| Unsure whether to capture | Skip; batch pass at session-end has a second shot |
|
|
65
|
+
|
|
66
|
+
## Detection Triggers
|
|
67
|
+
|
|
68
|
+
### Profile signals (write immediately, same turn)
|
|
69
|
+
|
|
70
|
+
- **Preferences**: "I prefer X", "I like Y", "I don't like Z", "I always do Q"
|
|
71
|
+
- **Facts about self**: "I'm a [role]", "my timezone is X", "I've been doing Y for Z years"
|
|
72
|
+
- **Config**: "use X", "our team uses Y", "the repo is at Z"
|
|
73
|
+
- **Constraints**: "I'm vegetarian", "no dairy", "I can't X", "don't use Y"
|
|
74
|
+
|
|
75
|
+
For each such signal, call the `reflexio_write_profile` tool with a kebab-case topic slug and an appropriate TTL. See "TTL Selection" below.
|
|
76
|
+
|
|
77
|
+
### Playbook signals (write AFTER confirmation)
|
|
78
|
+
|
|
79
|
+
Playbooks require a specific multi-turn pattern:
|
|
80
|
+
|
|
81
|
+
1. **Correction**: *"No, that's wrong"*, *"Actually..."*, *"Don't do X"*, *"Not like that"*, *"We don't use X here"*.
|
|
82
|
+
2. **You adjust**: you redo the work per the correction.
|
|
83
|
+
3. **Confirmation** (required — without this, do NOT write a playbook):
|
|
84
|
+
- Explicit: *"good"*, *"perfect"*, *"yes that's right"*, *"correct"*.
|
|
85
|
+
- Implicit: the user moves to an unrelated topic without re-correcting for 1-2 more turns.
|
|
86
|
+
|
|
87
|
+
**Explicit don't-write rule**: if you see a correction without subsequent confirmation, do not write a playbook. The fix may be wrong; let the batch pass at session end re-evaluate.
|
|
88
|
+
|
|
89
|
+
## Retrieval
|
|
90
|
+
|
|
91
|
+
### When Active Memory is enabled
|
|
92
|
+
|
|
93
|
+
Your turn context may already contain Reflexio-prefixed entries injected by Active Memory. Incorporate them before responding. No tool call needed.
|
|
94
|
+
|
|
95
|
+
### Fallback when Active Memory is absent
|
|
96
|
+
|
|
97
|
+
At the start of each user turn, call the `reflexio_search` tool with:
|
|
98
|
+
- query: "<user's message>"
|
|
99
|
+
|
|
100
|
+
The tool handles query preprocessing and memory search internally.
|
|
101
|
+
Incorporate any results into your response. Skip if the user's message is trivial.
|
|
102
|
+
|
|
103
|
+
**Important:** Do NOT use the `memory_search` tool (returns config, not results)
|
|
104
|
+
or `exec` with `openclaw memory search` — use the `reflexio_search` tool instead.
|
|
105
|
+
|
|
106
|
+
## File Format
|
|
107
|
+
|
|
108
|
+
**Do NOT construct filenames or frontmatter by hand.** Use the registered tools (`reflexio_write_profile`, `reflexio_write_playbook`). They generate IDs, enforce the frontmatter schema, and write atomically.
|
|
109
|
+
|
|
110
|
+
### Profile template (for mental model — the script emits this)
|
|
111
|
+
|
|
112
|
+
```markdown
|
|
113
|
+
---
|
|
114
|
+
type: profile
|
|
115
|
+
id: prof_<nanoid>
|
|
116
|
+
created: <ISO timestamp>
|
|
117
|
+
ttl: <enum>
|
|
118
|
+
expires: <ISO date or "never">
|
|
119
|
+
supersedes: [<old_id>] # optional, only after a merge
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
<1-3 sentences, one fact per file>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Playbook template
|
|
126
|
+
|
|
127
|
+
```markdown
|
|
128
|
+
---
|
|
129
|
+
type: playbook
|
|
130
|
+
id: pbk_<nanoid>
|
|
131
|
+
created: <ISO timestamp>
|
|
132
|
+
supersedes: [<old_id>] # optional
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## When
|
|
136
|
+
<1-sentence trigger — this is the search anchor; make it a noun phrase>
|
|
137
|
+
|
|
138
|
+
## What
|
|
139
|
+
<2-3 sentences of the procedural rule; DO / DON'T as actually observed>
|
|
140
|
+
|
|
141
|
+
## Why
|
|
142
|
+
<rationale, can be longer — reference only, not recall content>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### How to invoke
|
|
146
|
+
|
|
147
|
+
**Profile:** Call the `reflexio_write_profile` tool with:
|
|
148
|
+
- slug: "diet-vegan"
|
|
149
|
+
- ttl: "infinity"
|
|
150
|
+
- body: "User is vegan. No meat, no fish, no dairy, no eggs."
|
|
151
|
+
|
|
152
|
+
**Playbook:** Call the `reflexio_write_playbook` tool with:
|
|
153
|
+
- slug: "commit-no-ai-attribution"
|
|
154
|
+
- body: "## When\nComposing a git commit message.\n\n## What\nNo AI-attribution trailers.\n\n## Why\nUser corrected this."
|
|
155
|
+
|
|
156
|
+
**Retrieve context:** Call the `reflexio_search` tool with:
|
|
157
|
+
- query: "user's question here"
|
|
158
|
+
|
|
159
|
+
All tools handle preprocessing, memory search, contradiction detection, and file operations internally. You only detect the signal, compose the content, and call the tool.
|
|
160
|
+
|
|
161
|
+
## TTL Selection (profiles only)
|
|
162
|
+
|
|
163
|
+
- `infinity` — durable, non-perishable facts (diet, name, permanent preferences)
|
|
164
|
+
- `one_year` — stable but could plausibly change (address, role, team)
|
|
165
|
+
- `one_quarter` — current focus (active project, sprint theme)
|
|
166
|
+
- `one_month` — short-term context
|
|
167
|
+
- `one_week` / `one_day` — transient (today's agenda, this week's priorities)
|
|
168
|
+
|
|
169
|
+
Pick the most generous TTL that still reflects reality. When in doubt, prefer `infinity` — let dedup handle later contradictions via supersession.
|
|
170
|
+
|
|
171
|
+
## Safety
|
|
172
|
+
|
|
173
|
+
- **Never write secrets.** No API keys, tokens, access tokens, private keys, environment variables, OAuth secrets, auth headers. If the user's message contains any of these, redact them before writing.
|
|
174
|
+
- **Redact pasted code.** User-pasted snippets often contain credentials. Strip them first.
|
|
175
|
+
- **PII.** Do not capture PII beyond what's operationally useful (name, timezone, role are fine; government IDs, addresses, phone numbers only if explicitly relevant).
|
|
176
|
+
|
|
177
|
+
## Best Practices
|
|
178
|
+
|
|
179
|
+
1. **Write immediately** on a clear signal. Don't queue to session-end — that's Flow C's job; you have a different role.
|
|
180
|
+
2. **One fact per profile file.** Multi-fact files are harder to dedupe and easier to contradict.
|
|
181
|
+
3. **Trigger phrase = search anchor.** Write `## When` as a noun phrase describing the situation, not a sentence. Retrieval hits on semantic similarity to this field.
|
|
182
|
+
4. **Skip writing when uncertain.** Flow C has a second pass over the full transcript. It's better to let it handle ambiguous cases.
|
|
183
|
+
5. **Prefer shorter TTL for transient facts.** Don't let "working on project X" accumulate as infinity-TTL cruft.
|
|
184
|
+
|
|
185
|
+
## Opt-in Hook
|
|
186
|
+
|
|
187
|
+
This skill works standalone — your in-session Flow A (profile) and Flow B (playbook) writes populate `.reflexio/` without any hook.
|
|
188
|
+
|
|
189
|
+
The optional hook (`hook/` directory of this plugin) adds two capabilities:
|
|
190
|
+
|
|
191
|
+
1. **TTL sweep at session start**: deletes expired profiles before Active Memory runs.
|
|
192
|
+
2. **Session-end batch extraction (Flow C)**: on `session:compact:before`, `command:stop`, or `command:reset`, spawns a `reflexio-extractor` sub-agent that extracts profiles/playbooks from the full transcript and runs shallow pairwise dedup.
|
|
193
|
+
|
|
194
|
+
See this plugin's `README.md` for install instructions (runs via `./scripts/install.sh`). If the hook is not installed, Flows A+B still work.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reflexio-extractor
|
|
3
|
+
description: "Scoped sub-agent for openclaw-embedded Flow C. Extracts profiles and playbooks from a transcript, then runs shallow pairwise dedup against existing .reflexio/ entries."
|
|
4
|
+
tools:
|
|
5
|
+
- memory_search
|
|
6
|
+
- file_read
|
|
7
|
+
- file_write
|
|
8
|
+
- file_delete
|
|
9
|
+
- reflexio_write_profile
|
|
10
|
+
- reflexio_write_playbook
|
|
11
|
+
- reflexio_search
|
|
12
|
+
runTimeoutSeconds: 120
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
You are a one-shot sub-agent that extracts profiles and playbooks from a conversation transcript, then deduplicates against existing entries in `.reflexio/`.
|
|
16
|
+
|
|
17
|
+
## Your workflow
|
|
18
|
+
|
|
19
|
+
1. **Profile extraction**: load `prompts/profile_extraction.md`, substitute `{transcript}` with the provided transcript and `{existing_profiles_context}` with results from `memory_search(top_k=10, filter={type: profile})`. Call `llm-task` with the substituted prompt and output schema. You receive a list of profile candidates.
|
|
20
|
+
|
|
21
|
+
2. **Playbook extraction**: same process with `prompts/playbook_extraction.md`. You receive a list of playbook candidates.
|
|
22
|
+
|
|
23
|
+
3. **For each candidate**:
|
|
24
|
+
For profiles:
|
|
25
|
+
```
|
|
26
|
+
Call the `reflexio_write_profile` tool with: slug="<slug>", ttl="<ttl>", body="<content>"
|
|
27
|
+
```
|
|
28
|
+
For playbooks:
|
|
29
|
+
```
|
|
30
|
+
Call the `reflexio_write_playbook` tool with: slug="<slug>", body="<content>"
|
|
31
|
+
```
|
|
32
|
+
The tools handle dedup + supersession internally — no separate file deletion needed.
|
|
33
|
+
|
|
34
|
+
4. Exit. Openclaw's file watcher picks up the changes and reindexes.
|
|
35
|
+
|
|
36
|
+
## Constraints
|
|
37
|
+
|
|
38
|
+
- Never write secrets, tokens, API keys, or environment variables into `.md` files.
|
|
39
|
+
- On any LLM call failure: skip that candidate, log to stderr, continue.
|
|
40
|
+
- On tool call failure: skip; state unchanged; next cycle retries.
|
|
41
|
+
- You have 120 seconds. If approaching the limit, exit cleanly; any completed writes are durable.
|
|
42
|
+
|
|
43
|
+
## Tool scope
|
|
44
|
+
|
|
45
|
+
You have access only to: `memory_search`, `file_read`, `file_write`, `file_delete`, `reflexio_write_profile`, `reflexio_write_playbook`, `reflexio_search`. You do NOT have `sessions_spawn`, `web`, or network tools.
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// Reflexio Embedded — pure handler logic.
|
|
2
|
+
//
|
|
3
|
+
// This module is intentionally decoupled from the Openclaw SDK so that:
|
|
4
|
+
// 1. The TTL sweep / transcript serialization logic is easy to unit-test via
|
|
5
|
+
// `smoke-test.js` without spinning up a gateway.
|
|
6
|
+
// 2. Swapping the SDK wiring (see ../index.ts) never requires touching the
|
|
7
|
+
// behavioural code here.
|
|
8
|
+
import * as fs from "node:fs";
|
|
9
|
+
import * as path from "node:path";
|
|
10
|
+
|
|
11
|
+
/** Minimal subset of the Openclaw runtime we actually use. */
|
|
12
|
+
type SubagentRuntime = {
|
|
13
|
+
subagent?: {
|
|
14
|
+
run: (params: {
|
|
15
|
+
sessionKey: string;
|
|
16
|
+
message: string;
|
|
17
|
+
extraSystemPrompt?: string;
|
|
18
|
+
lane?: string;
|
|
19
|
+
idempotencyKey?: string;
|
|
20
|
+
}) => Promise<{ runId: string }>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type Logger = {
|
|
25
|
+
info?: (msg: string) => void;
|
|
26
|
+
warn?: (msg: string) => void;
|
|
27
|
+
error?: (msg: string) => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Find the workspace root. Openclaw passes it via ctx.workspaceDir; fall back
|
|
32
|
+
* to the WORKSPACE env var (handy for smoke tests) and finally process.cwd().
|
|
33
|
+
*/
|
|
34
|
+
export function resolveWorkspace(hint?: string): string {
|
|
35
|
+
if (hint && hint.trim()) return hint;
|
|
36
|
+
if (process.env.WORKSPACE) return process.env.WORKSPACE;
|
|
37
|
+
return process.cwd();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* TTL sweep: scan .reflexio/profiles/*.md and unlink expired files.
|
|
42
|
+
* Cheap: filesystem + YAML frontmatter parse only. Target <50ms for dozens of files.
|
|
43
|
+
*/
|
|
44
|
+
export async function ttlSweepProfiles(workspaceHint?: string): Promise<void> {
|
|
45
|
+
const workspace = resolveWorkspace(workspaceHint);
|
|
46
|
+
const dir = path.join(workspace, ".reflexio", "profiles");
|
|
47
|
+
if (!fs.existsSync(dir)) return;
|
|
48
|
+
|
|
49
|
+
const today = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
|
|
50
|
+
const entries = await fs.promises.readdir(dir);
|
|
51
|
+
|
|
52
|
+
for (const entry of entries) {
|
|
53
|
+
if (!entry.endsWith(".md")) continue;
|
|
54
|
+
const full = path.join(dir, entry);
|
|
55
|
+
let contents: string;
|
|
56
|
+
try {
|
|
57
|
+
contents = await fs.promises.readFile(full, "utf8");
|
|
58
|
+
} catch {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const expiresMatch = /^expires:\s*(\S+)/m.exec(contents);
|
|
62
|
+
if (!expiresMatch) continue;
|
|
63
|
+
const expires = expiresMatch[1];
|
|
64
|
+
if (expires === "never") continue;
|
|
65
|
+
if (expires < today) {
|
|
66
|
+
try {
|
|
67
|
+
await fs.promises.unlink(full);
|
|
68
|
+
} catch (err) {
|
|
69
|
+
console.error(
|
|
70
|
+
`[reflexio-embedded] ttl sweep: failed to unlink ${full}: ${err}`,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Short system-prompt reminder injected on every agent run so the LLM knows
|
|
79
|
+
* the Reflexio SKILL.md is available.
|
|
80
|
+
*/
|
|
81
|
+
export function injectBootstrapReminder(): string {
|
|
82
|
+
return [
|
|
83
|
+
"# Reflexio Embedded",
|
|
84
|
+
"",
|
|
85
|
+
"This agent has the openclaw-embedded plugin installed. Its SKILL.md",
|
|
86
|
+
"describes how to capture user facts and corrections into .reflexio/.",
|
|
87
|
+
"",
|
|
88
|
+
"Load the skill when: user states a preference/fact/config, user corrects",
|
|
89
|
+
"you and later confirms the fix, or you need to retrieve past context.",
|
|
90
|
+
].join("\n");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type TranscriptMessage = {
|
|
94
|
+
role?: string;
|
|
95
|
+
content?: unknown;
|
|
96
|
+
timestamp?: string;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** Decide whether the current transcript is worth extracting from. */
|
|
100
|
+
function transcriptWorthExtracting(messages: unknown[] | undefined): boolean {
|
|
101
|
+
if (!Array.isArray(messages) || messages.length < 2) return false;
|
|
102
|
+
return messages.some((m) => (m as TranscriptMessage).role === "user");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Serialize transcript into a plain-text form suitable for the sub-agent task prompt. */
|
|
106
|
+
function serializeTranscript(messages: unknown[] | undefined): string {
|
|
107
|
+
if (!Array.isArray(messages)) return "";
|
|
108
|
+
return messages
|
|
109
|
+
.map((raw) => {
|
|
110
|
+
const m = raw as TranscriptMessage;
|
|
111
|
+
const role = m.role ?? "unknown";
|
|
112
|
+
const content =
|
|
113
|
+
typeof m.content === "string" ? m.content : JSON.stringify(m.content);
|
|
114
|
+
const ts = m.timestamp ? ` [${m.timestamp}]` : "";
|
|
115
|
+
return `### ${role}${ts}\n${content}`;
|
|
116
|
+
})
|
|
117
|
+
.join("\n\n");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Build the task prompt handed to the reflexio-extractor sub-agent. The
|
|
122
|
+
* sub-agent's system prompt already contains its workflow (from
|
|
123
|
+
* agents/reflexio-extractor.md). This prompt just provides the transcript and
|
|
124
|
+
* reminds it of its job.
|
|
125
|
+
*/
|
|
126
|
+
function buildExtractionTaskPrompt(
|
|
127
|
+
messages: unknown[] | undefined,
|
|
128
|
+
sessionFile: string | undefined,
|
|
129
|
+
): string {
|
|
130
|
+
const parts = [
|
|
131
|
+
"Run your extraction workflow on the recent transcript.",
|
|
132
|
+
"",
|
|
133
|
+
"Follow your system prompt: extract profiles and playbooks, then run shallow pairwise dedup against existing .reflexio/ entries.",
|
|
134
|
+
"",
|
|
135
|
+
];
|
|
136
|
+
const transcript = serializeTranscript(messages);
|
|
137
|
+
if (transcript) {
|
|
138
|
+
parts.push("## Transcript", "", transcript);
|
|
139
|
+
} else if (sessionFile) {
|
|
140
|
+
parts.push(
|
|
141
|
+
"## Transcript",
|
|
142
|
+
"",
|
|
143
|
+
`The transcript lives on disk at: ${sessionFile}`,
|
|
144
|
+
"Read that file to reconstruct the session.",
|
|
145
|
+
);
|
|
146
|
+
} else {
|
|
147
|
+
parts.push(
|
|
148
|
+
"## Transcript",
|
|
149
|
+
"",
|
|
150
|
+
"No in-memory transcript is available for this event; skip if you cannot find a session file.",
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return parts.join("\n");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export type SpawnExtractorParams = {
|
|
157
|
+
runtime: SubagentRuntime | undefined;
|
|
158
|
+
workspaceDir?: string;
|
|
159
|
+
sessionKey?: string;
|
|
160
|
+
messages?: unknown[];
|
|
161
|
+
sessionFile?: string;
|
|
162
|
+
extraSystemPrompt?: string;
|
|
163
|
+
log?: Logger;
|
|
164
|
+
reason: string;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Fire-and-forget spawn of the reflexio-extractor sub-agent. The caller should
|
|
169
|
+
* NOT await the run itself — Openclaw manages the lifecycle via its Background
|
|
170
|
+
* Tasks ledger.
|
|
171
|
+
*
|
|
172
|
+
* Returns the runId when the spawn succeeds (caller can await the spawn to be
|
|
173
|
+
* sure the request reached the runtime, but not the sub-agent's completion).
|
|
174
|
+
*/
|
|
175
|
+
export async function spawnExtractor(
|
|
176
|
+
params: SpawnExtractorParams,
|
|
177
|
+
): Promise<string | undefined> {
|
|
178
|
+
const { runtime, sessionKey, messages, sessionFile, extraSystemPrompt, log, reason } = params;
|
|
179
|
+
|
|
180
|
+
if (!transcriptWorthExtracting(messages) && !sessionFile) {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
const runFn = runtime?.subagent?.run;
|
|
184
|
+
if (!runFn) {
|
|
185
|
+
log?.warn?.(
|
|
186
|
+
"[reflexio-embedded] runtime.subagent.run unavailable; skipping extraction",
|
|
187
|
+
);
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Session-key namespacing: each extractor run gets its own sub-session so
|
|
192
|
+
// the parent session transcript is not polluted.
|
|
193
|
+
const childSessionKey = `reflexio-extractor:${sessionKey ?? "unknown"}:${Date.now()}`;
|
|
194
|
+
const message = buildExtractionTaskPrompt(messages, sessionFile);
|
|
195
|
+
|
|
196
|
+
try {
|
|
197
|
+
const result = await runFn({
|
|
198
|
+
sessionKey: childSessionKey,
|
|
199
|
+
message,
|
|
200
|
+
extraSystemPrompt,
|
|
201
|
+
lane: "reflexio-extractor",
|
|
202
|
+
idempotencyKey: `reflexio-extractor:${sessionKey ?? "unknown"}:${reason}`,
|
|
203
|
+
});
|
|
204
|
+
log?.info?.(
|
|
205
|
+
`[reflexio-embedded] extractor spawned (runId=${result.runId}, reason=${reason})`,
|
|
206
|
+
);
|
|
207
|
+
return result.runId;
|
|
208
|
+
} catch (err) {
|
|
209
|
+
log?.error?.(
|
|
210
|
+
`[reflexio-embedded] failed to spawn extractor (reason=${reason}): ${err}`,
|
|
211
|
+
);
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Workspace auto-setup.
|
|
2
|
+
//
|
|
3
|
+
// On first load after install, appends the heartbeat consolidation check
|
|
4
|
+
// to the workspace HEARTBEAT.md. Skills are served from the extension dir
|
|
5
|
+
// via the manifest's "skills" field. Agents are injected via extraSystemPrompt.
|
|
6
|
+
// No workspace file copying needed — everything lives in the extension dir.
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as os from "node:os";
|
|
9
|
+
import * as path from "node:path";
|
|
10
|
+
|
|
11
|
+
function resolveOpenclawHome(): string {
|
|
12
|
+
return process.env.OPENCLAW_HOME || path.join(os.homedir(), ".openclaw");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Strip all existing reflexio heartbeat blocks from content.
|
|
17
|
+
* Splits by double-newline into paragraphs and drops any containing the tool name.
|
|
18
|
+
*/
|
|
19
|
+
function stripReflexioHeartbeatBlocks(content: string): string {
|
|
20
|
+
const paragraphs = content.split(/\n\n+/);
|
|
21
|
+
const cleaned = paragraphs.filter(
|
|
22
|
+
(p) => !p.includes("reflexio_consolidation_check") && !p.includes("Reflexio Consolidation Check")
|
|
23
|
+
);
|
|
24
|
+
return cleaned.join("\n\n").trim();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Append HEARTBEAT.md content to the workspace. Idempotent — strips all
|
|
29
|
+
* existing reflexio blocks first, then appends one canonical block.
|
|
30
|
+
*
|
|
31
|
+
* @param pluginDir - The plugin's install directory (import.meta.dirname)
|
|
32
|
+
*/
|
|
33
|
+
export function setupWorkspaceResources(pluginDir: string): void {
|
|
34
|
+
const workspace = path.join(resolveOpenclawHome(), "workspace");
|
|
35
|
+
|
|
36
|
+
const heartbeatSrc = path.join(pluginDir, "HEARTBEAT.md");
|
|
37
|
+
const heartbeatDest = path.join(workspace, "HEARTBEAT.md");
|
|
38
|
+
if (!fs.existsSync(heartbeatSrc)) return;
|
|
39
|
+
|
|
40
|
+
const heartbeatContent = fs.readFileSync(heartbeatSrc, "utf8");
|
|
41
|
+
|
|
42
|
+
let existing = "";
|
|
43
|
+
try {
|
|
44
|
+
existing = fs.readFileSync(heartbeatDest, "utf8");
|
|
45
|
+
} catch {
|
|
46
|
+
// file doesn't exist yet
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Always strip existing reflexio blocks (handles duplicates from prior installs),
|
|
50
|
+
// then append one canonical block
|
|
51
|
+
const cleaned = stripReflexioHeartbeatBlocks(existing);
|
|
52
|
+
const final = cleaned + (cleaned ? "\n\n" : "") + heartbeatContent;
|
|
53
|
+
fs.mkdirSync(workspace, { recursive: true });
|
|
54
|
+
fs.writeFileSync(heartbeatDest, final, "utf8");
|
|
55
|
+
}
|