@dsmm/dsmm 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +8 -10
  2. package/cordis.patch.yml +14 -0
  3. package/docs/agent-presets.md +4 -4
  4. package/docs/compatibility.md +19 -24
  5. package/docs/deferred-native-approval-risk.md +2 -2
  6. package/docs/model-routing.md +3 -3
  7. package/docs/profiles.md +1 -1
  8. package/docs/releasing.md +46 -6
  9. package/docs/settings-status.md +2 -2
  10. package/lib/agent-registry.d.ts +36 -0
  11. package/lib/agent-registry.js +75 -0
  12. package/lib/child-admission.d.ts +0 -2
  13. package/lib/child-admission.js +13 -24
  14. package/lib/child-capture.d.ts +5 -1
  15. package/lib/child-capture.js +7 -5
  16. package/lib/client/children-locales.d.ts +13 -13
  17. package/lib/client/deployment-controller.js +1 -1
  18. package/lib/client.js +3 -3
  19. package/lib/delivery-authority.d.ts +18 -3
  20. package/lib/delivery-authority.js +149 -12
  21. package/lib/index.d.ts +2 -2
  22. package/lib/index.js +13 -26
  23. package/lib/native-child-evidence.d.ts +1 -3
  24. package/lib/native-child-evidence.js +0 -29
  25. package/lib/permission-rpc.js +3 -3
  26. package/lib/profile-rpc.js +6 -4
  27. package/lib/profile-store.js +2 -2
  28. package/lib/role-control-rpc.js +12 -8
  29. package/lib/role-invocation.d.ts +1 -1
  30. package/lib/role-policy.d.ts +1 -4
  31. package/lib/role-policy.js +24 -41
  32. package/lib/role-providers.d.ts +1 -1
  33. package/lib/role-providers.js +15 -55
  34. package/lib/role-runs.d.ts +17 -14
  35. package/lib/role-runs.js +45 -14
  36. package/lib/role-subagents.js +16 -6
  37. package/lib/runtime-integration.d.ts +4 -35
  38. package/lib/runtime-integration.js +38 -120
  39. package/lib/session-persistence.d.ts +2 -1
  40. package/lib/session-persistence.js +1 -1
  41. package/lib/session-scope.js +4 -1
  42. package/lib/subagent-runtime.d.ts +19 -7
  43. package/lib/subagent-runtime.js +141 -15
  44. package/package.json +110 -100
  45. package/lib/legacy-child-policy.d.ts +0 -51
  46. package/lib/legacy-child-policy.js +0 -123
  47. package/lib/legacy-read-composition.d.ts +0 -20
  48. package/lib/legacy-read-composition.js +0 -144
  49. package/lib/legacy-read-contracts.d.ts +0 -157
  50. package/lib/legacy-read-contracts.js +0 -39
  51. package/lib/legacy-read-host.d.ts +0 -19
  52. package/lib/legacy-read-host.js +0 -67
  53. package/lib/legacy-read-integration.d.ts +0 -121
  54. package/lib/legacy-read-integration.js +0 -522
  55. package/lib/legacy-read-proxy.d.ts +0 -26
  56. package/lib/legacy-read-proxy.js +0 -237
  57. package/scripts/cold-profile-composition.mjs +0 -329
  58. package/scripts/cold-profile-sources.mjs +0 -238
  59. package/scripts/migrate-cold-profile.mjs +0 -315
  60. package/scripts/repair-session-log.mjs +0 -476
  61. package/scripts/session-repair-native-verifier.mjs +0 -367
package/lib/index.js CHANGED
@@ -24,8 +24,7 @@ import { agentForScope } from "./native-scope.js";
24
24
  import { resolveSelectedAgentPreset, sessionEvents } from "./session-scope.js";
25
25
  import { projectDsmmModules } from "./modules.js";
26
26
  import { scopeLifetime } from "./delivery-authority.js";
27
- import { admittedAgentContext, classifyDsmmAgent, integrateSubagentRuntime, managedAgentContext, publicProfileRuntime, registerRoleControlContribution, registerRuntimeGuidance, runtimeAdmissionView } from "./runtime-integration.js";
28
- import { LegacyReadUnavailable } from "./legacy-read-contracts.js";
27
+ import { admittedAgentContext, assertSupportedHostStartup, classifyDsmmAgent, integrateSubagentRuntime, managedAgentContext, publicProfileRuntime, registerRoleControlContribution, registerRuntimeGuidance, runtimeAdmissionView } from "./runtime-integration.js";
29
28
  import { createCorePermissionAuthority } from "./core-permission-authority.js";
30
29
  import { nativeStandingFullAccess } from "./permission-native-access.js";
31
30
  import { installCorePermissions } from "./core-permissions.js";
@@ -56,25 +55,17 @@ export { DsmmDeploymentConfig, parseGlobalConfig, editGlobalConfig } from "./dep
56
55
  export { DSMM_MODULE_DESCRIPTORS, deepworkEnabled, projectDeepworkModule } from "./modules.js";
57
56
  export { DEEPWORK_MODE_EVENT, DeepworkModeController, hasOpenTurn, isDeepworkActive } from "./state.js";
58
57
  export { DsmmNativeLlmRuntime } from "./llm-runtime.js";
