dsh-plugin-dev-kb 1.0.8 → 1.0.9

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 (169) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.en.md +6 -6
  3. package/README.md +6 -6
  4. package/kb/INDEX.md +19 -5
  5. package/kb/README.md +11 -10
  6. package/kb/extra/AGENTS.md +4 -4
  7. package/kb/extra/cookbook/adding-a-vendored-package.md +2 -2
  8. package/kb/extra/cookbook/adding-a-vendored-package.zh.md +2 -2
  9. package/kb/extra/deepseek-llm-api-wire-extensions.md +159 -0
  10. package/kb/extra/deepseek-llm-api-wire-extensions.zh.md +159 -0
  11. package/kb/extra/development.md +8 -14
  12. package/kb/extra/development.zh.md +8 -14
  13. package/kb/extra/event-producer-consumer.md +47 -41
  14. package/kb/extra/event-producer-consumer.zh.md +47 -41
  15. package/kb/extra/glossary.md +1 -1
  16. package/kb/extra/glossary.zh.md +1 -1
  17. package/kb/extra/graph-atlas.md +0 -2
  18. package/kb/extra/graph-atlas.zh.md +0 -2
  19. package/kb/extra/i18n/README.md +4 -4
  20. package/kb/extra/i18n/README.zh.md +4 -4
  21. package/kb/extra/module-graph.md +680 -413
  22. package/kb/extra/module-graph.zh.md +681 -414
  23. package/kb/extra/postmortem/0001-acp-default-export-drops-inject.md +2 -2
  24. package/kb/extra/postmortem/0001-acp-default-export-drops-inject.zh.md +2 -2
  25. package/kb/extra/postmortem/0002-js-expression-disabled-filesystem-tools.md +2 -2
  26. package/kb/extra/postmortem/0002-js-expression-disabled-filesystem-tools.zh.md +2 -2
  27. package/kb/extra/postmortem/0003-web-agent-gui-feedback-loop.md +2 -2
  28. package/kb/extra/postmortem/0003-web-agent-gui-feedback-loop.zh.md +2 -2
  29. package/kb/extra/postmortem/0004-landlock-partial-notice-misclassified-child-failures.md +1 -1
  30. package/kb/extra/postmortem/0004-landlock-partial-notice-misclassified-child-failures.zh.md +1 -1
  31. package/kb/extra/rescope.md +2 -2
  32. package/kb/extra/rescope.zh.md +2 -2
  33. package/kb/extra/subsystems/agent-team.md +24 -1
  34. package/kb/extra/subsystems/agent-team.zh.md +24 -1
  35. package/kb/extra/subsystems/attachment.md +12 -4
  36. package/kb/extra/subsystems/attachment.zh.md +12 -4
  37. package/kb/extra/subsystems/extensions.md +18 -0
  38. package/kb/extra/subsystems/extensions.zh.md +18 -0
  39. package/kb/extra/subsystems/feedback.md +2 -2
  40. package/kb/extra/subsystems/feedback.zh.md +2 -2
  41. package/kb/extra/subsystems/todo.md +32 -0
  42. package/kb/extra/subsystems/todo.zh.md +32 -0
  43. package/kb/extra/subsystems/webhook.md +70 -0
  44. package/kb/extra/subsystems/webhook.zh.md +70 -0
  45. package/kb/extra/testing.md +11 -10
  46. package/kb/extra/testing.zh.md +8 -7
  47. package/kb/meta/search-index.json +269 -161
  48. package/kb/meta/site-pages.txt +182 -168
  49. package/kb/meta/source.json +5 -5
  50. package/kb/meta/topics.md +14 -6
  51. package/kb/site/develop/basic/publish.md +2 -2
  52. package/kb/site/develop/basic/tool.md +1 -1
  53. package/kb/site/develop/cordis-tutorial/07-into-the-harness.md +4 -4
  54. package/kb/site/develop/framework/events.md +1 -1
  55. package/kb/site/develop/practice/dynamic-cordis.md +17 -0
  56. package/kb/site/develop/practice/llm-adapter.md +3 -3
  57. package/kb/site/en/develop/basic/publish.md +2 -2
  58. package/kb/site/en/develop/basic/tool.md +1 -1
  59. package/kb/site/en/develop/cordis-tutorial/07-into-the-harness.md +4 -4
  60. package/kb/site/en/develop/framework/events.md +1 -1
  61. package/kb/site/en/develop/practice/dynamic-cordis.md +17 -0
  62. package/kb/site/en/develop/practice/llm-adapter.md +3 -3
  63. package/kb/site/en/guide/github-review.md +104 -0
  64. package/kb/site/en/guide/mcp-memory.md +103 -0
  65. package/kb/site/en/guide/python-sdk.md +80 -34
  66. package/kb/site/en/guide/schedule.md +21 -0
  67. package/kb/site/en/reference/agent-lifecycle.md +1 -1
  68. package/kb/{extra → site/en/reference}/api-gateway.md +11 -9
  69. package/kb/site/en/reference/capability-seams.md +115 -67
  70. package/kb/site/en/reference/config-catalog.md +358 -164
  71. package/kb/site/en/reference/cookbook/adding-a-package.md +2 -2
  72. package/kb/site/en/reference/cookbook/adding-a-settings-card.md +2 -2
  73. package/kb/site/en/reference/cookbook/adding-a-tool.md +11 -4
  74. package/kb/site/en/reference/cookbook/adding-an-llm-adapter.md +1 -1
  75. package/kb/site/en/reference/cookbook/extension-cookbook.md +6 -6
  76. package/kb/site/en/reference/cordis-api/inherited.md +1 -1
  77. package/kb/site/en/reference/cordis-primer.md +2 -1
  78. package/kb/site/en/reference/index.md +19 -7
  79. package/kb/site/en/reference/persistence-catalog.md +91 -44
  80. package/kb/site/en/reference/subsystems/approval.md +10 -10
  81. package/kb/site/en/reference/subsystems/client-modules.md +58 -16
  82. package/kb/site/en/reference/subsystems/code-runtime.md +3 -3
  83. package/kb/site/en/reference/subsystems/compaction.md +2 -2
  84. package/kb/site/en/reference/{cookbook/adding-a-conversation-node.md → subsystems/conversation.md} +43 -24
  85. package/kb/site/en/reference/subsystems/core.md +70 -12
  86. package/kb/site/en/reference/subsystems/credentials.md +43 -3
  87. package/kb/site/en/reference/subsystems/filesystem.md +12 -2
  88. package/kb/site/en/reference/subsystems/index.md +6 -1
  89. package/kb/site/en/reference/subsystems/jobs.md +1 -1
  90. package/kb/site/en/reference/subsystems/llm-streaming.md +132 -11
  91. package/kb/site/en/reference/subsystems/permission-presets.md +1 -1
  92. package/kb/site/en/reference/subsystems/persistence.md +22 -3
  93. package/kb/site/en/reference/subsystems/plan.md +1 -1
  94. package/kb/site/en/reference/subsystems/session-projection.md +74 -33
  95. package/kb/site/en/reference/subsystems/session-query.md +9 -1
  96. package/kb/site/en/reference/subsystems/session-reference.md +28 -7
  97. package/kb/site/en/reference/subsystems/session-telemetry.md +2 -3
  98. package/kb/site/en/reference/subsystems/session.md +260 -41
  99. package/kb/site/en/reference/subsystems/settings.md +78 -1
  100. package/kb/site/en/reference/subsystems/skills.md +23 -0
  101. package/kb/site/en/reference/subsystems/slots.md +177 -0
  102. package/kb/site/en/reference/subsystems/spill.md +2 -2
  103. package/kb/site/en/reference/subsystems/storage.md +9 -1
  104. package/kb/site/en/reference/subsystems/subagent.md +90 -23
  105. package/kb/site/en/reference/subsystems/system-prompt.md +4 -4
  106. package/kb/site/en/reference/subsystems/token-meter.md +25 -10
  107. package/kb/site/en/reference/subsystems/tools.md +39 -39
  108. package/kb/site/en/reference/subsystems/typert.md +44 -37
  109. package/kb/site/en/reference/subsystems/user-questions.md +33 -33
  110. package/kb/site/en/reference/subsystems/web-client.md +98 -0
  111. package/kb/site/en/reference/subsystems/web-server.md +11 -5
  112. package/kb/site/en/reference/subsystems/web.md +7 -1
  113. package/kb/site/en/reference/subsystems/workspace.md +95 -2
  114. package/kb/site/en/reference/tool-catalog.md +76 -18
  115. package/kb/site/en/reference/tool-execution-pipeline.md +1 -1
  116. package/kb/site/guide/github-review.md +104 -0
  117. package/kb/site/guide/mcp-memory.md +103 -0
  118. package/kb/site/guide/python-sdk.md +87 -41
  119. package/kb/site/guide/schedule.md +21 -0
  120. package/kb/site/reference/agent-lifecycle.md +1 -1
  121. package/kb/{extra/api-gateway.zh.md → site/reference/api-gateway.md} +11 -9
  122. package/kb/site/reference/capability-seams.md +115 -67
  123. package/kb/site/reference/config-catalog.md +357 -163
  124. package/kb/site/reference/cookbook/adding-a-package.md +2 -2
  125. package/kb/site/reference/cookbook/adding-a-settings-card.md +2 -2
  126. package/kb/site/reference/cookbook/adding-a-tool.md +11 -4
  127. package/kb/site/reference/cookbook/adding-an-llm-adapter.md +1 -1
  128. package/kb/site/reference/cookbook/extension-cookbook.md +6 -6
  129. package/kb/site/reference/cordis-api/inherited.md +1 -1
  130. package/kb/site/reference/cordis-primer.md +2 -1
  131. package/kb/site/reference/index.md +19 -7
  132. package/kb/site/reference/persistence-catalog.md +87 -40
  133. package/kb/site/reference/subsystems/approval.md +10 -10
  134. package/kb/site/reference/subsystems/client-modules.md +58 -16
  135. package/kb/site/reference/subsystems/code-runtime.md +3 -3
  136. package/kb/site/reference/subsystems/compaction.md +2 -2
  137. package/kb/site/reference/{cookbook/adding-a-conversation-node.md → subsystems/conversation.md} +43 -24
  138. package/kb/site/reference/subsystems/core.md +70 -12
  139. package/kb/site/reference/subsystems/credentials.md +43 -3
  140. package/kb/site/reference/subsystems/filesystem.md +12 -2
  141. package/kb/site/reference/subsystems/index.md +6 -1
  142. package/kb/site/reference/subsystems/jobs.md +1 -1
  143. package/kb/site/reference/subsystems/llm-streaming.md +132 -11
  144. package/kb/site/reference/subsystems/persistence.md +22 -3
  145. package/kb/site/reference/subsystems/plan.md +1 -1
  146. package/kb/site/reference/subsystems/session-projection.md +74 -33
  147. package/kb/site/reference/subsystems/session-query.md +9 -1
  148. package/kb/site/reference/subsystems/session-reference.md +28 -7
  149. package/kb/site/reference/subsystems/session-telemetry.md +2 -3
  150. package/kb/site/reference/subsystems/session.md +260 -41
  151. package/kb/site/reference/subsystems/settings.md +78 -1
  152. package/kb/site/reference/subsystems/skills.md +23 -0
  153. package/kb/site/reference/subsystems/slots.md +177 -0
  154. package/kb/site/reference/subsystems/spill.md +2 -2
  155. package/kb/site/reference/subsystems/storage.md +9 -1
  156. package/kb/site/reference/subsystems/subagent.md +90 -23
  157. package/kb/site/reference/subsystems/system-prompt.md +4 -4
  158. package/kb/site/reference/subsystems/token-meter.md +25 -10
  159. package/kb/site/reference/subsystems/tools.md +39 -39
  160. package/kb/site/reference/subsystems/typert.md +44 -37
  161. package/kb/site/reference/subsystems/user-questions.md +33 -33
  162. package/kb/site/reference/subsystems/web-client.md +98 -0
  163. package/kb/site/reference/subsystems/web-server.md +11 -5
  164. package/kb/site/reference/subsystems/web.md +7 -1
  165. package/kb/site/reference/subsystems/workspace.md +95 -2
  166. package/kb/site/reference/tool-catalog.md +76 -18
  167. package/kb/site/reference/tool-execution-pipeline.md +1 -1
  168. package/package.json +2 -2
  169. package/skills/dsh-plugin-dev-kb.md +8 -6
