@dsmm/dsmm 0.3.30 → 0.3.31
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.
- package/docs/compatibility.md +2 -2
- package/dsh-plugin.json +1 -1
- package/lib/agent-prompt-scope.d.ts +3 -2
- package/lib/agent-prompt-scope.js +11 -16
- package/lib/core-permission-authority.js +4 -0
- package/lib/host-llm.d.ts +5 -0
- package/lib/host-llm.js +9 -0
- package/lib/index.js +13 -16
- package/lib/live-pi-ai-owner.d.ts +1 -0
- package/lib/live-pi-ai-owner.js +2 -1
- package/lib/mode.d.ts +3 -2
- package/lib/mode.js +8 -12
- package/lib/model-routing.js +2 -2
- package/lib/native-admission.d.ts +2 -0
- package/lib/native-admission.js +80 -24
- package/lib/native-pi-ai-wire.js +2 -2
- package/lib/native-scope.d.ts +3 -3
- package/lib/native-scope.js +5 -6
- package/lib/preset-skills.d.ts +3 -2
- package/lib/preset-skills.js +12 -14
- package/lib/resident-root.d.ts +10 -0
- package/lib/resident-root.js +151 -0
- package/lib/role-identity.d.ts +2 -2
- package/lib/role-identity.js +1 -5
- package/lib/role-llm-runtime.d.ts +12 -2
- package/lib/role-llm-runtime.js +28 -18
- package/lib/role-llm.d.ts +2 -0
- package/lib/role-llm.js +1 -0
- package/lib/role-policy.d.ts +2 -0
- package/lib/role-policy.js +10 -10
- package/lib/role-routing.d.ts +1 -1
- package/lib/role-routing.js +4 -3
- package/lib/role-subagents.d.ts +2 -2
- package/lib/role-subagents.js +43 -63
- package/package.json +1 -1
package/lib/role-subagents.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { symbols } from "@deepseek-ai/cordis";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
@@ -9,15 +9,13 @@ import { DsmmRolePolicy, roleToolName } from "./role-policy.js";
|
|
|
9
9
|
import { roleProviderName } from "./role-providers.js";
|
|
10
10
|
import { capturedRoleInvocation, invocationAgentOptions, invocationView, resolveRoleInvocation } from "./role-invocation.js";
|
|
11
11
|
import { childOwnedSessionEvents } from "./session-scope.js";
|
|
12
|
-
import {
|
|
12
|
+
import { agentScopeService, nativeAgentContext, scopeParentOf } from "./native-scope.js";
|
|
13
13
|
import { roleRouteRuntimeState } from "./role-routing.js";
|
|
14
14
|
import { modelRouteFromCall } from "./role-llm.js";
|
|
15
15
|
import { buildDsmmDelegationGuidance, buildDsmmTeamGuidance } from "./prompts.js";
|
|
16
16
|
import { startNativeActivation, supportsNativeNames } from "./native-subagents.js";
|
|
17
17
|
// Conditional Team tools stay in their native layer: copying a definition would discard its `when` registration.
|
|
18
18
|
const hostControls = ["send_message", "interrupt_agent", "list_agents", "wait_agent", "exit_plan_mode", "ask_user_question", "todo_write", "job_output", "job_list", "job_kill"];
|
|
19
|
-
// Agent-owned policy realms survive a bundle reinstall; do not register another
|
|
20
|
-
// delegation/tools layer on the same retained live Agent.
|
|
21
19
|
const admittedRealms = new WeakMap();
|
|
22
20
|
const callableDefinitions = new WeakMap();
|
|
23
21
|
/** Keep native controls on the frozen startup substrate, not desired-save reconciliation. */
|
|
@@ -132,9 +130,9 @@ export function admittedCallableRoleInventory(agent, settings, policy, tools) {
|
|
|
132
130
|
return targets.length === 0 ? [] : [{ ...registered.entry, targets }];
|
|
133
131
|
});
|
|
134
132
|
}
|
|
135
|
-
function registerRoleTool(agent,
|
|
133
|
+
function registerRoleTool(agent, ctx, tools, entry, getSettings, policy, admission) {
|
|
136
134
|
const settings = getSettings(agent);
|
|
137
|
-
const subagents =
|
|
135
|
+
const subagents = ctx.get("subagents");
|
|
138
136
|
if (subagents === undefined)
|
|
139
137
|
throw new Error("DSMM role tools require native subagents");
|
|
140
138
|
const named = supportsNativeNames(subagents);
|
|
@@ -222,7 +220,7 @@ function registerRoleTool(agent, agentCtx, tools, entry, getSettings, policy, ad
|
|
|
222
220
|
pending.signal.throwIfAborted();
|
|
223
221
|
}
|
|
224
222
|
try {
|
|
225
|
-
const child =
|
|
223
|
+
const child = ctx.get("agents").get(activation.childId);
|
|
226
224
|
if (child === undefined)
|
|
227
225
|
throw new SubagentError("Native role activation has no live child", "UNAUTHORIZED");
|
|
228
226
|
await admission.ensure(child);
|
|
@@ -260,32 +258,30 @@ function registerRoleTool(agent, agentCtx, tools, entry, getSettings, policy, ad
|
|
|
260
258
|
return () => { callableDefinitions.delete(definition); dispose(); };
|
|
261
259
|
}
|
|
262
260
|
/** Published name retained; all native/headless Agents consume one admitted policy. */
|
|
263
|
-
export
|
|
264
|
-
const refresh = admittedRealms.get(
|
|
261
|
+
export function registerHeadlessRoleTools(ctx, controller, getSettings, policy, admission, agent) {
|
|
262
|
+
const refresh = admittedRealms.get(ctx);
|
|
265
263
|
if (refresh) {
|
|
266
264
|
refresh();
|
|
267
265
|
return;
|
|
268
266
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
const raw = agentCtx.get("agentPresets")?.serviceFor({ ctx: agentCtx }, "tools");
|
|
276
|
-
const tools = raw === undefined ? agentCtx.get("tools") : getTraceable(agentCtx, raw);
|
|
267
|
+
if (!getSettings(agent).modules.deepwork.enabled)
|
|
268
|
+
return;
|
|
269
|
+
policy.admit(agent);
|
|
270
|
+
const state = { owned: [], hostDefinitions: [], providers: [] };
|
|
271
|
+
const reconcile = () => {
|
|
272
|
+
const tools = agentScopeService(ctx, "tools");
|
|
277
273
|
if (tools === undefined)
|
|
278
274
|
throw new Error("DSMM role tools require native guard/restrict services");
|
|
279
275
|
const settings = getSettings(agent), identity = policy.identity(agent), targets = policy.targets(agent);
|
|
280
|
-
const prompt =
|
|
276
|
+
const prompt = agentScopeService(ctx, "systemPrompt");
|
|
281
277
|
const promptRealm = Reflect.get(prompt, symbols.original) ?? prompt;
|
|
282
278
|
if (state.promptRealm !== promptRealm) {
|
|
283
279
|
state.guidance?.();
|
|
284
|
-
state.guidance =
|
|
285
|
-
if (context.scope !== agent
|
|
280
|
+
state.guidance = prompt.section({ name: "dsmm:delegation", order: 49, text(context) {
|
|
281
|
+
if (context.scope !== agent)
|
|
286
282
|
return "";
|
|
287
|
-
const identity = policy.identity(agent), tools =
|
|
288
|
-
const teams =
|
|
283
|
+
const identity = policy.identity(agent), tools = state.tools, settings = getSettings(agent);
|
|
284
|
+
const teams = ctx.get?.("agentTeams");
|
|
289
285
|
const toolSet = context.toolSet;
|
|
290
286
|
const teamGuidance = teams?.isEnabled(agent) && toolSet !== undefined
|
|
291
287
|
? buildDsmmTeamGuidance([...toolSet.view(agent).keys()]) : "";
|
|
@@ -296,14 +292,14 @@ export async function registerHeadlessRoleTools(ctx, controller, getSettings, po
|
|
|
296
292
|
delegation: tools === undefined ? [] : admittedCallableRoleInventory(agent, settings, policy, tools),
|
|
297
293
|
...(captured === undefined ? {} : { invocation: roleInvocationObservation(captured, DSMM_ROLES.find(role => role.id === captured.target).name, "continuable", getSettings, agent, { childId: agent.id }) }),
|
|
298
294
|
runtimeAdmission: getSettings.subagentRuntime?.(), capabilities: { continuable: true, nativeChildDelivery: true,
|
|
299
|
-
nativeTree: typeof
|
|
300
|
-
...(
|
|
295
|
+
nativeTree: typeof ctx.get("subagents")?.rootOf === "function",
|
|
296
|
+
...(ctx.get("dsmmChildren") === undefined ? {} : { nativeBrowserPrompt: { surface: "conversation.dsmm-children" } }) } });
|
|
301
297
|
return [delegationGuidance, teamGuidance].filter(Boolean).join("\n\n");
|
|
302
298
|
} });
|
|
303
299
|
state.promptRealm = promptRealm;
|
|
304
300
|
}
|
|
305
|
-
const subagents =
|
|
306
|
-
const host = ctx.get
|
|
301
|
+
const subagents = ctx.get("subagents");
|
|
302
|
+
const host = ctx.get("tools");
|
|
307
303
|
const names = [...hostControls, ...host?.schemas().map((row) => row.name).filter((name) => name.startsWith(`mcp__${settings.lsp.serverName}__`)) ?? []];
|
|
308
304
|
const definitions = names.map((name) => host?.get(name));
|
|
309
305
|
const providers = targets.map(role => {
|
|
@@ -338,48 +334,32 @@ export async function registerHeadlessRoleTools(ctx, controller, getSettings, po
|
|
|
338
334
|
}
|
|
339
335
|
const inventory = callableRoleInventory(settings, targets.filter(role => subagents?.getProvider(roleProviderName(role))?.capabilities.depthLimit === true));
|
|
340
336
|
for (const entry of inventory)
|
|
341
|
-
state.owned.push(registerRoleTool(agent,
|
|
337
|
+
state.owned.push(registerRoleTool(agent, ctx, tools, entry, getSettings, policy, admission));
|
|
342
338
|
policy.captureTools(agent, tools, [...inventory.map(entry => entry.name), ...names], !sameRealm || !sameParent);
|
|
343
339
|
state.signature = signature;
|
|
344
340
|
state.providers = providers;
|
|
345
341
|
state.hostDefinitions = definitions;
|
|
346
342
|
state.parentScope = parentScope;
|
|
347
343
|
};
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
admission.lifetime.signal.addEventListener("abort", retire, { once: true });
|
|
369
|
-
agentCtx.effect(() => retire);
|
|
370
|
-
try {
|
|
371
|
-
reconcile(agent);
|
|
372
|
-
}
|
|
373
|
-
catch (error) {
|
|
374
|
-
retire();
|
|
375
|
-
throw error;
|
|
376
|
-
}
|
|
377
|
-
admittedRealms.set(agent, () => reconcile(agent));
|
|
378
|
-
};
|
|
379
|
-
// Native assembly collects sections before its waterfall. Admission/mode/preset
|
|
380
|
-
// changes must update the Agent layer before that collection begins.
|
|
381
|
-
const stopIdentity = controller.watch(agent => { if (agent === onlyAgent)
|
|
382
|
-
reconcile(agent); });
|
|
383
|
-
onCreated({ agent: onlyAgent });
|
|
344
|
+
// Native assembly collects sections before its waterfall. Update the Agent layer before collection.
|
|
345
|
+
const stopIdentity = controller.watch(changed => { if (changed === agent)
|
|
346
|
+
reconcile(); });
|
|
347
|
+
const retire = ctx.effect(() => () => {
|
|
348
|
+
stopIdentity();
|
|
349
|
+
state.restriction?.();
|
|
350
|
+
state.guard?.();
|
|
351
|
+
state.guidance?.();
|
|
352
|
+
for (const dispose of state.owned)
|
|
353
|
+
dispose();
|
|
354
|
+
admittedRealms.delete(ctx);
|
|
355
|
+
});
|
|
356
|
+
try {
|
|
357
|
+
reconcile();
|
|
358
|
+
admittedRealms.set(ctx, reconcile);
|
|
359
|
+
}
|
|
360
|
+
catch (error) {
|
|
361
|
+
retire();
|
|
362
|
+
throw error;
|
|
363
|
+
}
|
|
384
364
|
}
|
|
385
365
|
//# sourceMappingURL=role-subagents.js.map
|