bailinghub 0.7.0 → 0.9.0

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.
Files changed (263) hide show
  1. package/README.en.md +7 -9
  2. package/README.md +7 -9
  3. package/docker-compose.images.yml +2 -2
  4. package/docs/AGENT_CLIENT_RUNTIME_API.en.md +46 -0
  5. package/docs/AGENT_CLIENT_RUNTIME_API.md +34 -0
  6. package/docs/AGENT_TASK_CONTROL.en.md +25 -0
  7. package/docs/AGENT_TASK_CONTROL.md +94 -0
  8. package/docs/AGENT_TASK_CONTROL_FOUNDATION.md +134 -0
  9. package/docs/ARCHITECTURE.md +1 -1
  10. package/docs/CHANGELOG.en.md +22 -1
  11. package/docs/CHANGELOG.md +22 -1
  12. package/docs/COMPATIBILITY.en.md +6 -0
  13. package/docs/CONTRACT.en.md +2 -0
  14. package/docs/CONTRACT.md +2 -0
  15. package/docs/GENERATED_ARTIFACTS.en.md +46 -0
  16. package/docs/GENERATED_ARTIFACTS.md +108 -0
  17. package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
  18. package/docs/INDEPENDENT_VALIDATION.md +4 -4
  19. package/docs/INVOCATION_RECEIPTS.md +111 -0
  20. package/docs/MODEL_BILLING.en.md +123 -0
  21. package/docs/MODEL_BILLING.md +125 -0
  22. package/docs/PERIOD_ALLOWANCE_UPGRADE.en.md +31 -0
  23. package/docs/PERIOD_ALLOWANCE_UPGRADE.md +31 -0
  24. package/docs/README.en.md +7 -0
  25. package/docs/README.md +7 -0
  26. package/docs/RELEASE_NOTES_NEXT.en.md +4 -2
  27. package/docs/RELEASE_NOTES_NEXT.md +4 -2
  28. package/docs/RELEASE_NOTES_v0.8.0.en.md +40 -0
  29. package/docs/RELEASE_NOTES_v0.8.0.md +62 -0
  30. package/docs/RELEASE_NOTES_v0.9.0.en.md +45 -0
  31. package/docs/RELEASE_NOTES_v0.9.0.md +45 -0
  32. package/docs/TOOL_RATE_LIMITS.md +50 -0
  33. package/docs/UPGRADE_v0.8.0.en.md +71 -0
  34. package/docs/UPGRADE_v0.8.0.md +73 -0
  35. package/docs/UPGRADE_v0.9.0.en.md +54 -0
  36. package/docs/UPGRADE_v0.9.0.md +54 -0
  37. package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +6 -0
  38. package/package.json +1 -1
  39. package/schemas/config/route.schema.json +1 -0
  40. package/schemas/config/tool-provider.schema.json +2 -1
  41. package/scripts/check-doc-links.mjs +5 -0
  42. package/scripts/check-image-tags.sh +1 -1
  43. package/scripts/check-release-consistency.test.mjs +2 -2
  44. package/scripts/e2e-console.mjs +32 -2
  45. package/scripts/install.sh +1 -1
  46. package/scripts/publish-images.sh +1 -1
  47. package/scripts/release-audit.mjs +2 -0
  48. package/scripts/sdk-runtime-test.mjs +6 -0
  49. package/scripts/verify-billing-install-upgrade.mjs +225 -0
  50. package/scripts/verify-github-repo.mjs +2 -0
  51. package/sdk/node/README.md +17 -0
  52. package/sdk/node/examples/billing.mjs +21 -0
  53. package/sdk/node/package.json +5 -1
  54. package/sdk/node/src/index.mjs +2 -0
  55. package/sdk/node/src/usage.d.mts +74 -0
  56. package/sdk/node/src/usage.mjs +62 -0
  57. package/sdk/node/tests/usage-types.mts +23 -0
  58. package/sdk/node/tests/usage.test.mjs +81 -0
  59. package/sdk/php7/README.md +19 -2
  60. package/sdk/php7/examples/billing.php +27 -0
  61. package/sdk/php7/examples/well-known.php +1 -1
  62. package/sdk/php7/src/ToolSpec.php +1 -1
  63. package/sdk/php7/src/UsageClient.php +95 -0
  64. package/sdk/php7/src/UsageClientException.php +22 -0
  65. package/sdk/php7/tests/billing-core-http.php +59 -0
  66. package/sdk/php7/tests/usage-client.php +78 -0
  67. package/sql/060_agent_artifacts.sql +11 -0
  68. package/sql/061_tool_rate_limit_policies.sql +3 -0
  69. package/sql/062_agent_task_control.sql +92 -0
  70. package/sql/063_usage_model_billing.sql +153 -0
  71. package/sql/064_period_plan_allowance.sql +25 -0
  72. package/sql/README.en.md +12 -4
  73. package/sql/README.md +14 -6
  74. package/src/adapters/storage/object-storage.ts +15 -3
  75. package/src/adapters/storage/oss-signature.test.ts +40 -0
  76. package/src/adapters/storage/oss-signature.ts +21 -0
  77. package/src/app/agent-artifacts.test.ts +165 -0
  78. package/src/app/agent-artifacts.ts +85 -0
  79. package/src/app/agent-client-runtime.test.ts +76 -1
  80. package/src/app/agent-client-runtime.ts +13 -0
  81. package/src/app/agent-invocation-snapshot.ts +35 -0
  82. package/src/app/agent-task-control.ts +187 -0
  83. package/src/app/agent-task-runtime.ts +68 -0
  84. package/src/app/agent-tool-invocations.test.ts +329 -1
  85. package/src/app/agent-tool-invocations.ts +223 -10
  86. package/src/app/agent-tool-job.test.ts +11 -1
  87. package/src/app/agent-tool-job.ts +8 -1
  88. package/src/app/auth.ts +2 -0
  89. package/src/app/builtin-tools.ts +4 -0
  90. package/src/app/oss-edition.ts +2 -0
  91. package/src/app/tool-approvals.ts +4 -0
  92. package/src/app/tool-assembly.ts +5 -0
  93. package/src/core/config/artifact-config.ts +15 -0
  94. package/src/core/config/config-codec.ts +3 -1
  95. package/src/core/config/config-models.ts +11 -1
  96. package/src/core/config/route-config.ts +3 -2
  97. package/src/core/contracts/tool-rate-limits.test.ts +59 -0
  98. package/src/core/contracts/tool-rate-limits.ts +48 -0
  99. package/src/core/contracts/tools.ts +122 -43
  100. package/src/core/contracts/types.ts +3 -1
  101. package/src/core/runtime/agent-task-control.test.ts +114 -0
  102. package/src/core/runtime/agent-task-control.ts +227 -0
  103. package/src/infrastructure/config/config-agent-artifact-repository.ts +32 -0
  104. package/src/infrastructure/config/config-agent-client-runtime-repository.ts +7 -1
  105. package/src/infrastructure/config/config-agent-task-control-journal-mysql.test.ts +315 -0
  106. package/src/infrastructure/config/config-agent-task-control-mysql.test.ts +331 -0
  107. package/src/infrastructure/config/config-agent-task-control-repository.ts +640 -0
  108. package/src/infrastructure/config/config-rate-limit-ledger.integration.test.ts +52 -0
  109. package/src/infrastructure/config/config-rate-limit-ledger.ts +48 -0
  110. package/src/infrastructure/config/config-storage-bucket-repository.ts +2 -2
  111. package/src/infrastructure/config/config-tool-provider-repository.ts +4 -4
  112. package/src/infrastructure/config/configstore.ts +15 -1
  113. package/src/modules/usage/allowance-reset.mysql.test.ts +122 -0
  114. package/src/modules/usage/billing-contracts.ts +59 -0
  115. package/src/modules/usage/billing-decimal.test.ts +22 -0
  116. package/src/modules/usage/billing-decimal.ts +36 -0
  117. package/src/modules/usage/billing-external.ts +39 -0
  118. package/src/modules/usage/billing-gateway.mysql.test.ts +24 -0
  119. package/src/modules/usage/billing-ledger.test.ts +51 -0
  120. package/src/modules/usage/billing-ledger.ts +104 -0
  121. package/src/modules/usage/billing-presentation.mysql.test.ts +95 -0
  122. package/src/modules/usage/billing-presentation.test.ts +49 -0
  123. package/src/modules/usage/billing-presentation.ts +34 -0
  124. package/src/modules/usage/billing-prices.mysql.test.ts +88 -0
  125. package/src/modules/usage/billing-repository.mysql.test.ts +181 -0
  126. package/src/modules/usage/billing-repository.ts +463 -0
  127. package/src/modules/usage/contracts.ts +49 -0
  128. package/src/modules/usage/dynamic-plan-models.mysql.test.ts +221 -0
  129. package/src/modules/usage/errors.ts +19 -0
  130. package/src/modules/usage/http.ts +85 -0
  131. package/src/modules/usage/identity-revocation.mysql.test.ts +286 -0
  132. package/src/modules/usage/identity.mysql.test.ts +120 -0
  133. package/src/modules/usage/identity.ts +303 -0
  134. package/src/modules/usage/issuer-sdk-billing.mysql.test.ts +92 -0
  135. package/src/modules/usage/model-gateway.mysql.test.ts +207 -0
  136. package/src/modules/usage/model-gateway.ts +229 -0
  137. package/src/modules/usage/model-tool-gateway.mysql.test.ts +137 -0
  138. package/src/modules/usage/model-tool-provider.test.ts +37 -0
  139. package/src/modules/usage/model-tool-provider.ts +110 -0
  140. package/src/modules/usage/model-tools.test.ts +36 -0
  141. package/src/modules/usage/model-tools.ts +62 -0
  142. package/src/modules/usage/period-allowance.mysql.test.ts +97 -0
  143. package/src/modules/usage/period.test.ts +26 -0
  144. package/src/modules/usage/period.ts +96 -0
  145. package/src/modules/usage/pricing.test.ts +178 -0
  146. package/src/modules/usage/pricing.ts +228 -0
  147. package/src/modules/usage/provider-failure.ts +37 -0
  148. package/src/modules/usage/provider-stream.test.ts +85 -0
  149. package/src/modules/usage/provider-stream.ts +77 -0
  150. package/src/modules/usage/provider.test.ts +67 -0
  151. package/src/modules/usage/provider.ts +142 -0
  152. package/src/modules/usage/repository.ts +539 -0
  153. package/src/modules/usage/service-availability.mysql.test.ts +68 -0
  154. package/src/modules/usage/service-availability.ts +13 -0
  155. package/src/modules/usage/service-delete.mysql.test.ts +87 -0
  156. package/src/modules/usage/stream-http.ts +32 -0
  157. package/src/modules/usage/test-harness.ts +108 -0
  158. package/src/modules/usage/usage-deletion.mysql.test.ts +312 -0
  159. package/src/modules/usage/usage-deletion.ts +119 -0
  160. package/src/modules/usage/validation.test.ts +18 -0
  161. package/src/modules/usage/validation.ts +33 -0
  162. package/src/routes/admin-agent-tasks.ts +32 -0
  163. package/src/routes/admin-billing-usage.ts +73 -0
  164. package/src/routes/admin-tool-providers.test.ts +22 -0
  165. package/src/routes/admin-tool-providers.ts +9 -1
  166. package/src/routes/admin-usage.ts +147 -0
  167. package/src/routes/admin.ts +7 -0
  168. package/src/routes/agent-api.test.ts +76 -0
  169. package/src/routes/agent-api.ts +42 -1
  170. package/src/routes/agent-artifacts.ts +29 -0
  171. package/src/routes/agent-task-control-http-mysql.test.ts +246 -0
  172. package/src/routes/private.ts +9 -0
  173. package/src/routes/run.ts +2 -1
  174. package/src/test-support/agent-task-control-mysql-fixture.ts +75 -0
  175. package/web/connect/bailing-connect-php7.tgz +0 -0
  176. package/web/console/assets/Accounts-Bervi5JU.css +1 -0
  177. package/web/console/assets/Accounts-DnddhY6t.js +3 -0
  178. package/web/console/assets/AgentClients-VInbD7JS.js +1 -0
  179. package/web/console/assets/AgentClients-i52AI6YV.css +1 -0
  180. package/web/console/assets/AgentTasks-B-1XklBg.js +2 -0
  181. package/web/console/assets/AgentTasks-BsG850Il.css +1 -0
  182. package/web/console/assets/{Approvals-Bs6FGbp2.js → Approvals-34qUPHf0.js} +1 -1
  183. package/web/console/assets/{Audit-4WWYhkFM.js → Audit-BbVgkSm2.js} +1 -1
  184. package/web/console/assets/{BrandLockup-D2GhCipL.js → BrandLockup-DgscF28e.js} +1 -1
  185. package/web/console/assets/{Channels-CmoGpiCJ.js → Channels-Bp-yuk8d.js} +1 -1
  186. package/web/console/assets/{ChatEntries-BFRMtwta.js → ChatEntries-C9Ft60TS.js} +1 -1
  187. package/web/console/assets/{Clients-DGkkSXyA.js → Clients-NPldD-DD.js} +1 -1
  188. package/web/console/assets/{Cost-BmGt0MfS.js → Cost-DZcuB-EB.js} +1 -1
  189. package/web/console/assets/{Credentials-CR-sYINT.js → Credentials-RTT7N6zl.js} +1 -1
  190. package/web/console/assets/{Diagnostics-DAPbKSJp.js → Diagnostics-_LeK8cce.js} +1 -1
  191. package/web/console/assets/{Executors-CgpiT3o8.js → Executors-Bi7H8rIm.js} +1 -1
  192. package/web/console/assets/{HelpTip-i-KJhf5s.js → HelpTip-BfyWrxCE.js} +1 -1
  193. package/web/console/assets/{Kb-Cm9dVSQw.js → Kb-BHamz8NP.js} +2 -2
  194. package/web/console/assets/{Login-CyUcsTZ_.js → Login-C1rJR-6w.js} +1 -1
  195. package/web/console/assets/{Projects-DldFPgWg.js → Projects-BRA4a48v.js} +1 -1
  196. package/web/console/assets/Routes-CTC7U-fQ.js +124 -0
  197. package/web/console/assets/Routes-CyXV4Pba.css +1 -0
  198. package/web/console/assets/{Runs-1hxgkuR4.js → Runs-B_fa_BlD.js} +1 -1
  199. package/web/console/assets/{Setup-DBLOnI2_.js → Setup-C1_d0mFy.js} +1 -1
  200. package/web/console/assets/Shell-CHEV6RGC.js +1 -0
  201. package/web/console/assets/Shell-ykb-tUfo.css +1 -0
  202. package/web/console/assets/StorageBuckets-CVgpZRWY.css +1 -0
  203. package/web/console/assets/StorageBuckets-DlG3ojhA.js +1 -0
  204. package/web/console/assets/{SystemSettings-cDkudo2y.js → SystemSettings-DYo2gg6d.js} +1 -1
  205. package/web/console/assets/{SystemStatus-DZd6s8OX.js → SystemStatus-DKCoUZlq.js} +1 -1
  206. package/web/console/assets/{Targets-DYNGq1NU.js → Targets-CdkG6BPR.js} +1 -1
  207. package/web/console/assets/Tools-DU8ei6sd.css +1 -0
  208. package/web/console/assets/Tools-DVpCt0ox.js +2 -0
  209. package/web/console/assets/Usage-CAeDGjrb.css +1 -0
  210. package/web/console/assets/Usage-DWCpLugC.js +1 -0
  211. package/web/console/assets/UsageAccess-B_Xq7ARW.js +1 -0
  212. package/web/console/assets/UsageAccess-CGGaWTuj.css +1 -0
  213. package/web/console/assets/UsageHelp-CSM4xO0K.css +1 -0
  214. package/web/console/assets/UsageHelp-t5ZG_f-e.js +1 -0
  215. package/web/console/assets/{index-QnmD7N7F.js → index-C6W4LWVV.js} +1 -1
  216. package/web/console/assets/{index-Fi9gkGxV.css → index-Cxuc9OCj.css} +1 -1
  217. package/web/console/assets/index-H1kfa0Mj.js +2 -0
  218. package/web/console/assets/{request-B7MLvOqo.js → request-DLsP1_ot.js} +1 -1
  219. package/web/console/assets/{schema-CMuwjYdJ.js → schema-BLOHvAJQ.js} +1 -1
  220. package/web/console/assets/{util-4bN2dv7B.js → util-CGVh2Jvr.js} +1 -1
  221. package/web/console/assets/{vendor-element-CZoEjZr8.js → vendor-element-BD089KxE.js} +1 -1
  222. package/web/console/assets/{vendor-mammoth-BUEEDX6A.js → vendor-mammoth-Bv-CZhmH.js} +1 -1
  223. package/web/console/index.html +3 -3
  224. package/web-admin/README.md +17 -0
  225. package/web-admin/scripts/agent-task-control-smoke.mjs +120 -0
  226. package/web-admin/src/components/AgentSetupPanel.vue +13 -0
  227. package/web-admin/src/components/ToolRateLimitEditor.vue +28 -0
  228. package/web-admin/src/components/UsageDeletionPreview.vue +44 -0
  229. package/web-admin/src/components/UsageHelp.vue +72 -0
  230. package/web-admin/src/components/UsageServiceReferences.vue +169 -0
  231. package/web-admin/src/layout/Shell.vue +23 -6
  232. package/web-admin/src/pages/Accounts.vue +3 -3
  233. package/web-admin/src/pages/AgentClients.vue +3 -1
  234. package/web-admin/src/pages/AgentTasks.vue +281 -0
  235. package/web-admin/src/pages/Routes.vue +5 -1
  236. package/web-admin/src/pages/StorageBuckets.vue +6 -6
  237. package/web-admin/src/pages/Tools.vue +53 -4
  238. package/web-admin/src/pages/Usage.vue +2470 -0
  239. package/web-admin/src/pages/UsageAccess.vue +1147 -0
  240. package/web-admin/src/router.ts +10 -4
  241. package/web-admin/src/styles/base.css +57 -0
  242. package/web-admin/src/table-widths.ts +16 -1
  243. package/web-admin/src/usage-deletion.ts +40 -0
  244. package/web-admin/src/usage-management.ts +13 -0
  245. package/web-admin/src/usage-presentation.test.ts +21 -0
  246. package/web-admin/src/usage-presentation.ts +107 -0
  247. package/web-admin/src/usage-price-preview.test.ts +60 -0
  248. package/web-admin/src/usage-price-preview.ts +54 -0
  249. package/web-admin/tests/token-usage.browser.mjs +773 -0
  250. package/web-admin/tests/usage-access.browser.mjs +398 -0
  251. package/web/console/assets/Accounts-B4ePH5jp.css +0 -1
  252. package/web/console/assets/Accounts-ChL9k-XA.js +0 -3
  253. package/web/console/assets/AgentClients-Bs7UgVDj.js +0 -1
  254. package/web/console/assets/AgentClients-DkgPTEbq.css +0 -1
  255. package/web/console/assets/Routes-DkMIjMQA.css +0 -1
  256. package/web/console/assets/Routes-DubfjlBD.js +0 -124
  257. package/web/console/assets/Shell-D9Uw-fsa.css +0 -1
  258. package/web/console/assets/Shell-gJ5Vz_E7.js +0 -1
  259. package/web/console/assets/StorageBuckets-DkDW16tj.js +0 -1
  260. package/web/console/assets/StorageBuckets-GnXnVvF0.css +0 -1
  261. package/web/console/assets/Tools-A20oaMaQ.css +0 -1
  262. package/web/console/assets/Tools-DpWM59vV.js +0 -2
  263. package/web/console/assets/index-DGqs28gI.js +0 -2
