@dsmm/dsmm 0.3.0 → 0.3.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 +26 -40
- package/cordis.patch.yml +9 -13
- package/docs/agent-presets.md +26 -14
- package/docs/compatibility.md +24 -68
- package/docs/deferred-native-approval-risk.md +8 -12
- package/docs/design.md +25 -254
- package/docs/lsp.md +2 -2
- package/docs/migration-from-ocmm.md +38 -51
- package/docs/model-routing.md +21 -21
- package/docs/native-permissions.md +17 -7
- package/docs/profiles.md +13 -9
- package/docs/releasing.md +25 -311
- package/docs/roadmap.md +52 -241
- package/docs/runtime-recovery.md +29 -91
- package/docs/safety-guards.md +19 -16
- package/docs/settings-status.md +23 -11
- package/docs/skill-sync.md +17 -17
- package/docs/web-fetch-fakeip.md +82 -0
- package/lib/child-capture.d.ts +12 -2
- package/lib/child-capture.js +22 -5
- package/lib/client/ChildPermissions.d.ts +43 -0
- package/lib/client/ChildPermissions.js +100 -0
- package/lib/client/ChildrenPanel.d.ts +5 -5
- package/lib/client/ChildrenPanel.js +6 -18
- package/lib/client/DeploymentFields.d.ts +32 -0
- package/lib/client/DeploymentFields.js +70 -0
- package/lib/client/DeploymentPage.d.ts +21 -6
- package/lib/client/DeploymentPage.js +80 -112
- package/lib/client/HistoryContinuation.d.ts +7 -0
- package/lib/client/HistoryContinuation.js +22 -0
- package/lib/client/NativeCommandEntries.d.ts +17 -0
- package/lib/client/NativeCommandEntries.js +68 -0
- package/lib/client/PermissionPanelEntry.d.ts +8 -0
- package/lib/client/PermissionPanelEntry.js +11 -0
- package/lib/client/PermissionsPanel.d.ts +3 -1
- package/lib/client/PermissionsPanel.js +10 -9
- package/lib/client/ProfilesSection.js +8 -6
- package/lib/client/RoleAvailability.js +1 -1
- package/lib/client/RoleToolView-data.d.ts +35 -0
- package/lib/client/RoleToolView-data.js +52 -0
- package/lib/client/RoleToolView-locales.d.ts +36 -0
- package/lib/client/RoleToolView-locales.js +20 -0
- package/lib/client/RoleToolView.d.ts +10 -0
- package/lib/client/RoleToolView.js +47 -0
- package/lib/client/SessionProfiles.js +51 -24
- package/lib/client/TemporaryPermissions.d.ts +21 -0
- package/lib/client/TemporaryPermissions.js +94 -0
- package/lib/client/children-controller.d.ts +2 -8
- package/lib/client/children-controller.js +1 -26
- package/lib/client/children-locales.d.ts +27 -52
- package/lib/client/children-locales.js +8 -12
- package/lib/client/configuration-display.d.ts +5 -0
- package/lib/client/configuration-display.js +11 -0
- package/lib/client/controller.d.ts +18 -0
- package/lib/client/controller.js +118 -28
- package/lib/client/deployment-controller.d.ts +13 -1
- package/lib/client/deployment-controller.js +84 -24
- package/lib/client/deployment-data.d.ts +1 -0
- package/lib/client/deployment-data.js +4 -1
- package/lib/client/deployment-locales.d.ts +43 -0
- package/lib/client/deployment-locales.js +45 -19
- package/lib/client/deployment-modules.d.ts +9 -0
- package/lib/client/deployment-modules.js +24 -0
- package/lib/client/deployment-workspace.d.ts +48 -0
- package/lib/client/deployment-workspace.js +123 -0
- package/lib/client/history-controller.d.ts +29 -0
- package/lib/client/history-controller.js +111 -0
- package/lib/client/history-entry.d.ts +11 -0
- package/lib/client/history-entry.js +106 -0
- package/lib/client/history-locales.d.ts +95 -0
- package/lib/client/history-locales.js +41 -0
- package/lib/client/index.js +26 -76
- package/lib/client/locales.d.ts +13 -0
- package/lib/client/locales.js +104 -86
- package/lib/client/permission-controller.d.ts +1 -0
- package/lib/client/permission-controller.js +3 -2
- package/lib/client/permission-locales.d.ts +51 -0
- package/lib/client/permission-locales.js +59 -19
- package/lib/client/session-labels.js +4 -3
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +9 -8
- package/lib/client/temporary-permission-client.d.ts +20 -0
- package/lib/client/temporary-permission-client.js +52 -0
- package/lib/client/temporary-permission-entry.d.ts +6 -0
- package/lib/client/temporary-permission-entry.js +56 -0
- package/lib/client.js +5691 -3439
- package/lib/commands.js +2 -0
- package/lib/config-file-store.d.ts +3 -0
- package/lib/config-file-store.js +4 -2
- package/lib/config-revision.d.ts +5 -0
- package/lib/config-revision.js +11 -0
- package/lib/core-permission-authority.js +11 -41
- package/lib/deployment-config.d.ts +9 -2
- package/lib/deployment-config.js +35 -8
- package/lib/deployment-permission-rules.js +19 -7
- package/lib/dsh-types.d.ts +1 -1
- package/lib/history-candidates.d.ts +30 -0
- package/lib/history-candidates.js +176 -0
- package/lib/history-codec.d.ts +11 -0
- package/lib/history-codec.js +102 -0
- package/lib/history-contract.d.ts +44 -0
- package/lib/history-contract.js +2 -0
- package/lib/history-controller.d.ts +42 -0
- package/lib/history-controller.js +329 -0
- package/lib/history-policy.d.ts +4 -0
- package/lib/history-policy.js +8 -0
- package/lib/history-remote.d.ts +28 -0
- package/lib/history-remote.js +17 -0
- package/lib/history-rpc.d.ts +24 -0
- package/lib/history-rpc.js +136 -0
- package/lib/history-support.d.ts +15 -0
- package/lib/history-support.js +21 -0
- package/lib/history-types.d.ts +67 -0
- package/lib/history-types.js +2 -0
- package/lib/host-llm-startup.js +3 -3
- package/lib/host-llm.d.ts +9 -3
- package/lib/host-llm.js +48 -8
- package/lib/index.d.ts +18 -20
- package/lib/index.js +147 -415
- package/lib/lifetime.d.ts +4 -0
- package/lib/lifetime.js +22 -0
- package/lib/live-pi-ai-owner.d.ts +1 -0
- package/lib/live-pi-ai-owner.js +8 -4
- package/lib/mode.d.ts +3 -2
- package/lib/mode.js +28 -41
- package/lib/model-routing.d.ts +2 -8
- package/lib/model-routing.js +59 -175
- package/lib/native-admission.d.ts +77 -0
- package/lib/native-admission.js +503 -0
- package/lib/native-pi-ai-wire.d.ts +3 -1
- package/lib/native-pi-ai-wire.js +47 -13
- package/lib/permission-child-control.d.ts +36 -0
- package/lib/permission-child-control.js +164 -0
- package/lib/permission-control.d.ts +2 -3
- package/lib/permission-control.js +7 -0
- package/lib/permission-controller.js +2 -2
- package/lib/permission-exec-argv.d.ts +32 -0
- package/lib/permission-exec-argv.js +171 -0
- package/lib/permission-fs-search.js +2 -1
- package/lib/permission-fs.js +2 -1
- package/lib/permission-native-rules.js +3 -3
- package/lib/permission-temporary-files.d.ts +19 -0
- package/lib/permission-temporary-files.js +248 -0
- package/lib/permission-temporary-grants.d.ts +106 -0
- package/lib/permission-temporary-grants.js +198 -0
- package/lib/permission-temporary-install.d.ts +25 -0
- package/lib/permission-temporary-install.js +86 -0
- package/lib/permission-temporary-remote.d.ts +19 -0
- package/lib/permission-temporary-remote.js +75 -0
- package/lib/permission-temporary-rpc.d.ts +37 -0
- package/lib/permission-temporary-rpc.js +154 -0
- package/lib/permission-temporary-types.d.ts +47 -0
- package/lib/permission-temporary-types.js +2 -0
- package/lib/permission-temporary-web.d.ts +11 -0
- package/lib/permission-temporary-web.js +154 -0
- package/lib/permission-web.js +2 -1
- package/lib/preset-registry.js +3 -2
- package/lib/preset-skills.d.ts +3 -12
- package/lib/preset-skills.js +28 -58
- package/lib/profile-diagnostics.d.ts +1 -1
- package/lib/profile-diagnostics.js +2 -2
- package/lib/profile-remote.js +61 -22
- package/lib/profile-rpc.d.ts +4 -3
- package/lib/profile-rpc.js +35 -37
- package/lib/profile-runtime.d.ts +42 -74
- package/lib/profile-runtime.js +314 -617
- package/lib/profile-store.d.ts +20 -8
- package/lib/profile-store.js +112 -63
- package/lib/profile-types.d.ts +19 -4
- package/lib/profiles.d.ts +3 -1
- package/lib/profiles.js +9 -7
- package/lib/prompt-content.d.ts +1 -0
- package/lib/prompt-content.js +4 -1
- package/lib/prompts.d.ts +2 -12
- package/lib/prompts.js +11 -66
- package/lib/role-control-remote.d.ts +1 -4
- package/lib/role-control-remote.js +8 -36
- package/lib/role-control-rpc.d.ts +10 -36
- package/lib/role-control-rpc.js +112 -269
- package/lib/role-control-types.d.ts +3 -26
- package/lib/role-control-types.js +3 -4
- package/lib/role-identity.d.ts +5 -0
- package/lib/role-identity.js +10 -0
- package/lib/role-invocation.d.ts +3 -3
- package/lib/role-invocation.js +2 -2
- package/lib/role-llm-runtime.js +5 -11
- package/lib/role-policy.d.ts +19 -50
- package/lib/role-policy.js +136 -508
- package/lib/role-providers.d.ts +5 -8
- package/lib/role-providers.js +20 -86
- package/lib/role-routing.d.ts +1 -3
- package/lib/role-routing.js +24 -34
- package/lib/role-subagents.d.ts +5 -14
- package/lib/role-subagents.js +163 -108
- package/lib/runtime-integration.d.ts +5 -78
- package/lib/runtime-integration.js +11 -697
- package/lib/session-metadata.d.ts +13 -12
- package/lib/session-metadata.js +6 -31
- package/lib/session-scope.js +2 -1
- package/lib/settings.d.ts +5 -18
- package/lib/settings.js +19 -43
- package/lib/skills.d.ts +1 -0
- package/lib/skills.js +5 -1
- package/lib/state.d.ts +3 -2
- package/lib/state.js +26 -10
- package/lib/status.d.ts +1 -9
- package/lib/status.js +3 -55
- package/lib/web-fetch-address-policy.d.ts +24 -0
- package/lib/web-fetch-address-policy.js +189 -0
- package/lib/web-fetch-fakeip.d.ts +25 -0
- package/lib/web-fetch-fakeip.js +107 -0
- package/package.json +124 -106
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +13291 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +9133 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +156 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +3546 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +431 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +119 -0
- package/patches/dsh-approval-settlement/README.md +41 -0
- package/patches/dsh-approval-settlement/metadata.json +10 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +383 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +55 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +16673 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +29 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +196 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +35 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +40 -0
- package/docs/research/deepseek-v4-pro.md +0 -74
- package/docs/research/oh-dsh.md +0 -96
- package/lib/agent-registry.d.ts +0 -36
- package/lib/agent-registry.js +0 -75
- package/lib/child-admission.d.ts +0 -40
- package/lib/child-admission.js +0 -151
- package/lib/delivery-authority.d.ts +0 -83
- package/lib/delivery-authority.js +0 -397
- package/lib/native-child-evidence.d.ts +0 -40
- package/lib/native-child-evidence.js +0 -104
- package/lib/role-runs.d.ts +0 -138
- package/lib/role-runs.js +0 -335
- package/lib/session-persistence.d.ts +0 -36
- package/lib/session-persistence.js +0 -304
- package/lib/subagent-runtime.d.ts +0 -57
- package/lib/subagent-runtime.js +0 -257
- package/prompts/deepseek-flash.md +0 -11
- package/prompts/deepseek-v4-pro.md +0 -14
package/lib/role-control-rpc.js
CHANGED
|
@@ -36,36 +36,35 @@ import { symbols } from "@deepseek-ai/cordis";
|
|
|
36
36
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
37
37
|
import { SubagentError } from "@deepseek-ai/dsh-subagent";
|
|
38
38
|
import { Remote, RemoteError, TypertRemoteService, remoteErrorOf } from "@deepseek-ai/dsh-typert-protocol";
|
|
39
|
-
import { scopeLifetime } from "./
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
39
|
+
import { scopeLifetime } from "./lifetime.js";
|
|
40
|
+
import { runtimeAdmissionView } from "./runtime-integration.js";
|
|
41
|
+
import { invocationView } from "./role-invocation.js";
|
|
42
|
+
import { roleRouteComparison } from "./role-subagents.js";
|
|
43
|
+
import { ROLE_CONTROL_HOST, parseChildSessionSnapshot, parseRoleControlDescendants, parseRoleControlPromptRequest, parseRoleControlInterruptRequest, parseRoleControlSessionId } from "./role-control-remote.js";
|
|
44
|
+
const unavailable = { enabled: false, reason: "unavailable" };
|
|
42
45
|
class ControlRefusal extends Error {
|
|
43
|
-
|
|
46
|
+
code;
|
|
47
|
+
field;
|
|
48
|
+
reason;
|
|
44
49
|
constructor(code, field, reason) {
|
|
45
|
-
super("
|
|
46
|
-
this.
|
|
50
|
+
super("Native child control refused");
|
|
51
|
+
this.code = code;
|
|
52
|
+
this.field = field;
|
|
53
|
+
this.reason = reason;
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
|
-
const disabled = (reason) => ({ enabled: false, reason });
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return state === "settled" ? { status: "already-settled", runId } : state === "cancelled" ? { status: "cancelled", runId } : undefined;
|
|
56
|
+
const disabled = (reason) => ({ enabled: false, reason: reason ?? "unavailable" });
|
|
57
|
+
function boundedLabel(label) {
|
|
58
|
+
const last = label.charCodeAt(119), next = label.charCodeAt(120);
|
|
59
|
+
const bounded = label.slice(0, last >= 0xd800 && last <= 0xdbff && next >= 0xdc00 && next <= 0xdfff ? 119 : 120).replace(/[\u0000-\u001f\u007f]/gu, " ");
|
|
60
|
+
return new TextDecoder().decode(new TextEncoder().encode(bounded));
|
|
55
61
|
}
|
|
56
|
-
|
|
57
|
-
const high = label.charCodeAt(119), low = label.charCodeAt(120);
|
|
58
|
-
// Preserve the UTF-16 wire bound without splitting a valid native code point.
|
|
59
|
-
const end = high >= 0xd800 && high <= 0xdbff && low >= 0xdc00 && low <= 0xdfff ? 119 : 120;
|
|
60
|
-
return label.slice(0, end).replace(/[\u0000-\u001f\u007f]/gu, " ");
|
|
61
|
-
}
|
|
62
|
-
/** Separate namespace: native inbox/jobs remain the sole execution owners. */
|
|
62
|
+
/** Authenticated projection of the native catalog. Listing never wakes a session. */
|
|
63
63
|
let DsmmChildrenHost = (() => {
|
|
64
64
|
let _classSuper = TypertRemoteService;
|
|
65
65
|
let _instanceExtraInitializers = [];
|
|
66
66
|
let _describe_decorators;
|
|
67
67
|
let _descendants_decorators;
|
|
68
|
-
let _background_decorators;
|
|
69
68
|
let _prompt_decorators;
|
|
70
69
|
let _interrupt_decorators;
|
|
71
70
|
return class DsmmChildrenHost extends _classSuper {
|
|
@@ -73,39 +72,65 @@ let DsmmChildrenHost = (() => {
|
|
|
73
72
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
74
73
|
_describe_decorators = [Remote];
|
|
75
74
|
_descendants_decorators = [Remote];
|
|
76
|
-
_background_decorators = [Remote];
|
|
77
75
|
_prompt_decorators = [Remote];
|
|
78
76
|
_interrupt_decorators = [Remote];
|
|
79
77
|
__esDecorate(this, null, _describe_decorators, { kind: "method", name: "describe", static: false, private: false, access: { has: obj => "describe" in obj, get: obj => obj.describe }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
80
78
|
__esDecorate(this, null, _descendants_decorators, { kind: "method", name: "descendants", static: false, private: false, access: { has: obj => "descendants" in obj, get: obj => obj.descendants }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
81
|
-
__esDecorate(this, null, _background_decorators, { kind: "method", name: "background", static: false, private: false, access: { has: obj => "background" in obj, get: obj => obj.background }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
82
79
|
__esDecorate(this, null, _prompt_decorators, { kind: "method", name: "prompt", static: false, private: false, access: { has: obj => "prompt" in obj, get: obj => obj.prompt }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
83
80
|
__esDecorate(this, null, _interrupt_decorators, { kind: "method", name: "interrupt", static: false, private: false, access: { has: obj => "interrupt" in obj, get: obj => obj.interrupt }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
84
81
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
85
82
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
constructor(ctx, collaborators) {
|
|
83
|
+
admission = __runInitializers(this, _instanceExtraInitializers);
|
|
84
|
+
lifetime = new AbortController();
|
|
85
|
+
constructor(ctx, admission) {
|
|
90
86
|
super(ctx, "dsmmChildren");
|
|
91
|
-
this.
|
|
92
|
-
scopeLifetime(ctx, "dsmm
|
|
87
|
+
this.admission = admission;
|
|
88
|
+
scopeLifetime(ctx, "dsmm: retire child controls", () => this.lifetime.abort());
|
|
93
89
|
}
|
|
94
|
-
async
|
|
90
|
+
async scoped(id, operation) {
|
|
91
|
+
let operationSignal;
|
|
95
92
|
try {
|
|
96
|
-
|
|
93
|
+
const sessionId = parseRoleControlSessionId(id), invocation = this.ctx.invocation;
|
|
94
|
+
const connection = this.ctx.get("connection");
|
|
95
|
+
if (!invocation?.peer || connection?.browserPeer !== invocation.peer)
|
|
96
|
+
throw new ControlRefusal("not-owned");
|
|
97
|
+
const owner = Reflect.get(connection, symbols.original) ?? connection;
|
|
98
|
+
const agents = this.ctx.get("agents");
|
|
99
|
+
if (!agents)
|
|
100
|
+
throw new ControlRefusal("unavailable");
|
|
101
|
+
const parent = agents.get(SessionId(sessionId));
|
|
102
|
+
if (!parent)
|
|
103
|
+
throw new ControlRefusal("not-found", "sessionId");
|
|
104
|
+
if (!agents.roots().includes(parent) || parent.session.header.origin === "subagent" || parent.session.id !== parent.id)
|
|
105
|
+
throw new ControlRefusal("not-owned", "sessionId");
|
|
106
|
+
const captured = this.admission.assert(parent);
|
|
107
|
+
const signal = AbortSignal.any([invocation.signal, invocation.peer.signal, this.lifetime.signal, this.admission.lifetime.signal]);
|
|
108
|
+
operationSignal = signal;
|
|
109
|
+
const check = () => {
|
|
110
|
+
signal.throwIfAborted();
|
|
111
|
+
const current = this.ctx.get("connection");
|
|
112
|
+
if (!current || (Reflect.get(current, symbols.original) ?? current) !== owner || current.browserPeer !== invocation.peer
|
|
113
|
+
|| this.admission.assert(parent) !== captured || agents.get(parent.id) !== parent)
|
|
114
|
+
throw new ControlRefusal("not-owned", "sessionId");
|
|
115
|
+
};
|
|
116
|
+
check();
|
|
117
|
+
return await operation({ parent, epoch: captured.epoch, signal, check });
|
|
97
118
|
}
|
|
98
119
|
catch (error) {
|
|
99
120
|
let info;
|
|
100
|
-
if (
|
|
101
|
-
info =
|
|
121
|
+
if (operationSignal?.aborted)
|
|
122
|
+
info = { code: "cancelled" };
|
|
123
|
+
else if (error instanceof ControlRefusal)
|
|
124
|
+
info = { code: error.code, ...(error.field === undefined ? {} : { field: error.field }), ...(error.reason === undefined ? {} : { reason: error.reason }) };
|
|
125
|
+
else if (error instanceof TypeError)
|
|
126
|
+
info = { code: "validation", field: "request" };
|
|
102
127
|
else {
|
|
103
|
-
const code =
|
|
104
|
-
if (
|
|
128
|
+
const code = remoteErrorOf(error)?.code ?? (error instanceof SubagentError ? error.code : undefined);
|
|
129
|
+
if (code === "ABORTED" || code === "gateway/cancelled" || error instanceof Error && error.name === "AbortError")
|
|
105
130
|
info = { code: "cancelled" };
|
|
106
|
-
else if (
|
|
131
|
+
else if (code === "UNAUTHORIZED" || code === "subagent/unauthorized")
|
|
107
132
|
info = { code: "not-owned" };
|
|
108
|
-
else if (
|
|
133
|
+
else if (code === "NOT_RESUMABLE" || code === "subagent/not-resumable")
|
|
109
134
|
info = { code: "not-resumable", field: "childSessionId" };
|
|
110
135
|
else if (code === "subagent/attachment-invalid" || code === "gateway/bad-request")
|
|
111
136
|
info = { code: "invalid-content", field: "content" };
|
|
@@ -114,267 +139,85 @@ let DsmmChildrenHost = (() => {
|
|
|
114
139
|
else
|
|
115
140
|
info = { code: "unavailable" };
|
|
116
141
|
}
|
|
117
|
-
|
|
118
|
-
throw new RemoteError("dsmm-children/refused", "The Host refused the child control operation.", parseRoleControlErrorInfo(info));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
decode(parse, value) {
|
|
122
|
-
try {
|
|
123
|
-
return parse(value);
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
throw new ControlRefusal("validation", "request");
|
|
142
|
+
throw new RemoteError("dsmm-children/refused", "The Host refused the native child control operation.", info);
|
|
127
143
|
}
|
|
128
144
|
}
|
|
129
|
-
async scoped(sessionId, readOnly, operation) {
|
|
130
|
-
const invocation = this.ctx.invocation;
|
|
131
|
-
const connection = this.ctx.get("connection");
|
|
132
|
-
if (invocation?.peer === undefined || connection === undefined || connection.browserPeer !== invocation.peer)
|
|
133
|
-
throw new ControlRefusal("not-owned");
|
|
134
|
-
const connectionOwner = original(connection);
|
|
135
|
-
const runtime = this.collaborators.runtime;
|
|
136
|
-
if (!runtime.authority.view().deliveryFenceReady)
|
|
137
|
-
throw new ControlRefusal("unavailable", undefined, "delivery-fence-unavailable");
|
|
138
|
-
const browserSignal = runtime.authority.acquireBrowserSignal(this.ctx);
|
|
139
|
-
const initialSignal = AbortSignal.any([invocation.signal, invocation.peer.signal, browserSignal, this.lifetime.signal]);
|
|
140
|
-
const checkConnection = () => {
|
|
141
|
-
if (initialSignal.aborted)
|
|
142
|
-
throw new ControlRefusal("cancelled");
|
|
143
|
-
const current = this.ctx.get("connection");
|
|
144
|
-
if (current === undefined || original(current) !== connectionOwner || current.browserPeer !== invocation.peer)
|
|
145
|
-
throw new ControlRefusal("not-owned");
|
|
146
|
-
const bound = this.ctx.get("subagents");
|
|
147
|
-
if (bound === undefined || original(bound) !== original(runtime))
|
|
148
|
-
throw new ControlRefusal("unavailable", undefined, "delivery-fence-unavailable");
|
|
149
|
-
};
|
|
150
|
-
checkConnection();
|
|
151
|
-
const agents = this.ctx.get("agents");
|
|
152
|
-
if (agents === undefined)
|
|
153
|
-
throw new ControlRefusal("unavailable");
|
|
154
|
-
let parent = agents.get(SessionId(sessionId));
|
|
155
|
-
if (parent === undefined) {
|
|
156
|
-
// Actions never wake an ordinary parent. Only an authenticated, decoded
|
|
157
|
-
// read may use the public controller; Gateway parameter lookup cannot.
|
|
158
|
-
if (!readOnly)
|
|
159
|
-
throw new ControlRefusal("unavailable", "sessionId");
|
|
160
|
-
const controller = this.ctx.get("sessionController");
|
|
161
|
-
if (controller === undefined)
|
|
162
|
-
throw new ControlRefusal("unavailable", "sessionId");
|
|
163
|
-
const found = await controller.resolveAgent(SessionId(sessionId));
|
|
164
|
-
checkConnection();
|
|
165
|
-
if ("error" in found)
|
|
166
|
-
throw new ControlRefusal("unavailable", "sessionId");
|
|
167
|
-
parent = found.agent;
|
|
168
|
-
}
|
|
169
|
-
const exactParent = parent;
|
|
170
|
-
const checkRoot = () => {
|
|
171
|
-
checkConnection();
|
|
172
|
-
const current = this.ctx.get("agents");
|
|
173
|
-
if (current === undefined || current.get(SessionId(sessionId)) !== exactParent || exactParent.id !== sessionId || exactParent.session.id !== sessionId
|
|
174
|
-
|| exactParent.session.header.origin === "subagent" || !current.roots().includes(exactParent)
|
|
175
|
-
|| current.list().some(owner => owner !== exactParent && current.isOwnedBy(SessionId(sessionId), owner)))
|
|
176
|
-
throw new ControlRefusal("not-owned", "sessionId");
|
|
177
|
-
};
|
|
178
|
-
checkRoot();
|
|
179
|
-
const ticket = runtime.authority.acquireParentTicket(exactParent);
|
|
180
|
-
const signal = AbortSignal.any([initialSignal, ticket.signal]);
|
|
181
|
-
const scope = { parent: exactParent, ticket, signal, check() {
|
|
182
|
-
if (signal.aborted)
|
|
183
|
-
throw new ControlRefusal("cancelled");
|
|
184
|
-
checkRoot();
|
|
185
|
-
runtime.authority.assertTicket(ticket);
|
|
186
|
-
} };
|
|
187
|
-
scope.check();
|
|
188
|
-
let result;
|
|
189
|
-
try {
|
|
190
|
-
result = await operation(scope);
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
if (signal.aborted)
|
|
194
|
-
throw new ControlRefusal("cancelled");
|
|
195
|
-
throw error;
|
|
196
|
-
}
|
|
197
|
-
// Native acceptance/handoff owns the write cutoff. Never turn a committed
|
|
198
|
-
// receipt into a failure, rollback accepted work or automatically retry.
|
|
199
|
-
if (readOnly)
|
|
200
|
-
scope.check();
|
|
201
|
-
return result;
|
|
202
|
-
}
|
|
203
145
|
capabilities(scope) {
|
|
204
146
|
scope.check();
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
return {
|
|
147
|
+
const runtime = runtimeAdmissionView(this.ctx), settings = this.admission.assert(scope.parent).settings;
|
|
148
|
+
const control = !runtime.deliveryFenceReady || this.ctx.get("subagents") === undefined ? unavailable
|
|
149
|
+
: !settings.modules.deepwork.enabled ? disabled("module-off") : { enabled: true };
|
|
150
|
+
return { prompt: control, interrupt: control, images: control.enabled && this.ctx.get("attachments") !== undefined ? control : unavailable, runtime };
|
|
209
151
|
}
|
|
210
|
-
|
|
211
|
-
scope.check();
|
|
212
|
-
const direct = parentSessionId === scope.parent.id;
|
|
213
|
-
const inactive = this.ctx.get("agents")?.get(entry.id)?.status !== "running";
|
|
214
|
-
const observation = direct ? await this.collaborators.observeChild(scope.ticket, entry, scope.signal) : undefined;
|
|
215
|
-
scope.check();
|
|
216
|
-
const projected = observation?.invocation === undefined ? undefined : parseDsmmInvocationView(observation.invocation);
|
|
217
|
-
const mode = entry.mode === "external" ? "unknown" : entry.mode === "continuable" && projected?.mode === "one-shot" ? "one-shot" : entry.mode;
|
|
218
|
-
const reason = !direct ? "not-direct-child" : mode === "one-shot" ? "one-shot" : "unknown-mode";
|
|
219
|
-
const global = this.capabilities(scope);
|
|
220
|
-
const controls = mode === "continuable" && entry.mode === "continuable" && observation !== undefined
|
|
221
|
-
? { prompt: global.prompt.enabled ? observation.prompt : global.prompt, interrupt: global.interrupt.enabled ? observation.interrupt : global.interrupt }
|
|
222
|
-
: { prompt: disabled(reason), interrupt: disabled(reason) };
|
|
223
|
-
const routeComparison = observation?.routeComparison === undefined ? undefined : parseDsmmRoleRouteComparison(observation.routeComparison);
|
|
224
|
-
if (projected?.childId !== undefined && projected.childId !== entry.id)
|
|
225
|
-
throw new ControlRefusal("unavailable", "childSessionId");
|
|
226
|
-
if (routeComparison !== undefined && routeComparison.childId !== entry.id)
|
|
227
|
-
throw new ControlRefusal("unavailable", "childSessionId");
|
|
228
|
-
return { id: entry.id, parentSessionId, mode, activity: inactive ? "inactive" : "running", readonly: !controls.prompt.enabled && !controls.interrupt.enabled,
|
|
229
|
-
...(entry.label === undefined ? {} : { label: boundedChildLabel(entry.label) }), controls,
|
|
230
|
-
...(projected === undefined ? {} : { invocation: { ...projected, childId: entry.id } }),
|
|
231
|
-
...(routeComparison === undefined ? {} : { routeComparison }),
|
|
232
|
-
...(observation?.evidence === undefined ? {} : { evidence: observation.evidence }) };
|
|
233
|
-
}
|
|
234
|
-
async runView(scope, holder) {
|
|
235
|
-
scope.check();
|
|
236
|
-
const identity = holder.invocation;
|
|
237
|
-
const background = identity === undefined ? disabled(holder.state === "cancelled" ? "cancelled" : "starting")
|
|
238
|
-
: await this.collaborators.backgroundAvailability(scope.ticket, identity, scope.signal);
|
|
152
|
+
child(scope, entry, parentId = scope.parent.id) {
|
|
239
153
|
scope.check();
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return { sessionId: holder.sessionId, toolCallId: holder.toolCallId, state: holder.state, ...(invocation === undefined ? {} : { invocation }),
|
|
250
|
-
background: holder.state === "starting" ? disabled("starting") : holder.state === "settled" ? disabled("already-settled") : holder.state === "cancelled" ? disabled("cancelled")
|
|
251
|
-
: holder.state === "background" ? disabled("already-background") : globalBackground.enabled ? background : globalBackground };
|
|
154
|
+
const child = this.ctx.get("agents")?.get(entry.id), direct = parentId === scope.parent.id;
|
|
155
|
+
const live = child && this.admission.get(child), invocation = child && this.admission.invocation(child);
|
|
156
|
+
const available = this.capabilities(scope);
|
|
157
|
+
const reason = !direct ? "not-direct-child" : entry.mode !== "continuable" ? entry.mode === "one-shot" ? "one-shot" : "unknown-mode" : !live || !child ? "evidence-unavailable" : undefined;
|
|
158
|
+
const control = reason !== undefined ? disabled(reason) : !this.ctx.get("agents")?.isOwnedBy(child.id, scope.parent) ? disabled("not-direct-child") : available.prompt;
|
|
159
|
+
return { id: entry.id, parentSessionId: parentId, mode: entry.mode === "external" ? "unknown" : entry.mode, activity: child?.status === "running" ? "running" : "inactive",
|
|
160
|
+
readonly: !control.enabled, controls: { prompt: control, interrupt: control }, ...(entry.label === undefined ? {} : { label: boundedLabel(entry.label) }),
|
|
161
|
+
...(invocation === undefined ? {} : { invocation: invocationView(invocation, boundedLabel(entry.label ?? invocation.target), "continuable", { childId: entry.id }) }),
|
|
162
|
+
...(child === undefined ? {} : { routeComparison: roleRouteComparison(child) }) };
|
|
252
163
|
}
|
|
253
164
|
describe(sessionId) {
|
|
254
|
-
return this.
|
|
255
|
-
const
|
|
256
|
-
scope.check();
|
|
257
|
-
const children = [], runs = [];
|
|
258
|
-
for (const child of catalog)
|
|
259
|
-
children.push(await this.childView(scope, child));
|
|
165
|
+
return this.scoped(sessionId, async (scope) => {
|
|
166
|
+
const rows = await this.ctx.get("subagents").listChildren(scope.parent.id, scope.signal);
|
|
260
167
|
scope.check();
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
scope.check();
|
|
264
|
-
return parseChildSessionSnapshot({ sessionId: scope.parent.id, admissionEpoch: scope.ticket.parentEpoch, children, runs, capabilities: this.capabilities(scope) });
|
|
265
|
-
}));
|
|
168
|
+
return parseChildSessionSnapshot({ sessionId, admissionEpoch: scope.epoch, children: rows.map(row => this.child(scope, row)), capabilities: this.capabilities(scope) });
|
|
169
|
+
});
|
|
266
170
|
}
|
|
267
171
|
descendants(sessionId) {
|
|
268
|
-
return this.
|
|
269
|
-
const
|
|
172
|
+
return this.scoped(sessionId, async (scope) => {
|
|
173
|
+
const rows = await this.ctx.get("subagents").listDescendants(scope.parent.id, scope.signal);
|
|
270
174
|
scope.check();
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (entry.kind === "diagnostic")
|
|
275
|
-
descendants.push({ kind: "diagnostic", id: entry.id, parentSessionId: entry.parentId, depth: entry.depth, reason: entry.reason });
|
|
276
|
-
else {
|
|
277
|
-
const child = await this.childView(scope, { id: entry.id, mode: entry.mode, createdAt: 0, ...("label" in entry ? { label: entry.label } : {}) }, entry.parentId);
|
|
278
|
-
descendants.push({ kind: "child", depth: entry.depth, hasChildren: entry.hasChildren, child: { ...child, activity: entry.activity } });
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
return parseRoleControlDescendants({ sessionId: scope.parent.id, admissionEpoch: scope.ticket.parentEpoch, descendants });
|
|
282
|
-
}));
|
|
283
|
-
}
|
|
284
|
-
background(sessionId, input) {
|
|
285
|
-
return this.invoke(async () => {
|
|
286
|
-
const request = this.decode(parseRoleControlBackgroundRequest, input);
|
|
287
|
-
if (request.sessionId !== this.decode(parseRoleControlSessionId, sessionId))
|
|
288
|
-
throw new ControlRefusal("validation", "sessionId");
|
|
289
|
-
return this.scoped(sessionId, false, async (scope) => {
|
|
290
|
-
if (request.expectedAdmissionEpoch !== scope.ticket.parentEpoch)
|
|
291
|
-
throw new ControlRefusal("conflict", "expectedAdmissionEpoch");
|
|
292
|
-
const holder = this.collaborators.runs.get(scope.parent, scope.ticket.owner, { sessionId: scope.parent.id,
|
|
293
|
-
toolCallId: request.toolCallId, runId: request.runId });
|
|
294
|
-
if (holder?.invocation === undefined)
|
|
295
|
-
throw new ControlRefusal("not-found", "runId");
|
|
296
|
-
const terminal = terminalTransition(holder.state, holder.invocation.runId);
|
|
297
|
-
if (terminal !== undefined) {
|
|
298
|
-
scope.check();
|
|
299
|
-
return terminal;
|
|
300
|
-
}
|
|
301
|
-
requireEnabled(this.capabilities(scope).background);
|
|
302
|
-
const permitted = await this.collaborators.backgroundAvailability(scope.ticket, holder.invocation, scope.signal);
|
|
303
|
-
scope.check();
|
|
304
|
-
// Result/cancellation may win while asynchronous capability preparation
|
|
305
|
-
// is pending. Observing that terminal state never creates a new job.
|
|
306
|
-
const observed = terminalTransition(holder.state, holder.invocation.runId);
|
|
307
|
-
if (observed !== undefined)
|
|
308
|
-
return observed;
|
|
309
|
-
requireEnabled(permitted);
|
|
310
|
-
// All async preparation is fenced before the holder's native synchronous
|
|
311
|
-
// jobs.start critical section, which rechecks its own exact authority.
|
|
312
|
-
const result = holder.background({ parent: scope.parent, owner: scope.ticket.owner, sessionId: scope.parent.id,
|
|
313
|
-
toolCallId: holder.toolCallId, runId: holder.invocation.runId, expectedAdmissionEpoch: request.expectedAdmissionEpoch });
|
|
314
|
-
if ("receipt" in result) {
|
|
315
|
-
this.backgroundJobs.set(holder, result.receipt.jobId);
|
|
316
|
-
return { status: result.status, runId: result.receipt.invocation.runId, jobId: result.receipt.jobId };
|
|
317
|
-
}
|
|
318
|
-
if (result.status === "starting")
|
|
319
|
-
throw new ControlRefusal("disabled", undefined, "starting");
|
|
320
|
-
return { status: result.status, runId: request.runId };
|
|
321
|
-
});
|
|
175
|
+
return parseRoleControlDescendants({ sessionId, admissionEpoch: scope.epoch, descendants: rows.map(row => row.kind === "diagnostic"
|
|
176
|
+
? { kind: "diagnostic", id: row.id, parentSessionId: row.parentId, depth: row.depth, reason: row.reason }
|
|
177
|
+
: { kind: "child", depth: row.depth, hasChildren: row.hasChildren, child: { ...this.child(scope, row, row.parentId), readonly: true, controls: { prompt: disabled("not-direct-child"), interrupt: disabled("not-direct-child") } } }) });
|
|
322
178
|
});
|
|
323
179
|
}
|
|
324
|
-
|
|
325
|
-
scope.check();
|
|
326
|
-
const catalog = await this.collaborators.runtime.listChildren(scope.parent.id, scope.signal);
|
|
180
|
+
direct(scope, childId) {
|
|
327
181
|
scope.check();
|
|
328
|
-
const child =
|
|
329
|
-
if (child
|
|
182
|
+
const child = this.ctx.get("agents")?.get(SessionId(childId));
|
|
183
|
+
if (!child)
|
|
184
|
+
throw new ControlRefusal("not-resumable", "childSessionId", "evidence-unavailable");
|
|
185
|
+
if (!this.ctx.get("agents")?.isOwnedBy(child.id, scope.parent))
|
|
330
186
|
throw new ControlRefusal("not-owned", "childSessionId");
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
const view = await this.childView(scope, child);
|
|
334
|
-
if (view.mode !== "continuable")
|
|
335
|
-
throw new ControlRefusal("not-resumable", "childSessionId");
|
|
336
|
-
return view;
|
|
187
|
+
this.admission.assert(child);
|
|
188
|
+
return child;
|
|
337
189
|
}
|
|
338
190
|
prompt(sessionId, input) {
|
|
339
|
-
return this.
|
|
340
|
-
const request =
|
|
341
|
-
if (request.parentSessionId !==
|
|
191
|
+
return this.scoped(sessionId, async (scope) => {
|
|
192
|
+
const request = parseRoleControlPromptRequest(input);
|
|
193
|
+
if (request.parentSessionId !== sessionId)
|
|
342
194
|
throw new ControlRefusal("validation", "parentSessionId");
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
scope.check();
|
|
351
|
-
// Original browser request identity, content, images, zone and delivery
|
|
352
|
-
// enter the unique C1 public override, then native pre-inbox cutoff.
|
|
353
|
-
return this.ctx.subagents.prompt(request, scope.signal);
|
|
354
|
-
});
|
|
195
|
+
const capabilities = this.capabilities(scope);
|
|
196
|
+
if (!capabilities.prompt.enabled)
|
|
197
|
+
throw new ControlRefusal("disabled", undefined, capabilities.prompt.reason);
|
|
198
|
+
if (request.content.some(part => part.type === "image") && !capabilities.images.enabled)
|
|
199
|
+
throw new ControlRefusal("disabled", "content", capabilities.images.reason);
|
|
200
|
+
this.direct(scope, request.childSessionId);
|
|
201
|
+
return this.ctx.get("subagents").prompt(request, scope.signal);
|
|
355
202
|
});
|
|
356
203
|
}
|
|
357
204
|
interrupt(sessionId, input) {
|
|
358
|
-
return this.
|
|
359
|
-
const request =
|
|
360
|
-
if (request.parentSessionId !==
|
|
205
|
+
return this.scoped(sessionId, async (scope) => {
|
|
206
|
+
const request = parseRoleControlInterruptRequest(input);
|
|
207
|
+
if (request.parentSessionId !== sessionId)
|
|
361
208
|
throw new ControlRefusal("validation", "parentSessionId");
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
scope.check();
|
|
368
|
-
return this.ctx.subagents.interruptByParent(SessionId(request.childSessionId), scope.parent.id, "continuable");
|
|
369
|
-
});
|
|
209
|
+
const capabilities = this.capabilities(scope);
|
|
210
|
+
if (!capabilities.interrupt.enabled)
|
|
211
|
+
throw new ControlRefusal("disabled", undefined, capabilities.interrupt.reason);
|
|
212
|
+
this.direct(scope, request.childSessionId);
|
|
213
|
+
return this.ctx.get("subagents").interruptByParent(SessionId(request.childSessionId), scope.parent.id, "continuable");
|
|
370
214
|
});
|
|
371
215
|
}
|
|
372
216
|
};
|
|
373
217
|
})();
|
|
374
218
|
export { DsmmChildrenHost };
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const host = new DsmmChildrenHost(ctx, collaborators);
|
|
219
|
+
export function registerRoleControlRpc(ctx, admission) {
|
|
220
|
+
const host = new DsmmChildrenHost(ctx, admission);
|
|
378
221
|
ctx.typert.register(ROLE_CONTROL_HOST);
|
|
379
222
|
return host;
|
|
380
223
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/** Browser-safe child control vocabulary; no Host or filesystem authority. */
|
|
2
2
|
import type { DsmmInvocationView, DsmmRoleRouteComparison, SubagentRuntimeAdmissionView } from "./profile-types.js";
|
|
3
|
-
import type { ChildAdmissionEvidenceView } from "./child-evidence.js";
|
|
4
3
|
import type { SubagentPromptReceipt, SubagentPromptRequest, SubagentInterruptReceipt } from "@deepseek-ai/dsh-subagent";
|
|
5
|
-
export type { DsmmInvocationView, DsmmRoleRouteComparison,
|
|
6
|
-
export declare const ROLE_CONTROL_DISABLED_REASONS: readonly ["module-off", "role-disabled", "read-only", "
|
|
4
|
+
export type { DsmmInvocationView, DsmmRoleRouteComparison, SubagentPromptRequest, SubagentPromptReceipt, SubagentInterruptReceipt };
|
|
5
|
+
export declare const ROLE_CONTROL_DISABLED_REASONS: readonly ["module-off", "role-disabled", "read-only", "one-shot", "unknown-mode", "not-direct-child", "evidence-unavailable", "unavailable"];
|
|
7
6
|
export type RoleControlDisabledReason = typeof ROLE_CONTROL_DISABLED_REASONS[number];
|
|
8
7
|
export type RoleControlAvailability = {
|
|
9
8
|
enabled: true;
|
|
@@ -12,21 +11,12 @@ export type RoleControlAvailability = {
|
|
|
12
11
|
reason: RoleControlDisabledReason;
|
|
13
12
|
};
|
|
14
13
|
export interface RoleControlCapabilities {
|
|
15
|
-
background: RoleControlAvailability;
|
|
16
14
|
prompt: RoleControlAvailability;
|
|
17
15
|
interrupt: RoleControlAvailability;
|
|
18
16
|
/** The native attachment/model admission still validates each image. */
|
|
19
17
|
images: RoleControlAvailability;
|
|
20
18
|
runtime: SubagentRuntimeAdmissionView;
|
|
21
19
|
}
|
|
22
|
-
export interface RoleControlRunView {
|
|
23
|
-
sessionId: string;
|
|
24
|
-
toolCallId: string;
|
|
25
|
-
state: "starting" | "running" | "background" | "settled" | "cancelled";
|
|
26
|
-
/** Absent before the real native run is published. */
|
|
27
|
-
invocation?: DsmmInvocationView;
|
|
28
|
-
background: RoleControlAvailability;
|
|
29
|
-
}
|
|
30
20
|
export interface RoleControlChildView {
|
|
31
21
|
id: string;
|
|
32
22
|
parentSessionId: string;
|
|
@@ -36,7 +26,6 @@ export interface RoleControlChildView {
|
|
|
36
26
|
readonly: boolean;
|
|
37
27
|
invocation?: DsmmInvocationView;
|
|
38
28
|
routeComparison?: DsmmRoleRouteComparison;
|
|
39
|
-
evidence?: ChildAdmissionEvidenceView;
|
|
40
29
|
controls: {
|
|
41
30
|
prompt: RoleControlAvailability;
|
|
42
31
|
interrupt: RoleControlAvailability;
|
|
@@ -45,7 +34,6 @@ export interface RoleControlChildView {
|
|
|
45
34
|
export interface ChildSessionSnapshot {
|
|
46
35
|
sessionId: string;
|
|
47
36
|
admissionEpoch: string;
|
|
48
|
-
runs: RoleControlRunView[];
|
|
49
37
|
children: RoleControlChildView[];
|
|
50
38
|
capabilities: RoleControlCapabilities;
|
|
51
39
|
}
|
|
@@ -66,24 +54,13 @@ export interface RoleControlDescendantsSnapshot {
|
|
|
66
54
|
admissionEpoch: string;
|
|
67
55
|
descendants: RoleControlDescendantView[];
|
|
68
56
|
}
|
|
69
|
-
export interface RoleControlBackgroundRequest {
|
|
70
|
-
sessionId: string;
|
|
71
|
-
toolCallId: string;
|
|
72
|
-
runId: string;
|
|
73
|
-
expectedAdmissionEpoch: string;
|
|
74
|
-
}
|
|
75
|
-
export interface BackgroundTransitionResult {
|
|
76
|
-
status: "background" | "already-background" | "already-settled" | "cancelled";
|
|
77
|
-
runId: string;
|
|
78
|
-
jobId?: string;
|
|
79
|
-
}
|
|
80
57
|
export interface RoleControlInterruptRequest {
|
|
81
58
|
parentSessionId: string;
|
|
82
59
|
childSessionId: string;
|
|
83
60
|
mode: "continuable";
|
|
84
61
|
}
|
|
85
62
|
export declare const ROLE_CONTROL_ERROR_CODES: readonly ["validation", "not-owned", "unavailable", "cancelled", "conflict", "not-found", "not-resumable", "invalid-content", "invalid-time-zone", "disabled"];
|
|
86
|
-
export declare const ROLE_CONTROL_ERROR_FIELDS: readonly ["sessionId", "parentSessionId", "childSessionId", "
|
|
63
|
+
export declare const ROLE_CONTROL_ERROR_FIELDS: readonly ["sessionId", "parentSessionId", "childSessionId", "request", "content", "clientTimeZone"];
|
|
87
64
|
export interface RoleControlErrorInfo {
|
|
88
65
|
code: typeof ROLE_CONTROL_ERROR_CODES[number];
|
|
89
66
|
field?: typeof ROLE_CONTROL_ERROR_FIELDS[number];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export const ROLE_CONTROL_DISABLED_REASONS = [
|
|
2
|
-
"module-off", "role-disabled", "read-only", "
|
|
3
|
-
"
|
|
4
|
-
"delivery-fence-unavailable", "evidence-unavailable", "legacy-capability-denied", "unavailable",
|
|
2
|
+
"module-off", "role-disabled", "read-only", "one-shot", "unknown-mode", "not-direct-child",
|
|
3
|
+
"evidence-unavailable", "unavailable",
|
|
5
4
|
];
|
|
6
5
|
export const ROLE_CONTROL_ERROR_CODES = ["validation", "not-owned", "unavailable", "cancelled", "conflict", "not-found", "not-resumable", "invalid-content", "invalid-time-zone", "disabled"];
|
|
7
|
-
export const ROLE_CONTROL_ERROR_FIELDS = ["sessionId", "parentSessionId", "childSessionId", "
|
|
6
|
+
export const ROLE_CONTROL_ERROR_FIELDS = ["sessionId", "parentSessionId", "childSessionId", "request", "content", "clientTimeZone"];
|
|
8
7
|
//# sourceMappingURL=role-control-types.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DshAgent } from "./dsh-types.js";
|
|
2
|
+
import type { DsmmRoleId } from "./roles.js";
|
|
3
|
+
/** The caller supplies the policy-admitted identity; only its Agent layer is changed. */
|
|
4
|
+
export declare function registerRoleHarnessIdentity(agent: DshAgent, role: DsmmRoleId): () => void;
|
|
5
|
+
//# sourceMappingURL=role-identity.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { nativeAgentContext } from "./native-scope.js";
|
|
2
|
+
import { buildRoleIdentity } from "./prompt-content.js";
|
|
3
|
+
import { DSMM_ROLES } from "./roles.js";
|
|
4
|
+
/** The caller supplies the policy-admitted identity; only its Agent layer is changed. */
|
|
5
|
+
export function registerRoleHarnessIdentity(agent, role) {
|
|
6
|
+
const prompt = nativeAgentContext(agent).get("systemPrompt");
|
|
7
|
+
return prompt.section({ name: "harness:identity", order: prompt.getSectionOrder("HARNESS_IDENTITY"),
|
|
8
|
+
text: buildRoleIdentity(DSMM_ROLES.find(row => row.id === role)) });
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=role-identity.js.map
|
package/lib/role-invocation.d.ts
CHANGED
|
@@ -22,16 +22,16 @@ export interface ResolvedRoleInvocation {
|
|
|
22
22
|
}
|
|
23
23
|
export declare function duringRoleInvocation<T>(parent: DshAgent, invocation: ResolvedRoleInvocation, operation: () => T): T;
|
|
24
24
|
export declare function currentRoleInvocation(parent: DshAgent, target: DsmmRoleId): ResolvedRoleInvocation | undefined;
|
|
25
|
-
export declare function bindRoleInvocation(agent: DshAgent, invocation: ResolvedRoleInvocation, original
|
|
25
|
+
export declare function bindRoleInvocation(agent: DshAgent, invocation: ResolvedRoleInvocation, original?: ChildAdmissionCapture): void;
|
|
26
26
|
export declare function capturedRoleInvocation(agent: DshAgent): ResolvedRoleInvocation | undefined;
|
|
27
27
|
export declare function capturedOriginalRoleInvocation(agent: DshAgent): ChildAdmissionCapture["invocation"] | undefined;
|
|
28
28
|
/** Complete selections replace model and effort together; effort-only selections narrow candidates. */
|
|
29
|
-
export declare function resolveRoleInvocation(parent: Agent, target: DsmmRoleId, settings: DsmmSettings, signal: AbortSignal, options?: DsmmInvocationOptions, nativeOptions?: AgentOptions): Promise<ResolvedRoleInvocation>;
|
|
29
|
+
export declare function resolveRoleInvocation(parent: Agent, target: DsmmRoleId, settings: DsmmSettings, signal: AbortSignal, options?: DsmmInvocationOptions, nativeOptions?: AgentOptions, parameterPolicy?: ResolvedModelParameterPolicy): Promise<ResolvedRoleInvocation>;
|
|
30
30
|
export declare function invocationAgentOptions(invocation: ResolvedRoleInvocation, options?: AgentOptions): AgentOptions;
|
|
31
31
|
export declare function invocationView(invocation: ResolvedRoleInvocation, label: string, mode: DsmmInvocationView["mode"], ids?: Pick<DsmmInvocationView, "runId" | "childId" | "jobId">): {
|
|
32
|
+
runId?: string | undefined;
|
|
32
33
|
childId?: string | undefined;
|
|
33
34
|
jobId?: string | undefined;
|
|
34
|
-
runId?: string | undefined;
|
|
35
35
|
role: "dsmm-orchestrator" | "dsmm-planner" | "dsmm-plan-critic" | "dsmm-builder" | "dsmm-reviewer" | "dsmm-oracle" | "dsmm-oracle-2nd" | "dsmm-creative" | "dsmm-code-search" | "dsmm-doc-search" | "dsmm-clarifier" | "dsmm-media-reader" | "dsmm-frontend" | "dsmm-hard-reasoning" | "dsmm-research" | "dsmm-quick" | "dsmm-coding" | "dsmm-normal-task" | "dsmm-complex" | "dsmm-deep" | "dsmm-documenting" | "dsmm-cross-cutting";
|
|
36
36
|
label: string;
|
|
37
37
|
level: DsmmInvocationLevel;
|
package/lib/role-invocation.js
CHANGED
|
@@ -27,7 +27,7 @@ export function bindRoleInvocation(agent, invocation, original) {
|
|
|
27
27
|
export function capturedRoleInvocation(agent) { return captured.get(agent); }
|
|
28
28
|
export function capturedOriginalRoleInvocation(agent) { return originalCaptures.get(agent)?.invocation; }
|
|
29
29
|
/** Complete selections replace model and effort together; effort-only selections narrow candidates. */
|
|
30
|
-
export async function resolveRoleInvocation(parent, target, settings, signal, options = {}, nativeOptions) {
|
|
30
|
+
export async function resolveRoleInvocation(parent, target, settings, signal, options = {}, nativeOptions, parameterPolicy) {
|
|
31
31
|
if (!isDsmmRoleId(target) || target === "dsmm-orchestrator")
|
|
32
32
|
throw new SubagentError("Unknown DSMM delegation target", "UNAUTHORIZED");
|
|
33
33
|
if (Object.keys(options).some(key => key !== "level" && key !== "route"))
|
|
@@ -93,7 +93,7 @@ export async function resolveRoleInvocation(parent, target, settings, signal, op
|
|
|
93
93
|
if (llm === undefined)
|
|
94
94
|
throw new Error("DSMM invocation requires the parent's native LLM service");
|
|
95
95
|
const admission = parent.ctx.get("dsmmProfileRuntime")?.admission(parent);
|
|
96
|
-
const modelParameterPolicy = capturedRoleInvocation(parent)?.modelParameterPolicy
|
|
96
|
+
const modelParameterPolicy = parameterPolicy ?? capturedRoleInvocation(parent)?.modelParameterPolicy
|
|
97
97
|
?? (admission === undefined ? configuredModelParameterPolicy(settings) : resolvedModelParameterPolicy(admission));
|
|
98
98
|
const project = (candidate, source) => modelRouteFromCall(projectModelRouteParameters(candidate, source, modelParameterPolicy.mode !== "native-defaults"));
|
|
99
99
|
const projected = initialCandidates.map((candidate, index) => project(candidate, index === 0 || candidateEffort !== undefined ? effortSource : "dsmm-config"));
|