bailinghub 0.9.4 → 0.10.1
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.en.md +6 -6
- package/README.md +6 -6
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/docker-compose.images.yml +2 -2
- package/docs/AGENT_CLIENT_QUICKSTART.en.md +1 -3
- package/docs/AGENT_CLIENT_QUICKSTART.md +1 -1
- package/docs/AGENT_CLIENT_RUNTIME_API.en.md +87 -2
- package/docs/AGENT_CLIENT_RUNTIME_API.md +36 -2
- package/docs/AGENT_KNOWLEDGE_API.en.md +77 -0
- package/docs/AGENT_KNOWLEDGE_API.md +86 -0
- package/docs/AGENT_TASK_CONTROL.md +4 -4
- package/docs/AGENT_TASK_CONTROL_FOUNDATION.md +1 -1
- package/docs/ARCHITECTURE.md +4 -0
- package/docs/CHANGELOG.en.md +24 -1
- package/docs/CHANGELOG.md +24 -1
- package/docs/COMPATIBILITY.en.md +27 -1
- package/docs/CONTRACT.en.md +1 -1
- package/docs/CONTRACT.md +1 -1
- package/docs/IMPLEMENTATION_STATUS.en.md +28 -15
- package/docs/IMPLEMENTATION_STATUS.md +28 -15
- package/docs/INDEPENDENT_VALIDATION.en.md +6 -4
- package/docs/INDEPENDENT_VALIDATION.md +6 -4
- package/docs/INTEGRATION_WALKTHROUGH.md +65 -0
- package/docs/MODEL_BILLING.en.md +2 -0
- package/docs/MODEL_BILLING.md +6 -2
- package/docs/MODEL_CONTINUATION.en.md +54 -0
- package/docs/MODEL_CONTINUATION.md +54 -0
- package/docs/MODEL_OUTPUT_BUDGET.en.md +69 -0
- package/docs/MODEL_OUTPUT_BUDGET.md +69 -0
- package/docs/OPERATIONS.en.md +16 -4
- package/docs/OPERATIONS.md +16 -4
- package/docs/QUICKSTART.md +1 -1
- package/docs/README.en.md +7 -0
- package/docs/README.md +7 -0
- package/docs/RELEASE_NOTES_NEXT.en.md +3 -3
- package/docs/RELEASE_NOTES_NEXT.md +3 -3
- package/docs/RELEASE_NOTES_v0.10.0.en.md +58 -0
- package/docs/RELEASE_NOTES_v0.10.0.md +58 -0
- package/docs/RELEASE_NOTES_v0.10.1.en.md +41 -0
- package/docs/RELEASE_NOTES_v0.10.1.md +41 -0
- package/docs/UPGRADE_PLAN.en.md +118 -0
- package/docs/UPGRADE_PLAN.md +124 -0
- package/docs/UPGRADE_v0.10.0.en.md +47 -0
- package/docs/UPGRADE_v0.10.0.md +47 -0
- package/docs/UPGRADE_v0.10.1.en.md +66 -0
- package/docs/UPGRADE_v0.10.1.md +66 -0
- package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +38 -22
- package/package.json +10 -5
- package/schemas/tool-definition.schema.json +13 -0
- package/scripts/check-doc-links.mjs +6 -0
- package/scripts/check-image-tags.sh +1 -1
- package/scripts/check-php-sdk-artifacts.mjs +152 -0
- package/scripts/check-php-sdk-artifacts.test.mjs +99 -0
- package/scripts/check-release-consistency.test.mjs +2 -2
- package/scripts/doctor-upgrade-plan.test.ts +205 -0
- package/scripts/doctor-upgrade-plan.ts +276 -0
- package/scripts/doctor.ts +4 -1
- package/scripts/e2e-console-approval-details.mjs +134 -0
- package/scripts/e2e-console-config-races.mjs +180 -0
- package/scripts/e2e-console-kb-audit.mjs +170 -0
- package/scripts/e2e-console-operations-audit.mjs +152 -0
- package/scripts/e2e-console-runtime-audit.mjs +179 -0
- package/scripts/e2e-console-settings-audit.mjs +125 -0
- package/scripts/e2e-console-troubleshooting-extra.mjs +267 -0
- package/scripts/e2e-console.mjs +476 -7
- package/scripts/install.sh +1 -1
- package/scripts/publish-images.sh +1 -1
- package/scripts/release-audit.mjs +9 -1
- package/scripts/sdk-declaration-contract-test.ts +34 -0
- package/scripts/sdk-p1-check.mjs +62 -26
- package/scripts/verify-github-repo.mjs +8 -0
- package/sdk/dotnet/Bailing.Connect/BailingConnect.cs +4 -4
- package/sdk/dotnet/README.md +8 -0
- package/sdk/dotnet/tests/Declaration/Declaration.csproj +11 -0
- package/sdk/dotnet/tests/Declaration/Program.cs +74 -0
- package/sdk/go/README.md +8 -0
- package/sdk/go/bailingconnect/connect.go +5 -5
- package/sdk/go/bailingconnect/declaration_test.go +107 -0
- package/sdk/java/README.md +13 -0
- package/sdk/java/src/main/java/com/bailing/connect/BailingConnect.java +4 -4
- package/sdk/java/tests/DeclarationTest.java +70 -0
- package/sdk/node/README.md +8 -0
- package/sdk/node/src/index.mjs +4 -4
- package/sdk/node/tests/declaration.test.mjs +41 -0
- package/sdk/php/README.md +16 -0
- package/sdk/php/src/Attributes/AiTool.php +4 -4
- package/sdk/php/src/SpecBuilder.php +8 -8
- package/sdk/php/tests/declaration-serialization.php +103 -0
- package/sdk/php7/README.md +14 -0
- package/sdk/php7/src/ToolDef.php +3 -3
- package/sdk/php7/src/ToolSpec.php +8 -13
- package/sdk/php7/tests/declaration-serialization.php +103 -0
- package/sdk/python/README.md +8 -0
- package/sdk/python/bailing_connect/__init__.py +6 -6
- package/sdk/python/tests/test_declaration.py +61 -0
- package/src/app/agent-client-runtime.test.ts +115 -2
- package/src/app/agent-client-runtime.ts +40 -11
- package/src/app/agent-knowledge.test.ts +171 -0
- package/src/app/agent-knowledge.ts +233 -0
- package/src/app/agent-tool-catalog-revision.test.ts +31 -0
- package/src/app/agent-tool-invocations.test.ts +7 -2
- package/src/app/agent-tool-invocations.ts +67 -7
- package/src/app/approval-continuations.test.ts +49 -1
- package/src/app/http.test.ts +16 -1
- package/src/app/http.ts +3 -3
- package/src/app/kernel-boot-recovery.mysql.test.ts +132 -0
- package/src/app/kernel-boot-recovery.test.ts +157 -0
- package/src/app/kernel.ts +12 -8
- package/src/app/readiness.mysql.test.ts +120 -0
- package/src/app/readiness.test.ts +111 -26
- package/src/app/readiness.ts +26 -22
- package/src/app/runtime-lifecycle.ts +34 -3
- package/src/app/tool-approvals.test.ts +83 -0
- package/src/app/tool-approvals.ts +25 -7
- package/src/app/tool-proxy-payload.test.ts +81 -0
- package/src/app/tool-proxy.ts +24 -2
- package/src/core/config/console-diagnostic-location.test.ts +36 -0
- package/src/core/config/console-form-guard.test.ts +69 -0
- package/src/core/config/console-task-location.test.ts +64 -0
- package/src/core/contracts/explicit-capability-values.test.ts +62 -0
- package/src/core/contracts/openapi-tools.ts +18 -7
- package/src/core/contracts/schema-readiness.ts +11 -0
- package/src/core/contracts/tool-annotations.ts +4 -4
- package/src/core/contracts/tool-definition.ts +26 -0
- package/src/core/contracts/tool-guidance.test.ts +77 -0
- package/src/core/contracts/tool-guidance.ts +31 -0
- package/src/core/contracts/tool-input-limits.ts +15 -0
- package/src/core/contracts/tools-idempotency.test.ts +90 -0
- package/src/core/contracts/tools.ts +52 -9
- package/src/core/runtime/agent-execution-memory.test.ts +64 -0
- package/src/core/runtime/agent-execution-memory.ts +63 -0
- package/src/core/state/state-contracts.ts +3 -0
- package/src/infrastructure/config/config-observability-ledger.ts +2 -0
- package/src/infrastructure/schema/schema-readiness.ts +29 -0
- package/src/infrastructure/state/state-mysql.ts +3 -0
- package/src/modules/usage/contracts.ts +7 -0
- package/src/modules/usage/http.ts +2 -0
- package/src/modules/usage/model-continuation.test.ts +109 -0
- package/src/modules/usage/model-gateway.ts +5 -1
- package/src/modules/usage/output-budget.mysql.test.ts +84 -0
- package/src/modules/usage/output-budget.test.ts +167 -0
- package/src/modules/usage/output-budget.ts +73 -0
- package/src/modules/usage/provider-stream.test.ts +22 -0
- package/src/modules/usage/provider.ts +2 -3
- package/src/modules/usage/repository.ts +6 -0
- package/src/modules/usage/test-harness.ts +4 -2
- package/src/routes/admin-approval-view.test.ts +109 -0
- package/src/routes/admin-approval-view.ts +36 -0
- package/src/routes/admin-readiness.test.ts +52 -0
- package/src/routes/admin-runtime-ux.test.ts +51 -0
- package/src/routes/admin-runtime-ux.ts +25 -0
- package/src/routes/admin-runtime.ts +36 -8
- package/src/routes/admin.ts +9 -0
- package/src/routes/agent-api.test.ts +80 -1
- package/src/routes/agent-api.ts +63 -4
- package/src/routes/agent-tool-detail.test.ts +140 -0
- package/src/routes/public-default.ts +1 -1
- package/src/services/kb-agent.test.ts +84 -0
- package/src/services/kb.ts +73 -0
- package/web/connect/bailing-connect-php.tgz +0 -0
- package/web/connect/bailing-connect-php7.tgz +0 -0
- package/web/console/assets/Accounts-CjIBO3sU.css +1 -0
- package/web/console/assets/Accounts-Dhyw-7wF.js +3 -0
- package/web/console/assets/AgentClients-BA0M26-I.css +1 -0
- package/web/console/assets/AgentClients-DWxb8-ko.js +1 -0
- package/web/console/assets/AgentTasks-DOyxANnx.css +1 -0
- package/web/console/assets/AgentTasks-DUHD4dzr.js +2 -0
- package/web/console/assets/Approvals-Brl-2uJq.css +1 -0
- package/web/console/assets/Approvals-CQx1YWxW.js +1 -0
- package/web/console/assets/Audit--QcdVlMh.js +1 -0
- package/web/console/assets/Audit-DAdmOnIs.css +1 -0
- package/web/console/assets/{BrandLockup-CffORQse.js → BrandLockup-DQcaW4Nt.js} +1 -1
- package/web/console/assets/Channels-DJJU3ksE.css +1 -0
- package/web/console/assets/Channels-cGS5WfQ-.js +105 -0
- package/web/console/assets/ChatEntries-BYpji27B.css +1 -0
- package/web/console/assets/ChatEntries-nh23Iz5O.js +7 -0
- package/web/console/assets/Clients-CX5EeYio.js +3 -0
- package/web/console/assets/Clients-CbZAou8E.css +1 -0
- package/web/console/assets/Cost-C6oQvz9P.css +1 -0
- package/web/console/assets/Cost-DOZfdNS9.js +1 -0
- package/web/console/assets/Credentials--aHs57yV.css +1 -0
- package/web/console/assets/Credentials-sy6W9Sac.js +1 -0
- package/web/console/assets/Diagnostics-CKs27Dnv.css +1 -0
- package/web/console/assets/Diagnostics-CyoM1XrZ.js +1 -0
- package/web/console/assets/Executors-2Upi6bOS.css +1 -0
- package/web/console/assets/Executors-BQqqiFwt.js +1 -0
- package/web/console/assets/HelpTip-DLlhaGQp.js +1 -0
- package/web/console/assets/HelpTip-bbDEyuqV.css +1 -0
- package/web/console/assets/Kb-5R3ce4UU.js +5 -0
- package/web/console/assets/Kb-BM_PYi11.css +1 -0
- package/web/console/assets/{Login-CGgLGTE1.js → Login-YKeUwdgo.js} +1 -1
- package/web/console/assets/Projects-DHwHrPT9.css +1 -0
- package/web/console/assets/Projects-Grgb6fOv.js +1 -0
- package/web/console/assets/Routes-DR_Yf02e.css +1 -0
- package/web/console/assets/Routes-DYgrXlRJ.js +138 -0
- package/web/console/assets/Runs-CwTddJJj.js +3 -0
- package/web/console/assets/Runs-D4FOvNfu.css +1 -0
- package/web/console/assets/Setup-Ca0b1d1-.css +1 -0
- package/web/console/assets/Setup-D_xUPNDq.js +1 -0
- package/web/console/assets/Shell-BTg8Vw_L.css +1 -0
- package/web/console/assets/Shell-Dfam2Uoj.js +1 -0
- package/web/console/assets/StorageBuckets-7QLBpV4a.css +1 -0
- package/web/console/assets/StorageBuckets-CP6e50wI.js +1 -0
- package/web/console/assets/SystemSettings-BRYKyJNa.js +1 -0
- package/web/console/assets/SystemSettings-HsXGx0aH.css +1 -0
- package/web/console/assets/SystemStatus-B-VfRsQd.css +1 -0
- package/web/console/assets/SystemStatus-CbPsDsGt.js +1 -0
- package/web/console/assets/Targets-1j4-g6rC.css +1 -0
- package/web/console/assets/Targets-C2LkR2AF.js +1 -0
- package/web/console/assets/Tools-C9HPJqJb.css +1 -0
- package/web/console/assets/Tools-C9JNJUS0.js +2 -0
- package/web/console/assets/Usage-D1Mv6vGY.js +1 -0
- package/web/console/assets/Usage-DMOzUsqh.css +1 -0
- package/web/console/assets/UsageAccess-77LmGCm6.js +1 -0
- package/web/console/assets/UsageAccess-C6ZGxEgJ.css +1 -0
- package/web/console/assets/{UsageHelp-CzS2gI40.js → UsageHelp-BmuiE1Ew.js} +1 -1
- package/web/console/assets/client-route-draft-DxZRxKPT.js +1 -0
- package/web/console/assets/console-location-Csv-xsnl.js +1 -0
- package/web/console/assets/form-guard-8GrFpry0.js +1 -0
- package/web/console/assets/{index-65JiiUr4.js → index-B_5UfiTw.js} +1 -1
- package/web/console/assets/index-MjZJEFIN.js +2 -0
- package/web/console/assets/{request-DKycpD7z.js → request-rqm6MT0s.js} +1 -1
- package/web/console/assets/runtime-feedback-gPfZVNvY.js +1 -0
- package/web/console/assets/{schema-SCiNxBlR.js → schema-o3mK4mid.js} +1 -1
- package/web/console/assets/task-page-location-DWiGtAln.js +1 -0
- package/web/console/assets/use-list-location-FvLFt0Tq.css +1 -0
- package/web/console/assets/use-list-location-cIPy2cKM.js +1 -0
- package/web/console/assets/use-unsaved-form-DScKD0h9.js +1 -0
- package/web/console/assets/{util-DZYfJ5Zo.js → util-B40VqOwl.js} +1 -1
- package/web/console/assets/{vendor-element-8cVcdt5T.js → vendor-element-BT8tHCFk.js} +1 -1
- package/web/console/assets/{vendor-mammoth-CnDA23N0.js → vendor-mammoth-CVIXVxTN.js} +1 -1
- package/web/console/assets/{vendor-vue-Co7x2FW6.js → vendor-vue-DhbG0vd4.js} +7 -7
- package/web/console/index.html +3 -3
- package/web-admin/package-lock.json +4 -4
- package/web-admin/package.json +1 -1
- package/web-admin/src/client-route-draft.ts +25 -0
- package/web-admin/src/components/AgentSetupPanel.vue +54 -41
- package/web-admin/src/components/HelpTip.vue +4 -1
- package/web-admin/src/components/ListLocationBar.vue +22 -0
- package/web-admin/src/components/NotificationOutboxPanel.vue +35 -7
- package/web-admin/src/console-entry.test.ts +26 -0
- package/web-admin/src/console-entry.ts +20 -0
- package/web-admin/src/console-location.ts +35 -0
- package/web-admin/src/form-guard.ts +35 -0
- package/web-admin/src/layout/Shell.vue +18 -65
- package/web-admin/src/onboarding-state.test.ts +174 -0
- package/web-admin/src/onboarding-state.ts +122 -0
- package/web-admin/src/pages/Accounts.vue +44 -24
- package/web-admin/src/pages/AgentClients.vue +47 -29
- package/web-admin/src/pages/AgentTasks.vue +57 -12
- package/web-admin/src/pages/Approvals.vue +105 -25
- package/web-admin/src/pages/Audit.vue +15 -6
- package/web-admin/src/pages/Channels.vue +136 -43
- package/web-admin/src/pages/ChatEntries.vue +96 -41
- package/web-admin/src/pages/Clients.vue +87 -26
- package/web-admin/src/pages/Cost.vue +15 -4
- package/web-admin/src/pages/Credentials.vue +63 -32
- package/web-admin/src/pages/Diagnostics.vue +103 -54
- package/web-admin/src/pages/Executors.vue +103 -40
- package/web-admin/src/pages/Kb.vue +278 -128
- package/web-admin/src/pages/Projects.vue +44 -16
- package/web-admin/src/pages/Routes.vue +168 -247
- package/web-admin/src/pages/Runs.vue +163 -91
- package/web-admin/src/pages/Setup.vue +182 -291
- package/web-admin/src/pages/StorageBuckets.vue +61 -25
- package/web-admin/src/pages/SystemSettings.vue +76 -51
- package/web-admin/src/pages/SystemStatus.vue +54 -30
- package/web-admin/src/pages/Targets.vue +45 -17
- package/web-admin/src/pages/Tools.vue +133 -68
- package/web-admin/src/pages/Usage.vue +64 -25
- package/web-admin/src/pages/UsageAccess.vue +11 -8
- package/web-admin/src/route-call-snippets.test.ts +82 -0
- package/web-admin/src/route-call-snippets.ts +178 -0
- package/web-admin/src/router.ts +11 -29
- package/web-admin/src/runtime-feedback.ts +43 -0
- package/web-admin/src/task-page-location.ts +66 -0
- package/web-admin/src/usage-output-budget.test.ts +26 -0
- package/web-admin/src/usage-output-budget.ts +46 -0
- package/web-admin/src/use-list-location.ts +24 -0
- package/web-admin/src/use-unsaved-form.ts +38 -0
- package/web-admin/tests/model-output-budget.browser.mjs +69 -0
- package/web/console/assets/Accounts-Bervi5JU.css +0 -1
- package/web/console/assets/Accounts-Dhj6PjXP.js +0 -3
- package/web/console/assets/AgentClients-CMy8StAH.js +0 -1
- package/web/console/assets/AgentClients-i52AI6YV.css +0 -1
- package/web/console/assets/AgentTasks-BsG850Il.css +0 -1
- package/web/console/assets/AgentTasks-DA1xZdmP.js +0 -2
- package/web/console/assets/Approvals-DIsd7R8N.js +0 -1
- package/web/console/assets/Approvals-DlTSHl_7.css +0 -1
- package/web/console/assets/Audit-AUDABLTX.js +0 -1
- package/web/console/assets/Audit-CSu6_3oD.css +0 -1
- package/web/console/assets/Channels-B8rjsM0S.js +0 -105
- package/web/console/assets/Channels-CCn0L1jg.css +0 -1
- package/web/console/assets/ChatEntries-DsYtcXN6.css +0 -1
- package/web/console/assets/ChatEntries-iZjJMEUZ.js +0 -7
- package/web/console/assets/Clients-CSHIsaWU.css +0 -1
- package/web/console/assets/Clients-CwgpGCSD.js +0 -3
- package/web/console/assets/Cost-B2tNxu71.js +0 -1
- package/web/console/assets/Cost-CjT39DSZ.css +0 -1
- package/web/console/assets/Credentials-BuwFB-fV.js +0 -1
- package/web/console/assets/Credentials-ioLP0qYN.css +0 -1
- package/web/console/assets/Diagnostics-Ya05PTDp.css +0 -1
- package/web/console/assets/Diagnostics-z5glms11.js +0 -1
- package/web/console/assets/Executors-Bc4SvjeH.js +0 -1
- package/web/console/assets/Executors-CjhEM54c.css +0 -1
- package/web/console/assets/HelpTip-CA6Bm7Nx.css +0 -1
- package/web/console/assets/HelpTip-Dtdt2tKR.js +0 -1
- package/web/console/assets/Kb-BRbRHxLy.js +0 -5
- package/web/console/assets/Kb-CzIzd9xr.css +0 -1
- package/web/console/assets/Projects-Bm8AjsNx.css +0 -1
- package/web/console/assets/Projects-CPWw3con.js +0 -1
- package/web/console/assets/Routes-CMIaE0Bx.js +0 -124
- package/web/console/assets/Routes-CyXV4Pba.css +0 -1
- package/web/console/assets/Runs-B8HuE700.js +0 -3
- package/web/console/assets/Runs-Bv6CV_Hk.css +0 -1
- package/web/console/assets/Setup-D7nxgn-9.css +0 -1
- package/web/console/assets/Setup-G8RKzliR.js +0 -1
- package/web/console/assets/Shell-DimHgraJ.js +0 -1
- package/web/console/assets/Shell-ykb-tUfo.css +0 -1
- package/web/console/assets/StorageBuckets-CVgpZRWY.css +0 -1
- package/web/console/assets/StorageBuckets-CiVYXIE2.js +0 -1
- package/web/console/assets/SystemSettings-BjiHyrXO.css +0 -1
- package/web/console/assets/SystemSettings-DF8sZNen.js +0 -1
- package/web/console/assets/SystemStatus-BlHywK13.js +0 -1
- package/web/console/assets/SystemStatus-I11I67rw.css +0 -1
- package/web/console/assets/Targets-BXaoPoAJ.js +0 -1
- package/web/console/assets/Targets-DTb5tn6z.css +0 -1
- package/web/console/assets/Tools-B22lNHXq.js +0 -2
- package/web/console/assets/Tools-DU8ei6sd.css +0 -1
- package/web/console/assets/Usage-C02EzoI2.js +0 -1
- package/web/console/assets/Usage-CAeDGjrb.css +0 -1
- package/web/console/assets/UsageAccess-CGGaWTuj.css +0 -1
- package/web/console/assets/UsageAccess-DOb-cyPE.js +0 -1
- package/web/console/assets/index-CK0ZCTZv.js +0 -2
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
<p>业务系统的 <b>Agent 可调接口清单</b>(OpenAPI + <code>x-agent-capability</code> 契约);注册后在「触发路由」挂 tools 白名单,即可让 Agent 查 / 办业务。</p>
|
|
6
6
|
</HelpTip>
|
|
7
7
|
<el-button style="margin-left: auto" @click="openDocs('tools')">开发文档</el-button>
|
|
8
|
-
<el-button type="primary" @click="openCreate">注册工具源</el-button></div>
|
|
8
|
+
<el-button v-if="s.can('tools:write')" type="primary" @click="openCreate">注册工具源</el-button></div>
|
|
9
9
|
</template>
|
|
10
|
-
<el-
|
|
10
|
+
<el-alert v-if="listError" :title="listError" type="error" :closable="false" show-icon><el-button link @click="load">重试读取</el-button></el-alert>
|
|
11
|
+
<ListLocationBar v-model="listQuery" :count="locatedRows.length" :total="list.length" :focus="listFocus" :return-to="listReturnTo" @clear="clearListLocation" />
|
|
12
|
+
<el-empty v-if="!listLoading && !listError && !list.length" description="还没有工具源:业务系统在自己的 OpenAPI 上声明 x-agent-capability 后,把 spec 注册进来">
|
|
11
13
|
<el-button @click="openDocs('tools')">查看开发文档</el-button>
|
|
12
|
-
<el-button type="primary" @click="openCreate">注册第一个</el-button>
|
|
14
|
+
<el-button v-if="s.can('tools:write')" type="primary" @click="openCreate">注册第一个</el-button>
|
|
13
15
|
</el-empty>
|
|
14
|
-
<el-table v-else :data="
|
|
16
|
+
<el-table v-else v-loading="listLoading" :data="locatedRows" :empty-text="listQuery || listFocus ? '没有匹配的对象,请调整或清除筛选' : '暂无数据'">
|
|
15
17
|
<el-table-column label="工具源" min-width="270" show-overflow-tooltip>
|
|
16
18
|
<template #default="{ row }">
|
|
17
19
|
<div class="tool-main">
|
|
@@ -86,11 +88,11 @@
|
|
|
86
88
|
<el-table-column width="320" align="right">
|
|
87
89
|
<template #default="{ row }">
|
|
88
90
|
<el-button link type="primary" @click="preview(row)">工具清单</el-button>
|
|
89
|
-
<el-button v-if="row.spec_source === 'url'" link type="primary" :loading="refreshing === row.name" @click="refresh(row.name)">刷新</el-button>
|
|
90
|
-
<el-button link type="primary" :loading="probing === row.name" @click="probeAuthz(row.name)">探针</el-button>
|
|
91
|
-
<el-button v-if="row.embed_credential" link type="primary" :loading="reindexing === row.name" @click="reindex(row.name)">重建索引</el-button>
|
|
92
|
-
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
|
|
93
|
-
<el-popconfirm title="删除该工具源?挂它的路由会降级为纯对话。" width="250" @confirm="del(row.name)">
|
|
91
|
+
<el-button v-if="s.can('tools:write') && row.spec_source === 'url'" link type="primary" :loading="refreshing === row.name" @click="refresh(row.name)">刷新</el-button>
|
|
92
|
+
<el-button v-if="s.can('tools:write')" link type="primary" :loading="probing === row.name" @click="probeAuthz(row.name)">探针</el-button>
|
|
93
|
+
<el-button v-if="s.can('tools:write') && row.embed_credential" link type="primary" :loading="reindexing === row.name" @click="reindex(row.name)">重建索引</el-button>
|
|
94
|
+
<el-button v-if="s.can('tools:write')" link type="primary" :disabled="Boolean(listError)" @click="openEdit(row)">编辑</el-button>
|
|
95
|
+
<el-popconfirm v-if="s.can('tools:write')" title="删除该工具源?挂它的路由会降级为纯对话。" width="250" @confirm="del(row.name)">
|
|
94
96
|
<template #reference><el-button link type="danger">删</el-button></template>
|
|
95
97
|
</el-popconfirm>
|
|
96
98
|
</template>
|
|
@@ -99,15 +101,15 @@
|
|
|
99
101
|
</el-card>
|
|
100
102
|
|
|
101
103
|
<!-- 注册/编辑 -->
|
|
102
|
-
<el-drawer v-model="open" :title="editing ? '编辑工具源' : '注册工具源'" size="560px">
|
|
103
|
-
<el-form label-position="top">
|
|
104
|
+
<el-drawer v-model="open" :title="editing ? '编辑工具源' : '注册工具源'" size="560px" :before-close="formGuard.beforeClose" @closed="clearSecret">
|
|
105
|
+
<el-form name="tool-source-settings" autocomplete="off" label-position="top" :disabled="saving || !s.can('tools:write')">
|
|
104
106
|
<el-tabs v-model="toolFormTab" class="console-tabs">
|
|
105
107
|
<el-tab-pane label="基础" name="basic">
|
|
106
108
|
<el-form-item>
|
|
107
109
|
<template #label>{{ fieldTitle('name', '名称') }} <span v-if="fieldRequired('name')" class="field-required">*</span>
|
|
108
110
|
<HelpTip :title="fieldTitle('name', '名称')"><p>{{ fieldDesc('name') }}</p></HelpTip>
|
|
109
111
|
</template>
|
|
110
|
-
<el-input v-model="form.name" :disabled="editing" placeholder="如 demo-business / business-api" class="mono" />
|
|
112
|
+
<el-input v-model="form.name" name="tool-source-name" autocomplete="off" :disabled="editing || saving" placeholder="如 demo-business / business-api" class="mono" />
|
|
111
113
|
</el-form-item>
|
|
112
114
|
<el-form-item>
|
|
113
115
|
<template #label>{{ fieldTitle('base_url', 'Base URL') }} <span v-if="fieldRequired('base_url')" class="field-required">*</span> <HelpTip :title="fieldTitle('base_url', 'Base URL')">
|
|
@@ -115,7 +117,7 @@
|
|
|
115
117
|
<p>AI 调工具时,请求发到 <code>base_url + 接口 path</code>。</p>
|
|
116
118
|
<p><b>必须指向源站直连地址</b>——中枢"签所发即所发",URI 会被重写 / 重编码的 CDN 或网关后面验签必挂。</p>
|
|
117
119
|
</HelpTip></template>
|
|
118
|
-
<el-input v-model="form.base_url" placeholder="https://server.example.com" class="mono" />
|
|
120
|
+
<el-input v-model="form.base_url" name="tool-source-base-url" type="url" autocomplete="off" placeholder="https://server.example.com" class="mono" />
|
|
119
121
|
</el-form-item>
|
|
120
122
|
<el-form-item>
|
|
121
123
|
<template #label>{{ fieldTitle('secret', '签名密钥') }} <span v-if="fieldRequired('secret')" class="field-required">*</span> <HelpTip :title="fieldTitle('secret', '签名密钥')">
|
|
@@ -124,7 +126,7 @@
|
|
|
124
126
|
<p>这是中枢与业务的<b>共享密钥</b>——业务侧验签要用同一串。建好后列表里只显示掩码,点该行「<b>复制</b>」按钮可随时取回完整值交给业务方(与模型凭证的 api_key 不同,那是中枢出站凭证、永不外泄)。</p>
|
|
125
127
|
<p>与接入方 token、中枢管理 token 完全解耦,可单独轮换;泄露只影响"伪装中枢调业务",不波及其他面。</p>
|
|
126
128
|
</HelpTip></template>
|
|
127
|
-
<el-input v-model="form.secret" type="password" show-password autocomplete="
|
|
129
|
+
<el-input v-model="form.secret" name="tool-source-signing-secret" type="password" show-password autocomplete="new-password" :placeholder="editing ? '留空 = 保留原密钥' : ''">
|
|
128
130
|
<template #append><el-button @click="genSecret">生成</el-button></template>
|
|
129
131
|
</el-input>
|
|
130
132
|
</el-form-item>
|
|
@@ -143,13 +145,14 @@
|
|
|
143
145
|
<p>推荐约定路径 <code>/.well-known/bailing/tools.json</code>,但<b>不强制</b>——宝塔等面板对点开头路径有特殊处理(详见官网开发文档),换任意路径(如 <code>/api/bailing/tools</code>)即可绕开。</p>
|
|
144
146
|
<p>建议 spec 根声明 <code>x-bailing-authz-probe</code>,并在业务系统单独挂一个授权探针端点;中枢刷新后会用不存在的主体验证业务侧是否 fail-closed。</p>
|
|
145
147
|
</HelpTip></template>
|
|
146
|
-
<el-input v-model="form.spec_url" placeholder="https://server.example.com/.well-known/bailing/tools.json" class="mono" />
|
|
148
|
+
<el-input v-model="form.spec_url" name="tool-source-spec-url" type="url" autocomplete="off" placeholder="https://server.example.com/.well-known/bailing/tools.json" class="mono" />
|
|
147
149
|
</el-form-item>
|
|
148
150
|
<el-form-item v-if="form.spec_source === 'url'">
|
|
149
151
|
<template #label>接口清单访问策略 <HelpTip title="接口清单访问策略">
|
|
150
152
|
<p><b>签名保护(推荐)</b>:未签名或错误签名的请求必须被业务侧拒绝;中枢刷新时会用正确签名读取,再以未签名和错误签名请求确认它们均被拒绝。</p>
|
|
151
153
|
<p><b>允许公开</b>:中枢以未签名请求读取;任何能访问该 URL 的人都可以下载接口路径、参数、scope 与风险声明。只应在你明确接受公开时选择。</p>
|
|
152
154
|
<p>该策略只约束接口清单的读取方式;工具调用仍必须验签并按操作主体授权。</p>
|
|
155
|
+
<p>公开的是能力清单,不是签名密钥;但接口路径、参数和风险声明会对 URL 访问者可见。保存时还会再次确认。</p>
|
|
153
156
|
</HelpTip></template>
|
|
154
157
|
<div class="spec-access-policy">
|
|
155
158
|
<el-radio-group v-model="form.spec_access_policy">
|
|
@@ -157,7 +160,7 @@
|
|
|
157
160
|
签名保护(推荐)
|
|
158
161
|
<el-tag v-if="historicalProtectedEvidence" size="small" type="success" effect="plain">与当前实测一致</el-tag>
|
|
159
162
|
</el-radio>
|
|
160
|
-
<el-radio value="public_allowed"
|
|
163
|
+
<el-radio value="public_allowed">允许公开(任何 URL 访问者可读清单)</el-radio>
|
|
161
164
|
</el-radio-group>
|
|
162
165
|
<el-alert
|
|
163
166
|
v-if="historicalAccessPending"
|
|
@@ -174,13 +177,6 @@
|
|
|
174
177
|
size="small"
|
|
175
178
|
@click="adoptProtectedSpecAccess"
|
|
176
179
|
>采用实测结果:签名保护</el-button>
|
|
177
|
-
<el-alert
|
|
178
|
-
v-if="form.spec_access_policy === 'public_allowed'"
|
|
179
|
-
title="公开的是能力清单,不是签名密钥;但接口路径、参数和风险声明会对 URL 访问者可见。保存时还会再次确认。"
|
|
180
|
-
type="warning"
|
|
181
|
-
:closable="false"
|
|
182
|
-
show-icon
|
|
183
|
-
/>
|
|
184
180
|
</div>
|
|
185
181
|
</el-form-item>
|
|
186
182
|
<el-form-item v-if="form.spec_source === 'url'">
|
|
@@ -212,16 +208,18 @@
|
|
|
212
208
|
<el-input-number v-model="form.timeout_ms" :min="1000" :max="60000" :step="1000" />
|
|
213
209
|
</el-form-item>
|
|
214
210
|
<el-form-item>
|
|
215
|
-
<template #label>工具源总限额(次/分钟,0
|
|
211
|
+
<template #label>工具源总限额(次/分钟,0=关闭) <HelpTip title="工具源总限额"><p>该工具源下所有工具、用户、授权和会话共用。设为 0 只关闭总闸,下方单工具策略独立生效。</p></HelpTip></template>
|
|
216
212
|
<el-input-number v-model="form.rate_limit_per_min" :min="0" :max="1000000" :precision="0" :step="100" />
|
|
217
|
-
<div class="muted hint">该工具源下所有工具、用户、授权和会话共用。设为 0 只关闭总闸,下方单工具策略独立生效。</div>
|
|
218
213
|
</el-form-item>
|
|
219
|
-
<el-form-item
|
|
214
|
+
<el-form-item>
|
|
215
|
+
<template #label>单工具默认策略 <HelpTip title="单工具默认策略">
|
|
216
|
+
<p>每个工具分别计数,同一工具的用户与会话共用;120 次/小时按一小时滑动窗口计数,允许在额度内连续调用。</p>
|
|
217
|
+
<p>自定义或关闭只调整中枢限额;接入方限额、业务系统自身限额、权限与审批仍独立生效。保存后对后续调度生效,当前窗口已有计数不会清零。</p>
|
|
218
|
+
</HelpTip></template>
|
|
220
219
|
<ToolRateLimitEditor v-model="toolRateDefault" />
|
|
221
|
-
<div class="muted hint">每个工具分别计数,同一工具的用户与会话共用;120 次/小时按一小时滑动窗口计数,允许在额度内连续调用。</div>
|
|
222
|
-
<div class="muted hint">自定义或关闭只调整中枢限额;接入方限额、业务系统自身限额、权限与审批仍独立生效。保存后对后续调度生效,当前窗口已有计数不会清零。</div>
|
|
223
220
|
</el-form-item>
|
|
224
|
-
<el-form-item
|
|
221
|
+
<el-form-item>
|
|
222
|
+
<template #label>指定工具覆盖 <HelpTip title="指定工具覆盖"><p>覆盖优先于默认策略;“继承业务声明”使用该工具的原声明。刷新能力清单会保留这里的设置。</p></HelpTip></template>
|
|
225
223
|
<div style="width: 100%">
|
|
226
224
|
<div v-for="(entry, index) in toolRateOverrides" :key="index" style="margin-bottom: 12px">
|
|
227
225
|
<div style="display: flex; gap: 8px; margin-bottom: 6px">
|
|
@@ -233,7 +231,6 @@
|
|
|
233
231
|
<ToolRateLimitEditor v-model="entry.policy" />
|
|
234
232
|
</div>
|
|
235
233
|
<el-button @click="toolRateOverrides.push({ name: '', policy: { mode: 'inherit' } })">添加工具覆盖</el-button>
|
|
236
|
-
<div class="muted hint">覆盖优先于默认策略;“继承业务声明”使用该工具的原声明。刷新能力清单会保留这里的设置。</div>
|
|
237
234
|
</div>
|
|
238
235
|
</el-form-item>
|
|
239
236
|
</el-tab-pane>
|
|
@@ -259,14 +256,21 @@
|
|
|
259
256
|
</el-tabs>
|
|
260
257
|
</el-form>
|
|
261
258
|
<template #footer>
|
|
262
|
-
<el-
|
|
263
|
-
<
|
|
259
|
+
<el-alert v-if="saveError" :title="saveError" type="error" :closable="false" show-icon style="margin-bottom:12px" />
|
|
260
|
+
<span v-if="formGuard.dirty.value" class="muted" style="margin-right:12px">有未保存修改</span>
|
|
261
|
+
<el-button :disabled="saving" @click="closeForm">取消</el-button>
|
|
262
|
+
<el-button v-if="s.can('tools:write')" type="primary" :loading="saving" @click="save">保存</el-button>
|
|
264
263
|
</template>
|
|
265
264
|
</el-drawer>
|
|
266
265
|
|
|
267
266
|
<!-- 工具清单预览 -->
|
|
268
267
|
<!-- 800 = 内表格最小宽 670 + 展开列 48 + 抽屉内边距 40 + 余量;改列宽时同步核算,别让抽屉底部出横向滚动 -->
|
|
269
268
|
<el-drawer v-model="previewOpen" :title="'工具清单 · ' + previewName" size="800px">
|
|
269
|
+
<el-alert v-if="previewLoading" title="正在读取工具清单…" type="info" :closable="false" />
|
|
270
|
+
<el-alert v-if="previewError" :title="previewError" type="error" :closable="false" show-icon>
|
|
271
|
+
<template #default><el-button link @click="retryPreview">重新读取</el-button></template>
|
|
272
|
+
</el-alert>
|
|
273
|
+
<el-empty v-if="!previewLoading && !previewError && !previewNote && !previewTools.length && !previewSkipped.length" description="该工具源当前没有可用工具" />
|
|
270
274
|
<el-alert v-if="previewNote" :title="previewNote" type="warning" :closable="false" style="margin-bottom: 12px" />
|
|
271
275
|
<template v-if="previewWarnings.length">
|
|
272
276
|
<div class="muted" style="margin: 0 0 6px">接入体检提醒:</div>
|
|
@@ -333,7 +337,7 @@
|
|
|
333
337
|
<div class="debug-actions">
|
|
334
338
|
<el-checkbox v-model="debugAllowRisky" size="small">允许实调高风险/审批工具</el-checkbox>
|
|
335
339
|
<el-button size="small" @click="syncDebugJsonFromForm">生成 JSON</el-button>
|
|
336
|
-
<el-button type="primary" size="small" :loading="debugLoading" @click="runDebugInvoke">实调验证</el-button>
|
|
340
|
+
<el-button v-if="s.can('tools:write')" type="primary" size="small" :loading="debugLoading" @click="runDebugInvoke">实调验证</el-button>
|
|
337
341
|
</div>
|
|
338
342
|
<div v-if="debugResult" class="debug-result">
|
|
339
343
|
<div class="debug-status">
|
|
@@ -391,7 +395,7 @@
|
|
|
391
395
|
· {{ row.readonly ? '只读' : '会改数据' }}
|
|
392
396
|
</div>
|
|
393
397
|
<div class="muted">业务声明:{{ row.rate_limit ? row.rate_limit.count + ' 次/' + rateWindowLabel[row.rate_limit.window] : row.rate_limit_per_min ? row.rate_limit_per_min + ' 次/分钟' : '未声明限额' }}。生效来源:{{ ({ declaration: '业务声明', provider_default: '中枢默认策略', tool_override: '指定工具覆盖' } as any)[row.effective_rate_limit?.source] || '业务声明' }}。</div>
|
|
394
|
-
<el-button text type="primary" @click="editLimitsFromPreview">设置限额</el-button>
|
|
398
|
+
<el-button v-if="s.can('tools:write')" text type="primary" @click="editLimitsFromPreview">设置限额</el-button>
|
|
395
399
|
<template v-if="row.confirm_prompt">
|
|
396
400
|
<div class="td-sec">审批通知话术(ACC approval.prompt,{参数名} 由实参填充后发给审批人)</div>
|
|
397
401
|
<div class="td-text">{{ row.confirm_prompt }}</div>
|
|
@@ -427,8 +431,11 @@
|
|
|
427
431
|
</template>
|
|
428
432
|
|
|
429
433
|
<script setup lang="ts">
|
|
434
|
+
import ListLocationBar from '../components/ListLocationBar.vue';
|
|
435
|
+
import { useListLocation } from '../use-list-location';
|
|
430
436
|
import ToolRateLimitEditor from '../components/ToolRateLimitEditor.vue';
|
|
431
437
|
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
|
438
|
+
import { useRoute } from 'vue-router';
|
|
432
439
|
import { ElMessage } from 'element-plus/es/components/message/index';
|
|
433
440
|
import { ElMessageBox } from 'element-plus/es/components/message-box/index';
|
|
434
441
|
import { api } from '../request';
|
|
@@ -437,13 +444,19 @@ import { fmtTime } from '../util';
|
|
|
437
444
|
import { useMe } from '../store';
|
|
438
445
|
import HelpTip from '../components/HelpTip.vue';
|
|
439
446
|
import { schemaDescription, schemaRequired, schemaTitle, useConfigSchema } from '../schema';
|
|
447
|
+
import { useUnsavedForm } from '../use-unsaved-form';
|
|
440
448
|
|
|
441
449
|
const s = useMe();
|
|
450
|
+
const route = useRoute();
|
|
442
451
|
const toolSchema = useConfigSchema('tool-provider');
|
|
443
452
|
const list = ref<any[]>([]);
|
|
453
|
+
const { keyword: listQuery, focus: listFocus, rows: locatedRows, returnTo: listReturnTo, clear: clearListLocation } = useListLocation(list, { id: r => String(r.name), text: r => `${r.name} ${r.description || ""}` });
|
|
454
|
+
const listLoading = ref(false), listError = ref('');
|
|
455
|
+
let listGeneration = 0;
|
|
444
456
|
const open = ref(false);
|
|
445
457
|
const editing = ref(false);
|
|
446
458
|
const saving = ref(false);
|
|
459
|
+
const saveError = ref('');
|
|
447
460
|
const toolFormTab = ref<'basic' | 'spec' | 'governance' | 'retrieval' | 'publish'>('basic');
|
|
448
461
|
const refreshing = ref('');
|
|
449
462
|
const reindexing = ref('');
|
|
@@ -468,11 +481,16 @@ function toolLimitLabel(limit: any): string {
|
|
|
468
481
|
return limit?.enabled ? `${limit.count} 次/${rateWindowLabel[limit.window] || limit.window}` : '关闭';
|
|
469
482
|
}
|
|
470
483
|
function editLimitsFromPreview(): void {
|
|
484
|
+
if (!s.can('tools:write')) return;
|
|
471
485
|
const row = list.value.find((item: any) => item.name === previewName.value);
|
|
472
486
|
if (row) { openEdit(row); toolFormTab.value = 'governance'; }
|
|
473
487
|
}
|
|
474
488
|
const form = reactive({ name: '', base_url: '', secret: '', spec_source: 'inline', spec_url: '', spec_json: '', spec_access_policy: 'signed_required' as SpecAccessChoice, log_payload: true, timeout_ms: 10000, rate_limit_per_min: 120, auto_refresh_min: 0, description: '', enabled: true, embed_credential: '', embed_model: '', embed_dim: 1024 });
|
|
475
489
|
const editBaseline = ref<ToolProviderEditBaseline | null>(null);
|
|
490
|
+
const formGuard = useUnsavedForm({ active: () => open.value, saving: () => saving.value, name: '工具源配置',
|
|
491
|
+
snapshot: () => ({ form, defaultRate: toolRateDefault.value, overrides: toolRateOverrides.value }) });
|
|
492
|
+
async function closeForm(): Promise<void> { if (await formGuard.confirmLeave()) open.value = false; }
|
|
493
|
+
function clearSecret(): void { if (!open.value) form.secret = ''; }
|
|
476
494
|
const historicalAccessPending = computed(() => editing.value
|
|
477
495
|
&& editBaseline.value?.spec_source === 'url'
|
|
478
496
|
&& editBaseline.value.spec_access_policy === 'legacy_unverified'
|
|
@@ -490,6 +508,8 @@ const historicalAccessDescription = computed(() => historicalProtectedEvidence.v
|
|
|
490
508
|
: '这只是升级前配置缺少管理员意图,不代表清单已公开。当前继续按历史兼容方式运行;可先停用或维护说明、治理、检索等非清单字段。');
|
|
491
509
|
|
|
492
510
|
const previewOpen = ref(false);
|
|
511
|
+
const previewLoading = ref(false), previewError = ref('');
|
|
512
|
+
let previewGeneration = 0, retrieveGeneration = 0, debugGeneration = 0;
|
|
493
513
|
const previewName = ref('');
|
|
494
514
|
const previewTools = ref<any[]>([]);
|
|
495
515
|
const previewSkipped = ref<any[]>([]);
|
|
@@ -732,42 +752,51 @@ const debugDiagnosis = computed(() => {
|
|
|
732
752
|
// 语义召回预演:跑派发同款向量检索,返回工具+分数,让开发者看精度、调优工具措辞
|
|
733
753
|
async function runRetrieveTest(): Promise<void> {
|
|
734
754
|
const q = retrieveQ.value.trim();
|
|
735
|
-
if (!q) return;
|
|
755
|
+
if (!q || retrieving.value) return;
|
|
756
|
+
const generation = ++retrieveGeneration, preview = previewGeneration, name = previewName.value;
|
|
757
|
+
const current = () => generation === retrieveGeneration && preview === previewGeneration && previewOpen.value;
|
|
736
758
|
retrieving.value = true;
|
|
737
759
|
try {
|
|
738
760
|
const r = await api<{ enabled: boolean; min_score_default: number; hits: Array<{ name: string; scope: string; score: number }> }>(
|
|
739
|
-
'/admin/api/tool-providers/' + encodeURIComponent(
|
|
761
|
+
'/admin/api/tool-providers/' + encodeURIComponent(name) + '/retrieve-test', { method: 'POST', body: JSON.stringify({ query: q }) });
|
|
762
|
+
if (!current()) return;
|
|
740
763
|
retrieveMinScore.value = r.min_score_default ?? 0.3;
|
|
741
764
|
retrieveHits.value = r.hits || [];
|
|
742
765
|
lastRetrieveQ.value = q;
|
|
743
766
|
if (!retrieveHits.value.length) ElMessage.info('没有召回(索引为空?先「重建索引」)');
|
|
744
|
-
} catch (e) { ElMessage.error((e as Error).message); }
|
|
745
|
-
finally { retrieving.value = false; }
|
|
767
|
+
} catch (e) { if (current()) ElMessage.error((e as Error).message); }
|
|
768
|
+
finally { if (current()) retrieving.value = false; }
|
|
746
769
|
}
|
|
747
770
|
|
|
748
771
|
async function runDebugInvoke(): Promise<void> {
|
|
772
|
+
if (!s.can('tools:write') || debugLoading.value) return;
|
|
749
773
|
if (!debugTool.value) { ElMessage.error('请选择工具'); return; }
|
|
750
774
|
let args: Record<string, unknown> = {};
|
|
751
775
|
try {
|
|
752
776
|
args = debugMode.value === 'form' ? buildDebugArgsFromForm() : parseDebugJson();
|
|
753
777
|
} catch (e) { ElMessage.error((e as Error).message); return; }
|
|
778
|
+
const generation = ++debugGeneration, preview = previewGeneration, name = previewName.value, tool = debugTool.value;
|
|
779
|
+
const subject = debugSubject.value.trim();
|
|
780
|
+
const current = () => generation === debugGeneration && preview === previewGeneration && previewOpen.value && debugTool.value === tool;
|
|
754
781
|
debugLoading.value = true;
|
|
755
782
|
try {
|
|
756
|
-
|
|
783
|
+
const result = await api<any>('/admin/api/tool-providers/' + encodeURIComponent(name) + '/debug-invoke', {
|
|
757
784
|
method: 'POST',
|
|
758
785
|
body: JSON.stringify({
|
|
759
|
-
tool
|
|
786
|
+
tool,
|
|
760
787
|
args,
|
|
761
|
-
on_behalf_of:
|
|
788
|
+
on_behalf_of: subject,
|
|
762
789
|
allow_risky: debugAllowRisky.value,
|
|
763
790
|
}),
|
|
764
791
|
});
|
|
765
|
-
|
|
792
|
+
if (!current()) return;
|
|
793
|
+
debugResult.value = result;
|
|
794
|
+
saveDebugSample(args, subject);
|
|
766
795
|
if (debugResult.value.blocked) ElMessage.warning('调用已被调试台阻断');
|
|
767
796
|
else if (debugResult.value.ok) ElMessage.success('工具调用成功');
|
|
768
797
|
else ElMessage.warning('工具调用返回失败状态');
|
|
769
|
-
} catch (e) { ElMessage.error((e as Error).message); }
|
|
770
|
-
finally { debugLoading.value = false; }
|
|
798
|
+
} catch (e) { if (current()) ElMessage.error((e as Error).message); }
|
|
799
|
+
finally { if (current()) debugLoading.value = false; }
|
|
771
800
|
}
|
|
772
801
|
|
|
773
802
|
function parseDebugJson(): Record<string, unknown> {
|
|
@@ -826,12 +855,13 @@ function loadDebugSamples(): void {
|
|
|
826
855
|
}
|
|
827
856
|
}
|
|
828
857
|
|
|
829
|
-
function saveDebugSample(args: Record<string, unknown
|
|
830
|
-
const sample = { id: `${Date.now()}`, at: new Date().toISOString(), subject
|
|
858
|
+
function saveDebugSample(args: Record<string, unknown>, subject: string): void {
|
|
859
|
+
const sample = { id: `${Date.now()}`, at: new Date().toISOString(), subject, args };
|
|
831
860
|
const same = (x: any) => x.subject === sample.subject && JSON.stringify(x.args) === JSON.stringify(args);
|
|
832
861
|
const next = [sample, ...debugSamples.value.filter((x) => !same(x))].slice(0, 5);
|
|
833
862
|
debugSamples.value = next;
|
|
834
|
-
localStorage.setItem(debugStorageKey(), JSON.stringify(next));
|
|
863
|
+
try { localStorage.setItem(debugStorageKey(), JSON.stringify(next)); }
|
|
864
|
+
catch { /* Sample persistence is optional and must not turn a completed business call into a failure. */ }
|
|
835
865
|
}
|
|
836
866
|
|
|
837
867
|
function applyDebugSampleById(id: string): void {
|
|
@@ -853,6 +883,7 @@ function applyDebugArgsToForm(args: Record<string, unknown>): void {
|
|
|
853
883
|
}
|
|
854
884
|
|
|
855
885
|
function resetDebugForTool(): void {
|
|
886
|
+
debugGeneration++; debugLoading.value = false;
|
|
856
887
|
debugResult.value = null;
|
|
857
888
|
debugAllowRisky.value = false;
|
|
858
889
|
loadDebugSamples();
|
|
@@ -888,6 +919,7 @@ function paramRows(t: any): Array<{ name: string; loc: string; type: string; req
|
|
|
888
919
|
|
|
889
920
|
// 取回完整签名密钥并复制(列表只给掩码;这把密钥要交给业务方验签,需随时可取)
|
|
890
921
|
async function copySecret(name: string): Promise<void> {
|
|
922
|
+
if (!s.can('tools:write')) return;
|
|
891
923
|
try {
|
|
892
924
|
const r = await api<{ secret: string }>(`/admin/api/tool-providers/${encodeURIComponent(name)}/secret`);
|
|
893
925
|
await navigator.clipboard.writeText(r.secret);
|
|
@@ -896,11 +928,20 @@ async function copySecret(name: string): Promise<void> {
|
|
|
896
928
|
}
|
|
897
929
|
|
|
898
930
|
async function load(): Promise<void> {
|
|
899
|
-
|
|
931
|
+
const generation = ++listGeneration;
|
|
932
|
+
listLoading.value = true;
|
|
933
|
+
try {
|
|
934
|
+
const rows = await api<any[]>('/admin/api/tool-providers');
|
|
935
|
+
if (generation === listGeneration) { list.value = rows; listError.value = ''; }
|
|
936
|
+
} catch { if (generation === listGeneration) listError.value = list.value.length ? '工具源列表刷新失败,当前保留旧快照。' : '工具源列表读取失败,请重试。'; }
|
|
937
|
+
finally { if (generation === listGeneration) listLoading.value = false; }
|
|
900
938
|
// 向量化凭证(工具检索选坐标系用);无权限/失败不阻塞页面
|
|
901
|
-
|
|
939
|
+
if (s.can('credentials:read')) {
|
|
940
|
+
try { embCreds.value = (await api<any[]>('/admin/api/credentials')).filter((c) => c.kind === 'embedding' || c.kind === 'both'); } catch { /* 可选 */ }
|
|
941
|
+
}
|
|
902
942
|
}
|
|
903
943
|
async function reindex(name: string): Promise<void> {
|
|
944
|
+
if (!s.can('tools:write')) return;
|
|
904
945
|
reindexing.value = name;
|
|
905
946
|
try {
|
|
906
947
|
const r = await api<{ total: number; added: string[]; changed: string[]; removed: string[] }>('/admin/api/tool-providers/' + encodeURIComponent(name) + '/reindex', { method: 'POST' });
|
|
@@ -909,6 +950,7 @@ async function reindex(name: string): Promise<void> {
|
|
|
909
950
|
finally { reindexing.value = ''; }
|
|
910
951
|
}
|
|
911
952
|
async function probeAuthz(name: string): Promise<void> {
|
|
953
|
+
if (!s.can('tools:write')) return;
|
|
912
954
|
probing.value = name;
|
|
913
955
|
try {
|
|
914
956
|
const r = await api<{ authz_probe: any }>('/admin/api/tool-providers/' + encodeURIComponent(name) + '/authz-probe', { method: 'POST' });
|
|
@@ -919,6 +961,7 @@ async function probeAuthz(name: string): Promise<void> {
|
|
|
919
961
|
finally { probing.value = ''; }
|
|
920
962
|
}
|
|
921
963
|
function openCreate(): void {
|
|
964
|
+
if (!s.can('tools:write') || saving.value || open.value) return;
|
|
922
965
|
toolRateDefault.value = { mode: 'inherit' };
|
|
923
966
|
toolRateOverrides.value = [];
|
|
924
967
|
limitToolNames.value = [];
|
|
@@ -926,9 +969,11 @@ function openCreate(): void {
|
|
|
926
969
|
editBaseline.value = null;
|
|
927
970
|
toolFormTab.value = 'basic';
|
|
928
971
|
Object.assign(form, { name: '', base_url: '', secret: '', spec_source: 'inline', spec_url: '', spec_json: '', spec_access_policy: 'signed_required', log_payload: true, timeout_ms: 10000, rate_limit_per_min: 120, auto_refresh_min: 0, description: '', enabled: true, embed_credential: '', embed_model: '', embed_dim: 1024 });
|
|
972
|
+
saveError.value = ''; formGuard.begin();
|
|
929
973
|
open.value = true;
|
|
930
974
|
}
|
|
931
975
|
function openEdit(row: any): void {
|
|
976
|
+
if (!s.can('tools:write') || saving.value || open.value || listError.value) return;
|
|
932
977
|
toolRateDefault.value = JSON.parse(JSON.stringify(row.tool_rate_limits?.default ?? { mode: 'inherit' }));
|
|
933
978
|
toolRateOverrides.value = Object.entries(row.tool_rate_limits?.overrides ?? {}).map(([name, policy]) => ({ name, policy: JSON.parse(JSON.stringify(policy)) as RatePolicy }));
|
|
934
979
|
limitToolNames.value = [];
|
|
@@ -950,6 +995,7 @@ function openEdit(row: any): void {
|
|
|
950
995
|
? policy === 'legacy_unverified' ? '' : policy
|
|
951
996
|
: 'signed_required';
|
|
952
997
|
Object.assign(form, { name: row.name, base_url: row.base_url, secret: '', spec_source: row.spec_source, spec_url: row.spec_url || '', spec_json: '', spec_access_policy: policyChoice, log_payload: !!row.log_payload, timeout_ms: row.timeout_ms, rate_limit_per_min: row.rate_limit_per_min, auto_refresh_min: row.auto_refresh_min ?? 0, description: row.description || '', enabled: !!row.enabled, embed_credential: row.embed_credential || '', embed_model: row.embed_model || '', embed_dim: row.embed_dim || 1024 });
|
|
998
|
+
saveError.value = ''; formGuard.begin();
|
|
953
999
|
open.value = true;
|
|
954
1000
|
}
|
|
955
1001
|
function onEmbedCred(): void {
|
|
@@ -972,27 +1018,29 @@ function historicalAccessSensitiveChange(): boolean {
|
|
|
972
1018
|
|| (!baseline.enabled && form.enabled);
|
|
973
1019
|
}
|
|
974
1020
|
async function save(): Promise<void> {
|
|
1021
|
+
if (!s.can('tools:write') || saving.value) return;
|
|
1022
|
+
saveError.value = '';
|
|
975
1023
|
if (historicalAccessSensitiveChange()) {
|
|
976
1024
|
toolFormTab.value = 'spec';
|
|
977
|
-
|
|
1025
|
+
saveError.value = '这项修改会改变接口清单拉取或重新启用历史工具源,请先确认签名保护或允许公开';
|
|
978
1026
|
return;
|
|
979
1027
|
}
|
|
980
|
-
if (form.spec_source === 'url' && form.spec_access_policy === 'public_allowed') {
|
|
981
|
-
try {
|
|
982
|
-
const message = historicalProtectedEvidence.value
|
|
983
|
-
? '当前实测为正签可读、未签和错签均被拒绝。选择允许公开是在改变访问方式;需先让业务端允许匿名读取,否则刷新会失败。确认仍允许公开吗?'
|
|
984
|
-
: '任何能访问该 URL 的人都可以下载接口路径、参数、scope 与风险声明。工具调用仍需验签和授权。确认允许公开这份接口清单吗?';
|
|
985
|
-
await ElMessageBox.confirm(
|
|
986
|
-
message,
|
|
987
|
-
'确认公开接口清单',
|
|
988
|
-
{ confirmButtonText: '确认允许公开', cancelButtonText: '返回修改', type: 'warning' },
|
|
989
|
-
);
|
|
990
|
-
} catch {
|
|
991
|
-
return;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
1028
|
saving.value = true;
|
|
995
1029
|
try {
|
|
1030
|
+
if (form.spec_source === 'url' && form.spec_access_policy === 'public_allowed') {
|
|
1031
|
+
try {
|
|
1032
|
+
const message = historicalProtectedEvidence.value
|
|
1033
|
+
? '当前实测为正签可读、未签和错签均被拒绝。选择允许公开是在改变访问方式;需先让业务端允许匿名读取,否则刷新会失败。确认仍允许公开吗?'
|
|
1034
|
+
: '任何能访问该 URL 的人都可以下载接口路径、参数、scope 与风险声明。工具调用仍需验签和授权。确认允许公开这份接口清单吗?';
|
|
1035
|
+
await ElMessageBox.confirm(
|
|
1036
|
+
message,
|
|
1037
|
+
'确认公开接口清单',
|
|
1038
|
+
{ confirmButtonText: '确认允许公开', cancelButtonText: '返回修改', type: 'warning' },
|
|
1039
|
+
);
|
|
1040
|
+
} catch {
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
996
1044
|
const names = toolRateOverrides.value.map((entry) => entry.name);
|
|
997
1045
|
if (new Set(names).size !== names.length || names.some((name) => !/^[A-Za-z_][A-Za-z0-9_]{0,63}$/.test(name))) throw new Error('指定工具覆盖的工具名不能为空、重复或包含特殊字符');
|
|
998
1046
|
const payload: Record<string, unknown> = { ...form, tool_rate_limits: {
|
|
@@ -1001,11 +1049,12 @@ async function save(): Promise<void> {
|
|
|
1001
1049
|
// 历史 URL 工具源未确认时省略该字段:后端会保留既有 sentinel,空串绝不代表允许公开。
|
|
1002
1050
|
if (form.spec_source === 'url' && form.spec_access_policy === '') delete payload.spec_access_policy;
|
|
1003
1051
|
await api('/admin/api/tool-providers', { method: 'POST', body: JSON.stringify(payload) });
|
|
1004
|
-
ElMessage.success('已保存(密钥不再回显完整值)'); open.value = false; await load();
|
|
1005
|
-
} catch (e) {
|
|
1052
|
+
formGuard.markSaved(); ElMessage.success('已保存(密钥不再回显完整值)'); open.value = false; await load();
|
|
1053
|
+
} catch (e) { saveError.value = `未能确认保存成功:${(e as Error).message}。输入已保留,请核对后重试。`; }
|
|
1006
1054
|
finally { saving.value = false; }
|
|
1007
1055
|
}
|
|
1008
1056
|
async function refresh(name: string): Promise<void> {
|
|
1057
|
+
if (!s.can('tools:write')) return;
|
|
1009
1058
|
refreshing.value = name;
|
|
1010
1059
|
try {
|
|
1011
1060
|
const r = await api<{ tools: number }>('/admin/api/tool-providers/' + encodeURIComponent(name) + '/refresh', { method: 'POST' });
|
|
@@ -1014,30 +1063,46 @@ async function refresh(name: string): Promise<void> {
|
|
|
1014
1063
|
finally { refreshing.value = ''; }
|
|
1015
1064
|
}
|
|
1016
1065
|
async function preview(row: any): Promise<void> {
|
|
1066
|
+
const generation = ++previewGeneration;
|
|
1067
|
+
retrieveGeneration++; debugGeneration++; retrieving.value = false; debugLoading.value = false;
|
|
1017
1068
|
previewName.value = row.name;
|
|
1069
|
+
previewLoading.value = true; previewError.value = ''; previewNote.value = ''; previewOpen.value = true;
|
|
1018
1070
|
previewEmbed.value = !!row.embed_credential;
|
|
1019
1071
|
previewFilter.value = ''; retrieveQ.value = ''; lastRetrieveQ.value = ''; retrieveHits.value = [];
|
|
1020
1072
|
debugTool.value = ''; debugSubject.value = ''; debugArgs.value = '{}'; debugAllowRisky.value = false; debugResult.value = null; debugSamples.value = []; debugSampleId.value = '';
|
|
1021
1073
|
previewWarnings.value = []; previewSkipped.value = []; previewTools.value = [];
|
|
1022
1074
|
try {
|
|
1023
1075
|
const r = await api<any>('/admin/api/tool-providers/' + encodeURIComponent(row.name) + '/tools');
|
|
1076
|
+
if (generation !== previewGeneration || !previewOpen.value) return;
|
|
1024
1077
|
previewTools.value = r.tools || [];
|
|
1025
1078
|
previewSkipped.value = r.skipped || [];
|
|
1026
1079
|
previewWarnings.value = r.warnings || [];
|
|
1027
1080
|
previewNote.value = r.note || '';
|
|
1028
|
-
previewOpen.value = true;
|
|
1029
1081
|
debugTool.value = previewTools.value[0]?.name || '';
|
|
1030
1082
|
resetDebugForTool();
|
|
1031
|
-
} catch (e) {
|
|
1083
|
+
} catch (e) { if (generation === previewGeneration && previewOpen.value) previewError.value = `工具清单读取失败:${(e as Error).message}`; }
|
|
1084
|
+
finally { if (generation === previewGeneration) previewLoading.value = false; }
|
|
1085
|
+
}
|
|
1086
|
+
function retryPreview(): void {
|
|
1087
|
+
const row = list.value.find(item => item.name === previewName.value);
|
|
1088
|
+
if (row) void preview(row);
|
|
1032
1089
|
}
|
|
1033
1090
|
async function del(name: string): Promise<void> {
|
|
1091
|
+
if (!s.can('tools:write')) return;
|
|
1034
1092
|
try { await api('/admin/api/tool-providers/' + encodeURIComponent(name), { method: 'DELETE' }); await load(); }
|
|
1035
1093
|
catch (e) { ElMessage.error((e as Error).message); }
|
|
1036
1094
|
}
|
|
1037
1095
|
onMounted(async () => {
|
|
1096
|
+
if (route.query.create === '1') openCreate();
|
|
1038
1097
|
await Promise.all([toolSchema.load().catch(() => undefined), load()]);
|
|
1039
1098
|
});
|
|
1099
|
+
watch(() => route.query.create, (create) => { if (create === '1') openCreate(); });
|
|
1040
1100
|
watch(debugTool, () => resetDebugForTool());
|
|
1101
|
+
watch(previewOpen, (value) => {
|
|
1102
|
+
if (value) return;
|
|
1103
|
+
previewGeneration++; retrieveGeneration++; debugGeneration++;
|
|
1104
|
+
previewLoading.value = false; retrieving.value = false; debugLoading.value = false;
|
|
1105
|
+
}, { flush: 'sync' });
|
|
1041
1106
|
</script>
|
|
1042
1107
|
|
|
1043
1108
|
<style scoped>
|