@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
@@ -0,0 +1,28 @@
1
+ import type { PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
2
+ import type { DeploymentSchemaNode } from "../profile-types.js";
3
+ import type { DeploymentController } from "./deployment-controller.js";
4
+ import type { PermissionLocaleKey } from "./permission-locales.js";
5
+ type Locale = PropsLocale<"plugins.dsmm">;
6
+ export declare const permissionText: (t: Locale["t"]) => (key: PermissionLocaleKey) => string;
7
+ export declare function fieldLabel(path: readonly string[], t: Locale["t"]): string;
8
+ export declare function displayValue(value: unknown, t: Locale["t"]): string;
9
+ export declare function AdvancedField({ schema, path, controller, inherited, upper, t }: Locale & {
10
+ schema: DeploymentSchemaNode;
11
+ path: string[];
12
+ controller: DeploymentController;
13
+ inherited: unknown;
14
+ upper: unknown;
15
+ }): import("react").JSX.Element;
16
+ export declare function ScalarField({ schema, path, controller, inherited, t }: Locale & {
17
+ schema: DeploymentSchemaNode;
18
+ path: string[];
19
+ controller: DeploymentController;
20
+ inherited: unknown;
21
+ }): import("react").JSX.Element;
22
+ export declare function Field({ schema, path, controller, t }: Locale & {
23
+ schema: DeploymentSchemaNode;
24
+ path: string[];
25
+ controller: DeploymentController;
26
+ }): import("react").JSX.Element;
27
+ export {};
28
+ //# sourceMappingURL=DeploymentFields.d.ts.map
@@ -0,0 +1,68 @@
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useId, useSyncExternalStore } from "react";
3
+ import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ import { at, enumValues, equal, mergeLayer, parseAdvanced, validateEditorValue } from "./deployment-data.js";
5
+ import { deploymentFieldLabels } from "./deployment-locales.js";
6
+ import { permissionEn, permissionZh } from "./permission-locales.js";
7
+ import { NativeCommandEntries } from "./NativeCommandEntries.js";
8
+ export const permissionText = (t) => (key) => (t("global") === "DSMM 全局配置" ? permissionZh : permissionEn)[key];
9
+ export function fieldLabel(path, t) {
10
+ const key = path.at(-1);
11
+ if (path[0] === "permissionControl" && ["outsideReads", "webSearch", "webFetch", "rules", "nativeCommands", "rule"].includes(key))
12
+ return permissionText(t)(key);
13
+ const item = deploymentFieldLabels[key];
14
+ return item === undefined ? key.replace(/^dsmm-/u, "").replace(/([a-z])([A-Z])/gu, "$1 $2") : item[t("global") === "DSMM 全局配置" ? 1 : 0];
15
+ }
16
+ export function displayValue(value, t) {
17
+ if (value === undefined)
18
+ return t("unknown");
19
+ if (typeof value === "boolean")
20
+ return t(value ? "on" : "off");
21
+ const text = JSON.stringify(value);
22
+ return text.length > 120 ? `${text.slice(0, 120)}…` : text;
23
+ }
24
+ export function AdvancedField({ schema, path, controller, inherited, upper, t }) {
25
+ const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot), id = useId(), name = path.join(".");
26
+ const value = at(state.draft, path), raw = state.raw[name], text = raw?.text ?? (value === undefined ? "" : JSON.stringify(value, null, 2)), invalid = raw?.invalid === true;
27
+ return _jsxs("details", { className: "dsmm-deployment-group", "data-field": name, children: [_jsxs("summary", { children: [fieldLabel(path, t), " \u00B7 ", t("advanced")] }), _jsxs("div", { className: "dsmm-field", children: [_jsxs("label", { htmlFor: id, children: [fieldLabel(path, t), " \u00B7 ", t("advanced")] }), _jsx("p", { className: "dsmm-hint", id: `${id}-hint`, children: t("advancedHint") }), path[0] === "permissionControl" && _jsx("p", { className: "dsmm-hint", children: permissionText(t)("configRulesHint") }), _jsx("p", { className: "dsmm-hint", children: t(value === undefined ? "inherit" : "explicit") }), upper !== undefined && _jsxs("p", { className: "dsmm-hint", children: [t("profileSource"), ": ", displayValue(upper, t)] }), _jsx("textarea", { id: id, rows: 6, maxLength: 32768, value: text, disabled: !controller.canEdit(), "aria-invalid": invalid, "aria-describedby": `${id}-hint ${id}-error`, onChange: event => {
28
+ const next = event.currentTarget.value;
29
+ let parsed, valid = true;
30
+ try {
31
+ parsed = parseAdvanced(next);
32
+ const candidate = parsed === undefined ? inherited : mergeLayer(inherited, parsed);
33
+ valid = parsed === undefined || validateEditorValue(parsed, schema, true) && validateEditorValue(upper === undefined ? candidate : mergeLayer(candidate, upper), schema);
34
+ }
35
+ catch {
36
+ valid = false;
37
+ }
38
+ controller.setRaw(name, next, !valid);
39
+ if (valid)
40
+ controller.edit(path, parsed);
41
+ } }), _jsx("p", { id: `${id}-error`, className: "dsmm-hint", children: invalid ? t("invalid") : "" }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: !controller.canEdit() || value === undefined && raw === undefined, onClick: () => { controller.clearRaw(name); controller.edit(path, undefined); }, children: t("unset") }), _jsxs("details", { children: [_jsx("summary", { children: t("inherit") }), _jsx("pre", { children: JSON.stringify(inherited, null, 2) })] }), _jsxs("details", { children: [_jsx("summary", { children: "schema" }), _jsx("pre", { children: JSON.stringify(schema, null, 2) })] })] })] });
42
+ }
43
+ export function ScalarField({ schema, path, controller, inherited, t }) {
44
+ const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot), id = useId(), name = path.join(".");
45
+ const value = at(state.draft, path), raw = state.raw[name], bad = raw?.invalid === true;
46
+ return _jsxs(_Fragment, { children: [_jsx("label", { htmlFor: id, children: fieldLabel(path, t) }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Input, { className: "dsmm-input", id: id, type: "text", inputMode: schema.type === "number" ? "decimal" : undefined, value: raw?.text ?? String(value ?? inherited ?? ""), disabled: !controller.canEdit(), "aria-invalid": bad, "aria-describedby": `${id}-error`, onChange: event => {
47
+ const text = event.currentTarget.value, candidate = schema.type === "number" ? Number(text) : text;
48
+ const valid = (schema.type !== "number" || text.trim() !== "") && validateEditorValue(candidate, schema);
49
+ controller.setRaw(name, text, !valid);
50
+ if (valid)
51
+ controller.edit(path, candidate);
52
+ } }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: !controller.canEdit() || value === undefined && raw === undefined, onClick: () => { controller.clearRaw(name); controller.edit(path, undefined); }, children: t("unset") })] }), _jsxs("p", { id: `${id}-error`, className: "dsmm-hint", children: [bad ? t("invalid") : "", schema.type === "number" && (schema.min !== undefined || schema.max !== undefined) ? ` ${schema.min ?? "—"} – ${schema.max ?? "—"}` : ""] })] });
53
+ }
54
+ export function Field({ schema, path, controller, t }) {
55
+ if (schema.type === "transform" && schema.inner !== undefined)
56
+ schema = schema.inner;
57
+ const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot), snapshot = state.snapshot, id = useId(), name = path.join(".");
58
+ const explicit = at(state.draft, path), inherited = controller.layer === "global" ? at(snapshot.defaults, path) : at(mergeLayer(mergeLayer(snapshot.defaults, snapshot.global), snapshot.nativeForm?.base ?? {}), path);
59
+ const choices = enumValues(schema), disabled = !controller.canEdit();
60
+ if (name === "permissionControl.nativeCommands.entries")
61
+ return _jsx("div", { "data-field": name, children: _jsx(NativeCommandEntries, { controller: controller, value: explicit, inherited: (inherited ?? []), disabled: disabled, onChange: value => controller.edit(path, value), setInvalid: (key, bad) => controller.setInvalid(key, bad), t: permissionText(t) }) });
62
+ if (schema.type === "object" && schema.fields !== undefined && path[0] !== "roleRouting")
63
+ return _jsxs("details", { className: "dsmm-deployment-group", "data-field": name, children: [_jsx("summary", { children: fieldLabel(path, t) }), _jsxs("div", { children: [name === "permissionControl" && _jsx("p", { className: "dsmm-hint", children: permissionText(t)("configPolicyHint") }), _jsx("p", { className: "dsmm-hint", children: t(explicit === undefined ? "inherit" : "explicit") }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: disabled || explicit === undefined && !Object.keys(state.raw).some(key => key === name || key.startsWith(`${name}.`)), onClick: () => { controller.clearRaw(name); controller.edit(path, undefined); }, children: t("unsetGroup") }), Object.entries(schema.fields).map(([key, node]) => _jsx(Field, { schema: node, path: [...path, key], controller: controller, t: t }, key))] })] });
64
+ if (!["boolean", "string", "number"].includes(schema.type) && choices === null)
65
+ return _jsx(AdvancedField, { schema: schema, path: path, controller: controller, inherited: inherited, upper: controller.layer === "global" ? at(snapshot.profile, path) : undefined, t: t });
66
+ return _jsxs("div", { className: "dsmm-field dsmm-deployment-field", "data-field": name, children: [schema.type === "boolean" || choices !== null ? _jsxs(_Fragment, { children: [_jsx("label", { htmlFor: id, children: fieldLabel(path, t) }), _jsxs("select", { id: id, disabled: disabled, value: explicit === undefined ? "inherit" : JSON.stringify(explicit), onChange: event => controller.edit(path, event.currentTarget.value === "inherit" ? undefined : JSON.parse(event.currentTarget.value)), children: [_jsx("option", { value: "inherit", children: `${t("unset")} · ${displayValue(inherited, t)}` }), (choices ?? [true, false]).map(choice => _jsx("option", { value: JSON.stringify(choice), children: displayValue(choice, t) }, String(choice)))] })] }) : _jsx(ScalarField, { schema: schema, path: path, controller: controller, inherited: inherited, t: t }), name === "modelParameters.passthrough" && _jsx("p", { className: "dsmm-hint", children: t("modelParametersHint") }), name === "permissionControl.enabled" && _jsx("p", { className: "dsmm-hint", children: permissionText(t)("coldHint") }), explicit !== undefined && _jsx("p", { className: "dsmm-hint", children: t(equal(explicit, at(snapshot.defaults, path)) ? "defaultPin" : "explicit") }), controller.layer === "profile" && at(snapshot.nativeForm?.base, path) !== undefined && _jsx("p", { className: "dsmm-hint", children: t("hostPin") }), controller.layer === "global" && at(snapshot.profile, path) !== undefined && _jsxs("p", { className: "dsmm-hint", children: [t("profileSource"), ": ", displayValue(at(snapshot.profile, path), t), " \u00B7 ", t("explicit")] })] });
67
+ }
68
+ //# sourceMappingURL=DeploymentFields.js.map
@@ -1,18 +1,30 @@
1
1
  import type { PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
2
2
  import type { ConfigForms } from "@deepseek-ai/dsh-client-ui-settings/client";
3
- import { DeploymentController } from "./deployment-controller.js";
4
- import type { NativePageForm } from "./deployment-controller.js";
5
3
  import type { DsmmConfigRemote } from "../profile-remote.js";
4
+ import type { SubagentRuntimeAdmissionView } from "../profile-types.js";
5
+ import type { DeploymentController } from "./deployment-controller.js";
6
+ import type { PermissionController } from "./permission-controller.js";
7
+ import type { DeploymentWorkspace } from "./deployment-workspace.js";
6
8
  type Locale = PropsLocale<"plugins.dsmm">;
7
9
  export interface DeploymentPageProps extends Locale {
8
10
  view: "summary" | "page";
9
- form?: NativePageForm;
10
11
  core: DeploymentController;
11
12
  remote: DsmmConfigRemote;
13
+ workspace?: DeploymentWorkspace;
14
+ permissions?: PermissionController;
12
15
  forms?: ConfigForms;
13
- rowNamespace?: string;
14
- profilePage?: boolean;
15
16
  }
17
+ export declare function ScopeSave({ controller, workspace, refreshOnly, t }: Locale & {
18
+ controller: DeploymentController;
19
+ workspace?: DeploymentWorkspace;
20
+ refreshOnly?: boolean;
21
+ }): import("react").JSX.Element;
22
+ export declare function NativeRuntimeState({ value, t }: Locale & {
23
+ value?: SubagentRuntimeAdmissionView;
24
+ }): import("react").JSX.Element;
25
+ export declare function StateInspector({ controller, t }: Locale & {
26
+ controller: DeploymentController;
27
+ }): import("react").JSX.Element;
16
28
  export declare function DeploymentPage(props: DeploymentPageProps): import("react").JSX.Element;
17
29
  export {};
18
30
  //# sourceMappingURL=DeploymentPage.d.ts.map
@@ -1,127 +1,94 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useEffect, useId, useMemo, useState, useSyncExternalStore } from "react";
3
- import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
4
- import { DeploymentController } from "./deployment-controller.js";
5
- import { at, enumValues, equal, inspectorPaths, mergeLayer, parseAdvanced, validateEditorValue, visibleDeploymentPath } from "./deployment-data.js";
6
- import { deploymentFieldLabels } from "./deployment-locales.js";
7
- function label(path, t) {
8
- const key = path.at(-1);
9
- const item = deploymentFieldLabels[key];
10
- return item === undefined ? key.replace(/^dsmm-/u, "").replace(/([a-z])([A-Z])/gu, "$1 $2") : item[t("global") === "DSMM 全局配置" ? 1 : 0];
11
- }
12
- function displayValue(value, t) {
13
- if (value === undefined)
14
- return t("unknown");
15
- if (typeof value === "boolean")
16
- return t(value ? "on" : "off");
17
- const text = JSON.stringify(value);
18
- return text.length > 120 ? `${text.slice(0, 120)}…` : text;
19
- }
20
- function AdvancedField({ schema, path, value, inherited, upper, reset, disabled, onChange, setInvalid, t }) {
21
- const id = useId(), name = path.join(".");
22
- const serialized = value === undefined ? "" : JSON.stringify(value, null, 2);
23
- const [text, setText] = useState(serialized);
24
- const [invalid, setLocalInvalid] = useState(false);
25
- useEffect(() => { setText(serialized); setLocalInvalid(false); setInvalid(name, false); }, [serialized, reset]);
26
- return _jsxs("details", { className: "dsmm-deployment-group", children: [_jsxs("summary", { children: [label(path, t), " \u00B7 ", t("advanced"), " ", _jsx("code", { children: name })] }), _jsxs("div", { className: "dsmm-field", children: [_jsxs("label", { htmlFor: id, children: [label(path, t), " \u00B7 ", t("advanced"), " ", _jsx("code", { children: name })] }), _jsx("p", { className: "dsmm-hint", id: `${id}-hint`, children: t("advancedHint") }), _jsx("textarea", { id: id, rows: 6, maxLength: 32768, value: text, disabled: disabled, "aria-invalid": invalid, "aria-describedby": `${id}-hint ${id}-error`, onChange: event => {
27
- const next = event.currentTarget.value;
28
- setText(next);
29
- let parsed, valid = true;
30
- try {
31
- parsed = parseAdvanced(next);
32
- const candidate = parsed === undefined ? inherited : mergeLayer(inherited, parsed);
33
- valid = parsed === undefined || validateEditorValue(parsed, schema, true) && validateEditorValue(upper === undefined ? candidate : mergeLayer(candidate, upper), schema);
34
- }
35
- catch {
36
- valid = false;
37
- }
38
- setLocalInvalid(!valid);
39
- setInvalid(name, !valid);
40
- if (valid)
41
- onChange(parsed);
42
- } }), _jsx("p", { id: `${id}-error`, className: "dsmm-hint", children: invalid ? t("invalid") : "" }), _jsxs("details", { children: [_jsxs("summary", { children: [t("advanced"), " \u00B7 schema"] }), _jsx("pre", { children: JSON.stringify(schema, null, 2) })] })] })] });
43
- }
44
- function ScalarField({ schema, path, controller, disabled, inherited, invalid, t }) {
45
- const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
46
- const value = at(state.draft, path), name = path.join("."), id = useId();
47
- const [text, setText] = useState(String(value ?? inherited ?? ""));
48
- const [bad, setBad] = useState(false);
49
- useEffect(() => { setText(String(value ?? inherited ?? "")); setBad(false); invalid(name, false); }, [value, inherited, state.snapshot]);
50
- return _jsxs(_Fragment, { children: [_jsxs("label", { htmlFor: id, children: [label(path, t), " ", _jsx("code", { children: name })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Input, { className: "dsmm-input", id: id, type: "text", inputMode: schema.type === "number" ? "decimal" : undefined, value: text, disabled: disabled, "aria-invalid": bad, "aria-describedby": `${id}-error`, onChange: event => {
51
- const raw = event.currentTarget.value;
52
- setText(raw);
53
- const candidate = schema.type === "number" ? Number(raw) : raw;
54
- const valid = (schema.type !== "number" || raw.trim() !== "") && validateEditorValue(candidate, schema);
55
- setBad(!valid);
56
- invalid(name, !valid);
57
- if (valid)
58
- controller.edit(path, candidate);
59
- } }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || value === undefined && !bad, onClick: () => { setText(String(inherited ?? "")); setBad(false); invalid(name, false); controller.edit(path, undefined); }, children: t("inherit") })] }), _jsxs("p", { id: `${id}-error`, className: "dsmm-hint", children: [bad ? t("invalid") : "", schema.type === "number" && (schema.min !== undefined || schema.max !== undefined) ? ` ${schema.min ?? "—"} – ${schema.max ?? "—"}` : ""] })] });
60
- }
61
- function Field({ schema, path, controller, invalid, t }) {
62
- if (schema.type === "transform" && schema.inner !== undefined)
63
- schema = schema.inner;
64
- const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot), snapshot = state.snapshot;
65
- const id = useId(), name = path.join("."), explicit = at(state.draft, path);
66
- const inherited = controller.layer === "global" ? at(snapshot.defaults, path) : at(mergeLayer(mergeLayer(snapshot.defaults, snapshot.global), snapshot.nativeForm?.base ?? {}), path);
67
- const disabled = state.busy || state.issue === "not-owned" || state.issue === "unavailable" || state.issue === "transport" || controller.layer === "profile" && !controller.canWriteProfile();
68
- const choices = enumValues(schema);
69
- const hint = name === "modelParameters.passthrough" ? "modelParametersHint" : name === "permissionControl.enabled" ? "permissionControlHint" : null;
70
- if (schema.type === "object" && schema.fields !== undefined && path[0] !== "roleRouting")
71
- return _jsxs("details", { className: "dsmm-deployment-group", children: [_jsxs("summary", { children: [label(path, t), " ", _jsx("code", { children: name })] }), _jsx("div", { children: Object.entries(schema.fields).filter(([key]) => visibleDeploymentPath([...path, key])).map(([key, node]) => _jsx(Field, { schema: node, path: [...path, key], controller: controller, invalid: invalid, t: t }, key)) })] });
72
- if (!["boolean", "string", "number"].includes(schema.type) && choices === null)
73
- return _jsx(AdvancedField, { schema: schema, path: path, value: explicit, inherited: inherited, upper: controller.layer === "global" ? at(snapshot.profile, path) : undefined, reset: snapshot, disabled: disabled, t: t, onChange: value => controller.edit(path, value), setInvalid: invalid });
74
- return _jsxs("div", { className: "dsmm-field dsmm-deployment-field", children: [schema.type === "boolean" || choices !== null ? _jsxs(_Fragment, { children: [_jsxs("label", { htmlFor: id, children: [label(path, t), " ", _jsx("code", { children: name })] }), _jsxs("select", { id: id, disabled: disabled, "aria-describedby": hint === null ? undefined : `${id}-hint`, value: explicit === undefined ? "inherit" : JSON.stringify(explicit), onChange: event => controller.edit(path, event.currentTarget.value === "inherit" ? undefined : JSON.parse(event.currentTarget.value)), children: [_jsxs("option", { value: "inherit", children: [t("inherit"), " \u00B7 ", displayValue(inherited, t)] }), (choices ?? [true, false]).map(choice => _jsx("option", { value: JSON.stringify(choice), children: displayValue(choice, t) }, String(choice)))] })] }) : _jsx(ScalarField, { schema: schema, path: path, controller: controller, disabled: disabled, inherited: inherited, invalid: invalid, t: t }), hint !== null && _jsx("p", { id: `${id}-hint`, className: "dsmm-hint", children: t(hint) }), (explicit !== undefined || controller.layer === "profile" && at(snapshot.nativeForm?.base, path) !== undefined) && _jsxs("p", { className: "dsmm-hint", children: [explicit === undefined ? "" : equal(explicit, at(snapshot.defaults, path)) ? t("defaultPin") : t("explicit"), controller.layer === "profile" && at(snapshot.nativeForm?.base, path) !== undefined ? `${explicit === undefined ? "" : " · "}${t("hostPin")}` : ""] })] });
75
- }
76
- function Layer({ controller, t }) {
2
+ import { useEffect, useId, useRef, useSyncExternalStore } from "react";
3
+ import { Button } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ import { deploymentWorkspace } from "./deployment-workspace.js";
5
+ import { CONFIG_MODULES, moduleFields, moduleFor, moduleTitle } from "./deployment-modules.js";
6
+ import { at, inspectorPaths, scopeSchema, visibleDeploymentPath } from "./deployment-data.js";
7
+ import { Field, displayValue, permissionText } from "./DeploymentFields.js";
8
+ import { configurationVersionState } from "./configuration-display.js";
9
+ import { PermissionsPanel } from "./PermissionsPanel.js";
10
+ import { permissionEn } from "./permission-locales.js";
11
+ export function ScopeSave({ controller, workspace, refreshOnly = false, t }) {
77
12
  const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
78
- const [invalid, setInvalid] = useState(new Set());
79
- const updateInvalid = (path, bad) => { controller.setInvalid(path, bad); setInvalid(previous => { if (previous.has(path) === bad)
80
- return previous; const next = new Set(previous); if (bad)
81
- next.add(path);
82
- else
83
- next.delete(path); return next; }); };
84
- const title = controller.layer === "global" ? "global" : "profile";
85
- const disabled = state.busy || state.snapshot === null || state.issue !== null || invalid.size > 0 || controller.layer === "profile" && !controller.canWriteProfile();
86
- return _jsxs("div", { "data-dsmm-layer": controller.layer, "aria-busy": state.busy, children: [_jsxs("details", { className: "dsmm-deployment-card", children: [_jsxs("summary", { children: [t(title), _jsx("span", { role: "status", "aria-live": "polite", className: "dsmm-hint", children: state.busy ? t("saving") : state.dirty ? t("dirty") : state.saved ? t("saved") : "" })] }), _jsxs("fieldset", { children: [_jsx("legend", { children: t(title) }), _jsx("p", { className: "dsmm-hint", children: t(title === "global" ? "globalHint" : "profileHint") }), state.snapshot !== null && _jsxs(_Fragment, { children: [_jsxs("details", { className: "dsmm-deployment-group", children: [_jsx("summary", { children: t("core") }), _jsxs("div", { children: [_jsx("p", { className: "dsmm-hint", children: t("coreHint") }), Object.entries(state.snapshot.schema.fields ?? {}).filter(([key]) => key === "modelParameters" || key === "permissionControl").map(([key, schema]) => _jsx(Field, { schema: schema, path: [key], controller: controller, invalid: updateInvalid, t: t }, key))] })] }), Object.entries(state.snapshot.schema.fields ?? {}).filter(([key]) => visibleDeploymentPath([key]) && key !== "modelParameters" && key !== "permissionControl" && (controller.layer === "global" || key !== "modules")).sort(([a], [b]) => a === "modules" ? -1 : b === "modules" ? 1 : 0).map(([key, schema]) => _jsx(Field, { schema: schema, path: [key], controller: controller, invalid: updateInvalid, t: t }, key))] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: disabled || !state.dirty, onClick: () => { void controller.save(); }, children: t(state.busy ? "saving" : title === "global" ? "saveGlobal" : "saveProfile") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => { void controller.refresh(); }, children: t("refresh") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.busy || !state.dirty && state.issue === null, onClick: () => { setInvalid(new Set()); void controller.refresh(true); }, children: t("discard") })] })] })] }), state.issue !== null && _jsx("p", { className: "dsmm-issue", role: "alert", children: t(state.issue) }), invalid.size > 0 && _jsx("p", { className: "dsmm-issue", role: "alert", children: t("invalid") }), controller.layer === "profile" && !controller.canWriteProfile() && _jsx("p", { className: "dsmm-hint", children: t("unavailableForm") })] });
13
+ const pending = [...new Set(controller.pendingPaths().map(moduleFor))];
14
+ return _jsxs("section", { className: "dsmm-scope-save", "aria-label": t(refreshOnly ? "refresh" : "saveScope"), children: [_jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: refreshOnly ? state.busy ? t("loading") : "" : state.busy ? t("saving") : state.refreshRequired ? t("savedRefreshRequired") : state.saved ? t("saved") : state.dirty ? t("dirty") : "" }), !refreshOnly && pending.length > 0 && _jsxs("p", { children: [t("pendingModules"), ": ", pending.map(module => t(moduleTitle(module))).join(" · ")] }), state.issue !== null && _jsx("p", { className: "dsmm-issue", role: "alert", children: t(state.issue) }), !refreshOnly && state.invalidFields.length > 0 && _jsx("p", { className: "dsmm-issue", role: "alert", children: t("invalid") }), controller.layer === "profile" && !controller.canWriteProfile() && _jsx("p", { className: "dsmm-hint", children: t("unavailableForm") }), _jsxs("div", { className: "dsmm-actions", children: [!refreshOnly && _jsx(Button, { type: "button", variant: "primary", disabled: !controller.canSave(), onClick: () => void (workspace?.save() ?? controller.save()), children: t(controller.layer === "global" ? "saveGlobal" : "saveProfile") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => void controller.refresh(), children: t("refresh") }), !refreshOnly && _jsx(Button, { type: "button", variant: "outline", disabled: state.busy || !state.dirty && state.issue === null && !state.refreshRequired, onClick: () => void controller.refresh(true), children: t("discard") })] })] });
87
15
  }
