@dsmm/dsmm 0.3.0 → 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 (166) hide show
  1. package/README.md +26 -40
  2. package/cordis.patch.yml +0 -13
  3. package/docs/agent-presets.md +26 -14
  4. package/docs/compatibility.md +19 -73
  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 -280
  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 +12 -2
  20. package/lib/child-capture.js +22 -5
  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 +27 -52
  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 +84 -24
  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 +2713 -2361
  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 +16 -20
  82. package/lib/index.js +130 -416
  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/preset-registry.js +3 -2
  97. package/lib/preset-skills.d.ts +3 -12
  98. package/lib/preset-skills.js +28 -58
  99. package/lib/profile-diagnostics.d.ts +1 -1
  100. package/lib/profile-diagnostics.js +2 -2
  101. package/lib/profile-remote.js +61 -22
  102. package/lib/profile-rpc.d.ts +4 -3
  103. package/lib/profile-rpc.js +33 -37
  104. package/lib/profile-runtime.d.ts +31 -74
  105. package/lib/profile-runtime.js +224 -639
  106. package/lib/profile-store.d.ts +18 -6
  107. package/lib/profile-store.js +104 -62
  108. package/lib/profile-types.d.ts +18 -4
  109. package/lib/profiles.d.ts +3 -1
  110. package/lib/profiles.js +9 -7
  111. package/lib/prompt-content.d.ts +1 -0
  112. package/lib/prompt-content.js +4 -1
  113. package/lib/prompts.d.ts +2 -12
  114. package/lib/prompts.js +11 -66
  115. package/lib/role-control-remote.d.ts +1 -4
  116. package/lib/role-control-remote.js +8 -36
  117. package/lib/role-control-rpc.d.ts +10 -36
  118. package/lib/role-control-rpc.js +112 -269
  119. package/lib/role-control-types.d.ts +3 -26
  120. package/lib/role-control-types.js +3 -4
  121. package/lib/role-identity.d.ts +5 -0
  122. package/lib/role-identity.js +10 -0
  123. package/lib/role-invocation.d.ts +2 -2
  124. package/lib/role-llm-runtime.js +5 -11
  125. package/lib/role-policy.d.ts +19 -50
  126. package/lib/role-policy.js +136 -508
  127. package/lib/role-providers.d.ts +5 -8
  128. package/lib/role-providers.js +20 -86
  129. package/lib/role-routing.d.ts +1 -3
  130. package/lib/role-routing.js +24 -34
  131. package/lib/role-subagents.d.ts +5 -14
  132. package/lib/role-subagents.js +148 -106
  133. package/lib/runtime-integration.d.ts +5 -78
  134. package/lib/runtime-integration.js +11 -697
  135. package/lib/session-metadata.d.ts +13 -12
  136. package/lib/session-metadata.js +6 -31
  137. package/lib/session-scope.js +2 -1
  138. package/lib/settings.d.ts +5 -18
  139. package/lib/settings.js +19 -43
  140. package/lib/state.d.ts +3 -2
  141. package/lib/state.js +26 -10
  142. package/lib/status.d.ts +1 -9
  143. package/lib/status.js +3 -55
  144. package/lib/web-fetch-address-policy.d.ts +24 -0
  145. package/lib/web-fetch-address-policy.js +189 -0
  146. package/lib/web-fetch-fakeip.d.ts +25 -0
  147. package/lib/web-fetch-fakeip.js +107 -0
  148. package/package.json +113 -103
  149. package/docs/research/deepseek-v4-pro.md +0 -74
  150. package/docs/research/oh-dsh.md +0 -96
  151. package/lib/agent-registry.d.ts +0 -36
  152. package/lib/agent-registry.js +0 -75
  153. package/lib/child-admission.d.ts +0 -40
  154. package/lib/child-admission.js +0 -151
  155. package/lib/delivery-authority.d.ts +0 -83
  156. package/lib/delivery-authority.js +0 -397
  157. package/lib/native-child-evidence.d.ts +0 -40
  158. package/lib/native-child-evidence.js +0 -104
  159. package/lib/role-runs.d.ts +0 -138
  160. package/lib/role-runs.js +0 -335
  161. package/lib/session-persistence.d.ts +0 -36
  162. package/lib/session-persistence.js +0 -304
  163. package/lib/subagent-runtime.d.ts +0 -57
  164. package/lib/subagent-runtime.js +0 -257
  165. package/prompts/deepseek-flash.md +0 -11
  166. package/prompts/deepseek-v4-pro.md +0 -14
@@ -14,7 +14,7 @@ export const PROFILE_DIAGNOSTIC_REASONS = {
14
14
  "deployment-ceiling": "A named profile cannot enable capabilities outside its captured deployment ceiling.",
15
15
  "blank-label": "The label is blank; the profile ID is used for display."
16
16
  };
