dsh-bailinghub 0.5.0 → 0.7.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 (46) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/PRIVACY.md +16 -5
  3. package/README.md +21 -3
  4. package/SECURITY.md +10 -2
  5. package/docs/AGENT_CLIENT_CONTRACT.md +27 -7
  6. package/docs/CAPABILITY_FEEDBACK.md +199 -0
  7. package/docs/COMPATIBILITY.md +19 -6
  8. package/docs/CROSS_SYSTEM_CONVERSATIONS.md +4 -2
  9. package/docs/GENERATED_ARTIFACTS.md +77 -0
  10. package/docs/GETTING_STARTED.md +5 -5
  11. package/docs/GETTING_STARTED.zh-CN.md +5 -5
  12. package/docs/INVOCATION_RECOVERY.md +182 -0
  13. package/docs/MIGRATION_VNEXT.md +8 -0
  14. package/docs/README.zh-CN.md +37 -3
  15. package/docs/RELEASE_NOTES_v0.6.0.en.md +39 -0
  16. package/docs/RELEASE_NOTES_v0.6.0.md +39 -0
  17. package/docs/RELEASE_NOTES_v0.7.0.en.md +15 -0
  18. package/docs/RELEASE_NOTES_v0.7.0.md +15 -0
  19. package/docs/SESSION_TOOL_REUSE.md +213 -0
  20. package/docs/TASK_CONTROL.md +183 -0
  21. package/docs/UPGRADE_v0.6.0.en.md +71 -0
  22. package/docs/UPGRADE_v0.6.0.md +73 -0
  23. package/docs/UPGRADE_v0.7.0.en.md +15 -0
  24. package/docs/UPGRADE_v0.7.0.md +15 -0
  25. package/docs/USAGE_SERVICE.md +96 -0
  26. package/lib/artifact-store.js +56 -0
  27. package/lib/artifacts.js +132 -0
  28. package/lib/capability-feedback.js +138 -0
  29. package/lib/conversation-outbox.js +24 -0
  30. package/lib/index.js +16 -1
  31. package/lib/invocation-journal.js +228 -0
  32. package/lib/invocation-store.js +275 -0
  33. package/lib/model-gateway-transport.js +246 -0
  34. package/lib/runtime.js +951 -146
  35. package/lib/session-scope.js +47 -5
  36. package/lib/session-task-store.js +275 -0
  37. package/lib/session-task.js +237 -0
  38. package/lib/session-tool-cache.js +168 -0
  39. package/lib/session-tools.js +240 -0
  40. package/lib/session-usage-store.js +280 -0
  41. package/lib/tool-catalog.js +38 -0
  42. package/lib/transport.js +19 -0
  43. package/lib/usage-llm-stream.js +157 -0
  44. package/lib/usage-model-transport.js +206 -0
  45. package/lib/usage-provider-stream.js +82 -0
  46. package/package.json +18 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,84 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0 - 2026-09-23
4
+
5
+ Optional host-orchestrated model gateway, USD plan presentation and asynchronous image tools.
6
+ See [changes](docs/RELEASE_NOTES_v0.7.0.en.md) and [upgrade](docs/UPGRADE_v0.7.0.en.md).
7
+
8
+ ## 0.6.0 - 2026-09-16
9
+
10
+ See [scenarios and upgrade](docs/RELEASE_NOTES_v0.6.0.md) · [English](docs/RELEASE_NOTES_v0.6.0.en.md).
11
+
12
+ - Bind administrator-created tasks through persistent taskStore and public host APIs. Preserve original members, cumulative budgets, cancellation and read-only receipt inspection; models cannot create or switch tasks.
13
+
14
+ - Let a conversation panel inspect a pending shop listing or inventory change
15
+ after reopening, without starting a model turn or business run. Explicit continuation
16
+ first inspects the original receipt, preserves approval and task controls, and never
17
+ replaces an uncertain write. Panel and model actions serialize the same invocation.
18
+ Preserve local storage errors, cancellation and original retry deadlines. See the
19
+ [host integration contract](docs/TASK_CONTROL.md).
20
+
21
+ - Let a host read original conversation and selected shop/inventory authorization
22
+ coordinates through `getSessionTaskCoordinates(session)` when preparing a governed
23
+ task. Revalidate the complete original group without locking a draft, creating a
24
+ run or exposing unselected targets. Keep persistence failures distinct from
25
+ retryable network failures and unsupported versions. Existing task binding and
26
+ execution rules remain in force; see [the host contract](docs/TASK_CONTROL.md).
27
+
28
+ - Let an opted-in host retain complete shop, inventory or other business tool
29
+ declarations across user messages in the same living Session. Prepare current
30
+ target context once per user turn; valid exact-name lookups need no additional
31
+ capability-search request. Ordinary chat starts no business run.
32
+ - Bound the session cache to 64 target-tool pairs and 2 MiB, with a 12-schema
33
+ presentation window. Separate cached declarations from currently prepared tools;
34
+ return full schemas and current context through the existing search entry point.
35
+ - A direct unprepared cached call returns preparation only. It creates no business
36
+ invocation, and replaying its call ID cannot turn it into a write. Current identity,
37
+ declaration changes, cancellation and original-invocation recovery remain enforced.
38
+ - Keep legacy `active_turn` behavior by default. Hosts explicitly enable
39
+ `toolLifecycle: 'session'` after handling preparation results. Core and SDK need
40
+ no additional API for this candidate. See [the integration contract](docs/SESSION_TOOL_REUSE.md).
41
+
42
+ - Preserve an authoritative `invocation_not_found` response during polling and
43
+ direct recovery. Stop automatic retries and ask for inspection of the original
44
+ execution evidence, without declaring the business action unexecuted or creating
45
+ a replacement write. Generic network/HTTP failures retain conservative recovery.
46
+
47
+ - Reopen a conversation after pending approval or a lost business response and recover
48
+ the original invocation through a durable, metadata-only local journal. Persist the
49
+ original authorization, run, invocation and parameter digest before dispatch; never
50
+ rebuild a business write from transcript text or substitute another account.
51
+ - Custom hosts can supply an invocation store and inspect or restore its local status.
52
+ Storage failures remain explicit. Restoring metadata sends no business recovery
53
+ request; an explicit resume may continue the original approved operation.
54
+ See [reopening and original invocation recovery](docs/INVOCATION_RECOVERY.md).
55
+
56
+ - Keep long tasks moving between product creation, queries and inventory checks:
57
+ searches merge valid tools during the active turn instead of unloading the previous
58
+ batch. Retain up to 64 callable tools behind a 12-schema model window; unchanged
59
+ registrations survive concurrent discovery and calls.
60
+ - Invalidate only the changed authorization catalog, quarantine contradictory
61
+ declarations, and preserve original invocation recovery and cancellation boundaries.
62
+ See [long-task lifecycle and host upgrade guidance](docs/CAPABILITY_FEEDBACK.md).
63
+
64
+ - Honor Hub retry delays after pre-dispatch rate limiting. Long waits retain the original invocation for later recovery; early manual resumes avoid extra requests. Shared quota details stay visible to the model.
65
+
66
+ - Add an image-first Local Agent attachment space for adapted hosts: list approved conversation
67
+ outputs, upload 1–8 PNG/JPEG/WebP images to an explicitly selected authorization, and reuse
68
+ ready URLs with existing business tools. Persist original upload records for recovery.
69
+ - See [attachment integration](docs/GENERATED_ARTIFACTS.md) for campaign artwork, charts
70
+ and shop examples. Host file access is explicit; upload success and business action results
71
+ are independent. Business limits and original-call recovery remain independent from attachment delivery.
72
+
73
+ - Explain each search target’s returned candidates separately from the conversation’s
74
+ currently loaded tools. Keep unknown totals explicit and describe the shared loading limit.
75
+ - Return actionable, safe failure feedback through native DSH dispatch, including retired
76
+ tool names rejected before the business SDK. Valid loaded tools remain directly callable.
77
+ - Keep an unconfirmed write bound to its original invocation; discovery cannot create
78
+ a replacement operation. Add read-only feedback seams for custom hosts.
79
+ - See [capability discovery and recovery](docs/CAPABILITY_FEEDBACK.md) for shop/inventory
80
+ examples, compatibility and exact candidate installation requirements.
81
+
3
82
  ## 0.5.0 - 2026-09-10
