@dsmm/dsmm 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -67
- package/agent-presets/dsmm-builder/agent.cordis.yml +10 -2015
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +24 -343
- package/agent-presets/dsmm-code-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-coding/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-complex/agent.cordis.yml +23 -1009
- package/agent-presets/dsmm-creative/agent.cordis.yml +25 -442
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +29 -1013
- package/agent-presets/dsmm-deep/agent.cordis.yml +24 -1008
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-documenting/agent.cordis.yml +26 -439
- package/agent-presets/dsmm-frontend/agent.cordis.yml +21 -440
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +22 -441
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-oracle/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +29 -2025
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +24 -341
- package/agent-presets/dsmm-planner/agent.cordis.yml +14 -344
- package/agent-presets/dsmm-quick/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-research/agent.cordis.yml +23 -8
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +25 -340
- package/cordis.patch.yml +14 -0
- package/docs/agent-presets.md +36 -52
- package/docs/compatibility.md +47 -110
- package/docs/deferred-native-approval-risk.md +19 -0
- package/docs/design.md +2 -2
- package/docs/lsp.md +11 -21
- package/docs/migration-from-ocmm.md +2 -2
- package/docs/model-routing.md +84 -59
- package/docs/native-permissions.md +35 -0
- package/docs/profiles.md +40 -87
- package/docs/releasing.md +123 -2
- package/docs/roadmap.md +71 -17
- package/docs/settings-status.md +34 -169
- package/docs/skill-sync.md +52 -15
- package/lib/agent-registry.d.ts +36 -0
- package/lib/agent-registry.js +75 -0
- package/lib/child-admission-contract.d.ts +37 -0
- package/lib/child-admission-contract.js +2 -0
- package/lib/child-admission.d.ts +40 -0
- package/lib/child-admission.js +151 -0
- package/lib/child-capture.d.ts +85 -0
- package/lib/child-capture.js +205 -0
- package/lib/child-evidence.d.ts +17 -0
- package/lib/child-evidence.js +43 -0
- package/lib/client/ChildrenPanel.d.ts +43 -0
- package/lib/client/ChildrenPanel.js +82 -0
- package/lib/client/DeploymentPage.js +15 -8
- package/lib/client/EditableChoice.d.ts +17 -0
- package/lib/client/EditableChoice.js +49 -0
- package/lib/client/PermissionsPanel.d.ts +14 -0
- package/lib/client/PermissionsPanel.js +46 -0
- package/lib/client/ProfilesSection.js +30 -15
- package/lib/client/RoleAvailability.d.ts +7 -0
- package/lib/client/RoleAvailability.js +19 -0
- package/lib/client/SessionProfiles.js +27 -9
- package/lib/client/StructuredEditor.js +15 -7
- package/lib/client/children-controller.d.ts +98 -0
- package/lib/client/children-controller.js +296 -0
- package/lib/client/children-locales.d.ts +367 -0
- package/lib/client/children-locales.js +69 -0
- package/lib/client/controller.d.ts +6 -1
- package/lib/client/controller.js +14 -8
- package/lib/client/deployment-controller.js +1 -1
- package/lib/client/deployment-data.d.ts +2 -1
- package/lib/client/deployment-data.js +34 -5
- package/lib/client/deployment-locales.d.ts +4 -0
- package/lib/client/deployment-locales.js +11 -2
- package/lib/client/diagnostics.d.ts +14 -0
- package/lib/client/diagnostics.js +53 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +96 -2
- package/lib/client/locales.d.ts +54 -0
- package/lib/client/locales.js +34 -16
- package/lib/client/permission-client.d.ts +16 -0
- package/lib/client/permission-client.js +38 -0
- package/lib/client/permission-controller.d.ts +62 -0
- package/lib/client/permission-controller.js +149 -0
- package/lib/client/permission-locales.d.ts +114 -0
- package/lib/client/permission-locales.js +75 -0
- package/lib/client/session-labels.js +4 -4
- package/lib/client/structured.js +19 -5
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +20 -0
- package/lib/client.js +5780 -1679
- package/lib/core-permission-authority.d.ts +18 -0
- package/lib/core-permission-authority.js +255 -0
- package/lib/core-permissions.d.ts +8 -0
- package/lib/core-permissions.js +33 -0
- package/lib/delivery-authority.d.ts +83 -0
- package/lib/delivery-authority.js +397 -0
- package/lib/deployment-config.d.ts +23 -0
- package/lib/deployment-config.js +61 -40
- package/lib/deployment-permission-rules.d.ts +55 -0
- package/lib/deployment-permission-rules.js +306 -0
- package/lib/dsh-types.d.ts +10 -4
- package/lib/guards.d.ts +1 -1
- package/lib/guards.js +29 -8
- package/lib/host-llm-startup.d.ts +41 -0
- package/lib/host-llm-startup.js +65 -0
- package/lib/host-llm.d.ts +92 -0
- package/lib/host-llm.js +325 -0
- package/lib/index.d.ts +15 -4
- package/lib/index.js +288 -48
- package/lib/live-pi-ai-owner.d.ts +18 -0
- package/lib/live-pi-ai-owner.js +144 -0
- package/lib/llm-runtime.d.ts +11 -0
- package/lib/llm-runtime.js +21 -0
- package/lib/managed-settings.d.ts +5 -0
- package/lib/managed-settings.js +14 -0
- package/lib/model-parameter-policy.d.ts +11 -0
- package/lib/model-parameter-policy.js +27 -0
- package/lib/model-routing.js +28 -17
- package/lib/modules.d.ts +13 -5
- package/lib/modules.js +17 -1
- package/lib/native-child-evidence.d.ts +40 -0
- package/lib/native-child-evidence.js +104 -0
- package/lib/native-pi-ai-wire.d.ts +37 -0
- package/lib/native-pi-ai-wire.js +261 -0
- package/lib/native-scope.js +1 -1
- package/lib/permission-bash.d.ts +6 -0
- package/lib/permission-bash.js +7 -0
- package/lib/permission-control.d.ts +73 -0
- package/lib/permission-control.js +205 -0
- package/lib/permission-controller.d.ts +68 -0
- package/lib/permission-controller.js +317 -0
- package/lib/permission-errors.d.ts +7 -0
- package/lib/permission-errors.js +21 -0
- package/lib/permission-fs-search.d.ts +5 -0
- package/lib/permission-fs-search.js +7 -0
- package/lib/permission-fs.d.ts +5 -0
- package/lib/permission-fs.js +7 -0
- package/lib/permission-native-access.d.ts +11 -0
- package/lib/permission-native-access.js +6 -0
- package/lib/permission-native-command.d.ts +10 -0
- package/lib/permission-native-command.js +93 -0
- package/lib/permission-native-rules.d.ts +75 -0
- package/lib/permission-native-rules.js +278 -0
- package/lib/permission-pwsh.d.ts +6 -0
- package/lib/permission-pwsh.js +7 -0
- package/lib/permission-remote.d.ts +26 -0
- package/lib/permission-remote.js +53 -0
- package/lib/permission-rpc.d.ts +29 -0
- package/lib/permission-rpc.js +152 -0
- package/lib/permission-rules.d.ts +115 -0
- package/lib/permission-rules.js +256 -0
- package/lib/permission-settings.d.ts +45 -0
- package/lib/permission-settings.js +48 -0
- package/lib/permission-shell.d.ts +38 -0
- package/lib/permission-shell.js +150 -0
- package/lib/permission-web.d.ts +5 -0
- package/lib/permission-web.js +7 -0
- package/lib/preset-registry.js +36 -25
- package/lib/profile-diagnostics.d.ts +45 -0
- package/lib/profile-diagnostics.js +148 -0
- package/lib/profile-locale.d.ts +3 -0
- package/lib/profile-locale.js +2 -0
- package/lib/profile-remote.d.ts +8 -0
- package/lib/profile-remote.js +163 -39
- package/lib/profile-rpc.d.ts +4 -3
- package/lib/profile-rpc.js +20 -16
- package/lib/profile-runtime.d.ts +40 -1
- package/lib/profile-runtime.js +368 -93
- package/lib/profile-store.d.ts +11 -0
- package/lib/profile-store.js +143 -11
- package/lib/profile-types.d.ts +70 -1
- package/lib/profile-types.js +1 -0
- package/lib/profiles.d.ts +16 -2
- package/lib/profiles.js +156 -79
- package/lib/prompt-content.js +1 -1
- package/lib/prompts.d.ts +37 -2
- package/lib/prompts.js +111 -9
- package/lib/recovery-policy.js +20 -7
- package/lib/role-control-remote.d.ts +38 -0
- package/lib/role-control-remote.js +211 -0
- package/lib/role-control-rpc.d.ts +51 -0
- package/lib/role-control-rpc.js +381 -0
- package/lib/role-control-types.d.ts +92 -0
- package/lib/role-control-types.js +8 -0
- package/lib/role-invocation.d.ts +47 -0
- package/lib/role-invocation.js +135 -0
- package/lib/role-llm-runtime.d.ts +17 -0
- package/lib/role-llm-runtime.js +62 -0
- package/lib/role-llm.d.ts +31 -0
- package/lib/role-llm.js +66 -0
- package/lib/role-policy.d.ts +46 -8
- package/lib/role-policy.js +421 -61
- package/lib/role-providers.d.ts +2 -2
- package/lib/role-providers.js +27 -72
- package/lib/role-routing.d.ts +11 -2
- package/lib/role-routing.js +42 -25
- package/lib/role-runs.d.ts +138 -0
- package/lib/role-runs.js +335 -0
- package/lib/role-subagents.d.ts +58 -3
- package/lib/role-subagents.js +179 -56
- package/lib/roles.d.ts +5 -6
- package/lib/roles.js +10 -39
- package/lib/route-json.d.ts +19 -0
- package/lib/route-json.js +129 -0
- package/lib/routing-policy.d.ts +2 -0
- package/lib/routing-policy.js +12 -2
- package/lib/runtime-integration.d.ts +81 -0
- package/lib/runtime-integration.js +702 -0
- package/lib/runtime-recovery.js +18 -8
- package/lib/session-persistence.d.ts +2 -1
- package/lib/session-persistence.js +1 -1
- package/lib/session-scope.js +4 -1
- package/lib/settings.d.ts +47 -13
- package/lib/settings.js +217 -82
- package/lib/skills.js +2 -2
- package/lib/status.d.ts +10 -1
- package/lib/status.js +11 -8
- package/lib/subagent-runtime.d.ts +57 -0
- package/lib/subagent-runtime.js +257 -0
- package/package.json +149 -89
- package/patches/subagent-runtime.yml +15 -0
- package/prompts/deepseek-flash.md +1 -1
- package/prompts/deepseek-v4-pro.md +2 -2
- package/prompts/deepwork.md +27 -18
- package/prompts/source/agents/clarifier.md +5 -3
- package/prompts/source/agents/orchestrator.md +18 -9
- package/prompts/source/agents/plan-critic.md +5 -1
- package/prompts/source/agents/planner.md +4 -2
- package/prompts/source/agents/reviewer.md +6 -0
- package/prompts/source/category/complex.md +4 -4
- package/prompts/source/category/creative.md +6 -4
- package/prompts/source/category/cross-cutting.md +10 -8
- package/prompts/source/category/deep.md +5 -3
- package/prompts/source/category/documenting.md +7 -1
- package/prompts/source/category/frontend.md +2 -2
- package/prompts/source/category/hard-reasoning.md +3 -3
- package/prompts/source/category/research.md +4 -2
- package/prompts/source/deepwork/claude-opus-5.md +2 -2
- package/prompts/source/deepwork/codex.md +1 -1
- package/prompts/source/deepwork/default.md +22 -15
- package/prompts/source/deepwork/gemini.md +23 -16
- package/prompts/source/deepwork/glm.md +21 -14
- package/prompts/source/deepwork/gpt.md +12 -6
- package/prompts/source/deepwork/planner.md +8 -5
- package/prompts/source/manifest.json +178 -63
- package/prompts/source/shared/dsh-host-contract.md +5 -3
- package/prompts/source/shared/locale.md +2 -2
- package/prompts/source/terminal/orchestrator.md +1 -1
- package/skills/ast-grep/SKILL.md +7 -4
- package/skills/brainstorming/SKILL.md +43 -22
- package/skills/coding-agent-sessions/SKILL.md +7 -4
- package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -46
- package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -130
- package/skills/debugging/SKILL.md +14 -9
- package/skills/debugging/references/methodology/00-setup.md +14 -62
- package/skills/debugging/references/methodology/02-investigate.md +4 -4
- package/skills/debugging/references/methodology/03-flaky-triage.md +3 -3
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +2 -14
- package/skills/debugging/references/methodology/06-fix.md +6 -6
- package/skills/debugging/references/methodology/08-qa.md +5 -5
- package/skills/debugging/references/methodology/09-cleanup.md +15 -153
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +3 -16
- package/skills/debugging/references/runtimes/bundled-js-binary.md +1 -16
- package/skills/debugging/references/runtimes/native-binary.md +9 -54
- package/skills/debugging/references/runtimes/node.md +4 -15
- package/skills/debugging/references/runtimes/python.md +3 -15
- package/skills/debugging/references/runtimes/rust.md +2 -18
- package/skills/debugging/references/tools/dap.md +1 -1
- package/skills/debugging/references/tools/ghidra.md +4 -15
- package/skills/debugging/references/tools/playwright-cli.md +3 -15
- package/skills/debugging/references/tools/pwntools.md +4 -16
- package/skills/dispatching-parallel-agents/SKILL.md +18 -16
- package/skills/frontend/SKILL.md +7 -4
- package/skills/frontend/references/design/react-dev-tooling-skill.md +1 -1
- package/skills/git-master/SKILL.md +7 -4
- package/skills/init-deep/SKILL.md +7 -4
- package/skills/receiving-code-review/SKILL.md +17 -12
- package/skills/remove-ai-slops/SKILL.md +39 -38
- package/skills/requesting-code-review/SKILL.md +19 -17
- package/skills/requesting-code-review/code-reviewer.md +13 -1
- package/skills/subagent-driven-development/SKILL.md +29 -26
- package/skills/subagent-driven-development/implementer-prompt.md +29 -11
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +6 -1
- package/skills/using-git-worktrees/SKILL.md +7 -4
- package/skills/writing-plans/SKILL.md +29 -24
- package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -1
- package/scripts/repair-session-log.mjs +0 -476
- package/scripts/session-repair-native-verifier.mjs +0 -367
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import * as Native from "@deepseek-ai/dsh-tool-web";
|
|
3
|
+
export { Config, inject, name } from "@deepseek-ai/dsh-tool-web";
|
|
4
|
+
export declare function apply(ctx: Context, config: Native.Config): ReturnType<typeof Native.apply>;
|
|
5
|
+
//# sourceMappingURL=permission-web.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as Native from "@deepseek-ai/dsh-tool-web";
|
|
2
|
+
import { DsmmPermissionController } from "./permission-controller.js";
|
|
3
|
+
export { Config, inject, name } from "@deepseek-ai/dsh-tool-web";
|
|
4
|
+
export function apply(ctx, config) {
|
|
5
|
+
return Native.apply(DsmmPermissionController.toolScope(ctx, "web"), config);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=permission-web.js.map
|
package/lib/preset-registry.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { getTraceable } from "@deepseek-ai/cordis";
|
|
2
|
-
import { DSMM_ROLES, DSMM_ROLE_IDS,
|
|
1
|
+
import { Context as NativeContext, getTraceable } from "@deepseek-ai/cordis";
|
|
2
|
+
import { DSMM_ROLES, DSMM_ROLE_IDS, rolePluginRows } from "./roles.js";
|
|
3
3
|
import { enabledSkillNames } from "./skills.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isRootRoleEnabled } from "./settings.js";
|
|
5
|
+
import { allowedRoleChildren, readonlyRoleTool, roleFromToolName, READONLY_ROLE_DENIED_TOOLS } from "./role-policy.js";
|
|
6
|
+
import { nativeStandingFullAccess } from "./permission-native-access.js";
|
|
7
|
+
import { scopeParentOf } from "./native-scope.js";
|
|
5
8
|
/** Declare roles to DSH 0.2's native registry; directories are not discovery inputs. */
|
|
6
9
|
export function registerRolePresets(ctx, getSettings) {
|
|
7
10
|
const install = async (readyCtx) => {
|
|
@@ -11,7 +14,7 @@ export function registerRolePresets(ctx, getSettings) {
|
|
|
11
14
|
throw new Error("dsmm requires the native DSH agentPresets registry");
|
|
12
15
|
const settings = getSettings();
|
|
13
16
|
const enabled = DSMM_ROLE_IDS.filter((id) => settings.modules.deepwork.enabled && settings.roles[id]);
|
|
14
|
-
const active = DSMM_ROLES.filter((role) =>
|
|
17
|
+
const active = DSMM_ROLES.filter((role) => isRootRoleEnabled(settings, role.id));
|
|
15
18
|
const disposers = [];
|
|
16
19
|
try {
|
|
17
20
|
for (const role of active) {
|
|
@@ -30,6 +33,14 @@ export function registerRolePresets(ctx, getSettings) {
|
|
|
30
33
|
// Blank Agents can switch presets without another agent/created event.
|
|
31
34
|
const states = new WeakMap();
|
|
32
35
|
const restrictedAgents = new Set();
|
|
36
|
+
const denial = (agent, name) => {
|
|
37
|
+
const role = registry.composedPreset(agent.ctx);
|
|
38
|
+
if (!isReadonlyRole(role))
|
|
39
|
+
return undefined;
|
|
40
|
+
const target = roleFromToolName(name);
|
|
41
|
+
return target === undefined ? readonlyRoleTool(name, settings) ? undefined : "dsmm read-only role does not permit this tool"
|
|
42
|
+
: allowedRoleChildren(role).includes(target) && settings.roles[target] ? undefined : "dsmm read-only role does not permit this delegation";
|
|
43
|
+
};
|
|
33
44
|
const reconcile = (agent) => {
|
|
34
45
|
const selected = registry.composedPreset(agent.ctx);
|
|
35
46
|
const previous = states.get(agent);
|
|
@@ -37,7 +48,6 @@ export function registerRolePresets(ctx, getSettings) {
|
|
|
37
48
|
return;
|
|
38
49
|
states.set(agent, { role: selected, pending: true });
|
|
39
50
|
previous?.disposeRestriction?.();
|
|
40
|
-
previous?.disposeGuard?.();
|
|
41
51
|
restrictedAgents.delete(agent);
|
|
42
52
|
if (!isReadonlyRole(selected)) {
|
|
43
53
|
states.set(agent, { role: selected });
|
|
@@ -51,34 +61,35 @@ export function registerRolePresets(ctx, getSettings) {
|
|
|
51
61
|
: agent.ctx.get?.("tools")
|
|
52
62
|
?? (agent.ctx.get === undefined ? agent.ctx.tools : undefined);
|
|
53
63
|
try {
|
|
54
|
-
if (tools?.restrict === undefined
|
|
55
|
-
throw new Error(`dsmm read-only role requires DSH tools
|
|
56
|
-
const disposeGuard = tools.guard((execution) => {
|
|
57
|
-
if (execution.agent !== agent || !isReadonlyRole(registry.composedPreset(agent.ctx)))
|
|
58
|
-
return undefined;
|
|
59
|
-
const role = registry.composedPreset(agent.ctx);
|
|
60
|
-
const target = roleFromToolName(execution.name);
|
|
61
|
-
return target === undefined ? readonlyRoleTool(execution.name, settings) ? undefined : "dsmm read-only role does not permit this tool"
|
|
62
|
-
: allowedRoleChildren(role).includes(target) && settings.roles[target] ? undefined : "dsmm read-only role does not permit this delegation";
|
|
63
|
-
});
|
|
64
|
-
states.set(agent, { role: selected, disposeGuard, pending: true });
|
|
64
|
+
if (tools?.restrict === undefined)
|
|
65
|
+
throw new Error(`dsmm read-only role requires DSH tools restrict: ${selected}`);
|
|
65
66
|
restrictedAgents.add(agent);
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
// Only inherited tools are maskable; own-layer tools remain subject to runtime denial.
|
|
68
|
+
const inheritedScope = scopeParentOf(agent);
|
|
69
|
+
const disposeRestriction = tools.restrict({ deny: READONLY_ROLE_DENIED_TOOLS.filter(name => tools.get(name, inheritedScope) !== undefined) });
|
|
70
|
+
states.set(agent, { role: selected, disposeRestriction });
|
|
68
71
|
}
|
|
69
72
|
catch (error) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
else
|
|
73
|
-
states.set(agent, { role: selected, disposeGuard: states.get(agent)?.disposeGuard });
|
|
73
|
+
states.set(agent, { role: selected });
|
|
74
|
+
restrictedAgents.delete(agent);
|
|
74
75
|
throw error;
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
|
-
const onCreated = readyCtx.on?.("agent/created", ({ agent }) => reconcile(agent), { global: true });
|
|
78
78
|
const agents = readyCtx.get?.("agents")
|
|
79
79
|
?? readyCtx.agents;
|
|
80
80
|
if (agents === undefined)
|
|
81
81
|
throw new Error("dsmm native preset restriction requires DSH Agent registry");
|
|
82
|
+
const onPreExecute = readyCtx.on?.("tools/pre-execute", async (execution, next) => {
|
|
83
|
+
const agent = execution.agent;
|
|
84
|
+
if (agent === undefined || agents.get(agent.id) !== agent)
|
|
85
|
+
return next();
|
|
86
|
+
const full = NativeContext.is(readyCtx) && nativeStandingFullAccess(readyCtx, agent);
|
|
87
|
+
if (full && !READONLY_ROLE_DENIED_TOOLS.includes(execution.name))
|
|
88
|
+
return next();
|
|
89
|
+
const reason = denial(agent, execution.name);
|
|
90
|
+
return reason === undefined ? next() : { kind: "deny", reason };
|
|
91
|
+
}, { global: true, prepend: true });
|
|
92
|
+
const onCreated = readyCtx.on?.("agent/created", ({ agent }) => reconcile(agent), { global: true });
|
|
82
93
|
const onToolChange = readyCtx.on?.("tools/change", () => {
|
|
83
94
|
for (const agent of agents.list())
|
|
84
95
|
reconcile(agent);
|
|
@@ -90,13 +101,14 @@ export function registerRolePresets(ctx, getSettings) {
|
|
|
90
101
|
}, { global: true });
|
|
91
102
|
const onDisposed = readyCtx.on?.("agent/disposed", ({ agent }) => {
|
|
92
103
|
states.get(agent)?.disposeRestriction?.();
|
|
93
|
-
states.get(agent)?.disposeGuard?.();
|
|
94
104
|
states.delete(agent);
|
|
95
105
|
restrictedAgents.delete(agent);
|
|
96
106
|
}, { global: true });
|
|
97
107
|
readyCtx.effect?.(() => () => {
|
|
98
108
|
if (typeof onCreated === "function")
|
|
99
109
|
onCreated();
|
|
110
|
+
if (typeof onPreExecute === "function")
|
|
111
|
+
onPreExecute();
|
|
100
112
|
if (typeof onToolChange === "function")
|
|
101
113
|
onToolChange();
|
|
102
114
|
if (typeof onSelection === "function")
|
|
@@ -105,7 +117,6 @@ export function registerRolePresets(ctx, getSettings) {
|
|
|
105
117
|
onDisposed();
|
|
106
118
|
for (const agent of restrictedAgents) {
|
|
107
119
|
states.get(agent)?.disposeRestriction?.();
|
|
108
|
-
states.get(agent)?.disposeGuard?.();
|
|
109
120
|
}
|
|
110
121
|
restrictedAgents.clear();
|
|
111
122
|
for (const dispose of disposers.reverse())
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Node } from "jsonc-parser";
|
|
2
|
+
export declare const PROFILE_DIAGNOSTIC_REASONS: {
|
|
3
|
+
readonly "invalid-jsonc": "Use one valid document with supported JSON syntax.";
|
|
4
|
+
readonly "duplicate-field": "Remove the duplicate field.";
|
|
5
|
+
readonly "unsafe-field": "Unsafe object fields are not supported.";
|
|
6
|
+
readonly "unknown-field": "This field is not supported; installation and private configuration belong in native deployment configuration.";
|
|
7
|
+
readonly "deprecated-field": "This retired field is not supported; configure explicit role levels instead.";
|
|
8
|
+
readonly "invalid-type": "Use the declared field type and bounded value.";
|
|
9
|
+
readonly "unsupported-value": "Use one of the explicitly supported values.";
|
|
10
|
+
readonly "invalid-route": "Use a complete provider/model route or a nonempty reasoning-effort override.";
|
|
11
|
+
readonly "required-role": "This role is required by the selected Deepwork policy.";
|
|
12
|
+
readonly "deployment-ceiling": "A named profile cannot enable capabilities outside its captured deployment ceiling.";
|
|
13
|
+
readonly "blank-label": "The label is blank; the profile ID is used for display.";
|
|
14
|
+
};
|
|
15
|
+
export type ProfileDiagnosticCode = keyof typeof PROFILE_DIAGNOSTIC_REASONS;
|
|
16
|
+
export interface ProfileDiagnosticLocation {
|
|
17
|
+
offset: number;
|
|
18
|
+
length: number;
|
|
19
|
+
line: number;
|
|
20
|
+
column: number;
|
|
21
|
+
}
|
|
22
|
+
export interface ProfileDiagnostic {
|
|
23
|
+
severity: "error" | "warning";
|
|
24
|
+
code: ProfileDiagnosticCode;
|
|
25
|
+
field: string;
|
|
26
|
+
reason: string;
|
|
27
|
+
location?: ProfileDiagnosticLocation;
|
|
28
|
+
}
|
|
29
|
+
export declare const DEPRECATED_DSMM_FIELDS: readonly ["deepseekV4ProMaxReasoningPresets", "deepseekFlashMaxReasoningPresets"];
|
|
30
|
+
/** Host parser location provenance only; never serialized on an error or DTO. */
|
|
31
|
+
export declare function diagnosticSourcePath(error: object): readonly (string | number)[] | undefined;
|
|
32
|
+
export declare function safeDiagnosticField(parts: readonly (string | number)[]): string;
|
|
33
|
+
export declare function isSafeDiagnosticField(value: unknown): value is string;
|
|
34
|
+
export declare function diagnostic(code: ProfileDiagnosticCode, field: string, location?: ProfileDiagnosticLocation): ProfileDiagnostic;
|
|
35
|
+
export declare class DsmmConfigValidationError extends TypeError {
|
|
36
|
+
readonly diagnostic: ProfileDiagnostic;
|
|
37
|
+
constructor(code: ProfileDiagnosticCode, field: string | readonly (string | number)[]);
|
|
38
|
+
}
|
|
39
|
+
export declare function diagnosticLocation(content: string, offset: number, length: number): ProfileDiagnosticLocation;
|
|
40
|
+
export declare function fieldLocation(content: string, tree: Node, field: string, sourcePath?: readonly (string | number)[]): ProfileDiagnosticLocation | undefined;
|
|
41
|
+
export declare function inspectJsonDocument(content: string, jsonc?: boolean): {
|
|
42
|
+
tree?: Node;
|
|
43
|
+
diagnostics: ProfileDiagnostic[];
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=profile-diagnostics.d.ts.map
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { findNodeAtLocation, parseTree } from "jsonc-parser";
|
|
2
|
+
import { DSMM_RATE_LIMIT_BOUNDS } from "./routing-policy.js";
|
|
3
|
+
import { permissionControlSchema } from "./permission-settings.js";
|
|
4
|
+
export const PROFILE_DIAGNOSTIC_REASONS = {
|
|
5
|
+
"invalid-jsonc": "Use one valid document with supported JSON syntax.",
|
|
6
|
+
"duplicate-field": "Remove the duplicate field.",
|
|
7
|
+
"unsafe-field": "Unsafe object fields are not supported.",
|
|
8
|
+
"unknown-field": "This field is not supported; installation and private configuration belong in native deployment configuration.",
|
|
9
|
+
"deprecated-field": "This retired field is not supported; configure explicit role levels instead.",
|
|
10
|
+
"invalid-type": "Use the declared field type and bounded value.",
|
|
11
|
+
"unsupported-value": "Use one of the explicitly supported values.",
|
|
12
|
+
"invalid-route": "Use a complete provider/model route or a nonempty reasoning-effort override.",
|
|
13
|
+
"required-role": "This role is required by the selected Deepwork policy.",
|
|
14
|
+
"deployment-ceiling": "A named profile cannot enable capabilities outside its captured deployment ceiling.",
|
|
15
|
+
"blank-label": "The label is blank; the profile ID is used for display."
|
|
16
|
+
};
|
|
17
|
+
export const DEPRECATED_DSMM_FIELDS = ["deepseekV4ProMaxReasoningPresets", "deepseekFlashMaxReasoningPresets"];
|
|
18
|
+
function schemaFieldShape(schema) {
|
|
19
|
+
if (schema.type === "transform")
|
|
20
|
+
return schemaFieldShape(schema.inner);
|
|
21
|
+
if (schema.type === "object")
|
|
22
|
+
return Object.fromEntries(Object.entries(schema.dict ?? {}).map(([key, child]) => [key, schemaFieldShape(child)]));
|
|
23
|
+
if (schema.type === "array")
|
|
24
|
+
return [schemaFieldShape(schema.inner)];
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
// Closed wire grammar: dynamic role/skill names are declared identifiers, not arbitrary object keys.
|
|
28
|
+
const roleId = /^dsmm-(?:orchestrator|planner|plan-critic|builder|reviewer|oracle|oracle-2nd|creative|code-search|doc-search|clarifier|media-reader|frontend|hard-reasoning|research|quick|coding|normal-task|complex|deep|documenting|cross-cutting)$/u;
|
|
29
|
+
const skillId = /^(?:brainstorming|writing-plans|requesting-code-review|receiving-code-review|subagent-driven-development|dispatching-parallel-agents|remove-ai-slops|debugging|frontend|git-master|ast-grep|coding-agent-sessions|init-deep|using-git-worktrees)$/u;
|
|
30
|
+
const route = { provider: null, model: null, reasoningEffort: null };
|
|
31
|
+
const rateLimit = Object.fromEntries(Object.keys(DSMM_RATE_LIMIT_BOUNDS).map(key => [key, null]));
|
|
32
|
+
const roleRouting = { primary: route, fallbackRoutes: [route], strategy: null, rateLimit, levels: { low: route, high: route, max: route } };
|
|
33
|
+
const configFields = {
|
|
34
|
+
permissionControl: schemaFieldShape(permissionControlSchema),
|
|
35
|
+
modelParameters: { passthrough: null },
|
|
36
|
+
locale: null, modeName: null, section: null, defaultActive: null, promptOrder: null,
|
|
37
|
+
deepseekV4ProCalibration: null, deepseekV4ProDefaultReasoningEffort: null, deepseekFlashCalibration: null, deepseekFlashDefaultReasoningEffort: null,
|
|
38
|
+
deepseekV4ProMaxReasoningPresets: null, deepseekFlashMaxReasoningPresets: null,
|
|
39
|
+
modules: { deepwork: { enabled: null } }, sessionPersistence: { root: null, compression: null },
|
|
40
|
+
skills: "skills", roles: "roles", roleRouting: "role-routing", runtimePolicy: { strategy: null, rateLimit },
|
|
41
|
+
presets: { materialize: null, plannerRootEnabled: null, root: null }, subagents: { toolTopology: null, allowRouteOverride: null, enableRunInBackground: null, backgroundMode: null, maxDepth: null },
|
|
42
|
+
workflow: { policy: null, strictGates: null, reviewCap: null, finalReviewPolicy: null },
|
|
43
|
+
guards: { scope: null, shellCommandSafety: null, gitWriteGuard: null, toolOutputTruncation: { enabled: null, maxInlineBytes: null }, planFormatValidation: null, questionLabelHelper: { enabled: null, maxLabelChars: null }, todoDisciplineHelper: null },
|
|
44
|
+
runtimeRecovery: { enabled: null, retryOnStatusCodes: [null], retryOnCodes: [null], fallbackRoutes: [route], maxFallbackAttempts: null, idleContinuation: { enabled: null, maxContinuations: null, prompt: null } },
|
|
45
|
+
lsp: { enabled: null, serverName: null, command: null, args: [null], cwd: null, env: {}, toolCallTimeoutMs: null, failOnStartupError: null }
|
|
46
|
+
};
|
|
47
|
+
const documentFields = { version: null, id: null, label: null, settings: configFields };
|
|
48
|
+
const rootFields = { ...configFields, ...documentFields, document: documentFields, content: null, expectedRevision: null, expectedSelectionRevision: null, expectedAdmissionEpoch: null, expectedModeRevision: null, sessionId: null, route };
|
|
49
|
+
function childShape(shape, key) {
|
|
50
|
+
if (typeof key === "number")
|
|
51
|
+
return Number.isSafeInteger(key) && key >= 0 && key <= 999999 && Array.isArray(shape) ? shape[0] : undefined;
|
|
52
|
+
if (shape === rootFields && roleId.test(key))
|
|
53
|
+
return null;
|
|
54
|
+
if (shape === "roles")
|
|
55
|
+
return roleId.test(key) ? null : undefined;
|
|
56
|
+
if (shape === "role-routing")
|
|
57
|
+
return roleId.test(key) ? roleRouting : undefined;
|
|
58
|
+
if (shape === "skills")
|
|
59
|
+
return skillId.test(key) ? null : undefined;
|
|
60
|
+
return shape !== null && typeof shape === "object" && !Array.isArray(shape) && Object.hasOwn(shape, key) ? shape[key] : undefined;
|
|
61
|
+
}
|
|
62
|
+
function fieldParts(field) {
|
|
63
|
+
return field.replace(/\[([0-9]+)\]/gu, ".$1").split(".").map(part => /^\d+$/u.test(part) ? Number(part) : part);
|
|
64
|
+
}
|
|
65
|
+
const sourcePaths = new WeakMap();
|
|
66
|
+
/** Host parser location provenance only; never serialized on an error or DTO. */
|
|
67
|
+
export function diagnosticSourcePath(error) { return sourcePaths.get(error); }
|
|
68
|
+
export function safeDiagnosticField(parts) {
|
|
69
|
+
let result = "";
|
|
70
|
+
let shape = rootFields;
|
|
71
|
+
for (const part of parts.slice(0, 16)) {
|
|
72
|
+
const declared = childShape(shape, part);
|
|
73
|
+
const key = declared !== undefined ? part : "[unknown]";
|
|
74
|
+
const next = typeof key === "number" ? `[${key}]` : `${result === "" ? "" : "."}${key}`;
|
|
75
|
+
if (result.length + next.length > 256)
|
|
76
|
+
break;
|
|
77
|
+
result += next;
|
|
78
|
+
shape = declared;
|
|
79
|
+
}
|
|
80
|
+
return result || "document";
|
|
81
|
+
}
|
|
82
|
+
export function isSafeDiagnosticField(value) {
|
|
83
|
+
return typeof value === "string" && value.length <= 256
|
|
84
|
+
&& /^(?:[a-zA-Z][a-zA-Z0-9_-]{0,63}|\[unknown\])(?:\.(?:[a-zA-Z][a-zA-Z0-9_-]{0,63}|\[unknown\])|\[(?:0|[1-9][0-9]{0,5})\])*$/u.test(value)
|
|
85
|
+
&& safeDiagnosticField(fieldParts(value)) === value;
|
|
86
|
+
}
|
|
87
|
+
export function diagnostic(code, field, location) {
|
|
88
|
+
const reason = code === "unsupported-value" && (field === "locale" || field === "settings.locale")
|
|
89
|
+
? "Supported locales: en, zh-Hans, zh-Hant, ja, ko, de, fr, es, pt-BR, ru."
|
|
90
|
+
: PROFILE_DIAGNOSTIC_REASONS[code];
|
|
91
|
+
return { severity: code === "blank-label" ? "warning" : "error", code, field: safeDiagnosticField(fieldParts(field)), reason, ...(location === undefined ? {} : { location }) };
|
|
92
|
+
}
|
|
93
|
+
export class DsmmConfigValidationError extends TypeError {
|
|
94
|
+
diagnostic;
|
|
95
|
+
constructor(code, field) {
|
|
96
|
+
const path = typeof field === "string" ? fieldParts(field) : [...field];
|
|
97
|
+
const info = diagnostic(code, safeDiagnosticField(path));
|
|
98
|
+
super(`${info.field}: ${info.reason}`);
|
|
99
|
+
this.diagnostic = info;
|
|
100
|
+
sourcePaths.set(this, Object.freeze([...path]));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export function diagnosticLocation(content, offset, length) {
|
|
104
|
+
const before = content.slice(0, offset).split(/\r\n|\r|\n/u);
|
|
105
|
+
return { offset, length, line: before.length, column: before.at(-1).length + 1 };
|
|
106
|
+
}
|
|
107
|
+
export function fieldLocation(content, tree, field, sourcePath) {
|
|
108
|
+
const path = sourcePath !== undefined ? [...sourcePath] : field === "document" || field === "content" ? [] : fieldParts(field);
|
|
109
|
+
let node = findNodeAtLocation(tree, path);
|
|
110
|
+
while (node === undefined && path.length) {
|
|
111
|
+
path.pop();
|
|
112
|
+
node = findNodeAtLocation(tree, path);
|
|
113
|
+
}
|
|
114
|
+
if (node === undefined)
|
|
115
|
+
return undefined;
|
|
116
|
+
const selected = node.parent?.type === "property" ? node.parent.children[0] : node;
|
|
117
|
+
return diagnosticLocation(content, selected.offset, selected.length);
|
|
118
|
+
}
|
|
119
|
+
export function inspectJsonDocument(content, jsonc = true) {
|
|
120
|
+
const errors = [];
|
|
121
|
+
// Replace, rather than remove, the BOM so offsets still address original bytes/text.
|
|
122
|
+
const tree = parseTree(content.replace(/^\uFEFF/u, " "), errors, { allowTrailingComma: jsonc, disallowComments: !jsonc, allowEmptyContent: false });
|
|
123
|
+
if (tree === undefined || errors.length)
|
|
124
|
+
return { tree, diagnostics: [diagnostic("invalid-jsonc", "content", diagnosticLocation(content, errors[0]?.offset ?? 0, errors[0]?.length ?? 0))] };
|
|
125
|
+
const diagnostics = [];
|
|
126
|
+
const walk = (node, path, depth) => {
|
|
127
|
+
if (depth > 32) {
|
|
128
|
+
diagnostics.push(diagnostic("invalid-type", safeDiagnosticField(path), diagnosticLocation(content, node.offset, node.length)));
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (node.type === "object") {
|
|
132
|
+
const found = new Set();
|
|
133
|
+
for (const property of node.children ?? []) {
|
|
134
|
+
const keyNode = property.children[0], key = String(keyNode.value), next = [...path, key];
|
|
135
|
+
const code = ["__proto__", "constructor", "prototype"].includes(key) ? "unsafe-field" : found.has(key) ? "duplicate-field" : undefined;
|
|
136
|
+
if (code !== undefined)
|
|
137
|
+
diagnostics.push(diagnostic(code, safeDiagnosticField(next), diagnosticLocation(content, keyNode.offset, keyNode.length)));
|
|
138
|
+
found.add(key);
|
|
139
|
+
walk(property.children[1], next, depth + 1);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else if (node.type === "array")
|
|
143
|
+
(node.children ?? []).forEach((child, index) => walk(child, [...path, index], depth + 1));
|
|
144
|
+
};
|
|
145
|
+
walk(tree, [], 0);
|
|
146
|
+
return { tree, diagnostics };
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=profile-diagnostics.js.map
|
package/lib/profile-remote.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import type { ProfileErrorInfo, ProfileReadResult, ProfileSaveRequest, ProfileSe
|
|
|
4
4
|
import type { GlobalConfigSaveRequest, GlobalConfigSnapshot } from "./deployment-config.js";
|
|
5
5
|
import type { DsmmModuleState } from "./modules.js";
|
|
6
6
|
import type { DeploymentEditorSnapshot } from "./profile-types.js";
|
|
7
|
+
import type { DsmmRoleAvailabilityState, ProfileDiagnostic, SubagentRuntimeAdmissionView } from "./profile-types.js";
|
|
8
|
+
import type { DsmmInvocationView, DsmmRoleRouteComparison } from "./profile-types.js";
|
|
7
9
|
export interface DsmmConfigRemote {
|
|
8
10
|
describe(): Promise<RemoteResult<GlobalConfigSnapshot>>;
|
|
9
11
|
save(request: GlobalConfigSaveRequest): Promise<RemoteResult<GlobalConfigSnapshot>>;
|
|
@@ -46,6 +48,12 @@ declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
|
46
48
|
export declare function isProfileId(value: unknown): value is string;
|
|
47
49
|
/** Opaque native identities are never interpreted as paths. */
|
|
48
50
|
export declare function isNativeSessionId(value: unknown): value is string;
|
|
51
|
+
export declare function parseProfileErrorInfo(value: unknown): ProfileErrorInfo;
|
|
52
|
+
export declare function parseProfileDiagnostic(value: unknown): ProfileDiagnostic;
|
|
53
|
+
export declare function parseRoleAvailability(value: unknown): DsmmRoleAvailabilityState;
|
|
54
|
+
export declare function parseSubagentRuntimeAdmissionView(value: unknown): SubagentRuntimeAdmissionView;
|
|
55
|
+
export declare function parseDsmmRoleRouteComparison(value: unknown): DsmmRoleRouteComparison;
|
|
56
|
+
export declare function parseDsmmInvocationView(value: unknown): DsmmInvocationView;
|
|
49
57
|
/** Explicit strict Host contract; no SRC fallback or browser-supplied authority. */
|
|
50
58
|
export declare const TYPERT_REMOTE: TypertRemoteContribution;
|
|
51
59
|
export declare const TYPERT_HOST: TypertContribution;
|