bailinghub 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (716) hide show
  1. package/.dockerignore +42 -0
  2. package/.env.example +83 -0
  3. package/.gitignore +44 -0
  4. package/.npmignore +56 -0
  5. package/CODE_OF_CONDUCT.md +24 -0
  6. package/CONTRIBUTING.md +74 -0
  7. package/Dockerfile +16 -0
  8. package/LICENSE +176 -0
  9. package/LICENSING.md +9 -0
  10. package/NOTICE +23 -0
  11. package/README.en.md +264 -0
  12. package/README.md +279 -0
  13. package/SECURITY.md +30 -0
  14. package/THIRD_PARTY_NOTICES.md +254 -0
  15. package/VISION.md +41 -0
  16. package/assets/architecture-overview.en-dark.png +0 -0
  17. package/assets/architecture-overview.en-dark.svg +57 -0
  18. package/assets/architecture-overview.en.png +0 -0
  19. package/assets/architecture-overview.en.svg +57 -0
  20. package/assets/architecture-overview.zh-CN-dark.png +0 -0
  21. package/assets/architecture-overview.zh-CN-dark.svg +57 -0
  22. package/assets/architecture-overview.zh-CN.png +0 -0
  23. package/assets/architecture-overview.zh-CN.svg +57 -0
  24. package/assets/bailinghub-lockup-dark.png +0 -0
  25. package/assets/bailinghub-lockup-dark.svg +8 -0
  26. package/assets/bailinghub-lockup.png +0 -0
  27. package/assets/bailinghub-lockup.svg +8 -0
  28. package/brain/README.en.md +23 -0
  29. package/brain/README.md +45 -0
  30. package/brain/agents/code-review.md +41 -0
  31. package/brain/agents/triage.md +37 -0
  32. package/brain/profiles.json +114 -0
  33. package/brain/runbooks/ticket-triage.md +24 -0
  34. package/config.example.json +58 -0
  35. package/contracts/client-api/consumers.json +28 -0
  36. package/contracts/client-api/v1/error-response.schema.json +21 -0
  37. package/contracts/client-api/v1/health-response.schema.json +13 -0
  38. package/contracts/client-api/v1/job-response.schema.json +49 -0
  39. package/contracts/client-api/v1/manifest.json +63 -0
  40. package/contracts/client-api/v1/run-request.schema.json +42 -0
  41. package/contracts/client-api/v1/submit-response.schema.json +35 -0
  42. package/contracts/client-api/v1/vectors.json +153 -0
  43. package/demo/business/Dockerfile +8 -0
  44. package/demo/business/server.mjs +483 -0
  45. package/docker-compose.images.yml +67 -0
  46. package/docker-compose.yml +79 -0
  47. package/docs/AI_FRIENDLY_TOOLS.en.md +69 -0
  48. package/docs/AI/345/217/213/345/245/275/345/267/245/345/205/267/350/256/276/350/256/241/346/214/207/345/215/227.md +198 -0
  49. package/docs/ARCHITECTURE.en.md +81 -0
  50. package/docs/ARCHITECTURE.md +795 -0
  51. package/docs/CHANGELOG.en.md +275 -0
  52. package/docs/CHANGELOG.md +279 -0
  53. package/docs/CHANNELS.en.md +35 -0
  54. package/docs/CHANNELS.md +72 -0
  55. package/docs/CLIENT_API.md +89 -0
  56. package/docs/COMPATIBILITY.en.md +103 -0
  57. package/docs/CONTRACT.en.md +254 -0
  58. package/docs/CONTRACT.md +653 -0
  59. package/docs/DEMO.en.md +90 -0
  60. package/docs/DEMO.md +297 -0
  61. package/docs/ECOSYSTEM.en.md +39 -0
  62. package/docs/ECOSYSTEM.md +39 -0
  63. package/docs/INDEPENDENT_VALIDATION.en.md +184 -0
  64. package/docs/INDEPENDENT_VALIDATION.md +184 -0
  65. package/docs/INTEGRATION.en.md +120 -0
  66. package/docs/KERNEL_HOST_API.en.md +59 -0
  67. package/docs/KERNEL_HOST_API.md +59 -0
  68. package/docs/OPERATIONS.en.md +182 -0
  69. package/docs/OPERATIONS.md +231 -0
  70. package/docs/PIPELINE.en.md +74 -0
  71. package/docs/PIPELINE.md +67 -0
  72. package/docs/QUICKSTART.en.md +297 -0
  73. package/docs/QUICKSTART.md +152 -0
  74. package/docs/README.en.md +103 -0
  75. package/docs/README.md +119 -0
  76. package/docs/RELEASE_NOTES_v0.1.0.en.md +46 -0
  77. package/docs/RELEASE_NOTES_v0.1.0.md +66 -0
  78. package/docs/RELEASE_NOTES_v0.1.1.en.md +38 -0
  79. package/docs/RELEASE_NOTES_v0.1.1.md +38 -0
  80. package/docs/RELEASE_NOTES_v0.1.10.en.md +102 -0
  81. package/docs/RELEASE_NOTES_v0.1.10.md +102 -0
  82. package/docs/RELEASE_NOTES_v0.1.11.en.md +99 -0
  83. package/docs/RELEASE_NOTES_v0.1.11.md +99 -0
  84. package/docs/RELEASE_NOTES_v0.1.12.en.md +64 -0
  85. package/docs/RELEASE_NOTES_v0.1.12.md +64 -0
  86. package/docs/RELEASE_NOTES_v0.1.13.en.md +46 -0
  87. package/docs/RELEASE_NOTES_v0.1.13.md +46 -0
  88. package/docs/RELEASE_NOTES_v0.1.14.en.md +55 -0
  89. package/docs/RELEASE_NOTES_v0.1.14.md +55 -0
  90. package/docs/RELEASE_NOTES_v0.1.15.en.md +50 -0
  91. package/docs/RELEASE_NOTES_v0.1.15.md +50 -0
  92. package/docs/RELEASE_NOTES_v0.1.16.en.md +106 -0
  93. package/docs/RELEASE_NOTES_v0.1.16.md +105 -0
  94. package/docs/RELEASE_NOTES_v0.1.2.en.md +39 -0
  95. package/docs/RELEASE_NOTES_v0.1.2.md +39 -0
  96. package/docs/RELEASE_NOTES_v0.1.3.en.md +55 -0
  97. package/docs/RELEASE_NOTES_v0.1.3.md +55 -0
  98. package/docs/RELEASE_NOTES_v0.1.4.en.md +55 -0
  99. package/docs/RELEASE_NOTES_v0.1.4.md +55 -0
  100. package/docs/RELEASE_NOTES_v0.1.5.en.md +49 -0
  101. package/docs/RELEASE_NOTES_v0.1.5.md +49 -0
  102. package/docs/RELEASE_NOTES_v0.1.6.en.md +41 -0
  103. package/docs/RELEASE_NOTES_v0.1.6.md +41 -0
  104. package/docs/RELEASE_NOTES_v0.1.7.en.md +39 -0
  105. package/docs/RELEASE_NOTES_v0.1.7.md +39 -0
  106. package/docs/RELEASE_NOTES_v0.1.8.en.md +88 -0
  107. package/docs/RELEASE_NOTES_v0.1.8.md +88 -0
  108. package/docs/RELEASE_NOTES_v0.1.9.en.md +127 -0
  109. package/docs/RELEASE_NOTES_v0.1.9.md +127 -0
  110. package/docs/RELEASE_NOTES_v0.2.0.en.md +95 -0
  111. package/docs/RELEASE_NOTES_v0.2.0.md +96 -0
  112. package/docs/RELEASE_NOTES_v0.3.0.en.md +77 -0
  113. package/docs/RELEASE_NOTES_v0.3.0.md +77 -0
  114. package/docs/SDK.en.md +177 -0
  115. package/docs/STREAMING.en.md +78 -0
  116. package/docs/STREAMING.md +109 -0
  117. package/docs/TOOLS.en.md +205 -0
  118. package/docs/TOOLS_DESIGN.en.md +142 -0
  119. package/docs/TOOLS_DESIGN.md +466 -0
  120. package/docs/TOOLS_MODEL.en.md +56 -0
  121. package/docs/TOOLS_MODEL.md +903 -0
  122. package/docs/WIDGET_RENDERERS.en.md +133 -0
  123. package/docs/WIDGET_RENDERERS.md +139 -0
  124. package/docs/examples/bailing-tool-verify.mjs +94 -0
  125. package/docs/examples/bailing-tool-verify.php +154 -0
  126. package/docs/examples/bailing-tool-verify.py +107 -0
  127. package/docs/examples/custom-streaming-chat-client.mjs +108 -0
  128. package/docs/examples/widget-chart-renderer-adapter.mjs +44 -0
  129. package/docs/integrations/bailian/README.en.md +181 -0
  130. package/docs/integrations/bailian/README.md +165 -0
  131. package/docs/integrations/bailian/bailian-mcp-config.json +17 -0
  132. package/docs/integrations/bailian/verify_recipe.py +97 -0
  133. package/docs/integrations/deepseek/README.en.md +225 -0
  134. package/docs/integrations/deepseek/README.md +225 -0
  135. package/docs/integrations/deepseek/verify_e2e.py +131 -0
  136. package/docs/integrations/dify/README.en.md +131 -0
  137. package/docs/integrations/dify/README.md +131 -0
  138. package/docs/integrations/dify/bailinghub-control-plane.openapi.json +129 -0
  139. package/docs/integrations/dify/verify_contract.py +88 -0
  140. package/docs/integrations/dify/verify_e2e.py +117 -0
  141. package/docs/integrations/jeecgboot/README.en.md +193 -0
  142. package/docs/integrations/jeecgboot/README.md +161 -0
  143. package/docs/integrations/jeecgboot/adapter-contract.v1.json +94 -0
  144. package/docs/integrations/jeecgboot/jeecgboot-user-adapter.openapi.json +183 -0
  145. package/docs/integrations/jeecgboot/verify_recipe.mjs +97 -0
  146. package/docs/integrations/ruoyi-vue-pro/README.en.md +91 -0
  147. package/docs/integrations/ruoyi-vue-pro/README.md +155 -0
  148. package/docs/integrations/ruoyi-vue-pro/adapter-contract.v1.json +71 -0
  149. package/docs/integrations/ruoyi-vue-pro/ruoyi-vue-pro-trade-adapter.openapi.json +148 -0
  150. package/docs/integrations/ruoyi-vue-pro/verify_recipe.mjs +71 -0
  151. package/docs/user-guide/README.en.md +39 -0
  152. package/docs/user-guide/README.md +40 -0
  153. package/docs/user-guide/concepts.en.md +69 -0
  154. package/docs/user-guide/concepts.md +225 -0
  155. package/docs/user-guide/console-map.en.md +58 -0
  156. package/docs/user-guide/console-map.md +473 -0
  157. package/docs/user-guide/overview.en.md +61 -0
  158. package/docs/user-guide/overview.md +156 -0
  159. package/docs/user-guide/scenarios.en.md +70 -0
  160. package/docs/user-guide/scenarios.md +398 -0
  161. package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +134 -0
  162. package/docs//347/254/254/344/270/211/346/226/271/345/257/271/346/216/245/346/214/207/345/215/227.md +625 -0
  163. package/package.json +119 -0
  164. package/schemas/agent-capability-contract.schema.json +104 -0
  165. package/schemas/api/approval-decision.schema.json +28 -0
  166. package/schemas/api/approval-request.schema.json +31 -0
  167. package/schemas/api/delivery-callback.schema.json +28 -0
  168. package/schemas/api/job-response.schema.json +6 -0
  169. package/schemas/api/kb-doc-upsert.schema.json +21 -0
  170. package/schemas/api/run-request.schema.json +6 -0
  171. package/schemas/api/run-response.schema.json +6 -0
  172. package/schemas/api/tool-spec.schema.json +38 -0
  173. package/schemas/config/alert-rule.schema.json +22 -0
  174. package/schemas/config/channel.schema.json +91 -0
  175. package/schemas/config/chat-entry.schema.json +47 -0
  176. package/schemas/config/client.schema.json +56 -0
  177. package/schemas/config/common.schema.json +215 -0
  178. package/schemas/config/credential.schema.json +48 -0
  179. package/schemas/config/executor-token.schema.json +20 -0
  180. package/schemas/config/page-context.schema.json +21 -0
  181. package/schemas/config/route.schema.json +152 -0
  182. package/schemas/config/storage-bucket.schema.json +31 -0
  183. package/schemas/config/target.schema.json +17 -0
  184. package/schemas/config/tool-provider.schema.json +60 -0
  185. package/schemas/tool-definition.schema.json +188 -0
  186. package/scripts/check-client-api-ecosystem.mjs +69 -0
  187. package/scripts/check-doc-links.mjs +136 -0
  188. package/scripts/check-image-tags.sh +43 -0
  189. package/scripts/check-package-artifact.mjs +185 -0
  190. package/scripts/check-release-consistency.mjs +199 -0
  191. package/scripts/check-release-consistency.test.mjs +63 -0
  192. package/scripts/client-api-contract-test.ts +127 -0
  193. package/scripts/create-admin.ts +27 -0
  194. package/scripts/demo-e2e.ts +133 -0
  195. package/scripts/docker-entrypoint.sh +33 -0
  196. package/scripts/doctor.ts +107 -0
  197. package/scripts/e2e-console.mjs +214 -0
  198. package/scripts/export-oss.mjs +204 -0
  199. package/scripts/generate-readme-assets.mjs +181 -0
  200. package/scripts/generate-third-party-notices.mjs +93 -0
  201. package/scripts/image-release-policy.mjs +75 -0
  202. package/scripts/image-release-policy.test.mjs +58 -0
  203. package/scripts/init-db.ts +21 -0
  204. package/scripts/install.sh +461 -0
  205. package/scripts/oss-boundary-check.mjs +183 -0
  206. package/scripts/publish-images.sh +63 -0
  207. package/scripts/publish-mysql-image.sh +41 -0
  208. package/scripts/release-audit.mjs +348 -0
  209. package/scripts/sdk-contract-test.ts +62 -0
  210. package/scripts/sdk-p1-check.mjs +58 -0
  211. package/scripts/sdk-runtime-test.mjs +106 -0
  212. package/scripts/security-scan.mjs +110 -0
  213. package/scripts/seed-demo.ts +116 -0
  214. package/scripts/selftest.ts +226 -0
  215. package/scripts/smoke.ts +31 -0
  216. package/scripts/validate-examples.mjs +93 -0
  217. package/scripts/verify-bootstrap-admin-restart.ts +66 -0
  218. package/scripts/verify-github-repo.mjs +195 -0
  219. package/scripts/verify-oss-export.mjs +192 -0
  220. package/scripts/verify-routing.ts +29 -0
  221. package/scripts/widget-renderer-test.mjs +206 -0
  222. package/scripts/write-build-info.mjs +29 -0
  223. package/sdk/dotnet/Bailing.Connect/Bailing.Connect.csproj +12 -0
  224. package/sdk/dotnet/Bailing.Connect/BailingConnect.cs +260 -0
  225. package/sdk/dotnet/README.md +32 -0
  226. package/sdk/dotnet/examples/BuildSpec/BuildSpec.csproj +11 -0
  227. package/sdk/dotnet/examples/BuildSpec/Program.cs +36 -0
  228. package/sdk/go/README.md +33 -0
  229. package/sdk/go/bailingconnect/connect.go +367 -0
  230. package/sdk/go/examples/build-spec/main.go +39 -0
  231. package/sdk/go/go.mod +3 -0
  232. package/sdk/java/README.md +43 -0
  233. package/sdk/java/examples/BuildSpec.java +31 -0
  234. package/sdk/java/src/main/java/com/bailing/connect/BailingConnect.java +376 -0
  235. package/sdk/node/README.md +107 -0
  236. package/sdk/node/examples/build-spec.mjs +84 -0
  237. package/sdk/node/package.json +22 -0
  238. package/sdk/node/src/index.mjs +250 -0
  239. package/sdk/php/README.md +204 -0
  240. package/sdk/php/composer.json +18 -0
  241. package/sdk/php/examples/DemoStaffController.php +108 -0
  242. package/sdk/php/examples/build-spec.php +27 -0
  243. package/sdk/php/examples/thinkphp-integration.php +81 -0
  244. package/sdk/php/src/Attributes/AiParam.php +40 -0
  245. package/sdk/php/src/Attributes/AiTool.php +75 -0
  246. package/sdk/php/src/HubClient.php +122 -0
  247. package/sdk/php/src/SpecBuilder.php +328 -0
  248. package/sdk/php/src/SpecServer.php +209 -0
  249. package/sdk/php/src/Ticket.php +37 -0
  250. package/sdk/php/src/Verify.php +178 -0
  251. package/sdk/php7/README.md +191 -0
  252. package/sdk/php7/composer.json +18 -0
  253. package/sdk/php7/examples/build-spec.php +68 -0
  254. package/sdk/php7/examples/well-known.php +33 -0
  255. package/sdk/php7/src/HubClient.php +111 -0
  256. package/sdk/php7/src/SpecServer.php +203 -0
  257. package/sdk/php7/src/Ticket.php +33 -0
  258. package/sdk/php7/src/ToolDef.php +169 -0
  259. package/sdk/php7/src/ToolSpec.php +334 -0
  260. package/sdk/php7/src/Verify.php +165 -0
  261. package/sdk/python/README.md +107 -0
  262. package/sdk/python/bailing_connect/__init__.py +307 -0
  263. package/sdk/python/examples/build_spec.py +90 -0
  264. package/sdk/python/pyproject.toml +24 -0
  265. package/sql/001_init_state.sql +66 -0
  266. package/sql/002_routes.sql +44 -0
  267. package/sql/003_executor.sql +15 -0
  268. package/sql/004_clients.sql +22 -0
  269. package/sql/005_admins.sql +25 -0
  270. package/sql/006_ledger.sql +57 -0
  271. package/sql/007_delivery.sql +8 -0
  272. package/sql/008_kb.sql +66 -0
  273. package/sql/009_rbac.sql +5 -0
  274. package/sql/010_targets.sql +28 -0
  275. package/sql/011_observability.sql +11 -0
  276. package/sql/012_generic.sql +5 -0
  277. package/sql/013_tools.sql +24 -0
  278. package/sql/014_approvals.sql +27 -0
  279. package/sql/015_chat.sql +21 -0
  280. package/sql/016_chat_feedback.sql +19 -0
  281. package/sql/017_provider_autorefresh.sql +6 -0
  282. package/sql/018_kb_ingest.sql +11 -0
  283. package/sql/019_kb_datasources.sql +32 -0
  284. package/sql/022_storage_buckets.sql +25 -0
  285. package/sql/024_channels.sql +15 -0
  286. package/sql/025_chat_appearance.sql +7 -0
  287. package/sql/026_thread_memory.sql +10 -0
  288. package/sql/027_page_contexts.sql +23 -0
  289. package/sql/028_executor_capabilities.sql +4 -0
  290. package/sql/029_executor_tokens.sql +13 -0
  291. package/sql/030_route_permission.sql +5 -0
  292. package/sql/031_tool_embeddings.sql +20 -0
  293. package/sql/032_tool_provider_embed.sql +7 -0
  294. package/sql/033_alert_rules.sql +21 -0
  295. package/sql/034_client_allowed_channels.sql +6 -0
  296. package/sql/035_tool_idempotency.sql +15 -0
  297. package/sql/036_delivery_dlq.sql +15 -0
  298. package/sql/038_audit_trace_shape.sql +15 -0
  299. package/sql/039_runtime_locks.sql +9 -0
  300. package/sql/040_budget_policy.sql +3 -0
  301. package/sql/041_approval_intent.sql +14 -0
  302. package/sql/042_approval_decision_contract.sql +11 -0
  303. package/sql/043_rate_limits.sql +7 -0
  304. package/sql/044_job_run_after.sql +3 -0
  305. package/sql/045_job_claim_lease.sql +7 -0
  306. package/sql/046_tool_authz_probe.sql +5 -0
  307. package/sql/047_route_audience.sql +4 -0
  308. package/sql/048_llm_target.sql +17 -0
  309. package/sql/049_llm_input_shape.sql +11 -0
  310. package/sql/050_operational_metrics_indexes.sql +8 -0
  311. package/sql/051_instance_branding.sql +17 -0
  312. package/sql/052_tool_execution_journal.sql +19 -0
  313. package/sql/053_tool_spec_access_policy.sql +9 -0
  314. package/sql/README.en.md +41 -0
  315. package/sql/README.md +40 -0
  316. package/src/adapters/channels/wecom-api.test.ts +77 -0
  317. package/src/adapters/channels/wecom-api.ts +224 -0
  318. package/src/adapters/channels/wecom-crypto.test.ts +85 -0
  319. package/src/adapters/channels/wecom-crypto.ts +77 -0
  320. package/src/adapters/executors/claudecode.ts +39 -0
  321. package/src/adapters/executors/profiles.ts +86 -0
  322. package/src/adapters/executors/report.ts +35 -0
  323. package/src/adapters/executors/runner.ts +114 -0
  324. package/src/adapters/executors/wecomnotify.ts +63 -0
  325. package/src/adapters/llm/file.test.ts +81 -0
  326. package/src/adapters/llm/file.ts +250 -0
  327. package/src/adapters/llm/openai-chat-stream.test.ts +74 -0
  328. package/src/adapters/llm/openai-chat-stream.ts +154 -0
  329. package/src/adapters/llm/perception.ts +159 -0
  330. package/src/adapters/llm/speech.test.ts +75 -0
  331. package/src/adapters/llm/speech.ts +146 -0
  332. package/src/adapters/storage/object-storage.test.ts +38 -0
  333. package/src/adapters/storage/object-storage.ts +140 -0
  334. package/src/adapters/targets/demo-agent.ts +88 -0
  335. package/src/adapters/targets/llm.test.ts +733 -0
  336. package/src/adapters/targets/llm.ts +862 -0
  337. package/src/app/admin-bootstrap.test.ts +112 -0
  338. package/src/app/admin-bootstrap.ts +48 -0
  339. package/src/app/auth-default.ts +26 -0
  340. package/src/app/auth.test.ts +57 -0
  341. package/src/app/auth.ts +207 -0
  342. package/src/app/builtin-tools-default.ts +17 -0
  343. package/src/app/builtin-tools.test.ts +202 -0
  344. package/src/app/builtin-tools.ts +380 -0
  345. package/src/app/channels-default.ts +8 -0
  346. package/src/app/channels.ts +141 -0
  347. package/src/app/delivery-default.ts +14 -0
  348. package/src/app/delivery.test.ts +46 -0
  349. package/src/app/delivery.ts +215 -0
  350. package/src/app/engine-default.ts +54 -0
  351. package/src/app/engine.ts +427 -0
  352. package/src/app/http-mount.test.ts +27 -0
  353. package/src/app/http-server.test.ts +114 -0
  354. package/src/app/http-server.ts +127 -0
  355. package/src/app/http.test.ts +27 -0
  356. package/src/app/http.ts +118 -0
  357. package/src/app/kernel.test.ts +191 -0
  358. package/src/app/kernel.ts +544 -0
  359. package/src/app/monitor-default.ts +9 -0
  360. package/src/app/monitor.ts +46 -0
  361. package/src/app/operational-metrics.test.ts +73 -0
  362. package/src/app/operational-metrics.ts +124 -0
  363. package/src/app/oss-edition.test.ts +71 -0
  364. package/src/app/oss-edition.ts +108 -0
  365. package/src/app/outbound-default.ts +57 -0
  366. package/src/app/outbound.ts +133 -0
  367. package/src/app/readiness.test.ts +37 -0
  368. package/src/app/readiness.ts +39 -0
  369. package/src/app/runtime-composition.test.ts +51 -0
  370. package/src/app/runtime-composition.ts +73 -0
  371. package/src/app/runtime-context-default.ts +30 -0
  372. package/src/app/runtime-context.test.ts +60 -0
  373. package/src/app/runtime-context.ts +79 -0
  374. package/src/app/runtime-lifecycle-default.ts +48 -0
  375. package/src/app/runtime-lifecycle.test.ts +322 -0
  376. package/src/app/runtime-lifecycle.ts +440 -0
  377. package/src/app/runtime.ts +36 -0
  378. package/src/app/tool-approvals-default.ts +16 -0
  379. package/src/app/tool-approvals.ts +214 -0
  380. package/src/app/tool-assembly-default.ts +11 -0
  381. package/src/app/tool-assembly.test.ts +112 -0
  382. package/src/app/tool-assembly.ts +83 -0
  383. package/src/app/tool-context-default.ts +7 -0
  384. package/src/app/tool-context.test.ts +82 -0
  385. package/src/app/tool-context.ts +109 -0
  386. package/src/app/tool-debug.test.ts +111 -0
  387. package/src/app/tool-debug.ts +152 -0
  388. package/src/app/tool-proxy-default.ts +35 -0
  389. package/src/app/tool-proxy.ts +173 -0
  390. package/src/app/tool-specs-default.ts +33 -0
  391. package/src/app/tool-specs.test.ts +322 -0
  392. package/src/app/tool-specs.ts +555 -0
  393. package/src/app/tools-runtime-default.ts +14 -0
  394. package/src/app/tools-runtime.ts +23 -0
  395. package/src/architecture-boundary.test.ts +119 -0
  396. package/src/core/config/config-codec.test.ts +105 -0
  397. package/src/core/config/config-codec.ts +231 -0
  398. package/src/core/config/config-diagnostics.test.ts +285 -0
  399. package/src/core/config/config-diagnostics.ts +436 -0
  400. package/src/core/config/config-models.test.ts +584 -0
  401. package/src/core/config/config-models.ts +392 -0
  402. package/src/core/config/config-schema.test.ts +153 -0
  403. package/src/core/config/config.test.ts +314 -0
  404. package/src/core/config/config.ts +324 -0
  405. package/src/core/config/route-config.test.ts +232 -0
  406. package/src/core/config/route-config.ts +246 -0
  407. package/src/core/config/target-config.test.ts +139 -0
  408. package/src/core/config/target-config.ts +219 -0
  409. package/src/core/config/tools-config.test.ts +124 -0
  410. package/src/core/config/tools-config.ts +126 -0
  411. package/src/core/contracts/approval-decision.test.ts +67 -0
  412. package/src/core/contracts/approval-decision.ts +93 -0
  413. package/src/core/contracts/openapi-tools.ts +201 -0
  414. package/src/core/contracts/tool-annotations.ts +121 -0
  415. package/src/core/contracts/tool-definition.test.ts +147 -0
  416. package/src/core/contracts/tool-definition.ts +304 -0
  417. package/src/core/contracts/tools-idempotency.test.ts +435 -0
  418. package/src/core/contracts/tools.test.ts +487 -0
  419. package/src/core/contracts/tools.ts +831 -0
  420. package/src/core/contracts/types.ts +408 -0
  421. package/src/core/edition/capabilities.ts +6 -0
  422. package/src/core/edition/context.test.ts +20 -0
  423. package/src/core/edition/context.ts +78 -0
  424. package/src/core/edition/index.ts +4 -0
  425. package/src/core/edition/scope-resolver.ts +24 -0
  426. package/src/core/edition/store-factory.ts +6 -0
  427. package/src/core/observability/openmetrics.test.ts +57 -0
  428. package/src/core/observability/openmetrics.ts +103 -0
  429. package/src/core/platform/content.test.ts +46 -0
  430. package/src/core/platform/content.ts +90 -0
  431. package/src/core/platform/fence.test.ts +31 -0
  432. package/src/core/platform/fence.ts +11 -0
  433. package/src/core/platform/instance-branding.test.ts +65 -0
  434. package/src/core/platform/instance-branding.ts +202 -0
  435. package/src/core/platform/metrics-token.test.ts +31 -0
  436. package/src/core/platform/metrics-token.ts +42 -0
  437. package/src/core/platform/pagecontext.ts +0 -0
  438. package/src/core/platform/password.test.ts +13 -0
  439. package/src/core/platform/password.ts +38 -0
  440. package/src/core/platform/queue.test.ts +59 -0
  441. package/src/core/platform/queue.ts +75 -0
  442. package/src/core/platform/serial.test.ts +73 -0
  443. package/src/core/platform/serial.ts +64 -0
  444. package/src/core/platform/server-token.test.ts +46 -0
  445. package/src/core/platform/server-token.ts +60 -0
  446. package/src/core/platform/signing.test.ts +24 -0
  447. package/src/core/platform/signing.ts +22 -0
  448. package/src/core/platform/time.ts +73 -0
  449. package/src/core/platform/version.test.ts +19 -0
  450. package/src/core/platform/version.ts +90 -0
  451. package/src/core/runtime/budget-runtime.test.ts +93 -0
  452. package/src/core/runtime/budget-runtime.ts +110 -0
  453. package/src/core/runtime/context-runtime.test.ts +106 -0
  454. package/src/core/runtime/context-runtime.ts +95 -0
  455. package/src/core/runtime/credential-resolver.test.ts +129 -0
  456. package/src/core/runtime/credential-resolver.ts +93 -0
  457. package/src/core/runtime/credential-verify.test.ts +76 -0
  458. package/src/core/runtime/credential-verify.ts +161 -0
  459. package/src/core/runtime/debug-report.test.ts +20 -0
  460. package/src/core/runtime/debug-report.ts +100 -0
  461. package/src/core/runtime/execution-runtime.test.ts +350 -0
  462. package/src/core/runtime/execution-runtime.ts +197 -0
  463. package/src/core/runtime/finish-runtime.test.ts +168 -0
  464. package/src/core/runtime/finish-runtime.ts +83 -0
  465. package/src/core/runtime/identity-runtime.test.ts +38 -0
  466. package/src/core/runtime/identity-runtime.ts +104 -0
  467. package/src/core/runtime/inhub-runtime.test.ts +297 -0
  468. package/src/core/runtime/inhub-runtime.ts +198 -0
  469. package/src/core/runtime/job-stream.test.ts +55 -0
  470. package/src/core/runtime/job-stream.ts +187 -0
  471. package/src/core/runtime/knowledge-runtime.test.ts +120 -0
  472. package/src/core/runtime/knowledge-runtime.ts +98 -0
  473. package/src/core/runtime/launch-runtime.test.ts +187 -0
  474. package/src/core/runtime/launch-runtime.ts +182 -0
  475. package/src/core/runtime/memory-runtime.test.ts +85 -0
  476. package/src/core/runtime/memory-runtime.ts +32 -0
  477. package/src/core/runtime/memory.ts +141 -0
  478. package/src/core/runtime/redaction-runtime.test.ts +35 -0
  479. package/src/core/runtime/redaction-runtime.ts +60 -0
  480. package/src/core/runtime/routing-runtime.test.ts +89 -0
  481. package/src/core/runtime/routing-runtime.ts +146 -0
  482. package/src/core/runtime/smoke-runtime.test.ts +65 -0
  483. package/src/core/runtime/smoke-runtime.ts +237 -0
  484. package/src/core/runtime/summary-runtime.test.ts +234 -0
  485. package/src/core/runtime/summary-runtime.ts +153 -0
  486. package/src/core/runtime/trace-runtime.test.ts +234 -0
  487. package/src/core/runtime/trace-runtime.ts +330 -0
  488. package/src/core/state/audit-observability.test.ts +51 -0
  489. package/src/core/state/audit-observability.ts +74 -0
  490. package/src/core/state/state-codec.ts +44 -0
  491. package/src/core/state/state-contracts.ts +59 -0
  492. package/src/core/targets/adapter.ts +69 -0
  493. package/src/core/targets/registry.test.ts +65 -0
  494. package/src/core/targets/registry.ts +153 -0
  495. package/src/core/targets/resolve.ts +21 -0
  496. package/src/executor.ts +201 -0
  497. package/src/extension-api.test.ts +84 -0
  498. package/src/extension-api.ts +194 -0
  499. package/src/infrastructure/config/config-admin-repository.test.ts +193 -0
  500. package/src/infrastructure/config/config-admin-repository.ts +175 -0
  501. package/src/infrastructure/config/config-alert-rule-repository.ts +38 -0
  502. package/src/infrastructure/config/config-approval-ledger.ts +74 -0
  503. package/src/infrastructure/config/config-channel-repository.ts +31 -0
  504. package/src/infrastructure/config/config-chat-repository.ts +83 -0
  505. package/src/infrastructure/config/config-client-repository.ts +46 -0
  506. package/src/infrastructure/config/config-conversation-ledger.ts +222 -0
  507. package/src/infrastructure/config/config-credential-repository.test.ts +32 -0
  508. package/src/infrastructure/config/config-credential-repository.ts +47 -0
  509. package/src/infrastructure/config/config-delivery-dlq-ledger.ts +49 -0
  510. package/src/infrastructure/config/config-executor-ledger.ts +30 -0
  511. package/src/infrastructure/config/config-executor-token-repository.ts +44 -0
  512. package/src/infrastructure/config/config-instance-branding-repository.ts +75 -0
  513. package/src/infrastructure/config/config-knowledge-repository.ts +249 -0
  514. package/src/infrastructure/config/config-observability-ledger.ts +262 -0
  515. package/src/infrastructure/config/config-project-repository.ts +30 -0
  516. package/src/infrastructure/config/config-rate-limit-ledger.ts +56 -0
  517. package/src/infrastructure/config/config-route-repository.ts +41 -0
  518. package/src/infrastructure/config/config-storage-bucket-repository.ts +43 -0
  519. package/src/infrastructure/config/config-target-repository.ts +25 -0
  520. package/src/infrastructure/config/config-tool-call-ledger.ts +142 -0
  521. package/src/infrastructure/config/config-tool-embedding-repository.test.ts +124 -0
  522. package/src/infrastructure/config/config-tool-embedding-repository.ts +78 -0
  523. package/src/infrastructure/config/config-tool-provider-repository.test.ts +71 -0
  524. package/src/infrastructure/config/config-tool-provider-repository.ts +50 -0
  525. package/src/infrastructure/config/configstore.ts +130 -0
  526. package/src/infrastructure/config/local-instance-branding-provider.test.ts +94 -0
  527. package/src/infrastructure/config/local-instance-branding-provider.ts +79 -0
  528. package/src/infrastructure/mysql/pool-owner.test.ts +36 -0
  529. package/src/infrastructure/mysql/pool-owner.ts +56 -0
  530. package/src/infrastructure/schema/core-schema-migrator.test.ts +340 -0
  531. package/src/infrastructure/schema/core-schema-migrator.ts +461 -0
  532. package/src/infrastructure/schema/migration-files.test.ts +18 -0
  533. package/src/infrastructure/schema/migration-files.ts +27 -0
  534. package/src/infrastructure/schema/retired-migrations.ts +35 -0
  535. package/src/infrastructure/state/operational-metrics-storage.test.ts +107 -0
  536. package/src/infrastructure/state/state-jsonl.ts +268 -0
  537. package/src/infrastructure/state/state-mysql-update-plan.test.ts +54 -0
  538. package/src/infrastructure/state/state-mysql-update-plan.ts +63 -0
  539. package/src/infrastructure/state/state-mysql.ts +359 -0
  540. package/src/infrastructure/state/state.test.ts +319 -0
  541. package/src/infrastructure/state/state.ts +11 -0
  542. package/src/kernel-api/v1/artifact.test.ts +46 -0
  543. package/src/kernel-api/v1/artifact.ts +71 -0
  544. package/src/kernel-api/v1/contracts.ts +168 -0
  545. package/src/kernel-api/v1/execution-gate.test.ts +25 -0
  546. package/src/kernel-api/v1/execution-gate.ts +18 -0
  547. package/src/kernel-api/v1/index.ts +51 -0
  548. package/src/openclaw-stdio.test.ts +60 -0
  549. package/src/routes/admin-access-default.ts +20 -0
  550. package/src/routes/admin-access.ts +94 -0
  551. package/src/routes/admin-branding.test.ts +116 -0
  552. package/src/routes/admin-branding.ts +48 -0
  553. package/src/routes/admin-chat-default.ts +12 -0
  554. package/src/routes/admin-chat.ts +84 -0
  555. package/src/routes/admin-default.ts +35 -0
  556. package/src/routes/admin-dispatch-config-default.ts +13 -0
  557. package/src/routes/admin-dispatch-config.ts +121 -0
  558. package/src/routes/admin-format.ts +12 -0
  559. package/src/routes/admin-host.test.ts +56 -0
  560. package/src/routes/admin-infra-default.ts +12 -0
  561. package/src/routes/admin-infra.ts +142 -0
  562. package/src/routes/admin-kb-default.ts +13 -0
  563. package/src/routes/admin-kb.ts +160 -0
  564. package/src/routes/admin-runtime-default.ts +31 -0
  565. package/src/routes/admin-runtime.ts +444 -0
  566. package/src/routes/admin-tool-providers-default.ts +20 -0
  567. package/src/routes/admin-tool-providers.test.ts +114 -0
  568. package/src/routes/admin-tool-providers.ts +186 -0
  569. package/src/routes/admin.ts +246 -0
  570. package/src/routes/approvals-default.ts +32 -0
  571. package/src/routes/approvals.ts +120 -0
  572. package/src/routes/chat-default.ts +61 -0
  573. package/src/routes/chat-mount.test.ts +58 -0
  574. package/src/routes/chat.test.ts +222 -0
  575. package/src/routes/chat.ts +478 -0
  576. package/src/routes/critical-routes.test.ts +292 -0
  577. package/src/routes/executor-default.ts +45 -0
  578. package/src/routes/executor.ts +226 -0
  579. package/src/routes/kb-default.ts +23 -0
  580. package/src/routes/kb.ts +92 -0
  581. package/src/routes/private-default.ts +38 -0
  582. package/src/routes/private-host-auth.test.ts +84 -0
  583. package/src/routes/private.ts +210 -0
  584. package/src/routes/public-default.ts +46 -0
  585. package/src/routes/public.test.ts +504 -0
  586. package/src/routes/public.ts +313 -0
  587. package/src/routes/run-default.ts +25 -0
  588. package/src/routes/run.ts +188 -0
  589. package/src/routes/send-default.ts +24 -0
  590. package/src/routes/send.ts +143 -0
  591. package/src/routes/wecom-default.ts +27 -0
  592. package/src/routes/wecom.ts +307 -0
  593. package/src/server.ts +13 -0
  594. package/src/services/embedding.test.ts +185 -0
  595. package/src/services/embedding.ts +138 -0
  596. package/src/services/kb-repository.ts +79 -0
  597. package/src/services/kb.ts +328 -0
  598. package/src/services/kbsync.ts +166 -0
  599. package/src/services/tool-index-repository.ts +50 -0
  600. package/src/services/tools-index.test.ts +756 -0
  601. package/src/services/tools-index.ts +427 -0
  602. package/tsconfig.json +17 -0
  603. package/web/connect/bailing-connect-php.tgz +0 -0
  604. package/web/connect/bailing-connect-php7.tgz +0 -0
  605. package/web/connect/executor.mjs +152 -0
  606. package/web/connect/openclaw-stdio.mjs +145 -0
  607. package/web/connect/skills/connect-bailinghub-executor/SKILL.md +97 -0
  608. package/web/connect/skills/connect-bailinghub-executor/agents/openai.yaml +4 -0
  609. package/web/connect/skills/connect-bailinghub-executor/references/direct-protocol.md +99 -0
  610. package/web/connect/skills/connect-bailinghub-executor/references/openclaw.md +39 -0
  611. package/web/console/assets/Accounts-B4ePH5jp.css +1 -0
  612. package/web/console/assets/Accounts-Dwzm4D_V.js +3 -0
  613. package/web/console/assets/Approvals-BxhuI0ku.js +1 -0
  614. package/web/console/assets/Approvals-DlTSHl_7.css +1 -0
  615. package/web/console/assets/Audit-CSu6_3oD.css +1 -0
  616. package/web/console/assets/Audit-dFAbGynl.js +1 -0
  617. package/web/console/assets/BrandLockup-BtZyvkM5.js +1 -0
  618. package/web/console/assets/BrandLockup-DKYBYzKU.css +1 -0
  619. package/web/console/assets/Channels-CCn0L1jg.css +1 -0
  620. package/web/console/assets/Channels-Dqg4-_yr.js +105 -0
  621. package/web/console/assets/ChatEntries-BweMx_CU.css +1 -0
  622. package/web/console/assets/ChatEntries-CEGZ3NnJ.js +7 -0
  623. package/web/console/assets/Clients-C0QD1x7g.js +3 -0
  624. package/web/console/assets/Clients-DcTYN-Js.css +1 -0
  625. package/web/console/assets/Cost-BAJqLhpK.js +1 -0
  626. package/web/console/assets/Cost-CjT39DSZ.css +1 -0
  627. package/web/console/assets/Credentials-D_GDRgWi.js +1 -0
  628. package/web/console/assets/Credentials-ioLP0qYN.css +1 -0
  629. package/web/console/assets/Diagnostics-BWYnDxRj.js +1 -0
  630. package/web/console/assets/Diagnostics-Ya05PTDp.css +1 -0
  631. package/web/console/assets/Executors-CjhEM54c.css +1 -0
  632. package/web/console/assets/Executors-Cmryk4Vk.js +1 -0
  633. package/web/console/assets/HelpTip-CA6Bm7Nx.css +1 -0
  634. package/web/console/assets/HelpTip-CT07o3kB.js +1 -0
  635. package/web/console/assets/Kb-BSXQE0Fa.js +5 -0
  636. package/web/console/assets/Kb-CzIzd9xr.css +1 -0
  637. package/web/console/assets/Login-BnBPqC8Z.js +1 -0
  638. package/web/console/assets/Login-xtPwDB5_.css +1 -0
  639. package/web/console/assets/Projects-Bm8AjsNx.css +1 -0
  640. package/web/console/assets/Projects-CNHx4L_7.js +1 -0
  641. package/web/console/assets/Routes-DWGQN5Pv.css +1 -0
  642. package/web/console/assets/Routes-u5cEAEXQ.js +124 -0
  643. package/web/console/assets/Runs-BeFUR77_.js +3 -0
  644. package/web/console/assets/Runs-CUtSsPW-.css +1 -0
  645. package/web/console/assets/Setup-BjZfrmfN.js +1 -0
  646. package/web/console/assets/Setup-QjlHZKdB.css +1 -0
  647. package/web/console/assets/Shell-CbGNTN91.css +1 -0
  648. package/web/console/assets/Shell-EJuYf3OO.js +1 -0
  649. package/web/console/assets/StorageBuckets-DMXRJxUA.js +1 -0
  650. package/web/console/assets/StorageBuckets-GnXnVvF0.css +1 -0
  651. package/web/console/assets/SystemSettings-B72F-loY.js +1 -0
  652. package/web/console/assets/SystemSettings-BjiHyrXO.css +1 -0
  653. package/web/console/assets/SystemStatus-I11I67rw.css +1 -0
  654. package/web/console/assets/SystemStatus-hOj_TPYE.js +1 -0
  655. package/web/console/assets/Targets-DTb5tn6z.css +1 -0
  656. package/web/console/assets/Targets-UVVf7twC.js +1 -0
  657. package/web/console/assets/Tools-A20oaMaQ.css +1 -0
  658. package/web/console/assets/Tools-ihkr9R9x.js +2 -0
  659. package/web/console/assets/_plugin-vue_export-helper-DlAUqK2U.js +1 -0
  660. package/web/console/assets/docs-DPUOCa7R.js +1 -0
  661. package/web/console/assets/index-DZEQL_yy.js +1 -0
  662. package/web/console/assets/index-DxvruykG.js +2 -0
  663. package/web/console/assets/index-Fi9gkGxV.css +1 -0
  664. package/web/console/assets/llm-catalog-HwRIrS94.js +1 -0
  665. package/web/console/assets/request-BisL2T9B.js +1 -0
  666. package/web/console/assets/schema-CzpUpoLk.js +1 -0
  667. package/web/console/assets/util-SiQC2MJh.js +1 -0
  668. package/web/console/assets/vendor-element-D7WRzHhy.js +37 -0
  669. package/web/console/assets/vendor-mammoth-DvgsHdlx.js +231 -0
  670. package/web/console/assets/vendor-turndown-kLzRgxYD.js +61 -0
  671. package/web/console/assets/vendor-vue-B2uhHUfE.js +29 -0
  672. package/web/console/index.html +16 -0
  673. package/web/widget/widget.js +1490 -0
  674. package/web-admin/index.html +13 -0
  675. package/web-admin/package-lock.json +1854 -0
  676. package/web-admin/package.json +25 -0
  677. package/web-admin/src/App.vue +9 -0
  678. package/web-admin/src/branding.ts +90 -0
  679. package/web-admin/src/components/BrandLockup.vue +40 -0
  680. package/web-admin/src/components/HelpTip.vue +51 -0
  681. package/web-admin/src/components/RichText.vue +35 -0
  682. package/web-admin/src/docs.ts +16 -0
  683. package/web-admin/src/layout/Shell.vue +356 -0
  684. package/web-admin/src/llm-catalog.ts +129 -0
  685. package/web-admin/src/main.ts +116 -0
  686. package/web-admin/src/pages/Accounts.vue +162 -0
  687. package/web-admin/src/pages/Approvals.vue +179 -0
  688. package/web-admin/src/pages/Audit.vue +110 -0
  689. package/web-admin/src/pages/Channels.vue +738 -0
  690. package/web-admin/src/pages/ChatEntries.vue +778 -0
  691. package/web-admin/src/pages/Clients.vue +353 -0
  692. package/web-admin/src/pages/Cost.vue +314 -0
  693. package/web-admin/src/pages/Credentials.vue +418 -0
  694. package/web-admin/src/pages/Diagnostics.vue +440 -0
  695. package/web-admin/src/pages/Executors.vue +398 -0
  696. package/web-admin/src/pages/Kb.vue +698 -0
  697. package/web-admin/src/pages/Login.vue +314 -0
  698. package/web-admin/src/pages/Projects.vue +106 -0
  699. package/web-admin/src/pages/Routes.vue +1661 -0
  700. package/web-admin/src/pages/Runs.vue +1113 -0
  701. package/web-admin/src/pages/Setup.vue +354 -0
  702. package/web-admin/src/pages/StorageBuckets.vue +182 -0
  703. package/web-admin/src/pages/SystemSettings.vue +281 -0
  704. package/web-admin/src/pages/SystemStatus.vue +185 -0
  705. package/web-admin/src/pages/Targets.vue +193 -0
  706. package/web-admin/src/pages/Tools.vue +1051 -0
  707. package/web-admin/src/request.ts +18 -0
  708. package/web-admin/src/router.ts +142 -0
  709. package/web-admin/src/runtime-path.ts +27 -0
  710. package/web-admin/src/schema.ts +52 -0
  711. package/web-admin/src/store.ts +35 -0
  712. package/web-admin/src/styles/base.css +272 -0
  713. package/web-admin/src/table-widths.ts +603 -0
  714. package/web-admin/src/util.ts +16 -0
  715. package/web-admin/tsconfig.json +15 -0
  716. package/web-admin/vite.config.ts +35 -0