4
83
 
5
84
  ### Shop and inventory in one conversation
package/PRIVACY.md CHANGED
@@ -104,8 +104,12 @@ Hidden reasoning is never uploaded by the adapter.
104
104
 
105
105
  The host checks the captured connection key, workspace, and original Agent Session id before
106
106
  transport operations without projecting those inspection fields into the model's directory.
107
- Invocation bindings are local to the running conversation; a new conversation or process restart
108
- does not recover unknown invocation ids from that map.
107
+ Invocation bindings stay host-side. The [durable recovery journal](docs/INVOCATION_RECOVERY.md)
108
+ adds a separate `invocation-records` store in the plugin data directory for original binding
109
+ metadata, parameter/receipt digests, last-known state and retry deadline. It stores no raw
110
+ arguments, receipt bodies, credentials or conversation text. Records remain until the host/operator
111
+ removes them; there is no automatic cleanup or upload of this journal. The same original Session
112
+ can recover known calls after reopening; new conversations and unknown IDs cannot use that binding.
109
113
 
110
114
  The default file adapter saves scope schema/version, DSH session id, revision, lock/state, public
111
115
  Hub/client/workspace binding, and the selected connection keys, sanitized labels, workspace, and
@@ -123,8 +127,9 @@ loading it does not query its old authorizations or send them user input. A fail
123
127
  write can leave that draft on disk, but it still cannot reactivate automatically in a new runtime.
124
128
  Configuration or metadata history alone does not lock a never-started draft. Missing or invalid
125
129
  scope snapshots on started conversations do not adopt current registry connections.
126
- Restoring that scope does not recover pending business invocations, approvals, completions, or
127
- tasks across a process restart.
130
+ Restoring the scope alone does not recover pending business invocations, approvals, completions,
131
+ or tasks across a process restart. Original invocation recovery requires the separate durable
132
+ journal and an explicit recovery request; it does not automatically resume the whole task.
128
133
 
129
134
  ## Visible conversation archive
130
135
 
@@ -151,7 +156,8 @@ Network failures preserve successfully written events for later upload. Local wr
151
156
  not prove durable capture. Reopened DSH history is checked for detectable missing visible events,
152
157
  reported as `recovery_gap`; unavailable host history is marked unverified. Previously unarchived
153
158
  messages, attachments, and hidden content are not claimed as a complete transcript. The archive
154
- does not restore business invocation or approval execution after restart. An older SDK reports
159
+ does not itself restore business invocation or approval execution after restart; the separate
160
+ invocation journal does not make an incomplete visible archive complete. An older SDK reports
155
161
  unsupported without creating an outbox, and business calls remain available.
156
162
 
157
163
  An offline reopen keeps the original frozen scope closed until every member can be revalidated.
@@ -159,3 +165,8 @@ A later retry on the same runtime may recover a temporary network failure, but c
159
165
  confirmed revocation, replacement identity, or a storage conflict. Archive status retains known
160
166
  unsaved events and history gaps while upload is blocked. Revocation confirmed during asynchronous
161
167
  archive capability discovery or opening is rechecked before reporting availability or uploading.
168
+
169
+
170
+ ## Task records in 0.6.0
171
+
172
+ A private persistent task store binds the original Session, fixed members and administrator-created task. It does not store administrative credentials or grant model task-management authority. Retain original scope, task, invocation and archive records; storage errors never downgrade to an unrestricted flow. Task enrollment persists on the original Agent Session even after cancellation. Do not downgrade an enrolled authorization to a host/Core that ignores that requirement. See [task control](docs/TASK_CONTROL.md) and [upgrade](docs/UPGRADE_v0.6.0.en.md).
package/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # BailingHub for DeepSeek Harness
2
2
 
3
+ ## 0.7.0: optional model services and plan billing
4
+
5
+ Keep orchestration local while Core relays model requests and meters shared allowance asynchronously. Discover chat models and image tools separately; preserve business authorization, approvals and audit. Pair Core 0.9.0 / SDK 0.7.0 / DSH 0.7.0.
6
+
7
+ [Changes](docs/RELEASE_NOTES_v0.7.0.en.md) · [Upgrade](docs/UPGRADE_v0.7.0.en.md)
8
+
9
+
3
10
  [简体中文](docs/README.zh-CN.md) | English