package/README.en.md CHANGED
@@ -29,17 +29,13 @@ You choose which business APIs become available. BailingHub connects the convers
29
29
  <img src="assets/readme-product-overview.en.svg" width="100%" alt="BailingHub connects conversational entry points to governed business capabilities while the business system remains the authority">
30
30
  </picture>
31
31
 
32
- ## v0.7.0: check stock, then update and list a shop product
32
+ ## v0.9.0: model services and shared plan allowances
33
33
 
34
- > “Check tumbler stock. If available, change the corresponding shop product's price to 59 and list it.”
34
+ Optionally enable a lightweight model billing gateway for an assistant's conversation models and text-to-image tools. Services share a USD allowance and one plan multiplier. Periodic allowance is separate from sale price; customers see Credits or remaining percentage. The local host continues orchestration, with existing business authority and approvals intact.
35
35
 
36
- Select inventory and shop authorizations on one Hub. The Agent uses each system's tools and authority for the right step. Controlled system descriptions explain their roles, business-supplied names identify the approved subjects, and centralized setup and visible records help administrators configure and trace the work.
36
+ Release pairing: **Core 0.9.0 + MCP / Agent Client SDK 0.7.0 + DSH 0.7.0**. Reference prices are not provider invoices; generation and settlement have separate states. Verify versions, Tags and artifact digests when upgrading.
37
37
 
