@dsmm/dsmm 0.1.1 → 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 +24 -13
- package/agent-presets/dsmm-builder/agent.cordis.yml +14 -12
- 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 +15 -13
- 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 +15 -5
- package/docs/compatibility.md +64 -11
- package/docs/model-routing.md +10 -6
- package/docs/profiles.md +83 -0
- package/docs/releasing.md +58 -19
- package/docs/settings-status.md +13 -5
- 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-types.d.ts +4 -0
- package/lib/guards.d.ts +2 -2
- package/lib/guards.js +3 -2
- package/lib/index.d.ts +12 -4
- package/lib/index.js +72 -20
- 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 +17 -2
- package/lib/preset-registry.js +5 -3
- 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/role-providers.d.ts +2 -2
- package/lib/role-providers.js +39 -6
- package/lib/role-routing.d.ts +2 -2
- package/lib/role-routing.js +4 -1
- package/lib/role-subagents.d.ts +2 -2
- package/lib/role-subagents.js +6 -4
- package/lib/roles.d.ts +4 -0
- package/lib/roles.js +43 -27
- package/lib/runtime-recovery.d.ts +2 -2
- package/lib/runtime-recovery.js +3 -3
- 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/settings.d.ts +8 -1
- package/lib/settings.js +4 -0
- package/lib/state.d.ts +1 -0
- package/lib/state.js +4 -0
- package/lib/status.js +6 -5
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +62 -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/profiles.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { getNodeValue, parseTree } from "jsonc-parser";
|
|
2
|
+
import { DSMM_ROLE_IDS } from "./roles.js";
|
|
3
|
+
import { resolveConfig } from "./settings.js";
|
|
4
|
+
export const MAX_PROFILE_BYTES = 128 * 1024;
|
|
5
|
+
export const MAX_PROFILE_COUNT = 128;
|
|
6
|
+
export const MAX_PROFILE_DIRECTORY_ENTRIES = 1024;
|
|
7
|
+
export const MAX_PROFILE_REVISIONS = 1024;
|
|
8
|
+
export class DsmmProfileError extends Error {
|
|
9
|
+
code;
|
|
10
|
+
field;
|
|
11
|
+
constructor(code, message, field) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "DsmmProfileError";
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.field = field;
|
|
16
|
+
}
|
|
17
|
+
toInfo() {
|
|
18
|
+
return { code: this.code, message: this.message, ...(this.field === undefined ? {} : { field: this.field }) };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function profileErrorInfo(error, fallback = "io") {
|
|
22
|
+
return error instanceof DsmmProfileError ? error.toInfo() : { code: fallback, message: "Deepwork profile operation failed; the previous selection and files were retained." };
|
|
23
|
+
}
|
|
24
|
+
export function validateProfileId(id) {
|
|
25
|
+
if (typeof id !== "string" || !/^[a-z0-9][a-z0-9_-]{0,63}$/u.test(id) || /^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])$/iu.test(id)) {
|
|
26
|
+
throw new DsmmProfileError("validation", "Profile ID must be 1–64 lowercase ASCII letters, digits, hyphens or underscores, and not a Windows reserved name.", "id");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function validateProfileRevision(revision, field = "expectedRevision") {
|
|
30
|
+
if (typeof revision !== "string" || !/^[a-f0-9]{64}$/u.test(revision))
|
|
31
|
+
invalid(field, "must be a SHA256 file revision");
|
|
32
|
+
}
|
|
33
|
+
const OVERLAY_FIELDS = ["defaultActive", "roleRouting", "workflow", "guards", "runtimeRecovery", "deepseekV4ProCalibration", "deepseekV4ProDefaultReasoningEffort", "deepseekV4ProMaxReasoningPresets", "deepseekFlashCalibration", "deepseekFlashDefaultReasoningEffort", "deepseekFlashMaxReasoningPresets"];
|
|
34
|
+
const FORBIDDEN_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
35
|
+
export function parseProfileDocument(content, expectedId) {
|
|
36
|
+
if (typeof content !== "string")
|
|
37
|
+
invalid("content", "must be JSONC text");
|
|
38
|
+
if (content.length > MAX_PROFILE_BYTES)
|
|
39
|
+
throw new DsmmProfileError("limit", "Profile files must not exceed 128 KiB.", "content");
|
|
40
|
+
const encoded = new TextEncoder().encode(content);
|
|
41
|
+
if (encoded.byteLength > MAX_PROFILE_BYTES)
|
|
42
|
+
throw new DsmmProfileError("limit", "Profile files must not exceed 128 KiB.", "content");
|
|
43
|
+
if (new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(encoded) !== content)
|
|
44
|
+
invalid("content", "must round-trip through UTF-8 without unpaired UTF-16 surrogates");
|
|
45
|
+
const errors = [];
|
|
46
|
+
const tree = parseTree(content.replace(/^\uFEFF/u, ""), errors, { allowTrailingComma: true, disallowComments: false, allowEmptyContent: false });
|
|
47
|
+
if (tree === undefined || errors.length > 0)
|
|
48
|
+
invalid("content", "must contain one valid JSONC document (comments and trailing commas are allowed)");
|
|
49
|
+
validateTree(tree, 0);
|
|
50
|
+
const document = record(getNodeValue(tree), "document");
|
|
51
|
+
keys(document, ["version", "id", "label", "settings"], "document");
|
|
52
|
+
if (document.version !== 1)
|
|
53
|
+
invalid("version", "must be 1");
|
|
54
|
+
validateProfileId(document.id);
|
|
55
|
+
if (expectedId !== undefined && document.id !== expectedId)
|
|
56
|
+
invalid("id", "must match the profile filename ID");
|
|
57
|
+
if (Object.hasOwn(document, "label"))
|
|
58
|
+
string(document.label, "label", 120);
|
|
59
|
+
const overlay = record(document.settings, "settings");
|
|
60
|
+
keys(overlay, OVERLAY_FIELDS, "settings", "Only runtime settings are supported; keep roles, skills, installation, providers, credentials, presets and LSP configuration in the native deployment configuration.");
|
|
61
|
+
optional(overlay, "defaultActive", bool, "settings");
|
|
62
|
+
for (const prefix of ["deepseekV4Pro", "deepseekFlash"]) {
|
|
63
|
+
optional(overlay, `${prefix}Calibration`, (value, field) => enumeration(value, ["off", "auto", "strict"], field), "settings");
|
|
64
|
+
optional(overlay, `${prefix}DefaultReasoningEffort`, (value, field) => enumeration(value, ["off", "low", "high"], field), "settings");
|
|
65
|
+
optional(overlay, `${prefix}MaxReasoningPresets`, roleList, "settings");
|
|
66
|
+
}
|
|
67
|
+
optional(overlay, "roleRouting", roleRouting, "settings");
|
|
68
|
+
optional(overlay, "workflow", workflow, "settings");
|
|
69
|
+
optional(overlay, "guards", guards, "settings");
|
|
70
|
+
optional(overlay, "runtimeRecovery", recovery, "settings");
|
|
71
|
+
const result = clone(document);
|
|
72
|
+
// The package's existing resolver remains authoritative for semantic normalization.
|
|
73
|
+
try {
|
|
74
|
+
resolveConfig(result.settings);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
invalid("settings", "contains an invalid Deepwork runtime policy");
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
export function mergeProfileConfig(baseline, overlay) {
|
|
82
|
+
return mergeRecords(baseline, overlay);
|
|
83
|
+
}
|
|
84
|
+
export function resolveProfileSettings(baseline, overlay) {
|
|
85
|
+
return resolveConfig(mergeProfileConfig(baseline, overlay));
|
|
86
|
+
}
|
|
87
|
+
function mergeRecords(baseline, overlay) {
|
|
88
|
+
const result = {};
|
|
89
|
+
for (const [key, value] of Object.entries(baseline))
|
|
90
|
+
result[key] = clone(value);
|
|
91
|
+
for (const [key, value] of Object.entries(overlay)) {
|
|
92
|
+
// Routes are complete values, whereas each role's policy keys merge independently.
|
|
93
|
+
result[key] = key !== "primary" && isRecord(value) && isRecord(result[key]) ? mergeRecords(result[key], value) : clone(value);
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
function clone(value) {
|
|
98
|
+
if (Array.isArray(value))
|
|
99
|
+
return value.map(clone);
|
|
100
|
+
return isRecord(value) ? mergeRecords({}, value) : value;
|
|
101
|
+
}
|
|
102
|
+
function validateTree(node, depth) {
|
|
103
|
+
if (depth > 32)
|
|
104
|
+
invalid("content", "exceeds the maximum JSON nesting depth");
|
|
105
|
+
if (node.type === "object") {
|
|
106
|
+
const found = new Set();
|
|
107
|
+
for (const property of node.children ?? []) {
|
|
108
|
+
const key = property.children?.[0]?.value;
|
|
109
|
+
if (typeof key !== "string" || FORBIDDEN_KEYS.has(key))
|
|
110
|
+
invalid("content", "contains an unsafe object key");
|
|
111
|
+
if (found.has(key))
|
|
112
|
+
invalid("content", "contains a duplicate object key; remove the duplicate before saving");
|
|
113
|
+
found.add(key);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
for (const child of node.children ?? [])
|
|
117
|
+
validateTree(child, depth + 1);
|
|
118
|
+
}
|
|
119
|
+
function isRecord(value) {
|
|
120
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
121
|
+
}
|
|
122
|
+
function record(value, field) {
|
|
123
|
+
if (!isRecord(value))
|
|
124
|
+
invalid(field, "must be an object");
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
function keys(value, allowed, field, extra = "Remove unsupported fields before saving.") {
|
|
128
|
+
if (Object.keys(value).some((key) => !allowed.includes(key)))
|
|
129
|
+
invalid(field, `contains unsupported fields. ${extra}`);
|
|
130
|
+
}
|
|
131
|
+
function optional(value, key, validator, field) {
|
|
132
|
+
if (Object.hasOwn(value, key))
|
|
133
|
+
validator(value[key], `${field}.${key}`);
|
|
134
|
+
}
|
|
135
|
+
function invalid(field, message) {
|
|
136
|
+
throw new DsmmProfileError("validation", `${field} ${message}.`, field);
|
|
137
|
+
}
|
|
138
|
+
function bool(value, field) {
|
|
139
|
+
if (typeof value !== "boolean")
|
|
140
|
+
invalid(field, "must be true or false");
|
|
141
|
+
}
|
|
142
|
+
function string(value, field, maximum) {
|
|
143
|
+
if (typeof value !== "string" || value.trim() === "" || value.length > maximum || /[\u0000-\u001F\u007F]/u.test(value))
|
|
144
|
+
invalid(field, `must be nonempty text of at most ${maximum} characters without control characters`);
|
|
145
|
+
}
|
|
146
|
+
function enumeration(value, allowed, field) {
|
|
147
|
+
if (typeof value !== "string" || !allowed.includes(value))
|
|
148
|
+
invalid(field, `must be one of ${allowed.join(", ")}`);
|
|
149
|
+
}
|
|
150
|
+
function integer(value, field, minimum, maximum) {
|
|
151
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum || value > maximum)
|
|
152
|
+
invalid(field, `must be an integer from ${minimum} to ${maximum}`);
|
|
153
|
+
}
|
|
154
|
+
function array(value, field, maximum, validator) {
|
|
155
|
+
if (!Array.isArray(value) || value.length > maximum)
|
|
156
|
+
invalid(field, `must be an array with at most ${maximum} entries`);
|
|
157
|
+
for (const item of value)
|
|
158
|
+
validator(item, field);
|
|
159
|
+
}
|
|
160
|
+
function roleList(value, field) {
|
|
161
|
+
array(value, field, DSMM_ROLE_IDS.length, (role, path) => enumeration(role, DSMM_ROLE_IDS, path));
|
|
162
|
+
if (new Set(value).size !== value.length)
|
|
163
|
+
invalid(field, "must not contain duplicate roles");
|
|
164
|
+
}
|
|
165
|
+
function route(value, field) {
|
|
166
|
+
const item = record(value, field);
|
|
167
|
+
keys(item, ["provider", "model", "reasoningEffort"], field);
|
|
168
|
+
string(item.provider, `${field}.provider`, 128);
|
|
169
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9_.:-]*$/u.test(item.provider))
|
|
170
|
+
invalid(`${field}.provider`, "must reference a native provider ID, not a URL, credential or path");
|
|
171
|
+
string(item.model, `${field}.model`, 512);
|
|
172
|
+
if (item.model.includes("://"))
|
|
173
|
+
invalid(`${field}.model`, "must reference a native model ID, not a credential-bearing URL");
|
|
174
|
+
optional(item, "reasoningEffort", (effort, path) => string(effort, path, 64), field);
|
|
175
|
+
}
|
|
176
|
+
function routeList(value, field) {
|
|
177
|
+
array(value, field, 32, route);
|
|
178
|
+
}
|
|
179
|
+
function roleRouting(value, field) {
|
|
180
|
+
const item = record(value, field);
|
|
181
|
+
keys(item, DSMM_ROLE_IDS, field);
|
|
182
|
+
for (const [role, raw] of Object.entries(item)) {
|
|
183
|
+
const path = `${field}.${role}`;
|
|
184
|
+
const policy = record(raw, path);
|
|
185
|
+
keys(policy, ["primary", "fallbackRoutes"], path);
|
|
186
|
+
optional(policy, "primary", route, path);
|
|
187
|
+
optional(policy, "fallbackRoutes", routeList, path);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function workflow(value, field) {
|
|
191
|
+
const item = record(value, field);
|
|
192
|
+
keys(item, ["policy", "strictGates", "reviewCap", "finalReviewPolicy"], field);
|
|
193
|
+
optional(item, "policy", (policy, path) => enumeration(policy, ["risk-based", "legacy"], path), field);
|
|
194
|
+
optional(item, "strictGates", bool, field);
|
|
195
|
+
optional(item, "reviewCap", (cap, path) => integer(cap, path, 0, 10), field);
|
|
196
|
+
optional(item, "finalReviewPolicy", (policy, path) => enumeration(policy, ["simple-oracle-complex-reviewer", "reviewer-only", "off"], path), field);
|
|
197
|
+
}
|
|
198
|
+
function guards(value, field) {
|
|
199
|
+
const item = record(value, field);
|
|
200
|
+
keys(item, ["scope", "shellCommandSafety", "gitWriteGuard", "toolOutputTruncation", "planFormatValidation", "questionLabelHelper", "todoDisciplineHelper"], field);
|
|
201
|
+
optional(item, "scope", (scope, path) => enumeration(scope, ["deepwork-or-dsmm-agent", "always", "off"], path), field);
|
|
202
|
+
optional(item, "gitWriteGuard", (policy, path) => enumeration(policy, ["ask", "deny", "off"], path), field);
|
|
203
|
+
for (const key of ["shellCommandSafety", "planFormatValidation", "todoDisciplineHelper"])
|
|
204
|
+
optional(item, key, bool, field);
|
|
205
|
+
optional(item, "toolOutputTruncation", (raw, path) => {
|
|
206
|
+
const nested = record(raw, path);
|
|
207
|
+
keys(nested, ["enabled", "maxInlineBytes"], path);
|
|
208
|
+
optional(nested, "enabled", bool, path);
|
|
209
|
+
optional(nested, "maxInlineBytes", (bytes, at) => integer(bytes, at, 1, 1024 * 1024), path);
|
|
210
|
+
}, field);
|
|
211
|
+
optional(item, "questionLabelHelper", (raw, path) => {
|
|
212
|
+
const nested = record(raw, path);
|
|
213
|
+
keys(nested, ["enabled", "maxLabelChars"], path);
|
|
214
|
+
optional(nested, "enabled", bool, path);
|
|
215
|
+
optional(nested, "maxLabelChars", (chars, at) => integer(chars, at, 1, 256), path);
|
|
216
|
+
}, field);
|
|
217
|
+
}
|
|
218
|
+
function recovery(value, field) {
|
|
219
|
+
const item = record(value, field);
|
|
220
|
+
keys(item, ["enabled", "retryOnStatusCodes", "retryOnCodes", "fallbackRoutes", "maxFallbackAttempts", "idleContinuation"], field);
|
|
221
|
+
optional(item, "enabled", bool, field);
|
|
222
|
+
optional(item, "retryOnStatusCodes", (raw, path) => array(raw, path, 64, (status, at) => integer(status, at, 100, 599)), field);
|
|
223
|
+
optional(item, "retryOnCodes", (raw, path) => array(raw, path, 64, (code, at) => string(code, at, 128)), field);
|
|
224
|
+
optional(item, "fallbackRoutes", routeList, field);
|
|
225
|
+
optional(item, "maxFallbackAttempts", (attempts, path) => integer(attempts, path, 0, 10), field);
|
|
226
|
+
optional(item, "idleContinuation", (raw, path) => {
|
|
227
|
+
const nested = record(raw, path);
|
|
228
|
+
keys(nested, ["enabled", "maxContinuations", "prompt"], path);
|
|
229
|
+
optional(nested, "enabled", bool, path);
|
|
230
|
+
optional(nested, "maxContinuations", (count, at) => integer(count, at, 0, 10), path);
|
|
231
|
+
optional(nested, "prompt", (prompt, at) => {
|
|
232
|
+
if (typeof prompt !== "string" || prompt.trim() === "" || prompt.length > 8192 || prompt.includes("\0"))
|
|
233
|
+
invalid(at, "must be nonempty text of at most 8192 characters without NUL");
|
|
234
|
+
}, path);
|
|
235
|
+
}, field);
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=profiles.js.map
|
package/lib/prompts.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DshLlmCallConfig } from "./dsh-types.js";
|
|
2
2
|
import type { DsmmSettings } from "./settings.js";
|
|
3
|
-
export declare const BASE_DEEPWORK_PROMPT = "<dsmm-deepwork-mode>\n\nDEEPWORK MODE ENABLED!\n\nUse this workflow only while the `{{modeName}}` mode is active OR a
|
|
4
|
-
export declare const DEEPSEEK_V4_PRO_OVERLAY = "<dsmm-deepseek-v4-pro-calibration>\n\nDeepSeek V4 Pro calibration is active.\n\n- Treat complex coding, architecture, migration, debugging, and review tasks as deliberate reasoning tasks.\n- First classify the task and identify the evidence needed.\n- Use tools before making repository-specific or API-specific claims.\n- Runtime reasoning effort is enforced by `agent/request`, not this prompt.\n- In `auto` calibration, explicit upstream reasoning effort is preserved; `strict` overrides it with computed policy.\n- Only adapter-advertised reasoning efforts are emitted; `max` is selected only for configured
|
|
3
|
+
export declare const BASE_DEEPWORK_PROMPT = "<dsmm-deepwork-mode>\n\nDEEPWORK MODE ENABLED!\n\nUse this workflow only while the `{{modeName}}` mode is active OR a DW-managed preset is selected. This is an opt-in boundary: outside both conditions, do not apply Deepwork-specific gates, intent routing, or tool-discipline requirements. The default mode name is `deepwork` unless configured.\n\n## Intent routing\n\nDetermine whether the user requests an explanation, diagnosis, implementation, or open-ended design. State the outcome and evidence in the user's language; classify aloud only when it helps the user.\n\n## Workflow gates\n\n- A clear implementation request authorizes its stated scope. Do not require design reapproval or a separate approval loop for equivalent implementation decisions.\n- For complex business or behavior implementation, default to planner \u2192 plan-critic \u2192 implementation. Skip this sequence only for a bounded, simple, low-risk change or an explicit permitted user request. A task having multiple steps alone is not the criterion.\n- Escalate choices that change scope or acceptance, weaken safety/data guarantees, change a public API/protocol or permissions, or cause an irreversible effect. Preserve explicit user configuration.\n- Request implementation review when risk, uncertainty, or user requirements warrant it; reviewer is primary-lane self-review, while an Oracle is an externally configured cross-check. Do not run fixed review loops or manufacture an Oracle model.\n- For completed implementation, gather evidence from tests, diagnostics, and real surfaces before declaring done.\n- Keep scope exact. Do not add unrelated refactors, speculative abstractions, or surprise features.\n- The bundled workflow skill set is available in this mode: `brainstorming`, `writing-plans`, `subagent-driven-development`, `dispatching-parallel-agents`, `requesting-code-review`, `receiving-code-review`, and `remove-ai-slops`.\n- `workflow.policy=risk-based` uses the rules above. Explicit `workflow.policy=legacy` retains the configured `strictGates`, `reviewCap`, and `finalReviewPolicy` gates. Do not apply any Deepwork policy outside active `{{modeName}}` mode or DW-managed preset scope.\n\n## Tool discipline\n\nUse repository tools for repository-specific claims. Prefer narrow reads and searches before broad exploration. Use external documentation for library, API, CLI, or cloud-service details.\n\n- Use the shell dialect available in the current DSH runtime. Keep commands short and inspectable; resolve exact paths before destructive actions and do not string-build cross-shell deletes.\n- No autonomous Git writes: implementing or fixing does not authorize a commit, and a commit does not authorize pushing, tagging, rebasing, or releasing.\n- Child tasks inherit the host's authority and depth limits. Delegate only through actually available DSH tools; preset files alone do not prove that a role is callable.\n\n- Deepwork safety guards may enforce shell dialect, git-write approval, output-size, plan-format, question-label, and todo-discipline policy inside this mode; treat `[dsmm safety]` messages as binding policy feedback.\n\n</dsmm-deepwork-mode>";
|
|
4
|
+
export declare const DEEPSEEK_V4_PRO_OVERLAY = "<dsmm-deepseek-v4-pro-calibration>\n\nDeepSeek V4 Pro calibration is active.\n\n- Treat complex coding, architecture, migration, debugging, and review tasks as deliberate reasoning tasks.\n- First classify the task and identify the evidence needed.\n- Use tools before making repository-specific or API-specific claims.\n- Runtime reasoning effort is enforced by `agent/request`, not this prompt.\n- In `auto` calibration, explicit upstream reasoning effort is preserved; `strict` overrides it with computed policy.\n- Only adapter-advertised reasoning efforts are emitted; `max` is selected only for configured DW presets.\n- Keep final answers concise and do not expose private chain-of-thought.\n- When tool calls are enabled through the provider, preserve the provider-required reasoning/tool-call continuity.\n\n</dsmm-deepseek-v4-pro-calibration>";
|
|
5
5
|
export declare const DEEPSEEK_FLASH_OVERLAY = "<dsmm-deepseek-flash-calibration>\n\nDeepSeek-V41-Flash applies only to the verified deepseek-official/deepseek-flash or deepseek-account/deepseek-flash routes. The host catalog and explicit user model choice are authoritative.\n\n- Keep work outcome-first and avoid procedural review or approval loops.\n- Runtime reasoning effort is chosen by the adapter only from the resolved model's advertised efforts. If the catalog advertises no reasoning efforts, leave the request unchanged.\n- Auto preserves explicit upstream effort; strict overrides it only with an advertised effort.\n- Do not assume max, high, temperature, or another model's capabilities. Do not claim model heterogeneity when all child roles use the same route.\n- Maintain tool-call continuity required by the provider and never reveal private reasoning.\n\n</dsmm-deepseek-flash-calibration>";
|
|
6
6
|
export interface DeepworkPromptOptions {
|
|
7
7
|
route?: Pick<DshLlmCallConfig, "provider" | "model">;
|
package/lib/prompts.js
CHANGED
|
@@ -3,7 +3,7 @@ export const BASE_DEEPWORK_PROMPT = `<dsmm-deepwork-mode>
|
|
|
3
3
|
|
|
4
4
|
DEEPWORK MODE ENABLED!
|
|
5
5
|
|
|
6
|
-
Use this workflow only while the \`{{modeName}}\` mode is active OR a
|
|
6
|
+
Use this workflow only while the \`{{modeName}}\` mode is active OR a DW-managed preset is selected. This is an opt-in boundary: outside both conditions, do not apply Deepwork-specific gates, intent routing, or tool-discipline requirements. The default mode name is \`deepwork\` unless configured.
|
|
7
7
|
|
|
8
8
|
## Intent routing
|
|
9
9
|
|
|
@@ -18,7 +18,7 @@ Determine whether the user requests an explanation, diagnosis, implementation, o
|
|
|
18
18
|
- For completed implementation, gather evidence from tests, diagnostics, and real surfaces before declaring done.
|
|
19
19
|
- Keep scope exact. Do not add unrelated refactors, speculative abstractions, or surprise features.
|
|
20
20
|
- The bundled workflow skill set is available in this mode: \`brainstorming\`, \`writing-plans\`, \`subagent-driven-development\`, \`dispatching-parallel-agents\`, \`requesting-code-review\`, \`receiving-code-review\`, and \`remove-ai-slops\`.
|
|
21
|
-
- \`workflow.policy=risk-based\` uses the rules above. Explicit \`workflow.policy=legacy\` retains the configured \`strictGates\`, \`reviewCap\`, and \`finalReviewPolicy\` gates. Do not apply any
|
|
21
|
+
- \`workflow.policy=risk-based\` uses the rules above. Explicit \`workflow.policy=legacy\` retains the configured \`strictGates\`, \`reviewCap\`, and \`finalReviewPolicy\` gates. Do not apply any Deepwork policy outside active \`{{modeName}}\` mode or DW-managed preset scope.
|
|
22
22
|
|
|
23
23
|
## Tool discipline
|
|
24
24
|
|
|
@@ -28,7 +28,7 @@ Use repository tools for repository-specific claims. Prefer narrow reads and sea
|
|
|
28
28
|
- No autonomous Git writes: implementing or fixing does not authorize a commit, and a commit does not authorize pushing, tagging, rebasing, or releasing.
|
|
29
29
|
- Child tasks inherit the host's authority and depth limits. Delegate only through actually available DSH tools; preset files alone do not prove that a role is callable.
|
|
30
30
|
|
|
31
|
-
-
|
|
31
|
+
- Deepwork safety guards may enforce shell dialect, git-write approval, output-size, plan-format, question-label, and todo-discipline policy inside this mode; treat \`[dsmm safety]\` messages as binding policy feedback.
|
|
32
32
|
|
|
33
33
|
</dsmm-deepwork-mode>`;
|
|
34
34
|
export const DEEPSEEK_V4_PRO_OVERLAY = `<dsmm-deepseek-v4-pro-calibration>
|
|
@@ -40,7 +40,7 @@ DeepSeek V4 Pro calibration is active.
|
|
|
40
40
|
- Use tools before making repository-specific or API-specific claims.
|
|
41
41
|
- Runtime reasoning effort is enforced by \`agent/request\`, not this prompt.
|
|
42
42
|
- In \`auto\` calibration, explicit upstream reasoning effort is preserved; \`strict\` overrides it with computed policy.
|
|
43
|
-
- Only adapter-advertised reasoning efforts are emitted; \`max\` is selected only for configured
|
|
43
|
+
- Only adapter-advertised reasoning efforts are emitted; \`max\` is selected only for configured DW presets.
|
|
44
44
|
- Keep final answers concise and do not expose private chain-of-thought.
|
|
45
45
|
- When tool calls are enabled through the provider, preserve the provider-required reasoning/tool-call continuity.
|
|
46
46
|
|
package/lib/role-providers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SubagentProvider } from "@deepseek-ai/dsh-subagent";
|
|
2
2
|
import type { DshContext } from "./dsh-types.js";
|
|
3
3
|
import type { DsmmRoleId } from "./roles.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { DsmmSettingsGetter } from "./settings.js";
|
|
5
5
|
export interface DsmmSubagentRegistry {
|
|
6
6
|
getProvider(name: string): SubagentProvider | undefined;
|
|
7
7
|
registerProvider(provider: SubagentProvider): () => void;
|
|
@@ -9,5 +9,5 @@ export interface DsmmSubagentRegistry {
|
|
|
9
9
|
export declare function roleProviderName(role: DsmmRoleId): string;
|
|
10
10
|
export declare function roleFromProviderName(provider: string): DsmmRoleId | undefined;
|
|
11
11
|
/** Only the native outer start owns descriptors, capability admission and returned runs. */
|
|
12
|
-
export declare function registerRoleProviders(ctx: DshContext, getSettings:
|
|
12
|
+
export declare function registerRoleProviders(ctx: DshContext, getSettings: DsmmSettingsGetter, getDeploymentSettings?: DsmmSettingsGetter): void;
|
|
13
13
|
//# sourceMappingURL=role-providers.d.ts.map
|
package/lib/role-providers.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { parentAgentOptionsForDelegation } from "@deepseek-ai/dsh-subagent";
|
|
2
|
+
import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
1
3
|
import { DSMM_ROLE_IDS } from "./roles.js";
|
|
2
4
|
export function roleProviderName(role) {
|
|
3
5
|
return `dsmm-role-${role.slice("dsmm-".length)}`;
|
|
@@ -12,7 +14,7 @@ function supportedSpawn(provider) {
|
|
|
12
14
|
&& Object.keys(SPAWN_CAPABILITIES).every((key) => provider.capabilities?.[key] === true);
|
|
13
15
|
}
|
|
14
16
|
/** Only the native outer start owns descriptors, capability admission and returned runs. */
|
|
15
|
-
export function registerRoleProviders(ctx, getSettings) {
|
|
17
|
+
export function registerRoleProviders(ctx, getSettings, getDeploymentSettings = getSettings) {
|
|
16
18
|
const installed = new WeakSet();
|
|
17
19
|
const install = (readyCtx) => {
|
|
18
20
|
const registry = readyCtx.get?.("subagents")
|
|
@@ -22,20 +24,51 @@ export function registerRoleProviders(ctx, getSettings) {
|
|
|
22
24
|
const disposers = [];
|
|
23
25
|
installed.add(registry);
|
|
24
26
|
try {
|
|
25
|
-
const settings =
|
|
27
|
+
const settings = getDeploymentSettings();
|
|
26
28
|
for (const role of DSMM_ROLE_IDS) {
|
|
27
29
|
if (role === "dsmm-orchestrator" || !settings.roles[role])
|
|
28
30
|
continue;
|
|
29
31
|
let active = true;
|
|
30
32
|
const dispose = registry.registerProvider({
|
|
31
33
|
name: roleProviderName(role), capabilities: SPAWN_CAPABILITIES, inheritsParentContext: false,
|
|
32
|
-
start(request) {
|
|
34
|
+
async start(request) {
|
|
33
35
|
if (!active)
|
|
34
|
-
|
|
36
|
+
throw new Error("dsmm role provider is disposed");
|
|
35
37
|
const spawn = registry.getProvider("spawn");
|
|
36
38
|
if (!supportedSpawn(spawn))
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
throw new Error("dsmm role provider requires the supported native spawn capabilities");
|
|
40
|
+
const parentSettings = getSettings(request.parent);
|
|
41
|
+
if (!parentSettings.roles[role])
|
|
42
|
+
throw new Error("dsmm role provider is disabled by deployment configuration");
|
|
43
|
+
const primary = parentSettings.roleRouting[role]?.primary;
|
|
44
|
+
const agentOptions = primary === undefined ? request.agentOptions : {
|
|
45
|
+
...primary,
|
|
46
|
+
reasoningEffort: primary.reasoningEffort === undefined ? undefined : ReasoningEffortId(primary.reasoningEffort),
|
|
47
|
+
...request.agentOptions
|
|
48
|
+
};
|
|
49
|
+
if (primary !== undefined && request.agentOptions?.reasoningEffort === undefined
|
|
50
|
+
&& ((request.agentOptions?.provider !== undefined && request.agentOptions.provider !== primary.provider)
|
|
51
|
+
|| (request.agentOptions?.model !== undefined && request.agentOptions.model !== primary.model))) {
|
|
52
|
+
agentOptions.reasoningEffort = undefined;
|
|
53
|
+
}
|
|
54
|
+
const parentOptions = parentAgentOptionsForDelegation(request.parent);
|
|
55
|
+
const provider = agentOptions?.provider ?? parentOptions.provider;
|
|
56
|
+
const model = agentOptions?.model ?? parentOptions.model;
|
|
57
|
+
if (provider === undefined || model === undefined)
|
|
58
|
+
throw new Error("dsmm role delegation requires an effective provider and model");
|
|
59
|
+
const routeChanged = provider !== parentOptions.provider || model !== parentOptions.model;
|
|
60
|
+
const reasoningEffort = agentOptions?.reasoningEffort
|
|
61
|
+
?? (primary === undefined && !routeChanged ? parentOptions.reasoningEffort : undefined);
|
|
62
|
+
const llm = request.parent.ctx.get("llm");
|
|
63
|
+
if (llm?.resolveCallConfig === undefined)
|
|
64
|
+
throw new Error("dsmm role delegation requires the parent Agent native LLM service");
|
|
65
|
+
await llm.resolveCallConfig({ provider, model, ...(reasoningEffort === undefined ? {} : { reasoningEffort }) }, request.signal);
|
|
66
|
+
request.signal.throwIfAborted();
|
|
67
|
+
if (!active || registry.getProvider("spawn") !== spawn)
|
|
68
|
+
throw new Error("dsmm role spawn provider changed during route validation; retry delegation");
|
|
69
|
+
// Preserve the native descriptor, authority filters and lifecycle;
|
|
70
|
+
// this alias owns only profile-derived route defaults and preflight.
|
|
71
|
+
return spawn.start(primary === undefined ? request : { ...request, agentOptions });
|
|
39
72
|
}
|
|
40
73
|
});
|
|
41
74
|
disposers.push(() => { active = false; dispose(); });
|
package/lib/role-routing.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { AgentRequestFrame, DshLlmCallConfig } from "./dsh-types.js";
|
|
1
|
+
import type { AgentRequestFrame, DshContext, DshLlmCallConfig } from "./dsh-types.js";
|
|
2
2
|
import type { DsmmRoleId } from "./roles.js";
|
|
3
3
|
import type { DsmmModelRoute, DsmmSettings } from "./settings.js";
|
|
4
4
|
export declare const DSMM_ROLE_POLICY_EVENT = "dsmm/role-policy";
|
|
5
5
|
export declare function rolePolicyIdentity(settings: DsmmSettings, role: DsmmRoleId | undefined): string | undefined;
|
|
6
6
|
/** Native custom events are model-hidden log facts, retained across surface compaction. */
|
|
7
|
-
export declare function establishRolePolicy(frame: AgentRequestFrame, settings: DsmmSettings, role: DsmmRoleId | undefined): Promise<string | undefined>;
|
|
7
|
+
export declare function establishRolePolicy(frame: AgentRequestFrame, settings: DsmmSettings, role: DsmmRoleId | undefined, ctx?: DshContext): Promise<string | undefined>;
|
|
8
8
|
export declare function recordAdmittedRecoveryRoute(frame: AgentRequestFrame, route: DsmmModelRoute): void;
|
|
9
9
|
export declare function takeAdmittedRecoveryRoute(frame: AgentRequestFrame): DsmmModelRoute | undefined;
|
|
10
10
|
export declare function effectiveRoleFallbackRoutes(settings: DsmmSettings, role: DsmmRoleId | undefined): readonly DsmmModelRoute[];
|
package/lib/role-routing.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { assertDsmmMetadataPersistence } from "./session-metadata.js";
|
|
2
3
|
import { isDsmmRoleId } from "./roles.js";
|
|
3
4
|
import { isCurrentRecoveryStep } from "./recovery-policy.js";
|
|
4
5
|
import { childOwnedSessionEvents, sessionEvents } from "./session-scope.js";
|
|
@@ -41,7 +42,7 @@ function readPolicyMarker(event) {
|
|
|
41
42
|
return { role: data.role, policy: data.policy };
|
|
42
43
|
}
|
|
43
44
|
/** Native custom events are model-hidden log facts, retained across surface compaction. */
|
|
44
|
-
export async function establishRolePolicy(frame, settings, role) {
|
|
45
|
+
export async function establishRolePolicy(frame, settings, role, ctx) {
|
|
45
46
|
const identity = rolePolicyIdentity(settings, role);
|
|
46
47
|
if (frame.signal.aborted)
|
|
47
48
|
return identity;
|
|
@@ -57,11 +58,13 @@ export async function establishRolePolicy(frame, settings, role) {
|
|
|
57
58
|
return identity;
|
|
58
59
|
if (identity === undefined || role === undefined) {
|
|
59
60
|
if (latest !== undefined && latest.policy !== null) {
|
|
61
|
+
assertDsmmMetadataPersistence(ctx ?? frame.agent.ctx);
|
|
60
62
|
await frame.agent.session.append(DSMM_ROLE_POLICY_EVENT, { version: 1, role: latest.role, policy: null });
|
|
61
63
|
}
|
|
62
64
|
return undefined;
|
|
63
65
|
}
|
|
64
66
|
if (latest?.role !== role || latest.policy !== identity) {
|
|
67
|
+
assertDsmmMetadataPersistence(ctx ?? frame.agent.ctx);
|
|
65
68
|
await frame.agent.session.append(DSMM_ROLE_POLICY_EVENT, { version: 1, role, policy: identity });
|
|
66
69
|
}
|
|
67
70
|
return identity;
|
package/lib/role-subagents.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
4
|
/** The DSH headless runner never mounts Agent presets; give it role-specific native tools. */
|
|
5
|
-
export declare function registerHeadlessRoleTools(ctx: DshContext, controller: DeepworkModeController, getSettings:
|
|
5
|
+
export declare function registerHeadlessRoleTools(ctx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): void;
|
|
6
6
|
//# sourceMappingURL=role-subagents.d.ts.map
|
package/lib/role-subagents.js
CHANGED
|
@@ -20,16 +20,16 @@ export function registerHeadlessRoleTools(ctx, controller, getSettings) {
|
|
|
20
20
|
throw new Error("dsmm headless role tools require Agent-scoped Cordis plugin and tool guard services");
|
|
21
21
|
installed.add(agentCtx);
|
|
22
22
|
try {
|
|
23
|
-
const settings = getSettings();
|
|
23
|
+
const settings = getSettings(agent);
|
|
24
24
|
const roles = DSMM_ROLES.filter((role) => role.id !== "dsmm-orchestrator" && settings.roles[role.id]);
|
|
25
25
|
const names = new Set(roles.map((role) => role.id.replace(/-/gu, "_")));
|
|
26
26
|
const guard = agentCtx.tools.guard((execution) => {
|
|
27
27
|
if (!names.has(execution.name))
|
|
28
28
|
return undefined;
|
|
29
|
-
const current = getSettings();
|
|
29
|
+
const current = getSettings(execution.agent);
|
|
30
30
|
if (controller.active(execution.agent, current.defaultActive) || isDsmmRoleId(resolveSelectedAgentPreset(execution.agent?.session)))
|
|
31
31
|
return undefined;
|
|
32
|
-
return "
|
|
32
|
+
return "DW role tools require an active Deepwork session or DW-selected preset";
|
|
33
33
|
});
|
|
34
34
|
agentCtx.effect?.(() => guard);
|
|
35
35
|
const catalog = agentCtx.tools;
|
|
@@ -38,7 +38,9 @@ export function registerHeadlessRoleTools(ctx, controller, getSettings) {
|
|
|
38
38
|
// Agent creation is awaited before first prompt assembly. Mounting here
|
|
39
39
|
// sees the Agent-isolated systemPrompt/tools and avoids leaking tools to
|
|
40
40
|
// its sibling sessions or the read-only child being delegated.
|
|
41
|
-
|
|
41
|
+
// Model routing belongs to the parent's admitted profile, not the tool's
|
|
42
|
+
// standing composition. The role provider validates it before spawning.
|
|
43
|
+
await agentCtx.plugin(nativeSubagentTool, roleSubagentConfig(role, availableTools));
|
|
42
44
|
}
|
|
43
45
|
agentCtx.effect?.(() => () => installed.delete(agentCtx));
|
|
44
46
|
}
|
package/lib/roles.d.ts
CHANGED
|
@@ -2,17 +2,21 @@ import type { DsmmSkillName } from "./skills.js";
|
|
|
2
2
|
import type { DsmmModelRoute, DsmmRoleRouting } from "./settings.js";
|
|
3
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"];
|
|
4
4
|
export type DsmmRoleId = (typeof DSMM_ROLE_IDS)[number];
|
|
5
|
+
export type DsmmRoleMode = "primary" | "all" | "subagent";
|
|
5
6
|
export interface DsmmRoleDefinition {
|
|
6
7
|
id: DsmmRoleId;
|
|
7
8
|
name: string;
|
|
8
9
|
description: string;
|
|
9
10
|
order: number;
|
|
11
|
+
mode: DsmmRoleMode;
|
|
10
12
|
enabledByDefault: boolean;
|
|
11
13
|
access?: "read-only" | "write";
|
|
12
14
|
persona: string;
|
|
13
15
|
}
|
|
14
16
|
export declare const DSMM_ROLES: readonly DsmmRoleDefinition[];
|
|
15
17
|
export declare function isDsmmRoleId(value: unknown): value is DsmmRoleId;
|
|
18
|
+
/** Root exposure is separate from whether a role is enabled for delegation. */
|
|
19
|
+
export declare function isRootRole(role: Pick<DsmmRoleDefinition, "mode">): boolean;
|
|
16
20
|
export declare function renderAgentCordis(role: DsmmRoleDefinition, skills?: readonly DsmmSkillName[], enabledRoles?: readonly DsmmRoleId[], roleRouting?: DsmmRoleRouting): string;
|
|
17
21
|
export interface RolePluginRow {
|
|
18
22
|
id: string;
|