claude-smart 0.2.45 → 0.2.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +3 -3
- package/README.md +47 -10
- package/bin/claude-smart.js +535 -23
- package/package.json +22 -3
- package/plugin/.claude-plugin/plugin.json +4 -2
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/README.md +27 -6
- package/plugin/commands/clear-all.md +1 -0
- package/plugin/commands/dashboard.md +1 -0
- package/plugin/commands/learn.md +1 -0
- package/plugin/commands/restart.md +1 -0
- package/plugin/commands/show.md +1 -0
- package/plugin/dashboard/app/configure/env/page.tsx +40 -14
- package/plugin/dashboard/app/configure/server/page.tsx +51 -1
- package/plugin/dashboard/app/layout.tsx +20 -0
- package/plugin/dashboard/app/preferences/[id]/page.tsx +8 -8
- package/plugin/dashboard/app/skills/project/[id]/page.tsx +7 -3
- package/plugin/dashboard/app/skills/shared/[id]/page.tsx +10 -3
- package/plugin/dashboard/lib/claude-settings-file.ts +20 -10
- package/plugin/dashboard/lib/reflexio-client.ts +16 -0
- package/plugin/dashboard/lib/status.ts +10 -3
- package/plugin/dashboard/lib/types.ts +18 -6
- package/plugin/hooks/codex-hooks.json +0 -1
- package/plugin/opencode/assistant-buffer.ts +108 -0
- package/plugin/opencode/dist/assistant-buffer.js +96 -0
- package/plugin/opencode/dist/internal.js +12 -0
- package/plugin/opencode/dist/payload.js +85 -0
- package/plugin/opencode/dist/server.mjs +232 -0
- package/plugin/opencode/internal.ts +18 -0
- package/plugin/opencode/package.json +3 -0
- package/plugin/opencode/payload.ts +90 -0
- package/plugin/opencode/server.mts +251 -0
- package/plugin/opencode/tsconfig.json +13 -0
- package/plugin/pyproject.toml +25 -4
- package/plugin/scripts/_lib.sh +5 -1
- package/plugin/scripts/backend-service.sh +22 -2
- package/plugin/scripts/ensure-plugin-root.sh +4 -4
- package/plugin/scripts/hook_entry.sh +1 -1
- package/plugin/scripts/opencode-claude-compat +4 -0
- package/plugin/scripts/opencode-claude-compat.cmd +3 -0
- package/plugin/scripts/opencode-claude-compat.js +225 -0
- package/plugin/scripts/smart-install.sh +17 -9
- package/plugin/src/README.md +1 -1
- package/plugin/src/claude_smart/cli.py +498 -12
- package/plugin/src/claude_smart/context_format.py +9 -9
- package/plugin/src/claude_smart/cs_cite.py +66 -19
- package/plugin/src/claude_smart/env_config.py +12 -4
- package/plugin/src/claude_smart/events/session_start.py +26 -7
- package/plugin/src/claude_smart/events/stop.py +1 -1
- package/plugin/src/claude_smart/ids.py +1 -1
- package/plugin/src/claude_smart/reflexio_adapter.py +5 -5
- package/plugin/src/claude_smart/runtime.py +7 -1
- package/plugin/uv.lock +5 -5
- package/plugin/vendor/reflexio/.env.example +54 -30
- package/plugin/vendor/reflexio/README.md +17 -11
- package/plugin/vendor/reflexio/pyproject.toml +13 -1
- package/plugin/vendor/reflexio/reflexio/README.md +4 -1
- package/plugin/vendor/reflexio/reflexio/cli/README.md +9 -7
- package/plugin/vendor/reflexio/reflexio/cli/__main__.py +10 -1
- package/plugin/vendor/reflexio/reflexio/cli/bootstrap_config.py +22 -5
- package/plugin/vendor/reflexio/reflexio/cli/commands/interactions.py +34 -4
- package/plugin/vendor/reflexio/reflexio/cli/commands/profiles.py +12 -7
- package/plugin/vendor/reflexio/reflexio/cli/commands/services.py +13 -6
- package/plugin/vendor/reflexio/reflexio/cli/commands/setup_cmd.py +212 -52
- package/plugin/vendor/reflexio/reflexio/cli/commands/shortcuts.py +15 -2
- package/plugin/vendor/reflexio/reflexio/cli/env_loader.py +292 -22
- package/plugin/vendor/reflexio/reflexio/cli/log_format.py +29 -4
- package/plugin/vendor/reflexio/reflexio/cli/run_services.py +17 -8
- package/plugin/vendor/reflexio/reflexio/cli/stop_services.py +13 -10
- package/plugin/vendor/reflexio/reflexio/cli/utils.py +44 -1
- package/plugin/vendor/reflexio/reflexio/client/client.py +154 -13
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/README.md +135 -257
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/npm/openclaw-smart/bin/openclaw-smart.js +13 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/npm/openclaw-smart/package.json +15 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/README.md +38 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/index.ts +151 -110
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/openclaw.plugin.json +20 -10
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/package.json +28 -6
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/pyproject.toml +42 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/_lib.sh +371 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/backend-log-runner.sh +33 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/backend-service.sh +271 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/cli.sh +68 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/dashboard-open.sh +15 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/ensure-plugin-root.sh +84 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/hook_entry.sh +106 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/npm-cli.js +219 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/scripts/smart-install.sh +269 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/clear-all/SKILL.md +8 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/dashboard/SKILL.md +8 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/learn/SKILL.md +10 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/reflexio/SKILL.md +15 -44
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/restart/SKILL.md +6 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/skills/show/SKILL.md +8 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/cli.py +634 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/context_format.py +224 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/context_inject.py +79 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/after_tool_call.py +160 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/agent_end.py +187 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/before_prompt_build.py +69 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/before_tool_call.py +30 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/session_end.py +36 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/events/session_start.py +130 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/hook.py +131 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/ids.py +94 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/internal_call.py +75 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/oc_cite.py +196 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/optimizer_assistant.py +272 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/publish.py +96 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/query_compose.py +66 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/reflexio_adapter.py +336 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/runtime.py +47 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/stall_banner.py +61 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/src/openclaw_smart/state.py +323 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_e2e_session_loop.py +190 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_publish_to_local_reflexio_integration.py +112 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_recursion_guard_integration.py +86 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/integration/test_search_inject_integration.py +144 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_cli.py +184 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_after_tool_call.py +142 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_agent_end.py +233 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_before_prompt_build.py +116 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_before_tool_call.py +35 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_session_end.py +47 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_events_session_start.py +109 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_hook_dispatch.py +117 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_ids.py +41 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_internal_call.py +50 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_oc_cite.py +88 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_publish.py +48 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_query_compose.py +48 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_reflexio_adapter.py +188 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_runtime.py +41 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests/test_state.py +235 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/__mocks__/plugin-entry-stub.ts +6 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/test_npm_cli.test.ts +56 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tests-ts/test_shim_dispatch.test.ts +171 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/tsconfig.build.json +18 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/{tsconfig.json → plugin/tsconfig.json} +2 -2
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/uv.lock +3835 -0
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/vitest.config.ts +18 -0
- package/plugin/vendor/reflexio/reflexio/lib/_agent_playbook.py +246 -10
- package/plugin/vendor/reflexio/reflexio/lib/_base.py +15 -0
- package/plugin/vendor/reflexio/reflexio/lib/_config.py +11 -4
- package/plugin/vendor/reflexio/reflexio/lib/_generation.py +17 -5
- package/plugin/vendor/reflexio/reflexio/lib/_lineage_parity_readers.py +187 -0
- package/plugin/vendor/reflexio/reflexio/lib/_profiles.py +224 -21
- package/plugin/vendor/reflexio/reflexio/lib/_reflection.py +1 -1
- package/plugin/vendor/reflexio/reflexio/lib/_search.py +52 -25
- package/plugin/vendor/reflexio/reflexio/lib/_user_playbook.py +11 -1
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/entities.py +127 -38
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/enums.py +4 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/domain/governance.py +117 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/eval_overview_schema.py +64 -41
- package/plugin/vendor/reflexio/reflexio/models/api_schema/internal_schema.py +19 -0
- package/plugin/vendor/reflexio/reflexio/models/api_schema/pending_tool_call_schema.py +12 -5
- package/plugin/vendor/reflexio/reflexio/models/api_schema/retriever_schema.py +97 -3
- package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/converters.py +5 -1
- package/plugin/vendor/reflexio/reflexio/models/api_schema/ui/entities.py +5 -1
- package/plugin/vendor/reflexio/reflexio/models/config_schema.py +104 -7
- package/plugin/vendor/reflexio/reflexio/models/structured_output.py +148 -0
- package/plugin/vendor/reflexio/reflexio/server/OVERVIEW.md +3 -3
- package/plugin/vendor/reflexio/reflexio/server/README.md +58 -33
- package/plugin/vendor/reflexio/reflexio/server/__init__.py +29 -5
- package/plugin/vendor/reflexio/reflexio/server/__main__.py +2 -2
- package/plugin/vendor/reflexio/reflexio/server/api.py +899 -103
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/precondition_checks.py +7 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/request_context.py +4 -2
- package/plugin/vendor/reflexio/reflexio/server/auth.py +90 -0
- package/plugin/vendor/reflexio/reflexio/server/billing_meter.py +173 -0
- package/plugin/vendor/reflexio/reflexio/server/billing_signals.py +64 -0
- package/plugin/vendor/reflexio/reflexio/server/cache/reflexio_cache.py +46 -16
- package/plugin/vendor/reflexio/reflexio/server/env_utils.py +65 -0
- package/plugin/vendor/reflexio/reflexio/server/extensions.py +213 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/embedding_service.py +19 -4
- package/plugin/vendor/reflexio/reflexio/server/llm/litellm_client.py +264 -77
- package/plugin/vendor/reflexio/reflexio/server/llm/llm_utils.py +69 -7
- package/plugin/vendor/reflexio/reflexio/server/llm/model_defaults.py +4 -4
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/claude_code_provider.py +1 -1
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/embedding_service_provider.py +75 -16
- package/plugin/vendor/reflexio/reflexio/server/llm/providers/openclaw_provider.py +280 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/rerank/cross_encoder_reranker.py +12 -1
- package/plugin/vendor/reflexio/reflexio/server/llm/token_accounting.py +48 -0
- package/plugin/vendor/reflexio/reflexio/server/llm/tools.py +107 -17
- package/plugin/vendor/reflexio/reflexio/server/operation_limiter.py +360 -4
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.6.0.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/memory_reflection/v1.7.0.prompt.md +85 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.2.0.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_aggregation/v2.3.0.prompt.md +253 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.2.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_consolidation/v2.3.3.prompt.md +74 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.2.3.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.3.0.prompt.md +266 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context/v4.4.0.prompt.md +278 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.3.0.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_context_expert/v3.4.0.prompt.md +137 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.2.0.prompt.md +1 -1
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/playbook_extraction_main/v1.3.0.prompt.md +34 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.0.0.prompt.md +5 -12
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.1.0.prompt.md +5 -12
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/profile_update_instruction_start/v1.2.0.prompt.md +155 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_bank/tagging/v1.0.0.prompt.md +23 -0
- package/plugin/vendor/reflexio/reflexio/server/prompt/prompt_manager.py +89 -32
- package/plugin/vendor/reflexio/reflexio/server/services/README.md +28 -11
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/README.md +22 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_constants.py +4 -2
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/agent_success_evaluation_utils.py +1 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/components/__init__.py +7 -0
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{agent_success_evaluator.py → components/evaluator.py} +3 -16
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/regen_jobs.py +28 -72
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{group_evaluation_runner.py → runner.py} +12 -10
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{delayed_group_evaluator.py → scheduler.py} +10 -2
- package/plugin/vendor/reflexio/reflexio/server/services/agent_success_evaluation/{agent_success_evaluation_service.py → service.py} +36 -1
- package/plugin/vendor/reflexio/reflexio/server/services/base_generation_service.py +160 -0
- package/plugin/vendor/reflexio/reflexio/server/services/configurator/base_configurator.py +5 -0
- package/plugin/vendor/reflexio/reflexio/server/services/deduplication_utils.py +1 -1
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/README.md +9 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/components/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{rule_attribution.py → components/rule_attribution.py} +10 -9
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/eval_sampler.py +15 -24
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/service.py +238 -164
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/README.md +31 -0
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/outcome.py +13 -3
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/pending_tool_call_dispatch.py +3 -2
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/resumable_agent.py +32 -118
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/resume_worker.py +47 -16
- package/plugin/vendor/reflexio/reflexio/server/services/generation_service.py +105 -23
- package/plugin/vendor/reflexio/reflexio/server/services/governance/config.py +52 -0
- package/plugin/vendor/reflexio/reflexio/server/services/governance/service.py +378 -0
- package/plugin/vendor/reflexio/reflexio/server/services/governance/subject_refs.py +34 -0
- package/plugin/vendor/reflexio/reflexio/server/services/lineage/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/lineage/gc_scheduler.py +219 -0
- package/plugin/vendor/reflexio/reflexio/server/services/lineage/resolve.py +98 -0
- package/plugin/vendor/reflexio/reflexio/server/services/operation_state_utils.py +26 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/README.md +18 -11
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/aggregation_prompt_processing.py +100 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/components/__init__.py +5 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_aggregator.py → components/aggregator.py} +334 -178
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_consolidator.py → components/consolidator.py} +168 -62
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_extractor.py → components/extractor.py} +5 -1
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_edit_apply.py +74 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/playbook_service_utils.py +33 -3
- package/plugin/vendor/reflexio/reflexio/server/services/playbook/{playbook_generation_service.py → service.py} +121 -19
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/README.md +10 -0
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/models.py +2 -1
- package/plugin/vendor/reflexio/reflexio/server/services/playbook_optimizer/optimizer.py +178 -30
- package/plugin/vendor/reflexio/reflexio/server/services/pre_retrieval/README.md +9 -0
- package/plugin/vendor/reflexio/reflexio/server/services/profile/components/__init__.py +17 -0
- package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_deduplicator.py → components/consolidator.py} +7 -6
- package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_extractor.py → components/extractor.py} +31 -22
- package/plugin/vendor/reflexio/reflexio/server/services/profile/profile_generation_service_utils.py +6 -13
- package/plugin/vendor/reflexio/reflexio/server/services/profile/{profile_generation_service.py → service.py} +32 -50
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/__init__.py +4 -8
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/components/__init__.py +7 -0
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/reflection_service_utils.py +12 -1
- package/plugin/vendor/reflexio/reflexio/server/services/reflection/{reflection_service.py → service.py} +36 -16
- package/plugin/vendor/reflexio/reflexio/server/services/retrieval/recency.py +211 -0
- package/plugin/vendor/reflexio/reflexio/server/services/retrieval/relevance_floor.py +99 -6
- package/plugin/vendor/reflexio/reflexio/server/services/service_utils.py +36 -1
- package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/README.md +8 -0
- package/plugin/vendor/reflexio/reflexio/server/services/shadow_comparison/outcome.py +1 -2
- package/plugin/vendor/reflexio/reflexio/server/services/storage/error.py +31 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/governance_validation.py +681 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/retention.py +9 -9
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/__init__.py +16 -2
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_agent_run.py +4 -1
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_base.py +644 -197
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_extras.py +106 -119
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_governance.py +1965 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_lineage.py +630 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_operations.py +38 -6
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_playbook.py +31 -1369
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_profiles.py +756 -210
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_requests.py +148 -34
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_shadow_verdicts.py +23 -9
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_stall_state.py +5 -2
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/__init__.py +13 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_agent.py +952 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_eval_results.py +189 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_optimization.py +247 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_source_linkage.py +145 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/playbook/_user.py +838 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/__init__.py +150 -23
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_agent_run.py +2 -8
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_base.py +5 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_extras.py +40 -57
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_governance.py +148 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_lineage.py +215 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_operations.py +20 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_playbook.py +4 -677
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_profiles.py +134 -1
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_requests.py +62 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_retrieval_log.py +51 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_shadow_verdicts.py +17 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/__init__.py +13 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_agent.py +365 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_eval_results.py +124 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_optimization.py +85 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_source_linkage.py +47 -0
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/playbook/_user.py +333 -0
- package/plugin/vendor/reflexio/reflexio/server/services/tagging/README.md +8 -0
- package/plugin/vendor/reflexio/reflexio/server/services/tagging/__init__.py +1 -0
- package/plugin/vendor/reflexio/reflexio/server/services/tagging/service.py +200 -0
- package/plugin/vendor/reflexio/reflexio/server/services/tagging/tagging_scheduler.py +149 -0
- package/plugin/vendor/reflexio/reflexio/server/services/unified_search_service.py +372 -34
- package/plugin/vendor/reflexio/reflexio/server/site_var/README.md +2 -1
- package/plugin/vendor/reflexio/reflexio/server/site_var/feature_flags.py +120 -1
- package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/feature_flags.json +4 -0
- package/plugin/vendor/reflexio/reflexio/server/site_var/site_var_sources/search_settings.json +5 -0
- package/plugin/vendor/reflexio/reflexio/server/tracing.py +30 -0
- package/plugin/vendor/reflexio/reflexio/server/usage_metrics.py +18 -0
- package/plugin/vendor/reflexio/reflexio/test_support/llm_mock.py +61 -26
- package/plugin/vendor/reflexio/reflexio/test_support/llm_model_registry.py +41 -4
- package/scripts/setup-claude-smart.sh +8 -3
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/TESTING.md +0 -517
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/hook/handler.js +0 -473
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package-lock.json +0 -2156
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/package.json +0 -18
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/handler.ts +0 -241
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/hook/setup.ts +0 -140
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/publish.ts +0 -113
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/search.ts +0 -52
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/server.ts +0 -103
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/sqlite-buffer.ts +0 -156
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/lib/user-id.ts +0 -134
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/plugin/rules/reflexio.md +0 -24
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/publish_clawhub.sh +0 -278
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/references/HOOK.md +0 -164
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/install.sh +0 -36
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/scripts/uninstall.sh +0 -35
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/publish.test.ts +0 -27
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/search.test.ts +0 -31
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/server.test.ts +0 -42
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/setup.test.ts +0 -49
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/sqlite-buffer.test.ts +0 -91
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/tests/user-id.test.ts +0 -50
- package/plugin/vendor/reflexio/reflexio/integrations/openclaw/vitest.config.ts +0 -13
- package/plugin/vendor/reflexio/reflexio/server/_auth.py +0 -25
- package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/group_aggregation.py +0 -192
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/invariants.py +0 -303
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/plan.py +0 -138
- package/plugin/vendor/reflexio/reflexio/server/services/extraction/tools.py +0 -1125
- /package/plugin/vendor/reflexio/reflexio/integrations/{__init__.py → openclaw/plugin/src/openclaw_smart/__init__.py} +0 -0
- /package/plugin/vendor/reflexio/reflexio/integrations/openclaw/{types → plugin/types}/openclaw.d.ts +0 -0
- /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{distribution.py → components/distribution.py} +0 -0
- /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{hero_state.py → components/hero_state.py} +0 -0
- /package/plugin/vendor/reflexio/reflexio/server/services/evaluation_overview/{shadow_aggregation.py → components/shadow_aggregation.py} +0 -0
- /package/plugin/vendor/reflexio/reflexio/server/services/reflection/{reflection_extractor.py → components/extractor.py} +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: reflexio-federated-plugin
|
|
3
|
-
description: "Automatically capture conversations and inject cross-session context before every response"
|
|
4
|
-
metadata:
|
|
5
|
-
openclaw:
|
|
6
|
-
emoji: "🧠"
|
|
7
|
-
hooks: ["before_prompt_build", "message_sent", "before_compaction", "before_reset", "session_end"]
|
|
8
|
-
requires:
|
|
9
|
-
bins: ["reflexio"]
|
|
10
|
-
env: ["REFLEXIO_USER_ID", "REFLEXIO_AGENT_VERSION"]
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
# Reflexio Federated Plugin
|
|
14
|
-
|
|
15
|
-
The plugin is the core component that enables automatic conversation capture and cross-session context injection. It is implemented against the **Openclaw Plugin SDK** (`openclaw/plugin-sdk`) and runs on every agent session, persisting data to a local SQLite buffer.
|
|
16
|
-
|
|
17
|
-
## Plugin SDK Hooks
|
|
18
|
-
|
|
19
|
-
The plugin registers the following hooks via `api.on(...)` in the Plugin SDK:
|
|
20
|
-
|
|
21
|
-
### `before_prompt_build` (before each response)
|
|
22
|
-
|
|
23
|
-
Fires before the agent builds its next response. This is the primary hook — it handles:
|
|
24
|
-
|
|
25
|
-
1. **First-use setup check** — detects whether the `reflexio` CLI is installed and configured. If setup is needed, injects a setup instruction into the system context.
|
|
26
|
-
2. **Server auto-start** — checks if the local Reflexio server is healthy via a health check; if not, spawns `reflexio services start --only backend` in the background.
|
|
27
|
-
3. **Retry unpublished turns** — publishes any buffered turns from previous sessions that failed to reach the server.
|
|
28
|
-
4. **Search injection** — runs `reflexio search` on the user's message and, if results are found, prepends them as system context before the agent responds. Skips search for trivial/short inputs to reduce noise. Times out after `search.timeout_ms` (default: 5 000 ms) — never blocks the response.
|
|
29
|
-
|
|
30
|
-
### `message_sent` (each turn)
|
|
31
|
-
|
|
32
|
-
Fires after the agent sends a response. Buffers the (user message, agent response) pair into local SQLite at `~/.reflexio/sessions.db`. Lightweight local write — no network calls. If the buffer exceeds `publish.batch_size * 2` unpublished turns, triggers an incremental publish to the server.
|
|
33
|
-
|
|
34
|
-
### `before_compaction` (before transcript compaction)
|
|
35
|
-
|
|
36
|
-
Fires before Openclaw compacts the transcript. Flushes all unpublished buffered turns to the Reflexio server so no data is lost when the compaction discards history.
|
|
37
|
-
|
|
38
|
-
### `before_reset` (before transcript wipe)
|
|
39
|
-
|
|
40
|
-
Fires before Openclaw wipes the transcript (e.g., `/reset`). Same as `before_compaction` — flushes all remaining unpublished turns.
|
|
41
|
-
|
|
42
|
-
### `session_end` (session end)
|
|
43
|
-
|
|
44
|
-
Fires when the session ends. Performs a final flush of all remaining buffered turns to the Reflexio server.
|
|
45
|
-
|
|
46
|
-
## Tool: `reflexio_publish`
|
|
47
|
-
|
|
48
|
-
In addition to hooks, the plugin registers one agent-invocable tool:
|
|
49
|
-
|
|
50
|
-
- **`reflexio_publish`** — immediately flushes all buffered conversation turns to the Reflexio server. Useful after user corrections or high-signal moments when automatic session-end flushing would be too late.
|
|
51
|
-
|
|
52
|
-
> **Single-session limitation:** The `execute` callback in the Plugin SDK does not receive session context, so this tool always targets the most recently active session. Concurrent multi-session use is not supported.
|
|
53
|
-
|
|
54
|
-
## Prerequisites
|
|
55
|
-
|
|
56
|
-
1. **`reflexio` CLI on PATH** — `pipx install reflexio-ai` or `pip install --user reflexio-ai`. The plugin shells out to this CLI to start the backend server and publish conversations.
|
|
57
|
-
|
|
58
|
-
2. **Node.js 18+** — Required to run the plugin.
|
|
59
|
-
|
|
60
|
-
3. **An LLM provider API key in `~/.reflexio/.env`** — Required for the backend server to extract playbooks and profiles. The first-use setup wizard prompts you to configure this on the first agent session.
|
|
61
|
-
|
|
62
|
-
## Configuration
|
|
63
|
-
|
|
64
|
-
All settings are optional and defined in `plugin/openclaw.plugin.json` under the `configSchema`:
|
|
65
|
-
|
|
66
|
-
### `publish` — Conversation capture and publish behavior
|
|
67
|
-
|
|
68
|
-
```json
|
|
69
|
-
"publish": {
|
|
70
|
-
"batch_size": 10, // Number of turns to buffer before mid-session publish
|
|
71
|
-
"max_retries": 3, // Retry count for failed publish attempts
|
|
72
|
-
"max_content_length": 10000 // Max characters per turn (prevents oversized payloads)
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### `search` — Context injection before each response
|
|
77
|
-
|
|
78
|
-
```json
|
|
79
|
-
"search": {
|
|
80
|
-
"timeout_ms": 5000, // Max time to wait for search results
|
|
81
|
-
"top_k": 5, // Number of playbooks to return per search
|
|
82
|
-
"min_prompt_length": 5 // Skip search for inputs shorter than this
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### `server` — Reflexio server health and startup
|
|
87
|
-
|
|
88
|
-
```json
|
|
89
|
-
"server": {
|
|
90
|
-
"health_check_timeout_ms": 3000, // Time limit for health checks
|
|
91
|
-
"stale_flag_ms": 120000 // Flag file age before retry (2 minutes)
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Security and Privacy
|
|
96
|
-
|
|
97
|
-
### What the plugin reads
|
|
98
|
-
|
|
99
|
-
- **Environment variables**: `REFLEXIO_USER_ID` (overrides auto-derived user ID) and `REFLEXIO_AGENT_VERSION` (overrides agent version label). Both are optional.
|
|
100
|
-
- **`~/.openclaw/openclaw.json`**: read by the Openclaw host process to load the plugin; the plugin itself does not read this file directly.
|
|
101
|
-
- **`~/.reflexio/.env`**: read to resolve `REFLEXIO_URL` if the env var is not set in the process environment.
|
|
102
|
-
|
|
103
|
-
### What the plugin shells out to
|
|
104
|
-
|
|
105
|
-
The plugin spawns the `reflexio` CLI for:
|
|
106
|
-
- `reflexio services start --only backend` — starts the local server if not running
|
|
107
|
-
- `reflexio search <query>` — fetches context from the local server
|
|
108
|
-
- `reflexio interactions publish --file <payload.json>` — publishes buffered turns
|
|
109
|
-
|
|
110
|
-
All spawned processes use the binary on your `PATH`. If `reflexio` is not found, the `error` event on the child process is caught, the affected turns are marked for retry, and the plugin continues working without blocking the agent.
|
|
111
|
-
|
|
112
|
-
### Network destinations
|
|
113
|
-
|
|
114
|
-
The plugin communicates only with the Reflexio server at the URL resolved from `REFLEXIO_URL` / `~/.reflexio/.env` / default `http://127.0.0.1:8081`. Local-server detection uses exact hostname matching (`127.0.0.1` or `localhost`); only local servers are auto-started.
|
|
115
|
-
|
|
116
|
-
**The local Reflexio server makes outbound LLM API calls** for profile/playbook extraction. The destination depends on your `~/.reflexio/.env` configuration (OpenAI, Anthropic, Gemini, or a local LLM). For a fully offline setup, configure a local LLM provider (Ollama, LM Studio, vLLM) during first-use setup.
|
|
117
|
-
|
|
118
|
-
## Buffering and Retry
|
|
119
|
-
|
|
120
|
-
The plugin uses SQLite to buffer conversations locally:
|
|
121
|
-
|
|
122
|
-
- **Location**: `~/.reflexio/sessions.db`
|
|
123
|
-
- **Retention**: Buffered turns are kept until successfully published to the server
|
|
124
|
-
- **Retry logic**: On every `before_prompt_build`, the plugin retries any unpublished sessions from previous runs (up to `max_retries`)
|
|
125
|
-
- **Graceful degradation**: If the server is down, the agent works normally and buffers persist
|
|
126
|
-
|
|
127
|
-
## Lifecycle Summary
|
|
128
|
-
|
|
129
|
-
| Hook | Trigger | Actions |
|
|
130
|
-
|------|---------|---------|
|
|
131
|
-
| `before_prompt_build` | Before each agent response | Setup check, server auto-start, retry old sessions, search injection |
|
|
132
|
-
| `message_sent` | After each agent response | Buffer turn to SQLite, incremental publish if batch threshold exceeded |
|
|
133
|
-
| `before_compaction` | Before transcript compaction | Flush all unpublished turns |
|
|
134
|
-
| `before_reset` | Before transcript wipe | Flush all unpublished turns |
|
|
135
|
-
| `session_end` | Session ends | Final flush of all remaining turns |
|
|
136
|
-
|
|
137
|
-
## Implementation
|
|
138
|
-
|
|
139
|
-
The plugin is implemented in TypeScript in `plugin/`:
|
|
140
|
-
|
|
141
|
-
- **`index.ts`** — SDK wiring: `definePluginEntry`, hook registration, tool registration
|
|
142
|
-
- **`hook/handler.ts`** — Core logic: `handleBeforePromptBuild`, `handleMessageSent`, `handleSessionFlush`, `handleToolPublish`
|
|
143
|
-
- **`hook/setup.ts`** — First-use setup: CLI detection, LLM provider prompt, server start
|
|
144
|
-
|
|
145
|
-
Supporting libraries in `plugin/lib/`:
|
|
146
|
-
|
|
147
|
-
- **`server.ts`** — URL resolution, health check, auto-start
|
|
148
|
-
- **`user-id.ts`** — User identity and agent version resolution from env vars / session key
|
|
149
|
-
- **`sqlite-buffer.ts`** — Turn buffering, retry management
|
|
150
|
-
- **`publish.ts`** — Payload construction, CLI spawn with error handling
|
|
151
|
-
- **`search.ts`** — Search invocation, result formatting, trivial-input filtering
|
|
152
|
-
|
|
153
|
-
## Debugging
|
|
154
|
-
|
|
155
|
-
All plugin log lines are prefixed with `[reflexio]` for easy filtering:
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
# Option A: capture stderr to file and tail it
|
|
159
|
-
openclaw chat 2>reflexio-plugin.log
|
|
160
|
-
tail -f reflexio-plugin.log | grep "\[reflexio\]"
|
|
161
|
-
|
|
162
|
-
# Option B: watch inline
|
|
163
|
-
openclaw chat 2>&1 | grep "\[reflexio\]"
|
|
164
|
-
```
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# reflexio-federated install.sh — plugin installation.
|
|
3
|
-
set -euo pipefail
|
|
4
|
-
|
|
5
|
-
PLUGIN_DIR="$(cd "$(dirname "$0")/../plugin" && pwd)"
|
|
6
|
-
OPENCLAW_HOME="${OPENCLAW_HOME:-$HOME/.openclaw}"
|
|
7
|
-
|
|
8
|
-
die() { echo "error: $*" >&2; exit 1; }
|
|
9
|
-
info() { echo "==> $*"; }
|
|
10
|
-
|
|
11
|
-
# 1. Prereq checks
|
|
12
|
-
info "Checking prerequisites..."
|
|
13
|
-
command -v openclaw >/dev/null || die "openclaw CLI required but not found on PATH"
|
|
14
|
-
command -v node >/dev/null || die "node required but not found on PATH"
|
|
15
|
-
|
|
16
|
-
# 2. Install the plugin
|
|
17
|
-
info "Installing plugin..."
|
|
18
|
-
openclaw plugins uninstall --force reflexio-federated 2>/dev/null || true
|
|
19
|
-
rm -rf "$OPENCLAW_HOME/extensions/reflexio-federated"
|
|
20
|
-
openclaw plugins install "$PLUGIN_DIR"
|
|
21
|
-
openclaw plugins enable reflexio-federated 2>/dev/null || true
|
|
22
|
-
|
|
23
|
-
# 3. Restart gateway
|
|
24
|
-
info "Restarting openclaw gateway..."
|
|
25
|
-
openclaw gateway restart
|
|
26
|
-
|
|
27
|
-
# 4. Verify
|
|
28
|
-
info "Verification:"
|
|
29
|
-
if openclaw plugins inspect reflexio-federated 2>/dev/null | grep -q "Status: loaded"; then
|
|
30
|
-
info " ✓ plugin registered and loaded"
|
|
31
|
-
else
|
|
32
|
-
die "Plugin did not reach 'loaded' status. Run 'openclaw plugins inspect reflexio-federated' to debug."
|
|
33
|
-
fi
|
|
34
|
-
|
|
35
|
-
info "Installation complete."
|
|
36
|
-
info "Reflexio setup (CLI install, storage config, server start) happens automatically on first agent session."
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# reflexio-federated uninstall.sh — reverses install.sh.
|
|
3
|
-
# Leaves ~/.reflexio/ user data intact unless --purge is passed.
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
OPENCLAW_HOME="${OPENCLAW_HOME:-$HOME/.openclaw}"
|
|
7
|
-
PURGE_DATA="${1:-}"
|
|
8
|
-
|
|
9
|
-
info() { echo "==> $*"; }
|
|
10
|
-
|
|
11
|
-
info "Disabling plugin..."
|
|
12
|
-
openclaw plugins disable reflexio-federated 2>/dev/null || echo "(already disabled)"
|
|
13
|
-
|
|
14
|
-
info "Uninstalling plugin..."
|
|
15
|
-
openclaw plugins uninstall --force reflexio-federated 2>/dev/null || echo "(already uninstalled)"
|
|
16
|
-
rm -rf "$OPENCLAW_HOME/extensions/reflexio-federated"
|
|
17
|
-
|
|
18
|
-
info "Cleaning up state files..."
|
|
19
|
-
rm -f "$HOME/.reflexio/sessions.db"
|
|
20
|
-
rm -f "$HOME/.reflexio/logs/.server-starting"
|
|
21
|
-
|
|
22
|
-
# Remove setup markers
|
|
23
|
-
find "$HOME/.reflexio/" -name ".setup_complete_*" -delete 2>/dev/null || true
|
|
24
|
-
|
|
25
|
-
if [[ "$PURGE_DATA" == "--purge" ]]; then
|
|
26
|
-
info "Purging ~/.reflexio/ user data per --purge flag..."
|
|
27
|
-
rm -rf "$HOME/.reflexio"
|
|
28
|
-
else
|
|
29
|
-
info "User data at ~/.reflexio/ preserved. Use --purge to delete it too."
|
|
30
|
-
fi
|
|
31
|
-
|
|
32
|
-
info "Restarting openclaw gateway..."
|
|
33
|
-
openclaw gateway restart || echo "warning: gateway restart failed — you may need to restart manually"
|
|
34
|
-
|
|
35
|
-
info "Uninstall complete."
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { buildPayload } from "../plugin/lib/publish.ts";
|
|
3
|
-
import type { Turn } from "../plugin/lib/sqlite-buffer.ts";
|
|
4
|
-
|
|
5
|
-
describe("buildPayload", () => {
|
|
6
|
-
it("builds correct JSON structure", () => {
|
|
7
|
-
const turns: Turn[] = [
|
|
8
|
-
{ id: 1, session_id: "s1", role: "user", content: "hello", timestamp: "2026-01-01T00:00:00Z", published: 0, retry_count: 0 },
|
|
9
|
-
{ id: 2, session_id: "s1", role: "assistant", content: "hi", timestamp: "2026-01-01T00:00:01Z", published: 0, retry_count: 0 },
|
|
10
|
-
];
|
|
11
|
-
const payload = buildPayload(turns, "user1", "openclaw-agent", "sess1");
|
|
12
|
-
const parsed = JSON.parse(payload);
|
|
13
|
-
expect(parsed.user_id).toBe("user1");
|
|
14
|
-
expect(parsed.source).toBe("openclaw");
|
|
15
|
-
expect(parsed.agent_version).toBe("openclaw-agent");
|
|
16
|
-
expect(parsed.session_id).toBe("sess1");
|
|
17
|
-
expect(parsed.interactions).toHaveLength(2);
|
|
18
|
-
expect(parsed.interactions[0].role).toBe("user");
|
|
19
|
-
expect(parsed.interactions[0].content).toBe("hello");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("returns empty interactions for empty turns", () => {
|
|
23
|
-
const payload = buildPayload([], "user1", "openclaw-agent", "sess1");
|
|
24
|
-
const parsed = JSON.parse(payload);
|
|
25
|
-
expect(parsed.interactions).toHaveLength(0);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { shouldSkipSearch, formatSearchContext } from "../plugin/lib/search.ts";
|
|
3
|
-
|
|
4
|
-
describe("shouldSkipSearch", () => {
|
|
5
|
-
it("skips short messages", () => {
|
|
6
|
-
expect(shouldSkipSearch("hi", 5)).toBe(true);
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it("skips trivial responses", () => {
|
|
10
|
-
expect(shouldSkipSearch("yes", 5)).toBe(true);
|
|
11
|
-
expect(shouldSkipSearch("ok", 5)).toBe(true);
|
|
12
|
-
expect(shouldSkipSearch("thanks", 5)).toBe(true);
|
|
13
|
-
expect(shouldSkipSearch("Sure", 5)).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("does not skip real messages", () => {
|
|
17
|
-
expect(shouldSkipSearch("Write a Python function to sort a list", 5)).toBe(false);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe("formatSearchContext", () => {
|
|
22
|
-
it("returns null for empty results", () => {
|
|
23
|
-
expect(formatSearchContext("")).toBeNull();
|
|
24
|
-
expect(formatSearchContext("Found 0 profiles, 0 playbooks")).toBeNull();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("returns trimmed content for real results", () => {
|
|
28
|
-
const result = formatSearchContext("## Playbooks\n- Use type hints");
|
|
29
|
-
expect(result).toBe("## Playbooks\n- Use type hints");
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { resolveServerUrl, isLocalServer } from "../plugin/lib/server.ts";
|
|
3
|
-
|
|
4
|
-
describe("resolveServerUrl", () => {
|
|
5
|
-
const originalEnv = process.env;
|
|
6
|
-
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
process.env = { ...originalEnv };
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
process.env = originalEnv;
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("returns REFLEXIO_URL env var when set", () => {
|
|
16
|
-
process.env.REFLEXIO_URL = "https://custom.server:9090";
|
|
17
|
-
expect(resolveServerUrl()).toBe("https://custom.server:9090");
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("returns default when no env var and no .env file", () => {
|
|
21
|
-
delete process.env.REFLEXIO_URL;
|
|
22
|
-
expect(resolveServerUrl()).toBe("http://127.0.0.1:8081");
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe("isLocalServer", () => {
|
|
27
|
-
it("returns true for localhost", () => {
|
|
28
|
-
expect(isLocalServer("http://localhost:8081")).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("returns true for 127.0.0.1", () => {
|
|
32
|
-
expect(isLocalServer("http://127.0.0.1:8081")).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("returns false for remote URL", () => {
|
|
36
|
-
expect(isLocalServer("https://reflexio.ai:8081")).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("returns false for localhost.evil.com", () => {
|
|
40
|
-
expect(isLocalServer("https://localhost.evil.com")).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import * as fs from "node:fs";
|
|
3
|
-
import * as os from "node:os";
|
|
4
|
-
import * as path from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
isSetupComplete,
|
|
7
|
-
markSetupComplete,
|
|
8
|
-
checkReflexioInstalled,
|
|
9
|
-
checkReflexioConfigured,
|
|
10
|
-
} from "../plugin/hook/setup.ts";
|
|
11
|
-
|
|
12
|
-
describe("isSetupComplete", () => {
|
|
13
|
-
let tmpDir: string;
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "reflexio-setup-test-"));
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("returns false when marker does not exist", () => {
|
|
24
|
-
expect(isSetupComplete(tmpDir, "main")).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("returns true after markSetupComplete", () => {
|
|
28
|
-
markSetupComplete(tmpDir, "main");
|
|
29
|
-
expect(isSetupComplete(tmpDir, "main")).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("is per-agent", () => {
|
|
33
|
-
markSetupComplete(tmpDir, "main");
|
|
34
|
-
expect(isSetupComplete(tmpDir, "work")).toBe(false);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("checkReflexioInstalled", () => {
|
|
39
|
-
it("returns a boolean", async () => {
|
|
40
|
-
const result = await checkReflexioInstalled();
|
|
41
|
-
expect(typeof result).toBe("boolean");
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe("checkReflexioConfigured", () => {
|
|
46
|
-
it("returns false for nonexistent directory", () => {
|
|
47
|
-
expect(checkReflexioConfigured("/tmp/nonexistent-reflexio-dir-" + Date.now())).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import * as fs from "node:fs";
|
|
3
|
-
import * as os from "node:os";
|
|
4
|
-
import * as path from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
openDb,
|
|
7
|
-
insertTurn,
|
|
8
|
-
getUnpublished,
|
|
9
|
-
markInFlight,
|
|
10
|
-
markPublished,
|
|
11
|
-
markFailed,
|
|
12
|
-
smartTruncate,
|
|
13
|
-
cleanupOldTurns,
|
|
14
|
-
} from "../plugin/lib/sqlite-buffer.ts";
|
|
15
|
-
import type Database from "better-sqlite3";
|
|
16
|
-
|
|
17
|
-
describe("smartTruncate", () => {
|
|
18
|
-
it("returns content unchanged when under limit", () => {
|
|
19
|
-
expect(smartTruncate("hello", 100)).toBe("hello");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("truncates with head + marker + tail within maxLength", () => {
|
|
23
|
-
const content = "a".repeat(200);
|
|
24
|
-
const result = smartTruncate(content, 100);
|
|
25
|
-
expect(result.length).toBeLessThanOrEqual(100);
|
|
26
|
-
expect(result).toContain("[...truncated");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("returns empty string for empty input", () => {
|
|
30
|
-
expect(smartTruncate("", 100)).toBe("");
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe("sqlite-buffer", () => {
|
|
35
|
-
let db: Database.Database;
|
|
36
|
-
let tmpDir: string;
|
|
37
|
-
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "reflexio-test-"));
|
|
40
|
-
const dbPath = path.join(tmpDir, "sessions.db");
|
|
41
|
-
db = openDb(dbPath);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
afterEach(() => {
|
|
45
|
-
db.close();
|
|
46
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("inserts and retrieves turns", () => {
|
|
50
|
-
insertTurn(db, "sess1", "user", "hello");
|
|
51
|
-
insertTurn(db, "sess1", "assistant", "hi there");
|
|
52
|
-
const turns = getUnpublished(db, "sess1", 3, 100);
|
|
53
|
-
expect(turns).toHaveLength(2);
|
|
54
|
-
expect(turns[0].role).toBe("user");
|
|
55
|
-
expect(turns[1].role).toBe("assistant");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("marks turns as in-flight then published", () => {
|
|
59
|
-
insertTurn(db, "sess1", "user", "hello");
|
|
60
|
-
const turns = getUnpublished(db, "sess1", 3, 100);
|
|
61
|
-
const maxId = turns[turns.length - 1].id;
|
|
62
|
-
markInFlight(db, "sess1", maxId, 3);
|
|
63
|
-
expect(getUnpublished(db, "sess1", 3, 100)).toHaveLength(0);
|
|
64
|
-
markPublished(db, "sess1", maxId);
|
|
65
|
-
expect(getUnpublished(db, "sess1", 3, 100)).toHaveLength(0);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("increments retry count on failure", () => {
|
|
69
|
-
insertTurn(db, "sess1", "user", "hello");
|
|
70
|
-
const turns = getUnpublished(db, "sess1", 3, 100);
|
|
71
|
-
const id = turns[0].id;
|
|
72
|
-
markInFlight(db, "sess1", id, 3);
|
|
73
|
-
markFailed(db, "sess1", id);
|
|
74
|
-
const after = getUnpublished(db, "sess1", 3, 100);
|
|
75
|
-
expect(after).toHaveLength(1);
|
|
76
|
-
// After MAX_RETRIES failures, turn should be excluded
|
|
77
|
-
markInFlight(db, "sess1", id, 3);
|
|
78
|
-
markFailed(db, "sess1", id);
|
|
79
|
-
markInFlight(db, "sess1", id, 3);
|
|
80
|
-
markFailed(db, "sess1", id);
|
|
81
|
-
expect(getUnpublished(db, "sess1", 3, 100)).toHaveLength(0);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("respects max interactions limit", () => {
|
|
85
|
-
for (let i = 0; i < 10; i++) {
|
|
86
|
-
insertTurn(db, "sess1", "user", `msg ${i}`);
|
|
87
|
-
}
|
|
88
|
-
const turns = getUnpublished(db, "sess1", 3, 5);
|
|
89
|
-
expect(turns).toHaveLength(5);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { resolveUserId, stripJsonComments, _resetCache } from "../plugin/lib/user-id.ts";
|
|
3
|
-
|
|
4
|
-
describe("stripJsonComments", () => {
|
|
5
|
-
it("strips line comments", () => {
|
|
6
|
-
expect(stripJsonComments('{ "key": "val" } // comment')).toBe('{ "key": "val" } ');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it("preserves URLs in quoted strings", () => {
|
|
10
|
-
expect(stripJsonComments('{ "url": "http://example.com" }')).toBe(
|
|
11
|
-
'{ "url": "http://example.com" }',
|
|
12
|
-
);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("strips comment after quoted string containing //", () => {
|
|
16
|
-
expect(stripJsonComments('{ "url": "http://x.com" } // note')).toBe(
|
|
17
|
-
'{ "url": "http://x.com" } ',
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe("resolveUserId", () => {
|
|
23
|
-
const originalEnv = process.env;
|
|
24
|
-
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
process.env = { ...originalEnv };
|
|
27
|
-
_resetCache();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
afterEach(() => {
|
|
31
|
-
process.env = originalEnv;
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("returns REFLEXIO_USER_ID env var if set", () => {
|
|
35
|
-
process.env.REFLEXIO_USER_ID = "custom-user";
|
|
36
|
-
expect(resolveUserId("agent:main:abc123")).toBe("custom-user");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("extracts agentId from session key format agent:<id>:<key>", () => {
|
|
40
|
-
expect(resolveUserId("agent:work:session789")).toBe("work");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("falls back to 'openclaw' when no session key or env", () => {
|
|
44
|
-
expect(resolveUserId("")).toBe("openclaw");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("falls back to 'openclaw' for non-agent session key format", () => {
|
|
48
|
-
expect(resolveUserId("random-session-key")).toBe("openclaw");
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
include: ["tests/**/*.test.ts"],
|
|
6
|
-
env: {
|
|
7
|
-
// Point HOME to a nonexistent path so tests cannot accidentally read
|
|
8
|
-
// ~/.reflexio/.env or other real user config files. Tests that need
|
|
9
|
-
// specific home-dir content must set HOME themselves.
|
|
10
|
-
HOME: "/nonexistent-test-home",
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"""Auth dependency primitives shared between :mod:`reflexio.server.api` and
|
|
2
|
-
endpoint helpers.
|
|
3
|
-
|
|
4
|
-
Lives in its own module to avoid an import cycle: api endpoints reference
|
|
5
|
-
:func:`default_get_org_id` (e.g. via FastAPI ``Depends``) and are themselves
|
|
6
|
-
imported by :mod:`reflexio.server.api`. Putting the dependency here keeps the
|
|
7
|
-
import graph acyclic.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from __future__ import annotations
|
|
11
|
-
|
|
12
|
-
DEFAULT_ORG_ID = "self-host-org"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def default_get_org_id() -> str:
|
|
16
|
-
"""Return the default organization ID for local hosting.
|
|
17
|
-
|
|
18
|
-
Enterprise deployments override this via
|
|
19
|
-
``app.dependency_overrides[default_get_org_id] = <bearer_auth_resolver>``
|
|
20
|
-
inside :func:`reflexio.server.api.create_app`.
|
|
21
|
-
|
|
22
|
-
Returns:
|
|
23
|
-
str: The default org identifier used for self-hosted deployments.
|
|
24
|
-
"""
|
|
25
|
-
return DEFAULT_ORG_ID
|