@dsmm/dsmm 0.1.0 → 0.1.4
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 +26 -12
- package/agent-presets/dsmm-builder/agent.cordis.yml +25 -23
- package/agent-presets/dsmm-builder/preset.yml +1 -1
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-clarifier/preset.yml +1 -1
- package/agent-presets/dsmm-code-search/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-code-search/preset.yml +1 -1
- package/agent-presets/dsmm-creative/agent.cordis.yml +3 -1
- package/agent-presets/dsmm-creative/preset.yml +1 -1
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-doc-search/preset.yml +1 -1
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-media-reader/preset.yml +1 -1
- package/agent-presets/dsmm-oracle/agent.cordis.yml +3 -1
- package/agent-presets/dsmm-oracle/preset.yml +1 -1
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +3 -1
- package/agent-presets/dsmm-oracle-2nd/preset.yml +1 -1
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +26 -24
- package/agent-presets/dsmm-orchestrator/preset.yml +2 -2
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-plan-critic/preset.yml +1 -1
- package/agent-presets/dsmm-planner/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-planner/preset.yml +1 -1
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-reviewer/preset.yml +1 -1
- package/docs/agent-presets.md +17 -5
- package/docs/compatibility.md +68 -12
- package/docs/migration-from-ocmm.md +10 -4
- package/docs/model-routing.md +50 -1
- package/docs/profiles.md +83 -0
- package/docs/releasing.md +59 -18
- package/docs/roadmap.md +1 -1
- package/docs/runtime-recovery.md +10 -2
- package/docs/settings-status.md +16 -4
- package/lib/client/ProfilesSection.d.ts +11 -0
- package/lib/client/ProfilesSection.js +62 -0
- package/lib/client/controller.d.ts +77 -0
- package/lib/client/controller.js +198 -0
- package/lib/client/index.d.ts +11 -0
- package/lib/client/index.js +34 -0
- package/lib/client/locales.d.ts +56 -0
- package/lib/client/locales.js +48 -0
- package/lib/client/styles.d.ts +3 -0
- package/lib/client/styles.js +25 -0
- package/lib/client.js +1930 -0
- package/lib/commands.d.ts +3 -3
- package/lib/commands.js +4 -4
- package/lib/dsh-events.d.ts +8 -0
- package/lib/dsh-types.d.ts +8 -0
- package/lib/guards.d.ts +2 -2
- package/lib/guards.js +3 -2
- package/lib/index.d.ts +16 -6
- package/lib/index.js +77 -21
- package/lib/mode.d.ts +2 -2
- package/lib/mode.js +1 -1
- package/lib/model-routing.d.ts +2 -2
- package/lib/model-routing.js +44 -4
- package/lib/preset-materializer.js +2 -2
- package/lib/preset-registry.js +4 -2
- package/lib/profile-remote.d.ts +31 -0
- package/lib/profile-remote.js +106 -0
- package/lib/profile-rpc.d.ts +27 -0
- package/lib/profile-rpc.js +90 -0
- package/lib/profile-runtime.d.ts +44 -0
- package/lib/profile-runtime.js +159 -0
- package/lib/profile-store.d.ts +42 -0
- package/lib/profile-store.js +478 -0
- package/lib/profile-types.d.ts +40 -0
- package/lib/profile-types.js +2 -0
- package/lib/profiles.d.ts +26 -0
- package/lib/profiles.js +237 -0
- package/lib/prompts.d.ts +2 -2
- package/lib/prompts.js +4 -4
- package/lib/recovery-policy.js +1 -1
- package/lib/role-providers.d.ts +13 -0
- package/lib/role-providers.js +94 -0
- package/lib/role-routing.d.ts +15 -0
- package/lib/role-routing.js +147 -0
- package/lib/role-subagents.d.ts +2 -2
- package/lib/role-subagents.js +6 -4
- package/lib/roles.d.ts +9 -4
- package/lib/roles.js +54 -36
- package/lib/runtime-recovery.d.ts +2 -2
- package/lib/runtime-recovery.js +36 -17
- package/lib/session-metadata.d.ts +13 -0
- package/lib/session-metadata.js +34 -0
- package/lib/session-persistence.d.ts +35 -0
- package/lib/session-persistence.js +304 -0
- package/lib/session-scope.d.ts +6 -1
- package/lib/session-scope.js +23 -0
- package/lib/settings.d.ts +20 -2
- package/lib/settings.js +127 -39
- package/lib/state.d.ts +1 -0
- package/lib/state.js +4 -0
- package/lib/status.d.ts +11 -2
- package/lib/status.js +52 -13
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +67 -15
- package/patches/agent-presets-root.example.cordis.patch.yml +6 -10
- package/prompts/deepseek-v4-pro.md +1 -1
- package/prompts/deepwork.md +3 -3
- package/scripts/repair-session-log.mjs +476 -0
- package/scripts/session-repair-native-verifier.mjs +367 -0
package/lib/roles.d.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import type { DsmmSkillName } from "./skills.js";
|
|
2
|
+
import type { DsmmModelRoute, DsmmRoleRouting } from "./settings.js";
|
|
2
3
|
export declare const DSMM_ROLE_IDS: readonly ["dsmm-orchestrator", "dsmm-planner", "dsmm-plan-critic", "dsmm-builder", "dsmm-reviewer", "dsmm-oracle", "dsmm-oracle-2nd", "dsmm-creative", "dsmm-code-search", "dsmm-doc-search", "dsmm-clarifier", "dsmm-media-reader"];
|
|
3
4
|
export type DsmmRoleId = (typeof DSMM_ROLE_IDS)[number];
|
|
5
|
+
export type DsmmRoleMode = "primary" | "all" | "subagent";
|
|
4
6
|
export interface DsmmRoleDefinition {
|
|
5
7
|
id: DsmmRoleId;
|
|
6
8
|
name: string;
|
|
7
9
|
description: string;
|
|
8
10
|
order: number;
|
|
11
|
+
mode: DsmmRoleMode;
|
|
9
12
|
enabledByDefault: boolean;
|
|
10
13
|
access?: "read-only" | "write";
|
|
11
14
|
persona: string;
|
|
12
15
|
}
|
|
13
16
|
export declare const DSMM_ROLES: readonly DsmmRoleDefinition[];
|
|
14
17
|
export declare function isDsmmRoleId(value: unknown): value is DsmmRoleId;
|
|
15
|
-
|
|
18
|
+
/** Root exposure is separate from whether a role is enabled for delegation. */
|
|
19
|
+
export declare function isRootRole(role: Pick<DsmmRoleDefinition, "mode">): boolean;
|
|
20
|
+
export declare function renderAgentCordis(role: DsmmRoleDefinition, skills?: readonly DsmmSkillName[], enabledRoles?: readonly DsmmRoleId[], roleRouting?: DsmmRoleRouting): string;
|
|
16
21
|
export interface RolePluginRow {
|
|
17
22
|
id: string;
|
|
18
23
|
name: string;
|
|
@@ -20,9 +25,9 @@ export interface RolePluginRow {
|
|
|
20
25
|
disabled?: boolean;
|
|
21
26
|
}
|
|
22
27
|
/** The native PresetDefinition and the static YAML mirror use this same inventory. */
|
|
23
|
-
export declare function rolePluginRows(role: DsmmRoleDefinition, skills?: readonly DsmmSkillName[], enabledRoles?: readonly DsmmRoleId[]): RolePluginRow[];
|
|
28
|
+
export declare function rolePluginRows(role: DsmmRoleDefinition, skills?: readonly DsmmSkillName[], enabledRoles?: readonly DsmmRoleId[], roleRouting?: DsmmRoleRouting): RolePluginRow[];
|
|
24
29
|
/** DSH's spawn provider joins the parent's preset; persona/filter give each child its own role. */
|
|
25
|
-
export declare function roleSubagentPluginRows(enabledRoles?: readonly DsmmRoleId[]): RolePluginRow[];
|
|
26
|
-
export declare function roleSubagentConfig(role: DsmmRoleDefinition, availableTools?: readonly string[]): Record<string, unknown>;
|
|
30
|
+
export declare function roleSubagentPluginRows(enabledRoles?: readonly DsmmRoleId[], roleRouting?: DsmmRoleRouting): RolePluginRow[];
|
|
31
|
+
export declare function roleSubagentConfig(role: DsmmRoleDefinition, availableTools?: readonly string[], primary?: DsmmModelRoute): Record<string, unknown>;
|
|
27
32
|
export declare function renderPresetMetadata(role: DsmmRoleDefinition): string;
|
|
28
33
|
//# sourceMappingURL=roles.d.ts.map
|
package/lib/roles.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DSMM_SKILL_NAMES } from "./skills.js";
|
|
2
|
+
import { roleProviderName } from "./role-providers.js";
|
|
2
3
|
export const DSMM_ROLE_IDS = [
|
|
3
4
|
"dsmm-orchestrator",
|
|
4
5
|
"dsmm-planner",
|
|
@@ -16,11 +17,12 @@ export const DSMM_ROLE_IDS = [
|
|
|
16
17
|
export const DSMM_ROLES = [
|
|
17
18
|
{
|
|
18
19
|
id: "dsmm-orchestrator",
|
|
19
|
-
name: "
|
|
20
|
-
description: "Coordinates
|
|
20
|
+
name: "DW Orchestrator",
|
|
21
|
+
description: "Coordinates Deepwork sessions and routes work to focused DW roles.",
|
|
21
22
|
order: 10,
|
|
23
|
+
mode: "primary",
|
|
22
24
|
enabledByDefault: true,
|
|
23
|
-
persona: `You are dsmm-orchestrator, a dsh-native coordinator for deepwork sessions.
|
|
25
|
+
persona: `You are DW Orchestrator (role ID: dsmm-orchestrator), a dsh-native coordinator for deepwork sessions.
|
|
24
26
|
For complex behavior implementation, default to planner → plan-critic → implementation; for simple bounded low-risk work, proceed directly. A clear implementation request authorizes its stated scope without repeated design approval.
|
|
25
27
|
Delegate bounded work only through callable role-specific DSH tools: dsmm-planner, dsmm-plan-critic, dsmm-builder, dsmm-reviewer, dsmm-oracle, dsmm-oracle-2nd, dsmm-creative, dsmm-code-search, dsmm-doc-search, dsmm-clarifier and dsmm-media-reader.
|
|
26
28
|
Reviewer is primary-lane self-review; use Oracle only for a useful external cross-check when a different model was explicitly selected. Review when risk warrants it, not in a fixed loop.
|
|
@@ -28,111 +30,122 @@ Keep scope explicit, preserve user constraints, and do not claim a preset is act
|
|
|
28
30
|
},
|
|
29
31
|
{
|
|
30
32
|
id: "dsmm-planner",
|
|
31
|
-
name: "
|
|
33
|
+
name: "DW Planner",
|
|
32
34
|
description: "Turns approved scope into ordered implementation steps with verification gates.",
|
|
33
35
|
order: 20,
|
|
36
|
+
mode: "all",
|
|
34
37
|
enabledByDefault: true,
|
|
35
38
|
access: "read-only",
|
|
36
|
-
persona: `You are dsmm-planner, a dsh-native planning specialist.
|
|
39
|
+
persona: `You are DW Planner (role ID: dsmm-planner), a dsh-native planning specialist.
|
|
37
40
|
Inspect evidence and convert approved complex work into an outcome-oriented plan with dependencies, interfaces, risks and verification. Do not implement or modify files. Flag decisions that change scope, safety or public APIs. Git writes need specific authorization.`
|
|
38
41
|
},
|
|
39
42
|
{
|
|
40
43
|
id: "dsmm-plan-critic",
|
|
41
|
-
name: "
|
|
44
|
+
name: "DW Plan Critic",
|
|
42
45
|
description: "Checks implementation plans for ambiguity, missing evidence, and unsafe sequencing.",
|
|
43
46
|
order: 30,
|
|
47
|
+
mode: "subagent",
|
|
44
48
|
enabledByDefault: true,
|
|
45
49
|
access: "read-only",
|
|
46
|
-
persona: `You are dsmm-plan-critic, a dsh-native plan review specialist.
|
|
50
|
+
persona: `You are DW Plan Critic (role ID: dsmm-plan-critic), a dsh-native plan review specialist.
|
|
47
51
|
Inspect the plan and evidence for material blockers in outcome coverage, dependencies, tests, safety and scope. Return concrete blockers or a concise pass with residual risks; do not require a fixed format or repeated reviews after editorial changes. Read only; do not implement or perform Git writes.`
|
|
48
52
|
},
|
|
49
53
|
{
|
|
50
54
|
id: "dsmm-builder",
|
|
51
|
-
name: "
|
|
55
|
+
name: "DW Builder",
|
|
52
56
|
description: "Implements one bounded approved outcome and verifies the changed surface.",
|
|
53
57
|
order: 35,
|
|
58
|
+
mode: "primary",
|
|
54
59
|
enabledByDefault: true,
|
|
55
60
|
access: "write",
|
|
56
|
-
persona: `You are dsmm-builder, a bounded implementation worker. Respect assigned file ownership and other workers' changes. Implement only the approved outcome, verify the affected surface, and report changes, evidence and risks. Escalate changes to public APIs, permissions, safety, data guarantees or irreversible behavior. Never stage, commit, push, tag, rebase or release without specific authorization.`
|
|
61
|
+
persona: `You are DW Builder (role ID: dsmm-builder), a bounded implementation worker. Respect assigned file ownership and other workers' changes. Implement only the approved outcome, verify the affected surface, and report changes, evidence and risks. Escalate changes to public APIs, permissions, safety, data guarantees or irreversible behavior. Never stage, commit, push, tag, rebase or release without specific authorization.`
|
|
57
62
|
},
|
|
58
63
|
{
|
|
59
64
|
id: "dsmm-reviewer",
|
|
60
|
-
name: "
|
|
65
|
+
name: "DW Reviewer",
|
|
61
66
|
description: "Reviews completed changes against requirements, tests, and regression risk.",
|
|
62
67
|
order: 40,
|
|
68
|
+
mode: "subagent",
|
|
63
69
|
enabledByDefault: true,
|
|
64
70
|
access: "read-only",
|
|
65
|
-
persona: `You are dsmm-reviewer, a dsh-native implementation reviewer.
|
|
71
|
+
persona: `You are DW Reviewer (role ID: dsmm-reviewer), a dsh-native implementation reviewer.
|
|
66
72
|
Read the current implementation diff and new files against requirements, conventions and verification. Prioritize actionable correctness and regression findings. This is primary-model or primary-lane self-review, not external Oracle review. Do not modify files or perform Git writes.`
|
|
67
73
|
},
|
|
68
74
|
{
|
|
69
75
|
id: "dsmm-oracle",
|
|
70
|
-
name: "
|
|
76
|
+
name: "DW Oracle",
|
|
71
77
|
description: "First-priority external-model implementation cross-check when explicitly configured.",
|
|
72
78
|
order: 42,
|
|
79
|
+
mode: "subagent",
|
|
73
80
|
enabledByDefault: true,
|
|
74
81
|
access: "read-only",
|
|
75
|
-
persona: `You are dsmm-oracle, first-priority implementation cross-check. Read only; inspect the current diff, evidence and requirements for concrete defects. Your role is externally heterogeneous only when the caller selects a different available model; do not claim model independence when inheriting the parent's route. Do not implement or perform Git writes.`
|
|
82
|
+
persona: `You are DW Oracle (role ID: dsmm-oracle), first-priority implementation cross-check. Read only; inspect the current diff, evidence and requirements for concrete defects. Your role is externally heterogeneous only when the caller selects a different available model; do not claim model independence when inheriting the parent's route. Do not implement or perform Git writes.`
|
|
76
83
|
},
|
|
77
84
|
{
|
|
78
85
|
id: "dsmm-oracle-2nd",
|
|
79
|
-
name: "
|
|
86
|
+
name: "DW Oracle 2nd",
|
|
80
87
|
description: "Second-priority external-model implementation cross-check for an additional evidence need.",
|
|
81
88
|
order: 44,
|
|
89
|
+
mode: "subagent",
|
|
82
90
|
enabledByDefault: true,
|
|
83
91
|
access: "read-only",
|
|
84
|
-
persona: `You are dsmm-oracle-2nd, second-priority implementation cross-check, not a higher-capability rank. Read only; report concrete defects in the current diff and evidence. An external model must be explicitly selected; the role label alone is no proof of independence. Do not implement or perform Git writes.`
|
|
92
|
+
persona: `You are DW Oracle 2nd (role ID: dsmm-oracle-2nd), second-priority implementation cross-check, not a higher-capability rank. Read only; report concrete defects in the current diff and evidence. An external model must be explicitly selected; the role label alone is no proof of independence. Do not implement or perform Git writes.`
|
|
85
93
|
},
|
|
86
94
|
{
|
|
87
95
|
id: "dsmm-creative",
|
|
88
|
-
name: "
|
|
96
|
+
name: "DW Creative",
|
|
89
97
|
description: "Explores unconventional but coherent approaches and explicit trade-offs.",
|
|
90
98
|
order: 46,
|
|
99
|
+
mode: "subagent",
|
|
91
100
|
enabledByDefault: true,
|
|
92
101
|
access: "read-only",
|
|
93
|
-
persona: `You are dsmm-creative. Explore distinct coherent approaches, state trade-offs, constraints and a grounded recommendation. Remain read-only unless a separate implementation assignment authorizes changes. Do not perform Git writes.`
|
|
102
|
+
persona: `You are DW Creative (role ID: dsmm-creative). Explore distinct coherent approaches, state trade-offs, constraints and a grounded recommendation. Remain read-only unless a separate implementation assignment authorizes changes. Do not perform Git writes.`
|
|
94
103
|
},
|
|
95
104
|
{
|
|
96
105
|
id: "dsmm-code-search",
|
|
97
|
-
name: "
|
|
106
|
+
name: "DW Code Search",
|
|
98
107
|
description: "Finds local codebase facts, symbols, patterns, and relevant implementation context.",
|
|
99
108
|
order: 50,
|
|
109
|
+
mode: "subagent",
|
|
100
110
|
enabledByDefault: true,
|
|
101
111
|
access: "read-only",
|
|
102
|
-
persona: `You are dsmm-code-search, a dsh-native codebase research specialist.
|
|
112
|
+
persona: `You are DW Code Search (role ID: dsmm-code-search), a dsh-native codebase research specialist.
|
|
103
113
|
Search local project context for exact files, symbols, references, and conventions needed by the caller.
|
|
104
114
|
Summarize findings with paths and evidence; do not modify files.`
|
|
105
115
|
},
|
|
106
116
|
{
|
|
107
117
|
id: "dsmm-doc-search",
|
|
108
|
-
name: "
|
|
118
|
+
name: "DW Doc Search",
|
|
109
119
|
description: "Finds current external documentation and examples for library or API questions.",
|
|
110
120
|
order: 60,
|
|
121
|
+
mode: "subagent",
|
|
111
122
|
enabledByDefault: true,
|
|
112
123
|
access: "read-only",
|
|
113
|
-
persona: `You are dsmm-doc-search, a dsh-native documentation research specialist.
|
|
124
|
+
persona: `You are DW Doc Search (role ID: dsmm-doc-search), a dsh-native documentation research specialist.
|
|
114
125
|
Find current documentation and real examples for libraries, APIs, CLIs, and services relevant to the task.
|
|
115
126
|
Cite source locations, separate facts from assumptions, and avoid guessing when documentation is unavailable.`
|
|
116
127
|
},
|
|
117
128
|
{
|
|
118
129
|
id: "dsmm-clarifier",
|
|
119
|
-
name: "
|
|
130
|
+
name: "DW Clarifier",
|
|
120
131
|
description: "Reduces ambiguous requests to the few decisions needed before planning or implementation.",
|
|
121
132
|
order: 70,
|
|
133
|
+
mode: "subagent",
|
|
122
134
|
enabledByDefault: true,
|
|
123
135
|
access: "read-only",
|
|
124
|
-
persona: `You are dsmm-clarifier, a dsh-native requirements clarification specialist.
|
|
136
|
+
persona: `You are DW Clarifier (role ID: dsmm-clarifier), a dsh-native requirements clarification specialist.
|
|
125
137
|
Identify ambiguity in purpose, constraints, success criteria, and scope boundaries.
|
|
126
138
|
Ask at most three material questions, prefer concrete choices, and propose safe defaults when evidence is strong.`
|
|
127
139
|
},
|
|
128
140
|
{
|
|
129
141
|
id: "dsmm-media-reader",
|
|
130
|
-
name: "
|
|
142
|
+
name: "DW Media Reader",
|
|
131
143
|
description: "Extracts implementation-relevant information from images, PDFs, and visual artifacts.",
|
|
132
144
|
order: 80,
|
|
145
|
+
mode: "subagent",
|
|
133
146
|
enabledByDefault: true,
|
|
134
147
|
access: "read-only",
|
|
135
|
-
persona: `You are dsmm-media-reader, a dsh-native visual and document analysis specialist.
|
|
148
|
+
persona: `You are DW Media Reader (role ID: dsmm-media-reader), a dsh-native visual and document analysis specialist.
|
|
136
149
|
Extract text, structure, UI details, diagrams, and implementation-relevant facts from provided media.
|
|
137
150
|
Report uncertainty clearly and avoid inventing details that are not visible.`
|
|
138
151
|
}
|
|
@@ -140,14 +153,18 @@ Report uncertainty clearly and avoid inventing details that are not visible.`
|
|
|
140
153
|
export function isDsmmRoleId(value) {
|
|
141
154
|
return typeof value === "string" && DSMM_ROLE_IDS.includes(value);
|
|
142
155
|
}
|
|
143
|
-
|
|
144
|
-
|
|
156
|
+
/** Root exposure is separate from whether a role is enabled for delegation. */
|
|
157
|
+
export function isRootRole(role) {
|
|
158
|
+
return role.mode === "primary" || role.mode === "all";
|
|
159
|
+
}
|
|
160
|
+
export function renderAgentCordis(role, skills = DSMM_SKILL_NAMES, enabledRoles = DSMM_ROLE_IDS, roleRouting = {}) {
|
|
161
|
+
return rolePluginRows(role, skills, enabledRoles, roleRouting).map(renderPluginRow).join("");
|
|
145
162
|
}
|
|
146
163
|
/** The native PresetDefinition and the static YAML mirror use this same inventory. */
|
|
147
|
-
export function rolePluginRows(role, skills = DSMM_SKILL_NAMES, enabledRoles = DSMM_ROLE_IDS) {
|
|
164
|
+
export function rolePluginRows(role, skills = DSMM_SKILL_NAMES, enabledRoles = DSMM_ROLE_IDS, roleRouting = {}) {
|
|
148
165
|
const rows = [
|
|
149
|
-
{ id: "persona", name: "@deepseek-ai/dsh-persona", config: {
|
|
150
|
-
{ id: "agent-instructions", name: "@deepseek-ai/dsh-agent-instructions" },
|
|
166
|
+
{ id: "persona", name: "@deepseek-ai/dsh-persona", config: { prefix: role.persona } },
|
|
167
|
+
{ id: "agent-instructions", name: "@deepseek-ai/dsh-agent-instructions", config: { maxBytes: 65536 } },
|
|
151
168
|
{ id: "tool-fs", name: "@deepseek-ai/dsh-tool-fs" },
|
|
152
169
|
{ id: "tool-fs-search", name: "@deepseek-ai/dsh-tool-fs-search", config: { sampleOverCapGlobResults: false } },
|
|
153
170
|
{ id: "tool-web", name: "@deepseek-ai/dsh-tool-web", config: { fetch: true } },
|
|
@@ -161,18 +178,18 @@ export function rolePluginRows(role, skills = DSMM_SKILL_NAMES, enabledRoles = D
|
|
|
161
178
|
rows.push({ id: "tool-jobs", name: "@deepseek-ai/dsh-tool-jobs" });
|
|
162
179
|
}
|
|
163
180
|
if (role.id === "dsmm-orchestrator" || role.id === "dsmm-builder")
|
|
164
|
-
rows.push(...roleSubagentPluginRows(enabledRoles));
|
|
181
|
+
rows.push(...roleSubagentPluginRows(enabledRoles, roleRouting));
|
|
165
182
|
return rows;
|
|
166
183
|
}
|
|
167
184
|
/** DSH's spawn provider joins the parent's preset; persona/filter give each child its own role. */
|
|
168
|
-
export function roleSubagentPluginRows(enabledRoles = DSMM_ROLE_IDS) {
|
|
185
|
+
export function roleSubagentPluginRows(enabledRoles = DSMM_ROLE_IDS, roleRouting = {}) {
|
|
169
186
|
return DSMM_ROLES.filter((role) => role.id !== "dsmm-orchestrator" && enabledRoles.includes(role.id)).map((role) => ({
|
|
170
187
|
id: `subagent-${role.id}`,
|
|
171
188
|
name: "@deepseek-ai/dsh-tool-subagent",
|
|
172
|
-
config: roleSubagentConfig(role)
|
|
189
|
+
config: roleSubagentConfig(role, [], roleRouting[role.id]?.primary)
|
|
173
190
|
}));
|
|
174
191
|
}
|
|
175
|
-
export function roleSubagentConfig(role, availableTools = []) {
|
|
192
|
+
export function roleSubagentConfig(role, availableTools = [], primary) {
|
|
176
193
|
const readOnlyTools = ["read", "glob", "grep"];
|
|
177
194
|
if (role.id === "dsmm-doc-search" || role.id === "dsmm-media-reader") {
|
|
178
195
|
readOnlyTools.push("web_search", "web_fetch");
|
|
@@ -182,7 +199,8 @@ export function roleSubagentConfig(role, availableTools = []) {
|
|
|
182
199
|
if (role.id === "dsmm-media-reader" && availableTools.includes("read_image"))
|
|
183
200
|
readOnlyTools.push("read_image");
|
|
184
201
|
return {
|
|
185
|
-
provider:
|
|
202
|
+
provider: roleProviderName(role.id),
|
|
203
|
+
...(primary === undefined ? {} : { agentOptions: { ...primary } }),
|
|
186
204
|
toolName: role.id.replace(/-/gu, "_"),
|
|
187
205
|
// A standing preset with modelSelectionSettings=true re-registers tools in
|
|
188
206
|
// each child Agent's own scope. DSH restrictions filter inherited tools,
|
|
@@ -225,7 +243,7 @@ function renderPluginRow(row) {
|
|
|
225
243
|
if (Array.isArray(nestedValue))
|
|
226
244
|
output += nestedValue.length === 0 ? ` ${nestedKey}: []\n` : ` ${nestedKey}:\n${nestedValue.map((item) => ` - ${quoteYamlString(String(item))}\n`).join("")}`;
|
|
227
245
|
else
|
|
228
|
-
output += ` ${nestedKey}: ${String(nestedValue)}\n`;
|
|
246
|
+
output += ` ${nestedKey}: ${typeof nestedValue === "string" ? quoteYamlString(nestedValue) : String(nestedValue)}\n`;
|
|
229
247
|
}
|
|
230
248
|
}
|
|
231
249
|
else
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DshContext } from "./dsh-types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DsmmSettingsGetter } from "./settings.js";
|
|
3
3
|
import type { DeepworkModeController } from "./state.js";
|
|
4
|
-
export declare function registerRuntimeRecovery(ctx: DshContext, controller: DeepworkModeController, getSettings:
|
|
4
|
+
export declare function registerRuntimeRecovery(ctx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): void;
|
|
5
5
|
//# sourceMappingURL=runtime-recovery.d.ts.map
|
package/lib/runtime-recovery.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
2
2
|
import { classifyRecoveryFailure, foldAttemptedRecoveryRoutes, foldDurableRecoveryWork, isCurrentRecoveryStep, selectFallbackRoute } from "./recovery-policy.js";
|
|
3
3
|
import { isDsmmRoleId } from "./roles.js";
|
|
4
|
-
import {
|
|
4
|
+
import { applyModelRoute, effectiveRoleFallbackRoutes, recordAdmittedRecoveryRoute, rolePolicyIdentity, sameModelRoute } from "./role-routing.js";
|
|
5
|
+
import { childOwnedSessionEvents, resolveEffectiveDsmmRole, resolveSelectedAgentPreset, sessionEvents } from "./session-scope.js";
|
|
5
6
|
const installedContexts = new WeakSet();
|
|
6
7
|
const RECOVERY_WARNING = "dsmm runtime recovery could not evaluate fallback; preserving the host request-error decision";
|
|
7
8
|
const CONTINUATION_WARNING = "dsmm runtime recovery continuation steering failed for turn";
|
|
@@ -11,6 +12,9 @@ function warnSafely(ctx, message) {
|
|
|
11
12
|
}
|
|
12
13
|
catch { }
|
|
13
14
|
}
|
|
15
|
+
function recoveryEvents(agent) {
|
|
16
|
+
return agent.session.header?.origin === "subagent" ? childOwnedSessionEvents(agent.session) : sessionEvents(agent.session);
|
|
17
|
+
}
|
|
14
18
|
export function registerRuntimeRecovery(ctx, controller, getSettings) {
|
|
15
19
|
if (installedContexts.has(ctx) || ctx.on === undefined)
|
|
16
20
|
return;
|
|
@@ -45,20 +49,31 @@ export function registerRuntimeRecovery(ctx, controller, getSettings) {
|
|
|
45
49
|
const pending = pendingByAgent.get(frame.agent);
|
|
46
50
|
if (pending === undefined)
|
|
47
51
|
return downstream;
|
|
48
|
-
if (frame.signal.aborted || !isCurrentRecoveryStep(
|
|
52
|
+
if (frame.signal.aborted || !isCurrentRecoveryStep(recoveryEvents(frame.agent), pending.turn, pending.step)) {
|
|
49
53
|
pendingByAgent.delete(frame.agent);
|
|
50
54
|
return downstream;
|
|
51
55
|
}
|
|
52
56
|
if (pending.turn !== frame.turn || pending.step !== frame.step)
|
|
53
57
|
return downstream;
|
|
58
|
+
if (pending.policy !== undefined) {
|
|
59
|
+
const settings = getSettings(frame.agent);
|
|
60
|
+
const role = resolveEffectiveDsmmRole(frame.agent, settings, controller.active(frame.agent, settings.defaultActive));
|
|
61
|
+
if (role !== pending.role || rolePolicyIdentity(settings, role) !== pending.policy) {
|
|
62
|
+
pendingByAgent.delete(frame.agent);
|
|
63
|
+
reservedByAgent.delete(frame.agent);
|
|
64
|
+
return downstream;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const reserved = reservedByAgent.get(frame.agent);
|
|
68
|
+
const accepted = frame.agent.session.requestHeader?.()?.config;
|
|
69
|
+
if (reserved !== undefined && accepted !== undefined && !sameModelRoute(accepted, reserved.route) && !sameModelRoute(accepted, pending.route)) {
|
|
70
|
+
pendingByAgent.delete(frame.agent);
|
|
71
|
+
return downstream;
|
|
72
|
+
}
|
|
54
73
|
pendingByAgent.delete(frame.agent);
|
|
55
|
-
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
provider: pending.route.provider,
|
|
59
|
-
model: pending.route.model
|
|
60
|
-
};
|
|
61
|
-
});
|
|
74
|
+
recordAdmittedRecoveryRoute(frame, pending.route);
|
|
75
|
+
return applyModelRoute(downstream, pending.route);
|
|
76
|
+
}, { prepend: true });
|
|
62
77
|
disposeRequestError = ctx.on("agent/request-error", async (frame, next) => {
|
|
63
78
|
const downstream = await next();
|
|
64
79
|
if (downstream?.kind === "retry") {
|
|
@@ -66,22 +81,26 @@ export function registerRuntimeRecovery(ctx, controller, getSettings) {
|
|
|
66
81
|
return downstream;
|
|
67
82
|
}
|
|
68
83
|
try {
|
|
69
|
-
const settings = getSettings();
|
|
84
|
+
const settings = getSettings(frame.agent);
|
|
70
85
|
if (!settings.runtimeRecovery.enabled || frame.signal.aborted
|
|
71
|
-
|| !isCurrentRecoveryStep(
|
|
86
|
+
|| !isCurrentRecoveryStep(recoveryEvents(frame.agent), frame.turn, frame.step))
|
|
72
87
|
return downstream;
|
|
73
88
|
const preset = resolveSelectedAgentPreset(frame.agent.session);
|
|
74
|
-
const
|
|
89
|
+
const role = resolveEffectiveDsmmRole(frame.agent, settings, controller.active(frame.agent, settings.defaultActive));
|
|
90
|
+
const inScope = role !== undefined || controller.active(frame.agent, settings.defaultActive)
|
|
91
|
+
|| (frame.agent.session.header?.origin !== "subagent" && isDsmmRoleId(preset) && settings.roles[preset]);
|
|
75
92
|
if (!inScope || classifyRecoveryFailure(frame.failure, settings.runtimeRecovery).kind !== "retryable")
|
|
76
93
|
return downstream;
|
|
77
94
|
const header = frame.agent.session.requestHeader?.();
|
|
78
95
|
if (header === undefined || header.config.provider !== frame.provider)
|
|
79
96
|
return downstream;
|
|
97
|
+
const policy = rolePolicyIdentity(settings, role);
|
|
80
98
|
const reserved = reservedByAgent.get(frame.agent);
|
|
81
99
|
if (reserved?.turn === frame.turn && reserved.step === frame.step
|
|
100
|
+
&& reserved.policy === policy
|
|
82
101
|
&& reserved.route.provider === header.config.provider && reserved.route.model === header.config.model)
|
|
83
102
|
return downstream;
|
|
84
|
-
const attemptedRoutes = foldAttemptedRecoveryRoutes(
|
|
103
|
+
const attemptedRoutes = foldAttemptedRecoveryRoutes(recoveryEvents(frame.agent), frame.turn, frame.step);
|
|
85
104
|
const lastAttemptedRoute = attemptedRoutes.at(-1);
|
|
86
105
|
if (lastAttemptedRoute === undefined
|
|
87
106
|
|| lastAttemptedRoute.provider !== header.config.provider
|
|
@@ -90,16 +109,16 @@ export function registerRuntimeRecovery(ctx, controller, getSettings) {
|
|
|
90
109
|
const route = selectFallbackRoute({
|
|
91
110
|
failedRoute: { provider: header.config.provider, model: header.config.model },
|
|
92
111
|
attemptedRoutes,
|
|
93
|
-
fallbackRoutes: settings
|
|
112
|
+
fallbackRoutes: effectiveRoleFallbackRoutes(settings, role),
|
|
94
113
|
maxFallbackAttempts: settings.runtimeRecovery.maxFallbackAttempts
|
|
95
114
|
});
|
|
96
115
|
if (route === undefined)
|
|
97
116
|
return downstream;
|
|
98
117
|
reservedByAgent.set(frame.agent, {
|
|
99
118
|
turn: frame.turn, step: frame.step,
|
|
100
|
-
route: { provider: header.config.provider, model: header.config.model }
|
|
119
|
+
route: { provider: header.config.provider, model: header.config.model }, role, policy
|
|
101
120
|
});
|
|
102
|
-
pendingByAgent.set(frame.agent, { turn: frame.turn, step: frame.step, route });
|
|
121
|
+
pendingByAgent.set(frame.agent, { turn: frame.turn, step: frame.step, route, role, policy });
|
|
103
122
|
return { kind: "retry" };
|
|
104
123
|
}
|
|
105
124
|
catch {
|
|
@@ -109,7 +128,7 @@ export function registerRuntimeRecovery(ctx, controller, getSettings) {
|
|
|
109
128
|
}, { prepend: true });
|
|
110
129
|
disposeTurnStopping = ctx.on("agent/turn-stopping", async (frame) => {
|
|
111
130
|
try {
|
|
112
|
-
const settings = getSettings();
|
|
131
|
+
const settings = getSettings(frame.agent);
|
|
113
132
|
const continuation = settings.runtimeRecovery.idleContinuation;
|
|
114
133
|
if (!settings.runtimeRecovery.enabled || !continuation.enabled || frame.signal.aborted)
|
|
115
134
|
return;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DshContext } from "./dsh-types.js";
|
|
2
|
+
export declare const DSMM_PERSISTENCE_COMPATIBILITY: unique symbol;
|
|
3
|
+
/** An ephemeral Host without persistence is safe; a durable Host must use the compatible provider. */
|
|
4
|
+
export declare function assertDsmmMetadataPersistence(ctx: DshContext | undefined): void;
|
|
5
|
+
/** Only these audited, model-hidden records are safe for a stock reader to skip. */
|
|
6
|
+
export declare function annotateDsmmEvent<T extends {
|
|
7
|
+
type: string;
|
|
8
|
+
data?: unknown;
|
|
9
|
+
ignorable?: unknown;
|
|
10
|
+
}>(event: T): T & {
|
|
11
|
+
ignorable?: true;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=session-metadata.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isDsmmRoleId } from "./roles.js";
|
|
2
|
+
export const DSMM_PERSISTENCE_COMPATIBILITY = Symbol.for("dsmm.sessionPersistence.ignorable.v1");
|
|
3
|
+
/** An ephemeral Host without persistence is safe; a durable Host must use the compatible provider. */
|
|
4
|
+
export function assertDsmmMetadataPersistence(ctx) {
|
|
5
|
+
const persistence = ctx?.get?.("sessionPersistence");
|
|
6
|
+
if (persistence !== undefined && (typeof persistence !== "object" || persistence === null
|
|
7
|
+
|| persistence[DSMM_PERSISTENCE_COMPATIBILITY] !== true)) {
|
|
8
|
+
throw new Error("Deepwork requires @dsmm/dsmm/session-persistence for durable session metadata; no unsafe event was appended");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** Only these audited, model-hidden records are safe for a stock reader to skip. */
|
|
12
|
+
export function annotateDsmmEvent(event) {
|
|
13
|
+
if (event.type !== "deepwork/mode" && event.type !== "dsmm/role-policy")
|
|
14
|
+
return event;
|
|
15
|
+
const envelope = event;
|
|
16
|
+
const allowedKeys = ["type", "seq", "time", "data", "ignorable"];
|
|
17
|
+
const validEnvelope = Reflect.ownKeys(event).every((key) => typeof key === "string" && allowedKeys.includes(key))
|
|
18
|
+
&& ["type", "seq", "time", "data"].every((key) => Object.hasOwn(event, key))
|
|
19
|
+
&& Number.isSafeInteger(envelope.seq) && envelope.seq >= 0 && !Object.is(envelope.seq, -0)
|
|
20
|
+
&& Number.isSafeInteger(envelope.time);
|
|
21
|
+
const data = event.data;
|
|
22
|
+
const record = typeof data === "object" && data !== null && !Array.isArray(data)
|
|
23
|
+
&& (Object.getPrototypeOf(data) === Object.prototype || Object.getPrototypeOf(data) === null)
|
|
24
|
+
? data : undefined;
|
|
25
|
+
const valid = record !== undefined && (event.type === "deepwork/mode"
|
|
26
|
+
? Reflect.ownKeys(record).length === 1 && typeof record.active === "boolean"
|
|
27
|
+
: Reflect.ownKeys(record).length === 3 && record.version === 1 && isDsmmRoleId(record.role)
|
|
28
|
+
&& (record.policy === null || typeof record.policy === "string" && /^[a-f0-9]{64}$/u.test(record.policy)));
|
|
29
|
+
if (!validEnvelope || !valid || event.ignorable !== undefined && event.ignorable !== true) {
|
|
30
|
+
throw new TypeError("invalid Deepwork session metadata; refusing to mark it ignorable");
|
|
31
|
+
}
|
|
32
|
+
return event.ignorable === true ? event : { ...event, ignorable: true };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=session-metadata.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Context, Service } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { SessionHeader, SessionId } from "@deepseek-ai/dsh-session";
|
|
3
|
+
import { SessionPersistence } from "@deepseek-ai/dsh-session-persistence";
|
|
4
|
+
import type { SessionAccess, SessionHandle, SessionPersistenceCreateOptions, SessionPersistenceListOptions, SessionPersistenceOpenOptions, SessionPersistenceStatOptions } from "@deepseek-ai/dsh-session-persistence";
|
|
5
|
+
import type { Config } from "@deepseek-ai/dsh-session-persistence-jsonl";
|
|
6
|
+
export { DSMM_PERSISTENCE_COMPATIBILITY } from "./session-metadata.js";
|
|
7
|
+
export type { Config } from "@deepseek-ai/dsh-session-persistence-jsonl";
|
|
8
|
+
/**
|
|
9
|
+
* Drop-in native JSONL persistence companion for audited DSMM metadata.
|
|
10
|
+
* A separate root Context is intentional: a child service-isolation scope still
|
|
11
|
+
* shares the host event bus and would persist every live event twice.
|
|
12
|
+
*/
|
|
13
|
+
export default class DsmmSessionPersistence extends SessionPersistence {
|
|
14
|
+
readonly config: Config;
|
|
15
|
+
static Config: import("@deepseek-ai/schemastery").default<Config>;
|
|
16
|
+
readonly name = "dsmm-session-persistence";
|
|
17
|
+
private readonly inner;
|
|
18
|
+
private readonly ready;
|
|
19
|
+
private readonly handles;
|
|
20
|
+
private readonly writers;
|
|
21
|
+
private readonly acquisitions;
|
|
22
|
+
private readonly closeFailures;
|
|
23
|
+
private disposed;
|
|
24
|
+
constructor(ctx: Context, config: Config);
|
|
25
|
+
[Service.init](): Promise<void>;
|
|
26
|
+
create(header: SessionHeader, options?: SessionPersistenceCreateOptions): Promise<SessionHandle>;
|
|
27
|
+
open(id: SessionId, access: SessionAccess, options?: SessionPersistenceOpenOptions): Promise<SessionHandle>;
|
|
28
|
+
flush(): Promise<void>;
|
|
29
|
+
stat(id: SessionId, options?: SessionPersistenceStatOptions): Promise<import("@deepseek-ai/dsh-session-persistence").SessionPersistenceSnapshot | undefined>;
|
|
30
|
+
list(options?: SessionPersistenceListOptions): Promise<readonly import("@deepseek-ai/dsh-session-persistence").SessionPersistenceSnapshot[]>;
|
|
31
|
+
private acquire;
|
|
32
|
+
private warn;
|
|
33
|
+
private assertActive;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=session-persistence.d.ts.map
|