@dsmm/dsmm 0.3.1 → 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 (119) hide show
  1. package/cordis.patch.yml +9 -0
  2. package/docs/compatibility.md +10 -0
  3. package/docs/releasing.md +25 -65
  4. package/docs/roadmap.md +44 -2
  5. package/lib/client/ChildPermissions.d.ts +43 -0
  6. package/lib/client/ChildPermissions.js +100 -0
  7. package/lib/client/ChildrenPanel.d.ts +4 -1
  8. package/lib/client/ChildrenPanel.js +3 -3
  9. package/lib/client/DeploymentFields.d.ts +6 -2
  10. package/lib/client/DeploymentFields.js +8 -6
  11. package/lib/client/DeploymentPage.d.ts +4 -1
  12. package/lib/client/DeploymentPage.js +5 -4
  13. package/lib/client/HistoryContinuation.d.ts +7 -0
  14. package/lib/client/HistoryContinuation.js +22 -0
  15. package/lib/client/PermissionPanelEntry.d.ts +8 -0
  16. package/lib/client/PermissionPanelEntry.js +11 -0
  17. package/lib/client/PermissionsPanel.d.ts +3 -1
  18. package/lib/client/PermissionsPanel.js +3 -2
  19. package/lib/client/ProfilesSection.js +3 -3
  20. package/lib/client/RoleAvailability.js +1 -1
  21. package/lib/client/SessionProfiles.js +21 -18
  22. package/lib/client/TemporaryPermissions.d.ts +21 -0
  23. package/lib/client/TemporaryPermissions.js +94 -0
  24. package/lib/client/children-locales.d.ts +4 -4
  25. package/lib/client/controller.d.ts +17 -0
  26. package/lib/client/controller.js +101 -18
  27. package/lib/client/deployment-locales.js +26 -26
  28. package/lib/client/history-controller.d.ts +29 -0
  29. package/lib/client/history-controller.js +111 -0
  30. package/lib/client/history-entry.d.ts +11 -0
  31. package/lib/client/history-entry.js +106 -0
  32. package/lib/client/history-locales.d.ts +95 -0
  33. package/lib/client/history-locales.js +41 -0
  34. package/lib/client/index.js +16 -3
  35. package/lib/client/locales.d.ts +6 -0
  36. package/lib/client/locales.js +104 -92
  37. package/lib/client/permission-locales.d.ts +26 -0
  38. package/lib/client/permission-locales.js +55 -35
  39. package/lib/client/temporary-permission-client.d.ts +20 -0
  40. package/lib/client/temporary-permission-client.js +52 -0
  41. package/lib/client/temporary-permission-entry.d.ts +6 -0
  42. package/lib/client/temporary-permission-entry.js +56 -0
  43. package/lib/client.js +3881 -1981
  44. package/lib/history-candidates.d.ts +30 -0
  45. package/lib/history-candidates.js +176 -0
  46. package/lib/history-codec.d.ts +11 -0
  47. package/lib/history-codec.js +102 -0
  48. package/lib/history-contract.d.ts +44 -0
  49. package/lib/history-contract.js +2 -0
  50. package/lib/history-controller.d.ts +42 -0
  51. package/lib/history-controller.js +329 -0
  52. package/lib/history-policy.d.ts +4 -0
  53. package/lib/history-policy.js +8 -0
  54. package/lib/history-remote.d.ts +28 -0
  55. package/lib/history-remote.js +17 -0
  56. package/lib/history-rpc.d.ts +24 -0
  57. package/lib/history-rpc.js +136 -0
  58. package/lib/history-support.d.ts +15 -0
  59. package/lib/history-support.js +21 -0
  60. package/lib/history-types.d.ts +67 -0
  61. package/lib/history-types.js +2 -0
  62. package/lib/index.d.ts +2 -0
  63. package/lib/index.js +24 -6
  64. package/lib/native-admission.d.ts +21 -0
  65. package/lib/native-admission.js +206 -16
  66. package/lib/permission-child-control.d.ts +36 -0
  67. package/lib/permission-child-control.js +164 -0
  68. package/lib/permission-control.d.ts +2 -0
  69. package/lib/permission-control.js +7 -0
  70. package/lib/permission-controller.js +2 -2
  71. package/lib/permission-exec-argv.d.ts +32 -0
  72. package/lib/permission-exec-argv.js +171 -0
  73. package/lib/permission-fs-search.js +2 -1
  74. package/lib/permission-fs.js +2 -1
  75. package/lib/permission-native-rules.js +3 -3
  76. package/lib/permission-temporary-files.d.ts +19 -0
  77. package/lib/permission-temporary-files.js +248 -0
  78. package/lib/permission-temporary-grants.d.ts +106 -0
  79. package/lib/permission-temporary-grants.js +198 -0
  80. package/lib/permission-temporary-install.d.ts +25 -0
  81. package/lib/permission-temporary-install.js +86 -0
  82. package/lib/permission-temporary-remote.d.ts +19 -0
  83. package/lib/permission-temporary-remote.js +75 -0
  84. package/lib/permission-temporary-rpc.d.ts +37 -0
  85. package/lib/permission-temporary-rpc.js +154 -0
  86. package/lib/permission-temporary-types.d.ts +47 -0
  87. package/lib/permission-temporary-types.js +2 -0
  88. package/lib/permission-temporary-web.d.ts +11 -0
  89. package/lib/permission-temporary-web.js +154 -0
  90. package/lib/permission-web.js +2 -1
  91. package/lib/preset-skills.d.ts +1 -1
  92. package/lib/preset-skills.js +2 -2
  93. package/lib/profile-rpc.js +2 -0
  94. package/lib/profile-runtime.d.ts +12 -1
  95. package/lib/profile-runtime.js +122 -10
  96. package/lib/profile-store.d.ts +2 -2
  97. package/lib/profile-store.js +8 -1
  98. package/lib/profile-types.d.ts +1 -0
  99. package/lib/role-invocation.d.ts +1 -1
  100. package/lib/role-invocation.js +2 -2
  101. package/lib/role-subagents.js +16 -3
  102. package/lib/skills.d.ts +1 -0
  103. package/lib/skills.js +5 -1
  104. package/package.json +41 -33
  105. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +13291 -0
  106. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +9133 -0
  107. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +156 -0
  108. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +3546 -0
  109. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +431 -0
  110. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +119 -0
  111. package/patches/dsh-approval-settlement/README.md +41 -0
  112. package/patches/dsh-approval-settlement/metadata.json +10 -0
  113. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +383 -0
  114. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +55 -0
  115. package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +16673 -0
  116. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +29 -0
  117. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +196 -0
  118. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +35 -0
  119. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +40 -0