38
- The business APIs and product mapping must already exist. Original approvals apply; a stock read is not a reservation, and a completed price change is not an approved listing.
39
-
40
- Full pairing: **Core 0.7.0 + MCP / Agent Client SDK 0.5.0 + DSH 0.5.0**, or a custom host implementing the same interfaces. Existing same-system conversations remain supported; cross-system scope stays within one Hub and audit domain.
41
-
42
- [Changes and upgrade steps](docs/RELEASE_NOTES_v0.7.0.en.md) · [Get started](docs/user-guide/conversations.en.md) · [Centralized setup](docs/LOCAL_AGENT_SETUP.en.md)
38
+ [Release notes](docs/RELEASE_NOTES_v0.9.0.en.md) · [Upgrade guide](docs/UPGRADE_v0.9.0.en.md) · [Model billing](docs/MODEL_BILLING.en.md) · [Previous release](docs/RELEASE_NOTES_v0.8.0.en.md)
43
39
 
44
40
  ## Operate the System by Conversation
45
41
 
@@ -208,14 +204,16 @@ Run separate BailingHub deployments for mutually isolated organizations. A `clie
208
204
  - [Quickstart](docs/QUICKSTART.en.md) — deploy and run the first route.
209
205
  - [Docker Demo](docs/DEMO.en.md) — complete the sample business-operation loop.
210
206
  - [Integration Guide](docs/INTEGRATION.en.md) — connect an existing application.
207
+ - [Read-only invocation receipts](docs/INVOCATION_RECEIPTS.md) — inspection without continuing a business operation.
211
208
  - [Agent Client v1](docs/AGENT_CLIENT_QUICKSTART.en.md) — browser authorization and local planning.
209
+ - [Local Agent attachment space](docs/GENERATED_ARTIFACTS.en.md) — the image-first extension for storing local outputs and obtaining business-usable URLs.
212
210
  - [Local Agent Setup](docs/LOCAL_AGENT_SETUP.en.md) — configure authorization, descriptions, tools, and connection checks in one place.
213
211
  - [System Information](docs/AGENT_SYSTEM_INFO.en.md) — explain selected systems before searching for tools.
214
212
  - [Business Tools and Governance](docs/TOOLS.en.md) — declare, sign, approve, and audit tools.
215
213
  - [HTTP Contract](docs/CONTRACT.en.md) — stable network and identity boundaries.
216
214
  - [Architecture](docs/ARCHITECTURE.en.md) — runtime layers and dependency direction.
217
215
  - [English Documentation Map](docs/README.en.md) — the complete public documentation index.
218
- - [Changelog](docs/CHANGELOG.en.md) and [v0.6.1 Release Notes](docs/RELEASE_NOTES_v0.6.1.en.md) — current release changes and upgrade notes.
216
+ - [Changelog](docs/CHANGELOG.en.md) and [v0.9.0](docs/RELEASE_NOTES_v0.9.0.en.md) — current release changes and upgrade notes.
219
217
 
220
218
  ## Feedback and Ecosystem
221
219
 
package/README.md CHANGED
@@ -27,17 +27,13 @@
27
27
 
28
28
  在线体验环境只用于了解产品和配置方式。请勿上传生产凭据、敏感数据或接入真实业务;正式使用请自行部署开源版。
29
29
 
30
- ## v0.7.0:先查库存,再到商城改价上架
30
+ ## v0.9.0:模型服务与统一套餐额度
31
31
 
32
- > “先查保温杯还有多少库存,有货就把商城对应商品改为 59 元并上架。”
32
+ 按需启用微型模型计费网关,为业务助手的对话模型与文生图工具配置共享 USD 额度。套餐统一倍率,周期额度与售价分开;客户看到 Credits 或剩余百分比。本地宿主继续编排任务,原业务授权和审批保持。
33
33
 
34
- 在同一个中枢内选定库存与商城授权,Agent 按每一步使用对应工具与权限。系统说明让它先分清谁负责什么,业务提供的授权名称让用户认清具体对象;集中配置入口和完整会话记录帮助管理员设置、检查与追溯。
34
+ 配套为 **Core 0.9.0 + MCP / Agent Client SDK 0.7.0 + DSH 0.7.0**。参考报价不等于供应商实付费用,生成结果与计费分别处理。升级时核对版本、Tag 与制品摘要。
35
35
 
36
- 示例动作需由业务系统开放,商品映射需已确认,原审批继续生效;查库存不等于锁库存,改价完成也不代表上架审批已通过。
37
-
38
- 完整配套为 **Core 0.7.0 + MCP / Agent Client SDK 0.5.0 + DSH 0.5.0**,或实现相同接口的自研客户端。保留原同系统多账户会话,跨系统范围限同一 Hub 与审计域。
39
-
40
- [看变化与升级步骤](docs/RELEASE_NOTES_v0.7.0.md) · [开始使用](docs/user-guide/conversations.md) · [集中配置](docs/LOCAL_AGENT_SETUP.md)
36
+ [版本说明](docs/RELEASE_NOTES_v0.9.0.md) · [升级指南](docs/UPGRADE_v0.9.0.md) · [模型计费](docs/MODEL_BILLING.md) · [上一版本](docs/RELEASE_NOTES_v0.8.0.md)
41
37
 
42
38
  ## 适合哪些团队
43
39
 
@@ -196,11 +192,13 @@ BailingHub Core 是独立服务,只通过稳定网络契约与业务系统协
196
192
  | 部署完整开源版 | [快速开始](docs/QUICKSTART.md) |
197
193
  | 跑通公开 Demo | [Docker Demo](docs/DEMO.md) |
198
194
  | 接入现有业务 | [第三方对接指南](docs/第三方对接指南.md) |
195
+ | 为本地智能体接入附件空间(首期图片) | [场景、配置与上传契约](docs/GENERATED_ARTIFACTS.md) |
196
+ | 只核对原操作有没有完成 | [只读回执与恢复的区别](docs/INVOCATION_RECEIPTS.md) |
199
197
  | 接入本地智能体 | [Agent Client v1 指南](docs/AGENT_CLIENT_QUICKSTART.md) |
200
198
  | 集中开启本地智能体与工具 | [四步配置指南](docs/LOCAL_AGENT_SETUP.md) · [系统说明](docs/AGENT_SYSTEM_INFO.md) |
201
199
  | 查 API 与边界契约 | [HTTP 契约](docs/CONTRACT.md) · [Client API](docs/CLIENT_API.md) |
202
200
  | 理解架构与长期取舍 | [架构](docs/ARCHITECTURE.md) · [项目愿景](VISION.md) |
203
- | 查看版本变化 | [CHANGELOG](docs/CHANGELOG.md) · [v0.6.1 Release Notes](docs/RELEASE_NOTES_v0.6.1.md) |
201
+ | 查看版本变化 | [CHANGELOG](docs/CHANGELOG.md) · [v0.9.0](docs/RELEASE_NOTES_v0.9.0.md) |
204
202
 
205
203
  完整中英文文档地图见 [docs/README.md](docs/README.md)。公共 API、SDK、Schema、Docker Demo 与代码标识保持语言中立。
206
204
 
@@ -18,7 +18,7 @@ services:
18
18
  retries: 30
19
19
 
20
20
  demo-business:
21
- image: ${BAILING_DEMO_BUSINESS_IMAGE:-crpi-xm97pbcjrmf5in3s.cn-shanghai.personal.cr.aliyuncs.com/bailinghub/bailing-demo-business:0.7.0}
21
+ image: ${BAILING_DEMO_BUSINESS_IMAGE:-crpi-xm97pbcjrmf5in3s.cn-shanghai.personal.cr.aliyuncs.com/bailinghub/bailing-demo-business:0.9.0}
22
22
  environment:
23
23
  DEMO_HOST: 0.0.0.0
24
24
  DEMO_PORT: 19080
@@ -29,7 +29,7 @@ services:
29
29
  - "${BAILING_DEMO_PUBLIC_PORT:-19080}:19080"
30
30
 
31
31
  bailinghub:
32
- image: ${BAILINGHUB_IMAGE:-crpi-xm97pbcjrmf5in3s.cn-shanghai.personal.cr.aliyuncs.com/bailinghub/bailinghub:0.7.0}
32
+ image: ${BAILINGHUB_IMAGE:-crpi-xm97pbcjrmf5in3s.cn-shanghai.personal.cr.aliyuncs.com/bailinghub/bailinghub:0.9.0}
33
33
  depends_on:
34
34
  mysql:
35
35
  condition: service_healthy
@@ -1,5 +1,7 @@
1
1
  # Agent Client Runtime v1
2
2
 
3
+ Unreleased paired addition: [task control](AGENT_TASK_CONTROL.en.md) adds trusted `task_binding` to turns and echoes it. Enrolled Sessions cannot omit it; runtime searches must use the original `run_id`. Read-only inspection and explicit original-operation continuation remain separate.
4
+
3
5
  English | [简体中文](AGENT_CLIENT_RUNTIME_API.md)
4
6
 
5
7
  This versioned API lets a browser-authorized local Agent plan locally while reusing BailingHub
@@ -121,6 +123,41 @@ Capability search returns no more than 12 complete typed tools under
121
123
  any source is unavailable, the whole search deterministically falls back to lexical ordering. A
122
124
  search needs a non-empty query or a valid `run_id` from the same Agent Session and route.
123
125
 
126
+ Search responses may include the following optional `discovery` metadata. This example returns
127
+ the first 12 ranked candidates from a currently authorized catalog of 14:
128
+
129
+ ```json
130
+ {
131
+ "discovery": {
132
+ "mode": "ranked_candidates",
133
+ "scope": "current_authorization",
134
+ "returned_count": 12,
135
+ "authorized_total": 14,
136
+ "matched_total": null,
137
+ "matched_total_exact": false,
138
+ "limit": 12,
139
+ "truncated": true,
140
+ "has_more": true,
141
+ "truncation_scope": "authorized_catalog",
142
+ "pagination": "unsupported"
143
+ }
144
+ }
145
+ ```
146
+
147
+ `authorized_total` uses the same authorized surface, route and capability revision as the returned
148
+ tools, after session, route, subject and direct-tool policy checks. It is neither the system's
149
+ global capability count nor the host session's shared loaded-tool count. `returned_count` equals
150
+ `tools.length`; `limit` is the effective result limit. `truncated` and `has_more` only indicate
151
+ authorized candidates omitted by that limit, not additional confirmed matches or a next page.
152
+
153
+ Search ranks candidates without filtering zero-score entries. An inventory query can therefore
154
+ still return an authorized order tool. Match totals remain unknown (`matched_total: null`,
155
+ `matched_total_exact: false`), never zero or the returned count. An empty authorized catalog has
156
+ zero authorized and returned candidates; it says nothing about capabilities in other scopes.
157
+ This additive v1 field may be ignored by older clients. New clients must treat missing metadata
158
+ from an older server as unknown. Core does not change authorization or approval rules; the host
159
+ owns dynamic tool replacement/append behavior and the current loaded-tool set.
160
+
124
161
  ## Tool invocation and recovery
125
162
 
126
163
  Invoke only a tool projected by the current bootstrap/search result. Core revalidates the Agent
@@ -128,6 +165,15 @@ Session, route, operation ID, ACC declaration, approval state, limits, and busin
128
165
  on every invocation. When the result is pending, in progress, or uncertain, resume the original
129
166
  `invocation_id`; do not create a replacement write call.
130
167
 
168
+ If a request was attempted but transport or response-body reading fails, Core reports
169
+ `reconciliation_required` with `auto_retry_allowed: false`, including for readonly and
170
+ declared-idempotent tools. It must not report `rejected_before_dispatch`: neither execution nor
171
+ non-execution has been confirmed. Keep the original invocation and authorization binding. Resume
172
+ revalidates authorization and replays the saved result without redispatch; a still-uncertain result
173
+ requires reconciliation. Do not create another inventory adjustment or order update, switch
174
+ authorization, or use another tool to repeat it. Capability rediscovery does not retry a business
175
+ operation. Existing approvals and execution journals remain in force.
176
+
131
177
  The Hub records visible governance milestones, operation IDs, parameter key names, approval state,
132
178
  and business status. It does not receive model hidden reasoning, complete sensitive arguments, or
133
179
  raw business response bodies.
@@ -1,5 +1,7 @@
1
1
  # Agent Client Runtime v1
2
2
 
3
+ 未发布配套增量:[任务控制](AGENT_TASK_CONTROL.md)为 turn 增加宿主 `task_binding` 和原样回显;已加入任务的 Session 不能省略,业务搜索须使用原 `run_id`。原调用只读核对与显式继续分别处理。
4
+
3
5
  本版本化接口让已完成 Agent Auth 网页授权的本地智能体在本地承担规划,同时继续复用 BailingHub 的身份重验、工具治理、审批、审计与对话总账。它不替代现有 `/run`、聊天入口或执行器协议。配套的部署、业务授权页和宿主接入步骤见 [Agent Client v1 接入指南](AGENT_CLIENT_QUICKSTART.md),身份授权契约见 [Agent Auth v1](AGENT_AUTH_API.md)。
4
6
 
5
7
  所有接口只接受 `Authorization: Bearer <Agent access token>`,响应均 `Cache-Control: no-store`。业务运行与能力接口的工作区授权面始终取以下交集:Client `allowed_routes` ∩ Agent Session `allowed_routes` ∩ 启用且 audience 允许的 route ∩ `tools.agent_direct`。`agent_client.enabled=false` 关闭 Runtime 工作区、上下文与能力接口,不关闭旧 `/agent-api/v1/tools`。
@@ -93,6 +95,38 @@ Bootstrap 只逐字段抽取 `target_config.system_prompt`,再拼接可选 `ag
93
95
  能力搜索最多返回 12 个完整 typed tools,schema 为 `bailing.agent-capability-search.v1`。检索只在当前授权集内进行;任一工具源的 embedding 不可用时,整次搜索确定性退回 lexical 排序。
