bailinghub 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/.gitignore +5 -0
  2. package/README.en.md +5 -2
  3. package/README.md +6 -2
  4. package/SECURITY.md +11 -0
  5. package/docker-compose.images.yml +2 -2
  6. package/docs/AGENT_AUTH_API.en.md +191 -0
  7. package/docs/AGENT_AUTH_API.md +202 -0
  8. package/docs/AGENT_CLIENT_QUICKSTART.en.md +263 -0
  9. package/docs/AGENT_CLIENT_QUICKSTART.md +245 -0
  10. package/docs/AGENT_CLIENT_RUNTIME_API.en.md +157 -0
  11. package/docs/AGENT_CLIENT_RUNTIME_API.md +107 -0
  12. package/docs/CHANGELOG.en.md +25 -0
  13. package/docs/CHANGELOG.md +25 -0
  14. package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
  15. package/docs/INDEPENDENT_VALIDATION.md +4 -4
  16. package/docs/README.en.md +10 -2
  17. package/docs/README.md +10 -2
  18. package/docs/RELEASE_NOTES_v0.5.0.en.md +41 -0
  19. package/docs/RELEASE_NOTES_v0.5.0.md +41 -0
  20. package/docs/RELEASE_NOTES_v0.5.1.en.md +45 -0
  21. package/docs/RELEASE_NOTES_v0.5.1.md +45 -0
  22. package/package.json +3 -2
  23. package/schemas/config/client.schema.json +7 -0
  24. package/schemas/config/common.schema.json +30 -0
  25. package/schemas/config/route.schema.json +11 -0
  26. package/scripts/check-doc-links.mjs +2 -1
  27. package/scripts/check-image-tags.sh +1 -1
  28. package/scripts/check-release-consistency.test.mjs +5 -5
  29. package/scripts/e2e-console.mjs +144 -0
  30. package/scripts/export-oss.mjs +5 -12
  31. package/scripts/install.sh +1 -1
  32. package/scripts/public-content-denylist.mjs +82 -0
  33. package/scripts/public-content-denylist.test.mjs +53 -0
  34. package/scripts/publish-images.sh +1 -1
  35. package/scripts/release-audit.mjs +9 -13
  36. package/scripts/sdk-runtime-test.mjs +171 -7
  37. package/scripts/security-scan.mjs +8 -5
  38. package/scripts/validate-examples.mjs +3 -1
  39. package/scripts/verify-github-repo.mjs +8 -12
  40. package/scripts/verify-oss-export.mjs +6 -12
  41. package/sdk/php/README.md +27 -1
  42. package/sdk/php/src/AgentAuth.php +78 -0
  43. package/sdk/php/src/HubClient.php +3 -0
  44. package/sdk/php7/README.md +32 -2
  45. package/sdk/php7/src/AgentAuth.php +77 -0
  46. package/sdk/php7/src/HubClient.php +3 -0
  47. package/sql/055_agent_auth.sql +72 -0
  48. package/sql/056_agent_client_runtime.sql +60 -0
  49. package/src/adapters/channels/wecom-api.ts +1 -1
  50. package/src/app/agent-client-runtime.test.ts +221 -0
  51. package/src/app/agent-client-runtime.ts +408 -0
  52. package/src/app/agent-tool-invocations.test.ts +462 -0
  53. package/src/app/agent-tool-invocations.ts +795 -0
  54. package/src/app/agent-tool-job.test.ts +62 -0
  55. package/src/app/agent-tool-job.ts +41 -0
  56. package/src/app/auth.ts +2 -1
  57. package/src/app/kernel.ts +2 -0
  58. package/src/app/oss-edition.ts +1 -0
  59. package/src/app/runtime-context.ts +8 -0
  60. package/src/app/tool-approvals.ts +5 -1
  61. package/src/app/tool-assembly.ts +19 -1
  62. package/src/app/tool-context.ts +2 -1
  63. package/src/core/config/agent-direct-console-selection.test.ts +22 -0
  64. package/src/core/config/config-codec.ts +2 -1
  65. package/src/core/config/config-models.test.ts +10 -0
  66. package/src/core/config/config-models.ts +21 -0
  67. package/src/core/config/config-schema.test.ts +6 -0
  68. package/src/core/config/route-config.test.ts +15 -0
  69. package/src/core/config/route-config.ts +36 -0
  70. package/src/core/config/tools-config.test.ts +58 -1
  71. package/src/core/config/tools-config.ts +84 -0
  72. package/src/core/contracts/tools.ts +162 -29
  73. package/src/core/contracts/types.ts +36 -0
  74. package/src/core/runtime/agent-client-trace.test.ts +154 -0
  75. package/src/core/runtime/agent-client-trace.ts +288 -0
  76. package/src/core/runtime/launch-runtime.ts +13 -0
  77. package/src/core/runtime/trace-runtime.test.ts +18 -1
  78. package/src/core/runtime/trace-runtime.ts +28 -3
  79. package/src/core/state/state-codec.ts +2 -0
  80. package/src/infrastructure/config/config-agent-auth-repository.test.ts +183 -0
  81. package/src/infrastructure/config/config-agent-auth-repository.ts +453 -0
  82. package/src/infrastructure/config/config-agent-client-runtime-repository.test.ts +38 -0
  83. package/src/infrastructure/config/config-agent-client-runtime-repository.ts +307 -0
  84. package/src/infrastructure/config/config-approval-ledger.test.ts +32 -0
  85. package/src/infrastructure/config/config-approval-ledger.ts +16 -0
  86. package/src/infrastructure/config/config-client-repository.ts +3 -3
  87. package/src/infrastructure/config/config-conversation-ledger.test.ts +69 -0
  88. package/src/infrastructure/config/config-conversation-ledger.ts +8 -7
  89. package/src/infrastructure/config/config-observability-ledger.test.ts +50 -0
  90. package/src/infrastructure/config/config-observability-ledger.ts +65 -10
  91. package/src/infrastructure/config/config-route-repository.ts +4 -3
  92. package/src/infrastructure/config/configstore.ts +14 -3
  93. package/src/infrastructure/state/state-mysql.ts +2 -2
  94. package/src/kernel-api/v1/contracts.ts +8 -0
  95. package/src/routes/admin-agent-clients.test.ts +120 -0
  96. package/src/routes/admin-agent-clients.ts +161 -0
  97. package/src/routes/admin-runtime.test.ts +214 -0
  98. package/src/routes/admin-runtime.ts +82 -2
  99. package/src/routes/admin.ts +3 -0
  100. package/src/routes/agent-api.test.ts +379 -0
  101. package/src/routes/agent-api.ts +251 -0
  102. package/src/routes/agent-auth.test.ts +276 -0
  103. package/src/routes/agent-auth.ts +395 -0
  104. package/src/routes/approvals.ts +4 -1
  105. package/src/routes/critical-routes.test.ts +235 -1
  106. package/src/routes/private-default.ts +2 -1
  107. package/src/routes/private.ts +16 -1
  108. package/src/routes/run.ts +79 -13
  109. package/web/connect/bailing-connect-php.tgz +0 -0
  110. package/web/connect/bailing-connect-php7.tgz +0 -0
  111. package/web/console/assets/{Accounts-DuUY2UJU.js → Accounts-r10QUjLQ.js} +1 -1
  112. package/web/console/assets/AgentClients-DsWADpzr.css +1 -0
  113. package/web/console/assets/AgentClients-UTTqbkjy.js +1 -0
  114. package/web/console/assets/{Approvals-B11mo1dy.js → Approvals-BGKkYIya.js} +1 -1
  115. package/web/console/assets/{Audit-CQwJRIJT.js → Audit-CQmjOAoO.js} +1 -1
  116. package/web/console/assets/{BrandLockup-BIF-h1pi.js → BrandLockup-BF_0pCa3.js} +1 -1
  117. package/web/console/assets/{Channels-BIploUT-.js → Channels-C4yZE67F.js} +1 -1
  118. package/web/console/assets/{ChatEntries-Cpg_WV-o.js → ChatEntries-OqsqLjU6.js} +1 -1
  119. package/web/console/assets/Clients-CNIVs7Qn.css +1 -0
  120. package/web/console/assets/Clients-Dv3sv51C.js +3 -0
  121. package/web/console/assets/{Cost-BF52tfU2.js → Cost-C_-kiH59.js} +1 -1
  122. package/web/console/assets/{Credentials-SwfmQAv6.js → Credentials-CPTEAiV6.js} +1 -1
  123. package/web/console/assets/{Diagnostics-CJfbI_8p.js → Diagnostics-O-NKFOeI.js} +1 -1
  124. package/web/console/assets/{Executors-CzlZlznA.js → Executors-GVIAiNgv.js} +1 -1
  125. package/web/console/assets/{HelpTip-CT07o3kB.js → HelpTip-i-KJhf5s.js} +1 -1
  126. package/web/console/assets/{Kb-CVX22U4k.js → Kb-BsCWkJI1.js} +2 -2
  127. package/web/console/assets/{Login-PoUVsBI-.js → Login-VFjkHNMr.js} +1 -1
  128. package/web/console/assets/{Projects-DYlbjLQy.js → Projects-Ds-sJwfy.js} +1 -1
  129. package/web/console/assets/Routes-CXGl9SMM.css +1 -0
  130. package/web/console/assets/Routes-Wwurw2UU.js +124 -0
  131. package/web/console/assets/Runs-4zDD9VOC.css +1 -0
  132. package/web/console/assets/Runs-DLPzXmSy.js +3 -0
  133. package/web/console/assets/{Setup-xiPXit_b.js → Setup-BLelw0_V.js} +1 -1
  134. package/web/console/assets/Shell-CvaeK4j_.js +1 -0
  135. package/web/console/assets/Shell-D9Uw-fsa.css +1 -0
  136. package/web/console/assets/{StorageBuckets-Bjsc3pLd.js → StorageBuckets-Dv6u47yO.js} +1 -1
  137. package/web/console/assets/{SystemSettings-CcKF2lJ9.js → SystemSettings-B9K7zaDU.js} +1 -1
  138. package/web/console/assets/{SystemStatus-Oj1xjxJn.js → SystemStatus-H-oKDo-y.js} +1 -1
  139. package/web/console/assets/{Targets-y1KllVXT.js → Targets-CCFhjPKf.js} +1 -1
  140. package/web/console/assets/{Tools-DoEP_y9x.js → Tools-D0H9xpFH.js} +1 -1
  141. package/web/console/assets/index-CuoTgf6q.js +2 -0
  142. package/web/console/assets/{index-DZEQL_yy.js → index-DyX9Bz3V.js} +1 -1
  143. package/web/console/assets/{request-CBLNpLth.js → request-F5lXa7Ro.js} +1 -1
  144. package/web/console/assets/{schema-DzwLpuOy.js → schema-DUWaWqPn.js} +1 -1
  145. package/web/console/assets/{util-SiQC2MJh.js → util-4bN2dv7B.js} +1 -1
  146. package/web/console/assets/{vendor-element-D7WRzHhy.js → vendor-element-CZoEjZr8.js} +1 -1
  147. package/web/console/assets/{vendor-mammoth-DvgsHdlx.js → vendor-mammoth-nXG51Cg7.js} +1 -1
  148. package/web/console/index.html +2 -2
  149. package/web-admin/src/agent-direct-selection.ts +21 -0
  150. package/web-admin/src/layout/Shell.vue +1 -1
  151. package/web-admin/src/pages/AgentClients.vue +254 -0
  152. package/web-admin/src/pages/Clients.vue +13 -3
  153. package/web-admin/src/pages/Routes.vue +331 -16
  154. package/web-admin/src/pages/Runs.vue +159 -38
  155. package/web-admin/src/router.ts +2 -0
  156. package/web/console/assets/Clients--D7NQJKk.css +0 -1
  157. package/web/console/assets/Clients-DS29eUi2.js +0 -3
  158. package/web/console/assets/Routes-DSEvGujN.js +0 -124
  159. package/web/console/assets/Routes-DWGQN5Pv.css +0 -1
  160. package/web/console/assets/Runs-B-TsYZEt.js +0 -3
  161. package/web/console/assets/Runs-CUtSsPW-.css +0 -1
  162. package/web/console/assets/Shell-BVIjmoY8.css +0 -1
  163. package/web/console/assets/Shell-DNiWZOYB.js +0 -1
  164. package/web/console/assets/index-CxPIS6G7.js +0 -2