@@ -1,9 +1,10 @@
1
1
  import { join } from "node:path";
2
2
  import { randomBytes } from "node:crypto";
3
- import { lstatSync } from "node:fs";
3
+ import { lstatSync, realpathSync } from "node:fs";
4
+ import { isDeepStrictEqual } from "node:util";
4
5
  import { Context } from "@deepseek-ai/cordis";
5
6
  import { ProfileStore, validateSessionProfileId } from "./profile-store.js";
6
- import { DsmmProfileError, profileDocumentWarnings, requiredReason, resolveProfileSettings } from "./profiles.js";
7
+ import { DsmmProfileError, parseProfileDocument, profileDocumentWarnings, requiredReason, resolveProfileSettings, validateProfileId } from "./profiles.js";
7
8
  import { DSMM_ROLES, isDsmmRoleId } from "./roles.js";
8
9
  import { freezeSettings, isRootRoleEnabled } from "./settings.js";
9
10
  import { roleRouteRuntimeState } from "./role-routing.js";
@@ -36,6 +37,7 @@ export class DsmmProfileRuntime {
36
37
  document = null;
37
38
  bound = new WeakMap();
38
39
  observations = new WeakMap();
40
+ historyAdmissions = new WeakSet();
39
41
  disposed = false;
40
42
  queue = Promise.resolve();
41
43
  mode;
@@ -88,6 +90,51 @@ export class DsmmProfileRuntime {
88
90
  this.bound.set(agent, admission);
89
91
  }
90
92
  release(agent) { this.bound.delete(agent); }
93
+ /** Prepare an explicit current choice; historical selection files and epochs are not read. */
94
+ async prepareHistory(profileId, signal) {
95
+ this.assertCurrent();
96
+ signal.throwIfAborted();
97
+ if (profileId !== null)
98
+ validateProfileId(profileId);
99
+ const directory = profileId === null ? undefined : this.store.profileDir;
100
+ if (profileId !== null && directory === undefined)
101
+ throw new DsmmProfileError("unavailable", "History continuation requires an observable saved-profile store.");
102
+ const path = directory === undefined ? undefined : join(directory, `${profileId}.jsonc`);
103
+ const observe = () => {
104
+ if (path === undefined)
105
+ return undefined;
106
+ const stat = lstatSync(path, { bigint: true }), parent = lstatSync(directory, { bigint: true });
107
+ if (!stat.isFile() || stat.isSymbolicLink() || !parent.isDirectory() || parent.isSymbolicLink())
108
+ throw new DsmmProfileError("unsafe-path", "The saved profile source is not a regular file.");
109
+ return [realpathSync(directory), parent.dev, parent.ino, stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs];
110
+ };
111
+ const source = observe();
112
+ const saved = profileId === null ? null : await this.store.read(profileId);
113
+ const deployment = await this.options.readDesired?.();
114
+ const document = saved === null ? null : parseProfileDocument(saved.content, saved.id);
115
+ const candidate = this.prepare(document, { selectedId: profileId, appliedRevision: saved?.revision ?? null,
116
+ selectionRevision: "unavailable", ...(saved === null ? {} : { sourceRevision: saved.revision }) }, newEpoch(), profileId === null ? "deployment-baseline" : "session-override", deployment);
117
+ const assertCurrent = () => {
118
+ this.assertCurrent();
119
+ signal.throwIfAborted();
120
+ if (!isDeepStrictEqual(source, observe()))
121
+ throw new DsmmProfileError("conflict", "The saved profile changed during history continuation.");
122
+ };
123
+ await this.validate(candidate.settings);
124
+ assertCurrent();
125
+ this.historyAdmissions.add(candidate);
126
+ return { admission: candidate, ...(saved?.label === undefined ? {} : { label: saved.label }), assertCurrent,
127
+ revalidate: async (currentSignal) => {
128
+ currentSignal.throwIfAborted();
129
+ assertCurrent();
130
+ const desired = await this.options.readDesired?.();
131
+ if (!isDeepStrictEqual(desired, deployment))
132
+ throw new DsmmProfileError("conflict", "Deployment changed during history continuation.");
133
+ await this.validate(candidate.settings);
134
+ currentSignal.throwIfAborted();
135
+ assertCurrent();
136
+ } };
137
+ }
91
138
  async prepareRoot(agent, signal) {
92
139
  this.assertRoot(agent);
93
140
  signal.throwIfAborted();
@@ -112,19 +159,24 @@ export class DsmmProfileRuntime {
112
159
  const disk = await this.store.loadSessionSelection(agent.id);
113
160
  await this.ctx.get?.("dsmmNativeAdmission")?.ensure?.(agent);
114
161
  this.assertRoot(agent);
115
- if (this.admission(agent) !== admitted || (disk.admissionEpoch === null && admitted.scope !== "global-default")
116
- || (disk.admissionEpoch !== null && (disk.admissionEpoch !== admitted.epoch || disk.selectedId !== admitted.selectedId || disk.appliedRevision !== admitted.appliedRevision))) {
162
+ if (this.admission(agent) !== admitted || !this.historyAdmissions.has(admitted) && ((disk.admissionEpoch === null && admitted.scope !== "global-default")
163
+ || (disk.admissionEpoch !== null && (disk.admissionEpoch !== admitted.epoch || disk.selectedId !== admitted.selectedId || disk.appliedRevision !== admitted.appliedRevision)))) {
117
164
  throw new DsmmProfileError("conflict", "The session choice changed outside this owner; its admitted configuration was retained.");
118
165
  }
166
+ if (disk.admissionEpoch === admitted.epoch)
167
+ this.observations.set(admitted, selectionState(disk));
168
+ return this.sessionSnapshot(agent, admitted, disk);
169
+ }
170
+ sessionSnapshot(agent, admitted, disk, inMaintenance = false) {
119
171
  const role = resolveAdmittedDsmmRole(agent, admitted.settings, this.mode.active(agent, admitted.settings.defaultActive));
120
172
  const profileModel = role === undefined ? undefined : admitted.settings.roleRouting[role]?.primary;
121
173
  const deepwork = this.mode.describe(agent, admitted.settings.defaultActive);
122
- return { sessionId: agent.id, globalDefault: this.observedSelection(this.current), selection: selectionState(disk), admittedSelection: selectionState(admitted), scope: admitted.scope,
174
+ return { sessionId: agent.id, globalDefault: this.observedSelection(this.current), selection: selectionState(disk), admittedSelection: this.observedSelection(admitted), scope: admitted.scope,
123
175
  rolePolicy: structuredClone(roleRouteRuntimeState(agent, admitted.settings, role, admitted.epoch)), deepwork,
124
176
  modules: projectDsmmModules(this.baseline, admitted.deployment, admitted, false, this.options.getMountedPermission), configuration: deploymentAdmissionView(admitted),
125
177
  warnings: structuredClone(admitted.warnings ?? []), roles: structuredClone(admitted.roleAvailability ?? []), subagentRuntime: this.runtimeView(),
126
178
  ...(profileModel === undefined ? {} : { profileModel: structuredClone(profileModel) }), admissionEpoch: admitted.epoch,
127
- ...this.sessionActions(agent, admitted, deepwork, profileModel !== undefined), switchAllowed: false, switchUnavailableReason: "unavailable" };
179
+ ...this.sessionActions(agent, admitted, deepwork, profileModel !== undefined, inMaintenance), switchAllowed: false, switchUnavailableReason: "unavailable" };
128
180
  }
129
181
  async selectMode(request, agent, signal, authority) {
130
182
  this.assertRoot(agent);
@@ -168,9 +220,68 @@ export class DsmmProfileRuntime {
168
220
  throw new DsmmProfileError("maintenance", "The native session refused the Deepwork change.");
169
221
  }
170
222
  }
171
- async selectSession(_request, agent, _signal, _authority) {
223
+ async selectSession(request, agent, signal, authority) {
172
224
  this.assertRoot(agent);
173
- throw new DsmmProfileError("unavailable", "Live Apply is unavailable; save and select a default for new sessions.");
225
+ if (this.historyAdmissions.has(this.admission(agent)))
226
+ throw new DsmmProfileError("unavailable", "A continued historical Agent is not a blank configuration target.");
227
+ if (request.sessionId !== agent.id)
228
+ throw new DsmmProfileError("not-owned", "The native session does not match the captured Agent.");
229
+ const previous = this.admission(agent);
230
+ const owner = this.ctx.get?.("dsmmNativeAdmission");
231
+ const check = (maintenanceSignal) => {
232
+ this.assertRoot(agent);
233
+ if (signal?.aborted || maintenanceSignal?.aborted)
234
+ throw new DsmmProfileError("cancelled", "The session configuration change was cancelled.");
235
+ if (this.admission(agent) !== previous || previous.epoch !== request.expectedAdmissionEpoch || this.ctx.get?.("dsmmNativeAdmission") !== owner) {
236
+ throw new DsmmProfileError("conflict", "The admitted session configuration changed; refresh before selecting again.");
237
+ }
238
+ authority?.();
239
+ };
240
+ check();
241
+ if (owner?.beginBlank === undefined || agent.runMaintenance === undefined)
242
+ throw new DsmmProfileError("unavailable", "Native blank-session configuration maintenance is unavailable.");
243
+ if (agent.status === "running")
244
+ throw new DsmmProfileError("busy", "Wait for the session to become idle.");
245
+ try {
246
+ return await agent.runMaintenance(async (maintenanceSignal) => {
247
+ check(maintenanceSignal);
248
+ const transaction = owner.beginBlank(agent, signal === undefined ? maintenanceSignal : AbortSignal.any([maintenanceSignal, signal]), () => check(maintenanceSignal));
249
+ const assertCurrent = () => transaction.assertCurrent();
250
+ let next, response;
251
+ try {
252
+ const epoch = newEpoch();
253
+ const result = await this.store.selectSession(request, epoch, async (document) => {
254
+ const deployment = await this.options.readDesired?.();
255
+ assertCurrent();
256
+ const candidate = this.prepare(document, { selectedId: request.id, appliedRevision: null, selectionRevision: "unavailable" }, epoch, request.id === null ? "deployment-baseline" : "session-override", deployment ?? previous.deployment);
257
+ await this.validate(candidate.settings);
258
+ assertCurrent();
259
+ return { candidate, document };
260
+ }, {
261
+ assertCurrent,
262
+ prepare: async (selection, prepared) => {
263
+ assertCurrent();
264
+ const candidate = prepared.candidate;
265
+ next = this.profileAdmission(selection, candidate.settings, selection.admissionEpoch, candidate.scope, candidate.baseline, candidate.deployment, candidate.restartRequired, prepared.document, selection.warnings);
266
+ await transaction.prepare(next, () => { response = this.sessionSnapshot(agent, next, selection, true); });
267
+ assertCurrent();
268
+ },
269
+ committed: () => { this.bound.set(agent, next); transaction.committed(); },
270
+ });
271
+ this.observations.set(next, selectionState(result.selection));
272
+ return { ...response, selection: selectionState(result.selection), admittedSelection: selectionState(result.selection),
273
+ ...(result.selection.refreshRequired ? { refreshRequired: true } : {}) };
274
+ }
275
+ finally {
276
+ await transaction.close();
277
+ }
278
+ });
279
+ }
280
+ catch (error) {
281
+ if (error instanceof DsmmProfileError)
282
+ throw error;
283
+ throw new DsmmProfileError("maintenance", "The native session refused the configuration change.");
284
+ }
174
285
  }
175
286
  assertRoot(agent) {
176
287
  this.assertCurrent();
@@ -324,7 +435,7 @@ export class DsmmProfileRuntime {
324
435
  return { id: role.id, label: role.name, enabled: admission.settings.roles[role.id], availability: admission.roleAvailability?.find(row => row.id === role.id), ...(Object.keys(runtimePolicy).length === 0 ? {} : { runtimePolicy }) };
325
436
  });
326
437
  }
327
- sessionActions(agent, admission, mode, hasProfileModel) {
438
+ sessionActions(agent, admission, mode, hasProfileModel, inMaintenance = false) {
328
439
  const llm = agent.ctx?.get?.("llm") ?? this.ctx.get?.("llm");
329
440
  const selectModelUnavailableReason = !hasProfileModel ? "model-unconfigured" : llm?.resolveCallConfig === undefined ? "model-service-unavailable" : undefined;
330
441
  const owner = this.ctx.get?.("dsmmNativeAdmission");
@@ -332,9 +443,10 @@ export class DsmmProfileRuntime {
332
443
  const toggleModeUnavailableReason = agent.status === "running" || hasOpenTurn(sessionEvents(agent.session)) ? "busy"
333
444
  : agent.runMaintenance === undefined ? "maintenance" : !mode.active && (!this.baseline.modules.deepwork.enabled || !admission.settings.modules.deepwork.enabled) ? "module-off"
334
445
  : mode.locked || !mode.active && !ready ? "runtime-unavailable" : undefined;
446
+ const applyOverlayUnavailableReason = this.historyAdmissions.has(admission) ? "new-session-required" : this.store.readOnly ? "runtime-unavailable" : owner?.blankReason?.(agent, inMaintenance) ?? (owner?.blankReason === undefined ? "runtime-unavailable" : undefined);
335
447
  return { canSelectModel: selectModelUnavailableReason === undefined, ...(selectModelUnavailableReason === undefined ? {} : { selectModelUnavailableReason }),
336
448
  canToggleMode: toggleModeUnavailableReason === undefined, ...(toggleModeUnavailableReason === undefined ? {} : { toggleModeUnavailableReason }),
337
- canApplyOverlay: false, applyOverlayUnavailableReason: "new-session-required" };
449
+ canApplyOverlay: applyOverlayUnavailableReason === undefined, ...(applyOverlayUnavailableReason === undefined ? {} : { applyOverlayUnavailableReason }) };
338
450
  }
339
451
  async validate(settings) {
340
452
  if (!settings.modules.deepwork.enabled)
@@ -16,8 +16,8 @@ export interface LoadedSessionProfileSelection extends LoadedProfileSelection {
16
16
  }
17
17
  export declare const MAX_SESSION_PROFILE_CHOICES = 1024;
18
18
  export interface SessionProfileCommit<T> {
19
- /** Fallible synchronous preparation before the final fence/rename; never publication. */
20
- prepare?(selection: LoadedSessionProfileSelection, prepared: T): void;
19
+ /** Fallible installation preparation before the final fence/rename; never publication. */
20
+ prepare?(selection: LoadedSessionProfileSelection, prepared: T): void | Promise<void>;
21
21
  /** Trusted native liveness/cancellation fence; invoked immediately before rename. */
22
22
  assertCurrent(): void;
23
23
  /** Synchronous publication after durable commit. Must not throw or await. */
@@ -179,7 +179,14 @@ export class ProfileStore {
179
179
  const bytes = Buffer.from(`${JSON.stringify(pointer)}\n`, "utf8");
180
180
  const selection = { sessionId: request.sessionId, admissionEpoch: epoch,
181
181
  selectedId: request.id, appliedRevision: revision, selectionRevision: "unavailable", document: draft?.document ?? null, content: draft?.content ?? null, ...source, ...warningFields(draft) };
182
- commit.prepare?.(selection, prepared);
182
+ try {
183
+ await commit.prepare?.(selection, prepared);
184
+ }
185
+ catch (error) {
186
+ if (error instanceof DsmmProfileError)
187
+ throw error;
188
+ throw new DsmmProfileError("activation", "The candidate installation could not be prepared; the previous session selection was retained.");
189
+ }
183
190
  const owned = this.atomicReplace(target, bytes, fence, assertLock);
184
191
  commit.committed(selection, prepared);
185
192
  const observed = observeCommitted(target, owned, this.observe);
@@ -203,6 +203,7 @@ export interface SessionProfileSnapshot {
203
203
  selectModelUnavailableReason?: SessionActionUnavailableReason;
204
204
  canToggleMode: boolean;
205
205
  toggleModeUnavailableReason?: SessionActionUnavailableReason;
206
+ /** Host-authoritative blank-session choice; never started-session hot Apply. */
206
207
  canApplyOverlay: boolean;
207
208
  applyOverlayUnavailableReason?: SessionActionUnavailableReason;
208
209
  rolePolicy?: DsmmRoleRuntimeState;
@@ -26,7 +26,7 @@ export declare function bindRoleInvocation(agent: DshAgent, invocation: Resolved
26
26
  export declare function capturedRoleInvocation(agent: DshAgent): ResolvedRoleInvocation | undefined;
27
27
  export declare function capturedOriginalRoleInvocation(agent: DshAgent): ChildAdmissionCapture["invocation"] | undefined;
28
28
  /** Complete selections replace model and effort together; effort-only selections narrow candidates. */
29
- export declare function resolveRoleInvocation(parent: Agent, target: DsmmRoleId, settings: DsmmSettings, signal: AbortSignal, options?: DsmmInvocationOptions, nativeOptions?: AgentOptions): Promise<ResolvedRoleInvocation>;
29
+ export declare function resolveRoleInvocation(parent: Agent, target: DsmmRoleId, settings: DsmmSettings, signal: AbortSignal, options?: DsmmInvocationOptions, nativeOptions?: AgentOptions, parameterPolicy?: ResolvedModelParameterPolicy): Promise<ResolvedRoleInvocation>;
30
30
  export declare function invocationAgentOptions(invocation: ResolvedRoleInvocation, options?: AgentOptions): AgentOptions;
31
31
  export declare function invocationView(invocation: ResolvedRoleInvocation, label: string, mode: DsmmInvocationView["mode"], ids?: Pick<DsmmInvocationView, "runId" | "childId" | "jobId">): {
32
32
  runId?: string | undefined;
@@ -27,7 +27,7 @@ export function bindRoleInvocation(agent, invocation, original) {
27
27
  export function capturedRoleInvocation(agent) { return captured.get(agent); }
28
28
  export function capturedOriginalRoleInvocation(agent) { return originalCaptures.get(agent)?.invocation; }
29
29
  /** Complete selections replace model and effort together; effort-only selections narrow candidates. */
30
- export async function resolveRoleInvocation(parent, target, settings, signal, options = {}, nativeOptions) {
30
+ export async function resolveRoleInvocation(parent, target, settings, signal, options = {}, nativeOptions, parameterPolicy) {
31
31
  if (!isDsmmRoleId(target) || target === "dsmm-orchestrator")
32
32
  throw new SubagentError("Unknown DSMM delegation target", "UNAUTHORIZED");
33
33
  if (Object.keys(options).some(key => key !== "level" && key !== "route"))
@@ -93,7 +93,7 @@ export async function resolveRoleInvocation(parent, target, settings, signal, op
93
93
  if (llm === undefined)
94
94
  throw new Error("DSMM invocation requires the parent's native LLM service");
95
95
  const admission = parent.ctx.get("dsmmProfileRuntime")?.admission(parent);
96
- const modelParameterPolicy = capturedRoleInvocation(parent)?.modelParameterPolicy
96
+ const modelParameterPolicy = parameterPolicy ?? capturedRoleInvocation(parent)?.modelParameterPolicy
97
97
  ?? (admission === undefined ? configuredModelParameterPolicy(settings) : resolvedModelParameterPolicy(admission));
98
98
  const project = (candidate, source) => modelRouteFromCall(projectModelRouteParameters(candidate, source, modelParameterPolicy.mode !== "native-defaults"));
99
99
  const projected = initialCandidates.map((candidate, index) => project(candidate, index === 0 || candidateEffort !== undefined ? effortSource : "dsmm-config"));
@@ -293,12 +293,18 @@ export async function registerHeadlessRoleTools(ctx, controller, getSettings, po
293
293
  const host = ctx.get?.("tools");
294
294
  const names = [...hostControls, ...host?.schemas().map((row) => row.name).filter((name) => name.startsWith(`mcp__${settings.lsp.serverName}__`)) ?? []];
295
295
  const definitions = names.map((name) => host?.get(name));
296
+ const providers = targets.map(role => {
297
+ const provider = subagents?.getProvider(roleProviderName(role));
298
+ return provider === undefined ? undefined : Reflect.get(provider, symbols.original) ?? provider;
299
+ });
300
+ const sameProviders = providers.length === state.providers.length && providers.every((provider, index) => provider === state.providers[index]);
296
301
  const signature = JSON.stringify([identity.role, targets, settings.subagents, targets.map((role) => [settings.roleRouting[role], subagents?.getProvider(roleProviderName(role))?.capabilities])]);
297
302
  const sameRealm = state.tools !== undefined && (Reflect.get(state.tools, symbols.original) ?? state.tools) === (Reflect.get(tools, symbols.original) ?? tools);
298
303
  const parentScope = scopeParentOf(agent);
299
304
  const sameParent = state.parentScope === parentScope;
300
- if (sameRealm && sameParent && signature === state.signature && definitions.length === state.hostDefinitions.length && definitions.every((definition, i) => definition === state.hostDefinitions[i]))
305
+ if (sameRealm && sameParent && sameProviders && signature === state.signature && definitions.length === state.hostDefinitions.length && definitions.every((definition, i) => definition === state.hostDefinitions[i]))
301
306
  return;
307
+ state.signature = undefined;
302
308
  for (const dispose of state.owned.splice(0))
303
309
  dispose();
304
310
  state.restriction?.();
@@ -322,6 +328,7 @@ export async function registerHeadlessRoleTools(ctx, controller, getSettings, po
322
328
  state.owned.push(registerRoleTool(agent, agentCtx, tools, entry, getSettings, policy, admission));
323
329
  policy.captureTools(agent, tools, [...inventory.map(entry => entry.name), ...names], !sameRealm || !sameParent);
324
330
  state.signature = signature;
331
+ state.providers = providers;
325
332
  state.hostDefinitions = definitions;
326
333
  state.parentScope = parentScope;
327
334
  };
@@ -332,7 +339,7 @@ export async function registerHeadlessRoleTools(ctx, controller, getSettings, po
332
339
  return;
333
340
  const agentCtx = nativeAgentContext(agent);
334
341
  policy.admit(agent);
335
- states.set(agent, { owned: [], hostDefinitions: [] });
342
+ states.set(agent, { owned: [], hostDefinitions: [], providers: [] });
336
343
  const retire = () => {
337
344
  stopIdentity();
338
345
  const state = states.get(agent);
@@ -348,7 +355,13 @@ export async function registerHeadlessRoleTools(ctx, controller, getSettings, po
348
355
  };
349
356
  admission.lifetime.signal.addEventListener("abort", retire, { once: true });
350
357
  agentCtx.effect(() => retire);
351
- reconcile(agent);
358
+ try {
359
+ reconcile(agent);
360
+ }
361
+ catch (error) {
362
+ retire();
363
+ throw error;
364
+ }
352
365
  admittedRealms.set(agent, () => reconcile(agent));
353
366
  };
354
367
  // Native assembly collects sections before its waterfall. Admission/mode/preset
package/lib/skills.d.ts CHANGED
@@ -22,6 +22,7 @@ export interface BundledSkillProviderOptions {
22
22
  agent: DshAgent;
23
23
  controller: DeepworkModeController;
24
24
  getSettings: DsmmSettingsGetter;
25
+ catalogReady?: () => boolean;
25
26
  /** Body I/O seam for deterministic cancellation/race contract tests. */
26
27
  load?: typeof readBundledSkill;
27
28
  }
package/lib/skills.js CHANGED
@@ -96,12 +96,14 @@ export function registerBundledSkills(ctx, skills, options) {
96
96
  async list(lookup) {
97
97
  const signal = signalFor(lookup), current = generation, parent = scopeParentOf(agentScope);
98
98
  signal.throwIfAborted();
99
+ if (options.catalogReady?.() === false)
100
+ return { candidates: [], complete: false };
99
101
  const enabled = names();
100
102
  if (enabled.length === 0)
101
103
  return [];
102
104
  const snapshot = await ancestor(lookup, signal);
103
105
  signal.throwIfAborted();
104
- if (!snapshot.complete || generation !== current || scopeParentOf(agentScope) !== parent)
106
+ if (!snapshot.complete || generation !== current || scopeParentOf(agentScope) !== parent || options.catalogReady?.() === false)
105
107
  return { candidates: [], complete: false };
106
108
  return enabled.filter((name) => !occupied(snapshot, name)).map((name) => ({
107
109
  ...bundledSkillMetadata(name), rank: BUNDLED_SKILL_RANK, locator: { name, parent }
@@ -110,6 +112,8 @@ export function registerBundledSkills(ctx, skills, options) {
110
112
  async get(candidate, lookup) {
111
113
  const signal = signalFor(lookup), current = generation;
112
114
  signal.throwIfAborted();
115
+ if (options.catalogReady?.() === false)
116
+ return undefined;
113
117
  const name = names().find((name) => name === candidate.name);
114
118
  const locator = candidate.locator;
115
119
  if (name === undefined || typeof locator !== "object" || locator === null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsmm/dsmm",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "DeepSeek Harness deepwork mode bundle for ocmm-style agentic workflows.",
5
5
  "author": "Hugefiver",
6
6
  "license": "LicenseRef-AAAPL",
@@ -26,6 +26,10 @@
26
26
  "main": "./lib/index.js",
27
27
  "types": "./lib/index.d.ts",
28
28
  "exports": {
29
+ "./history-support": {
30
+ "types": "./lib/history-support.d.ts",
31
+ "default": "./lib/history-support.js"
32
+ },
29
33
  "./managed-settings": {
30
34
  "types": "./lib/managed-settings.d.ts",
31
35
  "default": "./lib/managed-settings.js"
@@ -126,24 +130,30 @@
126
130
  "@deepseek-ai/dsh-agent-instructions": "0.2.1-rc.2",
127
131
  "@deepseek-ai/dsh-agent-loop": "0.2.1-rc.2",
128
132
  "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-rc.2",
133
+ "@deepseek-ai/dsh-api-remote-access": "0.2.1-rc.2",
129
134
  "@deepseek-ai/dsh-attachment": "0.2.1-rc.2",
130
135
  "@deepseek-ai/dsh-brand": "0.2.1-rc.2",
131
136
  "@deepseek-ai/dsh-client-connection": "0.2.1-rc.2",
137
+ "@deepseek-ai/dsh-client-store": "0.2.1-rc.2",
138
+ "@deepseek-ai/dsh-client-ui-approval": "0.2.1-rc.2",
132
139
  "@deepseek-ai/dsh-command-compact": "0.2.1-rc.2",
133
140
  "@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
134
141
  "@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.1-rc.2",
142
+ "@deepseek-ai/dsh-fs-local": "0.2.1-rc.2",
135
143
  "@deepseek-ai/dsh-http-proxy": "0.2.1-rc.2",
136
144
  "@deepseek-ai/dsh-jobs": "0.2.1-rc.2",
137
145
  "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
138
146
  "@deepseek-ai/dsh-llm-pi-ai": "0.2.1-rc.2",
139
147
  "@deepseek-ai/dsh-persona": "0.2.1-rc.2",
140
148
  "@deepseek-ai/dsh-plan-mode": "0.2.1-rc.2",
149
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.1-rc.2",
141
150
  "@deepseek-ai/dsh-session": "0.2.1-rc.2",
142
151
  "@deepseek-ai/dsh-session-persistence": "0.2.1-rc.2",
143
152
  "@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-rc.2",
144
153
  "@deepseek-ai/dsh-settings": "0.2.1-rc.2",
145
154
  "@deepseek-ai/dsh-skill-filesystem": "0.2.1-rc.2",
146
155
  "@deepseek-ai/dsh-subagent": "0.2.1-rc.2",
156
+ "@deepseek-ai/dsh-subprocess-local": "0.2.1-rc.2",
147
157
  "@deepseek-ai/dsh-timeout": "0.2.1-rc.2",
148
158
  "@deepseek-ai/dsh-tool-ask-user": "0.2.1-rc.2",
149
159
  "@deepseek-ai/dsh-tool-bash": "0.2.1-rc.2",
@@ -157,6 +167,7 @@
157
167
  "@deepseek-ai/dsh-tool-web": "0.2.1-rc.2",
158
168
  "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
159
169
  "@deepseek-ai/dsh-typert-protocol": "0.2.1-rc.2",
170
+ "@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
160
171
  "@deepseek-ai/dsh-web": "0.2.1-rc.2",
161
172
  "@earendil-works/pi-ai": "^1.1.0"
162
173
  },
@@ -170,37 +181,49 @@
170
181
  "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-rc.2",
171
182
  "@deepseek-ai/dsh-api-gateway": "0.2.1-rc.2",
172
183
  "@deepseek-ai/dsh-api-remote-access": "0.2.1-rc.2",
173
- "@deepseek-ai/dsh-fs-local": "0.2.1-rc.2",
174
- "@deepseek-ai/dsh-fs-observation-policy": "0.2.1-rc.2",
175
- "@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
176
- "@deepseek-ai/dsh-sandbox-policy": "0.2.1-rc.2",
177
- "@deepseek-ai/dsh-sandbox-local": "0.2.1-rc.2",
178
- "@deepseek-ai/dsh-shell-env": "0.2.1-rc.2",
179
- "@deepseek-ai/dsh-bash-sandbox": "0.2.1-rc.2",
180
- "@deepseek-ai/dsh-pwsh-sandbox": "0.2.1-rc.2",
181
- "@deepseek-ai/dsh-subprocess-local": "0.2.1-rc.2",
182
- "@deepseek-ai/dsh-web-app": "0.2.1-rc.2",
183
- "@deepseek-ai/dsh-jobs-local": "0.2.1-rc.2",
184
- "@deepseek-ai/dsh-working-directory": "0.2.1-rc.2",
185
184
  "@deepseek-ai/dsh-api-session-controller": "0.2.1-rc.2",
186
185
  "@deepseek-ai/dsh-attachment": "0.2.1-rc.2",
186
+ "@deepseek-ai/dsh-bash-sandbox": "0.2.1-rc.2",
187
187
  "@deepseek-ai/dsh-brand": "0.2.1-rc.2",
188
188
  "@deepseek-ai/dsh-client-connection": "0.2.1-rc.2",
189
+ "@deepseek-ai/dsh-client-locale": "0.2.1-rc.2",
190
+ "@deepseek-ai/dsh-client-store": "0.2.1-rc.2",
191
+ "@deepseek-ai/dsh-client-ui-approval": "0.2.1-rc.2",
192
+ "@deepseek-ai/dsh-client-ui-conversation": "0.2.1-rc.2",
193
+ "@deepseek-ai/dsh-client-ui-model-selection": "0.2.1-rc.2",
194
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.1-rc.2",
195
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.2",
196
+ "@deepseek-ai/dsh-client-ui-session": "0.2.1-rc.2",
197
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.2",
198
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.2",
199
+ "@deepseek-ai/dsh-client-ui-tool": "0.2.1-rc.2",
189
200
  "@deepseek-ai/dsh-command-compact": "0.2.1-rc.2",
190
201
  "@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
191
202
  "@deepseek-ai/dsh-compaction-tool-result-pruner": "0.2.1-rc.2",
203
+ "@deepseek-ai/dsh-fs-local": "0.2.1-rc.2",
204
+ "@deepseek-ai/dsh-fs-observation-policy": "0.2.1-rc.2",
192
205
  "@deepseek-ai/dsh-http-proxy": "0.2.1-rc.2",
193
206
  "@deepseek-ai/dsh-jobs": "0.2.1-rc.2",
207
+ "@deepseek-ai/dsh-jobs-local": "0.2.1-rc.2",
194
208
  "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
195
209
  "@deepseek-ai/dsh-llm-pi-ai": "0.2.1-rc.2",
196
210
  "@deepseek-ai/dsh-persona": "0.2.1-rc.2",
197
211
  "@deepseek-ai/dsh-plan-mode": "0.2.1-rc.2",
212
+ "@deepseek-ai/dsh-pwsh-sandbox": "0.2.1-rc.2",
213
+ "@deepseek-ai/dsh-sandbox-local": "0.2.1-rc.2",
214
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.1-rc.2",
215
+ "@deepseek-ai/dsh-scope": "0.2.1-rc.2",
198
216
  "@deepseek-ai/dsh-session": "0.2.1-rc.2",
199
217
  "@deepseek-ai/dsh-session-persistence": "0.2.1-rc.2",
200
218
  "@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-rc.2",
219
+ "@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
201
220
  "@deepseek-ai/dsh-settings": "0.2.1-rc.2",
221
+ "@deepseek-ai/dsh-shell-env": "0.2.1-rc.2",
202
222
  "@deepseek-ai/dsh-skill-filesystem": "0.2.1-rc.2",
203
223
  "@deepseek-ai/dsh-subagent": "0.2.1-rc.2",
224
+ "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.1-rc.2",
225
+ "@deepseek-ai/dsh-subprocess-local": "0.2.1-rc.2",
226
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
204
227
  "@deepseek-ai/dsh-timeout": "0.2.1-rc.2",
205
228
  "@deepseek-ai/dsh-tool-ask-user": "0.2.1-rc.2",
206
229
  "@deepseek-ai/dsh-tool-bash": "0.2.1-rc.2",
@@ -210,27 +233,16 @@
210
233
  "@deepseek-ai/dsh-tool-pwsh": "0.2.1-rc.2",
211
234
  "@deepseek-ai/dsh-tool-skill": "0.2.1-rc.2",
212
235
  "@deepseek-ai/dsh-tool-subagent": "0.2.1-rc.2",
236
+ "@deepseek-ai/dsh-tool-subagent-control": "0.2.1-rc.2",
213
237
  "@deepseek-ai/dsh-tool-todo": "0.2.1-rc.2",
214
238
  "@deepseek-ai/dsh-tool-web": "0.2.1-rc.2",
215
239
  "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
216
240
  "@deepseek-ai/dsh-typert-protocol": "0.2.1-rc.2",
217
- "@deepseek-ai/dsh-client-locale": "0.2.1-rc.2",
218
- "@deepseek-ai/dsh-client-store": "0.2.1-rc.2",
219
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.1-rc.2",
220
- "@deepseek-ai/dsh-client-ui-model-selection": "0.2.1-rc.2",
221
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.1-rc.2",
222
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.2",
223
- "@deepseek-ai/dsh-client-ui-session": "0.2.1-rc.2",
224
- "@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.2",
225
- "@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.2",
226
- "@deepseek-ai/dsh-client-ui-tool": "0.2.1-rc.2",
227
- "@deepseek-ai/dsh-scope": "0.2.1-rc.2",
228
- "@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
229
- "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.1-rc.2",
230
- "@deepseek-ai/dsh-tool-subagent-control": "0.2.1-rc.2",
231
- "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
232
241
  "@deepseek-ai/dsh-typert-registry": "0.2.1-rc.2",
242
+ "@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
233
243
  "@deepseek-ai/dsh-web": "0.2.1-rc.2",
244
+ "@deepseek-ai/dsh-web-app": "0.2.1-rc.2",
245
+ "@deepseek-ai/dsh-working-directory": "0.2.1-rc.2",
234
246
  "@earendil-works/pi-ai": "1.3.0",
235
247
  "@types/node": "^26.0.0",
236
248
  "@types/react": "^18.3.27",
@@ -257,16 +269,12 @@
257
269
  "scripts": {
258
270
  "build": "node scripts/materialize-frontend.mjs --check && tsc -p tsconfig.json && node scripts/build-client.mjs",
259
271
  "build:client": "node scripts/build-client.mjs",
260
- "check:release": "node scripts/check-release-readiness.mjs",
261
272
  "sync:source": "node --experimental-strip-types scripts/sync-source-assets.mjs",
262
273
  "generate:roles": "node scripts/generate-role-assets.mjs",
263
274
  "check:source": "node --experimental-strip-types scripts/check-source-assets.mjs",
264
275
  "sync:frontend": "node scripts/materialize-frontend.mjs --sync",
265
276
  "typecheck": "tsc -p tsconfig.json --noEmit",
266
277
  "typecheck:test": "pnpm run build && tsc -p tsconfig.test.json --noEmit",
267
- "test": "pnpm run build && node --test --experimental-strip-types --import ./test/prompt-source-loader.mjs --test-concurrency=1 test/*.test.ts",
268
- "smoke:docker:build": "docker build --build-arg DSH_PACKAGE=@deepseek-ai/dsh@0.2.1-rc.2 -f docker/Dockerfile.smoke -t dsmm-dsh-smoke:0.2 ..",
269
- "smoke:docker:run": "docker run --rm dsmm-dsh-smoke:0.2",
270
- "smoke:docker": "node scripts/docker-smoke.mjs"
278
+ "test": "pnpm run build && node --test --experimental-strip-types --import ./test/prompt-source-loader.mjs --test-concurrency=1 test/*.test.ts"
271
279
  }
272
280
  }