@dsmm/dsmm 0.2.0 → 0.2.2
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 +38 -66
- 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/docs/agent-presets.md +36 -52
- package/docs/compatibility.md +50 -108
- 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 +83 -2
- package/docs/roadmap.md +71 -17
- package/docs/settings-status.md +34 -169
- package/docs/skill-sync.md +52 -15
- package/lib/child-admission-contract.d.ts +37 -0
- package/lib/child-admission-contract.js +2 -0
- package/lib/child-admission.d.ts +42 -0
- package/lib/child-admission.js +162 -0
- package/lib/child-capture.d.ts +81 -0
- package/lib/child-capture.js +203 -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-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 +68 -0
- package/lib/delivery-authority.js +260 -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 +300 -47
- package/lib/legacy-child-policy.d.ts +51 -0
- package/lib/legacy-child-policy.js +123 -0
- package/lib/legacy-read-composition.d.ts +20 -0
- package/lib/legacy-read-composition.js +144 -0
- package/lib/legacy-read-contracts.d.ts +157 -0
- package/lib/legacy-read-contracts.js +39 -0
- package/lib/legacy-read-host.d.ts +19 -0
- package/lib/legacy-read-host.js +67 -0
- package/lib/legacy-read-integration.d.ts +121 -0
- package/lib/legacy-read-integration.js +522 -0
- package/lib/legacy-read-proxy.d.ts +26 -0
- package/lib/legacy-read-proxy.js +237 -0
- 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 +42 -0
- package/lib/native-child-evidence.js +133 -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 +14 -12
- 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 +377 -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 +49 -8
- package/lib/role-policy.js +437 -60
- package/lib/role-providers.d.ts +1 -1
- package/lib/role-providers.js +30 -35
- package/lib/role-routing.d.ts +11 -2
- package/lib/role-routing.js +42 -25
- package/lib/role-runs.d.ts +135 -0
- package/lib/role-runs.js +304 -0
- package/lib/role-subagents.d.ts +58 -3
- package/lib/role-subagents.js +169 -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 +112 -0
- package/lib/runtime-integration.js +784 -0
- package/lib/runtime-recovery.js +18 -8
- 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 +45 -0
- package/lib/subagent-runtime.js +131 -0
- package/package.json +106 -56
- 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/scripts/cold-profile-composition.mjs +329 -0
- package/scripts/cold-profile-sources.mjs +238 -0
- package/scripts/migrate-cold-profile.mjs +315 -0
- 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/lib/profiles.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { getNodeValue
|
|
1
|
+
import { getNodeValue } from "jsonc-parser";
|
|
2
2
|
import { DSMM_ROLE_IDS } from "./roles.js";
|
|
3
|
-
import { resolveConfig } from "./settings.js";
|
|
4
|
-
import { normalizeRateLimitOverrides, normalizeRoutingStrategy, normalizeRuntimePolicy } from "./routing-policy.js";
|
|
3
|
+
import { copyJson, DSMM_LOCALES, resolveConfig, normalizeLevelOverride } from "./settings.js";
|
|
4
|
+
import { DSMM_RATE_LIMIT_BOUNDS, normalizeRateLimitOverrides, normalizeRoutingStrategy, normalizeRuntimePolicy } from "./routing-policy.js";
|
|
5
|
+
import { DEPRECATED_DSMM_FIELDS, diagnostic, diagnosticSourcePath, DsmmConfigValidationError, fieldLocation, inspectJsonDocument } from "./profile-diagnostics.js";
|
|
6
|
+
import { normalizeModelRouteJson } from "./route-json.js";
|
|
5
7
|
export const MAX_PROFILE_BYTES = 128 * 1024;
|
|
6
8
|
export const MAX_PROFILE_COUNT = 128;
|
|
7
9
|
export const MAX_PROFILE_DIRECTORY_ENTRIES = 1024;
|
|
@@ -9,17 +11,23 @@ export const MAX_PROFILE_REVISIONS = 1024;
|
|
|
9
11
|
export class DsmmProfileError extends Error {
|
|
10
12
|
code;
|
|
11
13
|
field;
|
|
12
|
-
|
|
14
|
+
reason;
|
|
15
|
+
location;
|
|
16
|
+
constructor(code, message, field, reason, location) {
|
|
13
17
|
super(message);
|
|
14
18
|
this.name = "DsmmProfileError";
|
|
15
19
|
this.code = code;
|
|
16
20
|
this.field = field;
|
|
21
|
+
this.reason = reason;
|
|
22
|
+
this.location = location;
|
|
17
23
|
}
|
|
18
24
|
toInfo() {
|
|
19
|
-
return { code: this.code, message: this.message, ...(this.field === undefined ? {} : { field: this.field }) };
|
|
25
|
+
return { code: this.code, message: this.message, ...(this.field === undefined ? {} : { field: this.field }), ...(this.reason === undefined ? {} : { reason: this.reason }), ...(this.location === undefined ? {} : { location: this.location }) };
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
export function profileErrorInfo(error, fallback = "io") {
|
|
29
|
+
if (error instanceof DsmmConfigValidationError)
|
|
30
|
+
return { code: "validation", message: error.message, field: error.diagnostic.field, reason: error.diagnostic.code, ...(error.diagnostic.location === undefined ? {} : { location: error.diagnostic.location }) };
|
|
23
31
|
return error instanceof DsmmProfileError ? error.toInfo() : { code: fallback, message: "Deepwork profile operation failed; the previous selection and files were retained." };
|
|
24
32
|
}
|
|
25
33
|
export function validateProfileId(id) {
|
|
@@ -31,60 +39,127 @@ export function validateProfileRevision(revision, field = "expectedRevision") {
|
|
|
31
39
|
if (typeof revision !== "string" || !/^[a-f0-9]{64}$/u.test(revision))
|
|
32
40
|
invalid(field, "must be a SHA256 file revision");
|
|
33
41
|
}
|
|
34
|
-
const OVERLAY_FIELDS = ["defaultActive", "roleRouting", "runtimePolicy", "workflow", "guards", "runtimeRecovery", "
|
|
35
|
-
const FORBIDDEN_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
42
|
+
const OVERLAY_FIELDS = ["modelParameters", "defaultActive", "roleRouting", "runtimePolicy", "workflow", "guards", "runtimeRecovery", "roles", "locale", "subagents", "deepseekV4ProCalibration", "deepseekV4ProDefaultReasoningEffort", "deepseekFlashCalibration", "deepseekFlashDefaultReasoningEffort"];
|
|
36
43
|
export function parseProfileDocument(content, expectedId) {
|
|
44
|
+
const result = validateProfileDocument(content, expectedId);
|
|
45
|
+
const error = result.diagnostics.find(item => item.severity === "error");
|
|
46
|
+
if (error !== undefined)
|
|
47
|
+
throw new DsmmProfileError("validation", `${error.field}: ${error.reason}`, error.field, error.code, error.location);
|
|
48
|
+
return result.document;
|
|
49
|
+
}
|
|
50
|
+
export function validateProfileDocument(content, expectedId) {
|
|
37
51
|
if (typeof content !== "string")
|
|
38
|
-
|
|
52
|
+
return { diagnostics: [diagnostic("invalid-type", "content")] };
|
|
39
53
|
if (content.length > MAX_PROFILE_BYTES)
|
|
40
54
|
throw new DsmmProfileError("limit", "Profile files must not exceed 128 KiB.", "content");
|
|
41
55
|
const encoded = new TextEncoder().encode(content);
|
|
42
56
|
if (encoded.byteLength > MAX_PROFILE_BYTES)
|
|
43
57
|
throw new DsmmProfileError("limit", "Profile files must not exceed 128 KiB.", "content");
|
|
44
58
|
if (new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(encoded) !== content)
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
return { diagnostics: [diagnostic("invalid-type", "content")] };
|
|
60
|
+
const inspected = inspectJsonDocument(content);
|
|
61
|
+
if (inspected.diagnostics.length)
|
|
62
|
+
return { diagnostics: inspected.diagnostics };
|
|
63
|
+
const tree = inspected.tree;
|
|
64
|
+
try {
|
|
65
|
+
const document = record(getNodeValue(tree), "document");
|
|
66
|
+
keys(document, ["version", "id", "label", "settings"], "document");
|
|
67
|
+
if (document.version !== 1)
|
|
68
|
+
invalid("version", "must be 1", "unsupported-value");
|
|
69
|
+
validateProfileId(document.id);
|
|
70
|
+
if (expectedId !== undefined && document.id !== expectedId)
|
|
71
|
+
invalid("id", "must match the profile filename ID");
|
|
72
|
+
if (Object.hasOwn(document, "label")) {
|
|
73
|
+
if (typeof document.label !== "string" || document.label.length > 120 || /[\u0000-\u001F\u007F]/u.test(document.label)
|
|
74
|
+
|| new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(new TextEncoder().encode(document.label)) !== document.label)
|
|
75
|
+
invalid("label", "must be valid bounded text without controls");
|
|
76
|
+
}
|
|
77
|
+
const overlay = record(document.settings, "settings");
|
|
78
|
+
validateProfileOverlay(overlay);
|
|
79
|
+
const result = clone(document);
|
|
80
|
+
return { document: result, diagnostics: profileDocumentWarnings(result).map(info => ({ ...info, location: fieldLocation(content, tree, info.field) })) };
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (!(error instanceof DsmmProfileError) && !(error instanceof DsmmConfigValidationError))
|
|
84
|
+
throw error;
|
|
85
|
+
const code = error instanceof DsmmConfigValidationError ? error.diagnostic.code : error.reason ?? "invalid-type";
|
|
86
|
+
const field = error instanceof DsmmConfigValidationError ? error.diagnostic.field : error.field ?? "document";
|
|
87
|
+
return { diagnostics: [diagnostic(code, field, fieldLocation(content, tree, field, diagnosticSourcePath(error)))] };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export function profileDocumentWarnings(document) {
|
|
91
|
+
return document?.label !== undefined && document.label.trim() === "" ? [diagnostic("blank-label", "label")] : [];
|
|
92
|
+
}
|
|
93
|
+
export function validateProfileOverlay(input) {
|
|
94
|
+
let plain;
|
|
95
|
+
try {
|
|
96
|
+
plain = copyJson(input);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
invalid("settings", "must be plain JSON");
|
|
100
|
+
}
|
|
101
|
+
const overlay = record(plain, "settings");
|
|
102
|
+
keys(overlay, OVERLAY_FIELDS, "settings");
|
|
62
103
|
optional(overlay, "defaultActive", bool, "settings");
|
|
104
|
+
optional(overlay, "modelParameters", (value, field) => {
|
|
105
|
+
const parameters = record(value, field);
|
|
106
|
+
keys(parameters, ["passthrough"], field);
|
|
107
|
+
optional(parameters, "passthrough", bool, field);
|
|
108
|
+
}, "settings");
|
|
63
109
|
for (const prefix of ["deepseekV4Pro", "deepseekFlash"]) {
|
|
64
110
|
optional(overlay, `${prefix}Calibration`, (value, field) => enumeration(value, ["off", "auto", "strict"], field), "settings");
|
|
65
111
|
optional(overlay, `${prefix}DefaultReasoningEffort`, (value, field) => enumeration(value, ["off", "low", "high"], field), "settings");
|
|
66
|
-
optional(overlay, `${prefix}MaxReasoningPresets`, roleList, "settings");
|
|
67
112
|
}
|
|
68
113
|
optional(overlay, "roleRouting", roleRouting, "settings");
|
|
69
114
|
optional(overlay, "runtimePolicy", runtimePolicy, "settings");
|
|
70
115
|
optional(overlay, "workflow", workflow, "settings");
|
|
71
116
|
optional(overlay, "guards", guards, "settings");
|
|
72
117
|
optional(overlay, "runtimeRecovery", recovery, "settings");
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
118
|
+
optional(overlay, "locale", (value, field) => enumeration(value, DSMM_LOCALES, field), "settings");
|
|
119
|
+
optional(overlay, "roles", (value, field) => {
|
|
120
|
+
const roles = record(value, field);
|
|
121
|
+
keys(roles, DSMM_ROLE_IDS, field);
|
|
122
|
+
for (const [role, enabled] of Object.entries(roles))
|
|
123
|
+
bool(enabled, `${field}.${role}`);
|
|
124
|
+
}, "settings");
|
|
125
|
+
optional(overlay, "subagents", (value, field) => {
|
|
126
|
+
const settings = record(value, field);
|
|
127
|
+
keys(settings, ["toolTopology"], field);
|
|
128
|
+
optional(settings, "toolTopology", (value, path) => enumeration(value, ["per-role", "parameterized"], path), field);
|
|
129
|
+
}, "settings");
|
|
130
|
+
const settings = resolveConfig(overlay);
|
|
131
|
+
for (const role of requiredDeepworkRoles(settings))
|
|
132
|
+
if (overlay.roles?.[role] === false)
|
|
133
|
+
invalid(`settings.roles.${role}`, "is required", "required-role");
|
|
82
134
|
}
|
|
83
135
|
export function mergeProfileConfig(baseline, overlay) {
|
|
84
|
-
return mergeRecords(baseline, overlay);
|
|
136
|
+
return mergeRecords(copyJson(baseline), copyJson(overlay));
|
|
85
137
|
}
|
|
86
138
|
export function resolveProfileSettings(baseline, overlay) {
|
|
87
|
-
|
|
139
|
+
const ceiling = resolveConfig(baseline);
|
|
140
|
+
const settings = resolveConfig(mergeProfileConfig(baseline, overlay));
|
|
141
|
+
for (const role of requiredDeepworkRoles(settings))
|
|
142
|
+
if (overlay.roles?.[role] === false)
|
|
143
|
+
invalid(`settings.roles.${role}`, "is required", "required-role");
|
|
144
|
+
for (const [role, enabled] of Object.entries(overlay.roles ?? {}))
|
|
145
|
+
if (enabled && (!ceiling.modules.deepwork.enabled || !ceiling.roles[role]))
|
|
146
|
+
invalid(`settings.roles.${role}`, "exceeds captured deployment", "deployment-ceiling");
|
|
147
|
+
return settings;
|
|
148
|
+
}
|
|
149
|
+
export function requiredDeepworkRoles(settings) {
|
|
150
|
+
const required = ["dsmm-orchestrator", "dsmm-planner", "dsmm-plan-critic"];
|
|
151
|
+
if (settings.workflow.policy === "legacy") {
|
|
152
|
+
if (settings.workflow.finalReviewPolicy !== "off")
|
|
153
|
+
required.push("dsmm-reviewer");
|
|
154
|
+
if (settings.workflow.finalReviewPolicy === "simple-oracle-complex-reviewer")
|
|
155
|
+
required.push("dsmm-oracle");
|
|
156
|
+
}
|
|
157
|
+
return required;
|
|
158
|
+
}
|
|
159
|
+
export function requiredReason(settings, role) {
|
|
160
|
+
if (!requiredDeepworkRoles(settings).includes(role))
|
|
161
|
+
return undefined;
|
|
162
|
+
return ["dsmm-orchestrator", "dsmm-planner", "dsmm-plan-critic"].includes(role) ? "deepwork-planning" : "legacy-review";
|
|
88
163
|
}
|
|
89
164
|
function mergeRecords(baseline, overlay) {
|
|
90
165
|
const result = {};
|
|
@@ -92,7 +167,7 @@ function mergeRecords(baseline, overlay) {
|
|
|
92
167
|
result[key] = clone(value);
|
|
93
168
|
for (const [key, value] of Object.entries(overlay)) {
|
|
94
169
|
// Routes are complete values, whereas each role's policy keys merge independently.
|
|
95
|
-
result[key] =
|
|
170
|
+
result[key] = !["primary", "low", "high", "max"].includes(key) && isRecord(value) && isRecord(result[key]) ? mergeRecords(result[key], value) : clone(value);
|
|
96
171
|
}
|
|
97
172
|
return result;
|
|
98
173
|
}
|
|
@@ -101,23 +176,6 @@ function clone(value) {
|
|
|
101
176
|
return value.map(clone);
|
|
102
177
|
return isRecord(value) ? mergeRecords({}, value) : value;
|
|
103
178
|
}
|
|
104
|
-
function validateTree(node, depth) {
|
|
105
|
-
if (depth > 32)
|
|
106
|
-
invalid("content", "exceeds the maximum JSON nesting depth");
|
|
107
|
-
if (node.type === "object") {
|
|
108
|
-
const found = new Set();
|
|
109
|
-
for (const property of node.children ?? []) {
|
|
110
|
-
const key = property.children?.[0]?.value;
|
|
111
|
-
if (typeof key !== "string" || FORBIDDEN_KEYS.has(key))
|
|
112
|
-
invalid("content", "contains an unsafe object key");
|
|
113
|
-
if (found.has(key))
|
|
114
|
-
invalid("content", "contains a duplicate object key; remove the duplicate before saving");
|
|
115
|
-
found.add(key);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
for (const child of node.children ?? [])
|
|
119
|
-
validateTree(child, depth + 1);
|
|
120
|
-
}
|
|
121
179
|
function isRecord(value) {
|
|
122
180
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
123
181
|
}
|
|
@@ -126,16 +184,22 @@ function record(value, field) {
|
|
|
126
184
|
invalid(field, "must be an object");
|
|
127
185
|
return value;
|
|
128
186
|
}
|
|
129
|
-
function keys(value, allowed, field,
|
|
130
|
-
|
|
131
|
-
|
|
187
|
+
function keys(value, allowed, field, _extra = "Remove unsupported fields before saving.") {
|
|
188
|
+
for (const key of DEPRECATED_DSMM_FIELDS)
|
|
189
|
+
if (Object.hasOwn(value, key))
|
|
190
|
+
throw new DsmmConfigValidationError("deprecated-field", [...field === "document" ? [] : field.split("."), key]);
|
|
191
|
+
for (const key of Object.keys(value)) {
|
|
192
|
+
if (!allowed.includes(key))
|
|
193
|
+
throw new DsmmConfigValidationError("unknown-field", [...field === "document" ? [] : field.split("."), key]);
|
|
194
|
+
}
|
|
132
195
|
}
|
|
133
196
|
function optional(value, key, validator, field) {
|
|
134
197
|
if (Object.hasOwn(value, key))
|
|
135
198
|
validator(value[key], `${field}.${key}`);
|
|
136
199
|
}
|
|
137
|
-
function invalid(field,
|
|
138
|
-
|
|
200
|
+
function invalid(field, _message, code = "invalid-type") {
|
|
201
|
+
const info = diagnostic(code, field);
|
|
202
|
+
throw new DsmmProfileError("validation", `${info.field}: ${info.reason}`, info.field, code);
|
|
139
203
|
}
|
|
140
204
|
function bool(value, field) {
|
|
141
205
|
if (typeof value !== "boolean")
|
|
@@ -147,7 +211,7 @@ function string(value, field, maximum) {
|
|
|
147
211
|
}
|
|
148
212
|
function enumeration(value, allowed, field) {
|
|
149
213
|
if (typeof value !== "string" || !allowed.includes(value))
|
|
150
|
-
invalid(field, `must be one of ${allowed.join(", ")}
|
|
214
|
+
invalid(field, `must be one of ${allowed.join(", ")}`, "unsupported-value");
|
|
151
215
|
}
|
|
152
216
|
function integer(value, field, minimum, maximum) {
|
|
153
217
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum || value > maximum)
|
|
@@ -156,24 +220,15 @@ function integer(value, field, minimum, maximum) {
|
|
|
156
220
|
function array(value, field, maximum, validator) {
|
|
157
221
|
if (!Array.isArray(value) || value.length > maximum)
|
|
158
222
|
invalid(field, `must be an array with at most ${maximum} entries`);
|
|
159
|
-
|
|
160
|
-
validator(item, field);
|
|
161
|
-
}
|
|
162
|
-
function roleList(value, field) {
|
|
163
|
-
array(value, field, DSMM_ROLE_IDS.length, (role, path) => enumeration(role, DSMM_ROLE_IDS, path));
|
|
164
|
-
if (new Set(value).size !== value.length)
|
|
165
|
-
invalid(field, "must not contain duplicate roles");
|
|
223
|
+
value.forEach((item, index) => validator(item, `${field}[${index}]`));
|
|
166
224
|
}
|
|
167
225
|
function route(value, field) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
invalid(
|
|
173
|
-
|
|
174
|
-
if (item.model.includes("://"))
|
|
175
|
-
invalid(`${field}.model`, "must reference a native model ID, not a credential-bearing URL");
|
|
176
|
-
optional(item, "reasoningEffort", (effort, path) => string(effort, path, 64), field);
|
|
226
|
+
try {
|
|
227
|
+
normalizeModelRouteJson(value);
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
invalid(field, "must be a valid model route", "invalid-route");
|
|
231
|
+
}
|
|
177
232
|
}
|
|
178
233
|
function routeList(value, field) {
|
|
179
234
|
array(value, field, 32, route);
|
|
@@ -184,7 +239,23 @@ function roleRouting(value, field) {
|
|
|
184
239
|
for (const [role, raw] of Object.entries(item)) {
|
|
185
240
|
const path = `${field}.${role}`;
|
|
186
241
|
const policy = record(raw, path);
|
|
187
|
-
keys(policy, ["primary", "fallbackRoutes", "strategy", "rateLimit"], path);
|
|
242
|
+
keys(policy, ["primary", "fallbackRoutes", "strategy", "rateLimit", "levels"], path);
|
|
243
|
+
optional(policy, "levels", (value, field) => {
|
|
244
|
+
if (role === "dsmm-orchestrator")
|
|
245
|
+
invalid(field, "root model is native-owned", "unsupported-value");
|
|
246
|
+
const levels = record(value, field);
|
|
247
|
+
if (Object.hasOwn(levels, "normal"))
|
|
248
|
+
invalid(`${field}.normal`, "normal is a read-only default alias", "unsupported-value");
|
|
249
|
+
keys(levels, ["low", "high", "max"], field);
|
|
250
|
+
for (const [level, override] of Object.entries(levels)) {
|
|
251
|
+
const at = `${field}.${level}`;
|
|
252
|
+
normalizeLevelOverride(override, at);
|
|
253
|
+
if (isRecord(override) && (Object.hasOwn(override, "provider") || Object.hasOwn(override, "model")))
|
|
254
|
+
route(override, at);
|
|
255
|
+
else
|
|
256
|
+
string(override.reasoningEffort, `${at}.reasoningEffort`, 64);
|
|
257
|
+
}
|
|
258
|
+
}, path);
|
|
188
259
|
optional(policy, "primary", route, path);
|
|
189
260
|
optional(policy, "fallbackRoutes", routeList, path);
|
|
190
261
|
optional(policy, "strategy", strategy, path);
|
|
@@ -196,10 +267,16 @@ function strategy(value, field) {
|
|
|
196
267
|
normalizeRoutingStrategy(value);
|
|
197
268
|
}
|
|
198
269
|
catch {
|
|
199
|
-
invalid(field, "must be startup-lock or rate-limit-fallback");
|
|
270
|
+
invalid(field, "must be startup-lock or rate-limit-fallback", "unsupported-value");
|
|
200
271
|
}
|
|
201
272
|
}
|
|
202
273
|
function rateLimit(value, field) {
|
|
274
|
+
const item = record(value, field);
|
|
275
|
+
keys(item, Object.keys(DSMM_RATE_LIMIT_BOUNDS), field);
|
|
276
|
+
for (const [key, value] of Object.entries(item)) {
|
|
277
|
+
const [min, max] = DSMM_RATE_LIMIT_BOUNDS[key];
|
|
278
|
+
integer(value, `${field}.${key}`, min, max);
|
|
279
|
+
}
|
|
203
280
|
try {
|
|
204
281
|
normalizeRateLimitOverrides(value);
|
|
205
282
|
}
|
package/lib/prompt-content.js
CHANGED
|
@@ -22,6 +22,6 @@ export function splitCategory(text) {
|
|
|
22
22
|
export function buildRolePersona(role) {
|
|
23
23
|
const source = role.promptArtifact === null ? role.description : readPromptAsset(role.promptArtifact.replace("prompts/source/", ""));
|
|
24
24
|
const body = role.kind === "category" ? splitCategory(source).base : source;
|
|
25
|
-
return [`You are ${role.name} (role ID: ${role.id}).`,
|
|
25
|
+
return [`You are ${role.name} (role ID: ${role.id}).`, readPromptAsset("shared/locale.md"), body, readPromptAsset("shared/dsh-host-contract.md"), readPromptAsset(role.terminalArtifact.replace("prompts/source/", ""))].filter(Boolean).join("\n\n---\n\n");
|
|
26
26
|
}
|
|
27
27
|
//# sourceMappingURL=prompt-content.js.map
|
package/lib/prompts.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { DshLlmCallConfig } from "./dsh-types.js";
|
|
2
|
+
import type { ToolSchema } from "@deepseek-ai/dsh-llm";
|
|
2
3
|
import type { SourceRoleContent } from "./prompt-content.js";
|
|
3
4
|
import type { DsmmSettings } from "./settings.js";
|
|
5
|
+
import type { DsmmInvocationView, DsmmRoleAvailabilityState, SubagentRuntimeAdmissionView } from "./profile-types.js";
|
|
6
|
+
import type { DsmmCallableEntry } from "./role-subagents.js";
|
|
7
|
+
import type { ChildAdmissionEvidenceView } from "./child-evidence.js";
|
|
4
8
|
export { SOURCE_ROLE_CATALOG, buildRolePersona } from "./prompt-content.js";
|
|
5
9
|
export type { SourceRoleContent } from "./prompt-content.js";
|
|
6
10
|
export declare const BASE_DEEPWORK_PROMPT: string;
|
|
7
11
|
export declare function promptModelVariants(role: string | undefined, model: string): string[];
|
|
8
12
|
export declare function roleModelCalibration(role: SourceRoleContent | undefined, model: string): string;
|
|
9
|
-
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-
|
|
10
|
-
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-
|
|
13
|
+
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- Ordinary root model and effort stay under the native model picker. Explicit preflighted invocation effort takes precedence over calibration.\n- For other eligible child requests, `auto` preserves explicit upstream effort; `strict` uses the configured default only when the adapter advertises a supported effort. If none is advertised, leave the request unchanged.\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>";
|
|
14
|
+
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- Ordinary root model and effort stay native-owned; explicit preflighted invocation effort takes precedence. For other eligible child requests, auto preserves explicit upstream effort; strict uses only 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>";
|
|
11
15
|
export interface DeepworkPromptOptions {
|
|
12
16
|
route?: Pick<DshLlmCallConfig, "provider" | "model">;
|
|
13
17
|
selectedPreset?: string;
|
|
@@ -15,5 +19,36 @@ export interface DeepworkPromptOptions {
|
|
|
15
19
|
roleId?: string | null;
|
|
16
20
|
overrideSection?: string;
|
|
17
21
|
}
|
|
22
|
+
/** Host observations for this exact admitted Agent, not editor drafts or preset metadata. */
|
|
23
|
+
export interface DsmmPromptObservation {
|
|
24
|
+
scope: "root" | "child";
|
|
25
|
+
delegation: readonly DsmmCallableEntry[];
|
|
26
|
+
/** Already policy-filtered native schemas, including controls that really are callable. */
|
|
27
|
+
tools: readonly ToolSchema[];
|
|
28
|
+
roleAvailability?: readonly DsmmRoleAvailabilityState[];
|
|
29
|
+
invocation?: {
|
|
30
|
+
view: Readonly<DsmmInvocationView>;
|
|
31
|
+
routeKind: "initial" | "actual";
|
|
32
|
+
};
|
|
33
|
+
runtimeAdmission?: Readonly<SubagentRuntimeAdmissionView>;
|
|
34
|
+
capabilities?: {
|
|
35
|
+
nativeJobs?: boolean;
|
|
36
|
+
/** Admitted creation of new continuable children, not existing-child delivery. */
|
|
37
|
+
continuable?: boolean;
|
|
38
|
+
/** Observed managed running/idle/same-ID cold delivery to existing continuable children under this Agent's authority. */
|
|
39
|
+
managedChildDelivery?: boolean;
|
|
40
|
+
/** Only set after the operator/session/epoch-gated user surface is wired. */
|
|
41
|
+
foregroundHandoff?: {
|
|
42
|
+
surface: string;
|
|
43
|
+
};
|
|
44
|
+
nativeBrowserPrompt?: {
|
|
45
|
+
surface: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
childEvidence?: Readonly<ChildAdmissionEvidenceView>;
|
|
49
|
+
}
|
|
50
|
+
export declare function buildDsmmLocaleGuidance(settings: Pick<DsmmSettings, "locale">): string;
|
|
51
|
+
/** Register independently of the common-mode section, in the exact Agent scope. */
|
|
52
|
+
export declare function buildDsmmAgentGuidance(settings: DsmmSettings, observed: DsmmPromptObservation): string;
|
|
18
53
|
export declare function buildDeepworkPrompt(settings: DsmmSettings, options?: DeepworkPromptOptions): string;
|
|
19
54
|
//# sourceMappingURL=prompts.d.ts.map
|
package/lib/prompts.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { desiredDeepseekEffort, isDeepseekFlashRoute, isDeepseekV4ProRoute } from "./model-routing.js";
|
|
2
1
|
import { readPromptAsset as asset, SOURCE_ROLE_CATALOG, splitCategory } from "./prompt-content.js";
|
|
2
|
+
import { CHILD_EVIDENCE_FIELDS } from "./child-evidence.js";
|
|
3
3
|
export { SOURCE_ROLE_CATALOG, buildRolePersona } from "./prompt-content.js";
|
|
4
4
|
const activation = `<dsmm-deepwork-mode>
|
|
5
5
|
Use this workflow only while the \`{{modeName}}\` mode is effectively active. This is an opt-in boundary: ordinary presets default off; DW roles default on, but explicit off wins and retains only persona/access. Never force common workflow or skills on merely from a role name.
|
|
@@ -49,8 +49,8 @@ DeepSeek V4 Pro calibration is active.
|
|
|
49
49
|
- First classify the task and identify the evidence needed.
|
|
50
50
|
- Use tools before making repository-specific or API-specific claims.
|
|
51
51
|
- Runtime reasoning effort is enforced by \`agent/request\`, not this prompt.
|
|
52
|
-
-
|
|
53
|
-
-
|
|
52
|
+
- Ordinary root model and effort stay under the native model picker. Explicit preflighted invocation effort takes precedence over calibration.
|
|
53
|
+
- For other eligible child requests, \`auto\` preserves explicit upstream effort; \`strict\` uses the configured default only when the adapter advertises a supported effort. If none is advertised, leave the request unchanged.
|
|
54
54
|
- Keep final answers concise and do not expose private chain-of-thought.
|
|
55
55
|
- When tool calls are enabled through the provider, preserve the provider-required reasoning/tool-call continuity.
|
|
56
56
|
|
|
@@ -61,11 +61,112 @@ DeepSeek-V41-Flash applies only to the verified deepseek-official/deepseek-flash
|
|
|
61
61
|
|
|
62
62
|
- Keep work outcome-first and avoid procedural review or approval loops.
|
|
63
63
|
- 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.
|
|
64
|
-
-
|
|
64
|
+
- Ordinary root model and effort stay native-owned; explicit preflighted invocation effort takes precedence. For other eligible child requests, auto preserves explicit upstream effort; strict uses only an advertised effort.
|
|
65
65
|
- Do not assume max, high, temperature, or another model's capabilities. Do not claim model heterogeneity when all child roles use the same route.
|
|
66
66
|
- Maintain tool-call continuity required by the provider and never reveal private reasoning.
|
|
67
67
|
|
|
68
68
|
</dsmm-deepseek-flash-calibration>`;
|
|
69
|
+
const localeNames = {
|
|
70
|
+
en: "English", "zh-Hans": "Simplified Chinese", "zh-Hant": "Traditional Chinese", ja: "Japanese", ko: "Korean",
|
|
71
|
+
de: "German", fr: "French", es: "Spanish", "pt-BR": "Brazilian Portuguese", ru: "Russian"
|
|
72
|
+
};
|
|
73
|
+
export function buildDsmmLocaleGuidance(settings) {
|
|
74
|
+
return `<dsmm-visible-output-language>
|
|
75
|
+
${JSON.stringify({ capturedLocale: settings.locale ?? null, visibleOutputLanguage: settings.locale === undefined ? null : localeNames[settings.locale] })}
|
|
76
|
+
${settings.locale === undefined ? "No DSMM locale is captured; inherit applicable host/user language guidance, otherwise use the current request and conversation context." : `This Agent's immutable captured locale is ${settings.locale} (${localeNames[settings.locale]}). Use it as the default for visible replies, plans and role/category output.`}
|
|
77
|
+
The current user's explicit output-language request takes precedence. Preserve that instruction in child assignments. A parent's later profile change does not rewrite this child's captured preference. Preserve code, identifiers, commands, paths, protocol fields and exact quotations verbatim. This affects visible output only: it neither promises an internal reasoning language nor changes the host UI/project locale. Do not infer configuration or authority with natural-language matching.
|
|
78
|
+
</dsmm-visible-output-language>`;
|
|
79
|
+
}
|
|
80
|
+
function toolProperties(tool) {
|
|
81
|
+
return (tool.parameters.properties ?? {});
|
|
82
|
+
}
|
|
83
|
+
// Output projection must not serialize credentials/extra properties on structurally compatible DTOs.
|
|
84
|
+
function projectInvocation({ routeKind, view }) {
|
|
85
|
+
return { routeKind, view: {
|
|
86
|
+
role: view.role, label: view.label, level: view.level, routeSource: view.routeSource, mode: view.mode,
|
|
87
|
+
...(view.route === undefined ? {} : { route: { provider: view.route.provider, model: view.route.model,
|
|
88
|
+
...(view.route.reasoningEffort === undefined ? {} : { reasoningEffort: view.route.reasoningEffort }) } }),
|
|
89
|
+
...(view.runId === undefined ? {} : { runId: view.runId }), ...(view.childId === undefined ? {} : { childId: view.childId }),
|
|
90
|
+
...(view.jobId === undefined ? {} : { jobId: view.jobId })
|
|
91
|
+
} };
|
|
92
|
+
}
|
|
93
|
+
function projectChildEvidence(evidence) {
|
|
94
|
+
return { mode: evidence.mode, parentAdmissionEpoch: evidence.parentAdmissionEpoch,
|
|
95
|
+
...(evidence.mode === "captured" && evidence.originalAdmissionEpoch !== undefined ? { originalAdmissionEpoch: evidence.originalAdmissionEpoch } : {}),
|
|
96
|
+
provenFields: [...new Set(evidence.provenFields.filter(field => CHILD_EVIDENCE_FIELDS.includes(field)))],
|
|
97
|
+
limitations: evidence.limitations.filter(row => CHILD_EVIDENCE_FIELDS.includes(row.field)
|
|
98
|
+
&& ["missing-evidence", "not-persisted", "unverified", "parent-denied"].includes(row.code)
|
|
99
|
+
&& ["capability-denied", "native-default", "display-only"].includes(row.effect))
|
|
100
|
+
.slice(0, CHILD_EVIDENCE_FIELDS.length).map(row => ({ field: row.field, code: row.code, effect: row.effect })) };
|
|
101
|
+
}
|
|
102
|
+
/** Register independently of the common-mode section, in the exact Agent scope. */
|
|
103
|
+
export function buildDsmmAgentGuidance(settings, observed) {
|
|
104
|
+
const availability = new Map(observed.roleAvailability?.map(row => [row.id, row]));
|
|
105
|
+
const delegation = observed.delegation.flatMap(entry => {
|
|
106
|
+
const tool = observed.tools.find(tool => tool.name === entry.name);
|
|
107
|
+
if (tool === undefined)
|
|
108
|
+
return [];
|
|
109
|
+
const properties = toolProperties(tool);
|
|
110
|
+
const targetEnum = entry.targetParameter === undefined ? undefined : properties[entry.targetParameter]?.enum;
|
|
111
|
+
const targets = entry.targets.filter(id => (!availability.has(id) || availability.get(id).admitted)
|
|
112
|
+
&& (entry.targetParameter === undefined || Array.isArray(targetEnum) && targetEnum.includes(id)));
|
|
113
|
+
if (targets.length === 0)
|
|
114
|
+
return [];
|
|
115
|
+
const levelEnum = properties.level?.enum;
|
|
116
|
+
return [{ tool: entry.name, kind: entry.kind, ...(entry.targetParameter === undefined ? {} : { targetParameter: entry.targetParameter }),
|
|
117
|
+
targets: targets.map(id => ({ id, ...(properties.level === undefined ? {} : { levels: ["normal", "low", "high", "max"]
|
|
118
|
+
.filter(level => Array.isArray(levelEnum) && levelEnum.includes(level) && (level === "normal" || settings.roleRouting[id]?.levels?.[level] !== undefined)) }) })),
|
|
119
|
+
parameters: Object.keys(properties).filter(name => (name !== "route" || settings.subagents.allowRouteOverride)
|
|
120
|
+
&& (name !== "run_in_background" || settings.subagents.enableRunInBackground)),
|
|
121
|
+
routeOverride: settings.subagents.allowRouteOverride && properties.route !== undefined,
|
|
122
|
+
background: settings.subagents.enableRunInBackground && properties.run_in_background !== undefined }];
|
|
123
|
+
});
|
|
124
|
+
const controls = observed.tools.filter(tool => ["send_message", "interrupt_agent", "job_output", "job_list", "job_kill", "dsmm_children"].includes(tool.name));
|
|
125
|
+
const runtime = observed.runtimeAdmission === undefined ? undefined : {
|
|
126
|
+
binding: observed.runtimeAdmission.binding, deliveryFenceReady: observed.runtimeAdmission.deliveryFenceReady,
|
|
127
|
+
restartRequired: observed.runtimeAdmission.restartRequired,
|
|
128
|
+
...(observed.runtimeAdmission.reason === undefined ? {} : { reason: observed.runtimeAdmission.reason })
|
|
129
|
+
};
|
|
130
|
+
const deliveryFenceReady = runtime?.binding === "dsmm" && runtime.deliveryFenceReady;
|
|
131
|
+
const managedDelivery = deliveryFenceReady && observed.capabilities?.managedChildDelivery === true;
|
|
132
|
+
const lifecycle = {
|
|
133
|
+
backgroundEnabled: settings.subagents.enableRunInBackground,
|
|
134
|
+
backgroundMode: settings.subagents.backgroundMode,
|
|
135
|
+
nativeJobs: settings.subagents.enableRunInBackground && observed.capabilities?.nativeJobs === true,
|
|
136
|
+
continuable: settings.subagents.enableRunInBackground && observed.capabilities?.continuable === true && deliveryFenceReady,
|
|
137
|
+
managedChildDelivery: managedDelivery,
|
|
138
|
+
sendMessage: managedDelivery && controls.some(tool => tool.name === "send_message"),
|
|
139
|
+
childToParentReporting: observed.scope === "child" && controls.some(tool => tool.name === "send_message"),
|
|
140
|
+
foregroundHandoffSurface: settings.subagents.enableRunInBackground && observed.capabilities?.nativeJobs ? observed.capabilities.foregroundHandoff?.surface ?? null : null,
|
|
141
|
+
browserPromptSurface: managedDelivery ? observed.capabilities?.nativeBrowserPrompt?.surface ?? null : null,
|
|
142
|
+
...(runtime === undefined ? {} : { runtimeAdmission: runtime })
|
|
143
|
+
};
|
|
144
|
+
const sections = [buildDsmmLocaleGuidance(settings), `<dsmm-admitted-delegation>
|
|
145
|
+
${JSON.stringify({ scope: observed.scope, topology: settings.subagents.toolTopology, delegation,
|
|
146
|
+
controls: controls.map(tool => ({ tool: tool.name, parameters: Object.keys(toolProperties(tool)) })),
|
|
147
|
+
...(observed.roleAvailability === undefined ? {} : { roleAvailability: observed.roleAvailability.map(row => ({ id: row.id, admitted: row.admitted, ...(row.reason === undefined ? {} : { reason: row.reason }) })) }) }, null, 2)}
|
|
148
|
+
</dsmm-admitted-delegation>
|
|
149
|
+
Only the listed callable entries and target enums are observed here. Role availability alone is not tool availability. Inspect their native schemas; do not invent suffix roles, fields or tools. Omitted level and normal retain the default route; low/high/max are selectable only for the listed configured target levels, not workflow rigor or a fixed reasoning effort. Each level is a complete provider/model selection or an effort-only override with exact native preflight. Route override is deployment opt-in and additionally requires an exposed route parameter: provider/model must be paired; changing models discards the previous effort; effort-only uses the selected model's exact supported effort. An explicit complete invocation route does not silently use role fallback. Reusing a child does not reselect its role, level or route. Layout/level never enlarge target, read-only, inherited tool, ownership or depth authority. The ordinary root native model picker remains authoritative. Missing required planning/review capability returns to the stage owner, not a bypass.
|
|
150
|
+
`];
|
|
151
|
+
if (observed.invocation !== undefined)
|
|
152
|
+
sections.push(`<dsmm-observed-invocation>\n${JSON.stringify(projectInvocation(observed.invocation), null, 2)}\n</dsmm-observed-invocation>\nThe routeKind labels this observation: initial is preflighted start, not a claim about the current fallback route; actual is supplied by observed native request/status. Level is resource selection, never added permissions or a smaller verification obligation.`);
|
|
153
|
+
sections.push(`<dsmm-child-lifecycle>
|
|
154
|
+
<dsmm-child-lifecycle-state>\n${JSON.stringify(lifecycle, null, 2)}\n</dsmm-child-lifecycle-state>
|
|
155
|
+
${settings.subagents.enableRunInBackground ? "Background is enabled in this Agent's captured deployment policy; only tools that expose run_in_background may request it." : "Background is disabled in this Agent's captured policy; do not request it."}
|
|
156
|
+
${lifecycle.continuable && settings.subagents.backgroundMode === "continuable" ? "The admitted continuable configuration defaults background; explicit run_in_background:false still creates a non-reusable one-shot." : "No managed continuable default is established by this observation. One-shot calls default foreground; do not infer continuation from a persona or filename."}
|
|
157
|
+
${lifecycle.nativeJobs ? "Native jobs can own one-shot background work when the actual job controller admits it; use the returned job ID and exposed job controls." : "Native-job background ownership/controller is not established here; do not invent a job handle."}
|
|
158
|
+
${lifecycle.foregroundHandoffSurface !== null ? `The user surface ${lifecycle.foregroundHandoffSurface} may hand the existing foreground run to a native job, never start a duplicate. It rechecks exact operator/session/epoch, run ownership and background capacity before ownership transfer; failed preflight leaves foreground ownership/cancellation intact. A successful handoff releases only the foreground wait, not a child completion. Cancellation/settlement cannot revive a run.` : "No foreground-to-background user control is established here. Do not invent a tool or RPC for it."}
|
|
159
|
+
${lifecycle.sendMessage ? "Exposed send_message can address a permitted existing direct continuable child: running delivery reaches the nearest step, idle starts a next turn, and cold continuation uses the same durable child ID. An inbox receipt means accepted, not executed/completed. A settled one-shot cannot be revived. Reuse carries the child's original captured route/locale/authority intersected with the current exact parent's authority; it never inherits the parent's latest profile as its original policy." : "Managed parent-to-child continuation through send_message is not established here; do not advertise safe reuse from a static role or SDK method alone."}
|
|
160
|
+
${lifecycle.browserPromptSurface !== null ? `The actual native user surface ${lifecycle.browserPromptSurface} uses queue/steer for continuable children, with native attachment validation. Its operator/connection/session/epoch/lifetime gate precedes inbox acceptance. Do not impersonate an Agent sender. After acceptance do not automatically retry; an unknown disconnect outcome needs verification, not a guessed idempotency guarantee.` : "No operator-gated native user queue/steer surface is established here; do not announce an unconnected DSMM RPC."}
|
|
161
|
+
${controls.some(tool => tool.name === "interrupt_agent") ? "Exposed interrupt_agent requests cancellation, not proof of completion or a message-delivery fence." : "No child interruption tool is observed here."}
|
|
162
|
+
${lifecycle.childToParentReporting ? "Native child-to-parent reporting retains exact-sender/adjacency semantics; it does not grant parent-to-child delegation authority or replace the managed delivery gate." : ""}
|
|
163
|
+
${runtime === undefined ? "Managed runtime binding/readiness is unobserved; no delivery-fence guarantee follows from these resources." : deliveryFenceReady ? "The observed unique DSMM PUBLIC SubagentRuntime binding has a ready delivery fence. Binding readiness alone does not prove existing-child delivery capability. Where observed, current exact-parent tickets and target original evidence gate acceptance; later parent Apply does not rebind old children or cancel already accepted work. Native parent/Host teardown still cancels/drains owned work." : `Runtime binding=${runtime.binding}; deliveryFenceReady=${runtime.deliveryFenceReady}; restartRequired=${runtime.restartRequired}${runtime.reason === undefined ? "" : `; reason=${runtime.reason}`}. Managed child features require explicit startup composition: disable the stock subagents registration row, install the unique PUBLIC DSMM SubagentRuntime subclass, then restart. Never unload/drain a running stock instance to hot-replace it, register a shadow provider, or change the user's host configuration automatically.`}
|
|
164
|
+
Native capacity/depth, provider support, direct-parent ownership, captured permissions and cancellation remain mandatory in every branch. No OpenCode task_id/resume/retry protocol is supplied.
|
|
165
|
+
</dsmm-child-lifecycle>`);
|
|
166
|
+
if (observed.childEvidence !== undefined)
|
|
167
|
+
sections.push(`<dsmm-child-evidence>\n${JSON.stringify(projectChildEvidence(observed.childEvidence), null, 2)}\n</dsmm-child-evidence>\n${observed.childEvidence.mode === "legacy-conservative" ? "Any actually admitted continuation of this captureless legacy child is limited to useful proven capabilities under the same durable ID, intersected with current normal parent authority and native lineage/depth/tool filters. Evidence alone is not delivery availability. Missing evidence denies that capability with its reason; it is neither a blanket denial of all legacy children nor permission to copy the parent's latest policy, synthesize old capture/level, rewrite records or revive a one-shot." : "The child's original immutable capture is its authority ceiling. A different current parent epoch is not an instruction to rebind it."}`);
|
|
168
|
+
return sections.join("\n\n---\n\n");
|
|
169
|
+
}
|
|
69
170
|
export function buildDeepworkPrompt(settings, options = {}) {
|
|
70
171
|
const role = SOURCE_ROLE_CATALOG.find((role) => role.id === (options.roleId === undefined ? options.selectedPreset : options.roleId));
|
|
71
172
|
const common = role === undefined ? BASE_DEEPWORK_PROMPT : [activation, asset("deepwork/default.md")].join("\n\n---\n\n");
|
|
@@ -78,14 +179,15 @@ reviewCap: ${String(settings.workflow.reviewCap)}
|
|
|
78
179
|
finalReviewPolicy: ${settings.workflow.finalReviewPolicy}
|
|
79
180
|
</dsmm-workflow-policy>` : `<dsmm-workflow-policy>policy: risk-based</dsmm-workflow-policy>`;
|
|
80
181
|
const route = options.route;
|
|
81
|
-
|
|
82
|
-
|
|
182
|
+
// Content assembly must not load the native routing/provider graph.
|
|
183
|
+
const providerId = route?.provider.toLowerCase(), modelId = route?.model.toLowerCase();
|
|
184
|
+
const model = providerId === "deepseek-official" && modelId === "deepseek-v4-pro" ? "v4-pro"
|
|
185
|
+
: ["deepseek-official", "deepseek-account"].includes(providerId ?? "") && modelId === "deepseek-flash" ? "flash" : undefined;
|
|
83
186
|
const calibration = model === "flash" ? settings.deepseekFlashCalibration : settings.deepseekV4ProCalibration;
|
|
84
187
|
const calibrationPolicy = model === undefined ? "" : `<dsmm-deepseek-${model}-policy>
|
|
85
188
|
calibrationMode: ${calibration}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
effectiveDesiredReasoningEffort: ${desiredDeepseekEffort(settings, options.selectedPreset, model)}
|
|
189
|
+
configuredDesiredReasoningEffort: ${model === "flash" ? settings.deepseekFlashDefaultReasoningEffort : settings.deepseekV4ProDefaultReasoningEffort}
|
|
190
|
+
This configured default is not an observed request effort. Native root selection, explicit invocation effort and adapter capability remain authoritative.
|
|
89
191
|
</dsmm-deepseek-${model}-policy>`;
|
|
90
192
|
const calibrated = model !== undefined && calibration !== "off"
|
|
91
193
|
? `${base}\n\n${model === "flash" ? DEEPSEEK_FLASH_OVERLAY : DEEPSEEK_V4_PRO_OVERLAY}\n\n${calibrationPolicy}` : base;
|