@dsmm/dsmm 0.3.25 → 0.3.27

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 (54) hide show
  1. package/README.md +21 -8
  2. package/docs/agent-presets.md +7 -7
  3. package/docs/agent-teams.md +27 -0
  4. package/docs/compatibility.md +7 -5
  5. package/docs/lsp.md +10 -12
  6. package/docs/maintenance.md +29 -0
  7. package/docs/roadmap.md +25 -9
  8. package/docs/runtime-recovery.md +3 -3
  9. package/docs/testing.md +2 -1
  10. package/docs/web-fetch-fakeip.md +1 -1
  11. package/dsh-plugin.json +1 -1
  12. package/lib/client/NativeToolView-data.d.ts +8 -0
  13. package/lib/client/NativeToolView-data.js +19 -0
  14. package/lib/client/NativeToolView.d.ts +19 -0
  15. package/lib/client/NativeToolView.js +46 -0
  16. package/lib/client/RoleToolView-data.js +1 -1
  17. package/lib/client/RoleToolView-locales.d.ts +7 -0
  18. package/lib/client/RoleToolView-locales.js +6 -0
  19. package/lib/client/RoleToolView.js +2 -0
  20. package/lib/client/children-locales.d.ts +5 -5
  21. package/lib/client/controller.js +20 -0
  22. package/lib/client.js +347 -186
  23. package/lib/core-permission-authority.js +19 -8
  24. package/lib/deployment-permission-rules.js +2 -1
  25. package/lib/dsh-types.d.ts +2 -2
  26. package/lib/mode.js +2 -2
  27. package/lib/native-admission.d.ts +8 -0
  28. package/lib/native-admission.js +285 -48
  29. package/lib/native-ownership.d.ts +20 -0
  30. package/lib/native-ownership.js +92 -0
  31. package/lib/native-subagents.d.ts +21 -0
  32. package/lib/native-subagents.js +31 -0
  33. package/lib/permission-rpc.js +3 -2
  34. package/lib/preset-registry.js +2 -1
  35. package/lib/profile-rpc.js +4 -3
  36. package/lib/profile-runtime.d.ts +1 -1
  37. package/lib/profile-runtime.js +2 -1
  38. package/lib/prompts.d.ts +2 -0
  39. package/lib/prompts.js +14 -8
  40. package/lib/role-control-remote.js +19 -8
  41. package/lib/role-control-rpc.js +11 -9
  42. package/lib/role-control-types.d.ts +18 -5
  43. package/lib/role-identity.js +3 -19
  44. package/lib/role-invocation.d.ts +1 -1
  45. package/lib/role-policy.d.ts +11 -3
  46. package/lib/role-policy.js +64 -23
  47. package/lib/role-subagents.js +26 -6
  48. package/lib/session-metadata.d.ts +27 -1
  49. package/lib/session-metadata.js +46 -0
  50. package/lib/session-scope.d.ts +1 -1
  51. package/lib/session-scope.js +2 -2
  52. package/package.json +116 -114
  53. package/prompts/source/deepwork/general.md +19 -0
  54. package/prompts/source/shared/native-teams.md +11 -0
@@ -1,3 +1,4 @@
1
+ import { nativeRoots, nativeIsOwnedBy, nativeTreeRoot } from "./native-ownership.js";
1
2
  import { randomUUID } from "node:crypto";
2
3
  import { scopeLifetime } from "./lifetime.js";
3
4
  import { PermissionRefusal, permissionOriginal } from "./permission-control.js";
@@ -23,13 +24,23 @@ export function createCorePermissionAuthority(ctx, options) {
23
24
  throw new PermissionRefusal("cancelled");
24
25
  return ctx.get("dsmmNativeAdmission");
25
26
  };