17
- export const DEPRECATED_DSMM_FIELDS = ["deepseekV4ProMaxReasoningPresets", "deepseekFlashMaxReasoningPresets"];
17
+ export const DEPRECATED_DSMM_FIELDS = ["deepseekV4ProMaxReasoningPresets", "deepseekFlashMaxReasoningPresets", "deepseekV4ProCalibration", "deepseekV4ProDefaultReasoningEffort", "deepseekFlashCalibration", "deepseekFlashDefaultReasoningEffort"];
18
18
  function schemaFieldShape(schema) {
19
19
  if (schema.type === "transform")
20
20
  return schemaFieldShape(schema.inner);
@@ -36,7 +36,7 @@ const configFields = {
36
36
  locale: null, modeName: null, section: null, defaultActive: null, promptOrder: null,
37
37
  deepseekV4ProCalibration: null, deepseekV4ProDefaultReasoningEffort: null, deepseekFlashCalibration: null, deepseekFlashDefaultReasoningEffort: null,
38
38
  deepseekV4ProMaxReasoningPresets: null, deepseekFlashMaxReasoningPresets: null,
39
- modules: { deepwork: { enabled: null } }, sessionPersistence: { root: null, compression: null },
39
+ modules: { deepwork: { enabled: null } },
40
40
  skills: "skills", roles: "roles", roleRouting: "role-routing", runtimePolicy: { strategy: null, rateLimit },
41
41
  presets: { materialize: null, plannerRootEnabled: 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 },
@@ -4,6 +4,7 @@ import { parseModelParameterPolicy } from "./model-parameter-policy.js";
4
4
  import { DSMM_ROUTE_SOURCES } from "./profile-types.js";
5
5
  import { diagnostic, isSafeDiagnosticField, PROFILE_DIAGNOSTIC_REASONS } from "./profile-diagnostics.js";
6
6
  import { normalizeModelRouteJson } from "./route-json.js";
7
+ import { isConfigRevision, isProfileReference } from "./config-revision.js";
7
8
  const errorCodes = new Set(["validation", "conflict", "not-found", "lock-timeout", "unsafe-path", "io", "activation", "corrupt-selection", "limit", "busy", "maintenance", "disposed", "not-owned", "unavailable", "cancelled"]);
8
9
  const idPattern = /^[a-z0-9][a-z0-9_-]{0,63}$/u;
9
10
  const revisionPattern = /^[a-f0-9]{64}$/u;
@@ -26,11 +27,31 @@ function id(value) {
26
27
  return result;
27
28
  }
28
29
  function revision(value) {
29
- const result = text(value, "revision", 64);
30
- if (!revisionPattern.test(result))
30
+ const result = text(value, "revision", 128);
31
+ if (!isConfigRevision(result))
31
32
  fail("revision");
32
33
  return result;
33
34
  }
35
+ function epoch(value) {
36
+ if (typeof value !== "string" || !revisionPattern.test(value))
37
+ fail("epoch");
38
+ return value;
39
+ }
40
+ function reference(value) {
41
+ if (!isProfileReference(value))
42
+ fail("reference");
43
+ return value;
44
+ }
45
+ function modeRevision(value) {
46
+ if (typeof value !== "string" || !(/^(?:[a-f0-9]{64}|mode-v1-[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12})$/u).test(value))
47
+ fail("mode revision");
48
+ return value;
49
+ }
50
+ function refresh(value) { if (value !== true)
51
+ fail("refreshRequired"); return true; }
52
+ function observedRevision(value, row) {
53
+ return value === "unavailable" && row.refreshRequired === true ? value : selectionRevision(value);
54
+ }
34
55
  function selectionRevision(value) { return value === "absent" ? value : revision(value); }
35
56
  /** Opaque native identities are never interpreted as paths. */
36
57
  export function isNativeSessionId(value) {
@@ -134,16 +155,16 @@ function roleAvailabilityList(value) {
134
155
  }
135
156
  export function parseSubagentRuntimeAdmissionView(value) {
136
157
  const row = object(value, ["binding", "deliveryFenceReady", "restartRequired"], ["reason"]);
137
- if (typeof row.binding !== "string" || !["stock", "dsmm", "unavailable"].includes(row.binding) || row.reason !== undefined && (typeof row.reason !== "string" || !["explicit-composition-required", "duplicate-provider", "authority-not-ready"].includes(row.reason)))
158
+ if (typeof row.binding !== "string" || !["stock", "unavailable"].includes(row.binding) || row.reason !== undefined && row.reason !== "authority-not-ready")
138
159
  fail("subagentRuntime");
139
160
  const ready = boolean(row.deliveryFenceReady, "deliveryFenceReady");
140
- if (ready && (row.binding !== "dsmm" || row.reason !== undefined))
161
+ if (ready && (row.binding === "unavailable" || row.reason !== undefined))
141
162
  fail("subagentRuntime readiness");
142
163
  return { binding: row.binding, deliveryFenceReady: ready, restartRequired: boolean(row.restartRequired, "restartRequired"), ...(row.reason === undefined ? {} : { reason: row.reason }) };
143
164
  }
144
165
  function readResult(value) {
145
- const item = object(value, ["id", "revision", "content"], ["label", "warnings"]);
146
- return { id: id(item.id), revision: revision(item.revision), content: content(item.content), ...optional(item, "label", (input) => text(input, "label", 120)), ...optional(item, "warnings", warnings) };
166
+ const item = object(value, ["id", "revision", "content"], ["label", "warnings", "refreshRequired"]);
167
+ return { id: id(item.id), revision: item.revision === "unavailable" && item.refreshRequired === true ? "unavailable" : revision(item.revision), content: content(item.content), ...optional(item, "refreshRequired", refresh), ...optional(item, "label", (input) => text(input, "label", 120)), ...optional(item, "warnings", warnings) };
147
168
  }
148
169
  function content(value) {
149
170
  const result = text(value, "content", 128 * 1024);
@@ -152,7 +173,7 @@ function content(value) {
152
173
  return result;
153
174
  }
154
175
  function snapshot(value) {
155
- const item = object(value, ["profiles", "selectedId", "appliedRevision", "selectionRevision"], ["selectionError", "roles", "editorDefaults", "origin", "readOnly", "writeRestriction", "selectedWarnings"]);
176
+ const item = object(value, ["profiles", "selectedId", "appliedRevision", "selectionRevision"], ["selectionError", "roles", "editorDefaults", "origin", "readOnly", "writeRestriction", "selectedWarnings", "sourceRevision", "refreshRequired"]);
156
177
  if (!Array.isArray(item.profiles) || item.profiles.length > 128)
157
178
  fail("profiles");
158
179
  return {
@@ -161,8 +182,9 @@ function snapshot(value) {
161
182
  return { id: text(row.id, "id", 64), revision: row.revision === null ? null : revision(row.revision), ...optional(row, "label", (input) => text(input, "label", 120)), ...optional(row, "error", errorInfo), ...optional(row, "warnings", warnings) };
162
183
  }),
163
184
  selectedId: item.selectedId === null ? null : id(item.selectedId),
164
- appliedRevision: item.appliedRevision === null ? null : revision(item.appliedRevision),
165
- selectionRevision: item.selectionRevision === "unavailable" && Object.hasOwn(item, "selectionError") ? "unavailable" : selectionRevision(item.selectionRevision),
185
+ appliedRevision: item.appliedRevision === null ? null : reference(item.appliedRevision),
186
+ selectionRevision: item.selectionRevision === "unavailable" && Object.hasOwn(item, "selectionError") ? "unavailable" : observedRevision(item.selectionRevision, item),
187
+ ...optional(item, "sourceRevision", revision), ...optional(item, "refreshRequired", refresh),
166
188
  ...optional(item, "selectionError", errorInfo),
167
189
  ...optional(item, "selectedWarnings", warnings),
168
190
  ...optional(item, "roles", (input) => {
@@ -252,16 +274,28 @@ export function parseDsmmInvocationView(value) {
252
274
  return { role: target, label: text(row.label, "label", 120), level: row.level, routeSource: row.routeSource, mode: row.mode, ...optional(row, "route", modelRoute), ...optional(row, "runId", sessionId), ...optional(row, "childId", sessionId), ...optional(row, "jobId", sessionId), ...(routeComparison === undefined ? {} : { routeComparison }) };
253
275
  }
254
276
  function selectionState(value) {
255
- const item = object(value, ["selectedId", "appliedRevision", "selectionRevision"]);
256
- return { selectedId: item.selectedId === null ? null : id(item.selectedId), appliedRevision: item.appliedRevision === null ? null : revision(item.appliedRevision), selectionRevision: selectionRevision(item.selectionRevision) };
277
+ const item = object(value, ["selectedId", "appliedRevision", "selectionRevision"], ["sourceRevision", "refreshRequired"]);
278
+ return { selectedId: item.selectedId === null ? null : id(item.selectedId), appliedRevision: item.appliedRevision === null ? null : reference(item.appliedRevision), selectionRevision: observedRevision(item.selectionRevision, item), ...optional(item, "sourceRevision", revision), ...optional(item, "refreshRequired", refresh) };
279
+ }
280
+ function actionUnavailableReason(value) {
281
+ if (typeof value !== "string" || !["busy", "maintenance", "module-off", "runtime-unavailable", "model-unconfigured", "model-service-unavailable", "new-session-required"].includes(value))
282
+ fail("actionUnavailableReason");
283
+ return value;
257
284
  }
258
285
  function sessionSnapshot(value) {
259
- const item = object(value, ["sessionId", "globalDefault", "selection", "scope", "admissionEpoch", "switchAllowed"], ["admittedSelection", "switchUnavailableReason", "rolePolicy", "profileModel", "deepwork", "modules", "configuration", "warnings", "roles", "subagentRuntime"]);
286
+ const item = object(value, ["sessionId", "globalDefault", "selection", "scope", "admissionEpoch", "switchAllowed", "canSelectModel", "canToggleMode", "canApplyOverlay"], ["admittedSelection", "switchUnavailableReason", "selectModelUnavailableReason", "toggleModeUnavailableReason", "applyOverlayUnavailableReason", "rolePolicy", "profileModel", "deepwork", "modules", "configuration", "warnings", "roles", "subagentRuntime", "refreshRequired"]);
260
287
  if (typeof item.scope !== "string" || !["global-default", "session-override", "deployment-baseline"].includes(item.scope))
261
288
  fail("scope");
262
289
  return {
263
290
  sessionId: sessionId(item.sessionId), globalDefault: selectionState(item.globalDefault), selection: selectionState(item.selection),
264
- scope: item.scope, admissionEpoch: revision(item.admissionEpoch), switchAllowed: boolean(item.switchAllowed, "switchAllowed"),
291
+ scope: item.scope, admissionEpoch: epoch(item.admissionEpoch), switchAllowed: boolean(item.switchAllowed, "switchAllowed"),
292
+ canSelectModel: boolean(item.canSelectModel, "canSelectModel"),
293
+ canToggleMode: boolean(item.canToggleMode, "canToggleMode"),
294
+ canApplyOverlay: boolean(item.canApplyOverlay, "canApplyOverlay"),
295
+ ...optional(item, "selectModelUnavailableReason", actionUnavailableReason),
296
+ ...optional(item, "toggleModeUnavailableReason", actionUnavailableReason),
297
+ ...optional(item, "applyOverlayUnavailableReason", actionUnavailableReason),
298
+ ...optional(item, "refreshRequired", refresh),
265
299
  ...optional(item, "admittedSelection", selectionState),
266
300
  ...optional(item, "switchUnavailableReason", (input) => {
267
301
  if (typeof input !== "string" || !["busy", "maintenance", "disposed", "not-owned", "unavailable"].includes(input))
@@ -277,7 +311,7 @@ function sessionSnapshot(value) {
277
311
  ...optional(item, "subagentRuntime", parseSubagentRuntimeAdmissionView),
278
312
  ...optional(item, "deepwork", (input) => {
279
313
  const mode = object(input, ["active", "explicit", "locked", "revision"]);
280
- return { active: boolean(mode.active, "active"), explicit: boolean(mode.explicit, "explicit"), locked: boolean(mode.locked, "locked"), revision: revision(mode.revision) };
314
+ return { active: boolean(mode.active, "active"), explicit: boolean(mode.explicit, "explicit"), locked: boolean(mode.locked, "locked"), revision: modeRevision(mode.revision) };
281
315
  }),
282
316
  };
283
317
  }
@@ -297,11 +331,11 @@ function selectRequest(value) {
297
331
  function sessionSelectRequest(value) {
298
332
  const item = object(value, ["sessionId", "id", "expectedSelectionRevision", "expectedAdmissionEpoch"], ["expectedRevision"]);
299
333
  const { sessionId: inputSessionId, expectedAdmissionEpoch, ...profileRequest } = item;
300
- return { ...selectRequest(profileRequest), sessionId: sessionId(inputSessionId), expectedAdmissionEpoch: revision(expectedAdmissionEpoch) };
334
+ return { ...selectRequest(profileRequest), sessionId: sessionId(inputSessionId), expectedAdmissionEpoch: epoch(expectedAdmissionEpoch) };
301
335
  }
302
336
  function modeSelectRequest(value) {
303
337
  const item = object(value, ["sessionId", "active", "expectedModeRevision", "expectedAdmissionEpoch"]);
304
- return { sessionId: sessionId(item.sessionId), active: boolean(item.active, "active"), expectedModeRevision: revision(item.expectedModeRevision), expectedAdmissionEpoch: revision(item.expectedAdmissionEpoch) };
338
+ return { sessionId: sessionId(item.sessionId), active: boolean(item.active, "active"), expectedModeRevision: modeRevision(item.expectedModeRevision), expectedAdmissionEpoch: epoch(item.expectedAdmissionEpoch) };
305
339
  }
306
340
  function codec(symbol, parse) {
307
341
  return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: value => parse(jsonData(value)) }) };
@@ -341,9 +375,9 @@ function jsonData(value, depth = 0, active = new Set()) {
341
375
  return result;
342
376
  }
343
377
  function globalSnapshot(value) {
344
- const row = object(value, ["config", "revision"]);
378
+ const row = object(value, ["config", "revision"], ["refreshRequired"]);
345
379
  object(row.config, [], Object.keys(row.config));
346
- return { config: jsonData(row.config), revision: selectionRevision(row.revision) };
380
+ return { config: jsonData(row.config), revision: observedRevision(row.revision, row), ...optional(row, "refreshRequired", refresh) };
347
381
  }
348
382
  function admissionView(value) {
349
383
  const row = object(value, ["settings", "sources", "captures", "restartRequired", "named"], ["modelParameterPolicy"]);
@@ -361,7 +395,7 @@ function admissionView(value) {
361
395
  const named = row.named === null ? null : object(row.named, ["id", "revision"]);
362
396
  return { ...optional(row, "modelParameterPolicy", value => parseModelParameterPolicy(jsonData(value))), settings: readOnlySettingsData(row.settings), sources: jsonData(row.sources),
363
397
  captures: jsonData(row.captures), restartRequired: row.restartRequired.map(value => text(value, "field", 256)),
364
- named: named === null ? null : { id: id(named.id), revision: revision(named.revision) } };
398
+ named: named === null ? null : { id: id(named.id), revision: reference(named.revision) } };
365
399
  }
366
400
  function readOnlySettingsData(value) {
367
401
  const settings = jsonData(value);
@@ -393,14 +427,15 @@ function readOnlySettingsData(value) {
393
427
  return settings;
394
428
  }
395
429
  function editorSnapshot(value) {
396
- const row = object(value, ["entryId", "namespace", "hostProfileKey", "global", "globalRevision", "profile", "nativeRevision", "nativeFormRevision", "nativeForm", "desired", "sources", "startup", "defaults", "schema", "nextRoot", "modules"], ["startupSources"]);
430
+ const row = object(value, ["entryId", "namespace", "hostProfileKey", "global", "globalRevision", "profile", "nativeRevision", "nativeFormRevision", "nativeForm", "desired", "sources", "startup", "defaults", "schema", "nextRoot", "modules"], ["startupSources", "nativeSchema", "subagentRuntime"]);
397
431
  const result = jsonData(row);
398
432
  text(row.entryId, "entryId", 256);
399
433
  if (row.namespace !== null)
400
434
  text(row.namespace, "namespace", 256);
401
- revision(row.hostProfileKey);
435
+ epoch(row.hostProfileKey);
402
436
  selectionRevision(row.globalRevision);
403
- revision(row.nativeRevision);
437
+ if (row.nativeRevision !== "unavailable" && (typeof row.nativeRevision !== "string" || !/^native-v1-\d+$/u.test(row.nativeRevision)))
438
+ fail("nativeRevision");
404
439
  if (row.nativeFormRevision !== null)
405
440
  integer(row.nativeFormRevision, "nativeFormRevision");
406
441
  for (const key of ["global", "profile", "desired", "sources", "startup", "defaults", "schema"])
@@ -412,6 +447,10 @@ function editorSnapshot(value) {
412
447
  result.desired = readOnlySettingsData(row.desired);
413
448
  result.startup = readOnlySettingsData(row.startup);
414
449
  result.schema = schemaNode(row.schema);
450
+ if (row.nativeSchema !== undefined)
451
+ result.nativeSchema = schemaNode(row.nativeSchema);
452
+ if (row.subagentRuntime !== undefined)
453
+ result.subagentRuntime = parseSubagentRuntimeAdmissionView(row.subagentRuntime);
415
454
  for (const map of [result.sources, result.startupSources]) {
416
455
  if (map === undefined)
417
456
  continue;
@@ -10,8 +10,8 @@ import type { DsmmProfileRuntime } from "./profile-runtime.js";
10
10
  export interface ProfilesBackend {
11
11
  describe(): Promise<ProfileSnapshot>;
12
12
  read(id: string): Promise<ProfileReadResult>;
13
- save(request: ProfileSaveRequest): Promise<ProfileReadResult>;
14
- select(request: ProfileSelectRequest): Promise<ProfileSnapshot>;
13
+ save(request: ProfileSaveRequest, assertAuthority?: () => void): Promise<ProfileReadResult>;
14
+ select(request: ProfileSelectRequest, assertAuthority?: () => void): Promise<ProfileSnapshot>;
15
15
  getSession(agent: DshAgent): Promise<SessionProfileSnapshot>;
16
16
  selectSession(request: SessionProfileSelectRequest, capturedAgent: DshAgent, signal?: AbortSignal, assertAuthority?: () => void): Promise<SessionProfileSnapshot>;
17
17
  selectMode?(request: SessionModeSelectRequest, capturedAgent: DshAgent, signal?: AbortSignal, assertAuthority?: () => void): Promise<SessionProfileSnapshot>;
@@ -22,11 +22,12 @@ export declare class DsmmProfilesHost extends TypertRemoteService {
22
22
  private readonly lifetime;
23
23
  constructor(ctx: Context, backend: ProfilesBackend);
24
24
  private invoke;
25
+ private captureAuthority;
25
26
  describe(): Promise<ProfileSnapshot>;
26
27
  read(id: string): Promise<ProfileReadResult>;
27
28
  save(request: ProfileSaveRequest): Promise<ProfileReadResult>;
28
29
  select(request: ProfileSelectRequest): Promise<ProfileSnapshot>;
29
- /** Native Connection's exact operator is authority, not a claimed Peer ID. */
30
+ /** Native Connection's exact browser Peer is authority, not a claimed Peer ID. */
30
31
  private invokeSession;
31
32
  describeSession(sessionId: string): Promise<SessionProfileSnapshot>;
32
33
  selectSession(sessionId: string, request: SessionProfileSelectRequest): Promise<SessionProfileSnapshot>;
@@ -33,12 +33,12 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
33
33
  done = true;
34
34
  };
35
35
  import { symbols } from "@deepseek-ai/cordis";
36
- import { Remote, RemoteError, TypertRemoteService, remoteErrorOf } from "@deepseek-ai/dsh-typert-protocol";
37
- import { SessionId } from "@deepseek-ai/dsh-session";
36
+ import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
38
37
  import { parseProfileErrorInfo, TYPERT_HOST } from "./profile-remote.js";
39
38
  import { DsmmProfileError, profileErrorInfo } from "./profiles.js";
40
39
  import { projectDsmmModules } from "./modules.js";
41
40
  import { DEFAULT_DSMM_SETTINGS, deploymentEditorSchema } from "./settings.js";
41
+ import { runtimeAdmissionView } from "./runtime-integration.js";
42
42
  import { readOnlySettings, readOnlySettingSources } from "./status.js";
43
43
  /** Business service addressed only by native Typert Gateway invocations. */
44
44
  let DsmmProfilesHost = (() => {
@@ -91,11 +91,33 @@ let DsmmProfilesHost = (() => {
91
91
  throw new RemoteError("dsmm-profiles/refused", "The Host refused the profile operation.", parseProfileErrorInfo(profileErrorInfo(error)));
92
92
  }
93
93
  }
94
+ captureAuthority() {
95
+ assertLocalSettingsOperator(this.ctx);
96
+ const invocation = this.ctx.invocation;
97
+ const connection = this.ctx.get("connection");
98
+ const owner = Reflect.get(connection, symbols.original) ?? connection;
99
+ const signal = AbortSignal.any([invocation.signal, invocation.peer.signal, this.lifetime.signal]);
100
+ const assertAuthority = () => {
101
+ if (signal.aborted)
102
+ throw new DsmmProfileError("cancelled", "The profile operation was cancelled before commit.");
103
+ assertLocalSettingsOperator(this.ctx);
104
+ const current = this.ctx.get("connection");
105
+ if ((Reflect.get(current, symbols.original) ?? current) !== owner || current.browserPeer !== invocation.peer) {
106
+ throw new DsmmProfileError("not-owned", "The operator connection changed before committing the profile operation.");
107
+ }
108
+ };
109
+ assertAuthority();
110
+ return assertAuthority;
111
+ }
94
112
  describe() { return this.invoke(() => this.backend.describe()); }
95
113
  read(id) { return this.invoke(() => this.backend.read(id)); }
96
- save(request) { return this.invoke(() => this.backend.save(request)); }
97
- select(request) { return this.invoke(() => this.backend.select(request)); }
98
- /** Native Connection's exact operator is authority, not a claimed Peer ID. */
114
+ save(request) {
115
+ return this.invoke(() => this.backend.save(request, this.captureAuthority()));
116
+ }
117
+ select(request) {
118
+ return this.invoke(() => this.backend.select(request, this.captureAuthority()));
119
+ }
120
+ /** Native Connection's exact browser Peer is authority, not a claimed Peer ID. */
99
121
  async invokeSession(sessionId, operation, readOnly = false) {
100
122
  return this.invoke(async () => {
101
123
  const invocation = this.ctx.invocation;
@@ -122,36 +144,9 @@ let DsmmProfilesHost = (() => {
122
144
  return agents;
123
145
  };
124
146
  let agents = checkAuthority();
125
- let captured = agents.get(sessionId);
126
- if (captured === undefined) {
127
- // Gateway lookups run before invocation authentication. Resolve here,
128
- // after full strict JSON decoding and operator admission, so invalid or
129
- // unauthorized calls cannot cold-resume a native session as a side effect.
130
- const controller = this.ctx.get("sessionController");
131
- if (controller === undefined || typeof controller.resolveAgent !== "function") {
132
- throw new DsmmProfileError("unavailable", "The native ordinary-session resume service is unavailable.");
133
- }
134
- let found;
135
- try {
136
- found = await controller.resolveAgent(SessionId(sessionId));
137
- }
138
- catch {
139
- checkAuthority();
140
- throw new DsmmProfileError("unavailable", "The native session could not be safely resumed.", "sessionId");
141
- }
142
- agents = checkAuthority();
143
- if ("error" in found) {
144
- const code = remoteErrorOf(found.error)?.code;
145
- if (code === "session/not-found")
146
- throw new DsmmProfileError("not-found", "The native session was not found.", "sessionId");
147
- if (code === "session/agent-busy")
148
- throw new DsmmProfileError("not-owned", "Subagent-owned sessions cannot select a root profile.", "sessionId");
149
- if (code === "session/writer-held")
150
- throw new DsmmProfileError("busy", "The native session is owned by another active writer.", "sessionId");
151
- throw new DsmmProfileError("unavailable", "The native session could not be safely resumed.", "sessionId");
152
- }
153
- captured = found.agent;
154
- }
147
+ const captured = agents.get(sessionId);
148
+ if (captured === undefined)
149
+ throw new DsmmProfileError("unavailable", "Session admission is unknown; read-only configuration queries never resume history.", "sessionId");
155
150
  const agent = captured;
156
151
  const checkCaptured = () => {
157
152
  const current = checkAuthority();
@@ -267,12 +262,13 @@ let DsmmConfigHost = (() => {
267
262
  const runtime = this.runtime?.() ?? this.ctx.get("dsmmProfileRuntime");
268
263
  return { entryId: desired.entryId, namespace: desired.nativeNamespace ?? null, hostProfileKey: desired.hostProfileKey,
269
264
  global: desired.global, globalRevision: desired.globalRevision,
270
- profile: desired.profile, nativeRevision: desired.nativeRevision,
265
+ profile: { ...desired.profile }, nativeRevision: desired.nativeRevision,
271
266
  nativeFormRevision: desired.nativeFormRevision ?? null, nativeForm: desired.nativeForm === undefined ? null : { base: desired.nativeForm.base ?? null, user: desired.nativeForm.user ?? null },
272
267
  desired: { ...readOnlySettings(desired.settings) }, sources: readOnlySettingSources(desired.sources),
273
268
  startup: { ...readOnlySettings(this.startup) }, defaults: DEFAULT_DSMM_SETTINGS,
274
269
  ...(this.startupSources === undefined ? {} : { startupSources: readOnlySettingSources(this.startupSources) }),
275
- schema: deploymentEditorSchema(), nextRoot: runtime?.previewDeployment(desired) ?? null,
270
+ schema: deploymentEditorSchema(), nativeSchema: deploymentEditorSchema(true),
271
+ subagentRuntime: runtimeAdmissionView(this.ctx), nextRoot: runtime?.previewDeployment(desired) ?? null,
276
272
  modules: projectDsmmModules(this.startup, desired, undefined, true, this.getMountedPermission) };
277
273
  }
278
274
  catch (error) {
@@ -1,131 +1,88 @@
1
1
  import type { DshAgent, DshContext } from "./dsh-types.js";
2
- import type { LoadedProfileSelection, LoadedSessionProfileSelection, SessionProfileCommit } from "./profile-store.js";
3
- import type { ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSelectionState, ProfileSnapshot, SessionModeSelectRequest, SessionProfileSelectRequest, SessionProfileSnapshot } from "./profile-types.js";
2
+ import type { LoadedProfileSelection, LoadedSessionProfileSelection, ProfileCommit, SessionProfileCommit } from "./profile-store.js";
3
+ import type { ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSelectionState, ProfileSnapshot, SessionModeSelectRequest, SessionProfileSelectRequest, SessionProfileSnapshot, DeploymentAdmissionView, SubagentRuntimeAdmissionView } from "./profile-types.js";
4
4
  import type { DsmmProfileDocument } from "./profiles.js";
5
- import type { DsmmProfileAdmission, DsmmSettings, DsmmSettingsGetter } from "./settings.js";
5
+ import type { DsmmProfileAdmission, DsmmSettings, DsmmSettingsGetter, DsmmDeploymentSnapshot } from "./settings.js";
6
6
  import { DeepworkModeController } from "./state.js";
7
- import type { DsmmDeploymentSnapshot } from "./settings.js";
8
7
  import type { DsmmMountedPermissionGetter } from "./modules.js";
9
- import type { DeploymentAdmissionView } from "./profile-types.js";
10
- import type { ChildAdmissionCompletion, DsmmChildAdmissionAuthority, LegacyChildEvidenceReader, ParentAdmissionTicket } from "./child-admission-contract.js";
11
- import type { ChildAdmissionCapture, ChildAdmissionEvidence, PreparedChildAdmission } from "./child-capture.js";
12
8
  export interface DsmmProfileRuntimeStore {
13
- createChildAdmission?(capture: ChildAdmissionCapture, assertCurrent?: () => void): Promise<ChildAdmissionCapture>;
14
- readChildAdmission?(childId: string, parentId: string): Promise<ChildAdmissionCapture | null>;
15
- deleteChildAdmission?(childId: string, parentId: string): Promise<void>;
16
9
  readonly readOnly?: boolean;
17
10
  readonly origin?: "central" | "legacy" | "explicit";
18
11
  readonly writeRestriction?: string;
19
12
  loadSelection(): Promise<LoadedProfileSelection>;
20
13
  describe(): Promise<ProfileSnapshot>;
21
14
  read(id: string): Promise<ProfileReadResult>;
22
- save(request: ProfileSaveRequest): Promise<ProfileReadResult>;
23
- select<T>(request: ProfileSelectRequest, validateCandidate: (document: DsmmProfileDocument | null) => T | Promise<T>): Promise<{
15
+ save(request: ProfileSaveRequest, assertCurrent?: () => void): Promise<ProfileReadResult>;
16
+ select<T>(request: ProfileSelectRequest, validate: (document: DsmmProfileDocument | null) => T | Promise<T>, commit?: ProfileCommit<T>, assertCurrent?: () => void): Promise<{
24
17
  selection: ProfileSelectionState;
25
18
  prepared: T;
26
19
  }>;
27
- loadSessionSelection(sessionId: string): Promise<LoadedSessionProfileSelection>;
28
- selectSession<T>(request: SessionProfileSelectRequest, epoch: string, validateCandidate: (document: DsmmProfileDocument | null) => T | Promise<T>, commit: SessionProfileCommit<T>): Promise<{
20
+ loadSessionSelection(id: string): Promise<LoadedSessionProfileSelection>;
21
+ selectSession<T>(request: SessionProfileSelectRequest, epoch: string, validate: (document: DsmmProfileDocument | null) => T | Promise<T>, commit: SessionProfileCommit<T>): Promise<{
29
22
  selection: LoadedSessionProfileSelection;
30
23
  prepared: T;
31
24
  }>;
32
25
  }
33
26
  export interface DsmmProfileRuntimeOptions {
34
- /** Separate Host-owned central sidecars keep legacy profile libraries read-only. */
35
- childCaptureStore?: Pick<DsmmProfileRuntimeStore, "createChildAdmission" | "readChildAdmission" | "deleteChildAdmission">;
36
- childAuthority?: DsmmChildAdmissionAuthority;
37
- /** Exact entry identity bound by the stable Host authority; never wire input. */
38
- childAuthorityOwner?: object;
39
- childAdmission?: ChildAdmissionCompletion;
40
- /** Pure role/ceiling validation before awaited candidate checks and before commit; never publishes identity or authority. */
41
- validateRootRole?: (agent: DshAgent, admission: DsmmProfileAdmission) => void;
42
- /** Host session substrate decides this; resident mode makes no restart claim. */
43
- childCapturePersistence?: "durable" | "resident";
44
- /** Parent composition may enable its bound policy after guards exist, before retained Agents are admitted. */
45
- onAdmissionGuardsInstalled?: (runtime: DsmmProfileRuntime) => void | Promise<void>;
46
- /** Core startup admits roots first; the Host DW continuation completes retained controlled children. */
47
- deferRetainedChildren?: boolean;
48
- /** Trusted test/integration seam, never a wire-supplied path or callback. */
27
+ runtimeView?: () => SubagentRuntimeAdmissionView;
49
28
  validateCandidate?: (settings: DsmmSettings) => void | Promise<void>;
50
29
  modeController?: DeepworkModeController;
51
- /** Awaited once per new ordinary root; never used by children or idle switches. */
52
30
  readDesired?: () => Promise<DsmmDeploymentSnapshot>;
53
31
  startup?: DsmmDeploymentSnapshot;
54
- /** Read the current live Host controller's mounted status; unknown/retired is null. */
55
32
  getMountedPermission?: DsmmMountedPermissionGetter;
56
- /** Frozen actual native startup substrate; omission is the trusted legacy seam. */
57
- subagentCapabilities?: {
58
- backgroundJobs: boolean;
59
- continuable: boolean;
60
- };
61
33
  }
34
+ export type DsmmSessionActionUnavailableReason = import("./profile-types.js").SessionActionUnavailableReason;
35
+ export type DsmmSessionProfileSnapshot = SessionProfileSnapshot;
62
36
  interface AdmittedProfile extends ProfileSelectionState, DsmmProfileAdmission {
63
37
  baseline: DsmmSettings;
64
38
  }
65
- /** Global defaults admit new roots; scoped idle switches replace one root's epoch. */
39
+ /** Configuration transactions and immutable snapshots; native admission owns Agent binding. */
66
40
  export declare class DsmmProfileRuntime {
67
41
  private readonly ctx;
68
42
  private readonly store;
69
43
  private readonly options;
70
- readonly childCaptureStore: Pick<DsmmProfileRuntimeStore, "createChildAdmission" | "readChildAdmission" | "deleteChildAdmission">;
71
44
  readonly getSettings: DsmmSettingsGetter;
72
- private current;
73
- private currentDocument;
74
45
  private readonly baseline;
46
+ private current;
47
+ private document;
75
48
  private readonly bound;
76
- private readonly admitting;
77
- private readonly disposedAgents;
78
- private readonly switching;
79
- private readonly admissionObservers;
49
+ private readonly observations;
80
50
  private disposed;
81
- private selectionQueue;
51
+ private queue;
82
52
  private readonly mode;
83
53
  constructor(ctx: DshContext, baseline: DsmmSettings, store: DsmmProfileRuntimeStore, options?: DsmmProfileRuntimeOptions);
84
54
  initialize(): Promise<void>;
55
+ private assertCurrent;
85
56
  admission(agent?: DshAgent): AdmittedProfile;
86
- /** Host enrollment observes completed exact admissions, never an entered but unpublished policy. */
87
57
  hasAdmission(agent: DshAgent): boolean;
88
- observeAdmissions(observer: (agent: DshAgent) => void | Promise<void>): () => void;
89
- private announceAdmission;
90
- getSession(agent: DshAgent): Promise<SessionProfileSnapshot>;
91
- /** The fourth argument is trusted native caller authority, never wire data. */
92
- selectMode(request: SessionModeSelectRequest, agent: DshAgent, signal?: AbortSignal, assertAuthority?: () => void): Promise<SessionProfileSnapshot>;
93
- selectSession(request: SessionProfileSelectRequest, agent: DshAgent, signal?: AbortSignal, assertAuthority?: () => void): Promise<SessionProfileSnapshot>;
58
+ /** Called only by the awaited native creation owner after all Agent-scoped installation. */
59
+ publish(agent: DshAgent, admission: DsmmProfileAdmission): void;
60
+ release(agent: DshAgent): void;
61
+ prepareRoot(agent: DshAgent, signal: AbortSignal): Promise<AdmittedProfile>;
62
+ getSession(agent: DshAgent): Promise<DsmmSessionProfileSnapshot>;
63
+ selectMode(request: SessionModeSelectRequest, agent: DshAgent, signal?: AbortSignal, authority?: () => void): Promise<DsmmSessionProfileSnapshot>;
64
+ selectSession(_request: SessionProfileSelectRequest, agent: DshAgent, _signal?: AbortSignal, _authority?: () => void): Promise<SessionProfileSnapshot>;
65
+ private assertRoot;
94
66
  describe(): Promise<ProfileSnapshot>;
95
67
  read(id: string): Promise<ProfileReadResult>;
96
- save(request: ProfileSaveRequest): Promise<ProfileReadResult>;
68
+ save(request: ProfileSaveRequest, authority?: () => void): Promise<ProfileReadResult>;
97
69
  getStartupSettings(): DsmmSettings;
98
- /** Preview uses the admission path but neither binds nor creates an Agent. */
99
70
  previewDeployment(desired: DsmmDeploymentSnapshot): DeploymentAdmissionView;
100
71
  describeDeployment(agent?: DshAgent): Promise<{
101
72
  startup: DsmmDeploymentSnapshot | null;
102
73
  desired: DsmmDeploymentSnapshot | null;
103
- admission: DsmmProfileAdmission;
74
+ admission: AdmittedProfile | null;
104
75
  }>;
105
- select(request: ProfileSelectRequest): Promise<ProfileSnapshot>;
76
+ select(request: ProfileSelectRequest, authority?: () => void): Promise<ProfileSnapshot>;
106
77
  private prepare;
107
78
  private profileAdmission;
108
- private declaredProfileModel;
109
- private agents;
110
- private bind;
111
- private owner;
112
- private assertRoot;
113
- /** Host-only awaited completion for fresh, retained and cold exact Agents; no execution occurs here. */
114
- completeAdmission(agent: DshAgent, signal?: AbortSignal, startup?: DsmmDeploymentSnapshot): Promise<DsmmProfileAdmission>;
115
- private admit;
116
- /** Awaited native creation completion: evidence + persistence + role identity + exact-parent authority. */
117
- completeChildAdmission(agent: DshAgent, parent: DshAgent, prepared: PreparedChildAdmission, signal?: AbortSignal): Promise<void>;
118
- /** C's scoped resolver callback: original resident/durable evidence, then explicit trusted legacy folds. */
119
- resolveOriginalChildEvidence(ticket: ParentAdmissionTicket, childId: string, signal: AbortSignal, readLegacy?: LegacyChildEvidenceReader): Promise<ChildAdmissionEvidence>;
120
- private assertOwnedParentTicket;
121
- private subagentRuntimeView;
122
- private assertDeliveryFence;
123
- private assertRootRole;
124
- private validateRootRole;
125
79
  private roleAvailability;
80
+ private editorRoles;
81
+ private sessionActions;
126
82
  private validate;
83
+ private observedSelection;
84
+ private runtimeView;
127
85
  }
128
- /** No guessed home fallback: native deployment context owns this directory. */
129
86
  export declare function createProfileRuntime(ctx: DshContext, baseline: DsmmSettings, options?: DsmmProfileRuntimeOptions): Promise<DsmmProfileRuntime>;
130
87
  export {};
131
88
  //# sourceMappingURL=profile-runtime.d.ts.map