@dsmm/dsmm 0.2.2 → 0.3.1
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 -42
- package/cordis.patch.yml +1 -0
- package/docs/agent-presets.md +26 -14
- package/docs/compatibility.md +20 -79
- 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 +34 -240
- package/docs/roadmap.md +23 -254
- 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 +16 -2
- package/lib/child-capture.js +29 -10
- package/lib/client/ChildrenPanel.d.ts +1 -4
- package/lib/client/ChildrenPanel.js +4 -16
- package/lib/client/DeploymentFields.d.ts +28 -0
- package/lib/client/DeploymentFields.js +68 -0
- package/lib/client/DeploymentPage.d.ts +17 -5
- package/lib/client/DeploymentPage.js +79 -112
- package/lib/client/NativeCommandEntries.d.ts +17 -0
- package/lib/client/NativeCommandEntries.js +68 -0
- package/lib/client/PermissionsPanel.d.ts +1 -1
- package/lib/client/PermissionsPanel.js +8 -8
- package/lib/client/ProfilesSection.js +7 -5
- 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 +39 -15
- package/lib/client/children-controller.d.ts +2 -8
- package/lib/client/children-controller.js +1 -26
- package/lib/client/children-locales.d.ts +26 -51
- 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 +1 -0
- package/lib/client/controller.js +20 -13
- package/lib/client/deployment-controller.d.ts +13 -1
- package/lib/client/deployment-controller.js +85 -25
- 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 +35 -9
- 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/index.js +11 -74
- package/lib/client/locales.d.ts +7 -0
- package/lib/client/locales.js +12 -6
- package/lib/client/permission-controller.d.ts +1 -0
- package/lib/client/permission-controller.js +3 -2
- package/lib/client/permission-locales.d.ts +25 -0
- package/lib/client/permission-locales.js +24 -4
- 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.js +2716 -2364
- 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/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 +17 -21
- package/lib/index.js +131 -430
- 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 +56 -0
- package/lib/native-admission.js +313 -0
- package/lib/native-pi-ai-wire.d.ts +3 -1
- package/lib/native-pi-ai-wire.js +47 -13
- package/lib/permission-control.d.ts +0 -3
- package/lib/permission-rpc.js +3 -3
- 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 +39 -41
- package/lib/profile-runtime.d.ts +31 -74
- package/lib/profile-runtime.js +224 -639
- package/lib/profile-store.d.ts +18 -6
- package/lib/profile-store.js +106 -64
- package/lib/profile-types.d.ts +18 -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 -265
- 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 +2 -2
- package/lib/role-llm-runtime.js +5 -11
- package/lib/role-policy.d.ts +19 -53
- package/lib/role-policy.js +136 -525
- package/lib/role-providers.d.ts +5 -8
- package/lib/role-providers.js +20 -126
- 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 +149 -97
- package/lib/runtime-integration.d.ts +5 -109
- package/lib/runtime-integration.js +11 -779
- package/lib/session-metadata.d.ts +13 -12
- package/lib/session-metadata.js +6 -31
- package/lib/session-scope.js +6 -2
- package/lib/settings.d.ts +5 -18
- package/lib/settings.js +19 -43
- 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 +133 -113
- package/docs/research/deepseek-v4-pro.md +0 -74
- package/docs/research/oh-dsh.md +0 -96
- package/lib/child-admission.d.ts +0 -42
- package/lib/child-admission.js +0 -162
- package/lib/delivery-authority.d.ts +0 -68
- package/lib/delivery-authority.js +0 -260
- package/lib/legacy-child-policy.d.ts +0 -51
- package/lib/legacy-child-policy.js +0 -123
- package/lib/legacy-read-composition.d.ts +0 -20
- package/lib/legacy-read-composition.js +0 -144
- package/lib/legacy-read-contracts.d.ts +0 -157
- package/lib/legacy-read-contracts.js +0 -39
- package/lib/legacy-read-host.d.ts +0 -19
- package/lib/legacy-read-host.js +0 -67
- package/lib/legacy-read-integration.d.ts +0 -121
- package/lib/legacy-read-integration.js +0 -522
- package/lib/legacy-read-proxy.d.ts +0 -26
- package/lib/legacy-read-proxy.js +0 -237
- package/lib/native-child-evidence.d.ts +0 -42
- package/lib/native-child-evidence.js +0 -133
- package/lib/role-runs.d.ts +0 -135
- package/lib/role-runs.js +0 -304
- package/lib/session-persistence.d.ts +0 -35
- package/lib/session-persistence.js +0 -304
- package/lib/subagent-runtime.d.ts +0 -45
- package/lib/subagent-runtime.js +0 -131
- package/prompts/deepseek-flash.md +0 -11
- package/prompts/deepseek-v4-pro.md +0 -14
- package/scripts/cold-profile-composition.mjs +0 -329
- package/scripts/cold-profile-sources.mjs +0 -238
- package/scripts/migrate-cold-profile.mjs +0 -315
- package/scripts/repair-session-log.mjs +0 -476
- package/scripts/session-repair-native-verifier.mjs +0 -367
package/lib/legacy-read-proxy.js
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { isAbsolute } from "node:path";
|
|
3
|
-
import { isDeepStrictEqual } from "node:util";
|
|
4
|
-
import { HarnessError, ToolCallId } from "@deepseek-ai/dsh-llm";
|
|
5
|
-
import { createScope } from "@deepseek-ai/dsh-scope";
|
|
6
|
-
import { assertLegacyReadBindings } from "./legacy-read-composition.js";
|
|
7
|
-
import { isLegacyReadCallLease, LegacyReadUnavailable } from "./legacy-read-contracts.js";
|
|
8
|
-
export function installLegacyReadProxy(composition, parent, child, evidence, nativeDefinition) {
|
|
9
|
-
if (["ready", "disposed"].includes(composition.view().state) || composition.view().activeCalls)
|
|
10
|
-
throw new LegacyReadUnavailable("composition-unavailable");
|
|
11
|
-
if (nativeDefinition.name !== "read" || parent.ctx.tools.get("read", parent) !== nativeDefinition)
|
|
12
|
-
throw new LegacyReadUnavailable("provenance-unavailable");
|
|
13
|
-
const standingScope = createScope(child.ctx, child);
|
|
14
|
-
const proxyScope = createScope(child.ctx, child);
|
|
15
|
-
const calls = new Map();
|
|
16
|
-
let removed = false;
|
|
17
|
-
const openTurnStart = (agent) => agent.ctx.get("sessionProjections")?.stateOf(agent.session, "turnBoundary")?.openTurnStartSeq;
|
|
18
|
-
const assertContext = (call) => {
|
|
19
|
-
const context = call.context;
|
|
20
|
-
if (context === undefined)
|
|
21
|
-
throw new LegacyReadUnavailable("audit-unavailable");
|
|
22
|
-
context.assertAvailable();
|
|
23
|
-
if (context.approval.kind !== call.lease.approval)
|
|
24
|
-
throw new LegacyReadUnavailable("approval-unavailable");
|
|
25
|
-
if (context.approval.kind === "coordinated-turn") {
|
|
26
|
-
const approval = context.approval;
|
|
27
|
-
if (approval.turn.parent !== parent || openTurnStart(parent) == null || approval.turn.openTurnStartSeq !== openTurnStart(parent)
|
|
28
|
-
|| approval.signal.aborted)
|
|
29
|
-
throw new LegacyReadUnavailable("approval-unavailable");
|
|
30
|
-
if (approval.childTurn !== undefined && (approval.childTurn.child !== child || openTurnStart(child) == null
|
|
31
|
-
|| approval.childTurn.openTurnStartSeq !== openTurnStart(child) || approval.childTurn.signal.aborted))
|
|
32
|
-
throw new LegacyReadUnavailable("approval-unavailable");
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const callSignal = (exec, call) => AbortSignal.any([exec.signal, call.lease.signal,
|
|
36
|
-
...(call.context === undefined ? [] : [call.context.signal]),
|
|
37
|
-
...(call.context?.approval.kind === "coordinated-turn" ? [call.context.approval.signal,
|
|
38
|
-
...(call.context.approval.childTurn === undefined ? [] : [call.context.approval.childTurn.signal])] : [])]);
|
|
39
|
-
const definition = {
|
|
40
|
-
name: "read", description: nativeDefinition.description, parameters: nativeDefinition.parameters,
|
|
41
|
-
output: { schema: nativeDefinition.output.schema, render: (args, value) => nativeDefinition.output.render(args, value) },
|
|
42
|
-
isConcurrencySafe: () => true,
|
|
43
|
-
async execute(args, exec) {
|
|
44
|
-
const call = calls.get(exec.token);
|
|
45
|
-
if (call === undefined || call.invoked || removed)
|
|
46
|
-
throw new LegacyReadUnavailable("lifetime-unavailable");
|
|
47
|
-
call.invoked = true;
|
|
48
|
-
const { lease } = call;
|
|
49
|
-
lease.assertActive();
|
|
50
|
-
assertContext(call);
|
|
51
|
-
const signal = callSignal(exec, call);
|
|
52
|
-
signal.throwIfAborted();
|
|
53
|
-
const binding = composition.owner.resolveReadBindings(parent, child, lease);
|
|
54
|
-
assertLegacyReadBindings(lease, binding);
|
|
55
|
-
if (args === null || typeof args !== "object" || Array.isArray(args))
|
|
56
|
-
throw new LegacyReadUnavailable("arguments-unavailable");
|
|
57
|
-
const row = args;
|
|
58
|
-
if (Reflect.ownKeys(row).some(key => !["file_path", "offset", "limit"].includes(String(key)))
|
|
59
|
-
|| typeof row.file_path !== "string" || !row.file_path.trim() || row.file_path.includes("\0")
|
|
60
|
-
|| [row.offset, row.limit].some(value => value !== undefined && (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1))
|
|
61
|
-
|| (typeof row.limit === "number" && row.limit > binding.caps.limit))
|
|
62
|
-
throw new LegacyReadUnavailable("arguments-unavailable");
|
|
63
|
-
const target = await binding.childFs.resolve(row.file_path, { cwd: child.session.header.cwd, signal });
|
|
64
|
-
lease.assertActive();
|
|
65
|
-
signal.throwIfAborted();
|
|
66
|
-
const hostPath = binding.childFs.processPath(target);
|
|
67
|
-
const mapped = binding.parentFs.processPathFromHostPath(hostPath);
|
|
68
|
-
if (!isAbsolute(hostPath) || mapped === undefined || !isAbsolute(mapped))
|
|
69
|
-
throw new LegacyReadUnavailable("target-unavailable");
|
|
70
|
-
const parentTarget = await binding.parentFs.resolve(mapped, { cwd: parent.session.header.cwd, signal });
|
|
71
|
-
lease.assertActive();
|
|
72
|
-
signal.throwIfAborted();
|
|
73
|
-
if (target.targetKey === undefined || target.targetKey !== parentTarget.targetKey)
|
|
74
|
-
throw new LegacyReadUnavailable("target-unavailable");
|
|
75
|
-
assertLegacyReadBindings(lease, composition.owner.resolveReadBindings(parent, child, lease));
|
|
76
|
-
assertContext(call);
|
|
77
|
-
signal.throwIfAborted();
|
|
78
|
-
const callId = ToolCallId(`legacy-read:${randomUUID()}`);
|
|
79
|
-
call.parentExecution = { callId, rootCallId: exec.rootCallId, parent: exec.token };
|
|
80
|
-
const result = await parent.ctx.tools.execute({ agent: parent, name: "read", arguments: { ...row, file_path: mapped },
|
|
81
|
-
parent: exec.token, rootCallId: exec.rootCallId, callId, signal });
|
|
82
|
-
call.parentResult = result;
|
|
83
|
-
// Native execution has already settled. Never reclassify it using a newer epoch.
|
|
84
|
-
if (result.isError) {
|
|
85
|
-
const error = new HarnessError(result.error.message, result.error.info?.code ?? "LEGACY_READ_FAILED");
|
|
86
|
-
if (result.error.info !== undefined)
|
|
87
|
-
error.name = result.error.info.name;
|
|
88
|
-
call.transport = { isError: true, error: { message: error.message, info: { name: error.name, code: error.code } },
|
|
89
|
-
content: [{ type: "text", text: `Error: ${error.message}` }] };
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
if (result.concludesTurn)
|
|
93
|
-
exec.concludeTurn();
|
|
94
|
-
call.transport = { isError: false, value: result.value, content: definition.output.render(args, result.value),
|
|
95
|
-
...(result.concludesTurn ? { concludesTurn: true } : {}) };
|
|
96
|
-
return result.value;
|
|
97
|
-
},
|
|
98
|
-
projectContent(exec, result) {
|
|
99
|
-
const call = calls.get(exec.token);
|
|
100
|
-
// This runs BEFORE child post policy, and never replaces a later transformation.
|
|
101
|
-
return call?.projectionOutcome !== undefined && call.parentResult !== undefined && isDeepStrictEqual(result, call.projectionOutcome)
|
|
102
|
-
? call.parentResult.content : undefined;
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
const standingGuard = exec => exec.name !== "read" || exec.agent !== child ? undefined
|
|
106
|
-
: removed || !calls.has(exec.token) || child.ctx.tools.get("read", child) !== definition
|
|
107
|
-
|| calls.get(exec.token).lease.signal.aborted ? "Legacy read requires an active child-local operation lease" : undefined;
|
|
108
|
-
standingScope.ctx.tools.guard(standingGuard);
|
|
109
|
-
// The standing listener outlives the proxy so native completion always retires acquired leases.
|
|
110
|
-
const onResult = (exec, childResult) => {
|
|
111
|
-
const call = calls.get(exec.token);
|
|
112
|
-
if (call === undefined)
|
|
113
|
-
return;
|
|
114
|
-
calls.delete(exec.token);
|
|
115
|
-
const outcomes = { childExecution: exec, childResult,
|
|
116
|
-
...(call.parentExecution === undefined ? {} : { parentExecution: call.parentExecution }),
|
|
117
|
-
...(call.parentResult === undefined ? {} : { parentResult: call.parentResult }) };
|
|
118
|
-
const reportFault = (error) => {
|
|
119
|
-
void composition.closeForChange("audit-fault");
|
|
120
|
-
try {
|
|
121
|
-
composition.owner.reportAuditFault(error, outcomes);
|
|
122
|
-
}
|
|
123
|
-
catch (reportError) {
|
|
124
|
-
standingScope.ctx.logger.warn("Legacy read audit fault reporter failed", reportError);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
void (async () => {
|
|
128
|
-
try {
|
|
129
|
-
if (call.context !== undefined)
|
|
130
|
-
await call.context.finish(outcomes);
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
reportFault(error);
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
136
|
-
try {
|
|
137
|
-
call.context?.release();
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
reportFault(error);
|
|
141
|
-
}
|
|
142
|
-
finally {
|
|
143
|
-
call.lease.release();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
})();
|
|
147
|
-
};
|
|
148
|
-
standingScope.ctx.on("tools/result", onResult);
|
|
149
|
-
const preExecute = async (exec, next) => {
|
|
150
|
-
if (exec.agent !== child || exec.name !== "read")
|
|
151
|
-
return next();
|
|
152
|
-
let signal = exec.signal;
|
|
153
|
-
const unavailable = (error) => signal.aborted ? { kind: "cancel" }
|
|
154
|
-
: { kind: "deny", reason: "Legacy read operation unavailable", info: { name: "LegacyReadUnavailable",
|
|
155
|
-
code: error instanceof LegacyReadUnavailable ? error.code : "lifetime-unavailable" } };
|
|
156
|
-
let call;
|
|
157
|
-
try {
|
|
158
|
-
const lease = composition.acquireLease(parent, child, evidence, exec.signal);
|
|
159
|
-
call = { lease, invoked: false };
|
|
160
|
-
calls.set(exec.token, call);
|
|
161
|
-
signal = callSignal(exec, call);
|
|
162
|
-
const context = await composition.owner.acquireCallContext(parent, child, exec, lease);
|
|
163
|
-
if (!isLegacyReadCallLease(context))
|
|
164
|
-
throw new LegacyReadUnavailable("audit-unavailable");
|
|
165
|
-
call.context = context;
|
|
166
|
-
signal = callSignal(exec, call);
|
|
167
|
-
lease.assertActive();
|
|
168
|
-
assertContext(call);
|
|
169
|
-
signal.throwIfAborted();
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
return unavailable(error);
|
|
173
|
-
}
|
|
174
|
-
// Downstream exceptions remain native final-errors, and terminal decisions remain authoritative.
|
|
175
|
-
const decision = await next();
|
|
176
|
-
if (decision.kind === "deny" || decision.kind === "cancel")
|
|
177
|
-
return decision;
|
|
178
|
-
try {
|
|
179
|
-
signal = callSignal(exec, call);
|
|
180
|
-
call.lease.assertActive();
|
|
181
|
-
assertContext(call);
|
|
182
|
-
signal.throwIfAborted();
|
|
183
|
-
// This pre-only adapter cannot prove the original child caller includes these lifetimes.
|
|
184
|
-
// Parent approval instead receives a merged public execute input from the proxy body.
|
|
185
|
-
if (decision.kind === "ask")
|
|
186
|
-
throw new LegacyReadUnavailable("approval-unavailable");
|
|
187
|
-
}
|
|
188
|
-
catch (error) {
|
|
189
|
-
return unavailable(error);
|
|
190
|
-
}
|
|
191
|
-
return decision;
|
|
192
|
-
};
|
|
193
|
-
proxyScope.ctx.on("tools/pre-execute", preExecute, { prepend: true });
|
|
194
|
-
const complete = async (exec, next) => {
|
|
195
|
-
const call = calls.get(exec.token);
|
|
196
|
-
if (call === undefined)
|
|
197
|
-
return next();
|
|
198
|
-
const originalSignal = exec.signal;
|
|
199
|
-
exec.signal = callSignal(exec, call);
|
|
200
|
-
try {
|
|
201
|
-
const downstream = await next();
|
|
202
|
-
if (call.transport !== undefined && call.parentResult !== undefined && isDeepStrictEqual(downstream, call.transport)) {
|
|
203
|
-
call.projectionOutcome = call.parentResult.isError ? call.parentResult : { ...call.transport,
|
|
204
|
-
...(call.parentResult.additionalContexts === undefined ? {} : { additionalContexts: call.parentResult.additionalContexts }) };
|
|
205
|
-
return call.parentResult;
|
|
206
|
-
}
|
|
207
|
-
return downstream;
|
|
208
|
-
}
|
|
209
|
-
finally {
|
|
210
|
-
exec.signal = originalSignal;
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
proxyScope.ctx.on("tools/execute", complete, { prepend: true });
|
|
214
|
-
proxyScope.ctx.tools.register(definition);
|
|
215
|
-
return { parent, child, definition, nativeDefinition, proxyScope, standingScope,
|
|
216
|
-
contributions: Object.freeze([
|
|
217
|
-
{ stage: "pre", scope: proxyScope, reference: preExecute, order: 0 },
|
|
218
|
-
{ stage: "guard", scope: standingScope, reference: standingGuard, order: 0 },
|
|
219
|
-
{ stage: "around", scope: proxyScope, reference: complete, order: 0 },
|
|
220
|
-
{ stage: "project", scope: proxyScope, reference: definition.projectContent, order: 0 },
|
|
221
|
-
{ stage: "finalization", scope: standingScope, reference: onResult, order: 0 },
|
|
222
|
-
]),
|
|
223
|
-
async removeProxy() {
|
|
224
|
-
if (composition.view().state === "ready" || composition.view().activeCalls)
|
|
225
|
-
throw new LegacyReadUnavailable("composition-unavailable");
|
|
226
|
-
removed = true;
|
|
227
|
-
await proxyScope.dispose();
|
|
228
|
-
},
|
|
229
|
-
async releaseAfterChildDispose() {
|
|
230
|
-
if (child.ctx.get("agents")?.get(child.id) === child || composition.view().activeCalls)
|
|
231
|
-
throw new LegacyReadUnavailable("lifetime-unavailable");
|
|
232
|
-
removed = true;
|
|
233
|
-
await proxyScope.dispose();
|
|
234
|
-
await standingScope.dispose();
|
|
235
|
-
}, };
|
|
236
|
-
}
|
|
237
|
-
//# sourceMappingURL=legacy-read-proxy.js.map
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { SessionEvent, SessionHeader, SessionId as NativeSessionId } from "@deepseek-ai/dsh-session";
|
|
3
|
-
import type { ContinuableSubagentDescriptorData } from "@deepseek-ai/dsh-subagent";
|
|
4
|
-
import type { ParentAdmissionTicket } from "./delivery-authority.js";
|
|
5
|
-
import type { ChildAdmissionCapture, LegacyChildEvidence } from "./child-capture.js";
|
|
6
|
-
import type { DsmmProfileAdmission } from "./settings.js";
|
|
7
|
-
import type { DsmmRoleId } from "./roles.js";
|
|
8
|
-
/** Host-only borrowed cut returned by the PUBLIC SessionQueryEngine.observeSession service. */
|
|
9
|
-
export interface NativeChildObservation extends Disposable {
|
|
10
|
-
readonly header: SessionHeader;
|
|
11
|
-
readonly inheritedEventCount: number;
|
|
12
|
-
readonly events: readonly SessionEvent[];
|
|
13
|
-
}
|
|
14
|
-
/** Injection avoids making the optional query provider a new DSMM package dependency. No wire caller supplies history. */
|
|
15
|
-
export interface NativeChildHistory {
|
|
16
|
-
observeSession(id: NativeSessionId, options: {
|
|
17
|
-
signal: AbortSignal;
|
|
18
|
-
projectionMode: "none";
|
|
19
|
-
}): Promise<NativeChildObservation>;
|
|
20
|
-
}
|
|
21
|
-
export interface NativeChildFacts {
|
|
22
|
-
readonly childSessionId: string;
|
|
23
|
-
readonly parentSessionId: string;
|
|
24
|
-
readonly depth: number;
|
|
25
|
-
readonly role: DsmmRoleId;
|
|
26
|
-
readonly descriptor: ContinuableSubagentDescriptorData;
|
|
27
|
-
readonly active?: boolean;
|
|
28
|
-
readonly requestBudgetObserved: boolean;
|
|
29
|
-
}
|
|
30
|
-
/** Exact public catalog and replay-validated physical cuts; never resumes an Agent. */
|
|
31
|
-
export declare class NativeChildEvidenceReader {
|
|
32
|
-
private readonly ctx;
|
|
33
|
-
private readonly assertTicket;
|
|
34
|
-
private readonly history;
|
|
35
|
-
constructor(ctx: Context, assertTicket: (ticket: ParentAdmissionTicket<DsmmProfileAdmission>) => void, history: NativeChildHistory);
|
|
36
|
-
read(ticket: ParentAdmissionTicket<DsmmProfileAdmission>, childId: string, callerSignal: AbortSignal): Promise<NativeChildFacts>;
|
|
37
|
-
legacy(ticket: ParentAdmissionTicket<DsmmProfileAdmission>, childId: string, signal: AbortSignal): Promise<LegacyChildEvidence>;
|
|
38
|
-
}
|
|
39
|
-
export declare function legacyEvidenceFromNativeFacts(facts: NativeChildFacts): LegacyChildEvidence;
|
|
40
|
-
/** Capture evidence must agree with the child's establishing descriptor, not current parent routing. */
|
|
41
|
-
export declare function assertNativeChildCapture(capture: ChildAdmissionCapture, facts: NativeChildFacts): void;
|
|
42
|
-
//# sourceMappingURL=native-child-evidence.d.ts.map
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { symbols } from "@deepseek-ai/cordis";
|
|
2
|
-
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
3
|
-
import { foldSubagentDescriptor, SubagentError } from "@deepseek-ai/dsh-subagent";
|
|
4
|
-
import { parseLegacyChildEvidence } from "./child-capture.js";
|
|
5
|
-
import { freezeSettings } from "./settings.js";
|
|
6
|
-
import { isDsmmRoleId } from "./roles.js";
|
|
7
|
-
function unauthorized() { throw new SubagentError("Child history does not prove its direct native identity", "UNAUTHORIZED"); }
|
|
8
|
-
/** Exact public catalog and replay-validated physical cuts; never resumes an Agent. */
|
|
9
|
-
export class NativeChildEvidenceReader {
|
|
10
|
-
ctx;
|
|
11
|
-
assertTicket;
|
|
12
|
-
history;
|
|
13
|
-
constructor(ctx, assertTicket, history) {
|
|
14
|
-
this.ctx = ctx;
|
|
15
|
-
this.assertTicket = assertTicket;
|
|
16
|
-
this.history = history;
|
|
17
|
-
}
|
|
18
|
-
async read(ticket, childId, callerSignal) {
|
|
19
|
-
const signal = AbortSignal.any([ticket.signal, callerSignal]);
|
|
20
|
-
const check = () => {
|
|
21
|
-
signal.throwIfAborted();
|
|
22
|
-
this.assertTicket(ticket);
|
|
23
|
-
const current = this.ctx.get("sessionQuery");
|
|
24
|
-
if (current === undefined || (Reflect.get(current, symbols.original) ?? current) !== (Reflect.get(this.history, symbols.original) ?? this.history))
|
|
25
|
-
unauthorized();
|
|
26
|
-
};
|
|
27
|
-
check();
|
|
28
|
-
if (this.ctx.agents.get(ticket.parent.id) !== ticket.parent || childId === ticket.parent.id)
|
|
29
|
-
unauthorized();
|
|
30
|
-
const rows = await this.ctx.subagents.listChildren(ticket.parent.id, signal);
|
|
31
|
-
check();
|
|
32
|
-
const matches = rows.filter(row => row.id === childId);
|
|
33
|
-
if (matches.length !== 1 || matches[0].mode !== "continuable")
|
|
34
|
-
unauthorized();
|
|
35
|
-
const observation = await this.history.observeSession(SessionId(childId), { signal, projectionMode: "none" });
|
|
36
|
-
try {
|
|
37
|
-
check();
|
|
38
|
-
const facts = readFacts(ticket.parent, childId, observation);
|
|
39
|
-
const catalog = matches[0];
|
|
40
|
-
if (catalog.createdAt !== observation.header.createdAt || catalog.mode !== facts.descriptor.mode || catalog.label !== facts.descriptor.label)
|
|
41
|
-
unauthorized();
|
|
42
|
-
check();
|
|
43
|
-
return facts;
|
|
44
|
-
}
|
|
45
|
-
finally {
|
|
46
|
-
observation[Symbol.dispose]();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async legacy(ticket, childId, signal) {
|
|
50
|
-
return legacyEvidenceFromNativeFacts(await this.read(ticket, childId, signal));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function readFacts(parent, childId, observation) {
|
|
54
|
-
const header = observation.header;
|
|
55
|
-
if (header.version !== 4 || header.id !== childId || header.parentSession !== parent.id || header.origin !== "subagent"
|
|
56
|
-
|| !Number.isSafeInteger(header.delegationDepth) || header.delegationDepth <= (parent.session.header.delegationDepth ?? 0)
|
|
57
|
-
|| typeof header.cwd !== "string")
|
|
58
|
-
unauthorized();
|
|
59
|
-
const inherited = observation.inheritedEventCount;
|
|
60
|
-
if (!Number.isSafeInteger(inherited) || inherited < 0 || inherited > observation.events.length)
|
|
61
|
-
unauthorized();
|
|
62
|
-
const own = observation.events.slice(inherited);
|
|
63
|
-
// The catalog projection is display data; a second descriptor cannot replace the establishing composition.
|
|
64
|
-
if (own.filter(event => event.type === "subagent/descriptor").length !== 1)
|
|
65
|
-
unauthorized();
|
|
66
|
-
const descriptor = foldSubagentDescriptor(own);
|
|
67
|
-
if (descriptor?.mode !== "continuable" || !descriptor.provider.startsWith("dsmm-role-"))
|
|
68
|
-
unauthorized();
|
|
69
|
-
const role = `dsmm-${descriptor.provider.slice("dsmm-role-".length)}`;
|
|
70
|
-
if (!isDsmmRoleId(role) || role === "dsmm-orchestrator" || descriptor.agentProvider === undefined || descriptor.agentModel === undefined)
|
|
71
|
-
unauthorized();
|
|
72
|
-
let active;
|
|
73
|
-
for (const event of own) {
|
|
74
|
-
if (event.type === "dsmm/role-policy") {
|
|
75
|
-
const data = event.data;
|
|
76
|
-
if (data === null || typeof data !== "object" || Array.isArray(data) || Object.keys(data).length !== 3
|
|
77
|
-
|| data.version !== 1 || data.role !== role || data.policy !== null && (typeof data.policy !== "string" || !/^[a-f0-9]{64}$/u.test(data.policy)))
|
|
78
|
-
unauthorized();
|
|
79
|
-
}
|
|
80
|
-
else if (event.type === "deepwork/mode") {
|
|
81
|
-
const data = event.data;
|
|
82
|
-
if (data === null || typeof data !== "object" || Array.isArray(data) || Object.keys(data).length !== 1 || typeof data.active !== "boolean")
|
|
83
|
-
unauthorized();
|
|
84
|
-
active = data.active;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return freezeSettings({ childSessionId: childId, parentSessionId: parent.id, depth: header.delegationDepth, role, descriptor,
|
|
88
|
-
...(active === undefined ? {} : { active }), requestBudgetObserved: own.some(hasRequestBudget) });
|
|
89
|
-
}
|
|
90
|
-
function hasRequestBudget(event) {
|
|
91
|
-
if (event.type !== "request/header")
|
|
92
|
-
return false;
|
|
93
|
-
return event.data.header.config.maxTokens !== undefined;
|
|
94
|
-
}
|
|
95
|
-
export function legacyEvidenceFromNativeFacts(facts) {
|
|
96
|
-
const provenFields = ["lineage", "role", "route"];
|
|
97
|
-
if (facts.descriptor.toolFilter !== undefined)
|
|
98
|
-
provenFields.push("tool-filter");
|
|
99
|
-
if (facts.active !== undefined)
|
|
100
|
-
provenFields.push("active-intent");
|
|
101
|
-
if (facts.requestBudgetObserved)
|
|
102
|
-
provenFields.push("max-tokens");
|
|
103
|
-
const limitations = [
|
|
104
|
-
...["profile-pin", "admission-epoch", "invocation-level", "locale", "tool-topology"].map(field => ({ field, code: "missing-evidence", effect: "display-only" })),
|
|
105
|
-
...["runtime-policy", "modules", "roles", "read-only", "route-override", "max-depth", "guards", "git-write", "shell", "delegation"].map(field => ({ field, code: "missing-evidence", effect: "capability-denied" })),
|
|
106
|
-
{ field: "max-tokens", code: "not-persisted", effect: "native-default" },
|
|
107
|
-
{ field: "output-schema", code: "unverified", effect: "capability-denied" },
|
|
108
|
-
];
|
|
109
|
-
if (facts.descriptor.toolFilter === undefined)
|
|
110
|
-
limitations.push({ field: "tool-filter", code: "missing-evidence", effect: "capability-denied" });
|
|
111
|
-
if (facts.active === undefined)
|
|
112
|
-
limitations.push({ field: "active-intent", code: "missing-evidence", effect: "display-only" });
|
|
113
|
-
return parseLegacyChildEvidence({ version: 1, mode: "legacy-conservative", childSessionId: facts.childSessionId,
|
|
114
|
-
parentSessionId: facts.parentSessionId, role: facts.role, depth: facts.depth,
|
|
115
|
-
route: { provider: facts.descriptor.agentProvider, model: facts.descriptor.agentModel,
|
|
116
|
-
...(facts.descriptor.agentReasoningEffort === undefined ? {} : { reasoningEffort: facts.descriptor.agentReasoningEffort }) },
|
|
117
|
-
...(facts.descriptor.toolFilter === undefined ? {} : { toolFilter: facts.descriptor.toolFilter }),
|
|
118
|
-
...(facts.active === undefined ? {} : { active: facts.active }), provenFields, limitations });
|
|
119
|
-
}
|
|
120
|
-
/** Capture evidence must agree with the child's establishing descriptor, not current parent routing. */
|
|
121
|
-
export function assertNativeChildCapture(capture, facts) {
|
|
122
|
-
const route = capture.invocation.initialRoute, descriptor = facts.descriptor;
|
|
123
|
-
if (capture.childSessionId !== facts.childSessionId || capture.parentSessionId !== facts.parentSessionId || capture.role !== facts.role
|
|
124
|
-
|| facts.depth > capture.authorityCeiling.maxDepth || descriptor.agentProvider !== route.provider || descriptor.agentModel !== route.model
|
|
125
|
-
|| descriptor.agentReasoningEffort !== route.reasoningEffort)
|
|
126
|
-
unauthorized();
|
|
127
|
-
const ceiling = capture.authorityCeiling.toolFilter, native = descriptor.toolFilter;
|
|
128
|
-
if (native?.allow !== undefined && (ceiling?.allow === undefined || ceiling.allow.some(name => !native.allow.includes(name))))
|
|
129
|
-
unauthorized();
|
|
130
|
-
if (native?.deny?.some(name => ceiling?.allow?.includes(name) || ceiling?.allow === undefined && !ceiling?.deny?.includes(name)))
|
|
131
|
-
unauthorized();
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=native-child-evidence.js.map
|
package/lib/role-runs.d.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
import type { ContentBlock, ToolCallId } from "@deepseek-ai/dsh-llm";
|
|
4
|
-
import type { SessionId } from "@deepseek-ai/dsh-session";
|
|
5
|
-
import type { SubagentRun } from "@deepseek-ai/dsh-subagent";
|
|
6
|
-
export type RoleRunState = "starting" | "running" | "background" | "settled" | "cancelled";
|
|
7
|
-
export type RoleRunJobId = ReturnType<Context["jobs"]["start"]>;
|
|
8
|
-
export interface RoleRunAddress {
|
|
9
|
-
readonly sessionId: SessionId;
|
|
10
|
-
readonly toolCallId: ToolCallId;
|
|
11
|
-
/** The native SubagentRun.id, not the distinct lifecycle-event runId. */
|
|
12
|
-
readonly runId: SubagentRun["id"];
|
|
13
|
-
}
|
|
14
|
-
/** Host-only identity. Capture/projection are the borrowed original admitted objects. */
|
|
15
|
-
export interface RoleRunInvocation<C = unknown, P = unknown> extends RoleRunAddress {
|
|
16
|
-
readonly parent: Agent;
|
|
17
|
-
readonly owner: object;
|
|
18
|
-
readonly admissionEpoch: string;
|
|
19
|
-
readonly capture: C;
|
|
20
|
-
readonly projection: P;
|
|
21
|
-
readonly mode: "one-shot";
|
|
22
|
-
readonly childId?: SessionId;
|
|
23
|
-
}
|
|
24
|
-
export interface RoleRunForeground<C = unknown, P = unknown> {
|
|
25
|
-
readonly kind: "foreground";
|
|
26
|
-
readonly runId: SubagentRun["id"];
|
|
27
|
-
readonly invocation: RoleRunInvocation<C, P>;
|
|
28
|
-
readonly output: readonly ContentBlock[];
|
|
29
|
-
}
|
|
30
|
-
export interface RoleRunBackground<C = unknown, P = unknown> {
|
|
31
|
-
readonly kind: "background";
|
|
32
|
-
readonly jobId: RoleRunJobId;
|
|
33
|
-
readonly invocation: RoleRunInvocation<C, P>;
|
|
34
|
-
}
|
|
35
|
-
export type RoleRunTransition<C = unknown, P = unknown> = {
|
|
36
|
-
readonly status: "background" | "already-background";
|
|
37
|
-
readonly receipt: RoleRunBackground<C, P>;
|
|
38
|
-
} | {
|
|
39
|
-
readonly status: "already-settled" | "starting" | "cancelled";
|
|
40
|
-
};
|
|
41
|
-
export interface RoleRunBackgroundRequest extends RoleRunAddress {
|
|
42
|
-
readonly parent: Agent;
|
|
43
|
-
readonly owner: object;
|
|
44
|
-
readonly expectedAdmissionEpoch: string;
|
|
45
|
-
}
|
|
46
|
-
export interface RoleRunTeardown {
|
|
47
|
-
/** Supply the stable Host authority's revokeParent, never an epoch-only abort. */
|
|
48
|
-
revokeParent(agent: Agent, reason: string): void;
|
|
49
|
-
/**
|
|
50
|
-
* Invoke the original run disposer. Any opaque native handles/descendants this
|
|
51
|
-
* callback owns MUST also be authority-revoked before their original disposal.
|
|
52
|
-
* The holder revokes the public localAgent before calling this collaborator.
|
|
53
|
-
*/
|
|
54
|
-
disposeRun(run: SubagentRun): Promise<void>;
|
|
55
|
-
}
|
|
56
|
-
export interface RoleRunCollaborators<C = unknown, P = unknown> {
|
|
57
|
-
/** Synchronous exact-parent/entry-owner check plus the current stable epoch. */
|
|
58
|
-
currentEpoch(parent: Agent, owner: object): string;
|
|
59
|
-
/** Trusted admission/operator adapter; no UI/RPC protocol is synthesized here. */
|
|
60
|
-
canBackground(parent: Agent, identity: RoleRunInvocation<C, P>, currentEpoch: string): boolean;
|
|
61
|
-
readonly teardown: RoleRunTeardown;
|
|
62
|
-
}
|
|
63
|
-
export interface RoleRunStart<C = unknown, P = unknown> {
|
|
64
|
-
readonly parent: Agent;
|
|
65
|
-
readonly owner: object;
|
|
66
|
-
readonly sessionId: SessionId;
|
|
67
|
-
readonly toolCallId: ToolCallId;
|
|
68
|
-
readonly admissionEpoch: string;
|
|
69
|
-
readonly capture: C;
|
|
70
|
-
readonly projection: P;
|
|
71
|
-
readonly label: string;
|
|
72
|
-
readonly callerAbort: AbortSignal;
|
|
73
|
-
readonly jobs?: Context["jobs"];
|
|
74
|
-
/** Call native subagents.start exactly once, forwarding this holder signal. */
|
|
75
|
-
start(signal: AbortSignal): Promise<SubagentRun>;
|
|
76
|
-
}
|
|
77
|
-
/** One foreground call's real native run and its revocable caller-cancel relay. */
|
|
78
|
-
export declare class RoleRunHolder<C = unknown, P = unknown> {
|
|
79
|
-
private readonly controller;
|
|
80
|
-
private readonly readyResult;
|
|
81
|
-
private readonly foregroundResult;
|
|
82
|
-
private readonly drainedResult;
|
|
83
|
-
private currentState;
|
|
84
|
-
private identity?;
|
|
85
|
-
private receipt?;
|
|
86
|
-
private outcome?;
|
|
87
|
-
private terminal;
|
|
88
|
-
private finished;
|
|
89
|
-
private registering;
|
|
90
|
-
private committing;
|
|
91
|
-
private detachParent;
|
|
92
|
-
private readonly callerRelay;
|
|
93
|
-
readonly ready: Promise<RoleRunInvocation<C, P>>;
|
|
94
|
-
readonly foreground: Promise<RoleRunBackground<C, P> | RoleRunForeground<C, P>>;
|
|
95
|
-
/** Quiescence, preserving typed result and aggregate cleanup errors even in background. */
|
|
96
|
-
readonly drained: Promise<void>;
|
|
97
|
-
private readonly request;
|
|
98
|
-
private readonly collaborators;
|
|
99
|
-
private readonly release;
|
|
100
|
-
constructor(request: RoleRunStart<C, P>, collaborators: RoleRunCollaborators<C, P>, release: () => void);
|
|
101
|
-
get state(): RoleRunState;
|
|
102
|
-
get owner(): object;
|
|
103
|
-
get sessionId(): SessionId;
|
|
104
|
-
get toolCallId(): ToolCallId;
|
|
105
|
-
get invocation(): RoleRunInvocation<C, P> | undefined;
|
|
106
|
-
get holderSignal(): AbortSignal;
|
|
107
|
-
cancel(reason?: unknown): void;
|
|
108
|
-
background(request: RoleRunBackgroundRequest): RoleRunTransition<C, P>;
|
|
109
|
-
private assertAddress;
|
|
110
|
-
private assertAuthorization;
|
|
111
|
-
private begin;
|
|
112
|
-
private observed;
|
|
113
|
-
}
|
|
114
|
-
/** Current process-local calls only; native jobs remain the sole background registry. */
|
|
115
|
-
export declare class RoleRunRegistry<C = unknown, P = unknown> {
|
|
116
|
-
private readonly calls;
|
|
117
|
-
private closed;
|
|
118
|
-
private readonly collaborators;
|
|
119
|
-
/** ctx is the stable Host-owned scope, not a reinstalled profile entry. */
|
|
120
|
-
constructor(ctx: Context, collaborators: RoleRunCollaborators<C, P>);
|
|
121
|
-
start(request: RoleRunStart<C, P>): RoleRunHolder<C, P>;
|
|
122
|
-
/** Host-only lookup; C3 must authorize operator/session/epoch before exposing a view. */
|
|
123
|
-
get(parent: Agent, owner: object, address: RoleRunAddress): RoleRunHolder<C, P> | undefined;
|
|
124
|
-
/** Host-only active-call inventory, including starting calls without invented run ids. */
|
|
125
|
-
list(parent: Agent, owner: object): readonly RoleRunHolder<C, P>[];
|
|
126
|
-
/**
|
|
127
|
-
* Trusted parent teardown first revokes C1 authority, then awaits this before
|
|
128
|
-
* the original AgentHandle.dispose. Already-revoked tickets are not reacquired.
|
|
129
|
-
*/
|
|
130
|
-
drainParent(parent: Agent, owner: object, reason: string): Promise<void>;
|
|
131
|
-
close(reason: string): void;
|
|
132
|
-
drain(): Promise<void>;
|
|
133
|
-
private awaitHolders;
|
|
134
|
-
}
|
|
135
|
-
//# sourceMappingURL=role-runs.d.ts.map
|