@dsmm/dsmm 0.3.2 → 0.3.3

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 (110) hide show
  1. package/README.md +2 -2
  2. package/cordis.patch.yml +0 -9
  3. package/docs/agent-presets.md +5 -5
  4. package/docs/compatibility.md +2 -6
  5. package/docs/migration-from-ocmm.md +1 -1
  6. package/docs/roadmap.md +5 -12
  7. package/docs/settings-status.md +1 -1
  8. package/lib/client/ChildrenPanel.d.ts +1 -4
  9. package/lib/client/ChildrenPanel.js +3 -3
  10. package/lib/client/DeploymentPage.d.ts +1 -3
  11. package/lib/client/DeploymentPage.js +2 -2
  12. package/lib/client/PermissionsPanel.d.ts +1 -3
  13. package/lib/client/PermissionsPanel.js +2 -3
  14. package/lib/client/children-locales.d.ts +4 -4
  15. package/lib/client/controller.js +4 -1
  16. package/lib/client/deployment-locales.js +0 -1
  17. package/lib/client/deployment-modules.js +1 -1
  18. package/lib/client/index.js +2 -7
  19. package/lib/client/locales.js +131 -119
  20. package/lib/client/permission-locales.d.ts +0 -26
  21. package/lib/client/permission-locales.js +0 -20
  22. package/lib/client.js +1837 -3634
  23. package/lib/index.d.ts +0 -2
  24. package/lib/index.js +9 -22
  25. package/lib/native-admission.d.ts +0 -3
  26. package/lib/native-admission.js +12 -45
  27. package/lib/permission-fs-search.js +1 -2
  28. package/lib/permission-fs.js +1 -2
  29. package/lib/permission-web.js +1 -2
  30. package/lib/preset-materializer.js +3 -3
  31. package/lib/preset-registry.d.ts +20 -2
  32. package/lib/preset-registry.js +46 -17
  33. package/lib/profile-diagnostics.js +1 -1
  34. package/lib/profile-remote.js +1 -3
  35. package/lib/role-policy.js +2 -2
  36. package/lib/role-subagents.js +2 -1
  37. package/lib/roles.d.ts +2 -0
  38. package/lib/roles.js +2 -0
  39. package/lib/settings.d.ts +1 -3
  40. package/lib/settings.js +4 -9
  41. package/package.json +1 -5
  42. package/lib/client/ChildPermissions.d.ts +0 -43
  43. package/lib/client/ChildPermissions.js +0 -100
  44. package/lib/client/HistoryContinuation.d.ts +0 -7
  45. package/lib/client/HistoryContinuation.js +0 -22
  46. package/lib/client/PermissionPanelEntry.d.ts +0 -8
  47. package/lib/client/PermissionPanelEntry.js +0 -11
  48. package/lib/client/TemporaryPermissions.d.ts +0 -21
  49. package/lib/client/TemporaryPermissions.js +0 -94
  50. package/lib/client/history-controller.d.ts +0 -29
  51. package/lib/client/history-controller.js +0 -111
  52. package/lib/client/history-entry.d.ts +0 -11
  53. package/lib/client/history-entry.js +0 -106
  54. package/lib/client/history-locales.d.ts +0 -95
  55. package/lib/client/history-locales.js +0 -41
  56. package/lib/client/temporary-permission-client.d.ts +0 -20
  57. package/lib/client/temporary-permission-client.js +0 -52
  58. package/lib/client/temporary-permission-entry.d.ts +0 -6
  59. package/lib/client/temporary-permission-entry.js +0 -56
  60. package/lib/history-candidates.d.ts +0 -30
  61. package/lib/history-candidates.js +0 -176
  62. package/lib/history-codec.d.ts +0 -11
  63. package/lib/history-codec.js +0 -102
  64. package/lib/history-contract.d.ts +0 -44
  65. package/lib/history-contract.js +0 -2
  66. package/lib/history-controller.d.ts +0 -42
  67. package/lib/history-controller.js +0 -329
  68. package/lib/history-policy.d.ts +0 -4
  69. package/lib/history-policy.js +0 -8
  70. package/lib/history-remote.d.ts +0 -28
  71. package/lib/history-remote.js +0 -17
  72. package/lib/history-rpc.d.ts +0 -24
  73. package/lib/history-rpc.js +0 -136
  74. package/lib/history-support.d.ts +0 -15
  75. package/lib/history-support.js +0 -21
  76. package/lib/history-types.d.ts +0 -67
  77. package/lib/history-types.js +0 -2
  78. package/lib/permission-child-control.d.ts +0 -36
  79. package/lib/permission-child-control.js +0 -164
  80. package/lib/permission-exec-argv.d.ts +0 -32
  81. package/lib/permission-exec-argv.js +0 -171
  82. package/lib/permission-temporary-files.d.ts +0 -19
  83. package/lib/permission-temporary-files.js +0 -248
  84. package/lib/permission-temporary-grants.d.ts +0 -106
  85. package/lib/permission-temporary-grants.js +0 -198
  86. package/lib/permission-temporary-install.d.ts +0 -25
  87. package/lib/permission-temporary-install.js +0 -86
  88. package/lib/permission-temporary-remote.d.ts +0 -19
  89. package/lib/permission-temporary-remote.js +0 -75
  90. package/lib/permission-temporary-rpc.d.ts +0 -37
  91. package/lib/permission-temporary-rpc.js +0 -154
  92. package/lib/permission-temporary-types.d.ts +0 -47
  93. package/lib/permission-temporary-types.js +0 -2
  94. package/lib/permission-temporary-web.d.ts +0 -11
  95. package/lib/permission-temporary-web.js +0 -154
  96. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +0 -13291
  97. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +0 -9133
  98. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +0 -156
  99. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +0 -3546
  100. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +0 -431
  101. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +0 -119
  102. package/patches/dsh-approval-settlement/README.md +0 -41
  103. package/patches/dsh-approval-settlement/metadata.json +0 -10
  104. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +0 -383
  105. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +0 -55
  106. package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +0 -16673
  107. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +0 -29
  108. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +0 -196
  109. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +0 -35
  110. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +0 -40