@@ -0,0 +1,177 @@
1
+ ---
2
+ editSource: "docs/subsystems/slots.md"
3
+ outline: [2,3]
4
+ ---
5
+
6
+ # Web Client Slots
7
+
8
+ Slots are the Web Client's typed React composition system. [`dsh-client-ui-slots`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/client/ui-slots/README.md) defines the React-free registry and type algebra; [`dsh-client-ui-renderer`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/client/ui-renderer/README.md) binds observable sources to hooks, renders the tree, and owns React contexts internally. A feature plugin contributes UI through `ctx.slots.register()` and never imports another feature plugin's component.
9
+
10
+ This page documents slot ownership, component inputs, extension APIs, and the shipped hierarchy. The surrounding boot, Remote, Client model, and Conversation paths are in [Web Client architecture](./web-client.md).
11
+
12
+ ## Declaration and lifecycle
13
+
14
+ `SlotMap` is the compile-time registry. A package declaration-merges the key, cardinality, scope, owner props, keyed props, and optional slot-level inject face. The runtime declaration is the matching `children` entry on the component that owns the render location.
15
+
16
+ Declaring a child has three effects: it makes the child key live, authorizes that parent entry's `renderSlot` or `renderSlotChain` call, and records the runtime dispatch specification. One live entry owns each declaration. Registering into an undeclared slot or declaring a child already owned elsewhere fails during plugin activation.
17
+
18
+ `root` is the only built-in declaration and the only key rendered through the Cordis service itself. `ui-renderer` calls `ctx.slots.renderSlot('root', {})`; every descendant is rendered through the `renderSlot` or `renderSlotChain` prop of the entry that declared it.
19
+
20
+ Registrations and declarations follow Cordis effect lifetimes. Disposing an entry removes its contribution and recursively collapses the child slots it declared. A feature that contributes into another package's slot therefore uses `ctx.slots.inject(key, callback)`: the callback runs for each declaration lifetime, its effects are removed when the owner collapses, and it runs again if the owner is mounted again.
21
+
22
+ ```tsx ignore-check
23
+ import type { Context } from '@deepseek-ai/cordis'
24
+ import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
25
+ import type {} from '@deepseek-ai/dsh-client-ui-session/client'
26
+ import type { PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
27
+
28
+ type HeaderActionProps = PropsRuntime<'conversation.session.header.actions'>
29
+
30
+ function HeaderAction({ useSession }: HeaderActionProps) {
31
+ const running = useSession(snapshot => snapshot.running)
32
+ return <button disabled={running}>Review</button>
33
+ }
34
+
35
+ export const inject = ['slots']
36
+
37
+ export function apply(ctx: Context): void {
38
+ ctx.slots.inject('conversation.session.header.actions', () =>
39
+ ctx.slots.register({
40
+ name: 'conversation.session.header.actions',
41
+ id: 'review',
42
+ order: 100,
43
+ }, HeaderAction))
44
+ }
45
+ ```
46
+
47
+ ## Cardinality and scope
48
+
49
+ The slot declaration fixes two independent axes.
50
+
51
+ | Axis | Value | Meaning |
52
+ |---|---|---|
53
+ | cardinality | `single` | One cell. The active priority winner renders. Use a child slot instead of treating this as an additive list. |
54
+ | cardinality | `list` | Cells are addressed by required `id` and ordered by `order`, then registration order. |
55
+ | cardinality | `keyed` | The owner dispatches an `entryKey`; the matching cell renders with any key-specific props. |
56
+ | cardinality | `chain` | Each entry supplies a pure `select(owner)` function. The first non-null result in priority order renders and receives that result as `matched`; otherwise the owner fallback renders. |
57
+ | scope | `root` | One root-scoped component and store instance. |
58
+ | scope | `session-maybe` | Follows current selection but stays renderable without a Session; Session values are optional. |
59
+ | scope | `session` | Requires a resolved Session binding and receives definite Session values. |
60
+
61
+ `priority` is a shadowing rank for `single`, `list`, and `keyed` cells and an election order for `chain`. Lower values run or render first. Ordinary additive contributions should choose a fresh list `id` or keyed `key`; intentionally reusing a shipped cell replaces its presentation.
62
+
63
+ ## Component inputs
64
+
65
+ A registered component receives inputs assembled at its binding site. Components derive these types rather than copying their members.
66
+
67
+ | Input | Declared by | Component type |
68
+ |---|---|---|
69
+ | owner values and standard scope values | the `SlotMap` row and installed scope adapters | `PropsRuntime<K>` |
70
+ | authorized child renderers | the registration's `children` keys | `PropsRenderSlots<S>` |
71
+ | selector hook and mutation callbacks for shared view state | the registration's `store` | `PropsStore<H>` |
72
+ | private data, callbacks, and observable hooks | the registration's `inject` factory | `InjectFace<I>` |
73
+ | localized `t` function | the registration's `locale` namespace | `PropsLocale<N>` |
74
+ | selected chain value | the registration's `select` result | `matched` through `ComposedProps` |
75
+
76
+ `SessionProvider` is also present in `PropsRenderSlots` when an entry declares a strict Session child. It binds that subtree to the current Session identity and remounts the body when the identity changes.
77
+
78
+ Components never receive `ctx`. Parent-owned point-in-time values enter through the owner argument to `renderSlot`; shared view state uses a declared store; services and model objects stay in the `apply` closure and are projected into callbacks or observable sources.
79
+
80
+ ## Framework-provided hooks
81
+
82
+ The shipped adapters add these standard props. They are available according to the target slot's scope, independent of which package registered the component.
83
+
84
+ | Availability | Props | Owner |
85
+ |---|---|---|
86
+ | every scope | `useSessions`, `useSessionPendingInteraction` | `ui-session` |
87
+ | every scope | `useWorkspaces` | `ui-workspace` |
88
+ | `session` | `sessionId`, `useSession`, `useProjection` | `ui-session` |
89
+ | `session-maybe` | optional `sessionId`, `useSession`, `useProjection` results | `ui-session` |
90
+ | `session` | `useConversation`, `useInput`, `inputActions` | `ui-conversation` |
91
+ | `session-maybe` | optional `useConversation`, `useInput`, `inputActions` results | `ui-conversation` |
92
+ | `session` | `useChat` | `ui-chat` |
93
+ | `session` | `useTrajectory` | `ui-trajectory` |
94
+
95
+ The renderer also creates `useStore` from a declared store and `t` from a declared locale namespace. These are registration-derived props rather than global standard props.
96
+
97
+ Framework and domain-adapter owners may extend the standard set through `ctx.slots.provideRoot()` or `ctx.uiSession.provide()` together with the corresponding `GlobalStandardProps`, `SessionStandardProps`, or `SessionMaybeStandardProps` declaration merge. A feature component should not create a React hook prop itself or add a global standard prop for entry-private data.
98
+
99
+ ## Developer-provided injection
100
+
101
+ The `inject` option on a registration is the ordinary feature-owned injection point. Its factory runs in the plugin's `apply` world, may close over injected Cordis services, and returns only the data and callbacks that the component needs. For a `session` slot it receives `sessionId`; for `session-maybe` it receives `sessionId | undefined`; when a store is declared it also receives the store's bound actions.
102
+
103
+ A reserved `hooks` object in that return value accepts bare `getSnapshot`/`subscribe` sources. The renderer converts `hooks: { status }` into a `useStatus(selector)` component prop and caches the binding by source identity. Components do not receive the source itself and do not call `useSyncExternalStore` directly.
104
+
105
+ The owner of a slot may put an `inject` face in the child declaration when every occupant needs the same capability. Plain members reach all occupants unchanged. Function-valued members inside its `hooks` object are hook factories; they receive the slot's standard props and optional per-render `hookContext`, then return the constrained hook exposed to the occupant. `conversation.chat.node` uses this mechanism to provide `useTurnData(key)` for the node currently being rendered.
106
+
107
+ Use owner props for values already known at one render occurrence, registration `inject` for one entry's callbacks and private observables, slot-level `inject` for a capability controlled by the slot owner, and a declared store for mutable view state shared across entries or preserved across remounts. React nodes compose through child slots, not through injected values.
108
+
109
+ ## Current hierarchy
110
+
111
+ The hierarchy below is the shipped declaration tree. A child exists only while the named parent entry is mounted; optional feature entries can therefore make a subtree appear or disappear as one lifecycle unit.
112
+
113
+ ```text
114
+ root
115
+ ├─ sidebar
116
+ │ ├─ sidebar.brand.mark
117
+ │ ├─ sidebar.brand.name
118
+ │ ├─ sidebar.footer.action
119
+ │ ├─ sidebar.workspaces
120
+ │ │ └─ sidebar.workspaces.directoryFlow
121
+ │ └─ sidebar.settings
122
+ │ ├─ settings.trigger
123
+ │ ├─ settings.header
124
+ │ ├─ settings.action
125
+ │ ├─ settings.close
126
+ │ ├─ settings.onboarding
127
+ │ └─ settings.section
128
+ │ ├─ settings.general.item
129
+ │ ├─ settings.models.provider-card
130
+ │ ├─ settings.models.footer
131
+ │ └─ settings.plugins.tab
132
+ │ └─ settings.plugin.item
133
+ ├─ conversation
134
+ │ ├─ conversation.session
135
+ │ │ └─ conversation.view
136
+ │ │ ├─ conversation.chat.node
137
+ │ │ │ ├─ conversation.chat.assistant-actions
138
+ │ │ │ ├─ conversation.chat.commandview
139
+ │ │ │ ├─ conversation.chat.turnTail
140
+ │ │ │ └─ tool.call.toolview
141
+ │ │ │ └─ tool.view.cordis
142
+ │ │ ├─ conversation.message.images
143
+ │ │ └─ conversation.trajectory.images
144
+ │ ├─ conversation.session.header
145
+ │ │ ├─ conversation.session.header.lineage
146
+ │ │ ├─ conversation.session.header.actions
147
+ │ │ └─ conversation.session.header.utilities
148
+ │ ├─ conversation.composer
149
+ │ │ └─ conversation.approval.detail
150
+ │ ├─ conversation.composer.bar
151
+ │ │ ├─ conversation.input.attachments
152
+ │ │ ├─ conversation.input.plan
153
+ │ │ └─ conversation.input.model
154
+ │ ├─ conversation.input.overlay
155
+ │ ├─ conversation.input.dock
156
+ │ ├─ conversation.composer.dock
157
+ │ ├─ conversation.input.left
158
+ │ ├─ conversation.input.right
159
+ │ ├─ conversation.hero.brand.mark
160
+ │ ├─ conversation.hero.workspace
161
+ │ │ └─ conversation.hero.workspace.directoryFlow
162
+ │ └─ conversation.hero.agentPreset
163
+ ├─ details
164
+ │ └─ conversation.details.tool
165
+ └─ shell.overlay
166
+ ```
167
+
168
+ The generated Client inspect catalog is the exhaustive contract for each key: cardinality, scope, owner props, standard props, current occupants, declaration owner, and replacement risk. A running dynamic package can query the live tree and an exact key with `cordis_inspect what:"client"`; the source catalog is generated from `SlotMap` declarations and `slots.register()` call sites by `pnpm run gen-client-catalog`.
169
+
170
+ ## Extension rules
171
+
172
+ - Import another feature package only for declarations with `import type`; never import or re-export its runtime values.
173
+ - Declare a new child slot only in the component that owns and renders that location. Other packages wait with `ctx.slots.inject()` and contribute through `ctx.slots.register()`.
174
+ - Keep business and transport state in their owning Cordis services or Client models. Slot stores hold shared viewing and interaction state only.
175
+ - Keep observable source and snapshot identities stable between changes. Republish through the same source whenever its value changes.
176
+ - Pass JSON-compatible data and callbacks between UI domains. The `hooks` compartment is the sole exception for bare observables; React content travels through slots.
177
+ - Treat `single` and an occupied keyed cell as replacement points. Use list ids or an unoccupied key for additive extensions.
@@ -41,7 +41,7 @@ interface SpillOwner {
41
41
  }
