@dsmm/dsmm 0.3.0 → 0.3.2

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 (245) hide show
  1. package/README.md +26 -40
  2. package/cordis.patch.yml +9 -13
  3. package/docs/agent-presets.md +26 -14
  4. package/docs/compatibility.md +24 -68
  5. package/docs/deferred-native-approval-risk.md +8 -12
  6. package/docs/design.md +25 -254
  7. package/docs/lsp.md +2 -2
  8. package/docs/migration-from-ocmm.md +38 -51
  9. package/docs/model-routing.md +21 -21
  10. package/docs/native-permissions.md +17 -7
  11. package/docs/profiles.md +13 -9
  12. package/docs/releasing.md +25 -311
  13. package/docs/roadmap.md +52 -241
  14. package/docs/runtime-recovery.md +29 -91
  15. package/docs/safety-guards.md +19 -16
  16. package/docs/settings-status.md +23 -11
  17. package/docs/skill-sync.md +17 -17
  18. package/docs/web-fetch-fakeip.md +82 -0
  19. package/lib/child-capture.d.ts +12 -2
  20. package/lib/child-capture.js +22 -5
  21. package/lib/client/ChildPermissions.d.ts +43 -0
  22. package/lib/client/ChildPermissions.js +100 -0
  23. package/lib/client/ChildrenPanel.d.ts +5 -5
  24. package/lib/client/ChildrenPanel.js +6 -18
  25. package/lib/client/DeploymentFields.d.ts +32 -0
  26. package/lib/client/DeploymentFields.js +70 -0
  27. package/lib/client/DeploymentPage.d.ts +21 -6
  28. package/lib/client/DeploymentPage.js +80 -112
  29. package/lib/client/HistoryContinuation.d.ts +7 -0
  30. package/lib/client/HistoryContinuation.js +22 -0
  31. package/lib/client/NativeCommandEntries.d.ts +17 -0
  32. package/lib/client/NativeCommandEntries.js +68 -0
  33. package/lib/client/PermissionPanelEntry.d.ts +8 -0
  34. package/lib/client/PermissionPanelEntry.js +11 -0
  35. package/lib/client/PermissionsPanel.d.ts +3 -1
  36. package/lib/client/PermissionsPanel.js +10 -9
  37. package/lib/client/ProfilesSection.js +8 -6
  38. package/lib/client/RoleAvailability.js +1 -1
  39. package/lib/client/RoleToolView-data.d.ts +35 -0
  40. package/lib/client/RoleToolView-data.js +52 -0
  41. package/lib/client/RoleToolView-locales.d.ts +36 -0
  42. package/lib/client/RoleToolView-locales.js +20 -0
  43. package/lib/client/RoleToolView.d.ts +10 -0
  44. package/lib/client/RoleToolView.js +47 -0
  45. package/lib/client/SessionProfiles.js +51 -24
  46. package/lib/client/TemporaryPermissions.d.ts +21 -0
  47. package/lib/client/TemporaryPermissions.js +94 -0
  48. package/lib/client/children-controller.d.ts +2 -8
  49. package/lib/client/children-controller.js +1 -26
  50. package/lib/client/children-locales.d.ts +27 -52
  51. package/lib/client/children-locales.js +8 -12
  52. package/lib/client/configuration-display.d.ts +5 -0
  53. package/lib/client/configuration-display.js +11 -0
  54. package/lib/client/controller.d.ts +18 -0
  55. package/lib/client/controller.js +118 -28
  56. package/lib/client/deployment-controller.d.ts +13 -1
  57. package/lib/client/deployment-controller.js +84 -24
  58. package/lib/client/deployment-data.d.ts +1 -0
  59. package/lib/client/deployment-data.js +4 -1
  60. package/lib/client/deployment-locales.d.ts +43 -0
  61. package/lib/client/deployment-locales.js +45 -19
  62. package/lib/client/deployment-modules.d.ts +9 -0
  63. package/lib/client/deployment-modules.js +24 -0
  64. package/lib/client/deployment-workspace.d.ts +48 -0
  65. package/lib/client/deployment-workspace.js +123 -0
  66. package/lib/client/history-controller.d.ts +29 -0
  67. package/lib/client/history-controller.js +111 -0
  68. package/lib/client/history-entry.d.ts +11 -0
  69. package/lib/client/history-entry.js +106 -0
  70. package/lib/client/history-locales.d.ts +95 -0
  71. package/lib/client/history-locales.js +41 -0
  72. package/lib/client/index.js +26 -76
  73. package/lib/client/locales.d.ts +13 -0
  74. package/lib/client/locales.js +104 -86
  75. package/lib/client/permission-controller.d.ts +1 -0
  76. package/lib/client/permission-controller.js +3 -2
  77. package/lib/client/permission-locales.d.ts +51 -0
  78. package/lib/client/permission-locales.js +59 -19
  79. package/lib/client/session-labels.js +4 -3
  80. package/lib/client/styles.d.ts +1 -1
  81. package/lib/client/styles.js +9 -8
  82. package/lib/client/temporary-permission-client.d.ts +20 -0
  83. package/lib/client/temporary-permission-client.js +52 -0
  84. package/lib/client/temporary-permission-entry.d.ts +6 -0
  85. package/lib/client/temporary-permission-entry.js +56 -0
  86. package/lib/client.js +5691 -3439
  87. package/lib/commands.js +2 -0
  88. package/lib/config-file-store.d.ts +3 -0
  89. package/lib/config-file-store.js +4 -2
  90. package/lib/config-revision.d.ts +5 -0
  91. package/lib/config-revision.js +11 -0
  92. package/lib/core-permission-authority.js +11 -41
  93. package/lib/deployment-config.d.ts +9 -2
  94. package/lib/deployment-config.js +35 -8
  95. package/lib/deployment-permission-rules.js +19 -7
  96. package/lib/dsh-types.d.ts +1 -1
  97. package/lib/history-candidates.d.ts +30 -0
  98. package/lib/history-candidates.js +176 -0
  99. package/lib/history-codec.d.ts +11 -0
  100. package/lib/history-codec.js +102 -0
  101. package/lib/history-contract.d.ts +44 -0
  102. package/lib/history-contract.js +2 -0
  103. package/lib/history-controller.d.ts +42 -0
  104. package/lib/history-controller.js +329 -0
  105. package/lib/history-policy.d.ts +4 -0
  106. package/lib/history-policy.js +8 -0
  107. package/lib/history-remote.d.ts +28 -0
  108. package/lib/history-remote.js +17 -0
  109. package/lib/history-rpc.d.ts +24 -0
  110. package/lib/history-rpc.js +136 -0
  111. package/lib/history-support.d.ts +15 -0
  112. package/lib/history-support.js +21 -0
  113. package/lib/history-types.d.ts +67 -0
  114. package/lib/history-types.js +2 -0
  115. package/lib/host-llm-startup.js +3 -3
  116. package/lib/host-llm.d.ts +9 -3
  117. package/lib/host-llm.js +48 -8
  118. package/lib/index.d.ts +18 -20
  119. package/lib/index.js +147 -415
  120. package/lib/lifetime.d.ts +4 -0
  121. package/lib/lifetime.js +22 -0
  122. package/lib/live-pi-ai-owner.d.ts +1 -0
  123. package/lib/live-pi-ai-owner.js +8 -4
  124. package/lib/mode.d.ts +3 -2
  125. package/lib/mode.js +28 -41
  126. package/lib/model-routing.d.ts +2 -8
  127. package/lib/model-routing.js +59 -175
  128. package/lib/native-admission.d.ts +77 -0
  129. package/lib/native-admission.js +503 -0
  130. package/lib/native-pi-ai-wire.d.ts +3 -1
  131. package/lib/native-pi-ai-wire.js +47 -13
  132. package/lib/permission-child-control.d.ts +36 -0
  133. package/lib/permission-child-control.js +164 -0
  134. package/lib/permission-control.d.ts +2 -3
  135. package/lib/permission-control.js +7 -0
  136. package/lib/permission-controller.js +2 -2
  137. package/lib/permission-exec-argv.d.ts +32 -0
  138. package/lib/permission-exec-argv.js +171 -0
  139. package/lib/permission-fs-search.js +2 -1
  140. package/lib/permission-fs.js +2 -1
  141. package/lib/permission-native-rules.js +3 -3
  142. package/lib/permission-temporary-files.d.ts +19 -0
  143. package/lib/permission-temporary-files.js +248 -0
  144. package/lib/permission-temporary-grants.d.ts +106 -0
  145. package/lib/permission-temporary-grants.js +198 -0
  146. package/lib/permission-temporary-install.d.ts +25 -0
  147. package/lib/permission-temporary-install.js +86 -0
  148. package/lib/permission-temporary-remote.d.ts +19 -0
  149. package/lib/permission-temporary-remote.js +75 -0
  150. package/lib/permission-temporary-rpc.d.ts +37 -0
  151. package/lib/permission-temporary-rpc.js +154 -0
  152. package/lib/permission-temporary-types.d.ts +47 -0
  153. package/lib/permission-temporary-types.js +2 -0
  154. package/lib/permission-temporary-web.d.ts +11 -0
  155. package/lib/permission-temporary-web.js +154 -0
  156. package/lib/permission-web.js +2 -1
  157. package/lib/preset-registry.js +3 -2
  158. package/lib/preset-skills.d.ts +3 -12
  159. package/lib/preset-skills.js +28 -58
  160. package/lib/profile-diagnostics.d.ts +1 -1
  161. package/lib/profile-diagnostics.js +2 -2
  162. package/lib/profile-remote.js +61 -22
  163. package/lib/profile-rpc.d.ts +4 -3
  164. package/lib/profile-rpc.js +35 -37
  165. package/lib/profile-runtime.d.ts +42 -74
  166. package/lib/profile-runtime.js +314 -617
  167. package/lib/profile-store.d.ts +20 -8
  168. package/lib/profile-store.js +112 -63
  169. package/lib/profile-types.d.ts +19 -4
  170. package/lib/profiles.d.ts +3 -1
  171. package/lib/profiles.js +9 -7
  172. package/lib/prompt-content.d.ts +1 -0
  173. package/lib/prompt-content.js +4 -1
  174. package/lib/prompts.d.ts +2 -12
  175. package/lib/prompts.js +11 -66
  176. package/lib/role-control-remote.d.ts +1 -4
  177. package/lib/role-control-remote.js +8 -36
  178. package/lib/role-control-rpc.d.ts +10 -36
  179. package/lib/role-control-rpc.js +112 -269
  180. package/lib/role-control-types.d.ts +3 -26
  181. package/lib/role-control-types.js +3 -4
  182. package/lib/role-identity.d.ts +5 -0
  183. package/lib/role-identity.js +10 -0
  184. package/lib/role-invocation.d.ts +3 -3
  185. package/lib/role-invocation.js +2 -2
  186. package/lib/role-llm-runtime.js +5 -11
  187. package/lib/role-policy.d.ts +19 -50
  188. package/lib/role-policy.js +136 -508
  189. package/lib/role-providers.d.ts +5 -8
  190. package/lib/role-providers.js +20 -86
  191. package/lib/role-routing.d.ts +1 -3
  192. package/lib/role-routing.js +24 -34
  193. package/lib/role-subagents.d.ts +5 -14
  194. package/lib/role-subagents.js +163 -108
  195. package/lib/runtime-integration.d.ts +5 -78
  196. package/lib/runtime-integration.js +11 -697
  197. package/lib/session-metadata.d.ts +13 -12
  198. package/lib/session-metadata.js +6 -31
  199. package/lib/session-scope.js +2 -1
  200. package/lib/settings.d.ts +5 -18
  201. package/lib/settings.js +19 -43
  202. package/lib/skills.d.ts +1 -0
  203. package/lib/skills.js +5 -1
  204. package/lib/state.d.ts +3 -2
  205. package/lib/state.js +26 -10
  206. package/lib/status.d.ts +1 -9
  207. package/lib/status.js +3 -55
  208. package/lib/web-fetch-address-policy.d.ts +24 -0
  209. package/lib/web-fetch-address-policy.js +189 -0
  210. package/lib/web-fetch-fakeip.d.ts +25 -0
  211. package/lib/web-fetch-fakeip.js +107 -0
  212. package/package.json +124 -106
  213. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +13291 -0
  214. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +9133 -0
  215. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +156 -0
  216. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +3546 -0
  217. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +431 -0
  218. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +119 -0
  219. package/patches/dsh-approval-settlement/README.md +41 -0
  220. package/patches/dsh-approval-settlement/metadata.json +10 -0
  221. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +383 -0
  222. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +55 -0
  223. package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +16673 -0
  224. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +29 -0
  225. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +196 -0
  226. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +35 -0
  227. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +40 -0
  228. package/docs/research/deepseek-v4-pro.md +0 -74
  229. package/docs/research/oh-dsh.md +0 -96
  230. package/lib/agent-registry.d.ts +0 -36
  231. package/lib/agent-registry.js +0 -75
  232. package/lib/child-admission.d.ts +0 -40
  233. package/lib/child-admission.js +0 -151
  234. package/lib/delivery-authority.d.ts +0 -83
  235. package/lib/delivery-authority.js +0 -397
  236. package/lib/native-child-evidence.d.ts +0 -40
  237. package/lib/native-child-evidence.js +0 -104
  238. package/lib/role-runs.d.ts +0 -138
  239. package/lib/role-runs.js +0 -335
  240. package/lib/session-persistence.d.ts +0 -36
  241. package/lib/session-persistence.js +0 -304
  242. package/lib/subagent-runtime.d.ts +0 -57
  243. package/lib/subagent-runtime.js +0 -257
  244. package/prompts/deepseek-flash.md +0 -11
  245. package/prompts/deepseek-v4-pro.md +0 -14
