claude-smart 0.2.45 → 0.2.46
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 +34 -5
- package/bin/claude-smart.js +295 -5
- 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 +22 -2
- 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/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 +158 -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 +174 -0
- package/plugin/opencode/tsconfig.json +13 -0
- package/plugin/pyproject.toml +20 -3
- 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 +10 -8
- package/plugin/src/README.md +1 -1
- package/plugin/src/claude_smart/cli.py +304 -6
- 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 +1 -1
- package/plugin/vendor/reflexio/.env.example +54 -30
- package/plugin/vendor/reflexio/README.md +14 -8
- package/plugin/vendor/reflexio/pyproject.toml +13 -1
- package/plugin/vendor/reflexio/reflexio/README.md +1 -0
- 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 +210 -50
- 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/client/client.py +57 -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 +238 -10
- package/plugin/vendor/reflexio/reflexio/lib/_config.py +11 -4
- package/plugin/vendor/reflexio/reflexio/lib/_generation.py +16 -5
- package/plugin/vendor/reflexio/reflexio/lib/_lineage_parity_readers.py +187 -0
- package/plugin/vendor/reflexio/reflexio/lib/_profiles.py +198 -6
- package/plugin/vendor/reflexio/reflexio/lib/_reflection.py +1 -1
- package/plugin/vendor/reflexio/reflexio/lib/_search.py +29 -20
- package/plugin/vendor/reflexio/reflexio/lib/_user_playbook.py +2 -1
- 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/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 +52 -0
- 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 +88 -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 +45 -32
- 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/_auth.py +65 -2
- package/plugin/vendor/reflexio/reflexio/server/api.py +734 -85
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/precondition_checks.py +7 -0
- package/plugin/vendor/reflexio/reflexio/server/api_endpoints/request_context.py +3 -1
- 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/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/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/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 +266 -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 +26 -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 +39 -16
- package/plugin/vendor/reflexio/reflexio/server/services/generation_service.py +105 -23
- package/plugin/vendor/reflexio/reflexio/server/services/lineage/__init__.py +0 -0
- package/plugin/vendor/reflexio/reflexio/server/services/lineage/gc_scheduler.py +193 -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 +11 -12
- 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} +316 -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/user_detail_stripping.py +84 -0
- 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} +30 -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/relevance_floor.py +83 -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 +27 -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 +2 -0
- 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 +642 -197
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_extras.py +61 -104
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_lineage.py +628 -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 +978 -184
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_profiles.py +519 -128
- package/plugin/vendor/reflexio/reflexio/server/services/storage/sqlite_storage/_requests.py +77 -3
- 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/storage_base/__init__.py +131 -20
- 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 +36 -53
- 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 +243 -7
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_profiles.py +121 -1
- package/plugin/vendor/reflexio/reflexio/server/services/storage/storage_base/_requests.py +60 -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/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 +229 -32
- 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/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,156 +0,0 @@
|
|
|
1
|
-
// SQLite session buffer — persistent, crash-safe conversation store.
|
|
2
|
-
import Database from "better-sqlite3";
|
|
3
|
-
import * as fs from "node:fs";
|
|
4
|
-
import * as path from "node:path";
|
|
5
|
-
|
|
6
|
-
const MAX_CONTENT_LENGTH = 10_000;
|
|
7
|
-
|
|
8
|
-
export interface Turn {
|
|
9
|
-
id: number;
|
|
10
|
-
session_id: string;
|
|
11
|
-
role: string;
|
|
12
|
-
content: string;
|
|
13
|
-
timestamp: string;
|
|
14
|
-
published: number;
|
|
15
|
-
retry_count: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Smart truncation: preserve head + tail with marker, guaranteed <= maxLength. */
|
|
19
|
-
export function smartTruncate(
|
|
20
|
-
content: string,
|
|
21
|
-
maxLength: number = MAX_CONTENT_LENGTH,
|
|
22
|
-
): string {
|
|
23
|
-
if (!content || content.length <= maxLength) return content || "";
|
|
24
|
-
// Use a fixed-width marker estimate to break the circular dependency
|
|
25
|
-
// between marker length and truncated count.
|
|
26
|
-
const markerTemplate = "\n\n[...truncated NNNNNNN chars...]\n\n"; // ~38 chars
|
|
27
|
-
const budget = maxLength - markerTemplate.length;
|
|
28
|
-
if (budget <= 0) return content.slice(0, maxLength);
|
|
29
|
-
const headLen = Math.floor(budget * 0.8);
|
|
30
|
-
const tailLen = budget - headLen;
|
|
31
|
-
const truncated = content.length - headLen - tailLen;
|
|
32
|
-
const marker = `\n\n[...truncated ${truncated} chars...]\n\n`;
|
|
33
|
-
const result =
|
|
34
|
-
tailLen <= 0
|
|
35
|
-
? content.slice(0, headLen) + marker
|
|
36
|
-
: content.slice(0, headLen) + marker + content.slice(-tailLen);
|
|
37
|
-
// Final safety clamp for edge cases (very large truncated counts exceeding reserved marker width)
|
|
38
|
-
return result.length <= maxLength ? result : result.slice(0, maxLength);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Open (or create) the SQLite database and ensure schema exists. */
|
|
42
|
-
export function openDb(dbPath: string): Database.Database {
|
|
43
|
-
fs.mkdirSync(path.dirname(dbPath), { recursive: true, mode: 0o700 });
|
|
44
|
-
const db = new Database(dbPath);
|
|
45
|
-
db.pragma("journal_mode = WAL");
|
|
46
|
-
db.exec(`
|
|
47
|
-
CREATE TABLE IF NOT EXISTS turns (
|
|
48
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
49
|
-
session_id TEXT NOT NULL,
|
|
50
|
-
role TEXT NOT NULL,
|
|
51
|
-
content TEXT NOT NULL,
|
|
52
|
-
timestamp TEXT NOT NULL,
|
|
53
|
-
published INTEGER DEFAULT 0,
|
|
54
|
-
retry_count INTEGER DEFAULT 0
|
|
55
|
-
);
|
|
56
|
-
CREATE INDEX IF NOT EXISTS idx_session_published
|
|
57
|
-
ON turns(session_id, published);
|
|
58
|
-
`);
|
|
59
|
-
try {
|
|
60
|
-
db.exec("ALTER TABLE turns ADD COLUMN retry_count INTEGER DEFAULT 0");
|
|
61
|
-
} catch {
|
|
62
|
-
// Column already exists
|
|
63
|
-
}
|
|
64
|
-
return db;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Insert a single turn into the buffer. */
|
|
68
|
-
export function insertTurn(
|
|
69
|
-
db: Database.Database,
|
|
70
|
-
sessionId: string,
|
|
71
|
-
role: string,
|
|
72
|
-
content: string,
|
|
73
|
-
maxContentLength: number = MAX_CONTENT_LENGTH,
|
|
74
|
-
): void {
|
|
75
|
-
const truncated = smartTruncate(content, maxContentLength);
|
|
76
|
-
const now = new Date().toISOString();
|
|
77
|
-
db.prepare(
|
|
78
|
-
"INSERT INTO turns (session_id, role, content, timestamp) VALUES (?, ?, ?, ?)",
|
|
79
|
-
).run(sessionId, role, truncated, now);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** Get unpublished turns for a session, respecting retry limit. */
|
|
83
|
-
export function getUnpublished(
|
|
84
|
-
db: Database.Database,
|
|
85
|
-
sessionId: string,
|
|
86
|
-
maxRetries: number,
|
|
87
|
-
maxInteractions: number,
|
|
88
|
-
): Turn[] {
|
|
89
|
-
return db
|
|
90
|
-
.prepare(
|
|
91
|
-
"SELECT * FROM turns WHERE session_id = ? AND published = 0 AND retry_count < ? ORDER BY id LIMIT ?",
|
|
92
|
-
)
|
|
93
|
-
.all(sessionId, maxRetries, maxInteractions) as Turn[];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** Get distinct session IDs with unpublished turns (excluding current session). */
|
|
97
|
-
export function getOldUnpublishedSessions(
|
|
98
|
-
db: Database.Database,
|
|
99
|
-
currentSessionId: string,
|
|
100
|
-
maxRetries: number,
|
|
101
|
-
limit: number,
|
|
102
|
-
): string[] {
|
|
103
|
-
const rows = db
|
|
104
|
-
.prepare(
|
|
105
|
-
"SELECT session_id FROM turns WHERE published = 0 AND retry_count < ? AND session_id != ? GROUP BY session_id ORDER BY MIN(id) LIMIT ?",
|
|
106
|
-
)
|
|
107
|
-
.all(maxRetries, currentSessionId, limit) as { session_id: string }[];
|
|
108
|
-
return rows.map((r) => r.session_id);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** Count unpublished turns for a session. */
|
|
112
|
-
export function countUnpublished(
|
|
113
|
-
db: Database.Database,
|
|
114
|
-
sessionId: string,
|
|
115
|
-
): number {
|
|
116
|
-
const row = db
|
|
117
|
-
.prepare(
|
|
118
|
-
"SELECT COUNT(*) as count FROM turns WHERE session_id = ? AND published = 0",
|
|
119
|
-
)
|
|
120
|
-
.get(sessionId) as { count: number };
|
|
121
|
-
return row.count;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** Mark turns as in-flight (published=2) to prevent concurrent publish. */
|
|
125
|
-
export function markInFlight(
|
|
126
|
-
db: Database.Database,
|
|
127
|
-
sessionId: string,
|
|
128
|
-
maxId: number,
|
|
129
|
-
maxRetries: number,
|
|
130
|
-
): void {
|
|
131
|
-
db.prepare(
|
|
132
|
-
"UPDATE turns SET published = 2 WHERE session_id = ? AND published = 0 AND retry_count < ? AND id <= ?",
|
|
133
|
-
).run(sessionId, maxRetries, maxId);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/** Mark in-flight turns as successfully published (scoped to batch). */
|
|
137
|
-
export function markPublished(db: Database.Database, sessionId: string, maxId: number): void {
|
|
138
|
-
db.prepare(
|
|
139
|
-
"UPDATE turns SET published = 1 WHERE session_id = ? AND published = 2 AND id <= ?",
|
|
140
|
-
).run(sessionId, maxId);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/** Reset in-flight turns back to unpublished and increment retry count (scoped to batch). */
|
|
144
|
-
export function markFailed(db: Database.Database, sessionId: string, maxId: number): void {
|
|
145
|
-
db.prepare(
|
|
146
|
-
"UPDATE turns SET published = 0, retry_count = retry_count + 1 WHERE session_id = ? AND published = 2 AND id <= ?",
|
|
147
|
-
).run(sessionId, maxId);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/** Delete published turns older than the given number of days. */
|
|
151
|
-
export function cleanupOldTurns(db: Database.Database, days: number = 7): void {
|
|
152
|
-
const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString();
|
|
153
|
-
db.prepare(
|
|
154
|
-
"DELETE FROM turns WHERE published = 1 AND timestamp < ?",
|
|
155
|
-
).run(cutoff);
|
|
156
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
// Multi-user identity resolution.
|
|
2
|
-
//
|
|
3
|
-
// Each Openclaw agent instance maps to a distinct Reflexio user.
|
|
4
|
-
// Resolution chain: env var > session key agentId > openclaw.json > fallback.
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
import * as os from "node:os";
|
|
7
|
-
import * as path from "node:path";
|
|
8
|
-
|
|
9
|
-
let _openclawConfig: Record<string, unknown> | null = null;
|
|
10
|
-
|
|
11
|
-
/** Strip JSON5 line and block comments while respecting quoted strings. */
|
|
12
|
-
export function stripJsonComments(raw: string): string {
|
|
13
|
-
const result: string[] = [];
|
|
14
|
-
let inBlockComment = false;
|
|
15
|
-
for (const line of raw.split("\n")) {
|
|
16
|
-
let out = "";
|
|
17
|
-
let inString = false;
|
|
18
|
-
let escape = false;
|
|
19
|
-
let i = 0;
|
|
20
|
-
while (i < line.length) {
|
|
21
|
-
const ch = line[i];
|
|
22
|
-
if (inBlockComment) {
|
|
23
|
-
// Look for end of block comment
|
|
24
|
-
if (ch === "*" && line[i + 1] === "/") {
|
|
25
|
-
inBlockComment = false;
|
|
26
|
-
i += 2;
|
|
27
|
-
} else {
|
|
28
|
-
i++;
|
|
29
|
-
}
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (escape) {
|
|
33
|
-
escape = false;
|
|
34
|
-
out += ch;
|
|
35
|
-
i++;
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (inString) {
|
|
39
|
-
if (ch === "\\") {
|
|
40
|
-
escape = true;
|
|
41
|
-
out += ch;
|
|
42
|
-
i++;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (ch === '"') {
|
|
46
|
-
inString = false;
|
|
47
|
-
out += ch;
|
|
48
|
-
i++;
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
out += ch;
|
|
52
|
-
i++;
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
// Outside string
|
|
56
|
-
if (ch === '"') {
|
|
57
|
-
inString = true;
|
|
58
|
-
out += ch;
|
|
59
|
-
i++;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (ch === "/" && line[i + 1] === "/") {
|
|
63
|
-
// Line comment — rest of line is comment
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
if (ch === "/" && line[i + 1] === "*") {
|
|
67
|
-
// Block comment start
|
|
68
|
-
inBlockComment = true;
|
|
69
|
-
i += 2;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
out += ch;
|
|
73
|
-
i++;
|
|
74
|
-
}
|
|
75
|
-
result.push(out);
|
|
76
|
-
}
|
|
77
|
-
return result.join("\n");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** Read and cache ~/.openclaw/openclaw.json (JSON5 — strip comments before parsing). */
|
|
81
|
-
function loadOpenclawConfig(): Record<string, unknown> {
|
|
82
|
-
if (_openclawConfig !== null) return _openclawConfig;
|
|
83
|
-
try {
|
|
84
|
-
const configPath = path.join(os.homedir(), ".openclaw", "openclaw.json");
|
|
85
|
-
const raw = fs.readFileSync(configPath, "utf-8");
|
|
86
|
-
const stripped = stripJsonComments(raw);
|
|
87
|
-
_openclawConfig = JSON.parse(stripped);
|
|
88
|
-
} catch {
|
|
89
|
-
_openclawConfig = {};
|
|
90
|
-
}
|
|
91
|
-
return _openclawConfig!;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Resolve the Reflexio user ID.
|
|
96
|
-
*
|
|
97
|
-
* @param sessionKey - The Openclaw session key from hook context.
|
|
98
|
-
* @returns The resolved user ID string.
|
|
99
|
-
*/
|
|
100
|
-
export function resolveUserId(sessionKey: string): string {
|
|
101
|
-
// 1. Explicit env override
|
|
102
|
-
if (process.env.REFLEXIO_USER_ID) return process.env.REFLEXIO_USER_ID;
|
|
103
|
-
|
|
104
|
-
// 2. Extract agentId from session key (format: agent:<agentId>:<key>)
|
|
105
|
-
const sessionMatch = sessionKey.match(/^agent:([^:]+):/);
|
|
106
|
-
if (sessionMatch) return sessionMatch[1];
|
|
107
|
-
|
|
108
|
-
// 3. Read openclaw.json
|
|
109
|
-
const config = loadOpenclawConfig();
|
|
110
|
-
const agents = config.agents as Record<string, unknown> | undefined;
|
|
111
|
-
if (agents) {
|
|
112
|
-
if (typeof agents.defaults === "string") return agents.defaults;
|
|
113
|
-
if (Array.isArray(agents.list) && agents.list.length > 0) {
|
|
114
|
-
const first = agents.list[0];
|
|
115
|
-
if (first && typeof first === "object" && (first as Record<string, unknown>).name) {
|
|
116
|
-
return (first as Record<string, unknown>).name as string;
|
|
117
|
-
}
|
|
118
|
-
if (typeof first === "string") return first;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// 4. Fallback
|
|
123
|
-
return "openclaw";
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** Resolve the agent version label. */
|
|
127
|
-
export function resolveAgentVersion(): string {
|
|
128
|
-
return process.env.REFLEXIO_AGENT_VERSION || "openclaw-agent";
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** Reset cached state — for testing only. */
|
|
132
|
-
export function _resetCache(): void {
|
|
133
|
-
_openclawConfig = null;
|
|
134
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Reflexio: Cross-Session Memory
|
|
2
|
-
|
|
3
|
-
This agent uses Reflexio to remember corrections and preferences across sessions.
|
|
4
|
-
|
|
5
|
-
## How It Works
|
|
6
|
-
|
|
7
|
-
A `before_prompt_build` hook automatically runs `reflexio search` on every message you receive. When relevant corrections or preferences exist, they are injected as context before your response.
|
|
8
|
-
|
|
9
|
-
## What You MUST Do
|
|
10
|
-
|
|
11
|
-
1. **When you see injected Reflexio context** — read it carefully and follow every instruction. Behavior Corrections tell you what to do differently. User Preferences tell you how the user works. Agent Playbooks are shared corrections from all instances.
|
|
12
|
-
|
|
13
|
-
2. **If no Reflexio context appears for a substantive task request** — run a manual search. Skip this for short or trivial messages (greetings, one-word replies, yes/no responses):
|
|
14
|
-
```
|
|
15
|
-
reflexio search "<the user's task or request>"
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
3. **After user corrections** — once confirmed, call the `reflexio_publish` tool to flush the conversation to Reflexio immediately.
|
|
19
|
-
|
|
20
|
-
4. **Never mention Reflexio to the user** unless they ask about it. It should be invisible.
|
|
21
|
-
|
|
22
|
-
5. **If Reflexio is unavailable, proceed normally** — it enhances but never blocks your work. Never degrade the core agent experience because of Reflexio issues.
|
|
23
|
-
|
|
24
|
-
6. **Never ask the user to manage the Reflexio server** — infrastructure is the plugin's responsibility.
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Publishes the reflexio openclaw integration as a single ClawHub skill.
|
|
3
|
-
#
|
|
4
|
-
# Two modes:
|
|
5
|
-
# 1) CLI publish — stages into a temp dir, generates top-level SKILL.md,
|
|
6
|
-
# runs `bun clawhub skill publish`. Requires bun + an authed session.
|
|
7
|
-
# 2) Stage-only — same staging + SKILL.md generation, but skips publish
|
|
8
|
-
# and prints the staged path so you can drop it onto the web form at
|
|
9
|
-
# https://clawhub.ai/publish-skill.
|
|
10
|
-
#
|
|
11
|
-
# Usage:
|
|
12
|
-
# ./publish_clawhub.sh <semver> [changelog] # CLI publish
|
|
13
|
-
# ./publish_clawhub.sh --stage-only # produce folder for web upload
|
|
14
|
-
#
|
|
15
|
-
# Prereqs:
|
|
16
|
-
# - CLI mode: `bun clawhub login` done, `bun` on PATH
|
|
17
|
-
# - Stage-only mode: just `rsync` and `python3` on PATH
|
|
18
|
-
|
|
19
|
-
set -euo pipefail
|
|
20
|
-
|
|
21
|
-
STAGE_ONLY=0
|
|
22
|
-
if [[ "${1:-}" == "--stage-only" ]]; then
|
|
23
|
-
STAGE_ONLY=1
|
|
24
|
-
VERSION="0.0.0-staged"
|
|
25
|
-
CHANGELOG=""
|
|
26
|
-
else
|
|
27
|
-
VERSION="${1:?usage: publish_clawhub.sh <semver> [changelog] | --stage-only}"
|
|
28
|
-
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][A-Za-z0-9.-]+)?$ ]]; then
|
|
29
|
-
echo "error: version must be semver (got: $VERSION)" >&2
|
|
30
|
-
exit 1
|
|
31
|
-
fi
|
|
32
|
-
CHANGELOG="${2:-Release $VERSION}"
|
|
33
|
-
fi
|
|
34
|
-
|
|
35
|
-
SRC="$(cd "$(dirname "$0")" && pwd)"
|
|
36
|
-
STAGE="$(mktemp -d -t reflexio-clawhub-XXXXXX)"
|
|
37
|
-
if (( STAGE_ONLY == 0 )); then
|
|
38
|
-
trap 'rm -rf "$STAGE"' EXIT
|
|
39
|
-
fi
|
|
40
|
-
|
|
41
|
-
if (( STAGE_ONLY == 0 )); then
|
|
42
|
-
if ! command -v bun >/dev/null 2>&1; then
|
|
43
|
-
echo "error: bun not found on PATH (install from https://bun.sh)" >&2
|
|
44
|
-
exit 1
|
|
45
|
-
fi
|
|
46
|
-
|
|
47
|
-
if ! bun clawhub whoami >/dev/null 2>&1; then
|
|
48
|
-
echo "error: not logged in to clawhub. run: bun clawhub login" >&2
|
|
49
|
-
exit 1
|
|
50
|
-
fi
|
|
51
|
-
fi
|
|
52
|
-
|
|
53
|
-
echo "staging bundle → $STAGE"
|
|
54
|
-
# Prune everything that shouldn't be in the published bundle. The web
|
|
55
|
-
# uploader at clawhub.ai/publish-skill does NOT read .clawhubignore
|
|
56
|
-
# (that's a CLI-only feature), so we pre-filter here and the same stage
|
|
57
|
-
# dir works for both CLI publish and web drag-drop.
|
|
58
|
-
rsync -a \
|
|
59
|
-
--exclude='node_modules/' \
|
|
60
|
-
--exclude='package-lock.json' \
|
|
61
|
-
--exclude='.DS_Store' \
|
|
62
|
-
--exclude='eval/' \
|
|
63
|
-
--exclude='TESTING.md' \
|
|
64
|
-
--exclude='publish_clawhub.sh' \
|
|
65
|
-
--exclude='.clawhubignore' \
|
|
66
|
-
"$SRC"/ "$STAGE"/
|
|
67
|
-
|
|
68
|
-
echo "generating top-level SKILL.md from skill/SKILL.md"
|
|
69
|
-
python3 - "$STAGE" <<'PY'
|
|
70
|
-
import re
|
|
71
|
-
import sys
|
|
72
|
-
from pathlib import Path
|
|
73
|
-
|
|
74
|
-
stage = Path(sys.argv[1])
|
|
75
|
-
src_skill = stage / "skill" / "SKILL.md"
|
|
76
|
-
body = src_skill.read_text()
|
|
77
|
-
|
|
78
|
-
m = re.match(r"^---\n(.*?)\n---\n(.*)$", body, re.DOTALL)
|
|
79
|
-
if not m:
|
|
80
|
-
sys.exit(f"error: {src_skill} has no YAML frontmatter")
|
|
81
|
-
orig_frontmatter, orig_body = m.group(1), m.group(2)
|
|
82
|
-
|
|
83
|
-
# Pull the original description verbatim (multi-line safe).
|
|
84
|
-
desc_match = re.search(
|
|
85
|
-
r'^description:\s*"((?:[^"\\]|\\.)*)"', orig_frontmatter, re.MULTILINE
|
|
86
|
-
)
|
|
87
|
-
if not desc_match:
|
|
88
|
-
sys.exit("error: could not find description in skill/SKILL.md frontmatter")
|
|
89
|
-
description = desc_match.group(1)
|
|
90
|
-
|
|
91
|
-
frontmatter = (
|
|
92
|
-
"---\n"
|
|
93
|
-
"name: reflexio\n"
|
|
94
|
-
f'description: "{description}"\n'
|
|
95
|
-
"metadata:\n"
|
|
96
|
-
" openclaw:\n"
|
|
97
|
-
" homepage: https://github.com/reflexio-ai/reflexio/tree/main/reflexio/integrations/openclaw\n"
|
|
98
|
-
" emoji: 🧠\n"
|
|
99
|
-
" requires:\n"
|
|
100
|
-
" bins: [reflexio]\n"
|
|
101
|
-
"---\n"
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
privacy = """
|
|
105
|
-
## Privacy & Data Collection — Read This First
|
|
106
|
-
|
|
107
|
-
**This skill causes the agent to automatically capture conversations and
|
|
108
|
-
forward them to a local Reflexio server for LLM-based extraction.** Read this
|
|
109
|
-
before enabling — there are two distinct network hops and you need to
|
|
110
|
-
understand both.
|
|
111
|
-
|
|
112
|
-
### Credential requirement (not declared in skill metadata)
|
|
113
|
-
|
|
114
|
-
The skill's registry metadata declares no required environment variables and
|
|
115
|
-
the hook reads none. **But the end-to-end system does require an LLM provider
|
|
116
|
-
API key**, and you WILL be asked for one during First-Use Setup.
|
|
117
|
-
|
|
118
|
-
- Step 2 of First-Use Setup below runs `reflexio setup openclaw`, which opens
|
|
119
|
-
an **interactive wizard** prompting you to choose an LLM provider (OpenAI,
|
|
120
|
-
Anthropic, Gemini, DeepSeek, OpenRouter, and several others) and paste an
|
|
121
|
-
API key.
|
|
122
|
-
- The key is stored in `~/.reflexio/.env` and read by the local Reflexio
|
|
123
|
-
server during extraction. **The hook itself never reads the key** (the hook
|
|
124
|
-
has no environment variable access and no filesystem config reads — both
|
|
125
|
-
enforced in `handler.js`).
|
|
126
|
-
- If you want fully offline operation, point the wizard at a local LLM
|
|
127
|
-
(Ollama at `http://127.0.0.1:11434`, LM Studio, vLLM, etc.) instead of a
|
|
128
|
-
hosted provider — the wizard accepts any LiteLLM-compatible base URL.
|
|
129
|
-
|
|
130
|
-
**Why the metadata doesn't declare it:** ClawHub's `metadata.openclaw.requires.env`
|
|
131
|
-
describes environment variables the hook's own code path reads. The hook is
|
|
132
|
-
deliberately stateless at the credential level, so listing anything there
|
|
133
|
-
would be inaccurate. The dependency is at the *backend server* level, one
|
|
134
|
-
hop away. This disclosure is here instead of in the metadata because prose
|
|
135
|
-
is the right place to explain the distinction.
|
|
136
|
-
|
|
137
|
-
### Network hops — two of them
|
|
138
|
-
|
|
139
|
-
**Hop 1: the hook → the local Reflexio server (always localhost).**
|
|
140
|
-
The hook is hard-pinned to `http://127.0.0.1:8081`. It communicates via native
|
|
141
|
-
`fetch()` with no configuration knobs; the destination is a hardcoded constant
|
|
142
|
-
in `handler.js`. It reads zero environment variables and zero configuration
|
|
143
|
-
files. This hop cannot leave your machine.
|
|
144
|
-
|
|
145
|
-
**Hop 2: the local Reflexio server → an LLM provider (may leave your
|
|
146
|
-
machine).** The server uses an LLM provider (OpenAI, Anthropic, Gemini,
|
|
147
|
-
DeepSeek, etc.) to extract playbooks and profiles from captured conversations.
|
|
148
|
-
That provider is configured in `~/.reflexio/.env`. **If you configured an
|
|
149
|
-
external provider, excerpts of your conversations will be sent to that
|
|
150
|
-
provider** as part of extraction — trigger text, sample content, and enough
|
|
151
|
-
context for the extractor to produce a useful summary. The primary full
|
|
152
|
-
conversation text stays in your local SQLite database at `~/.reflexio/`, but
|
|
153
|
-
the extracted summaries and illustrative excerpts traverse whatever the LLM
|
|
154
|
-
provider's network path is.
|
|
155
|
-
|
|
156
|
-
**If you want fully offline operation**, configure the local server to use a
|
|
157
|
-
local LLM (Ollama, LM Studio, vLLM, etc.) before enabling this skill. Do not
|
|
158
|
-
rely on the hook's localhost pinning as a privacy guarantee for the system as
|
|
159
|
-
a whole — that only bounds the hook, not the server behind it.
|
|
160
|
-
|
|
161
|
-
**What is captured:** full user and assistant messages; every tool call, input,
|
|
162
|
-
and output (including failed tool calls and exact error strings); self-correction
|
|
163
|
-
text from the assistant's own output. None of this is scrubbed for PII,
|
|
164
|
-
credentials, file paths, or API outputs. If you work on sensitive tasks,
|
|
165
|
-
disable the hook before starting them, or tell the agent mid-task.
|
|
166
|
-
|
|
167
|
-
**How to disable:**
|
|
168
|
-
|
|
169
|
-
- Per-session, stop automatic capture: `openclaw hooks disable reflexio-context`
|
|
170
|
-
- Remove the integration entirely: `reflexio setup openclaw --uninstall`
|
|
171
|
-
- Search-only mode (keep retrieval, drop auto-publish): edit `hook/handler.js`,
|
|
172
|
-
remove the `command:stop` handler, and reinstall
|
|
173
|
-
- Sensitive task: tell the agent "don't log this" — the workspace rule instructs
|
|
174
|
-
it to stop all capture and search calls for the rest of the session
|
|
175
|
-
|
|
176
|
-
**Transparency contract:** the agent is instructed to tell you Reflexio is
|
|
177
|
-
active on the first turn of each session, disclose what is captured AND
|
|
178
|
-
mention that the local server may forward excerpts to an LLM provider, and
|
|
179
|
-
honor session-level opt-outs. This is enforced by
|
|
180
|
-
`~/.openclaw/workspace/reflexio.md`. Edit that file if your deployment needs
|
|
181
|
-
different rules (require explicit approval before every publish, offline-only,
|
|
182
|
-
etc).
|
|
183
|
-
|
|
184
|
-
Full data-handling details live in the **Privacy & Data Collection** section
|
|
185
|
-
further down in this SKILL.md.
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
"""
|
|
190
|
-
|
|
191
|
-
first_use = """
|
|
192
|
-
## First-Use Setup
|
|
193
|
-
|
|
194
|
-
Run these commands the first time this skill is invoked. They are idempotent —
|
|
195
|
-
skip if `reflexio` is already on PATH, the local Reflexio server is responding
|
|
196
|
-
at `http://127.0.0.1:8081/health`, and `openclaw hooks list` shows
|
|
197
|
-
`reflexio-context` as `ready`. **Only run them after reading the privacy
|
|
198
|
-
disclosure above, and be aware that step 2 is interactive — it will prompt
|
|
199
|
-
you to pick an LLM provider and paste an API key for the local server's
|
|
200
|
-
extraction pipeline.**
|
|
201
|
-
|
|
202
|
-
```bash
|
|
203
|
-
# 1. Install the reflexio CLI (pipx preferred; pip as fallback).
|
|
204
|
-
command -v reflexio >/dev/null 2>&1 \\
|
|
205
|
-
|| pipx install reflexio-ai 2>/dev/null \\
|
|
206
|
-
|| pip install --user reflexio-ai
|
|
207
|
-
|
|
208
|
-
# 2. INTERACTIVE: activates the hook, slash commands, and workspace rule in
|
|
209
|
-
# OpenClaw. Also prompts you to choose an LLM provider and paste an API key,
|
|
210
|
-
# which gets written to ~/.reflexio/.env. That key is what the local server
|
|
211
|
-
# uses to extract playbooks from captured conversations. Point at a local LLM
|
|
212
|
-
# (Ollama / LM Studio / vLLM) here if you want fully offline operation.
|
|
213
|
-
# Before running this, tell the user what will be asked and why.
|
|
214
|
-
reflexio setup openclaw
|
|
215
|
-
|
|
216
|
-
# 3. Start the local Reflexio backend in the background. The hook talks to
|
|
217
|
-
# this server via HTTP on 127.0.0.1:8081 — it will NOT start the server for
|
|
218
|
-
# you. Tell the user you are doing this before running it.
|
|
219
|
-
curl -sf --max-time 2 http://127.0.0.1:8081/health >/dev/null 2>&1 \\
|
|
220
|
-
|| (nohup reflexio services start --only backend --no-reload \\
|
|
221
|
-
>> ~/.reflexio/logs/server.log 2>&1 & \\
|
|
222
|
-
sleep 5)
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
This installs:
|
|
226
|
-
|
|
227
|
-
- `reflexio-context` hook — HTTP-only capture + per-message playbook
|
|
228
|
-
injection (communicates only with `http://127.0.0.1:8081`)
|
|
229
|
-
- `/reflexio-extract` slash command — publish session learnings mid-session
|
|
230
|
-
- `/reflexio-aggregate` slash command — consolidate user playbooks into
|
|
231
|
-
shared agent playbooks
|
|
232
|
-
- `~/.openclaw/workspace/reflexio.md` — always-active behavioral rule
|
|
233
|
-
(transparency + opt-out handling)
|
|
234
|
-
|
|
235
|
-
If the local server is unreachable, the hook logs the error and the agent
|
|
236
|
-
continues the user's task without Reflexio context that session.
|
|
237
|
-
|
|
238
|
-
---
|
|
239
|
-
|
|
240
|
-
"""
|
|
241
|
-
|
|
242
|
-
(stage / "SKILL.md").write_text(frontmatter + privacy + first_use + orig_body)
|
|
243
|
-
print(f"wrote {stage / 'SKILL.md'}")
|
|
244
|
-
PY
|
|
245
|
-
|
|
246
|
-
if (( STAGE_ONLY == 1 )); then
|
|
247
|
-
cat <<EOF
|
|
248
|
-
|
|
249
|
-
─────────────────────────────────────────────────────────────
|
|
250
|
-
Stage ready. Upload via web at https://clawhub.ai/publish-skill
|
|
251
|
-
|
|
252
|
-
Drag this folder onto the drop zone:
|
|
253
|
-
$STAGE
|
|
254
|
-
|
|
255
|
-
Form values to use:
|
|
256
|
-
Slug: reflexio
|
|
257
|
-
Display name: Reflexio
|
|
258
|
-
Version: <pick a semver, e.g. 1.0.0>
|
|
259
|
-
Tags: latest
|
|
260
|
-
Changelog: Initial release
|
|
261
|
-
|
|
262
|
-
When done, delete the temp folder: rm -rf $STAGE
|
|
263
|
-
─────────────────────────────────────────────────────────────
|
|
264
|
-
EOF
|
|
265
|
-
exit 0
|
|
266
|
-
fi
|
|
267
|
-
|
|
268
|
-
echo "publishing to clawhub: slug=reflexio version=$VERSION"
|
|
269
|
-
(
|
|
270
|
-
cd "$STAGE"
|
|
271
|
-
bun clawhub skill publish . \
|
|
272
|
-
--slug reflexio \
|
|
273
|
-
--version "$VERSION" \
|
|
274
|
-
--tags latest \
|
|
275
|
-
--changelog "$CHANGELOG"
|
|
276
|
-
)
|
|
277
|
-
|
|
278
|
-
echo "done. verify at https://clawhub.ai/skill/reflexio"
|