bailinghub 0.3.3 → 0.4.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 +3 -1
- package/README.md +4 -0
- package/docker-compose.images.yml +2 -2
- package/docs/CHANGELOG.en.md +58 -1
- package/docs/CHANGELOG.md +26 -1
- package/docs/COMPATIBILITY.en.md +25 -0
- package/docs/CONTRACT.en.md +91 -8
- package/docs/CONTRACT.md +39 -7
- package/docs/DEMO.en.md +6 -0
- package/docs/DEMO.md +2 -0
- package/docs/INDEPENDENT_VALIDATION.en.md +9 -6
- package/docs/INDEPENDENT_VALIDATION.md +9 -6
- package/docs/QUICKSTART.en.md +20 -0
- package/docs/QUICKSTART.md +2 -2
- package/docs/README.en.md +4 -0
- package/docs/README.md +4 -0
- package/docs/RELEASE_NOTES_v0.3.4.en.md +38 -0
- package/docs/RELEASE_NOTES_v0.3.4.md +38 -0
- package/docs/RELEASE_NOTES_v0.4.0.en.md +39 -0
- package/docs/RELEASE_NOTES_v0.4.0.md +39 -0
- package/docs/STREAMING.en.md +32 -0
- package/docs/STREAMING.md +8 -2
- package/docs/WIDGET_RENDERERS.en.md +123 -6
- package/docs/WIDGET_RENDERERS.md +75 -6
- package/docs/user-guide/concepts.en.md +8 -1
- package/docs/user-guide/concepts.md +3 -1
- package/docs/user-guide/console-map.en.md +1 -2
- package/docs/user-guide/console-map.md +3 -3
- package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +9 -0
- package/package.json +1 -1
- package/schemas/config/chat-entry.schema.json +2 -1
- package/scripts/check-doc-links.mjs +2 -0
- package/scripts/check-image-tags.sh +1 -1
- package/scripts/check-release-consistency.test.mjs +5 -5
- package/scripts/e2e-console.mjs +38 -10
- package/scripts/install.sh +1 -1
- package/scripts/publish-images.sh +1 -1
- package/scripts/release-audit.mjs +2 -0
- package/scripts/verify-github-repo.mjs +2 -0
- package/scripts/widget-renderer-test.mjs +244 -16
- package/src/core/config/config-models.test.ts +18 -1
- package/src/core/config/config-models.ts +25 -3
- package/src/core/config/config-schema.test.ts +2 -0
- package/src/core/contracts/types.ts +2 -1
- package/src/core/platform/chat-form.test.ts +147 -0
- package/src/core/platform/chat-form.ts +402 -0
- package/src/core/platform/version.ts +1 -1
- package/src/core/runtime/execution-runtime.test.ts +73 -4
- package/src/core/runtime/execution-runtime.ts +18 -1
- package/src/routes/chat-mount.test.ts +9 -1
- package/src/routes/chat.test.ts +319 -7
- package/src/routes/chat.ts +179 -28
- package/web/console/assets/{Accounts-08VltF2i.js → Accounts-DuUY2UJU.js} +1 -1
- package/web/console/assets/{Approvals-CqgmsMau.js → Approvals-B11mo1dy.js} +1 -1
- package/web/console/assets/{Audit-bPlpSQt3.js → Audit-CQwJRIJT.js} +1 -1
- package/web/console/assets/{BrandLockup-DhX07g3G.js → BrandLockup-BIF-h1pi.js} +1 -1
- package/web/console/assets/{Channels-BZe0pLgx.js → Channels-BIploUT-.js} +1 -1
- package/web/console/assets/ChatEntries-Cpg_WV-o.js +7 -0
- package/web/console/assets/ChatEntries-DsYtcXN6.css +1 -0
- package/web/console/assets/Clients--D7NQJKk.css +1 -0
- package/web/console/assets/{Clients-BVVZfX3r.js → Clients-DS29eUi2.js} +2 -2
- package/web/console/assets/{Cost-DANcjr_p.js → Cost-BF52tfU2.js} +1 -1
- package/web/console/assets/{Credentials-D_8tP2Xa.js → Credentials-SwfmQAv6.js} +1 -1
- package/web/console/assets/{Diagnostics-Bw1WImFe.js → Diagnostics-CJfbI_8p.js} +1 -1
- package/web/console/assets/{Executors-fuieN2Sl.js → Executors-CzlZlznA.js} +1 -1
- package/web/console/assets/{Kb-BaMi_7xf.js → Kb-CVX22U4k.js} +1 -1
- package/web/console/assets/{Login-Cmz2ppY8.js → Login-PoUVsBI-.js} +1 -1
- package/web/console/assets/{Projects-D6xIgFB3.js → Projects-DYlbjLQy.js} +1 -1
- package/web/console/assets/{Routes-B90i3ZNa.js → Routes-DSEvGujN.js} +1 -1
- package/web/console/assets/{Runs-9qpwotOj.js → Runs-B-TsYZEt.js} +1 -1
- package/web/console/assets/Setup-D7nxgn-9.css +1 -0
- package/web/console/assets/Setup-xiPXit_b.js +1 -0
- package/web/console/assets/{Shell-Dm6eFcl1.js → Shell-DNiWZOYB.js} +1 -1
- package/web/console/assets/{StorageBuckets-DY8WuJlM.js → StorageBuckets-Bjsc3pLd.js} +1 -1
- package/web/console/assets/{SystemSettings-O_NMPzq_.js → SystemSettings-CcKF2lJ9.js} +1 -1
- package/web/console/assets/{SystemStatus-Cok3S7S3.js → SystemStatus-Oj1xjxJn.js} +1 -1
- package/web/console/assets/{Targets-YWBoxqvy.js → Targets-y1KllVXT.js} +1 -1
- package/web/console/assets/{Tools-BgXDw7Mg.js → Tools-DoEP_y9x.js} +1 -1
- package/web/console/assets/{index-S_J0I0Zh.js → index-CxPIS6G7.js} +2 -2
- package/web/console/assets/{request-FM608Kfz.js → request-CBLNpLth.js} +1 -1
- package/web/console/assets/{schema-DWnFqTkB.js → schema-DzwLpuOy.js} +1 -1
- package/web/console/index.html +1 -1
- package/web/widget/widget.js +493 -14
- package/web-admin/src/pages/ChatEntries.vue +46 -23
- package/web-admin/src/pages/Clients.vue +2 -2
- package/web-admin/src/pages/Setup.vue +12 -8
- package/web/console/assets/ChatEntries-BweMx_CU.css +0 -1
- package/web/console/assets/ChatEntries-Ca0lcGqn.js +0 -7
- package/web/console/assets/Clients-DcTYN-Js.css +0 -1
- package/web/console/assets/Setup-BIjCiA2i.js +0 -1
- package/web/console/assets/Setup-BuyKFofL.css +0 -1
package/docs/README.en.md
CHANGED
|
@@ -97,6 +97,10 @@ This directory contains public documentation for the open-source BailingHub proj
|
|
|
97
97
|
| [RELEASE_NOTES_v0.3.2.md](RELEASE_NOTES_v0.3.2.md) | Chinese `v0.3.2` release notes. |
|
|
98
98
|
| [RELEASE_NOTES_v0.3.3.en.md](RELEASE_NOTES_v0.3.3.en.md) | `v0.3.3` npm publication provenance-metadata correction. |
|
|
99
99
|
| [RELEASE_NOTES_v0.3.3.md](RELEASE_NOTES_v0.3.3.md) | Chinese `v0.3.3` release notes. |
|
|
100
|
+
| [RELEASE_NOTES_v0.3.4.en.md](RELEASE_NOTES_v0.3.4.en.md) | `v0.3.4` anonymous-preview and trusted-business-identity guidance. |
|
|
101
|
+
| [RELEASE_NOTES_v0.3.4.md](RELEASE_NOTES_v0.3.4.md) | Chinese `v0.3.4` release notes. |
|
|
102
|
+
| [RELEASE_NOTES_v0.4.0.en.md](RELEASE_NOTES_v0.4.0.en.md) | `v0.4.0` native conversational forms and chat-entry controls. |
|
|
103
|
+
| [RELEASE_NOTES_v0.4.0.md](RELEASE_NOTES_v0.4.0.md) | Chinese `v0.4.0` release notes. |
|
|
100
104
|
| [RELEASE_NOTES_v0.1.0.en.md](RELEASE_NOTES_v0.1.0.en.md) | First public release notes. |
|
|
101
105
|
| [CHANGELOG.en.md](CHANGELOG.en.md) | Public changelog format and current release summary. |
|
|
102
106
|
| [COMPATIBILITY.en.md](COMPATIBILITY.en.md) | Versioning, compatibility, migration, and schema discipline. |
|
package/docs/README.md
CHANGED
|
@@ -110,6 +110,10 @@
|
|
|
110
110
|
| [RELEASE_NOTES_v0.3.2.en.md](RELEASE_NOTES_v0.3.2.en.md) | English `v0.3.2` managed demo dataset onboarding. |
|
|
111
111
|
| [RELEASE_NOTES_v0.3.3.md](RELEASE_NOTES_v0.3.3.md) | `v0.3.3` npm 发布来源元数据纠偏说明。 |
|
|
112
112
|
| [RELEASE_NOTES_v0.3.3.en.md](RELEASE_NOTES_v0.3.3.en.md) | English `v0.3.3` npm publication provenance-metadata correction. |
|
|
113
|
+
| [RELEASE_NOTES_v0.3.4.md](RELEASE_NOTES_v0.3.4.md) | `v0.3.4` 匿名预览与可信业务身份引导说明。 |
|
|
114
|
+
| [RELEASE_NOTES_v0.3.4.en.md](RELEASE_NOTES_v0.3.4.en.md) | English `v0.3.4` anonymous-preview and trusted-business-identity guidance. |
|
|
115
|
+
| [RELEASE_NOTES_v0.4.0.md](RELEASE_NOTES_v0.4.0.md) | `v0.4.0` 原生对话表单与聊天入口控制说明。 |
|
|
116
|
+
| [RELEASE_NOTES_v0.4.0.en.md](RELEASE_NOTES_v0.4.0.en.md) | English `v0.4.0` native conversational forms and chat-entry controls. |
|
|
113
117
|
| [RELEASE_NOTES_v0.1.0.md](RELEASE_NOTES_v0.1.0.md) | 首个公开版本的 GitHub Release 草稿。 |
|
|
114
118
|
| [RELEASE_NOTES_v0.1.0.en.md](RELEASE_NOTES_v0.1.0.en.md) | English release notes. |
|
|
115
119
|
| [CHANGELOG.md](CHANGELOG.md) | 公开发布后的对外变更记录。 |
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# BailingHub v0.3.4: Anonymous Preview and Trusted Business Identity Guidance
|
|
2
|
+
|
|
3
|
+
`v0.3.4` clarifies the user journey between a chat-entry preview, the built-in demo, and a real trusted business identity. The console action previously presented as a generic trial chat is now explicitly labeled **Anonymous Preview**, so administrators and visitors are not led to assume that a BailingHub console session automatically becomes a business-operation subject.
|
|
4
|
+
|
|
5
|
+
## Main changes
|
|
6
|
+
|
|
7
|
+
- **Explicit anonymous-preview semantics**: the chat-entry list, embed dialog, and standalone preview page now state that the preview does not inherit the BailingHub administrator session and has no standalone business-login surface.
|
|
8
|
+
- **Accurate no-subject guidance**: when a conversation has no trusted identity ticket signed by the business backend, the Agent explains that the user must return to the real business system, sign in there, and reopen or refresh the assistant. It must not claim that the preview can perform a login or ask for an account, password, token, or user ID.
|
|
9
|
+
- **Separate demo validation path**: after managed demo configuration is imported, Getting Started presents **Run Demo-Subject Smoke** as the next explicit action. Smoke uses a controlled demo subject and creates a real job and trace. Importing configuration does not run a task automatically and does not promote the administrator into a business subject.
|
|
10
|
+
- **More precise ticket configuration**: the console now explains that the business-identity ticket issuer only declares which client may sign tickets for the entry. A trusted business subject exists only when the backend of an authenticated business system signs a short-lived ticket and its page supplies `data-ticket`.
|
|
11
|
+
|
|
12
|
+
## Identity and authorization boundary
|
|
13
|
+
|
|
14
|
+
This release does not relax any identity or tool gate:
|
|
15
|
+
|
|
16
|
+
- `visitor_id` remains anonymous conversation continuity data, not an identity credential;
|
|
17
|
+
- without a verified ticket that establishes a trusted subject, every tool declared with `subject.required:true`, including read-only queries and writes, remains hidden from the Agent;
|
|
18
|
+
- ticket verification establishes a trusted business subject and makes subject-required tools eligible, but the real business system must still perform final authorization from On-Behalf-Of and its own permissions;
|
|
19
|
+
- a BailingHub administrator is never automatically converted into a business user.
|
|
20
|
+
|
|
21
|
+
## Compatibility and upgrade
|
|
22
|
+
|
|
23
|
+
- There is no new database migration or Schema change. `054_demo_dataset_state.sql` remains the latest migration.
|
|
24
|
+
- There is no new or changed HTTP API, Client API, Kernel Host API v1, chat protocol, Executor Protocol, ACC contract, ticket format, tool signature, or approval semantic.
|
|
25
|
+
- Existing anonymous entries and ticket-bearing embeds require no integration change. The changes primarily improve console, preview-page, and no-subject response semantics.
|
|
26
|
+
- Deployments on `v0.3.3` can upgrade as a normal patch release.
|
|
27
|
+
|
|
28
|
+
## Validation
|
|
29
|
+
|
|
30
|
+
The release gate covers the complete `npm run release:check`, no-subject tool-assembly tests, the anonymous-preview page contract, real-browser console E2E, demo-subject Smoke, bilingual documentation, and npm artifact consistency.
|
|
31
|
+
|
|
32
|
+
## Related documentation
|
|
33
|
+
|
|
34
|
+
- [Quickstart](QUICKSTART.en.md)
|
|
35
|
+
- [Chat entry and identity contract](CONTRACT.en.md)
|
|
36
|
+
- [Docker Demo](DEMO.en.md)
|
|
37
|
+
- [User guide: core concepts](user-guide/concepts.en.md)
|
|
38
|
+
- [中文发布说明](RELEASE_NOTES_v0.3.4.md)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# BailingHub v0.3.4:匿名预览与可信业务身份引导
|
|
2
|
+
|
|
3
|
+
`v0.3.4` 收紧了聊天入口、内置演示和真实业务身份之间的用户引导。控制台原“试聊”入口现在明确标识为“匿名预览”,避免让管理员或访客误以为中枢后台登录态会自动变成业务操作主体。
|
|
4
|
+
|
|
5
|
+
## 主要变化
|
|
6
|
+
|
|
7
|
+
- **匿名预览语义**:聊天入口列表、嵌入弹窗和独立预览页统一说明,该页不继承中枢管理员登录态,也不提供独立业务登录入口。
|
|
8
|
+
- **无主体时的正确引导**:当会话没有收到业务后端签发的可信身份票据时,Agent 会说明应返回真实业务系统完成登录并重新打开或刷新助手;不会声称预览页可自行登录,也不会索要账号、密码、Token 或用户 ID。
|
|
9
|
+
- **演示验证分流**:导入内置演示配置后,上手向导将“运行演示主体 Smoke”作为明确的下一步。Smoke 使用受控演示主体产生真实 job 和 trace;导入配置本身不会自动运行任务,也不会把管理员提升为业务主体。
|
|
10
|
+
- **票据配置更准确**:控制台明确“业务身份票据签发方”只表示入口支持哪个接入方签票。只有已登录业务系统的后端签发短票并由页面携带 `data-ticket` 时,才会建立可信业务主体。
|
|
11
|
+
|
|
12
|
+
## 身份与授权边界
|
|
13
|
+
|
|
14
|
+
本版本没有放宽身份或工具闸门:
|
|
15
|
+
|
|
16
|
+
- `visitor_id` 仍只用于匿名会话连续性,不是身份凭证;
|
|
17
|
+
- 没有通过验签票据建立可信主体时,所有声明 `subject.required:true` 的工具(包括只读查询和写操作)仍不会向 Agent 暴露;
|
|
18
|
+
- 票据验证只建立可信业务主体并让需主体工具进入候选清单,真实业务系统仍必须根据 On-Behalf-Of 和自身权限做最终授权;
|
|
19
|
+
- 中枢管理员身份不会自动转换为任何业务用户。
|
|
20
|
+
|
|
21
|
+
## 兼容性与升级
|
|
22
|
+
|
|
23
|
+
- 无新增数据库迁移或 Schema 变化;最新迁移仍为 `054_demo_dataset_state.sql`。
|
|
24
|
+
- 无新增或变更 HTTP API、Client API、Kernel Host API v1、聊天协议、Executor Protocol、ACC、票据格式、工具签名或审批语义。
|
|
25
|
+
- 现有匿名入口和携票据嵌入代码无需修改;主要变化是控制台、预览页和无主体回答的准确语义。
|
|
26
|
+
- 已部署 `v0.3.3` 的实例可按普通补丁版本升级。
|
|
27
|
+
|
|
28
|
+
## 验证
|
|
29
|
+
|
|
30
|
+
发布门禁覆盖完整 `npm run release:check`、无主体工具装配测试、匿名预览页契约、控制台真实浏览器 E2E、演示主体 Smoke、双语文档和 npm 制品一致性检查。
|
|
31
|
+
|
|
32
|
+
## 相关文档
|
|
33
|
+
|
|
34
|
+
- [快速开始](QUICKSTART.md)
|
|
35
|
+
- [聊天入口与身份契约](CONTRACT.md)
|
|
36
|
+
- [Docker Demo](DEMO.md)
|
|
37
|
+
- [用户指南:核心概念](user-guide/concepts.md)
|
|
38
|
+
- [English release notes](RELEASE_NOTES_v0.3.4.en.md)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# BailingHub v0.4.0: Native Conversational Forms and Chat-Entry Controls
|
|
2
|
+
|
|
3
|
+
`v0.4.0` adds constrained native conversational forms to the official web widget and completes chat-entry controls for default-open presentation and browser Origin allowlists. Forms reuse the existing presentation-capability negotiation and non-blocking conversation model rather than introducing a second task state or approval protocol.
|
|
4
|
+
|
|
5
|
+
## Main changes
|
|
6
|
+
|
|
7
|
+
- **Native conversational forms**: the dependency-free official widget supports `bailing-form` v1 for text, textarea, number, date, boolean, single-select, and multi-select fields, with client/server validation, submission receipts, and history recovery.
|
|
8
|
+
- **Proactive information collection**: the built-in LLM receives constrained form guidance only when the client explicitly advertises `bailing-form`. When the context shows that several fields are required before the task can continue, the model may emit a form proactively without waiting for the user to request one.
|
|
9
|
+
- **Non-blocking continuation**: the source answer still reaches `done`. Submit, cancel, or skip creates a new user turn and job in the same thread, without adding `input_required` or changing existing SSE terminal semantics.
|
|
10
|
+
- **Default-open entries**: appearance configuration adds a default-false `default_open` setting. When enabled, existing official embeds open on load without page changes; the existing `data-open="1"` force-open behavior remains compatible.
|
|
11
|
+
- **Origin allowlist guardrails**: the console accepts exact `scheme://host[:port]` origins, canonicalizes and deduplicates them, and rejects non-allowlisted browser Origins with 403 before a job starts. Invalid formats or types return 400.
|
|
12
|
+
- **Ecosystem documentation discovery**: the README links to an independently maintained community plugin for DeepSeek Harness. The link is not part of BailingHub Core and does not imply official DeepSeek development, certification, endorsement, or adoption.
|
|
13
|
+
|
|
14
|
+
## Security and trust boundaries
|
|
15
|
+
|
|
16
|
+
- The server reloads the authoritative form from the source job's final reply and matches entry, identity, thread, and `submission_id`; a client-supplied Schema cannot rewrite submission rules.
|
|
17
|
+
- Forms cannot request passwords, tokens, API keys, private keys, or payment credentials, and cannot change identity, routing, tool eligibility, approval, business permissions, or side-effect gates.
|
|
18
|
+
- Ordinary form values follow existing chat semantics and enter the conversation ledger and model context. Deployers remain responsible for their own retention, privacy notice, and compliance policies.
|
|
19
|
+
- The Origin allowlist prevents direct browser re-embedding; it is not server authentication. An empty array remains unrestricted, and existing server or mini-program calls without Origin remain compatible. Use request signing or a business identity ticket when non-browser callers must be restricted.
|
|
20
|
+
- Custom or external executors do not automatically receive the built-in LLM form prompt and must implement the same public output contract themselves.
|
|
21
|
+
|
|
22
|
+
## Compatibility and upgrade
|
|
23
|
+
|
|
24
|
+
- The public contract advances additively to `bailing.contract.v2.14`; `WIDGET_API` and `rendererApiVersion` remain 1.
|
|
25
|
+
- There is no new database migration. `054_demo_dataset_state.sql` remains the latest migration.
|
|
26
|
+
- Client API v1, Kernel Host API v1, Executor Protocol, ACC, SDKs, tool signatures, approval semantics, and final business authorization remain unchanged.
|
|
27
|
+
- Existing chat entries remain collapsed by default, and existing `allowed_origins: []` remains unrestricted. To restrict browser embeds, save exact origins without paths, query strings, or wildcards.
|
|
28
|
+
|
|
29
|
+
## Validation
|
|
30
|
+
|
|
31
|
+
The release gate covers the complete `npm run release:check`, 554 Core tests, real-browser widget interaction, console builds, bilingual documentation, OSS boundaries, security scans, Client API contracts, and npm artifact consistency. Proactive form output, submission continuation, history recovery, default-open presentation, and non-allowlisted browser rejection also completed real end-to-end validation.
|
|
32
|
+
|
|
33
|
+
## Related documentation
|
|
34
|
+
|
|
35
|
+
- [Public runtime contract](CONTRACT.en.md)
|
|
36
|
+
- [Widget renderer and form contract](WIDGET_RENDERERS.en.md)
|
|
37
|
+
- [Streaming protocol](STREAMING.en.md)
|
|
38
|
+
- [Compatibility and upgrade](COMPATIBILITY.en.md)
|
|
39
|
+
- [中文发布说明](RELEASE_NOTES_v0.4.0.md)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# BailingHub v0.4.0:原生对话表单与聊天入口控制
|
|
2
|
+
|
|
3
|
+
`v0.4.0` 为官方网页聊天组件增加受约束的原生对话表单,并补齐聊天入口的默认展开与浏览器 Origin 白名单配置。表单沿用现有展示能力协商与非阻塞会话模型,不建立第二套任务状态或审批协议。
|
|
4
|
+
|
|
5
|
+
## 主要变化
|
|
6
|
+
|
|
7
|
+
- **原生对话表单**:官方零依赖 Widget 支持 `bailing-form` v1,可安全渲染文本、多行文本、数字、日期、布尔、单选和多选字段,并提供客户端/服务端双重校验、提交回执与历史恢复。
|
|
8
|
+
- **主动收集信息**:只有客户端明确声明支持 `bailing-form` 时,内置 LLM 才会收到受限表单输出指引。当上下文表明继续任务必须一次补齐多项信息时,模型可以主动输出表单,无需用户先要求“输出一个表单”。
|
|
9
|
+
- **非阻塞续聊**:源回答仍正常进入 `done`;提交、取消或跳过表单会在同一 thread 创建新的用户轮次和 job,不新增 `input_required`,也不改变既有 SSE 终态。
|
|
10
|
+
- **默认展开**:聊天入口外观新增默认关闭的 `default_open`。开启后现有官方嵌入脚本加载即展开,无需修改业务页面;原有 `data-open="1"` 强制展开方式继续兼容。
|
|
11
|
+
- **Origin 白名单防误配**:控制台只接受精确 `scheme://host[:port]`,保存时规范化并去重;非白名单浏览器 Origin 在创建任务前返回 403,非法或错误类型配置返回 400。
|
|
12
|
+
- **生态文档发现**:README 增加独立维护的 DeepSeek Harness 社区插件链接;该链接不进入 BailingHub Core,也不代表 DeepSeek 官方开发、认证、背书或采用。
|
|
13
|
+
|
|
14
|
+
## 安全与信任边界
|
|
15
|
+
|
|
16
|
+
- 表单 Schema 从源 job 的权威最终回复重新读取;服务端同时核对入口、身份、thread 与 `submission_id`,客户端不能用自带 Schema 改写提交规则。
|
|
17
|
+
- 表单不能请求密码、Token、API Key、私钥或支付凭据,也不能改变身份、路由、工具白名单、审批、业务权限或副作用闸门。
|
|
18
|
+
- 普通表单值会按既有聊天语义进入对话总账和模型上下文,部署方仍需执行自己的数据保留、隐私告知与合规策略。
|
|
19
|
+
- Origin 白名单只防浏览器直接盗嵌,不是服务端鉴权。空数组仍表示不限制;不带 Origin 的小程序或服务端请求继续按既有契约放行,需要限制此类调用时应使用签名或业务票据。
|
|
20
|
+
- 自定义或外部 executor 不会自动获得内置 LLM 的表单提示,接入方需要自行遵守同一公开输出契约。
|
|
21
|
+
|
|
22
|
+
## 兼容性与升级
|
|
23
|
+
|
|
24
|
+
- 公开契约增量到 `bailing.contract.v2.14`;`WIDGET_API` 与 `rendererApiVersion` 仍为 1。
|
|
25
|
+
- 没有新增数据库迁移,最新迁移仍为 `054_demo_dataset_state.sql`。
|
|
26
|
+
- Client API v1、Kernel Host API v1、Executor Protocol、ACC、SDK、工具签名、审批语义与业务系统最终授权保持不变。
|
|
27
|
+
- 既有聊天入口默认保持收起;既有 `allowed_origins: []` 继续表示不限制。需要限制网页嵌入时,应在控制台保存精确来源,不要填写路径、查询参数或通配符。
|
|
28
|
+
|
|
29
|
+
## 验证
|
|
30
|
+
|
|
31
|
+
发布门禁覆盖完整 `npm run release:check`、554 项 Core 测试、Widget 真实浏览器交互、控制台构建、双语文档、OSS 边界、安全扫描、Client API 契约与 npm 制品一致性检查。主动表单、提交续轮、刷新恢复、默认展开和非白名单浏览器拒绝也完成了真实端到端验证。
|
|
32
|
+
|
|
33
|
+
## 相关文档
|
|
34
|
+
|
|
35
|
+
- [公开运行时契约](CONTRACT.md)
|
|
36
|
+
- [Widget 渲染与表单契约](WIDGET_RENDERERS.md)
|
|
37
|
+
- [流式协议](STREAMING.md)
|
|
38
|
+
- [兼容性与升级](兼容性与升级.md)
|
|
39
|
+
- [English release notes](RELEASE_NOTES_v0.4.0.en.md)
|
package/docs/STREAMING.en.md
CHANGED
|
@@ -63,6 +63,38 @@ Reverse proxies and CDNs must disable response buffering, preserve `text/event-s
|
|
|
63
63
|
- Existing clients may ignore `phase`, `reset`, and `delta` and wait for `done`.
|
|
64
64
|
- New clients must treat `done`, not accumulated fragments, as the final authoritative value.
|
|
65
65
|
|
|
66
|
+
### 7.1 Presentation capability negotiation
|
|
67
|
+
|
|
68
|
+
A custom client may advertise only the declarative renderers it has actually
|
|
69
|
+
installed and validated:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"client_capabilities": {
|
|
74
|
+
"renderers": ["bailing-chart", "bailing-form"]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This affects optional model presentation guidance only. It is not an SSE
|
|
80
|
+
field and cannot change identity, authorization, approval, or tool access.
|
|
81
|
+
Charts and forms remain fenced content inside `done.reply`; never mount either
|
|
82
|
+
from provisional `delta` text. Apply the allowlist and fallback rules in
|
|
83
|
+
[WIDGET_RENDERERS.en.md](WIDGET_RENDERERS.en.md) only after `done`.
|
|
84
|
+
|
|
85
|
+
### 7.2 A form response does not add stream states
|
|
86
|
+
|
|
87
|
+
A `bailing-form` is final declarative content in `done.reply`. Its source job
|
|
88
|
+
is already terminal; it never enters a waiting-for-input or `input_required`
|
|
89
|
+
state. Submit or cancel makes a new `POST /chat/:entry_key`, creating a new job
|
|
90
|
+
in the same thread. That new job uses the existing
|
|
91
|
+
`open/status/phase/reset/delta/ping/done/failed/timeout` event set.
|
|
92
|
+
|
|
93
|
+
Retain the source `done.job_id` as `source_job_id` and subscribe separately to
|
|
94
|
+
the new job. Do not keep or resume the closed source-job stream. Cross-device
|
|
95
|
+
receipt recovery comes from the durable `/thread` ledger, not the incremental
|
|
96
|
+
replay window.
|
|
97
|
+
|
|
66
98
|
## 8. Validation
|
|
67
99
|
|
|
68
100
|
```bash
|
package/docs/STREAMING.md
CHANGED
|
@@ -87,12 +87,18 @@
|
|
|
87
87
|
```json
|
|
88
88
|
{
|
|
89
89
|
"client_capabilities": {
|
|
90
|
-
"renderers": ["bailing-chart"]
|
|
90
|
+
"renderers": ["bailing-chart", "bailing-form"]
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
该字段只影响模型收到的可选展示提示,不进入 SSE 事件,不构成身份、授权、审批或工具权限。富内容仍属于 `done.reply` 的一部分;客户端不得在 `delta`
|
|
95
|
+
该字段只影响模型收到的可选展示提示,不进入 SSE 事件,不构成身份、授权、审批或工具权限。富内容仍属于 `done.reply` 的一部分;客户端不得在 `delta` 阶段挂载图表或表单,应在 `done` 后按 [`WIDGET_RENDERERS.md`](WIDGET_RENDERERS.md) 的白名单与失败降级规则处理完整 fenced code block。
|
|
96
|
+
|
|
97
|
+
### 7.2 表单回传不改变流式状态机
|
|
98
|
+
|
|
99
|
+
`bailing-form` 是 `done.reply` 中的最终声明式内容。源 job 输出表单后已经终态 `done`,不会进入“等待填写”或 `input_required`。用户提交/取消表单时,客户端向同一聊天入口发起新 `POST /chat/:entry_key`;服务端在同 thread 创建新 job,该 job 仍使用本文现有的 `open/status/phase/reset/delta/ping/done/failed/timeout` 集合。
|
|
100
|
+
|
|
101
|
+
因此客户端要保留源 `done.job_id` 作为回传的 `source_job_id`,另外订阅新 job 的 SSE;不得继续占用或恢复源 job 的已关闭连接。表单回执的跨设备恢复来自 `/thread` 权威总账,不来自增量回放窗口。
|
|
96
102
|
|
|
97
103
|
## 8. 验证
|
|
98
104
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Rich Content Renderers for the Embedded Chat Widget
|
|
2
2
|
|
|
3
|
-
The BailingHub widget natively renders Markdown text, tables, images, and file links. Charts and interactive reports use
|
|
3
|
+
The BailingHub widget natively renders Markdown text, tables, images, and file links. Charts and interactive reports use a trusted renderer registry. The constrained `bailing-form` v1 renderer is built into the official widget. Both consume declarative fenced payloads while the core widget remains free of third-party runtime dependencies.
|
|
4
4
|
|
|
5
5
|
## Trust Boundary
|
|
6
6
|
|
|
7
7
|
- The model emits declarative data only. It cannot supply or select JavaScript, HTML, remote script URLs, or component code.
|
|
8
|
-
-
|
|
8
|
+
- Custom renderers are installed and registered by the embedding application and are therefore trusted host code. The built-in `bailing-form` follows the same allowlist and fallback boundary.
|
|
9
9
|
- A renderer never receives chat tickets, business credentials, acting-subject identity, or full page context.
|
|
10
10
|
- Unknown types, invalid JSON, oversized payloads, and renderer failures fall back to a code block rendered through `textContent`.
|
|
11
11
|
- Rich content mounts only after a complete, closed fenced code block arrives. Incremental streaming output does not repeatedly create charts.
|
|
@@ -24,7 +24,7 @@ const unregister = window.BailingChat.registerRenderer({
|
|
|
24
24
|
label: 'Business chart',
|
|
25
25
|
contentType: 'application/json', // or text/plain
|
|
26
26
|
maxPayloadBytes: 64 * 1024,
|
|
27
|
-
mount({ container, payload, source, type, version, theme, signal }) {
|
|
27
|
+
mount({ container, payload, source, type, version, theme, signal, message, respond }) {
|
|
28
28
|
// payload is untrusted input; validate fields, counts, and ranges here.
|
|
29
29
|
const chart = createMyChart(container, payload, theme);
|
|
30
30
|
return () => chart.destroy();
|
|
@@ -36,6 +36,25 @@ unregister();
|
|
|
36
36
|
|
|
37
37
|
`mount` may return a cleanup function, an object with `destroy()`, a Promise, or nothing. Async renderers should stop work when `signal` is aborted.
|
|
38
38
|
|
|
39
|
+
Widget API v1 adds two optional, backward-compatible context values for an
|
|
40
|
+
interactive renderer:
|
|
41
|
+
|
|
42
|
+
- `message` contains the current assistant message `jobId` and known
|
|
43
|
+
`responses`. Each response summary contains only
|
|
44
|
+
`type/version/source_job_id/form_id/submission_id/action`, never form values.
|
|
45
|
+
- `respond(response, presentation?)` returns a Promise and creates the next
|
|
46
|
+
user message in the same thread. A form response is
|
|
47
|
+
`{form_id, submission_id, action:"submit"|"cancel", values?}`;
|
|
48
|
+
`submission_id` matches `[A-Za-z0-9_-]{8,64}` and serialized `values` is at
|
|
49
|
+
most 32 KiB. The widget forces `type:"bailing-form"`, `version:1`, and
|
|
50
|
+
`source_job_id` from the current message closure. A renderer cannot select an
|
|
51
|
+
endpoint, method, or arbitrary source job. The optional `{displayText}`
|
|
52
|
+
presentation is local user-bubble copy and is never sent to the server.
|
|
53
|
+
|
|
54
|
+
Existing renderers may ignore the new properties, so
|
|
55
|
+
`rendererApiVersion === "1"` is unchanged. Neither `message` nor `respond`
|
|
56
|
+
exposes the ticket, visitor id, thread id, or other identity material.
|
|
57
|
+
|
|
39
58
|
## Reply Format
|
|
40
59
|
|
|
41
60
|
After `bailing-chart` is registered, a complete reply can include:
|
|
@@ -55,6 +74,93 @@ After `bailing-chart` is registered, a complete reply can include:
|
|
|
55
74
|
|
|
56
75
|
Type names start with a lowercase letter and contain only letters, numbers, dots, underscores, plus signs, and hyphens, up to 64 characters. JSON renderers accept objects or arrays; scalar payloads should use `text/plain`.
|
|
57
76
|
|
|
77
|
+
## Built-in `bailing-form` v1
|
|
78
|
+
|
|
79
|
+
The official widget advertises and renders `bailing-form` without React, Vue,
|
|
80
|
+
a JSON Schema runtime, or a form library. The model emits data only; the widget
|
|
81
|
+
owns controls, validation, submission, and receipts.
|
|
82
|
+
|
|
83
|
+
A host may preload its own `bailing-form` renderer before an asynchronous
|
|
84
|
+
widget script to explicitly replace the built-in UI. That trusted host code
|
|
85
|
+
must implement this section's complete validation, response, and cleanup
|
|
86
|
+
contract. The server still reloads and validates the source reply, so a host
|
|
87
|
+
override never relaxes the authoritative boundary.
|
|
88
|
+
|
|
89
|
+
````markdown
|
|
90
|
+
```bailing-form
|
|
91
|
+
{
|
|
92
|
+
"version": 1,
|
|
93
|
+
"form_id": "refund_info",
|
|
94
|
+
"title": "Refund information",
|
|
95
|
+
"description": "The conversation will continue after submission",
|
|
96
|
+
"schema": {
|
|
97
|
+
"reason": {
|
|
98
|
+
"type": "textarea",
|
|
99
|
+
"label": "Reason",
|
|
100
|
+
"required": true,
|
|
101
|
+
"maxLength": 200
|
|
102
|
+
},
|
|
103
|
+
"method": {
|
|
104
|
+
"type": "single_select",
|
|
105
|
+
"label": "Refund method",
|
|
106
|
+
"required": true,
|
|
107
|
+
"options": [
|
|
108
|
+
{ "label": "Original payment method", "value": "original" },
|
|
109
|
+
{ "label": "Account balance", "value": "balance" }
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"submit_label": "Submit",
|
|
114
|
+
"cancel_label": "Cancel"
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
````
|
|
118
|
+
|
|
119
|
+
Top-level keys are limited to `version:1`, `form_id`, `title`, optional
|
|
120
|
+
`description`, `schema`, optional `submit_label`, and optional `cancel_label`.
|
|
121
|
+
Form and field ids match `[a-z][a-z0-9_-]{0,63}`. A fenced JSON payload is at
|
|
122
|
+
most 32 KiB and contains 1–12 fields. Titles and labels are at most 80
|
|
123
|
+
characters, form descriptions 300, field descriptions 200, placeholders 120,
|
|
124
|
+
and button labels 32.
|
|
125
|
+
|
|
126
|
+
| `type` | Additional keys and limits |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `text` | optional `minLength` / `maxLength`; maximum cap 500 |
|
|
129
|
+
| `textarea` | optional `minLength` / `maxLength`; maximum cap 2000 |
|
|
130
|
+
| `number` | optional finite numeric `min` / `max` |
|
|
131
|
+
| `date` | optional `min` / `max` in fixed `YYYY-MM-DD` format |
|
|
132
|
+
| `boolean` | no additional keys |
|
|
133
|
+
| `single_select` | required `options`, 1–50 entries, one choice |
|
|
134
|
+
| `multi_select` | required `options`, 1–50 entries, multiple choices |
|
|
135
|
+
|
|
136
|
+
All fields use `label` and may use `description`, `placeholder`, and
|
|
137
|
+
`required`. An option contains only `{label,value}`; labels are at most 80
|
|
138
|
+
characters, values at most 120, and values are unique within the field.
|
|
139
|
+
Unknown keys, nested objects, files, regular expressions, HTML/JavaScript/CSS,
|
|
140
|
+
remote scripts/data sources, and values containing triple backticks are
|
|
141
|
+
rejected.
|
|
142
|
+
|
|
143
|
+
### Submission, receipts, and history recovery
|
|
144
|
+
|
|
145
|
+
1. The form mounts only after the source reply is complete and `done`; the
|
|
146
|
+
source job never enters a waiting state.
|
|
147
|
+
2. Submit or cancel posts an `interaction_response` to the original entry. The
|
|
148
|
+
server creates a new job in the same thread and uses the existing SSE flow.
|
|
149
|
+
3. Controls are disabled while sending. Once job creation succeeds, the source
|
|
150
|
+
form becomes a read-only Submitted or Cancelled receipt. A failed request
|
|
151
|
+
restores the controls and is not presented as success.
|
|
152
|
+
4. A user history message may include an `interaction` summary. The widget uses
|
|
153
|
+
`source_job_id + form_id` to restore replied state after reload or on another
|
|
154
|
+
device, without making the source form submit again.
|
|
155
|
+
|
|
156
|
+
Forms collect ordinary information or choices. They are not approvals,
|
|
157
|
+
authorization credentials, or tool-execution confirmations. Credential- or
|
|
158
|
+
payment-like text in the form title/description or a field's name, label,
|
|
159
|
+
description, or placeholder is rejected, including passwords, API keys, tokens,
|
|
160
|
+
private keys, card numbers, and CVV. Non-secret submitted values become
|
|
161
|
+
conversation-ledger and model-context data, so deployments must apply their own
|
|
162
|
+
retention and compliance rules.
|
|
163
|
+
|
|
58
164
|
## Loading Order
|
|
59
165
|
|
|
60
166
|
Register after the widget loads:
|
|
@@ -99,7 +205,7 @@ Content-Type: application/json
|
|
|
99
205
|
"message": "Analyze revenue for the last seven days",
|
|
100
206
|
"visitor_id": "visitor_01HXYZ",
|
|
101
207
|
"client_capabilities": {
|
|
102
|
-
"renderers": ["bailing-chart"]
|
|
208
|
+
"renderers": ["bailing-chart", "bailing-form"]
|
|
103
209
|
}
|
|
104
210
|
}
|
|
105
211
|
```
|
|
@@ -107,7 +213,7 @@ Content-Type: application/json
|
|
|
107
213
|
`client_capabilities` is presentation-only negotiation:
|
|
108
214
|
|
|
109
215
|
- when it is absent, BailingHub does not assume that the client can render charts;
|
|
110
|
-
- declaring `bailing-chart` does not change identity, permissions, approval, routing, tool allowlists, or final business authorization;
|
|
216
|
+
- declaring `bailing-chart` or `bailing-form` does not change identity, permissions, approval, routing, tool allowlists, or final business authorization;
|
|
111
217
|
- do not advertise a renderer that the client has not installed; the server accepts at most 16 valid type names;
|
|
112
218
|
- a capable client does not require a chart in every answer, and missing data must never be fabricated to produce one.
|
|
113
219
|
|
|
@@ -116,11 +222,19 @@ After creating the job, connect to `GET /chat/:entry_key/events/:job_id` and fol
|
|
|
116
222
|
1. append `delta` events to a provisional text bubble without mounting rich content;
|
|
117
223
|
2. discard the provisional buffer and render state on `reset`;
|
|
118
224
|
3. replace the provisional bubble with the authoritative `done.reply`;
|
|
119
|
-
4. only after `done`, parse complete fenced blocks with a mature Markdown parser and dispatch allowlisted types to trusted renderers;
|
|
225
|
+
4. only after `done`, parse complete fenced blocks with a mature Markdown parser and dispatch allowlisted types to trusted renderers; retain that `done.job_id` as the form `source_job_id`;
|
|
120
226
|
5. never present provisional text from `failed` or `timeout` as a final business result.
|
|
121
227
|
|
|
122
228
|
See [`docs/examples/custom-streaming-chat-client.mjs`](examples/custom-streaming-chat-client.mjs) for the transport lifecycle. It intentionally omits a Markdown parser and chart library. Integrators should consume fenced-code AST/tokens from their existing Markdown parser rather than interpreting model output with `eval`, `innerHTML`, or remote scripts.
|
|
123
229
|
|
|
230
|
+
To submit a form, a custom client posts
|
|
231
|
+
`{interaction_response:{type:"bailing-form",version:1,source_job_id,form_id,submission_id,action,values?}, visitor_id?, ticket?, thread_id?}`
|
|
232
|
+
to the same `POST /chat/:entry_key`. The server checks the source
|
|
233
|
+
job/entry/identity/thread, reloads the authoritative schema, validates values,
|
|
234
|
+
and deduplicates by `submission_id`. Do not send `message` in the same request
|
|
235
|
+
or send a client-side schema as authority. See
|
|
236
|
+
[CONTRACT.en.md](CONTRACT.en.md#non-blocking-bailing-form-responses).
|
|
237
|
+
|
|
124
238
|
### Minimum Requirements for a Custom Renderer
|
|
125
239
|
|
|
126
240
|
- match the type against a local allowlist such as `bailing-chart`;
|
|
@@ -129,5 +243,8 @@ See [`docs/examples/custom-streaming-chat-client.mjs`](examples/custom-streaming
|
|
|
129
243
|
- fall back to plain text or a code block on unknown types, invalid JSON, limits, or renderer errors;
|
|
130
244
|
- destroy chart instances and listeners when the final message is replaced, the route changes, or the component unmounts;
|
|
131
245
|
- keep attachments, references, charts, and business execution results as separate contracts.
|
|
246
|
+
- for `bailing-form`, implement this document's field allowlist, range checks,
|
|
247
|
+
unique submission id, failure recovery, and history receipt; never pass an
|
|
248
|
+
arbitrary JSON Schema directly into a dynamic form runtime.
|
|
132
249
|
|
|
133
250
|
In short: the official widget is the batteries-included path. A custom client owns capability advertisement, SSE lifecycle handling, final-reply parsing, and trusted rendering; BailingHub does not silently assume those host responsibilities.
|
package/docs/WIDGET_RENDERERS.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# 嵌入聊天组件富内容渲染器
|
|
2
2
|
|
|
3
|
-
BailingHub 的嵌入聊天组件原生支持 Markdown
|
|
3
|
+
BailingHub 的嵌入聊天组件原生支持 Markdown 文本、表格、图片和文件链接。图表、动态报表等展示内容通过可信渲染器注册表扩展;受限的 `bailing-form` v1 则由官方 Widget 原生渲染。两者都消费声明式 fenced payload,核心组件继续保持零第三方运行时依赖。
|
|
4
4
|
|
|
5
5
|
## 适用边界
|
|
6
6
|
|
|
7
7
|
- 模型只能输出声明式数据,不能输出或选择要执行的 JavaScript、HTML、远程脚本地址或组件代码。
|
|
8
|
-
-
|
|
8
|
+
- 自定义渲染器由嵌入页面的开发者预先安装并注册,属于宿主应用的可信代码;官方 `bailing-form` 实现使用同一白名单和失败回退边界。
|
|
9
9
|
- 渲染器不会收到聊天票据、业务凭证、会话身份或完整页面上下文。
|
|
10
10
|
- 未注册类型、非法 JSON、超限载荷和渲染异常都会降级成使用 `textContent` 展示的代码块。
|
|
11
11
|
- 富内容只在完整闭合的 fenced code block 到达后挂载;流式增量阶段不会反复创建图表。
|
|
@@ -24,7 +24,7 @@ const unregister = window.BailingChat.registerRenderer({
|
|
|
24
24
|
label: '业务图表',
|
|
25
25
|
contentType: 'application/json', // 或 text/plain
|
|
26
26
|
maxPayloadBytes: 64 * 1024,
|
|
27
|
-
mount({ container, payload, source, type, version, theme, signal }) {
|
|
27
|
+
mount({ container, payload, source, type, version, theme, signal, message, respond }) {
|
|
28
28
|
// payload 是不可信输入,适配器必须校验字段、数量和取值范围。
|
|
29
29
|
const chart = createMyChart(container, payload, theme);
|
|
30
30
|
return () => chart.destroy();
|
|
@@ -37,6 +37,13 @@ unregister();
|
|
|
37
37
|
|
|
38
38
|
`mount` 可以返回销毁函数、带 `destroy()` 的对象、Promise,或不返回值。`signal` 在消息离开视图时触发 abort,异步渲染器应及时停止工作。
|
|
39
39
|
|
|
40
|
+
Widget API v1 为需要交互回传的渲染器兼容新增了两个可选上下文:
|
|
41
|
+
|
|
42
|
+
- `message` 提供当前助手消息的 `jobId` 和已知 `responses`。`responses` 每项只含 `type/version/source_job_id/form_id/submission_id/action`,不含表单值。
|
|
43
|
+
- `respond(response, presentation?)` 返回 Promise,用于发起同 thread 的下一条用户消息。表单 response 体为 `{form_id, submission_id, action:"submit"|"cancel", values?}`,`submission_id` 匹配 `[A-Za-z0-9_-]{8,64}`,`values` 最大 32 KiB;Widget 从当前消息闭包强制补入 `type:"bailing-form"` / `version:1` / `source_job_id`,渲染器不能指定任意端点、方法或源 job。`presentation` 目前只支持本地用户气泡文案 `{displayText}`,不发往服务端。
|
|
44
|
+
|
|
45
|
+
旧渲染器可继续只解构原有参数;增加 `message/respond` 不改变 `rendererApiVersion === "1"`。`respond` 不会向渲染器暴露 `ticket`、`visitor_id`、`thread_id` 或其他身份材料。
|
|
46
|
+
|
|
40
47
|
## 输出格式
|
|
41
48
|
|
|
42
49
|
注册 `bailing-chart` 后,完整回复中的以下代码块会交给对应渲染器:
|
|
@@ -56,6 +63,65 @@ unregister();
|
|
|
56
63
|
|
|
57
64
|
类型名只接受小写字母开头的字母、数字、点、下划线、加号和连字符组合,最长 64 个字符。JSON 渲染器只接受对象或数组;字符串等标量请使用 `text/plain`。
|
|
58
65
|
|
|
66
|
+
## 官方 `bailing-form` v1
|
|
67
|
+
|
|
68
|
+
官方 Widget 自动声明并渲染 `bailing-form`,不需要宿主引入 React、Vue、JSON Schema 运行时或表单库。模型只能输出数据,字段控件、校验、提交和回执由 Widget 固定实现。
|
|
69
|
+
|
|
70
|
+
宿主可在异步 Widget 加载前预注册同名 `bailing-form` 渲染器以显式覆盖内置 UI;这是宿主可信代码的责任,必须完整实现本节的校验、回传和销毁契约。服务端无论如何都会重读源回复验值,宿主覆盖不会放宽权威边界。
|
|
71
|
+
|
|
72
|
+
````markdown
|
|
73
|
+
```bailing-form
|
|
74
|
+
{
|
|
75
|
+
"version": 1,
|
|
76
|
+
"form_id": "refund_info",
|
|
77
|
+
"title": "请补充退款信息",
|
|
78
|
+
"description": "提交后将在当前会话继续处理",
|
|
79
|
+
"schema": {
|
|
80
|
+
"reason": {
|
|
81
|
+
"type": "textarea",
|
|
82
|
+
"label": "退款原因",
|
|
83
|
+
"required": true,
|
|
84
|
+
"maxLength": 200
|
|
85
|
+
},
|
|
86
|
+
"method": {
|
|
87
|
+
"type": "single_select",
|
|
88
|
+
"label": "退款方式",
|
|
89
|
+
"required": true,
|
|
90
|
+
"options": [
|
|
91
|
+
{ "label": "原路退回", "value": "original" },
|
|
92
|
+
{ "label": "余额退回", "value": "balance" }
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"submit_label": "提交信息",
|
|
97
|
+
"cancel_label": "取消"
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
````
|
|
101
|
+
|
|
102
|
+
顶层只接受 `version:1`、`form_id`、`title`、`description?`、`schema`、`submit_label?`、`cancel_label?`。`form_id` 和字段名匹配 `[a-z][a-z0-9_-]{0,63}`;单个 fenced JSON 最大 32 KiB,`schema` 包含 1–12 个字段。标题和字段标签最长 80 字符,顶层说明 300,字段说明 200,占位文字 120,按钮文字 32。
|
|
103
|
+
|
|
104
|
+
| `type` | 额外字段与限制 |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `text` | `minLength?` / `maxLength?`,最长上限 500 |
|
|
107
|
+
| `textarea` | `minLength?` / `maxLength?`,最长上限 2000 |
|
|
108
|
+
| `number` | 可选有限数值 `min?` / `max?` |
|
|
109
|
+
| `date` | 可选 `min?` / `max?`,格式固定为 `YYYY-MM-DD` |
|
|
110
|
+
| `boolean` | 无额外字段 |
|
|
111
|
+
| `single_select` | 必填 `options`,1–50 项,单选 |
|
|
112
|
+
| `multi_select` | 必填 `options`,1–50 项,多选 |
|
|
113
|
+
|
|
114
|
+
所有字段可使用 `label`、`description?`、`placeholder?`、`required?`。选项只包含 `{label,value}`,label 最长 80、value 最长 120,且同一字段的 value 唯一。未声明字段、嵌套对象、文件、正则表达式、HTML/JavaScript/CSS、远程脚本/数据源和内含三反引号的值会被拒绝。
|
|
115
|
+
|
|
116
|
+
### 提交、回执与历史恢复
|
|
117
|
+
|
|
118
|
+
1. 表单只在源回答完整 `done` 后挂载,源 job 不会进入等待状态。
|
|
119
|
+
2. 用户提交或取消后,Widget 将 `interaction_response` 发往原入口,服务端在同 thread 创建新 job,再走既有 SSE 流。
|
|
120
|
+
3. 发送中控件禁用;创建新 job 成功后,源表单变为只读的“已提交”或“已取消”回执。请求失败时恢复控件,不把本地点击冒充成功。
|
|
121
|
+
4. `/thread` 返回的用户消息可带 `interaction` 摘要;Widget 用 `source_job_id + form_id` 重建已回复状态,跨设备/刷新后不会再显示可重复提交的表单。
|
|
122
|
+
|
|
123
|
+
表单只用来收集普通信息或选择,不是审批单、授权凭据或工具执行确认。表单标题/说明、字段名/标签/说明/占位文字如疑似密码、API Key、Token、私钥、银行卡号或 CVV 会被拒绝;部署方还应注意,用户提交的非秘密值会作为对话消息进入总账和模型上下文,须按自己的数据保留与合规规则使用。
|
|
124
|
+
|
|
59
125
|
## 加载顺序
|
|
60
126
|
|
|
61
127
|
### Widget 加载后注册
|
|
@@ -105,7 +171,7 @@ Content-Type: application/json
|
|
|
105
171
|
"message": "分析近七日营业额",
|
|
106
172
|
"visitor_id": "visitor_01HXYZ",
|
|
107
173
|
"client_capabilities": {
|
|
108
|
-
"renderers": ["bailing-chart"]
|
|
174
|
+
"renderers": ["bailing-chart", "bailing-form"]
|
|
109
175
|
}
|
|
110
176
|
}
|
|
111
177
|
```
|
|
@@ -113,7 +179,7 @@ Content-Type: application/json
|
|
|
113
179
|
`client_capabilities` 只用于回答呈现提示:
|
|
114
180
|
|
|
115
181
|
- 不提供时,中枢不会因为客户端“可能支持图表”而主动要求模型输出图表;
|
|
116
|
-
- 声明 `bailing-chart` 只表示客户端能安全展示该声明,不改变身份、权限、审批、路由、工具白名单或业务授权;
|
|
182
|
+
- 声明 `bailing-chart` 或 `bailing-form` 只表示客户端能安全展示该声明,不改变身份、权限、审批、路由、工具白名单或业务授权;
|
|
117
183
|
- 不要把尚未安装的渲染器写进能力列表;服务端最多接受 16 个符合命名规则的类型;
|
|
118
184
|
- 运行时是否输出图表仍由真实数据和表达需要决定,不能用图表填补缺失数据。
|
|
119
185
|
|
|
@@ -122,11 +188,13 @@ Content-Type: application/json
|
|
|
122
188
|
1. `delta` 只追加到临时文本气泡,不在增量阶段执行富内容渲染;
|
|
123
189
|
2. `reset` 立即清空临时文本和对应渲染状态;
|
|
124
190
|
3. `done.reply` 是权威最终文本,必须替换临时气泡;
|
|
125
|
-
4. 只有 `done` 到达后,才用成熟 Markdown 解析器读取完整 fenced code block
|
|
191
|
+
4. 只有 `done` 到达后,才用成熟 Markdown 解析器读取完整 fenced code block,并把白名单类型交给可信渲染器;表单回传必须保留此 `done.job_id` 作为 `source_job_id`;
|
|
126
192
|
5. `failed` 或 `timeout` 不得把临时文本冒充成最终业务结果。
|
|
127
193
|
|
|
128
194
|
最小传输范例见 [`docs/examples/custom-streaming-chat-client.mjs`](examples/custom-streaming-chat-client.mjs)。它故意不包含 Markdown 解析器和图表库:业务前端应复用自己的 Markdown AST/token 流,在 fenced code token 层识别渲染类型,不要用 `eval`、`innerHTML` 或远程脚本解释模型输出。
|
|
129
195
|
|
|
196
|
+
自建客户端提交表单时,向同一 `POST /chat/:entry_key` 发送 `{interaction_response:{type:"bailing-form",version:1,source_job_id,form_id,submission_id,action,values?}, visitor_id?, ticket?, thread_id?}`。服务端会核对源 job/入口/身份/thread,从权威回复重新取 schema 验值,并以 `submission_id` 幂等去重;客户端不得同时发 `message`,也不得把自己的 schema 当作权威传回。完整 HTTP 契约见 [CONTRACT.md §1.1.1](CONTRACT.md#111-bailing-form-非阻塞交互回传)。
|
|
197
|
+
|
|
130
198
|
### 自建渲染器的最低门槛
|
|
131
199
|
|
|
132
200
|
- 类型必须命中本地白名单,例如只接受 `bailing-chart`;
|
|
@@ -135,5 +203,6 @@ Content-Type: application/json
|
|
|
135
203
|
- 未知类型、解析失败、超限或渲染异常必须回退成普通代码块/文本,不得放宽校验重试;
|
|
136
204
|
- 最终消息替换、路由切换和组件卸载时,应销毁图表实例与监听器;
|
|
137
205
|
- 附件、引用、图表和业务执行结果是不同契约,不能互相推断。
|
|
206
|
+
- `bailing-form` 须实现本文的字段白名单、范围验证、唯一提交标识、失败恢复和历史回执;不得把任意 JSON Schema 直接交给动态表单引擎。
|
|
138
207
|
|
|
139
208
|
一句话判断:官方 Widget 负责开箱即用;自建客户端负责能力自报、SSE 生命周期、最终文本解析和可信渲染,BailingHub 不会把宿主前端的安全责任隐式接管。
|
|
@@ -39,6 +39,14 @@ Knowledge bases provide retrievable documents such as manuals, policies, product
|
|
|
39
39
|
|
|
40
40
|
A web chat entry binds a public widget to a route. A business backend may sign a visitor ticket so the hub can carry a trusted acting subject into business-tool calls.
|
|
41
41
|
|
|
42
|
+
The standalone link opened from the console is only an anonymous preview. It
|
|
43
|
+
does not inherit the BailingHub administrator session and has no business-login
|
|
44
|
+
surface of its own. Every tool that requires an acting subject, including
|
|
45
|
+
read-only queries and write operations, remains hidden. For authenticated use,
|
|
46
|
+
the business backend signs the identity ticket from its own user session; the
|
|
47
|
+
business system still makes the final authorization decision, and a BailingHub
|
|
48
|
+
administrator is never promoted to a business acting subject.
|
|
49
|
+
|
|
42
50
|
## Inbound Channel
|
|
43
51
|
|
|
44
52
|
An inbound channel adapts messages from systems such as WeCom, DingTalk, or Feishu into a route. Channel credentials and reply constraints stay in the channel adapter, not the route core.
|
|
@@ -66,4 +74,3 @@ For “let logged-in users ask about their order and create a support request,
|
|
|
66
74
|
- support knowledge;
|
|
67
75
|
- the final reply or callback path;
|
|
68
76
|
- approval only for operations that require it.
|
|
69
|
-
|
|
@@ -148,7 +148,9 @@
|
|
|
148
148
|
|
|
149
149
|
聊天入口解决的是“用户从网页上怎么和这条路由对话”。
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
控制台打开的独立链接只是匿名预览:不继承中枢管理员登录态,也没有独立业务登录入口。所有声明需要主体的工具,包括只读查询和写操作,都会保持不可见。
|
|
152
|
+
|
|
153
|
+
如果需要让已登录业务用户带可信身份,业务后端应在自己的登录态里签发身份票据,组件带票进入中枢。中枢只验证票据,真正的权限仍由业务系统在工具接口里裁决;中枢管理员身份不会自动转换为业务操作主体。
|
|
152
154
|
|
|
153
155
|
## 入站渠道:让外部平台消息进中枢
|
|
154
156
|
|
|
@@ -30,7 +30,7 @@ Create a base, select an embedding credential, ingest documents or data sources,
|
|
|
30
30
|
|
|
31
31
|
## Web Chat Entries
|
|
32
32
|
|
|
33
|
-
Bind a widget to a route, configure origins, appearance, welcome text, identity ticket behavior, AI disclosure, and embed code.
|
|
33
|
+
Bind a widget to a route, configure exact HTTP(S) origins in `scheme://host[:port]` form, appearance (including optional default-open behavior), welcome text, identity ticket behavior, AI disclosure, and embed code.
|
|
34
34
|
|
|
35
35
|
## Inbound Channels
|
|
36
36
|
|
|
@@ -55,4 +55,3 @@ Review build version, contract versions, migration state, runtime backend, and c
|
|
|
55
55
|
## Accounts And Change Audit
|
|
56
56
|
|
|
57
57
|
Accounts control console RBAC. Change Audit records who changed configuration and when. These are administrative controls for the single organization operating the open-source instance.
|
|
58
|
-
|