@@ -0,0 +1,263 @@
1
+ # Agent Client v1 Integration Guide
2
+
3
+ English | [简体中文](AGENT_CLIENT_QUICKSTART.md)
4
+
5
+ Agent Client lets a local Agent host such as DeepSeek Harness perform reasoning, planning, and
6
+ multi-step tool selection while BailingHub continues to own trusted business identity,
7
+ capability filtering, approvals, idempotency, business invocation, and audit. It is not the
8
+ existing executor protocol, and it does not give local models business passwords, tokens, or
9
+ direct business API endpoints.
10
+
11
+ This guide separates the responsibilities of the BailingHub deployer, the business-system
12
+ developer, and the local Agent user. They do not share one credential or configuration file.
13
+
14
+ ## 1. Component relationship
15
+
16
+ ```text
17
+ Local Agent host (for example, DSH)
18
+ └─ dsh-bailinghub: host lifecycle, dynamic tools, and visible results
19
+ └─ bailinghub-mcp-server/sdk: PKCE, browser login, credential storage, Runtime DTOs
20
+ └─ BailingHub Core: identity revalidation, capability filtering, approval,
21
+ execution, audit, and the visible conversation ledger
22
+ ├─ business authorization page: binds the current business login
23
+ └─ Tool Provider: ACC declarations, signature verification, final authorization
24
+ ```
25
+
26
+ The dependency direction is host to generic SDK to BailingHub Core. The business system never
27
+ sends its login cookie, password, or API secret to DSH, and DSH never calls business APIs directly.
28
+
29
+ ## 2. Configuration ownership
30
+
31
+ | Configuration | Owner | Storage | Secret |
32
+ |---|---|---|---|
33
+ | `hubUrl` | host deployer | host plugin settings | No; public BailingHub HTTPS origin |
34
+ | `clientAppId` | host deployer | host plugin settings | No; BailingHub client `app_id` |
35
+ | `workspace` | host deployer | host plugin settings | No; an allowed BailingHub `route_key` |
36
+ | `connectionName` | local user | local SDK registry | No; readable selector for one local connection instance |
37
+ | Agent authorization URL | business developer / Hub admin | BailingHub client config | No; one neutral entry per app, never entered by end users |
38
+ | business Client Token | business backend | server-side secret store | **Yes; never browser or DSH config** |
39
+ | Tool Provider Secret | business backend and BailingHub | both secret stores | **Yes; never DSH** |
40
+ | Agent access/refresh token | generic SDK | Keychain or explicit secure store | **Yes; never plugin settings** |
41
+ | model API key | local Agent host | DSH model-provider credential store | **Yes; independent of Hub auth** |
42
+ | BailingHub admin token | Hub operator | Hub server secret store | **Yes; never any Agent client** |
43
+
44
+ `clientAppId` is a public identifier, not a Client Token. A native Agent Client setup must not ask
45
+ the end user to paste a BailingHub Client Token, Tool Provider Secret, or business password.
46
+
47
+ ## 3. BailingHub deployer: expose one Agent Client workspace
48
+
49
+ ### 3.1 Deploy Core and apply migrations
50
+
51
+ Use a BailingHub release that contains Agent Auth v1, Agent Client Runtime v1, and migrations 055
52
+ and 056. Confirm that health and readiness pass, no migration is pending, the console can edit
53
+ Agent Client settings, and production traffic uses HTTPS.
54
+
55
+ Never copy databases, tokens, business domains, or route configuration from a maintainer's
56
+ self-use instance into a public deployment.
57
+
58
+ ### 3.2 Connect business tools
59
+
60
+ The business system still publishes ACC/OpenAPI capability declarations and performs signature
61
+ verification plus final authorization at the real endpoint. Use `bailing/connect` or implement
62
+ the public HTTP/HMAC contract:
63
+
64
+ - [Business integration guide](INTEGRATION.en.md)
65
+ - [Tool governance design](TOOLS_DESIGN.en.md)
66
+ - [PHP SDK](../sdk/php/README.md)
67
+
68
+ Register the business `base_url`, `spec_url`, and a Hub-side credential reference in the Tool
69
+ Provider. The Tool Provider Secret must never enter a route, knowledge base, prompt, or Agent
70
+ Client setting.
71
+
72
+ ### 3.3 Configure a route
73
+
74
+ 1. Set `tools.agent_direct.enabled=true`.
75
+ 2. Add only explicitly allowed write operation IDs to `write_tools`. For a large catalog, use
76
+ **Select all current write operations** in the console; it stores an exact snapshot of the
77
+ current operation IDs and does not authorize future writes automatically. Read-only tools do
78
+ not need to be listed there.
79
+ 3. Inherit approval requirements from the ACC declaration. Use `force_approval_tools` only to
80
+ make selected writes stricter.
81
+ 4. Enable Local Agent Runtime and optionally set host-specific instructions and an active tool
82
+ limit from 1 to 12 (default 8).
83
+ 5. Configure audience, tenant, and role boundaries instead of using `*` as production design.
84
+
85
+ The Agent Client never receives model credentials, Tool Provider Secrets, business API URLs, or
86
+ the complete `target_config`.
87
+
88
+ ### 3.4 Create a client application
89
+
90
+ In Clients, create one Agent Client application:
91
+
92
+ - a stable public `app_id`, for example `merchant-agent`;
93
+ - the minimum `allowed_routes` set;
94
+ - one stable, account- and tenant-neutral HTTPS business authorization entry point, for example
95
+ `https://business.example.com/agent/authorize`;
96
+ - a reasonable rate limit and `enabled=true`.
97
+
98
+ BailingHub displays the Client Token once. Give it only to the business backend that implements
99
+ the authorization page. Never put it in DSH settings, browser JavaScript, a URL, documentation,
100
+ or screenshots.
101
+
102
+ After creation, open **Agent Clients** in the console to:
103
+
104
+ - inspect which existing clients enable Agent authorization and their allowed workspaces;
105
+ - inspect device label, trusted business principal, last activity, and expiry for Agent Sessions;
106
+ - remotely revoke a lost or no-longer-authorized Agent Session;
107
+ - generate secret-free JSON or DSH commands from
108
+ `hubUrl + clientAppId + workspace + connectionName`;
109
+ - view recent conversation, Agent Run, tool-call, token, failure-rate, and approval aggregates.
110
+
111
+ This page projects the existing client, Agent Session, and Agent Run ledgers. It does not create a
112
+ second Client resource and is not the Executor feature. Generated configuration contains no Client
113
+ Token, Agent token, or model key.
114
+
115
+ ## 4. Business developer: bind trusted identity
116
+
117
+ The BailingHub SDK provides server-side Agent Auth methods; it does not inject one universal UI
118
+ into every business system. The business system owns one stable entry point that follows its normal
119
+ login and permission model. It handles login and, when needed, account switching plus selection
120
+ from tenants the backend confirms are accessible. The backend derives `principal`, `on_behalf_of`,
121
+ and allowed routes from the resulting current authenticated server session. Do not register a
122
+ different authorization URL per account, tenant, or store.
123
+
124
+ 1. BailingHub appends only `authorization_id` to the configured page URL.
125
+ 2. The page sends only that ID to its own backend.
126
+ 3. The backend uses its server-side Client Token to read the authorization context.
127
+ 4. After user confirmation, the backend derives trusted identity and approves the request.
128
+ 5. The page navigates only to the `redirect_uri` returned by BailingHub.
129
+ 6. Deny or revoke the session when the user rejects, leaves the organization, or loses a device.
130
+
131
+ PHP example:
132
+
133
+ ```php
134
+ use Bailing\Connect\AgentAuth;
135
+
136
+ $agentAuth = new AgentAuth(
137
+ getenv('BAILINGHUB_BASE_URL'),
138
+ getenv('BAILINGHUB_CLIENT_TOKEN')
139
+ );
140
+
141
+ $context = $agentAuth->context($authorizationId);
142
+
143
+ // Both values come from the authenticated backend session, never from browser claims.
144
+ $result = $agentAuth->approve(
145
+ $authorizationId,
146
+ [
147
+ 'id' => (string) $currentUser->id,
148
+ 'tenant' => (string) $tenantId,
149
+ 'roles' => $currentUser->roles,
150
+ ],
151
+ "tenant_{$tenantId}:user_{$currentUser->id}",
152
+ $context['requested_routes']
153
+ );
154
+
155
+ return redirect($result['redirect_uri']);
156
+ ```
157
+
158
+ Other languages can implement the Agent Auth v1 HTTP contract directly. The Client Token stays
159
+ in the backend `Authorization: Bearer <BUSINESS_CLIENT_TOKEN>` header and is never sent to the
160
+ browser.
161
+
162
+ ## 5. Local Agent user: install and authorize
163
+
164
+ For DSH, follow the versioned installation and compatibility matrix in the
165
+ [dsh-bailinghub repository](https://github.com/bailinghub/bailinghub-dsh-plugin). The native
166
+ plugin configuration contains only:
167
+
168
+ ```text
169
+ hubUrl=https://hub.example.com
170
+ clientAppId=merchant-agent
171
+ workspace=order-assistant
172
+ connectionName=default
173
+ ```
174
+
175
+ Equivalent environment variables are:
176
+
177
+ ```bash
178
+ export BAILINGHUB_HUB_URL='https://hub.example.com'
179
+ export BAILINGHUB_CLIENT_APP_ID='merchant-agent'
180
+ export BAILINGHUB_WORKSPACE='order-assistant'
181
+ export BAILINGHUB_CONNECTION_NAME='default'
182
+ ```
183
+
184
+ `hubUrl` is the Hub origin without `/console`, `/agent-api`, or a business path. `workspace` is a
185
+ route key, not a business domain, tenant ID, or chat-entry ID. Plugin settings contain no business
186
+ URL: BailingHub returns the registered page for `clientAppId`, and the user confirms the business
187
+ account and tenant only on that page.
188
+
189
+ Run in DSH:
190
+
191
+ ```text
192
+ /bailinghub login
193
+ /bailinghub status
194
+ ```
195
+
196
+ Login creates a random loopback PKCE callback and opens the business authorization page. The SDK
197
+ uses macOS Keychain; a Linux/POSIX file fallback is explicit opt-in and requires mode `0600`.
198
+ Agent Session fails closed on Windows until a native secure store is available.
199
+
200
+ Configure the model provider and model API key separately in DSH. The BailingHub plugin neither
201
+ reads nor manages model-provider keys.
202
+
203
+ ## 6. Multiple Hubs, workspaces, and same-binding identity instances
204
+
205
+ The public binding is `Hub + clientAppId + workspace`; `connectionName` is only a local connection
206
+ selector and cannot name an account, tenant, or store. The unreleased multi-connection candidate
207
+ permits multiple instances on the same public binding, but every instance requires separate
208
+ browser authorization. Core does not trust the local instance name or id: the trusted subject
209
+ still comes only from business-backend approval as `principal` and `on_behalf_of`.
210
+
211
+ Each login requests one workspace for least privilege. For another Hub, route, or business identity
212
+ on the same public binding, use a console-generated command or run these user commands in DSH:
213
+
214
+ ```text
215
+ /bailinghub connections add "identity-a" https://hub-a.example.com merchant-agent order-assistant
216
+ /bailinghub connections list
217
+ /bailinghub connections use "identity-a"
218
+ /bailinghub login
219
+ ```
220
+
221
+ Connection selection is a user command, not a model tool. It affects only newly created Agent
222
+ sessions; existing sessions stay pinned to their original connection. `/bailinghub use
223
+ <workspace>` moves only within workspaces already granted to the current authorization and is not
224
+ a multi-connection selector. `/bailinghub connections remove <name>` first revokes the remote
225
+ Agent Session and deletes that instance's local credentials only after success; a failed remote
226
+ revoke keeps that instance for retry. Never copy access or refresh-token files between connections.
227
+
228
+ On one device, when a newly authorized connection under the same public binding yields the same
229
+ trusted `on_behalf_of` as an older connection, the SDK revokes and removes the older local
230
+ connection after the new authorization succeeds. Different identities remain independent. If the
231
+ new authorization succeeded but revoking or removing the older connection failed, the result marks
232
+ `cleanupRequired` and retains a recoverable state. Do not reauthorize; clean up the reported old
233
+ connection first. Core still keys `bz_agent_sessions` by `session_id` and performs no global
234
+ cross-device identity deduplication, so sessions on different devices can be revoked and audited
235
+ independently.
236
+
237
+ ## 7. Minimum acceptance
238
+
239
+ 1. Install a clean DSH profile using public packages only, without local paths or tarballs.
240
+ 2. Confirm `/bailinghub login` opens the configured business authorization domain.
241
+ 3. Confirm `/bailinghub status` exposes non-secret session metadata only.
242
+ 4. Run one read-only business capability.
243
+ 5. Run one reversible write that follows ACC/route approval semantics and is never duplicated.
244
+ 6. Confirm BailingHub shows local-orchestration and Hub-governance trace boundaries.
245
+ 7. Confirm logs, pages, and package artifacts contain no Client Token, Agent token, model key,
246
+ business cookie, tool argument value, or response body.
247
+
248
+ ## 8. Troubleshooting
249
+
250
+ - **`invalid_client`:** check `clientAppId`, enabled state, authorization URL, and allowed route.
251
+ - **Authorization page does not open:** production requires HTTPS; only loopback development may
252
+ use port-qualified `127.0.0.1` or `::1` HTTP.
253
+ - **A fixed tenant or store opens:** `agent_authorize_url` is misconfigured. Register the business
254
+ system's neutral authorization entry point, perform account/tenant choice inside that page, and
255
+ do not add a business URL to plugin settings.
256
+ - **`cleanupRequired`:** the new identity authorization already succeeded. Do not authorize again;
257
+ retry revoke or removal for the reported old connection.
258
+ - **Authorized but no tools:** check the Tool Provider, `tools.agent_direct.enabled`, audience
259
+ policy, and Local Agent Runtime switch.
260
+ - **A write requires approval:** inspect the ACC declaration first. `force_approval_tools` may
261
+ only make policy stricter.
262
+ - **Missing SDK:** the host adapter and `bailinghub-mcp-server/sdk` were not installed at compatible
263
+ versions. Fix the public package dependency; do not copy SDK source or add a local absolute path.
@@ -0,0 +1,245 @@
1
+ # Agent Client v1 接入指南
2
+
3
+ [English](AGENT_CLIENT_QUICKSTART.en.md) | 简体中文
4
+
5
+ Agent Client 让 DeepSeek Harness 等本地智能体负责理解、规划和多步工具选择,同时继续由
6
+ BailingHub 负责可信业务身份、能力裁剪、审批、幂等、业务调用和审计。它不是现有“执行器”,
7
+ 也不是把业务系统的账号、Token 或接口地址交给本地模型。
8
+
9
+ 本指南面向三类角色:BailingHub 部署者、业务系统开发者和本地智能体使用者。三者需要填写的
10
+ 配置不同,不应共享同一份密钥或配置文件。
11
+
12
+ ## 1. 组件关系
13
+
14
+ ```text
15
+ 本地智能体宿主(例如 DSH)
16
+ └─ dsh-bailinghub:接入宿主生命周期、动态工具和可见结果
17
+ └─ bailinghub-mcp-server/sdk:PKCE、浏览器登录、凭据存储、Runtime DTO
18
+ └─ BailingHub Core:身份重验、路由/能力裁剪、审批、执行、审计、会话总账
19
+ ├─ 业务系统授权页:复用业务登录态确认当前用户和允许的 workspace
20
+ └─ Tool Provider:业务侧 ACC 能力声明、验签和最终业务授权
21
+ ```
22
+
23
+ 依赖方向始终从宿主指向通用 SDK,再指向 BailingHub Core。业务系统不会把自己的登录 Cookie、
24
+ 密码或业务 API Secret 发给 DSH;DSH 也不会直接调用业务 API。
25
+
26
+ ## 2. 谁配置什么
27
+
28
+ | 配置 | 谁填写 | 存放位置 | 是否秘密 |
29
+ |---|---|---|---|
30
+ | `hubUrl` | DSH/宿主部署者 | 宿主插件配置 | 否;只填中枢公开 HTTPS 根地址 |
31
+ | `clientAppId` | DSH/宿主部署者 | 宿主插件配置 | 否;对应中枢“接入方”的 `app_id` |
32
+ | `workspace` | DSH/宿主部署者 | 宿主插件配置 | 否;对应允许的 BailingHub `route_key` |
33
+ | `connectionName` | 最终用户或宿主部署者 | 本机 SDK 连接注册表 | 否;选择一个本机连接实例的可读名称 |
34
+ | Agent 授权页 URL | 业务开发者/中枢管理员 | BailingHub 接入方配置 | 否;同一应用只配一个中立入口,不让最终用户手填 |
35
+ | 接入方 Client Token | 业务后端 | 服务端 Secret/环境变量 | **是;不得进入浏览器、DSH 或公开配置** |
36
+ | Tool Provider Secret | 业务后端与 BailingHub | 两端 Secret/凭据管理 | **是;不得进入 DSH** |
37
+ | Agent access/refresh token | 通用 SDK | Keychain 或显式启用的安全存储 | **是;不得显示或写入插件配置** |
38
+ | 模型 API Key | 本地智能体宿主 | DSH 模型提供方凭据 | **是;与 BailingHub 授权完全独立** |
39
+ | BailingHub 管理 Token | 中枢管理员 | 中枢服务端 Secret | **是;不得进入任何 Agent 客户端** |
40
+
41
+ `clientAppId` 是公开客户端标识,不是 Client Token。插件安装完成后不应出现要求用户粘贴
42
+ BailingHub Client Token、Tool Provider Secret 或业务系统密码的步骤。
43
+
44
+ ## 3. BailingHub 部署者:开放一条 Agent Client workspace
45
+
46
+ ### 3.1 部署 Core 并执行数据库迁移
47
+
48
+ 使用包含 Agent Auth v1、Agent Client Runtime v1、migration 055 和 056 的 BailingHub 版本。
49
+ 升级后先确认:
50
+
51
+ - `/health` 和 `/health/ready` 正常;
52
+ - 数据库迁移没有 pending;
53
+ - 管理后台可以编辑“接入方”和“路由”的 Agent Client 配置;
54
+ - 生产环境使用 HTTPS。
55
+
56
+ 不要从自用实例复制数据库、Token、业务域名或 route 配置到公开部署。
57
+
58
+ ### 3.2 接入业务工具
59
+
60
+ 业务侧仍按既有工具接入流程发布 ACC/OpenAPI 能力声明,并在真实调用端执行验签与最终授权。
61
+ 可使用现有 `bailing/connect` SDK,也可以按公开 HTTP/HMAC 契约自行实现:
62
+
63
+ - [业务侧接入指南](第三方对接指南.md)
64
+ - [工具治理设计](TOOLS_DESIGN.md)
65
+ - [PHP SDK](../sdk/php/README.md)
66
+
67
+ 在 BailingHub“工具源”中登记业务侧 `base_url`、`spec_url` 和中枢侧凭据引用。Tool Provider
68
+ Secret 只存在于业务后端与中枢凭据管理中,不进入 route、知识库、提示词或 Agent Client 配置。
69
+
70
+ ### 3.3 配置 route
71
+
72
+ 在“路由”中选择刚才的工具源,并配置:
73
+
74
+ 1. `tools.agent_direct.enabled=true`,显式开放本地 Agent 工具面;
75
+ 2. 只把允许本地 Agent 调用的写操作精确列入 `write_tools`;写操作较多时可在控制台点击“全选当前写操作”,它会保存当前目录的 operationId 快照,不会自动授权未来新增写操作;只读能力无需逐项加入该数组;
76
+ 3. 工具审批默认继承业务侧 ACC 声明;只有确需额外收紧时才加入 `force_approval_tools`;
77
+ 4. 开启“本地 Agent Runtime”,按需填写补充指令和每轮主动工具数(1–12,默认 8);
78
+ 5. 配置 route 的受众、租户和角色边界,不使用 `*` 代替生产授权设计。
79
+
80
+ Agent Client 不会收到模型凭据、Tool Provider Secret、业务 API 地址或完整 `target_config`。
81
+
82
+ ### 3.4 创建接入方
83
+
84
+ 在“接入方”中新建一个用于 Agent Client 的应用:
85
+
86
+ - `app_id`:稳定的公开 `clientAppId`,例如 `merchant-agent`;
87
+ - `allowed_routes`:只选择要开放的 route;
88
+ - `agent_authorize_url`:业务系统实现的一个稳定、统一 HTTPS 授权入口,例如
89
+ `https://business.example.com/agent/authorize`;不要配置成绑定具体账号、租户或门店的 URL;
90
+ - `enabled=true`,并设置合理限速。
91
+
92
+ 中枢创建接入方时会显示一次 Client Token。它只交给业务后端,用于业务授权页服务端调用
93
+ BailingHub Agent Auth 接口。不要把它写入 DSH 配置、网页 JavaScript、URL、README 或截图。
94
+
95
+ 创建完成后可打开控制台“智能体客户端”:
96
+
97
+ - 查看哪些既有接入方已经开放 Agent 授权,以及允许的 workspace;
98
+ - 查看 Agent Session 的设备名、可信业务主体、最后活跃与有效期;
99
+ - 远程撤销遗失设备或不再允许的 Agent Session;
100
+ - 按 `hubUrl + clientAppId + workspace + connectionName` 生成不含秘密的 JSON 或 DSH 命令;
101
+ - 查看近期会话、Agent Run、工具调用、Token、失败率与审批状态聚合。
102
+
103
+ 该页面复用现有接入方、Agent Session 和 Agent Run 账本,不会创建第二套 Client,也不等同于
104
+ “执行器”。生成的配置不包含 Client Token、Agent Token 或模型 Key。
105
+
106
+ ## 4. 业务开发者:建立可信身份授权页
107
+
108
+ BailingHub SDK 提供的是服务端 Agent Auth 方法,不会在任意业务系统中自动生成统一样式的页面。
109
+ 业务系统负责提供一个符合自身登录和权限体系的稳定统一入口;页面必须先要求用户登录,并在需要
110
+ 时允许切换账号、从服务端确认有权访问的租户中进行选择,再由业务后端从选择完成后的当前服务端
111
+ 登录态推导 `principal`、`on_behalf_of` 和可授权 route。不要为每个租户或门店创建不同授权 URL。
112
+
113
+ ### 4.1 浏览器与后端边界
114
+
115
+ 1. BailingHub 在授权页 URL 后只追加 `authorization_id`;
116
+ 2. 授权页前端只把该 ID 发送给自己的业务后端;
117
+ 3. 业务后端携带服务端保存的 Client Token 调用 BailingHub 查询授权上下文;
118
+ 4. 用户确认后,业务后端从当前登录态生成可信身份并批准;
119
+ 5. 前端只跳转 BailingHub 返回的 `redirect_uri`,不得接受任意回调地址;
120
+ 6. 用户拒绝、员工离职或设备丢失时,调用 deny/revoke。
121
+
122
+ PHP 示例:
123
+
124
+ ```php
125
+ use Bailing\Connect\AgentAuth;
126
+
127
+ $agentAuth = new AgentAuth(
128
+ getenv('BAILINGHUB_BASE_URL'),
129
+ getenv('BAILINGHUB_CLIENT_TOKEN')
130
+ );
131
+
132
+ $context = $agentAuth->context($authorizationId);
133
+
134
+ // $currentUser 与 $tenantId 必须来自业务服务端登录态,不能相信前端提交值。
135
+ $result = $agentAuth->approve(
136
+ $authorizationId,
137
+ [
138
+ 'id' => (string) $currentUser->id,
139
+ 'tenant' => (string) $tenantId,
140
+ 'roles' => $currentUser->roles,
141
+ ],
142
+ "tenant_{$tenantId}:user_{$currentUser->id}",
143
+ $context['requested_routes']
144
+ );
145
+
146
+ return redirect($result['redirect_uri']);
147
+ ```
148
+
149
+ 非 PHP 项目可直接实现相同的 Agent Auth v1 HTTP 契约。Client Token 始终放在服务端
150
+ `Authorization: Bearer <BUSINESS_CLIENT_TOKEN>` 请求头中,不得下发到浏览器。
151
+
152
+ ## 5. 本地智能体使用者:安装并授权
153
+
154
+ 以 DSH 原生插件为例,安装步骤、目标版本和兼容矩阵以
155
+ [dsh-bailinghub 仓库](https://github.com/bailinghub/bailinghub-dsh-plugin)为准。插件配置只包含:
156
+
157
+ ```text
158
+ hubUrl=https://hub.example.com
159
+ clientAppId=merchant-agent
160
+ workspace=order-assistant
161
+ connectionName=default
162
+ ```
163
+
164
+ 对应环境变量为:
165
+
166
+ ```bash
167
+ export BAILINGHUB_HUB_URL='https://hub.example.com'
168
+ export BAILINGHUB_CLIENT_APP_ID='merchant-agent'
169
+ export BAILINGHUB_WORKSPACE='order-assistant'
170
+ export BAILINGHUB_CONNECTION_NAME='default'
171
+ ```
172
+
173
+ `hubUrl` 只填中枢根地址,不带 `/console`、`/agent-api` 或业务接口路径;`workspace` 填 route
174
+ 标识,不填业务域名、租户 ID 或聊天入口 ID。插件配置没有业务 URL 字段:授权地址始终由中枢按
175
+ `clientAppId` 返回,业务账号与租户只在该业务授权页中由用户确认。
176
+
177
+ 在 DSH 中执行:
178
+
179
+ ```text
180
+ /bailinghub login
181
+ /bailinghub status
182
+ ```
183
+
184
+ 登录命令会在本机随机 `127.0.0.1` 端口建立 PKCE 回调并打开业务系统授权页。授权成功后,SDK
185
+ 在 macOS 使用 Keychain 保存凭据;Linux/POSIX 文件回退必须显式启用且文件权限为 `0600`;
186
+ Windows 在具备原生安全存储前对 Agent Session 失败关闭。
187
+
188
+ DSH 的模型提供方和模型 API Key 需要在 DSH 自己的模型设置中单独配置。BailingHub 插件既不读取
189
+ 也不代管模型 Key。
190
+
191
+ ## 6. 多 Hub、多 workspace 与同绑定身份实例
192
+
193
+ 公开绑定由 `Hub + clientAppId + workspace` 组成;`connectionName` 只是一个本机连接选择器,不能
194
+ 指定账号、租户或门店。未发布的多连接候选允许多个实例使用同一公开绑定,但每个实例都必须单独
195
+ 完成浏览器授权。Core 不信任本机实例名或实例 ID,可信主体仍只来自业务后端批准得到的
196
+ `principal` 与 `on_behalf_of`。
197
+
198
+ 每次登录按最小权限原则申请一个 workspace。需要连接另一套中枢、另一条 route,或在同一公开
199
+ 绑定下授权另一业务身份时,可由控制台生成命令,或由用户在 DSH 中执行:
200
+
201
+ ```text
202
+ /bailinghub connections add "identity-a" https://hub-a.example.com merchant-agent order-assistant
203
+ /bailinghub connections list
204
+ /bailinghub connections use "identity-a"
205
+ /bailinghub login
206
+ ```
207
+
208
+ 连接切换是用户命令,不是模型工具;它只影响之后新建的 Agent 会话,已有会话保持原连接不漂移。
209
+ `/bailinghub use <workspace>` 只在当前授权已经允许的 workspace 内切换,不能替代多连接选择。
210
+ 删除连接时使用 `/bailinghub connections remove <名称>`:SDK 会先远程撤销 Agent Session,成功
211
+ 后再删除该实例的本地凭据;远程撤销失败则保留该实例和凭据供重试。不要复制 access/refresh token
212
+ 文件。
213
+
214
+ 同一台设备上,如果新连接在相同公开绑定下最终得到与旧连接相同的可信 `on_behalf_of`,SDK 会在
215
+ 新授权成功后撤销并移除旧连接,避免同一身份留下重复本机连接;若身份不同,则两个连接保持独立。
216
+ 如果新授权已经成功、但旧会话撤销或本地清理失败,结果会标记 `cleanupRequired` 并保留可恢复状态。
217
+ 此时不要重新授权,应先按结果列出的旧连接完成清理。Core 的 `bz_agent_sessions` 仍以 `session_id`
218
+ 为主键,不执行跨设备的全局身份去重,因此不同设备上的授权仍可独立失效和审计。
219
+
220
+ ## 7. 最小验收
221
+
222
+ 发布或接入完成后,至少验证:
223
+
224
+ 1. 全新 DSH Profile 只通过公开包安装,不引用本机路径或本地 tgz;
225
+ 2. `/bailinghub login` 打开的域名是开发者配置的业务授权页;
226
+ 3. `/bailinghub status` 只显示非秘密会话元数据;
227
+ 4. 本地 Agent 能查询一项只读能力;
228
+ 5. 一项可回滚写操作遵循 ACC/route 审批语义,且不会重复调用;
229
+ 6. BailingHub 会话页能看到本地编排边界和中枢治理轨迹;
230
+ 7. 日志、页面和包制品中没有 Client Token、Agent token、模型 Key、业务 Cookie、工具参数值或响应正文。
231
+
232
+ ## 8. 常见问题
233
+
234
+ - **`invalid_client`**:检查 `clientAppId`、接入方是否启用、是否配置授权页,以及 workspace 是否在
235
+ `allowed_routes` 中。
236
+ - **授权页打不开**:生产授权页必须是 HTTPS;仅本机开发允许带端口的 `127.0.0.1`/`::1` HTTP。
237
+ - **打开了固定租户或门店**:`agent_authorize_url` 配错了;应改成业务系统的统一授权入口,并在页面
238
+ 内依据当前登录态完成切号或选租户,插件端不要增加业务 URL 配置。
239
+ - **`cleanupRequired`**:新身份授权已经成功,不要再次授权;先按返回的旧连接名称重试撤销或移除。
240
+ - **登录成功但没有业务工具**:检查 route 的工具源、`tools.agent_direct.enabled`、受众策略和
241
+ “本地 Agent Runtime”开关。
242
+ - **写操作要求审批**:先查看业务侧 ACC 声明;route 的 `force_approval_tools` 只能额外收紧,不能
243
+ 降低高风险或 ACC 明示审批。
244
+ - **提示缺少 SDK**:说明宿主适配器与 `bailinghub-mcp-server/sdk` 没有按兼容版本安装;不要通过
245
+ 复制 SDK 源码或改成本机绝对路径绕过,应修正公开包依赖。
@@ -0,0 +1,157 @@
1
+ # Agent Client Runtime v1
2
+
3
+ English | [简体中文](AGENT_CLIENT_RUNTIME_API.md)
4
+
5
+ This versioned API lets a browser-authorized local Agent plan locally while reusing BailingHub
6
+ identity revalidation, tool governance, approvals, audit, and the visible conversation ledger. It
7
+ does not replace `/run`, chat entries, or the executor protocol. See the
8
+ [Agent Client Integration Guide](AGENT_CLIENT_QUICKSTART.en.md) and
9
+ [Agent Auth v1](AGENT_AUTH_API.en.md) for deployment and authorization.
10
+
11
+ Every endpoint requires `Authorization: Bearer <Agent access token>` and returns
12
+ `Cache-Control: no-store`. The workspace is the intersection of the Client `allowed_routes`, Agent
13
+ Session `allowed_routes`, enabled and audience-compatible routes, and `tools.agent_direct`.
14
+ `agent_client.enabled=false` disables this Runtime only; it does not disable the older
15
+ `/agent-api/v1/tools` surface.
16
+
17
+ ## Endpoints
18
+
19
+ - `GET /agent-api/v1/workspaces`
20
+ - `GET /agent-api/v1/workspaces/:route/bootstrap`
21
+ - `POST /agent-api/v1/workspaces/:route/turns`
22
+ - `POST /agent-api/v1/workspaces/:route/capabilities/search`
23
+ - `POST /agent-api/v1/runs/:run_id/complete`
24
+ - Tool execution continues to use `POST /agent-api/v1/tool-invocations` and the existing resume
25
+ endpoint.
26
+
27
+ Raw JSON for `turns` and `complete` is limited to 512 KiB. Parsed values still have strict field
28
+ limits; the service rejects invalid input instead of truncating it silently.
29
+
30
+ ## Write and approval semantics
31
+
32
+ `tools.agent_direct.write_tools` exposes exact write operation IDs to the local Agent. Approval
33
+ requirements continue to come from the business ACC `risk`, `approval.required`, and
34
+ `approval.when` declarations. A route may add stricter approval by listing an exact operation ID
35
+ under `tools.agent_direct.force_approval_tools`; it cannot weaken ACC policy.
36
+
37
+ The deprecated private-candidate field `unattended_write_tools` remains readable for migration.
38
+ Do not configure it together with `force_approval_tools`. When converting old configuration, put
39
+ the difference between the old `write_tools` and `unattended_write_tools` sets into
40
+ `force_approval_tools`, rather than copying the old list unchanged.
41
+
42
+ ## Bootstrap
43
+
44
+ ```json
45
+ {
46
+ "schema_version": "bailing.agent-runtime-profile.v1",
47
+ "workspace": {
48
+ "route": "order-assistant",
49
+ "name": "Order assistant",
50
+ "description": ""
51
+ },
52
+ "profile": {
53
+ "revision": "<sha256>",
54
+ "instructions": "...",
55
+ "memory": {
56
+ "recent_messages": 12,
57
+ "recent_budget_chars": 8000,
58
+ "per_message_chars": 2000,
59
+ "summary_enabled": false,
60
+ "summary_max_chars": 1200
61
+ },
62
+ "knowledge": {
63
+ "enabled": true,
64
+ "sources": 1,
65
+ "mode": "chunk",
66
+ "top_k": 5,
67
+ "max_docs": 4,
68
+ "page_boost": false
69
+ },
70
+ "governance": {
71
+ "planner": "local_agent",
72
+ "execution": "bailinghub_governed",
73
+ "authorization": "server_revalidated",
74
+ "knowledge_trust": "reference_only",
75
+ "tool_results_trust": "untrusted_data",
76
+ "hidden_reasoning_sync": false,
77
+ "max_tool_calls": 5,
78
+ "permission": "full"
79
+ }
80
+ },
81
+ "capabilities": {
82
+ "revision": "<sha256>",
83
+ "authorized_total": 312,
84
+ "active_limit": 8,
85
+ "readonly": 311,
86
+ "writes": 1,
87
+ "approval_required": 0
88
+ }
89
+ }
90
+ ```
91
+
92
+ Bootstrap extracts only `target_config.system_prompt` field by field and appends optional
93
+ `agent_client.instructions`. It never returns credentials, model configuration, other
94
+ `target_config`, Tool Provider base URLs/secrets, or business egress configuration.
95
+
96
+ ## Turn
97
+
98
+ ```json
99
+ {
100
+ "client_conversation_id": "local-conversation-1",
101
+ "client_turn_id": "turn-1",
102
+ "user_message_id": "message-1",
103
+ "user_input": "Find the employee named Ada",
104
+ "page_context": { "url": "/staff", "title": "Staff" },
105
+ "renderers": ["markdown", "bailing-form.v1"]
106
+ }
107
+ ```
108
+
109
+ The four identifiers/input fields are required. `page_context` and `renderers` are optional and
110
+ unknown fields are rejected. `user_input` is limited to 64,000 characters; no more than 20 unique,
111
+ valid renderer names are accepted.
112
+
113
+ The response uses `bailing.agent-turn-context.v1` and contains a stable `run_id`, profile and
114
+ capability revisions, safe instructions, memory, reference-only knowledge, governance, and the
115
+ active typed tool set. The same Agent Session + route + conversation + turn, and the same
116
+ `user_message_id`, resolve to the same frozen run/context. A changed payload under the same key
117
+ returns `409`. Core reads prior memory before it appends the current visible user message.
118
+
119
+ Capability search returns no more than 12 complete typed tools under
120
+ `bailing.agent-capability-search.v1`, always within the authorized set. If semantic retrieval for
121
+ any source is unavailable, the whole search deterministically falls back to lexical ordering. A
122
+ search needs a non-empty query or a valid `run_id` from the same Agent Session and route.
123
+
124
+ ## Tool invocation and recovery
125
+
126
+ Invoke only a tool projected by the current bootstrap/search result. Core revalidates the Agent
127
+ Session, route, operation ID, ACC declaration, approval state, limits, and business authorization
128
+ on every invocation. When the result is pending, in progress, or uncertain, resume the original
129
+ `invocation_id`; do not create a replacement write call.
130
+
131
+ The Hub records visible governance milestones, operation IDs, parameter key names, approval state,
132
+ and business status. It does not receive model hidden reasoning, complete sensitive arguments, or
133
+ raw business response bodies.
134
+
135
+ ## Complete
136
+
137
+ ```json
138
+ {
139
+ "assistant_message_id": "assistant-message-1",
140
+ "status": "completed",
141
+ "content": "Done.",
142
+ "model": "optional-model-name",
143
+ "runtime": "optional-runtime-name",
144
+ "usage": {
145
+ "input_tokens": 120,
146
+ "cached_input_tokens": 80,
147
+ "output_tokens": 30,
148
+ "total_tokens": 150,
149
+ "tool_calls": 1
150
+ }
151
+ }
152
+ ```
153
+
154
+ The assistant message ID, status, visible content, model, runtime, and public usage form one
155
+ idempotency fingerprint. An identical replay returns `200`; any changed field returns `409`.
156
+ Hidden reasoning is neither accepted nor stored. Content is limited to 64,000 characters and
157
+ model/runtime to 191 characters each; invalid values are rejected rather than normalized silently.