bailinghub 0.8.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.
- package/README.en.md +6 -5
- package/README.md +6 -5
- package/docker-compose.images.yml +2 -2
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CHANGELOG.en.md +12 -1
- package/docs/CHANGELOG.md +12 -1
- package/docs/COMPATIBILITY.en.md +4 -0
- package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
- package/docs/INDEPENDENT_VALIDATION.md +4 -4
- package/docs/MODEL_BILLING.en.md +123 -0
- package/docs/MODEL_BILLING.md +125 -0
- package/docs/PERIOD_ALLOWANCE_UPGRADE.en.md +31 -0
- package/docs/PERIOD_ALLOWANCE_UPGRADE.md +31 -0
- package/docs/README.en.md +5 -1
- package/docs/README.md +4 -0
- package/docs/RELEASE_NOTES_NEXT.en.md +4 -2
- package/docs/RELEASE_NOTES_NEXT.md +4 -2
- package/docs/RELEASE_NOTES_v0.9.0.en.md +45 -0
- package/docs/RELEASE_NOTES_v0.9.0.md +45 -0
- package/docs/UPGRADE_v0.9.0.en.md +54 -0
- package/docs/UPGRADE_v0.9.0.md +54 -0
- package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +4 -0
- package/package.json +1 -1
- package/scripts/check-doc-links.mjs +4 -0
- package/scripts/check-image-tags.sh +1 -1
- package/scripts/check-release-consistency.test.mjs +2 -2
- package/scripts/install.sh +1 -1
- package/scripts/publish-images.sh +1 -1
- package/scripts/release-audit.mjs +1 -0
- package/scripts/sdk-runtime-test.mjs +6 -0
- package/scripts/verify-billing-install-upgrade.mjs +225 -0
- package/scripts/verify-github-repo.mjs +1 -0
- package/sdk/node/README.md +17 -0
- package/sdk/node/examples/billing.mjs +21 -0
- package/sdk/node/package.json +5 -1
- package/sdk/node/src/index.mjs +2 -0
- package/sdk/node/src/usage.d.mts +74 -0
- package/sdk/node/src/usage.mjs +62 -0
- package/sdk/node/tests/usage-types.mts +23 -0
- package/sdk/node/tests/usage.test.mjs +81 -0
- package/sdk/php7/README.md +19 -2
- package/sdk/php7/examples/billing.php +27 -0
- package/sdk/php7/examples/well-known.php +1 -1
- package/sdk/php7/src/ToolSpec.php +1 -1
- package/sdk/php7/src/UsageClient.php +95 -0
- package/sdk/php7/src/UsageClientException.php +22 -0
- package/sdk/php7/tests/billing-core-http.php +59 -0
- package/sdk/php7/tests/usage-client.php +78 -0
- package/sql/063_usage_model_billing.sql +153 -0
- package/sql/064_period_plan_allowance.sql +25 -0
- package/sql/README.en.md +12 -4
- package/sql/README.md +14 -6
- package/src/app/auth.ts +2 -0
- package/src/app/oss-edition.ts +1 -0
- package/src/infrastructure/config/configstore.ts +6 -0
- package/src/modules/usage/allowance-reset.mysql.test.ts +122 -0
- package/src/modules/usage/billing-contracts.ts +59 -0
- package/src/modules/usage/billing-decimal.test.ts +22 -0
- package/src/modules/usage/billing-decimal.ts +36 -0
- package/src/modules/usage/billing-external.ts +39 -0
- package/src/modules/usage/billing-gateway.mysql.test.ts +24 -0
- package/src/modules/usage/billing-ledger.test.ts +51 -0
- package/src/modules/usage/billing-ledger.ts +104 -0
- package/src/modules/usage/billing-presentation.mysql.test.ts +95 -0
- package/src/modules/usage/billing-presentation.test.ts +49 -0
- package/src/modules/usage/billing-presentation.ts +34 -0
- package/src/modules/usage/billing-prices.mysql.test.ts +88 -0
- package/src/modules/usage/billing-repository.mysql.test.ts +181 -0
- package/src/modules/usage/billing-repository.ts +463 -0
- package/src/modules/usage/contracts.ts +49 -0
- package/src/modules/usage/dynamic-plan-models.mysql.test.ts +221 -0
- package/src/modules/usage/errors.ts +19 -0
- package/src/modules/usage/http.ts +85 -0
- package/src/modules/usage/identity-revocation.mysql.test.ts +286 -0
- package/src/modules/usage/identity.mysql.test.ts +120 -0
- package/src/modules/usage/identity.ts +303 -0
- package/src/modules/usage/issuer-sdk-billing.mysql.test.ts +92 -0
- package/src/modules/usage/model-gateway.mysql.test.ts +207 -0
- package/src/modules/usage/model-gateway.ts +229 -0
- package/src/modules/usage/model-tool-gateway.mysql.test.ts +137 -0
- package/src/modules/usage/model-tool-provider.test.ts +37 -0
- package/src/modules/usage/model-tool-provider.ts +110 -0
- package/src/modules/usage/model-tools.test.ts +36 -0
- package/src/modules/usage/model-tools.ts +62 -0
- package/src/modules/usage/period-allowance.mysql.test.ts +97 -0
- package/src/modules/usage/period.test.ts +26 -0
- package/src/modules/usage/period.ts +96 -0
- package/src/modules/usage/pricing.test.ts +178 -0
- package/src/modules/usage/pricing.ts +228 -0
- package/src/modules/usage/provider-failure.ts +37 -0
- package/src/modules/usage/provider-stream.test.ts +85 -0
- package/src/modules/usage/provider-stream.ts +77 -0
- package/src/modules/usage/provider.test.ts +67 -0
- package/src/modules/usage/provider.ts +142 -0
- package/src/modules/usage/repository.ts +539 -0
- package/src/modules/usage/service-availability.mysql.test.ts +68 -0
- package/src/modules/usage/service-availability.ts +13 -0
- package/src/modules/usage/service-delete.mysql.test.ts +87 -0
- package/src/modules/usage/stream-http.ts +32 -0
- package/src/modules/usage/test-harness.ts +108 -0
- package/src/modules/usage/usage-deletion.mysql.test.ts +312 -0
- package/src/modules/usage/usage-deletion.ts +119 -0
- package/src/modules/usage/validation.test.ts +18 -0
- package/src/modules/usage/validation.ts +33 -0
- package/src/routes/admin-billing-usage.ts +73 -0
- package/src/routes/admin-usage.ts +147 -0
- package/src/routes/admin.ts +4 -0
- package/src/routes/private.ts +8 -0
- package/web/connect/bailing-connect-php7.tgz +0 -0
- package/web/console/assets/Accounts-Bervi5JU.css +1 -0
- package/web/console/assets/Accounts-DnddhY6t.js +3 -0
- package/web/console/assets/{AgentClients-Bf7sUUs_.js → AgentClients-VInbD7JS.js} +1 -1
- package/web/console/assets/AgentTasks-B-1XklBg.js +2 -0
- package/web/console/assets/AgentTasks-BsG850Il.css +1 -0
- package/web/console/assets/{Approvals-BIbZvInm.js → Approvals-34qUPHf0.js} +1 -1
- package/web/console/assets/{Audit-KyPSmBdZ.js → Audit-BbVgkSm2.js} +1 -1
- package/web/console/assets/{BrandLockup-Sv5DU2G6.js → BrandLockup-DgscF28e.js} +1 -1
- package/web/console/assets/{Channels-B9n4fbxg.js → Channels-Bp-yuk8d.js} +1 -1
- package/web/console/assets/{ChatEntries-xsOCUXi_.js → ChatEntries-C9Ft60TS.js} +1 -1
- package/web/console/assets/{Clients-CI3DBDHf.js → Clients-NPldD-DD.js} +1 -1
- package/web/console/assets/{Cost-JgNXQPlN.js → Cost-DZcuB-EB.js} +1 -1
- package/web/console/assets/{Credentials-B5UUUdt0.js → Credentials-RTT7N6zl.js} +1 -1
- package/web/console/assets/{Diagnostics-BMGciWQb.js → Diagnostics-_LeK8cce.js} +1 -1
- package/web/console/assets/{Executors-CRbboOCZ.js → Executors-Bi7H8rIm.js} +1 -1
- package/web/console/assets/{HelpTip-i-KJhf5s.js → HelpTip-BfyWrxCE.js} +1 -1
- package/web/console/assets/{Kb-CgLNGjRp.js → Kb-BHamz8NP.js} +2 -2
- package/web/console/assets/{Login-C52JmXzx.js → Login-C1rJR-6w.js} +1 -1
- package/web/console/assets/{Projects-CDOvHPVS.js → Projects-BRA4a48v.js} +1 -1
- package/web/console/assets/Routes-CTC7U-fQ.js +124 -0
- package/web/console/assets/Routes-CyXV4Pba.css +1 -0
- package/web/console/assets/{Runs-DYNDXsqk.js → Runs-B_fa_BlD.js} +1 -1
- package/web/console/assets/{Setup-B91P6i1x.js → Setup-C1_d0mFy.js} +1 -1
- package/web/console/assets/Shell-CHEV6RGC.js +1 -0
- package/web/console/assets/Shell-ykb-tUfo.css +1 -0
- package/web/console/assets/{StorageBuckets-DkuDM0oX.js → StorageBuckets-DlG3ojhA.js} +1 -1
- package/web/console/assets/{SystemSettings-B7Mqj3k1.js → SystemSettings-DYo2gg6d.js} +1 -1
- package/web/console/assets/{SystemStatus-Db93b6dc.js → SystemStatus-DKCoUZlq.js} +1 -1
- package/web/console/assets/{Targets-CuuIYeZO.js → Targets-CdkG6BPR.js} +1 -1
- package/web/console/assets/{Tools-CHiqz9XZ.js → Tools-DVpCt0ox.js} +1 -1
- package/web/console/assets/Usage-CAeDGjrb.css +1 -0
- package/web/console/assets/Usage-DWCpLugC.js +1 -0
- package/web/console/assets/UsageAccess-B_Xq7ARW.js +1 -0
- package/web/console/assets/UsageAccess-CGGaWTuj.css +1 -0
- package/web/console/assets/UsageHelp-CSM4xO0K.css +1 -0
- package/web/console/assets/UsageHelp-t5ZG_f-e.js +1 -0
- package/web/console/assets/{index-QnmD7N7F.js → index-C6W4LWVV.js} +1 -1
- package/web/console/assets/{index-Fi9gkGxV.css → index-Cxuc9OCj.css} +1 -1
- package/web/console/assets/index-H1kfa0Mj.js +2 -0
- package/web/console/assets/{request-DeGya810.js → request-DLsP1_ot.js} +1 -1
- package/web/console/assets/{schema-BqlqLw1R.js → schema-BLOHvAJQ.js} +1 -1
- package/web/console/assets/{util-4bN2dv7B.js → util-CGVh2Jvr.js} +1 -1
- package/web/console/assets/{vendor-element-CZoEjZr8.js → vendor-element-BD089KxE.js} +1 -1
- package/web/console/assets/{vendor-mammoth-BUEEDX6A.js → vendor-mammoth-Bv-CZhmH.js} +1 -1
- package/web/console/index.html +3 -3
- package/web-admin/README.md +17 -0
- package/web-admin/src/components/UsageDeletionPreview.vue +44 -0
- package/web-admin/src/components/UsageHelp.vue +72 -0
- package/web-admin/src/components/UsageServiceReferences.vue +169 -0
- package/web-admin/src/layout/Shell.vue +22 -5
- package/web-admin/src/pages/Accounts.vue +3 -3
- package/web-admin/src/pages/AgentTasks.vue +2 -2
- package/web-admin/src/pages/Routes.vue +5 -1
- package/web-admin/src/pages/Usage.vue +2470 -0
- package/web-admin/src/pages/UsageAccess.vue +1147 -0
- package/web-admin/src/router.ts +8 -4
- package/web-admin/src/styles/base.css +57 -0
- package/web-admin/src/table-widths.ts +16 -1
- package/web-admin/src/usage-deletion.ts +40 -0
- package/web-admin/src/usage-management.ts +13 -0
- package/web-admin/src/usage-presentation.test.ts +21 -0
- package/web-admin/src/usage-presentation.ts +107 -0
- package/web-admin/src/usage-price-preview.test.ts +60 -0
- package/web-admin/src/usage-price-preview.ts +54 -0
- package/web-admin/tests/token-usage.browser.mjs +773 -0
- package/web-admin/tests/usage-access.browser.mjs +398 -0
- package/web/console/assets/Accounts-B4ePH5jp.css +0 -1
- package/web/console/assets/Accounts-BRCR3O0P.js +0 -3
- package/web/console/assets/AgentTasks--bqL_QKg.js +0 -2
- package/web/console/assets/AgentTasks-C8ox3TyS.css +0 -1
- package/web/console/assets/Routes-DkMIjMQA.css +0 -1
- package/web/console/assets/Routes-X9vHLpKW.js +0 -124
- package/web/console/assets/Shell-Bj6C8Hgo.css +0 -1
- package/web/console/assets/Shell-BsRa7bQQ.js +0 -1
- package/web/console/assets/index-UGvfF3Xr.js +0 -2
package/README.en.md
CHANGED
|
@@ -29,13 +29,14 @@ 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.
|
|
32
|
+
## v0.9.0: model services and shared plan allowances
|
|
33
33
|
|
|
34
|
-
|
|
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
|
-
|
|
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
|
+
|
|
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)
|
|
37
39
|
|
|
38
|
-
[Release scenarios](docs/RELEASE_NOTES_v0.8.0.en.md) · [Upgrade and enablement](docs/UPGRADE_v0.8.0.en.md) · [Setup](docs/LOCAL_AGENT_SETUP.en.md)
|
|
39
40
|
## Operate the System by Conversation
|
|
40
41
|
|
|
41
42
|
Most business software already has the data, permission model, and APIs it needs. What it lacks is a safe bridge between a natural-language request and the exact operation the current user is allowed to perform.
|
|
@@ -212,7 +213,7 @@ Run separate BailingHub deployments for mutually isolated organizations. A `clie
|
|
|
212
213
|
- [HTTP Contract](docs/CONTRACT.en.md) — stable network and identity boundaries.
|
|
213
214
|
- [Architecture](docs/ARCHITECTURE.en.md) — runtime layers and dependency direction.
|
|
214
215
|
- [English Documentation Map](docs/README.en.md) — the complete public documentation index.
|
|
215
|
-
- [Changelog](docs/CHANGELOG.en.md) and [v0.
|
|
216
|
+
- [Changelog](docs/CHANGELOG.en.md) and [v0.9.0](docs/RELEASE_NOTES_v0.9.0.en.md) — current release changes and upgrade notes.
|
|
216
217
|
|
|
217
218
|
## Feedback and Ecosystem
|
|
218
219
|
|
package/README.md
CHANGED
|
@@ -27,13 +27,14 @@
|
|
|
27
27
|
|
|
28
28
|
在线体验环境只用于了解产品和配置方式。请勿上传生产凭据、敏感数据或接入真实业务;正式使用请自行部署开源版。
|
|
29
29
|
|
|
30
|
-
## v0.
|
|
30
|
+
## v0.9.0:模型服务与统一套餐额度
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
按需启用微型模型计费网关,为业务助手的对话模型与文生图工具配置共享 USD 额度。套餐统一倍率,周期额度与售价分开;客户看到 Credits 或剩余百分比。本地宿主继续编排任务,原业务授权和审批保持。
|
|
33
33
|
|
|
34
|
-
配套为 **Core 0.
|
|
34
|
+
配套为 **Core 0.9.0 + MCP / Agent Client SDK 0.7.0 + DSH 0.7.0**。参考报价不等于供应商实付费用,生成结果与计费分别处理。升级时核对版本、Tag 与制品摘要。
|
|
35
|
+
|
|
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)
|
|
35
37
|
|
|
36
|
-
[更新场景](docs/RELEASE_NOTES_v0.8.0.md) · [升级与启用边界](docs/UPGRADE_v0.8.0.md) · [集中配置](docs/LOCAL_AGENT_SETUP.md)
|
|
37
38
|
## 适合哪些团队
|
|
38
39
|
|
|
39
40
|
- 已有商城、SaaS、CRM、ERP 或内部后台,希望增加能查数据、办业务的 AI 助手。
|
|
@@ -197,7 +198,7 @@ BailingHub Core 是独立服务,只通过稳定网络契约与业务系统协
|
|
|
197
198
|
| 集中开启本地智能体与工具 | [四步配置指南](docs/LOCAL_AGENT_SETUP.md) · [系统说明](docs/AGENT_SYSTEM_INFO.md) |
|
|
198
199
|
| 查 API 与边界契约 | [HTTP 契约](docs/CONTRACT.md) · [Client API](docs/CLIENT_API.md) |
|
|
199
200
|
| 理解架构与长期取舍 | [架构](docs/ARCHITECTURE.md) · [项目愿景](VISION.md) |
|
|
200
|
-
| 查看版本变化 | [CHANGELOG](docs/CHANGELOG.md) · [v0.
|
|
201
|
+
| 查看版本变化 | [CHANGELOG](docs/CHANGELOG.md) · [v0.9.0](docs/RELEASE_NOTES_v0.9.0.md) |
|
|
201
202
|
|
|
202
203
|
完整中英文文档地图见 [docs/README.md](docs/README.md)。公共 API、SDK、Schema、Docker Demo 与代码标识保持语言中立。
|
|
203
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.
|
|
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.
|
|
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
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -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-
|
|
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`:告警规则仓储,负责事件前缀匹配、渠道、收件人和冷却时间;
|
package/docs/CHANGELOG.en.md
CHANGED
|
@@ -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
|
|
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,17 @@ 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
|
+
|
|
25
36
|
## v0.8.0 - Longer task recovery, attachments and task controls
|
|
26
37
|
|
|
27
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).
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
## 记录规则
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
每次先用业务助手、企业服务等通用场景说明原问题与本版行为,再按使用者、业务后端与客户端开发者交代升级影响。中英文使用同一事实,新增能力、修复和已有能力分别标明;参考[本版场景说明](RELEASE_NOTES_v0.9.0.md)。
|
|
9
9
|
|
|
10
10
|
每个公开版本至少说明:
|
|
11
11
|
|
|
@@ -15,6 +15,17 @@
|
|
|
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
|
+
|
|
18
29
|
## v0.8.0 - 长任务恢复、附件空间与任务控制
|
|
19
30
|
|
|
20
31
|
发布日期:2026-09-16。配套 SDK/DSH 0.6.0;[场景与更新](RELEASE_NOTES_v0.8.0.md)、[升级指南](UPGRADE_v0.8.0.md)。
|
package/docs/COMPATIBILITY.en.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
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
|
+
|
|
3
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).
|
|
4
8
|
|
|
5
9
|
BailingHub follows SemVer for public releases.
|
|
@@ -7,7 +7,7 @@ It is not certification, a benchmark, or evidence of production adoption. Passin
|
|
|
7
7
|
## Scope
|
|
8
8
|
|
|
9
9
|
- Target: the open-source BailingHub Docker demo;
|
|
10
|
-
- Stable baseline: `v0.
|
|
10
|
+
- Stable baseline: `v0.9.0`;
|
|
11
11
|
- Data: the bundled demo orders, tickets, refunds, and failure probe;
|
|
12
12
|
- Expected time: about 20 minutes after images and dependencies are available;
|
|
13
13
|
- Not required: a real model key, production API, production credential, or real business data.
|
|
@@ -32,7 +32,7 @@ curl -fsSL https://www.bailinghub.com/install.sh | sh
|
|
|
32
32
|
cd "$HOME/bailinghub"
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
The installer pulls the official `v0.
|
|
35
|
+
The installer pulls the official `v0.9.0` images by default, generates random tokens and an admin password, starts the services, and runs the smoke test. The initial administrator is created only when the administrator table is empty; restarting, upgrading, recreating containers, or reinstalling against the same persistent database does not overwrite a changed password. The optional `/metrics` endpoint remains disabled and does not affect core validation. Keep the reported version, install mode, elapsed time, and the commands printed under `常用命令`, but never include passwords or tokens in your report. After Docker is installed, the current non-root login usually still needs the printed `sudo docker compose ...` commands; Docker group membership may not take effect until the next login.
|
|
36
36
|
|
|
37
37
|
If the default directory is already in use, choose a new empty directory instead of overwriting an existing deployment:
|
|
38
38
|
|
|
@@ -46,7 +46,7 @@ cd "$HOME/bailinghub-validation"
|
|
|
46
46
|
### Path B: local source reproduction
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
git clone --depth 1 --branch v0.
|
|
49
|
+
git clone --depth 1 --branch v0.9.0 https://github.com/bailinghub/bailinghub.git
|
|
50
50
|
cd bailinghub
|
|
51
51
|
git rev-parse HEAD
|
|
52
52
|
export BAILING_TOKEN="$(openssl rand -hex 32)"
|
|
@@ -167,7 +167,7 @@ After the core task passes, you may continue with:
|
|
|
167
167
|
- [Trusted rich rendering and chat reliability](RELEASE_NOTES_v0.1.15.en.md).
|
|
168
168
|
- [Bounded tool runtime and resilient semantic retrieval](RELEASE_NOTES_v0.1.16.en.md).
|
|
169
169
|
- [Composable Core and Kernel Host API v1](RELEASE_NOTES_v0.3.0.en.md).
|
|
170
|
-
- [Current stable release notes](RELEASE_NOTES_v0.
|
|
170
|
+
- [Current stable release notes](RELEASE_NOTES_v0.9.0.en.md).
|
|
171
171
|
|
|
172
172
|
Select the relevant track in the same Issue form and disclose whether you received direct maintainer assistance.
|
|
173
173
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
## 验证范围
|
|
8
8
|
|
|
9
9
|
- 验证对象:BailingHub 开源版 Docker demo;
|
|
10
|
-
- 稳定基线:`v0.
|
|
10
|
+
- 稳定基线:`v0.9.0`;
|
|
11
11
|
- 数据范围:仓库自带的 demo 订单、工单、退款和故障工具;
|
|
12
12
|
- 预计用时:镜像和依赖下载完成后约 20 分钟;
|
|
13
13
|
- 不需要:真实大模型 Key、生产 API、生产凭据或真实业务数据。
|
|
@@ -32,7 +32,7 @@ curl -fsSL https://www.bailinghub.com/install.sh | sh
|
|
|
32
32
|
cd "$HOME/bailinghub"
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
脚本默认拉取 `v0.
|
|
35
|
+
脚本默认拉取 `v0.9.0` 官方镜像,生成随机 Token 与后台密码,启动服务并自动运行基础体检。首次管理员只在数据库管理员表为空时创建;对同一持久化数据库进行重启、升级、容器重建或重新安装,不会覆盖已经修改的管理员密码。可选 `/metrics` 端点默认关闭,不影响基础验证。请保留终端输出中的版本、安装模式、耗时和“常用命令”,但不要把密码或 Token 写入反馈。新安装 Docker 后,当前非 root 会话通常仍需使用脚本打印的 `sudo docker compose ...` 命令;重新登录后 Docker 组权限才可能生效。
|
|
36
36
|
|
|
37
37
|
如果默认目录已被占用,请使用一个新的空目录,不要覆盖现有部署:
|
|
38
38
|
|
|
@@ -46,7 +46,7 @@ cd "$HOME/bailinghub-validation"
|
|
|
46
46
|
### 路径 B:本地源码复现
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
git clone --depth 1 --branch v0.
|
|
49
|
+
git clone --depth 1 --branch v0.9.0 https://github.com/bailinghub/bailinghub.git
|
|
50
50
|
cd bailinghub
|
|
51
51
|
git rev-parse HEAD
|
|
52
52
|
export BAILING_TOKEN="$(openssl rand -hex 32)"
|
|
@@ -167,7 +167,7 @@ docker compose exec -T bailinghub npm run demo:e2e
|
|
|
167
167
|
- [可信富内容渲染与聊天可靠性](RELEASE_NOTES_v0.1.15.md)。
|
|
168
168
|
- [工具运行时收敛与语义检索韧性](RELEASE_NOTES_v0.1.16.md)。
|
|
169
169
|
- [可组合 Core 与 Kernel Host API v1](RELEASE_NOTES_v0.3.0.md)。
|
|
170
|
-
- [当前稳定版发布说明](RELEASE_NOTES_v0.
|
|
170
|
+
- [当前稳定版发布说明](RELEASE_NOTES_v0.9.0.md)。
|
|
171
171
|
|
|
172
172
|
扩展验证请在同一 Issue 模板中选择对应路径,并说明是否获得过维护者的直接帮助。
|
|
173
173
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Model services and plan billing
|
|
2
|
+
|
|
3
|
+
This optional lightweight model billing gateway is introduced in Core 0.9.0. Administrators configure provider connections, reference prices and plans, then grant them to accounts. Local agents continue to orchestrate reasoning, tool search, image generation and business actions. The Hub does not take over host orchestration or charge per user turn or task step. [简体中文](MODEL_BILLING.md).
|
|
4
|
+
|
|
5
|
+
## One plan, one allowance
|
|
6
|
+
|
|
7
|
+
For example, a monthly plan may sell for 300 USD and provide a 100 USD allowance with a 1.5 multiplier, two conversation models and one image tool. A request costing 0.20 USD at reference prices deducts 0.30 USD and leaves an actual allowance ratio of 99.70%. Summaries expose precise values and separate display strings; percentage display may round down. Models and tools share the allowance.
|
|
8
|
+
|
|
9
|
+
- **Periodic plans:** `priceUsd` is the sale price; explicit positive `periodAllowanceUsd` is the USD allowance per day, week or month. Customers see a percentage using that allowance as its denominator.
|
|
10
|
+
- **Credit packs:** `priceUsd` is the one-time USD allowance; `periodAllowanceUsd` is rejected. Customer Credits use a fixed 1000 Credits per USD with no separate credit ledger.
|
|
11
|
+
- `duration` controls validity separately from reset periods. A final partial period still receives the full allowance. Expiration stops new requests; unused allowance does not roll over. Daily, weekly and monthly periods retain the original grant time and UTC anchor. Payment, exchange rates, refunds and product pricing belong to the business application.
|
|
12
|
+
- `multiplier` applies uniformly across a plan; there are no separate model multipliers within it.
|
|
13
|
+
- Existing grants read the current plan service set and multiplier by plan ID. Price, allowance, period and validity are fixed when granted. Template price changes apply to future grants and do not reset active account balances.
|
|
14
|
+
- Removing a service does not remove allowance. Plans may have no available models and return an empty catalog. A plan still used by an effective grant requires its use relationship to be resolved before removal. Historical settlement evidence is retained.
|
|
15
|
+
|
|
16
|
+
Input, output and total Tokens remain raw usage fields for administration and history. They are neither allowance limits nor percentage denominators. Image services that provide no Tokens do not receive invented counts.
|
|
17
|
+
|
|
18
|
+
## Reference prices
|
|
19
|
+
|
|
20
|
+
The current reference source is OpenRouter's public model and image endpoint price catalog, bound to an exact `modelId + endpointId`. Actual calls use the administrator's credentials, URL and model identifier. A reference price does not represent another provider's paid price or invoice; operators must verify the mapping.
|
|
21
|
+
|
|
22
|
+
Access triggers a background refresh after the six-hour cache lifetime; administrators can also synchronize explicitly. A failed catalog fetch may retain an existing quote and expose its stale state. A successful refresh that identifies unsupported endpoint rules blocks new pricing requests rather than treating them as free. Each request saves its price and multiplier snapshot, so later changes never recalculate history.
|
|
23
|
+
|
|
24
|
+
Charge = actual provider metering × reference unit price × plan multiplier. Adapters map Token, image-count and supported image-pixel metering. Unreliable mappings keep `billing_state=pending` rather than guessing zero cost. An arbitrary provider `cost` field cannot replace the stored price snapshot.
|
|
25
|
+
|
|
26
|
+
Amounts use twelve-decimal fixed precision. Positive balances admit new requests and actual charges settle asynchronously; concurrency can create overage, which is recorded, while depleted balances block new requests. Settlement does not interrupt streaming, and an earlier pending settlement does not block every subsequent independent task.
|
|
27
|
+
|
|
28
|
+
## Models and tools
|
|
29
|
+
|
|
30
|
+
Services have `chat` or `tool` purpose:
|
|
31
|
+
|
|
32
|
+
- Conversation models populate the model picker; responses and streaming chunks return directly to the local host.
|
|
33
|
+
- Model tools have a separate catalog of names, purpose, parameters, output and callable state. Hosts inject and execute those tools.
|
|
34
|
+
- Initial executable adapters support text-to-image through Aliyun OpenAI Images-compatible, native DashScope and OpenRouter Images APIs. Requests persist dispatch evidence, return `202/pending` and finish asynchronously.
|
|
35
|
+
- Video, voice and custom capabilities may be declared. Without an execution adapter they have `callable=false`; declarations do not imply generation support.
|
|
36
|
+
- Image results are URL or Base64. Hosts may reuse the existing attachment space for durable or business use. Image generation does not automatically change business data.
|
|
37
|
+
|
|
38
|
+
Image adapters accept only declared, supported text-to-image parameters. An attachment reference cannot stand in for a provider-accessible URL. Aliyun has two explicit adapters: `aliyun-image` uses OpenAI Images compatibility and `aliyun-image-native` uses native DashScope. Credentials may use the standard service root, `/api/v1` or `/compatible-mode/v1`; the native adapter maps parameters to a fixed native path on the same origin. Errors never trigger an automatic protocol, region or model switch and retry.
|
|
39
|
+
|
|
40
|
+
## Client API
|
|
41
|
+
|
|
42
|
+
Discover `model_gateway.supported=true` in `GET /usage/v1/capabilities`. Its schema is `bailing.model-gateway.v1`, with `billing_unit=USD`, `orchestration=host` and `turn_required=false`.
|
|
43
|
+
|
|
44
|
+
| Endpoint | Purpose |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `GET /usage/v1/model/models` | Conversation models in the account's plan, using configured labels |
|
|
47
|
+
| `GET /usage/v1/model/tools` | Plan tool declarations and callable state |
|
|
48
|
+
| `GET /usage/v1/model/summary` | Remaining allowance, period and customer presentation |
|
|
49
|
+
| `POST /usage/v1/model/requests` | One conversation-model request |
|
|
50
|
+
| `POST /usage/v1/model/requests/stream` | Streaming using the same request contract |
|
|
51
|
+
| `POST /usage/v1/model/tools/requests` | `{operation_id,service_id,arguments,conversation_id?,turn_id?}` |
|
|
52
|
+
| `GET /usage/v1/model/requests/{operation_id}` | Read the original result without calling or generating again |
|
|
53
|
+
| `POST /usage/v1/model/requests/{operation_id}/cancel` | Cancel further result use while retaining incurred usage |
|
|
54
|
+
|
|
55
|
+
Persist the original `operation_id` locally. Missing responses, offline reopening and uncertain outcomes require querying the original request, never generating again with another ID. The same ID and content dispatch only once; different content with the same ID conflicts. New actions are distinct from recovery. Late usage after cancellation remains recorded and cannot resume a finished host turn.
|
|
56
|
+
|
|
57
|
+
Responses expose `result_state`, `billing_state`, `response`, raw `usage` (possibly absent), `raw_usage`, `reference_cost_usd`, `billed_usd` and `overage_usd`. `billing_rate` includes plan revision, multiplier and price snapshot. Results have bounded retention; `response_expired` does not authorize re-dispatch.
|
|
58
|
+
|
|
59
|
+
Trusted backends retain the existing identity-exchange entry point. `model_access: token_gateway` identifies plan-scoped credentials, not a legacy Token allowance mode; `service` remains restricted to one model. Identity, business authority, fixed session scope, approvals and business-call archives remain independent and are not expanded by a plan.
|
|
60
|
+
|
|
61
|
+
Console endpoints use `/admin/api/usage/billing/`. Business backends can use `/usage/v1/external/billing/plans` and `/accounts/{id}/summary|grant|control`, retaining source ownership, permissions and idempotent grants.
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
From public Core 0.8.0, apply added `063_usage_model_billing.sql` and `064_period_plan_allowance.sql` through the official migrator. Fresh installations apply all outstanding files. Normal upgrades retain real data and require no old-schema purge. Instances already running a 063 billing preview follow the [period allowance migration](PERIOD_ALLOWANCE_UPGRADE.en.md) for their original snapshots. There are no legacy Token allowance, per-turn or per-model-multiplier interfaces. Maintenance of abandoned development schemas is not a customer upgrade requirement and test-data cleanup is not part of public SQL. See the [v0.9.0 upgrade guide](UPGRADE_v0.9.0.en.md).
|
|
66
|
+
|
|
67
|
+
## Configuration readiness and discovery
|
|
68
|
+
|
|
69
|
+
A service being `active` is not sufficient to call it: executable services also need explicit reference-model/endpoint bindings and usable cached quotes. The console exposes `availability` with `state`, `code` and `message`, and validates the quote before saving an active executable service. A plan cannot newly select an unready service; existing selections can remain or be removed without recreating accounts or changing allowance. External provisioning can stage declarations, but staging never makes them callable.
|
|
70
|
+
|
|
71
|
+
Both `/usage/v1/model/models` and `/usage/v1/model/tools` return only ready entries in `items`. `unavailable_items` contains unavailable service IDs, labels, revisions and reasons within the current plan/credential scope, without provider credentials or tool schemas. The default conversation model is ready or `null`. Hosts must not automatically switch models or replay requests when a service becomes unavailable. Refresh the catalog after configuration is fixed; no reauthorization or allowance reset is required. Existing SDKs pass these additive fields through; `items` alone is sufficient for a safe picker and callable registry.
|
|
72
|
+
|
|
73
|
+
- `USAGE_PRICE_NOT_CONFIGURED`: missing or invalid reference binding.
|
|
74
|
+
- `USAGE_PRICE_UNAVAILABLE`: no synchronized quote, or the fixed endpoint disappeared.
|
|
75
|
+
- `USAGE_PRICE_UNSUPPORTED`: unsupported endpoint metering rules.
|
|
76
|
+
- `MODEL_TOOL_ADAPTER_NOT_READY`: declaration only, without an execution adapter.
|
|
77
|
+
|
|
78
|
+
Configuration failures precede admission or provider dispatch and use `next_action=contact_operator`, not automatic retry. Discovery uses the same cached quote as admission and neither generates content nor waits for remote price lookup. A valid stale quote can remain usable during a catalog outage with a background refresh. Readiness does not guarantee provider availability or complete metering; missing actual usage remains pending settlement, never an invented fee.
|
|
79
|
+
|
|
80
|
+
## Generation and billing states are separate
|
|
81
|
+
|
|
82
|
+
- `result_state=pending`: work is ongoing; query the original ID without another generation.
|
|
83
|
+
- `complete`: use the result immediately even if `billing_state=pending`; settlement does not block it.
|
|
84
|
+
- `failed`: confirmed rejection, such as an absent API, invalid parameters or denied access. `dispatch=rejected`; stop waiting and show the safe error without automatic resubmission. Confirmed rejection without generation closes with zero charge.
|
|
85
|
+
- `unknown`: a disconnect, server error or incomplete result leaves execution uncertain. Stop the generating indicator and retain the ID for inspection; do not change ID or endpoint and retry. Other independent requests remain possible.
|
|
86
|
+
- `cancelled`: remain cancelled; late results and charges do not re-enable a tool or resume a finished turn.
|
|
87
|
+
|
|
88
|
+
Failure `error` contains only `code`, fixed safe `message`, optional `http_status / provider_code / provider_request_id`, `retryable=false` and `next_action`. Provider raw error bodies, prompts, secrets and URLs are not stored or returned as errors. HTTP 408, 409 and 5xx do not prove non-execution.
|
|
89
|
+
|
|
90
|
+
Hub asynchronous admission and provider task protocols are separate. Current native/compatible image adapters perform one provider request in the background; original-ID lookup reads persisted results. Without a provider task ID, provider-task recovery must not be claimed. Historical unknown outcomes are not guessed into failure; original evidence and price snapshots remain.
|
|
91
|
+
|
|
92
|
+
## Removing plans and retaining history
|
|
93
|
+
|
|
94
|
+
Plans are soft-deleted with their original IDs. Removal checks active, unexpired grants currently referenced by active accounts, including future-start grants. Older grants, expired grants, disabled accounts and suspended grants do not prevent removal. Suspending a template stops new grants without terminating existing ones.
|
|
95
|
+
|
|
96
|
+
Historical grants, pools, ledger and request snapshots remain. Already-dispatched requests recover and settle against their original snapshots without moving to a new plan or re-dispatching. Restoring an account does not restore a removed plan; renewed use requires a valid grant.
|
|
97
|
+
|
|
98
|
+
## Archiving and restoring accounts
|
|
99
|
+
|
|
100
|
+
Disabled personal and shared organization accounts can be archived. Default lists hide them while retaining the original account ID, trusted identity, member states, grants, allowance, requests and ledger associations. History does not block archiving; integrity problems must be repaired first. Source account scopes remain unchanged but cannot use archived accounts.
|
|
101
|
+
|
|
102
|
+
Archiving revokes existing usage credentials and blocks new requests, grants and membership/account-state changes. Already-dispatched requests still save results and settle idempotently under original snapshots. Logging in again under the same identity does not create a replacement account or replenish allowance.
|
|
103
|
+
|
|
104
|
+
Administrators restore an original account from Accounts and Members → Archived. Restoration returns it to disabled state, does not restore revoked members or credentials and does not reset allowance. Re-enable and log in again to use it; a removed or expired plan requires a valid grant. The legacy `deleted` marker is not revived through restoration.
|
|
105
|
+
|
|
106
|
+
- List: `GET /admin/api/usage/accounts?view=current|archived`, default `current`, with existing pagination. Client account lists omit archived accounts.
|
|
107
|
+
- Archive: existing `DELETE /admin/api/usage/accounts/:id` and preview, requiring a disabled account, current revision and `request_key`.
|
|
108
|
+
- Restore: `POST /admin/api/usage/accounts/:id/restore` with `expected_revision` and `request_key`, requiring administrator `usage:write`.
|
|
109
|
+
- Both operations replay the original receipt idempotently without overriding later management decisions.
|
|
110
|
+
|
|
111
|
+
These administration changes add no tables or SQL migration and independently require no SDK/DSH changes.
|
|
112
|
+
|
|
113
|
+
## Manually resetting one account's allowance
|
|
114
|
+
|
|
115
|
+
Under Account Usage → Usage Details → Reset Allowance, administrators with `usage:write` and `usage:adjust` can reset an active account's effective Hub-managed plan. A periodic plan regains its original period allowance (100%) and starts a new period at the server-confirmed reset time. A credit pack regains original Credits without an automatic reset date. Remaining balances do not stack and expiration is not extended. If expiration ends the final period first, no later reset date is shown.
|
|
116
|
+
|
|
117
|
+
- `POST /admin/api/usage/billing/accounts/:id/reset` requires `request_key` and the current grant's `expected_revision`.
|
|
118
|
+
- Future, expired or suspended grants and disabled/archived accounts cannot reset. Backend-managed allowance must be adjusted by its owning source.
|
|
119
|
+
- A new current grant reuses the existing allowance terms and pool mechanism. Template price changes do not change its restored amount; service selection and the current multiplier keep their existing rules.
|
|
120
|
+
- Original grants, requests, usage and ledger remain. Late results from already-dispatched requests settle against the original pool without charging the new allowance. Undispatched old requests retain their original grant-revision checks and do not automatically re-dispatch.
|
|
121
|
+
- Idempotent replay returns the original receipt. Revision checks prevent duplicate concurrent resets. The receipt records `reset.previousGrantId`, `reset.actor` and `reset.at` to identify the original grant and operator.
|
|
122
|
+
|
|
123
|
+
Existing summaries return the new balance and next reset date. This feature adds no SQL migration and independently requires no SDK/DSH or backend changes.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# 模型服务与套餐计费
|
|
2
|
+
|
|
3
|
+
本模块为可选的微型模型计费网关,从 Core 0.9.0 提供。[English](MODEL_BILLING.en.md)。管理员添加模型连接、选择参考价格,创建套餐并开通给账户;本地智能体继续决定如何思考、搜索工具、生成图片及执行业务动作。中枢不接管客户端编排,也不按用户轮次或任务步数扣费。
|
|
4
|
+
|
|
5
|
+
## 一个套餐,一份额度
|
|
6
|
+
|
|
7
|
+
例如,为团队开通一个售价 300 USD、每月额度 100 USD 的套餐,统一倍率为 1.5,勾选两个对话模型及一个图片工具。一次模型请求的参考费用为 0.20 USD,则套餐扣除 0.30 USD,实际剩余额度占比为 99.70%。摘要同时提供精确数值与用于界面的显示字符串;百分比显示可向下取整。不同模型和工具共用这份额度。
|
|
8
|
+
|
|
9
|
+
- **周期套餐**:`priceUsd` 是售价,`periodAllowanceUsd` 必须明确填写且大于零,是每个重置周期可用的美元额度;周期可为日、周、月。客户显示剩余百分比,分母为周期额度。
|
|
10
|
+
- **额度包**:`priceUsd` 是一次开通的美元额度,不接受 `periodAllowanceUsd`。客户显示积分,固定 1 USD = 1000 积分,无独立积分账本。
|
|
11
|
+
- `duration` 决定开通有效期,与重置周期分开;最后不足一个完整周期仍提供完整周期额度,到期停止,未用额度不结转。日、周、月继续按原开通时间及 UTC 锚点重置。支付、汇率、退款及商品定价归接入方负责。
|
|
12
|
+
- `multiplier` 是套餐统一倍率,不能为同一个套餐的不同模型配置另一套倍率。
|
|
13
|
+
- 已开通账户按套餐 ID 读取当前模型集合与倍率;售价、周期额度、周期和有效期在开通时固定。修改套餐金额用于以后开通,不会重置正在使用的账户余额。
|
|
14
|
+
- 删除套餐内某个模型不会删除账户额度。允许套餐没有可用模型,此时客户目录为空;删除套餐本身须先解除当前使用关系。已有真实结算的历史记录保留审计证据。
|
|
15
|
+
|
|
16
|
+
输入、输出和总 Token 数仍是原始用量字段,可供后台和使用明细查看;它们不是额度上限或百分比分母。没有提供 Token 的生图服务不伪造 Token 值。
|
|
17
|
+
|
|
18
|
+
## 参考价格
|
|
19
|
+
|
|
20
|
+
当前参考来源为 OpenRouter 的公开模型及图片端点价格目录,绑定精确 `modelId + endpointId`。实际模型调用仍使用管理员配置的模型凭证、URL 与型号。参考价格不表示其他服务商的实际账单,管理员应核对模型对应关系。
|
|
21
|
+
|
|
22
|
+
价格缓存六小时后由访问触发后台刷新,管理员也可以主动同步。暂时拉取失败时可使用已存价格并显示过期状态;成功刷新明确发现该端点规则不支持时拒绝新的计价请求,不能当作免费。每个请求保存自己的价格与套餐倍率快照;后来调价不会重算旧请求。
|
|
23
|
+
|
|
24
|
+
费用 = 供应商返回的实际计量 × 参考单价 × 套餐倍率。Token 单价、图片数量和支持的图片像素计价由适配器映射;无法可靠对应的计量保持 `billing_state=pending`,不会猜测零成本。供应商响应里的任意 `cost` 字段不能覆盖已保存的价格快照。
|
|
25
|
+
|
|
26
|
+
内部采用十二位小数定点金额。余额为正时允许新请求,实际费用异步结算;并发请求可能带来小额超出,记录超出金额并阻止余额耗尽后的新请求。不会为了实时结算打断正在输出的内容,也不会因上一笔待核算而禁止全部后续任务。
|
|
27
|
+
|
|
28
|
+
## 模型与工具
|
|
29
|
+
|
|
30
|
+
模型服务用途分为 `chat` 与 `tool`:
|
|
31
|
+
|
|
32
|
+
- 对话模型进入模型选择器,模型响应和流式片段直接交回本地宿主。
|
|
33
|
+
- 模型工具进入独立工具目录,包含名称、用途、参数、输出及可调用状态,由宿主注入并执行。
|
|
34
|
+
- 首批执行适配为阿里云 OpenAI Images 兼容接口、DashScope 原生接口及 OpenRouter Images 接口的文生图。图片请求先保存派发记录,返回 `202/pending` 后异步完成。
|
|
35
|
+
- 视频、语音及自定义能力可以保存声明,尚无执行适配时明确 `callable=false`;声明不代表已支持生成。
|
|
36
|
+
- 图片结果为 URL 或 Base64。若要长期使用或写入业务系统,宿主按需复用已有附件空间。生成图片不会自动修改商品或其他业务数据。
|
|
37
|
+
|
|
38
|
+
当前图片适配只接受已声明并受支持的文生图参数。附件引用不能冒充供应商可访问的文件地址。阿里云提供两个显式适配:`aliyun-image` 使用 OpenAI Images 兼容协议,`aliyun-image-native` 使用 DashScope 原生协议。同一凭据可配置为标准服务根地址、`/api/v1` 或 `/compatible-mode/v1`;原生适配在同一 origin 下使用固定的原生路径,将文生图参数转换为该协议。不会遇到错误就自动切换协议、地区或模型重试。
|
|
39
|
+
|
|
40
|
+
## 客户端接口
|
|
41
|
+
|
|
42
|
+
`GET /usage/v1/capabilities` 的 `model_gateway.supported=true` 为接入入口,schema 为 `bailing.model-gateway.v1`,`billing_unit=USD`、`orchestration=host`、`turn_required=false`。
|
|
43
|
+
|
|
44
|
+
| 接口 | 用途 |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `GET /usage/v1/model/models` | 当前账户套餐中的对话模型;显示管理员配置的 label |
|
|
47
|
+
| `GET /usage/v1/model/tools` | 当前账户套餐中的工具声明、可调用状态 |
|
|
48
|
+
| `GET /usage/v1/model/summary` | 剩余金额、周期及客户展示 presentation |
|
|
49
|
+
| `POST /usage/v1/model/requests` | 单次对话模型请求 |
|
|
50
|
+
| `POST /usage/v1/model/requests/stream` | 同一协议的流式请求 |
|
|
51
|
+
| `POST /usage/v1/model/tools/requests` | `{operation_id,service_id,arguments,conversation_id?,turn_id?}` |
|
|
52
|
+
| `GET /usage/v1/model/requests/{operation_id}` | 查原结果,不重新调用模型或生成工具 |
|
|
53
|
+
| `POST /usage/v1/model/requests/{operation_id}/cancel` | 取消继续使用结果;保留已发生用量 |
|
|
54
|
+
|
|
55
|
+
所有请求在本地持久保存原 `operation_id`。丢失回包、断网重开、结果不确定时只查询原请求,不能换 ID 重发生成。相同 ID、相同内容只派发一次;相同 ID 不同内容明确冲突。新动作和原调用恢复严格区分。取消的晚返回仍记录用量,不恢复已结束的本地轮次。
|
|
56
|
+
|
|
57
|
+
响应分别提供 `result_state`、`billing_state`、`response`、原始 `usage`(可为空)、`raw_usage`、`reference_cost_usd`、`billed_usd`、`overage_usd`。`billing_rate` 包含套餐修订、统一倍率和参考价格快照。`response` 有限期保存,过期返回 `response_expired`,不能因此重发原操作。
|
|
58
|
+
|
|
59
|
+
可信业务后端使用原身份交换接口。`model_access: token_gateway` 是套餐范围凭证的身份标记,不是旧 Token 额度模式;`service` 仍严格限制单个模型。身份、原业务授权、固定会话范围、审批和业务调用归档独立存在,不因套餐扩大授权。
|
|
60
|
+
|
|
61
|
+
后台接口统一 `/admin/api/usage/billing/`;业务后端可使用 `/usage/v1/external/billing/plans` 及 `/accounts/{id}/summary|grant|control`,沿用来源所有权、权限和幂等开通规则。
|
|
62
|
+
|
|
63
|
+
## 安装边界
|
|
64
|
+
|
|
65
|
+
从公开 Core 0.8.0 升级时,通过正式迁移器应用新增的 `063_usage_model_billing.sql` 及 `064_period_plan_allowance.sql`;首次安装应用全部未执行文件。正常升级保留真实数据,无需清退旧结构。已经部署过 063 计费预览的实例按[周期额度升级说明](PERIOD_ALLOWANCE_UPGRADE.md)转换各自原快照。模块不提供旧 Token 额度、按轮收费或逐模型倍率接口。废弃开发结构的维护不属于客户升级要求,不将测试数据清理混入公共 SQL。参见 [v0.9.0 升级指南](UPGRADE_v0.9.0.md)。
|
|
66
|
+
|
|
67
|
+
参考文档:[OpenRouter 图片接口](https://openrouter.ai/docs/guides/overview/multimodal/image-generation)、[阿里云图片接口](https://help.aliyun.com/zh/model-studio/qwen-image-generation-and-editing-api-reference)。
|
|
68
|
+
|
|
69
|
+
## 配置就绪与能力发现
|
|
70
|
+
|
|
71
|
+
服务状态为 `active` 不代表已经可调用:可执行服务还必须明确绑定参考模型与端点,并具有可用缓存报价。控制台服务列表的 `availability` 返回 `state`、`code` 和 `message`;保存启用的可执行服务前会验证报价。套餐不能新增选择未就绪服务,已有选择可以保留或移除,无需重建账户或改变额度。外部开通流程可以暂存声明,暂存服务不会因此变为可调用。
|
|
72
|
+
|
|
73
|
+
`/usage/v1/model/models` 与 `/usage/v1/model/tools` 的 `items` 只返回就绪项目。`unavailable_items` 提供当前套餐/凭证范围内未就绪服务的 ID、名称、修订和原因,不包含供应商凭据或工具 schema。默认对话模型必须是就绪项,否则为 `null`。选中模型不可用时,宿主不能自动切换模型或重放失败请求;管理员修复配置后刷新目录即可,无需重新授权或重置额度。旧 SDK 会传递这些新增字段;仅使用 `items` 也能构建安全的选择器与可调用工具目录。
|
|
74
|
+
|
|
75
|
+
- `USAGE_PRICE_NOT_CONFIGURED`:参考绑定缺失或不合法。
|
|
76
|
+
- `USAGE_PRICE_UNAVAILABLE`:无同步报价,或固定端点已消失。
|
|
77
|
+
- `USAGE_PRICE_UNSUPPORTED`:端点计量规则尚不支持。
|
|
78
|
+
- `MODEL_TOOL_ADAPTER_NOT_READY`:只有声明,没有执行适配。
|
|
79
|
+
|
|
80
|
+
这些配置错误发生在准入或供应商派发前,使用 `next_action=contact_operator`,不能自动重试。目录检查与准入使用同一缓存报价,不生成内容,也不等待远程价格查询。价格目录暂时不可用时,合法的过期报价仍可使用,并触发后台刷新。就绪不保证供应商可用性或完整计量回执;缺少实际用量仍待结算,不编造费用。
|
|
81
|
+
|
|
82
|
+
## 生成结果与计费状态分开
|
|
83
|
+
|
|
84
|
+
- `result_state=pending`:供应商请求仍在进行,宿主按原 ID 查询,不发起第二次生成。
|
|
85
|
+
- `complete`:立即使用图片,即使 `billing_state=pending`;结算不阻塞结果。
|
|
86
|
+
- `failed`:已获得明确拒绝(例如不存在的接口、无效参数、权限拒绝),`dispatch=rejected`,停止等待,显示安全错误;不自动重发。当前已确认拒绝无生成的请求以零扣费关闭。
|
|
87
|
+
- `unknown`:连接断开、服务器错误或无法解析完整结果,执行结果确实不确定。停止“正在生成”的展示,保留原 ID 供核对;不能自动换 ID 或切接口重发。不阻塞其他独立模型请求。
|
|
88
|
+
- `cancelled`:维持取消;晚到的结果和费用不重新启用宿主工具或恢复已结束轮次。
|
|
89
|
+
|
|
90
|
+
失败回执的 `error` 仅包含 `code`、固定安全文案 `message`、可选的 `http_status / provider_code / provider_request_id`、`retryable=false` 及 `next_action`。不保存或返回供应商原始错误正文、提示词、密钥或地址。HTTP 408、409 与 5xx 不等于已证明没有执行。
|
|
91
|
+
|
|
92
|
+
中枢异步受理与供应商异步任务协议是不同层次:当前原生/兼容图片适配都是单次供应商请求在后台完成;原 ID 查询只读取已持久化结果。没有供应商任务 ID 时不能宣称已具备供应商任务恢复。历史 unknown 不因本次修复被猜测改成失败。原记录和原价格快照保留。
|
|
93
|
+
|
|
94
|
+
## 套餐移除与历史记录
|
|
95
|
+
|
|
96
|
+
删除套餐采用保留原标识的软删除。只检查启用账户当前指向的、启用且未到期的开通记录(包括待生效记录);旧开通、已到期、已停用账户或已暂停开通不阻止移除。停用套餐模板仅停止新开通,不会终止现有账户的套餐。
|
|
97
|
+
|
|
98
|
+
历史开通、原额度池、账本与请求快照继续保留。已派发原请求仍按原快照恢复和结算,不转移到新套餐或再次派发。恢复账户身份不会恢复已删除的套餐;重新使用需开通有效套餐。
|
|
99
|
+
|
|
100
|
+
## 账户移除与恢复
|
|
101
|
+
|
|
102
|
+
个人账户和组织共享账户均可在停用后移除(`archived`)。默认列表隐藏,原账户 ID、可信身份、成员状态、套餐开通、额度、请求及账本保持原关联。已有历史不阻止移除,完整性异常须先修复。来源配置中的账户范围保持不变,但不能使用已移除账户。
|
|
103
|
+
|
|
104
|
+
移除撤销该账户现有使用凭证,阻止新请求、套餐开通、成员及账户状态修改。已派发请求仍按原快照保存结果并幂等结算。同一身份再次登录不会创建替代账户或补发额度。
|
|
105
|
+
|
|
106
|
+
管理员在“账户与成员 → 已移除”查看并恢复原账户。恢复只改为停用状态,不恢复被撤销的成员或旧凭证,不重置额度。需要使用时再启用并重新登录;若原套餐已删除或到期,需开通有效套餐。原 `deleted` 删除标记不通过恢复接口复活。
|
|
107
|
+
|
|
108
|
+
- 管理列表:`GET /admin/api/usage/accounts?view=current|archived`,默认 `current`,支持原分页参数。客户端账户列表不包含已移除账户。
|
|
109
|
+
- 移除:沿用 `DELETE /admin/api/usage/accounts/:id` 及预览接口,要求账户停用、当前修订与 `request_key`。
|
|
110
|
+
- 恢复:`POST /admin/api/usage/accounts/:id/restore`,请求含 `expected_revision`、`request_key`,要求管理员 `usage:write`。
|
|
111
|
+
- 两项变更均按原请求幂等;旧回执重试不覆盖后续管理决定。
|
|
112
|
+
|
|
113
|
+
不新增表或 SQL 迁移;SDK/DSH 无需调整。
|
|
114
|
+
|
|
115
|
+
## 单账户手动重置额度
|
|
116
|
+
|
|
117
|
+
控制台“账户用量 → 用量详情 → 重置额度”允许有 `usage:write` 与 `usage:adjust` 权限的管理员,为启用账户重置中枢维护的当前有效套餐。周期套餐恢复至原开通记录的周期额度(100%),从服务端确认重置的时刻重新起算周期;额度包恢复至原始积分,无自动重置时间。剩余额度不叠加,套餐到期时间不延长。最后一个周期若先到期,仍以到期时间结束,不显示到期后的下次重置时间。
|
|
118
|
+
|
|
119
|
+
- `POST /admin/api/usage/billing/accounts/:id/reset`,请求为 `request_key` 与当前开通记录的 `expected_revision`。
|
|
120
|
+
- 原套餐未生效、已到期、已暂停,或账户停用/移除时不能重置。业务后端维护的额度由原来源调整。
|
|
121
|
+
- 复用已有开通快照与额度池,创建新的当前开通记录;复制原额度条款,不因套餐模板后来改价而改变本次满额值。原模型目录和当前套餐倍率继续遵循既有规则。
|
|
122
|
+
- 原开通、请求、计量和账本保留;已派发请求晚到的结果仍归原额度池结算,不扣新额度。尚未派发的旧请求继续遵循原开通修订校验,不自动重新派发。
|
|
123
|
+
- 原请求幂等重试只返回原回执;并发变更通过修订号检查,避免重复重置。变更回执记录 `reset.previousGrantId`、`reset.actor`、`reset.at`,可关联原开通与操作人。
|
|
124
|
+
|
|
125
|
+
沿用现有摘要接口返回新的剩余额度及下次重置时间,不新增 SQL 迁移,不需要客户端 SDK/DSH 或业务后端改造。
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Separating periodic plan price from allowance
|
|
2
|
+
|
|
3
|
+
This guide applies to Core 0.9.0 and explains periodic allowance terms and migration of existing billing snapshots. Public Core 0.8.0 did not include this billing module. Its normal upgrade adds 063/064 through the official migrator and requires no real-data purge. See the [v0.9.0 upgrade guide](UPGRADE_v0.9.0.en.md).
|
|
4
|
+
|
|
5
|
+
## Period allowance contract
|
|
6
|
+
|
|
7
|
+
Periodic plans require both `priceUsd > 0` (sale price) and `periodAllowanceUsd > 0` (USD available per period), with at most twelve decimal places and a maximum of 1,000,000,000. Credit packs continue to use `priceUsd` as allowance and reject `periodAllowanceUsd`. Unknown fields remain rejected. There is no fallback to sale price, legacy field alias, turn limit or request-count limit.
|
|
8
|
+
|
|
9
|
+
For example, a weekly plan selling for 100 USD with a 20 USD allowance has 10 USD / 50% remaining after a 10 USD charge and regains 20 USD in the next week. A final partial week still receives the full allowance; expiration blocks new requests. Late settlement belongs to the original period, with its original multiplier, price and pool. Template edits affect future grant terms and do not automatically re-grant existing accounts.
|
|
10
|
+
|
|
11
|
+
`GET /admin/api/usage/billing/plans` provides `period_allowance_supported: true`. Without this marker, the frontend may preview the field but cannot save periodic plans. The marker describes code capability, not proof of database migration; verify the migration ledger and billing-structure readiness as well.
|
|
12
|
+
|
|
13
|
+
## Instances that already deployed a billing preview
|
|
14
|
+
|
|
15
|
+
These data checks apply only when 063 billing data already exists and periodic snapshots lack the new field. Separate cleanup of abandoned test schemas is outside this process and must not be applied to real customer data.
|
|
16
|
+
|
|
17
|
+
1. Coordinate all Core instances, frontends and plan writers sharing the state database on the new contract. Back up billing tables and migration ledger and retain previous artifacts. Stop old-version writes, including maintenance settlement and backend grant/control calls. Retain original IDs and evidence for dispatched requests; do not dispatch replacements.
|
|
18
|
+
2. Apply the outstanding `064_period_plan_allowance.sql` through the official Core schema migrator (`npm run db:init` for source installations), keeping its ledger and checksum checks.
|
|
19
|
+
3. Each periodic record missing the field receives its own original `priceUsd`, not the current template price. This covers plan `config_json`, grant snapshot `config_json`, request `grant_json` and grant/control replay `result_json.config`, including history. Original allowance semantics and cached request hashes remain unchanged. Explicit new allowances are never overwritten; credit packs are untouched. Original pools, ledger, charges, revisions and expiration are not rewritten.
|
|
20
|
+
4. Confirm positive new fields in all four periodic JSON forms and no new field on credit packs. Compare record counts, original prices, pool allowances and ledger amounts. Start the new Core and UI, then check capability discovery, historical summaries, original-ID lookup and idempotent replay. Runtime does not infer missing fields; do not start it expecting automatic compatibility.
|
|
21
|
+
5. Edit templates explicitly for later price or allowance changes. New terms apply to future grants; template edits are not migration of original grants. Use the normal provisioning flow if a new grant is needed.
|
|
22
|
+
|
|
23
|
+
The SQL converts only missing fields and retains explicit allowances. After interruption, keep writers stopped until the official migrator completes and checks pass. Do not manually change the migration ledger or replay recorded files.
|
|
24
|
+
|
|
25
|
+
## Rollback and verification
|
|
26
|
+
|
|
27
|
+
Once the new fields exist, old Core's strict validation cannot read those configurations. Rollback requires stopped writers and coordinated backup/artifact restoration. If new requests or charges exist, retain them and repair forward instead of discarding the ledger through an older backup.
|
|
28
|
+
|
|
29
|
+
Check positive values and precision, rejection of periodic fields on credits, percentage calculations, month-end rules, independence of template edits and original snapshots, period renewal, late original-period settlement, final partial periods and expiration. Migration checks include differing template/grant amounts, original-request settlement, replay of original idempotency keys and preservation of explicit new allowances.
|
|
30
|
+
|
|
31
|
+
[Model billing contract](MODEL_BILLING.en.md) · [简体中文](PERIOD_ALLOWANCE_UPGRADE.md)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# 周期套餐售价与额度拆分
|
|
2
|
+
|
|
3
|
+
本说明适用于 Core 0.9.0,解释周期额度契约及已存在计费快照的迁移。公开 Core 0.8.0 尚无此计费模块,正常升级通过正式迁移器新增 063/064,不要求清退真实数据。完整步骤见 [v0.9.0 升级指南](UPGRADE_v0.9.0.md)。
|
|
4
|
+
|
|
5
|
+
## 周期额度契约
|
|
6
|
+
|
|
7
|
+
周期套餐需同时提供 `priceUsd > 0`(售价)与 `periodAllowanceUsd > 0`(每周期 USD 额度),金额最多十二位小数、上限 1,000,000,000。额度包继续以 `priceUsd` 提供额度,拒绝 `periodAllowanceUsd`。未知字段继续拒绝,无售价回落、旧字段别名、轮次或请求次数限制。
|
|
8
|
+
|
|
9
|
+
例如周套餐售价 100 USD、周期额度 20 USD,结算 10 USD 后剩余 10 USD / 50%;跨周重新获得 20 USD。有效期最后不足一周仍获得完整 20 USD,到期后停止新请求。原请求的晚结算归入原周期,原倍率、参考价格和额度池保持不变。套餐编辑只影响后续开通的额度条款,原账户不自动重新开通。
|
|
10
|
+
|
|
11
|
+
`GET /admin/api/usage/billing/plans` 提供 `period_allowance_supported: true`。旧 Core 不返回此标记时,前端只能预览周期额度,不能保存周期套餐。该标记表示代码能力,不能单独证明数据库已迁移;应同时核对迁移账本和计费结构就绪状态。
|
|
12
|
+
|
|
13
|
+
## 已部署计费预览实例的迁移
|
|
14
|
+
|
|
15
|
+
仅在实例已经存在 063 计费数据且周期快照缺少新字段时,需要以下数据核对。废弃测试结构的独立清理不属于本升级流程,不能用于真实客户数据。
|
|
16
|
+
|
|
17
|
+
1. 确认所有共用状态库的 Core、前端及套餐配置调用方采用新契约。备份计费表与迁移账本,保留旧产物;停止旧版本写入,包括维护结算及业务侧开通/控制请求。已派发请求保留原 ID 与证据,不能重派。
|
|
18
|
+
2. 使用官方 Core schema migrator(源码入口 `npm run db:init`)执行未应用的 `064_period_plan_allowance.sql`,按原迁移账本和摘要规则处理。
|
|
19
|
+
3. 迁移为每条缺少新字段的周期记录写入其自身旧 `priceUsd`,不是当前套餐售价。范围为套餐 `config_json`、开通快照 `config_json`、原请求 `grant_json`、开通/控制幂等缓存 `result_json.config`,包括历史记录。原历史额度语义和缓存请求哈希不变;已有明确新额度不覆盖,credits 不修改。原额度池、账本、扣费、修订和有效期均不重写。
|
|
20
|
+
4. 核对四类周期 JSON 均有合法正数新字段、credits 无新字段。比较迁移前后记录数、原价格、原池额度和账本金额;启动新 Core 与配套界面,验收能力位、历史摘要、原 ID 查询与幂等重放。运行时不会推断缺失字段,不能先启新版本再等待自动兼容。
|
|
21
|
+
5. 后续调整售价或周期额度时显式编辑套餐;新条款用于以后开通,不能把模板编辑当作原开通迁移。需要重新开通时按正常开通流程处理。
|
|
22
|
+
|
|
23
|
+
SQL 只转换缺字段记录,不覆盖已有明确额度;中断后保持停写,按正式迁移器完成剩余步骤并核对后再恢复使用。不要手工修改迁移账本或重跑已记账文件。
|
|
24
|
+
|
|
25
|
+
## 回退与验证
|
|
26
|
+
|
|
27
|
+
新字段写入后,旧 Core 的严格校验不能读取新配置。回退需要停写并协调备份和旧产物;如已发生新请求或计费,保留新记录并修复,不能直接恢复旧备份丢弃账本。
|
|
28
|
+
|
|
29
|
+
检查显式正数与金额精度、credits 拒收周期字段、周期百分比、月末规则、模板编辑与原快照独立、跨周期恢复、原周期晚结算以及最后短周期和到期行为。迁移核对包括模板与原开通金额不同、原请求结算、原幂等键重放及已有新额度不覆盖。
|
|
30
|
+
|
|
31
|
+
[模型计费契约](MODEL_BILLING.md) · [English](PERIOD_ALLOWANCE_UPGRADE.en.md)
|
package/docs/README.en.md
CHANGED
|
@@ -6,6 +6,10 @@ This directory contains public documentation for the open-source BailingHub proj
|
|
|
6
6
|
|
|
7
7
|
| Document | Purpose |
|
|
8
8
|
|---|---|
|
|
9
|
+
| [RELEASE_NOTES_v0.9.0.en.md](RELEASE_NOTES_v0.9.0.en.md) · [Chinese](RELEASE_NOTES_v0.9.0.md) | v0.9.0: optional model billing, shared allowances and image tools. |
|
|
10
|
+
| [UPGRADE_v0.9.0.en.md](UPGRADE_v0.9.0.en.md) · [Chinese](UPGRADE_v0.9.0.md) | Upgrade from public 0.8.0, migrations 063/064 and optional host integration. |
|
|
11
|
+
| [MODEL_BILLING.en.md](MODEL_BILLING.en.md) · [Chinese](MODEL_BILLING.md) | Models/tools, reference prices, asynchronous settlement, archive and allowance reset contract. |
|
|
12
|
+
| [PERIOD_ALLOWANCE_UPGRADE.en.md](PERIOD_ALLOWANCE_UPGRADE.en.md) · [Chinese](PERIOD_ALLOWANCE_UPGRADE.md) | Separate periodic price/allowance and migrate existing preview snapshots. |
|
|
9
13
|
| [RELEASE_NOTES_v0.8.0.md](RELEASE_NOTES_v0.8.0.md) · [English](RELEASE_NOTES_v0.8.0.en.md) | v0.8.0: long tasks, original receipts, attachments and upgrade boundaries. |
|
|
10
14
|
| [RELEASE_NOTES_v0.7.0.md](RELEASE_NOTES_v0.7.0.md) · [English](RELEASE_NOTES_v0.7.0.en.md) | v0.7.0 shop/inventory scenarios, upgrade steps and limits. |
|
|
11
15
|
| [user-guide/conversations.en.md](user-guide/conversations.en.md) | Multi-account conversations, full-text review and offline recovery for users. |
|
|
@@ -22,7 +26,7 @@ This directory contains public documentation for the open-source BailingHub proj
|
|
|
22
26
|
| [AGENT_SUBJECT_DISPLAY.en.md](AGENT_SUBJECT_DISPLAY.en.md) | Business authorization display names: responsibilities, new approvals and existing-session synchronization. |
|
|
23
27
|
| [AGENT_AUTH_API.en.md](AGENT_AUTH_API.en.md) | Agent Auth v1, PKCE, trusted business identity, and revocation. |
|
|
24
28
|
| [AGENT_AUTH_API.md](AGENT_AUTH_API.md) | Chinese Agent Auth v1 protocol. |
|
|
25
|
-
| [INVOCATION_RECEIPTS.md](INVOCATION_RECEIPTS.md) |
|
|
29
|
+
| [INVOCATION_RECEIPTS.md](INVOCATION_RECEIPTS.md) | Read an original receipt without continuing its business operation. |
|
|
26
30
|
| [AGENT_CLIENT_RUNTIME_API.en.md](AGENT_CLIENT_RUNTIME_API.en.md) | Agent Client Runtime v1 workspaces, turns, tools, and completion contract. |
|
|
27
31
|
| [AGENT_TASK_CONTROL.en.md](AGENT_TASK_CONTROL.en.md) · [Chinese](AGENT_TASK_CONTROL.md) | Core 0.8.0: cumulative task budgets, actual dispatch, pause and SDK/DSH host integration. |
|
|
28
32
|
| [AGENT_CLIENT_RUNTIME_API.md](AGENT_CLIENT_RUNTIME_API.md) | Chinese Agent Client Runtime v1 contract. |
|
package/docs/README.md
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
| 文档 | 用途 |
|
|
10
10
|
|---|---|
|
|
11
|
+
| [RELEASE_NOTES_v0.9.0.md](RELEASE_NOTES_v0.9.0.md) · [English](RELEASE_NOTES_v0.9.0.en.md) | v0.9.0:可选模型计费、统一套餐额度与文生图工具。 |
|
|
12
|
+
| [UPGRADE_v0.9.0.md](UPGRADE_v0.9.0.md) · [English](UPGRADE_v0.9.0.en.md) | 从公开 0.8.0 升级、063/064 迁移及宿主按需接入。 |
|
|
13
|
+
| [MODEL_BILLING.md](MODEL_BILLING.md) · [English](MODEL_BILLING.en.md) | 模型与工具、参考价格、异步结算、账户归档和额度重置契约。 |
|
|
14
|
+
| [PERIOD_ALLOWANCE_UPGRADE.md](PERIOD_ALLOWANCE_UPGRADE.md) · [English](PERIOD_ALLOWANCE_UPGRADE.en.md) | 周期售价与额度拆分,以及已有计费预览快照的迁移。 |
|
|
11
15
|
| [RELEASE_NOTES_v0.8.0.md](RELEASE_NOTES_v0.8.0.md) · [English](RELEASE_NOTES_v0.8.0.en.md) | v0.8.0: long tasks, original receipts, attachments and upgrade boundaries. |
|
|
12
16
|
| [RELEASE_NOTES_v0.7.0.md](RELEASE_NOTES_v0.7.0.md) · [English](RELEASE_NOTES_v0.7.0.en.md) | v0.7.0:商城与库存场景、配套升级和限制。 |
|
|
13
17
|
| [user-guide/conversations.md](user-guide/conversations.md) | 普通用户的多账户对话、完整沟通追溯和离线恢复指南。 |
|