package/lib/index.d.ts CHANGED
@@ -38,8 +38,6 @@ export type { DsmmLlmAdmission, DsmmLlmCallConfig, DsmmLlmHostOwner, DsmmLlmGene
38
38
  export { registerRuntimeRecovery } from "./runtime-recovery.js";
39
39
  export { classifyRecoveryFailure, foldAttemptedRecoveryRoutes, foldDurableRecoveryWork, selectFallbackRoute } from "./recovery-policy.js";
40
40
  export type { DurableRecoveryWork, RecoveryFailureDecision } from "./recovery-policy.js";
41
- export { DSMM_HISTORY_HOST_CONFIG } from "./history-support.js";
42
- export { HISTORY_REMOTE } from "./history-remote.js";
43
41
  export declare function createDsmmHostPlugin(startup: DsmmHostStartupOptions): {
44
42
  name: string;
45
43
  Config: import("@deepseek-ai/schemastery").default<import("./settings.js").DsmmPluginConfig>;
package/lib/index.js CHANGED
@@ -22,10 +22,6 @@ import { registerRoleControlRpc } from "./role-control-rpc.js";
22
22
  import { nativeStandingFullAccess } from "./permission-native-access.js";
23
23
  import { DsmmProfileError } from "./profiles.js";
24
24
  import { registerLspRuntime } from "./lsp.js";
25
- import { DsmmHistoryCandidates } from "./history-candidates.js";
26
- import { registerHistoryContinuationRpc } from "./history-rpc.js";
27
- import { requireHistoryAdmission } from "./history-support.js";
28
- import { installTemporaryPermissions } from "./permission-temporary-install.js";
29
25
  export const name = "dsmm";
30
26
  export const inject = ["profileContext", "agents"];
31
27
  export const Config = new Proxy(DSMM_NATIVE_CONFIG_SCHEMA, { apply(_target, _receiver, args) { return DSMM_CONFIG_SCHEMA(args[0] ?? {}); } });
@@ -49,8 +45,6 @@ export { DEEPWORK_MODE_EVENT, DeepworkModeController, hasOpenTurn, isDeepworkAct
49
45
  export { DsmmNativeLlmRuntime } from "./llm-runtime.js";
50
46
  export { registerRuntimeRecovery } from "./runtime-recovery.js";
51
47
  export { classifyRecoveryFailure, foldAttemptedRecoveryRoutes, foldDurableRecoveryWork, selectFallbackRoute } from "./recovery-policy.js";
52
- export { DSMM_HISTORY_HOST_CONFIG } from "./history-support.js";
53
- export { HISTORY_REMOTE } from "./history-remote.js";
54
48
  export function createDsmmHostPlugin(startup) {
55
49
  assertSupportedHostStartup(startup);
56
50
  return { name, Config, inject, apply(ctx, config = {}) { return apply(ctx, config, startup); } };
@@ -60,7 +54,6 @@ export async function apply(input, config = {}, startupOptions = {}) {
60
54
  if (!Context.is(input))
61
55
  throw new Error("DSMM requires the native Cordis Host");
62
56
  const ctx = input;
63
- requireHistoryAdmission(ctx);
64
57
  const deployment = new DsmmDeploymentConfig(ctx, config);
65
58
  const lifetime = new AbortController();
66
59
  scopeLifetime(ctx, "dsmm: retire Core", () => lifetime.abort());
@@ -126,7 +119,12 @@ export async function apply(input, config = {}, startupOptions = {}) {
126
119
  const nativeAdmission = admission;
127
120
  if (startup.settings.modules.deepwork.enabled) {
128
121
  const presets = ctx.inject(["agentPresets"], async (scope) => {
129
- await registerRolePresets(scope, () => startup.settings);
122
+ await registerRolePresets(scope, () => startup.settings, agent => { try {
123
+ return policy.identity(agent).role;
124
+ }
125
+ catch {
126
+ return undefined;
127
+ } });
130
128
  const providers = scope.inject(["subagents"], async (runtimeScope) => {
131
129
  registerRoleProviders(runtimeScope, () => startup.settings, nativeAdmission);
132
130
  await registerNativeSubagentControls(runtimeScope);
@@ -141,7 +139,7 @@ export async function apply(input, config = {}, startupOptions = {}) {
141
139
  await registerLspRuntime(ctx, startup.settings.lsp, getSettings);
142
140
  lifetime.signal.throwIfAborted();
143
141
  const installed = new WeakSet();
144
- admission.activate(async (agent, candidate, phase) => {
142
+ admission.activate(async (agent, candidate) => {
145
143
  candidate.subagentRuntime = () => runtimeAdmissionView(ctx);
146
144
  const scope = agent.ctx;
147
145
  if (startup.settings.modules.deepwork.enabled) {
@@ -149,14 +147,14 @@ export async function apply(input, config = {}, startupOptions = {}) {
149
147
  registerDeepworkPrompt(scope, controller, candidate, { section: startup.profile.section ?? startup.global.section }, agent, admission.lifetime.signal);
150
148
  }
151
149
  if (installed.has(agent)) {
152
- if (phase !== "history-setup" && startup.settings.modules.deepwork.enabled && ctx.get("subagents") !== undefined)
150
+ if (startup.settings.modules.deepwork.enabled && ctx.get("subagents") !== undefined)
153
151
  await registerHeadlessRoleTools(scope, controller, candidate, policy, nativeAdmission, agent);
154
152
  return;
155
153
  }
156
154
  registerModelRouting(scope, controller, candidate);
157
155
  registerSafetyGuards(scope, controller, candidate, policy);
158
156
  if (startup.settings.modules.deepwork.enabled) {
159
- if (phase !== "history-setup" && ctx.get("subagents") !== undefined)
157
+ if (ctx.get("subagents") !== undefined)
160
158
  await registerHeadlessRoleTools(scope, controller, candidate, policy, nativeAdmission, agent);
161
159
  }
162
160
  installed.add(agent);
@@ -168,19 +166,8 @@ export async function apply(input, config = {}, startupOptions = {}) {
168
166
  });
169
167
  ctx.inject(["typert"], scope => { registerConfigRpc(scope, deployment, startup.settings, () => profiles, startup.sources, mountedPermission); new DsmmProfilesHost(scope, profiles); registerRoleControlRpc(scope, nativeAdmission); });
170
168
  const permissions = createCorePermissionAuthority(ctx, { getSettings, rolePolicy: policy, signal: lifetime.signal });
171
- const history = ctx.inject(["typert", "agentLoop", "sessionController", "sessionPersistence", "agentPresets"], function mountHistoryContinuation(scope) {
172
- registerHistoryContinuationRpc(scope, new DsmmHistoryCandidates(scope, profiles, deployment, nativeAdmission), nativeAdmission);
173
- });
174
- if (["typert", "agentLoop", "sessionController", "sessionPersistence", "agentPresets"].every(key => ctx.get(key)))
175
- await history.await();
176
169
  const installPermissions = () => ctx.inject(["tools", ...(ctx.fiber.entry === undefined ? [] : ["settings"])], scope => {
177
170
  const installed = installCorePermissions(scope, deployment, permissions.authority, permissions.assertWritable);
178
- scope.inject(["approval", "typertGateway", "typert", "subagents"], temporaryScope => {
179
- if (typeof temporaryScope.approval.settlement !== "function" || typeof temporaryScope.typertGateway.registerApprovalPermits !== "function")
180
- return;
181
- const temporary = installTemporaryPermissions(temporaryScope, { core: permissions, roles: policy, rules: installed.rules });
182
- temporaryScope.effect(() => () => temporary.dispose(), "dsmm: temporary permissions");
183
- });
184
171
  const identity = Reflect.get(installed, symbols.original) ?? installed;
185
172
  scopeLifetime(scope, "dsmm: release permission projection", () => { if (permissionOwner === identity)
186
173
  permissionOwner = undefined; }, () => { permissionOwner = identity; });
@@ -22,7 +22,6 @@ export declare class NativeAdmission {
22
22
  private readonly pending;
23
23
  private readonly live;
24
24
  private readonly candidates;
25
- private readonly historyPrepared;
26
25
  private readonly agents;
27
26
  private readonly activations;
28
27
  private readonly activities;
@@ -42,8 +41,6 @@ export declare class NativeAdmission {
42
41
  constructor(ctx: Context, profiles: DsmmProfileRuntime, policy: DsmmRolePolicy);
43
42
  activate(install: NonNullable<NativeAdmission["install"]>): void;
44
43
  get isReady(): boolean;
45
- /** Install the current configuration before publication, without enrolling a historical Agent as blank. */
46
- prepareHistory(agent: Agent, admission: DsmmProfileAdmission, signal: AbortSignal): Promise<void>;
47
44
  isSelecting(agent: Agent): boolean;
48
45
  get(agent: Agent): DsmmProfileAdmission | undefined;
49
46
  configuration(agent: Agent): DsmmProfileAdmission;
@@ -20,7 +20,6 @@ export class NativeAdmission {
20
20
  pending = new Map();
21
21
  live = new WeakMap();
22
22
  candidates = new WeakMap();
23
- historyPrepared = new WeakMap();
24
23
  agents = new Set();
25
24
  activations = new Set();
26
25
  activities = new Map();
@@ -93,28 +92,6 @@ export class NativeAdmission {
93
92
  }
94
93
  activate(install) { this.lifetime.signal.throwIfAborted(); this.install = install; this.ready = true; }
95
94
  get isReady() { return this.ready && !this.lifetime.signal.aborted; }
96
- /** Install the current configuration before publication, without enrolling a historical Agent as blank. */
97
- async prepareHistory(agent, admission, signal) {
98
- const check = () => {
99
- signal.throwIfAborted();
100
- this.lifetime.signal.throwIfAborted();
101
- if (!this.isReady || !this.install || this.ctx.agents.get(agent.id) !== undefined || agent.session.header.origin === "subagent"
102
- || this.ctx.get("dsmmHistoryContinuation")?.admissionForCreated(agent) !== admission)
103
- throw new SubagentError("Exact unpublished history candidate required", "UNAUTHORIZED");
104
- };
105
- check();
106
- const prepared = { admission, preset: agent.ctx.get("agentPresets")?.composedPreset(agent.ctx), scopeParent: scopeParentOf(agent), dependencies: this.dependencies(agent) };
107
- if (prepared.dependencies.some(value => value === undefined))
108
- throw new SubagentError("History composition is unavailable", "UNAUTHORIZED");
109
- this.candidates.set(agent, admission);
110
- scopeLifetime(agent.ctx, "dsmm: release unpublished history configuration", () => { this.historyPrepared.delete(agent); this.candidates.delete(agent); });
111
- this.guardTools(agent);
112
- await this.install(agent, this.getter(agent), "history-setup");
113
- check();
114
- if (prepared.dependencies.some((value, index) => value !== this.dependencies(agent)[index]) || prepared.scopeParent !== scopeParentOf(agent))
115
- throw new SubagentError("History composition changed during setup", "UNAUTHORIZED");
116
- this.historyPrepared.set(agent, prepared);
117
- }
118
95
  isSelecting(agent) { return this.selecting.has(agent); }
119
96
  get(agent) { return this.live.get(agent)?.admission; }
120
97
  configuration(agent) {
@@ -277,7 +254,10 @@ export class NativeAdmission {
277
254
  const presets = this.ctx.get("agentPresets");
278
255
  if (!presets)
279
256
  throw new SubagentError("Native preset registry unavailable", "UNSUPPORTED_CAPABILITY");
280
- const lease = await presets.acquireScope(invocation.target);
257
+ // The child shares the parent's standing composition; its role is carried
258
+ // by the admitted invocation, not by an own registered preset.
259
+ const expectedPreset = presets.composedPreset(parent.ctx);
260
+ const lease = await presets.acquireScope(expectedPreset);
281
261
  try {
282
262
  exec.signal.throwIfAborted();
283
263
  this.assert(parent);
@@ -286,7 +266,7 @@ export class NativeAdmission {
286
266
  throw new SubagentError("Creation dependencies changed", "UNAUTHORIZED");
287
267
  const childId = SessionId(randomUUID()), signal = AbortSignal.any([exec.signal, this.lifetime.signal, this.agentLifetimes.get(parent).signal]);
288
268
  const admission = freezeSettings({ ...parentAdmission, settings: structuredClone(parentAdmission.settings) });
289
- const pending = Object.freeze({ childId, parent, parentAdmission, callId: exec.callId, invocation, admission, provider, presetScope: lease.key, signal, maxDepth, toolFilter });
269
+ const pending = Object.freeze({ childId, parent, parentAdmission, callId: exec.callId, invocation, admission, provider, expectedPreset, presetScope: lease.key, signal, maxDepth, toolFilter });
290
270
  this.pending.set(childId, pending);
291
271
  const revoke = () => { if (this.pending.get(childId) === pending)
292
272
  this.pending.delete(childId); };
@@ -418,7 +398,7 @@ export class NativeAdmission {
418
398
  throw new SubagentError("Invalid native child header", "UNAUTHORIZED");
419
399
  if (pending) {
420
400
  this.check(pending);
421
- if (pending.parent !== parent || pending.parentAdmission !== parentAdmission || preset !== pending.invocation.target || agent.session.header.isSeeded
401
+ if (pending.parent !== parent || pending.parentAdmission !== parentAdmission || preset !== pending.expectedPreset || agent.session.header.isSeeded
422
402
  || scopeParentOf(agent) !== pending.presetScope)
423
403
  throw new SubagentError("Child does not match the pending invocation", "UNAUTHORIZED");
424
404
  if (pending.maxDepth !== undefined && delegationDepthOf(agent) > pending.maxDepth)
@@ -434,24 +414,12 @@ export class NativeAdmission {
434
414
  else {
435
415
  if (agent.session.header.origin === "subagent" || pending)
436
416
  throw new SubagentError("Missing exact parent", "UNAUTHORIZED");
437
- const history = source === "resume" ? this.ctx.get("dsmmHistoryContinuation")?.admissionForCreated(agent) : undefined;
438
- if (source === "resume") {
439
- const prepared = this.historyPrepared.get(agent);
440
- if (!history || prepared?.admission !== history || prepared.preset !== preset || prepared.scopeParent !== presetScope
441
- || prepared.dependencies.some((value, index) => value !== this.dependencies(agent)[index]))
442
- throw new SubagentError("History resume requires its exact prepared candidate", "UNAUTHORIZED");
443
- admission = history;
444
- this.policy.validateRootRole(agent, admission);
445
- }
446
- else {
447
- // A resume may have opened the native log, but cannot recover DSMM authorization.
448
- if ((source !== "startup" || agent.session.header.isSeeded) && (preset?.startsWith("dsmm-") || sessionEvents(agent.session).some(event => ["deepwork/mode", "dsmm/role-policy"].includes(event.type))))
449
- throw new SubagentError("DSMM cold recovery is unavailable", "UNAUTHORIZED");
450
- admission = await this.profiles.prepareRoot(agent, signal);
451
- this.policy.validateRootRole(agent, admission);
452
- if ((source !== "startup" || agent.session.header.isSeeded) && admission.settings.defaultActive)
453
- throw new SubagentError("Historical sessions are not automatically admitted to Deepwork", "UNAUTHORIZED");
454
- }
417
+ // A resumed session receives a fresh admission from the current deployment:
418
+ // its persisted history stays readable user intent, while no old
419
+ // authorization survives — delegation authority and child residency can
420
+ // never be reconstructed from a log.
421
+ admission = await this.profiles.prepareRoot(agent, signal);
422
+ this.policy.validateRootRole(agent, admission);
455
423
  }
456
424
  this.agentLifetimes.set(agent, new AbortController());
457
425
  scopeLifetime(agent.ctx, "dsmm: retire exact Agent work", () => { void this.retireAgent(agent).catch(() => { }); });
@@ -495,7 +463,6 @@ export class NativeAdmission {
495
463
  }
496
464
  finally {
497
465
  this.candidates.delete(agent);
498
- this.historyPrepared.delete(agent);
499
466
  }
500
467
  }
501
468
  }
@@ -1,8 +1,7 @@
1
1
  import * as Native from "@deepseek-ai/dsh-tool-fs-search";
2
2
  import { DsmmPermissionController } from "./permission-controller.js";
3
- import { temporaryFileToolScope } from "./permission-temporary-files.js";
4
3
  export { Config, inject, name } from "@deepseek-ai/dsh-tool-fs-search";
5
4
  export function apply(ctx, config) {
6
- return Native.apply(temporaryFileToolScope(DsmmPermissionController.toolScope(ctx, "fs-search"), "fs-search"), config);
5
+ return Native.apply(DsmmPermissionController.toolScope(ctx, "fs-search"), config);
7
6
  }
8
7
  //# sourceMappingURL=permission-fs-search.js.map
@@ -1,8 +1,7 @@
1
1
  import * as Native from "@deepseek-ai/dsh-tool-fs";
2
2
  import { DsmmPermissionController } from "./permission-controller.js";
3
- import { temporaryFileToolScope } from "./permission-temporary-files.js";
4
3
  export { Config, inject, name } from "@deepseek-ai/dsh-tool-fs";
5
4
  export function apply(ctx, config) {
6
- return Native.apply(temporaryFileToolScope(DsmmPermissionController.toolScope(ctx, "fs"), "fs"), config);
5
+ return Native.apply(DsmmPermissionController.toolScope(ctx, "fs"), config);
7
6
  }
8
7
  //# sourceMappingURL=permission-fs.js.map
@@ -1,8 +1,7 @@
1
1
  import * as Native from "@deepseek-ai/dsh-tool-web";
2
2
  import { DsmmPermissionController } from "./permission-controller.js";
3
- import { temporaryWebToolScope } from "./permission-temporary-web.js";
4
3
  export { Config, inject, name } from "@deepseek-ai/dsh-tool-web";
5
4
  export function apply(ctx, config) {
6
- return Native.apply(temporaryWebToolScope(DsmmPermissionController.toolScope(ctx, "web")), config);
5
+ return Native.apply(DsmmPermissionController.toolScope(ctx, "web"), config);
7
6
  }
8
7
  //# sourceMappingURL=permission-web.js.map
@@ -2,7 +2,7 @@ import { lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSy
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { isAbsolute, join, relative, sep } from "node:path";
4
4
  import { DSMM_ROLES, DSMM_ROLE_IDS, renderAgentCordis, renderPresetMetadata } from "./roles.js";
5
- import { isRoleEnabled } from "./settings.js";
5
+ import { isRoleEnabled, isRootRoleEnabled } from "./settings.js";
6
6
  import { enabledSkillNames } from "./skills.js";
7
7
  export const DSMM_MANAGED_PRESET_MARKER = ".dsmm-managed-preset";
8
8
  export const DSMM_MANAGED_PRESET_MARKER_VERSION = 1;
@@ -71,12 +71,12 @@ export function reconcileRolePresets({ root, settings, filesystem: filesystemOve
71
71
  };
72
72
  });
73
73
  for (const knownDirectory of knownDirectories) {
74
- if (settings.presets.materialize && isRoleEnabled(settings, knownDirectory.role.id) && knownDirectory.ownership === "foreign") {
74
+ if (settings.presets.materialize && isRootRoleEnabled(settings, knownDirectory.role.id) && knownDirectory.ownership === "foreign") {
75
75
  throw new Error(`dsmm preset directory is foreign and will not be claimed: ${knownDirectory.directory}`);
76
76
  }
77
77
  }
78
78
  for (const knownDirectory of knownDirectories) {
79
- if (settings.presets.materialize && isRoleEnabled(settings, knownDirectory.role.id)) {
79
+ if (settings.presets.materialize && isRootRoleEnabled(settings, knownDirectory.role.id)) {
80
80
  if (knownDirectory.ownership === "absent") {
81
81
  publishNewRoleDirectory(canonicalRoot, root, knownDirectory.role.id, settings, filesystem);
82
82
  }
@@ -1,5 +1,23 @@
1
1
  import type { DshContext } from "./dsh-types.js";
2
2
  import type { DsmmSettings } from "./settings.js";
3
- /** Declare roles to DSH 0.2's native registry; directories are not discovery inputs. */
4
- export declare function registerRolePresets(ctx: DshContext, getSettings: () => DsmmSettings): void | Promise<void>;
3
+ interface NativeScopedTools {
4
+ get(name: string, scope?: object): unknown;
5
+ restrict(filter: {
6
+ deny: string[];
7
+ }): () => void;
8
+ }
9
+ interface NativeAgent {
10
+ ctx: {
11
+ tools?: NativeScopedTools;
12
+ get?<T>(name: string): T | undefined;
13
+ };
14
+ id?: string;
15
+ }
16
+ /**
17
+ * Declare the selectable dispatcher composition to DSH 0.2's native registry;
18
+ * directories are not discovery inputs. `roleIdentity` reports the admitted
19
+ * delegation role of an Agent, whose composition is shared with its parent.
20
+ */
21
+ export declare function registerRolePresets(ctx: DshContext, getSettings: () => DsmmSettings, roleIdentity?: (agent: NativeAgent) => string | undefined): void | Promise<void>;
22
+ export {};
5
23
  //# sourceMappingURL=preset-registry.d.ts.map
@@ -1,19 +1,29 @@
1
1
  import { Context as NativeContext, getTraceable } from "@deepseek-ai/cordis";
2
2
  import { DSMM_ROLES, DSMM_ROLE_IDS, rolePluginRows } from "./roles.js";
3
3
  import { enabledSkillNames } from "./skills.js";
4
+ import { isRootRoleEnabled } from "./settings.js";
4
5
  import { allowedRoleChildren, readonlyRoleTool, roleFromToolName, READONLY_ROLE_DENIED_TOOLS } from "./role-policy.js";
5
6
  import { nativeStandingFullAccess } from "./permission-native-access.js";
6
7
  import { scopeParentOf } from "./native-scope.js";
7
- /** Declare roles to DSH 0.2's native registry; directories are not discovery inputs. */
8
- export function registerRolePresets(ctx, getSettings) {
8
+ /**
9
+ * Declare the selectable dispatcher composition to DSH 0.2's native registry;
10
+ * directories are not discovery inputs. `roleIdentity` reports the admitted
11
+ * delegation role of an Agent, whose composition is shared with its parent.
12
+ */
13
+ export function registerRolePresets(ctx, getSettings, roleIdentity) {
9
14
  const install = async (readyCtx) => {
10
15
  const registry = readyCtx.get?.("agentPresets")
11
16
  ?? readyCtx.agentPresets;
12
17
  if (registry === undefined)
13
18
  throw new Error("dsmm requires the native DSH agentPresets registry");
14
19
  const settings = getSettings();
15
- const enabled = DSMM_ROLE_IDS.filter((id) => settings.modules.deepwork.enabled && settings.roles[id]);
16
- const active = DSMM_ROLES.filter((role) => enabled.includes(role.id));
20
+ // Only the dispatcher is a user-selectable composition. Delegation targets
21
+ // share their parent's standing composition and carry their role entirely
22
+ // through the admitted invocation and per-Agent registrations.
23
+ // Only the dispatcher is a user-selectable composition. Delegation targets
24
+ // share their parent's standing composition and carry their role entirely
25
+ // through the admitted invocation and per-Agent registrations.
26
+ const active = DSMM_ROLES.filter((role) => isRootRoleEnabled(settings, role.id));
17
27
  const disposers = [];
18
28
  try {
19
29
  for (const role of active) {
@@ -24,16 +34,23 @@ export function registerRolePresets(ctx, getSettings) {
24
34
  order: role.order,
25
35
  // Profiles do not replace standing native compositions. Child routes
26
36
  // are admitted by the role provider from the parent's fixed snapshot.
27
- plugins: rolePluginRows(role, enabledSkillNames(settings), enabled)
37
+ plugins: rolePluginRows(role, enabledSkillNames(settings), DSMM_ROLE_IDS.filter((id) => settings.modules.deepwork.enabled && settings.roles[id]))
28
38
  }));
29
39
  }
30
- // A direct selection of a read-only preset must be restricted at the Agent
31
- // scope: preset-local fs registrations cannot be filtered within their own layer.
32
- // Blank Agents can switch presets without another agent/created event.
40
+ // A directly selected read-only preset and a delegated read-only child
41
+ // must both be restricted at the Agent scope: preset-local fs
42
+ // registrations cannot be filtered within their own layer. Delegation
43
+ // children share their parent's composition, so their role comes from
44
+ // the admitted invocation identity, not from composedPreset.
45
+ const roleOf = (agent) => roleIdentity?.(agent) ?? registry.composedPreset(agent.ctx);
46
+ const agents = readyCtx.get?.("agents")
47
+ ?? readyCtx.agents;
48
+ if (agents === undefined)
49
+ throw new Error("dsmm native preset restriction requires DSH Agent registry");
33
50
  const states = new WeakMap();
34
51
  const restrictedAgents = new Set();
35
52
  const denial = (agent, name) => {
36
- const role = registry.composedPreset(agent.ctx);
53
+ const role = roleOf(agent);
37
54
  if (!isReadonlyRole(role))
38
55
  return undefined;
39
56
  const target = roleFromToolName(name);
@@ -41,13 +58,23 @@ export function registerRolePresets(ctx, getSettings) {
41
58
  : allowedRoleChildren(role).includes(target) && settings.roles[target] ? undefined : "dsmm read-only role does not permit this delegation";
42
59
  };
43
60
  const reconcile = (agent) => {
44
- const selected = registry.composedPreset(agent.ctx);
61
+ const identityRole = roleIdentity?.(agent);
62
+ // A delegation child's identity is bound by native admission's created
63
+ // guard, which may still be in flight during this synchronous
64
+ // reconcile. A parented agent with no bound identity stays pending
65
+ // instead of concluding "not read-only" from a not-yet-bound role.
66
+ const agentId = agent.id;
67
+ const parented = agentId !== undefined && agents.list().some(other => other !== agent && agents.isOwnedBy(agentId, other));
68
+ const pendingIdentity = roleIdentity !== undefined && identityRole === undefined && parented;
69
+ const selected = pendingIdentity ? undefined : identityRole ?? registry.composedPreset(agent.ctx);
45
70
  const previous = states.get(agent);
46
71
  if (previous !== undefined && previous.role === selected && (previous.pending || !isReadonlyRole(selected) || previous.disposeRestriction !== undefined))
47
72
  return;
48
- states.set(agent, { role: selected, pending: true });
73
+ states.set(agent, { role: selected, pending: pendingIdentity || undefined });
49
74
  previous?.disposeRestriction?.();
50
75
  restrictedAgents.delete(agent);
76
+ if (pendingIdentity)
77
+ return;
51
78
  if (!isReadonlyRole(selected)) {
52
79
  states.set(agent, { role: selected });
53
80
  return;
@@ -63,9 +90,15 @@ export function registerRolePresets(ctx, getSettings) {
63
90
  if (tools?.restrict === undefined)
64
91
  throw new Error(`dsmm read-only role requires DSH tools restrict: ${selected}`);
65
92
  restrictedAgents.add(agent);
66
- // Only inherited tools are maskable; own-layer tools remain subject to runtime denial.
93
+ // A delegation child shares its parent's standing composition realm,
94
+ // where a realm-level restriction would also mask the writable
95
+ // parent. Such children are fenced per-Agent through the runtime
96
+ // denial above instead; schema masking applies only to a directly
97
+ // selected read-only composition with its own realm.
67
98
  const inheritedScope = scopeParentOf(agent);
68
- const disposeRestriction = tools.restrict({ deny: READONLY_ROLE_DENIED_TOOLS.filter(name => tools.get(name, inheritedScope) !== undefined) });
99
+ const sharedRealmChild = roleIdentity !== undefined && roleIdentity(agent) === selected;
100
+ const maskable = READONLY_ROLE_DENIED_TOOLS.filter(name => tools.get(name, inheritedScope) !== undefined);
101
+ const disposeRestriction = sharedRealmChild || maskable.length === 0 ? () => { } : tools.restrict({ deny: maskable });
69
102
  states.set(agent, { role: selected, disposeRestriction });
70
103
  }
71
104
  catch (error) {
@@ -74,10 +107,6 @@ export function registerRolePresets(ctx, getSettings) {
74
107
  throw error;
75
108
  }
76
109
  };
77
- const agents = readyCtx.get?.("agents")
78
- ?? readyCtx.agents;
79
- if (agents === undefined)
80
- throw new Error("dsmm native preset restriction requires DSH Agent registry");
81
110
  const onPreExecute = readyCtx.on?.("tools/pre-execute", async (execution, next) => {
82
111
  const agent = execution.agent;
83
112
  if (agent === undefined || agents.get(agent.id) !== agent)
@@ -38,7 +38,7 @@ const configFields = {
38
38
  deepseekV4ProMaxReasoningPresets: null, deepseekFlashMaxReasoningPresets: null,
39
39
  modules: { deepwork: { enabled: null } },
40
40
  skills: "skills", roles: "roles", roleRouting: "role-routing", runtimePolicy: { strategy: null, rateLimit },
41
- presets: { materialize: null, plannerRootEnabled: null, root: null }, subagents: { toolTopology: null, allowRouteOverride: null, enableRunInBackground: null, backgroundMode: null, maxDepth: null },
41
+ presets: { materialize: null, root: null }, subagents: { toolTopology: null, allowRouteOverride: null, enableRunInBackground: null, backgroundMode: null, maxDepth: null },
42
42
  workflow: { policy: null, strictGates: null, reviewCap: null, finalReviewPolicy: null },
43
43
  guards: { scope: null, shellCommandSafety: null, gitWriteGuard: null, toolOutputTruncation: { enabled: null, maxInlineBytes: null }, planFormatValidation: null, questionLabelHelper: { enabled: null, maxLabelChars: null }, todoDisciplineHelper: null },
44
44
  runtimeRecovery: { enabled: null, retryOnStatusCodes: [null], retryOnCodes: [null], fallbackRoutes: [route], maxFallbackAttempts: null, idleContinuation: { enabled: null, maxContinuations: null, prompt: null } },
@@ -413,9 +413,7 @@ function readOnlySettingsData(value) {
413
413
  fail("private environment");
414
414
  }
415
415
  if (settings.presets !== undefined) {
416
- const presets = object(settings.presets, ["materialize"], ["root", "plannerRootEnabled"]);
417
- if (Object.hasOwn(presets, "plannerRootEnabled"))
418
- boolean(presets.plannerRootEnabled, "presets.plannerRootEnabled");
416
+ const presets = object(settings.presets, ["materialize"], ["root"]);
419
417
  if (presets.root !== undefined && presets.root !== "<configured>")
420
418
  fail("private directory");
421
419
  }
@@ -53,7 +53,7 @@ export class DsmmRolePolicy {
53
53
  this.assertLive(agent);
54
54
  this.assertLive(parent);
55
55
  this.assertDelegation(parent, invocation.target);
56
- if (!this.agents().isOwnedBy(agent.id, parent) || agent.session.header?.parentSession !== parent.id || this.selected(agent) !== invocation.target)
56
+ if (!this.agents().isOwnedBy(agent.id, parent) || agent.session.header?.parentSession !== parent.id || this.selected(agent) !== this.selected(parent))
57
57
  throw new SubagentError("Child lineage or composition mismatch", "UNAUTHORIZED");
58
58
  if (maximum !== undefined && delegationDepthOf(agent) > maximum)
59
59
  throw new SubagentError("Delegation depth exceeded", "UNAUTHORIZED");
@@ -70,7 +70,7 @@ export class DsmmRolePolicy {
70
70
  const settings = this.getSettings(agent), identity = liveIdentities.get(agent), selected = this.selected(agent);
71
71
  if (identity?.child) {
72
72
  this.assertLive(identity.parent);
73
- if (!this.agents().isOwnedBy(agent.id, identity.parent) || selected !== identity.role)
73
+ if (!this.agents().isOwnedBy(agent.id, identity.parent) || selected !== this.selected(identity.parent))
74
74
  throw new SubagentError("Child admission no longer matches composition", "UNAUTHORIZED");
75
75
  }
76
76
  else if (agent.session.header?.origin !== "subagent")
@@ -188,7 +188,8 @@ function registerRoleTool(agent, agentCtx, tools, entry, getSettings, policy, ad
188
188
  return admission.duringCall(parent, exec.signal, async (signal) => {
189
189
  const invocation = await resolveRoleInvocation(parent, role.id, current, signal, { ...(args.level === undefined ? {} : { level: args.level }), ...(args.route === undefined ? {} : { route: args.route }) });
190
190
  const capturedProvider = provider;
191
- const request = { parent, agentPreset: role.id, prompt: [{ type: "text", text: args.prompt }],
191
+ const parentComposition = parent.ctx.get?.("agentPresets")?.composedPreset(parent.ctx);
192
+ const request = { parent, ...(parentComposition === undefined ? {} : { agentPreset: parentComposition }), prompt: [{ type: "text", text: args.prompt }],
192
193
  agentOptions: invocationAgentOptions(invocation), maxDepth: subagents.resolveMaxDepth(current.subagents.maxDepth) };
193
194
  const assertCurrent = () => {
194
195
  if (policy.assertDelegation(parent, role.id).epoch !== admitted.epoch)
package/lib/roles.d.ts CHANGED
@@ -2,6 +2,8 @@ import type { DsmmSkillName } from "./skills.js";
2
2
  import type { DsmmRoleRouting } from "./settings.js";
3
3
  export declare const DSMM_ROLE_IDS: readonly ["dsmm-orchestrator", "dsmm-planner", "dsmm-plan-critic", "dsmm-builder", "dsmm-reviewer", "dsmm-oracle", "dsmm-oracle-2nd", "dsmm-creative", "dsmm-code-search", "dsmm-doc-search", "dsmm-clarifier", "dsmm-media-reader", "dsmm-frontend", "dsmm-hard-reasoning", "dsmm-research", "dsmm-quick", "dsmm-coding", "dsmm-normal-task", "dsmm-complex", "dsmm-deep", "dsmm-documenting", "dsmm-cross-cutting"];
4
4
  export type DsmmRoleId = (typeof DSMM_ROLE_IDS)[number];
5
+ /** The one user-selectable composition; every other role is an internal delegation target. */
6
+ export declare const DSMM_DISPATCHER_ROLE: DsmmRoleId;
5
7
  export type DsmmRoleMode = "primary" | "all" | "subagent";
6
8
  export type DsmmDelegationGroup = "primary-coordinator" | "utility-leaf" | "read-only-workflow" | "standard-workflow" | "local-coordinator";
7
9
  export interface DsmmRoleDefinition {
package/lib/roles.js CHANGED
@@ -8,6 +8,8 @@ export const DSMM_ROLE_IDS = [
8
8
  "dsmm-coding", "dsmm-normal-task", "dsmm-complex", "dsmm-deep",
9
9
  "dsmm-documenting", "dsmm-cross-cutting"
10
10
  ];
11
+ /** The one user-selectable composition; every other role is an internal delegation target. */
12
+ export const DSMM_DISPATCHER_ROLE = "dsmm-orchestrator";
11
13
  // Generated source catalog is checked against the exact literal ID inventory.
12
14
  // It carries no OCMM provider/model default and requires only package assets.
13
15
  export const DSMM_ROLES = SOURCE_ROLE_CATALOG.map((row) => ({
package/lib/settings.d.ts CHANGED
@@ -36,8 +36,6 @@ export interface DsmmWorkflowSettings {
36
36
  }
37
37
  export interface DsmmPresetSettings {
38
38
  materialize: boolean;
39
- /** Startup-pinned root exposure only; workflow Planner delegation stays enabled. */
40
- plannerRootEnabled: boolean;
41
39
  root?: string;
42
40
  }
43
41
  export interface DsmmSubagentSettings {
@@ -238,7 +236,7 @@ export declare function validateLocale(value: unknown, field?: string): asserts
238
236
  export declare function normalizeLevelOverride(value: unknown, field?: string): DsmmLevelOverride;
239
237
  export declare function resolveRoleRouting(input: DsmmRoleRouting | undefined): DsmmRoleRouting;
240
238
  export declare function isRoleEnabled(settings: DsmmSettings, role: DsmmRoleId): boolean;
241
- /** Native standing-root availability is independent of child role enablement. */
239
+ /** Only the dispatcher is a selectable standing root; every other role stays an internal delegation target. */
242
240
  export declare function isRootRoleEnabled(settings: DsmmSettings, id: DsmmRoleId): boolean;
243
241
  export declare function resolveGuardSettings(config: DsmmPluginConfig["guards"]): DsmmGuardSettings;
244
242
  export declare function registerSettings(ctx: DshContext, config?: DsmmPluginConfig, options?: RegisterSettingsOptions): () => DsmmSettings;
package/lib/settings.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import Schema from "@deepseek-ai/schemastery";
2
2
  import { DEFAULT_DSMM_LSP_SETTINGS, resolveLspSettings } from "./lsp.js";
3
- import { DSMM_ROLES, DSMM_ROLE_IDS, isRootRole } from "./roles.js";
3
+ import { DSMM_DISPATCHER_ROLE, DSMM_ROLES, DSMM_ROLE_IDS } from "./roles.js";
4
4
  import { DSMM_SKILL_NAMES } from "./skills.js";
5
5
  import { DEFAULT_DSMM_RUNTIME_POLICY, DSMM_RATE_LIMIT_BOUNDS, normalizeRateLimitOverrides, normalizeRoutingStrategy, normalizeRuntimePolicy, resolveRoleRuntimePolicy } from "./routing-policy.js";
6
6
  import { DEPRECATED_DSMM_FIELDS, DsmmConfigValidationError, safeDiagnosticField } from "./profile-diagnostics.js";
@@ -23,8 +23,7 @@ export const DEFAULT_DSMM_SETTINGS = {
23
23
  roleRouting: {},
24
24
  runtimePolicy: DEFAULT_DSMM_RUNTIME_POLICY,
25
25
  presets: {
26
- materialize: false,
27
- plannerRootEnabled: false
26
+ materialize: false
28
27
  },
29
28
  subagents: { enableRunInBackground: false, backgroundMode: "one-shot", toolTopology: "per-role", allowRouteOverride: false },
30
29
  workflow: {
@@ -117,7 +116,6 @@ const ROLE_ROUTING_VALIDATION_SCHEMA = Schema.transform(Schema.any(), (input) =>
117
116
  });
118
117
  const PRESETS_SCHEMA = Schema.object({
119
118
  materialize: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.presets.materialize),
120
- plannerRootEnabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.presets.plannerRootEnabled),
121
119
  root: Schema.string()
122
120
  });
123
121
  const SUBAGENTS_SCHEMA = Schema.object({
@@ -649,18 +647,15 @@ function normalizeExplicitRoute(value) {
649
647
  export function isRoleEnabled(settings, role) {
650
648
  return settings.roles[role];
651
649
  }
652
- /** Native standing-root availability is independent of child role enablement. */
650
+ /** Only the dispatcher is a selectable standing root; every other role stays an internal delegation target. */
653
651
  export function isRootRoleEnabled(settings, id) {
654
- const role = DSMM_ROLES.find(role => role.id === id);
655
- return settings.modules.deepwork.enabled && settings.roles[id] && isRootRole(role)
656
- && (id !== "dsmm-planner" || settings.presets.plannerRootEnabled);
652
+ return id === DSMM_DISPATCHER_ROLE && settings.modules.deepwork.enabled && settings.roles[id];
657
653
  }
658
654
  function resolvePresetSettings(config) {
659
655
  if (config !== undefined)
660
656
  validateShape(config, PRESETS_SCHEMA, ["presets"]);
661
657
  return {
662
658
  materialize: config?.materialize ?? DEFAULT_DSMM_SETTINGS.presets.materialize,
663
- plannerRootEnabled: config?.plannerRootEnabled ?? DEFAULT_DSMM_SETTINGS.presets.plannerRootEnabled,
664
659
  ...(config?.root === undefined ? {} : { root: config.root })
665
660
  };
666
661
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsmm/dsmm",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "DeepSeek Harness deepwork mode bundle for ocmm-style agentic workflows.",
5
5
  "author": "Hugefiver",
6
6
  "license": "LicenseRef-AAAPL",
@@ -26,10 +26,6 @@
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
- },
33
29
  "./managed-settings": {
34
30
  "types": "./lib/managed-settings.d.ts",
35
31
  "default": "./lib/managed-settings.js"