94
96
  能力搜索必须提供非空 `query`,或者提供属于当前 Agent Session 与 route 的合法 `run_id`,由服务端回退使用该 run 的 `user_input`。
95
97
 
98
+ 搜索响应新增可选 `discovery` 元数据,以下示例表示当前授权目录的 14 项候选中,本次返回排序靠前的 12 项:
99
+
100
+ ```json
101
+ {
102
+ "discovery": {
103
+ "mode": "ranked_candidates",
104
+ "scope": "current_authorization",
105
+ "returned_count": 12,
106
+ "authorized_total": 14,
107
+ "matched_total": null,
108
+ "matched_total_exact": false,
109
+ "limit": 12,
110
+ "truncated": true,
111
+ "has_more": true,
112
+ "truncation_scope": "authorized_catalog",
113
+ "pagination": "unsupported"
114
+ }
115
+ }
116
+ ```
117
+
118
+ `authorized_total` 来自本次响应相同 `route`、`capability_revision` 对应的授权目录,已经过会话、路由、主体和直调策略裁剪。它不是系统全量能力数,也不是客户端会话共享的已加载工具数。`returned_count` 是本次 `tools.length`;`limit` 是实际返回上限。`truncated` / `has_more` 只表示授权候选因上限未全部返回,不表示还有确定匹配结果,也不提供下一页。
119
+
120
+ 搜索按相关性排序,不过滤零分候选。例如查询库存时,已授权的订单工具仍可能作为后续候选返回;不能据返回数量断言系统具备或缺少某项能力。`matched_total` 为 `null`,精确性为 `false`,不可用 `0` 或返回数量代替。授权目录为空时,`returned_count` 和 `authorized_total` 均为 `0`,仍不代表其他授权范围没有能力。
121
+
122
+ 这是现有 v1 响应的可选扩展;旧客户端可以忽略,新客户端遇到缺少 `discovery` 的旧服务端应把这些统计视为未知。搜索不修改 Core 权限或审批规则,宿主负责说明动态工具的替换/追加方式和当前有效的已加载工具。
123
+
124
+ ## 工具调用与恢复
125
+
126
+ 工具已经尝试发送、但网络中断或响应正文丢失时,Core 返回 `reconciliation_required` 和 `auto_retry_allowed: false`;只读和声明幂等的工具也不能被标为 `rejected_before_dispatch`。该状态表示尚无可信结果,不证明业务已经执行或尚未执行。
127
+
128
+ 客户端必须保留原 `invocation_id` 及授权关联,使用现有 resume 恢复原调用。Core 重新验证当前授权并回放已保存的结果,不重新派发;结果仍不确定时需要人工核实,不能新建库存调整、订单更新等操作,也不能切换授权或改用另一工具重复执行。重新发现工具与恢复业务调用是两个动作。原审批和执行日志机制保持不变。
129
+
96
130
  ## Complete