@@ -0,0 +1,35 @@
1
+ # Inbound Channels
2
+
3
+ Inbound channels let external messaging platforms send messages into BailingHub. A channel maps platform callbacks to hub routes without hard-coding the platform into business logic.
4
+
5
+ ## Channel Model
6
+
7
+ | Field | Purpose |
8
+ |---|---|
9
+ | `kind` | Adapter type, such as a collaboration platform or custom webhook adapter. |
10
+ | `route_key` | Route used for messages received through this channel. |
11
+ | `config` | Adapter-specific settings. |
12
+ | `client_id` | Optional client boundary for authentication, budgets, and allowlists. |
13
+
14
+ ## Runtime Path
15
+
16
+ ```text
17
+ platform callback
18
+ -> channel adapter verifies platform signature
19
+ -> normalize sender and message
20
+ -> resolve route
21
+ -> create or continue conversation
22
+ -> dispatch job
23
+ -> reply through platform-specific delivery rules
24
+ ```
25
+
26
+ ## Adapter Rules
27
+
28
+ - Platform verification should happen before creating hub jobs.
29
+ - Channel-specific sender IDs should be normalized into principals or visitor identities.
30
+ - Long-running tasks should use asynchronous delivery if the platform has a short response window.
31
+ - Channel adapters should not bypass route allowlists, tool governance, or audit records.
32
+
33
+ ## Current Scope
34
+
35
+ The framework contains concrete adapter work for enterprise messaging scenarios, but the public contract is channel-agnostic. Additional platforms should be implemented as adapters that preserve the same route and principal model.
@@ -0,0 +1,72 @@
1
+ # 百灵中枢 · 入站渠道接入说明(2026-06 上线)
2
+
3
+ 「入站渠道」是**外部平台的消息进中枢的前门**:用户在企业微信(未来飞书等)里发消息 → 平台回调中枢 → 中枢按渠道绑定的路由派给大脑 → 把回答送回平台。与 `POST /run`(业务后端主动调)、网页聊天组件(公开面)并列,是第三类触发入口。
4
+
5
+ 设计要点:**`kind + config + route_key` 三段解耦**——`kind` 区分平台、`config` 放平台专属参数(含密钥)、`route_key` 把「消息进来」与「谁来处理」解开。换大脑只改路由,渠道配置不动;加平台只加一个 handler,信封不变。当前实现 **企业微信(wecom)**。
6
+
7
+ ---
8
+
9
+ ## 1. 一条渠道是什么
10
+
11
+ 控制台「渠道」注册表(`bz_channels`),每行一条入站渠道:
12
+
13
+ | 字段 | 说明 |
14
+ |---|---|
15
+ | `name` | 渠道名,**同时是回调 URL 的路径段**:企微回调 = `https://<中枢域名>/wecom/<name>`。仅小写字母/数字/中划线/下划线 |
16
+ | `kind` | 平台类型,当前 `wecom`(飞书等预留) |
17
+ | `route_key` | 绑定的触发路由(即大脑)——消息都派给它 |
18
+ | `config` | 平台专属配置(见下,含密钥,列表只回显掩码) |
19
+ | `enabled` | 停用即回调返回 404,不处理 |
20
+
21
+ 企微 `config` 字段:
22
+
23
+ | 字段 | 必填 | 说明 |
24
+ |---|---|---|
25
+ | `token` | 是 | 企微「接收消息」配置里的 Token,用于回调签名校验 |
26
+ | `aes_key` | 是 | 企微 EncodingAESKey(43 位),消息加解密用 |
27
+ | `corpid` | 否 | 企业 ID。**留空时运行时从解密报文的 receiveId 自动识别**;多企业共用一个应用可不填 |
28
+ | `agentid` | 否 | 应用 AgentId——**仅「超窗异步主动推」需要**(被动回复不需要) |
29
+ | `secret` | 否 | 应用 Secret——**仅异步主动推需要**(换 access_token 调 qyapi) |
30
+ | `reply_wait_ms` | 否 | 被动回复等待窗口,默认 4000,**上限 4500**(须 < 企微 5s 超时)。窗口内答完走被动回复,超窗转异步推 |
31
+
32
+ > 密钥纪律:`token` / `aes_key` / `secret` 列表只回显掩码,编辑时**留空 = 保留原值**;`corpid` / `agentid` 非密钥,明文回显。
33
+
34
+ ---
35
+
36
+ ## 2. 企业微信接入步骤
37
+
38
+ ### 2.1 中枢侧:注册渠道
39
+ 控制台「渠道 → 新建」:填 `name`(如 `kefu`)、选 `kind=wecom`、选已建好的 `route_key`、填 `token` + `aes_key`(必填),如需主动推再填 `corpid` + `agentid` + `secret`。保存即生效(无需重启)。回调地址即 `https://<中枢域名>/wecom/<name>`。
40
+
41
+ ### 2.2 企微侧:自建应用「接收消息」配置
42
+ 进入企业微信管理后台 → 应用管理 → 你的自建应用 → 「接收消息」→ 设置 API 接收:
43
+ - **URL**:`https://<中枢域名>/wecom/<name>`(与 2.1 的 `name` 一致)
44
+ - **Token**:与渠道 `config.token` 一致
45
+ - **EncodingAESKey**:与渠道 `config.aes_key` 一致
46
+
47
+ 点「保存」时企微会发一个 **GET 验证请求**(带 `msg_signature/timestamp/nonce/echostr`),中枢解密 `echostr` 原样回显完成握手。验证不过 → 检查 token/aes_key 是否两侧一致、URL 是否可公网访问。
48
+
49
+ ### 2.3 收发链路(中枢自动处理,了解即可)
50
+ 1. **GET**(企微保存 URL 时):校验签名 + 解密 echostr 回显 → 握手成功。
51
+ 2. **POST**(用户发消息):校验 `msg_signature` → 解密 → 可选校验 corpid → 取 `FromUserName`(成员 UserID,可信主体)和文本内容。
52
+ 3. 非文本消息回「只看得懂文字」;关注/进入应用等 event 静默 ack;同一 `MsgId` 企微会重试,中枢按 MsgId 去重,重试一律空 ack 不重复处理。
53
+ 4. 文本消息 → 按 `route_key` 派给大脑,会话按 `wecom:<渠道>:<成员>` 切分(同一成员连续对话自动续聊),主体 = `wxuid:<成员UserID>`。
54
+ 5. **快路径**:`reply_wait_ms` 窗口内答完 → **被动加密回复**(零依赖,不碰 qyapi)。
55
+ 6. **慢路径**:超窗 → 空 ack + 任务完成后**异步主动推**(走 qyapi,需 `agentid`+`secret`+可识别的 `corpid`)。执行器类慢大脑、长任务靠这条覆盖。
56
+
57
+ ---
58
+
59
+ ## 3. 身份与安全
60
+
61
+ - **主体可信**:`FromUserName` 来自企微**解密后**的报文,是企业成员 UserID,中枢作为可信主体写入(`metadata.wecom_userid`、principal `wxuid:<user>`)。若路由挂了写工具,这个主体会作为 `X-Bailing-On-Behalf-Of` 发给业务侧——业务按自家权限表裁决。
62
+ - **签名校验**:回调 `msg_signature` 必须用渠道 `token` 重算一致才处理,伪造请求被 401 挡掉;corpid 配了则再校验解密报文的 receiveId 匹配。
63
+ - **注意**:入站渠道走平台自己的身份体系(企微解密报文里的成员身份),中枢信任的是「平台已验明的成员」。要让 Agent 替成员做写操作,仍按工具插座的 on-behalf-of + `sha256=` 签名 + 业务侧裁决那一套走(见 [CONTRACT §2.4](CONTRACT.md))。
64
+ - 服务暂停(kill switch)时回「服务暂停中,请稍后再试」。
65
+
66
+ ---
67
+
68
+ ## 4. 扩展到其他平台
69
+
70
+ 加飞书/钉钉等:在 `src/server.ts` 加一个按 `channel.kind` 分派的入站 handler(参照 `handleWecomInbound`:平台 URL 验证握手 + 消息解密 + 派路由 + 回复/推送),渠道注册表与 `route_key` 解耦机制完全复用。回调路径约定 `/<平台>/<渠道名>`。被动回复 / 异步推的窗口取舍按平台超时规则定。
71
+
72
+ 相关:[CONTRACT.md](CONTRACT.md)(边界契约)、[ARCHITECTURE.md](ARCHITECTURE.md)(整体架构)。
@@ -0,0 +1,89 @@
1
+ # BailingHub Client API
2
+
3
+ The BailingHub Client API is the stable, product-neutral boundary used by external
4
+ workflow engines and agent platforms to submit governed work and inspect its result.
5
+
6
+ Its contract version is independent from the BailingHub application version and from
7
+ adapter package versions:
8
+
9
+ ```text
10
+ BailingHub 0.x
11
+ |
12
+ +-- bailing.client-api.v1
13
+ |
14
+ +-- Dify adapter 0.x
15
+ +-- n8n adapter 0.x
16
+ +-- MCP adapter 0.x
17
+ +-- future ecosystem adapters
18
+ ```
19
+
20
+ The current machine-readable contract is published at:
21
+
22
+ - `/contracts/client-api/v1/manifest.json`
23
+ - `/contracts/client-api/v1/run-request.schema.json`
24
+ - `/contracts/client-api/v1/submit-response.schema.json`
25
+ - `/contracts/client-api/v1/job-response.schema.json`
26
+ - `/contracts/client-api/v1/health-response.schema.json`
27
+ - `/contracts/client-api/v1/error-response.schema.json`
28
+ - `/contracts/client-api/v1/vectors.json`
29
+
30
+ ## Stable Surface
31
+
32
+ | Method | Path | Authentication | Purpose |
33
+ | --- | --- | --- | --- |
34
+ | `GET` | `/health` | None | Verify the BailingHub origin |
35
+ | `POST` | `/run` | Client bearer token | Submit a governed job through an allowlisted route |
36
+ | `GET` | `/jobs/{job_id}` | Client bearer token | Read a job owned by the authenticated client |
37
+
38
+ Client requests cannot choose a project, profile, server-owned source identity, approval
39
+ result, executor, or business authority. Those decisions remain on the BailingHub and
40
+ business-system sides of the boundary.
41
+
42
+ `request_id` is a client-scoped idempotency key. A retry must reuse the same value.
43
+
44
+ ## Versioning
45
+
46
+ `bailing.client-api.v1` identifies the compatibility family. The manifest's semantic
47
+ version identifies additive revisions inside that family.
48
+
49
+ - Additive response fields are compatible. Consumers must ignore fields they do not use.
50
+ - A new required request field is a breaking change.
51
+ - Authentication changes are breaking changes.
52
+ - Removing or changing the meaning of a job status is a breaking change.
53
+ - Consumers fail closed on an unknown job status until their adapter is reviewed.
54
+
55
+ Application, plugin, node, and Client API versions are deliberately not synchronized.
56
+
57
+ ## Executable Compatibility Gate
58
+
59
+ The contract is not maintained as prose alone.
60
+
61
+ ```bash
62
+ # Validate schemas, status semantics, aliases, and conformance vectors.
63
+ npm run client-api:contract
64
+
65
+ # Validate the current local Dify, n8n, and MCP sibling repositories.
66
+ npm run client-api:ecosystem:local
67
+
68
+ # Clone the registered public adapter branches and validate them.
69
+ npm run client-api:ecosystem:clone
70
+ ```
71
+
72
+ The consumer registry lives at `contracts/client-api/consumers.json`. Each adapter owns
73
+ its compatibility declaration and checker. The declaration pins endpoint method, path,
74
+ authentication shape, consumed fields, job statuses, classified HTTP failures, and the
75
+ request limits enforced by the adapter. Core CI tests current adapter branches against the
76
+ proposed core contract, while adapter CI tests itself against the current core branch.
77
+ This bidirectional gate catches both kinds of drift:
78
+
79
+ 1. a core change that would break an existing adapter;
80
+ 2. an adapter claim that no longer matches the core contract.
81
+
82
+ ## Boundary With Executor Protocols
83
+
84
+ The Client API is not an executor protocol. OpenClaw and portable executors use the
85
+ separate claim, heartbeat, lease, and result-submission lifecycle under `/executor/*`.
86
+ Those semantics require their own versioned contract and future compatibility gate.
87
+
88
+ Keeping the two surfaces separate prevents a workflow adapter from gaining executor
89
+ authority and prevents executor lifecycle changes from destabilizing Client API consumers.
@@ -0,0 +1,103 @@
1
+ # Compatibility And Upgrade Policy
2
+
3
+ BailingHub follows SemVer for public releases.
4
+
5
+ Before `1.0.0`, the project may still adjust public contracts, but breaking changes must be documented clearly in release notes and changelog entries.
6
+
7
+ ## Stable Public Surfaces
8
+
9
+ The following surfaces should be treated as public:
10
+
11
+ - HTTP APIs documented in the contract docs;
12
+ - tool call and callback signature shape;
13
+ - OpenAPI `x-agent-capability` fields;
14
+ - SDK package behavior;
15
+ - database migration ordering;
16
+ - Docker demo and installer entry points;
17
+ - configuration schema files under `schemas/`.
18
+
19
+ ## Database Migration Rules
20
+
21
+ - Add new numbered SQL files instead of editing already released migrations.
22
+ - Prefer additive schema changes.
23
+ - New non-null columns must have defaults.
24
+ - Avoid destructive operations such as drop, rename, or type changes in minor versions.
25
+ - Use transition windows for major schema changes.
26
+
27
+ ## File-Level Customization
28
+
29
+ Tracked default files should remain upgradeable. Operator customization should use `.local` overlay files when supported, such as executor brain profiles and prompts.
30
+
31
+ ## Contract Changes
32
+
33
+ When public contracts change, update together:
34
+
35
+ - contract docs;
36
+ - SDK examples;
37
+ - schemas;
38
+ - changelog;
39
+ - smoke or contract tests.
40
+
41
+ ## Upgrade Goal
42
+
43
+ Operators should be able to upgrade the open-source core without losing local secrets, runtime state, or deployment-specific customization.
44
+
45
+ ## Instance Branding And Platform-Managed Upgrades
46
+
47
+ The instance name, browser title, metadata, logo, favicon, and login copy use the
48
+ stable `InstanceBrandingProvider` contract. The console and public
49
+ `GET /branding` endpoint depend only on that contract, not on a particular
50
+ database or hosting platform.
51
+
52
+ - The open-source edition uses the local provider and persists settings in
53
+ `bz_instance_branding`.
54
+ - A platform-managed deployment replaces that provider at its composition root while
55
+ keeping the same API and console.
56
+ - The upgrade process may import the local record into the platform once, then
57
+ switch ownership to the platform provider.
58
+ - After takeover, the local page is read-only and may link to the platform
59
+ management page. The local row remains migration evidence, not a second
60
+ source of truth.
61
+ - Platform and local storage must never be dual-written.
62
+ - A temporary platform read failure may fall back to the built-in display
63
+ defaults, but must not restore local write access.
64
+
65
+ Branding is instance presentation only. It does not extend the ACC core and
66
+ must not carry business authorization, secrets, custom HTML/CSS/JavaScript,
67
+ redirects, or other executable configuration.
68
+
69
+ ## Embedded Widget Contract
70
+
71
+ The hub-hosted `widget.js` is a public wire surface because an instance upgrade
72
+ updates every embedding page. Stable fields include the `data-entry`,
73
+ `data-open`, and `data-ticket` script attributes, the documented chat endpoint
74
+ family, and the `window.BailingChat` APIs.
75
+
76
+ The optional rich-content extension evolves under
77
+ `window.BailingChat.rendererApiVersion`. Adding a new renderer type is
78
+ compatible when older widgets and hosts can still show its fenced payload as a
79
+ safe code block. Changing an existing type's payload meaning, lifecycle, or
80
+ trust boundary requires a renderer contract major version or a new type with a
81
+ transition window. The widget core remains dependency-free; see
82
+ [WIDGET_RENDERERS.en.md](WIDGET_RENDERERS.en.md) for registration, cleanup, and
83
+ fallback rules.
84
+
85
+ ## URL Tool Catalog Access Policy Upgrade
86
+
87
+ The release that introduces `053_tool_spec_access_policy.sql` adds two nullable columns to `bz_tool_providers`. Keep the normal backup, `db:init`, and restart order. The public configuration surface always has exactly two values, `signed_required` and `public_allowed`; new URL providers default to the former.
88
+
89
+ For URL providers created before this change, the new database field remains `NULL` and is derived at read time as the internal, read-only migration state `legacy_unverified`. It is not a third public policy: it is not accepted as a writable create or update value and is never a selectable option. The console list labels it “Pending confirmation (historical configuration),” and neither real policy is preselected in the editor. Its only purpose is to avoid guessing that an undeclared historical endpoint is public or protected. Until an operator selects a policy, the cached spec remains in place, refresh keeps the previous signed-fetch behavior, and the access probe records `skipped`. Inline providers do not persist this URL-only state.
90
+
91
+ “Pending confirmation” does not make the whole record immutable. An operator may still disable the provider or save descriptive, governance, retrieval, and other fields that do not alter catalog access. Those changes do not force a policy choice. Selecting `signed_required` or `public_allowed` is required only before changing `spec_url`, the provider `secret`, `auto_refresh_min`, re-enabling a disabled provider, or another sensitive action that changes or resumes catalog reads.
92
+
93
+ Resolve existing URL providers one at a time:
94
+
95
+ 1. Confirm that the catalog URL is the final direct address and does not redirect.
96
+ 2. Before a catalog-sensitive action listed above, select `signed_required` when the business endpoint verifies the provider signature. Select `public_allowed` only when public catalog discovery is intentional. Saving persists the selected public policy and resolves the internal migration state.
97
+ 3. Save and refresh manually. Changing the URL, secret, or policy clears previous evidence.
98
+ 4. `signed_required` is `protected` only when the signed primary request returns 2xx and unsigned plus invalid-signature probes each return 401/403/404. A negative 2xx is `public`; redirects, 429, 5xx, and network errors are `inconclusive`. A 404 on the signed primary request is a failure, not protection evidence.
99
+ 5. Confirm `Cache-Control: private, no-store` and verify that reverse proxies or CDNs cannot cache or rewrite a protected catalog.
100
+
101
+ Refresh failures preserve the previous cache. Each request is bounded to 10 seconds and the successful primary response is limited to 5 MiB. The safest application rollback is to restore the old code while keeping the additive columns and migration ledger; the old version ignores them. Use the full pre-upgrade database snapshot only for a coordinated rollback with the old application. Do not delete the ledger entry or drop the columns independently.
102
+
103
+ This policy governs catalog discovery only. It does not change ACC, tool-call signatures, route allowlists, approvals, idempotency, or final business authorization.
@@ -0,0 +1,254 @@
1
+ # HTTP Contract
2
+
3
+ > Current contract: `bailing.contract.v2.13`. This is the only network boundary between a business system and BailingHub.
4
+
5
+ This document summarizes the public wire contract between a business system and BailingHub.
6
+
7
+ The detailed Chinese contract remains the most complete reference: [CONTRACT.md](CONTRACT.md).
8
+
9
+ ## Trigger a Job
10
+
11
+ ```http
12
+ POST /run
13
+ Authorization: Bearer <client-token>
14
+ Content-Type: application/json
15
+ ```
16
+
17
+ ```json
18
+ {
19
+ "request_id": "order-10001-ai-001",
20
+ "route": "order_assistant",
21
+ "input": "Help me analyze why this order has not shipped",
22
+ "metadata": {
23
+ "tenant_id": "t_100",
24
+ "operator_uid": "u_42",
25
+ "order_id": "SO20260701001"
26
+ },
27
+ "callback": "https://biz.example.com/ai/callback"
28
+ }
29
+ ```
30
+
31
+ Response:
32
+
33
+ ```json
34
+ {
35
+ "job_id": "job_...",
36
+ "status": "queued"
37
+ }
38
+ ```
39
+
40
+ `request_id` is the business-side idempotency key.
41
+
42
+ ## Query a Job
43
+
44
+ ```http
45
+ GET /jobs/{job_id}
46
+ Authorization: Bearer <client-token>
47
+ ```
48
+
49
+ ```json
50
+ {
51
+ "id": "job_...",
52
+ "status": "queued | running | done | error",
53
+ "result": {
54
+ "summary": "...",
55
+ "detail": {}
56
+ },
57
+ "error": null
58
+ }
59
+ ```
60
+
61
+ ## Callback
62
+
63
+ If a callback URL is configured, the hub sends signed result payloads.
64
+
65
+ ```http
66
+ POST <business-callback-url>
67
+ X-Bailing-Signature: sha256=<hmac>
68
+ X-Bailing-Timestamp: 1782912000
69
+ Content-Type: application/json
70
+ ```
71
+
72
+ ```json
73
+ {
74
+ "job_id": "job_...",
75
+ "route": "order_assistant",
76
+ "status": "done",
77
+ "result": {
78
+ "summary": "..."
79
+ }
80
+ }
81
+ ```
82
+
83
+ The business system must verify the callback signature before consuming the payload.
84
+
85
+ ## Embedded Chat Streaming
86
+
87
+ The embedded widget creates a job with `POST /chat/{entry_key}` and consumes its result through:
88
+
89
+ ```http
90
+ GET /chat/{entry_key}/events/{job_id}
91
+ Accept: text/event-stream
92
+ ```
93
+
94
+ The base event set is `open`, `status`, `ping`, `done`, `failed`, and `timeout`. When incremental model output is available, the stream also emits `phase`, `reset`, and `delta` events under protocol `bailing.chat.stream.v1`.
95
+
96
+ Incremental text is provisional transport data. It is not a durable conversation message, callback payload, or audit record. Clients must replace provisional output with the canonical `done` payload, which is rebuilt from the final job record. Event IDs are monotonic per job and support `Last-Event-ID` replay. A `reset` event instructs the client to discard provisional text before continuing.
97
+
98
+ See [STREAMING.en.md](STREAMING.en.md) for event payloads, reconnect rules, provider fallback, audit boundaries, and multi-replica deployment requirements.
99
+
100
+ ### Optional Widget Renderers
101
+
102
+ Charts and interactive reports do not add a new server-side attachment type or
103
+ change the canonical `reply` payload. A host page may register a trusted
104
+ renderer through `window.BailingChat.registerRenderer(...)` and consume a
105
+ declarative fenced payload. Unknown types, invalid JSON, oversized payloads, or
106
+ renderer failures fall back to a text code block. See
107
+ [WIDGET_RENDERERS.en.md](WIDGET_RENDERERS.en.md) for the full trust and lifecycle
108
+ contract.
109
+
110
+ ## Tool Provider Spec
111
+
112
+ Recommended location:
113
+
114
+ ```text
115
+ /.well-known/bailing/tools.json
116
+ ```
117
+
118
+ For URL-backed providers, declare the expected access posture with
119
+ `spec_access_policy`:
120
+
121
+ - `signed_required` is the default and recommended policy;
122
+ - `public_allowed` is an explicit decision to let anyone who can reach the URL
123
+ read the capability catalog; it never relaxes tool-call signatures or
124
+ business authorization.
125
+
126
+ These are the only configurable policy values. The read-only migration state
127
+ for providers created before this contract is not part of the public
128
+ configuration surface; see
129
+ [COMPATIBILITY.en.md](COMPATIBILITY.en.md#url-tool-catalog-access-policy-upgrade).
130
+
131
+ For `signed_required`, a URL refresh reads with a correct signature and then
132
+ checks unsigned and invalid-signature requests. It updates the cache only when
133
+ the signed request succeeds and both negative requests return 401/403/404;
134
+ public or inconclusive evidence fails the refresh and preserves the old cache.
135
+ `public_allowed` uses only an unsigned primary request and records `public` on
136
+ success; if the endpoint is actually protected, it records `inconclusive` and
137
+ fails instead of silently retrying with a signature. The console displays
138
+ expected policy and observed status separately.
139
+ A signed-only spec response must include
140
+ `Cache-Control: private, no-store` so an intermediary cannot replay one valid
141
+ response as a public cached document. PHP/PHP7 `SpecServer::respond()` adds this
142
+ header when a secret is supplied; framework integrations can apply
143
+ `SpecServer::responseHeaders($secret)`. Deliberately public PHP endpoints should
144
+ use `handlePublic()` or `respondPublic()` instead of hiding the decision in a
145
+ `null` secret.
146
+
147
+ Minimal OpenAPI shape:
148
+
149
+ ```json
150
+ {
151
+ "openapi": "3.0.0",
152
+ "info": { "title": "Order Tools", "version": "1.0.0" },
153
+ "paths": {
154
+ "/api/orders/{id}": {
155
+ "get": {
156
+ "operationId": "order_get",
157
+ "summary": "Query order detail",
158
+ "x-agent-capability": {
159
+ "version": 1,
160
+ "enabled": true,
161
+ "scope": "order.read",
162
+ "subject": { "required": true }
163
+ },
164
+ "parameters": [
165
+ {
166
+ "name": "id",
167
+ "in": "path",
168
+ "required": true,
169
+ "schema": { "type": "string", "description": "Order ID" }
170
+ }
171
+ ]
172
+ }
173
+ }
174
+ }
175
+ }
176
+ ```
177
+
178
+ Important `x-agent-capability` fields:
179
+
180
+ | Field | Meaning |
181
+ |---|---|
182
+ | `version` / `enabled` / `scope` | Contract version, exposure switch, and route allowlist scope. |
183
+ | `risk.level` | `low`, `medium`, or `high`. |
184
+ | `approval.required` | Always require approval before execution. |
185
+ | `approval.when` | Require approval only when parameter rules match. A rule must target a typed parameter declared in the standard schema. Comparisons preserve JSON types: strings are never coerced into numbers or booleans, and a type mismatch is rejected before the business request is sent. |
186
+ | `subject.required` | Hide the tool if there is no trusted on-behalf-of subject. |
187
+ | `audit.sensitive` | Redact sensitive parameter values from audit logs. |
188
+ | `execution.readonly` | Mark POST-based query endpoints as semantically read-only. |
189
+ | `execution.idempotent` | Mark non-GET endpoints as safe to retry. |
190
+ | `execution.timeout_ms` | Override the provider timeout for this operation with an integer from 1 to 600000 milliseconds. |
191
+
192
+ ## Tool Call Signature
193
+
194
+ BailingHub calls business tools with signed headers:
195
+
196
+ ```http
197
+ X-Bailing-Signature: sha256=<hmac>
198
+ X-Bailing-Timestamp: 1782912000
199
+ X-Bailing-Tool-Scope: order.read
200
+ X-Bailing-Job-Id: job_...
201
+ X-Bailing-On-Behalf-Of: u_42
202
+ X-Bailing-Idempotency-Key: <stable side-effect key>
203
+ ```
204
+
205
+ The signature binds:
206
+
207
+ - timestamp
208
+ - HTTP method
209
+ - path with query
210
+ - body hash
211
+ - on-behalf-of subject
212
+ - job id
213
+
214
+ Business systems must verify the signature and then run their own authorization logic.
215
+
216
+ For non-read-only, non-idempotent tools, the idempotency key is stable for the job, subject, tool, and canonical arguments. The business system should use it, or a stronger domain key, to deduplicate side effects. BailingHub persists an execution journal before dispatch; if that journal is unavailable, the side-effecting request is not sent. It does not automatically replay an uncertain outcome after a timeout, disconnect, audit failure, or restart. Recovery checks unresolved journal entries before invoking the model. Such a call terminates with `governance_state=reconciliation_required` and `auto_retry_allowed=false`.
217
+
218
+ This is fail-closed behavior, not an exactly-once guarantee. A request that never reached the business system can still be frozen, so operators must reconcile the journal against business-side records. The idempotency key does not replace signature verification or business authorization.
219
+
220
+ The built-in `send_message` capability is treated as a side effect as well. It uses the same durable journal. Partial delivery, including a successful text chunk followed by a failed attachment or card, is frozen as potentially committed and is not replayed automatically. When a channel has no native idempotency contract, reconciliation must use the job, recipient, canonical message arguments, and channel-side records.
221
+
222
+ ## Approval Decision
223
+
224
+ High-risk or confirmation-required tool calls can be frozen as approval intents.
225
+
226
+ The business side can later send a decision:
227
+
228
+ ```json
229
+ {
230
+ "approval_id": "appr_...",
231
+ "job_id": "job_...",
232
+ "request_id": "tool_call_...",
233
+ "args_hash": "sha256:...",
234
+ "decision_id": "biz_decision_1001",
235
+ "decision": "approved",
236
+ "approver": {
237
+ "id": "u_manager",
238
+ "name": "Manager"
239
+ },
240
+ "comment": "Approved by manager"
241
+ }
242
+ ```
243
+
244
+ The hub verifies that the decision matches the frozen call snapshot before allowing the task to continue.
245
+
246
+ ## Security Baseline
247
+
248
+ - Treat all user input as untrusted data.
249
+ - Use production secrets only through environment variables or secret managers.
250
+ - Give each business system its own client token.
251
+ - Use route allowlists for tools.
252
+ - Verify HMAC signatures on tool calls and callbacks.
253
+ - Never treat a valid signature as business authorization.
254
+ - Keep audit retention aligned with your compliance requirements.