@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,69 +1,39 @@
1
- import Schema from "@deepseek-ai/schemastery";
2
1
  import { getTraceable } from "@deepseek-ai/cordis";
3
- import { DSMM_SKILL_NAMES, registerBundledSkills } from "./skills.js";
2
+ import { registerBundledSkills } from "./skills.js";
4
3
  import { nativeAgentContext, scopeParentOf } from "./native-scope.js";
5
- export const name = "dsmm/preset-skills";
6
- export const inject = [];
7
- const SKILL_NAME_SCHEMA = Schema.union(DSMM_SKILL_NAMES.map((name) => Schema.const(name)));
8
- export const Config = Schema.object({
9
- skills: Schema.array(SKILL_NAME_SCHEMA).default([...DSMM_SKILL_NAMES])
10
- });
11
- export function apply(ctx, config = {}) {
12
- // Retain the published 0.1.9 Cordis entry shape for older callers. Current
13
- // generated presets do not consume it; this hook registers no skills.
14
- // The main entry calls registerAgentSkills below for real Agent mounts.
15
- }
16
- export function registerAgentSkills(ctx, controller, getSettings) {
17
- const mounted = new Map();
18
- const remove = (agent) => { mounted.get(agent)?.provider.dispose(); mounted.delete(agent); };
19
- const reconcile = (agent) => {
20
- const agentCtx = nativeAgentContext(agent);
21
- const presets = ctx.get?.("agentPresets");
22
- const raw = presets?.serviceFor(agent, "skills") ?? agentCtx.get("skills");
23
- const previous = mounted.get(agent), parent = scopeParentOf(agent);
24
- const settings = getSettings(agent);
4
+ const bindings = new WeakMap();
5
+ /** Admission owns installation; mode changes only invalidate this Agent's lazy provider. */
6
+ export function registerAgentSkills(ctx, controller, getSettings, agent, lifetime) {
7
+ const refresh = bindings.get(agent);
8
+ if (refresh) {
9
+ refresh();
10
+ return;
11
+ }
12
+ let mounted;
13
+ const remove = () => { mounted?.provider.dispose(); mounted = undefined; };
14
+ const reconcile = () => {
15
+ const agentCtx = nativeAgentContext(agent), settings = getSettings(agent);
25
16
  if (!settings.modules.deepwork.enabled || !controller.active(agent, settings.defaultActive)) {
26
- remove(agent);
17
+ remove();
27
18
  return;
28
19
  }
20
+ const presets = ctx.get?.("agentPresets");
21
+ const raw = presets?.serviceFor(agent, "skills") ?? agentCtx.get("skills"), parent = scopeParentOf(agent);
29
22
  if (raw === undefined)
30
- throw new Error("dsmm active skills require the native skill registry; no prompt-body fallback is available");
31
- if (previous?.parent === parent && previous?.registry === raw) {
32
- previous.provider.invalidate();
23
+ throw new Error("Active skills require the native skill registry");
24
+ if (mounted?.parent === parent && mounted?.registry === raw) {
25
+ mounted.provider.invalidate();
33
26
  return;
34
27
  }
35
- remove(agent);
36
- const registry = getTraceable(agentCtx, raw);
37
- const provider = registerBundledSkills(agentCtx, registry, { agent, controller, getSettings });
38
- mounted.set(agent, { parent, registry: raw, provider });
28
+ remove();
29
+ mounted = { parent, registry: raw, provider: registerBundledSkills(agentCtx, getTraceable(agentCtx, raw), { agent, controller, getSettings }) };
39
30
  };
40
- const stopMode = controller.watch(reconcile);
41
- const created = ctx.on?.("agent/created", ({ agent }) => reconcile(agent), { global: true });
42
- const selected = ctx.on?.("agent-preset/selected", (id) => {
43
- const agent = ctx.get?.("agents")?.get(id);
44
- if (agent !== undefined) {
45
- remove(agent);
46
- reconcile(agent);
47
- }
48
- }, { global: true });
49
- const disposed = ctx.on?.("agent/disposed", ({ agent }) => remove(agent), { global: true });
50
- const modeEvent = ctx.on?.("session/event", (session, event) => {
51
- if (event.type !== "deepwork/mode")
52
- return;
53
- const agent = ctx.get?.("agents")?.list().find((agent) => agent.session === session);
54
- if (agent !== undefined)
55
- reconcile(agent);
56
- }, { global: true });
57
- ctx.effect?.(() => () => {
58
- stopMode();
59
- for (const stop of [created, selected, disposed, modeEvent])
60
- if (typeof stop === "function")
61
- stop();
62
- for (const agent of [...mounted.keys()])
63
- remove(agent);
64
- });
65
- for (const agent of ctx.get?.("agents")?.list() ?? [])
66
- reconcile(agent);
31
+ const stopMode = controller.watch(changed => { if (changed === agent)
32
+ reconcile(); });
33
+ bindings.set(agent, reconcile);
34
+ const dispose = () => { stopMode(); remove(); bindings.delete(agent); lifetime.removeEventListener("abort", dispose); };
35
+ lifetime.addEventListener("abort", dispose, { once: true });
36
+ ctx.effect?.(() => dispose);
37
+ reconcile();
67
38
  }
68
- export default apply;
69
39
  //# sourceMappingURL=preset-skills.js.map
@@ -26,7 +26,7 @@ export interface ProfileDiagnostic {
26
26
  reason: string;
27
27
  location?: ProfileDiagnosticLocation;
28
28
  }
29
- export declare const DEPRECATED_DSMM_FIELDS: readonly ["deepseekV4ProMaxReasoningPresets", "deepseekFlashMaxReasoningPresets"];
29
+ export declare const DEPRECATED_DSMM_FIELDS: readonly ["deepseekV4ProMaxReasoningPresets", "deepseekFlashMaxReasoningPresets", "deepseekV4ProCalibration", "deepseekV4ProDefaultReasoningEffort", "deepseekFlashCalibration", "deepseekFlashDefaultReasoningEffort"];
30
30
  /** Host parser location provenance only; never serialized on an error or DTO. */
31
31
  export declare function diagnosticSourcePath(error: object): readonly (string | number)[] | undefined;
32
32
  export declare function safeDiagnosticField(parts: readonly (string | number)[]): string;
@@ -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 = (() => {
@@ -83,6 +83,7 @@ let DsmmProfilesHost = (() => {
83
83
  throw new RemoteError("dsmm-profiles/peer-required", "Use Deepwork Profiles through the native Host connection.", {});
84
84
  }
85
85
  invocation.signal.throwIfAborted();
86
+ invocation.peer.signal.throwIfAborted();
86
87
  try {
87
88
  return await operation();
88
89
  }
@@ -90,28 +91,50 @@ let DsmmProfilesHost = (() => {
90
91
  throw new RemoteError("dsmm-profiles/refused", "The Host refused the profile operation.", parseProfileErrorInfo(profileErrorInfo(error)));
91
92
  }
92
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
+ }
93
112
  describe() { return this.invoke(() => this.backend.describe()); }
94
113
  read(id) { return this.invoke(() => this.backend.read(id)); }
95
- save(request) { return this.invoke(() => this.backend.save(request)); }
96
- select(request) { return this.invoke(() => this.backend.select(request)); }
97
- /** 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. */
98
121
  async invokeSession(sessionId, operation, readOnly = false) {
99
122
  return this.invoke(async () => {
100
123
  const invocation = this.ctx.invocation;
101
124
  const connection = this.ctx.get("connection");
102
- if (connection === undefined || connection.operator !== invocation.peer) {
125
+ if (connection === undefined || connection.browserPeer !== invocation.peer) {
103
126
  throw new DsmmProfileError("not-owned", "The native Host operator must own this session profile operation.");
104
127
  }
105
128
  // Cordis rebinds Service projections for each accessing Context. Its
106
129
  // public original symbol identifies the exact native authority owner.
107
130
  const connectionOwner = Reflect.get(connection, symbols.original) ?? connection;
108
- const signal = AbortSignal.any([invocation.signal, this.lifetime.signal]);
131
+ const signal = AbortSignal.any([invocation.signal, connection.browserPeer.signal, this.lifetime.signal]);
109
132
  const checkAuthority = () => {
110
133
  if (signal.aborted)
111
134
  throw new DsmmProfileError("cancelled", "The session profile operation was cancelled; no late selection is allowed.");
112
135
  const currentConnection = this.ctx.get("connection");
113
136
  const currentOwner = currentConnection === undefined ? undefined : Reflect.get(currentConnection, symbols.original) ?? currentConnection;
114
- if (currentOwner !== connectionOwner || currentConnection?.operator !== invocation.peer) {
137
+ if (currentOwner !== connectionOwner || currentConnection?.browserPeer !== invocation.peer) {
115
138
  throw new DsmmProfileError("not-owned", "The native Host operator connection is no longer active.");
116
139
  }
117
140
  const agents = this.ctx.get("agents");
@@ -121,36 +144,9 @@ let DsmmProfilesHost = (() => {
121
144
  return agents;
122
145
  };
123
146
  let agents = checkAuthority();
124
- let captured = agents.get(sessionId);
125
- if (captured === undefined) {
126
- // Gateway lookups run before invocation authentication. Resolve here,
127
- // after full strict JSON decoding and operator admission, so invalid or
128
- // unauthorized calls cannot cold-resume a native session as a side effect.
129
- const controller = this.ctx.get("sessionController");
130
- if (controller === undefined || typeof controller.resolveAgent !== "function") {
131
- throw new DsmmProfileError("unavailable", "The native ordinary-session resume service is unavailable.");
132
- }
133
- let found;
134
- try {
135
- found = await controller.resolveAgent(SessionId(sessionId));
136
- }
137
- catch {
138
- checkAuthority();
139
- throw new DsmmProfileError("unavailable", "The native session could not be safely resumed.", "sessionId");
140
- }
141
- agents = checkAuthority();
142
- if ("error" in found) {
143
- const code = remoteErrorOf(found.error)?.code;
144
- if (code === "session/not-found")
145
- throw new DsmmProfileError("not-found", "The native session was not found.", "sessionId");
146
- if (code === "session/agent-busy")
147
- throw new DsmmProfileError("not-owned", "Subagent-owned sessions cannot select a root profile.", "sessionId");
148
- if (code === "session/writer-held")
149
- throw new DsmmProfileError("busy", "The native session is owned by another active writer.", "sessionId");
150
- throw new DsmmProfileError("unavailable", "The native session could not be safely resumed.", "sessionId");
151
- }
152
- captured = found.agent;
153
- }
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");
154
150
  const agent = captured;
155
151
  const checkCaptured = () => {
156
152
  const current = checkAuthority();
@@ -200,11 +196,12 @@ export function assertLocalSettingsOperator(ctx) {
200
196
  const connection = ctx.get("connection");
201
197
  const webServer = ctx.get("webServer");
202
198
  const settings = ctx.get("settings");
203
- if (invocation?.peer === undefined || connection?.operator !== invocation.peer
199
+ if (invocation?.peer === undefined || connection?.browserPeer !== invocation.peer
204
200
  || webServer?.host !== "127.0.0.1" || settings?.writable !== true) {
205
201
  throw new DsmmProfileError("not-owned", "Global deployment edits require the authenticated operator of a local writable native Host.");
206
202
  }
207
203
  invocation.signal.throwIfAborted();
204
+ invocation.peer.signal.throwIfAborted();
208
205
  }
209
206
  let DsmmConfigHost = (() => {
210
207
  let _classSuper = TypertRemoteService;
@@ -265,12 +262,13 @@ let DsmmConfigHost = (() => {
265
262
  const runtime = this.runtime?.() ?? this.ctx.get("dsmmProfileRuntime");
266
263
  return { entryId: desired.entryId, namespace: desired.nativeNamespace ?? null, hostProfileKey: desired.hostProfileKey,
267
264
  global: desired.global, globalRevision: desired.globalRevision,
268
- profile: desired.profile, nativeRevision: desired.nativeRevision,
265
+ profile: { ...desired.profile }, nativeRevision: desired.nativeRevision,
269
266
  nativeFormRevision: desired.nativeFormRevision ?? null, nativeForm: desired.nativeForm === undefined ? null : { base: desired.nativeForm.base ?? null, user: desired.nativeForm.user ?? null },
270
267
  desired: { ...readOnlySettings(desired.settings) }, sources: readOnlySettingSources(desired.sources),
271
268
  startup: { ...readOnlySettings(this.startup) }, defaults: DEFAULT_DSMM_SETTINGS,
272
269
  ...(this.startupSources === undefined ? {} : { startupSources: readOnlySettingSources(this.startupSources) }),
273
- schema: deploymentEditorSchema(), nextRoot: runtime?.previewDeployment(desired) ?? null,
270
+ schema: deploymentEditorSchema(), nativeSchema: deploymentEditorSchema(true),
271
+ subagentRuntime: runtimeAdmissionView(this.ctx), nextRoot: runtime?.previewDeployment(desired) ?? null,
274
272
  modules: projectDsmmModules(this.startup, desired, undefined, true, this.getMountedPermission) };
275
273
  }
276
274
  catch (error) {