4
11
 
5
12
  Ask your local DeepSeek Harness Agent to work with a business system connected to BailingHub:
@@ -28,18 +35,19 @@ that record fails, it can retry after reconnecting or restarting without repeati
28
35
  This is an independent community integration, not a plugin developed, certified, endorsed, or
29
36
  recommended by DeepSeek.
30
37
 
38
+
31
39
  ## Install and start
32
40
 
33
41
  You need Node.js `22.19.0+` or `24+`, pnpm, and a compatible DeepSeek Harness release. Your
34
42
  administrator must first connect the business system to BailingHub. The matched release set is
35
- **BailingHub Core 0.7.0 → BailingHub MCP/SDK 0.5.0 → this plugin 0.5.0**.
43
+ **BailingHub Core 0.9.0 → BailingHub MCP/SDK 0.7.0 → this plugin 0.7.0**.
36
44
 
37
45
  ```bash
38
46
  npm install --global pnpm @deepseek-ai/dsh@0.1.1-rc.2
39
- dsh plugin --profile web add dsh-bailinghub@0.5.0
47
+ dsh plugin --profile web add dsh-bailinghub@0.7.0
40
48
  ```
41
49
 
42
- The plugin installs its exact `bailinghub-mcp-server@0.5.0` dependency automatically.
50
+ The plugin installs its exact `bailinghub-mcp-server@0.7.0` dependency automatically.
43
51
  For an existing installation, read the [migration steps from 0.4.0 and earlier](docs/MIGRATION_VNEXT.md).
44
52
 
45
53
  Follow the [getting started guide](docs/GETTING_STARTED.md) to enter your administrator's four
