@dsmm/dsmm 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -67
- package/agent-presets/dsmm-builder/agent.cordis.yml +10 -2015
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +24 -343
- package/agent-presets/dsmm-code-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-coding/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-complex/agent.cordis.yml +23 -1009
- package/agent-presets/dsmm-creative/agent.cordis.yml +25 -442
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +29 -1013
- package/agent-presets/dsmm-deep/agent.cordis.yml +24 -1008
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-documenting/agent.cordis.yml +26 -439
- package/agent-presets/dsmm-frontend/agent.cordis.yml +21 -440
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +22 -441
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-oracle/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +29 -2025
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +24 -341
- package/agent-presets/dsmm-planner/agent.cordis.yml +14 -344
- package/agent-presets/dsmm-quick/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-research/agent.cordis.yml +23 -8
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +25 -340
- package/cordis.patch.yml +14 -0
- package/docs/agent-presets.md +36 -52
- package/docs/compatibility.md +47 -110
- package/docs/deferred-native-approval-risk.md +19 -0
- package/docs/design.md +2 -2
- package/docs/lsp.md +11 -21
- package/docs/migration-from-ocmm.md +2 -2
- package/docs/model-routing.md +84 -59
- package/docs/native-permissions.md +35 -0
- package/docs/profiles.md +40 -87
- package/docs/releasing.md +123 -2
- package/docs/roadmap.md +71 -17
- package/docs/settings-status.md +34 -169
- package/docs/skill-sync.md +52 -15
- package/lib/agent-registry.d.ts +36 -0
- package/lib/agent-registry.js +75 -0
- package/lib/child-admission-contract.d.ts +37 -0
- package/lib/child-admission-contract.js +2 -0
- package/lib/child-admission.d.ts +40 -0
- package/lib/child-admission.js +151 -0
- package/lib/child-capture.d.ts +85 -0
- package/lib/child-capture.js +205 -0
- package/lib/child-evidence.d.ts +17 -0
- package/lib/child-evidence.js +43 -0
- package/lib/client/ChildrenPanel.d.ts +43 -0
- package/lib/client/ChildrenPanel.js +82 -0
- package/lib/client/DeploymentPage.js +15 -8
- package/lib/client/EditableChoice.d.ts +17 -0
- package/lib/client/EditableChoice.js +49 -0
- package/lib/client/PermissionsPanel.d.ts +14 -0
- package/lib/client/PermissionsPanel.js +46 -0
- package/lib/client/ProfilesSection.js +30 -15
- package/lib/client/RoleAvailability.d.ts +7 -0
- package/lib/client/RoleAvailability.js +19 -0
- package/lib/client/SessionProfiles.js +27 -9
- package/lib/client/StructuredEditor.js +15 -7
- package/lib/client/children-controller.d.ts +98 -0
- package/lib/client/children-controller.js +296 -0
- package/lib/client/children-locales.d.ts +367 -0
- package/lib/client/children-locales.js +69 -0
- package/lib/client/controller.d.ts +6 -1
- package/lib/client/controller.js +14 -8
- package/lib/client/deployment-controller.js +1 -1
- package/lib/client/deployment-data.d.ts +2 -1
- package/lib/client/deployment-data.js +34 -5
- package/lib/client/deployment-locales.d.ts +4 -0
- package/lib/client/deployment-locales.js +11 -2
- package/lib/client/diagnostics.d.ts +14 -0
- package/lib/client/diagnostics.js +53 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +96 -2
- package/lib/client/locales.d.ts +54 -0
- package/lib/client/locales.js +34 -16
- package/lib/client/permission-client.d.ts +16 -0
- package/lib/client/permission-client.js +38 -0
- package/lib/client/permission-controller.d.ts +62 -0
- package/lib/client/permission-controller.js +149 -0
- package/lib/client/permission-locales.d.ts +114 -0
- package/lib/client/permission-locales.js +75 -0
- package/lib/client/session-labels.js +4 -4
- package/lib/client/structured.js +19 -5
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +20 -0
- package/lib/client.js +5780 -1679
- package/lib/core-permission-authority.d.ts +18 -0
- package/lib/core-permission-authority.js +255 -0
- package/lib/core-permissions.d.ts +8 -0
- package/lib/core-permissions.js +33 -0
- package/lib/delivery-authority.d.ts +83 -0
- package/lib/delivery-authority.js +397 -0
- package/lib/deployment-config.d.ts +23 -0
- package/lib/deployment-config.js +61 -40
- package/lib/deployment-permission-rules.d.ts +55 -0
- package/lib/deployment-permission-rules.js +306 -0
- package/lib/dsh-types.d.ts +10 -4
- package/lib/guards.d.ts +1 -1
- package/lib/guards.js +29 -8
- package/lib/host-llm-startup.d.ts +41 -0
- package/lib/host-llm-startup.js +65 -0
- package/lib/host-llm.d.ts +92 -0
- package/lib/host-llm.js +325 -0
- package/lib/index.d.ts +15 -4
- package/lib/index.js +288 -48
- package/lib/live-pi-ai-owner.d.ts +18 -0
- package/lib/live-pi-ai-owner.js +144 -0
- package/lib/llm-runtime.d.ts +11 -0
- package/lib/llm-runtime.js +21 -0
- package/lib/managed-settings.d.ts +5 -0
- package/lib/managed-settings.js +14 -0
- package/lib/model-parameter-policy.d.ts +11 -0
- package/lib/model-parameter-policy.js +27 -0
- package/lib/model-routing.js +28 -17
- package/lib/modules.d.ts +13 -5
- package/lib/modules.js +17 -1
- package/lib/native-child-evidence.d.ts +40 -0
- package/lib/native-child-evidence.js +104 -0
- package/lib/native-pi-ai-wire.d.ts +37 -0
- package/lib/native-pi-ai-wire.js +261 -0
- package/lib/native-scope.js +1 -1
- package/lib/permission-bash.d.ts +6 -0
- package/lib/permission-bash.js +7 -0
- package/lib/permission-control.d.ts +73 -0
- package/lib/permission-control.js +205 -0
- package/lib/permission-controller.d.ts +68 -0
- package/lib/permission-controller.js +317 -0
- package/lib/permission-errors.d.ts +7 -0
- package/lib/permission-errors.js +21 -0
- package/lib/permission-fs-search.d.ts +5 -0
- package/lib/permission-fs-search.js +7 -0
- package/lib/permission-fs.d.ts +5 -0
- package/lib/permission-fs.js +7 -0
- package/lib/permission-native-access.d.ts +11 -0
- package/lib/permission-native-access.js +6 -0
- package/lib/permission-native-command.d.ts +10 -0
- package/lib/permission-native-command.js +93 -0
- package/lib/permission-native-rules.d.ts +75 -0
- package/lib/permission-native-rules.js +278 -0
- package/lib/permission-pwsh.d.ts +6 -0
- package/lib/permission-pwsh.js +7 -0
- package/lib/permission-remote.d.ts +26 -0
- package/lib/permission-remote.js +53 -0
- package/lib/permission-rpc.d.ts +29 -0
- package/lib/permission-rpc.js +152 -0
- package/lib/permission-rules.d.ts +115 -0
- package/lib/permission-rules.js +256 -0
- package/lib/permission-settings.d.ts +45 -0
- package/lib/permission-settings.js +48 -0
- package/lib/permission-shell.d.ts +38 -0
- package/lib/permission-shell.js +150 -0
- package/lib/permission-web.d.ts +5 -0
- package/lib/permission-web.js +7 -0
- package/lib/preset-registry.js +36 -25
- package/lib/profile-diagnostics.d.ts +45 -0
- package/lib/profile-diagnostics.js +148 -0
- package/lib/profile-locale.d.ts +3 -0
- package/lib/profile-locale.js +2 -0
- package/lib/profile-remote.d.ts +8 -0
- package/lib/profile-remote.js +163 -39
- package/lib/profile-rpc.d.ts +4 -3
- package/lib/profile-rpc.js +20 -16
- package/lib/profile-runtime.d.ts +40 -1
- package/lib/profile-runtime.js +368 -93
- package/lib/profile-store.d.ts +11 -0
- package/lib/profile-store.js +143 -11
- package/lib/profile-types.d.ts +70 -1
- package/lib/profile-types.js +1 -0
- package/lib/profiles.d.ts +16 -2
- package/lib/profiles.js +156 -79
- package/lib/prompt-content.js +1 -1
- package/lib/prompts.d.ts +37 -2
- package/lib/prompts.js +111 -9
- package/lib/recovery-policy.js +20 -7
- package/lib/role-control-remote.d.ts +38 -0
- package/lib/role-control-remote.js +211 -0
- package/lib/role-control-rpc.d.ts +51 -0
- package/lib/role-control-rpc.js +381 -0
- package/lib/role-control-types.d.ts +92 -0
- package/lib/role-control-types.js +8 -0
- package/lib/role-invocation.d.ts +47 -0
- package/lib/role-invocation.js +135 -0
- package/lib/role-llm-runtime.d.ts +17 -0
- package/lib/role-llm-runtime.js +62 -0
- package/lib/role-llm.d.ts +31 -0
- package/lib/role-llm.js +66 -0
- package/lib/role-policy.d.ts +46 -8
- package/lib/role-policy.js +421 -61
- package/lib/role-providers.d.ts +2 -2
- package/lib/role-providers.js +27 -72
- package/lib/role-routing.d.ts +11 -2
- package/lib/role-routing.js +42 -25
- package/lib/role-runs.d.ts +138 -0
- package/lib/role-runs.js +335 -0
- package/lib/role-subagents.d.ts +58 -3
- package/lib/role-subagents.js +179 -56
- package/lib/roles.d.ts +5 -6
- package/lib/roles.js +10 -39
- package/lib/route-json.d.ts +19 -0
- package/lib/route-json.js +129 -0
- package/lib/routing-policy.d.ts +2 -0
- package/lib/routing-policy.js +12 -2
- package/lib/runtime-integration.d.ts +81 -0
- package/lib/runtime-integration.js +702 -0
- package/lib/runtime-recovery.js +18 -8
- package/lib/session-persistence.d.ts +2 -1
- package/lib/session-persistence.js +1 -1
- package/lib/session-scope.js +4 -1
- package/lib/settings.d.ts +47 -13
- package/lib/settings.js +217 -82
- package/lib/skills.js +2 -2
- package/lib/status.d.ts +10 -1
- package/lib/status.js +11 -8
- package/lib/subagent-runtime.d.ts +57 -0
- package/lib/subagent-runtime.js +257 -0
- package/package.json +149 -89
- package/patches/subagent-runtime.yml +15 -0
- package/prompts/deepseek-flash.md +1 -1
- package/prompts/deepseek-v4-pro.md +2 -2
- package/prompts/deepwork.md +27 -18
- package/prompts/source/agents/clarifier.md +5 -3
- package/prompts/source/agents/orchestrator.md +18 -9
- package/prompts/source/agents/plan-critic.md +5 -1
- package/prompts/source/agents/planner.md +4 -2
- package/prompts/source/agents/reviewer.md +6 -0
- package/prompts/source/category/complex.md +4 -4
- package/prompts/source/category/creative.md +6 -4
- package/prompts/source/category/cross-cutting.md +10 -8
- package/prompts/source/category/deep.md +5 -3
- package/prompts/source/category/documenting.md +7 -1
- package/prompts/source/category/frontend.md +2 -2
- package/prompts/source/category/hard-reasoning.md +3 -3
- package/prompts/source/category/research.md +4 -2
- package/prompts/source/deepwork/claude-opus-5.md +2 -2
- package/prompts/source/deepwork/codex.md +1 -1
- package/prompts/source/deepwork/default.md +22 -15
- package/prompts/source/deepwork/gemini.md +23 -16
- package/prompts/source/deepwork/glm.md +21 -14
- package/prompts/source/deepwork/gpt.md +12 -6
- package/prompts/source/deepwork/planner.md +8 -5
- package/prompts/source/manifest.json +178 -63
- package/prompts/source/shared/dsh-host-contract.md +5 -3
- package/prompts/source/shared/locale.md +2 -2
- package/prompts/source/terminal/orchestrator.md +1 -1
- package/skills/ast-grep/SKILL.md +7 -4
- package/skills/brainstorming/SKILL.md +43 -22
- package/skills/coding-agent-sessions/SKILL.md +7 -4
- package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -46
- package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -130
- package/skills/debugging/SKILL.md +14 -9
- package/skills/debugging/references/methodology/00-setup.md +14 -62
- package/skills/debugging/references/methodology/02-investigate.md +4 -4
- package/skills/debugging/references/methodology/03-flaky-triage.md +3 -3
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +2 -14
- package/skills/debugging/references/methodology/06-fix.md +6 -6
- package/skills/debugging/references/methodology/08-qa.md +5 -5
- package/skills/debugging/references/methodology/09-cleanup.md +15 -153
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +3 -16
- package/skills/debugging/references/runtimes/bundled-js-binary.md +1 -16
- package/skills/debugging/references/runtimes/native-binary.md +9 -54
- package/skills/debugging/references/runtimes/node.md +4 -15
- package/skills/debugging/references/runtimes/python.md +3 -15
- package/skills/debugging/references/runtimes/rust.md +2 -18
- package/skills/debugging/references/tools/dap.md +1 -1
- package/skills/debugging/references/tools/ghidra.md +4 -15
- package/skills/debugging/references/tools/playwright-cli.md +3 -15
- package/skills/debugging/references/tools/pwntools.md +4 -16
- package/skills/dispatching-parallel-agents/SKILL.md +18 -16
- package/skills/frontend/SKILL.md +7 -4
- package/skills/frontend/references/design/react-dev-tooling-skill.md +1 -1
- package/skills/git-master/SKILL.md +7 -4
- package/skills/init-deep/SKILL.md +7 -4
- package/skills/receiving-code-review/SKILL.md +17 -12
- package/skills/remove-ai-slops/SKILL.md +39 -38
- package/skills/requesting-code-review/SKILL.md +19 -17
- package/skills/requesting-code-review/code-reviewer.md +13 -1
- package/skills/subagent-driven-development/SKILL.md +29 -26
- package/skills/subagent-driven-development/implementer-prompt.md +29 -11
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +6 -1
- package/skills/using-git-worktrees/SKILL.md +7 -4
- package/skills/writing-plans/SKILL.md +29 -24
- package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -1
- package/scripts/repair-session-log.mjs +0 -476
- package/scripts/session-repair-native-verifier.mjs +0 -367
package/lib/recovery-policy.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import { normalizeModelRouteJson } from "./route-json.js";
|
|
3
|
+
import { modelRouteFromHeader } from "./role-llm.js";
|
|
1
4
|
const REQUEST_HEADER_REASONS = new Set(["initial", "resume", "change", "series"]);
|
|
2
5
|
const TODO_STATUSES = new Set(["pending", "in_progress", "completed"]);
|
|
3
6
|
const GOAL_OPERATIONS = new Set(["create", "edit", "pause", "resume", "complete", "block"]);
|
|
@@ -106,9 +109,6 @@ export function selectFallbackRoute({ failedRoute, attemptedRoutes, fallbackRout
|
|
|
106
109
|
function isRecord(value) {
|
|
107
110
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
108
111
|
}
|
|
109
|
-
function isNonEmptyString(value) {
|
|
110
|
-
return typeof value === "string" && value.trim() !== "";
|
|
111
|
-
}
|
|
112
112
|
function isNormalizedNonEmptyString(value) {
|
|
113
113
|
return typeof value === "string" && value !== "" && value === value.trim();
|
|
114
114
|
}
|
|
@@ -123,12 +123,15 @@ function hasExactKeys(value, expectedKeys) {
|
|
|
123
123
|
return keys.length === expectedKeys.length && keys.every((key) => expectedKeys.includes(key));
|
|
124
124
|
}
|
|
125
125
|
function readRoute(value) {
|
|
126
|
-
|
|
126
|
+
try {
|
|
127
|
+
return normalizeModelRouteJson(value, false, true);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
127
130
|
return undefined;
|
|
128
|
-
|
|
131
|
+
}
|
|
129
132
|
}
|
|
130
133
|
function sameRoute(left, right) {
|
|
131
|
-
return left
|
|
134
|
+
return isDeepStrictEqual(readRoute(left), readRoute(right));
|
|
132
135
|
}
|
|
133
136
|
function appendUniqueRoute(routes, route) {
|
|
134
137
|
if (!routes.some((candidate) => sameRoute(candidate, route)))
|
|
@@ -168,7 +171,17 @@ function readHeaderRoute(event) {
|
|
|
168
171
|
return undefined;
|
|
169
172
|
if (!isRecord(data.header) || !isRecord(data.header.config))
|
|
170
173
|
return undefined;
|
|
171
|
-
|
|
174
|
+
try {
|
|
175
|
+
const provider = data.header.config.provider;
|
|
176
|
+
if (typeof provider !== "string")
|
|
177
|
+
return undefined;
|
|
178
|
+
// Decode native envelopes with valid grammar, then retain the exact durable identity.
|
|
179
|
+
const route = modelRouteFromHeader({ ...data.header, config: { ...data.header.config, provider: provider.trim() } });
|
|
180
|
+
return readRoute({ ...route, provider });
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
172
185
|
}
|
|
173
186
|
function endsTargetScope(event) {
|
|
174
187
|
const type = eventType(event);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RemoteResult, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
|
+
import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry";
|
|
3
|
+
import type { BackgroundTransitionResult, ChildSessionSnapshot, RoleControlBackgroundRequest, RoleControlCapabilities, RoleControlDescendantsSnapshot, RoleControlErrorInfo, RoleControlInterruptRequest, SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from "./role-control-types.js";
|
|
4
|
+
export interface DsmmChildrenRemote {
|
|
5
|
+
describe(sessionId: string): Promise<RemoteResult<ChildSessionSnapshot>>;
|
|
6
|
+
descendants(sessionId: string): Promise<RemoteResult<RoleControlDescendantsSnapshot>>;
|
|
7
|
+
background(sessionId: string, request: RoleControlBackgroundRequest): Promise<RemoteResult<BackgroundTransitionResult>>;
|
|
8
|
+
prompt(sessionId: string, request: SubagentPromptRequest): Promise<RemoteResult<SubagentPromptReceipt>>;
|
|
9
|
+
interrupt(sessionId: string, request: RoleControlInterruptRequest): Promise<RemoteResult<SubagentInterruptReceipt>>;
|
|
10
|
+
}
|
|
11
|
+
declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
12
|
+
interface TypertRemoteMap {
|
|
13
|
+
"dsmmChildren/describe": DsmmChildrenRemote["describe"];
|
|
14
|
+
"dsmmChildren/descendants": DsmmChildrenRemote["descendants"];
|
|
15
|
+
"dsmmChildren/background": DsmmChildrenRemote["background"];
|
|
16
|
+
"dsmmChildren/prompt": DsmmChildrenRemote["prompt"];
|
|
17
|
+
"dsmmChildren/interrupt": DsmmChildrenRemote["interrupt"];
|
|
18
|
+
}
|
|
19
|
+
interface TypertRemoteNamespaceMap {
|
|
20
|
+
dsmmChildren: DsmmChildrenRemote;
|
|
21
|
+
}
|
|
22
|
+
interface RemoteErrorDetailsMap {
|
|
23
|
+
"dsmm-children/refused": RoleControlErrorInfo;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export declare const parseRoleControlErrorInfo: (value: unknown) => RoleControlErrorInfo;
|
|
27
|
+
export declare const parseChildSessionSnapshot: (value: unknown) => ChildSessionSnapshot;
|
|
28
|
+
export declare const parseRoleControlDescendants: (value: unknown) => RoleControlDescendantsSnapshot;
|
|
29
|
+
export declare const parseRoleControlBackgroundRequest: (value: unknown) => RoleControlBackgroundRequest;
|
|
30
|
+
export declare const parseRoleControlPromptRequest: (value: unknown) => SubagentPromptRequest;
|
|
31
|
+
export declare const parseRoleControlInterruptRequest: (value: unknown) => RoleControlInterruptRequest;
|
|
32
|
+
export declare const parseRoleControlCapabilities: (value: unknown) => RoleControlCapabilities;
|
|
33
|
+
export declare const parseRoleControlSessionId: (value: unknown) => string;
|
|
34
|
+
/** Separate package identity prevents replacing the Profiles contribution. */
|
|
35
|
+
export declare const ROLE_CONTROL_REMOTE: TypertRemoteContribution;
|
|
36
|
+
export declare const ROLE_CONTROL_HOST: TypertContribution;
|
|
37
|
+
export default ROLE_CONTROL_REMOTE;
|
|
38
|
+
//# sourceMappingURL=role-control-remote.d.ts.map
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { parseDsmmInvocationView, parseDsmmRoleRouteComparison, parseSubagentRuntimeAdmissionView, isNativeSessionId } from "./profile-remote.js";
|
|
2
|
+
import { parseChildAdmissionEvidenceView } from "./child-evidence.js";
|
|
3
|
+
import { ROLE_CONTROL_DISABLED_REASONS, ROLE_CONTROL_ERROR_CODES, ROLE_CONTROL_ERROR_FIELDS } from "./role-control-types.js";
|
|
4
|
+
function fail() { throw new TypeError("Invalid Deepwork child control DTO."); }
|
|
5
|
+
/** Reject executable/non-JSON shapes before accessing any properties. */
|
|
6
|
+
function json(value, depth = 0, active = new Set()) {
|
|
7
|
+
if (depth > 24)
|
|
8
|
+
fail();
|
|
9
|
+
if (value === null || typeof value === "boolean" || typeof value === "string")
|
|
10
|
+
return value;
|
|
11
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
12
|
+
return value;
|
|
13
|
+
if (typeof value !== "object" || value === null || active.has(value))
|
|
14
|
+
fail();
|
|
15
|
+
const isArray = Array.isArray(value);
|
|
16
|
+
if (Object.getPrototypeOf(value) !== (isArray ? Array.prototype : Object.prototype) && (isArray || Object.getPrototypeOf(value) !== null))
|
|
17
|
+
fail();
|
|
18
|
+
if (Object.getOwnPropertySymbols(value).length)
|
|
19
|
+
fail();
|
|
20
|
+
for (const [key, property] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
21
|
+
if (isArray && key === "length")
|
|
22
|
+
continue;
|
|
23
|
+
if (!Object.hasOwn(property, "value") || !property.enumerable || ["__proto__", "prototype", "constructor"].includes(key)
|
|
24
|
+
|| isArray && !/^(0|[1-9][0-9]*)$/u.test(key))
|
|
25
|
+
fail();
|
|
26
|
+
}
|
|
27
|
+
if (isArray && Object.keys(value).length !== value.length)
|
|
28
|
+
fail();
|
|
29
|
+
active.add(value);
|
|
30
|
+
const result = isArray ? value.map(child => json(child, depth + 1, active)) : Object.fromEntries(Object.entries(value).map(([key, child]) => [key, json(child, depth + 1, active)]));
|
|
31
|
+
active.delete(value);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
function object(value, required, optional = []) {
|
|
35
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
36
|
+
fail();
|
|
37
|
+
const row = value;
|
|
38
|
+
if (required.some(key => !Object.hasOwn(row, key)) || Object.keys(row).some(key => !required.includes(key) && !optional.includes(key)))
|
|
39
|
+
fail();
|
|
40
|
+
return row;
|
|
41
|
+
}
|
|
42
|
+
function choice(value, choices) { if (!choices.includes(value))
|
|
43
|
+
fail(); return value; }
|
|
44
|
+
function text(value, max) {
|
|
45
|
+
if (typeof value !== "string" || value.length > max || /[\u0000-\u001f\u007f]/u.test(value)
|
|
46
|
+
|| new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value)
|
|
47
|
+
fail();
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
function identity(value) { if (!isNativeSessionId(value))
|
|
51
|
+
fail(); return value; }
|
|
52
|
+
function epoch(value) { if (typeof value !== "string" || !/^[a-f0-9]{64}$/u.test(value))
|
|
53
|
+
fail(); return value; }
|
|
54
|
+
function array(value, max = 4096) { if (!Array.isArray(value) || value.length > max)
|
|
55
|
+
fail(); return value; }
|
|
56
|
+
function bool(value) { if (typeof value !== "boolean")
|
|
57
|
+
fail(); return value; }
|
|
58
|
+
function depth(value) { if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 4096)
|
|
59
|
+
fail(); return value; }
|
|
60
|
+
function availability(value) {
|
|
61
|
+
const row = object(value, ["enabled"], ["reason"]);
|
|
62
|
+
if (row.enabled === true && !Object.hasOwn(row, "reason"))
|
|
63
|
+
return { enabled: true };
|
|
64
|
+
if (row.enabled !== false)
|
|
65
|
+
fail();
|
|
66
|
+
return { enabled: false, reason: choice(row.reason, ROLE_CONTROL_DISABLED_REASONS) };
|
|
67
|
+
}
|
|
68
|
+
function capabilities(value) {
|
|
69
|
+
const row = object(value, ["background", "prompt", "interrupt", "images", "runtime"]);
|
|
70
|
+
return { background: availability(row.background), prompt: availability(row.prompt), interrupt: availability(row.interrupt), images: availability(row.images), runtime: parseSubagentRuntimeAdmissionView(row.runtime) };
|
|
71
|
+
}
|
|
72
|
+
function run(value) {
|
|
73
|
+
const row = object(value, ["sessionId", "toolCallId", "state", "background"], ["invocation"]);
|
|
74
|
+
const state = choice(row.state, ["starting", "running", "background", "settled", "cancelled"]);
|
|
75
|
+
const invocation = Object.hasOwn(row, "invocation") ? parseDsmmInvocationView(row.invocation) : undefined;
|
|
76
|
+
if (state === "starting" && invocation !== undefined || invocation !== undefined && (invocation.mode !== "one-shot" || invocation.runId === undefined)
|
|
77
|
+
|| ["running", "background", "settled"].includes(state) && invocation === undefined)
|
|
78
|
+
fail();
|
|
79
|
+
return { sessionId: identity(row.sessionId), toolCallId: identity(row.toolCallId), state, background: availability(row.background), ...(invocation === undefined ? {} : { invocation }) };
|
|
80
|
+
}
|
|
81
|
+
function child(value) {
|
|
82
|
+
const row = object(value, ["id", "parentSessionId", "mode", "activity", "readonly", "controls"], ["label", "invocation", "routeComparison", "evidence"]);
|
|
83
|
+
const controls = object(row.controls, ["prompt", "interrupt"]);
|
|
84
|
+
const mode = choice(row.mode, ["one-shot", "continuable", "unknown"]);
|
|
85
|
+
const prompt = availability(controls.prompt), interrupt = availability(controls.interrupt);
|
|
86
|
+
const readonly = bool(row.readonly);
|
|
87
|
+
if (readonly !== (!prompt.enabled && !interrupt.enabled) || mode !== "continuable" && (prompt.enabled || interrupt.enabled))
|
|
88
|
+
fail();
|
|
89
|
+
const invocation = Object.hasOwn(row, "invocation") ? parseDsmmInvocationView(row.invocation) : undefined;
|
|
90
|
+
const routeComparison = Object.hasOwn(row, "routeComparison") ? parseDsmmRoleRouteComparison(row.routeComparison) : undefined;
|
|
91
|
+
const evidence = Object.hasOwn(row, "evidence") ? parseChildAdmissionEvidenceView(row.evidence) : undefined;
|
|
92
|
+
const id = identity(row.id);
|
|
93
|
+
if (invocation !== undefined && (invocation.childId !== id || invocation.mode !== mode))
|
|
94
|
+
fail();
|
|
95
|
+
if (routeComparison !== undefined && routeComparison.childId !== id)
|
|
96
|
+
fail();
|
|
97
|
+
if (evidence?.mode === "legacy-conservative" && invocation !== undefined)
|
|
98
|
+
fail();
|
|
99
|
+
return { id, parentSessionId: identity(row.parentSessionId), mode, activity: choice(row.activity, ["running", "inactive"]), readonly,
|
|
100
|
+
controls: { prompt, interrupt }, ...(Object.hasOwn(row, "label") ? { label: text(row.label, 120) } : {}),
|
|
101
|
+
...(invocation === undefined ? {} : { invocation }), ...(routeComparison === undefined ? {} : { routeComparison }), ...(evidence === undefined ? {} : { evidence }) };
|
|
102
|
+
}
|
|
103
|
+
function snapshot(value) {
|
|
104
|
+
const row = object(value, ["sessionId", "admissionEpoch", "runs", "children", "capabilities"]);
|
|
105
|
+
const sessionId = identity(row.sessionId), admissionEpoch = epoch(row.admissionEpoch), runs = array(row.runs).map(run), children = array(row.children).map(child);
|
|
106
|
+
if (runs.some(run => run.sessionId !== sessionId) || children.some(child => child.parentSessionId !== sessionId || child.evidence !== undefined && child.evidence.parentAdmissionEpoch !== admissionEpoch))
|
|
107
|
+
fail();
|
|
108
|
+
return { sessionId, admissionEpoch, runs, children, capabilities: capabilities(row.capabilities) };
|
|
109
|
+
}
|
|
110
|
+
function descendants(value) {
|
|
111
|
+
const row = object(value, ["sessionId", "admissionEpoch", "descendants"]);
|
|
112
|
+
const sessionId = identity(row.sessionId), admissionEpoch = epoch(row.admissionEpoch);
|
|
113
|
+
const entries = array(row.descendants).map(value => {
|
|
114
|
+
const entry = object(value, ["kind", "depth"], ["child", "hasChildren", "id", "parentSessionId", "reason"]);
|
|
115
|
+
if (entry.kind === "child") {
|
|
116
|
+
object(entry, ["kind", "depth", "child", "hasChildren"]);
|
|
117
|
+
const projected = child(entry.child);
|
|
118
|
+
if (entry.depth !== 1 && (projected.controls.prompt.enabled || projected.controls.interrupt.enabled))
|
|
119
|
+
fail();
|
|
120
|
+
return { kind: "child", depth: depth(entry.depth), child: projected, hasChildren: bool(entry.hasChildren) };
|
|
121
|
+
}
|
|
122
|
+
object(entry, ["kind", "depth", "id", "parentSessionId", "reason"]);
|
|
123
|
+
if (entry.kind !== "diagnostic")
|
|
124
|
+
fail();
|
|
125
|
+
return { kind: "diagnostic", depth: depth(entry.depth), id: identity(entry.id), parentSessionId: identity(entry.parentSessionId), reason: choice(entry.reason, ["corrupt", "unsupported", "unavailable"]) };
|
|
126
|
+
});
|
|
127
|
+
for (const entry of entries) {
|
|
128
|
+
const parent = entry.kind === "child" ? entry.child.parentSessionId : entry.parentSessionId;
|
|
129
|
+
if ((entry.depth === 1) !== (parent === sessionId))
|
|
130
|
+
fail();
|
|
131
|
+
if (entry.kind === "child" && entry.child.evidence !== undefined && entry.child.evidence.parentAdmissionEpoch !== admissionEpoch)
|
|
132
|
+
fail();
|
|
133
|
+
}
|
|
134
|
+
return { sessionId, admissionEpoch, descendants: entries };
|
|
135
|
+
}
|
|
136
|
+
function backgroundRequest(value) {
|
|
137
|
+
const row = object(value, ["sessionId", "toolCallId", "runId", "expectedAdmissionEpoch"]);
|
|
138
|
+
return { sessionId: identity(row.sessionId), toolCallId: identity(row.toolCallId), runId: identity(row.runId), expectedAdmissionEpoch: epoch(row.expectedAdmissionEpoch) };
|
|
139
|
+
}
|
|
140
|
+
function transition(value) {
|
|
141
|
+
const row = object(value, ["status", "runId"], ["jobId"]);
|
|
142
|
+
const status = choice(row.status, ["background", "already-background", "already-settled", "cancelled"]);
|
|
143
|
+
if (["background", "already-background"].includes(status) !== Object.hasOwn(row, "jobId"))
|
|
144
|
+
fail();
|
|
145
|
+
return { status, runId: identity(row.runId), ...(Object.hasOwn(row, "jobId") ? { jobId: identity(row.jobId) } : {}) };
|
|
146
|
+
}
|
|
147
|
+
function promptRequest(value) {
|
|
148
|
+
const row = object(value, ["requestId", "parentSessionId", "childSessionId", "mode", "delivery", "content"], ["clientTimeZone"]);
|
|
149
|
+
if (row.mode !== "continuable")
|
|
150
|
+
fail();
|
|
151
|
+
const content = array(row.content, Number.MAX_SAFE_INTEGER).map(value => {
|
|
152
|
+
const part = object(value, ["type"], ["text", "mediaType", "data", "name"]);
|
|
153
|
+
if (part.type === "text") {
|
|
154
|
+
object(part, ["type", "text"]);
|
|
155
|
+
if (typeof part.text !== "string")
|
|
156
|
+
fail();
|
|
157
|
+
return { type: "text", text: part.text };
|
|
158
|
+
}
|
|
159
|
+
object(part, ["type", "mediaType", "data"], ["name"]);
|
|
160
|
+
if (part.type !== "image" || typeof part.data !== "string")
|
|
161
|
+
fail();
|
|
162
|
+
return { type: "image", mediaType: choice(part.mediaType, ["image/png", "image/jpeg", "image/webp", "image/gif"]), data: part.data,
|
|
163
|
+
...(Object.hasOwn(part, "name") ? { name: text(part.name, 256) } : {}) };
|
|
164
|
+
});
|
|
165
|
+
if (content.length === 0)
|
|
166
|
+
fail();
|
|
167
|
+
return { requestId: identity(row.requestId), parentSessionId: identity(row.parentSessionId),
|
|
168
|
+
childSessionId: identity(row.childSessionId), mode: "continuable", delivery: choice(row.delivery, ["queue", "steer"]), content,
|
|
169
|
+
...(Object.hasOwn(row, "clientTimeZone") ? { clientTimeZone: text(row.clientTimeZone, 128) } : {}) };
|
|
170
|
+
}
|
|
171
|
+
function interruptRequest(value) {
|
|
172
|
+
const row = object(value, ["parentSessionId", "childSessionId", "mode"]);
|
|
173
|
+
if (row.mode !== "continuable")
|
|
174
|
+
fail();
|
|
175
|
+
return { parentSessionId: identity(row.parentSessionId), childSessionId: identity(row.childSessionId), mode: "continuable" };
|
|
176
|
+
}
|
|
177
|
+
function promptReceipt(value) { const row = object(value, ["messageId"]); return { messageId: identity(row.messageId) }; }
|
|
178
|
+
function interruptReceipt(value) { const row = object(value, ["accepted"]); if (row.accepted !== true)
|
|
179
|
+
fail(); return { accepted: true }; }
|
|
180
|
+
function errorInfo(value) {
|
|
181
|
+
const row = object(value, ["code"], ["field", "reason"]);
|
|
182
|
+
return { code: choice(row.code, ROLE_CONTROL_ERROR_CODES), ...(Object.hasOwn(row, "field") ? { field: choice(row.field, ROLE_CONTROL_ERROR_FIELDS) } : {}),
|
|
183
|
+
...(Object.hasOwn(row, "reason") ? { reason: choice(row.reason, ROLE_CONTROL_DISABLED_REASONS) } : {}) };
|
|
184
|
+
}
|
|
185
|
+
export const parseRoleControlErrorInfo = (value) => errorInfo(json(value));
|
|
186
|
+
export const parseChildSessionSnapshot = (value) => snapshot(json(value));
|
|
187
|
+
export const parseRoleControlDescendants = (value) => descendants(json(value));
|
|
188
|
+
export const parseRoleControlBackgroundRequest = (value) => backgroundRequest(json(value));
|
|
189
|
+
export const parseRoleControlPromptRequest = (value) => promptRequest(json(value));
|
|
190
|
+
export const parseRoleControlInterruptRequest = (value) => interruptRequest(json(value));
|
|
191
|
+
export const parseRoleControlCapabilities = (value) => capabilities(json(value));
|
|
192
|
+
export const parseRoleControlSessionId = (value) => identity(value);
|
|
193
|
+
function codec(symbol, parse) {
|
|
194
|
+
return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: value => parse(json(value)) }) };
|
|
195
|
+
}
|
|
196
|
+
function descriptor(method, result, request) {
|
|
197
|
+
return { id: `@dsmm/dsmm-children#dsmmChildren/${method}`, service: "dsmmChildren", namespace: "dsmmChildren", method, invocation: { kind: "direct" },
|
|
198
|
+
parameters: [{ name: "sessionId", wire: "sessionId", source: "json", codec: codec("ChildControlSessionId", identity) },
|
|
199
|
+
...(request === undefined ? [] : [{ name: "request", wire: "request", source: "json", codec: request }])], result };
|
|
200
|
+
}
|
|
201
|
+
/** Separate package identity prevents replacing the Profiles contribution. */
|
|
202
|
+
export const ROLE_CONTROL_REMOTE = { package: "@dsmm/dsmm-children", descriptors: [
|
|
203
|
+
descriptor("describe", codec("ChildSessionSnapshot", snapshot)),
|
|
204
|
+
descriptor("descendants", codec("RoleControlDescendantsSnapshot", descendants)),
|
|
205
|
+
descriptor("background", codec("BackgroundTransitionResult", transition), codec("RoleControlBackgroundRequest", backgroundRequest)),
|
|
206
|
+
descriptor("prompt", codec("SubagentPromptReceipt", promptReceipt), codec("SubagentPromptRequest", promptRequest)),
|
|
207
|
+
descriptor("interrupt", codec("SubagentInterruptReceipt", interruptReceipt), codec("RoleControlInterruptRequest", interruptRequest)),
|
|
208
|
+
] };
|
|
209
|
+
export const ROLE_CONTROL_HOST = { package: ROLE_CONTROL_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: ROLE_CONTROL_REMOTE.descriptors };
|
|
210
|
+
export default ROLE_CONTROL_REMOTE;
|
|
211
|
+
//# sourceMappingURL=role-control-remote.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { SubagentCatalogEntry } from "@deepseek-ai/dsh-subagent";
|
|
3
|
+
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
4
|
+
import type { DeliveryAdmission, ParentAdmissionTicket } from "./delivery-authority.js";
|
|
5
|
+
import type { DsmmSubagentRuntime } from "./subagent-runtime.js";
|
|
6
|
+
import type { RoleRunInvocation, RoleRunRegistry } from "./role-runs.js";
|
|
7
|
+
import type { BackgroundTransitionResult, ChildAdmissionEvidenceView, ChildSessionSnapshot, DsmmInvocationView, DsmmRoleRouteComparison, RoleControlAvailability, RoleControlBackgroundRequest, RoleControlCapabilities, RoleControlDescendantsSnapshot, RoleControlInterruptRequest, SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from "./role-control-types.js";
|
|
8
|
+
export interface RoleControlChildObservation {
|
|
9
|
+
readonly invocation?: DsmmInvocationView;
|
|
10
|
+
readonly routeComparison?: DsmmRoleRouteComparison;
|
|
11
|
+
readonly evidence?: ChildAdmissionEvidenceView;
|
|
12
|
+
readonly prompt: RoleControlAvailability;
|
|
13
|
+
readonly interrupt: RoleControlAvailability;
|
|
14
|
+
}
|
|
15
|
+
/** Trusted Host adapters borrow captured B/C2b state, never wire claims or new settings. */
|
|
16
|
+
export interface RoleControlCollaborators<A extends DeliveryAdmission, E, C, P> {
|
|
17
|
+
readonly runtime: DsmmSubagentRuntime<A, E>;
|
|
18
|
+
readonly runs: RoleRunRegistry<C, P>;
|
|
19
|
+
capabilities(ticket: ParentAdmissionTicket<A>): RoleControlCapabilities;
|
|
20
|
+
projectRun(invocation: RoleRunInvocation<C, P>): DsmmInvocationView;
|
|
21
|
+
backgroundAvailability(ticket: ParentAdmissionTicket<A>, invocation: RoleRunInvocation<C, P>, signal: AbortSignal): Promise<RoleControlAvailability>;
|
|
22
|
+
/** Read-only evidence fold; must not resume/materialize a child. */
|
|
23
|
+
observeChild(ticket: ParentAdmissionTicket<A>, child: SubagentCatalogEntry, signal: AbortSignal): Promise<RoleControlChildObservation>;
|
|
24
|
+
}
|
|
25
|
+
/** Separate namespace: native inbox/jobs remain the sole execution owners. */
|
|
26
|
+
export declare class DsmmChildrenHost<A extends DeliveryAdmission, E, C, P> extends TypertRemoteService {
|
|
27
|
+
private readonly lifetime;
|
|
28
|
+
private readonly backgroundJobs;
|
|
29
|
+
private readonly collaborators;
|
|
30
|
+
constructor(ctx: Context, collaborators: RoleControlCollaborators<A, E, C, P>);
|
|
31
|
+
private invoke;
|
|
32
|
+
private decode;
|
|
33
|
+
private scoped;
|
|
34
|
+
private capabilities;
|
|
35
|
+
private childView;
|
|
36
|
+
private runView;
|
|
37
|
+
describe(sessionId: string): Promise<ChildSessionSnapshot>;
|
|
38
|
+
descendants(sessionId: string): Promise<RoleControlDescendantsSnapshot>;
|
|
39
|
+
background(sessionId: string, input: RoleControlBackgroundRequest): Promise<BackgroundTransitionResult>;
|
|
40
|
+
private directChild;
|
|
41
|
+
prompt(sessionId: string, input: SubagentPromptRequest): Promise<SubagentPromptReceipt>;
|
|
42
|
+
interrupt(sessionId: string, input: RoleControlInterruptRequest): Promise<SubagentInterruptReceipt>;
|
|
43
|
+
}
|
|
44
|
+
declare module "@deepseek-ai/cordis" {
|
|
45
|
+
interface Context {
|
|
46
|
+
dsmmChildren: DsmmChildrenHost<DeliveryAdmission, unknown, unknown, unknown>;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Caller supplies an owned Host injection fiber; no replacement or auto-mount. */
|
|
50
|
+
export declare function registerRoleControlRpc<A extends DeliveryAdmission, E, C, P>(ctx: Context, collaborators: RoleControlCollaborators<A, E, C, P>): DsmmChildrenHost<A, E, C, P>;
|
|
51
|
+
//# sourceMappingURL=role-control-rpc.d.ts.map
|