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
package/scripts/sdk-p1-check.mjs
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cpSync, mkdtempSync, rmSync } from 'node:fs';
|
|
2
2
|
import { tmpdir } from 'node:os';
|
|
3
|
-
import { join, resolve } from 'node:path';
|
|
3
|
+
import { basename, join, resolve } from 'node:path';
|
|
4
4
|
import { spawnSync } from 'node:child_process';
|
|
5
5
|
|
|
6
6
|
const root = resolve(import.meta.dirname, '..');
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
if (args.some((arg) => arg !== '--require-all')) {
|
|
9
|
+
console.error('Usage: node scripts/sdk-p1-check.mjs [--require-all]');
|
|
10
|
+
process.exit(2);
|
|
11
|
+
}
|
|
12
|
+
const requireAll = args.includes('--require-all');
|
|
13
|
+
const matrixMarker = 'PASS: 24 readonly/risk combinations + 6 idempotent combinations';
|
|
7
14
|
let pass = 0;
|
|
8
15
|
let fail = 0;
|
|
16
|
+
let skipped = 0;
|
|
9
17
|
|
|
10
18
|
function ok(name, cond, extra = '') {
|
|
11
19
|
if (cond) {
|
|
@@ -17,42 +25,70 @@ function ok(name, cond, extra = '') {
|
|
|
17
25
|
}
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
function
|
|
21
|
-
return
|
|
28
|
+
function details(result) {
|
|
29
|
+
return [result.error?.message, result.stderr, result.stdout].filter(Boolean).join('\n').trim();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function run(cmd, args, cwd = root, timeout = 300_000) {
|
|
33
|
+
return spawnSync(cmd, args, { cwd, encoding: 'utf8', timeout, maxBuffer: 10 * 1024 * 1024 });
|
|
22
34
|
}
|
|
23
35
|
|
|
24
|
-
function
|
|
25
|
-
|
|
36
|
+
function toolchain(name, probes) {
|
|
37
|
+
// Probe the actual executables with the same inherited PATH as every test.
|
|
38
|
+
// A login shell can replace PATH and accidentally validate a different toolchain.
|
|
39
|
+
const unavailable = probes.map(([cmd, probeArgs]) => ({ cmd, result: run(cmd, probeArgs, root, 15_000) }))
|
|
40
|
+
.filter(({ result }) => result.status !== 0);
|
|
41
|
+
if (!unavailable.length) return true;
|
|
42
|
+
skipped++;
|
|
43
|
+
console.log(` SKIP ${name} example and declaration matrix: ${unavailable.map(({ cmd, result }) => `${cmd}: ${details(result) || `exit ${result.status}`}`).join('; ')}`);
|
|
44
|
+
if (requireAll) ok(`${name} toolchain required (--require-all)`, false);
|
|
45
|
+
return false;
|
|
26
46
|
}
|
|
27
47
|
|
|
28
48
|
console.log('— P1 SDK checks');
|
|
29
49
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
if (toolchain('Java', [['javac', ['-version']], ['java', ['-version']]])) {
|
|
51
|
+
const javaOut = mkdtempSync(join(tmpdir(), 'bailing-java-'));
|
|
52
|
+
try {
|
|
53
|
+
const compile = run('javac', ['-d', javaOut, 'sdk/java/src/main/java/com/bailing/connect/BailingConnect.java', 'sdk/java/examples/BuildSpec.java', 'sdk/java/tests/DeclarationTest.java']);
|
|
54
|
+
ok('Java SDK, example and declaration matrix compile', compile.status === 0, details(compile));
|
|
55
|
+
if (compile.status === 0) {
|
|
56
|
+
const out = run('java', ['-cp', javaOut, 'BuildSpec']);
|
|
57
|
+
ok('Java example emits OpenAPI', out.status === 0 && out.stdout.includes('"openapi":"3.0.0"'), details(out));
|
|
58
|
+
const matrix = run('java', ['-cp', javaOut, 'DeclarationTest']);
|
|
59
|
+
ok('Java declaration matrix: 24 readonly/risk + 6 idempotent', matrix.status === 0 && matrix.stdout.includes(matrixMarker), details(matrix));
|
|
60
|
+
}
|
|
61
|
+
} finally {
|
|
62
|
+
rmSync(javaOut, { recursive: true, force: true });
|
|
37
63
|
}
|
|
38
|
-
rmSync(javaOut, { recursive: true, force: true });
|
|
39
|
-
} else {
|
|
40
|
-
ok('Java SDK source present', existsSync(resolve(root, 'sdk/java/src/main/java/com/bailing/connect/BailingConnect.java')));
|
|
41
64
|
}
|
|
42
65
|
|
|
43
|
-
if (
|
|
66
|
+
if (toolchain('Go', [['go', ['version']]])) {
|
|
44
67
|
const out = run('go', ['run', './examples/build-spec'], resolve(root, 'sdk/go'));
|
|
45
|
-
ok('Go example emits OpenAPI', out.status === 0 && out.stdout.includes('"openapi": "3.0.0"'), out
|
|
46
|
-
|
|
47
|
-
ok('Go
|
|
68
|
+
ok('Go example emits OpenAPI', out.status === 0 && out.stdout.includes('"openapi": "3.0.0"'), details(out));
|
|
69
|
+
const matrix = run('go', ['test', '-count=1', '-v', './bailingconnect'], resolve(root, 'sdk/go'));
|
|
70
|
+
ok('Go declaration matrix: 24 readonly/risk + 6 idempotent', matrix.status === 0
|
|
71
|
+
&& matrix.stdout.includes('--- PASS: TestDeclarationReadonlyRiskMatrix (')
|
|
72
|
+
&& matrix.stdout.includes('--- PASS: TestDeclarationIdempotentPresence ('), details(matrix));
|
|
48
73
|
}
|
|
49
74
|
|
|
50
|
-
if (
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
if (toolchain('.NET', [['dotnet', ['--version']]])) {
|
|
76
|
+
const dotnetRoot = mkdtempSync(join(tmpdir(), 'bailing-dotnet-'));
|
|
77
|
+
try {
|
|
78
|
+
// dotnet writes bin/obj next to each project. Keep them out of SDK sources
|
|
79
|
+
// and distribution archives, and do not reuse stale local build outputs.
|
|
80
|
+
cpSync(resolve(root, 'sdk/dotnet'), dotnetRoot, {
|
|
81
|
+
recursive: true,
|
|
82
|
+
filter: (source) => !['bin', 'obj'].includes(basename(source)),
|
|
83
|
+
});
|
|
84
|
+
const out = run('dotnet', ['run', '--project', 'examples/BuildSpec/BuildSpec.csproj'], dotnetRoot);
|
|
85
|
+
ok('.NET example emits OpenAPI', out.status === 0 && out.stdout.includes('"openapi": "3.0.0"'), details(out));
|
|
86
|
+
const matrix = run('dotnet', ['run', '--project', 'tests/Declaration/Declaration.csproj'], dotnetRoot);
|
|
87
|
+
ok('.NET declaration matrix: 24 readonly/risk + 6 idempotent', matrix.status === 0 && matrix.stdout.includes(matrixMarker), details(matrix));
|
|
88
|
+
} finally {
|
|
89
|
+
rmSync(dotnetRoot, { recursive: true, force: true });
|
|
90
|
+
}
|
|
55
91
|
}
|
|
56
92
|
|
|
57
|
-
console.log(`\n结果:通过 ${pass} / 失败 ${fail}`);
|
|
93
|
+
console.log(`\n结果:通过 ${pass} / 失败 ${fail} / 跳过工具链 ${skipped}${requireAll ? '(不允许跳过)' : ''}`);
|
|
58
94
|
process.exit(fail ? 1 : 0);
|
|
@@ -145,6 +145,14 @@ const requiredFiles = [
|
|
|
145
145
|
'docs/RELEASE_NOTES_v0.9.4.en.md',
|
|
146
146
|
'docs/UPGRADE_v0.9.4.md',
|
|
147
147
|
'docs/UPGRADE_v0.9.4.en.md',
|
|
148
|
+
'docs/RELEASE_NOTES_v0.10.0.md',
|
|
149
|
+
'docs/RELEASE_NOTES_v0.10.0.en.md',
|
|
150
|
+
'docs/UPGRADE_v0.10.0.md',
|
|
151
|
+
'docs/UPGRADE_v0.10.0.en.md',
|
|
152
|
+
'docs/RELEASE_NOTES_v0.10.1.md',
|
|
153
|
+
'docs/RELEASE_NOTES_v0.10.1.en.md',
|
|
154
|
+
'docs/UPGRADE_v0.10.1.md',
|
|
155
|
+
'docs/UPGRADE_v0.10.1.en.md',
|
|
148
156
|
'docs/RELEASE_NOTES_v0.6.1.md',
|
|
149
157
|
'docs/RELEASE_NOTES_v0.6.0.md',
|
|
150
158
|
'docs/CHANGELOG.md',
|
|
@@ -140,7 +140,7 @@ public static class BailingConnect
|
|
|
140
140
|
private static Dictionary<string, object?> BuildCapability(Tool t, string method)
|
|
141
141
|
{
|
|
142
142
|
var capability = new Dictionary<string, object?> { ["version"] = 1, ["enabled"] = true, ["scope"] = t.Scope };
|
|
143
|
-
if (!string.IsNullOrEmpty(t.Risk)
|
|
143
|
+
if (!string.IsNullOrEmpty(t.Risk)) capability["risk"] = new Dictionary<string, object?> { ["level"] = t.Risk };
|
|
144
144
|
if (t.Confirm || t.ConfirmWhen.Count > 0 || !string.IsNullOrEmpty(t.ConfirmPrompt))
|
|
145
145
|
{
|
|
146
146
|
var approval = new Dictionary<string, object?>();
|
|
@@ -151,8 +151,8 @@ public static class BailingConnect
|
|
|
151
151
|
}
|
|
152
152
|
if (t.RequiresSubject) capability["subject"] = new Dictionary<string, object?> { ["required"] = true };
|
|
153
153
|
var execution = new Dictionary<string, object?>();
|
|
154
|
-
if (t.Readonly
|
|
155
|
-
if (t.Idempotent
|
|
154
|
+
if (t.Readonly.HasValue) execution["readonly"] = t.Readonly.Value;
|
|
155
|
+
if (t.Idempotent.HasValue) execution["idempotent"] = t.Idempotent.Value;
|
|
156
156
|
var rateLimit = NormalizeRateLimit(t.RateLimit);
|
|
157
157
|
if (rateLimit is not null) execution["rate_limit"] = rateLimit;
|
|
158
158
|
if (t.TimeoutMs is not null) execution["timeout_ms"] = t.TimeoutMs;
|
|
@@ -200,7 +200,7 @@ public sealed class Tool
|
|
|
200
200
|
public string Scope { get; init; } = "";
|
|
201
201
|
public string Path { get; init; } = "";
|
|
202
202
|
public string Method { get; init; } = "GET";
|
|
203
|
-
public string Risk { get; init; } = "
|
|
203
|
+
public string Risk { get; init; } = "";
|
|
204
204
|
public bool Confirm { get; init; }
|
|
205
205
|
public List<Dictionary<string, object?>> ConfirmWhen { get; init; } = [];
|
|
206
206
|
public bool? Readonly { get; init; }
|
package/sdk/dotnet/README.md
CHANGED
|
@@ -30,3 +30,11 @@ var ok = BailingConnect.VerifyToolCall(secret, method, pathWithQuery, rawBody, t
|
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
Verification proves the call came from the hub. Your business service must still authorize `onBehalfOf` against its own permission table.
|
|
33
|
+
|
|
34
|
+
## Omitted and explicit declaration values
|
|
35
|
+
|
|
36
|
+
Unspecified `risk`, `readonly`, and `idempotent` fields stay absent from ACC. Explicit low/medium/high risk and both boolean values are preserved, including false on GET. With risk omitted, the ACC OpenAPI binding gives an explicit readonly value precedence over the HTTP method: GET without a readonly declaration defaults to low; other non-readonly operations default to medium. Risk does not replace approval or final business authorization.
|
|
37
|
+
|
|
38
|
+
Regenerate and compare declarations when upgrading; do not turn previously omitted risk into explicit low for all operations. The default `Tool.Risk` is now the empty string rather than `"low"`; it represents omission and retains the existing string property type. `Readonly` and `Idempotent` continue to use null for omission.
|
|
39
|
+
|
|
40
|
+
Run `dotnet run --project sdk/dotnet/tests/Declaration/Declaration.csproj` for 24 readonly/risk combinations and 6 idempotency combinations.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
<PropertyGroup>
|
|
3
|
+
<OutputType>Exe</OutputType>
|
|
4
|
+
<TargetFramework>net8.0</TargetFramework>
|
|
5
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
6
|
+
<Nullable>enable</Nullable>
|
|
7
|
+
</PropertyGroup>
|
|
8
|
+
<ItemGroup>
|
|
9
|
+
<ProjectReference Include="../../Bailing.Connect/Bailing.Connect.csproj" />
|
|
10
|
+
</ItemGroup>
|
|
11
|
+
</Project>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
using System.Text.Json;
|
|
2
|
+
using Bailing.Connect;
|
|
3
|
+
|
|
4
|
+
static JsonElement Capability(Tool tool)
|
|
5
|
+
{
|
|
6
|
+
var spec = BailingConnect.BuildOpenApiSpec("Fixture", "1", [tool]);
|
|
7
|
+
using var json = JsonDocument.Parse(BailingConnect.ToJson(spec));
|
|
8
|
+
return json.RootElement.GetProperty("paths").GetProperty("/fixture")
|
|
9
|
+
.GetProperty(tool.Method.ToLowerInvariant()).GetProperty("x-agent-capability").Clone();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static void Check(bool condition, string message)
|
|
13
|
+
{
|
|
14
|
+
if (!condition) throw new InvalidOperationException(message);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static Tool Fixture(string method, bool? readonlyValue = null, string risk = "", bool? idempotent = null)
|
|
18
|
+
{
|
|
19
|
+
// Exercise the real property default when risk is omitted.
|
|
20
|
+
if (risk == "") return new Tool
|
|
21
|
+
{
|
|
22
|
+
Name = "serialization_fixture", Description = "Declaration serialization fixture",
|
|
23
|
+
Scope = "fixture.write", Path = "/fixture", Method = method,
|
|
24
|
+
Readonly = readonlyValue, Idempotent = idempotent,
|
|
25
|
+
Params = [new Param { Name = "fixture" }]
|
|
26
|
+
};
|
|
27
|
+
return new Tool
|
|
28
|
+
{
|
|
29
|
+
Name = "serialization_fixture", Description = "Declaration serialization fixture",
|
|
30
|
+
Scope = "fixture.write", Path = "/fixture", Method = method,
|
|
31
|
+
Readonly = readonlyValue, Risk = risk, Idempotent = idempotent,
|
|
32
|
+
Params = [new Param { Name = "fixture" }]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
int matrix = 0, idempotency = 0;
|
|
37
|
+
foreach (var method in new[] { "GET", "POST" })
|
|
38
|
+
{
|
|
39
|
+
foreach (bool? readonlyValue in new bool?[] { null, false, true })
|
|
40
|
+
{
|
|
41
|
+
foreach (var risk in new[] { "", "low", "medium", "high" })
|
|
42
|
+
{
|
|
43
|
+
var cap = Capability(Fixture(method, readonlyValue, risk));
|
|
44
|
+
var hasExecution = cap.TryGetProperty("execution", out var execution);
|
|
45
|
+
JsonElement readonlyJson = default;
|
|
46
|
+
var hasReadonly = hasExecution && execution.TryGetProperty("readonly", out readonlyJson);
|
|
47
|
+
var label = $"{method} readonly={readonlyValue} risk={risk}";
|
|
48
|
+
Check(hasReadonly == readonlyValue.HasValue, label + " readonly presence");
|
|
49
|
+
if (readonlyValue.HasValue) Check(readonlyJson.GetBoolean() == readonlyValue.Value, label + " readonly value");
|
|
50
|
+
var hasRisk = cap.TryGetProperty("risk", out var riskJson);
|
|
51
|
+
Check(hasRisk == (risk != ""), label + " risk presence");
|
|
52
|
+
if (hasRisk) Check(riskJson.GetProperty("level").GetString() == risk, label + " risk value");
|
|
53
|
+
var expectedReadonly = readonlyValue ?? (method == "GET");
|
|
54
|
+
var expectedRisk = risk != "" ? risk : (expectedReadonly ? "low" : "medium");
|
|
55
|
+
var effectiveReadonly = hasReadonly ? readonlyJson.GetBoolean() : method == "GET";
|
|
56
|
+
var effectiveRisk = hasRisk ? riskJson.GetProperty("level").GetString() : (effectiveReadonly ? "low" : "medium");
|
|
57
|
+
Check(effectiveRisk == expectedRisk, label + " effective risk");
|
|
58
|
+
Check(cap.GetProperty("version").GetInt32() == 1, label + " declaration version");
|
|
59
|
+
matrix++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
foreach (bool? value in new bool?[] { null, false, true })
|
|
63
|
+
{
|
|
64
|
+
var cap = Capability(Fixture(method, idempotent: value));
|
|
65
|
+
var hasExecution = cap.TryGetProperty("execution", out var execution);
|
|
66
|
+
JsonElement idempotentJson = default;
|
|
67
|
+
var present = hasExecution && execution.TryGetProperty("idempotent", out idempotentJson);
|
|
68
|
+
Check(present == value.HasValue, method + " idempotent presence");
|
|
69
|
+
if (value.HasValue) Check(idempotentJson.GetBoolean() == value.Value, method + " idempotent value");
|
|
70
|
+
idempotency++;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
Check(matrix == 24 && idempotency == 6, "matrix completeness");
|
|
74
|
+
Console.WriteLine("PASS: 24 readonly/risk combinations + 6 idempotent combinations");
|
package/sdk/go/README.md
CHANGED
|
@@ -31,3 +31,11 @@ ok := bailingconnect.VerifyToolCall(secret, method, pathWithQuery, rawBody, time
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
Verification proves the call came from the hub. Your business service must still authorize `onBehalfOf` against its own permission table.
|
|
34
|
+
|
|
35
|
+
## Omitted and explicit declaration values
|
|
36
|
+
|
|
37
|
+
Unspecified `risk`, `readonly`, and `idempotent` fields stay absent from ACC. Explicit low/medium/high risk and both boolean values are preserved, including false on GET. With risk omitted, the ACC OpenAPI binding gives an explicit readonly value precedence over the HTTP method: GET without a readonly declaration defaults to low; other non-readonly operations default to medium. Risk does not replace approval or final business authorization.
|
|
38
|
+
|
|
39
|
+
Regenerate and compare declarations when upgrading; do not turn previously omitted risk into explicit low for all operations. `Tool.Risk == ""` remains the omission marker; `Readonly` and `Idempotent` use nil for omission and pointers for explicit values.
|
|
40
|
+
|
|
41
|
+
Run `go test ./...` from `sdk/go` for the 24 readonly/risk cases and 6 idempotency cases.
|
|
@@ -129,7 +129,7 @@ func normalizeRateLimit(value string) map[string]any {
|
|
|
129
129
|
|
|
130
130
|
func buildCapability(t Tool, method string) map[string]any {
|
|
131
131
|
capability := map[string]any{"version": 1, "enabled": true, "scope": t.Scope}
|
|
132
|
-
if t.Risk != ""
|
|
132
|
+
if t.Risk != "" {
|
|
133
133
|
capability["risk"] = map[string]any{"level": t.Risk}
|
|
134
134
|
}
|
|
135
135
|
if t.Confirm || len(t.ConfirmWhen) > 0 || t.ConfirmPrompt != "" {
|
|
@@ -149,11 +149,11 @@ func buildCapability(t Tool, method string) map[string]any {
|
|
|
149
149
|
capability["subject"] = map[string]any{"required": true}
|
|
150
150
|
}
|
|
151
151
|
execution := map[string]any{}
|
|
152
|
-
if t.Readonly != nil
|
|
153
|
-
execution["readonly"] =
|
|
152
|
+
if t.Readonly != nil {
|
|
153
|
+
execution["readonly"] = *t.Readonly
|
|
154
154
|
}
|
|
155
|
-
if t.Idempotent != nil
|
|
156
|
-
execution["idempotent"] =
|
|
155
|
+
if t.Idempotent != nil {
|
|
156
|
+
execution["idempotent"] = *t.Idempotent
|
|
157
157
|
}
|
|
158
158
|
if rl := normalizeRateLimit(t.RateLimit); rl != nil {
|
|
159
159
|
execution["rate_limit"] = rl
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
package bailingconnect
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"fmt"
|
|
6
|
+
"testing"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
func declarationFixture(method string) Tool {
|
|
10
|
+
return Tool{Name: "serialization_fixture", Description: "Declaration serialization fixture", Scope: "fixture.write", Path: "/fixture", Method: method, Params: []Param{{Name: "fixture", Type: "string"}}}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func serializedCapability(t *testing.T, tool Tool) map[string]any {
|
|
14
|
+
t.Helper()
|
|
15
|
+
spec := BuildOpenAPISpec("Fixture", "1", []Tool{tool}, nil)
|
|
16
|
+
encoded, err := json.Marshal(spec)
|
|
17
|
+
if err != nil {
|
|
18
|
+
t.Fatal(err)
|
|
19
|
+
}
|
|
20
|
+
var decoded map[string]any
|
|
21
|
+
if err := json.Unmarshal(encoded, &decoded); err != nil {
|
|
22
|
+
t.Fatal(err)
|
|
23
|
+
}
|
|
24
|
+
method := "get"
|
|
25
|
+
if tool.Method == "POST" {
|
|
26
|
+
method = "post"
|
|
27
|
+
}
|
|
28
|
+
return decoded["paths"].(map[string]any)["/fixture"].(map[string]any)[method].(map[string]any)["x-agent-capability"].(map[string]any)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
func executionOf(cap map[string]any) map[string]any {
|
|
32
|
+
if execution, ok := cap["execution"].(map[string]any); ok {
|
|
33
|
+
return execution
|
|
34
|
+
}
|
|
35
|
+
return map[string]any{}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func TestDeclarationReadonlyRiskMatrix(t *testing.T) {
|
|
39
|
+
no, yes := false, true
|
|
40
|
+
cases := 0
|
|
41
|
+
for _, method := range []string{"GET", "POST"} {
|
|
42
|
+
for ri, readonly := range []*bool{nil, &no, &yes} {
|
|
43
|
+
for _, risk := range []string{"", "low", "medium", "high"} {
|
|
44
|
+
cases++
|
|
45
|
+
t.Run(fmt.Sprintf("%s/readonly_%d/risk_%s", method, ri, risk), func(t *testing.T) {
|
|
46
|
+
tool := declarationFixture(method)
|
|
47
|
+
tool.Readonly, tool.Risk = readonly, risk
|
|
48
|
+
cap := serializedCapability(t, tool)
|
|
49
|
+
execution := executionOf(cap)
|
|
50
|
+
gotReadonly, hasReadonly := execution["readonly"]
|
|
51
|
+
if hasReadonly != (readonly != nil) || (readonly != nil && gotReadonly != *readonly) {
|
|
52
|
+
t.Fatalf("readonly not preserved: %#v", cap)
|
|
53
|
+
}
|
|
54
|
+
gotRisk, hasRisk := cap["risk"]
|
|
55
|
+
if hasRisk != (risk != "") || (risk != "" && gotRisk.(map[string]any)["level"] != risk) {
|
|
56
|
+
t.Fatalf("risk not preserved: %#v", cap)
|
|
57
|
+
}
|
|
58
|
+
expectedReadonly := method == "GET"
|
|
59
|
+
if readonly != nil {
|
|
60
|
+
expectedReadonly = *readonly
|
|
61
|
+
}
|
|
62
|
+
expectedRisk := risk
|
|
63
|
+
if expectedRisk == "" {
|
|
64
|
+
expectedRisk = "medium"
|
|
65
|
+
if expectedReadonly {
|
|
66
|
+
expectedRisk = "low"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
effectiveReadonly := method == "GET"
|
|
70
|
+
if hasReadonly {
|
|
71
|
+
effectiveReadonly = gotReadonly.(bool)
|
|
72
|
+
}
|
|
73
|
+
effectiveRisk := "medium"
|
|
74
|
+
if effectiveReadonly {
|
|
75
|
+
effectiveRisk = "low"
|
|
76
|
+
}
|
|
77
|
+
if hasRisk {
|
|
78
|
+
effectiveRisk = gotRisk.(map[string]any)["level"].(string)
|
|
79
|
+
}
|
|
80
|
+
if effectiveRisk != expectedRisk {
|
|
81
|
+
t.Fatalf("effective risk = %s, want %s", effectiveRisk, expectedRisk)
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if cases != 24 {
|
|
88
|
+
t.Fatalf("matrix contains %d cases", cases)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func TestDeclarationIdempotentPresence(t *testing.T) {
|
|
93
|
+
no, yes := false, true
|
|
94
|
+
for _, method := range []string{"GET", "POST"} {
|
|
95
|
+
for i, value := range []*bool{nil, &no, &yes} {
|
|
96
|
+
t.Run(fmt.Sprintf("%s/idempotent_%d", method, i), func(t *testing.T) {
|
|
97
|
+
tool := declarationFixture(method)
|
|
98
|
+
tool.Idempotent = value
|
|
99
|
+
execution := executionOf(serializedCapability(t, tool))
|
|
100
|
+
actual, present := execution["idempotent"]
|
|
101
|
+
if present != (value != nil) || (value != nil && actual != *value) {
|
|
102
|
+
t.Fatalf("idempotent not preserved: %#v", execution)
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
package/sdk/java/README.md
CHANGED
|
@@ -41,3 +41,16 @@ boolean ok = BailingConnect.verifyToolCall(
|
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
Verification proves the call came from the hub. Your business service must still authorize `onBehalfOf` against its own permission table.
|
|
44
|
+
|
|
45
|
+
## Omitted and explicit declaration values
|
|
46
|
+
|
|
47
|
+
Unspecified `risk`, `readonly`, and `idempotent` fields stay absent from ACC. Explicit low/medium/high risk and both boolean values are preserved, including false on GET. With risk omitted, the ACC OpenAPI binding gives an explicit readonly value precedence over the HTTP method: GET without a readonly declaration defaults to low; other non-readonly operations default to medium. Risk does not replace approval or final business authorization.
|
|
48
|
+
|
|
49
|
+
Regenerate and compare declarations when upgrading; do not turn previously omitted risk into explicit low for all operations. An unspecified `Tool.risk` is now null rather than `"low"`; code that reads the intermediate Tool object must handle null. `readonly` and `idempotent` remain nullable Boolean values.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
javac -d /tmp/bailing-java sdk/java/src/main/java/com/bailing/connect/BailingConnect.java sdk/java/tests/DeclarationTest.java
|
|
53
|
+
java -cp /tmp/bailing-java DeclarationTest
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This checks 24 readonly/risk combinations and 6 idempotency combinations.
|
|
@@ -88,7 +88,7 @@ public final class BailingConnect {
|
|
|
88
88
|
|
|
89
89
|
private static Map<String, Object> buildCapability(Tool t, String method) {
|
|
90
90
|
Map<String, Object> capability = mapOf("version", 1, "enabled", true, "scope", t.scope);
|
|
91
|
-
if (t.risk != null
|
|
91
|
+
if (t.risk != null) capability.put("risk", mapOf("level", t.risk));
|
|
92
92
|
if (t.confirm || !t.confirmWhen.isEmpty() || t.confirmPrompt != null) {
|
|
93
93
|
Map<String, Object> approval = new LinkedHashMap<>();
|
|
94
94
|
if (t.confirm) approval.put("required", true);
|
|
@@ -98,8 +98,8 @@ public final class BailingConnect {
|
|
|
98
98
|
}
|
|
99
99
|
if (t.requiresSubject) capability.put("subject", mapOf("required", true));
|
|
100
100
|
Map<String, Object> execution = new LinkedHashMap<>();
|
|
101
|
-
if (
|
|
102
|
-
if (
|
|
101
|
+
if (t.readonly != null) execution.put("readonly", t.readonly);
|
|
102
|
+
if (t.idempotent != null) execution.put("idempotent", t.idempotent);
|
|
103
103
|
Map<String, Object> rateLimit = normalizeRateLimit(t.rateLimit);
|
|
104
104
|
if (rateLimit != null) execution.put("rate_limit", rateLimit);
|
|
105
105
|
if (t.timeoutMs != null) execution.put("timeout_ms", t.timeoutMs);
|
|
@@ -285,7 +285,7 @@ public final class BailingConnect {
|
|
|
285
285
|
public final String path;
|
|
286
286
|
public String method = "GET";
|
|
287
287
|
public String name;
|
|
288
|
-
public String risk
|
|
288
|
+
public String risk;
|
|
289
289
|
public boolean confirm;
|
|
290
290
|
public Boolean readonly;
|
|
291
291
|
public boolean requiresSubject;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import com.bailing.connect.BailingConnect;
|
|
2
|
+
import java.util.List;
|
|
3
|
+
import java.util.Map;
|
|
4
|
+
import java.util.Objects;
|
|
5
|
+
|
|
6
|
+
/** No network or business operations: exercises the actual OpenAPI builder. */
|
|
7
|
+
public final class DeclarationTest {
|
|
8
|
+
@SuppressWarnings("unchecked")
|
|
9
|
+
private static Map<String, Object> capability(BailingConnect.Tool tool) {
|
|
10
|
+
Map<String, Object> spec = BailingConnect.buildOpenApiSpec("Fixture", "1", List.of(tool), null);
|
|
11
|
+
Map<String, Object> paths = (Map<String, Object>) spec.get("paths");
|
|
12
|
+
Map<String, Object> path = (Map<String, Object>) paths.get("/fixture");
|
|
13
|
+
Map<String, Object> operation = (Map<String, Object>) path.get(tool.method.toLowerCase());
|
|
14
|
+
return (Map<String, Object>) operation.get("x-agent-capability");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
private static void check(boolean condition, String message) {
|
|
18
|
+
if (!condition) throw new AssertionError(message);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private static BailingConnect.Tool fixture(String method) {
|
|
22
|
+
return new BailingConnect.Tool("Declaration serialization fixture", "fixture.write", "/fixture")
|
|
23
|
+
.method(method).name("serialization_fixture")
|
|
24
|
+
.param(new BailingConnect.Param("fixture"));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@SuppressWarnings("unchecked")
|
|
28
|
+
public static void main(String[] args) {
|
|
29
|
+
int matrix = 0;
|
|
30
|
+
int idempotency = 0;
|
|
31
|
+
for (String method : List.of("GET", "POST")) {
|
|
32
|
+
for (Boolean readonly : new Boolean[] { null, false, true }) {
|
|
33
|
+
for (String risk : new String[] { null, "low", "medium", "high" }) {
|
|
34
|
+
BailingConnect.Tool tool = fixture(method);
|
|
35
|
+
if (readonly != null) tool.readonly(readonly);
|
|
36
|
+
if (risk != null) tool.risk(risk);
|
|
37
|
+
Map<String, Object> cap = capability(tool);
|
|
38
|
+
Map<String, Object> execution = (Map<String, Object>) cap.getOrDefault("execution", Map.of());
|
|
39
|
+
String label = method + " readonly=" + readonly + " risk=" + risk;
|
|
40
|
+
check(execution.containsKey("readonly") == (readonly != null), label + " readonly presence");
|
|
41
|
+
if (readonly != null) check(Objects.equals(execution.get("readonly"), readonly), label + " readonly value");
|
|
42
|
+
check(cap.containsKey("risk") == (risk != null), label + " risk presence");
|
|
43
|
+
if (risk != null) check(risk.equals(((Map<?, ?>) cap.get("risk")).get("level")), label + " risk value");
|
|
44
|
+
boolean expectedReadonly = readonly != null ? readonly : "GET".equals(method);
|
|
45
|
+
String expectedRisk = risk != null ? risk : (expectedReadonly ? "low" : "medium");
|
|
46
|
+
boolean effectiveReadonly = (Boolean) execution.getOrDefault("readonly", "GET".equals(method));
|
|
47
|
+
String effectiveRisk = cap.containsKey("risk")
|
|
48
|
+
? (String) ((Map<?, ?>) cap.get("risk")).get("level") : (effectiveReadonly ? "low" : "medium");
|
|
49
|
+
check(expectedRisk.equals(effectiveRisk), label + " effective risk");
|
|
50
|
+
check(Integer.valueOf(1).equals(cap.get("version")), label + " declaration version");
|
|
51
|
+
String json = BailingConnect.toJson(cap);
|
|
52
|
+
if (readonly != null) check(json.contains("\"readonly\":" + readonly), label + " serialized readonly");
|
|
53
|
+
if (risk != null) check(json.contains("\"level\":\"" + risk + "\""), label + " serialized risk");
|
|
54
|
+
matrix++;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (Boolean value : new Boolean[] { null, false, true }) {
|
|
58
|
+
BailingConnect.Tool tool = fixture(method);
|
|
59
|
+
if (value != null) tool.idempotent(value);
|
|
60
|
+
Map<String, Object> cap = capability(tool);
|
|
61
|
+
Map<String, Object> execution = (Map<String, Object>) cap.getOrDefault("execution", Map.of());
|
|
62
|
+
check(execution.containsKey("idempotent") == (value != null), method + " idempotent presence");
|
|
63
|
+
if (value != null) check(Objects.equals(execution.get("idempotent"), value), method + " idempotent value");
|
|
64
|
+
idempotency++;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
check(matrix == 24 && idempotency == 6, "matrix completeness");
|
|
68
|
+
System.out.println("PASS: 24 readonly/risk combinations + 6 idempotent combinations");
|
|
69
|
+
}
|
|
70
|
+
}
|
package/sdk/node/README.md
CHANGED
|
@@ -122,3 +122,11 @@ await hub.send({ requestId: `notice_${orderId}`, channel: 'team-im', to: 'user_0
|
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
示例将准备和发送分开:先调用 `prepareBillingPlan` 并持久化 `grantInput`,再调用 `applyBillingPlan`;回包不确定时沿用已保存的输入,不能重新计算修订。服务端开通示例见 [examples/billing.mjs](examples/billing.mjs)。TypeScript 可通过 `import { UsageIssuerClient, type BillingSummary } from "@bailinghub/connect/usage"` 获取完整的套餐与身份类型。
|
|
125
|
+
|
|
126
|
+
## 声明字段的省略与显式值
|
|
127
|
+
|
|
128
|
+
未设置的 `risk`、`readonly`、`idempotent` 不会写入 ACC 声明。显式的 `risk: low/medium/high` 和布尔值 `false/true` 都会保留,包括 GET 上的 `false`。省略风险时,按 ACC OpenAPI binding:显式只读优先于 HTTP 方法;未声明只读的 GET 默认 low,其余非只读操作默认 medium。风险声明不代替审批或业务最终授权。
|
|
129
|
+
|
|
130
|
+
升级后应重新生成声明并比较差异;不要把以前省略的字段一律补成 low。 `tool().risk` 在未设置时现在为 `undefined`,不再是 `low`;直接读取构建中间对象的调用方需兼容未设置状态。
|
|
131
|
+
|
|
132
|
+
回归:`node --test sdk/node/tests/declaration.test.mjs`(24种只读/风险组合及6种幂等组合)。
|
package/sdk/node/src/index.mjs
CHANGED
|
@@ -60,7 +60,7 @@ export function tool(opts) {
|
|
|
60
60
|
path: opts.path,
|
|
61
61
|
method: String(opts.method || 'GET').toUpperCase(),
|
|
62
62
|
name: opts.name,
|
|
63
|
-
risk: opts.risk
|
|
63
|
+
risk: opts.risk,
|
|
64
64
|
confirm: !!opts.confirm,
|
|
65
65
|
confirmWhen: opts.confirmWhen || [],
|
|
66
66
|
readonly: opts.readonly,
|
|
@@ -100,7 +100,7 @@ function normalizeRateLimit(value) {
|
|
|
100
100
|
|
|
101
101
|
function buildCapability(t, method) {
|
|
102
102
|
const capability = { version: 1, enabled: true, scope: t.scope };
|
|
103
|
-
if (t.risk
|
|
103
|
+
if (t.risk != null) capability.risk = { level: t.risk };
|
|
104
104
|
if (t.confirm || t.confirmWhen?.length || t.confirmPrompt) {
|
|
105
105
|
capability.approval = {};
|
|
106
106
|
if (t.confirm) capability.approval.required = true;
|
|
@@ -109,8 +109,8 @@ function buildCapability(t, method) {
|
|
|
109
109
|
}
|
|
110
110
|
if (t.requiresSubject) capability.subject = { required: true };
|
|
111
111
|
const execution = {};
|
|
112
|
-
if (t.readonly ===
|
|
113
|
-
if (t.idempotent ===
|
|
112
|
+
if (typeof t.readonly === 'boolean') execution.readonly = t.readonly;
|
|
113
|
+
if (typeof t.idempotent === 'boolean') execution.idempotent = t.idempotent;
|
|
114
114
|
const rateLimit = normalizeRateLimit(t.rateLimit);
|
|
115
115
|
if (rateLimit) execution.rate_limit = rateLimit;
|
|
116
116
|
if (t.timeoutMs !== undefined) execution.timeout_ms = t.timeoutMs;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { buildOpenApiSpec, param, tool } from '../src/index.mjs';
|
|
4
|
+
|
|
5
|
+
function capability(method, options) {
|
|
6
|
+
const spec = buildOpenApiSpec({ tools: [tool({
|
|
7
|
+
name: 'serialization_fixture', description: 'Declaration serialization fixture',
|
|
8
|
+
path: '/fixture', scope: 'fixture.write', method,
|
|
9
|
+
params: [param('fixture', { type: 'string' })], ...options,
|
|
10
|
+
})] });
|
|
11
|
+
return JSON.parse(JSON.stringify(spec)).paths['/fixture'][method.toLowerCase()]['x-agent-capability'];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
for (const method of ['GET', 'POST']) {
|
|
15
|
+
for (const readonly of [undefined, false, true]) {
|
|
16
|
+
for (const risk of [undefined, 'low', 'medium', 'high']) {
|
|
17
|
+
test(`${method}: readonly=${String(readonly)}, risk=${String(risk)}`, () => {
|
|
18
|
+
const options = {};
|
|
19
|
+
if (readonly !== undefined) options.readonly = readonly;
|
|
20
|
+
if (risk !== undefined) options.risk = risk;
|
|
21
|
+
const cap = capability(method, options);
|
|
22
|
+
assert.equal(Object.hasOwn(cap.execution ?? {}, 'readonly'), readonly !== undefined);
|
|
23
|
+
if (readonly !== undefined) assert.equal(cap.execution.readonly, readonly);
|
|
24
|
+
assert.equal(Object.hasOwn(cap, 'risk'), risk !== undefined);
|
|
25
|
+
if (risk !== undefined) assert.equal(cap.risk.level, risk);
|
|
26
|
+
const expectedRisk = risk ?? ((readonly ?? (method === 'GET')) ? 'low' : 'medium');
|
|
27
|
+
const effectiveReadonly = cap.execution?.readonly ?? (method === 'GET');
|
|
28
|
+
const effectiveRisk = cap.risk?.level ?? (effectiveReadonly ? 'low' : 'medium');
|
|
29
|
+
assert.equal(effectiveRisk, expectedRisk);
|
|
30
|
+
assert.equal(cap.version, 1);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const idempotent of [undefined, false, true]) {
|
|
35
|
+
test(`${method}: idempotent=${String(idempotent)}`, () => {
|
|
36
|
+
const cap = capability(method, idempotent === undefined ? {} : { idempotent });
|
|
37
|
+
assert.equal(Object.hasOwn(cap.execution ?? {}, 'idempotent'), idempotent !== undefined);
|
|
38
|
+
if (idempotent !== undefined) assert.equal(cap.execution.idempotent, idempotent);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
package/sdk/php/README.md
CHANGED
|
@@ -53,6 +53,22 @@ public function list() { /* 你原有的逻辑 */ }
|
|
|
53
53
|
构建期即体检:scope 缺失、写接口无参数、工具名重复等会**直接抛异常**,
|
|
54
54
|
不会等发布后才在控制台"被跳过"列表里发现。
|
|
55
55
|
|
|
56
|
+
### 显式声明与缺省值
|
|
57
|
+
|
|
58
|
+
`readonly`、`idempotent` 的显式 `true` / `false` 和 `risk` 的显式 `low` / `medium` / `high` 都会原样写入 ACC;未设置的字段保持省略。按 ACC v1 的 OpenAPI binding,只有未显式声明只读性时才使用 GET 的缺省信号。因此 GET + `readonly: false` 且未设置 risk 的有效风险是 `medium`;POST + `risk: 'low'` 的有效风险是 `low`,既有审批与最终业务授权要求仍然保留。
|
|
59
|
+
|
|
60
|
+
升级后请重新生成、核对并刷新工具源声明。过去被省略的显式值现在会出现,JSON/ETag 可能变化,但 ACC 的 `version: 1` 不变。不需要批量给写接口添加 `risk: 'low'`。
|
|
61
|
+
|
|
62
|
+
PHP 注解模型的 `AiTool::$risk` 现在是 `?string`,默认 `null` 表示未设置;构造参数名称和顺序不变。已有显式字符串声明保持兼容;若接入代码自行读取该属性,应处理 `null`,不要把它解释为统一的 low 风险。
|
|
63
|
+
|
|
64
|
+
实际生成器回归(24 种 readonly/risk 组合、6 种幂等声明组合及审批/主体保留检查):
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
php tests/declaration-serialization.php
|
|
68
|
+
# 用同一套测试检查另一个解包目录:
|
|
69
|
+
php tests/declaration-serialization.php /path/to/bailing-connect-php
|
|
70
|
+
```
|
|
71
|
+
|
|
56
72
|
## 第二步:发布 spec(约定路径)
|
|
57
73
|
|
|
58
74
|
```
|