97
131
 
98
132
  ```json
@@ -0,0 +1,25 @@
1
+ # Task budgets and pause control
2
+
3
+ Use Core 0.8.0 with Agent Client SDK / DSH 0.6.0 and an adapted host. Task controls require explicit administrator enrollment. See the [complete protocol and operator guide](AGENT_TASK_CONTROL.md).
4
+
5
+ An assistant updating shop products and checking stock may work across several messages and systems. An administrator can freeze the original authorizations, exact tool names, cumulative write-call allowance, concurrency and optional expiry for that task. New messages, tool searches and client restarts do not reset the allowance. Existing business APIs, ACC declarations, authorization and approval rules remain unchanged.
6
+
7
+ Use **Agent Clients → Task control** to create and inspect tasks. The host verifies every original member and persists the binding before business execution. Agent access tokens cannot create tasks, increase budgets or control their state. Participating Agent Sessions become persistently task-required across conversations; cancelling a task does not remove that requirement. Use dedicated synthetic authorizations when first integrating.
8
+
9
+ - A write call is a call whose trusted declaration has `readonly=false`, including idempotent writes. It is not a product, monetary amount, token or successful business change. `null` means unlimited; zero allows reads only.
10
+ - Metering covers governed business tool invocations through the Hub, not local host tools, inference, artifact uploads or conversation archives.
11
+ - Approval waits reserve writes. Confirmed HTTP outcomes consume them, including business rejection. Unknown outcomes retain their reservation and concurrency permit.
12
+ - Pause blocks new permits, while already permitted requests can finish. Continue keeps the original scope and limits and does not execute anything automatically. Cancel cannot be undone and does not roll back business changes.
13
+ - Approval consumption, permit, original-job fence and execution journal commit atomically before HTTP dispatch. Unknown results are inspected using the original invocation; do not submit a replacement write.
14
+
15
+ Agent endpoints are `GET /agent-api/v1/task-control/capabilities` and `GET /agent-api/v1/tasks/{task_id}?workspace=...&client_conversation_id=...`. Turn creation accepts and echoes trusted `task_binding` (`bailing.agent-task-binding.v1`, `task_id`, `scope_hash`). Task snapshots use `bailing.agent-task.v1`, disclose only the requesting member and shared counters, and explicitly do not confer dispatch permission. Verify the complete original group; this release supports one Hub and audit domain only.
16
+
17
+ Read-only progress uses `GET /agent-api/v1/tool-invocations/{invocation_id}/receipt`. `POST .../resume` can dispatch an approved original operation and must never be used as a polling method. Managed runtime searches require the bound `run_id`; discovery itself does not consume the write allowance.
18
+
19
+ The administrator APIs are `GET/POST /admin/api/agent-tasks`, `GET /admin/api/agent-tasks/{task_id}`, and `POST /admin/api/agent-tasks/{task_id}/control`. They require `clients:read` or `clients:write`. Create freezes `members` and `policy`; controls require a stable request ID, expected revision and `pause/resume/cancel`. Read the complete guide for exact wire fields and pagination.
20
+
21
+ The paired SDK adds `getTaskControlCapabilities`, `getTask`, and trusted `startTurn` task binding. DSH supplies host CAS storage and task restoration, lazy business runs, read-only polling and original-invocation recovery. Business backends need no new endpoints.
22
+
23
+ This integrates the existing six-table migration `062`; it adds no further migration. Fully unmigrated installations report unsupported. Partial tables or database failures fail closed. Old clients can continue using non-enrolled Sessions, but cannot bypass an enrolled Session's requirement. After enrollment, do not roll back to a Core that cannot enforce the marker or remove task tables to disable enforcement.
24
+
25
+ `TASK_DISPATCH_UNCERTAIN`, or `TASK_UNAVAILABLE` during invoke/resume, conservatively requires original-call inspection. Revocation of any original member blocks the group; neither default targets nor a remaining subset are valid fallbacks. Local synthetic acceptance does not imply deployment or production acceptance.
@@ -0,0 +1,94 @@
1
+ # 一个任务,跨轮次累计额度与暂停控制
2
+
3
+ 配套版本:Core 0.8.0 / SDK 0.6.0 / DSH 0.6.0。新能力需部署方升级并按宿主契约接入;业务权限、审批和原身份约束保持。 业务后端的 API、ACC 声明、授权和审批规则不需要为此修改。
4
+
5
+ 例如,用户请助手“整理商城商品,再核对库存”。对话可能持续多轮、切换多个工具、涉及两个系统。管理员可以给这个任务指定原授权集合、精确工具范围、累计最多 20 次写调用、最多 2 个在途派发许可。后续消息、重新搜索工具、重开客户端都不能把任务额度归零。普通聊天不为了恢复任务而创建业务运行。
6
+
7
+ ## 怎么用
8
+
9
+ 1. 客户端先显式固定会话授权范围,并提供每个成员原 Agent Session、接入方、工作区和本地会话 ID。
10
+ 2. 管理员在 **智能体客户端 → 任务控制** 创建任务,选择相同成员和精确工具名单,设置累计写额度、并发许可数和可选截止时间。
11
+ 3. 客户端通过 SDK 对全部原成员读取任务,核对 `task_id`、`scope_hash`、成员总数和自己的绑定。宿主把任务关联持久保存,再允许这段会话发起业务操作。任务 ID 不作为模型工具参数。
12
+ 4. 首次真正使用某个系统时,`startTurn` 携带可信 `task_binding`,Core 在创建业务 run 或装配正文上下文之前核验整个原范围,并将真实 run 固定到该任务。
13
+ 5. 管理员在同一页面查看累计用量、原调用与运行关联,按需暂停、继续或取消。页面刷新只读,不继续审批后的业务操作。
14
+
15
+ **启用范围的重要影响:** 创建任务会为每个原 Agent Session 保存持续有效的任务强制标记。之后该授权的其他会话及旧调用入口也不能省略任务绑定。取消任务不删除此标记。第一次联调请使用专门的合成测试授权,先核对全部客户端版本;没有兼容客户端的授权不应提前加入任务。管理员可以明确创建后续任务,但模型和客户端不能为绕开旧额度自动创建新任务。
16
+
17
+ ## 额度到底数什么
18
+
19
+ | 项目 | 含义 |
20
+ |---|---|
21
+ | 累计写额度 | 按可信声明中 `readonly=false` 的原工具调用计数;声明幂等的写操作也计入。`null` 不限;`0` 只读。 |
22
+ | 已预留 | 等待审批或派发的写调用。结果不明的写操作继续保留预留,不能先释放给下一笔。 |
23
+ | 已消耗 | 原调用已经获得可信 HTTP 回执。业务拒绝也计入;它不是业务成功次数。 |
24
+ | 在途许可 | 已获得派发许可、尚未结清的读写调用。结果不明时不自动释放。 |
25
+ | 并发上限 | 同任务同时在途许可的上限,至少 1;读操作也占在途许可。 |
26
+
27
+ 这不是共享工具频率限流,也不按消息、商品数量、金额或 Token 计数。一次批量接口可能影响多个商品,仍只算一次写调用;业务侧需继续按自身规则确认批量影响。已有工具源、单工具限流及审批仍独立生效,不被任务额度替代。
28
+
29
+ 本批计量范围是经中枢派发的受治理业务工具调用,不包含宿主本地工具、模型推理、附件上传或聊天归档。它不是这些资源的通用配额系统。
30
+
31
+ ## 暂停、继续与不确定结果
32
+
33
+ - **暂停**:阻止后续派发许可。已获得许可的请求可能完成;暂停不等于撤回请求。
34
+ - **继续**:恢复原任务可派发状态,不增加额度、不变更成员,也不会自动执行任何业务调用。审批已通过的操作仍需显式继续原 `invocation_id`。
35
+ - **取消**:终止后续派发,不能重新开启,也不会回滚已经发生的业务变化。
36
+ - **原成员失效**:任一成员撤销、身份变化或绑定变化,整组阻断;不缩成剩余子集,不换默认授权。
37
+ - **结果不明**:只核对原调用。不能换 ID、换授权、重建任务或改用另一个工具重新发出同一写操作。当前候选不会自动向业务系统查询补证,也不自动释放未知许可。
38
+
39
+ 审批单消费、原调用派发标记、任务许可和执行 journal 在同一 MySQL 事务提交;之后才发出 HTTP。可信响应与额度结算也同事务保存。审计降级或传输不确定会保留明确的不确定状态,不能当成业务成功。
40
+
41
+ ## Agent / 宿主接口
42
+
43
+ 全部 Agent 端点仅接受原 Agent Bearer,响应 `Cache-Control: no-store`。
44
+
45
+ | 接口 | 用途 |
46
+ |---|---|
47
+ | `GET /agent-api/v1/task-control/capabilities` | 协商 `supported`、`mode=optional/required`、`same_hub_only`、`metering=write_invocation` 和只读核对能力。 |
48
+ | `GET /agent-api/v1/tasks/{task_id}?workspace=...&client_conversation_id=...` | 核验整组选定身份,返回当前请求成员和任务共享计数;不返回其他成员身份、凭据、正文或工具结果。 |
49
+ | `POST /agent-api/v1/workspaces/{workspace}/turns` | 增量接受下述可信绑定,并在上下文响应顶层原样回显。 |
50
+ | `GET /agent-api/v1/tool-invocations/{invocation_id}/receipt` | 只读原记录;管理任务还会重新验证整个原成员集合。 |
51
+ | `POST /agent-api/v1/tool-invocations/{invocation_id}/resume` | 可能真正派发原操作,只能作为显式继续,不能当轮询。 |
52
+
53
+ ```json
54
+ {
55
+ "task_binding": {
56
+ "schema_version": "bailing.agent-task-binding.v1",
57
+ "task_id": "11111111-1111-4111-8111-111111111111",
58
+ "scope_hash": "<64位十六进制摘要>"
59
+ }
60
+ }
61
+ ```
62
+
63
+ 任务快照 schema 为 `bailing.agent-task.v1`,包括 `state`、控制 `revision`、账本 `ledger_sequence`、`scope_hash`、`member_count`、当前 `member`、`policy`、`counters`。`snapshot_is_dispatch_permission=false`:读取成功不是下一笔派发的许可。SDK/DSH 必须对全部原成员验证,不能只读某一个成员就推断其他成员也可用。
64
+
65
+ 能力搜索不消耗写额度。已加入任务的 Session 在 Runtime 搜索时须携带原 `run_id`;只带裸查询不能绕过任务范围。当前目录仍描述原授权下的能力,任务精确工具名单在执行前再次裁剪和校验;不能把目录存在理解成这项任务一定允许执行。
66
+
67
+ SDK 增量方法为 `getTaskControlCapabilities`、`getTask` 和 `startTurn(..., { taskBinding })`。DSH 提供宿主 `setSessionTaskBinding/getSessionTaskState/restoreSessionTaskBinding` 及 CAS 存储接缝;精确签名以配套 DSH 的 `docs/TASK_CONTROL.md` 为准。模型不获得管理员 Token、创建任务、改额度或解除暂停的工具。沿用已选授权、跨轮工具缓存和原调用持久 journal;新操作使用本轮真实 run,恢复操作使用原 run / invocation。
68
+
69
+ 本候选限同一 Hub 和同一审计域。不同 Hub 的预算、正文转发和权限不能自动合并。
70
+
71
+ ## 管理接口
72
+
73
+ 仅管理员身份且具备 `clients:read` / `clients:write` 可使用,Agent Bearer 无权创建或控制任务。
74
+
75
+ | 接口 | 请求/返回 |
76
+ |---|---|
77
+ | `GET /admin/api/agent-tasks?limit=30&before=...` | `{items,next_cursor}`;按稳定 task ID 降序分页,不是创建时间排序。 |
78
+ | `POST /admin/api/agent-tasks` | `{request_id,members,policy}`,返回任务快照。 |
79
+ | `GET /admin/api/agent-tasks/{task_id}?limit=30&before=...` | `{task,invocations,next_cursor}`;原调用按稳定 job ID 分页。 |
80
+ | `POST /admin/api/agent-tasks/{task_id}/control` | `{request_id,expected_revision,action}`,`action=pause/resume/cancel`,返回快照。 |
81
+
82
+ `members` 每项为 `{session_id,client_app_id,workspace,client_conversation_id,allowed_tools}`;工具只允许精确名称。`policy` 为 `{max_write_calls,max_concurrent,expires_at}`,截止时间可为 `null`。成员与策略创建后冻结,本候选不支持直接编辑。
83
+
84
+ 创建与控制必须保留同一逻辑请求的 `request_id`,丢失确认时重试原请求。控制使用 CAS;修订冲突先刷新并请操作者重新判断,不能自动换修订号重放操作。后台只展示原关联、状态和计数,任务接口不返回工具参数或业务正文。
85
+
86
+ ## 错误与兼容
87
+
88
+ `TASK_PAUSED`、`TASK_CANCELLED`、`TASK_EXPIRED`、`TASK_WRITE_BUDGET_EXHAUSTED`、`TASK_CONCURRENCY_EXHAUSTED`、`TASK_TOOL_NOT_ALLOWED` 分别表达具体闸门;`TASK_REQUIRED` 表示不能省略任务。`TASK_SCOPE_BLOCKED` 不允许缩小原范围;绑定、成员和记录错误不能通过猜测坐标修复。
89
+
90
+ `TASK_DISPATCH_UNCERTAIN` 以及 invoke/resume 的 `TASK_UNAVAILABLE` 由配套 SDK 保守标成原调用结果未知,指导 `inspect_original`,不建议新写。旧 Core 404/405/501 能力协商为明确不支持;网络问题不能冒充“不支持”。旧 SDK/DSH 可继续使用**未加入任务**的授权,但不能执行已强制任务的 Session。
91
+
92
+ 数据库需要既有 `062_agent_task_control.sql` 的六张表,本次接线不增加后续迁移。全未迁移时任务能力不支持;部分表缺失或数据库故障必须阻断,不降级绕过。正式部署需先备份并核对当前数据库、成套候选和宿主兼容性;本地测试通过不代表已经部署。启用任务后不要回退到不认识强制标记的旧 Core,也不要删除标记或任务表作为回滚手段。
93
+
94
+ Core 的可复现检查:`npm run typecheck`、`npm test`。真实事务/HTTP 验收通过显式 `BAILING_TASK_TEST_MYSQL_CONFIG` 指向专用 loopback 临时数据库,再运行 `src/routes/agent-task-control-http-mysql.test.ts` 与任务仓储的 MySQL 测试。禁止将该测试指向业务数据库。
@@ -0,0 +1,134 @@
1
+ # Task control: persistence foundation
2
+
3
+ Historical foundation notes. The paired integration candidate now connects the actual runtime, HTTP, SDK/DSH and console; see [Task control](AGENT_TASK_CONTROL.en.md). The limitations below describe the earlier foundation slice only.
4
+
5
+ Status: internal implementation foundation. It is **not connected to the HTTP APIs,
6
+ tool runtime, SDK, DSH, or console**. Applying the new SQL alone does not enforce a
7
+ task budget or pause business execution. No client should enable task mode from
8
+ this foundation alone.
9
+
10
+ ## What this layer is for
11
+
12
+ A user may ask an assistant to update product descriptions in a shop and check
13
+ stock in an inventory system. A task links those selected authorizations and the
14
+ original calls. It can restrict the allowed tools, cumulative write calls,
15
+ concurrent dispatch permits, and expiry time. Existing authorization and business
16
+ approval checks remain necessary.
17
+
18
+ The write counter counts calls to tools whose trusted declaration is not
19
+ `readonly`. This includes idempotent writes. It does not count products, money,
20
+ successful business changes, or tokens. One bulk call may affect many objects.
21
+
22
+ ## Trusted inputs and persistent records
23
+
24
+ The future authenticated management layer must create the task and supply its
25
+ actor. The model cannot create a replacement task or increase its budget. Members
26
+ freeze the original Agent Session, Client, route, client conversation, identity
27
+ digest, and allowed tool names. Display names are not identities.
28
+
29
+ The repository also stores a persistent enforcement marker for each participating
30
+ Agent Session. Cancelling a task does not remove that marker. A future final
31
+ dispatch guard must check it even when a caller omits task metadata, changes its
32
+ conversation ID, or uses an older execution API. This first foundation does not
33
+ yet install that guard.
34
+
35
+ The first trusted reservation also binds the real run to exactly one task. A new
36
+ invocation ID cannot move that run to another approved task. The future run
37
+ creation path must establish this association from authenticated host state,
38
+ rather than letting the model choose a task on its first call.
39
+
40
+ `reserveInvocation` verifies a real Agent runtime run and the original Agent tool
41
+ Job. New operations require an active run. An existing original operation keeps
42
+ its original run even after that run ends. The classification must match a
43
+ Core-written `agent_task_tool_contract` snapshot in the original Job; user text or
44
+ model arguments cannot establish that snapshot. Current capability permission
45
+ and execution fingerprint validation must still be applied by the future runtime
46
+ integration before admission.
47
+
48
+ The task tables contain identifiers, hashes, control state and counters. They do
49
+ not duplicate conversation bodies, access tokens, or full business arguments.
50
+ Internal repository views include identity digests and group state; they are not
51
+ safe response DTOs. An authenticated API must authorize and project these views.
52
+
53
+ ## Budget and dispatch semantics
54
+
55
+ | Fact | Write budget | Concurrency permit |
56
+ | --- | --- | --- |
57
+ | Original write reserved, including waiting for approval | reserved once | none |
58
+ | A fresh dispatch permit committed | remains reserved | held |
59
+ | Result is unknown | remains reserved | held as unknown |
60
+ | Trusted evidence confirms dispatch and a terminal outcome | consumed once | released |
61
+ | Trusted evidence confirms no dispatch, terminal outcome | released | released |
62
+ | Confirmed no dispatch, explicit retry of the same original operation | original reservation retained | a new permit may be granted |
63
+ | Read-only tool | no write charge | same concurrency policy |
64
+
65
+ Only `fresh: true` from a successful grant authorizes a new dispatch attempt. A
66
+ lost grant acknowledgement or a repeated grant returns the original permit and
67
+ must never cause a second request. An unresolved grant may require original
68
+ evidence reconciliation; a timer alone cannot prove that no request was sent.
69
+
70
+ Permit IDs fence settlement. A late response from an older permit cannot settle a
71
+ newer attempt. Only the trusted execution/evidence layer can report a settlement;
72
+ an Agent-facing API must not let the model claim `confirmed_not_dispatched` to
73
+ release its own quota.
74
+
75
+ A reservation that has never obtained a permit can be closed after an exact
76
+ denied approval or an authenticated administrator's abandonment. The transaction
77
+ checks the original no-dispatch fence and absence of an execution journal before
78
+ releasing budget. After a permit, this shortcut is forbidden. If a trusted
79
+ observation confirms that the original permitted operation was not dispatched,
80
+ an explicit retry may reuse its original still-approved approval ID; an unknown
81
+ outcome cannot enable that reuse or a new dispatch.
82
+
83
+ Task control revisions are separate from the execution ledger sequence. High
84
+ call volume should not continuously invalidate an administrator's pause request.
85
+ Pause stops **new permits** after the control transaction commits. Previously
86
+ granted permits can still finish and report their results. Cancellation is final
87
+ and does not promise rollback of completed business operations. Reading original
88
+ receipts remains distinct from explicitly continuing a business operation.
89
+
90
+ ## Transaction boundary
91
+
92
+ This foundation requires the same MySQL database for task records, original Jobs,
93
+ Agent identities, and approvals. Granting a permit, consuming the matching
94
+ approval when required, and persisting the original Job attempt fence use one
95
+ connection and one transaction. Sharing a pool without sharing the connection is
96
+ insufficient.
97
+
98
+ The runtime integration must also coordinate the existing execution journal with
99
+ that transaction and the actual HTTP dispatch point. It must preserve known
100
+ journal results before allocating new permits and must not consume an approval
101
+ before discovering that the task is paused or its concurrency is exhausted.
102
+ External state stores and JSONL are not supported for task enforcement by this
103
+ foundation.
104
+
105
+ ## Remaining activation requirements
106
+
107
+ Before advertising task-control support or enabling it for a client:
108
+
109
+ 1. Connect one final admission path to direct invoke/resume and cover or reject
110
+ older run, engine rerun, approval continuation and executor tool paths.
111
+ 2. Require authoritative run/task association. A marked Session cannot escape
112
+ enforcement by omitting a field or creating another conversation.
113
+ 3. Add authenticated management APIs, protected Agent projections, capability
114
+ negotiation, and explicit unsupported behavior for incompatible stores.
115
+ 4. Integrate SDK/DSH using the original scope and invocation journal. Observation
116
+ must use read-only receipts; explicit continuation must pass task admission.
117
+ 5. Add the console controls and full synthetic HTTP/host acceptance, including
118
+ cancellation, missing acknowledgements, identity revocation and local storage
119
+ failures. A repository test is not proof of end-to-end enforcement.
120
+
121
+ `062_agent_task_control.sql` only adds task tables; it does not backfill tasks or
122
+ change existing limits. Once enforcement is activated in a later implementation,
123
+ downgrading to an implementation that ignores markers is not a safe rollback.
124
+ Keep the original task and invocation records when disabling new admission.
125
+
126
+ ## Local verification
127
+
128
+ Pure state tests run with the normal test suite. The separate MySQL test accepts
129
+ `BAILING_TASK_TEST_MYSQL_CONFIG`, a path to a disposable database connection JSON.
130
+ It refuses non-loopback hosts and databases outside the `bailing_task_test` naming
131
+ boundary. It runs the real migration twice, seeds synthetic identities and empty
132
+ conversation bodies, then exercises concurrent budget/permit decisions,
133
+ transaction rollback, pause, revocation, and original-ID recovery. Never point
134
+ these tests at a business or shared environment.
@@ -410,7 +410,7 @@ MCP tools / -> MCP projection
410
410
  - `config-tool-provider-repository`:工具源仓储,负责 provider spec、密钥、刷新策略、嵌入配置与启停;
411
411
  - `config-admin-repository`:管理员与后台会话仓储,负责账号、角色、登录时间、会话签发、滑动续期与吊销;
412
412
  - `config-project-repository`:项目目录仓储,负责项目名、路径、启停和说明;
413
- - `config-executor-token-repository`:执行器令牌仓储,负责 token 生成、轮换、target 白名单和 last_seen 观测;
413
+ - `config-executor-billing-repository`:执行器令牌仓储,负责 token 生成、轮换、target 白名单和 last_seen 观测;
414
414
  - `config-target-repository`:执行目标仓储,负责 target 注册、执行形态、超时与启停;
415
415
  - `config-storage-bucket-repository`:对象存储桶仓储,负责存储配置、密钥留空保留和启停;
416
416
  - `config-alert-rule-repository`:告警规则仓储,负责事件前缀匹配、渠道、收件人和冷却时间;
@@ -12,7 +12,7 @@ For the current integration contract, use:
12
12
 
13
13
  ## Recording Rules
14
14
 
15
- Lead each release with a familiar shop, product-maintenance or inventory scenario: the previous problem, changed behavior, affected users and developers, upgrade steps, observable checks and limits. Keep English and Chinese facts aligned and distinguish additions, fixes and existing features. See [the release scenario notes](RELEASE_NOTES_v0.7.0.en.md).
15
+ Lead each release with a familiar business-assistant or enterprise-service scenario: the previous problem, changed behavior, affected users and developers, upgrade steps, observable checks and limits. Keep English and Chinese facts aligned and distinguish additions, fixes and existing features. See [the release scenario notes](RELEASE_NOTES_v0.9.0.en.md).
16
16
 
17
17
  Each public version should describe:
18
18
 
@@ -22,6 +22,27 @@ Each public version should describe:
22
22
  - validation commands;
23
23
  - related docs.
24
24
 
25
+ ## v0.9.0 - Model services, shared allowances and image tools
26
+
27
+ Version date: 2026-09-23. Release pairing: Core 0.9.0 / SDK 0.7.0 / DSH 0.7.0. See [release notes](RELEASE_NOTES_v0.9.0.en.md) and the [upgrade guide](UPGRADE_v0.9.0.en.md).
28
+
29
+ - Add an optional model billing gateway while hosts retain orchestration. Models and tools share USD allowance and one multiplier; periodic sale price and allowance are separate, with Credits or percentage presentation.
30
+ - Add explicit model/reference-endpoint mappings and price snapshots. OpenRouter prices are references, not another provider's invoice. Unready services stay out of callable catalogs.
31
+ - Add Aliyun compatible/native and OpenRouter text-to-image adapters, durable original requests and independent result/actual-usage settlement. Video and voice declarations are not execution support.
32
+ - Complete plan removal, account archive/restore and per-account manual allowance reset, retaining original requests, pools and ledger. Reset does not extend expiration; in-flight requests settle to their original pool.
33
+ - Add migrations 063/064. Public 0.8.0 upgrades retain real data and require no abandoned test-schema purge. Business applications retain payment, currency conversion, refunds and final authorization.
34
+ - Hosts opt into catalogs, summaries and original-operation records. Verify configuration, actual usage, presentation, original-ID lookup and administration; automated checks do not establish live provider or deployment acceptance.
35
+
36
+ ## v0.8.0 - Longer task recovery, attachments and task controls
37
+
38
+ Release date: 2026-09-16. Pair SDK/DSH 0.6.0; see [scenarios](RELEASE_NOTES_v0.8.0.en.md) and [upgrade guide](UPGRADE_v0.8.0.en.md).
39
+
40
+ - Add public image attachment delivery, read-only original receipts and administrator task budgets, concurrency, pause and cancellation.
41
+ - Clarify discovery counts and structured failures; configure inherited, custom or disabled Hub tool limits while retaining hour/day windows.
42
+ - Fix cross-turn artifact run links, original argument recovery, legal long Client IDs and concurrent metadata updates; uncertain writes are never replaced.
43
+ - Add migrations060–062. Task enrollment persists on original Agent Sessions, cancellation does not remove it, and enrolled deployments must not downgrade to versions that ignore it.
44
+ - Keep business APIs/authorization/approval; hosts supply matched persistent stores and opt into cross-turn reuse. See release limits; no full-plan automatic restart is claimed.
45
+
25
46
  ## v0.7.0 - cross-system conversations, authorization names and centralized setup
26
47
 
27
48
  Release date: 2026-09-10. These additions extend Core 0.6.1 and pair with SDK/DSH 0.5.0. See [shop and inventory scenarios](RELEASE_NOTES_v0.7.0.en.md).
package/docs/CHANGELOG.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  ## 记录规则
7
7
 
8
- 每次先用商城、商品维护或库存等常见场景说明原问题与本版行为,再按使用者、业务后端与客户端开发者交代升级影响。中英文使用同一事实,新增能力、修复和已有能力分别标明;参考[本版场景说明](RELEASE_NOTES_v0.7.0.md)。
8
+ 每次先用业务助手、企业服务等通用场景说明原问题与本版行为,再按使用者、业务后端与客户端开发者交代升级影响。中英文使用同一事实,新增能力、修复和已有能力分别标明;参考[本版场景说明](RELEASE_NOTES_v0.9.0.md)。
9
9
 
10
10
  每个公开版本至少说明:
11
11
 
@@ -15,6 +15,27 @@
15
15
  - **验证方式**:部署方如何确认该版本运行正常;
16
16
  - **相关文档**:对应的契约、指南或示例。
17
17
 
18
+ ## v0.9.0 - 模型服务、统一套餐额度与文生图工具
19
+
20
+ 版本日期:2026-09-23。配套 Core 0.9.0 / SDK 0.7.0 / DSH 0.7.0。[版本说明](RELEASE_NOTES_v0.9.0.md)、[升级指南](UPGRADE_v0.9.0.md)。
21
+
22
+ - 新增可选模型计费网关,本地宿主继续编排;模型与工具共享 USD 额度和套餐统一倍率,周期售价与额度分开,客户显示 Credits 或剩余百分比。
23
+ - 新增显式模型/参考端点映射和价格快照;OpenRouter 报价是参考价,不是其他供应商的实际账单。配置未就绪的服务不进入可调用目录。
24
+ - 新增阿里云兼容/原生及 OpenRouter 文生图适配,原请求持久恢复,结果与实际用量结算独立;视频、语音只可声明,未适配能力不可执行。
25
+ - 完善套餐移除、账户归档/恢复和单账户手动重置额度;保留原请求、额度池与账本,到期时间不延长,在途请求结算到原池。
26
+ - 新增 063/064 迁移,公开 0.8.0 升级保留真实数据,不要求清退旧测试结构;业务侧继续负责支付、汇率、退款与最终授权。
27
+ - 配套宿主按需接入目录、摘要和原操作记录。验收核对配置、实际计量、展示、原 ID 查询和管理动作,自动化检查不替代真实供应商与部署验收。
28
+
29
+ ## v0.8.0 - 长任务恢复、附件空间与任务控制
30
+
31
+ 发布日期:2026-09-16。配套 SDK/DSH 0.6.0;[场景与更新](RELEASE_NOTES_v0.8.0.md)、[升级指南](UPGRADE_v0.8.0.md)。
32
+
33
+ - 新增公开图片附件空间、只读原调用回执和管理端任务预算/并发/暂停/取消。
34
+ - 改进能力发现数量与结构化错误;中枢工具限额可继承、自定义或关闭,小时/日窗口保留。
35
+ - 修复跨轮附件run关联、原调用参数恢复、合法长接入方ID与并发metadata更新;未知写结果不新建替代调用。
36
+ - 新增060–062迁移;任务enrollment对原Agent Session持续生效,取消不解除,启用后不能降到忽略标记的旧版本。
37
+ - 业务API/授权/审批不重做;宿主需配套持久记录,跨轮工具复用显式启用。已测范围与未覆盖项见版本说明,不宣称整项计划自动续跑。
38
+
18
39
  ## v0.7.0 - 多系统会话、授权名称与集中配置
19
40
 
20
41
  发布日期:2026-09-10。相对 Core 0.6.1 新增以下能力,完整配套为 SDK/DSH 0.5.0。见[商城与库存场景说明](RELEASE_NOTES_v0.7.0.md)。
@@ -1,5 +1,11 @@
1
1
  # Compatibility And Upgrade Policy
2
2
 
3
+ ## Core 0.9.0 release pairing
4
+
5
+ Pair Core 0.9.0 with SDK 0.7.0 / DSH 0.7.0 for the optional model billing gateway. Hosts retain orchestration, existing business authority, approvals and original-call recovery. Public 0.8.0 upgrades apply outstanding 063/064 migrations and retain real data, with no test-schema purge. Periodic sale price and allowance are separate; original grant snapshots and ledger remain. Hosts opt into model plans explicitly; existing business-tool-only hosts need not enable billing. See the [0.9.0 upgrade guide](UPGRADE_v0.9.0.en.md).
6
+
7
+ > 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).
8
+
3
9
  BailingHub follows SemVer for public releases.
4
10
 
5
11
  Before `1.0.0`, the project may still adjust public contracts, but breaking changes must be documented clearly in release notes and changelog entries.
@@ -1,5 +1,7 @@
1
1
  # HTTP Contract
2
2
 
3
+ Unreleased additive candidate: [task control](AGENT_TASK_CONTROL.en.md) defines separate task schemas, trusted turn binding and administrator controls. It requires paired capability negotiation and does not change the stable business authorization or approval semantics below.
4
+
3
5
  > Current contract: `bailing.contract.v2.14`. This is the only network boundary between a business system and BailingHub.
4
6
 
5
7
  This document summarizes the public wire contract between a business system and BailingHub.
package/docs/CONTRACT.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # 百灵中枢 · 边界契约
2
2
 
3
+ 未发布增量:[任务控制候选](AGENT_TASK_CONTROL.md)新增独立任务 schema、受信 turn 绑定和管理员控制接口,须成套协商启用;不改变下面稳定业务契约的权限或审批含义。
4
+
3
5
  > 当前契约:`bailing.contract.v2.14`。这是业务系统与中枢之间唯一的网络边界。
4
6
 
5
7
  **冻结它,两边就能各自独立开发。** 任何字段变更都按兼容方式演进(只增不改语义、不删字段)。