42
42
  ```
43
43
 
44
- `SpillOwner.sessionId` is the save-time storage namespace. Forked sessions inherit existing spill locators from the seeded log; those artifacts are not copied or re-owned, and spills produced after the fork use the child session id. A retention-period cleanup may expire old locators with other old session artifacts; the spill seam does not define a per-session cleanup policy.
44
+ A retention-period cleanup may expire old locators with other old session artifacts; the spill seam does not define a per-session cleanup policy.
45
45
 
46
46
  ```ts type-equiv
47
47
  /**
@@ -53,7 +53,7 @@ interface SpillSource {
53
53
  /** The tool whose result was spilled (e.g. `web_fetch`). */
54
54
  toolName: string
55
55
  /** The model-issued call id the result belongs to. */
56
- callId: CallId
56
+ callId: ToolCallId
57
57
  /** A short human label for the artifact (e.g. `result`). */
58
58
  label: string
59
59
  }
@@ -47,7 +47,7 @@ interface StorageBackend {
47
47
  }
48
48
  ```
49
49
 
50
- A backend owns one medium (a file-tree root, a database file) and exposes optional operation groups; `kv` is the only group today. `KvFacet.open(descriptor)` opens one named unit — `KvUnitDescriptor` carries the name, format version, table names, and whether a global singleton slot exists — and returns a `KvUnit` with `loadAll`, `putRecord`, `deleteRecord`, `setGlobal`, and `close`. Unit and table names must match `UNIT_NAME_RE` (safe as a file name and as a SQL identifier segment); record keys are arbitrary strings that never reach file paths. A unit does not serialize concurrent writes — ordering belongs to the caller — but each single call is atomic on the medium and durable once resolved. A medium stamped with a different version rejects `version-mismatch`; one that cannot be parsed as the unit rejects `malformed-medium` (no migration, pre-release stance). [`backend.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/storage/storage/src/backend.ts) is the normative clause-by-clause contract, and the shared conformance suite in [`tests/contract.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/storage/storage/tests/contract.ts) checks every clause against each backend. The [json backend](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/storage/storage-json/README.md) republishes one whole human-readable file per unit atomically; the [sqlite backend](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/storage/storage-sqlite/README.md) stores one document per row in one database for frequently updated data.
50
+ A backend owns one medium (a file-tree root, a database file) and exposes optional operation groups; `kv` is the only shipped group. `KvFacet.open(descriptor)` opens one named unit — `KvUnitDescriptor` carries the name, format version, table names, and whether a global singleton slot exists — and returns a `KvUnit` with `loadAll`, `putRecord`, `deleteRecord`, `setGlobal`, and `close`. Unit and table names must match `UNIT_NAME_RE` (safe as a file name and as a SQL identifier segment); record keys are arbitrary strings that never reach file paths. A unit does not serialize concurrent writes — ordering belongs to the caller — but each single call is atomic on the medium and durable once resolved. A medium stamped with a different version rejects `version-mismatch`; one that cannot be parsed as the unit rejects `malformed-medium` (no migration, pre-release stance). [`backend.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/storage/storage/src/backend.ts) is the normative clause-by-clause contract, and the shared conformance suite in [`tests/contract.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/storage/storage/tests/contract.ts) checks every clause against each backend. The [json backend](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/storage/storage-json/README.md) republishes one whole human-readable file per unit atomically; the [sqlite backend](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/storage/storage-sqlite/README.md) stores one document per row in one database for frequently updated data.
51
51
 
52
52
  ## Declaring a domain
53
53
 
@@ -60,6 +60,14 @@ interface DomainSpec {
60
60
  readonly name: string
61
61
  /** Domain format version; a medium stamped with a different version rejects at open. */
62
62
  readonly version: number
63
+ /**
64
+ * Medium layout for the backend unit: `single` (the default) stores the
65
+ * whole unit as one document; `per-record` stores each record as its own
66
+ * document, for units whose records are large, sparse, or individually
67
+ * disposable — the projection cache — and scopes version bumps per record
68
+ * (a stale record document is discarded, never migrated).
69
+ */
70
+ readonly layout?: 'single' | 'per-record'
63
71
  /** Optional global singleton slot. */
64
72
  readonly global?: DomainGlobalSpec<unknown>
65
73
  /** Table declarations keyed by table name; each name must match `UNIT_NAME_RE`. */
@@ -7,7 +7,7 @@ outline: [2,3]
7
7
 
8
8
  The subagent seam lets an agent delegate work to a child agent. Like [bash](./shell.md), it is **one optional capability**, not part of the agent loop, so its types live here rather than in [core.md](./core.md). It differs from the other capability seams because **multiple provider implementations coexist** in one context, registered by name (`ctx.subagents`), while bash allows only one executor. Its registry follows the [LLM adapter registry](./llm-streaming.md), not the single-service bash executor.
9
9
 
10
- Service Definition: [dsh-subagent](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/subagent/subagent) (`ctx.subagents` + the vocabulary below). Service Providers are sibling packages (`dsh-subagent-spawn-in-process`, `-fork`, `-acp`, `-codex`, `-claude-code`, `-dsh-sdk`); the model-facing Consumers are [dsh-tool-subagent](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/subagent/tool-subagent) (per-provider delegation), [dsh-tool-subagent-control](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/subagent/tool-subagent-control) (the optional global `send_message`, `interrupt_agent`, and `list_agents` controls), and [dsh-tool-subagent-report](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/subagent/tool-subagent-report) (the optional child-scoped `report` return channel). The same `ctx.subagents` service owns continuable-child orchestration through an internal activation manager and read-only child and descendant discovery straight from the session store and optional session persistence. Product-provider rationale lives in [the Codex and Claude Code Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-08-04-claude-code-and-codex-subagent-backends.md); common-seam rationale lives in [the subagent Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-06-21-subagent-capability-seam.md), [the continuable subagents Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-07-28-continuable-subagent-conversations.md), [the report-tool Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-07-30-continuable-subagent-report-tool.md), [the durable catalog Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-07-22-durable-subagent-catalog-and-list-agents.md), [the list-identity-projection Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/architecture/2026-08-06-subagent-list-identity-projection.md), and [the merged-service Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/simplification/2026-07-26-merge-subagent-control-service.md).
10
+ Service Definition: [dsh-subagent](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/subagent/subagent) (`ctx.subagents` + the vocabulary below). Service Providers are sibling packages (`dsh-subagent-spawn-in-process`, `dsh-subagent-fork-in-process`, `dsh-subagent-acp`, `dsh-subagent-codex`, `dsh-subagent-claude-code`, `dsh-subagent-dsh-sdk`); the model-facing Consumers are [dsh-tool-subagent](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/subagent/tool-subagent) (per-provider delegation), [dsh-tool-subagent-control](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/subagent/tool-subagent-control) (the optional global `send_message`, `interrupt_agent`, and `list_agents` controls), and [dsh-tool-subagent-report](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/subagent/tool-subagent-report) (the optional child-scoped `report` return channel). The same `ctx.subagents` service owns continuable-child orchestration through an internal activation manager and read-only child and descendant discovery straight from the session store and optional session persistence. Product-provider rationale lives in [the Codex and Claude Code Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-08-04-claude-code-and-codex-subagent-backends.md); common-seam rationale lives in [the subagent Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-06-21-subagent-capability-seam.md), [the continuable subagents Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-07-28-continuable-subagent-conversations.md), [the report-tool Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-07-30-continuable-subagent-report-tool.md), [the durable catalog Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-07-22-durable-subagent-catalog-and-list-agents.md), [the list-identity-projection Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/architecture/2026-08-06-subagent-list-identity-projection.md), and [the merged-service Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/simplification/2026-07-26-merge-subagent-control-service.md).
11
11
 
12
12
  Sources: [`packages/subagent/subagent/src/types.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/subagent/subagent/src/types.ts), [`packages/subagent/subagent/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/subagent/subagent/src/index.ts), and [`packages/subagent/subagent/src/continuation.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/subagent/subagent/src/continuation.ts)