@@ -168,6 +176,7 @@ identity separately. Custom DSH hosts must implement the [scope selection and re
168
176
  and display confirmation before the first message. The native slash commands already use those
169
177
  APIs. Tool envelopes, persistence, event schemas, and recovery limits are documented in the
170
178
  [Agent Client contract](docs/AGENT_CLIENT_CONTRACT.md).
179
+ For the Local Agent attachment space (image-first), see [host artifact integration](docs/GENERATED_ARTIFACTS.md). Register approved conversation outputs, upload them once, and use ready URLs with existing business tools.
171
180
 
172
181
  Use Native Tool Mode. DSH Code Mode is deliberately degraded because it cannot safely present the
173
182
  current-turn dynamic schemas. See the [compatibility matrix](docs/COMPATIBILITY.md).
@@ -182,3 +191,12 @@ legacy version when using that path and follow the [migration guide](docs/MIGRAT
182
191
  Report issues at [GitHub Issues](https://github.com/bailinghub/bailinghub-dsh-plugin/issues) with
183
192
  versions and redacted errors. Do not include tokens, private URLs, personal data, or production
184
193
  payloads. Compatibility tests and package downloads are not evidence of production adoption.
194
+
195
+
196
+ ## Recover an original action after reopening
197
+
198
+ Version 0.6.0 adds a local invocation journal for actions such as a product listing
199
+ awaiting approval or an inventory update whose response was lost. Reopen the same conversation
200
+ and explicitly recover the original call without creating a second business request. Custom
201
+ hosts must retain the new store alongside their existing Session scope. See the
202
+ [recovery contract, limits and host integration](docs/INVOCATION_RECOVERY.md).
package/SECURITY.md CHANGED
@@ -118,8 +118,11 @@ Each invocation binds its chosen authorization, Core run, and capability revisio
118
118
  accepts only an invocation known to this conversation and resolves its original binding; the
119
119
  model cannot provide a replacement authorization. Changing a default connection cannot retarget
120
120
  an existing call.
121
- This invocation map lasts only for the live conversation: later turns can recover its original
122
- calls, while new conversations and process restarts must reject unknown invocation ids.
121
+ The live invocation map supports later turns of the same conversation. The unreleased
122
+ [durable recovery journal](docs/INVOCATION_RECOVERY.md) additionally persists original
123
+ metadata before dispatch and validates it after reopening. New conversations, missing records,
124
+ and conflicting original identities still reject recovery. Raw parameters and credentials do
125
+ not belong in the invocation journal; model text never reconstructs its authority.
123
126
 
124
127
  Only non-secret scope metadata belongs in the scope store. Its default file store uses SHA-256 session filenames,
125
128
  mode-0600 files and mode-0700 directories on POSIX, bounded reads, rejection of symlinks/non-regular files,
@@ -174,3 +177,8 @@ that validation. Confirmed revocation/replacement and storage/CAS conflicts rema
174
177
  blocked, with no default or subset fallback. The gate is rechecked after asynchronous archive
175
178
  capability discovery and outbox opening; a late result cannot erase a confirmed revocation.
176
179
  Known local storage errors and capture gaps remain visible even while network or scope checks block upload.
180
+
181
+
182
+ ## Task records in 0.6.0
183
+
184
+ A private persistent task store binds the original Session, fixed members and administrator-created task. It does not store administrative credentials or grant model task-management authority. Retain original scope, task, invocation and archive records; storage errors never downgrade to an unrestricted flow. Task enrollment persists on the original Agent Session even after cancellation. Do not downgrade an enrolled authorization to a host/Core that ignores that requirement. See [task control](docs/TASK_CONTROL.md) and [upgrade](docs/UPGRADE_v0.6.0.en.md).
@@ -1,5 +1,12 @@
1
1
  # Agent Client Host Adapter Contract
2
2
 
3
+ The additive [session tool reuse contract](SESSION_TOOL_REUSE.md) is explicitly
4
+ enabled with `createAgentClientPlugin({ toolLifecycle: 'session', ... })`. It uses
5
+ lazy current-turn target preparation for one or many selected authorizations,
6
+ and retains bounded declarations between messages. The lifecycle descriptions
7
+ below remain the default `active_turn` behavior unless that option is enabled.
8
+ Neither mode changes fixed scope, business approval or original-invocation recovery.
9
+
3
10
  ## Authorization subject display (0.5.0)
4
11
 
5
12
  The business backend may supply `subject_display: { name }` for the subject actually approved by
@@ -133,12 +140,14 @@ Each alias enumerates only its own `authorization_ref` values and wraps unchange
133
140
  snapshots and original target bindings remain fixed on replay. The SDK receives host-only
134
141
  `expectedBinding: { hubUrl, clientAppId, workspace, sessionId }` together with an explicit key
135
142
  on status and all business calls. Model arguments cannot replace these fields.
136
- Explicit search prioritizes that target's results inside the existing twelve-tool budget;
143
+ Explicit search prioritizes that target's results inside the twelve-schema window while retaining up to 64 callable tools;
137
144
  same-named capabilities on earlier targets cannot permanently crowd it out.
138
145
 
139
146
  Recovery accepts only a known original invocation. When needed in a later live turn, it opens
140
147
  only that original target's run with a recovery-specific input and resumes the original invocation;
141
- it does not call the business action again. It does not restore invocation state after process restart.
148
+ it does not create a replacement invocation. The [durable recovery journal](INVOCATION_RECOVERY.md)
149
+ can restore original binding metadata after process restart; scope or archive restoration alone
150
+ cannot. Explicit Core resume may continue the original approved operation.
142
151
  Cancellation and superseding turns cannot register tools or dispatch a new write from a late start.
143
152
  Each cross-system turn owns an AbortSignal combined with the host's signal. SDK dispatch checks
144
153
  that signal after local IO and before HTTP; an in-flight write with an unknown outcome keeps its
@@ -218,7 +227,7 @@ attribution; all injected context still shares the local Agent/model boundary de
218
227
  Business definitions with the same name, description, input schema, and governance are registered
219
228
  once.
220
229
  Conflicting declarations are not merged for execution. Availability remains specific to each
221
- authorization, and the conversation's total active business-tool limit remains 12. In a
230
+ authorization, and the conversation's retained business-tool limit is 64, with at most 12 full schemas shown at once. In a
222
231
  multi-authorization session, each shared definition wraps its unchanged business schema:
223
232
 
224
233
  ```json
@@ -241,9 +250,10 @@ invocation known to this conversation and uses the original binding; it accepts
241
250
  authorization selector. Pending approval and unknown dispatch outcomes follow the same
242
251
  exact-invocation recovery rules as the baseline. Removing or selecting another default must not
243
252
  retarget an existing invocation.
244
- The local invocation map survives later turns of the same live conversation. It is not persisted
245
- across process restarts or copied into new conversations, and unknown invocation ids fail closed.
246
- This increment does not provide durable task recovery across those boundaries.
253
+ The local invocation map survives later turns of the same live conversation. The
254
+ [durable recovery journal](INVOCATION_RECOVERY.md) can restore trusted original binding metadata
255
+ across process restarts, never into another conversation. Unknown IDs fail closed. This is
256
+ original-invocation recovery, not durable automatic continuation of a whole task.
247
257
 
248
258
  On multi-authorization completion, the adapter freezes one deterministic summary of each run's
249
259
  own governed calls and synchronizes that run separately. It does not send the combined visible
@@ -522,7 +532,8 @@ exactly `bailing.agent-turn-context.v1`. Its runtime result is:
522
532
  }
523
533
  ```
524
534
 
525
- At most 12 active tools are accepted. Each tool must use the Core tool-name grammar, an
535
+ At most 12 active tools are accepted per Core response. Further searches can accumulate
536
+ up to 64 retained tools in this active turn; see [discovery lifecycle](CAPABILITY_FEEDBACK.md). Each tool must use the Core tool-name grammar, an
526
537
  object-rooted input schema, and complete governance metadata (`scope`, `risk`,
527
538
  `approval_required`, `readonly`, and `idempotent`).
528
539
  Both revision fields are required lowercase 64-character SHA-256 values; shorter labels or
@@ -668,3 +679,12 @@ Missing/invalid configuration, missing SDK, failed authorization, failed Core co
668
679
  collision, or unsupported DSH Code Mode removes the Core business tools and inserts a concise
669
680
  status section. The local Agent may continue using unrelated local tools, but it is explicitly
670
681
  told not to claim a BailingHub business action was executed.
682
+
683
+
684
+ ## Original invocation recovery after reopening
685
+
686
+ See [the durable recovery contract](INVOCATION_RECOVERY.md) for the additive
687
+ `invocationStore`, `getSessionInvocationStatus(sessionId)` and
688
+ `restoreSessionInvocations(sessionId)` host interfaces. They do not replace the fixed
689
+ scope, original visible-event archive, or attachment store. A host using its own scope
690
+ store must explicitly provide durable invocation storage to support full reopening.
@@ -0,0 +1,199 @@
1
+ # Discover capabilities and recover the right operation
2
+
3
+ DSH 0.6.0 improves the information the Agent receives. Use the paired SDK 0.6.0 and Core 0.8.0 for authoritative counts and feedback. Existing authorization, approval, fixed conversation scope and archive rules still apply.
4
+
5
+ ## What users should notice
6
+
7
+ For example, an Agent checks warehouse stock and then updates a shop product.
8
+
9
+ - A currently loaded shop tool can be called directly for its selected account.
10
+ - The Agent can discover product creation, create a product, discover a query tool,
11
+ check the result, and return to product creation without another search. Searching
12
+ warehouse tools also retains valid shop tools within the current turn.
13
+ - Only 12 full schemas are shown at a time; up to 64 discovered business tools remain
14
+ registered and directly callable with their original target and known parameters.
15
+ This is a tool-type budget, not a limit on operations, products or task duration.
16
+ - Hosts can opt into [cross-turn declaration reuse](SESSION_TOOL_REUSE.md) with
17
+ `toolLifecycle: 'session'`. A cached tool is prepared with current target context
18
+ before use in a new turn. The default remains `active_turn`.
19
+ - If the shop request was sent but its response is unconfirmed, recover only its
20
+ original invocation. A new search or tool name must not produce another write.
21
+
22
+ Business systems still define their own product fields, validation and approvals.
23
+ This change adds no stock synchronization, cross-system transaction or rollback.
24
+
25
+ ## Search result meanings
26
+
27
+ The default `search_business_capabilities` keeps its existing parameters. Opt-in
28
+ session mode adds `tool_name` for exact cached declaration preparation and retrieval;
29
+ a broad `query` without `tool_name` still discovers capabilities. Cross-system search
30
+ requires the original `authorization_ref` and a minimal target-specific query.
31
+ Single-account and same-system selection continue to work.
32
+
33
+ | Field | Meaning |
34
+ | --- | --- |
35
+ | `discovery.returned_count` | Candidates actually returned for this search target |
36
+ | `discovery.authorized_total` | Tools in the same authorization-filtered catalog; `null` when unknown |
37
+ | `discovery.matched_total` | `null`: ranked candidates do not establish an exact match count |
38
+ | `discovery.truncated`, `has_more` | Whether authorized catalog candidates were omitted by the search limit; `null` when unknown |
39
+ | `discovery.truncation_scope` | `authorized_catalog` when reported, otherwise `unknown` |
40
+ | `discovery.mode` | `ranked_candidates`, or `unknown` for older/malformed optional metadata |
41
+ | `discovery.pagination` | `unsupported`; the result does not promise complete paging |
42
+ | `active_tools` | Business tools ready for dispatch in the current turn, with their target references where applicable; session-mode cached preparation guards are listed separately in `cached_tools` |
43
+ | `toolset.active_count`, `limit` | Current registered business-tool count and shared ceiling of 64; search/resume/local tools do not consume this budget |
44
+ | `visible_tools`, `toolset.visible_count`, `visible_limit` | Current full-schema presentation window, capped at 12 across targets; absence here does not mean unloaded |
45
+ | `toolset.retained_outside_window_count` | Registered tools outside that window, still callable using the exact schema already discovered |
46
+ | `toolset.lifetime` | `active_turn`: one user message through its completion/cancellation, including all intermediate searches and operations |
47
+ | `toolset.reuse`, `cache.lifetime` | `session_runtime` only when the host opted into cross-turn declaration reuse; does not change the current-run execution lifetime |
48
+ | `toolset.generation` | Local collection generation, separate from Core's capability revision; compare only within the same runtime/session |
49
+ | `toolset.omitted_tool_count` | Compatible cached candidates omitted by the shared budget, not all unreturned Core capabilities |
50
+ | `toolset.conflicting_tool_count` | Excluded shared declaration conflicts plus per-target contradictory catalog entries |
51
+ | `toolset.catalog_conflict_count` | The per-target contradictory catalog portion of that count |
52
+
53
+ Multi-account results place `discovery` under each searched `authorizations[]`
54
+ entry. The top-level `toolset` covers the whole conversation, not just that target.
55
+ The existing top-level `omitted_tool_count` remains as a compatibility alias for
56
+ the shared-budget count. `toolset.update=merge` describes the registration policy, consistently for one or
57
+ many accounts. Per-target `candidate_update=merge` means the new results were added
58
+ under the same authoritative catalog revision; `reset` with
59
+ `invalidation_reason=capability_revision_changed` invalidates that target's old
60
+ cache before retaining the new response. Tools from other targets keep their own
61
+ revisions. `evicted_count` counts candidates removed by the per-target cache cap
62
+ in this update; it is not a catalog total.
63
+
64
+ If the same target, revision and tool name claim different declarations, that
65
+ name is quarantined for the revision. `conflicting_tools` and structured
66
+ `feedback.category=capability_changed` explain the exclusion. Other valid tools
67
+ remain available. The runtime never silently reinterprets old arguments under the
68
+ new declaration. An authoritative new revision can remove the quarantine.
69
+
70
+ An unrelated query can still return ranked candidates. Neither an empty result
71
+ nor a transport failure proves that the entire business system lacks a feature.
72
+ Optional metadata from older components is unknown, never a fabricated zero.
73
+
74
+ ## Long-task lifecycle and safety
75
+
76
+ Discovery merges only tools actually returned for selected authorizations; it does
77
+ not preload a system's whole catalog. An empty successful search with an unchanged
78
+ revision or a temporary search failure preserves prior valid candidates. A new
79
+ revision clears that target's old candidates even if the new response is empty.
80
+ Core still checks the original identity, allowed surface and revision before each
81
+ new invocation; local retention does not extend permission or skip approval.
82
+
83
+ In the default `active_turn` mode, each target retains up to 64 recently
84
+ discovered/used declarations. The shared
85
+ registry also caps at 64, favoring recently searched/used tools; the schema window
86
+ favors the latest search and subsequent use. Candidates outside the registry cap
87
+ need discovery again. Tools merely outside `visible_tools` do not. This keeps
88
+ memory and prompt costs bounded without forcing a search for every call.
89
+
90
+ With `toolLifecycle: 'session'`, the declaration cache instead shares a total
91
+ budget of 64 target-tool pairs and 2 MiB of JSON across the living Session. Its
92
+ 12-schema presentation window remains separate. New turns prepare only targets
93
+ actually needed, using new context and runs; exact valid cached declarations
94
+ avoid an extra search request. Core's existing `startTurn` may still perform
95
+ bounded internal discovery. See the [session lifecycle contract](SESSION_TOOL_REUSE.md)
96
+ for `cached_tools`, target readiness and preparation-only call handling.
97
+
98
+ The registry applies differences rather than clearing all registrations on every
99
+ search. Unchanged definitions keep their registration; changed schemas or target
100
+ enumerations are retired individually. Searches are serialized within the turn;
101
+ independent calls keep their original invocation bindings while discovery runs.
102
+ An invocation already issued keeps its original arguments, revision, authorization
103
+ and ID regardless of cache eviction. Resume never creates a replacement write.
104
+
105
+ Completion, cancellation, scope failure and a new user turn retain their existing
106
+ boundaries: ended turns cannot accept late search results or reactivate tools.
107
+ The default cache ends with the active turn. Opt-in session-mode declarations
108
+ can survive between turns in the same living runtime; they are never reused as
109
+ authorization or old run context, and are not persisted across restarts. Archive
110
+ events, original run links, ACK/CAS and attachment upload identities are unchanged.
111
+ Original invocation metadata can be persisted separately by the
112
+ [durable recovery](INVOCATION_RECOVERY.md); it does not restore the old tool cache.
113
+
114
+ ## Structured failure feedback
115
+
116
+ Failures carry `bailing.agent-feedback.v1` with `category`, `code`, `origin`,
117
+ `operation`, `dispatch`, `retryable`, `next_action`, a controlled `message`, and the
118
+ original `invocation_id` when one exists. SDK-defined feedback is projected through
119
+ a safe allowlist; raw transport messages and arbitrary extra fields are omitted.
120
+
121
+ `retryable` refers only to `next_action`. It never grants permission to issue a new
122
+ business invocation. `dispatch=not_dispatched` is used only for a known stage; a
123
+ transport failure after invoking cannot establish that the request was not sent.
124
+
125
+ | Category | Intended next step |
126
+ | --- | --- |
127
+ | `tool_not_loaded` | Rediscover the same selected target, unless an existing invocation needs recovery |
128
+ | `capability_changed` | Check the current declaration; an original recovery stays bound to the original invocation |
129
+ | `transport_unavailable` | Retry discovery or original identity validation/recovery as indicated |
130
+ | `authorization_unavailable` | Restore/confirm the original scope or reauthorize; do not use defaults or a surviving subset |
131
+ | `unsupported` | Check the supported component combination; arbitrary 404/503 errors are not version evidence |
132
+ | `invocation_outcome_unknown` | Resume or inspect the original invocation; never create a replacement write |
133
+ | `cancelled`, `invalid_request`, `unknown_failure` | Follow the explicit action; do not guess a business retry |
134
+
135
+ Core's `reconciliation_required` result remains a non-auto-retry result. Its
136
+ feedback says `inspect_original`; ordinary resume may only replay the recorded
137
+ uncertainty and can require an operator to verify the result.
138
+
139
+ An authoritative original-record lookup failure also requires inspection:
140
+ `code=invocation_not_found`, `category=invocation_outcome_unknown`,
141
+ `next_action=inspect_original`, `retryable=false`, `original_outcome=unverified`.
142
+ The plugin stops the current recovery poll and preserves the original invocation ID.
143
+ For example, a host may have saved a shop listing's dispatch fence before it crashed,
144
+ while the request never reached Core. That is only one possible cause: a missing
145
+ record does not prove that the listing was never performed. Do not recreate it from
146
+ the conversation or switch accounts. Generic 404/network errors cannot establish
147
+ this condition. See [recovery failure rules](INVOCATION_RECOVERY.md#failure-and-compatibility-rules).
148
+
149
+ ## Client host integration
150
+
151
+ Standard native DSH uses the existing `tools/execute` hook. Error results retain
152
+ `isError=true` and the original host error information, while carrying the same
153
+ safe feedback in `result.meta.bailinghub.feedback` and JSON text content
154
+ `{"feedback": ...}`. Ordinary multi-target search can succeed overall while a
155
+ target entry contains `state=unavailable` plus its own `feedback`.
156
+
157
+ Only BailingHub-owned tool failures are decorated. Host `UNKNOWN_TOOL` is classified
158
+ as retired only for a previously registered business name in that conversation
159
+ which is no longer registered. Other plugins, unknown names, currently registered
160
+ tools hidden by host presentation, and reserved tools are not reclassified.
161
+
162
+ Two read-only runtime methods support hosts which intercept dispatch earlier:
163
+
164
+ ```js
165
+ runtime.getSessionToolState(sessionId)
166
+ // { state, toolset, active_tools, visible_tools }; no HTTP requests or new business run
167
+
168
+ runtime.getToolDispatchFeedback(sessionId, {
169
+ toolName, callId, errorCode: 'UNKNOWN_TOOL',
170
+ })
171
+ // feedback or null; call only after the host registry actually rejects lookup
172
+ ```
173
+
174
+ Pass the original call ID. If that call already has an invocation, feedback points
175
+ to that original ID instead of suggesting a new operation. These methods do not
176
+ execute or restore tools and must not be used to bypass normal scope validation.
177
+ Do not filter dispatch against `visible_tools` or the latest search response: the
178
+ native registry and `active_tools` determine retained availability. Do not cache a
179
+ stale copy of the registry or demand discovery before every call. Keep all new
180
+ fields in model-facing search results. Custom hosts which only allow names in the
181
+ current schema window need to support retained native registry dispatch; otherwise
182
+ their presentation layer can still produce an artificial `UNKNOWN_TOOL`.
183
+ No new user/assistant message upload path is needed.
184
+
185
+ Session-mode hosts must also preserve `targets`, `cached_tools`, `contexts`,
186
+ `tool_schemas` and the preparation result's `business_operation_performed=false`.
187
+ An unprepared cached tool name can return preparation and schema without performing
188
+ the requested operation. The model must read current context and issue a new call
189
+ before a new business operation; replaying the preparation's call ID does not
190
+ convert it into an operation. Do not gate these native preparation guards against
191
+ `active_tools` alone. Read-only tool-state methods do not prepare targets.
192
+
193
+ Tested with the public native registry `@deepseek-ai/dsh-tools@0.1.1-rc.2` and real
194
+ Cordis/DSH Sessions. A custom host must verify the hook and preserve the feedback
195
+ carrier through its own model loop. Simply adding properties to a thrown Error is
196
+ insufficient: the host may discard them. Older SDK/Core combinations retain their
197
+ business flows, but may lack precise counts or authoritative error detail.
198
+
199
+ These discovery and tool-lifecycle changes require no credential, scope or archive conversion. Follow the [release upgrade guide](UPGRADE_v0.6.0.en.md) for the complete release, including Core migrations for attachments, limits and task controls.
@@ -1,22 +1,32 @@
1
+ # Current 0.7.0 pairing
2
+
3
+ Use Core 0.9.0, SDK 0.7.0 and DSH 0.7.0 for optional model plans and image tools. Existing business-governance APIs retain their documented minima. Host orchestration, scope, approval and audit rules remain in effect. See [upgrade](UPGRADE_v0.7.0.en.md).
4
+
1
5
  # Compatibility
2
6
 
3
- ## Native Agent Client 0.5.0
7
+ ## Capability feedback
8
+
9
+ The additive [capability feedback contract](CAPABILITY_FEEDBACK.md) requires the paired
10
+ Core 0.8.0 / SDK 0.6.0 / DSH 0.6.0 release set for complete counts and error detail. Older unenrolled combinations keep their existing business behavior with unknown optional metadata.
11
+
12
+
13
+ ## Native Agent Client 0.7.0
4
14
 
5
15
  | Component | Release pairing / requirement |
6
16
  | --- | --- |
7
17
  | DeepSeek Harness | `0.1.1-rc.2`; real Session and native Cordis lifecycle |
8
18
  | Node.js | `^22.19.0` or `>=24.0.0` |
9
19
  | DSH tool presentation | Native Tool Mode; Code Mode deliberately degraded |
10
- | Generic Agent Client SDK | Exact `bailinghub-mcp-server@0.5.0` via `./sdk` |
11
- | BailingHub Core | `bailinghub@0.7.0`, with outstanding migrations through 059 applied |
20
+ | Generic Agent Client SDK | Exact `bailinghub-mcp-server@0.7.0` via `./sdk` |
21
+ | BailingHub Core | `bailinghub@0.9.0`, with outstanding migrations through 064 applied |
12
22
  | Selected scope | Single account, same-system multiple accounts, or different Client Apps/workspaces on one Hub and audit domain |
13
23
  | Original authorization | A distinct original Agent Session for every selected target |
14
24
  | Persistence | Existing same-system v1 scope/outbox and cross-system v2 records |
15
25
 
16
- Install `dsh-bailinghub@0.5.0`; its ordinary dependency installs the exact SDK automatically.
26
+ Install `dsh-bailinghub@0.7.0`; its ordinary dependency installs the exact SDK automatically.
17
27
  Core 0.6.1 and SDK/plugin 0.4.0 remain the historical same-system baseline, not an alternative
18
28
  pairing for new cross-system features. See the [upgrade steps](MIGRATION_VNEXT.md) and
19
- [release scenario](RELEASE_NOTES_v0.5.0.md).
29
+ [release scenarios](RELEASE_NOTES_v0.7.0.en.md).
20
30
 
21
31
  ### Authorization subject display
22
32
 
@@ -68,7 +78,10 @@ New conversations need explicit scope selection before the first message. Custom
68
78
  and display selection, preserve the stable conversation id, and restore the original scope before
69
79
  sending on reopen. Missing started-session snapshots stay blocked. Saved drafts require fresh
70
80
  confirmation. Scope restoration and archive synchronization do not recover business invocations,
71
- approvals, or task execution after a process restart.
81
+ approvals, or task execution after a process restart. The
82
+ [invocation recovery journal](INVOCATION_RECOVERY.md) supplies a separate durable journal
83
+ for explicit recovery of original calls. Custom scope-store hosts must explicitly provide
84
+ `invocationStore`; existing calls remain available if they have not enabled that feature.
72
85
 
73
86
  Temporary network failure during reopening is retryable on the same runtime under the complete
74
87
  original scope. Confirmed revocation, replaced identity, or storage/CAS conflict stays blocked.
@@ -82,8 +82,10 @@ installing this plugin does not migrate or deploy the Hub.
82
82
  and multiple selected routes sharing one Agent Session are not supported.
83
83
  - Task planning and step ordering are performed by the Agent. This is not a deterministic
84
84
  dependency engine, a distributed transaction, automatic rollback, or cross-process task recovery.
85
- - Original invocation recovery is available in later turns of the same live runtime. Archive
86
- restoration after restart does not reconstruct pending invocations or approvals.
85
+ - Original invocation recovery is available in later turns of the same live runtime. The
86
+ unreleased [durable recovery candidate](INVOCATION_RECOVERY.md) adds explicit recovery after
87
+ restart when the host retains its invocation journal. Archive restoration alone does not
88
+ reconstruct pending invocations or approvals.
87
89
  - Different systems' object IDs are unrelated unless a verified business mapping establishes
88
90
  the relationship. The Agent must clarify an ambiguous mapping.
89
91
  - The runtime enforces target and capability boundaries. It does not provide automatic
@@ -0,0 +1,77 @@
1
+ # 本地智能体附件空间:DSH 宿主接入
2
+
3
+ 智能体生成或用户明确指定用于业务的图片,可以用于活动海报、内容封面、经营图表,也可以用于商城商品。宿主把当前会话获准使用的图片登记到附件目录,插件提供目录查询和上传工具;模型选择目标授权与附件引用,中枢保存图片并返回 URL,供后续业务工具使用。图片不必在当前轮生成;仅用于聊天理解的附件不会因此自动登记或上传,聊天附件历史存档是另一项独立能力。
4
+
5
+ 首期支持 PNG、JPEG、WebP。附件空间提供会话级目录、上传与上传结果恢复,不把 PDF、Word、视频或完整网盘管理写成已经交付的能力。业务系统需要预先提供相应的图片 URL 接口。
6
+
7
+ 配套版本:Core 0.8.0 / SDK 0.6.0 / DSH 0.6.0。新能力需部署方升级并按宿主契约接入;业务权限、审批和原身份约束保持。
8
+
9
+ ## 宿主需要接哪两处
10
+
11
+ ```js
12
+ import { createAgentClientPlugin, createFileArtifactStore } from 'dsh-bailinghub'
13
+
14
+ const plugin = createAgentClientPlugin({
15
+ // 保留原 SDK、scopeStore、archiveStore 等配置。
16
+ artifactSource: {
17
+ async list({ sessionId }) {
18
+ // 从本会话已获准用于业务的图片中读取;只返回元数据,最多 100 项。
19
+ return [{ artifactRef: 'campaign-banner', name: 'campaign-banner.png',
20
+ mime: 'image/png', bytes: generatedSize, sha256: generatedDigest }]
21
+ },
22
+ async read({ sessionId, artifactRef }) {
23
+ // 宿主按已登记引用读取获准文件,返回 Uint8Array。
24
+ // 检查归属、允许目录、符号链接及读取期间文件变化;不要直接拼接模型给出的路径。
25
+ return generatedBytes
26
+ },
27
+ },
28
+ artifactStore: createFileArtifactStore({ directory: artifactRecoveryDirectory }),
29
+ })
30
+ ```
31
+
32
+ `artifactRef` 是宿主管理的稳定引用,允许字母、数字、下划线和短横线,最多128字符;不可把同一个引用改指另一份文件。同名图片可以用不同引用。目录属于真实 DSH Session,重新打开时保持原归属;后台持久化上传元数据目录同样需要跨重启保留。也可实现自有 `artifactStore.get(uploadId)` / `reserve(record)`:reserve 必须原子、只写一次并返回先前记录或新记录,落盘完成才成功返回。内存 store 仅用于测试或明确的临时会话。
33
+
34
+ 未提供 artifactSource 时不会新增模型工具,已有业务流程不变。缺少持久恢复 store 时上传返回 storage_error,并且不会发送文件。
35
+
36
+ ## 模型实际能用的工具
37
+
38
+ - `list_generated_artifacts`:读取当前会话产物目录,不返回路径或文件正文。
39
+ - `upload_generated_artifacts`:必须明确 `authorization_ref` 与 `artifact_refs` 数组;每批1–8张,单张不超过6MiB,支持PNG/JPEG/WebP。
40
+
41
+ 上传成功后模型直接使用 ready URL,不需要为每次使用重复查询地址或上传。只有不确定的上传结果或会话重开恢复才查询原上传记录。
42
+
43
+ 业务操作独立执行并单独判断结果。例如更新商城轮播图时,所有必需图片 ready 后再提交完整清单,保留未被要求删除的旧图片;业务结果未知时保留原 invocation,不能重发写操作。
44
+
45
+ 模型不选择桶或密钥。中枢管理员在“智能体客户端 → 配置接入 → 工具与审批 → 生成图片上传”选择媒体存储。第一期图片用于公开展示;普通COS/OSS或显式本地存储都由部署方管理保留,不增加文件到期判定。
46
+
47
+ ## 失败和重开
48
+
49
+ ### 跨轮上传与旧错误记录恢复
50
+
51
+ 新上传只关联目标授权**当前轮次的 active run**。跨系统按需启动业务 run;该目标当轮尚未启动时,上传使用原会话与当前轮次、不带可选 runId,既不沿用上轮记录,也不为上传额外创建业务 run。
52
+
53
+ 旧候选可能保存了“本轮上传 + 上轮 run”的记录。只有配套 Core 返回 `artifact_run_turn_mismatch`(同一原身份、路由、会话均一致,仅轮次不同),且再次读取原上传 ID 明确返回 `artifact_not_found`,DSH 才自动纠正。泛化的 `artifact_run_mismatch`、授权失效、网络错误或结果未知都不能触发纠正。Core 的身份和关联检查保持生效。
54
+
55
+ 纠正不覆盖原恢复记录:通过现有 get/reserve 原子保存独立的 `bailing.artifact-run-link-repair.v1` 记录,保留原记录摘要和原上传 ID。修正元数据只删除已证明属于另一轮的 runId,保留原上传会话、轮次、内容及目标;实际 HTTP 始终使用原上传 ID。宿主应完整保存记录中的 `runLinkRepair` 字段,不把这个本地记录键当成新增云端上传或新产物。无需新增 store 方法。
56
+
57
+ 纠正必须落盘后才补传;已 ready 的原回执直接复用,pending 不改绑,确认丢失后读取原 ID。原记录或纠正记录缺失、损坏时返回 storage_error,不根据服务端 URL 猜补本地历史。旧 Core/SDK 没有精确错误码时,旧错链记录继续明确阻断;当前正确链接的新上传仍兼容原附件 API。
58
+
59
+ 两个工具名中的 `generated` 为兼容保留,不限制来源必须是 AI 生成。宿主需要更新自己的目录说明,让用户明确指定业务用途的图片可以受控登记,不新增聊天附件自动同步或用户手动上传入口。
60
+
61
+ 每文件上传身份绑定原真实 Session、连接与产物引用,首发前原子保存原 Hub/client/workspace/Agent Session、内容摘要、名称和原会话/轮次/run关联。重试或重开先读取原中枢记录,成功项直接复用 URL;pending 或尚未写入时补传原文件。即使原文件已不可读,已确认成功的上传仍可恢复。
62
+
63
+ 批量结果包含 `results`、`all_ready` 和 `business_operation_performed=false`。每项为 ready、pending 或 blocked。成功项保留,失败项独立处理;不要因部分上传成功就写入残缺图库。
64
+
65
+ 本地持久化失败返回 storage_error;原记录损坏或丢失须由宿主标记恢复缺口,不能猜补原历史。暂时网络失败可以在同一 runtime 重试,保留原记录。任何原授权成员撤销或改绑时整组阻断,不退回默认、子集或替代 Session。取消后迟到上传不会重新注册业务工具或返回可继续执行的轮次;已经保存的对象及原记录仍可在合法恢复时查询。
66
+
67
+ 旧SDK/Core返回artifact_unsupported,保留原业务工具能力。Lazy SDK transport 已转发新增接口,但宿主仍必须实际提供生成文件来源。测试替身与真实对象存储连通性分开验收。
68
+
69
+ ## 业务后端要不要改
70
+
71
+ 如果原业务能力已经接收图片 URL,不必改授权或审批规则。客户端将 ready URL 作为原业务参数传入即可。需要业务自身素材ID、转存或素材库归属时,另接该系统的业务导入能力。
72
+
73
+ ## 分开记录的已知限制
74
+
75
+ 配套 Core 0.8.0 已提供可配置的中枢工具限额,小时/日额度按原窗口计数,并为新调用保留加密原参数。DSH 读取 `retry_after_ms`,等待后只恢复原 `invocation_id`;长于自动等待预算时返回 `agent_client_wait.state=rate_limited`,保留等待时间和原调用。手动过早恢复也不向中枢反复请求。原权限、审批、取消和授权目标约束继续生效;旧 Core 不返回提示时仍沿原恢复流程。
76
+
77
+ 当前列表工具的源错误可能经过通用分类变成 unknown_failure;宿主应保留自己检查到的 storage_error/recovery_gap,不能将其描述为空目录。上传工具仍返回逐项错误。不要用新业务调用或重新上传已经 ready 的附件掩盖这些问题。