26
- /** Registry ownership is direct, so each physical edge must be walked independently. */
27
+ /** Tree admission has a live root owner; older registries retain direct-edge ancestry. */
27
28
  const ancestry = (exec) => {
28
29
  const agents = ctx.get("agents"), agent = exec.agent;
29
30
  const realmAgents = agent?.ctx.get("agents");
30
31
  if (agents === undefined || agent === undefined || agents.get(agent.id) !== agent
31
32
  || realmAgents === undefined || permissionOriginal(realmAgents) !== permissionOriginal(agents))
32
33
  throw new PermissionRefusal("not-owned");
34
+ const root = nativeTreeRoot(agents, agent);
35
+ if (root !== undefined) {
36
+ const host = integration();
37
+ if (host?.owns(agent)) {
38
+ host.assert(agent);
39
+ if (agent !== root && rolePolicy.identity(agent).owner !== root)
40
+ throw new PermissionRefusal("not-owned");
41
+ }
42
+ return agent === root ? [root] : [agent, root];
43
+ }
33
44
  const chain = [], seen = new Set(), residents = agents.list();
34
45
  let current = agent;
35
46
  while (true) {
@@ -37,9 +48,9 @@ export function createCorePermissionAuthority(ctx, options) {
37
48
  throw new PermissionRefusal("not-owned");
38
49
  seen.add(current);
39
50
  chain.push(current);
40
- const owners = residents.filter(candidate => candidate !== current && agents.isOwnedBy(current.id, candidate));
51
+ const owners = residents.filter(candidate => candidate !== current && nativeIsOwnedBy(agents, current.id, candidate));
41
52
  if (owners.length === 0) {
42
- if (!agents.roots().includes(current) || current.session.header.origin === "subagent")
53
+ if (!nativeRoots(agents).includes(current) || current.session.header.origin === "subagent")
43
54
  throw new PermissionRefusal("not-owned");
44
55
  return chain;
45
56
  }
@@ -83,7 +94,7 @@ export function createCorePermissionAuthority(ctx, options) {
83
94
  const identity = native ? undefined : rolePolicy.identity(structural);
84
95
  const tools = agent.ctx.get("tools"), approval = agent.ctx.get("approval");
85
96
  if (tools === undefined || !native && (identity?.epoch !== admission.epoch
86
- || (parent === undefined ? agent !== root || identity.child : identity.parent !== parent.authority.agent || !identity.child)))
97
+ || (parent === undefined ? agent !== root || identity.child : (identity.owner ?? identity.parent) !== parent.authority.agent || !identity.child)))
87
98
  throw new PermissionRefusal("not-owned");
88
99
  const nativePolicy = approval === undefined ? undefined : approval.overrideOf(agent.session) ?? approval.config.policy;
89
100
  if (approval !== undefined && nativePolicy !== "ask" && nativePolicy !== "never")
@@ -96,7 +107,7 @@ export function createCorePermissionAuthority(ctx, options) {
96
107
  const facts = [root, agent.ctx, parent?.authority.signal, permissionOriginal(ctx.get("dsmmCoreLlmOwner")),
97
108
  permissionOriginal(ctx.get("dsmmProfileRuntime")), permissionOriginal(tools),
98
109
  approval === undefined ? undefined : permissionOriginal(approval),
99
- admission?.settings, native, captured, identity?.role, identity?.child, identity?.parent, identity?.epoch, identity?.readOnly,
110
+ admission?.settings, native, captured, identity?.role, identity?.child, identity?.owner ?? identity?.parent, identity?.creatorId, identity?.epoch, identity?.readOnly,
100
111
  JSON.stringify(identity?.toolFilter)];
101
112
  if (previous !== undefined && !previous.authority.signal.aborted && previous.integration === entry
102
113
  && previous.authority.owner === owner && previous.admission === admission && sameFacts(previous.facts, facts)) {
@@ -181,7 +192,7 @@ export function createCorePermissionAuthority(ctx, options) {
181
192
  rootCurrent(root, exec) {
182
193
  const host = integration(), chain = ancestry(exec);
183
194
  const agents = ctx.get("agents");
184
- if (chain.at(-1) !== root || agents?.get(root.id) !== root || !agents.roots().includes(root))
195
+ if (chain.at(-1) !== root || agents?.get(root.id) !== root || !nativeRoots(agents).includes(root))
185
196
  throw new PermissionRefusal("not-owned");
186
197
  const generation = local(host, root, root);
187
198
  if (root.ctx.get("approval") === undefined)
@@ -208,8 +219,8 @@ export function createCorePermissionAuthority(ctx, options) {
208
219
  throw new PermissionRefusal("cancelled");
209
220
  const agents = ctx.get("agents"), realmAgents = root.ctx.get("agents");
210
221
  if (agents === undefined || realmAgents === undefined || permissionOriginal(agents) !== permissionOriginal(realmAgents)
211
- || agents.get(root.id) !== root || root.session.id !== root.id || !agents.roots().includes(root)
212
- || root.session.header.origin === "subagent" || agents.list().some(agent => agent !== root && agents.isOwnedBy(root.id, agent)))
222
+ || agents.get(root.id) !== root || root.session.id !== root.id || !nativeRoots(agents).includes(root)
223
+ || root.session.header.origin === "subagent" || agents.list().some(agent => agent !== root && nativeIsOwnedBy(agents, root.id, agent)))
213
224
  throw new PermissionRefusal("not-owned");
214
225
  const seen = new Set();
215
226
  for (let fiber = root.ctx.fiber; !seen.has(fiber.ctx); fiber = fiber.parent.fiber) {
@@ -1,3 +1,4 @@
1
+ import { nativeRoots, nativeIsOwnedBy } from "./native-ownership.js";
1
2
  import { PermissionRefusal, permissionOriginal } from "./permission-control.js";
2
3
  import { applyPermissionRulesSave, importPermissionRules, operatorPermissionRulesSource, parsePermissionRules, parsePermissionRulesSave, PermissionRulesRuntimeSync } from "./permission-rules.js";
3
4
  import { copyJson, validateSparseConfig, validateNativeConfig } from "./settings.js";
@@ -119,7 +120,7 @@ export class DeploymentPermissionRules {
119
120
  this.lifetime.signal.throwIfAborted();
120
121
  const registry = this.ctx.agents;
121
122
  if (permissionOriginal(registry) !== this.registry || registry.get(root.id) !== root || root.session.id !== root.id || root.session.header.origin === "subagent"
122
- || !registry.roots().includes(root) || registry.list().some(owner => owner !== root && registry.isOwnedBy(root.id, owner)))
123
+ || !nativeRoots(registry).includes(root) || registry.list().some(owner => owner !== root && nativeIsOwnedBy(registry, root.id, owner)))
123
124
  throw new PermissionRefusal("not-owned");
124
125
  this.options.assertWritable(root);
125
126
  }
@@ -55,8 +55,8 @@ export interface DshAgentModel {
55
55
  export interface DshAgentsRegistry {
56
56
  get(id: string): DshAgent | undefined;
57
57
  list(): DshAgent[];
58
- roots(): DshAgent[];
59
- isOwnedBy(id: string, owner: DshAgent): boolean;
58
+ roots?(): DshAgent[];
59
+ isOwnedBy?(id: string, owner: DshAgent): boolean;
60
60
  }
61
61
  export interface DshAgentCreatedFrame {
62
62
  agent: DshAgent;
package/lib/mode.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getTraceable } from "@deepseek-ai/cordis";
2
2
  import { agentForScope, nativeAgentContext } from "./native-scope.js";
3
3
  import { buildDeepworkPrompt } from "./prompts.js";
4
- import { resolveEffectiveDsmmRole, resolveSelectedAgentPreset } from "./session-scope.js";
4
+ import { resolveAdmittedDsmmRole } from "./role-policy.js";
5
5
  const bindings = new WeakMap();
6
6
  function routeFromAgent(agent) {
7
7
  const header = agent.session.requestHeader?.();
@@ -31,7 +31,7 @@ export function registerDeepworkPrompt(readyCtx, controller, getSettings, config
31
31
  const settings = getSettings(agent);
32
32
  if (!settings.modules.deepwork.enabled || !controller.active(agent, settings.defaultActive))
33
33
  return "";
34
- return buildDeepworkPrompt(settings, { route: routeFromAgent(agent), selectedPreset: resolveSelectedAgentPreset(agent.session), roleId: resolveEffectiveDsmmRole(agent, settings, true) ?? null, overrideSection: config.section });
34
+ return buildDeepworkPrompt(settings, { route: routeFromAgent(agent), roleId: resolveAdmittedDsmmRole(agent, settings, true) ?? null, overrideSection: config.section });
35
35
  }
36
36
  });
37
37
  };
@@ -33,6 +33,7 @@ export declare class NativeAdmission {
33
33
  private readonly activities;
34
34
  private readonly calls;
35
35
  private readonly rebindings;
36
+ private readonly awaitingPublication;
36
37
  private readonly guardedTools;
37
38
  private readonly agentLifetimes;
38
39
  private readonly retirements;
@@ -47,6 +48,8 @@ export declare class NativeAdmission {
47
48
  private readonly ambiguousCallIds;
48
49
  private readonly observedCallTokens;
49
50
  private readonly observedCallChildren;
51
+ private readonly nativeToolObservations;
52
+ private readonly nativeToolExecution;
50
53
  private readonly observedCallRuns;
51
54
  private readonly callSubscribers;
52
55
  private readonly providerScopes;
@@ -68,11 +71,16 @@ export declare class NativeAdmission {
68
71
  private publishObservedCall;
69
72
  private publishObservedRemoval;
70
73
  private observedInvocation;
74
+ private awaitChildPublication;
75
+ private admitPublishedChild;
71
76
  private startObservedActivation;
72
77
  private endObservedActivation;
73
78
  private settleObservedActivation;
74
79
  private bindObservedChild;
75
80
  private observeCallRequestHeader;
81
+ private setObservedRoute;
82
+ private beginNativeToolObservation;
83
+ private finishNativeToolObservation;
76
84
  private finishObservedTool;
77
85
  private retireObservedParent;
78
86
  observeRoleCalls(parent: Agent, admission: DsmmProfileAdmission, signal: AbortSignal, check: () => void): AsyncIterable<RoleCallObservationFrame>;