@dsmm/dsmm 0.2.0 → 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.
- package/README.md +37 -67
- package/agent-presets/dsmm-builder/agent.cordis.yml +10 -2015
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +24 -343
- package/agent-presets/dsmm-code-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-coding/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-complex/agent.cordis.yml +23 -1009
- package/agent-presets/dsmm-creative/agent.cordis.yml +25 -442
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +29 -1013
- package/agent-presets/dsmm-deep/agent.cordis.yml +24 -1008
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-documenting/agent.cordis.yml +26 -439
- package/agent-presets/dsmm-frontend/agent.cordis.yml +21 -440
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +22 -441
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-oracle/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +29 -2025
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +24 -341
- package/agent-presets/dsmm-planner/agent.cordis.yml +14 -344
- package/agent-presets/dsmm-quick/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-research/agent.cordis.yml +23 -8
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +25 -340
- package/cordis.patch.yml +14 -0
- package/docs/agent-presets.md +36 -52
- package/docs/compatibility.md +47 -110
- package/docs/deferred-native-approval-risk.md +19 -0
- package/docs/design.md +2 -2
- package/docs/lsp.md +11 -21
- package/docs/migration-from-ocmm.md +2 -2
- package/docs/model-routing.md +84 -59
- package/docs/native-permissions.md +35 -0
- package/docs/profiles.md +40 -87
- package/docs/releasing.md +123 -2
- package/docs/roadmap.md +71 -17
- package/docs/settings-status.md +34 -169
- package/docs/skill-sync.md +52 -15
- package/lib/agent-registry.d.ts +36 -0
- package/lib/agent-registry.js +75 -0
- package/lib/child-admission-contract.d.ts +37 -0
- package/lib/child-admission-contract.js +2 -0
- package/lib/child-admission.d.ts +40 -0
- package/lib/child-admission.js +151 -0
- package/lib/child-capture.d.ts +85 -0
- package/lib/child-capture.js +205 -0
- package/lib/child-evidence.d.ts +17 -0
- package/lib/child-evidence.js +43 -0
- package/lib/client/ChildrenPanel.d.ts +43 -0
- package/lib/client/ChildrenPanel.js +82 -0
- package/lib/client/DeploymentPage.js +15 -8
- package/lib/client/EditableChoice.d.ts +17 -0
- package/lib/client/EditableChoice.js +49 -0
- package/lib/client/PermissionsPanel.d.ts +14 -0
- package/lib/client/PermissionsPanel.js +46 -0
- package/lib/client/ProfilesSection.js +30 -15
- package/lib/client/RoleAvailability.d.ts +7 -0
- package/lib/client/RoleAvailability.js +19 -0
- package/lib/client/SessionProfiles.js +27 -9
- package/lib/client/StructuredEditor.js +15 -7
- package/lib/client/children-controller.d.ts +98 -0
- package/lib/client/children-controller.js +296 -0
- package/lib/client/children-locales.d.ts +367 -0
- package/lib/client/children-locales.js +69 -0
- package/lib/client/controller.d.ts +6 -1
- package/lib/client/controller.js +14 -8
- package/lib/client/deployment-controller.js +1 -1
- package/lib/client/deployment-data.d.ts +2 -1
- package/lib/client/deployment-data.js +34 -5
- package/lib/client/deployment-locales.d.ts +4 -0
- package/lib/client/deployment-locales.js +11 -2
- package/lib/client/diagnostics.d.ts +14 -0
- package/lib/client/diagnostics.js +53 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +96 -2
- package/lib/client/locales.d.ts +54 -0
- package/lib/client/locales.js +34 -16
- package/lib/client/permission-client.d.ts +16 -0
- package/lib/client/permission-client.js +38 -0
- package/lib/client/permission-controller.d.ts +62 -0
- package/lib/client/permission-controller.js +149 -0
- package/lib/client/permission-locales.d.ts +114 -0
- package/lib/client/permission-locales.js +75 -0
- package/lib/client/session-labels.js +4 -4
- package/lib/client/structured.js +19 -5
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +20 -0
- package/lib/client.js +5780 -1679
- package/lib/core-permission-authority.d.ts +18 -0
- package/lib/core-permission-authority.js +255 -0
- package/lib/core-permissions.d.ts +8 -0
- package/lib/core-permissions.js +33 -0
- package/lib/delivery-authority.d.ts +83 -0
- package/lib/delivery-authority.js +397 -0
- package/lib/deployment-config.d.ts +23 -0
- package/lib/deployment-config.js +61 -40
- package/lib/deployment-permission-rules.d.ts +55 -0
- package/lib/deployment-permission-rules.js +306 -0
- package/lib/dsh-types.d.ts +10 -4
- package/lib/guards.d.ts +1 -1
- package/lib/guards.js +29 -8
- package/lib/host-llm-startup.d.ts +41 -0
- package/lib/host-llm-startup.js +65 -0
- package/lib/host-llm.d.ts +92 -0
- package/lib/host-llm.js +325 -0
- package/lib/index.d.ts +15 -4
- package/lib/index.js +288 -48
- package/lib/live-pi-ai-owner.d.ts +18 -0
- package/lib/live-pi-ai-owner.js +144 -0
- package/lib/llm-runtime.d.ts +11 -0
- package/lib/llm-runtime.js +21 -0
- package/lib/managed-settings.d.ts +5 -0
- package/lib/managed-settings.js +14 -0
- package/lib/model-parameter-policy.d.ts +11 -0
- package/lib/model-parameter-policy.js +27 -0
- package/lib/model-routing.js +28 -17
- package/lib/modules.d.ts +13 -5
- package/lib/modules.js +17 -1
- package/lib/native-child-evidence.d.ts +40 -0
- package/lib/native-child-evidence.js +104 -0
- package/lib/native-pi-ai-wire.d.ts +37 -0
- package/lib/native-pi-ai-wire.js +261 -0
- package/lib/native-scope.js +1 -1
- package/lib/permission-bash.d.ts +6 -0
- package/lib/permission-bash.js +7 -0
- package/lib/permission-control.d.ts +73 -0
- package/lib/permission-control.js +205 -0
- package/lib/permission-controller.d.ts +68 -0
- package/lib/permission-controller.js +317 -0
- package/lib/permission-errors.d.ts +7 -0
- package/lib/permission-errors.js +21 -0
- package/lib/permission-fs-search.d.ts +5 -0
- package/lib/permission-fs-search.js +7 -0
- package/lib/permission-fs.d.ts +5 -0
- package/lib/permission-fs.js +7 -0
- package/lib/permission-native-access.d.ts +11 -0
- package/lib/permission-native-access.js +6 -0
- package/lib/permission-native-command.d.ts +10 -0
- package/lib/permission-native-command.js +93 -0
- package/lib/permission-native-rules.d.ts +75 -0
- package/lib/permission-native-rules.js +278 -0
- package/lib/permission-pwsh.d.ts +6 -0
- package/lib/permission-pwsh.js +7 -0
- package/lib/permission-remote.d.ts +26 -0
- package/lib/permission-remote.js +53 -0
- package/lib/permission-rpc.d.ts +29 -0
- package/lib/permission-rpc.js +152 -0
- package/lib/permission-rules.d.ts +115 -0
- package/lib/permission-rules.js +256 -0
- package/lib/permission-settings.d.ts +45 -0
- package/lib/permission-settings.js +48 -0
- package/lib/permission-shell.d.ts +38 -0
- package/lib/permission-shell.js +150 -0
- package/lib/permission-web.d.ts +5 -0
- package/lib/permission-web.js +7 -0
- package/lib/preset-registry.js +36 -25
- package/lib/profile-diagnostics.d.ts +45 -0
- package/lib/profile-diagnostics.js +148 -0
- package/lib/profile-locale.d.ts +3 -0
- package/lib/profile-locale.js +2 -0
- package/lib/profile-remote.d.ts +8 -0
- package/lib/profile-remote.js +163 -39
- package/lib/profile-rpc.d.ts +4 -3
- package/lib/profile-rpc.js +20 -16
- package/lib/profile-runtime.d.ts +40 -1
- package/lib/profile-runtime.js +368 -93
- package/lib/profile-store.d.ts +11 -0
- package/lib/profile-store.js +143 -11
- package/lib/profile-types.d.ts +70 -1
- package/lib/profile-types.js +1 -0
- package/lib/profiles.d.ts +16 -2
- package/lib/profiles.js +156 -79
- package/lib/prompt-content.js +1 -1
- package/lib/prompts.d.ts +37 -2
- package/lib/prompts.js +111 -9
- package/lib/recovery-policy.js +20 -7
- package/lib/role-control-remote.d.ts +38 -0
- package/lib/role-control-remote.js +211 -0
- package/lib/role-control-rpc.d.ts +51 -0
- package/lib/role-control-rpc.js +381 -0
- package/lib/role-control-types.d.ts +92 -0
- package/lib/role-control-types.js +8 -0
- package/lib/role-invocation.d.ts +47 -0
- package/lib/role-invocation.js +135 -0
- package/lib/role-llm-runtime.d.ts +17 -0
- package/lib/role-llm-runtime.js +62 -0
- package/lib/role-llm.d.ts +31 -0
- package/lib/role-llm.js +66 -0
- package/lib/role-policy.d.ts +46 -8
- package/lib/role-policy.js +421 -61
- package/lib/role-providers.d.ts +2 -2
- package/lib/role-providers.js +27 -72
- package/lib/role-routing.d.ts +11 -2
- package/lib/role-routing.js +42 -25
- package/lib/role-runs.d.ts +138 -0
- package/lib/role-runs.js +335 -0
- package/lib/role-subagents.d.ts +58 -3
- package/lib/role-subagents.js +179 -56
- package/lib/roles.d.ts +5 -6
- package/lib/roles.js +10 -39
- package/lib/route-json.d.ts +19 -0
- package/lib/route-json.js +129 -0
- package/lib/routing-policy.d.ts +2 -0
- package/lib/routing-policy.js +12 -2
- package/lib/runtime-integration.d.ts +81 -0
- package/lib/runtime-integration.js +702 -0
- package/lib/runtime-recovery.js +18 -8
- package/lib/session-persistence.d.ts +2 -1
- package/lib/session-persistence.js +1 -1
- package/lib/session-scope.js +4 -1
- package/lib/settings.d.ts +47 -13
- package/lib/settings.js +217 -82
- package/lib/skills.js +2 -2
- package/lib/status.d.ts +10 -1
- package/lib/status.js +11 -8
- package/lib/subagent-runtime.d.ts +57 -0
- package/lib/subagent-runtime.js +257 -0
- package/package.json +149 -89
- package/patches/subagent-runtime.yml +15 -0
- package/prompts/deepseek-flash.md +1 -1
- package/prompts/deepseek-v4-pro.md +2 -2
- package/prompts/deepwork.md +27 -18
- package/prompts/source/agents/clarifier.md +5 -3
- package/prompts/source/agents/orchestrator.md +18 -9
- package/prompts/source/agents/plan-critic.md +5 -1
- package/prompts/source/agents/planner.md +4 -2
- package/prompts/source/agents/reviewer.md +6 -0
- package/prompts/source/category/complex.md +4 -4
- package/prompts/source/category/creative.md +6 -4
- package/prompts/source/category/cross-cutting.md +10 -8
- package/prompts/source/category/deep.md +5 -3
- package/prompts/source/category/documenting.md +7 -1
- package/prompts/source/category/frontend.md +2 -2
- package/prompts/source/category/hard-reasoning.md +3 -3
- package/prompts/source/category/research.md +4 -2
- package/prompts/source/deepwork/claude-opus-5.md +2 -2
- package/prompts/source/deepwork/codex.md +1 -1
- package/prompts/source/deepwork/default.md +22 -15
- package/prompts/source/deepwork/gemini.md +23 -16
- package/prompts/source/deepwork/glm.md +21 -14
- package/prompts/source/deepwork/gpt.md +12 -6
- package/prompts/source/deepwork/planner.md +8 -5
- package/prompts/source/manifest.json +178 -63
- package/prompts/source/shared/dsh-host-contract.md +5 -3
- package/prompts/source/shared/locale.md +2 -2
- package/prompts/source/terminal/orchestrator.md +1 -1
- package/skills/ast-grep/SKILL.md +7 -4
- package/skills/brainstorming/SKILL.md +43 -22
- package/skills/coding-agent-sessions/SKILL.md +7 -4
- package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -46
- package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -130
- package/skills/debugging/SKILL.md +14 -9
- package/skills/debugging/references/methodology/00-setup.md +14 -62
- package/skills/debugging/references/methodology/02-investigate.md +4 -4
- package/skills/debugging/references/methodology/03-flaky-triage.md +3 -3
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +2 -14
- package/skills/debugging/references/methodology/06-fix.md +6 -6
- package/skills/debugging/references/methodology/08-qa.md +5 -5
- package/skills/debugging/references/methodology/09-cleanup.md +15 -153
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +3 -16
- package/skills/debugging/references/runtimes/bundled-js-binary.md +1 -16
- package/skills/debugging/references/runtimes/native-binary.md +9 -54
- package/skills/debugging/references/runtimes/node.md +4 -15
- package/skills/debugging/references/runtimes/python.md +3 -15
- package/skills/debugging/references/runtimes/rust.md +2 -18
- package/skills/debugging/references/tools/dap.md +1 -1
- package/skills/debugging/references/tools/ghidra.md +4 -15
- package/skills/debugging/references/tools/playwright-cli.md +3 -15
- package/skills/debugging/references/tools/pwntools.md +4 -16
- package/skills/dispatching-parallel-agents/SKILL.md +18 -16
- package/skills/frontend/SKILL.md +7 -4
- package/skills/frontend/references/design/react-dev-tooling-skill.md +1 -1
- package/skills/git-master/SKILL.md +7 -4
- package/skills/init-deep/SKILL.md +7 -4
- package/skills/receiving-code-review/SKILL.md +17 -12
- package/skills/remove-ai-slops/SKILL.md +39 -38
- package/skills/requesting-code-review/SKILL.md +19 -17
- package/skills/requesting-code-review/code-reviewer.md +13 -1
- package/skills/subagent-driven-development/SKILL.md +29 -26
- package/skills/subagent-driven-development/implementer-prompt.md +29 -11
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +6 -1
- package/skills/using-git-worktrees/SKILL.md +7 -4
- package/skills/writing-plans/SKILL.md +29 -24
- package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -1
- package/scripts/repair-session-log.mjs +0 -476
- package/scripts/session-repair-native-verifier.mjs +0 -367
package/lib/status.js
CHANGED
|
@@ -45,6 +45,10 @@ export function createDsmmStatusSnapshot(input) {
|
|
|
45
45
|
&& route.model === selectedRoute.model && route.reasoningEffort === selectedRoute.reasoningEffort);
|
|
46
46
|
return {
|
|
47
47
|
version: DSMM_STATUS_VERSION,
|
|
48
|
+
...(input.admission?.roleAvailability === undefined ? {} : { roles: structuredClone(input.admission.roleAvailability) }),
|
|
49
|
+
...(input.admission?.warnings === undefined ? {} : { warnings: structuredClone(input.admission.warnings) }),
|
|
50
|
+
...(input.subagentRuntime === undefined && input.admission?.subagentRuntime === undefined ? {} : { subagentRuntime: { ...(input.subagentRuntime ?? input.admission.subagentRuntime) } }),
|
|
51
|
+
...(settings.locale === undefined ? {} : { locale: { value: settings.locale, source: input.admission?.sources?.locale ?? "defaults", capture: input.admission?.sourceCaptures?.fields.locale ?? "admission" } }),
|
|
48
52
|
...(input.modules === undefined ? {} : { modules: structuredClone(input.modules) }),
|
|
49
53
|
...(input.admission?.store === undefined ? {} : { profileStore: { ...input.admission.store } }),
|
|
50
54
|
...(input.admission?.deployment === undefined ? {} : { deployment: {
|
|
@@ -170,11 +174,8 @@ function resolveRoute(agent) {
|
|
|
170
174
|
function readString(value) {
|
|
171
175
|
return typeof value === "string" ? value : undefined;
|
|
172
176
|
}
|
|
173
|
-
function resolvePolicyEffort(settings,
|
|
174
|
-
|
|
175
|
-
return isDsmmRoleId(selectedPreset) && presets.includes(selectedPreset)
|
|
176
|
-
? "max"
|
|
177
|
-
: flash ? settings.deepseekFlashDefaultReasoningEffort : settings.deepseekV4ProDefaultReasoningEffort;
|
|
177
|
+
function resolvePolicyEffort(settings, _selectedPreset, flash) {
|
|
178
|
+
return flash ? settings.deepseekFlashDefaultReasoningEffort : settings.deepseekV4ProDefaultReasoningEffort;
|
|
178
179
|
}
|
|
179
180
|
function resolveCalibration(input) {
|
|
180
181
|
if (input.calibration === "off") {
|
|
@@ -196,23 +197,25 @@ function resolveCalibration(input) {
|
|
|
196
197
|
/** Read-only diagnostics only; never use this copy as configuration input. */
|
|
197
198
|
export function readOnlySettings(settings) {
|
|
198
199
|
return {
|
|
200
|
+
permissionControl: structuredClone(settings.permissionControl),
|
|
201
|
+
modelParameters: { ...settings.modelParameters },
|
|
199
202
|
modules: { deepwork: { enabled: settings.modules.deepwork.enabled } },
|
|
203
|
+
...(settings.locale === undefined ? {} : { locale: settings.locale }),
|
|
200
204
|
modeName: settings.modeName,
|
|
201
205
|
defaultActive: settings.defaultActive,
|
|
202
206
|
promptOrder: settings.promptOrder,
|
|
203
207
|
deepseekV4ProCalibration: settings.deepseekV4ProCalibration,
|
|
204
208
|
deepseekV4ProDefaultReasoningEffort: settings.deepseekV4ProDefaultReasoningEffort,
|
|
205
|
-
deepseekV4ProMaxReasoningPresets: [...settings.deepseekV4ProMaxReasoningPresets],
|
|
206
209
|
deepseekFlashCalibration: settings.deepseekFlashCalibration,
|
|
207
210
|
deepseekFlashDefaultReasoningEffort: settings.deepseekFlashDefaultReasoningEffort,
|
|
208
|
-
deepseekFlashMaxReasoningPresets: [...settings.deepseekFlashMaxReasoningPresets],
|
|
209
211
|
skills: { ...settings.skills },
|
|
210
212
|
roles: { ...settings.roles },
|
|
211
213
|
roleRouting: Object.fromEntries(Object.entries(settings.roleRouting).map(([role, policy]) => [role, {
|
|
212
214
|
...(policy.primary === undefined ? {} : { primary: { ...policy.primary } }),
|
|
213
215
|
...(policy.fallbackRoutes === undefined ? {} : { fallbackRoutes: policy.fallbackRoutes.map((route) => ({ ...route })) }),
|
|
214
216
|
...(policy.strategy === undefined ? {} : { strategy: policy.strategy }),
|
|
215
|
-
...(policy.rateLimit === undefined ? {} : { rateLimit: { ...policy.rateLimit } })
|
|
217
|
+
...(policy.rateLimit === undefined ? {} : { rateLimit: { ...policy.rateLimit } }),
|
|
218
|
+
...(policy.levels === undefined ? {} : { levels: structuredClone(policy.levels) })
|
|
216
219
|
}])),
|
|
217
220
|
runtimePolicy: { strategy: settings.runtimePolicy.strategy, rateLimit: { ...settings.runtimePolicy.rateLimit } },
|
|
218
221
|
presets: { ...settings.presets, ...(settings.presets.root === undefined ? {} : { root: "<configured>" }) },
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
+
import type { ContentBlock, MessageId } from "@deepseek-ai/dsh-llm";
|
|
4
|
+
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
5
|
+
import { SubagentRuntime } from "@deepseek-ai/dsh-subagent";
|
|
6
|
+
import type { SubagentActivation, SubagentActivationSpec, SubagentPromptReceipt, SubagentPromptRequest, SubagentProvider, SubagentSendMessageOptions } from "@deepseek-ai/dsh-subagent";
|
|
7
|
+
import { DsmmDeliveryAuthority } from "./delivery-authority.js";
|
|
8
|
+
import type { DeliveryAdmission, DeliveryParentClassifier } from "./delivery-authority.js";
|
|
9
|
+
export { DsmmDeliveryAuthority } from "./delivery-authority.js";
|
|
10
|
+
export type { DeliveryAdmission, DeliveryFenceView, DeliveryParentClassifier, DeliveryPolicyBinding, ParentAdmissionTicket } from "./delivery-authority.js";
|
|
11
|
+
declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
12
|
+
interface RemoteErrorDetailsMap {
|
|
13
|
+
"subagent/unauthorized": {
|
|
14
|
+
readonly childSessionId: SessionId;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
type ActivationStart = (spec: SubagentActivationSpec) => Promise<SubagentActivation>;
|
|
19
|
+
type ActivationPreflight = (spec: SubagentActivationSpec, start: ActivationStart) => Promise<SubagentActivation>;
|
|
20
|
+
/** Explicit startup replacement for the stock row, in the SAME Host service scope. */
|
|
21
|
+
export declare class DsmmSubagentRuntime<A extends DeliveryAdmission = DeliveryAdmission, E = unknown> extends SubagentRuntime {
|
|
22
|
+
static inject: string[];
|
|
23
|
+
readonly authority: DsmmDeliveryAuthority<A, E>;
|
|
24
|
+
private readonly waiters;
|
|
25
|
+
private readonly lifetime;
|
|
26
|
+
private requiredProviders;
|
|
27
|
+
private activationPreflight?;
|
|
28
|
+
constructor(ctx: Context, config: ConstructorParameters<typeof SubagentRuntime>[1], hostClassifier?: DeliveryParentClassifier);
|
|
29
|
+
/** Host composition may select spawn/fork names before enabling the policy. */
|
|
30
|
+
requireProviders(names: readonly string[]): void;
|
|
31
|
+
registerProvider(provider: SubagentProvider): () => void;
|
|
32
|
+
/** Host entry route preparation before native normalization loses caller option provenance. */
|
|
33
|
+
configureActivationPreflight(preflight: ActivationPreflight, signal: AbortSignal): void;
|
|
34
|
+
startActivation(spec: SubagentActivationSpec & {
|
|
35
|
+
readonly childId: SessionId;
|
|
36
|
+
}): Promise<SubagentActivation & {
|
|
37
|
+
readonly messageId: MessageId;
|
|
38
|
+
}>;
|
|
39
|
+
startActivation(spec: SubagentActivationSpec): Promise<SubagentActivation>;
|
|
40
|
+
private startManaged;
|
|
41
|
+
private operation;
|
|
42
|
+
private coldDelivery;
|
|
43
|
+
private retireTree;
|
|
44
|
+
drainDescendants(parents: readonly Agent[]): Promise<void>;
|
|
45
|
+
drainChildren(parent: Agent, childIds: readonly SessionId[]): Promise<void>;
|
|
46
|
+
/** Fulfillment proves this exact registry contains the provider, not just a mounted plugin. */
|
|
47
|
+
waitForProvider(name: string, signal?: AbortSignal): Promise<SubagentProvider>;
|
|
48
|
+
/** Policy explicitly enabled AND every required provider actually registered. */
|
|
49
|
+
waitUntilReady(signal?: AbortSignal): Promise<void>;
|
|
50
|
+
sendMessage(sender: Agent, targetId: SessionId, content: ContentBlock[], options: SubagentSendMessageOptions): Promise<MessageId>;
|
|
51
|
+
prompt(request: SubagentPromptRequest, callerSignal: AbortSignal): Promise<SubagentPromptReceipt>;
|
|
52
|
+
private wakeWaiters;
|
|
53
|
+
private substrateReady;
|
|
54
|
+
private waitFor;
|
|
55
|
+
}
|
|
56
|
+
export default DsmmSubagentRuntime;
|
|
57
|
+
//# sourceMappingURL=subagent-runtime.d.ts.map
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
3
|
+
import { SubagentError, SubagentRuntime } from "@deepseek-ai/dsh-subagent";
|
|
4
|
+
import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
|
|
5
|
+
import { TYPERT as NATIVE_SUBAGENT_HOST } from "@deepseek-ai/dsh-subagent/typert";
|
|
6
|
+
import { DsmmDeliveryAuthority, scopeLifetime } from "./delivery-authority.js";
|
|
7
|
+
import { activationOwnerSignal, DsmmAgentRegistry, duringManagedCreation, exactRegistry, managedCancellation } from "./agent-registry.js";
|
|
8
|
+
export { DsmmDeliveryAuthority } from "./delivery-authority.js";
|
|
9
|
+
/** Explicit startup replacement for the stock row, in the SAME Host service scope. */
|
|
10
|
+
export class DsmmSubagentRuntime extends SubagentRuntime {
|
|
11
|
+
static inject = ["agents", ...SubagentRuntime.inject];
|
|
12
|
+
authority;
|
|
13
|
+
waiters = new Set();
|
|
14
|
+
lifetime = new AbortController();
|
|
15
|
+
requiredProviders = ["spawn"];
|
|
16
|
+
activationPreflight;
|
|
17
|
+
constructor(ctx, config, hostClassifier) {
|
|
18
|
+
if (ctx.get("subagents") !== undefined) {
|
|
19
|
+
throw new SubagentError("Explicit DSMM startup composition must exclude the stock subagents row; restart with one provider.", "DUPLICATE_PROVIDER");
|
|
20
|
+
}
|
|
21
|
+
super(ctx, config);
|
|
22
|
+
this.authority = new DsmmDeliveryAuthority(ctx, () => this.substrateReady(), () => this.wakeWaiters(), hostClassifier);
|
|
23
|
+
const agents = exactRegistry(ctx.agents);
|
|
24
|
+
if (!(agents instanceof DsmmAgentRegistry))
|
|
25
|
+
throw new SubagentError("Managed activations require the DSMM startup agents provider", "UNSUPPORTED_CAPABILITY");
|
|
26
|
+
const retire = () => { this.lifetime.abort(); for (const agent of agents.list())
|
|
27
|
+
this.authority.revokeParent(agent, "agents-provider-ended"); this.wakeWaiters(); };
|
|
28
|
+
agents.managedLifetime.signal.addEventListener("abort", retire, { once: true });
|
|
29
|
+
if (agents.managedLifetime.signal.aborted)
|
|
30
|
+
retire();
|
|
31
|
+
ctx.inject(["typert"], (remoteCtx) => {
|
|
32
|
+
if (remoteCtx.typert.getPackage("@deepseek-ai/dsh-subagent", "host") === undefined) {
|
|
33
|
+
remoteCtx.typert.register(NATIVE_SUBAGENT_HOST);
|
|
34
|
+
}
|
|
35
|
+
this.wakeWaiters();
|
|
36
|
+
});
|
|
37
|
+
ctx.on("subagent/provider-added", () => this.wakeWaiters());
|
|
38
|
+
ctx.on("subagent/provider-removed", () => this.wakeWaiters());
|
|
39
|
+
scopeLifetime(ctx, "dsmm.subagents: close registration barriers", () => { this.lifetime.abort(); this.wakeWaiters(); });
|
|
40
|
+
}
|
|
41
|
+
/** Host composition may select spawn/fork names before enabling the policy. */
|
|
42
|
+
requireProviders(names) {
|
|
43
|
+
if (this.authority.view().deliveryFenceReady || names.length === 0 || names.some((name) => name.length === 0)) {
|
|
44
|
+
throw new SubagentError("Provider readiness must be configured before DSMM admission becomes ready.", "UNAUTHORIZED");
|
|
45
|
+
}
|
|
46
|
+
this.requiredProviders = [...new Set(names)];
|
|
47
|
+
this.wakeWaiters();
|
|
48
|
+
}
|
|
49
|
+
registerProvider(provider) {
|
|
50
|
+
const dispose = super.registerProvider(provider);
|
|
51
|
+
this.wakeWaiters();
|
|
52
|
+
return dispose;
|
|
53
|
+
}
|
|
54
|
+
/** Host entry route preparation before native normalization loses caller option provenance. */
|
|
55
|
+
configureActivationPreflight(preflight, signal) {
|
|
56
|
+
signal.throwIfAborted();
|
|
57
|
+
if (this.activationPreflight !== undefined)
|
|
58
|
+
throw new SubagentError("Activation routing already has a Host owner", "UNAUTHORIZED");
|
|
59
|
+
this.activationPreflight = preflight;
|
|
60
|
+
signal.addEventListener("abort", () => { if (this.activationPreflight === preflight)
|
|
61
|
+
this.activationPreflight = undefined; }, { once: true });
|
|
62
|
+
}
|
|
63
|
+
async startActivation(spec) {
|
|
64
|
+
this.authority.assertSender(spec.request.parent);
|
|
65
|
+
const start = request => this.startManaged(request);
|
|
66
|
+
return this.activationPreflight === undefined ? start(spec) : this.activationPreflight(spec, start);
|
|
67
|
+
}
|
|
68
|
+
async startManaged(spec) {
|
|
69
|
+
const parent = spec.request.parent;
|
|
70
|
+
if (!this.authority.isManaged(parent, "creation"))
|
|
71
|
+
return super.startActivation(spec);
|
|
72
|
+
const provider = this.getProvider(spec.provider);
|
|
73
|
+
if (provider === undefined)
|
|
74
|
+
throw new SubagentError(`Subagent provider "${spec.provider}" is not registered`, "NO_PROVIDER");
|
|
75
|
+
if (provider.prepareContinuable === undefined)
|
|
76
|
+
throw new SubagentError("Managed delegation requires a local activation provider", "UNSUPPORTED_CAPABILITY");
|
|
77
|
+
const ticket = this.authority.acquireParentTicket(parent);
|
|
78
|
+
const childId = spec.childId ?? SessionId(randomUUID());
|
|
79
|
+
const operation = this.operation(parent, childId, "fresh", ticket.owner, spec.delivery === "caller" ? "one-shot" : "continuable");
|
|
80
|
+
let receipt;
|
|
81
|
+
try {
|
|
82
|
+
receipt = await duringManagedCreation(operation, () => super.startActivation({ ...spec, childId,
|
|
83
|
+
signal: AbortSignal.any([spec.signal, ticket.signal, this.lifetime.signal]) }));
|
|
84
|
+
this.authority.promote(operation);
|
|
85
|
+
let disposal;
|
|
86
|
+
const accepted = receipt;
|
|
87
|
+
return { ...accepted, dispose: () => {
|
|
88
|
+
if (disposal !== undefined)
|
|
89
|
+
return disposal;
|
|
90
|
+
this.retireTree(operation.child, "activation-disposed");
|
|
91
|
+
return disposal = accepted.dispose();
|
|
92
|
+
} };
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
this.authority.retireOperation(operation, "activation-refused");
|
|
96
|
+
if (receipt !== undefined) {
|
|
97
|
+
try {
|
|
98
|
+
await receipt.dispose();
|
|
99
|
+
}
|
|
100
|
+
catch (cleanup) {
|
|
101
|
+
throw new AggregateError([error, cleanup], "Managed activation admission and cleanup failed");
|
|
102
|
+
}
|
|
103
|
+
if (operation.ownerSignal?.aborted)
|
|
104
|
+
throw managedCancellation(operation.ownerSignal.reason);
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
operation(parent, childId, kind, owner, delegationMode) {
|
|
110
|
+
this.lifetime.signal.throwIfAborted();
|
|
111
|
+
const operation = { registry: exactRegistry(this.ctx.agents), parent, childId, kind, owner, delegationMode,
|
|
112
|
+
ownerSignal: activationOwnerSignal(), claimed: false, retired: false, entered: agent => this.authority.beginPending(operation, agent) };
|
|
113
|
+
return operation;
|
|
114
|
+
}
|
|
115
|
+
async coldDelivery(parent, childId, owner, deliver) {
|
|
116
|
+
const operation = this.operation(parent, childId, "cold", owner);
|
|
117
|
+
let accepted = false;
|
|
118
|
+
try {
|
|
119
|
+
const receipt = await duringManagedCreation(operation, deliver);
|
|
120
|
+
accepted = true;
|
|
121
|
+
// A competing operation may have established this residency before the native lock.
|
|
122
|
+
if (operation.claimed)
|
|
123
|
+
this.authority.promote(operation);
|
|
124
|
+
return receipt;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
this.authority.retireOperation(operation, "cold-delivery-refused");
|
|
128
|
+
const child = operation.child;
|
|
129
|
+
if (accepted && child !== undefined && this.ctx.agents.get(child.id) === child && this.ctx.agents.isOwnedBy(child.id, parent)) {
|
|
130
|
+
try {
|
|
131
|
+
await super.drainChildren(parent, [child.id]);
|
|
132
|
+
}
|
|
133
|
+
catch (cleanup) {
|
|
134
|
+
throw new AggregateError([error, cleanup], "Managed cold admission and cleanup failed");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
retireTree(parent, reason) {
|
|
141
|
+
const registry = this.ctx.agents, pending = [parent], seen = new Set();
|
|
142
|
+
while (pending.length) {
|
|
143
|
+
const agent = pending.pop();
|
|
144
|
+
if (seen.has(agent))
|
|
145
|
+
continue;
|
|
146
|
+
seen.add(agent);
|
|
147
|
+
this.authority.revokeParent(agent, reason);
|
|
148
|
+
for (const child of registry.list())
|
|
149
|
+
if (child !== agent && registry.isOwnedBy(child.id, agent))
|
|
150
|
+
pending.push(child);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
drainDescendants(parents) {
|
|
154
|
+
for (const parent of parents)
|
|
155
|
+
if (this.ctx.agents.get(parent.id) !== parent)
|
|
156
|
+
throw new SubagentError("Drain requires exact live parents", "UNAUTHORIZED");
|
|
157
|
+
for (const parent of parents)
|
|
158
|
+
this.retireTree(parent, "descendants-draining");
|
|
159
|
+
return super.drainDescendants(parents);
|
|
160
|
+
}
|
|
161
|
+
drainChildren(parent, childIds) {
|
|
162
|
+
const registry = this.ctx.agents;
|
|
163
|
+
if (registry.get(parent.id) !== parent)
|
|
164
|
+
throw new SubagentError("Drain requires exact live parent", "UNAUTHORIZED");
|
|
165
|
+
const children = childIds.flatMap(id => { const child = registry.get(id); return child === undefined ? [] : [child]; });
|
|
166
|
+
if (children.some(child => !registry.isOwnedBy(child.id, parent)))
|
|
167
|
+
throw new SubagentError("Drain target is not a direct child", "UNAUTHORIZED");
|
|
168
|
+
for (const child of children)
|
|
169
|
+
this.retireTree(child, "child-draining");
|
|
170
|
+
return super.drainChildren(parent, childIds);
|
|
171
|
+
}
|
|
172
|
+
/** Fulfillment proves this exact registry contains the provider, not just a mounted plugin. */
|
|
173
|
+
waitForProvider(name, signal) {
|
|
174
|
+
return this.waitFor(() => this.getProvider(name), signal);
|
|
175
|
+
}
|
|
176
|
+
/** Policy explicitly enabled AND every required provider actually registered. */
|
|
177
|
+
waitUntilReady(signal) {
|
|
178
|
+
return this.waitFor(() => this.authority.view().deliveryFenceReady ? true : undefined, signal).then(() => { });
|
|
179
|
+
}
|
|
180
|
+
async sendMessage(sender, targetId, content, options) {
|
|
181
|
+
this.authority.assertSender(sender);
|
|
182
|
+
// The SDK alone validates exact residency and adjacency on child -> parent.
|
|
183
|
+
if (sender.session.header.parentSession === targetId || !this.authority.isManaged(sender)) {
|
|
184
|
+
return super.sendMessage(sender, targetId, content, options);
|
|
185
|
+
}
|
|
186
|
+
const ticket = this.authority.acquireParentTicket(sender);
|
|
187
|
+
const signal = AbortSignal.any([options.signal, ticket.signal]);
|
|
188
|
+
const evidence = await this.authority.resolveChildEvidence(ticket, targetId, signal);
|
|
189
|
+
const managed = this.authority.assertDelivery(ticket, targetId, evidence);
|
|
190
|
+
signal.throwIfAborted();
|
|
191
|
+
if (!managed)
|
|
192
|
+
return super.sendMessage(sender, targetId, content, { ...options, signal });
|
|
193
|
+
return this.coldDelivery(sender, targetId, ticket.owner, () => super.sendMessage(sender, targetId, content, { ...options, signal }));
|
|
194
|
+
}
|
|
195
|
+
async prompt(request, callerSignal) {
|
|
196
|
+
const parent = this.ctx.get("agents")?.get(request.parentSessionId);
|
|
197
|
+
if (parent === undefined)
|
|
198
|
+
return super.prompt(request, callerSignal);
|
|
199
|
+
let signal = callerSignal;
|
|
200
|
+
let owner;
|
|
201
|
+
let managed;
|
|
202
|
+
try {
|
|
203
|
+
this.authority.assertSender(parent);
|
|
204
|
+
if (!this.authority.isManaged(parent))
|
|
205
|
+
return super.prompt(request, callerSignal);
|
|
206
|
+
const ticket = this.authority.acquireParentTicket(parent);
|
|
207
|
+
owner = ticket.owner;
|
|
208
|
+
signal = AbortSignal.any([callerSignal, ticket.signal, this.authority.acquireBrowserSignal(this.ctx)]);
|
|
209
|
+
const evidence = await this.authority.resolveChildEvidence(ticket, request.childSessionId, signal);
|
|
210
|
+
managed = this.authority.assertDelivery(ticket, request.childSessionId, evidence);
|
|
211
|
+
signal.throwIfAborted();
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
// Match the native public prompt error boundary, without relabeling success.
|
|
215
|
+
if (signal.aborted)
|
|
216
|
+
throw new RemoteError("gateway/cancelled", "Subagent prompt was cancelled.", {}, { cause: error });
|
|
217
|
+
if (error instanceof SubagentError && error.code === "UNAUTHORIZED") {
|
|
218
|
+
throw new RemoteError("subagent/unauthorized", "Subagent delivery was not authorized.", { childSessionId: request.childSessionId }, { cause: error });
|
|
219
|
+
}
|
|
220
|
+
throw new RemoteError("gateway/internal", "Subagent prompt failed.", {}, { cause: error });
|
|
221
|
+
}
|
|
222
|
+
return managed ? this.coldDelivery(parent, request.childSessionId, owner, () => super.prompt(request, signal)) : super.prompt(request, signal);
|
|
223
|
+
}
|
|
224
|
+
wakeWaiters() {
|
|
225
|
+
for (const waiter of this.waiters)
|
|
226
|
+
waiter.check();
|
|
227
|
+
}
|
|
228
|
+
substrateReady() {
|
|
229
|
+
const typert = this.ctx.get("typert");
|
|
230
|
+
return this.requiredProviders.every((name) => this.getProvider(name) !== undefined)
|
|
231
|
+
&& (typert === undefined || typert.local.get("subagents/prompt") !== undefined);
|
|
232
|
+
}
|
|
233
|
+
waitFor(read, callerSignal) {
|
|
234
|
+
const signal = callerSignal === undefined ? this.lifetime.signal : AbortSignal.any([callerSignal, this.lifetime.signal]);
|
|
235
|
+
return new Promise((resolve, reject) => {
|
|
236
|
+
const cleanup = () => { this.waiters.delete(waiter); signal.removeEventListener("abort", check); };
|
|
237
|
+
const check = () => {
|
|
238
|
+
if (signal.aborted) {
|
|
239
|
+
cleanup();
|
|
240
|
+
reject(signal.reason);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const value = read();
|
|
244
|
+
if (value !== undefined) {
|
|
245
|
+
cleanup();
|
|
246
|
+
resolve(value);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const waiter = { check };
|
|
250
|
+
this.waiters.add(waiter);
|
|
251
|
+
signal.addEventListener("abort", check, { once: true });
|
|
252
|
+
check();
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
export default DsmmSubagentRuntime;
|
|
257
|
+
//# sourceMappingURL=subagent-runtime.js.map
|