@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.
Files changed (182) hide show
  1. package/README.md +26 -42
  2. package/cordis.patch.yml +1 -0
  3. package/docs/agent-presets.md +26 -14
  4. package/docs/compatibility.md +20 -79
  5. package/docs/deferred-native-approval-risk.md +8 -12
  6. package/docs/design.md +25 -254
  7. package/docs/lsp.md +2 -2
  8. package/docs/migration-from-ocmm.md +38 -51
  9. package/docs/model-routing.md +21 -21
  10. package/docs/native-permissions.md +17 -7
  11. package/docs/profiles.md +13 -9
  12. package/docs/releasing.md +34 -240
  13. package/docs/roadmap.md +23 -254
  14. package/docs/runtime-recovery.md +29 -91
  15. package/docs/safety-guards.md +19 -16
  16. package/docs/settings-status.md +23 -11
  17. package/docs/skill-sync.md +17 -17
  18. package/docs/web-fetch-fakeip.md +82 -0
  19. package/lib/child-capture.d.ts +16 -2
  20. package/lib/child-capture.js +29 -10
  21. package/lib/client/ChildrenPanel.d.ts +1 -4
  22. package/lib/client/ChildrenPanel.js +4 -16
  23. package/lib/client/DeploymentFields.d.ts +28 -0
  24. package/lib/client/DeploymentFields.js +68 -0
  25. package/lib/client/DeploymentPage.d.ts +17 -5
  26. package/lib/client/DeploymentPage.js +79 -112
  27. package/lib/client/NativeCommandEntries.d.ts +17 -0
  28. package/lib/client/NativeCommandEntries.js +68 -0
  29. package/lib/client/PermissionsPanel.d.ts +1 -1
  30. package/lib/client/PermissionsPanel.js +8 -8
  31. package/lib/client/ProfilesSection.js +7 -5
  32. package/lib/client/RoleToolView-data.d.ts +35 -0
  33. package/lib/client/RoleToolView-data.js +52 -0
  34. package/lib/client/RoleToolView-locales.d.ts +36 -0
  35. package/lib/client/RoleToolView-locales.js +20 -0
  36. package/lib/client/RoleToolView.d.ts +10 -0
  37. package/lib/client/RoleToolView.js +47 -0
  38. package/lib/client/SessionProfiles.js +39 -15
  39. package/lib/client/children-controller.d.ts +2 -8
  40. package/lib/client/children-controller.js +1 -26
  41. package/lib/client/children-locales.d.ts +26 -51
  42. package/lib/client/children-locales.js +8 -12
  43. package/lib/client/configuration-display.d.ts +5 -0
  44. package/lib/client/configuration-display.js +11 -0
  45. package/lib/client/controller.d.ts +1 -0
  46. package/lib/client/controller.js +20 -13
  47. package/lib/client/deployment-controller.d.ts +13 -1
  48. package/lib/client/deployment-controller.js +85 -25
  49. package/lib/client/deployment-data.d.ts +1 -0
  50. package/lib/client/deployment-data.js +4 -1
  51. package/lib/client/deployment-locales.d.ts +43 -0
  52. package/lib/client/deployment-locales.js +35 -9
  53. package/lib/client/deployment-modules.d.ts +9 -0
  54. package/lib/client/deployment-modules.js +24 -0
  55. package/lib/client/deployment-workspace.d.ts +48 -0
  56. package/lib/client/deployment-workspace.js +123 -0
  57. package/lib/client/index.js +11 -74
  58. package/lib/client/locales.d.ts +7 -0
  59. package/lib/client/locales.js +12 -6
  60. package/lib/client/permission-controller.d.ts +1 -0
  61. package/lib/client/permission-controller.js +3 -2
  62. package/lib/client/permission-locales.d.ts +25 -0
  63. package/lib/client/permission-locales.js +24 -4
  64. package/lib/client/session-labels.js +4 -3
  65. package/lib/client/styles.d.ts +1 -1
  66. package/lib/client/styles.js +9 -8
  67. package/lib/client.js +2716 -2364
  68. package/lib/commands.js +2 -0
  69. package/lib/config-file-store.d.ts +3 -0
  70. package/lib/config-file-store.js +4 -2
  71. package/lib/config-revision.d.ts +5 -0
  72. package/lib/config-revision.js +11 -0
  73. package/lib/core-permission-authority.js +11 -41
  74. package/lib/deployment-config.d.ts +9 -2
  75. package/lib/deployment-config.js +35 -8
  76. package/lib/deployment-permission-rules.js +19 -7
  77. package/lib/dsh-types.d.ts +1 -1
  78. package/lib/host-llm-startup.js +3 -3
  79. package/lib/host-llm.d.ts +9 -3
  80. package/lib/host-llm.js +48 -8
  81. package/lib/index.d.ts +17 -21
  82. package/lib/index.js +131 -430
  83. package/lib/lifetime.d.ts +4 -0
  84. package/lib/lifetime.js +22 -0
  85. package/lib/live-pi-ai-owner.d.ts +1 -0
  86. package/lib/live-pi-ai-owner.js +8 -4
  87. package/lib/mode.d.ts +3 -2
  88. package/lib/mode.js +28 -41
  89. package/lib/model-routing.d.ts +2 -8
  90. package/lib/model-routing.js +59 -175
  91. package/lib/native-admission.d.ts +56 -0
  92. package/lib/native-admission.js +313 -0
  93. package/lib/native-pi-ai-wire.d.ts +3 -1
  94. package/lib/native-pi-ai-wire.js +47 -13
  95. package/lib/permission-control.d.ts +0 -3
  96. package/lib/permission-rpc.js +3 -3
  97. package/lib/preset-registry.js +3 -2
  98. package/lib/preset-skills.d.ts +3 -12
  99. package/lib/preset-skills.js +28 -58
  100. package/lib/profile-diagnostics.d.ts +1 -1
  101. package/lib/profile-diagnostics.js +2 -2
  102. package/lib/profile-remote.js +61 -22
  103. package/lib/profile-rpc.d.ts +4 -3
  104. package/lib/profile-rpc.js +39 -41
  105. package/lib/profile-runtime.d.ts +31 -74
  106. package/lib/profile-runtime.js +224 -639
  107. package/lib/profile-store.d.ts +18 -6
  108. package/lib/profile-store.js +106 -64
  109. package/lib/profile-types.d.ts +18 -4
  110. package/lib/profiles.d.ts +3 -1
  111. package/lib/profiles.js +9 -7
  112. package/lib/prompt-content.d.ts +1 -0
  113. package/lib/prompt-content.js +4 -1
  114. package/lib/prompts.d.ts +2 -12
  115. package/lib/prompts.js +11 -66
  116. package/lib/role-control-remote.d.ts +1 -4
  117. package/lib/role-control-remote.js +8 -36
  118. package/lib/role-control-rpc.d.ts +10 -36
  119. package/lib/role-control-rpc.js +112 -265
  120. package/lib/role-control-types.d.ts +3 -26
  121. package/lib/role-control-types.js +3 -4
  122. package/lib/role-identity.d.ts +5 -0
  123. package/lib/role-identity.js +10 -0
  124. package/lib/role-invocation.d.ts +2 -2
  125. package/lib/role-llm-runtime.js +5 -11
  126. package/lib/role-policy.d.ts +19 -53
  127. package/lib/role-policy.js +136 -525
  128. package/lib/role-providers.d.ts +5 -8
  129. package/lib/role-providers.js +20 -126
  130. package/lib/role-routing.d.ts +1 -3
  131. package/lib/role-routing.js +24 -34
  132. package/lib/role-subagents.d.ts +5 -14
  133. package/lib/role-subagents.js +149 -97
  134. package/lib/runtime-integration.d.ts +5 -109
  135. package/lib/runtime-integration.js +11 -779
  136. package/lib/session-metadata.d.ts +13 -12
  137. package/lib/session-metadata.js +6 -31
  138. package/lib/session-scope.js +6 -2
  139. package/lib/settings.d.ts +5 -18
  140. package/lib/settings.js +19 -43
  141. package/lib/state.d.ts +3 -2
  142. package/lib/state.js +26 -10
  143. package/lib/status.d.ts +1 -9
  144. package/lib/status.js +3 -55
  145. package/lib/web-fetch-address-policy.d.ts +24 -0
  146. package/lib/web-fetch-address-policy.js +189 -0
  147. package/lib/web-fetch-fakeip.d.ts +25 -0
  148. package/lib/web-fetch-fakeip.js +107 -0
  149. package/package.json +133 -113
  150. package/docs/research/deepseek-v4-pro.md +0 -74
  151. package/docs/research/oh-dsh.md +0 -96
  152. package/lib/child-admission.d.ts +0 -42
  153. package/lib/child-admission.js +0 -162
  154. package/lib/delivery-authority.d.ts +0 -68
  155. package/lib/delivery-authority.js +0 -260
  156. package/lib/legacy-child-policy.d.ts +0 -51
  157. package/lib/legacy-child-policy.js +0 -123
  158. package/lib/legacy-read-composition.d.ts +0 -20
  159. package/lib/legacy-read-composition.js +0 -144
  160. package/lib/legacy-read-contracts.d.ts +0 -157
  161. package/lib/legacy-read-contracts.js +0 -39
  162. package/lib/legacy-read-host.d.ts +0 -19
  163. package/lib/legacy-read-host.js +0 -67
  164. package/lib/legacy-read-integration.d.ts +0 -121
  165. package/lib/legacy-read-integration.js +0 -522
  166. package/lib/legacy-read-proxy.d.ts +0 -26
  167. package/lib/legacy-read-proxy.js +0 -237
  168. package/lib/native-child-evidence.d.ts +0 -42
  169. package/lib/native-child-evidence.js +0 -133
  170. package/lib/role-runs.d.ts +0 -135
  171. package/lib/role-runs.js +0 -304
  172. package/lib/session-persistence.d.ts +0 -35
  173. package/lib/session-persistence.js +0 -304
  174. package/lib/subagent-runtime.d.ts +0 -45
  175. package/lib/subagent-runtime.js +0 -131
  176. package/prompts/deepseek-flash.md +0 -11
  177. package/prompts/deepseek-v4-pro.md +0 -14
  178. package/scripts/cold-profile-composition.mjs +0 -329
  179. package/scripts/cold-profile-sources.mjs +0 -238
  180. package/scripts/migrate-cold-profile.mjs +0 -315
  181. package/scripts/repair-session-log.mjs +0 -476
  182. package/scripts/session-repair-native-verifier.mjs +0 -367