88
- function NativeProfileLayer({ namespace, forms, remote, form, core, t }) {
89
- const shared = useMemo(() => forms.get(namespace), [forms, namespace]);
90
- const snapshot = useSyncExternalStore(listener => shared.subscribe(listener), () => shared.getSnapshot());
91
- const controller = useMemo(() => core.forProfile(namespace), [core, remote, namespace]);
92
- const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
93
- const coreState = useSyncExternalStore(core.subscribe, core.getSnapshot);
94
- controller.attachForm(form ?? { state: snapshot, mutate: (ops, revision) => shared.mutate(ops, revision) });
95
- useEffect(() => { void controller.refresh(); return () => controller.dispose(); }, [controller]);
96
- useEffect(() => { if (state.saved)
97
- void core.refresh(); }, [state.saved, core]);
98
- useEffect(() => { if (controller.getSnapshot().snapshot !== null)
99
- void controller.refresh(); }, [coreState.snapshot?.globalRevision, snapshot.revision, controller]);
100
- return _jsx(Layer, { controller: controller, t: t });
16
+ export function NativeRuntimeState({ value, t }) {
17
+ return _jsxs("section", { className: "dsmm-availability", "aria-label": t("nativeRuntimeState"), children: [_jsx("h3", { children: t("nativeRuntimeState") }), _jsxs("p", { children: [t("nativeRuntimeBinding"), ": ", t(value?.binding === "stock" ? "nativeRuntimeStock" : value?.binding === "unavailable" ? "nativeRuntimeUnavailable" : "unknown")] }), _jsxs("p", { children: [t("nativeRuntimeFence"), ": ", value === undefined ? t("unknown") : t(value.deliveryFenceReady ? "on" : "off"), " \u00B7 ", t("nativeRuntimeRestart"), ": ", value === undefined ? t("unknown") : t(value.restartRequired ? "on" : "off")] }), value?.reason !== undefined && _jsx("p", { children: t(`nativeRuntimeReason-${value.reason}`) }), _jsx("p", { className: "dsmm-hint", children: t("nativeRuntimeReadinessHint") })] });
101
18
  }
102
- function StateInspector({ controller, session, t }) {
103
- const { snapshot, dirty, issue } = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
19
+ export function StateInspector({ controller, t }) {
20
+ const { snapshot, session, dirty, issue } = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
104
21
  if (snapshot === null)
105
- return null;
22
+ return _jsx("p", { children: t("unavailable") });
106
23
  const admitted = session?.configuration ?? null;
107
- const restartRequired = (snapshot.nextRoot?.restartRequired ?? []).filter(path => visibleDeploymentPath(path.split(".")));
108
24
  const source = (value) => t(value === "profile" ? "profileSource" : value === "global" ? "globalSource" : value === "defaults" ? "defaultsSource" : value === "named-session" ? "namedSource" : value === "startup" ? "startupSource" : value === "deployment" ? "deploymentCapture" : value === "mixed" ? "mixedSource" : "unknown");
109
25
  const value = (layer, path) => layer === undefined ? t("unknown") : at(layer, path.split(".")) === undefined ? t("absent") : displayValue(at(layer, path.split(".")), t);
110
- const metadata = (layer, path, entry) => layer !== undefined && at(layer, path.split(".")) === undefined && entry === undefined ? t("absent") : source(entry);
111
- return _jsxs("details", { className: "dsmm-deployment-card", children: [_jsxs("summary", { children: [t("state"), _jsx("span", { className: "dsmm-hint", children: restartRequired.length > 0 ? t("pending") : dirty || issue !== null ? t("inspectorStale") : "" })] }), _jsxs("div", { children: [_jsx("p", { role: "status", "aria-live": "polite", children: session === null ? t("noSession") : admitted === null ? t("sessionUnavailable") : `${t("namedSource")}: ${admitted.named?.id ?? "—"}` }), session !== null && _jsxs("p", { children: [t("session"), ": ", _jsx("code", { children: session.sessionId }), " \u00B7 ", _jsx("code", { children: session.admissionEpoch }), " \u00B7 ", session.scope] }), (dirty || issue !== null) && _jsx("p", { className: "dsmm-hint", children: t("inspectorStale") }), _jsxs("p", { className: "dsmm-hint", children: ["Global CAS: ", _jsx("code", { children: snapshot.globalRevision }), " \u00B7 native CAS: ", _jsx("code", { children: snapshot.nativeRevision }), " \u00B7 Host form: ", snapshot.nativeFormRevision ?? "—"] }), inspectorPaths(snapshot, admitted).map(path => _jsxs("dl", { className: "dsmm-deployment-state", children: [_jsx("dt", { children: _jsx("code", { children: path }) }), _jsxs("dd", { children: [t("globalSource"), ": ", at(snapshot.global, path.split(".")) === undefined ? t("absent") : t("globalSource")] }), _jsxs("dd", { children: [t("desired"), ": ", value(snapshot.desired, path), " \u00B7 ", metadata(snapshot.desired, path, snapshot.sources[path])] }), _jsxs("dd", { children: [t("startup"), ": ", value(snapshot.startup, path), " \u00B7 ", metadata(snapshot.startup, path, snapshot.startupSources?.[path]), " / ", at(snapshot.startup, path.split(".")) === undefined ? t("absent") : t("startupSource")] }), _jsxs("dd", { children: [t("next"), ": ", value(snapshot.nextRoot?.settings, path), " \u00B7 ", metadata(snapshot.nextRoot?.settings, path, snapshot.nextRoot?.sources[path]), " / ", metadata(snapshot.nextRoot?.settings, path, snapshot.nextRoot?.captures[path])] }), _jsxs("dd", { children: [t("session"), ": ", value(admitted?.settings, path), " \u00B7 ", metadata(admitted?.settings, path, admitted?.sources[path]), " / ", metadata(admitted?.settings, path, admitted?.captures[path])] })] }, path)), restartRequired.length > 0 && _jsxs("p", { children: [t("pending"), ": ", restartRequired.join(", ")] })] })] });
26
+ const restart = (snapshot.nextRoot?.restartRequired ?? []).filter(path => visibleDeploymentPath(path.split(".")));
27
+ return _jsxs("div", { className: "dsmm-structured", children: [_jsx("p", { role: "status", children: session === null ? t("noSession") : admitted === null ? t("sessionUnavailable") : t("sessionObserved") }), (dirty || issue !== null) && _jsx("p", { className: "dsmm-hint", children: t("inspectorStale") }), _jsxs("p", { children: [t("globalSource"), ": ", t(configurationVersionState(snapshot.globalRevision)), " \u00B7 ", t("profileSource"), ": ", t(configurationVersionState(snapshot.nativeRevision))] }), snapshot.subagentRuntime !== undefined && _jsx(NativeRuntimeState, { value: snapshot.subagentRuntime, t: t }), snapshot.modules.map(module => _jsxs("section", { className: "dsmm-zone", children: [_jsx("h3", { children: module.descriptor.label }), _jsxs("p", { children: [t("desired"), ": ", t(module.desired.enabled ? "on" : "off"), " \u00B7 ", source(module.desired.source)] }), _jsxs("p", { children: [t("startup"), ": ", module.startupMounted == null ? t("unknown") : t(module.startupMounted ? "on" : "off")] }), _jsxs("p", { children: [t("next"), ": ", module.nextRoot.admitted == null ? t("unknown") : t(module.nextRoot.admitted ? "on" : "off")] }), module.pending && _jsx("p", { children: t("pending") })] }, module.descriptor.id)), inspectorPaths(snapshot, admitted).map(path => _jsxs("dl", { className: "dsmm-deployment-state", children: [_jsx("dt", { children: path }), _jsxs("dd", { children: [t("desired"), ": ", value(snapshot.desired, path), " \u00B7 ", source(snapshot.sources[path])] }), _jsxs("dd", { children: [t("startup"), ": ", value(snapshot.startup, path), " \u00B7 ", source(snapshot.startupSources?.[path])] }), _jsxs("dd", { children: [t("next"), ": ", value(snapshot.nextRoot?.settings, path), " \u00B7 ", source(snapshot.nextRoot?.sources[path])] }), _jsxs("dd", { children: [t("session"), ": ", value(admitted?.settings, path), " \u00B7 ", source(admitted?.sources[path])] })] }, path)), restart.length > 0 && _jsxs("p", { children: [t("pending"), ": ", restart.join(", ")] })] });
112
28
  }
113
29
  export function DeploymentPage(props) {
114
- const state = useSyncExternalStore(props.core.subscribe, props.core.getSnapshot);
30
+ const workspace = props.workspace ?? deploymentWorkspace(props.core, props.permissions);
31
+ const navigation = useSyncExternalStore(workspace.subscribe, workspace.getSnapshot);
32
+ const core = useSyncExternalStore(props.core.subscribe, props.core.getSnapshot);
33
+ const controller = workspace.controller() ?? props.core;
34
+ const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
35
+ const id = useId(), heading = useRef(null), triggers = useRef(new Map()), previous = useRef(null);
36
+ const scopeControl = useRef(null), confirmation = useRef(null);
37
+ const resume = useRef(null);
38
+ const { t } = props, snapshot = state.snapshot ?? core.snapshot, active = navigation.module;
115
39
  useEffect(() => { if (props.view === "page")
116
40
  void props.core.refresh(); }, [props.core, props.view]);
41
+ useEffect(() => { if (props.forms !== undefined)
42
+ workspace.bindForms(props.forms); }, [workspace, props.forms]);
43
+ useEffect(() => {
44
+ if (active !== null)
45
+ heading.current?.focus();
46
+ else if (previous.current !== null)
47
+ triggers.current.get(previous.current)?.focus();
48
+ previous.current = active;
49
+ }, [active]);
50
+ useEffect(() => {
51
+ if (navigation.pending !== null) {
52
+ resume.current = { element: document.activeElement, scope: navigation.scope, module: active };
53
+ confirmation.current?.focus();
54
+ }
55
+ else if (resume.current !== null) {
56
+ const from = resume.current;
57
+ resume.current = null;
58
+ if (from.scope === navigation.scope && from.module === active) {
59
+ if (from.element.isConnected)
60
+ from.element.focus();
61
+ }
62
+ else if (active !== null)
63
+ heading.current?.focus();
64
+ else if (from.scope !== navigation.scope)
65
+ scopeControl.current?.focus();
66
+ }
67
+ }, [navigation.pending, navigation.scope, active]);
117
68
  if (props.view === "summary")
118
- return _jsx("span", { children: props.t("summary") });
119
- const { t } = props, snapshot = state.snapshot;
120
- return _jsxs("section", { className: "dsmm-profiles dsmm-deployment", "data-dsmm-page": true, "aria-label": t("title"), children: [_jsx("p", { className: "dsmm-hint", children: t("description") }), _jsx("p", { className: "dsmm-hint", children: t("boundaries") }), snapshot?.modules.map(module => {
121
- const admitted = state.session?.modules?.find(value => value.descriptor.id === module.descriptor.id)?.admitted;
122
- return _jsxs("details", { className: "dsmm-deployment-card", children: [_jsxs("summary", { children: [module.descriptor.label, _jsx("span", { className: "dsmm-hint", children: module.pending ? t("pending") : t(module.desired.enabled ? "on" : "off") })] }), _jsxs("div", { children: [_jsx("p", { children: t("hostUnknown") }), _jsxs("p", { children: [t("desired"), ": ", t(module.desired.enabled ? "on" : "off"), " \u00B7 ", module.desired.source] }), _jsxs("p", { children: [t("startup"), ": ", module.startupMounted == null ? t("unknown") : t(module.startupMounted ? "on" : "off"), " \u00B7 ", t("next"), ": ", module.nextRoot.admitted == null ? t("unknown") : t(module.nextRoot.admitted ? "on" : "off")] }), _jsxs("p", { children: [t("session"), ": ", admitted == null ? t("unknown") : t(admitted ? "on" : "off")] }), _jsx("p", { className: "dsmm-hint", children: t(module.descriptor.id === "deepwork" ? "ceiling" : "permissionControlHint") })] })] }, module.descriptor.id);
123
- }), _jsx(Layer, { controller: props.core, t: t }), props.profilePage && props.forms !== undefined && snapshot?.namespace !== null && snapshot?.namespace !== undefined && (props.rowNamespace === undefined || props.rowNamespace === snapshot.namespace)
124
- ? _jsx(NativeProfileLayer, { namespace: snapshot.namespace, forms: props.forms, remote: props.remote, form: props.form, core: props.core, t: t }, `${snapshot.hostProfileKey}:${snapshot.entryId}`)
125
- : _jsxs("div", { children: [_jsxs("details", { className: "dsmm-deployment-card", children: [_jsxs("summary", { children: [t("profile"), _jsx("span", { className: "dsmm-hint", children: t("profileUnavailable") })] }), _jsx("div", { children: _jsx("p", { children: t("profileHint") }) })] }), _jsx("p", { className: "dsmm-hint", children: t("unavailableForm") })] }), _jsx(StateInspector, { controller: props.core, session: state.session, t: t })] });
69
+ return _jsx("span", { children: t("summary") });
70
+ const fields = snapshot === null || active === null ? [] : moduleFields(scopeSchema(snapshot, controller.layer), active, controller.layer);
71
+ const modules = CONFIG_MODULES.filter(module => module === "state" || module === "permissions" || snapshot === null || moduleFields(snapshot.schema, module, "global").length + moduleFields(scopeSchema(snapshot, "profile"), module, "profile").length > 0);
72
+ const scopeActions = _jsx(ScopeSave, { controller: active === "state" ? props.core : controller, workspace: workspace, refreshOnly: active === "state" || workspace.controller() === null, t: t });
73
+ return _jsxs("section", { className: "dsmm-profiles dsmm-deployment", "data-dsmm-page": true, "aria-label": t("title"), children: [_jsx("p", { children: t("description") }), _jsx("p", { className: "dsmm-hint", children: t("boundaries") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-scope`, children: t("scope") }), _jsxs("select", { ref: scopeControl, id: `${id}-scope`, value: navigation.scope, disabled: state.busy || navigation.pending !== null, onChange: event => {
74
+ const scope = event.currentTarget.value;
75
+ if (scope === "global" || scope === "profile")
76
+ workspace.request({ scope, module: active });
77
+ }, children: [_jsx("option", { value: "global", children: t("global") }), _jsx("option", { value: "profile", children: t("profile") })] })] }), _jsx("p", { className: "dsmm-hint", children: t(navigation.scope === "global" ? "globalHint" : "profileHint") }), navigation.scope === "profile" && (navigation.native === null || !navigation.native.canWriteProfile()) && _jsx("p", { className: "dsmm-hint", children: t("unavailableForm") }), _jsxs("div", { className: "dsmm-deployment-frame", "data-drawer-open": active !== null, children: [_jsx("nav", { className: "dsmm-module-list", "aria-label": t("modules"), children: modules.map(module => _jsx(Button, { ref: element => { if (element !== null)
78
+ triggers.current.set(module, element); }, type: "button", variant: "outline", disabled: navigation.pending !== null, "aria-expanded": active === module, "aria-controls": `${id}-drawer`, onClick: () => workspace.request({ scope: navigation.scope, module }), children: t(moduleTitle(module)) }, module)) }), active !== null && _jsxs("aside", { id: `${id}-drawer`, className: "dsmm-module-drawer", "aria-labelledby": `${id}-heading`, "data-dsmm-module": active, onKeyDown: event => {
79
+ if (event.key !== "Escape" || event.defaultPrevented)
80
+ return;
81
+ const target = event.target;
82
+ if (target.tagName === "SELECT" && (!globalThis.CSS?.supports("selector(select:open)") || target.matches("select:open")))
83
+ return;
84
+ event.preventDefault();
85
+ if (navigation.pending !== null)
86
+ workspace.continueEditing();
87
+ else
88
+ workspace.request({ scope: navigation.scope, module: null });
89
+ }, children: [_jsxs("div", { className: "dsmm-drawer-heading", children: [_jsx("h2", { id: `${id}-heading`, ref: heading, tabIndex: -1, children: t(moduleTitle(active)) }), _jsx(Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => workspace.request({ scope: navigation.scope, module: null }), children: t("close") })] }), active === "state" ? _jsxs(_Fragment, { children: [_jsx(StateInspector, { controller: props.core, t: t }), scopeActions] }) : _jsxs(_Fragment, { children: [navigation.scope === "profile" && navigation.native === null ? _jsx("p", { children: t("unavailableForm") }) : state.snapshot === null ? _jsx("p", { children: t(state.busy ? "loading" : "unavailable") }) : _jsxs("div", { "data-dsmm-layer": controller.layer, "aria-busy": state.busy, className: "dsmm-structured", children: [fields.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("noModuleFields") }), fields.map(([key, schema]) => _jsx(Field, { schema: schema, path: [key], controller: controller, t: t }, key)), active === "run" && controller.layer === "profile" && _jsx(NativeRuntimeState, { value: state.snapshot.subagentRuntime, t: t })] }), scopeActions, active === "permissions" && _jsxs("section", { className: "dsmm-zone", children: [_jsx("h3", { children: t("rootRules") }), _jsx("p", { className: "dsmm-hint", children: t("rootRulesHint") }), workspace.permissions === undefined ? _jsx("p", { children: t("rootRulesUnavailable") }) : _jsx(PermissionsPanel, { controller: workspace.permissions, t: key => Object.hasOwn(permissionEn, key) ? permissionText(t)(key) : key })] })] })] })] }), navigation.pending !== null && _jsxs("section", { className: "dsmm-confirm", role: "group", "aria-label": t("leaveDraft"), onKeyDown: event => { if (event.key === "Escape" && !event.defaultPrevented) {
90
+ event.preventDefault();
91
+ workspace.continueEditing();
92
+ } }, children: [_jsx("p", { children: t("leaveDraft") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { ref: confirmation, type: "button", variant: "primary", onClick: () => workspace.continueEditing(), children: t("continueEditing") }), _jsx(Button, { type: "button", variant: "outline", onClick: () => workspace.keepAndNavigate(), children: t("keepDraft") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => void workspace.discardAndNavigate(), children: t("discardDraft") })] })] })] });
126
93
  }
127
94
  //# sourceMappingURL=DeploymentPage.js.map
@@ -0,0 +1,17 @@
1
+ import type { NativeCommandEntry } from "../permission-settings.js";
2
+ import type { PermissionLocaleKey } from "./permission-locales.js";
3
+ import type { DeploymentController } from "./deployment-controller.js";
4
+ type Text = (key: PermissionLocaleKey) => string;
5
+ export declare function validNativeEntries(entries: readonly NativeCommandEntry[]): boolean;
6
+ export declare function emptyNativeEntry(): NativeCommandEntry;
7
+ export declare function NativeCommandEntries({ value, inherited, controller, disabled, onChange, setInvalid, t }: {
8
+ value: readonly NativeCommandEntry[] | undefined;
9
+ inherited: readonly NativeCommandEntry[];
10
+ controller: DeploymentController;
11
+ disabled: boolean;
12
+ onChange(value: readonly NativeCommandEntry[] | undefined): void;
13
+ setInvalid(path: string, bad: boolean): void;
14
+ t: Text;
15
+ }): import("react").JSX.Element;
16
+ export {};
17
+ //# sourceMappingURL=NativeCommandEntries.d.ts.map
@@ -0,0 +1,68 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId, useSyncExternalStore } from "react";
3
+ import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ import { parseNativeCommands } from "../permission-settings.js";
5
+ import { parseAdvanced } from "./deployment-data.js";
6
+ export function validNativeEntries(entries) {
7
+ try {
8
+ parseNativeCommands({ entries });
9
+ return true;
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ }
15
+ export function emptyNativeEntry() {
16
+ return { id: "", mode: "ask", sandboxMode: "workspace-write", match: { tool: "bash", executable: "", args: [], workingDirectory: "" } };
17
+ }
18
+ function Arguments({ value, controller, name, disabled, onChange, t }) {
19
+ const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot), id = useId(), raw = state.raw[name], text = raw?.text ?? JSON.stringify(value), bad = raw?.invalid === true;
20
+ return _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: id, children: t("args") }), _jsx("textarea", { id: id, rows: 3, maxLength: 32768, disabled: disabled, value: text, "aria-invalid": bad, "aria-describedby": `${id}-error`, onChange: event => {
21
+ const raw = event.currentTarget.value;
22
+ let parsed;
23
+ try {
24
+ parsed = parseAdvanced(raw);
25
+ }
26
+ catch { /* Keep invalid text local until corrected. */ }
27
+ const valid = Array.isArray(parsed) && parsed.every(item => typeof item === "string" && item.trim() !== "" && !item.includes("\0") && item.length <= 32768);
28
+ controller.setRaw(name, raw, !valid);
29
+ if (valid)
30
+ onChange(parsed);
31
+ } }), _jsx("p", { id: `${id}-error`, className: "dsmm-hint", children: bad ? t("invalidEntry") : "" })] });
32
+ }
33
+ function Entry({ entry, index, controller, disabled, removeDisabled, change, remove, t }) {
34
+ const id = useId();
35
+ const valid = validNativeEntries([entry]);
36
+ const text = (key, label) => _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-${key}`, children: t(label) }), _jsx(Input, { className: "dsmm-input", id: `${id}-${key}`, value: key === "id" ? entry.id : entry.match[key] ?? "", maxLength: 32768, disabled: disabled, required: key !== "subcommand", onChange: event => {
37
+ const value = event.currentTarget.value;
38
+ if (key === "id")
39
+ change({ ...entry, id: value });
40
+ else if (key === "subcommand" && value === "") {
41
+ const { subcommand: _omitted, ...match } = entry.match;
42
+ change({ ...entry, match });
43
+ }
44
+ else
45
+ change({ ...entry, match: { ...entry.match, [key]: value } });
46
+ } })] });
47
+ return _jsxs("fieldset", { "aria-describedby": !valid ? `${id}-error` : undefined, children: [_jsxs("legend", { children: [t("nativeCommands"), " ", index + 1] }), !valid && _jsx("p", { className: "dsmm-hint", id: `${id}-error`, children: t("invalidEntry") }), text("id", "entryId"), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-tool`, children: t("tool") }), _jsx("select", { id: `${id}-tool`, disabled: disabled, value: entry.match.tool, onChange: event => {
48
+ const tool = event.currentTarget.value;
49
+ if (tool === "bash" || tool === "pwsh")
50
+ change({ ...entry, match: { ...entry.match, tool } });
51
+ }, children: ["bash", "pwsh"].map(value => _jsx("option", { value: value, children: value }, value)) })] }), text("executable", "nativeExecutable"), text("subcommand", "subcommand"), _jsx(Arguments, { value: entry.match.args, controller: controller, name: `permissionControl.nativeCommands.entries.${index}.args`, disabled: disabled, t: t, onChange: args => change({ ...entry, match: { ...entry.match, args } }) }), text("workingDirectory", "cwd"), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-sandbox`, children: t("sandboxMode") }), _jsxs("select", { id: `${id}-sandbox`, disabled: disabled, value: entry.sandboxMode, onChange: event => {
52
+ if (event.currentTarget.value === "workspace-write")
53
+ change({ ...entry, sandboxMode: "workspace-write" });
54
+ }, children: [_jsx("option", { value: "workspace-write", children: "workspace-write" }), entry.sandboxMode === "danger-full-access" && _jsxs("option", { value: "danger-full-access", disabled: true, children: ["danger-full-access (", t("source"), ")"] })] })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-mode`, children: t("mode") }), _jsxs("select", { id: `${id}-mode`, disabled: disabled, value: entry.mode, onChange: event => {
55
+ const mode = event.currentTarget.value;
56
+ if (mode === "ask" || mode === "allow")
57
+ change({ ...entry, mode });
58
+ }, children: [_jsx("option", { value: "ask", children: t("action:ask") }), _jsx("option", { value: "allow", children: t("action:allow") })] })] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled || removeDisabled, onClick: remove, children: [t("removeEntry"), " ", index + 1] })] });
59
+ }
60
+ export function NativeCommandEntries({ value, inherited, controller, disabled, onChange, setInvalid, t }) {
61
+ const entries = value ?? inherited, name = "permissionControl.nativeCommands.entries";
62
+ const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
63
+ const invalidArgs = state.invalidFields.filter(path => path.startsWith(`${name}.`) && path.endsWith(".args"));
64
+ const valid = validNativeEntries(entries);
65
+ const change = (next) => { setInvalid(name, !validNativeEntries(next ?? inherited)); onChange(next); };
66
+ return _jsxs("details", { className: "dsmm-deployment-group", children: [_jsxs("summary", { children: [t("nativeCommands"), " ", _jsx("code", { children: name })] }), _jsxs("div", { className: "dsmm-structured", children: [_jsx("p", { className: "dsmm-hint", children: t("nativeCommandsHint") }), _jsx("p", { className: "dsmm-hint", children: t("registrationUnresolved") }), _jsx("p", { className: "dsmm-hint", children: t(value === undefined ? "inheritedEntries" : "explicitEntries") }), !valid && _jsx("p", { className: "dsmm-issue", role: "alert", children: t("invalidEntry") }), invalidArgs.length > 0 && _jsx("p", { className: "dsmm-hint", children: t("invalidArgsHint") }), entries.length === 0 && _jsx("p", { children: t("noEntries") }), entries.map((entry, index) => _jsx(Entry, { entry: entry, index: index, controller: controller, disabled: disabled, removeDisabled: invalidArgs.length > 0, t: t, change: next => change(entries.map((row, position) => position === index ? next : row)), remove: () => { controller.clearRaw(name); change(entries.filter((_, position) => position !== index)); } }, index)), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || entries.length >= 1024, onClick: () => change([...entries, emptyNativeEntry()]), children: t("addEntry") }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: disabled || value === undefined && invalidArgs.length === 0, onClick: () => { controller.clearRaw(name); change(undefined); }, children: t("unset") })] })] })] });
67
+ }
68
+ //# sourceMappingURL=NativeCommandEntries.js.map
@@ -9,6 +9,6 @@ export declare function PermissionRulesEditor({ controller, state, t }: Locale &
9
9
  controller: PermissionController;
10
10
  state: PermissionView;
11
11
  }): import("react").JSX.Element;
12
- export declare function PermissionsPanel({ controller, t, sessionId }: PermissionsPanelProps): import("react").JSX.Element | null;
12
+ export declare function PermissionsPanel({ controller, t, sessionId }: PermissionsPanelProps): import("react").JSX.Element;
13
13
  export {};
14
14
  //# sourceMappingURL=PermissionsPanel.d.ts.map