13
13
 
@@ -28,6 +28,7 @@ A provider advertises its **start-time** features on a static descriptor the ser
28
28
  * to `maxDepth`; the other names match.
29
29
  */
30
30
  interface SubagentCapabilities {
31
+ readonly agentOptions: boolean
31
32
  readonly outputSchema: boolean
32
33
  readonly depthLimit: boolean
33
34
  readonly toolFilter: boolean
@@ -37,7 +38,7 @@ interface SubagentCapabilities {
37
38
 
38
39
  ## The one-shot start request
39
40
 
40
- The tool layer builds this request from the model input and its own config; the service validates it against the named provider before `start`. Required `parent` supplies the session cwd, lineage, and delegation depth. Optional output schema, depth, tool filter, and persona require matching capability flags. Unsupported schemas fail at start; in-process backends scope filters and personas to child creation and implement the supported object-rooted schema with a forced capture tool.
41
+ The tool layer builds this request from the model input and its own config; the service validates it against the named provider before `start`. Required `parent` supplies the session cwd, lineage, and delegation depth. Optional Agent provider, model, reasoning-effort, and token overrides, output schema, depth, tool filter, and persona require matching capability flags. In-process backends merge `agentOptions` over the parent Agent's options, scope filters and personas to child creation, and implement the supported object-rooted schema with a forced capture tool. The DSH SDK backend merges the four Agent route fields over its instance defaults and validates them in the child runtime's initialization; ACP, Codex, and Claude Code reject `agentOptions` before starting their transports.
41
42
 
42
43
  ```ts type-equiv
43
44
  /**
@@ -66,6 +67,13 @@ interface SubagentStartRequest {
66
67
  * remaining turn work when it fires afterward.
67
68
  */
68
69
  readonly signal: AbortSignal
70
+ /**
71
+ * Optional host-Agent provider, model, reasoning-effort, and output-token
72
+ * overrides. Requires {@link SubagentCapabilities.agentOptions}; in-process
73
+ * providers merge them over the parent Agent's options when they create the
74
+ * child, while the DSH SDK provider merges them over its instance defaults
75
+ * before initializing the separate child runtime.
76
+ */
69
77
  readonly agentOptions?: AgentOptions
70
78
  /**
71
79
  * Object-rooted JSON Schema within `assertObjectJsonSchema`'s enforced subset. Start rejects
@@ -243,7 +251,7 @@ interface SubagentReportOptions {
243
251
  }
244
252
  ```
245
253
 
246
- The provider participates only in preparing the initial creation spec, where `spawn` and `fork` differ. Its returned spec carries only detached provider-specific creation inputs — today the optional parent-history seed — and no Agent, `AgentHandle`, prompt delivery, result, disposal, or resume operation. Cold resume does not dispatch through a provider at all: the manager folds the generic descriptor, calls `ctx.agents.resume()` through the same activation-owner scope, and submits the waiting turn.
254
+ The provider participates only in preparing the initial creation spec, where `spawn` and `fork` differ. Its returned spec carries only detached provider-specific creation inputs — the optional parent-history seed — and no Agent, `AgentHandle`, prompt delivery, result, disposal, or resume operation. Cold resume does not dispatch through a provider at all: the manager folds the generic descriptor, calls `ctx.agents.resume()` through the same activation-owner scope, and submits the waiting turn.
247
255
 
248
256
  ```ts type-equiv
249
257
  /**
@@ -283,7 +291,7 @@ interface ContinuableCreateSpec {
283
291
  }
284
292
  ```
285
293
 
286
- The descriptor (`SubagentDescriptorData` in [descriptor.ts](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/subagent/subagent/src/descriptor.ts)) is a mode-discriminated durable identity for every session-backed subagent. Both modes carry the provider name. A `one-shot` descriptor optionally carries a caller-owned display `label`; a `continuable` descriptor requires the delegation `description` as its durable creation label and additionally snapshots resolved child `agentOptions.provider`/`model` and optional `persona`/`toolFilter` for cold resume. It never snapshots the merge-extensible `AgentOptions` object, so an unrelated extension value cannot break continuation and a later composition input is a deliberate version change. It omits `subagentDepth` (cold resume trusts the persisted header's `delegationDepth` as the monotone floor) and `outputSchema` (one run or Activation's result contract, not durable identity).
294
+ The descriptor (`SubagentDescriptorData` in [descriptor.ts](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/subagent/subagent/src/descriptor.ts)) is a mode-discriminated durable identity for every session-backed subagent. Both modes carry the provider name. A `one-shot` descriptor optionally carries a caller-owned display `label`; a `continuable` descriptor requires the delegation `description` as its durable creation label and additionally snapshots resolved child `agentOptions.provider`/`model`/`reasoningEffort` and optional `persona`/`toolFilter` for cold resume. It never snapshots the merge-extensible `AgentOptions` object, so an unrelated extension value cannot break continuation and a later composition input is a deliberate version change. It omits `subagentDepth` (cold resume trusts the persisted header's `delegationDepth` as the monotone floor) and `outputSchema` (one run or Activation's result contract, not durable identity).
287
295
 
288
296
  A local one-shot provider appends the descriptor inside the child's initial turn before its first request. The continuation manager appends the descriptor after any provider-supplied lineage and before the initial prompt is admitted; `header.seedLength` remains the fork-lineage boundary: resume-time descriptor authority reads the child's own suffix, while the list-serving identity projection folds `subagent/descriptor` last-wins so the child's own descriptor overrides a fork-seeded ancestor's. The event is log-only: no `surfaceOp`, never in model history, and retained across compaction by the append-only log. Malformed current-version descriptors are corrupt; unsupported versions cannot be classified by this runtime.
289
297
 
@@ -415,7 +423,7 @@ A local one-shot run MUST publish an ordinary child agent/session before `start(
415
423
 
416
424
  ## The provider contract: `SubagentProvider`
417
425
 
418
- Each provider is a named child-agent transport, and multiple providers may coexist. The service validates requested start-time capabilities before `start()`, and rejects a continuable start on a provider without `prepareContinuable`. `inheritsParentContext` describes only conversation seeding (`fork`: true; `spawn` and `acp`: false), allowing consumers to generate accurate model-facing wording without implying inherited tools, services, or authority.
426
+ Each provider is a named child-agent transport, and multiple providers may coexist. The service validates requested start-time capabilities before `start()`, and rejects a continuable start on a provider without `prepareContinuable`. `inheritsParentContext` describes only conversation seeding (`fork`: true; `spawn` and `acp`: false), allowing consumers to generate accurate model-facing wording without implying inherited tools, services, or authority. A provider whose one-shot route has static provider-owned defaults publishes optional immutable `agentRouteDefaults`, allowing a Consumer to merge model/tool overrides against the correct baseline before preflight.
419
427
 
420
428
  ```ts type-equiv
421
429
  /**
@@ -437,6 +445,13 @@ interface SubagentProvider {
437
445
  * It says nothing about tool registration, injected services, or authority inheritance.
438
446
  */
439
447
  readonly inheritsParentContext: boolean
448
+ /**
449
+ * Optional static provider-owned provider/model route for one-shot Agent
450
+ * options. Consumers merge tool/model overrides over these values before
451
+ * preflight; providers whose route derives from the parent omit it. The value
452
+ * is detached immutable data and requires `agentOptions` support.
453
+ */
454
+ readonly agentRouteDefaults?: Readonly<{ provider: string; model: string }>
440
455
  /**
441
456
  * Establish a ONE-SHOT child and return its handle after publication.
442
457
  * The service has already validated that every requested start-time
@@ -485,6 +500,22 @@ The spawn and fork backends create an ordinary one-shot agent through `parent.ct
485
500
 
486
501
  Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
487
502
 
503
+ <a id="ctxsubagentmodelselection--subagentmodelselectionconfig"></a>
504
+
505
+ ### `ctx.subagentModelSelection` — `SubagentModelSelectionConfig`
506
+
507
+ Singleton settings owner read by delegation tools when an Agent is published.
508
+
509
+ ```ts cordis-catalog
510
+ /**
511
+ * Read a detached selection preference for the next eligible Agent publication.
512
+ * @returns the enabled state and exact allowed routes.
513
+ */
514
+ current(): SubagentModelSelectionSettings
515
+ ```
516
+
517
+ Source: [`packages/subagent/tool-subagent/src/model-selection-settings.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/subagent/tool-subagent/src/model-selection-settings.ts)
518
+
488
519
  <a id="ctxsubagents--subagentruntime"></a>
489
520
 
490
521
  ### `ctx.subagents` — `SubagentRuntime`
@@ -586,27 +617,16 @@ async drainContinuableChildren(parent: Agent, childIds: readonly SessionId[]): P
586
617
 
587
618
  /**
588
619
  * Enumerate the parent's direct session-backed subagents without loading or
589
- * resuming an Agent and without any query service: the listing merges the live
590
- * session store with optional session persistence (live-preferred) and
591
- * serves each child's durable mode/label from the registered `subagent`
592
- * projection unit down a three-rung ladder — the registry's watermark
593
- * snapshot for a live child; for a cold one, a durable projection-cache
594
- * row when the optional cache serves an own-suffix identity (its `seq`
595
- * gate proves the value postdates the fork seed, where a child's own
596
- * descriptor is immutable once appended), else one persistence inspection
597
- * folded through the registry. The
598
- * projection fold is the single classification authority; per-child
599
- * diagnostics relay a fold that served no identity or a failed inspection,
600
- * never a list-time descriptor parse. Absent persistence, enumeration is
601
- * live-only (a cold child cannot be resumed then either, so its absence is
602
- * capability absence, not an error). This service consults no Agent
603
- * registrations, Activations, or providers.
620
+ * resuming an Agent. The Session query service supplies one live-preferred
621
+ * corpus and shared point observations; the projection cache supplies
622
+ * immutable descriptor hits without opening cold logs. The registered
623
+ * `subagent` projection remains the sole mode/label classifier.
604
624
  *
605
- * Every persistence read receives `signal`, and the listing rechecks
606
- * cancellation around each of those awaits. Read rejections that settle
625
+ * Every query receives `signal`, and the listing rechecks cancellation
626
+ * around each await. Read rejections that settle
607
627
  * after an abort become a stable `SubagentError` with code `CANCELLED`.
608
628
  * @param parentSessionId - parent session whose direct children are listed.
609
- * @param signal - caller-owned cancellation forwarded to persistence reads
629
+ * @param signal - caller-owned cancellation forwarded to Session queries
610
630
  * and observed around every read await.
611
631
  * @returns children and per-child diagnostics ordered by `createdAt`, then id.
612
632
  * @throws {@link SubagentError} when the projection registry or the session
@@ -631,6 +651,53 @@ listChildren(parentSessionId: SessionId, signal?: AbortSignal): Promise<Subagent
631
651
  */
632
652
  listDescendants(rootSessionId: SessionId, signal?: AbortSignal): Promise<SubagentDescendantListEntry[]>
633
653
 
654
+ /**
655
+ * Remote face of {@link listChildren} for one browser: the durable listing
656
+ * plus live Agent activity and the delivery-time parent availability hint.
657
+ * Parent availability is a hint; {@link prompt} performs the authoritative
658
+ * check. Named apart from the provider-name {@link list}, which owns the
659
+ * member.
660
+ * @param parentSessionId - parent session whose direct children are listed.
661
+ * @param signal - carrier cancellation forwarded to Session queries.
662
+ * @returns the catalog view for that parent.
663
+ * @throws {TypertRemoteFailure} `bad-request` for an empty parent id,
664
+ * `cancelled` for an aborted read, `subagent-projections-unavailable` when
665
+ * the deployment has no projection registry, otherwise `internal`.
666
+ */
667
+ @Remote('list') async remoteExportList(parentSessionId: SessionId, signal: AbortSignal): Promise<SubagentCatalog>
668
+
669
+ /**
670
+ * Deliver one browser-authored message to a continuable child through the
671
+ * exact live direct parent, retaining the caller-minted request identity and
672
+ * validated browser zone on the accepted message. Success identifies the
673
+ * message the child's FIFO inbox accepted; later execution is independent of
674
+ * this call.
675
+ * @param request - durable address, minted identity, content, and optional browser zone.
676
+ * @param signal - carrier cancellation, owning the call until inbox acceptance.
677
+ * @returns the accepted message's inbox identity.
678
+ * @throws {TypertRemoteFailure} `bad-request`, `invalid-time-zone`,
679
+ * `subagent-parent-unavailable`, `subagent-not-resumable`,
680
+ * `subagent-unauthorized`, `subagent-delivery-unavailable`, `cancelled`, or
681
+ * `internal`.
682
+ */
683
+ @Remote('prompt') async prompt(request: SubagentPromptRequest, signal: AbortSignal): Promise<SubagentPromptReceipt>
684
+
685
+ /**
686
+ * Remote face of {@link interrupt} under one durable parent address. No
687
+ * catalog, history, persistence, or parent Agent lookup runs: the core
688
+ * primitive alone authorizes the address against the live Activation, which
689
+ * is what keeps a live child interruptible while its parent Agent is offline.
690
+ * Absent, idle, and already-completed targets are accepted no-ops there.
691
+ * @param childSessionId - durable child session id to interrupt.
692
+ * @param parentSessionId - durable direct parent whose authority is claimed.
693
+ * @param mode - required continuable-address discriminator.
694
+ * @returns acknowledgement that the cancel signal was admitted, not that the target is quiescent.
695
+ * @throws {TypertRemoteFailure} `bad-request` for an empty id,
696
+ * `subagent-unauthorized` when the address does not own the live target,
697
+ * otherwise `internal`.
698
+ */
699
+ @Remote('interruptByParent') interruptByParent( childSessionId: SessionId, parentSessionId: SessionId, mode: 'continuable', ): SubagentInterruptReceipt
700
+
634
701
  /**
635
702
  * Register a provider under its name. Registration is effect-scoped and HMR
636
703
  * safe; removing a provider blocks new starts but does not revoke runs that
@@ -42,7 +42,7 @@ interface ToolProviderResult {
42
42
 
43
43
  ## Prompt sections
44
44
 
45
- `PromptSection` is a readonly same-process registration contract. Its text may be static or resolved from the current assembly context. One effective `complete` section becomes the sole prompt section after cooperative assembly.
45
+ `PromptSection` is a readonly same-process registration contract. Its text may be static or resolved from the current assembly context. Sections sort by ascending order and then code-unit name; `FIRST_PARTY_SECTION_ORDER` publishes the sparse named allocation for repository-owned contributions. One effective `complete` section becomes the sole prompt section after cooperative assembly.
46
46
 
47
47
  ```ts type-equiv
48
48
  /** One contributed section of the system prompt (registry input). */
@@ -50,9 +50,9 @@ interface PromptSection {
50
50
  /** Unique name — a duplicate registration throws (see {@link SystemPrompt.section}). */
51
51
  readonly name: string
52
52
  /**
53
- * Sections are concatenated in ascending order. Convention: `-100` is the
54
- * harness identity, `0` the deployment persona, tool guidance uses 100–199;
55
- * other negative orders also render before the persona.
53
+ * Sections are concatenated in ascending order. Equal orders use code-unit
54
+ * name order. Repository-owned placements use
55
+ * {@link FIRST_PARTY_SECTION_ORDER}.
56
56
  */
57
57
  readonly order: number
58
58
  /**
@@ -22,14 +22,14 @@ interface TokenMeasurement {
22
22
  readonly surfaceDeltaTokens: number
23
23
  /** Non-negative current request-and-response pressure. */
24
24
  readonly totalTokens: number
25
- /** Total heuristic tokens across the current surface. */
25
+ /** Total route-priced request tokens across the current surface; equals the sum of the node prices. */
26
26
  readonly surfaceTokens: number
27
27
  /** Current surface nodes in positional head-to-tail order. */
28
28
  readonly nodes: readonly TokenSurfaceNode[]
29
29
  }
30
30
  ```
31
31
 
32
- `baseline.kind === 'usage'` means the latest successful provider call has the same canonical request envelope and its total is no lower than that call's full heuristic anchor. `estimated` means no reusable conservative usage anchor exists, so the service priced the complete envelope and surface with its fixed heuristic. A later successful request replaces the earlier anchor; signed `surfaceDeltaTokens` preserves growth and shrinkage relative to a matching anchor. `totalTokens` remains request-and-response pressure, while `surfaceTokens` is the surface-only heuristic total and equals the sum of the node prices.
32
+ Every measurement resolves the effective envelope's routed provider/model to that route's declared request-image pricing through `ctx.llm`, so image occurrences are priced as the visual tokens plus model-visible text the request actually sends; routes and compositions without declared pricing keep the fixed heuristic. `baseline.kind === 'usage'` means the latest successful provider call has the same canonical request envelope and its total is no lower than that call's full route-priced anchor. `estimated` means no reusable conservative usage anchor exists, so the service priced the complete envelope and surface itself. A later successful request replaces the earlier anchor; signed `surfaceDeltaTokens` preserves growth and shrinkage relative to a matching anchor, repricing both sides under the same route. `totalTokens` remains request-and-response pressure, while `surfaceTokens` is the surface-only route-priced total and equals the sum of the node prices.
33
33
 
34
34
  ## `TokenSurfaceNode`
35
35
 
@@ -38,8 +38,19 @@ interface TokenMeasurement {
38
38
  interface TokenSurfaceNode {
39
39
  /** Durable sequence number of the surface event. */
40
40
  readonly seq: number
41
- /** Heuristic tokens for the exact message projected by this node. */
41
+ /**
42
+ * Request-pressure tokens for the exact message projected by this node under
43
+ * the measured route: image occurrences carry the route's declared visual
44
+ * price when the routed adapter declares one, and the fixed heuristic
45
+ * otherwise. Trigger, retention, and range selection all read this price.
46
+ */
42
47
  readonly tokens: number
48
+ /**
49
+ * Fixed-heuristic tokens for the same message, independent of any route.
50
+ * The shadow-price protocol prices replacements with this value so the O(1)
51
+ * projection fold stays in agreement with its own appends.
52
+ */
53
+ readonly heuristicTokens: number
43
54
  }
44
55
  ```
45
56
 
@@ -63,14 +74,18 @@ Replay owner for one service-wide estimator and isolated per-session folds.
63
74
  /**
64
75
  * Measure current request pressure and surface through the durable tail.
65
76
  *
66
- * Provider usage is reused only when the latest successful call's canonical
67
- * request envelope matches `requestHeader` and its total is no lower than
68
- * that call's full heuristic anchor; otherwise the complete envelope and
69
- * surface are heuristically repriced.
77
+ * The effective envelope's routed provider/model selects the request-image
78
+ * pricing every node is priced under: a route whose adapter declares image
79
+ * pricing charges each retained image its visual tokens plus its
80
+ * model-visible text, while other routes keep the fixed heuristic. Provider
81
+ * usage is reused only when the latest successful call's canonical request
82
+ * envelope matches `requestHeader` and its total is no lower than that
83
+ * call's full route-priced anchor; otherwise the complete envelope and
84
+ * surface are repriced.
70
85
  *
71
- * `requestHeader` affects request pressure only; surface fields always
72
- * describe the current session surface. Every call clones those positional
73
- * nodes, so measurement is O(surface).
86
+ * `requestHeader` replaces the latest logged envelope for pressure and node
87
+ * pricing; the node set always describes the current session surface. Every
88
+ * call clones those positional nodes, so measurement is O(surface).
74
89
  *
75
90
  * @param session - session to replay through its current durable tail.
76
91
  * @param requestHeader - optional effective request envelope replacing the latest logged header.