@@ -1,304 +0,0 @@
1
- import { Context, Service } from "@deepseek-ai/cordis";
2
- import { SessionHandleClosedError, SessionPersistence, SessionReadOnlyError, materializeAppendBatch } from "@deepseek-ai/dsh-session-persistence";
3
- import * as JsonlSessionPersistence from "@deepseek-ai/dsh-session-persistence-jsonl";
4
- import { isDeepStrictEqual } from "node:util";
5
- import { annotateDsmmEvent, DSMM_PERSISTENCE_COMPATIBILITY } from "./session-metadata.js";
6
- export { DSMM_PERSISTENCE_COMPATIBILITY } from "./session-metadata.js";
7
- /** Host-owned live routing; the native handle remains the sole storage/lock owner. */
8
- class DsmmSessionHandle {
9
- native;
10
- cursor;
11
- warn;
12
- released;
13
- chain = Promise.resolve();
14
- closing;
15
- buffered = [];
16
- timer;
17
- paused = false;
18
- failure;
19
- routingFailure;
20
- constructor(native, cursor, warn, released) {
21
- this.native = native;
22
- this.cursor = cursor;
23
- this.warn = warn;
24
- this.released = released;
25
- }
26
- get id() { return this.native.id; }
27
- get header() { return this.native.header; }
28
- get access() { return this.native.access; }
29
- get inheritedEventCount() { return this.native.inheritedEventCount; }
30
- async read(offset, length, options) {
31
- this.assertOpen("read");
32
- return this.native.read(offset, length, options);
33
- }
34
- async append(events, options) {
35
- this.assertOpen("append");
36
- options?.signal?.throwIfAborted();
37
- const batch = materializeAppendBatch(events).map(annotateDsmmEvent);
38
- await this.enqueue(async () => {
39
- options?.signal?.throwIfAborted();
40
- if (this.access !== "write")
41
- throw new SessionReadOnlyError(this.id, "append");
42
- if (this.paused)
43
- throw this.failure;
44
- // Live records preceding this explicit batch must commit first. Later live
45
- // records cannot overtake a direct append waiting on the mutation chain.
46
- await this.drain(batch[0]?.seq ?? Number.POSITIVE_INFINITY, options?.signal);
47
- await this.native.append(batch, options);
48
- this.cursor += batch.length;
49
- this.scheduleDrain();
50
- });
51
- }
52
- async flush(options) {
53
- this.assertOpen("flush");
54
- await this.enqueue(async () => {
55
- options?.signal?.throwIfAborted();
56
- if (this.access !== "write")
57
- throw new SessionReadOnlyError(this.id, "flush");
58
- this.paused = false;
59
- await this.drain(Number.POSITIVE_INFINITY, options?.signal);
60
- await this.native.flush(options);
61
- });
62
- }
63
- enqueueLive(event) {
64
- if (this.closing !== undefined)
65
- return;
66
- let owned;
67
- try {
68
- owned = annotateDsmmEvent(materializeAppendBatch([event])[0]);
69
- }
70
- catch (error) {
71
- this.routingFailure ??= error;
72
- this.cancelTimer();
73
- this.warn(this.id, error);
74
- return;
75
- }
76
- this.buffered.push(owned);
77
- this.scheduleDrain();
78
- }
79
- scheduleDrain() {
80
- if (this.buffered.length === 0 || this.timer !== undefined || this.paused
81
- || this.routingFailure !== undefined || this.closing !== undefined)
82
- return;
83
- this.timer = setTimeout(() => {
84
- this.timer = undefined;
85
- const last = this.buffered.at(-1);
86
- if (last === undefined)
87
- return;
88
- // Fence this queued operation to the prefix accepted now. Events published
89
- // after a later direct append is queued belong behind that append.
90
- const beforeSeq = last.seq + 1;
91
- void this.enqueue(async () => {
92
- if (!this.paused) {
93
- await this.drain(beforeSeq);
94
- this.scheduleDrain();
95
- }
96
- }).catch((error) => this.warn(this.id, error));
97
- }, 200);
98
- }
99
- close() {
100
- return this.closing ??= this.enqueue(async () => {
101
- this.cancelTimer();
102
- const errors = [];
103
- try {
104
- this.paused = false;
105
- await this.drain();
106
- if (this.access === "write")
107
- await this.native.flush();
108
- }
109
- catch (error) {
110
- errors.push(error);
111
- }
112
- try {
113
- await this.native.close();
114
- }
115
- catch (error) {
116
- errors.push(error);
117
- }
118
- const failure = errors.length > 1 ? new AggregateError(errors, `session "${this.id}": close failed`)
119
- : errors[0];
120
- this.released(this, failure);
121
- if (errors.length > 0)
122
- throw failure;
123
- });
124
- }
125
- [Symbol.asyncDispose]() { return this.close(); }
126
- enqueue(operation) {
127
- const next = this.chain.then(operation);
128
- // The caller observes rejection; this recovery only keeps later barriers usable.
129
- this.chain = next.then(() => undefined, () => undefined);
130
- return next;
131
- }
132
- async drain(beforeSeq = Number.POSITIVE_INFINITY, signal) {
133
- this.cancelTimer();
134
- if (this.routingFailure !== undefined)
135
- throw this.routingFailure;
136
- while (this.buffered.length > 0 && this.buffered[0].seq < beforeSeq) {
137
- signal?.throwIfAborted();
138
- const count = this.buffered.findIndex((event) => event.seq >= beforeSeq);
139
- const batch = this.buffered.slice(0, count < 0 ? undefined : count);
140
- try {
141
- // An explicitly appended event may subsequently be published by the live
142
- // store. Coalesce only byte-equivalent logical events, never conflicts.
143
- let duplicateCount = 0;
144
- while (duplicateCount < batch.length && batch[duplicateCount].seq < this.cursor)
145
- duplicateCount++;
146
- if (duplicateCount > 0) {
147
- const existing = await this.native.read(batch[0].seq, duplicateCount, { signal });
148
- if (!isDeepStrictEqual(existing.events, batch.slice(0, duplicateCount))) {
149
- throw new Error(`session "${this.id}": live event conflicts with the persisted prefix`);
150
- }
151
- }
152
- const fresh = batch.slice(duplicateCount);
153
- await this.native.append(fresh, { signal });
154
- this.cursor += fresh.length;
155
- this.buffered.splice(0, batch.length);
156
- this.failure = undefined;
157
- }
158
- catch (error) {
159
- this.cancelTimer();
160
- this.paused = true;
161
- this.failure = error;
162
- throw error;
163
- }
164
- }
165
- }
166
- cancelTimer() {
167
- if (this.timer !== undefined)
168
- clearTimeout(this.timer);
169
- this.timer = undefined;
170
- }
171
- assertOpen(operation) {
172
- if (this.closing !== undefined)
173
- throw new SessionHandleClosedError(this.id, operation);
174
- }
175
- }
176
- /**
177
- * Drop-in native JSONL persistence companion for audited DSMM metadata.
178
- * A separate root Context is intentional: a child service-isolation scope still
179
- * shares the host event bus and would persist every live event twice.
180
- */
181
- export default class DsmmSessionPersistence extends SessionPersistence {
182
- config;
183
- static Config = JsonlSessionPersistence.Config;
184
- name = "dsmm-session-persistence";
185
- inner = new Context();
186
- ready;
187
- handles = new Set();
188
- writers = new Map();
189
- acquisitions = new Set();
190
- closeFailures = new Map();
191
- disposed = false;
192
- constructor(ctx, config) {
193
- super(ctx);
194
- this.config = config;
195
- Object.defineProperty(this, DSMM_PERSISTENCE_COMPATIBILITY, {
196
- value: true, writable: false, configurable: false, enumerable: false
197
- });
198
- const nativeFiber = this.inner.plugin(JsonlSessionPersistence, config);
199
- this.ready = nativeFiber.await().then(() => this.inner.sessionPersistence);
200
- ctx.on("session/event", (session, event) => this.writers.get(session.id)?.enqueueLive(event));
201
- ctx.on("session/flush", (session) => this.writers.get(session.id)?.flush());
202
- ctx.on("session/disposed", (session) => {
203
- const writer = this.writers.get(session.id);
204
- if (writer !== undefined)
205
- void writer.close().catch((error) => this.warn(session.id, error));
206
- });
207
- // One outer disposer enforces the ownership boundary: drain/close every
208
- // adapter handle before disposing the still-live native storage Context.
209
- ctx.effect(() => async () => {
210
- this.disposed = true;
211
- await Promise.allSettled([...this.acquisitions]);
212
- const errors = [...this.closeFailures.values()];
213
- for (const handle of [...this.handles]) {
214
- try {
215
- await handle.close();
216
- }
217
- catch (error) {
218
- errors.push(error);
219
- }
220
- }
221
- try {
222
- await this.inner.fiber.dispose();
223
- }
224
- catch (error) {
225
- errors.push(error);
226
- }
227
- if (errors.length > 0)
228
- throw new AggregateError(errors, `${this.name} dispose failed`);
229
- }, "dsmm-session-persistence ordered shutdown");
230
- }
231
- async [Service.init]() { await this.ready; }
232
- create(header, options) {
233
- return this.acquire(async (native) => native.create(header, options), false);
234
- }
235
- open(id, access, options) {
236
- return this.acquire(async (native) => native.open(id, access, options), access === "write");
237
- }
238
- async flush() {
239
- this.assertActive();
240
- const errors = [];
241
- for (const handle of [...this.writers.values()]) {
242
- try {
243
- await handle.flush();
244
- }
245
- catch (error) {
246
- if (!(error instanceof SessionHandleClosedError))
247
- errors.push(error);
248
- }
249
- }
250
- if (errors.length > 0)
251
- throw new AggregateError(errors, `${this.name} flush failed`);
252
- }
253
- async stat(id, options) {
254
- this.assertActive();
255
- return (await this.ready).stat(id, options);
256
- }
257
- async list(options) {
258
- this.assertActive();
259
- return (await this.ready).list(options);
260
- }
261
- acquire(factory, existing) {
262
- this.assertActive();
263
- const operation = (async () => {
264
- const native = await factory(await this.ready);
265
- let cursor = 0;
266
- try {
267
- if (existing)
268
- cursor = (await native.read()).events.length;
269
- }
270
- catch (error) {
271
- try {
272
- await native.close();
273
- }
274
- catch (closeError) {
275
- throw new AggregateError([error, closeError], `session "${native.id}": open failed`);
276
- }
277
- throw error;
278
- }
279
- const handle = new DsmmSessionHandle(native, cursor, (id, error) => this.warn(id, error), (closed, error) => {
280
- this.handles.delete(closed);
281
- if (this.writers.get(closed.id) === closed)
282
- this.writers.delete(closed.id);
283
- if (error !== undefined)
284
- this.closeFailures.set(closed.id, error);
285
- });
286
- this.handles.add(handle);
287
- if (handle.access === "write")
288
- this.writers.set(handle.id, handle);
289
- return handle;
290
- })();
291
- this.acquisitions.add(operation);
292
- void operation.then(() => this.acquisitions.delete(operation), () => this.acquisitions.delete(operation));
293
- return operation;
294
- }
295
- warn(id, error) {
296
- const errorClass = error instanceof Error && /^[A-Za-z][A-Za-z0-9]*Error$/u.test(error.name) ? error.name : "Error";
297
- this.ctx.logger.warn("Deepwork session persistence failed", { sessionId: id, errorClass });
298
- }
299
- assertActive() {
300
- if (this.disposed)
301
- throw new Error("Deepwork session persistence is disposed");
302
- }
303
- }
304
- //# sourceMappingURL=session-persistence.js.map
@@ -1,57 +0,0 @@
1
- import type { Context } from "@deepseek-ai/cordis";
2
- import type { Agent } from "@deepseek-ai/dsh-agent";
3
- import type { ContentBlock, MessageId } from "@deepseek-ai/dsh-llm";
4
- import { SessionId } from "@deepseek-ai/dsh-session";
5
- import { SubagentRuntime } from "@deepseek-ai/dsh-subagent";
6
- import type { SubagentActivation, SubagentActivationSpec, SubagentPromptReceipt, SubagentPromptRequest, SubagentProvider, SubagentSendMessageOptions } from "@deepseek-ai/dsh-subagent";
7
- import { DsmmDeliveryAuthority } from "./delivery-authority.js";
8
- import type { DeliveryAdmission, DeliveryParentClassifier } from "./delivery-authority.js";
9
- export { DsmmDeliveryAuthority } from "./delivery-authority.js";
10
- export type { DeliveryAdmission, DeliveryFenceView, DeliveryParentClassifier, DeliveryPolicyBinding, ParentAdmissionTicket } from "./delivery-authority.js";
11
- declare module "@deepseek-ai/dsh-typert-protocol/types" {
12
- interface RemoteErrorDetailsMap {
13
- "subagent/unauthorized": {
14
- readonly childSessionId: SessionId;
15
- };
16
- }
17
- }
18
- type ActivationStart = (spec: SubagentActivationSpec) => Promise<SubagentActivation>;
19
- type ActivationPreflight = (spec: SubagentActivationSpec, start: ActivationStart) => Promise<SubagentActivation>;
20
- /** Explicit startup replacement for the stock row, in the SAME Host service scope. */
21
- export declare class DsmmSubagentRuntime<A extends DeliveryAdmission = DeliveryAdmission, E = unknown> extends SubagentRuntime {
22
- static inject: string[];
23
- readonly authority: DsmmDeliveryAuthority<A, E>;
24
- private readonly waiters;
25
- private readonly lifetime;
26
- private requiredProviders;
27
- private activationPreflight?;
28
- constructor(ctx: Context, config: ConstructorParameters<typeof SubagentRuntime>[1], hostClassifier?: DeliveryParentClassifier);
29
- /** Host composition may select spawn/fork names before enabling the policy. */
30
- requireProviders(names: readonly string[]): void;
31
- registerProvider(provider: SubagentProvider): () => void;
32
- /** Host entry route preparation before native normalization loses caller option provenance. */
33
- configureActivationPreflight(preflight: ActivationPreflight, signal: AbortSignal): void;
34
- startActivation(spec: SubagentActivationSpec & {
35
- readonly childId: SessionId;
36
- }): Promise<SubagentActivation & {
37
- readonly messageId: MessageId;
38
- }>;
39
- startActivation(spec: SubagentActivationSpec): Promise<SubagentActivation>;
40
- private startManaged;
41
- private operation;
42
- private coldDelivery;
43
- private retireTree;
44
- drainDescendants(parents: readonly Agent[]): Promise<void>;
45
- drainChildren(parent: Agent, childIds: readonly SessionId[]): Promise<void>;
46
- /** Fulfillment proves this exact registry contains the provider, not just a mounted plugin. */
47
- waitForProvider(name: string, signal?: AbortSignal): Promise<SubagentProvider>;
48
- /** Policy explicitly enabled AND every required provider actually registered. */
49
- waitUntilReady(signal?: AbortSignal): Promise<void>;
50
- sendMessage(sender: Agent, targetId: SessionId, content: ContentBlock[], options: SubagentSendMessageOptions): Promise<MessageId>;
51
- prompt(request: SubagentPromptRequest, callerSignal: AbortSignal): Promise<SubagentPromptReceipt>;
52
- private wakeWaiters;
53
- private substrateReady;
54
- private waitFor;
55
- }
56
- export default DsmmSubagentRuntime;
57
- //# sourceMappingURL=subagent-runtime.d.ts.map
@@ -1,257 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { SessionId } from "@deepseek-ai/dsh-session";
3
- import { SubagentError, SubagentRuntime } from "@deepseek-ai/dsh-subagent";
4
- import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
5
- import { TYPERT as NATIVE_SUBAGENT_HOST } from "@deepseek-ai/dsh-subagent/typert";
6
- import { DsmmDeliveryAuthority, scopeLifetime } from "./delivery-authority.js";
7
- import { activationOwnerSignal, DsmmAgentRegistry, duringManagedCreation, exactRegistry, managedCancellation } from "./agent-registry.js";
8
- export { DsmmDeliveryAuthority } from "./delivery-authority.js";
9
- /** Explicit startup replacement for the stock row, in the SAME Host service scope. */
10
- export class DsmmSubagentRuntime extends SubagentRuntime {
11
- static inject = ["agents", ...SubagentRuntime.inject];
12
- authority;
13
- waiters = new Set();
14
- lifetime = new AbortController();
15
- requiredProviders = ["spawn"];
16
- activationPreflight;
17
- constructor(ctx, config, hostClassifier) {
18
- if (ctx.get("subagents") !== undefined) {
19
- throw new SubagentError("Explicit DSMM startup composition must exclude the stock subagents row; restart with one provider.", "DUPLICATE_PROVIDER");
20
- }
21
- super(ctx, config);
22
- this.authority = new DsmmDeliveryAuthority(ctx, () => this.substrateReady(), () => this.wakeWaiters(), hostClassifier);
23
- const agents = exactRegistry(ctx.agents);
24
- if (!(agents instanceof DsmmAgentRegistry))
25
- throw new SubagentError("Managed activations require the DSMM startup agents provider", "UNSUPPORTED_CAPABILITY");
26
- const retire = () => { this.lifetime.abort(); for (const agent of agents.list())
27
- this.authority.revokeParent(agent, "agents-provider-ended"); this.wakeWaiters(); };
28
- agents.managedLifetime.signal.addEventListener("abort", retire, { once: true });
29
- if (agents.managedLifetime.signal.aborted)
30
- retire();
31
- ctx.inject(["typert"], (remoteCtx) => {
32
- if (remoteCtx.typert.getPackage("@deepseek-ai/dsh-subagent", "host") === undefined) {
33
- remoteCtx.typert.register(NATIVE_SUBAGENT_HOST);
34
- }
35
- this.wakeWaiters();
36
- });
37
- ctx.on("subagent/provider-added", () => this.wakeWaiters());
38
- ctx.on("subagent/provider-removed", () => this.wakeWaiters());
39
- scopeLifetime(ctx, "dsmm.subagents: close registration barriers", () => { this.lifetime.abort(); this.wakeWaiters(); });
40
- }
41
- /** Host composition may select spawn/fork names before enabling the policy. */
42
- requireProviders(names) {
43
- if (this.authority.view().deliveryFenceReady || names.length === 0 || names.some((name) => name.length === 0)) {
44
- throw new SubagentError("Provider readiness must be configured before DSMM admission becomes ready.", "UNAUTHORIZED");
45
- }
46
- this.requiredProviders = [...new Set(names)];
47
- this.wakeWaiters();
48
- }
49
- registerProvider(provider) {
50
- const dispose = super.registerProvider(provider);
51
- this.wakeWaiters();
52
- return dispose;
53
- }
54
- /** Host entry route preparation before native normalization loses caller option provenance. */
55
- configureActivationPreflight(preflight, signal) {
56
- signal.throwIfAborted();
57
- if (this.activationPreflight !== undefined)
58
- throw new SubagentError("Activation routing already has a Host owner", "UNAUTHORIZED");
59
- this.activationPreflight = preflight;
60
- signal.addEventListener("abort", () => { if (this.activationPreflight === preflight)
61
- this.activationPreflight = undefined; }, { once: true });
62
- }
63
- async startActivation(spec) {
64
- this.authority.assertSender(spec.request.parent);
65
- const start = request => this.startManaged(request);
66
- return this.activationPreflight === undefined ? start(spec) : this.activationPreflight(spec, start);
67
- }
68
- async startManaged(spec) {
69
- const parent = spec.request.parent;
70
- if (!this.authority.isManaged(parent, "creation"))
71
- return super.startActivation(spec);
72
- const provider = this.getProvider(spec.provider);
73
- if (provider === undefined)
74
- throw new SubagentError(`Subagent provider "${spec.provider}" is not registered`, "NO_PROVIDER");
75
- if (provider.prepareContinuable === undefined)
76
- throw new SubagentError("Managed delegation requires a local activation provider", "UNSUPPORTED_CAPABILITY");
77
- const ticket = this.authority.acquireParentTicket(parent);
78
- const childId = spec.childId ?? SessionId(randomUUID());
79
- const operation = this.operation(parent, childId, "fresh", ticket.owner, spec.delivery === "caller" ? "one-shot" : "continuable");
80
- let receipt;
81
- try {
82
- receipt = await duringManagedCreation(operation, () => super.startActivation({ ...spec, childId,
83
- signal: AbortSignal.any([spec.signal, ticket.signal, this.lifetime.signal]) }));
84
- this.authority.promote(operation);
85
- let disposal;
86
- const accepted = receipt;
87
- return { ...accepted, dispose: () => {
88
- if (disposal !== undefined)
89
- return disposal;
90
- this.retireTree(operation.child, "activation-disposed");
91
- return disposal = accepted.dispose();
92
- } };
93
- }
94
- catch (error) {
95
- this.authority.retireOperation(operation, "activation-refused");
96
- if (receipt !== undefined) {
97
- try {
98
- await receipt.dispose();
99
- }
100
- catch (cleanup) {
101
- throw new AggregateError([error, cleanup], "Managed activation admission and cleanup failed");
102
- }
103
- if (operation.ownerSignal?.aborted)
104
- throw managedCancellation(operation.ownerSignal.reason);
105
- }
106
- throw error;
107
- }
108
- }
109
- operation(parent, childId, kind, owner, delegationMode) {
110
- this.lifetime.signal.throwIfAborted();
111
- const operation = { registry: exactRegistry(this.ctx.agents), parent, childId, kind, owner, delegationMode,
112
- ownerSignal: activationOwnerSignal(), claimed: false, retired: false, entered: agent => this.authority.beginPending(operation, agent) };
113
- return operation;
114
- }
115
- async coldDelivery(parent, childId, owner, deliver) {
116
- const operation = this.operation(parent, childId, "cold", owner);
117
- let accepted = false;
118
- try {
119
- const receipt = await duringManagedCreation(operation, deliver);
120
- accepted = true;
121
- // A competing operation may have established this residency before the native lock.
122
- if (operation.claimed)
123
- this.authority.promote(operation);
124
- return receipt;
125
- }
126
- catch (error) {
127
- this.authority.retireOperation(operation, "cold-delivery-refused");
128
- const child = operation.child;
129
- if (accepted && child !== undefined && this.ctx.agents.get(child.id) === child && this.ctx.agents.isOwnedBy(child.id, parent)) {
130
- try {
131
- await super.drainChildren(parent, [child.id]);
132
- }
133
- catch (cleanup) {
134
- throw new AggregateError([error, cleanup], "Managed cold admission and cleanup failed");
135
- }
136
- }
137
- throw error;
138
- }
139
- }
140
- retireTree(parent, reason) {
141
- const registry = this.ctx.agents, pending = [parent], seen = new Set();
142
- while (pending.length) {
143
- const agent = pending.pop();
144
- if (seen.has(agent))
145
- continue;
146
- seen.add(agent);
147
- this.authority.revokeParent(agent, reason);
148
- for (const child of registry.list())
149
- if (child !== agent && registry.isOwnedBy(child.id, agent))
150
- pending.push(child);
151
- }
152
- }
153
- drainDescendants(parents) {
154
- for (const parent of parents)
155
- if (this.ctx.agents.get(parent.id) !== parent)
156
- throw new SubagentError("Drain requires exact live parents", "UNAUTHORIZED");
157
- for (const parent of parents)
158
- this.retireTree(parent, "descendants-draining");
159
- return super.drainDescendants(parents);
160
- }
161
- drainChildren(parent, childIds) {
162
- const registry = this.ctx.agents;
163
- if (registry.get(parent.id) !== parent)
164
- throw new SubagentError("Drain requires exact live parent", "UNAUTHORIZED");
165
- const children = childIds.flatMap(id => { const child = registry.get(id); return child === undefined ? [] : [child]; });
166
- if (children.some(child => !registry.isOwnedBy(child.id, parent)))
167
- throw new SubagentError("Drain target is not a direct child", "UNAUTHORIZED");
168
- for (const child of children)
169
- this.retireTree(child, "child-draining");
170
- return super.drainChildren(parent, childIds);
171
- }
172
- /** Fulfillment proves this exact registry contains the provider, not just a mounted plugin. */
173
- waitForProvider(name, signal) {
174
- return this.waitFor(() => this.getProvider(name), signal);
175
- }
176
- /** Policy explicitly enabled AND every required provider actually registered. */
177
- waitUntilReady(signal) {
178
- return this.waitFor(() => this.authority.view().deliveryFenceReady ? true : undefined, signal).then(() => { });
179
- }
180
- async sendMessage(sender, targetId, content, options) {
181
- this.authority.assertSender(sender);
182
- // The SDK alone validates exact residency and adjacency on child -> parent.
183
- if (sender.session.header.parentSession === targetId || !this.authority.isManaged(sender)) {
184
- return super.sendMessage(sender, targetId, content, options);
185
- }
186
- const ticket = this.authority.acquireParentTicket(sender);
187
- const signal = AbortSignal.any([options.signal, ticket.signal]);
188
- const evidence = await this.authority.resolveChildEvidence(ticket, targetId, signal);
189
- const managed = this.authority.assertDelivery(ticket, targetId, evidence);
190
- signal.throwIfAborted();
191
- if (!managed)
192
- return super.sendMessage(sender, targetId, content, { ...options, signal });
193
- return this.coldDelivery(sender, targetId, ticket.owner, () => super.sendMessage(sender, targetId, content, { ...options, signal }));
194
- }
195
- async prompt(request, callerSignal) {
196
- const parent = this.ctx.get("agents")?.get(request.parentSessionId);
197
- if (parent === undefined)
198
- return super.prompt(request, callerSignal);
199
- let signal = callerSignal;
200
- let owner;
201
- let managed;
202
- try {
203
- this.authority.assertSender(parent);
204
- if (!this.authority.isManaged(parent))
205
- return super.prompt(request, callerSignal);
206
- const ticket = this.authority.acquireParentTicket(parent);
207
- owner = ticket.owner;
208
- signal = AbortSignal.any([callerSignal, ticket.signal, this.authority.acquireBrowserSignal(this.ctx)]);
209
- const evidence = await this.authority.resolveChildEvidence(ticket, request.childSessionId, signal);
210
- managed = this.authority.assertDelivery(ticket, request.childSessionId, evidence);
211
- signal.throwIfAborted();
212
- }
213
- catch (error) {
214
- // Match the native public prompt error boundary, without relabeling success.
215
- if (signal.aborted)
216
- throw new RemoteError("gateway/cancelled", "Subagent prompt was cancelled.", {}, { cause: error });
217
- if (error instanceof SubagentError && error.code === "UNAUTHORIZED") {
218
- throw new RemoteError("subagent/unauthorized", "Subagent delivery was not authorized.", { childSessionId: request.childSessionId }, { cause: error });
219
- }
220
- throw new RemoteError("gateway/internal", "Subagent prompt failed.", {}, { cause: error });
221
- }
222
- return managed ? this.coldDelivery(parent, request.childSessionId, owner, () => super.prompt(request, signal)) : super.prompt(request, signal);
223
- }
224
- wakeWaiters() {
225
- for (const waiter of this.waiters)
226
- waiter.check();
227
- }
228
- substrateReady() {
229
- const typert = this.ctx.get("typert");
230
- return this.requiredProviders.every((name) => this.getProvider(name) !== undefined)
231
- && (typert === undefined || typert.local.get("subagents/prompt") !== undefined);
232
- }
233
- waitFor(read, callerSignal) {
234
- const signal = callerSignal === undefined ? this.lifetime.signal : AbortSignal.any([callerSignal, this.lifetime.signal]);
235
- return new Promise((resolve, reject) => {
236
- const cleanup = () => { this.waiters.delete(waiter); signal.removeEventListener("abort", check); };
237
- const check = () => {
238
- if (signal.aborted) {
239
- cleanup();
240
- reject(signal.reason);
241
- return;
242
- }
243
- const value = read();
244
- if (value !== undefined) {
245
- cleanup();
246
- resolve(value);
247
- }
248
- };
249
- const waiter = { check };
250
- this.waiters.add(waiter);
251
- signal.addEventListener("abort", check, { once: true });
252
- check();
253
- });
254
- }
255
- }
256
- export default DsmmSubagentRuntime;
257
- //# sourceMappingURL=subagent-runtime.js.map
@@ -1,11 +0,0 @@
1
- <dsmm-deepseek-flash-calibration>
2
-
3
- DeepSeek-V41-Flash applies only to the verified deepseek-official/deepseek-flash or deepseek-account/deepseek-flash routes. The host catalog and explicit user model choice are authoritative.
4
-
5
- - Keep work outcome-first and avoid procedural review or approval loops.
6
- - Runtime reasoning effort is chosen by the adapter only from the resolved model's advertised efforts. If the catalog advertises no reasoning efforts, leave the request unchanged.
7
- - Ordinary root model and effort stay native-owned; explicit preflighted invocation effort takes precedence. For other eligible child requests, auto preserves explicit upstream effort; strict uses only an advertised effort.
8
- - Do not assume max, high, temperature, or another model's capabilities. Do not claim model heterogeneity when all child roles use the same route.
9
- - Maintain tool-call continuity required by the provider and never reveal private reasoning.
10
-
11
- </dsmm-deepseek-flash-calibration>
@@ -1,14 +0,0 @@
1
- <dsmm-deepseek-v4-pro-calibration>
2
-
3
- DeepSeek V4 Pro calibration is active.
4
-
5
- - Treat complex coding, architecture, migration, debugging, and review tasks as deliberate reasoning tasks.
6
- - First classify the task and identify the evidence needed.
7
- - Use tools before making repository-specific or API-specific claims.
8
- - Runtime reasoning effort is enforced by `agent/request`, not this prompt.
9
- - Ordinary root model and effort stay under the native model picker. Explicit preflighted invocation effort takes precedence over calibration.
10
- - For other eligible child requests, `auto` preserves explicit upstream effort; `strict` uses the configured default only when the adapter advertises a supported effort. If none is advertised, leave the request unchanged.
11
- - Keep final answers concise and do not expose private chain-of-thought.
12
- - When tool calls are enabled through the provider, preserve the provider-required reasoning/tool-call continuity.
13
-
14
- </dsmm-deepseek-v4-pro-calibration>