foxclaw 0.1.0 → 0.1.3
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/README.md +54 -29
- package/bin/foxclaw.cjs +51 -0
- package/index.js +4 -10
- package/package.json +46 -38
- package/python/.dockerignore +35 -0
- package/python/.env.example +173 -0
- package/python/.gitattributes +46 -0
- package/python/.github/workflows/ci.yml +167 -0
- package/python/.github/workflows/release.yml +183 -0
- package/python/CHANGELOG.md +57 -0
- package/python/CHANGELOG_CN.md +57 -0
- package/python/Dockerfile +64 -0
- package/python/LICENSE +21 -0
- package/python/MANIFEST.in +14 -0
- package/python/README.md +201 -0
- package/python/README_CN.md +336 -0
- package/python/bench/bm25_audit.py +186 -0
- package/python/bench/bm25_regression.py +177 -0
- package/python/bench/bm25_stress.py +155 -0
- package/python/bench/cd_audit.py +215 -0
- package/python/bench/chaos.py +140 -0
- package/python/bench/concurrency.py +103 -0
- package/python/bench/e2e_real_models.py +94 -0
- package/python/bench/llm_retry_test.py +241 -0
- package/python/bench/load_test.py +193 -0
- package/python/bench/vector_ivf_upgrade.py +128 -0
- package/python/docs/CHANNELS.md +195 -0
- package/python/docs/GOVERNANCE.md +164 -0
- package/python/docs/RELEASE.md +110 -0
- package/python/docs/RUN.md +75 -0
- package/python/docs/RUN_CN.md +121 -0
- package/python/docs//351/205/215/347/275/256/346/214/207/345/215/227.md +152 -0
- package/python/evals/__init__.py +0 -0
- package/python/evals/governance/README.md +61 -0
- package/python/evals/governance/__init__.py +0 -0
- package/python/evals/governance/cases.py +115 -0
- package/python/evals/governance/compare_embeddings.py +94 -0
- package/python/evals/governance/convergence.svg +11 -0
- package/python/evals/governance/report.json +371 -0
- package/python/evals/governance/run_evals.py +368 -0
- package/python/examples/governance_middleware_demo.py +72 -0
- package/python/examples/langgraph_governance_demo.py +104 -0
- package/python/examples/sample_itinerary.csv +6 -0
- package/python/examples/sample_knowledge.csv +9 -0
- package/python/examples/sample_transactions.csv +14 -0
- package/python/foxclaw/__init__.py +408 -0
- package/python/foxclaw/agents/__init__.py +12 -0
- package/python/foxclaw/agents/agents.py +35 -0
- package/python/foxclaw/agents/base.py +794 -0
- package/python/foxclaw/agents/impl/__init__.py +1 -0
- package/python/foxclaw/agents/impl/_helpers.py +70 -0
- package/python/foxclaw/agents/impl/finance.py +231 -0
- package/python/foxclaw/agents/impl/office.py +350 -0
- package/python/foxclaw/agents/impl/supervisor.py +592 -0
- package/python/foxclaw/agents/mixins/_context.py +128 -0
- package/python/foxclaw/agents/mixins/augment.py +143 -0
- package/python/foxclaw/agents/mixins/llm.py +67 -0
- package/python/foxclaw/agents/mixins/memory.py +41 -0
- package/python/foxclaw/agents/mixins/preference.py +131 -0
- package/python/foxclaw/agents/mixins/prompt.py +71 -0
- package/python/foxclaw/agents/mixins/skillbox.py +58 -0
- package/python/foxclaw/agents/mixins/tool_exec.py +417 -0
- package/python/foxclaw/api/__init__.py +224 -0
- package/python/foxclaw/api/_state.py +43 -0
- package/python/foxclaw/api/bootstrap.py +96 -0
- package/python/foxclaw/api/middleware.py +294 -0
- package/python/foxclaw/api/routes/ahs.py +404 -0
- package/python/foxclaw/api/routes/attachments.py +116 -0
- package/python/foxclaw/api/routes/browser.py +35 -0
- package/python/foxclaw/api/routes/domain.py +306 -0
- package/python/foxclaw/api/routes/knowledge.py +145 -0
- package/python/foxclaw/api/routes/llm_admin.py +449 -0
- package/python/foxclaw/api/routes/memory.py +105 -0
- package/python/foxclaw/api/routes/orchestration.py +39 -0
- package/python/foxclaw/api/routes/recovery.py +44 -0
- package/python/foxclaw/api/routes/review.py +266 -0
- package/python/foxclaw/api/routes/search.py +33 -0
- package/python/foxclaw/api/routes/system.py +311 -0
- package/python/foxclaw/api/routes/task.py +263 -0
- package/python/foxclaw/api/routes/ws.py +64 -0
- package/python/foxclaw/api/spine.py +52 -0
- package/python/foxclaw/browser/__init__.py +13 -0
- package/python/foxclaw/browser/action/__init__.py +1 -0
- package/python/foxclaw/browser/action/action_executor.py +50 -0
- package/python/foxclaw/browser/action/action_types.py +44 -0
- package/python/foxclaw/browser/action/action_verifier.py +68 -0
- package/python/foxclaw/browser/action/url_policy.py +143 -0
- package/python/foxclaw/browser/adapter/__init__.py +1 -0
- package/python/foxclaw/browser/adapter/base_adapter.py +23 -0
- package/python/foxclaw/browser/adapter/web_adapter.py +46 -0
- package/python/foxclaw/browser/driver/__init__.py +1 -0
- package/python/foxclaw/browser/driver/base_driver.py +61 -0
- package/python/foxclaw/browser/driver/playwright_driver.py +170 -0
- package/python/foxclaw/browser/perception/__init__.py +1 -0
- package/python/foxclaw/browser/perception/dom_extractor.py +42 -0
- package/python/foxclaw/browser/perception/element_indexer.py +56 -0
- package/python/foxclaw/browser/perception/semantic_reducer.py +33 -0
- package/python/foxclaw/browser/perception/snapshot.py +29 -0
- package/python/foxclaw/browser/service.py +144 -0
- package/python/foxclaw/browser/session/__init__.py +1 -0
- package/python/foxclaw/browser/session/session_manager.py +57 -0
- package/python/foxclaw/capability/__init__.py +12 -0
- package/python/foxclaw/capability/embedding_service.py +65 -0
- package/python/foxclaw/channels/__init__.py +138 -0
- package/python/foxclaw/channels/discord.py +175 -0
- package/python/foxclaw/channels/dispatcher.py +179 -0
- package/python/foxclaw/channels/feishu.py +215 -0
- package/python/foxclaw/channels/openclaw_bridge.py +151 -0
- package/python/foxclaw/channels/signing.py +187 -0
- package/python/foxclaw/channels/telegram.py +120 -0
- package/python/foxclaw/channels/weixin.py +215 -0
- package/python/foxclaw/cli.py +183 -0
- package/python/foxclaw/cognitive/__init__.py +4 -0
- package/python/foxclaw/cognitive/reasoner.py +81 -0
- package/python/foxclaw/cognitive/state.py +141 -0
- package/python/foxclaw/core/__init__.py +9 -0
- package/python/foxclaw/core/audit_chain.py +131 -0
- package/python/foxclaw/core/audit_sink.py +100 -0
- package/python/foxclaw/core/compaction.py +265 -0
- package/python/foxclaw/core/config.py +65 -0
- package/python/foxclaw/core/confirm_nonce.py +151 -0
- package/python/foxclaw/core/dispatch.py +27 -0
- package/python/foxclaw/core/envfile.py +48 -0
- package/python/foxclaw/core/failure_policy.py +142 -0
- package/python/foxclaw/core/gateway.py +81 -0
- package/python/foxclaw/core/governance_audit.py +171 -0
- package/python/foxclaw/core/idempotency.py +282 -0
- package/python/foxclaw/core/injection_guard.py +202 -0
- package/python/foxclaw/core/memory_adapter.py +489 -0
- package/python/foxclaw/core/metrics.py +88 -0
- package/python/foxclaw/core/model_router.py +985 -0
- package/python/foxclaw/core/paths.py +103 -0
- package/python/foxclaw/core/recovery.py +349 -0
- package/python/foxclaw/core/scheduler.py +141 -0
- package/python/foxclaw/core/secrets.py +131 -0
- package/python/foxclaw/core/sessions.py +155 -0
- package/python/foxclaw/core/settings.py +414 -0
- package/python/foxclaw/core/shared_write.py +186 -0
- package/python/foxclaw/core/steering_queue.py +154 -0
- package/python/foxclaw/core/system_bus.py +84 -0
- package/python/foxclaw/core/thought_chain.py +316 -0
- package/python/foxclaw/core/token_meter.py +231 -0
- package/python/foxclaw/core/tools.py +164 -0
- package/python/foxclaw/core/tracing.py +375 -0
- package/python/foxclaw/core/truth_pipeline.py +110 -0
- package/python/foxclaw/core/update_check.py +149 -0
- package/python/foxclaw/core/vec_recall_adapter.py +477 -0
- package/python/foxclaw/core/verify.py +173 -0
- package/python/foxclaw/core/web_search.py +218 -0
- package/python/foxclaw/finance/__init__.py +15 -0
- package/python/foxclaw/finance/evidence.py +149 -0
- package/python/foxclaw/finance/fx.py +98 -0
- package/python/foxclaw/finance/graph.py +179 -0
- package/python/foxclaw/finance/models.py +146 -0
- package/python/foxclaw/finance/nlparse.py +515 -0
- package/python/foxclaw/finance/policy.py +301 -0
- package/python/foxclaw/finance/reasoner.py +121 -0
- package/python/foxclaw/finance/reasoning.py +319 -0
- package/python/foxclaw/finance/reconcile.py +175 -0
- package/python/foxclaw/finance/runtime.py +500 -0
- package/python/foxclaw/governance/__init__.py +24 -0
- package/python/foxclaw/governance/middleware.py +176 -0
- package/python/foxclaw/harness/__init__.py +17 -0
- package/python/foxclaw/harness/_base.py +66 -0
- package/python/foxclaw/harness/_policy.py +340 -0
- package/python/foxclaw/harness/drift.py +77 -0
- package/python/foxclaw/harness/event_bus.py +28 -0
- package/python/foxclaw/harness/harness.py +358 -0
- package/python/foxclaw/harness/loop_detection.py +145 -0
- package/python/foxclaw/itinerary/__init__.py +10 -0
- package/python/foxclaw/itinerary/amap_client.py +114 -0
- package/python/foxclaw/itinerary/models.py +80 -0
- package/python/foxclaw/itinerary/reasoner.py +96 -0
- package/python/foxclaw/itinerary/reasoning.py +168 -0
- package/python/foxclaw/itinerary/runtime.py +144 -0
- package/python/foxclaw/kernel/__init__.py +13 -0
- package/python/foxclaw/kernel/capabilities.py +72 -0
- package/python/foxclaw/kernel/policy_gate.py +108 -0
- package/python/foxclaw/kernel/process_manager.py +186 -0
- package/python/foxclaw/kernel/scheduler.py +125 -0
- package/python/foxclaw/kernel/sentinel.py +443 -0
- package/python/foxclaw/kernel/sentinel_client.py +243 -0
- package/python/foxclaw/kernel/spine.py +97 -0
- package/python/foxclaw/knowledge/__init__.py +360 -0
- package/python/foxclaw/knowledge/truth_crystallizer.py +89 -0
- package/python/foxclaw/learning/__init__.py +12 -0
- package/python/foxclaw/learning/knowledge_graph.py +144 -0
- package/python/foxclaw/learning/models.py +93 -0
- package/python/foxclaw/learning/reasoner.py +67 -0
- package/python/foxclaw/learning/runtime.py +351 -0
- package/python/foxclaw/learning/spaced_repetition.py +91 -0
- package/python/foxclaw/mcp_server.py +188 -0
- package/python/foxclaw/orchestration/__init__.py +167 -0
- package/python/foxclaw/pipeline/__init__.py +23 -0
- package/python/foxclaw/pipeline/cognitive_pipeline.py +429 -0
- package/python/foxclaw/pipeline/stage_meta.py +21 -0
- package/python/foxclaw/pipeline/supervisor_stages.py +201 -0
- package/python/foxclaw/planning/__init__.py +17 -0
- package/python/foxclaw/planning/llm_planner.py +232 -0
- package/python/foxclaw/planning/planner.py +94 -0
- package/python/foxclaw/search/__init__.py +24 -0
- package/python/foxclaw/search/agent_port.py +190 -0
- package/python/foxclaw/search/evidence.py +109 -0
- package/python/foxclaw/search/external_search.py +50 -0
- package/python/foxclaw/search/hkc_read_port.py +60 -0
- package/python/foxclaw/search/internal_search.py +71 -0
- package/python/foxclaw/search/models.py +127 -0
- package/python/foxclaw/search/planner.py +44 -0
- package/python/foxclaw/search/retriever.py +39 -0
- package/python/foxclaw/search/runtime.py +127 -0
- package/python/foxclaw/search/strategy.py +44 -0
- package/python/foxclaw/skills/__init__.py +559 -0
- package/python/foxclaw/skills/archive.py +111 -0
- package/python/foxclaw/skills/fetch.py +226 -0
- package/python/foxclaw/skills/hooks_spec.py +69 -0
- package/python/foxclaw/skills/install_cmd.py +216 -0
- package/python/foxclaw/skills/lifecycle.py +252 -0
- package/python/foxclaw/skills/markdown_skill.py +175 -0
- package/python/foxclaw/skills/markdown_store.py +39 -0
- package/python/foxclaw/skills/mcp_client.py +184 -0
- package/python/foxclaw/skills/mcp_store.py +40 -0
- package/python/foxclaw/skills/permission.py +145 -0
- package/python/foxclaw/skills/pipeline.py +354 -0
- package/python/foxclaw/skills/policy.py +74 -0
- package/python/foxclaw/skills/review.py +72 -0
- package/python/foxclaw/skills/store.py +57 -0
- package/python/frontend/assets/core_bg.jpg +0 -0
- package/python/frontend/deck/auth.js +25 -0
- package/python/frontend/deck/chat_model_picker.js +483 -0
- package/python/frontend/deck/domain.js +276 -0
- package/python/frontend/deck/main.js +1806 -0
- package/python/frontend/deck/markdown.js +44 -0
- package/python/frontend/deck/settings.js +307 -0
- package/python/frontend/deck/state.js +5 -0
- package/python/frontend/deck/util.js +4 -0
- package/python/frontend/deck/visuals.js +190 -0
- package/python/frontend/deck.css +855 -0
- package/python/frontend/deck.html +686 -0
- package/python/frontend/deck_v2.html +341 -0
- package/python/frontend/planet/index.html +266 -0
- package/python/frontend/planet/planet.css +579 -0
- package/python/frontend/planet/planet.js +1436 -0
- package/python/frontend/planet/vendor/three.core.min.js +6 -0
- package/python/frontend/planet/vendor/three.module.min.js +6 -0
- package/python/frontend/v3/assets/index-CQSBdxk4.js +34 -0
- package/python/frontend/v3/assets/index-D5nIsjms.css +1 -0
- package/python/frontend/v3/index.html +15 -0
- package/python/frontend/widget_runtime.js +252 -0
- package/python/frontend/widgets.js +639 -0
- package/python/frontend_src/index.html +14 -0
- package/python/frontend_src/package-lock.json +1376 -0
- package/python/frontend_src/package.json +19 -0
- package/python/frontend_src/src/App.vue +58 -0
- package/python/frontend_src/src/api.js +82 -0
- package/python/frontend_src/src/components/ChatDock.vue +365 -0
- package/python/frontend_src/src/components/ComposerMenu.vue +75 -0
- package/python/frontend_src/src/components/DocViewer.vue +162 -0
- package/python/frontend_src/src/components/Inspector.vue +235 -0
- package/python/frontend_src/src/components/LeftRail.vue +415 -0
- package/python/frontend_src/src/components/MenuPopover.vue +128 -0
- package/python/frontend_src/src/components/MessageStream.vue +389 -0
- package/python/frontend_src/src/components/ModelPicker.vue +350 -0
- package/python/frontend_src/src/components/QuickIngest.vue +112 -0
- package/python/frontend_src/src/components/Stage.vue +272 -0
- package/python/frontend_src/src/components/ToolMenu.vue +141 -0
- package/python/frontend_src/src/components/TopBar.vue +118 -0
- package/python/frontend_src/src/components/panels/ActivityPanel.vue +82 -0
- package/python/frontend_src/src/components/panels/AgentsPanel.vue +83 -0
- package/python/frontend_src/src/components/panels/KnowledgePanel.vue +425 -0
- package/python/frontend_src/src/components/panels/MemoryPanel.vue +117 -0
- package/python/frontend_src/src/components/panels/PanelBox.vue +50 -0
- package/python/frontend_src/src/components/panels/ReviewPanel.vue +292 -0
- package/python/frontend_src/src/components/panels/SettingsPanel.vue +358 -0
- package/python/frontend_src/src/components/panels/TasksPanel.vue +73 -0
- package/python/frontend_src/src/components/panels/ToolsPanel.vue +746 -0
- package/python/frontend_src/src/components/panels/UsagePanel.vue +105 -0
- package/python/frontend_src/src/lib/fmt.js +44 -0
- package/python/frontend_src/src/lib/i18n.js +53 -0
- package/python/frontend_src/src/lib/locales/en.js +173 -0
- package/python/frontend_src/src/lib/locales/zh.js +174 -0
- package/python/frontend_src/src/lib/md.js +190 -0
- package/python/frontend_src/src/main.js +9 -0
- package/python/frontend_src/src/stores/app.js +91 -0
- package/python/frontend_src/src/stores/chat.js +450 -0
- package/python/frontend_src/src/stores/model.js +96 -0
- package/python/frontend_src/src/stores/panels.js +289 -0
- package/python/frontend_src/src/stores/profile.js +31 -0
- package/python/frontend_src/src/stores/system.js +25 -0
- package/python/frontend_src/src/styles/base.css +138 -0
- package/python/frontend_src/src/styles/panel.css +117 -0
- package/python/frontend_src/src/styles/tokens.css +78 -0
- package/python/frontend_src/vite.config.js +39 -0
- package/python/pyproject.toml +268 -0
- package/python/requirements.txt +311 -0
- package/python/skills/README.md +123 -0
- package/python/skills/execution-contract/SKILL.md +30 -0
- package/python/skills/general-assistant/SKILL.md +34 -0
- package/python/skills/planner/SKILL.md +33 -0
- package/python/skills/schedule-itinerary/SKILL.md +35 -0
- package/python/skills/skill-composition/SKILL.md +31 -0
- package/python/skills/skill-guard/SKILL.md +67 -0
- package/python/skills/skill-memory/SKILL.md +50 -0
- package/python/skills/skill-router/SKILL.md +35 -0
- package/python/tests/conftest.py +54 -0
- package/python/tests/run_all.py +200 -0
- package/python/tests/test_agent_lifecycle.py +326 -0
- package/python/tests/test_ahs_p2.py +393 -0
- package/python/tests/test_anthropic_tools.py +192 -0
- package/python/tests/test_api.py +97 -0
- package/python/tests/test_api_auth.py +79 -0
- package/python/tests/test_api_host_guard.py +69 -0
- package/python/tests/test_attachments.py +151 -0
- package/python/tests/test_audit_chain.py +116 -0
- package/python/tests/test_audit_sink.py +130 -0
- package/python/tests/test_browser.py +149 -0
- package/python/tests/test_browser_request_guard.py +180 -0
- package/python/tests/test_capabilities.py +152 -0
- package/python/tests/test_channel_signing.py +185 -0
- package/python/tests/test_channel_trust.py +109 -0
- package/python/tests/test_channels.py +174 -0
- package/python/tests/test_cli.py +46 -0
- package/python/tests/test_compaction_toolpair.py +119 -0
- package/python/tests/test_config_layering.py +61 -0
- package/python/tests/test_confirm_nonce.py +186 -0
- package/python/tests/test_context_compaction_wiring.py +124 -0
- package/python/tests/test_dispatch.py +89 -0
- package/python/tests/test_domain_evals.py +334 -0
- package/python/tests/test_domain_import.py +72 -0
- package/python/tests/test_domain_reasoners.py +134 -0
- package/python/tests/test_e2e.py +161 -0
- package/python/tests/test_emb_cache.py +97 -0
- package/python/tests/test_embedding_singleton.py +87 -0
- package/python/tests/test_envfile.py +83 -0
- package/python/tests/test_evals_smoke.py +90 -0
- package/python/tests/test_event_spine.py +174 -0
- package/python/tests/test_evidence_semantic.py +88 -0
- package/python/tests/test_evidence_sse.py +94 -0
- package/python/tests/test_file_ingest.py +135 -0
- package/python/tests/test_finance.py +144 -0
- package/python/tests/test_finance_ledger.py +245 -0
- package/python/tests/test_finance_persist.py +174 -0
- package/python/tests/test_gateway.py +125 -0
- package/python/tests/test_governance.py +421 -0
- package/python/tests/test_governance_audit.py +324 -0
- package/python/tests/test_governance_middleware.py +137 -0
- package/python/tests/test_hkc.py +268 -0
- package/python/tests/test_hkc_index_build_manager.py +306 -0
- package/python/tests/test_hkc_manifest_reuse.py +294 -0
- package/python/tests/test_hkc_search_event_sync.py +482 -0
- package/python/tests/test_import_path_guard.py +155 -0
- package/python/tests/test_injection_guard.py +193 -0
- package/python/tests/test_integration.py +117 -0
- package/python/tests/test_itinerary.py +100 -0
- package/python/tests/test_kee_semantic.py +84 -0
- package/python/tests/test_kernel.py +212 -0
- package/python/tests/test_learning.py +101 -0
- package/python/tests/test_llm_admin.py +145 -0
- package/python/tests/test_llm_planner.py +344 -0
- package/python/tests/test_markdown_skills.py +62 -0
- package/python/tests/test_markdown_skills_openclaw.py +66 -0
- package/python/tests/test_mcp_connectors.py +97 -0
- package/python/tests/test_mcp_guardian_discovery.py +87 -0
- package/python/tests/test_mcp_no_memory.py +43 -0
- package/python/tests/test_mcp_policy_gate.py +76 -0
- package/python/tests/test_mcp_server.py +92 -0
- package/python/tests/test_memory_recall.py +92 -0
- package/python/tests/test_metrics.py +58 -0
- package/python/tests/test_multi_chain.py +90 -0
- package/python/tests/test_multimodal.py +122 -0
- package/python/tests/test_negotiation.py +136 -0
- package/python/tests/test_orchestration.py +109 -0
- package/python/tests/test_orchestration_decoupled.py +103 -0
- package/python/tests/test_p3_p5_hardening.py +324 -0
- package/python/tests/test_parallel_dispatch.py +207 -0
- package/python/tests/test_pipeline.py +492 -0
- package/python/tests/test_plan_visible.py +86 -0
- package/python/tests/test_planner.py +88 -0
- package/python/tests/test_policy_gate.py +108 -0
- package/python/tests/test_profile.py +67 -0
- package/python/tests/test_readme_claims.py +163 -0
- package/python/tests/test_reasoner.py +170 -0
- package/python/tests/test_release_check.py +252 -0
- package/python/tests/test_resume_checkpoint.py +148 -0
- package/python/tests/test_routing.py +85 -0
- package/python/tests/test_scheduler.py +138 -0
- package/python/tests/test_search.py +194 -0
- package/python/tests/test_secrets.py +153 -0
- package/python/tests/test_semantic.py +69 -0
- package/python/tests/test_sessions.py +90 -0
- package/python/tests/test_settings.py +265 -0
- package/python/tests/test_shadow_learning.py +290 -0
- package/python/tests/test_shared_write.py +200 -0
- package/python/tests/test_skill_taint_gate.py +145 -0
- package/python/tests/test_skills.py +117 -0
- package/python/tests/test_skills_fetch.py +282 -0
- package/python/tests/test_stats_and_events.py +162 -0
- package/python/tests/test_streaming.py +55 -0
- package/python/tests/test_supervisor_pipeline.py +176 -0
- package/python/tests/test_supervisor_triage.py +102 -0
- package/python/tests/test_taint.py +112 -0
- package/python/tests/test_task_stream.py +74 -0
- package/python/tests/test_thinking_sse.py +66 -0
- package/python/tests/test_thinking_stream.py +76 -0
- package/python/tests/test_tool_center.py +113 -0
- package/python/tests/test_tool_parallel.py +113 -0
- package/python/tests/test_tool_params.py +99 -0
- package/python/tests/test_tool_use.py +229 -0
- package/python/tests/test_toplevel_concurrency.py +116 -0
- package/python/tests/test_tracing.py +256 -0
- package/python/tests/test_truth_crystallizer.py +125 -0
- package/python/tests/test_truth_flow.py +88 -0
- package/python/tests/test_update_check.py +95 -0
- package/python/tests/test_url_policy.py +53 -0
- package/python/tests/test_verify_evidence.py +212 -0
- package/python/tests/test_version_sync.py +100 -0
- package/python/tests/test_web_trigger.py +82 -0
- package/python/tools/check_faiss_type.py +30 -0
- package/python/tools/check_log.ps1 +38 -0
- package/python/tools/ivf_status.py +72 -0
- package/python/tools/mypy_baseline.txt +13 -0
- package/python/tools/mypy_ratchet.py +143 -0
- package/python/tools/pack.py +173 -0
- package/python/tools/release_check.py +349 -0
- package/python/tools/restart_foxclaw.ps1 +71 -0
- package/python/tools/shared_write_audit.py +190 -0
- package/python/tools/size_baseline.txt +28 -0
- package/python/tools/size_check.py +102 -0
- package/python/tools/strip_comments.py +228 -0
- package/python/tools/verify_env.bat +2 -0
- package/python/tools/verify_env.py +25 -0
- package/python/vendor/HMR_LICENSE +37 -0
- package/python/vendor/HMR_README.md +65 -0
- package/python/vendor/hkc/LICENSE +37 -0
- package/python/vendor/hkc/hkc_ace/__init__.py +0 -0
- package/python/vendor/hkc/hkc_ace/ace.py +457 -0
- package/python/vendor/hkc/hkc_ace/skill_taxonomy.json +465 -0
- package/python/vendor/hkc/hkc_api/__init__.py +0 -0
- package/python/vendor/hkc/hkc_api/container.py +416 -0
- package/python/vendor/hkc/hkc_api/ingest_jobs.py +103 -0
- package/python/vendor/hkc/hkc_api/main.py +157 -0
- package/python/vendor/hkc/hkc_api/routes/__init__.py +0 -0
- package/python/vendor/hkc/hkc_api/routes/ability.py +151 -0
- package/python/vendor/hkc/hkc_api/routes/config.py +51 -0
- package/python/vendor/hkc/hkc_api/routes/knowledge.py +630 -0
- package/python/vendor/hkc/hkc_api/routes/search.py +88 -0
- package/python/vendor/hkc/hkc_api/schemas.py +153 -0
- package/python/vendor/hkc/hkc_api/synthesis.py +179 -0
- package/python/vendor/hkc/hkc_core/__init__.py +0 -0
- package/python/vendor/hkc/hkc_core/graph/__init__.py +0 -0
- package/python/vendor/hkc/hkc_core/graph/base.py +188 -0
- package/python/vendor/hkc/hkc_core/graph/sqlite_store.py +789 -0
- package/python/vendor/hkc/hkc_core/models/__init__.py +0 -0
- package/python/vendor/hkc/hkc_core/models/enums.py +65 -0
- package/python/vendor/hkc/hkc_core/models/ku.py +307 -0
- package/python/vendor/hkc/hkc_core/utils/__init__.py +0 -0
- package/python/vendor/hkc/hkc_core/utils/id_gen.py +113 -0
- package/python/vendor/hkc/hkc_crystallizer/__init__.py +44 -0
- package/python/vendor/hkc/hkc_crystallizer/adapters.py +94 -0
- package/python/vendor/hkc/hkc_crystallizer/candidate.py +145 -0
- package/python/vendor/hkc/hkc_crystallizer/crystallizer.py +179 -0
- package/python/vendor/hkc/hkc_crystallizer/ingress.py +90 -0
- package/python/vendor/hkc/hkc_kde/__init__.py +0 -0
- package/python/vendor/hkc/hkc_kde/chunker.py +197 -0
- package/python/vendor/hkc/hkc_kde/extractor.py +623 -0
- package/python/vendor/hkc/hkc_kde/kde.py +298 -0
- package/python/vendor/hkc/hkc_kde/loaders/__init__.py +0 -0
- package/python/vendor/hkc/hkc_kde/loaders/ebook_loader.py +153 -0
- package/python/vendor/hkc/hkc_kde/loaders/office_loader.py +194 -0
- package/python/vendor/hkc/hkc_kde/loaders/pdf_loader.py +162 -0
- package/python/vendor/hkc/hkc_kde/loaders/text_loader.py +157 -0
- package/python/vendor/hkc/hkc_kde/loaders/web_loader.py +91 -0
- package/python/vendor/hkc/hkc_kde/models.py +74 -0
- package/python/vendor/hkc/hkc_kde/packager.py +329 -0
- package/python/vendor/hkc/hkc_kde/relation_disc.py +151 -0
- package/python/vendor/hkc/hkc_kee/__init__.py +0 -0
- package/python/vendor/hkc/hkc_kee/dedup.py +227 -0
- package/python/vendor/hkc/hkc_kee/fingerprint.py +106 -0
- package/python/vendor/hkc/hkc_kee/kee.py +541 -0
- package/python/vendor/hkc/hkc_kep/__init__.py +0 -0
- package/python/vendor/hkc/hkc_kep/event_bus.py +205 -0
- package/python/vendor/hkc/hkc_sdk/__init__.py +63 -0
- package/python/vendor/hkc/hkc_sdk/base.py +151 -0
- package/python/vendor/hkc/hkc_sdk/direct_client.py +153 -0
- package/python/vendor/hkc/hkc_sdk/exceptions.py +39 -0
- package/python/vendor/hkc/hkc_sdk/http_client.py +166 -0
- package/python/vendor/hkc/hkc_sdk/models.py +171 -0
- package/python/vendor/hkc/hkc_search/__init__.py +0 -0
- package/python/vendor/hkc/hkc_search/bm25.py +325 -0
- package/python/vendor/hkc/hkc_search/embedding_backends.py +374 -0
- package/python/vendor/hkc/hkc_search/graph_search.py +132 -0
- package/python/vendor/hkc/hkc_search/hybrid.py +331 -0
- package/python/vendor/hkc/hkc_search/index_build_manager.py +378 -0
- package/python/vendor/hkc/hkc_search/vector_search.py +484 -0
- package/python/vendor/hmr/__init__.py +0 -0
- package/python/vendor/hmr/core/__init__.py +0 -0
- package/python/vendor/hmr/core/hmr.py +684 -0
- package/python/vendor/hmr/core/models.py +310 -0
- package/python/vendor/hmr/engines/__init__.py +0 -0
- package/python/vendor/hmr/engines/evolution.py +710 -0
- package/python/vendor/hmr/engines/jit_compiler.py +472 -0
- package/python/vendor/hmr/engines/lifecycle.py +264 -0
- package/python/vendor/hmr/engines/policy.py +625 -0
- package/python/vendor/hmr/engines/recall.py +260 -0
- package/python/vendor/hmr/engines/runtime_state.py +158 -0
- package/python/vendor/hmr/engines/scheduler.py +323 -0
- package/python/vendor/hmr/engines/semantic.py +150 -0
- package/python/vendor/hmr/engines/temporal.py +261 -0
- package/python/vendor/hmr/engines/thought_chain.py +635 -0
- package/python/vendor/hmr/graph/__init__.py +0 -0
- package/python/vendor/hmr/graph/cwg.py +338 -0
- package/python/vendor/hmr/graph/memory_graph.py +530 -0
- package/python/vendor/hmr/storage/__init__.py +0 -0
- package/python/vendor/hmr/storage/memory_fs.py +300 -0
- package/python/vendor/hmr/storage/vector_store.py +520 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { escapeHtml } from './util.js';
|
|
2
|
+
|
|
3
|
+
function _safeUrl(u){ u=(u||'').trim(); return (/^https?:\/\//i.test(u)||/^mailto:/i.test(u))?u:''; }
|
|
4
|
+
function _safeImgUrl(u){ u=(u||'').trim(); return (/^https?:\/\//i.test(u)||/^data:image\/(png|jpe?g|gif|webp);base64,/i.test(u))?u:''; }
|
|
5
|
+
function _mdInline(s){
|
|
6
|
+
s=s.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(m,alt,url)=>{ const u=_safeImgUrl(url); return u?`<img class="cc-img" src="${u}" alt="${alt}" loading="lazy">`:m; });
|
|
7
|
+
s=s.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(m,txt,url)=>{ const u=_safeUrl(url); return u?`<a href="${u}" target="_blank" rel="noopener noreferrer">${txt}</a>`:m; });
|
|
8
|
+
s=s.replace(/(^|\s)(https?:\/\/[^\s<]+?\.(?:png|jpe?g|gif|webp))(?=\s|$)/gi,(m,pre,url)=>`${pre}<img class="cc-img" src="${url}" alt="" loading="lazy">`);
|
|
9
|
+
s=s.replace(/(^|\s)(https?:\/\/[^\s<]+?\.(?:mp3|wav|ogg|m4a))(?=\s|$)/gi,(m,pre,url)=>`${pre}<audio class="cc-media" controls src="${url}"></audio>`);
|
|
10
|
+
s=s.replace(/(^|\s)(https?:\/\/[^\s<]+?\.(?:mp4|webm|mov))(?=\s|$)/gi,(m,pre,url)=>`${pre}<video class="cc-media" controls src="${url}"></video>`);
|
|
11
|
+
s=s.replace(/`([^`]+)`/g,(m,c)=>`<code class="cc-ic">${c}</code>`);
|
|
12
|
+
s=s.replace(/\*\*([^*]+)\*\*/g,'<strong>$1</strong>').replace(/__([^_]+)__/g,'<strong>$1</strong>');
|
|
13
|
+
s=s.replace(/(^|[^*])\*([^*\n]+)\*/g,'$1<em>$2</em>').replace(/(^|[^_\w])_([^_\n]+)_/g,'$1<em>$2</em>');
|
|
14
|
+
return s;
|
|
15
|
+
}
|
|
16
|
+
export function renderMarkdown(src){
|
|
17
|
+
if(!src) return '';
|
|
18
|
+
const blocks=[];
|
|
19
|
+
src=src.replace(/```(\w*)\n?([\s\S]*?)```/g,(m,lang,code)=>{ blocks.push(`<pre class="cc-code"><code>${escapeHtml(code.replace(/\n$/,''))}</code></pre>`); return `B${blocks.length-1}`; });
|
|
20
|
+
const t=escapeHtml(src); // 整体转义:此后所有原始 <>&" 都是纯文本
|
|
21
|
+
const lines=t.split('\n'); const out=[]; let inUl=false, inOl=false;
|
|
22
|
+
const closeLists=()=>{ if(inUl){out.push('</ul>');inUl=false;} if(inOl){out.push('</ol>');inOl=false;} };
|
|
23
|
+
for(const raw of lines){
|
|
24
|
+
const line=raw, tr=line.trim(); let m;
|
|
25
|
+
if(/^B\d+$/.test(tr)){ closeLists(); out.push(tr); continue; }
|
|
26
|
+
if((m=line.match(/^(#{1,6})\s+(.*)$/))){ closeLists(); const n=m[1].length; out.push(`<h${n} class="cc-h">${_mdInline(m[2])}</h${n}>`); continue; }
|
|
27
|
+
if(/^\s*([-*_])\s*\1\s*\1\s*$/.test(line)){ closeLists(); out.push('<hr class="cc-hr">'); continue; }
|
|
28
|
+
if((m=line.match(/^\s*>\s?(.*)$/))){ closeLists(); out.push(`<blockquote class="cc-bq">${_mdInline(m[1])}</blockquote>`); continue; }
|
|
29
|
+
if((m=line.match(/^\s*[-*+]\s+(.*)$/))){ if(inOl){out.push('</ol>');inOl=false;} if(!inUl){out.push('<ul class="cc-ul">');inUl=true;} out.push(`<li>${_mdInline(m[1])}</li>`); continue; }
|
|
30
|
+
if((m=line.match(/^\s*\d+\.\s+(.*)$/))){ if(inUl){out.push('</ul>');inUl=false;} if(!inOl){out.push('<ol class="cc-ol">');inOl=true;} out.push(`<li>${_mdInline(m[1])}</li>`); continue; }
|
|
31
|
+
if(tr===''){ closeLists(); continue; }
|
|
32
|
+
closeLists(); out.push(`<p class="cc-p">${_mdInline(line)}</p>`);
|
|
33
|
+
}
|
|
34
|
+
closeLists();
|
|
35
|
+
let html=out.join('');
|
|
36
|
+
html=html.replace(/B(\d+)/g,(m,i)=>blocks[+i]||'');
|
|
37
|
+
return html;
|
|
38
|
+
}
|
|
39
|
+
/* 把 markdown 结果渲染进回复区(带 .cc-md 容器,关掉 pre-wrap)*/
|
|
40
|
+
export function renderReply(md){
|
|
41
|
+
const rp=document.getElementById('ccReply');
|
|
42
|
+
rp.innerHTML='<div class="cc-md">'+renderMarkdown(md)+'</div>';
|
|
43
|
+
rp.scrollTop=rp.scrollHeight;
|
|
44
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { API } from './state.js';
|
|
2
|
+
|
|
3
|
+
const SETTINGS_TITLE={
|
|
4
|
+
model:'模型路由',runtime:'运行参数',ui:'界面偏好',data:'数据管理',auth:'访问密钥',about:'关于',
|
|
5
|
+
'ag-supervisor':'主管 Agent','ag-finance':'财务 Agent','ag-admin':'行政 Agent',
|
|
6
|
+
'ag-office':'办公 Agent','ag-assistant':'助手 Agent',
|
|
7
|
+
'mem-backend':'记忆后端','mem-layer':'双层记忆','mem-recall':'召回参数','mem-manage':'记忆管理',
|
|
8
|
+
};
|
|
9
|
+
export const uiPref={ autoChat:true, ballAnim:false, mapStyle:'light' }; // ballAnim 默认 false(球体特效默认关,省 GPU;需要时手动勾)
|
|
10
|
+
let _sysInfo=null;
|
|
11
|
+
async function fetchSysInfo(){ try{ _sysInfo=await(await fetch(`${API}/system/info`)).json(); }catch(e){ _sysInfo=null; } return _sysInfo; }
|
|
12
|
+
|
|
13
|
+
async function renderSettingDetail(key){
|
|
14
|
+
const body=document.getElementById('sdBody');
|
|
15
|
+
body.innerHTML='<div class="sd-ph">加载中…</div>';
|
|
16
|
+
if(key==='model'){
|
|
17
|
+
const d=await fetchSysInfo(); const m=d?.model||{};
|
|
18
|
+
let h=`<div class="sd-card"><div class="sd-k">当前模型</div>
|
|
19
|
+
<div class="sd-big">${(m.provider||'—')} <span>${m.active?m.model:'(降级 stub)'}</span></div></div>`;
|
|
20
|
+
h+='<div class="sd-sec">可用 Provider · 点击切换<span class="badge edit">可调</span></div>';
|
|
21
|
+
(m.available_providers||[]).forEach(p=>{
|
|
22
|
+
const cur=p.provider===m.provider, dis=!p.configured;
|
|
23
|
+
h+=`<div class="sd-row ${cur?'cur':''} ${dis?'dis':''}" ${dis||cur?'':`onclick="switchProvider('${p.provider}')"`}>
|
|
24
|
+
<span>${PROVIDER_LABEL[p.provider]?.n||p.provider}<small>${p.default_model}</small></span>
|
|
25
|
+
<span class="tag">${cur?'当前':dis?'未配置':'可用'}</span></div>`;
|
|
26
|
+
});
|
|
27
|
+
h+='<div class="sd-note">模型 Key 在项目根目录 <code>.env</code> 配置,改后重启生效。</div>';
|
|
28
|
+
body.innerHTML=h;
|
|
29
|
+
}else if(key==='runtime'){
|
|
30
|
+
const d=await fetchSysInfo();
|
|
31
|
+
body.innerHTML=`
|
|
32
|
+
<div class="sd-sec">运行参数<span class="badge ro">只读</span></div>
|
|
33
|
+
<div class="sd-ro">
|
|
34
|
+
<div class="sd-kv"><span>数据目录</span><b>${d?.data_dir||'—'}</b></div>
|
|
35
|
+
<div class="sd-kv"><span>Harness 影子轮数</span><b>${d?.shadow_rounds??'—'}</b></div>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="sd-note">运行参数在 <code>.env</code> 配置(FOXCLAW_DATA_DIR / FOXCLAW_SHADOW_ROUNDS),改后重启生效。影子轮数越小,Harness 越快进入漂移拦截模式。</div>`;
|
|
38
|
+
}else if(key==='ui'){
|
|
39
|
+
body.innerHTML=`
|
|
40
|
+
<div class="sd-sec">界面偏好<span class="badge edit">可调</span></div>
|
|
41
|
+
<div class="sd-toggle"><span>发任务自动弹中央对话层</span><label class="sw"><input type="checkbox" id="pf-autoChat" ${uiPref.autoChat?'checked':''}><i></i></label></div>
|
|
42
|
+
<div class="sd-toggle"><span>背景全息球动画</span><label class="sw"><input type="checkbox" id="pf-ballAnim" ${uiPref.ballAnim?'checked':''}><i></i></label></div>
|
|
43
|
+
<div class="sd-kv2"><span>地图默认样式</span>
|
|
44
|
+
<select id="pf-mapStyle"><option value="light" ${uiPref.mapStyle==='light'?'selected':''}>亮色(官网风格)</option><option value="dark" ${uiPref.mapStyle==='dark'?'selected':''}>暗色</option></select></div>
|
|
45
|
+
<div class="sd-note">界面偏好实时生效,保存在当前会话。</div>`;
|
|
46
|
+
document.getElementById('pf-autoChat').onchange=e=>uiPref.autoChat=e.target.checked;
|
|
47
|
+
document.getElementById('pf-ballAnim').onchange=e=>{uiPref.ballAnim=e.target.checked; toggleBallAnim(e.target.checked);};
|
|
48
|
+
document.getElementById('pf-mapStyle').onchange=e=>uiPref.mapStyle=e.target.value;
|
|
49
|
+
}else if(key==='data'){
|
|
50
|
+
const s=await(await fetch(`${API}/memory/stats`)).json().catch(()=>({}));
|
|
51
|
+
body.innerHTML=`
|
|
52
|
+
<div class="sd-kv"><span>记忆后端</span><b>${s.backend||'—'}</b></div>
|
|
53
|
+
<div class="sd-kv"><span>记忆总条数</span><b>${s.total_memories??0}</b></div>
|
|
54
|
+
<div class="sd-kv"><span>知识关系数</span><b>${s.relations??0}</b></div>
|
|
55
|
+
<div class="sd-note">运行数据存于本地 <code>foxclaw_data/</code> 目录。清空数据请在本地删除该目录后重启(网页端不直接删除,避免误操作)。</div>`;
|
|
56
|
+
}else if(key==='auth'){
|
|
57
|
+
const cur=localStorage.getItem('foxclawApiKey')||'';
|
|
58
|
+
body.innerHTML=`
|
|
59
|
+
<div class="sd-sec">后端访问密钥<span class="badge ${cur?'ro':'edit'}">${cur?'已配置':'未配置'}</span></div>
|
|
60
|
+
<div class="sd-desc">后端 <code>.env</code> 若设置了 <code>FOXCLAW_API_KEY</code>,则所有 <code>/api</code>、<code>/knowledge</code> 请求与 WebSocket 都需携带此密钥,否则返回 401/403、数据无法加载。填入与 <code>.env</code> 相同的值即可恢复。</div>
|
|
61
|
+
<div class="api-key-row">
|
|
62
|
+
<input type="password" id="pf-apiKey" class="api-key-inp" placeholder="粘贴 FOXCLAW_API_KEY 的值" value="${cur}" autocomplete="off" spellcheck="false">
|
|
63
|
+
</div>
|
|
64
|
+
<div class="api-key-btns">
|
|
65
|
+
<button id="pf-apiKey-save" class="api-key-btn primary">保存并重连</button>
|
|
66
|
+
<button id="pf-apiKey-clear" class="api-key-btn">清除</button>
|
|
67
|
+
</div>
|
|
68
|
+
<div class="sd-note">密钥仅保存在本机浏览器 <code>localStorage</code>,不会上传到服务器。后端未设 <code>FOXCLAW_API_KEY</code> 时此项留空即可(默认开放)。</div>`;
|
|
69
|
+
document.getElementById('pf-apiKey-save').onclick=()=>{
|
|
70
|
+
const v=document.getElementById('pf-apiKey').value.trim();
|
|
71
|
+
if(v) localStorage.setItem('foxclawApiKey', v);
|
|
72
|
+
else localStorage.removeItem('foxclawApiKey');
|
|
73
|
+
location.reload();
|
|
74
|
+
};
|
|
75
|
+
document.getElementById('pf-apiKey-clear').onclick=()=>{
|
|
76
|
+
localStorage.removeItem('foxclawApiKey');
|
|
77
|
+
location.reload();
|
|
78
|
+
};
|
|
79
|
+
}else if(key==='about'){
|
|
80
|
+
const d=await fetchSysInfo();
|
|
81
|
+
body.innerHTML=`
|
|
82
|
+
<div class="sd-card"><div class="sd-big">Foxclaw <span>v${d?.version||'1.0.0'}</span></div>
|
|
83
|
+
<div class="sd-desc">有记忆的个人智能体 · 记忆/认知层与 LLM 解耦</div></div>
|
|
84
|
+
<div class="sd-sec">五个 Agent</div>
|
|
85
|
+
<div class="sd-kv"><span>主管 Supervisor</span><b>分诊调度 · 全局态势</b></div>
|
|
86
|
+
<div class="sd-kv"><span>财务 Finance</span><b>理财 · 风控 · 守门人</b></div>
|
|
87
|
+
<div class="sd-kv"><span>行政 Admin</span><b>行程 · 路线 · 高德地图</b></div>
|
|
88
|
+
<div class="sd-kv"><span>办公 Office</span><b>学习 · 知识图谱</b></div>
|
|
89
|
+
<div class="sd-kv"><span>助手 Assistant</span><b>通用 · Skill 接入</b></div>
|
|
90
|
+
<div class="sd-sec">三大模块</div>
|
|
91
|
+
<div class="sd-desc">Foxclaw(主系统) · Agents(三智能体) · HMR(记忆系统)</div>
|
|
92
|
+
<div class="sd-note">配置说明见项目 <code>docs/配置指南.md</code></div>`;
|
|
93
|
+
}else if(key && key.startsWith('mem-')){
|
|
94
|
+
const s=await(await fetch(`${API}/memory/stats`)).json().catch(()=>({}));
|
|
95
|
+
if(key==='mem-backend'){
|
|
96
|
+
body.innerHTML=`
|
|
97
|
+
<div class="sd-card"><div class="sd-big">${s.backend||'HMR'} <span>v${s.version||'—'}</span></div>
|
|
98
|
+
<div class="sd-desc">分层记忆系统 · 记忆/认知层与 LLM 解耦</div></div>
|
|
99
|
+
<div class="sd-sec">后端信息<span class="badge ro">只读</span></div>
|
|
100
|
+
<div class="sd-kv"><span>记忆后端</span><b>${s.backend||'—'}</b></div>
|
|
101
|
+
<div class="sd-kv"><span>版本</span><b>v${s.version||'—'}</b></div>
|
|
102
|
+
<div class="sd-kv"><span>Embedding 模型</span><b>${s.embedding||'—'}</b></div>
|
|
103
|
+
<div class="sd-kv"><span>知识图谱关系数</span><b>${s.relations??0}</b></div>
|
|
104
|
+
<div class="sd-note">安装 <code>openai</code> 或 <code>sentence-transformers</code> 可启用更精确的语义向量(当前默认 TF-IDF n-gram 降级)。</div>`;
|
|
105
|
+
}else if(key==='mem-layer'){
|
|
106
|
+
const ba=s.by_agent||{}; const entries=Object.entries(ba).sort((a,b)=>b[1]-a[1]);
|
|
107
|
+
let rows=entries.length?entries.map(([a,n])=>`<div class="sd-kv"><span>${AGENT_META[a]?.cn||a}</span><b>${n} 条</b></div>`).join(''):'<div class="sd-desc">暂无分层记忆数据。</div>';
|
|
108
|
+
body.innerHTML=`
|
|
109
|
+
<div class="sd-sec">双层记忆架构<span class="badge ro">只读</span></div>
|
|
110
|
+
<div class="sd-kv"><span>私有层(各 Agent 独立)</span><b>${s.private??0} 条</b></div>
|
|
111
|
+
<div class="sd-kv"><span>共享层(跨 Agent 可召回)</span><b>${s.shared??0} 条</b></div>
|
|
112
|
+
<div class="sd-sec">按 Agent 分布<span class="badge ro">只读</span></div>
|
|
113
|
+
${rows}
|
|
114
|
+
<div class="sd-note">私有层:每个 Agent 只能召回自己的记忆;共享层:标记 shared 的记忆所有 Agent 都可召回(如主管的全局决策)。</div>`;
|
|
115
|
+
}else if(key==='mem-recall'){
|
|
116
|
+
body.innerHTML=`
|
|
117
|
+
<div class="sd-sec">召回参数<span class="badge ro">只读</span></div>
|
|
118
|
+
<div class="sd-kv"><span>默认召回数量 (top-k)</span><b>5</b></div>
|
|
119
|
+
<div class="sd-kv"><span>相似度阈值</span><b>自适应</b></div>
|
|
120
|
+
<div class="sd-kv"><span>召回范围</span><b>本 Agent 私有 + 共享层</b></div>
|
|
121
|
+
<div class="sd-note">召回采用语义向量相似度排序,默认返回最相关的 top-k 条记忆 + 共享层记忆。参数在记忆适配器中定义,随召回质量自调。</div>`;
|
|
122
|
+
}else if(key==='mem-manage'){
|
|
123
|
+
body.innerHTML=`
|
|
124
|
+
<div class="sd-card"><div class="sd-big">${s.total_memories??0} <span>条记忆</span></div>
|
|
125
|
+
<div class="sd-desc">私有 ${s.private??0} · 共享 ${s.shared??0} · 关系 ${s.relations??0}</div></div>
|
|
126
|
+
<div class="sd-sec">记忆管理<span class="badge ro">只读</span></div>
|
|
127
|
+
<div class="sd-kv"><span>记忆总条数</span><b>${s.total_memories??0}</b></div>
|
|
128
|
+
<div class="sd-kv"><span>知识关系数</span><b>${s.relations??0}</b></div>
|
|
129
|
+
<div class="sd-note">运行数据存于本地 <code>foxclaw_data/</code> 目录。清空记忆请在本地删除该目录后重启(网页端不直接删除,避免误操作)。导出功能可通过 HMR 后端 API 实现。</div>`;
|
|
130
|
+
}
|
|
131
|
+
}else if(key && key.startsWith('ag-')){
|
|
132
|
+
await renderAgentDetail(key.slice(3), body);
|
|
133
|
+
}else{
|
|
134
|
+
body.innerHTML=`<div class="sd-ph">该模块设置开发中</div>`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const AGENT_META={
|
|
139
|
+
supervisor:{cn:'主管',en:'Supervisor',ac:'#ffc24b',role:'分诊调度 · 全局态势编排'},
|
|
140
|
+
finance:{cn:'财务',en:'Finance',ac:'#00ffb2',role:'理财 · 预算 · 风控守门'},
|
|
141
|
+
admin:{cn:'行政',en:'Admin',ac:'#ff9d00',role:'行程 · 日程 · 高德地图'},
|
|
142
|
+
office:{cn:'办公',en:'Office',ac:'#d99a3c',role:'学习 · 知识 · 间隔重复'},
|
|
143
|
+
assistant:{cn:'助手',en:'Assistant',ac:'#38bdf8',role:'通用任务 · Skill 接入'},
|
|
144
|
+
};
|
|
145
|
+
async function renderAgentDetail(aid, body){
|
|
146
|
+
const meta=AGENT_META[aid]||{cn:aid,en:aid,ac:'#00d9ff',role:''};
|
|
147
|
+
let hs=null, sys=null;
|
|
148
|
+
try{ hs=await(await fetch(`${API}/harness/${aid}/status`)).json(); }catch(e){}
|
|
149
|
+
try{ sys=await fetchSysInfo(); }catch(e){}
|
|
150
|
+
const ag=sys?.agents?.[aid]||{};
|
|
151
|
+
const shadow=ag.shadow_mode, rounds=ag.shadow_rounds??'—', run=ag.run_count??0;
|
|
152
|
+
const th=hs?.thresholds||{}, w=hs?.weights||{}, pol=hs?.policy||{};
|
|
153
|
+
|
|
154
|
+
let h=`<div class="sd-card" style="border-color:${meta.ac}55">
|
|
155
|
+
<div class="sd-big" style="color:${meta.ac}">${meta.cn} <span>${meta.en}</span></div>
|
|
156
|
+
<div class="sd-desc">${meta.role}</div></div>`;
|
|
157
|
+
|
|
158
|
+
h+='<div class="sd-sec">Harness 漂移检测<span class="badge ro">只读</span></div>';
|
|
159
|
+
h+=`<div class="sd-kv"><span>运行模式</span><b style="color:${shadow?'var(--amber)':'var(--green)'}">${shadow?'影子校准中':'已激活拦截'}</b></div>`;
|
|
160
|
+
h+=`<div class="sd-kv"><span>校准进度</span><b>${run} / ${rounds} 轮</b></div>`;
|
|
161
|
+
if(th.warn!=null||th.block!=null){
|
|
162
|
+
h+=`<div class="sd-kv"><span>预警阈值 (WARN)</span><b>${fmt(th.warn)}</b></div>`;
|
|
163
|
+
h+=`<div class="sd-kv"><span>拦截阈值 (BLOCK)</span><b>${fmt(th.block)}</b></div>`;
|
|
164
|
+
}
|
|
165
|
+
if(w.semantic!=null){
|
|
166
|
+
h+=`<div class="sd-kv"><span>三维权重</span><b>语义 ${fmt(w.semantic)} · 工具 ${fmt(w.tool)} · 范围 ${fmt(w.scope)}</b></div>`;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
h+='<div class="sd-sec">守门人 Policy<span class="badge ro">只读</span></div>';
|
|
170
|
+
if(pol.version!=null||pol.total_rules!=null){
|
|
171
|
+
h+=`<div class="sd-kv"><span>Policy 版本</span><b>v${pol.version??'—'}</b></div>`;
|
|
172
|
+
h+=`<div class="sd-kv"><span>规则总数</span><b>${pol.total_rules??0}</b></div>`;
|
|
173
|
+
h+=`<div class="sd-kv"><span>手工规则 / 自学习</span><b>${pol.manual_rules??0} / ${pol.learned_rules??0}</b></div>`;
|
|
174
|
+
}else{
|
|
175
|
+
h+='<div class="sd-desc">策略随运行自学习更新,当前无自定义规则覆盖。</div>';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if(aid==='admin'){
|
|
179
|
+
h+='<div class="sd-sec">高德地图(行政专属)<span class="badge ro">只读</span></div>';
|
|
180
|
+
const a=sys?.amap||{};
|
|
181
|
+
h+=`<div class="sd-kv"><span>Web服务 Key(路线/POI)</span><b style="color:${a.web_key?'var(--green)':'var(--ink-faint)'}">${a.web_key?'已配置':'未配置'}</b></div>`;
|
|
182
|
+
h+=`<div class="sd-kv"><span>JSAPI Key(前端地图)</span><b style="color:${a.js_key?'var(--green)':'var(--ink-faint)'}">${a.js_key?'已配置':'未配置'}</b></div>`;
|
|
183
|
+
h+=`<div class="sd-kv"><span>JSAPI 安全密钥</span><b style="color:${a.js_scode?'var(--green)':'var(--ink-faint)'}">${a.js_scode?'已配置':'未配置'}</b></div>`;
|
|
184
|
+
h+=`<div class="sd-toggle"><span>地图默认样式(暗色)</span><label class="sw"><input type="checkbox" id="pf-mapDark2" ${uiPref.mapStyle==='dark'?'checked':''}><i></i></label></div>`;
|
|
185
|
+
h+='<div class="sd-note">高德三个 Key 在 <code>.env</code> 配置(AMAP_MAPS_API_KEY / AMAP_JS_KEY / AMAP_JS_SCODE)。</div>';
|
|
186
|
+
}else if(aid==='finance'){
|
|
187
|
+
h+='<div class="sd-sec">财务领域参数<span class="badge ro">只读</span></div>';
|
|
188
|
+
h+='<div class="sd-desc">预算阈值、MAD 异常灵敏度、风控规则在财务内核 policy 中定义,随交易数据自学习。守门人对大额/越权操作执行确认或冻结。</div>';
|
|
189
|
+
}else if(aid==='office'){
|
|
190
|
+
h+='<div class="sd-sec">学习领域参数<span class="badge ro">只读</span></div>';
|
|
191
|
+
h+='<div class="sd-desc">采用 SM-2 间隔重复算法管理知识复习节奏;知识图谱关系自动抽取,守门人防止知识污染。</div>';
|
|
192
|
+
}else if(aid==='supervisor'){
|
|
193
|
+
h+='<div class="sd-sec">路由编排<span class="badge ro">只读</span></div>';
|
|
194
|
+
h+='<div class="sd-desc">元问题(介绍/系统级)由主管自答;业务任务按关键词分诊到财务/行政/办公/助手。可在 agents.py 的 ROUTING_KEYWORDS / META_KEYWORDS 调整。</div>';
|
|
195
|
+
}else if(aid==='assistant'){
|
|
196
|
+
h+='<div class="sd-sec">Skill 接入<span class="badge ro">只读</span></div>';
|
|
197
|
+
h+='<div class="sd-desc">通用任务兜底处理,可接入外部 Skill 工具扩展能力。主管无法明确归类的任务默认派给助手。</div>';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
h+='<div class="sd-note">Agent 行为参数大多在后端 policy 与代码中定义,此处为只读状态展示。漂移阈值由影子校准期自动学习得出。</div>';
|
|
201
|
+
body.innerHTML=h;
|
|
202
|
+
|
|
203
|
+
const md=document.getElementById('pf-mapDark2');
|
|
204
|
+
if(md) md.onchange=e=>{ uiPref.mapStyle=e.target.checked?'dark':'light'; };
|
|
205
|
+
}
|
|
206
|
+
function fmt(v){ return (v==null||isNaN(v))?'—':(typeof v==='number'?v.toFixed(3):v); }
|
|
207
|
+
export async function switchProvider(prov){
|
|
208
|
+
try{ await fetch(`${API}/model/switch`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({provider:prov})});
|
|
209
|
+
_sysInfo=null; renderSettingDetail('model'); loadModel(); }catch(e){}
|
|
210
|
+
}
|
|
211
|
+
function toggleBallAnim(on){
|
|
212
|
+
const c=document.getElementById('coreCanvas'); if(c)c.style.display=on?'block':'none';
|
|
213
|
+
try{ localStorage.setItem('foxclaw_lowpower', on ? '0' : '1'); }catch{}
|
|
214
|
+
if (!on) {
|
|
215
|
+
console.info('[foxclaw] 关掉球动画后需刷新一次才停止 GPU 占用');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const SETTINGS_SUBS={
|
|
220
|
+
foxclaw:[['model','模型路由'],['runtime','运行参数'],['ui','界面偏好'],['data','数据管理'],['auth','访问密钥'],['about','关于']],
|
|
221
|
+
agents:[['ag-supervisor','主管 Agent'],['ag-finance','财务 Agent'],['ag-admin','行政 Agent'],['ag-office','办公 Agent'],['ag-assistant','助手 Agent']],
|
|
222
|
+
hmr:[['mem-backend','记忆后端'],['mem-layer','双层记忆'],['mem-recall','召回参数'],['mem-manage','记忆管理']],
|
|
223
|
+
};
|
|
224
|
+
const _setMenu=document.getElementById('setMenu');
|
|
225
|
+
const _smL2=document.getElementById('smL2');
|
|
226
|
+
const _sdPop=document.getElementById('sdPop');
|
|
227
|
+
let _setHideTimer=null;
|
|
228
|
+
|
|
229
|
+
export function openSetMenu(){ clearTimeout(_setHideTimer); _setMenu.classList.add('show'); }
|
|
230
|
+
export function openAuthSetting(){ _setMenu.classList.add('show'); openDetailPop('auth'); }
|
|
231
|
+
function closeSetMenu(){
|
|
232
|
+
clearTimeout(_setHideTimer);
|
|
233
|
+
_setHideTimer=setTimeout(()=>{ _setMenu.classList.remove('show'); _smL2.innerHTML=''; document.querySelectorAll('.sm-l1 .sm-btn').forEach(b=>b.classList.remove('active')); }, 400);
|
|
234
|
+
}
|
|
235
|
+
function showL2(group, l1btn){
|
|
236
|
+
document.querySelectorAll('.sm-l1 .sm-btn').forEach(b=>b.classList.remove('active'));
|
|
237
|
+
l1btn.classList.add('active');
|
|
238
|
+
_smL2.innerHTML=(SETTINGS_SUBS[group]||[]).map(([k,name])=>
|
|
239
|
+
`<div class="sm-btn" data-sub="${k}"><b>${name}</b><span class="chev">›</span></div>`).join('');
|
|
240
|
+
_smL2.querySelectorAll('.sm-btn').forEach(b=>{
|
|
241
|
+
b.addEventListener('click',()=>openDetailPop(b.dataset.sub));
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
function openDetailPop(key){
|
|
245
|
+
document.getElementById('sdTitle').textContent=SETTINGS_TITLE[key]||'详情';
|
|
246
|
+
_sdPop.classList.add('show');
|
|
247
|
+
renderSettingDetail(key);
|
|
248
|
+
}
|
|
249
|
+
function closeDetailPop(){ _sdPop.classList.remove('show'); }
|
|
250
|
+
|
|
251
|
+
const _gear=document.getElementById('settingsBtn');
|
|
252
|
+
_gear.addEventListener('mouseenter', openSetMenu);
|
|
253
|
+
_gear.addEventListener('mouseleave', closeSetMenu);
|
|
254
|
+
_gear.addEventListener('click', openSetMenu);
|
|
255
|
+
_setMenu.addEventListener('mouseenter', ()=>clearTimeout(_setHideTimer));
|
|
256
|
+
_setMenu.addEventListener('mouseleave', closeSetMenu);
|
|
257
|
+
document.querySelectorAll('.sm-l1 .sm-btn').forEach(b=>{
|
|
258
|
+
b.addEventListener('mouseenter', ()=>showL2(b.dataset.group, b));
|
|
259
|
+
});
|
|
260
|
+
document.getElementById('settingsBtn2')?.addEventListener('click', ()=>{ openSetMenu(); clearTimeout(_setHideTimer); });
|
|
261
|
+
document.getElementById('sdClose').addEventListener('click', closeDetailPop);
|
|
262
|
+
|
|
263
|
+
document.querySelectorAll('.nav-mini, .feed-item').forEach(it=>{
|
|
264
|
+
it.addEventListener('click',()=>{ it.classList.add('pressed'); setTimeout(()=>it.classList.remove('pressed'),180); });
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const PROVIDER_LABEL=
|
|
268
|
+
{anthropic:{n:'Claude',c:'#ff9d00'},openai:{n:'GPT',c:'#00ffb2'},
|
|
269
|
+
google:{n:'Gemini',c:'#38bdf8'},qwen:{n:'通义千问',c:'#ffc24b'},
|
|
270
|
+
local:{n:'本地模型',c:'#d99a3c'},stub:{n:'Stub 降级',c:'#7e93b8'}};
|
|
271
|
+
async function loadModel(){
|
|
272
|
+
try{
|
|
273
|
+
const d=await(await fetch(`${API}/model`)).json();
|
|
274
|
+
const lbl=PROVIDER_LABEL[d.provider]||{n:d.provider,c:'#7e93b8'};
|
|
275
|
+
document.getElementById('modelName').textContent=lbl.n;
|
|
276
|
+
renderModelMenu(d);
|
|
277
|
+
}catch(e){}
|
|
278
|
+
}
|
|
279
|
+
function renderModelMenu(d){
|
|
280
|
+
const menu=document.getElementById('modelMenu'); if(!menu)return;
|
|
281
|
+
let h='<div class="mtitle">模型路由 · 点击切换</div>';
|
|
282
|
+
(d.available_providers||[]).forEach(p=>{
|
|
283
|
+
const lbl=PROVIDER_LABEL[p.provider]||{n:p.provider,c:'#7e93b8'};
|
|
284
|
+
const cur=p.provider===d.provider;
|
|
285
|
+
const dis=!p.configured;
|
|
286
|
+
h+=`<div class="model-opt ${cur?'active':''} ${dis?'disabled':''}" data-prov="${p.provider}">
|
|
287
|
+
<span class="mdot" style="background:${lbl.c};box-shadow:0 0 6px ${lbl.c}"></span>
|
|
288
|
+
<span class="mname"><b>${lbl.n}</b><span>${p.default_model}</span></span>
|
|
289
|
+
${cur?'<span class="mtag">当前</span>':dis?'<span class="mtag" style="background:rgba(255,157,0,.12);color:var(--amber)">未配置</span>':'<span class="mtag">可用</span>'}</div>`;
|
|
290
|
+
});
|
|
291
|
+
menu.innerHTML=h;
|
|
292
|
+
menu.querySelectorAll('.model-opt:not(.disabled):not(.active)').forEach(opt=>{
|
|
293
|
+
opt.addEventListener('click',async()=>{
|
|
294
|
+
const prov=opt.dataset.prov;
|
|
295
|
+
try{await fetch(`${API}/model/switch`,{method:'POST',headers:{'Content-Type':'application/json'},
|
|
296
|
+
body:JSON.stringify({provider:prov})});
|
|
297
|
+
menu.classList.remove('show'); loadModel();
|
|
298
|
+
}catch(e){}
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
document.getElementById('modelPill').addEventListener('click',e=>{
|
|
303
|
+
e.stopPropagation();
|
|
304
|
+
document.getElementById('modelMenu').classList.toggle('show');
|
|
305
|
+
});
|
|
306
|
+
document.addEventListener('click',()=>document.getElementById('modelMenu')?.classList.remove('show'));
|
|
307
|
+
loadModel();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const _origin=(location.protocol==='http:'||location.protocol==='https:')?location.origin:'http://localhost:8000';
|
|
2
|
+
const API=_origin+'/api';
|
|
3
|
+
const WS=_origin.replace(/^http/,'ws')+'/ws/harness';
|
|
4
|
+
let _lastKernelData={}; // 缓存各 Agent 最近一次内核数据,供全屏复用
|
|
5
|
+
export { _origin, API, WS, _lastKernelData };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
const _lowpower = (() => {
|
|
2
|
+
try {
|
|
3
|
+
if (new URLSearchParams(location.search).get('visual') === '1') return false;
|
|
4
|
+
if (localStorage.getItem('foxclaw_visual') === '1') return false;
|
|
5
|
+
if (localStorage.getItem('foxclaw_lowpower') === '0') return false; // 兼容旧版开关
|
|
6
|
+
if (new URLSearchParams(location.search).get('low') === '1') return true;
|
|
7
|
+
if (matchMedia('(prefers-reduced-motion: reduce)').matches) return true;
|
|
8
|
+
if (navigator.connection && navigator.connection.saveData) return true;
|
|
9
|
+
} catch {}
|
|
10
|
+
return true; // ← 默认:不启动(保护 GPU + 启动秒开)
|
|
11
|
+
})();
|
|
12
|
+
window._foxclawLowpower = _lowpower; // 暴露给其他模块读
|
|
13
|
+
window.foxclawVisual = {
|
|
14
|
+
isOn: () => !_lowpower,
|
|
15
|
+
on() { try { localStorage.setItem('foxclaw_visual', '1'); } catch{} location.reload(); },
|
|
16
|
+
off() { try { localStorage.removeItem('foxclaw_visual'); localStorage.setItem('foxclaw_lowpower', '1'); } catch{} location.reload(); },
|
|
17
|
+
toggle() { this.isOn() ? this.off() : this.on(); },
|
|
18
|
+
};
|
|
19
|
+
if (_lowpower) console.info('[foxclaw] 球体特效已关闭(默认) — 想看动画:控制台跑 foxclawVisual.on() 或 URL 加 ?visual=1');
|
|
20
|
+
function _lpThrottle(fn, fps) { // 30fps 节流(不关,但降频)— 关闭模式直接 noop
|
|
21
|
+
if (_lowpower) return () => {};
|
|
22
|
+
let last = 0; const gap = 1000 / fps;
|
|
23
|
+
return function(t) { if (t - last >= gap) { last = t; fn(t); } };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
(function(){
|
|
27
|
+
if (_lowpower) return; // 省电:不开中央全息核心(520 球面点 + 经纬弧 + 渐变 60fps)
|
|
28
|
+
const c=document.getElementById('coreCanvas'), x=c.getContext('2d');
|
|
29
|
+
function size(){const r=c.parentElement.getBoundingClientRect();c.width=r.width;c.height=r.height;}
|
|
30
|
+
size(); window.addEventListener('resize',size);
|
|
31
|
+
const N=520, pts=[];
|
|
32
|
+
for(let i=0;i<N;i++){const t=Math.acos(2*Math.random()-1),p=Math.random()*Math.PI*2;
|
|
33
|
+
pts.push({t,p});}
|
|
34
|
+
let rot=0;
|
|
35
|
+
function loop(){
|
|
36
|
+
x.clearRect(0,0,c.width,c.height);
|
|
37
|
+
const cx=c.width/2, cy=c.height/2, R=Math.min(cx,cy)*0.62;
|
|
38
|
+
rot+=0.0024;
|
|
39
|
+
for(let k=0;k<3;k++){
|
|
40
|
+
x.beginPath();
|
|
41
|
+
x.ellipse(cx,cy+R*0.92,R*(1.05+k*0.18),R*(0.26+k*0.05),0,0,Math.PI*2);
|
|
42
|
+
x.strokeStyle=`rgba(0,217,255,${0.18-k*0.04})`; x.lineWidth=2; x.stroke();
|
|
43
|
+
}
|
|
44
|
+
for(const pt of pts){
|
|
45
|
+
const t=pt.t, p=pt.p+rot;
|
|
46
|
+
const xx=Math.sin(t)*Math.cos(p), yy=Math.cos(t), zz=Math.sin(t)*Math.sin(p);
|
|
47
|
+
const sx=cx+xx*R, sy=cy+yy*R;
|
|
48
|
+
const depth=(zz+1)/2;
|
|
49
|
+
x.beginPath(); x.arc(sx,sy,depth*1.6+0.3,0,Math.PI*2);
|
|
50
|
+
const hue=depth>0.5?'0,217,255':'255,194,75';
|
|
51
|
+
x.fillStyle=`rgba(${hue},${depth*0.85+0.1})`; x.fill();
|
|
52
|
+
}
|
|
53
|
+
x.strokeStyle='rgba(41,243,255,.12)';x.lineWidth=1;
|
|
54
|
+
for(let m=0;m<6;m++){
|
|
55
|
+
x.beginPath();
|
|
56
|
+
for(let a=0;a<=64;a++){const t=a/64*Math.PI, p=m/6*Math.PI*2+rot;
|
|
57
|
+
const xx=Math.sin(t)*Math.cos(p),yy=Math.cos(t),zz=Math.sin(t)*Math.sin(p);
|
|
58
|
+
const sx=cx+xx*R,sy=cy+yy*R; a?x.lineTo(sx,sy):x.moveTo(sx,sy);}
|
|
59
|
+
x.stroke();
|
|
60
|
+
}
|
|
61
|
+
const g=x.createRadialGradient(cx,cy,0,cx,cy,R*0.5);
|
|
62
|
+
g.addColorStop(0,'rgba(0,217,255,.28)');g.addColorStop(1,'transparent');
|
|
63
|
+
x.fillStyle=g;x.beginPath();x.arc(cx,cy,R*0.5,0,Math.PI*2);x.fill();
|
|
64
|
+
requestAnimationFrame(loop);
|
|
65
|
+
}
|
|
66
|
+
loop();
|
|
67
|
+
})();
|
|
68
|
+
|
|
69
|
+
(function(){
|
|
70
|
+
if (_lowpower) return; // 省电:不开记忆向量空间动画
|
|
71
|
+
const c=document.getElementById('memCanvas'); if(!c) return; // 右栏改版后无此装饰画布 → 静默跳过
|
|
72
|
+
const x=c.getContext('2d');
|
|
73
|
+
function size(){const r=c.parentElement.getBoundingClientRect();c.width=r.width;c.height=r.height;}
|
|
74
|
+
size();window.addEventListener('resize',size);
|
|
75
|
+
const nodes=[];for(let i=0;i<46;i++)nodes.push({x:Math.random(),y:Math.random(),z:Math.random(),s:Math.random()*2+1});
|
|
76
|
+
let rot=0;
|
|
77
|
+
function loop(){
|
|
78
|
+
x.clearRect(0,0,c.width,c.height);rot+=0.005;
|
|
79
|
+
const cx=c.width/2,cy=c.height/2;
|
|
80
|
+
nodes.forEach(n=>{
|
|
81
|
+
const a=n.x*Math.PI*2+rot, rad=(n.y*0.4+0.15)*Math.min(cx,cy);
|
|
82
|
+
const px=cx+Math.cos(a)*rad, py=cy+Math.sin(a)*rad*0.6+(n.z-0.5)*40;
|
|
83
|
+
n._x=px;n._y=py;
|
|
84
|
+
x.beginPath();x.arc(px,py,n.s,0,Math.PI*2);
|
|
85
|
+
x.fillStyle=n.z>0.5?'rgba(255,194,75,.9)':'rgba(0,217,255,.85)';x.fill();
|
|
86
|
+
});
|
|
87
|
+
x.strokeStyle='rgba(255,194,75,.12)';x.lineWidth=.5;
|
|
88
|
+
for(let i=0;i<nodes.length;i++)for(let j=i+1;j<nodes.length;j++){
|
|
89
|
+
const dx=nodes[i]._x-nodes[j]._x,dy=nodes[i]._y-nodes[j]._y,d=Math.hypot(dx,dy);
|
|
90
|
+
if(d<46){x.beginPath();x.moveTo(nodes[i]._x,nodes[i]._y);x.lineTo(nodes[j]._x,nodes[j]._y);x.stroke();}
|
|
91
|
+
}
|
|
92
|
+
requestAnimationFrame(loop);
|
|
93
|
+
}
|
|
94
|
+
loop();
|
|
95
|
+
})();
|
|
96
|
+
|
|
97
|
+
(function(){
|
|
98
|
+
if (_lowpower) return; // 省电:不开中枢数据流 + 2.2s 粒子 emit
|
|
99
|
+
const cv=document.getElementById('streamCanvas'); if(!cv)return;
|
|
100
|
+
const ctx=cv.getContext('2d');
|
|
101
|
+
const center=document.querySelector('.center');
|
|
102
|
+
function resize(){ const r=center.getBoundingClientRect(); cv.width=r.width; cv.height=r.height; }
|
|
103
|
+
resize(); window.addEventListener('resize',resize);
|
|
104
|
+
function pts(){
|
|
105
|
+
const cr=center.getBoundingClientRect();
|
|
106
|
+
const core=document.querySelector('.corewrap');
|
|
107
|
+
const coreC=core?core.getBoundingClientRect():cr;
|
|
108
|
+
const origin={x:coreC.left-cr.left+coreC.width/2, y:coreC.top-cr.top+coreC.height/2};
|
|
109
|
+
const targets=[...document.querySelectorAll('.acard')].map(a=>{
|
|
110
|
+
const b=a.getBoundingClientRect();
|
|
111
|
+
return {x:b.left-cr.left+b.width/2, y:b.top-cr.top+b.height/2,
|
|
112
|
+
color:getComputedStyle(a).getPropertyValue('--ac').trim()||'#00d9ff'};
|
|
113
|
+
});
|
|
114
|
+
return {origin,targets};
|
|
115
|
+
}
|
|
116
|
+
let particles=[];
|
|
117
|
+
function emit(targetAgent){
|
|
118
|
+
const {origin,targets}=pts();
|
|
119
|
+
if(!targets.length)return;
|
|
120
|
+
let t;
|
|
121
|
+
if(targetAgent){
|
|
122
|
+
const cards=[...document.querySelectorAll('.acard')];
|
|
123
|
+
const idx=cards.findIndex(c=>c.dataset.agent===targetAgent);
|
|
124
|
+
t=idx>=0?targets[idx]:targets[Math.floor(Math.random()*targets.length)];
|
|
125
|
+
}else{
|
|
126
|
+
t=targets[Math.floor(Math.random()*targets.length)];
|
|
127
|
+
}
|
|
128
|
+
const reverse=targetAgent?false:Math.random()<0.4; // 发任务恒为 核心→Agent
|
|
129
|
+
particles.push({
|
|
130
|
+
sx:reverse?t.x:origin.x, sy:reverse?t.y:origin.y,
|
|
131
|
+
ex:reverse?origin.x:t.x, ey:reverse?origin.y:t.y,
|
|
132
|
+
x:reverse?t.x:origin.x, y:reverse?t.y:origin.y,
|
|
133
|
+
p:0, speed:0.012+Math.random()*0.01, color:t.color, trail:[]
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
window._emitStream=emit; // 暴露给发任务联动
|
|
137
|
+
function ease(t){ return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2; }
|
|
138
|
+
function hexA(c,a){
|
|
139
|
+
c=c||'#00d9ff';
|
|
140
|
+
if(c.startsWith('rgb'))return c.replace(/rgba?\(([^)]+)\)/,(m,p)=>{const v=p.split(',').slice(0,3).join(','); return `rgba(${v},${a})`;});
|
|
141
|
+
let h=c.replace('#',''); if(h.length===3)h=h.split('').map(x=>x+x).join('');
|
|
142
|
+
const n=parseInt(h,16); return `rgba(${(n>>16)&255},${(n>>8)&255},${n&255},${a})`;
|
|
143
|
+
}
|
|
144
|
+
function loop(){
|
|
145
|
+
ctx.clearRect(0,0,cv.width,cv.height);
|
|
146
|
+
particles.forEach(pt=>{
|
|
147
|
+
pt.p+=pt.speed;
|
|
148
|
+
pt.x=pt.sx+(pt.ex-pt.sx)*ease(pt.p);
|
|
149
|
+
pt.y=pt.sy+(pt.ey-pt.sy)*ease(pt.p);
|
|
150
|
+
pt.trail.push({x:pt.x,y:pt.y}); if(pt.trail.length>14)pt.trail.shift();
|
|
151
|
+
pt.trail.forEach((tp,i)=>{
|
|
152
|
+
const a=(i/pt.trail.length)*(1-pt.p)*0.7;
|
|
153
|
+
ctx.beginPath(); ctx.arc(tp.x,tp.y,1.6,0,7);
|
|
154
|
+
ctx.fillStyle=hexA(pt.color,a); ctx.fill();
|
|
155
|
+
});
|
|
156
|
+
ctx.beginPath(); ctx.arc(pt.x,pt.y,2.4,0,7);
|
|
157
|
+
ctx.fillStyle=hexA(pt.color,(1-pt.p)*0.9); ctx.shadowBlur=8; ctx.shadowColor=pt.color; ctx.fill(); ctx.shadowBlur=0;
|
|
158
|
+
});
|
|
159
|
+
particles=particles.filter(pt=>pt.p<1);
|
|
160
|
+
requestAnimationFrame(loop);
|
|
161
|
+
}
|
|
162
|
+
loop();
|
|
163
|
+
setInterval(emit, 2200);
|
|
164
|
+
setTimeout(emit, 800);
|
|
165
|
+
})();
|
|
166
|
+
|
|
167
|
+
(function(){
|
|
168
|
+
if (_lowpower) return; // 省电:不开系统活动波形
|
|
169
|
+
const c=document.getElementById('actCanvas'); if(!c)return;
|
|
170
|
+
const x=c.getContext('2d');
|
|
171
|
+
function size(){const r=c.parentElement.getBoundingClientRect();c.width=r.width;c.height=90;}
|
|
172
|
+
size();window.addEventListener('resize',size);
|
|
173
|
+
let t=0;
|
|
174
|
+
function loop(){
|
|
175
|
+
x.clearRect(0,0,c.width,c.height);t+=0.03;
|
|
176
|
+
if(window.actPulse>0)window.actPulse*=0.96;
|
|
177
|
+
const boost=1+(window.actPulse||0);
|
|
178
|
+
[[ '0,217,255',0],['255,194,75',1.5]].forEach(([col,ph])=>{
|
|
179
|
+
x.beginPath();
|
|
180
|
+
for(let i=0;i<=c.width;i+=4){
|
|
181
|
+
const y=c.height/2+Math.sin(i*0.025+t+ph)*18*boost*Math.sin(i*0.006+t*0.5)+
|
|
182
|
+
Math.sin(i*0.05+t*1.3+ph)*8*boost;
|
|
183
|
+
i?x.lineTo(i,y):x.moveTo(i,y);
|
|
184
|
+
}
|
|
185
|
+
x.strokeStyle=`rgba(${col},.7)`;x.lineWidth=2;x.shadowBlur=8;x.shadowColor=`rgba(${col},.6)`;x.stroke();x.shadowBlur=0;
|
|
186
|
+
});
|
|
187
|
+
requestAnimationFrame(loop);
|
|
188
|
+
}
|
|
189
|
+
loop();
|
|
190
|
+
})();
|