foxclaw 0.1.0 → 0.1.2
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 +11 -10
- package/package.json +46 -38
- package/python/.dockerignore +35 -0
- package/python/.env.example +165 -0
- package/python/.gitattributes +46 -0
- package/python/.github/workflows/ci.yml +122 -0
- package/python/.github/workflows/release.yml +183 -0
- package/python/Dockerfile +64 -0
- package/python/LICENSE +21 -0
- package/python/MANIFEST.in +14 -0
- package/python/README.md +192 -0
- package/python/README_CN.md +324 -0
- package/python/bench/bm25_audit.py +199 -0
- package/python/bench/bm25_regression.py +178 -0
- package/python/bench/bm25_stress.py +159 -0
- package/python/bench/cd_audit.py +238 -0
- package/python/bench/chaos.py +142 -0
- package/python/bench/concurrency.py +103 -0
- package/python/bench/e2e_real_models.py +95 -0
- package/python/bench/llm_retry_test.py +248 -0
- package/python/bench/load_test.py +196 -0
- package/python/bench/vector_ivf_upgrade.py +134 -0
- package/python/docs/CHANNELS.md +195 -0
- package/python/docs/GOVERNANCE.md +164 -0
- package/python/docs/RELEASE.md +109 -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 +152 -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 +400 -0
- package/python/examples/governance_middleware_demo.py +77 -0
- package/python/examples/langgraph_governance_demo.py +108 -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 +526 -0
- package/python/foxclaw/agents/__init__.py +12 -0
- package/python/foxclaw/agents/agents.py +35 -0
- package/python/foxclaw/agents/base.py +865 -0
- package/python/foxclaw/agents/impl/__init__.py +1 -0
- package/python/foxclaw/agents/impl/_helpers.py +78 -0
- package/python/foxclaw/agents/impl/finance.py +248 -0
- package/python/foxclaw/agents/impl/office.py +367 -0
- package/python/foxclaw/agents/impl/supervisor.py +659 -0
- package/python/foxclaw/agents/mixins/_context.py +151 -0
- package/python/foxclaw/agents/mixins/augment.py +149 -0
- package/python/foxclaw/agents/mixins/llm.py +66 -0
- package/python/foxclaw/agents/mixins/memory.py +35 -0
- package/python/foxclaw/agents/mixins/preference.py +81 -0
- package/python/foxclaw/agents/mixins/prompt.py +77 -0
- package/python/foxclaw/agents/mixins/skillbox.py +58 -0
- package/python/foxclaw/agents/mixins/tool_exec.py +443 -0
- package/python/foxclaw/api/__init__.py +283 -0
- package/python/foxclaw/api/app.py +123 -0
- package/python/foxclaw/api/middleware.py +317 -0
- package/python/foxclaw/api/routes/ahs.py +417 -0
- package/python/foxclaw/api/routes/attachments.py +117 -0
- package/python/foxclaw/api/routes/browser.py +39 -0
- package/python/foxclaw/api/routes/domain.py +314 -0
- package/python/foxclaw/api/routes/knowledge.py +163 -0
- package/python/foxclaw/api/routes/llm_admin.py +461 -0
- package/python/foxclaw/api/routes/memory.py +89 -0
- package/python/foxclaw/api/routes/orchestration.py +41 -0
- package/python/foxclaw/api/routes/recovery.py +43 -0
- package/python/foxclaw/api/routes/review.py +275 -0
- package/python/foxclaw/api/routes/search.py +37 -0
- package/python/foxclaw/api/routes/system.py +327 -0
- package/python/foxclaw/api/routes/task.py +281 -0
- package/python/foxclaw/api/routes/ws.py +68 -0
- package/python/foxclaw/api/spine.py +55 -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 +54 -0
- package/python/foxclaw/browser/action/action_types.py +45 -0
- package/python/foxclaw/browser/action/action_verifier.py +68 -0
- package/python/foxclaw/browser/action/url_policy.py +147 -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 +166 -0
- package/python/foxclaw/browser/perception/__init__.py +1 -0
- package/python/foxclaw/browser/perception/dom_extractor.py +43 -0
- package/python/foxclaw/browser/perception/element_indexer.py +57 -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 +148 -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 +67 -0
- package/python/foxclaw/channels/__init__.py +140 -0
- package/python/foxclaw/channels/discord.py +184 -0
- package/python/foxclaw/channels/dispatcher.py +204 -0
- package/python/foxclaw/channels/feishu.py +225 -0
- package/python/foxclaw/channels/openclaw_bridge.py +156 -0
- package/python/foxclaw/channels/signing.py +187 -0
- package/python/foxclaw/channels/telegram.py +121 -0
- package/python/foxclaw/channels/weixin.py +225 -0
- package/python/foxclaw/cli.py +154 -0
- package/python/foxclaw/cognitive/__init__.py +4 -0
- package/python/foxclaw/cognitive/reasoner.py +82 -0
- package/python/foxclaw/cognitive/state.py +147 -0
- package/python/foxclaw/core/__init__.py +9 -0
- package/python/foxclaw/core/audit_chain.py +133 -0
- package/python/foxclaw/core/audit_sink.py +100 -0
- package/python/foxclaw/core/compaction.py +283 -0
- package/python/foxclaw/core/config.py +65 -0
- package/python/foxclaw/core/confirm_nonce.py +157 -0
- package/python/foxclaw/core/dispatch.py +27 -0
- package/python/foxclaw/core/envfile.py +48 -0
- package/python/foxclaw/core/failure_policy.py +151 -0
- package/python/foxclaw/core/gateway.py +85 -0
- package/python/foxclaw/core/governance_audit.py +175 -0
- package/python/foxclaw/core/idempotency.py +289 -0
- package/python/foxclaw/core/injection_guard.py +221 -0
- package/python/foxclaw/core/memory_adapter.py +516 -0
- package/python/foxclaw/core/metrics.py +89 -0
- package/python/foxclaw/core/model_router.py +1097 -0
- package/python/foxclaw/core/paths.py +103 -0
- package/python/foxclaw/core/recovery.py +362 -0
- package/python/foxclaw/core/scheduler.py +144 -0
- package/python/foxclaw/core/secrets.py +134 -0
- package/python/foxclaw/core/sessions.py +157 -0
- package/python/foxclaw/core/settings.py +430 -0
- package/python/foxclaw/core/shared_write.py +198 -0
- package/python/foxclaw/core/steering_queue.py +153 -0
- package/python/foxclaw/core/system_bus.py +84 -0
- package/python/foxclaw/core/thought_chain.py +318 -0
- package/python/foxclaw/core/token_meter.py +235 -0
- package/python/foxclaw/core/tools.py +172 -0
- package/python/foxclaw/core/tracing.py +390 -0
- package/python/foxclaw/core/truth_pipeline.py +114 -0
- package/python/foxclaw/core/vec_recall_adapter.py +503 -0
- package/python/foxclaw/core/verify.py +181 -0
- package/python/foxclaw/core/web_search.py +242 -0
- package/python/foxclaw/finance/__init__.py +15 -0
- package/python/foxclaw/finance/evidence.py +153 -0
- package/python/foxclaw/finance/fx.py +100 -0
- package/python/foxclaw/finance/graph.py +188 -0
- package/python/foxclaw/finance/models.py +150 -0
- package/python/foxclaw/finance/nlparse.py +575 -0
- package/python/foxclaw/finance/policy.py +329 -0
- package/python/foxclaw/finance/reasoner.py +129 -0
- package/python/foxclaw/finance/reasoning.py +340 -0
- package/python/foxclaw/finance/reconcile.py +180 -0
- package/python/foxclaw/finance/runtime.py +527 -0
- package/python/foxclaw/governance/__init__.py +24 -0
- package/python/foxclaw/governance/middleware.py +184 -0
- package/python/foxclaw/harness/__init__.py +17 -0
- package/python/foxclaw/harness/_base.py +72 -0
- package/python/foxclaw/harness/_policy.py +359 -0
- package/python/foxclaw/harness/drift.py +89 -0
- package/python/foxclaw/harness/event_bus.py +31 -0
- package/python/foxclaw/harness/harness.py +446 -0
- package/python/foxclaw/harness/loop_detection.py +152 -0
- package/python/foxclaw/itinerary/__init__.py +10 -0
- package/python/foxclaw/itinerary/amap_client.py +117 -0
- package/python/foxclaw/itinerary/models.py +80 -0
- package/python/foxclaw/itinerary/reasoner.py +101 -0
- package/python/foxclaw/itinerary/reasoning.py +174 -0
- package/python/foxclaw/itinerary/runtime.py +148 -0
- package/python/foxclaw/kernel/__init__.py +13 -0
- package/python/foxclaw/kernel/capabilities.py +73 -0
- package/python/foxclaw/kernel/policy_gate.py +114 -0
- package/python/foxclaw/kernel/process_manager.py +205 -0
- package/python/foxclaw/kernel/scheduler.py +131 -0
- package/python/foxclaw/kernel/sentinel.py +453 -0
- package/python/foxclaw/kernel/sentinel_client.py +246 -0
- package/python/foxclaw/kernel/spine.py +97 -0
- package/python/foxclaw/knowledge/__init__.py +376 -0
- package/python/foxclaw/knowledge/truth_crystallizer.py +92 -0
- package/python/foxclaw/learning/__init__.py +12 -0
- package/python/foxclaw/learning/knowledge_graph.py +149 -0
- package/python/foxclaw/learning/models.py +93 -0
- package/python/foxclaw/learning/reasoner.py +70 -0
- package/python/foxclaw/learning/runtime.py +363 -0
- package/python/foxclaw/learning/spaced_repetition.py +96 -0
- package/python/foxclaw/mcp_server.py +189 -0
- package/python/foxclaw/orchestration/__init__.py +184 -0
- package/python/foxclaw/pipeline/__init__.py +23 -0
- package/python/foxclaw/pipeline/cognitive_pipeline.py +481 -0
- package/python/foxclaw/pipeline/supervisor_stages.py +230 -0
- package/python/foxclaw/planning/__init__.py +17 -0
- package/python/foxclaw/planning/llm_planner.py +232 -0
- package/python/foxclaw/planning/planner.py +99 -0
- package/python/foxclaw/search/__init__.py +24 -0
- package/python/foxclaw/search/agent_port.py +194 -0
- package/python/foxclaw/search/evidence.py +113 -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 +73 -0
- package/python/foxclaw/search/models.py +129 -0
- package/python/foxclaw/search/planner.py +44 -0
- package/python/foxclaw/search/retriever.py +39 -0
- package/python/foxclaw/search/runtime.py +134 -0
- package/python/foxclaw/search/strategy.py +44 -0
- package/python/foxclaw/skills/__init__.py +613 -0
- package/python/foxclaw/skills/hooks_spec.py +73 -0
- package/python/foxclaw/skills/lifecycle.py +278 -0
- package/python/foxclaw/skills/markdown_skill.py +174 -0
- package/python/foxclaw/skills/markdown_store.py +39 -0
- package/python/foxclaw/skills/mcp_client.py +190 -0
- package/python/foxclaw/skills/mcp_store.py +43 -0
- package/python/foxclaw/skills/permission.py +180 -0
- package/python/foxclaw/skills/pipeline.py +386 -0
- package/python/foxclaw/skills/policy.py +80 -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 +32 -0
- package/python/frontend/deck/chat_model_picker.js +537 -0
- package/python/frontend/deck/domain.js +296 -0
- package/python/frontend/deck/main.js +1950 -0
- package/python/frontend/deck/markdown.js +48 -0
- package/python/frontend/deck/settings.js +324 -0
- package/python/frontend/deck/state.js +6 -0
- package/python/frontend/deck/util.js +6 -0
- package/python/frontend/deck/visuals.js +212 -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 +1637 -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-BD7VPbMV.js +33 -0
- package/python/frontend/v3/assets/index-CAvnYWGH.css +1 -0
- package/python/frontend/v3/index.html +15 -0
- package/python/frontend/widget_runtime.js +295 -0
- package/python/frontend/widgets.js +696 -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 +62 -0
- package/python/frontend_src/src/api.js +89 -0
- package/python/frontend_src/src/components/ChatDock.vue +377 -0
- package/python/frontend_src/src/components/ComposerMenu.vue +75 -0
- package/python/frontend_src/src/components/DocViewer.vue +171 -0
- package/python/frontend_src/src/components/Inspector.vue +241 -0
- package/python/frontend_src/src/components/LeftRail.vue +394 -0
- package/python/frontend_src/src/components/MenuPopover.vue +130 -0
- package/python/frontend_src/src/components/MessageStream.vue +401 -0
- package/python/frontend_src/src/components/ModelPicker.vue +355 -0
- package/python/frontend_src/src/components/QuickIngest.vue +118 -0
- package/python/frontend_src/src/components/Stage.vue +226 -0
- package/python/frontend_src/src/components/ToolMenu.vue +144 -0
- package/python/frontend_src/src/components/TopBar.vue +90 -0
- package/python/frontend_src/src/components/panels/ActivityPanel.vue +84 -0
- package/python/frontend_src/src/components/panels/AgentsPanel.vue +86 -0
- package/python/frontend_src/src/components/panels/KnowledgePanel.vue +441 -0
- package/python/frontend_src/src/components/panels/MemoryPanel.vue +118 -0
- package/python/frontend_src/src/components/panels/PanelBox.vue +51 -0
- package/python/frontend_src/src/components/panels/ReviewPanel.vue +308 -0
- package/python/frontend_src/src/components/panels/SettingsPanel.vue +254 -0
- package/python/frontend_src/src/components/panels/TasksPanel.vue +74 -0
- package/python/frontend_src/src/components/panels/ToolsPanel.vue +640 -0
- package/python/frontend_src/src/components/panels/UsagePanel.vue +105 -0
- package/python/frontend_src/src/lib/fmt.js +48 -0
- package/python/frontend_src/src/lib/md.js +204 -0
- package/python/frontend_src/src/main.js +7 -0
- package/python/frontend_src/src/stores/app.js +106 -0
- package/python/frontend_src/src/stores/chat.js +484 -0
- package/python/frontend_src/src/stores/model.js +104 -0
- package/python/frontend_src/src/stores/panels.js +330 -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 +46 -0
- package/python/pyproject.toml +265 -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 +76 -0
- package/python/tests/run_all.py +263 -0
- package/python/tests/test_agent_lifecycle.py +360 -0
- package/python/tests/test_ahs_p2.py +414 -0
- package/python/tests/test_anthropic_tools.py +206 -0
- package/python/tests/test_api.py +87 -0
- package/python/tests/test_api_auth.py +83 -0
- package/python/tests/test_api_host_guard.py +69 -0
- package/python/tests/test_attachments.py +167 -0
- package/python/tests/test_audit_chain.py +121 -0
- package/python/tests/test_audit_sink.py +136 -0
- package/python/tests/test_browser.py +153 -0
- package/python/tests/test_browser_request_guard.py +184 -0
- package/python/tests/test_capabilities.py +158 -0
- package/python/tests/test_channel_signing.py +192 -0
- package/python/tests/test_channel_trust.py +109 -0
- package/python/tests/test_channels.py +184 -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 +65 -0
- package/python/tests/test_confirm_nonce.py +197 -0
- package/python/tests/test_context_compaction_wiring.py +130 -0
- package/python/tests/test_dispatch.py +95 -0
- package/python/tests/test_domain_evals.py +403 -0
- package/python/tests/test_domain_import.py +78 -0
- package/python/tests/test_domain_reasoners.py +148 -0
- package/python/tests/test_e2e.py +178 -0
- package/python/tests/test_emb_cache.py +107 -0
- package/python/tests/test_embedding_singleton.py +89 -0
- package/python/tests/test_envfile.py +83 -0
- package/python/tests/test_evals_smoke.py +114 -0
- package/python/tests/test_event_spine.py +182 -0
- package/python/tests/test_evidence_semantic.py +101 -0
- package/python/tests/test_evidence_sse.py +97 -0
- package/python/tests/test_file_ingest.py +146 -0
- package/python/tests/test_finance.py +153 -0
- package/python/tests/test_finance_ledger.py +252 -0
- package/python/tests/test_finance_persist.py +178 -0
- package/python/tests/test_gateway.py +144 -0
- package/python/tests/test_governance.py +468 -0
- package/python/tests/test_governance_audit.py +359 -0
- package/python/tests/test_governance_middleware.py +143 -0
- package/python/tests/test_hkc.py +286 -0
- package/python/tests/test_hkc_index_build_manager.py +339 -0
- package/python/tests/test_hkc_manifest_reuse.py +317 -0
- package/python/tests/test_hkc_search_event_sync.py +533 -0
- package/python/tests/test_import_path_guard.py +161 -0
- package/python/tests/test_injection_guard.py +211 -0
- package/python/tests/test_integration.py +141 -0
- package/python/tests/test_itinerary.py +103 -0
- package/python/tests/test_kee_semantic.py +89 -0
- package/python/tests/test_kernel.py +222 -0
- package/python/tests/test_learning.py +110 -0
- package/python/tests/test_llm_admin.py +160 -0
- package/python/tests/test_llm_planner.py +366 -0
- package/python/tests/test_markdown_skills.py +73 -0
- package/python/tests/test_markdown_skills_openclaw.py +71 -0
- package/python/tests/test_mcp_connectors.py +109 -0
- package/python/tests/test_mcp_guardian_discovery.py +91 -0
- package/python/tests/test_mcp_no_memory.py +43 -0
- package/python/tests/test_mcp_policy_gate.py +77 -0
- package/python/tests/test_mcp_server.py +95 -0
- package/python/tests/test_memory_recall.py +95 -0
- package/python/tests/test_metrics.py +66 -0
- package/python/tests/test_multi_chain.py +102 -0
- package/python/tests/test_multimodal.py +135 -0
- package/python/tests/test_negotiation.py +146 -0
- package/python/tests/test_orchestration.py +119 -0
- package/python/tests/test_orchestration_decoupled.py +109 -0
- package/python/tests/test_p3_p5_hardening.py +338 -0
- package/python/tests/test_parallel_dispatch.py +215 -0
- package/python/tests/test_pipeline.py +533 -0
- package/python/tests/test_plan_visible.py +86 -0
- package/python/tests/test_planner.py +95 -0
- package/python/tests/test_policy_gate.py +109 -0
- package/python/tests/test_reasoner.py +185 -0
- package/python/tests/test_release_check.py +263 -0
- package/python/tests/test_resume_checkpoint.py +156 -0
- package/python/tests/test_routing.py +95 -0
- package/python/tests/test_scheduler.py +141 -0
- package/python/tests/test_search.py +204 -0
- package/python/tests/test_secrets.py +159 -0
- package/python/tests/test_semantic.py +78 -0
- package/python/tests/test_sessions.py +91 -0
- package/python/tests/test_settings.py +281 -0
- package/python/tests/test_shadow_learning.py +330 -0
- package/python/tests/test_shared_write.py +207 -0
- package/python/tests/test_skill_taint_gate.py +154 -0
- package/python/tests/test_skills.py +133 -0
- package/python/tests/test_stats_and_events.py +165 -0
- package/python/tests/test_streaming.py +60 -0
- package/python/tests/test_supervisor_pipeline.py +177 -0
- package/python/tests/test_supervisor_triage.py +108 -0
- package/python/tests/test_taint.py +117 -0
- package/python/tests/test_task_stream.py +85 -0
- package/python/tests/test_thinking_sse.py +67 -0
- package/python/tests/test_thinking_stream.py +76 -0
- package/python/tests/test_tool_center.py +129 -0
- package/python/tests/test_tool_parallel.py +113 -0
- package/python/tests/test_tool_params.py +103 -0
- package/python/tests/test_tool_use.py +242 -0
- package/python/tests/test_toplevel_concurrency.py +117 -0
- package/python/tests/test_tracing.py +290 -0
- package/python/tests/test_truth_crystallizer.py +127 -0
- package/python/tests/test_truth_flow.py +93 -0
- package/python/tests/test_url_policy.py +53 -0
- package/python/tests/test_verify_evidence.py +225 -0
- package/python/tests/test_version_sync.py +71 -0
- package/python/tests/test_web_trigger.py +99 -0
- package/python/tools/check_faiss_type.py +31 -0
- package/python/tools/check_log.ps1 +46 -0
- package/python/tools/ivf_status.py +72 -0
- package/python/tools/mypy_baseline.txt +5 -0
- package/python/tools/mypy_ratchet.py +97 -0
- package/python/tools/pack.py +178 -0
- package/python/tools/release_check.py +349 -0
- package/python/tools/restart_foxclaw.ps1 +74 -0
- package/python/tools/shared_write_audit.py +204 -0
- package/python/tools/size_baseline.txt +28 -0
- package/python/tools/size_check.py +102 -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,640 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, onMounted, reactive, ref } from 'vue'
|
|
3
|
+
import PanelBox from './PanelBox.vue'
|
|
4
|
+
import { panels, loadPanel, refreshPanel, openMdSkill, toggleMdSkill } from '../../stores/panels.js'
|
|
5
|
+
import { getJSON, postJSON, delJSON } from '../../api.js'
|
|
6
|
+
import { clip } from '../../lib/fmt.js'
|
|
7
|
+
|
|
8
|
+
const p = panels.tools
|
|
9
|
+
const busy = ref('')
|
|
10
|
+
const err = ref('')
|
|
11
|
+
|
|
12
|
+
const mcp = ref([])
|
|
13
|
+
async function loadMcp() {
|
|
14
|
+
try {
|
|
15
|
+
const d = await getJSON('/ahs/mcp/servers')
|
|
16
|
+
mcp.value = d.servers || []
|
|
17
|
+
} catch {
|
|
18
|
+
mcp.value = []
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
onMounted(() => {
|
|
22
|
+
loadPanel('tools')
|
|
23
|
+
loadMcp()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const ready = computed(() => p.skills.length > 0 || p.md.length > 0 || mcp.value.length > 0)
|
|
27
|
+
const blocked = computed(() =>
|
|
28
|
+
p.skills.filter((s) => s.blocked).length + p.md.filter((s) => s.blocked).length
|
|
29
|
+
)
|
|
30
|
+
const breakerN = computed(() => Object.keys(p.breakers || {}).length)
|
|
31
|
+
|
|
32
|
+
const TRUST = { high: 'green', medium: 'amber', low: 'red' }
|
|
33
|
+
const trustCN = (t) => ({ high: '高信任', medium: '中信任', low: '低信任' }[t] || t || '—')
|
|
34
|
+
|
|
35
|
+
async function pickMd(s) {
|
|
36
|
+
err.value = ''
|
|
37
|
+
try { await openMdSkill(s.id) } catch (e) { err.value = String(e.message || e) }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function flip(s) {
|
|
41
|
+
busy.value = s.id
|
|
42
|
+
err.value = ''
|
|
43
|
+
try { await toggleMdSkill(s.id, !s.enabled) } catch (e) { err.value = String(e.message || e) }
|
|
44
|
+
busy.value = ''
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* ── 单技能测试:POST /ahs/skills/{id}/test ──
|
|
48
|
+
走真管线(权限/断路器/SSRF),所以界面要能填参数,也要把 needs_confirmation /
|
|
49
|
+
blocked / circuit_open 这些非成功态原样显示,不能只画个绿勾。 */
|
|
50
|
+
const tId = ref('')
|
|
51
|
+
const tArgs = ref({})
|
|
52
|
+
const tBusy = ref(false)
|
|
53
|
+
const tRes = ref(null)
|
|
54
|
+
const tErr = ref('')
|
|
55
|
+
const tNonce = ref('')
|
|
56
|
+
|
|
57
|
+
function endTest() {
|
|
58
|
+
tId.value = ''
|
|
59
|
+
tArgs.value = {}
|
|
60
|
+
tRes.value = null
|
|
61
|
+
tErr.value = ''
|
|
62
|
+
tNonce.value = ''
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function beginTest(s) {
|
|
66
|
+
if (tId.value === s.id) { endTest(); return }
|
|
67
|
+
const a = {}
|
|
68
|
+
for (const [k] of Object.entries(s.params || {})) a[k] = ''
|
|
69
|
+
tId.value = s.id
|
|
70
|
+
tArgs.value = a
|
|
71
|
+
tRes.value = null
|
|
72
|
+
tErr.value = ''
|
|
73
|
+
tNonce.value = ''
|
|
74
|
+
err.value = ''
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* params 是 {名: 类型} 的朴素 schema,类型只是提示;这里按声明做最小转换,其余原样送字符串 */
|
|
78
|
+
function coerce(params, args) {
|
|
79
|
+
const out = {}
|
|
80
|
+
for (const [k, ty] of Object.entries(params || {})) {
|
|
81
|
+
const raw = String(args[k] ?? '').trim()
|
|
82
|
+
if (raw === '') continue
|
|
83
|
+
const t = String(ty || '').toLowerCase()
|
|
84
|
+
if (t.includes('bool')) out[k] = /^(1|true|yes|y|是)$/i.test(raw)
|
|
85
|
+
else if (t.includes('float') || t.includes('number')) out[k] = Number(raw)
|
|
86
|
+
else if (t.includes('int')) out[k] = parseInt(raw, 10) || 0
|
|
87
|
+
else out[k] = raw
|
|
88
|
+
}
|
|
89
|
+
return out
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function runTest(s, confirm = false) {
|
|
93
|
+
if (tBusy.value) return
|
|
94
|
+
tBusy.value = true
|
|
95
|
+
tErr.value = ''
|
|
96
|
+
try {
|
|
97
|
+
const d = await postJSON(`/ahs/skills/${encodeURIComponent(s.id)}/test`, {
|
|
98
|
+
args: coerce(s.params, tArgs.value),
|
|
99
|
+
confirmed: confirm,
|
|
100
|
+
mode: 'strict',
|
|
101
|
+
confirm_nonce: confirm ? tNonce.value : '',
|
|
102
|
+
})
|
|
103
|
+
tRes.value = d
|
|
104
|
+
tNonce.value = d.confirm_nonce || ''
|
|
105
|
+
} catch (e) {
|
|
106
|
+
tErr.value = String(e.message || e)
|
|
107
|
+
} finally {
|
|
108
|
+
tBusy.value = false
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const pretty = (o) => {
|
|
113
|
+
if (o == null) return ''
|
|
114
|
+
if (typeof o === 'string') return o
|
|
115
|
+
try { return JSON.stringify(o, null, 2) } catch { return String(o) }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function dropSkill(s) {
|
|
119
|
+
if (!confirm(`删除技能「${s.name || s.id}」?它的触发词和参数会一起消失。`)) return
|
|
120
|
+
busy.value = s.id
|
|
121
|
+
err.value = ''
|
|
122
|
+
try {
|
|
123
|
+
await delJSON(`/ahs/skills/${encodeURIComponent(s.id)}`)
|
|
124
|
+
if (tId.value === s.id) endTest()
|
|
125
|
+
await refreshPanel('tools')
|
|
126
|
+
await loadMcp()
|
|
127
|
+
} catch (e) {
|
|
128
|
+
err.value = String(e.message || e)
|
|
129
|
+
} finally {
|
|
130
|
+
busy.value = ''
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const splitList = (t) => String(t || '').split(/[,,\s]+/).map((s) => s.trim()).filter(Boolean)
|
|
135
|
+
|
|
136
|
+
/* "city:str, days:int" → {city:"str", days:"int"} */
|
|
137
|
+
function parseParams(txt) {
|
|
138
|
+
const out = {}
|
|
139
|
+
for (const part of String(txt || '').split(/[,,;\n]/)) {
|
|
140
|
+
const i = part.search(/[::]/)
|
|
141
|
+
const k = (i < 0 ? part : part.slice(0, i)).trim()
|
|
142
|
+
const v = i < 0 ? '' : part.slice(i + 1).trim()
|
|
143
|
+
if (k) out[k] = v || 'str'
|
|
144
|
+
}
|
|
145
|
+
return out
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* "Authorization: Bearer x" 每行一条 → dict(空行 / 无冒号行忽略) */
|
|
149
|
+
function parseHeaders(txt) {
|
|
150
|
+
const out = {}
|
|
151
|
+
for (const line of String(txt || '').split('\n')) {
|
|
152
|
+
const i = line.indexOf(':')
|
|
153
|
+
if (i > 0) out[line.slice(0, i).trim()] = line.slice(i + 1).trim()
|
|
154
|
+
}
|
|
155
|
+
return out
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* ── 安装技能:POST /ahs/skills ──
|
|
159
|
+
后端只收 web_api / mcp;审核门 deny → 403, warn → 409 needs_ack(要再点一次「已知风险」) */
|
|
160
|
+
const SIDE = { read: 'read · 只读', write: 'write · 写入', send: 'send · 代发', pay: 'pay · 付款' }
|
|
161
|
+
const showIns = ref(false)
|
|
162
|
+
const insBusy = ref(false)
|
|
163
|
+
const insErr = ref('')
|
|
164
|
+
const insOk = ref('')
|
|
165
|
+
const insAck = ref(false)
|
|
166
|
+
const insParams = ref('query:str')
|
|
167
|
+
const insHeaders = ref('')
|
|
168
|
+
const ins = reactive({
|
|
169
|
+
id: '', name: '', description: '', kind: 'web_api', side_effect: 'read',
|
|
170
|
+
endpoint: '', http_method: 'GET', mcp_server: '', mcp_tool: '', triggers: '',
|
|
171
|
+
timeout: 10, destructive: false, external: true, allow_local: false,
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
function toggleIns() {
|
|
175
|
+
showIns.value = !showIns.value
|
|
176
|
+
insErr.value = ''
|
|
177
|
+
insOk.value = ''
|
|
178
|
+
insAck.value = false
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async function doInstall(ack = false) {
|
|
182
|
+
if (insBusy.value) return
|
|
183
|
+
const id = ins.id.trim()
|
|
184
|
+
insErr.value = ''
|
|
185
|
+
insOk.value = ''
|
|
186
|
+
if (!id) { insErr.value = '技能 id 必填'; return }
|
|
187
|
+
insBusy.value = true
|
|
188
|
+
const body = {
|
|
189
|
+
id,
|
|
190
|
+
name: (ins.name || id).trim(),
|
|
191
|
+
description: ins.description.trim(),
|
|
192
|
+
kind: ins.kind,
|
|
193
|
+
triggers: splitList(ins.triggers),
|
|
194
|
+
side_effect: ins.side_effect,
|
|
195
|
+
destructive: !!ins.destructive,
|
|
196
|
+
external: !!ins.external,
|
|
197
|
+
params: parseParams(insParams.value),
|
|
198
|
+
endpoint: ins.kind === 'web_api' ? ins.endpoint.trim() : '',
|
|
199
|
+
http_method: ins.http_method,
|
|
200
|
+
http_headers: parseHeaders(insHeaders.value),
|
|
201
|
+
param_location: 'auto',
|
|
202
|
+
allow_local: !!ins.allow_local,
|
|
203
|
+
timeout: Number(ins.timeout) || 10,
|
|
204
|
+
mcp_server: ins.kind === 'mcp' ? ins.mcp_server.trim() : '',
|
|
205
|
+
mcp_tool: ins.kind === 'mcp' ? ins.mcp_tool.trim() : '',
|
|
206
|
+
acknowledged: ack,
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
const d = await postJSON('/ahs/skills', body)
|
|
210
|
+
const warn = (d.warnings || []).length ? ` · ${d.warnings.join(';')}` : ''
|
|
211
|
+
insOk.value = `${d.created ? '已安装' : '已更新'}「${body.name}」${warn}`
|
|
212
|
+
insAck.value = false
|
|
213
|
+
Object.assign(ins, { id: '', name: '', description: '', endpoint: '', triggers: '', mcp_server: '', mcp_tool: '' })
|
|
214
|
+
await refreshPanel('tools')
|
|
215
|
+
} catch (e) {
|
|
216
|
+
insErr.value = String(e.message || e)
|
|
217
|
+
insAck.value = !!(e.detail && e.detail.needs_ack)
|
|
218
|
+
} finally {
|
|
219
|
+
insBusy.value = false
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/* ── 连接器:POST|DELETE /ahs/mcp/servers ──
|
|
224
|
+
接入会真连一次 server 拉工具清单(可能几十秒);连不上是 502,原样显示 */
|
|
225
|
+
const showMcpAdd = ref(false)
|
|
226
|
+
const mcpBusy = ref(false)
|
|
227
|
+
const mcpErr = ref('')
|
|
228
|
+
const mcpOk = ref('')
|
|
229
|
+
const mcpAck = ref(false)
|
|
230
|
+
const mf = reactive({ id: '', name: '', url: '', transport: 'streamable_http', headers: '' })
|
|
231
|
+
|
|
232
|
+
function toggleMcpAdd() {
|
|
233
|
+
showMcpAdd.value = !showMcpAdd.value
|
|
234
|
+
mcpErr.value = ''
|
|
235
|
+
mcpOk.value = ''
|
|
236
|
+
mcpAck.value = false
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async function addMcp(ack = false) {
|
|
240
|
+
if (mcpBusy.value) return
|
|
241
|
+
const id = mf.id.trim()
|
|
242
|
+
mcpErr.value = ''
|
|
243
|
+
mcpOk.value = ''
|
|
244
|
+
if (!id || !mf.url.trim()) { mcpErr.value = 'id 和 URL 都要填'; return }
|
|
245
|
+
mcpBusy.value = true
|
|
246
|
+
try {
|
|
247
|
+
const d = await postJSON('/ahs/mcp/servers', {
|
|
248
|
+
id,
|
|
249
|
+
name: mf.name.trim() || id,
|
|
250
|
+
url: mf.url.trim(),
|
|
251
|
+
headers: parseHeaders(mf.headers),
|
|
252
|
+
transport: mf.transport,
|
|
253
|
+
acknowledged: ack,
|
|
254
|
+
})
|
|
255
|
+
mcpOk.value = `已接入 ${d.server?.name || id} · 注册 ${d.tools_registered ?? 0} 个工具`
|
|
256
|
+
mcpAck.value = false
|
|
257
|
+
Object.assign(mf, { id: '', name: '', url: '', headers: '' })
|
|
258
|
+
await loadMcp()
|
|
259
|
+
await refreshPanel('tools')
|
|
260
|
+
} catch (e) {
|
|
261
|
+
mcpErr.value = String(e.message || e)
|
|
262
|
+
mcpAck.value = !!(e.detail && e.detail.needs_ack)
|
|
263
|
+
} finally {
|
|
264
|
+
mcpBusy.value = false
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/* 重连:server 那边的工具会变,POST .../refresh 增量对齐注册表 */
|
|
269
|
+
async function refreshMcp(s) {
|
|
270
|
+
if (mcpBusy.value) return
|
|
271
|
+
mcpBusy.value = true
|
|
272
|
+
mcpErr.value = ''
|
|
273
|
+
mcpOk.value = ''
|
|
274
|
+
try {
|
|
275
|
+
const d = await postJSON(`/ahs/mcp/servers/${encodeURIComponent(s.id)}/refresh`, {})
|
|
276
|
+
mcpOk.value = `已重连 ${s.name || s.id} · 现共 ${d.tools ?? 0} 个工具`
|
|
277
|
+
await loadMcp()
|
|
278
|
+
await refreshPanel('tools')
|
|
279
|
+
} catch (e) {
|
|
280
|
+
mcpErr.value = String(e.message || e)
|
|
281
|
+
} finally {
|
|
282
|
+
mcpBusy.value = false
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
async function delMcp(s) {
|
|
287
|
+
if (!confirm(`移除连接器「${s.name || s.id}」?它注册的 MCP 技能会一起删掉。`)) return
|
|
288
|
+
err.value = ''
|
|
289
|
+
try {
|
|
290
|
+
const d = await delJSON(`/ahs/mcp/servers/${encodeURIComponent(s.id)}`)
|
|
291
|
+
await loadMcp()
|
|
292
|
+
await refreshPanel('tools')
|
|
293
|
+
mcpOk.value = `已移除,连带删除 ${d.removed_skills ?? 0} 个技能`
|
|
294
|
+
} catch (e) {
|
|
295
|
+
err.value = String(e.message || e)
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
</script>
|
|
299
|
+
|
|
300
|
+
<template>
|
|
301
|
+
<PanelBox
|
|
302
|
+
title="技能"
|
|
303
|
+
tag="Tools"
|
|
304
|
+
:state="p.state"
|
|
305
|
+
:ready="ready"
|
|
306
|
+
@refresh="refreshPanel('tools'); loadMcp()"
|
|
307
|
+
>
|
|
308
|
+
<div class="pn-kpi">
|
|
309
|
+
<div><b>{{ p.skills.length + p.md.length }}</b><span>技能总数</span></div>
|
|
310
|
+
<div><b>{{ p.skills.length }}</b><span>执行技能</span></div>
|
|
311
|
+
<div><b>{{ p.md.length }}</b><span>指令技能</span></div>
|
|
312
|
+
<div><b>{{ blocked }}</b><span>被封杀</span></div>
|
|
313
|
+
<div><b>{{ breakerN }}</b><span>熔断中</span></div>
|
|
314
|
+
</div>
|
|
315
|
+
|
|
316
|
+
<div v-if="err" class="pn-st err">{{ err }}</div>
|
|
317
|
+
|
|
318
|
+
<div class="pn-cols">
|
|
319
|
+
<div class="pn-sec">
|
|
320
|
+
<div class="pn-h">执行技能 <em>{{ p.skills.length }}</em></div>
|
|
321
|
+
<div v-if="!p.skills.length" class="pn-empty">没有注册的执行技能。</div>
|
|
322
|
+
<template v-for="s in p.skills" :key="s.id">
|
|
323
|
+
<div class="pn-row" :title="s.description">
|
|
324
|
+
<span class="m">
|
|
325
|
+
<b>{{ s.name || s.id }}</b>
|
|
326
|
+
<span class="s">
|
|
327
|
+
{{ s.kind }} · {{ s.side_effect || 'read' }}<template v-if="s.source === 'user'"> · 用户安装</template><template v-if="s.blocked"> · 已封杀</template>
|
|
328
|
+
</span>
|
|
329
|
+
</span>
|
|
330
|
+
<span class="pn-tag" :class="TRUST[s.trust] || ''">{{ trustCN(s.trust) }}</span>
|
|
331
|
+
<button class="mbtn" :class="{ on: tId === s.id }" @click="beginTest(s)">
|
|
332
|
+
{{ tId === s.id ? '收起' : '测试' }}
|
|
333
|
+
</button>
|
|
334
|
+
<button v-if="s.source !== 'builtin'" class="mbtn danger" :disabled="busy === s.id" @click="dropSkill(s)">
|
|
335
|
+
删除
|
|
336
|
+
</button>
|
|
337
|
+
</div>
|
|
338
|
+
|
|
339
|
+
<div v-if="tId === s.id" class="tk-test">
|
|
340
|
+
<div v-if="!(s.params && Object.keys(s.params).length)" class="tip dim">
|
|
341
|
+
该技能没有声明参数,直接运行即可。
|
|
342
|
+
</div>
|
|
343
|
+
<label v-for="(ty, k) in (s.params || {})" :key="k" class="f">
|
|
344
|
+
<span>{{ k }}<em>{{ ty }}</em></span>
|
|
345
|
+
<input v-model="tArgs[k]" :placeholder="String(ty || 'str')" spellcheck="false" />
|
|
346
|
+
</label>
|
|
347
|
+
<div class="fbar">
|
|
348
|
+
<button class="go" :disabled="tBusy" @click="runTest(s, false)">
|
|
349
|
+
{{ tBusy ? '调用中…' : '运行' }}
|
|
350
|
+
</button>
|
|
351
|
+
<button
|
|
352
|
+
v-if="tRes && tRes.status === 'needs_confirmation'"
|
|
353
|
+
class="go warn"
|
|
354
|
+
:disabled="tBusy"
|
|
355
|
+
@click="runTest(s, true)"
|
|
356
|
+
>
|
|
357
|
+
确认并重跑
|
|
358
|
+
</button>
|
|
359
|
+
<span class="tip dim">走真实权限 / 断路器 / SSRF 校验</span>
|
|
360
|
+
</div>
|
|
361
|
+
<div v-if="tErr" class="pn-note meta bad">{{ tErr }}</div>
|
|
362
|
+
<div v-if="tRes" class="tk-res" :class="tRes.success ? 'ok' : 'bad'">
|
|
363
|
+
<div class="r-h">
|
|
364
|
+
<b>{{ tRes.status }}</b>
|
|
365
|
+
<span v-if="tRes.message">{{ tRes.message }}</span>
|
|
366
|
+
</div>
|
|
367
|
+
<pre v-if="pretty(tRes.output)">{{ pretty(tRes.output) }}</pre>
|
|
368
|
+
</div>
|
|
369
|
+
</div>
|
|
370
|
+
</template>
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
<div class="pn-sec">
|
|
374
|
+
<div class="pn-h">指令技能 <em>{{ p.md.length }}</em></div>
|
|
375
|
+
<div v-if="!p.md.length" class="pn-empty">没有 SKILL.md 指令技能。</div>
|
|
376
|
+
<div v-for="s in p.md" :key="s.id" class="pn-row clickable" :title="'点击查看 SKILL.md 正文'" @click="pickMd(s)">
|
|
377
|
+
<span class="m">
|
|
378
|
+
<b>{{ s.name || s.id }}</b>
|
|
379
|
+
<span class="s">{{ clip(s.description || '无描述', 34) }}</span>
|
|
380
|
+
</span>
|
|
381
|
+
<span class="pn-tag" :class="TRUST[s.trust] || ''">{{ trustCN(s.trust) }}</span>
|
|
382
|
+
<button
|
|
383
|
+
class="sw"
|
|
384
|
+
:class="{ on: s.enabled }"
|
|
385
|
+
:disabled="busy === s.id"
|
|
386
|
+
:title="s.enabled ? '点击停用' : '点击启用'"
|
|
387
|
+
@click.stop="flip(s)"
|
|
388
|
+
>
|
|
389
|
+
{{ s.enabled ? '启用' : '停用' }}
|
|
390
|
+
</button>
|
|
391
|
+
</div>
|
|
392
|
+
</div>
|
|
393
|
+
</div>
|
|
394
|
+
|
|
395
|
+
<div class="pn-sec">
|
|
396
|
+
<div class="pn-h">
|
|
397
|
+
安装技能
|
|
398
|
+
<button class="mbtn" @click="toggleIns">{{ showIns ? '收起' : '+ 新增' }}</button>
|
|
399
|
+
</div>
|
|
400
|
+
<div v-if="showIns" class="tk-form">
|
|
401
|
+
<div class="frow">
|
|
402
|
+
<label class="f"><span>id</span>
|
|
403
|
+
<input v-model="ins.id" placeholder="weather_query" spellcheck="false" />
|
|
404
|
+
</label>
|
|
405
|
+
<label class="f"><span>名称</span>
|
|
406
|
+
<input v-model="ins.name" placeholder="查天气" />
|
|
407
|
+
</label>
|
|
408
|
+
</div>
|
|
409
|
+
<label class="f"><span>描述</span>
|
|
410
|
+
<input v-model="ins.description" placeholder="给模型看的说明:能做什么,什么时候用" />
|
|
411
|
+
</label>
|
|
412
|
+
<div class="frow">
|
|
413
|
+
<label class="f"><span>类型</span>
|
|
414
|
+
<select v-model="ins.kind">
|
|
415
|
+
<option value="web_api">web_api · HTTP 接口</option>
|
|
416
|
+
<option value="mcp">mcp · 已有 server 的工具</option>
|
|
417
|
+
</select>
|
|
418
|
+
</label>
|
|
419
|
+
<label class="f"><span>副作用</span>
|
|
420
|
+
<select v-model="ins.side_effect">
|
|
421
|
+
<option v-for="(cn, k) in SIDE" :key="k" :value="k">{{ cn }}</option>
|
|
422
|
+
</select>
|
|
423
|
+
</label>
|
|
424
|
+
<label class="f narrow"><span>超时(s)</span>
|
|
425
|
+
<input v-model.number="ins.timeout" type="number" min="1" max="120" />
|
|
426
|
+
</label>
|
|
427
|
+
</div>
|
|
428
|
+
<label class="f"><span>触发词(逗号分隔)</span>
|
|
429
|
+
<input v-model="ins.triggers" placeholder="天气, 气温, 下雨" />
|
|
430
|
+
</label>
|
|
431
|
+
<label class="f"><span>参数(schema:名:类型)</span>
|
|
432
|
+
<input v-model="insParams" placeholder="city:str, days:int" spellcheck="false" />
|
|
433
|
+
</label>
|
|
434
|
+
|
|
435
|
+
<template v-if="ins.kind === 'web_api'">
|
|
436
|
+
<div class="frow">
|
|
437
|
+
<label class="f grow"><span>endpoint</span>
|
|
438
|
+
<input v-model="ins.endpoint" placeholder="https://api.example.com/weather" spellcheck="false" />
|
|
439
|
+
</label>
|
|
440
|
+
<label class="f narrow"><span>方法</span>
|
|
441
|
+
<select v-model="ins.http_method">
|
|
442
|
+
<option>GET</option>
|
|
443
|
+
<option>POST</option>
|
|
444
|
+
</select>
|
|
445
|
+
</label>
|
|
446
|
+
</div>
|
|
447
|
+
<label class="f"><span>请求头(每行 Key: Value)</span>
|
|
448
|
+
<textarea v-model="insHeaders" rows="2" spellcheck="false" placeholder="Authorization: Bearer xxx" />
|
|
449
|
+
</label>
|
|
450
|
+
<label class="chk"><input v-model="ins.allow_local" type="checkbox" /> 允许访问内网 / 本机地址</label>
|
|
451
|
+
</template>
|
|
452
|
+
<div v-else class="frow">
|
|
453
|
+
<label class="f"><span>MCP server</span>
|
|
454
|
+
<input v-model="ins.mcp_server" placeholder="amap-maps" spellcheck="false" />
|
|
455
|
+
</label>
|
|
456
|
+
<label class="f"><span>工具名</span>
|
|
457
|
+
<input v-model="ins.mcp_tool" placeholder="maps_direction" spellcheck="false" />
|
|
458
|
+
</label>
|
|
459
|
+
</div>
|
|
460
|
+
|
|
461
|
+
<label class="chk"><input v-model="ins.destructive" type="checkbox" /> 不可逆操作(删除 / 付款这类)</label>
|
|
462
|
+
<label class="chk"><input v-model="ins.external" type="checkbox" /> 会调用外部服务(联网)</label>
|
|
463
|
+
|
|
464
|
+
<div class="fbar">
|
|
465
|
+
<button class="go" :disabled="insBusy" @click="doInstall(false)">
|
|
466
|
+
{{ insBusy ? '安装中…' : '安装' }}
|
|
467
|
+
</button>
|
|
468
|
+
<button v-if="insAck" class="go warn" :disabled="insBusy" @click="doInstall(true)">
|
|
469
|
+
已知风险,继续安装
|
|
470
|
+
</button>
|
|
471
|
+
<span v-if="insErr" class="tip bad">{{ insErr }}</span>
|
|
472
|
+
<span v-else-if="insOk" class="tip ok">{{ insOk }}</span>
|
|
473
|
+
<span v-else class="tip dim">同 id 覆盖更新;内置技能的 id 不可覆盖</span>
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
<div v-else class="pn-note">
|
|
477
|
+
只能装 <code>web_api</code> 与 <code>mcp</code> 两类 —— 本地代码技能不接受从界面安装。
|
|
478
|
+
</div>
|
|
479
|
+
</div>
|
|
480
|
+
|
|
481
|
+
<div class="pn-sec">
|
|
482
|
+
<div class="pn-h">
|
|
483
|
+
连接器 <em>{{ mcp.length }}</em>
|
|
484
|
+
<button class="mbtn" @click="toggleMcpAdd">{{ showMcpAdd ? '收起' : '+ 接入' }}</button>
|
|
485
|
+
</div>
|
|
486
|
+
|
|
487
|
+
<div v-if="showMcpAdd" class="tk-form">
|
|
488
|
+
<div class="frow">
|
|
489
|
+
<label class="f"><span>id</span>
|
|
490
|
+
<input v-model="mf.id" placeholder="my-notes" spellcheck="false" />
|
|
491
|
+
</label>
|
|
492
|
+
<label class="f"><span>显示名</span>
|
|
493
|
+
<input v-model="mf.name" placeholder="我的备忘录" />
|
|
494
|
+
</label>
|
|
495
|
+
</div>
|
|
496
|
+
<label class="f"><span>URL</span>
|
|
497
|
+
<input v-model="mf.url" placeholder="https://example.com/mcp" spellcheck="false" />
|
|
498
|
+
</label>
|
|
499
|
+
<div class="frow">
|
|
500
|
+
<label class="f narrow"><span>传输</span>
|
|
501
|
+
<select v-model="mf.transport">
|
|
502
|
+
<option value="streamable_http">streamable_http</option>
|
|
503
|
+
<option value="sse">sse</option>
|
|
504
|
+
</select>
|
|
505
|
+
</label>
|
|
506
|
+
<label class="f grow"><span>请求头(每行 Key: Value)</span>
|
|
507
|
+
<textarea v-model="mf.headers" rows="2" spellcheck="false" placeholder="Authorization: Bearer xxx" />
|
|
508
|
+
</label>
|
|
509
|
+
</div>
|
|
510
|
+
<div class="fbar">
|
|
511
|
+
<button class="go" :disabled="mcpBusy" @click="addMcp(false)">
|
|
512
|
+
{{ mcpBusy ? '连接中…' : '接入' }}
|
|
513
|
+
</button>
|
|
514
|
+
<button v-if="mcpAck" class="go warn" :disabled="mcpBusy" @click="addMcp(true)">
|
|
515
|
+
已知风险,继续
|
|
516
|
+
</button>
|
|
517
|
+
<span v-if="mcpErr" class="tip bad">{{ mcpErr }}</span>
|
|
518
|
+
<span v-else-if="mcpOk" class="tip ok">{{ mcpOk }}</span>
|
|
519
|
+
<span v-else class="tip dim">接入后会连一次,把它暴露的工具注册成技能</span>
|
|
520
|
+
</div>
|
|
521
|
+
</div>
|
|
522
|
+
|
|
523
|
+
<div v-if="!mcp.length" class="pn-empty">
|
|
524
|
+
还没接入外部应用。邮箱、你自己的另一个知识库这类需要授权的,会作为 MCP 服务出现在这一节。
|
|
525
|
+
</div>
|
|
526
|
+
<div v-for="s in mcp" :key="s.id" class="pn-row" :title="s.url">
|
|
527
|
+
<span class="m">
|
|
528
|
+
<b>{{ s.name || s.id }}</b>
|
|
529
|
+
<span class="s">{{ s.tool_count ?? 0 }} 个工具<template v-if="s.transport"> · {{ s.transport }}</template></span>
|
|
530
|
+
</span>
|
|
531
|
+
<button class="mbtn" :disabled="mcpBusy" @click="refreshMcp(s)">重连</button>
|
|
532
|
+
<button class="mbtn danger" @click="delMcp(s)">移除</button>
|
|
533
|
+
</div>
|
|
534
|
+
</div>
|
|
535
|
+
|
|
536
|
+
<div class="pn-note">
|
|
537
|
+
指令技能正文 <code>/api/ahs/md-skills/{id}</code>,执行技能运行 <code>POST /api/ahs/skills/{id}/test</code>;
|
|
538
|
+
连接器与技能面板是同一份数据(<code>/api/ahs/mcp/servers</code>)。
|
|
539
|
+
</div>
|
|
540
|
+
</PanelBox>
|
|
541
|
+
</template>
|
|
542
|
+
|
|
543
|
+
<style scoped>
|
|
544
|
+
.sw {
|
|
545
|
+
flex-shrink: 0; padding: 4px 10px; border-radius: var(--r-pill);
|
|
546
|
+
font-size: 11px; font-family: var(--mono);
|
|
547
|
+
background: var(--surface-2); color: var(--faint);
|
|
548
|
+
border: 1px solid transparent;
|
|
549
|
+
}
|
|
550
|
+
.sw.on { background: rgba(26, 157, 95, 0.12); color: var(--green); }
|
|
551
|
+
.sw:disabled { opacity: 0.5; }
|
|
552
|
+
|
|
553
|
+
/* 行内小按钮:测试 / 删除 / 新增 —— 原来「执行技能」整行是死的,点了没反应 */
|
|
554
|
+
.mbtn {
|
|
555
|
+
flex-shrink: 0; padding: 4px 10px; border-radius: var(--r-pill);
|
|
556
|
+
font-size: 11px; font-family: var(--mono); color: var(--dim);
|
|
557
|
+
background: rgba(255, 255, 255, 0.8); border: 1px solid var(--line-soft);
|
|
558
|
+
transition: color 0.13s, border-color 0.13s, background 0.13s;
|
|
559
|
+
}
|
|
560
|
+
.mbtn:hover { color: var(--green); border-color: rgba(26, 157, 95, 0.35); background: #fff; }
|
|
561
|
+
.mbtn.on { color: var(--green); background: rgba(26, 157, 95, 0.1); border-color: rgba(26, 157, 95, 0.4); }
|
|
562
|
+
.mbtn.danger:hover { color: var(--red); border-color: rgba(229, 72, 77, 0.35); }
|
|
563
|
+
.mbtn:disabled { opacity: 0.5; }
|
|
564
|
+
|
|
565
|
+
/* ── 表单(安装技能 / 接入连接器 / 技能测试)── */
|
|
566
|
+
.tk-form, .tk-test {
|
|
567
|
+
margin: 4px 0 6px;
|
|
568
|
+
padding: 11px 12px;
|
|
569
|
+
border-radius: var(--r-mid);
|
|
570
|
+
background: rgba(255, 255, 255, 0.86);
|
|
571
|
+
border: 1px solid var(--line-soft);
|
|
572
|
+
}
|
|
573
|
+
.tk-test { display: flex; flex-direction: column; gap: 7px; }
|
|
574
|
+
.tk-test .f span em {
|
|
575
|
+
font-style: normal; font-weight: 600; font-family: var(--mono); font-size: 11px; color: var(--dim);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
.frow { display: flex; gap: 8px; }
|
|
579
|
+
.frow .f { flex: 1 1 0; min-width: 0; }
|
|
580
|
+
.frow .f.grow { flex: 2 1 0; }
|
|
581
|
+
.frow .f.narrow { flex: 0 1 104px; }
|
|
582
|
+
.f { display: block; margin-bottom: 7px; }
|
|
583
|
+
.f > span {
|
|
584
|
+
display: block; margin-bottom: 3px;
|
|
585
|
+
font-size: 11px; color: var(--faint);
|
|
586
|
+
}
|
|
587
|
+
.f input, .f select, .f textarea {
|
|
588
|
+
display: block; width: 100%;
|
|
589
|
+
padding: 5px 8px; border-radius: 6px;
|
|
590
|
+
font-family: inherit; font-size: 12.5px; color: var(--ink);
|
|
591
|
+
background: rgba(23, 32, 26, 0.04);
|
|
592
|
+
border: 1px solid transparent; outline: none;
|
|
593
|
+
transition: border-color 0.14s, background 0.14s;
|
|
594
|
+
}
|
|
595
|
+
.f textarea { resize: vertical; line-height: 1.6; }
|
|
596
|
+
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--line); background: #fff; }
|
|
597
|
+
.f input::placeholder, .f textarea::placeholder { color: var(--dim); }
|
|
598
|
+
|
|
599
|
+
.chk {
|
|
600
|
+
display: flex; align-items: center; gap: 6px;
|
|
601
|
+
margin-bottom: 6px; font-size: 12px; color: var(--dim);
|
|
602
|
+
}
|
|
603
|
+
.chk input { accent-color: var(--green); }
|
|
604
|
+
|
|
605
|
+
.fbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 3px; }
|
|
606
|
+
.go {
|
|
607
|
+
flex-shrink: 0; padding: 6px 15px; border-radius: var(--r-pill);
|
|
608
|
+
font-size: 12.5px; font-weight: 600; color: #fff; background: var(--green);
|
|
609
|
+
transition: opacity 0.15s, transform 0.12s;
|
|
610
|
+
}
|
|
611
|
+
.go:hover:not(:disabled) { opacity: 0.9; }
|
|
612
|
+
.go:active:not(:disabled) { transform: scale(0.97); }
|
|
613
|
+
.go:disabled { background: rgba(23, 32, 26, 0.12); color: var(--faint); }
|
|
614
|
+
.go.warn { background: var(--amber); }
|
|
615
|
+
|
|
616
|
+
.tip {
|
|
617
|
+
flex: 1 1 auto; min-width: 0;
|
|
618
|
+
font-size: 11.5px; color: var(--dim);
|
|
619
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
620
|
+
}
|
|
621
|
+
.tip.dim { color: var(--faint); }
|
|
622
|
+
.tip.ok { color: var(--green); }
|
|
623
|
+
.tip.bad { color: var(--red); white-space: normal; }
|
|
624
|
+
|
|
625
|
+
/* 测试结果:成功/失败都原文展示,失败(needs_confirmation/blocked)不涂成成功色 */
|
|
626
|
+
.tk-res {
|
|
627
|
+
margin-top: 4px; padding: 8px 10px; border-radius: var(--r-sm);
|
|
628
|
+
background: rgba(23, 32, 26, 0.03); border: 1px solid var(--line-soft);
|
|
629
|
+
}
|
|
630
|
+
.tk-res .r-h { display: flex; gap: 6px; font-size: 12px; color: var(--dim); }
|
|
631
|
+
.tk-res .r-h b { font-family: var(--mono); font-size: 11.5px; color: var(--ink); }
|
|
632
|
+
.tk-res.bad .r-h b { color: var(--amber); }
|
|
633
|
+
.tk-res pre {
|
|
634
|
+
margin: 6px 0 0; max-height: 220px; overflow: auto;
|
|
635
|
+
font-family: var(--mono); font-size: 11.5px; line-height: 1.6; color: var(--dim);
|
|
636
|
+
white-space: pre-wrap; word-break: break-word;
|
|
637
|
+
}
|
|
638
|
+
.pn-note.meta { margin-top: 6px; }
|
|
639
|
+
.pn-note.meta.bad { color: var(--red); }
|
|
640
|
+
</style>
|