@dsmm/dsmm 0.3.10 → 0.3.12
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 +1 -1
- package/agent-presets/dsmm-builder/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-code-search/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-coding/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-complex/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-creative/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-deep/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-documenting/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-frontend/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-oracle/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-planner/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-quick/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-research/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +0 -4
- package/docs/agent-presets.md +5 -5
- package/docs/compatibility.md +10 -4
- package/docs/deferred-native-approval-risk.md +11 -1
- package/docs/design.md +15 -5
- package/docs/lsp.md +1 -1
- package/docs/model-routing.md +6 -6
- package/docs/native-permissions.md +5 -1
- package/docs/profiles.md +36 -5
- package/docs/roadmap.md +3 -3
- package/docs/runtime-recovery.md +5 -5
- package/docs/safety-guards.md +23 -5
- package/docs/settings-status.md +3 -3
- package/lib/child-capture.d.ts +9 -0
- package/lib/child-capture.js +29 -2
- package/lib/client/ProfilesSection.js +65 -13
- package/lib/client/RoleToolView-data.d.ts +4 -4
- package/lib/client/RoleToolView-data.js +3 -1
- package/lib/client/RoleToolView-locales.d.ts +7 -4
- package/lib/client/RoleToolView-locales.js +10 -6
- package/lib/client/RoleToolView.js +20 -5
- package/lib/client/SessionProfiles.d.ts +5 -1
- package/lib/client/SessionProfiles.js +13 -9
- package/lib/client/StructuredEditor.d.ts +32 -0
- package/lib/client/StructuredEditor.js +75 -23
- package/lib/client/controller.d.ts +10 -0
- package/lib/client/controller.js +44 -14
- package/lib/client/deployment-locales.js +1 -0
- package/lib/client/locales.d.ts +36 -0
- package/lib/client/locales.js +47 -17
- package/lib/client/permission-locales.js +8 -8
- package/lib/client/session-labels.js +4 -1
- package/lib/client/structured.d.ts +4 -0
- package/lib/client/structured.js +16 -1
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +19 -1
- package/lib/client.js +772 -312
- package/lib/command-approval.d.ts +50 -0
- package/lib/command-approval.js +148 -0
- package/lib/core-permissions.d.ts +2 -1
- package/lib/core-permissions.js +6 -3
- package/lib/guards.d.ts +2 -1
- package/lib/guards.js +45 -8
- package/lib/host-llm.js +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +5 -3
- package/lib/model-routing.d.ts +3 -2
- package/lib/model-routing.js +28 -7
- package/lib/native-admission.d.ts +2 -0
- package/lib/native-admission.js +106 -34
- package/lib/permission-control.d.ts +5 -2
- package/lib/permission-control.js +46 -24
- package/lib/permission-controller.d.ts +2 -0
- package/lib/permission-controller.js +13 -8
- package/lib/permission-native-command.d.ts +2 -0
- package/lib/permission-native-command.js +9 -4
- package/lib/permission-native-rules.d.ts +2 -2
- package/lib/permission-native-rules.js +12 -10
- package/lib/profile-diagnostics.js +1 -1
- package/lib/profile-runtime.d.ts +11 -0
- package/lib/profile-runtime.js +48 -13
- package/lib/profile-store.d.ts +4 -1
- package/lib/profile-store.js +37 -14
- package/lib/profiles.js +2 -1
- package/lib/prompt-content.js +2 -2
- package/lib/role-control-rpc.js +18 -5
- package/lib/role-llm-runtime.js +10 -1
- package/lib/role-policy.d.ts +4 -3
- package/lib/role-policy.js +6 -6
- package/lib/role-providers.js +1 -0
- package/lib/runtime-recovery.d.ts +2 -2
- package/lib/runtime-recovery.js +7 -4
- package/lib/settings.d.ts +2 -0
- package/lib/settings.js +10 -0
- package/lib/shell-command.d.ts +16 -0
- package/lib/shell-command.js +443 -119
- package/package.json +1 -1
|
@@ -53,14 +53,14 @@ export function parseNativePermissionReadPaths(kind, input) {
|
|
|
53
53
|
export function registerNativePermissionRules(ctx, options) {
|
|
54
54
|
if (!options.runtime.status().mounted)
|
|
55
55
|
return () => { };
|
|
56
|
-
const bindings = new
|
|
56
|
+
const bindings = new WeakMap();
|
|
57
57
|
const asks = new WeakMap();
|
|
58
58
|
const lifetime = new AbortController();
|
|
59
59
|
const tools = ctx.tools;
|
|
60
60
|
const checkIntegrity = (exec, binding) => {
|
|
61
61
|
if (exec.signal.aborted || binding.signal.aborted)
|
|
62
62
|
throw new PermissionRefusal("cancelled");
|
|
63
|
-
if (exec.arguments !== binding.args || exec.agent !== binding.agent || exec.callId !== binding.callId || exec.name !== binding.name
|
|
63
|
+
if (exec !== binding.exec || exec.token !== binding.token || exec.arguments !== binding.args || exec.agent !== binding.agent || exec.callId !== binding.callId || exec.name !== binding.name
|
|
64
64
|
|| tools.get(binding.name, binding.agent) !== binding.definition || binding.definition.execute !== binding.body)
|
|
65
65
|
throw new PermissionRefusal("stale");
|
|
66
66
|
if (exec.agent !== undefined && ctx.agents.get(exec.agent.id) !== exec.agent)
|
|
@@ -178,8 +178,10 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
178
178
|
return policy.rules.some(rule => !rule.revoked && rule.match.kind === "shell" && rule.action === "deny") ? "deny" : "inherit";
|
|
179
179
|
const operation = classifyPermissionShell(shell, exec.arguments, cwd, exec);
|
|
180
180
|
shell.readCapability?.assertCurrent(exec);
|
|
181
|
-
const
|
|
182
|
-
&& rule.match.command === operation.command && rule.match.workingDirectory === operation.workingDirectory)
|
|
181
|
+
const matched = policy.rules.filter(rule => !rule.revoked && rule.match.kind === "shell" && rule.match.executable === operation.executable
|
|
182
|
+
&& rule.match.command === operation.command && rule.match.workingDirectory === operation.workingDirectory);
|
|
183
|
+
binding.asks.push(...matched.filter(rule => rule.action === "ask"));
|
|
184
|
+
const rules = matched.map(rule => rule.action);
|
|
183
185
|
if (operation.effect !== "read") {
|
|
184
186
|
// Unknown reads cannot bypass a configured hard outside-read boundary.
|
|
185
187
|
const hardRead = operation.effect === "unknown" && (policy.outsideReads === "deny" || policy.rules.some(rule => !rule.revoked && rule.match.kind === "outside-read" && rule.action === "deny"));
|
|
@@ -210,11 +212,11 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
210
212
|
}
|
|
211
213
|
const authority = nativeOnly ? undefined : options.captureAuthority?.(exec);
|
|
212
214
|
const integrity = options.captureIntegrity?.(exec);
|
|
213
|
-
const binding = { definition, body: definition.execute, identity, snapshot, nativeOnly, authority, integrity,
|
|
215
|
+
const binding = { exec, token: exec.token, asks: [], definition, body: definition.execute, identity, snapshot, nativeOnly, authority, integrity,
|
|
214
216
|
args: exec.arguments, agent: exec.agent, name: exec.name, callId: exec.callId,
|
|
215
217
|
signal: AbortSignal.any([exec.signal, lifetime.signal, ...identity.signal === undefined ? [] : [identity.signal], ...integrity?.signal === undefined ? [] : [integrity.signal]]), approval: ctx.get("approval"), fs: identity.context.get("fs"),
|
|
216
218
|
workspaceRoot: exec.agent?.session.header.cwd ?? "" };
|
|
217
|
-
bindings.set(exec
|
|
219
|
+
bindings.set(exec, binding);
|
|
218
220
|
check(exec, binding);
|
|
219
221
|
let action = "inherit";
|
|
220
222
|
if (snapshot !== undefined) {
|
|
@@ -231,7 +233,7 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
231
233
|
if (action === "deny")
|
|
232
234
|
return { kind: "deny", reason: "DSMM native permission rule denied this tool call." };
|
|
233
235
|
if (identity.kind === "shell" && options.managedShellDecision !== undefined)
|
|
234
|
-
return options.managedShellDecision(exec, action, next, snapshot);
|
|
236
|
+
return options.managedShellDecision(exec, action, next, snapshot, binding.asks);
|
|
235
237
|
const downstream = await next();
|
|
236
238
|
if (exec.signal.aborted)
|
|
237
239
|
return { kind: "cancel" };
|
|
@@ -262,7 +264,7 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
262
264
|
return permissionOutcome(next, ask.binding.signal, "cancelled");
|
|
263
265
|
}), { prepend: true, global: true });
|
|
264
266
|
const unguard = tools.guard(exec => {
|
|
265
|
-
const binding = bindings.get(exec
|
|
267
|
+
const binding = bindings.get(exec);
|
|
266
268
|
if (binding === undefined)
|
|
267
269
|
return undefined;
|
|
268
270
|
try {
|
|
@@ -273,8 +275,8 @@ export function registerNativePermissionRules(ctx, options) {
|
|
|
273
275
|
return "Native tool execution identity is no longer current.";
|
|
274
276
|
}
|
|
275
277
|
});
|
|
276
|
-
const unresult = ctx.on("tools/result", exec => { bindings.delete(exec
|
|
277
|
-
const dispose = () => { lifetime.abort(); unhook(); unguard(); unresult(); unapproval();
|
|
278
|
+
const unresult = ctx.on("tools/result", exec => { bindings.delete(exec); }, { global: true });
|
|
279
|
+
const dispose = () => { lifetime.abort(); unhook(); unguard(); unresult(); unapproval(); };
|
|
278
280
|
return ctx.effect(() => dispose);
|
|
279
281
|
}
|
|
280
282
|
export const NATIVE_PERMISSION_CAPABILITIES = Object.freeze({ outsideReads: "tool-call-boundary", finalInode: false,
|
|
@@ -40,7 +40,7 @@ const configFields = {
|
|
|
40
40
|
skills: "skills", roles: "roles", roleRouting: "role-routing", runtimePolicy: { strategy: null, rateLimit },
|
|
41
41
|
presets: { materialize: null, root: null }, subagents: { toolTopology: null, allowRouteOverride: null, enableRunInBackground: null, backgroundMode: null, maxDepth: null },
|
|
42
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 },
|
|
43
|
+
guards: { scope: null, shellCommandSafety: null, gitWriteGuard: null, gitWriteScope: null, toolOutputTruncation: { enabled: null, maxInlineBytes: null }, planFormatValidation: null, questionLabelHelper: { enabled: null, maxLabelChars: null }, todoDisciplineHelper: null },
|
|
44
44
|
runtimeRecovery: { enabled: null, retryOnStatusCodes: [null], retryOnCodes: [null], fallbackRoutes: [route], maxFallbackAttempts: null, idleContinuation: { enabled: null, maxContinuations: null, prompt: null } },
|
|
45
45
|
lsp: { enabled: null, serverName: null, command: null, args: [null], cwd: null, env: {}, toolCallTimeoutMs: null, failOnStartupError: null }
|
|
46
46
|
};
|
package/lib/profile-runtime.d.ts
CHANGED
|
@@ -5,12 +5,16 @@ import type { DsmmProfileDocument } from "./profiles.js";
|
|
|
5
5
|
import type { DsmmProfileAdmission, DsmmSettings, DsmmSettingsGetter, DsmmDeploymentSnapshot } from "./settings.js";
|
|
6
6
|
import { DeepworkModeController } from "./state.js";
|
|
7
7
|
import type { DsmmMountedPermissionGetter } from "./modules.js";
|
|
8
|
+
import type { ChildAdmissionIdentity } from "./child-capture.js";
|
|
8
9
|
export interface DsmmProfileRuntimeStore {
|
|
9
10
|
readonly profileDir?: string;
|
|
10
11
|
readonly readOnly?: boolean;
|
|
11
12
|
readonly origin?: "central" | "legacy" | "explicit";
|
|
12
13
|
readonly writeRestriction?: string;
|
|
13
14
|
loadSelection(): Promise<LoadedProfileSelection>;
|
|
15
|
+
loadSelectionIdentity(): Promise<LoadedProfileSelection>;
|
|
16
|
+
loadSessionSelectionIdentity(id: string): Promise<LoadedSessionProfileSelection>;
|
|
17
|
+
readChildIdentity(childId: string, parentId: string): Promise<ChildAdmissionIdentity | null>;
|
|
14
18
|
describe(): Promise<ProfileSnapshot>;
|
|
15
19
|
read(id: string): Promise<ProfileReadResult>;
|
|
16
20
|
save(request: ProfileSaveRequest, assertCurrent?: () => void): Promise<ProfileReadResult>;
|
|
@@ -55,6 +59,8 @@ export declare class DsmmProfileRuntime {
|
|
|
55
59
|
private readonly bound;
|
|
56
60
|
private readonly observations;
|
|
57
61
|
private readonly historyAdmissions;
|
|
62
|
+
private readonly activationChecks;
|
|
63
|
+
private readonly sessionObservations;
|
|
58
64
|
private disposed;
|
|
59
65
|
private queue;
|
|
60
66
|
private readonly mode;
|
|
@@ -69,6 +75,11 @@ export declare class DsmmProfileRuntime {
|
|
|
69
75
|
/** Prepare an explicit current choice; historical selection files and epochs are not read. */
|
|
70
76
|
prepareHistory(profileId: string | null, signal: AbortSignal): Promise<PreparedHistoryProfile>;
|
|
71
77
|
prepareRoot(agent: DshAgent, signal: AbortSignal): Promise<AdmittedProfile>;
|
|
78
|
+
readChildIdentity(childId: string, parentId: string): Promise<ChildAdmissionIdentity | null>;
|
|
79
|
+
prepareChild(agent: DshAgent, parent: DsmmProfileAdmission, signal: AbortSignal, identity?: ChildAdmissionIdentity | null): Promise<AdmittedProfile>;
|
|
80
|
+
private currentSelection;
|
|
81
|
+
private prepareActivation;
|
|
82
|
+
revalidateActivation(admission: DsmmProfileAdmission): Promise<void>;
|
|
72
83
|
getSession(agent: DshAgent): Promise<DsmmSessionProfileSnapshot>;
|
|
73
84
|
private sessionSnapshot;
|
|
74
85
|
selectMode(request: SessionModeSelectRequest, agent: DshAgent, signal?: AbortSignal, authority?: () => void): Promise<DsmmSessionProfileSnapshot>;
|
package/lib/profile-runtime.js
CHANGED
|
@@ -38,6 +38,8 @@ export class DsmmProfileRuntime {
|
|
|
38
38
|
bound = new WeakMap();
|
|
39
39
|
observations = new WeakMap();
|
|
40
40
|
historyAdmissions = new WeakSet();
|
|
41
|
+
activationChecks = new WeakMap();
|
|
42
|
+
sessionObservations = new WeakMap();
|
|
41
43
|
disposed = false;
|
|
42
44
|
queue = Promise.resolve();
|
|
43
45
|
mode;
|
|
@@ -58,7 +60,7 @@ export class DsmmProfileRuntime {
|
|
|
58
60
|
scopeLifetime(this.ctx, "dsmm: retire profile writes", retire);
|
|
59
61
|
else
|
|
60
62
|
this.ctx.effect?.(() => retire);
|
|
61
|
-
const selection = await this.store.
|
|
63
|
+
const selection = await this.currentSelection(await this.store.loadSelectionIdentity());
|
|
62
64
|
this.assertCurrent();
|
|
63
65
|
this.document = selection.document === null ? null : freezeSettings(selection.document);
|
|
64
66
|
this.current = this.prepare(this.document, selection);
|
|
@@ -138,29 +140,62 @@ export class DsmmProfileRuntime {
|
|
|
138
140
|
async prepareRoot(agent, signal) {
|
|
139
141
|
this.assertRoot(agent);
|
|
140
142
|
signal.throwIfAborted();
|
|
141
|
-
const
|
|
142
|
-
const selection = await this.store.loadSessionSelection(agent.id);
|
|
143
|
-
this.assertRoot(agent);
|
|
144
|
-
signal.throwIfAborted();
|
|
145
|
-
const candidate = selection.admissionEpoch === null
|
|
146
|
-
? this.prepare(this.document, this.observedSelection(this.current), newEpoch(), "global-default", deployment)
|
|
147
|
-
: this.prepare(selection.document, selection, selection.admissionEpoch, selection.selectedId === null ? "deployment-baseline" : "session-override", deployment);
|
|
143
|
+
const candidate = await this.prepareActivation(agent.id, signal);
|
|
148
144
|
const role = agent.ctx?.get?.("agentPresets")?.composedPreset(agent.ctx) ?? resolveSelectedAgentPreset(agent.session);
|
|
149
145
|
if (role?.startsWith("dsmm-") && (!isDsmmRoleId(role) || !isRootRoleEnabled(candidate.settings, role)))
|
|
150
146
|
throw new DsmmProfileError("activation", "Preset is not eligible for a root Agent.");
|
|
151
|
-
await this.validate(candidate.settings);
|
|
152
147
|
this.assertRoot(agent);
|
|
153
148
|
signal.throwIfAborted();
|
|
154
149
|
return candidate;
|
|
155
150
|
}
|
|
151
|
+
readChildIdentity(childId, parentId) { return this.store.readChildIdentity(childId, parentId); }
|
|
152
|
+
prepareChild(agent, parent, signal, identity = null) {
|
|
153
|
+
return this.prepareActivation(agent.id, signal, identity === null ? parent : { scope: identity.profileId === null ? "deployment-baseline" : "session-override", profile: identity.profileId === null ? null : { id: identity.profileId, revision: "" } }, parent.settings.subagents.maxDepth);
|
|
154
|
+
}
|
|
155
|
+
async currentSelection(pointer) {
|
|
156
|
+
if (pointer.selectedId === null)
|
|
157
|
+
return pointer;
|
|
158
|
+
const saved = await this.store.read(pointer.selectedId);
|
|
159
|
+
return { ...pointer, appliedRevision: saved.revision, sourceRevision: saved.revision, content: saved.content,
|
|
160
|
+
document: parseProfileDocument(saved.content, saved.id), warnings: saved.warnings };
|
|
161
|
+
}
|
|
162
|
+
async prepareActivation(sessionId, signal, inherited, parentMaxDepth) {
|
|
163
|
+
const own = await this.store.loadSessionSelectionIdentity(sessionId);
|
|
164
|
+
const scope = own.admissionEpoch !== null ? own.selectedId === null ? "deployment-baseline" : "session-override" : inherited?.scope ?? "global-default";
|
|
165
|
+
const pointer = own.admissionEpoch !== null ? own : scope === "global-default" ? await this.store.loadSelectionIdentity()
|
|
166
|
+
: { selectedId: inherited?.profile?.id ?? null, appliedRevision: null, selectionRevision: "absent", document: null, content: null };
|
|
167
|
+
const selected = await this.currentSelection(pointer);
|
|
168
|
+
const deployment = await this.options.readDesired?.();
|
|
169
|
+
const prepared = this.prepare(selected.document, selected, newEpoch(), scope, deployment);
|
|
170
|
+
const candidate = parentMaxDepth === undefined ? prepared : freezeSettings({ ...prepared, settings: { ...prepared.settings,
|
|
171
|
+
subagents: { ...prepared.settings.subagents, maxDepth: Math.min(parentMaxDepth, prepared.settings.subagents.maxDepth ?? parentMaxDepth) } } });
|
|
172
|
+
const check = async () => {
|
|
173
|
+
this.assertCurrent();
|
|
174
|
+
signal.throwIfAborted();
|
|
175
|
+
const latestOwn = await this.store.loadSessionSelectionIdentity(sessionId);
|
|
176
|
+
const latest = scope === "global-default" && own.admissionEpoch === null ? await this.store.loadSelectionIdentity() : pointer;
|
|
177
|
+
if (latestOwn.selectionRevision !== own.selectionRevision || latest.selectionRevision !== pointer.selectionRevision
|
|
178
|
+
|| selected.selectedId !== null && (await this.store.read(selected.selectedId)).revision !== selected.appliedRevision
|
|
179
|
+
|| !isDeepStrictEqual(await this.options.readDesired?.(), deployment))
|
|
180
|
+
throw new DsmmProfileError("conflict", "Configuration changed during activation.");
|
|
181
|
+
this.assertCurrent();
|
|
182
|
+
signal.throwIfAborted();
|
|
183
|
+
};
|
|
184
|
+
await this.validate(candidate.settings);
|
|
185
|
+
await check();
|
|
186
|
+
this.activationChecks.set(candidate, check);
|
|
187
|
+
this.sessionObservations.set(candidate, own.selectionRevision);
|
|
188
|
+
return candidate;
|
|
189
|
+
}
|
|
190
|
+
async revalidateActivation(admission) { await this.activationChecks.get(admission)?.(); }
|
|
156
191
|
async getSession(agent) {
|
|
157
192
|
this.assertRoot(agent);
|
|
158
193
|
const admitted = this.admission(agent);
|
|
159
|
-
const disk = await this.store.
|
|
194
|
+
const disk = await this.store.loadSessionSelectionIdentity(agent.id);
|
|
160
195
|
await this.ctx.get?.("dsmmNativeAdmission")?.ensure?.(agent);
|
|
161
196
|
this.assertRoot(agent);
|
|
162
|
-
if (this.admission(agent) !== admitted || !this.historyAdmissions.has(admitted) && ((disk.admissionEpoch === null && admitted.scope !== "global-default")
|
|
163
|
-
|| (disk.admissionEpoch !== null && (disk.admissionEpoch !== admitted.epoch || disk.selectedId !== admitted.selectedId || disk.appliedRevision !== admitted.appliedRevision)))) {
|
|
197
|
+
if (this.admission(agent) !== admitted || (this.sessionObservations.has(admitted) ? disk.selectionRevision !== this.sessionObservations.get(admitted) : !this.historyAdmissions.has(admitted) && ((disk.admissionEpoch === null && admitted.scope !== "global-default")
|
|
198
|
+
|| (disk.admissionEpoch !== null && (disk.admissionEpoch !== admitted.epoch || disk.selectedId !== admitted.selectedId || disk.appliedRevision !== admitted.appliedRevision))))) {
|
|
164
199
|
throw new DsmmProfileError("conflict", "The session choice changed outside this owner; its admitted configuration was retained.");
|
|
165
200
|
}
|
|
166
201
|
if (disk.admissionEpoch === admitted.epoch)
|
|
@@ -295,7 +330,7 @@ export class DsmmProfileRuntime {
|
|
|
295
330
|
const disk = await this.store.describe();
|
|
296
331
|
this.assertCurrent();
|
|
297
332
|
const current = this.current;
|
|
298
|
-
const changed = disk.selectedId !== current.selectedId
|
|
333
|
+
const changed = disk.selectedId !== current.selectedId
|
|
299
334
|
|| (this.observedSelection(current).selectionRevision !== "unavailable" && disk.selectionRevision !== this.observedSelection(current).selectionRevision);
|
|
300
335
|
if (!changed && disk.selectionError === undefined)
|
|
301
336
|
this.observations.set(current, selectionState(disk));
|
package/lib/profile-store.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Stats, BigIntStats } from "node:fs";
|
|
|
2
2
|
import type { ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSelectionState, ProfileSnapshot, SessionProfileSelectRequest } from "./profile-types.js";
|
|
3
3
|
import type { DsmmProfileDocument } from "./profiles.js";
|
|
4
4
|
import type { ProfileDiagnostic } from "./profile-diagnostics.js";
|
|
5
|
-
import type { ChildAdmissionCapture } from "./child-capture.js";
|
|
5
|
+
import type { ChildAdmissionCapture, ChildAdmissionIdentity } from "./child-capture.js";
|
|
6
6
|
export type SaveProfileRequest = ProfileSaveRequest;
|
|
7
7
|
export type SelectProfileRequest = ProfileSelectRequest;
|
|
8
8
|
export interface LoadedProfileSelection extends ProfileSelectionState {
|
|
@@ -67,6 +67,8 @@ export declare class ProfileStore {
|
|
|
67
67
|
/** The optional fence belongs to the trusted server caller, never the saved document. */
|
|
68
68
|
save(request: ProfileSaveRequest, assertCurrent?: () => void): Promise<ProfileReadResult>;
|
|
69
69
|
loadSelection(): Promise<LoadedProfileSelection>;
|
|
70
|
+
loadSelectionIdentity(): Promise<LoadedProfileSelection>;
|
|
71
|
+
loadSessionSelectionIdentity(sessionId: string): Promise<LoadedSessionProfileSelection>;
|
|
70
72
|
loadSessionSelection(sessionId: string): Promise<LoadedSessionProfileSelection>;
|
|
71
73
|
selectSession<T>(request: SessionProfileSelectRequest, epoch: string, validateCandidate: (document: DsmmProfileDocument | null) => T | Promise<T>, commit: SessionProfileCommit<T>): Promise<{
|
|
72
74
|
selection: LoadedSessionProfileSelection;
|
|
@@ -94,6 +96,7 @@ export declare class ProfileStore {
|
|
|
94
96
|
/** Host-only immutable state. No RPC exposes this writer or a filesystem path. */
|
|
95
97
|
createChildAdmission(input: ChildAdmissionCapture, assertCurrent?: () => void): Promise<ChildAdmissionCapture>;
|
|
96
98
|
readChildAdmission(childId: string, parentId: string): Promise<ChildAdmissionCapture | null>;
|
|
99
|
+
readChildIdentity(childId: string, parentId: string): Promise<ChildAdmissionIdentity | null>;
|
|
97
100
|
/** Only a trusted native session-deleted handler may call this; drain never does. */
|
|
98
101
|
deleteChildAdmission(childId: string, parentId: string): Promise<void>;
|
|
99
102
|
private childAdmission;
|
package/lib/profile-store.js
CHANGED
|
@@ -5,7 +5,7 @@ import { parseTree } from "jsonc-parser";
|
|
|
5
5
|
import { ABSENT_PROFILE_SELECTION_REVISION } from "./profile-types.js";
|
|
6
6
|
import { DsmmProfileError, MAX_PROFILE_BYTES, MAX_PROFILE_COUNT, MAX_PROFILE_DIRECTORY_ENTRIES, MAX_PROFILE_REVISIONS, parseProfileDocument, validateProfileDocument, profileErrorInfo, validateProfileId, validateProfileRevision } from "./profiles.js";
|
|
7
7
|
import { inspectJsonDocument } from "./profile-diagnostics.js";
|
|
8
|
-
import { parseChildAdmissionCapture } from "./child-capture.js";
|
|
8
|
+
import { parseChildAdmissionCapture, parseChildAdmissionIdentity } from "./child-capture.js";
|
|
9
9
|
import { isProfileReference } from "./config-revision.js";
|
|
10
10
|
import { validateAdmissionEpoch } from "./profiles.js";
|
|
11
11
|
export const MAX_SESSION_PROFILE_CHOICES = 1024;
|
|
@@ -83,8 +83,9 @@ export class ProfileStore {
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
try {
|
|
86
|
-
const selected = this.selection();
|
|
87
|
-
|
|
86
|
+
const selected = this.selection(true);
|
|
87
|
+
const current = selected.selectedId === null ? undefined : this.draft(selected.selectedId, entries);
|
|
88
|
+
return { ...this.metadata(), profiles, selectedId: selected.selectedId, appliedRevision: selected.appliedRevision, selectionRevision: selected.selectionRevision, ...(selected.sourceRevision === undefined ? {} : { sourceRevision: selected.sourceRevision }), ...(current?.warnings === undefined ? {} : { selectedWarnings: current.warnings }) };
|
|
88
89
|
}
|
|
89
90
|
catch (error) {
|
|
90
91
|
// An error is not a successful fallback to the baseline.
|
|
@@ -129,6 +130,13 @@ export class ProfileStore {
|
|
|
129
130
|
async loadSelection() {
|
|
130
131
|
return this.readOperation(() => this.selection());
|
|
131
132
|
}
|
|
133
|
+
async loadSelectionIdentity() {
|
|
134
|
+
return this.readOperation(() => this.selection(true));
|
|
135
|
+
}
|
|
136
|
+
async loadSessionSelectionIdentity(sessionId) {
|
|
137
|
+
validateSessionProfileId(sessionId);
|
|
138
|
+
return this.readOperation(() => this.sessionSelection(sessionId, undefined, true));
|
|
139
|
+
}
|
|
132
140
|
async loadSessionSelection(sessionId) {
|
|
133
141
|
validateSessionProfileId(sessionId);
|
|
134
142
|
return this.readOperation(() => this.sessionSelection(sessionId));
|
|
@@ -140,7 +148,7 @@ export class ProfileStore {
|
|
|
140
148
|
validateAdmissionEpoch(epoch);
|
|
141
149
|
return this.locked(async (assertLock) => {
|
|
142
150
|
commit.assertCurrent();
|
|
143
|
-
if (this.sessionSelection(request.sessionId).selectionRevision !== request.expectedSelectionRevision)
|
|
151
|
+
if (this.sessionSelection(request.sessionId, undefined, true).selectionRevision !== request.expectedSelectionRevision)
|
|
144
152
|
conflict("The session profile changed. Refresh before selecting again.");
|
|
145
153
|
const draft = request.id === null ? undefined : this.draft(request.id, this.inventory());
|
|
146
154
|
if (draft !== undefined && draft.revision !== request.expectedRevision)
|
|
@@ -158,7 +166,7 @@ export class ProfileStore {
|
|
|
158
166
|
const target = join(directory, `${sessionChoiceKey(request.sessionId)}.json`);
|
|
159
167
|
const fence = (temporary) => {
|
|
160
168
|
commit.assertCurrent();
|
|
161
|
-
if (this.sessionSelection(request.sessionId, temporary).selectionRevision !== request.expectedSelectionRevision)
|
|
169
|
+
if (this.sessionSelection(request.sessionId, temporary, true).selectionRevision !== request.expectedSelectionRevision)
|
|
162
170
|
conflict("The session selection was edited externally. Refresh before selecting again.");
|
|
163
171
|
if (draft !== undefined && this.draft(request.id, this.inventory()).revision !== draft.revision)
|
|
164
172
|
conflict("The draft changed during activation. Reload and select again.");
|
|
@@ -202,7 +210,7 @@ export class ProfileStore {
|
|
|
202
210
|
validateSelectionRequest(request);
|
|
203
211
|
return this.locked(async (assertLock) => {
|
|
204
212
|
assertCurrent?.();
|
|
205
|
-
const current = this.selection();
|
|
213
|
+
const current = this.selection(true);
|
|
206
214
|
if (current.selectionRevision !== request.expectedSelectionRevision)
|
|
207
215
|
conflict("The selected profile changed. Refresh before selecting again.");
|
|
208
216
|
const draft = request.id === null ? undefined : this.draft(request.id, this.inventory());
|
|
@@ -277,7 +285,7 @@ export class ProfileStore {
|
|
|
277
285
|
const file = regularFile(join(this.profileDir, name), MAX_PROFILE_BYTES);
|
|
278
286
|
return { ...file, ...validatedProfile(file.content, id) };
|
|
279
287
|
}
|
|
280
|
-
selection() {
|
|
288
|
+
selection(identityOnly = false) {
|
|
281
289
|
this.validateRoot(false);
|
|
282
290
|
this.validateState(false);
|
|
283
291
|
const path = join(this.stateDir, ".selection.json");
|
|
@@ -289,6 +297,11 @@ export class ProfileStore {
|
|
|
289
297
|
try {
|
|
290
298
|
const file = regularFile(path, 1024);
|
|
291
299
|
const pointer = parseSelectionPointer(file.content);
|
|
300
|
+
if (identityOnly) {
|
|
301
|
+
assertPointerVersion(path, file);
|
|
302
|
+
return { selectedId: pointer.id, appliedRevision: pointer.revision, selectionRevision: file.revision,
|
|
303
|
+
...(pointer.sourceRevision === undefined ? {} : { sourceRevision: pointer.sourceRevision }), document: null, content: null };
|
|
304
|
+
}
|
|
292
305
|
if (pointer.id === null)
|
|
293
306
|
return { selectedId: null, appliedRevision: null, selectionRevision: file.revision, document: null, content: null };
|
|
294
307
|
validateDirectories(join(this.profileDir, ".revisions"), false);
|
|
@@ -304,7 +317,7 @@ export class ProfileStore {
|
|
|
304
317
|
throw new DsmmProfileError("corrupt-selection", "The selected profile pointer or immutable revision is missing or invalid. Repair it explicitly; the baseline was not silently selected.");
|
|
305
318
|
}
|
|
306
319
|
}
|
|
307
|
-
sessionSelection(sessionId, temporary) {
|
|
320
|
+
sessionSelection(sessionId, temporary, identityOnly = false) {
|
|
308
321
|
this.validateRoot(false);
|
|
309
322
|
this.validateState(false);
|
|
310
323
|
const absent = { sessionId, admissionEpoch: null, selectedId: null, appliedRevision: null,
|
|
@@ -323,6 +336,11 @@ export class ProfileStore {
|
|
|
323
336
|
try {
|
|
324
337
|
const file = regularFile(path, 2048);
|
|
325
338
|
const pointer = parseSessionSelectionPointer(file.content, sessionId);
|
|
339
|
+
if (identityOnly) {
|
|
340
|
+
assertPointerVersion(path, file);
|
|
341
|
+
return { ...absent, admissionEpoch: pointer.epoch, selectedId: pointer.id, appliedRevision: pointer.revision,
|
|
342
|
+
selectionRevision: file.revision, ...(pointer.sourceRevision === undefined ? {} : { sourceRevision: pointer.sourceRevision }) };
|
|
343
|
+
}
|
|
326
344
|
if (pointer.id === null)
|
|
327
345
|
return { ...absent, admissionEpoch: pointer.epoch, selectionRevision: file.revision };
|
|
328
346
|
validateDirectories(join(this.profileDir, ".revisions"), false);
|
|
@@ -340,7 +358,7 @@ export class ProfileStore {
|
|
|
340
358
|
}
|
|
341
359
|
}
|
|
342
360
|
assertSelectionRevision(expected) {
|
|
343
|
-
if (this.selection().selectionRevision !== expected)
|
|
361
|
+
if (this.selection(true).selectionRevision !== expected)
|
|
344
362
|
conflict("The selection was edited externally. Refresh before selecting again.");
|
|
345
363
|
}
|
|
346
364
|
publishRevision(draft, assertLock) {
|
|
@@ -420,7 +438,7 @@ export class ProfileStore {
|
|
|
420
438
|
this.validateState(true);
|
|
421
439
|
validateDirectories(directory, true, false, this.identities);
|
|
422
440
|
const path = join(directory, `${sessionChoiceKey(capture.childSessionId)}.json`);
|
|
423
|
-
const existing = this.childAdmission(capture.childSessionId, capture.parentSessionId);
|
|
441
|
+
const existing = this.childAdmission(capture.childSessionId, capture.parentSessionId, parseChildAdmissionCapture);
|
|
424
442
|
if (existing !== null) {
|
|
425
443
|
if (JSON.stringify(existing) !== JSON.stringify(capture))
|
|
426
444
|
conflict("An immutable child admission already exists; it cannot be overwritten.");
|
|
@@ -464,7 +482,12 @@ export class ProfileStore {
|
|
|
464
482
|
async readChildAdmission(childId, parentId) {
|
|
465
483
|
validateSessionProfileId(childId);
|
|
466
484
|
validateSessionProfileId(parentId);
|
|
467
|
-
return this.readOperation(() => this.childAdmission(childId, parentId));
|
|
485
|
+
return this.readOperation(() => this.childAdmission(childId, parentId, parseChildAdmissionCapture));
|
|
486
|
+
}
|
|
487
|
+
async readChildIdentity(childId, parentId) {
|
|
488
|
+
validateSessionProfileId(childId);
|
|
489
|
+
validateSessionProfileId(parentId);
|
|
490
|
+
return this.readOperation(() => this.childAdmission(childId, parentId, parseChildAdmissionIdentity));
|
|
468
491
|
}
|
|
469
492
|
/** Only a trusted native session-deleted handler may call this; drain never does. */
|
|
470
493
|
async deleteChildAdmission(childId, parentId) {
|
|
@@ -472,7 +495,7 @@ export class ProfileStore {
|
|
|
472
495
|
validateSessionProfileId(childId);
|
|
473
496
|
validateSessionProfileId(parentId);
|
|
474
497
|
await this.locked(assertLock => {
|
|
475
|
-
const capture = this.childAdmission(childId, parentId);
|
|
498
|
+
const capture = this.childAdmission(childId, parentId, parseChildAdmissionCapture);
|
|
476
499
|
if (capture === null)
|
|
477
500
|
return;
|
|
478
501
|
const path = join(this.stateDir, ".children", "v1", `${sessionChoiceKey(childId)}.json`);
|
|
@@ -483,7 +506,7 @@ export class ProfileStore {
|
|
|
483
506
|
unlinkSync(path);
|
|
484
507
|
});
|
|
485
508
|
}
|
|
486
|
-
childAdmission(childId, parentId) {
|
|
509
|
+
childAdmission(childId, parentId, parse) {
|
|
487
510
|
this.validateRoot(false);
|
|
488
511
|
this.validateState(false);
|
|
489
512
|
const directory = join(this.stateDir, ".children", "v1");
|
|
@@ -508,7 +531,7 @@ export class ProfileStore {
|
|
|
508
531
|
validateAdmissionEpoch(envelope.revision, "revision");
|
|
509
532
|
if (digest(Buffer.from(JSON.stringify(envelope.capture), "utf8")) !== envelope.revision)
|
|
510
533
|
throw new Error("Capture integrity mismatch");
|
|
511
|
-
const capture =
|
|
534
|
+
const capture = parse(envelope.capture);
|
|
512
535
|
if (capture.childSessionId !== childId || capture.parentSessionId !== parentId)
|
|
513
536
|
throw new Error("Child capture identity mismatch");
|
|
514
537
|
return capture;
|
package/lib/profiles.js
CHANGED
|
@@ -308,9 +308,10 @@ function workflow(value, field) {
|
|
|
308
308
|
}
|
|
309
309
|
function guards(value, field) {
|
|
310
310
|
const item = record(value, field);
|
|
311
|
-
keys(item, ["scope", "shellCommandSafety", "gitWriteGuard", "toolOutputTruncation", "planFormatValidation", "questionLabelHelper", "todoDisciplineHelper"], field);
|
|
311
|
+
keys(item, ["scope", "shellCommandSafety", "gitWriteGuard", "gitWriteScope", "toolOutputTruncation", "planFormatValidation", "questionLabelHelper", "todoDisciplineHelper"], field);
|
|
312
312
|
optional(item, "scope", (scope, path) => enumeration(scope, ["deepwork-or-dsmm-agent", "always", "off"], path), field);
|
|
313
313
|
optional(item, "gitWriteGuard", (policy, path) => enumeration(policy, ["ask", "deny", "off"], path), field);
|
|
314
|
+
optional(item, "gitWriteScope", (scope, path) => enumeration(scope, ["all-writes", "high-risk"], path), field);
|
|
314
315
|
for (const key of ["shellCommandSafety", "planFormatValidation", "todoDisciplineHelper"])
|
|
315
316
|
optional(item, key, bool, field);
|
|
316
317
|
optional(item, "toolOutputTruncation", (raw, path) => {
|
package/lib/prompt-content.js
CHANGED
|
@@ -15,7 +15,7 @@ export function readPromptAsset(path) {
|
|
|
15
15
|
}
|
|
16
16
|
export const SOURCE_ROLE_CATALOG = JSON.parse(readPromptAsset("catalog.json"));
|
|
17
17
|
export function buildRoleIdentity(role) {
|
|
18
|
-
return `You are ${role.name}
|
|
18
|
+
return `You are ${role.name}.`;
|
|
19
19
|
}
|
|
20
20
|
export function splitCategory(text) {
|
|
21
21
|
const calibrations = new Map();
|
|
@@ -25,6 +25,6 @@ export function splitCategory(text) {
|
|
|
25
25
|
export function buildRolePersona(role) {
|
|
26
26
|
const source = role.promptArtifact === null ? role.description : readPromptAsset(role.promptArtifact.replace("prompts/source/", ""));
|
|
27
27
|
const body = role.kind === "category" ? splitCategory(source).base : source;
|
|
28
|
-
return [
|
|
28
|
+
return [readPromptAsset("shared/locale.md"), body, readPromptAsset("shared/dsh-host-contract.md"), readPromptAsset(role.terminalArtifact.replace("prompts/source/", ""))].filter(Boolean).join("\n\n---\n\n");
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=prompt-content.js.map
|
package/lib/role-control-rpc.js
CHANGED
|
@@ -154,10 +154,10 @@ let DsmmChildrenHost = (() => {
|
|
|
154
154
|
const child = this.ctx.get("agents")?.get(entry.id), direct = parentId === scope.parent.id;
|
|
155
155
|
const live = child && this.admission.get(child), invocation = child && this.admission.invocation(child);
|
|
156
156
|
const available = this.capabilities(scope);
|
|
157
|
-
const reason = !direct ? "not-direct-child" : entry.mode !== "continuable" ? entry.mode === "one-shot" ? "one-shot" : "unknown-mode" :
|
|
158
|
-
const control = reason !== undefined ? disabled(reason) : !this.ctx.get("agents")?.isOwnedBy(child.id, scope.parent) ? disabled("not-direct-child") : available.prompt;
|
|
157
|
+
const reason = !direct ? "not-direct-child" : entry.mode !== "continuable" ? entry.mode === "one-shot" ? "one-shot" : "unknown-mode" : child && !live ? "evidence-unavailable" : undefined;
|
|
158
|
+
const control = reason !== undefined ? disabled(reason) : child && !this.ctx.get("agents")?.isOwnedBy(child.id, scope.parent) ? disabled("not-direct-child") : available.prompt;
|
|
159
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) }),
|
|
160
|
+
readonly: !control.enabled, controls: { prompt: control, interrupt: child ? control : disabled("evidence-unavailable") }, ...(entry.label === undefined ? {} : { label: boundedLabel(entry.label) }),
|
|
161
161
|
...(invocation === undefined ? {} : { invocation: invocationView(invocation, boundedLabel(entry.label ?? invocation.target), "continuable", { childId: entry.id }) }),
|
|
162
162
|
...(child === undefined ? {} : { routeComparison: roleRouteComparison(child) }) };
|
|
163
163
|
}
|
|
@@ -197,8 +197,21 @@ let DsmmChildrenHost = (() => {
|
|
|
197
197
|
throw new ControlRefusal("disabled", undefined, capabilities.prompt.reason);
|
|
198
198
|
if (request.content.some(part => part.type === "image") && !capabilities.images.enabled)
|
|
199
199
|
throw new ControlRefusal("disabled", "content", capabilities.images.reason);
|
|
200
|
-
this.
|
|
201
|
-
|
|
200
|
+
const rows = await this.ctx.get("subagents").listChildren(scope.parent.id, scope.signal);
|
|
201
|
+
scope.check();
|
|
202
|
+
const row = rows.find(row => row.id === request.childSessionId);
|
|
203
|
+
if (!row)
|
|
204
|
+
throw new ControlRefusal("not-owned", "childSessionId");
|
|
205
|
+
if (row.mode !== "continuable")
|
|
206
|
+
throw new ControlRefusal("not-resumable", "childSessionId");
|
|
207
|
+
if (this.ctx.get("agents")?.get(SessionId(request.childSessionId)))
|
|
208
|
+
this.direct(scope, request.childSessionId);
|
|
209
|
+
return this.admission.duringCall(scope.parent, scope.signal, async (signal) => {
|
|
210
|
+
scope.check();
|
|
211
|
+
const receipt = await this.ctx.get("subagents").prompt(request, signal);
|
|
212
|
+
scope.check();
|
|
213
|
+
return receipt;
|
|
214
|
+
});
|
|
202
215
|
});
|
|
203
216
|
}
|
|
204
217
|
interrupt(sessionId, input) {
|
package/lib/role-llm-runtime.js
CHANGED
|
@@ -2,6 +2,7 @@ import { LlmError } from "@deepseek-ai/dsh-llm";
|
|
|
2
2
|
import { captureDsmmEffortSource, requiresDsmmCallAdmission, snapshotDsmmCall } from "./host-llm.js";
|
|
3
3
|
import { resolvedModelParameterPolicy } from "./model-parameter-policy.js";
|
|
4
4
|
import { modelRouteFromCall, projectModelRouteParameters } from "./role-llm.js";
|
|
5
|
+
import { prepareDsmmRequest } from "./model-routing.js";
|
|
5
6
|
/** Connect the cold Host LLM owner to the existing exact Agent/role admission authority. */
|
|
6
7
|
export function createDsmmRoleLlmOwner(ctx, providers) {
|
|
7
8
|
const nativeFallback = async (frame, proposal) => {
|
|
@@ -29,10 +30,18 @@ export function createDsmmRoleLlmOwner(ctx, providers) {
|
|
|
29
30
|
if (original !== admission.admission)
|
|
30
31
|
throw new Error("LLM policy does not own the exact admission");
|
|
31
32
|
const policy = resolvedModelParameterPolicy(original);
|
|
33
|
+
admission.assertCurrent();
|
|
34
|
+
frame.signal.throwIfAborted();
|
|
35
|
+
const routed = await prepareDsmmRequest(frame, proposal, admission.assertCurrent);
|
|
36
|
+
admission.assertCurrent();
|
|
37
|
+
frame.signal.throwIfAborted();
|
|
32
38
|
const effortSource = captureDsmmEffortSource(frame.agent);
|
|
33
|
-
const config = snapshotDsmmCall(projectModelRouteParameters(modelRouteFromCall(
|
|
39
|
+
const config = snapshotDsmmCall(projectModelRouteParameters(modelRouteFromCall(routed), effortSource, policy.mode !== "native-defaults"));
|
|
34
40
|
admission.assertCurrent();
|
|
35
41
|
if (policy.mode !== "passthrough") {
|
|
42
|
+
await ctx.get("llm").resolveCallConfig(config, frame.signal);
|
|
43
|
+
admission.assertCurrent();
|
|
44
|
+
frame.signal.throwIfAborted();
|
|
36
45
|
return { kind: "stock", admission, config, effortSource };
|
|
37
46
|
}
|
|
38
47
|
if (!requiresDsmmCallAdmission(config, providers)) {
|
package/lib/role-policy.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface DsmmRoleIdentity {
|
|
|
13
13
|
readonly readOnly?: boolean;
|
|
14
14
|
readonly toolFilter?: ToolRestriction;
|
|
15
15
|
readonly preset?: string;
|
|
16
|
+
readonly independentComposition?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export declare const READONLY_ROLE_DENIED_TOOLS: readonly ["write", "edit", "bash", "pwsh"];
|
|
18
19
|
export declare function roleToolName(role: DsmmRoleId): string;
|
|
@@ -32,9 +33,9 @@ export declare class DsmmRolePolicy {
|
|
|
32
33
|
assertLive(agent: DshAgent): void;
|
|
33
34
|
private selected;
|
|
34
35
|
validateRootRole(agent: DshAgent, admission: DsmmProfileAdmission): void;
|
|
35
|
-
bindChild(agent: DshAgent, parent: DshAgent, admission: DsmmProfileAdmission, invocation: ResolvedRoleInvocation, maximum: number | undefined, toolFilter: ToolRestriction): void;
|
|
36
|
+
bindChild(agent: DshAgent, parent: DshAgent, admission: DsmmProfileAdmission, invocation: ResolvedRoleInvocation, maximum: number | undefined, toolFilter: ToolRestriction, independentComposition?: boolean): void;
|
|
36
37
|
/** Ordinary native inheritance captures ceilings without inventing a role invocation. */
|
|
37
|
-
bindInheritedChild(agent: DshAgent, parent: DshAgent, admission: DsmmProfileAdmission): void;
|
|
38
|
+
bindInheritedChild(agent: DshAgent, parent: DshAgent, admission: DsmmProfileAdmission, continuation?: boolean): void;
|
|
38
39
|
release(agent: DshAgent): void;
|
|
39
40
|
assertModuleAdmission(agent: DshAgent): void;
|
|
40
41
|
identity(agent: DshAgent): DsmmRoleIdentity;
|
|
@@ -50,7 +51,7 @@ export declare class DsmmRolePolicy {
|
|
|
50
51
|
toolBlacklistDenial(agent: DshAgent, name: string, execution?: Readonly<ToolExecution>): string | undefined;
|
|
51
52
|
captureToolExecution(execution: Readonly<ToolExecution>, _full: boolean): void;
|
|
52
53
|
/** Visible native names are a narrowing ceiling, never permission to execute a definition. */
|
|
53
|
-
|
|
54
|
+
visibleToolCeiling(agent: DshAgent): ToolRestriction;
|
|
54
55
|
delegationToolFilter(execution: Readonly<ToolExecution>): ToolRestriction;
|
|
55
56
|
assertToolExecution(execution: Readonly<ToolExecution>): void;
|
|
56
57
|
beforeToolDecision<T>(operation: () => T): T;
|
package/lib/role-policy.js
CHANGED
|
@@ -61,27 +61,27 @@ export class DsmmRolePolicy {
|
|
|
61
61
|
if (selected?.startsWith("dsmm-") && (!isDsmmRoleId(selected) || !isRootRoleEnabled(admission.settings, selected)))
|
|
62
62
|
throw new SubagentError("Preset is not eligible as a root", "UNAUTHORIZED");
|
|
63
63
|
}
|
|
64
|
-
bindChild(agent, parent, admission, invocation, maximum, toolFilter) {
|
|
64
|
+
bindChild(agent, parent, admission, invocation, maximum, toolFilter, independentComposition = false) {
|
|
65
65
|
this.assertLive(agent);
|
|
66
66
|
this.assertLive(parent);
|
|
67
67
|
this.assertDelegation(parent, invocation.target);
|
|
68
|
-
if (!this.agents().isOwnedBy(agent.id, parent) || agent.session.header?.parentSession !== parent.id || this.selected(agent) !== this.selected(parent))
|
|
68
|
+
if (!this.agents().isOwnedBy(agent.id, parent) || agent.session.header?.parentSession !== parent.id || !independentComposition && this.selected(agent) !== this.selected(parent))
|
|
69
69
|
throw new SubagentError("Child lineage or composition mismatch", "UNAUTHORIZED");
|
|
70
70
|
if (maximum !== undefined && delegationDepthOf(agent) > maximum)
|
|
71
71
|
throw new SubagentError("Delegation depth exceeded", "UNAUTHORIZED");
|
|
72
72
|
const upstream = this.identity(parent);
|
|
73
|
-
liveIdentities.set(agent, Object.freeze({ role: invocation.target, child: true, parent, preset: this.selected(agent), epoch: admission.epoch,
|
|
73
|
+
liveIdentities.set(agent, Object.freeze({ role: invocation.target, child: true, parent, preset: this.selected(agent), epoch: admission.epoch, independentComposition,
|
|
74
74
|
readOnly: this.readOnly(upstream) || DSMM_ROLES.find(row => row.id === invocation.target).access === "read-only",
|
|
75
75
|
toolFilter: inheritToolFilter(inheritToolFilter(upstream.toolFilter, toolFilter), this.visibleToolCeiling(parent)) }));
|
|
76
76
|
bindRoleInvocation(agent, invocation);
|
|
77
77
|
captureRoleRuntimePolicy(admission.settings, invocation.target, invocation.policy);
|
|
78
78
|
}
|
|
79
79
|
/** Ordinary native inheritance captures ceilings without inventing a role invocation. */
|
|
80
|
-
bindInheritedChild(agent, parent, admission) {
|
|
80
|
+
bindInheritedChild(agent, parent, admission, continuation = false) {
|
|
81
81
|
this.assertLive(agent);
|
|
82
82
|
this.assertModuleAdmission(parent);
|
|
83
83
|
const upstream = this.identity(parent), preset = this.selected(agent);
|
|
84
|
-
if (upstream.role !== undefined || preset?.startsWith("dsmm-") || !this.agents().isOwnedBy(agent.id, parent)
|
|
84
|
+
if (!continuation && (upstream.role !== undefined || preset?.startsWith("dsmm-")) || !this.agents().isOwnedBy(agent.id, parent)
|
|
85
85
|
|| agent.session.header?.origin !== "subagent" || agent.session.header.parentSession !== parent.id)
|
|
86
86
|
throw new SubagentError("Ordinary inheritance requires its exact non-controlled parent", "UNAUTHORIZED");
|
|
87
87
|
liveIdentities.set(agent, Object.freeze({ child: true, parent, preset, epoch: admission.epoch,
|
|
@@ -94,7 +94,7 @@ export class DsmmRolePolicy {
|
|
|
94
94
|
if (identity?.child) {
|
|
95
95
|
this.assertLive(identity.parent);
|
|
96
96
|
if (!this.agents().isOwnedBy(agent.id, identity.parent) || selected !== identity.preset
|
|
97
|
-
|| identity.role !== undefined && selected !== this.selected(identity.parent))
|
|
97
|
+
|| identity.role !== undefined && !identity.independentComposition && selected !== this.selected(identity.parent))
|
|
98
98
|
throw new SubagentError("Child admission no longer matches composition", "UNAUTHORIZED");
|
|
99
99
|
}
|
|
100
100
|
else if (agent.session.header?.origin !== "subagent")
|
package/lib/role-providers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DshContext } from "./dsh-types.js";
|
|
1
|
+
import type { AgentRequestFrame, DshLlmCallConfig, DshContext } from "./dsh-types.js";
|
|
2
2
|
import type { DsmmSettingsGetter } from "./settings.js";
|
|
3
3
|
import type { DeepworkModeController } from "./state.js";
|
|
4
|
-
export declare function registerRuntimeRecovery(ctx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): void;
|
|
4
|
+
export declare function registerRuntimeRecovery(ctx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter, bindRequest?: (prepare: (frame: AgentRequestFrame, proposal: DshLlmCallConfig) => Promise<DshLlmCallConfig>) => void): void;
|
|
5
5
|
//# sourceMappingURL=runtime-recovery.d.ts.map
|