@@ -1,260 +0,0 @@
1
- import { symbols } from "@deepseek-ai/cordis";
2
- import { SubagentError } from "@deepseek-ai/dsh-subagent";
3
- function original(value) {
4
- return Reflect.get(value, symbols.original) ?? value;
5
- }
6
- function unauthorized() {
7
- throw new SubagentError("DSMM delivery requires current exact direct-parent authority.", "UNAUTHORIZED");
8
- }
9
- /** Public plugin/status dispatch precedes async cleanup, including ancestor Host teardown. */
10
- export function scopeLifetime(scope, label, revoke, install = () => { }) {
11
- // Cordis's public ambient const enum has no JavaScript export for source-only Node loading.
12
- const unloading = 5, disposed = 4;
13
- return scope.effect(() => {
14
- // Context.fiber can be a facade; its public readonly ctx identifies the exact owner.
15
- const owners = new Map();
16
- for (let fiber = scope.fiber; !owners.has(fiber.ctx); fiber = fiber.parent.fiber)
17
- owners.set(fiber.ctx, fiber);
18
- let retired = false;
19
- let detachPlugin = () => { }, detachStatus = () => { };
20
- const retire = () => { retired = true; revoke(); };
21
- const cleanup = () => { detachPlugin(); detachStatus(); retire(); };
22
- try {
23
- detachPlugin = scope.on("internal/plugin", (fiber) => {
24
- if (owners.has(fiber.ctx) && fiber.uid === null)
25
- retire();
26
- }, { global: true, prepend: true });
27
- detachStatus = scope.on("internal/status", (fiber) => {
28
- if (owners.has(fiber.ctx) && (fiber.state === unloading || fiber.state === disposed))
29
- retire();
30
- }, { global: true, prepend: true });
31
- if ([...owners.values()].some((fiber) => fiber.uid === null || fiber.state === unloading || fiber.state === disposed))
32
- unauthorized();
33
- install();
34
- if (retired)
35
- unauthorized();
36
- return cleanup;
37
- }
38
- catch (error) {
39
- cleanup();
40
- throw error;
41
- }
42
- }, label);
43
- }
44
- /** Stable Host lifetime; profile entry disposal must not replace this object. */
45
- export class DsmmDeliveryAuthority {
46
- ctx;
47
- lifetime = new AbortController();
48
- parents = new Map();
49
- tickets = new WeakMap();
50
- managedIds = new Set();
51
- binding;
52
- connection;
53
- providersReady;
54
- changed;
55
- hostClassifier;
56
- constructor(ctx, providersReady = () => true, changed = () => { }, hostClassifier) {
57
- this.ctx = ctx;
58
- this.providersReady = providersReady;
59
- this.changed = changed;
60
- this.hostClassifier = hostClassifier;
61
- scopeLifetime(ctx, "dsmm.deliveryAuthority: revoke Host tickets", () => {
62
- this.lifetime.abort();
63
- for (const parent of this.parents.keys())
64
- this.revokeParent(parent, "host-disposed");
65
- this.changed();
66
- });
67
- ctx.on("agent/disposed", ({ agent }) => this.revokeParent(agent, "registry-residency-disposed"), { global: true });
68
- ctx.inject(["connection"], (connectionCtx) => {
69
- const connection = connectionCtx.get("connection");
70
- const state = { owner: original(connection), operator: connection.operator, controller: new AbortController() };
71
- const revoke = () => {
72
- state.controller.abort();
73
- if (this.connection === state)
74
- this.connection = undefined;
75
- };
76
- // Native operator scope ancestry includes the exact providing Connection fiber.
77
- const detachOperator = scopeLifetime(connection.operator.ctx, "dsmm.deliveryAuthority: revoke operator and Connection lifetime", revoke);
78
- scopeLifetime(connectionCtx, "dsmm.deliveryAuthority: release Connection observer", () => { revoke(); detachOperator(); }, () => {
79
- if (state.controller.signal.aborted)
80
- unauthorized();
81
- this.connection = state;
82
- });
83
- });
84
- }
85
- view() {
86
- const ready = !this.lifetime.signal.aborted && this.binding?.enabled === true && this.providersReady();
87
- return { binding: "dsmm", deliveryFenceReady: ready, restartRequired: false,
88
- ...(ready ? {} : { reason: "authority-not-ready" }) };
89
- }
90
- /** Bind once per entry scope; teardown revokes its pending tickets synchronously. */
91
- bindPolicy(scope, owner, policy) {
92
- if (this.lifetime.signal.aborted || this.binding !== undefined)
93
- unauthorized();
94
- const binding = { owner, policy, enabled: false };
95
- return scopeLifetime(scope, "dsmm.deliveryAuthority: release policy owner", () => {
96
- if (this.binding !== binding)
97
- return;
98
- this.binding = undefined;
99
- this.revokeOwner(owner, "policy-owner-disposed");
100
- this.changed();
101
- }, () => {
102
- this.binding = binding;
103
- this.changed();
104
- });
105
- }
106
- /** Called after A/B admission/capture guards are installed, not at service mount. */
107
- enablePolicy(owner) {
108
- if (this.binding?.owner !== owner || this.lifetime.signal.aborted)
109
- unauthorized();
110
- this.binding.enabled = true;
111
- this.changed();
112
- }
113
- isManaged(parent) {
114
- if (this.managedIds.has(parent.id))
115
- return true;
116
- // An absent binding is unknown authority, never proof of a native caller.
117
- const hostKind = this.hostClassifier?.(parent);
118
- if (hostKind === "dsmm")
119
- return true;
120
- const kind = this.binding?.policy.classifyParent(parent) ?? hostKind;
121
- return kind !== "native";
122
- }
123
- registerParent(parent, admission, owner) {
124
- if (this.binding?.owner !== owner || this.lifetime.signal.aborted
125
- || this.ctx.get("agents")?.get(parent.id) !== parent || admission.epoch.length === 0)
126
- unauthorized();
127
- const existing = this.parents.get(parent);
128
- if (existing !== undefined) {
129
- if (existing.owner !== owner || existing.admission !== admission || existing.publishing)
130
- unauthorized();
131
- return;
132
- }
133
- // Durable IDs may be reused on cold resume; the former exact Agent cannot retain authority.
134
- for (const [previous, state] of this.parents) {
135
- if (previous.id === parent.id)
136
- this.revokeParent(state.parent, "residency-replaced");
137
- }
138
- const state = { parent, owner, admission, epoch: new AbortController(), lifetime: new AbortController(),
139
- publishing: false, usedEpochs: new Set([admission.epoch]) };
140
- state.detachResidency = scopeLifetime(parent.ctx, "dsmm.deliveryAuthority: revoke exact Agent residency", () => {
141
- if (this.parents.get(parent) === state)
142
- this.revokeParent(parent, "residency-disposed");
143
- }, () => {
144
- this.parents.set(parent, state);
145
- this.managedIds.add(parent.id);
146
- });
147
- }
148
- acquireParentTicket(parent) {
149
- if (!this.view().deliveryFenceReady)
150
- unauthorized();
151
- const state = this.current(parent);
152
- const ticket = Object.freeze({ parent, owner: state.owner, admission: state.admission, parentEpoch: state.admission.epoch,
153
- signal: AbortSignal.any([state.epoch.signal, state.lifetime.signal, this.lifetime.signal]) });
154
- this.tickets.set(ticket, state);
155
- return ticket;
156
- }
157
- assertTicket(ticket) {
158
- ticket.signal.throwIfAborted();
159
- if (!this.view().deliveryFenceReady)
160
- unauthorized();
161
- const state = this.current(ticket.parent);
162
- if (this.tickets.get(ticket) !== state || state.owner !== ticket.owner || state.admission !== ticket.admission
163
- || state.admission.epoch !== ticket.parentEpoch)
164
- unauthorized();
165
- }
166
- async resolveChildEvidence(ticket, childId, signal) {
167
- signal.throwIfAborted();
168
- this.assertTicket(ticket);
169
- const policy = this.binding.policy;
170
- const evidence = await policy.resolveChildEvidence(ticket, childId, signal);
171
- signal.throwIfAborted();
172
- this.assertTicket(ticket);
173
- return evidence;
174
- }
175
- assertDelivery(ticket, childId, evidence) {
176
- this.assertTicket(ticket);
177
- this.binding.policy.assertDelivery(ticket, childId, evidence);
178
- this.assertTicket(ticket);
179
- }
180
- prepareParentAdmission(parent, expectedEpoch, nextAdmission) {
181
- if (!this.view().deliveryFenceReady)
182
- unauthorized();
183
- const state = this.current(parent);
184
- if (state.admission.epoch !== expectedEpoch || nextAdmission.epoch.length === 0 || state.usedEpochs.has(nextAdmission.epoch))
185
- unauthorized();
186
- state.prepared = { expectedEpoch, expected: state.admission, admission: nextAdmission, controller: new AbortController() };
187
- }
188
- /** Core configuration uses the same exact parent state without acquiring delivery capability. */
189
- assertCoreParentAdmission(parent, owner, expected) {
190
- const state = this.current(parent);
191
- if (state.owner !== owner || state.admission !== expected || state.admission.epoch !== expected.epoch
192
- || parent.session.header.origin === "subagent" || !this.ctx.agents.roots().includes(parent))
193
- unauthorized();
194
- }
195
- prepareCoreParentAdmission(parent, owner, expected, nextAdmission) {
196
- this.assertCoreParentAdmission(parent, owner, expected);
197
- const state = this.current(parent);
198
- if (nextAdmission.epoch.length === 0 || state.usedEpochs.has(nextAdmission.epoch))
199
- unauthorized();
200
- state.prepared = { expectedEpoch: expected.epoch, expected, admission: nextAdmission, controller: new AbortController() };
201
- }
202
- /** Trusted successful-commit callback: install MUST be synchronous and nonthrowing. */
203
- publishParentAdmission(parent, expectedEpoch, nextAdmission, install) {
204
- const state = this.current(parent);
205
- const prepared = state.prepared;
206
- if (state.admission.epoch !== expectedEpoch || prepared?.expectedEpoch !== expectedEpoch || prepared.expected !== state.admission || prepared.admission !== nextAdmission)
207
- unauthorized();
208
- const previous = state.epoch;
209
- state.publishing = true;
210
- try {
211
- install();
212
- state.admission = nextAdmission;
213
- state.epoch = prepared.controller;
214
- state.usedEpochs.add(nextAdmission.epoch);
215
- state.prepared = undefined;
216
- previous.abort();
217
- }
218
- catch (error) {
219
- this.revokeParent(parent, "publication-failed");
220
- throw error;
221
- }
222
- finally {
223
- state.publishing = false;
224
- }
225
- }
226
- revokeParent(parent, _reason) {
227
- const state = this.parents.get(parent);
228
- if (state === undefined)
229
- return;
230
- this.parents.delete(parent);
231
- state.lifetime.abort();
232
- state.epoch.abort();
233
- state.prepared?.controller.abort();
234
- state.detachResidency?.();
235
- }
236
- revokeOwner(owner, reason) {
237
- for (const [parent, state] of this.parents)
238
- if (state.owner === owner)
239
- this.revokeParent(parent, reason);
240
- }
241
- /** Only the native exact operator/Connection can authorize browser delivery. */
242
- acquireBrowserSignal(callerCtx) {
243
- const invocation = callerCtx.invocation;
244
- const connection = callerCtx.get("connection");
245
- const state = this.connection;
246
- if (invocation?.peer === undefined || connection === undefined || state === undefined
247
- || original(connection) !== state.owner || connection.operator !== invocation.peer || state.operator !== invocation.peer)
248
- unauthorized();
249
- state.controller.signal.throwIfAborted();
250
- return state.controller.signal;
251
- }
252
- current(parent) {
253
- const state = this.parents.get(parent);
254
- if (state === undefined || state.publishing || state.lifetime.signal.aborted || this.lifetime.signal.aborted
255
- || this.binding?.owner !== state.owner || this.ctx.get("agents")?.get(parent.id) !== parent)
256
- unauthorized();
257
- return state;
258
- }
259
- }
260
- //# sourceMappingURL=delivery-authority.js.map
@@ -1,51 +0,0 @@
1
- import type { Agent } from "@deepseek-ai/dsh-agent";
2
- import type { ToolDefinition, ToolExecution, ToolGuard, ToolRuntime } from "@deepseek-ai/dsh-tools";
3
- import type { ChildAdmissionLimitation, ChildEvidenceField, LegacyChildEvidence } from "./child-capture.js";
4
- import type { DsmmProfileAdmission, DsmmSettings } from "./settings.js";
5
- import type { LegacyReadCompositionLease } from "./legacy-read-contracts.js";
6
- import type { LegacyReadProxy } from "./legacy-read-proxy.js";
7
- export interface LegacyToolCapability {
8
- readonly kind: "read" | "child-report" | "write" | "shell" | "delegation" | "other";
9
- /** Stable native definition identity; name alone does not prove parameter permissions. */
10
- readonly definition: ToolDefinition;
11
- /** Exact schema/argument contract is audited by the Host/B collaborator, never inferred from a name. */
12
- assertArguments(arguments_: unknown): void;
13
- /** A read is admitted only inside the real registered proxy's leased native invocation. */
14
- readonly operation?: LegacyReadOperationCapability;
15
- }
16
- export interface LegacyReadOperationCapability {
17
- readonly parent: Agent;
18
- readonly child: Agent;
19
- readonly definition: ToolDefinition;
20
- assertLeasedOperation(exec: Readonly<ToolExecution>): void;
21
- }
22
- /** Process-local glue for the trusted startup adapter, never a permission-query or wire grant. */
23
- export declare function createLegacyReadOperationCapability(proxy: LegacyReadProxy, leaseFor: (exec: Readonly<ToolExecution>) => LegacyReadCompositionLease | undefined): LegacyReadOperationCapability;
24
- export interface LegacyCapabilityCollaborators {
25
- classifyTool(name: string, tools: ToolRuntime, child: Agent): LegacyToolCapability | undefined;
26
- /** Exact direct-parent reporting authority only; read permission is decided by the real parent pipeline. */
27
- assertParentReport?(parent: Agent, child: Agent, arguments_: unknown, definition: ToolDefinition, evidence: LegacyChildEvidence): void;
28
- /** Older report collaborators may use this spelling. It is NEVER consulted for read. */
29
- assertParentTool?(parent: Agent, name: string, arguments_: unknown, definition: ToolDefinition): void;
30
- /** Trusted cold Host inventory of the actual registered child guard; never a permission grant. */
31
- onGuardInstalled?(child: Agent, guard: ToolGuard): void;
32
- }
33
- export interface LegacyToolDenial {
34
- readonly field: ChildEvidenceField;
35
- readonly code: ChildAdmissionLimitation["code"];
36
- }
37
- /** A restrictive current admission, explicitly NOT a reconstruction of the original settings or epoch. */
38
- export declare function createConservativeLegacyAdmission(raw: LegacyChildEvidence, parent: DsmmProfileAdmission, nativeSubstrate: DsmmSettings): DsmmProfileAdmission;
39
- /** Body-before guard for the proven read subset and the native child -> direct-parent report path. */
40
- export declare class LegacyChildToolPolicy {
41
- private readonly evidence;
42
- private readonly parent;
43
- private readonly child;
44
- private readonly collaborators;
45
- constructor(evidence: LegacyChildEvidence, parent: Agent, child: Agent, collaborators: LegacyCapabilityCollaborators);
46
- denial(name: string, arguments_: unknown, tools: ToolRuntime, exec?: Readonly<ToolExecution>): LegacyToolDenial | undefined;
47
- assertTool(name: string, arguments_: unknown, tools: ToolRuntime, exec?: Readonly<ToolExecution>): void;
48
- }
49
- /** Scoped monotonic native guard; denied bodies never execute, including locally registered tools. */
50
- export declare function installLegacyChildToolPolicy(evidence: LegacyChildEvidence, parent: Agent, child: Agent, collaborators: LegacyCapabilityCollaborators): () => void;
51
- //# sourceMappingURL=legacy-child-policy.d.ts.map
@@ -1,123 +0,0 @@
1
- import { randomBytes } from "node:crypto";
2
- import { SubagentError } from "@deepseek-ai/dsh-subagent";
3
- import { parseLegacyChildEvidence } from "./child-capture.js";
4
- import { DSMM_ROLE_IDS } from "./roles.js";
5
- import { copyJson, freezeSettings, resolveConfig } from "./settings.js";
6
- const readOperations = new WeakSet();
7
- /** Process-local glue for the trusted startup adapter, never a permission-query or wire grant. */
8
- export function createLegacyReadOperationCapability(proxy, leaseFor) {
9
- const { parent, child, definition } = proxy;
10
- const capability = Object.freeze({ parent, child, definition, assertLeasedOperation(exec) {
11
- const lease = leaseFor(exec);
12
- if (lease === undefined || definition === proxy.nativeDefinition || exec.agent !== child || exec.name !== "read"
13
- || child.ctx.tools.get("read", child) !== definition || parent.ctx.tools.get("read", parent) !== proxy.nativeDefinition
14
- || lease.bindings.parent !== parent || lease.bindings.child !== child || lease.bindings.definition !== proxy.nativeDefinition
15
- || lease.ticket.parent !== parent)
16
- throw new SubagentError("Legacy read requires the real proxy's leased invocation", "UNAUTHORIZED");
17
- lease.assertActive();
18
- } });
19
- readOperations.add(capability);
20
- return capability;
21
- }
22
- /** A restrictive current admission, explicitly NOT a reconstruction of the original settings or epoch. */
23
- export function createConservativeLegacyAdmission(raw, parent, nativeSubstrate) {
24
- const evidence = parseLegacyChildEvidence(raw);
25
- if (!parent.settings.modules.deepwork.enabled || !parent.settings.roles[evidence.role])
26
- throw new SubagentError("Current parent denies the legacy role", "UNAUTHORIZED");
27
- const { locale: _locale, ...substrate } = copyJson(nativeSubstrate);
28
- const settings = resolveConfig({ ...substrate,
29
- modules: { deepwork: { enabled: true } },
30
- roles: Object.fromEntries(DSMM_ROLE_IDS.map(role => [role, role === evidence.role])),
31
- roleRouting: { [evidence.role]: { primary: evidence.route, fallbackRoutes: [] } },
32
- defaultActive: evidence.active ?? false,
33
- skills: Object.fromEntries(Object.keys(substrate.skills).map(skill => [skill, false])),
34
- deepseekV4ProCalibration: "off", deepseekV4ProDefaultReasoningEffort: "off", deepseekFlashCalibration: "off", deepseekFlashDefaultReasoningEffort: "off",
35
- workflow: { policy: "risk-based", strictGates: true, reviewCap: 0, finalReviewPolicy: "off" },
36
- guards: { scope: "always", shellCommandSafety: true, gitWriteGuard: "deny" },
37
- runtimeRecovery: { enabled: false, fallbackRoutes: [], idleContinuation: { enabled: false } },
38
- subagents: { toolTopology: "per-role", allowRouteOverride: false, enableRunInBackground: false, backgroundMode: "continuable", maxDepth: evidence.depth },
39
- });
40
- return freezeSettings({ settings, profile: null, epoch: randomBytes(32).toString("hex"), scope: "deployment-baseline", childEvidence: {
41
- mode: "legacy-conservative", parentAdmissionEpoch: parent.epoch, provenFields: evidence.provenFields, limitations: evidence.limitations
42
- } });
43
- }
44
- /** Body-before guard for the proven read subset and the native child -> direct-parent report path. */
45
- export class LegacyChildToolPolicy {
46
- evidence;
47
- parent;
48
- child;
49
- collaborators;
50
- constructor(evidence, parent, child, collaborators) {
51
- this.evidence = parseLegacyChildEvidence(evidence);
52
- if (child.id !== evidence.childSessionId || parent.id !== evidence.parentSessionId || child.session.header.parentSession !== parent.id) {
53
- throw new SubagentError("Legacy tools require exact child/direct-parent identity", "UNAUTHORIZED");
54
- }
55
- this.parent = parent;
56
- this.child = child;
57
- this.collaborators = collaborators;
58
- }
59
- denial(name, arguments_, tools, exec) {
60
- const capability = this.collaborators.classifyTool(name, tools, this.child);
61
- if (capability?.kind === "write")
62
- return { field: "runtime-policy", code: "missing-evidence" };
63
- if (capability?.kind === "shell")
64
- return { field: "shell", code: "missing-evidence" };
65
- if (capability?.kind === "delegation")
66
- return { field: "delegation", code: "missing-evidence" };
67
- if (capability === undefined || capability.kind === "other" || tools.get(name, this.child) !== capability.definition)
68
- return { field: "tool-filter", code: "missing-evidence" };
69
- if (capability.kind === "read" && (this.evidence.toolFilter?.allow === undefined || !this.evidence.toolFilter.allow.includes(name)
70
- || this.evidence.toolFilter.deny?.includes(name)))
71
- return { field: "tool-filter", code: "missing-evidence" };
72
- // The report collaborator must check the explicit destination against the exact direct parent.
73
- try {
74
- capability.assertArguments(arguments_);
75
- }
76
- catch {
77
- return { field: "tool-filter", code: "missing-evidence" };
78
- }
79
- if (capability.kind === "read") {
80
- const operation = capability.operation;
81
- if (operation === undefined || !readOperations.has(operation) || operation.parent !== this.parent || operation.child !== this.child
82
- || operation.definition !== capability.definition || exec === undefined || exec.agent !== this.child || exec.name !== name
83
- || exec.arguments !== arguments_)
84
- return { field: "tool-filter", code: "unverified" };
85
- try {
86
- operation.assertLeasedOperation(exec);
87
- }
88
- catch {
89
- return { field: "tool-filter", code: "unverified" };
90
- }
91
- return undefined;
92
- }
93
- try {
94
- if (this.collaborators.assertParentReport !== undefined)
95
- this.collaborators.assertParentReport(this.parent, this.child, arguments_, capability.definition, this.evidence);
96
- else if (this.collaborators.assertParentTool !== undefined)
97
- this.collaborators.assertParentTool(this.parent, name, arguments_, capability.definition);
98
- else
99
- throw new SubagentError("Legacy report requires exact parent authority", "UNAUTHORIZED");
100
- }
101
- catch {
102
- return { field: "tool-filter", code: "parent-denied" };
103
- }
104
- return undefined;
105
- }
106
- assertTool(name, arguments_, tools, exec) {
107
- if (this.denial(name, arguments_, tools, exec) !== undefined)
108
- throw new SubagentError("Legacy evidence does not authorize this tool capability", "UNAUTHORIZED");
109
- }
110
- }
111
- /** Scoped monotonic native guard; denied bodies never execute, including locally registered tools. */
112
- export function installLegacyChildToolPolicy(evidence, parent, child, collaborators) {
113
- const tools = child.ctx.get("tools");
114
- if (tools === undefined)
115
- throw new SubagentError("Legacy execution requires a native tool guard", "UNAUTHORIZED");
116
- const policy = new LegacyChildToolPolicy(evidence, parent, child, collaborators);
117
- const guard = exec => exec.agent !== child || policy.denial(exec.name, exec.arguments, tools, exec) !== undefined
118
- ? "Legacy child capability is not proven by its durable evidence" : undefined;
119
- const release = tools.guard(guard);
120
- collaborators.onGuardInstalled?.(child, guard);
121
- return release;
122
- }
123
- //# sourceMappingURL=legacy-child-policy.js.map
@@ -1,20 +0,0 @@
1
- import type { Agent } from "@deepseek-ai/dsh-agent";
2
- import type { LegacyChildEvidence } from "./child-capture.js";
3
- import type { LegacyReadBindings, LegacyReadClosedSnapshot, LegacyReadCompositionLease, LegacyReadHostOwner } from "./legacy-read-contracts.js";
4
- export interface LegacyReadComposition {
5
- readonly owner: LegacyReadHostOwner;
6
- view(): {
7
- state: "off" | "ready" | "closed" | "disposed";
8
- generation: number;
9
- activeCalls: number;
10
- reason?: string;
11
- };
12
- captureClosedComposition(): LegacyReadClosedSnapshot | undefined;
13
- publishGeneration(snapshot: LegacyReadClosedSnapshot, expectedGeneration: number): void;
14
- acquireLease(parent: Agent, child: Agent, evidence: LegacyChildEvidence, signal: AbortSignal): LegacyReadCompositionLease;
15
- closeForChange(reason: string): Promise<void>;
16
- closeForDispose(reason: string): Promise<void>;
17
- }
18
- export declare function createLegacyReadComposition(owner: LegacyReadHostOwner): LegacyReadComposition;
19
- export declare function assertLegacyReadBindings(lease: LegacyReadCompositionLease, current: LegacyReadBindings): void;
20
- //# sourceMappingURL=legacy-read-composition.d.ts.map
@@ -1,144 +0,0 @@
1
- import { symbols } from "@deepseek-ai/cordis";
2
- import { parseLegacyChildEvidence } from "./child-capture.js";
3
- import { isLegacyReadHostOwner, LegacyReadUnavailable } from "./legacy-read-contracts.js";
4
- function checkSnapshot(owner, snapshot) {
5
- if (snapshot?.owner !== owner || snapshot.coverage !== "host-owned-complete" || snapshot.mutation !== "owner-coordinated"
6
- || snapshot.fidelity !== "canonical-value-content-contexts" || !["never-ask", "coordinated-turn"].includes(snapshot.approval)
7
- || !snapshot.scopes?.length || !snapshot.bindings?.length || !Array.isArray(snapshot.policies))
8
- throw new LegacyReadUnavailable("composition-unavailable");
9
- for (const scope of snapshot.scopes) {
10
- if (!scope.ctx || !scope.key || !Array.isArray(scope.ancestors))
11
- throw new LegacyReadUnavailable("composition-unavailable");
12
- }
13
- for (const policy of snapshot.policies) {
14
- if (policy.semantics !== "audited-zero-or-once" || !policy.reference || !snapshot.scopes.some(scope => scope.ctx === policy.scope)
15
- || !Number.isSafeInteger(policy.order))
16
- throw new LegacyReadUnavailable("composition-unavailable");
17
- }
18
- for (const binding of snapshot.bindings) {
19
- if (!binding.mount || !binding.config || !binding.parentProvider || !binding.childProvider || !binding.parentWorld || !binding.childWorld
20
- || !binding.parentFs || !binding.childFs || binding.definition?.name !== "read"
21
- || !binding.caps || [binding.caps.limit, binding.caps.maxBytes, binding.caps.maxLineLength, binding.caps.streamMinSize].some(cap => !Number.isSafeInteger(cap) || cap < 1)
22
- || !snapshot.scopes.some(scope => scope.key === binding.parent) || !snapshot.scopes.some(scope => scope.key === binding.child)) {
23
- throw new LegacyReadUnavailable("composition-unavailable");
24
- }
25
- }
26
- }
27
- export function createLegacyReadComposition(owner) {
28
- if (!isLegacyReadHostOwner(owner))
29
- throw new LegacyReadUnavailable("composition-unavailable");
30
- let state = "off";
31
- let generation = 0, reason, snapshot;
32
- const lifetime = new AbortController();
33
- const active = new Set();
34
- const waiters = new Set();
35
- let captures = new WeakSet();
36
- const drain = () => active.size === 0 ? Promise.resolve() : new Promise(resolve => waiters.add(resolve));
37
- const composition = {
38
- owner,
39
- view: () => ({ state, generation, activeCalls: active.size, ...(reason === undefined ? {} : { reason }) }),
40
- captureClosedComposition() {
41
- if (state === "ready" || state === "disposed" || active.size)
42
- throw new LegacyReadUnavailable("composition-unavailable");
43
- const captured = owner.captureClosedComposition();
44
- if (captured !== undefined) {
45
- checkSnapshot(owner, captured);
46
- captures.add(captured);
47
- }
48
- return captured;
49
- },
50
- publishGeneration(next, expected) {
51
- if (state === "ready" || state === "disposed" || active.size || generation !== expected || !captures.has(next))
52
- throw new LegacyReadUnavailable("composition-unavailable");
53
- checkSnapshot(owner, next);
54
- // Copy attested inventory, retaining actual definition/service/policy identities.
55
- snapshot = Object.freeze({ ...next, scopes: Object.freeze(next.scopes.map(scope => Object.freeze({ ...scope, ancestors: Object.freeze([...scope.ancestors]) }))),
56
- policies: Object.freeze(next.policies.map(policy => Object.freeze({ ...policy }))), bindings: Object.freeze([...next.bindings]) });
57
- captures.delete(next);
58
- generation++;
59
- state = "ready";
60
- reason = undefined;
61
- },
62
- acquireLease(parent, child, rawEvidence, signal) {
63
- if (state !== "ready" || snapshot === undefined)
64
- throw new LegacyReadUnavailable("composition-unavailable");
65
- signal.throwIfAborted();
66
- const evidence = parseLegacyChildEvidence(rawEvidence);
67
- if (parent === child || parent.id !== evidence.parentSessionId || child.id !== evidence.childSessionId
68
- || child.session.header.parentSession !== parent.id || parent.ctx.agents.get(parent.id) !== parent || child.ctx.agents.get(child.id) !== child
69
- || !child.ctx.agents.isOwnedBy(child.id, parent) || !evidence.toolFilter?.allow?.includes("read") || evidence.toolFilter.deny?.includes("read"))
70
- throw new LegacyReadUnavailable("evidence-unavailable");
71
- const acquiredGeneration = generation, acquiredSnapshot = snapshot;
72
- const ticket = owner.acquireParentTicket(parent);
73
- if (ticket.parent !== parent)
74
- throw new LegacyReadUnavailable("evidence-unavailable");
75
- owner.assertParentTicket(ticket);
76
- const original = owner.resolveChildAdmission(parent, child, rawEvidence, ticket);
77
- if (original.source !== "physical-old" || original.evidence !== rawEvidence || original.originalCapture !== undefined
78
- || !original.physicalRecords.length || !Object.isFrozen(original.admission))
79
- throw new LegacyReadUnavailable("evidence-unavailable");
80
- const bindings = snapshot.bindings.find(binding => binding.parent === parent && binding.child === child);
81
- if (bindings === undefined)
82
- throw new LegacyReadUnavailable("provenance-unavailable");
83
- const merged = AbortSignal.any([signal, ticket.signal, original.childLifetime, lifetime.signal]);
84
- merged.throwIfAborted();
85
- if (state !== "ready" || generation !== acquiredGeneration || snapshot !== acquiredSnapshot)
86
- throw new LegacyReadUnavailable("composition-unavailable");
87
- let released = false;
88
- const lease = Object.freeze({ owner, generation, signal: merged, ticket, bindings, approval: snapshot.approval,
89
- assertActive() {
90
- if (released || !active.has(lease))
91
- throw new LegacyReadUnavailable("lifetime-unavailable");
92
- merged.throwIfAborted();
93
- owner.assertParentTicket(ticket);
94
- },
95
- release() {
96
- if (released)
97
- return;
98
- released = true;
99
- active.delete(lease);
100
- if (!active.size) {
101
- for (const resolve of waiters)
102
- resolve();
103
- waiters.clear();
104
- }
105
- },
106
- });
107
- active.add(lease);
108
- return lease;
109
- },
110
- closeForChange(nextReason) {
111
- captures = new WeakSet();
112
- if (state !== "disposed") {
113
- state = "closed";
114
- reason = nextReason;
115
- }
116
- return drain();
117
- },
118
- closeForDispose(nextReason) {
119
- captures = new WeakSet();
120
- if (state !== "disposed") {
121
- state = "disposed";
122
- reason = nextReason;
123
- try {
124
- owner.revoke(nextReason);
125
- }
126
- finally {
127
- lifetime.abort(nextReason);
128
- }
129
- }
130
- return drain();
131
- },
132
- };
133
- return composition;
134
- }
135
- export function assertLegacyReadBindings(lease, current) {
136
- const expected = lease.bindings;
137
- const original = (value) => value === undefined ? undefined : Reflect.get(value, symbols.original) ?? value;
138
- if (current !== expected || current.parent.ctx.get("tools")?.get("read", current.parent) !== current.definition
139
- || original(current.child.ctx.get("fs")) !== original(current.childFs) || original(current.parent.ctx.get("fs")) !== original(current.parentFs)
140
- || current.parentProvider !== current.childProvider || current.parentWorld !== current.childWorld)
141
- throw new LegacyReadUnavailable("provenance-unavailable");
142
- lease.assertActive();
143
- }
144
- //# sourceMappingURL=legacy-read-composition.js.map