59
- /** Experimental Host collaborators are programmatic only; serialized settings cannot authenticate them. */
58
+ /** The current Host composition does not accept compatibility adapters. */
60
59
  export function createDsmmHostPlugin(startup) {
61
- if (startup.experimentalLegacyRead !== undefined) {
62
- const host = startup.experimentalLegacyRead.startup;
63
- if (host === null || typeof host !== "object" || [host.captureClosedComposition, host.resolveReadBindings, host.acquireCallContext,
64
- host.reportAuditFault, host.reportRetirementFault, host.revoke].some(callback => typeof callback !== "function"))
65
- throw new DsmmProfileError("unavailable", "Legacy read startup requires actual Host composition, FS, turn and audit collaborators.");
66
- }
67
- return { name, Config, inject: startup.experimentalLegacyRead === undefined ? inject : [...inject, "subagents"],
60
+ assertSupportedHostStartup(startup);
61
+ return { name, Config, inject,
68
62
  apply(ctx, config = {}) { return apply(ctx, config, startup); } };
69
63
  }
70
64
  export function apply(ctx, config = {}, hostStartup = {}) {
65
+ assertSupportedHostStartup(hostStartup);
71
66
  if (!Context.is(ctx)) {
72
- if (hostStartup.experimentalLegacyRead !== undefined)
73
- throw new DsmmProfileError("unavailable", "Legacy read requires a real cold native Host.");
74
67
  return applyConfigured(ctx, config, undefined, undefined, hostStartup);
75
68
  }
76
- if (hostStartup.experimentalLegacyRead !== undefined && (ctx.get("dsmmProfileRuntime") !== undefined || runtimeAdmissionView(ctx).deliveryFenceReady))
77
- throw new LegacyReadUnavailable("lifetime-unavailable");
78
69
  const deployment = new DsmmDeploymentConfig(ctx, config);
79
70
  return deployment.readDesired().then((startup) => applyConfigured(ctx, config, deployment, startup, hostStartup));
80
71
  }
@@ -245,8 +236,6 @@ function applyRuntime(ctx, config, deployment, startup, hostStartup = {}) {
245
236
  await presets;
246
237
  const integration = await integrateSubagentRuntime(hostCtx, getReadySettings(), rolePolicy, () => runtime, hostStartup);
247
238
  lifetime.signal.throwIfAborted();
248
- if (hostStartup.experimentalLegacyRead !== undefined && integration === undefined)
249
- throw new DsmmProfileError("unavailable", "Legacy read requires the explicit cold DSMM runtime composition.");
250
239
  if (startupMounted && hostCtx.get("subagents") !== undefined) {
251
240
  // The actual registry exists now. Alias registration is synchronous and
252
241
  // does not wait on a policy-ready provider, avoiding a startup cycle.
@@ -257,7 +246,7 @@ function applyRuntime(ctx, config, deployment, startup, hostStartup = {}) {
257
246
  getMountedPermission, deferRetainedChildren: integration !== undefined,
258
247
  ...(startup === undefined ? {} : { startup }), ...(deployment === undefined ? {} : { readDesired: () => deployment.readDesired() }),
259
248
  ...(integration === undefined ? {} : { childAuthority: integration.bridge.authority, childAuthorityOwner: integration.owner,
260
- childAdmission: integration.bridge.childAdmission, childCapturePersistence: hostCtx.get("sessionPersistence") === undefined ? "resident" : "durable" }),
249
+ childAdmission: integration.bridge.childAdmission, childCapturePersistence: "durable" }),
261
250
  validateRootRole: (agent, admission) => {
262
251
  // Candidate identity validation precedes publication. Its mode check
263
252
  // must not recursively demand the not-yet-bound live admission.
@@ -280,11 +269,6 @@ function applyRuntime(ctx, config, deployment, startup, hostStartup = {}) {
280
269
  completedRootAdmissions.add(agent);
281
270
  }
282
271
  rootAdmissionsInitialized = true;
283
- if (integration?.legacyRead !== undefined) {
284
- profileCtx.on?.("agent/created", async ({ agent, signal }) => {
285
- await integration.afterChildAdmission(agent, signal);
286
- }, { global: true });
287
- }
288
272
  },
289
273
  subagentCapabilities: {
290
274
  backgroundJobs: profileCtx.get?.("jobs") !== undefined,
@@ -298,7 +282,7 @@ function applyRuntime(ctx, config, deployment, startup, hostStartup = {}) {
298
282
  const admittedCtx = admittedAgentContext(profileCtx, manager);
299
283
  install(admittedCtx, getBoundSettings);
300
284
  registerRuntimeGuidance(admittedCtx, getBoundSettings, rolePolicy);
301
- const published = publicProfileRuntime(manager, hostCtx, integration?.legacyRead === undefined ? undefined : integration);
285
+ const published = publicProfileRuntime(manager, hostCtx);
302
286
  profileCtx.provide?.("dsmmProfileRuntime", published);
303
287
  if (integration !== undefined) {
304
288
  hostCtx.provide("dsmmRuntimeIntegration", integration);
@@ -319,7 +303,6 @@ function applyRuntime(ctx, config, deployment, startup, hostStartup = {}) {
319
303
  if (parent !== undefined && classifyDsmmAgent(agent) === "native" && !controlledParent(parent))
320
304
  return;
321
305
  await manager.completeAdmission(agent, signal, startup);
322
- await integration.afterChildAdmission(agent, signal);
323
306
  };
324
307
  for (const agent of retainedChildren)
325
308
  if (hostCtx.agents.get(agent.id) === agent)
@@ -332,7 +315,7 @@ function applyRuntime(ctx, config, deployment, startup, hostStartup = {}) {
332
315
  await registerHeadlessRoleTools(admittedAgentContext(profileCtx, manager), controller, getBoundSettings, rolePolicy, integration);
333
316
  signal.throwIfAborted();
334
317
  lifetime.signal.throwIfAborted();
335
- hostCtx.inject(["typert"], scope => integration.registerControls(scope));
318
+ hostCtx.inject(["typert", "subagents"], scope => integration.registerControls(scope));
336
319
  }, AbortSignal.any([lifetime.signal, continuation.signal]));
337
320
  });
338
321
  }
@@ -367,11 +350,15 @@ function applyRuntime(ctx, config, deployment, startup, hostStartup = {}) {
367
350
  if (ctx.get !== undefined) {
368
351
  ctx.on?.("system-prompt/assemble", async (_assembly, options, next) => {
369
352
  const agent = agentForScope(ctx, options.scope);
370
- if (agent !== undefined)
353
+ if (agent !== undefined) {
354
+ await native?.get("dsmmRuntimeIntegration")?.runtime.authority.waitForPromotion(agent, options.signal);
371
355
  rolePolicy.assertModuleAdmission(agent);
356
+ assertDwDelivery(agent);
357
+ }
372
358
  return next();
373
359
  }, { prepend: true, global: true });
374
360
  ctx.on?.("agent/request", async (frame, next) => {
361
+ await native?.get("dsmmRuntimeIntegration")?.runtime.authority.waitForPromotion(frame.agent, frame.signal);
375
362
  rolePolicy.assertModuleAdmission(frame.agent);
376
363
  assertDwDelivery(frame.agent);
377
364
  return next();
@@ -2,7 +2,7 @@ import type { Context } from "@deepseek-ai/cordis";
2
2
  import type { SessionEvent, SessionHeader, SessionId as NativeSessionId } from "@deepseek-ai/dsh-session";
3
3
  import type { ContinuableSubagentDescriptorData } from "@deepseek-ai/dsh-subagent";
4
4
  import type { ParentAdmissionTicket } from "./delivery-authority.js";
5
- import type { ChildAdmissionCapture, LegacyChildEvidence } from "./child-capture.js";
5
+ import type { ChildAdmissionCapture } from "./child-capture.js";
6
6
  import type { DsmmProfileAdmission } from "./settings.js";
7
7
  import type { DsmmRoleId } from "./roles.js";
8
8
  /** Host-only borrowed cut returned by the PUBLIC SessionQueryEngine.observeSession service. */
@@ -34,9 +34,7 @@ export declare class NativeChildEvidenceReader {
34
34
  private readonly history;
35
35
  constructor(ctx: Context, assertTicket: (ticket: ParentAdmissionTicket<DsmmProfileAdmission>) => void, history: NativeChildHistory);
36
36
  read(ticket: ParentAdmissionTicket<DsmmProfileAdmission>, childId: string, callerSignal: AbortSignal): Promise<NativeChildFacts>;
37
- legacy(ticket: ParentAdmissionTicket<DsmmProfileAdmission>, childId: string, signal: AbortSignal): Promise<LegacyChildEvidence>;
38
37
  }
39
- export declare function legacyEvidenceFromNativeFacts(facts: NativeChildFacts): LegacyChildEvidence;
40
38
  /** Capture evidence must agree with the child's establishing descriptor, not current parent routing. */
41
39
  export declare function assertNativeChildCapture(capture: ChildAdmissionCapture, facts: NativeChildFacts): void;
42
40
  //# sourceMappingURL=native-child-evidence.d.ts.map
@@ -1,7 +1,6 @@
1
1
  import { symbols } from "@deepseek-ai/cordis";
2
2
  import { SessionId } from "@deepseek-ai/dsh-session";
3
3
  import { foldSubagentDescriptor, SubagentError } from "@deepseek-ai/dsh-subagent";
4
- import { parseLegacyChildEvidence } from "./child-capture.js";
5
4
  import { freezeSettings } from "./settings.js";
6
5
  import { isDsmmRoleId } from "./roles.js";
7
6
  function unauthorized() { throw new SubagentError("Child history does not prove its direct native identity", "UNAUTHORIZED"); }
@@ -46,9 +45,6 @@ export class NativeChildEvidenceReader {
46
45
  observation[Symbol.dispose]();
47
46
  }
48
47
  }
49
- async legacy(ticket, childId, signal) {
50
- return legacyEvidenceFromNativeFacts(await this.read(ticket, childId, signal));
51
- }
52
48
  }
53
49
  function readFacts(parent, childId, observation) {
54
50
  const header = observation.header;
@@ -92,31 +88,6 @@ function hasRequestBudget(event) {
92
88
  return false;
93
89
  return event.data.header.config.maxTokens !== undefined;
94
90
  }
95
- export function legacyEvidenceFromNativeFacts(facts) {
96
- const provenFields = ["lineage", "role", "route"];
97
- if (facts.descriptor.toolFilter !== undefined)
98
- provenFields.push("tool-filter");
99
- if (facts.active !== undefined)
100
- provenFields.push("active-intent");
101
- if (facts.requestBudgetObserved)
102
- provenFields.push("max-tokens");
103
- const limitations = [
104
- ...["profile-pin", "admission-epoch", "invocation-level", "locale", "tool-topology"].map(field => ({ field, code: "missing-evidence", effect: "display-only" })),
105
- ...["runtime-policy", "modules", "roles", "read-only", "route-override", "max-depth", "guards", "git-write", "shell", "delegation"].map(field => ({ field, code: "missing-evidence", effect: "capability-denied" })),
106
- { field: "max-tokens", code: "not-persisted", effect: "native-default" },
107
- { field: "output-schema", code: "unverified", effect: "capability-denied" },
108
- ];
109
- if (facts.descriptor.toolFilter === undefined)
110
- limitations.push({ field: "tool-filter", code: "missing-evidence", effect: "capability-denied" });
111
- if (facts.active === undefined)
112
- limitations.push({ field: "active-intent", code: "missing-evidence", effect: "display-only" });
113
- return parseLegacyChildEvidence({ version: 1, mode: "legacy-conservative", childSessionId: facts.childSessionId,
114
- parentSessionId: facts.parentSessionId, role: facts.role, depth: facts.depth,
115
- route: { provider: facts.descriptor.agentProvider, model: facts.descriptor.agentModel,
116
- ...(facts.descriptor.agentReasoningEffort === undefined ? {} : { reasoningEffort: facts.descriptor.agentReasoningEffort }) },
117
- ...(facts.descriptor.toolFilter === undefined ? {} : { toolFilter: facts.descriptor.toolFilter }),
118
- ...(facts.active === undefined ? {} : { active: facts.active }), provenFields, limitations });
119
- }
120
91
  /** Capture evidence must agree with the child's establishing descriptor, not current parent routing. */
121
92
  export function assertNativeChildCapture(capture, facts) {
122
93
  const route = capture.invocation.initialRoute, descriptor = facts.descriptor;
@@ -63,17 +63,17 @@ let DsmmPermissionsHost = (() => {
63
63
  return Promise.resolve().then(() => {
64
64
  const id = SessionId(parsePermissionSessionId(sessionId));
65
65
  const invocation = this.ctx.invocation, connection = this.ctx.get("connection");
66
- if (invocation?.peer === undefined || connection === undefined || invocation.peer !== connection.operator)
66
+ if (invocation?.peer === undefined || connection === undefined || invocation.peer !== connection.browserPeer)
67
67
  throw new PermissionRefusal("not-owned");
68
68
  const peer = invocation.peer, owner = permissionOriginal(connection), agents = this.ctx.get("agents"), root = agents?.get(id);
69
69
  if (root === undefined)
70
70
  throw new PermissionRefusal("not-owned");
71
- const signal = AbortSignal.any([invocation.signal, this.lifetime.signal]);
71
+ const signal = AbortSignal.any([invocation.signal, peer.signal, this.lifetime.signal]);
72
72
  const check = () => {
73
73
  const current = this.ctx.get("connection"), registry = this.ctx.get("agents");
74
74
  if (signal.aborted)
75
75
  throw new PermissionRefusal("cancelled");
76
- if (current === undefined || permissionOriginal(current) !== owner || current.operator !== peer || registry?.get(id) !== root
76
+ if (current === undefined || permissionOriginal(current) !== owner || current.browserPeer !== peer || registry?.get(id) !== root
77
77
  || root.id !== sessionId || root.session.id !== sessionId || root.session.header.origin === "subagent" || !registry.roots().includes(root)
78
78
  || registry.list().some(agent => agent !== root && registry.isOwnedBy(id, agent)))
79
79
  throw new PermissionRefusal("not-owned");
@@ -83,6 +83,7 @@ let DsmmProfilesHost = (() => {
83
83
  throw new RemoteError("dsmm-profiles/peer-required", "Use Deepwork Profiles through the native Host connection.", {});
84
84
  }
85
85
  invocation.signal.throwIfAborted();
86
+ invocation.peer.signal.throwIfAborted();
86
87
  try {
87
88
  return await operation();
88
89
  }
@@ -99,19 +100,19 @@ let DsmmProfilesHost = (() => {
99
100
  return this.invoke(async () => {
100
101
  const invocation = this.ctx.invocation;
101
102
  const connection = this.ctx.get("connection");
102
- if (connection === undefined || connection.operator !== invocation.peer) {
103
+ if (connection === undefined || connection.browserPeer !== invocation.peer) {
103
104
  throw new DsmmProfileError("not-owned", "The native Host operator must own this session profile operation.");
104
105
  }
105
106
  // Cordis rebinds Service projections for each accessing Context. Its
106
107
  // public original symbol identifies the exact native authority owner.
107
108
  const connectionOwner = Reflect.get(connection, symbols.original) ?? connection;
108
- const signal = AbortSignal.any([invocation.signal, this.lifetime.signal]);
109
+ const signal = AbortSignal.any([invocation.signal, connection.browserPeer.signal, this.lifetime.signal]);
109
110
  const checkAuthority = () => {
110
111
  if (signal.aborted)
111
112
  throw new DsmmProfileError("cancelled", "The session profile operation was cancelled; no late selection is allowed.");
112
113
  const currentConnection = this.ctx.get("connection");
113
114
  const currentOwner = currentConnection === undefined ? undefined : Reflect.get(currentConnection, symbols.original) ?? currentConnection;
114
- if (currentOwner !== connectionOwner || currentConnection?.operator !== invocation.peer) {
115
+ if (currentOwner !== connectionOwner || currentConnection?.browserPeer !== invocation.peer) {
115
116
  throw new DsmmProfileError("not-owned", "The native Host operator connection is no longer active.");
116
117
  }
117
118
  const agents = this.ctx.get("agents");
@@ -200,11 +201,12 @@ export function assertLocalSettingsOperator(ctx) {
200
201
  const connection = ctx.get("connection");
201
202
  const webServer = ctx.get("webServer");
202
203
  const settings = ctx.get("settings");
203
- if (invocation?.peer === undefined || connection?.operator !== invocation.peer
204
+ if (invocation?.peer === undefined || connection?.browserPeer !== invocation.peer
204
205
  || webServer?.host !== "127.0.0.1" || settings?.writable !== true) {
205
206
  throw new DsmmProfileError("not-owned", "Global deployment edits require the authenticated operator of a local writable native Host.");
206
207
  }
207
208
  invocation.signal.throwIfAborted();
209
+ invocation.peer.signal.throwIfAborted();
208
210
  }
209
211
  let DsmmConfigHost = (() => {
210
212
  let _classSuper = TypertRemoteService;
@@ -384,8 +384,8 @@ export class ProfileStore {
384
384
  async createChildAdmission(input, assertCurrent) {
385
385
  this.assertWritable();
386
386
  const capture = parseChildAdmissionCapture(input);
387
- if (capture.version !== 2)
388
- throw new DsmmProfileError("validation", "New child admissions require capture v2.");
387
+ if (capture.version !== 3)
388
+ throw new DsmmProfileError("validation", "New child admissions require capture v3.");
389
389
  const revision = digest(Buffer.from(JSON.stringify(capture), "utf8"));
390
390
  const bytes = Buffer.from(`${JSON.stringify({ version: 1, revision, capture })}\n`, "utf8");
391
391
  if (bytes.length > MAX_PROFILE_BYTES)
@@ -129,19 +129,19 @@ let DsmmChildrenHost = (() => {
129
129
  async scoped(sessionId, readOnly, operation) {
130
130
  const invocation = this.ctx.invocation;
131
131
  const connection = this.ctx.get("connection");
132
- if (invocation?.peer === undefined || connection === undefined || connection.operator !== invocation.peer)
132
+ if (invocation?.peer === undefined || connection === undefined || connection.browserPeer !== invocation.peer)
133
133
  throw new ControlRefusal("not-owned");
134
134
  const connectionOwner = original(connection);
135
135
  const runtime = this.collaborators.runtime;
136
136
  if (!runtime.authority.view().deliveryFenceReady)
137
137
  throw new ControlRefusal("unavailable", undefined, "delivery-fence-unavailable");
138
138
  const browserSignal = runtime.authority.acquireBrowserSignal(this.ctx);
139
- const initialSignal = AbortSignal.any([invocation.signal, browserSignal, this.lifetime.signal]);
139
+ const initialSignal = AbortSignal.any([invocation.signal, invocation.peer.signal, browserSignal, this.lifetime.signal]);
140
140
  const checkConnection = () => {
141
141
  if (initialSignal.aborted)
142
142
  throw new ControlRefusal("cancelled");
143
143
  const current = this.ctx.get("connection");
144
- if (current === undefined || original(current) !== connectionOwner || current.operator !== invocation.peer)
144
+ if (current === undefined || original(current) !== connectionOwner || current.browserPeer !== invocation.peer)
145
145
  throw new ControlRefusal("not-owned");
146
146
  const bound = this.ctx.get("subagents");
147
147
  if (bound === undefined || original(bound) !== original(runtime))
@@ -213,18 +213,19 @@ let DsmmChildrenHost = (() => {
213
213
  const inactive = this.ctx.get("agents")?.get(entry.id)?.status !== "running";
214
214
  const observation = direct ? await this.collaborators.observeChild(scope.ticket, entry, scope.signal) : undefined;
215
215
  scope.check();
216
- const reason = !direct ? "not-direct-child" : entry.mode === "one-shot" ? "one-shot" : "unknown-mode";
216
+ const projected = observation?.invocation === undefined ? undefined : parseDsmmInvocationView(observation.invocation);
217
+ const mode = entry.mode === "external" ? "unknown" : entry.mode === "continuable" && projected?.mode === "one-shot" ? "one-shot" : entry.mode;
218
+ const reason = !direct ? "not-direct-child" : mode === "one-shot" ? "one-shot" : "unknown-mode";
217
219
  const global = this.capabilities(scope);
218
- const controls = entry.mode === "continuable" && observation !== undefined
220
+ const controls = mode === "continuable" && entry.mode === "continuable" && observation !== undefined
219
221
  ? { prompt: global.prompt.enabled ? observation.prompt : global.prompt, interrupt: global.interrupt.enabled ? observation.interrupt : global.interrupt }
220
222
  : { prompt: disabled(reason), interrupt: disabled(reason) };
221
- const projected = observation?.invocation === undefined ? undefined : parseDsmmInvocationView(observation.invocation);
222
223
  const routeComparison = observation?.routeComparison === undefined ? undefined : parseDsmmRoleRouteComparison(observation.routeComparison);
223
224
  if (projected?.childId !== undefined && projected.childId !== entry.id)
224
225
  throw new ControlRefusal("unavailable", "childSessionId");
225
226
  if (routeComparison !== undefined && routeComparison.childId !== entry.id)
226
227
  throw new ControlRefusal("unavailable", "childSessionId");
227
- return { id: entry.id, parentSessionId, mode: entry.mode, activity: inactive ? "inactive" : "running", readonly: !controls.prompt.enabled && !controls.interrupt.enabled,
228
+ return { id: entry.id, parentSessionId, mode, activity: inactive ? "inactive" : "running", readonly: !controls.prompt.enabled && !controls.interrupt.enabled,
228
229
  ...(entry.label === undefined ? {} : { label: boundedChildLabel(entry.label) }), controls,
229
230
  ...(projected === undefined ? {} : { invocation: { ...projected, childId: entry.id } }),
230
231
  ...(routeComparison === undefined ? {} : { routeComparison }),
@@ -329,7 +330,10 @@ let DsmmChildrenHost = (() => {
329
330
  throw new ControlRefusal("not-owned", "childSessionId");
330
331
  if (child.mode !== "continuable")
331
332
  throw new ControlRefusal("not-resumable", "childSessionId");
332
- return this.childView(scope, child);
333
+ const view = await this.childView(scope, child);
334
+ if (view.mode !== "continuable")
335
+ throw new ControlRefusal("not-resumable", "childSessionId");
336
+ return view;
333
337
  }
334
338
  prompt(sessionId, input) {
335
339
  return this.invoke(async () => {
@@ -29,9 +29,9 @@ export declare function capturedOriginalRoleInvocation(agent: DshAgent): ChildAd
29
29
  export declare function resolveRoleInvocation(parent: Agent, target: DsmmRoleId, settings: DsmmSettings, signal: AbortSignal, options?: DsmmInvocationOptions, nativeOptions?: AgentOptions): 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
+ childId?: string | undefined;
32
33
  jobId?: string | undefined;
33
34
  runId?: string | undefined;
34
- childId?: string | undefined;
35
35
  role: "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";
36
36
  label: string;
37
37
  level: DsmmInvocationLevel;
@@ -5,8 +5,6 @@ import type { DsmmRoleId } from "./roles.js";
5
5
  import type { DsmmProfileAdmission, DsmmSettings, DsmmSettingsGetter } from "./settings.js";
6
6
  import type { ChildAdmissionCompletion, ChildRoleAdmissionCandidate, ParentAdmissionTicket } from "./child-admission-contract.js";
7
7
  import type { ChildAdmissionEvidence, PreparedChildAdmission } from "./child-capture.js";
8
- import type { LegacyCapabilityCollaborators } from "./legacy-child-policy.js";
9
- export { createConservativeLegacyAdmission as conservativeLegacyAdmission } from "./legacy-child-policy.js";
10
8
  import type { ResolvedRoleInvocation } from "./role-invocation.js";
11
9
  import type { DeepworkModeController } from "./state.js";
12
10
  export interface DsmmRoleIdentity {
@@ -35,8 +33,6 @@ export interface RoleAdmissionCollaborators {
35
33
  resolveOriginalEvidence(ticket: ParentAdmissionTicket, childId: string, signal: AbortSignal): Promise<ChildAdmissionEvidence>;
36
34
  nativeSubstrate: DsmmSettings;
37
35
  revokeParent(agent: DshAgent, reason: string): void;
38
- /** Shared C2b native-capability audit; this does not grant parent tool permissions. */
39
- classifyLegacyTool?: LegacyCapabilityCollaborators["classifyTool"];
40
36
  }
41
37
  /** Identity admission only: native services retain every run, inbox and retry lifecycle. */
42
38
  export declare class DsmmRolePolicy {
@@ -62,6 +58,7 @@ export declare class DsmmRolePolicy {
62
58
  /** Used at A's single awaited completion point; old original epochs remain valid facts. */
63
59
  validatePreparedRole(agent: DshAgent, parent: DshAgent, candidate: ChildRoleAdmissionCandidate): void;
64
60
  assertChildDelivery(ticket: ParentAdmissionTicket, childId: string, raw: ChildAdmissionEvidence): void;
61
+ assertChildExecution(ticket: ParentAdmissionTicket, childId: string, raw: ChildAdmissionEvidence): void;
65
62
  private readOnly;
66
63
  private agents;
67
64
  assertLive(agent: DshAgent): void;
@@ -1,12 +1,11 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { currentManagedCreation } from "./agent-registry.js";
2
3
  import { delegationDepthOf, foldSubagentDescriptor, SubagentError } from "@deepseek-ai/dsh-subagent";
3
4
  import { symbols } from "@deepseek-ai/cordis";
4
5
  import { DSMM_ROLE_IDS, DSMM_ROLES, allowedRoleChildren, isDsmmRoleId } from "./roles.js";
5
6
  export { allowedRoleChildren } from "./roles.js";
6
7
  import { copyJson, freezeSettings, isRootRoleEnabled } from "./settings.js";
7
- import { admissionFromChildCapture, parseChildAdmissionCapture, parseLegacyChildEvidence } from "./child-capture.js";
8
- import { createConservativeLegacyAdmission } from "./legacy-child-policy.js";
9
- export { createConservativeLegacyAdmission as conservativeLegacyAdmission } from "./legacy-child-policy.js";
8
+ import { admissionFromChildCapture, parseChildAdmissionCapture } from "./child-capture.js";
10
9
  import { bindRoleInvocation, currentRoleInvocation, resolveRoleInvocation } from "./role-invocation.js";
11
10
  import { captureRoleRuntimePolicy, resolveRoleRuntimePolicy } from "./routing-policy.js";
12
11
  import { childOwnedSessionEvents, resolveEffectiveDsmmRole, resolveSelectedAgentPreset } from "./session-scope.js";
@@ -120,8 +119,9 @@ export class DsmmRolePolicy {
120
119
  const evidence = await this.collaborators.resolveOriginalEvidence(ticket, agent.id, signal);
121
120
  signal.throwIfAborted();
122
121
  ticket.signal.throwIfAborted();
123
- return { evidence, admission: "mode" in evidence ? createConservativeLegacyAdmission(evidence, ticket.admission, this.collaborators.nativeSubstrate)
124
- : admissionFromChildCapture(evidence, this.collaborators.nativeSubstrate), creation: false };
122
+ if ("mode" in evidence || evidence.version !== 3)
123
+ throw new SubagentError("Only current child capture V3 is supported", "UNSUPPORTED_CAPABILITY");
124
+ return { evidence, admission: admissionFromChildCapture(evidence, this.collaborators.nativeSubstrate), creation: false };
125
125
  }
126
126
  if ((call?.parent === parent ? call.epoch : pending.epoch) !== ticket.parentEpoch)
127
127
  throw new SubagentError("Child invocation parent epoch changed", "UNAUTHORIZED");
@@ -139,7 +139,8 @@ export class DsmmRolePolicy {
139
139
  primary: { ...route, ...(invocation.exactEffort && reasoningEffort !== undefined ? { reasoningEffort } : {}) },
140
140
  fallbackRoutes: (invocation.requestedPolicy ?? invocation.policy).fallbackRoutes.map(route => ({ ...route })) };
141
141
  }
142
- const capture = parseChildAdmissionCapture({ version: 2, childSessionId: agent.id, parentSessionId: parent.id, role: invocation.target,
142
+ const capture = parseChildAdmissionCapture({ version: 3, childSessionId: agent.id, parentSessionId: parent.id, role: invocation.target,
143
+ delegationMode: currentManagedCreation()?.delegationMode,
143
144
  modelParameterPolicy: invocation.modelParameterPolicy ?? resolvedModelParameterPolicy(ticket.admission),
144
145
  profilePin: ticket.admission.profile, originalAdmissionEpoch: ticket.parentEpoch,
145
146
  invocation: { level: invocation.effectiveLevel, initialRoute: invocation.initialRoute, requestedRoute: invocation.requestedRoute ?? invocation.initialRoute,
@@ -156,7 +157,11 @@ export class DsmmRolePolicy {
156
157
  validatePreparedRole(agent, parent, candidate) {
157
158
  this.assertLive(agent);
158
159
  this.assertLive(parent);
159
- const evidence = "mode" in candidate.evidence ? parseLegacyChildEvidence(candidate.evidence) : parseChildAdmissionCapture(candidate.evidence);
160
+ if ("mode" in candidate.evidence || candidate.evidence.version !== 3)
161
+ throw new SubagentError("Only current child capture V3 is supported", "UNSUPPORTED_CAPABILITY");
162
+ const evidence = parseChildAdmissionCapture(candidate.evidence);
163
+ if (!candidate.creation && !candidate.retained && !("mode" in evidence) && evidence.version === 3 && evidence.delegationMode === "one-shot")
164
+ throw new SubagentError("One-shot child cannot acquire a new residency", "UNAUTHORIZED");
160
165
  if (evidence.childSessionId !== agent.id || evidence.parentSessionId !== parent.id || agent.session.header.parentSession !== parent.id || !this.agents().isOwnedBy(agent.id, parent))
161
166
  throw new SubagentError("Child evidence does not match exact native lineage", "UNAUTHORIZED");
162
167
  this.assertDelegation(parent, evidence.role);
@@ -169,7 +174,7 @@ export class DsmmRolePolicy {
169
174
  if (!original.settings.modules.deepwork.enabled || !original.settings.roles[evidence.role])
170
175
  throw new SubagentError("Original child role/module is disabled", "UNAUTHORIZED");
171
176
  if (descriptor?.mode === "continuable") {
172
- const route = "mode" in evidence ? evidence.route : evidence.invocation.initialRoute;
177
+ const route = evidence.invocation.initialRoute;
173
178
  if (descriptor.agentProvider !== undefined && descriptor.agentProvider !== route.provider || descriptor.agentModel !== undefined && descriptor.agentModel !== route.model
174
179
  || descriptor.agentReasoningEffort !== undefined && descriptor.agentReasoningEffort !== route.reasoningEffort)
175
180
  throw new SubagentError("Original route does not match native descriptor provenance", "UNAUTHORIZED");
@@ -183,17 +188,7 @@ export class DsmmRolePolicy {
183
188
  let invocation;
184
189
  let filter;
185
190
  let readOnly;
186
- if ("mode" in evidence) {
187
- if (evidence.depth !== delegationDepthOf(agent))
188
- throw new SubagentError("Legacy depth evidence does not match its physical native lineage", "UNAUTHORIZED");
189
- const safe = evidence.toolFilter?.allow?.filter(name => readonlyRoleTool(name, original.settings) && !["interrupt_agent", "job_kill"].includes(name)) ?? [];
190
- filter = inheritToolFilter({ allow: safe }, evidence.toolFilter);
191
- readOnly = true;
192
- invocation = freezeSettings({ target: evidence.role, effectiveLevel: "normal", routeSource: "inherited", initialRoute: evidence.route,
193
- candidates: [evidence.route], exactEffort: evidence.route.reasoningEffort !== undefined, modelParameterPolicy: resolvedModelParameterPolicy(original), effortSource: "native",
194
- policy: { ...resolveRoleRuntimePolicy(original.settings, evidence.role), primary: evidence.route, fallbackRoutes: [] } });
195
- }
196
- else {
191
+ {
197
192
  if (candidate.creation && JSON.stringify(this.preparedCaptures.get(agent)) !== JSON.stringify(evidence))
198
193
  throw new SubagentError("Fresh capture does not match its trusted prepared invocation and ceiling", "UNAUTHORIZED");
199
194
  if (original.epoch !== evidence.originalAdmissionEpoch || candidate.creation && this.getSettings.admission?.(parent).epoch !== evidence.originalAdmissionEpoch)
@@ -225,7 +220,7 @@ export class DsmmRolePolicy {
225
220
  const identity = Object.freeze({ role: evidence.role, child: true, parent, epoch: original.epoch, readOnly,
226
221
  ...(filter === undefined ? {} : { toolFilter: inheritToolFilter(undefined, filter) }) });
227
222
  this.captureIdentity(agent, identity, original);
228
- bindRoleInvocation(agent, invocation, "mode" in evidence ? undefined : evidence);
223
+ bindRoleInvocation(agent, invocation, evidence);
229
224
  captureRoleRuntimePolicy(original.settings, evidence.role, invocation.policy);
230
225
  const call = this.calls.getStore();
231
226
  if (candidate.creation && call?.parent === parent && call.role === evidence.role)
@@ -234,11 +229,18 @@ export class DsmmRolePolicy {
234
229
  this.preparedCaptures.delete(agent);
235
230
  }
236
231
  assertChildDelivery(ticket, childId, raw) {
232
+ if (!("mode" in raw) && raw.version === 3 && raw.delegationMode === "one-shot")
233
+ throw new SubagentError("One-shot children cannot resume", "UNAUTHORIZED");
234
+ this.assertChildExecution(ticket, childId, raw);
235
+ }
236
+ assertChildExecution(ticket, childId, raw) {
237
237
  ticket.signal.throwIfAborted();
238
238
  this.assertLive(ticket.parent);
239
239
  if (this.getSettings.admission?.(ticket.parent) !== ticket.admission || ticket.admission.epoch !== ticket.parentEpoch)
240
240
  throw new SubagentError("Delivery parent admission changed", "UNAUTHORIZED");
241
- const evidence = "mode" in raw ? parseLegacyChildEvidence(raw) : parseChildAdmissionCapture(raw);
241
+ if ("mode" in raw || raw.version !== 3)
242
+ throw new SubagentError("Only current child capture V3 is supported", "UNSUPPORTED_CAPABILITY");
243
+ const evidence = parseChildAdmissionCapture(raw);
242
244
  if (evidence.childSessionId !== childId || evidence.parentSessionId !== ticket.parent.id)
243
245
  throw new SubagentError("Delivery evidence is not this direct child", "UNAUTHORIZED");
244
246
  this.assertDelegation(ticket.parent, evidence.role);
@@ -554,25 +556,6 @@ export class DsmmRolePolicy {
554
556
  if (identity.toolFilter?.allow !== undefined && !identity.toolFilter.allow.includes(name) && name !== "structured_output"
555
557
  || identity.toolFilter?.deny?.includes(name))
556
558
  return "DSMM child native toolFilter does not permit this tool";
557
- if (name === "send_message" && liveIdentities.get(agent)?.admission?.childEvidence?.mode === "legacy-conservative") {
558
- const realm = tools ?? agent.ctx.get("tools"), parent = identity.parent;
559
- const capability = realm === undefined ? undefined : this.collaborators?.classifyLegacyTool?.(name, realm, agent);
560
- if (parent === undefined || realm === undefined || capability?.kind !== "child-report" || realm.get(name, agent) !== capability.definition)
561
- return "DSMM legacy report requires its audited native capability";
562
- try {
563
- this.assertLive(parent);
564
- this.assertDelegation(parent, identity.role);
565
- if (execution !== undefined) {
566
- capability.assertArguments(execution.arguments);
567
- const args = execution.arguments;
568
- if (args === null || typeof args !== "object" || args.agent_id !== parent.id)
569
- return "DSMM legacy report destination must be this exact direct parent";
570
- }
571
- }
572
- catch {
573
- return "DSMM legacy report arguments or current parent authority are not admitted";
574
- }
575
- }
576
559
  if (readonly && !readonlyRoleTool(name, settings))
577
560
  return "DSMM read-only role does not permit this tool";
578
561
  if (identity.role === undefined)
@@ -592,7 +575,7 @@ export class DsmmRolePolicy {
592
575
  const agents = this.agents();
593
576
  if (agents.get(agent.id) !== agent)
594
577
  throw new Error("DSMM Agent was detached before continuable descendants drained");
595
- await native.get("subagents")?.drainContinuableDescendants([agent]);
578
+ await native.get("subagents")?.drainDescendants([agent]);
596
579
  liveIdentities.delete(agent);
597
580
  toolIdentities.delete(agent);
598
581
  });
@@ -12,6 +12,6 @@ export interface DsmmSubagentRegistry {
12
12
  }
13
13
  export declare function roleFromProviderName(provider: string): DsmmRoleId | undefined;
14
14
  export declare function roleAgentOptions(parent: Agent, role: DsmmRoleId, settings: DsmmSettings, signal: AbortSignal, explicit?: AgentOptions): Promise<AgentOptions | undefined>;
15
- /** Only the native outer start owns descriptors, capability admission and returned runs. */
15
+ /** The native manager owns descriptors, capability admission and activations. */
16
16
  export declare function registerRoleProviders(ctx: DshContext, getSettings: DsmmSettingsGetter, getDeploymentSettings?: DsmmSettingsGetter, policy?: DsmmRolePolicy): void;
17
17
  //# sourceMappingURL=role-providers.d.ts.map