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
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# 百灵中枢 · 兼容性与升级策略
|
|
2
2
|
|
|
3
|
+
## Core 0.10.0 兼容扩展升级
|
|
4
|
+
|
|
5
|
+
Core 0.10.0 配套 MCP / Agent Client SDK 0.8.0、DSH 0.8.0,新增可选 Agent 知识协议、工具指导和显式模型输出预算。相对公开 0.9.4 没有新增 SQL;旧客户端保持 inline,旧模型策略不自动修改。实际 state/configuration 资源与完整迁移摘要现在参与 readiness,自定义 MySQL store 须提供 `schemaReadinessDb`,否则失败关闭。升级、配置回退和独立消费者边界见 [0.10.0 升级指南](UPGRADE_v0.10.0.md)。
|
|
6
|
+
|
|
7
|
+
## 当前 0.9.x 升级入口
|
|
8
|
+
|
|
9
|
+
Core 0.9.2、0.9.3、0.9.4 分别增加 065/066、067、068 迁移。**补丁版本不等于没有数据库迁移,也不等于只重启即可升级。** 根据当前版本逐项阅读 [0.9.2](UPGRADE_v0.9.2.md)、[0.9.3](UPGRADE_v0.9.3.md)、[0.9.4](UPGRADE_v0.9.4.md) 升级指南,保留原始任务、审批、通知和迁移记录。以下历史配套说明不代替目标版本指南。
|
|
10
|
+
|
|
3
11
|
## Core 0.9.1 补丁升级
|
|
4
12
|
|
|
5
13
|
相对 0.9.0 仅修复异步 usage 工作关闭等待并更新公开文档/通用安全治理,没有新增 API、SQL、套餐规则或客户端功能。SDK 0.7.0 / DSH 0.7.0 不变。旧版关闭返回不能证明 usage 后台工作已结束;替换制品前核对原请求,新版 usage 排空超时在原实例重试。见 [0.9.1 升级指南](UPGRADE_v0.9.1.md)。
|
|
@@ -10,7 +18,7 @@ Core 0.9.0 配套 SDK 0.7.0 / DSH 0.7.0,新增可选模型计费网关;本
|
|
|
10
18
|
|
|
11
19
|
> Core 0.8.0 task enrollment persists on original Agent Sessions. Do not downgrade an enrolled deployment to a version that ignores enforcement markers. See [upgrade boundaries](UPGRADE_v0.8.0.md).
|
|
12
20
|
|
|
13
|
-
>
|
|
21
|
+
> 本文说明当前 0.x 的兼容纪律;不宣告已进入 1.0。升级目标是保留已有配置与数据,但每次都须检查制品、实际存储拓扑、迁移及回退条件。公共契约的破坏性变更必须显式说明,提供迁移路径与适用的过渡窗口。
|
|
14
22
|
|
|
15
23
|
---
|
|
16
24
|
|
|
@@ -20,53 +28,57 @@ Core 0.9.0 配套 SDK 0.7.0 / DSH 0.7.0,新增可选模型计费网关;本
|
|
|
20
28
|
|
|
21
29
|
| 面 | 是什么 | 升级时怎么不被入侵 |
|
|
22
30
|
|---|---|---|
|
|
23
|
-
| **hub 服务**(`src/`) |
|
|
24
|
-
| **官方 SDK**(`sdk
|
|
25
|
-
|
|
|
31
|
+
| **hub 服务**(`src/`) | 中枢进程、在途工作与后台恢复 | 停止接单、排空已接受工作,再替换制品;排空超时不证明工作已结束 |
|
|
32
|
+
| **官方 SDK**(`sdk/` + `docs/examples/*`) | 业务系统里的声明、验签与调用代码 | 按目标能力及配套版本判断是否更新,不将 Core、Agent Client SDK、适配器机械捆绑发版 |
|
|
33
|
+
| **状态与配置存储**(`sql/*.sql`、JSONL 等) | 任务、审批、配置、通知、账本及队列 | 识别实际状态库和配置库,分别备份、核对账本并显式迁移;共库只执行一次,JSONL 仅支持单 writer |
|
|
26
34
|
| **brain 文件配置**(`brain/`) | executor 大脑的能力档 / agent 提示词 / runbook | `.local` 叠加层(§三):定制写 `.local` 文件,升级只动默认文件、永不冲突 |
|
|
27
35
|
| **嵌入组件**(`web/widget/widget.js`) | 别人网站里 `<script>` 引的聊天组件 | 受 `WIDGET_API` 约束的稳定嵌入面(§六);hub 升级=嵌入页自动拿新版,故只增不改 |
|
|
28
36
|
|
|
29
37
|
> 关键心智:**配置不在代码里**。路由、凭证、工具源、聊天入口全在 DB(`bz_` 表)、由控制台配;`.env`/密钥管理器/`brain/*.local.*` 是部署方本地材料、已 gitignore。`config.json` 只适合本地开发或非敏感结构配置;生产部署设置 `BAILING_ENV=production` 后,敏感项必须由环境变量或密钥管理器注入。
|
|
30
38
|
|
|
31
|
-
##
|
|
39
|
+
## 二、版本语义与迁移工作量
|
|
40
|
+
|
|
41
|
+
版本号描述兼容意图,不能单独证明部署工作量。当前仍为 `0.x`:公共契约可能调整,但必须在发行说明列明;不能把已有 0.x 行为误称为 1.0 稳定承诺。进入 1.0 时需明确稳定 API、支持范围和弃用政策。
|
|
32
42
|
|
|
33
43
|
| 版本位 | 含义 | 部署方要做什么 |
|
|
34
44
|
|---|---|---|
|
|
35
|
-
| **patch**(x.y.**Z**) |
|
|
36
|
-
| **minor**(x.**Y**.0) |
|
|
37
|
-
| **major**(**X**.0.0) |
|
|
45
|
+
| **patch**(x.y.**Z**) | 向后兼容的修复和文档修正;可能包含修复所需的增量迁移 | 阅读目标升级指南,核对新增 SQL、备份、排空和回退边界;不能仅重启 |
|
|
46
|
+
| **minor**(x.**Y**.0) | 新能力和兼容扩展;当前 0.x 若调整公共契约须单独说明 | 核对能力协商、客户端配套及实际存储,按指南迁移和验收;可选功能显式启用 |
|
|
47
|
+
| **major**(**X**.0.0) | 1.0 以后公共 API 的不兼容变更使用主版本;1.0 本身需先定义稳定面 | 阅读 `BREAKING`、支持范围和迁移方案;依适用的过渡窗口逐项迁移 |
|
|
38
48
|
|
|
39
|
-
>
|
|
49
|
+
> SQL 是独立升级检查面。新增表或列可能由兼容修复引入,但 DDL 锁、数据回填、旧制品账本校验和恢复顺序仍需检查;“增量”不等于无需停写或可以直接降级。Widget 等公开契约按其独立版本及过渡规则演进。
|
|
40
50
|
|
|
41
|
-
##
|
|
51
|
+
## 三、降低升级成本的机制与边界
|
|
42
52
|
|
|
43
53
|
**wire 面(三个):**
|
|
44
54
|
|
|
45
55
|
1. **签名标签 `sha256=` 是扩展点,不是版本号**。要换签名算法/构造,就**另起一个自描述新标签**(如 `sha256-2=`),绝不复用已有标签语义,也不在协议里堆隐式版本。验签侧靠前缀分派,新增标签天然不冲突。
|
|
46
56
|
2. **spec 的 `x-agent-capability` 未知字段一律忽略**(CONTRACT §2.4a)。注解注册表加新键时,未升级的 hub 会直接跳过不认识的键——业务按自己节奏采用新注解,不被新版本逼着改。
|
|
47
|
-
3.
|
|
57
|
+
3. **兼容扩展优先使用可选字段**。新增回包字段还需核对消费者 Schema、严格校验器和降级行为;新增能力可能需要显式协商,不能仅凭 JSON 允许多字段就宣称全部消费者兼容。
|
|
48
58
|
|
|
49
59
|
**部署面(三个):**
|
|
50
60
|
|
|
51
|
-
4.
|
|
61
|
+
4. **数据库结构按官方迁移账本校验**。已记账文件不重放;未知记录或摘要冲突会阻断,不能删账本绕过。新增结构优先采用增量迁移,数据回填单独编号。`npm run db:init` 只处理 `state.mysql`;独立 MySQL 配置库须额外调用 `migrateBailingHubCoreSchema`,同一库不能并行迁移。JSONL 状态不需要 SQL,但其 MySQL 配置库仍须检查。详见 [SQL 说明](../sql/README.md)及 [Kernel Host API](KERNEL_HOST_API.md)。
|
|
52
62
|
5. **brain 文件走 `.local` 叠加层**。`brain/profiles.json`·`agents/*.md`·`runbooks/*.md` 是仓库默认;部署方定制写进同名 `.local` 文件(已 gitignore)。升级 `git pull` 只动默认文件、永不碰 `.local`——**默认可升级、定制不冲突**。详见 `brain/README.md`。
|
|
53
|
-
6.
|
|
63
|
+
6. **配置校验与密钥隔离**。生产模式由 `BAILING_ENV=production` 显式开启,敏感项必须来自环境变量或密钥管理器。升级保留本地配置,但新增校验可能拒绝不完整或不安全配置;按发行指南事先核对,不能假定所有缺失项都有可运行默认值。
|
|
54
64
|
|
|
55
|
-
##
|
|
65
|
+
## 四、公共契约破坏性变更的流程
|
|
56
66
|
|
|
57
67
|
真要改签名构造、删/改一个头或一个 schema 列、改嵌入属性名时,**必须**走完整流程,绝不"换个公式/改个列直接发新版":
|
|
58
68
|
|
|
59
69
|
1. **新名不复用已有语义**:引入 `sha256-2=` / 新列名 / 新属性名 / bump `WIDGET_API`,与现存的并存、可区分。
|
|
60
70
|
2. **过渡窗内双发或双收**:在 ≥ 1 个完整 minor 版本里,hub 能**同时发两种格式**(或同时收两种格式),让部署方**先升 hub、再逐个升业务系统 SDK / 嵌入页**,分步完成、无停机硬切。
|
|
61
71
|
3. **CHANGELOG 写死时间表**:哪个版本起弃用(deprecated)、哪个版本起移除(removed),白纸黑字。
|
|
62
|
-
4.
|
|
72
|
+
4. **提供迁移诊断**:具体弃用功能应提供可验证的告警、审计或检查入口,并在说明中指明。不能把这项演进要求当作所有旧字段都已经具备告警的实现事实。
|
|
73
|
+
|
|
74
|
+
当前 0.x 若有不兼容调整,也须明确列出影响与迁移办法;不能因为主版本为 0 就静默改变权限或审批含义。对于无法安全双收/双发的安全修复,应说明替代流程,不承诺不存在的无停机窗口。
|
|
63
75
|
|
|
64
76
|
## 五、DB schema 演进纪律(贡献者必读)
|
|
65
77
|
|
|
66
78
|
写数据库结构文件前先读 **`sql/README.md`**。三条铁律:
|
|
67
79
|
|
|
68
80
|
1. **永远新增编号文件,绝不编辑已发布过的 `sql` 文件**。已部署实例会按账本跳过已应用文件;改已发布文件会造成不同实例之间的 schema 分叉。
|
|
69
|
-
2.
|
|
81
|
+
2. **优先增量结构**:`CREATE TABLE IF NOT EXISTS`、带兼容默认值的 `ADD COLUMN` 与索引;必要的数据回填单独编号并依赖账本只执行一次。增量 DDL 仍须评估锁和容量,不能仅靠语句形式推定无中断。
|
|
70
82
|
3. **禁 `RENAME` / `DROP COLUMN` / `DROP TABLE` / 改列义**。要删要改名 → 走第四节:先加新列双写、过渡窗、下个 major 再删旧列。
|
|
71
83
|
- 尤其 `RENAME`:它让结构变更只能在特定状态下执行;一旦换库或重置后重放,容易中断初始化——能不用就不用。
|
|
72
84
|
|
|
@@ -97,14 +109,18 @@ Core 0.9.0 配套 SDK 0.7.0 / DSH 0.7.0,新增可选模型计费网关;本
|
|
|
97
109
|
|
|
98
110
|
## 七、部署方升级清单(贴在运维手册里)
|
|
99
111
|
|
|
100
|
-
1.
|
|
101
|
-
2.
|
|
102
|
-
3.
|
|
103
|
-
4.
|
|
112
|
+
1. 固定当前与目标 Tag、提交和制品摘要,阅读 [CHANGELOG.md](CHANGELOG.md)及路径上每份升级指南;不要在运行目录直接拉取浮动分支。
|
|
113
|
+
2. 识别状态/配置库是否共库、JSONL、附件及本地配置;保留可恢复的一致备份和旧制品,先在隔离副本验证恢复组合。
|
|
114
|
+
3. 暂停所有共用存储的写入方,排空在途工作并核对原调用、审批、通知和回执。超时或结果未知时保持原 ID,不能换请求重发业务写。
|
|
115
|
+
4. 按目标制品 manifest 和各库完整账本核对迁移。对每个实际 MySQL 库串行执行官方迁移器;`db:init` 不覆盖独立配置库。启动本身不执行迁移。
|
|
116
|
+
5. 核对新版本、readiness、权限/审批/通知恢复、客户端兼容和业务侧去重,再恢复接单。没有 `BREAKING` 段也不能跳过迁移与恢复验证。
|
|
117
|
+
6. 回退前验证旧制品是否接受新账本和持久状态。不得删除迁移记录、任务强制标记或通知记录来绕过检查;恢复数据库也不能撤销已经发生的外部业务动作。
|
|
118
|
+
|
|
119
|
+
可先用[只读升级计划](UPGRADE_PLAN.md)比较显式提供的制品及脱敏账本快照。离线比较不是现场数据库核验,也不证明备份可恢复或升级已获放行。
|
|
104
120
|
|
|
105
121
|
---
|
|
106
122
|
|
|
107
|
-
|
|
123
|
+
兼容性说明、迁移执行与实际验收分别留证。保留配置是升级目标,制品与备份一致、权限语义不退化才是验证结果。
|
|
108
124
|
|
|
109
125
|
## 八、每次改动必须同步的开发者说明
|
|
110
126
|
|
|
@@ -148,6 +164,6 @@ Core 0.9.0 配套 SDK 0.7.0 / DSH 0.7.0,新增可选模型计费网关;本
|
|
|
148
164
|
4. `signed_required` 只有“正签 2xx + 无签/错签分别 401/403/404”才是 `protected`;负向 2xx 是 `public`,3xx/429/5xx/网络错误是 `inconclusive`。正签 404 是主请求失败,不是保护证据。
|
|
149
165
|
5. 核对受保护响应包含 `Cache-Control: private, no-store`,并检查 CDN/反向代理没有缓存或改写受保护清单。
|
|
150
166
|
|
|
151
|
-
刷新失败会保留旧缓存;单请求时限为 10 秒,正向正文上限为 5 MiB
|
|
167
|
+
刷新失败会保留旧缓存;单请求时限为 10 秒,正向正文上限为 5 MiB。回退时保留 053 两列、历史配置和迁移账本,但必须先验证具体旧制品能接受该账本及数据;不能只因字段可空就推定旧版可运行。需要恢复迁移前状态时,按一致集合与旧应用停机恢复,并核对备份后的外部动作;不要单独删除账本或 DROP 新列。
|
|
152
168
|
|
|
153
169
|
这组访问策略只治理“谁能读取工具清单”。它不改变 ACC、工具调用签名、路由白名单、审批、幂等或业务系统最终授权。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bailinghub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Open-source ACC runtime and agent control plane for existing business systems.",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"executor:watch": "tsx watch src/executor.ts",
|
|
57
57
|
"typecheck": "tsc --noEmit",
|
|
58
58
|
"installer:secrets:test": "node --test scripts/install-secrets.test.mjs",
|
|
59
|
-
"test": "node --import tsx --test \"src/**/*.test.ts\"",
|
|
59
|
+
"test": "node --import tsx --test \"src/**/*.test.ts\" \"web-admin/src/*.test.ts\"",
|
|
60
60
|
"db:init": "tsx scripts/init-db.ts",
|
|
61
61
|
"demo:seed": "tsx scripts/seed-demo.ts",
|
|
62
62
|
"admin:create": "tsx scripts/create-admin.ts",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"build:info": "node scripts/write-build-info.mjs",
|
|
67
67
|
"demo:e2e": "tsx scripts/demo-e2e.ts",
|
|
68
68
|
"bootstrap-admin:restart-test": "tsx scripts/verify-bootstrap-admin-restart.ts",
|
|
69
|
-
"e2e:console": "node scripts/e2e-console.mjs",
|
|
69
|
+
"e2e:console": "node scripts/e2e-console.mjs && node scripts/e2e-console-approval-details.mjs && node scripts/e2e-console-runtime-audit.mjs && node scripts/e2e-console-settings-audit.mjs && node scripts/e2e-console-operations-audit.mjs && node scripts/e2e-console-kb-audit.mjs",
|
|
70
70
|
"widget:renderer:test": "node scripts/widget-renderer-test.mjs",
|
|
71
71
|
"package:build": "npm --prefix web-admin ci --include=dev && npm --prefix web-admin run build",
|
|
72
72
|
"package:artifact:check": "node scripts/check-package-artifact.mjs",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"release:consistency:test": "node --test scripts/check-release-consistency.test.mjs",
|
|
92
92
|
"release:audit": "npm run release:consistency && npm run release:consistency:test && npm run images:policy:test && npm run public-content:denylist:test && npm run security:scan && npm run oss:guard && node scripts/release-audit.mjs && npm run package:artifact:check",
|
|
93
93
|
"github:verify": "node scripts/verify-github-repo.mjs",
|
|
94
|
-
"release:check": "npm run notices:check && npm run assets:check && npm run audit:deps && npm run audit:deps:test && npm run docx:vendor:verify-upstream && npm run docx:test && npm run client-api:contract && npm run client-api:ecosystem:clone && npm run typecheck && npm run installer:secrets:test && npm run doctor:deployment:typecheck && npm run doctor:deployment:test && npm test && npm run widget:renderer:test && npm run web-admin:check && npm run docx:browser:test && npm run notification:console:test && npm run docs:check && npm run examples:check && npm run sdk:test && npm run sdk:test7 && npm run sdk:test-node && npm run sdk:test-python && npm run sdk:test-runtime && npm run sdk:test-p1 && npm run release:audit && npm run oss:verify && npm run github:verify",
|
|
94
|
+
"release:check": "npm run notices:check && npm run assets:check && npm run audit:deps && npm run audit:deps:test && npm run docx:vendor:verify-upstream && npm run docx:test && npm run client-api:contract && npm run client-api:ecosystem:clone && npm run typecheck && npm run installer:secrets:test && npm run doctor:deployment:typecheck && npm run doctor:deployment:test && npm run doctor:upgrade-plan:typecheck && npm run doctor:upgrade-plan:test && npm test && npm run widget:renderer:test && npm run web-admin:check && npm run docx:browser:test && npm run notification:console:test && npm run docs:check && npm run examples:check && npm run sdk:test && npm run sdk:test7 && npm run sdk:test-node && npm run sdk:test-python && npm run sdk:test-runtime && npm run sdk:test-p1 && npm run sdk:test-declarations && npm run sdk:artifacts:check && npm run release:audit && npm run oss:verify && npm run github:verify",
|
|
95
95
|
"images:build": "sh scripts/publish-images.sh",
|
|
96
96
|
"images:publish": "BAILING_PUSH_IMAGES=1 sh scripts/publish-images.sh",
|
|
97
97
|
"images:publish-mysql": "BAILING_PUSH_IMAGES=1 sh scripts/publish-mysql-image.sh",
|
|
@@ -114,7 +114,12 @@
|
|
|
114
114
|
"docx:vendor:verify-upstream": "node scripts/vendor-mammoth.mjs --verify-upstream",
|
|
115
115
|
"docx:test": "node --import tsx --test scripts/docx-compatibility.test.mjs",
|
|
116
116
|
"docx:browser:test": "node scripts/docx-browser-test.mjs",
|
|
117
|
-
"notification:console:test": "node scripts/notification-console-test.mjs"
|
|
117
|
+
"notification:console:test": "node scripts/notification-console-test.mjs",
|
|
118
|
+
"doctor:upgrade-plan": "tsx scripts/doctor.ts --upgrade-plan",
|
|
119
|
+
"doctor:upgrade-plan:test": "node --import tsx --test scripts/doctor-upgrade-plan.test.ts",
|
|
120
|
+
"doctor:upgrade-plan:typecheck": "tsc --noEmit --strict --noUncheckedIndexedAccess --noUnusedLocals --skipLibCheck --target ES2022 --module ESNext --moduleResolution Bundler --lib ES2022 --types node scripts/doctor-upgrade-plan.ts scripts/doctor-upgrade-plan.test.ts",
|
|
121
|
+
"sdk:test-declarations": "php sdk/php/tests/declaration-serialization.php | tsx scripts/sdk-declaration-contract-test.ts && php sdk/php7/tests/declaration-serialization.php | tsx scripts/sdk-declaration-contract-test.ts && node --test sdk/node/tests/declaration.test.mjs && PYTHONDONTWRITEBYTECODE=1 python3 sdk/python/tests/test_declaration.py",
|
|
122
|
+
"sdk:artifacts:check": "node --test scripts/check-php-sdk-artifacts.test.mjs && node scripts/check-php-sdk-artifacts.mjs"
|
|
118
123
|
},
|
|
119
124
|
"dependencies": {
|
|
120
125
|
"mammoth": "file:vendor/bailinghub-mammoth-library-1.12.0-bailinghub.1.tgz",
|
|
@@ -52,6 +52,8 @@
|
|
|
52
52
|
"minLength": 1,
|
|
53
53
|
"maxLength": 500
|
|
54
54
|
},
|
|
55
|
+
"descriptionTruncated": { "type": "boolean" },
|
|
56
|
+
"usageGuidance": { "$ref": "#/$defs/usageGuidance" },
|
|
55
57
|
"scope": {
|
|
56
58
|
"type": "string",
|
|
57
59
|
"minLength": 1,
|
|
@@ -122,6 +124,17 @@
|
|
|
122
124
|
}
|
|
123
125
|
},
|
|
124
126
|
"$defs": {
|
|
127
|
+
"usageGuidance": {
|
|
128
|
+
"type": "object",
|
|
129
|
+
"additionalProperties": false,
|
|
130
|
+
"required": ["text", "truncated", "sourceChars", "sourceBytes"],
|
|
131
|
+
"properties": {
|
|
132
|
+
"text": { "type": "string", "minLength": 1, "maxLength": 32768, "description": "Additionally bounded to 65536 UTF-8 bytes by the compiler/runtime validator." },
|
|
133
|
+
"truncated": { "type": "boolean" },
|
|
134
|
+
"sourceChars": { "type": "integer", "minimum": 0 },
|
|
135
|
+
"sourceBytes": { "type": "integer", "minimum": 0 }
|
|
136
|
+
}
|
|
137
|
+
},
|
|
125
138
|
"confirmCondition": {
|
|
126
139
|
"type": "object",
|
|
127
140
|
"additionalProperties": false,
|
|
@@ -113,6 +113,12 @@ const englishCompanions = {
|
|
|
113
113
|
'docs/UPGRADE_v0.9.3.md': 'docs/UPGRADE_v0.9.3.en.md',
|
|
114
114
|
'docs/RELEASE_NOTES_v0.9.4.md': 'docs/RELEASE_NOTES_v0.9.4.en.md',
|
|
115
115
|
'docs/UPGRADE_v0.9.4.md': 'docs/UPGRADE_v0.9.4.en.md',
|
|
116
|
+
'docs/RELEASE_NOTES_v0.10.0.md': 'docs/RELEASE_NOTES_v0.10.0.en.md',
|
|
117
|
+
'docs/UPGRADE_v0.10.0.md': 'docs/UPGRADE_v0.10.0.en.md',
|
|
118
|
+
'docs/RELEASE_NOTES_v0.10.1.md': 'docs/RELEASE_NOTES_v0.10.1.en.md',
|
|
119
|
+
'docs/UPGRADE_v0.10.1.md': 'docs/UPGRADE_v0.10.1.en.md',
|
|
120
|
+
'docs/MODEL_OUTPUT_BUDGET.md': 'docs/MODEL_OUTPUT_BUDGET.en.md',
|
|
121
|
+
'docs/MODEL_CONTINUATION.md': 'docs/MODEL_CONTINUATION.en.md',
|
|
116
122
|
'docs/UPGRADE_v0.9.1.md': 'docs/UPGRADE_v0.9.1.en.md',
|
|
117
123
|
'docs/MODEL_BILLING.md': 'docs/MODEL_BILLING.en.md',
|
|
118
124
|
'docs/PERIOD_ALLOWANCE_UPGRADE.md': 'docs/PERIOD_ALLOWANCE_UPGRADE.en.md',
|
|
@@ -9,7 +9,7 @@ REGISTRY="${BAILING_IMAGE_REGISTRY:-$DEFAULT_REGISTRY}"
|
|
|
9
9
|
NAMESPACE="${BAILING_IMAGE_NAMESPACE:-$DEFAULT_NAMESPACE}"
|
|
10
10
|
PACKAGE_VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' package.json | head -1)"
|
|
11
11
|
TAG="${BAILING_IMAGE_TAG:-$PACKAGE_VERSION}"
|
|
12
|
-
[ -n "$TAG" ] || TAG="0.
|
|
12
|
+
[ -n "$TAG" ] || TAG="0.10.1"
|
|
13
13
|
MYSQL_TAG="${BAILING_MYSQL_IMAGE_TAG:-8.4}"
|
|
14
14
|
MYSQL_IMAGE="${BAILING_MYSQL_IMAGE:-$REGISTRY/$NAMESPACE/bailing-mysql:$MYSQL_TAG}"
|
|
15
15
|
PLATFORM="${BAILING_IMAGE_PLATFORM:-linux/amd64}"
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { lstatSync, mkdtempSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { dirname, join, posix, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const defaultRoot = fileURLToPath(new URL('../', import.meta.url));
|
|
9
|
+
const supportedSdks = ['php', 'php7'];
|
|
10
|
+
const sha256 = (value) => createHash('sha256').update(value).digest('hex');
|
|
11
|
+
|
|
12
|
+
function run(command, args) {
|
|
13
|
+
const result = spawnSync(command, args, { maxBuffer: 32 * 1024 * 1024 });
|
|
14
|
+
if (result.error) throw result.error;
|
|
15
|
+
if (result.status !== 0) {
|
|
16
|
+
throw new Error(`${command} exited ${result.status}: ${String(result.stderr || result.stdout).slice(0, 8000)}`);
|
|
17
|
+
}
|
|
18
|
+
return result.stdout;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function sourceFiles(root, relative = '') {
|
|
22
|
+
const files = [];
|
|
23
|
+
for (const name of readdirSync(join(root, relative)).sort()) {
|
|
24
|
+
if (/[\r\n\\]/.test(name)) throw new Error(`Unsupported SDK filename: ${JSON.stringify(name)}`);
|
|
25
|
+
const path = relative ? `${relative}/${name}` : name;
|
|
26
|
+
const stat = lstatSync(join(root, path));
|
|
27
|
+
if (stat.isSymbolicLink()) throw new Error(`SDK source symlinks are not allowed: ${path}`);
|
|
28
|
+
if (stat.isDirectory()) files.push(...sourceFiles(root, path));
|
|
29
|
+
else if (stat.isFile()) files.push(path);
|
|
30
|
+
else throw new Error(`SDK source contains a non-regular file: ${path}`);
|
|
31
|
+
}
|
|
32
|
+
return files.sort();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function lines(output) {
|
|
36
|
+
const result = String(output).split('\n');
|
|
37
|
+
if (result.at(-1) === '') result.pop();
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function archiveFiles(archive, prefix) {
|
|
42
|
+
const names = lines(run('tar', ['-tzf', archive]));
|
|
43
|
+
const details = lines(run('tar', ['-tvzf', archive]));
|
|
44
|
+
if (names.length !== details.length) throw new Error('Archive listing and file types do not agree');
|
|
45
|
+
const seen = new Set();
|
|
46
|
+
const files = [];
|
|
47
|
+
for (let index = 0; index < names.length; index++) {
|
|
48
|
+
const name = names[index];
|
|
49
|
+
const normalized = name.endsWith('/') ? name.slice(0, -1) : name;
|
|
50
|
+
if (!normalized || /[\r\n\\]/.test(normalized)
|
|
51
|
+
|| posix.normalize(normalized) !== normalized
|
|
52
|
+
|| (normalized !== prefix && !normalized.startsWith(`${prefix}/`))) {
|
|
53
|
+
throw new Error(`Unsafe archive path: ${JSON.stringify(name)}`);
|
|
54
|
+
}
|
|
55
|
+
if (seen.has(normalized)) throw new Error(`Duplicate archive path: ${name}`);
|
|
56
|
+
seen.add(normalized);
|
|
57
|
+
const type = details[index]?.[0];
|
|
58
|
+
if (type !== '-' && type !== 'd') throw new Error(`Archive links or special files are not allowed: ${name}`);
|
|
59
|
+
if (type === '-') {
|
|
60
|
+
if (normalized === prefix) throw new Error('Archive root must be a directory');
|
|
61
|
+
files.push(normalized.slice(prefix.length + 1));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return files.sort();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function regression(driver, sdkRoot, phpCommand, sdk) {
|
|
68
|
+
const output = run(phpCommand, [driver, sdkRoot]);
|
|
69
|
+
let result;
|
|
70
|
+
try { result = JSON.parse(String(output)); }
|
|
71
|
+
catch { throw new Error(`${sdk}: generator regression did not return JSON`); }
|
|
72
|
+
if (result.sdk !== sdk || result.passed !== true || result.matrixCases !== 24
|
|
73
|
+
|| result.idempotenceCases !== 6 || !Array.isArray(result.errors) || result.errors.length !== 0
|
|
74
|
+
|| !Array.isArray(result.matrix) || result.matrix.length !== 24
|
|
75
|
+
|| !Array.isArray(result.idempotence) || result.idempotence.length !== 6
|
|
76
|
+
|| !Number.isInteger(result.checks) || result.checks < 100) {
|
|
77
|
+
throw new Error(`${sdk}: generator regression is failed or incomplete`);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function verifyPhpSdkArtifact({ root = defaultRoot, sdk, phpCommand = 'php' }) {
|
|
83
|
+
if (!supportedSdks.includes(sdk)) throw new Error(`Unsupported PHP SDK: ${sdk}`);
|
|
84
|
+
const source = join(root, 'sdk', sdk);
|
|
85
|
+
const archiveRelative = `web/connect/bailing-connect-${sdk}.tgz`;
|
|
86
|
+
const archive = join(root, archiveRelative);
|
|
87
|
+
const prefix = `bailing-connect-${sdk}`;
|
|
88
|
+
const expected = sourceFiles(source);
|
|
89
|
+
const actual = archiveFiles(archive, prefix);
|
|
90
|
+
const missing = expected.filter((file) => !actual.includes(file));
|
|
91
|
+
const unexpected = actual.filter((file) => !expected.includes(file));
|
|
92
|
+
if (missing.length || unexpected.length) {
|
|
93
|
+
throw new Error(`${sdk}: archive file set differs from source; missing=${JSON.stringify(missing)}, unexpected=${JSON.stringify(unexpected)}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const temp = mkdtempSync(join(tmpdir(), 'bailinghub-php-artifact-'));
|
|
97
|
+
const extracted = join(temp, prefix);
|
|
98
|
+
const files = [];
|
|
99
|
+
try {
|
|
100
|
+
for (const file of expected) {
|
|
101
|
+
// Read each validated regular member to stdout, then write only our own
|
|
102
|
+
// source-derived paths. Never let tar create paths, links, or devices.
|
|
103
|
+
const bytes = run('tar', ['-xOzf', archive, '--', `${prefix}/${file}`]);
|
|
104
|
+
const sourceBytes = readFileSync(join(source, file));
|
|
105
|
+
if (!sourceBytes.equals(bytes)) throw new Error(`${sdk}: archive bytes differ from source: ${file}`);
|
|
106
|
+
files.push({ path: file, bytes: bytes.length, sha256: sha256(bytes) });
|
|
107
|
+
const destination = join(extracted, file);
|
|
108
|
+
mkdirSync(dirname(destination), { recursive: true });
|
|
109
|
+
writeFileSync(destination, bytes, { mode: 0o600 });
|
|
110
|
+
}
|
|
111
|
+
const sourceDriver = join(source, 'tests', 'declaration-serialization.php');
|
|
112
|
+
const artifactDriver = join(extracted, 'tests', 'declaration-serialization.php');
|
|
113
|
+
const sourceRegression = regression(sourceDriver, source, phpCommand, sdk);
|
|
114
|
+
const artifactRegression = regression(artifactDriver, extracted, phpCommand, sdk);
|
|
115
|
+
return {
|
|
116
|
+
sdk,
|
|
117
|
+
archive: archiveRelative,
|
|
118
|
+
archiveSha256: sha256(readFileSync(archive)),
|
|
119
|
+
fileCount: files.length,
|
|
120
|
+
files,
|
|
121
|
+
sourceRegression,
|
|
122
|
+
artifactRegression,
|
|
123
|
+
};
|
|
124
|
+
} finally {
|
|
125
|
+
rmSync(temp, { recursive: true, force: true });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function options(argv) {
|
|
130
|
+
const result = { root: defaultRoot, sdks: supportedSdks, phpCommand: 'php' };
|
|
131
|
+
for (let index = 0; index < argv.length; index++) {
|
|
132
|
+
const arg = argv[index];
|
|
133
|
+
const value = argv[++index];
|
|
134
|
+
if (!value) throw new Error(`Missing value for ${arg}`);
|
|
135
|
+
if (arg === '--root') result.root = resolve(value);
|
|
136
|
+
else if (arg === '--sdk' && supportedSdks.includes(value)) result.sdks = [value];
|
|
137
|
+
else if (arg === '--php') result.phpCommand = value;
|
|
138
|
+
else throw new Error(`Unsupported argument: ${arg} ${value}`);
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (process.argv[1] && pathToFileURL(resolve(process.argv[1])).href === import.meta.url) {
|
|
144
|
+
try {
|
|
145
|
+
const { root, sdks, phpCommand } = options(process.argv.slice(2));
|
|
146
|
+
const artifacts = sdks.map((sdk) => verifyPhpSdkArtifact({ root, sdk, phpCommand }));
|
|
147
|
+
process.stdout.write(`${JSON.stringify({ passed: true, artifacts }, null, 2)}\n`);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error(`PHP SDK artifact check failed: ${error.message}`);
|
|
150
|
+
process.exitCode = 1;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { cpSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import test from 'node:test';
|
|
7
|
+
import { verifyPhpSdkArtifact } from './check-php-sdk-artifacts.mjs';
|
|
8
|
+
|
|
9
|
+
function fixture(t, driver) {
|
|
10
|
+
const root = mkdtempSync(join(tmpdir(), 'php-artifact-check-test-'));
|
|
11
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
12
|
+
const source = join(root, 'sdk', 'php7');
|
|
13
|
+
const stage = join(root, 'stage');
|
|
14
|
+
const prefix = 'bailing-connect-php7';
|
|
15
|
+
const staged = join(stage, prefix);
|
|
16
|
+
mkdirSync(join(source, 'src'), { recursive: true });
|
|
17
|
+
mkdirSync(join(source, 'tests'), { recursive: true });
|
|
18
|
+
mkdirSync(join(root, 'web', 'connect'), { recursive: true });
|
|
19
|
+
writeFileSync(join(source, 'src', 'Tool.php'), '<?php return "fixture";\n');
|
|
20
|
+
// These tests exercise archive enforcement. The real SDK matrix drivers are
|
|
21
|
+
// executed separately by the artifact command against the actual packages.
|
|
22
|
+
const report = {
|
|
23
|
+
sdk: 'php7', passed: true, matrixCases: 24, idempotenceCases: 6,
|
|
24
|
+
checks: 171, errors: [], matrix: Array(24).fill({}), idempotence: Array(6).fill({}),
|
|
25
|
+
};
|
|
26
|
+
writeFileSync(join(source, 'tests', 'declaration-serialization.php'), driver ?? `<?php echo '${JSON.stringify(report)}';`);
|
|
27
|
+
cpSync(source, staged, { recursive: true });
|
|
28
|
+
const archive = join(root, 'web', 'connect', `${prefix}.tgz`);
|
|
29
|
+
const pack = (members = [prefix]) => {
|
|
30
|
+
const packed = spawnSync('tar', ['-czf', archive, '-C', stage, ...members], { encoding: 'utf8' });
|
|
31
|
+
assert.equal(packed.status, 0, packed.stderr);
|
|
32
|
+
};
|
|
33
|
+
pack();
|
|
34
|
+
return { root, source, staged, prefix, pack };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
test('valid archive verifies complete file identity and both regression executions', (t) => {
|
|
38
|
+
const { root } = fixture(t);
|
|
39
|
+
const result = verifyPhpSdkArtifact({ root, sdk: 'php7' });
|
|
40
|
+
assert.equal(result.fileCount, 2);
|
|
41
|
+
assert.match(result.archiveSha256, /^[0-9a-f]{64}$/);
|
|
42
|
+
assert.deepEqual(result.files.map((file) => file.path), ['src/Tool.php', 'tests/declaration-serialization.php']);
|
|
43
|
+
assert.equal(result.sourceRegression.passed, true);
|
|
44
|
+
assert.equal(result.artifactRegression.passed, true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('stale archive bytes fail before any generator is run', (t) => {
|
|
48
|
+
const { root, source } = fixture(t);
|
|
49
|
+
writeFileSync(join(source, 'src', 'Tool.php'), '<?php return "updated";\n');
|
|
50
|
+
assert.throws(() => verifyPhpSdkArtifact({ root, sdk: 'php7' }), /archive bytes differ from source: src\/Tool.php/);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('archive missing a source file is rejected', (t) => {
|
|
54
|
+
const { root, staged, pack } = fixture(t);
|
|
55
|
+
rmSync(join(staged, 'src', 'Tool.php'));
|
|
56
|
+
pack();
|
|
57
|
+
assert.throws(() => verifyPhpSdkArtifact({ root, sdk: 'php7' }), /archive file set differs.*missing=\["src\/Tool.php"\]/);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('archive with an extra file is rejected', (t) => {
|
|
61
|
+
const { root, staged, pack } = fixture(t);
|
|
62
|
+
writeFileSync(join(staged, 'extra.php'), '<?php echo "unexpected";');
|
|
63
|
+
pack();
|
|
64
|
+
assert.throws(() => verifyPhpSdkArtifact({ root, sdk: 'php7' }), /unexpected=\["extra.php"\]/);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('archive links are rejected without extracting them', (t) => {
|
|
68
|
+
const { root, staged, pack } = fixture(t);
|
|
69
|
+
symlinkSync('/outside/sdk', join(staged, 'link'));
|
|
70
|
+
pack();
|
|
71
|
+
assert.throws(() => verifyPhpSdkArtifact({ root, sdk: 'php7' }), /Archive links or special files are not allowed/);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('duplicate archive members are rejected', (t) => {
|
|
75
|
+
const { root, prefix, pack } = fixture(t);
|
|
76
|
+
pack([prefix, `${prefix}/src/Tool.php`]);
|
|
77
|
+
assert.throws(() => verifyPhpSdkArtifact({ root, sdk: 'php7' }), /Duplicate archive path/);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('source symlinks are rejected', (t) => {
|
|
81
|
+
const { root, source } = fixture(t);
|
|
82
|
+
symlinkSync('/outside/sdk', join(source, 'link'));
|
|
83
|
+
assert.throws(() => verifyPhpSdkArtifact({ root, sdk: 'php7' }), /SDK source symlinks are not allowed/);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('regression failure cannot be reported as a valid artifact', (t) => {
|
|
87
|
+
const { root } = fixture(t, '<?php fwrite(STDERR, "regression failed"); exit(1);');
|
|
88
|
+
assert.throws(() => verifyPhpSdkArtifact({ root, sdk: 'php7' }), /php exited 1: regression failed/);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('an incomplete successful regression report is rejected', (t) => {
|
|
92
|
+
const { root } = fixture(t, '<?php echo \'{"sdk":"php7","passed":true,"matrixCases":1}\';');
|
|
93
|
+
assert.throws(() => verifyPhpSdkArtifact({ root, sdk: 'php7' }), /generator regression is failed or incomplete/);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('missing PHP runtime fails instead of silently skipping', (t) => {
|
|
97
|
+
const { root } = fixture(t);
|
|
98
|
+
assert.throws(() => verifyPhpSdkArtifact({ root, sdk: 'php7', phpCommand: join(root, 'missing-php') }), /ENOENT/);
|
|
99
|
+
});
|
|
@@ -38,8 +38,8 @@ function updateJson(root, relativePath, update) {
|
|
|
38
38
|
test('current release surface is internally consistent', () => {
|
|
39
39
|
const result = checkReleaseConsistency({ root: repoRoot });
|
|
40
40
|
assert.deepEqual(result.findings, []);
|
|
41
|
-
assert.equal(result.version, '0.
|
|
42
|
-
assert.equal(result.stableVersion, '0.
|
|
41
|
+
assert.equal(result.version, '0.10.1');
|
|
42
|
+
assert.equal(result.stableVersion, '0.10.1');
|
|
43
43
|
assert.equal(result.publishTag, 'latest');
|
|
44
44
|
});
|
|
45
45
|
|