@dsmm/dsmm 0.1.4 → 0.1.6

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 (52) hide show
  1. package/README.md +13 -12
  2. package/docs/compatibility.md +8 -6
  3. package/docs/migration-from-ocmm.md +8 -0
  4. package/docs/model-routing.md +22 -6
  5. package/docs/profiles.md +23 -9
  6. package/docs/releasing.md +27 -15
  7. package/docs/runtime-recovery.md +41 -14
  8. package/docs/settings-status.md +10 -8
  9. package/lib/client/ProfilesSection.js +7 -3
  10. package/lib/client/SessionProfiles.d.ts +19 -0
  11. package/lib/client/SessionProfiles.js +55 -0
  12. package/lib/client/StructuredEditor.d.ts +11 -0
  13. package/lib/client/StructuredEditor.js +74 -0
  14. package/lib/client/controller.d.ts +68 -1
  15. package/lib/client/controller.js +282 -11
  16. package/lib/client/index.d.ts +3 -1
  17. package/lib/client/index.js +47 -0
  18. package/lib/client/locales.d.ts +109 -0
  19. package/lib/client/locales.js +56 -2
  20. package/lib/client/session-labels.d.ts +8 -0
  21. package/lib/client/session-labels.js +13 -0
  22. package/lib/client/structured.d.ts +18 -0
  23. package/lib/client/structured.js +98 -0
  24. package/lib/client/styles.d.ts +1 -1
  25. package/lib/client/styles.js +14 -1
  26. package/lib/client.js +1215 -74
  27. package/lib/commands.js +1 -0
  28. package/lib/dsh-types.d.ts +16 -0
  29. package/lib/index.js +27 -1
  30. package/lib/model-routing.js +109 -23
  31. package/lib/profile-remote.d.ts +7 -1
  32. package/lib/profile-remote.js +117 -2
  33. package/lib/profile-rpc.d.ts +9 -1
  34. package/lib/profile-rpc.js +99 -2
  35. package/lib/profile-runtime.d.ts +25 -5
  36. package/lib/profile-runtime.js +193 -31
  37. package/lib/profile-store.d.ts +19 -1
  38. package/lib/profile-store.js +120 -10
  39. package/lib/profile-types.d.ts +43 -1
  40. package/lib/profiles.d.ts +1 -1
  41. package/lib/profiles.js +34 -2
  42. package/lib/role-providers.js +12 -2
  43. package/lib/role-routing.d.ts +37 -3
  44. package/lib/role-routing.js +107 -35
  45. package/lib/routing-policy.d.ts +32 -0
  46. package/lib/routing-policy.js +92 -0
  47. package/lib/runtime-recovery.js +216 -52
  48. package/lib/settings.d.ts +27 -1
  49. package/lib/settings.js +29 -7
  50. package/lib/status.d.ts +10 -2
  51. package/lib/status.js +36 -10
  52. package/package.json +8 -1
@@ -4,13 +4,13 @@
4
4
 
5
5
  `/deepwork [off|message]` changes the receiving session's mode. `/dsmm-status` reports bounded normalized state; `/dsmm-status json` returns a defensive JSON snapshot with version 1. Other input returns `Usage: /dsmm-status [json]`.
6
6
 
7
- Human-facing status/mode copy uses Deepwork. The technical commands, JSON fields, namespace and configurable `modeName` remain unchanged in 0.1.4.
7
+ Human-facing status/mode copy uses Deepwork. The technical commands, JSON fields, namespace and configurable `modeName` remain unchanged in 0.1.5.
8
8
 
9
9
  Commands belong to the native command adapter. Headless task text is not a slash-command invocation.
10
10
 
11
11
  ## DSH 0.2 deployment configuration
12
12
 
13
- The Loader plugin entry remains the deployment baseline. Structural fields are **restart-scoped**; the 0.1.4 source contract includes runtime-only file overlays for newly admitted Agents. The removed `settings.register()` service and old `$DSH_HOME/settings.yaml` namespace are not used by DSH 0.2. Copy deployment values into the profile's `cordis.patch.yml`, restart, and inspect `--dump-config` and status:
13
+ The Loader plugin entry remains the deployment baseline. Structural fields are **restart-scoped**; the 0.1.5 source contract includes runtime-only file overlays for newly admitted Agents. The removed `settings.register()` service and old `$DSH_HOME/settings.yaml` namespace are not used by DSH 0.2. Copy deployment values into the profile's `cordis.patch.yml`, restart, and inspect `--dump-config` and status:
14
14
 
15
15
  ```yaml
16
16
  - id: dsmm
@@ -30,9 +30,9 @@ The Loader plugin entry remains the deployment baseline. Structural fields are *
30
30
  enabled: false
31
31
  ```
32
32
 
33
- The 0.1.4 source contract includes the additive native Settings **Deepwork Profiles** / **Deepwork 配置档** section through the native client/authorized RPC surface. It is not a volatile SettingsForms projection and does not turn structural fields into live references. Create/read/edit/save/apply/reset operate on independent files under `<profileContext.dir>/dsmm-profiles/`; neither a Settings schema nor these docs prove completed Desktop activation. See [runtime profiles](profiles.md) for the exact allowlist, file formats and pending acceptance boundary.
33
+ The 0.1.5 source contract includes the additive native Settings **Deepwork Profiles** / **Deepwork 配置档** section through the native client/authorized RPC surface. It is not a volatile SettingsForms projection and does not turn structural fields into live references. Create/read/edit/save/apply/reset operate on independent files under `<profileContext.dir>/dsmm-profiles/`; neither a Settings schema nor these docs prove completed Desktop activation. See [runtime profiles](profiles.md) for the exact allowlist, file formats and pending acceptance boundary.
34
34
 
35
- Save changes only the draft. Explicit apply pins an immutable revision and changes settings for **new Agents only**; existing live Agents, including blank Agents, retain their admitted snapshots. Children and recovery inherit the parent snapshot. After restart, cold-resumed sessions use the current selection, not historical per-session settings. Reset restores the deployment baseline for future Agents and leaves drafts intact.
35
+ Save changes only the draft. Global Apply pins an immutable revision for **new unscoped Agents only**; existing even-blank Agents retain their admissions. The separate current-session selector uses the native view's actual session ID and idle maintenance/CAS/epoch fences. It changes only that ordinary root and future children; old children retain their old epoch. Cold resume honors an explicit sidecar or, when absent, the current global default. Global reset and session baseline pinning are distinct and leave drafts intact.
36
36
 
37
37
  ## Workflow compatibility
38
38
 
@@ -42,13 +42,13 @@ Risk-based behavior scales discovery, planning, and review to uncertainty and in
42
42
 
43
43
  ## Other settings
44
44
 
45
- `roleRouting` defaults to an empty map, configured in the deployment baseline or a selected runtime profile. Each canonical role accepts an optional fixed `primary` and an optional ordered `fallbackRoutes` list of `{provider, model, reasoningEffort?}`. It is separate from the deployment-only boolean `roles` enable map. Unknown role keys and malformed explicit routes fail closed; omitted chains and explicit empty chains have different meanings. See [model routing](model-routing.md) and [runtime recovery](runtime-recovery.md).
45
+ `roleRouting` defaults to an empty map. Each canonical role accepts optional `primary`, ordered `fallbackRoutes`, `strategy` and bounded `rateLimit` fields. Profile-level `runtimePolicy` supplies inherited strategy/retry defaults. Child Agents use their configured startup lock or explicit per-role rate-limit rollover. Ordinary top-level Agents instead preserve the native model tab's exact model/effort and only retry on that same route. Native catalog/form controls edit JSONC paths without changing native global model defaults. Only the explicit header option to switch a profile and use its model invokes native model selection; a normal profile switch does not. The deployment-only `roles` enable map remains separate. Unknown keys/malformed routes fail; omitted and explicit empty chains differ. See [model routing](model-routing.md) and [runtime recovery](runtime-recovery.md).
46
46
 
47
47
  The public schema and exported `DEFAULT_DSMM_SETTINGS` are the complete defaults. Seven core skill toggles and all twelve role toggles default on; effective application is scoped to active mode or a selected DSMM role, not global task policy. Managed preset-directory materialization remains off by default and is an export facility rather than native discovery.
48
48
 
49
- Runtime overlays allow only `defaultActive`, `roleRouting`, `workflow`, `guards`, `runtimeRecovery`, and both `deepseekV4Pro*`/`deepseekFlash*` Calibration, DefaultReasoningEffort and MaxReasoningPresets fields. `roles`, `skills`, `modeName`, `promptOrder`, `section`, `presets`, `lsp`, `sessionPersistence`, native provider/account/install controls, embedded profiles and unknown fields are rejected. Defaults resolve before deployment settings, then the selected immutable overlay. A missing selection leaves the deployment baseline unchanged.
49
+ Runtime overlays allow only `defaultActive`, `roleRouting`, `runtimePolicy`, `workflow`, `guards`, `runtimeRecovery`, and both `deepseekV4Pro*`/`deepseekFlash*` Calibration, DefaultReasoningEffort and MaxReasoningPresets fields. `roles`, `skills`, `modeName`, `promptOrder`, `section`, `presets`, `lsp`, `sessionPersistence`, native provider/account/install controls, embedded profiles and unknown fields are rejected. Defaults resolve before deployment settings, then the admitted immutable overlay. A missing global selection leaves the deployment baseline unchanged.
50
50
 
51
- Existing `deepseekV4ProCalibration`, `deepseekV4ProDefaultReasoningEffort`, and `deepseekV4ProMaxReasoningPresets` remain compatible. Flash has independent corresponding `deepseekFlash*` settings; calibration modes are off/auto/strict. Auto preserves explicit effort, strict chooses supported policy effort, and unsupported capabilities never justify guessed parameters.
51
+ Existing `deepseekV4ProCalibration`, `deepseekV4ProDefaultReasoningEffort`, and `deepseekV4ProMaxReasoningPresets` remain compatible for child Agents. Flash has independent corresponding `deepseekFlash*` settings; calibration modes are off/auto/strict. Auto preserves explicit effort, strict chooses supported policy effort, and unsupported capabilities never justify guessed parameters. Ordinary root effort is always native-owned, including when a calibration setting says strict.
52
52
 
53
53
  Guard scope defaults to `deepwork-or-dsmm-agent`; shell safety and helpers remain enabled and Git writes require host approval. LSP and runtime recovery default off. Recovery caps are finite; an empty fallback list does not enable automatic model discovery or substitution.
54
54
 
@@ -60,4 +60,6 @@ Status does not perform capability/network queries, expose credentials or provid
60
60
 
61
61
  Configured role policy/chain and the actual persisted current route are distinct facts. The normalized settings snapshot defensively copies nested role routes and lists; configuration presence is not a claim of successful provider authentication or a completed fallback.
62
62
 
63
- Status describes the receiving Agent's admitted settings; the profile UI's current selection describes future Agents. These can intentionally differ. `--dump-config` shows deployment composition, not proof of runtime-profile application or authenticated UI behavior.
63
+ For ordinary roots, effective status reports `startup-lock`, no applied profile primary/fallback chain, and reasoning action `native-owned`. The original child-role configuration remains available under `effectiveSettings`; it is not falsely presented as an automatic main-model override. `profileModel` in a session-profile response is only the declared model for an explicit user action, never proof that the native model has already changed.
64
+
65
+ Status describes the receiving Agent's admitted profile/revision/epoch, resolved strategy/retry policy and actual route state separately from future global defaults. Settings and the header selector display those scopes distinctly; a global change can intentionally differ from a live Agent. `--dump-config` shows deployment composition, not proof of runtime-profile application or authenticated UI behavior.
@@ -2,6 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useId, useRef } from "react";
3
3
  import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
4
4
  import { canReconcileSelection } from "./controller.js";
5
+ import { StructuredEditor } from "./StructuredEditor.js";
6
+ import { SessionScope } from "./SessionProfiles.js";
7
+ import { structuredDocument } from "./structured.js";
5
8
  function issueKey(issue) {
6
9
  if (issue.source === "selection")
7
10
  return issue.code === "conflict" ? "selectionConflict" : "appliedInvalid";
@@ -21,13 +24,14 @@ export function ProfilesSection(props) {
21
24
  const editorRef = useRef(null);
22
25
  const cancelRef = useRef(null);
23
26
  const hadConfirmation = useRef(false);
24
- const disabled = state.busy !== null || state.pendingEditor !== null;
27
+ const disabled = state.busy !== null || state.pendingEditor !== null || state.sessionBusy === "apply" || state.sessionBusy === "reset";
25
28
  const snapshot = state.snapshot;
26
29
  const editor = state.editor;
27
30
  const reconcilable = canReconcileSelection(snapshot);
28
31
  const selectionConflict = reconcilable && snapshot?.selectionError?.code === "conflict";
29
32
  const invalid = state.issue?.kind === "domain" && state.issue.code === "validation";
30
33
  const idInvalid = invalid && state.issue?.field === "id";
34
+ const rawInvalid = editor !== null && structuredDocument(editor.content) === null;
31
35
  useEffect(() => {
32
36
  if (state.pendingEditor !== null) {
33
37
  cancelRef.current?.focus();
@@ -53,10 +57,10 @@ export function ProfilesSection(props) {
53
57
  else if (snapshot?.selectedId !== null && snapshot?.selectedId !== undefined)
54
58
  selection = t("appliedProfile", { id: snapshot.selectedId, revision: snapshot.appliedRevision?.slice(0, 12) ?? "—" });
55
59
  const notice = state.notice === null ? "" : t(state.notice.key === "reset" ? "resetDone" : state.notice.key, { id: state.notice.id });
56
- return _jsxs("section", { className: "dsmm-profiles", "aria-labelledby": `${prefix}-title`, "aria-busy": state.busy !== null, children: [_jsx("h2", { id: `${prefix}-title`, children: t("title") }), _jsx("p", { children: t("description") }), _jsx("p", { className: "dsmm-hint", children: t("newSessions") }), _jsx("p", { "data-dsmm-selection": true, children: selection }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || snapshot === null, onClick: () => { void props.create(); }, children: t("new") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => { void props.refresh(); }, children: t(state.busy === "refresh" ? "refreshing" : "refresh") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !reconcilable || (snapshot?.selectedId === null && !selectionConflict), onClick: () => { void props.reset(); }, children: t(state.busy === "reset" ? "resetting" : "reset") })] }), snapshot !== null && _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-select`, children: t("editorSelect") }), _jsxs("select", { ref: selectRef, id: `${prefix}-select`, disabled: disabled, value: editor?.revision == null ? "" : editor.id, onChange: (event) => { if (event.currentTarget.value)
60
+ return _jsxs("section", { className: "dsmm-profiles", "aria-labelledby": `${prefix}-title`, "aria-busy": state.busy !== null, children: [_jsx("h2", { id: `${prefix}-title`, children: t("title") }), _jsx("p", { children: t("description") }), _jsx("h3", { id: `${prefix}-global`, children: t("globalScope") }), _jsx("p", { className: "dsmm-hint", children: t("newSessions") }), _jsx("p", { "data-dsmm-selection": true, children: selection }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || snapshot === null, onClick: () => { void props.create(); }, children: t("new") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => { void props.refresh(); }, children: t(state.busy === "refresh" ? "refreshing" : "refresh") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !reconcilable || (snapshot?.selectedId === null && !selectionConflict), onClick: () => { void props.reset(); }, children: t(state.busy === "reset" ? "resetting" : "reset") })] }), snapshot !== null && _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-select`, children: t("editorSelect") }), _jsxs("select", { ref: selectRef, id: `${prefix}-select`, disabled: disabled, value: editor?.revision == null ? "" : editor.id, onChange: (event) => { if (event.currentTarget.value)
57
61
  void props.open(event.currentTarget.value); }, children: [_jsx("option", { value: "", children: t(editor?.revision === null ? "newDraft" : "choose") }), snapshot.profiles.map((profile, index) => _jsxs("option", { value: profile.id, children: [profile.label === undefined ? profile.id : `${profile.label} (${profile.id})`, profile.error === undefined ? "" : ` — ${t("invalidProfile", { id: profile.id })}`] }, `${index}:${profile.id}`))] }), snapshot.profiles.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("empty") })] }), state.pendingEditor !== null && _jsxs("div", { className: "dsmm-confirm", role: "group", "aria-labelledby": `${prefix}-confirm`, onKeyDown: (event) => { if (event.key === "Escape") {
58
62
  event.preventDefault();
59
63
  props.cancelDiscard();
60
- } }, children: [_jsx("p", { id: `${prefix}-confirm`, children: t("discardPrompt") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => { void props.discardAndOpen(); }, children: t("discard") }), _jsx(Button, { ref: cancelRef, type: "button", variant: "primary", onClick: props.cancelDiscard, children: t("cancel") })] })] }), editor !== null && _jsxs("div", { className: "dsmm-editor", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-id`, children: t("profileId") }), _jsx(Input, { ref: inputRef, id: `${prefix}-id`, className: "dsmm-input", value: editor.id, disabled: disabled || editor.revision !== null, "aria-invalid": idInvalid || undefined, "aria-describedby": `${prefix}-id-hint${idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editId(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-id-hint`, className: "dsmm-hint", children: t("idHint") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-content`, children: t("configuration") }), _jsx("textarea", { ref: editorRef, id: `${prefix}-content`, rows: 12, spellCheck: false, value: editor.content, disabled: disabled, "aria-invalid": (invalid && !idInvalid) || undefined, "aria-describedby": `${prefix}-content-hint ${prefix}-structural-hint${invalid && !idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editContent(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-content-hint`, className: "dsmm-hint", children: t("configurationHint") }), _jsx("p", { id: `${prefix}-structural-hint`, className: "dsmm-hint", children: t("structuralHint") })] }), _jsx("p", { "data-dsmm-editor-state": true, children: t(state.dirty ? "dirty" : applied ? "savedApplied" : "savedNotApplied") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: disabled || !state.dirty || snapshot === null, onClick: () => { void props.save(); }, children: t(state.busy === "save" ? "saving" : "save") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || state.dirty || editor.revision === null || !reconcilable || (applied && !selectionConflict), onClick: () => { void props.apply(); }, children: t(state.busy === "apply" ? "applying" : "apply") }), editor.revision !== null && _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => { void props.reload(); }, children: t("reload") })] })] }), state.issue !== null && _jsxs("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: [_jsx("p", { children: t(issueKey(state.issue)) }), state.issue.kind === "domain" && state.issue.message !== undefined && _jsxs("p", { children: [t("details"), ": ", state.issue.message] })] }), snapshot?.selectionError !== undefined && _jsxs("div", { className: "dsmm-issue", children: [_jsxs("p", { children: [t("details"), ": ", snapshot.selectionError.message] }), _jsx("p", { children: t(selectionConflict ? "selectionConflict" : "retry") })] }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.busy === "refresh" && snapshot === null ? t("loading") : state.busy === "read" ? t("reading") : notice })] });
64
+ } }, children: [_jsx("p", { id: `${prefix}-confirm`, children: t("discardPrompt") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => { void props.discardAndOpen(); }, children: t("discard") }), _jsx(Button, { ref: cancelRef, type: "button", variant: "primary", onClick: props.cancelDiscard, children: t("cancel") })] })] }), _jsx(SessionScope, { state: state, actions: props, t: t }), _jsxs("div", { className: "dsmm-catalog", children: [_jsx("h3", { children: t("catalogTitle") }), _jsx("p", { className: "dsmm-hint", children: t("catalogHint") }), state.catalogUnavailable && _jsx("p", { className: "dsmm-hint", children: t("catalogUnavailable") }), state.catalog?.failures.map((failure) => _jsx("p", { className: "dsmm-hint", children: t("catalogFailure", { name: failure.name, id: failure.id }) }, failure.id)), _jsx(Button, { type: "button", variant: "outline", disabled: state.catalogBusy, onClick: () => { void props.refreshCatalog(); }, children: t(state.catalogBusy ? "catalogRefreshing" : "catalogRefresh") })] }), editor !== null && _jsxs("div", { className: "dsmm-editor", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-id`, children: t("profileId") }), _jsx(Input, { ref: inputRef, id: `${prefix}-id`, className: "dsmm-input", value: editor.id, disabled: disabled || editor.revision !== null, "aria-invalid": idInvalid || undefined, "aria-describedby": `${prefix}-id-hint${idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editId(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-id-hint`, className: "dsmm-hint", children: t("idHint") })] }), _jsx(StructuredEditor, { state: state, actions: props, disabled: disabled, t: t }, state.editorEpoch), _jsxs("details", { className: "dsmm-advanced", open: true, children: [_jsx("summary", { children: t("advanced") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-content`, children: t("configuration") }), _jsx("textarea", { ref: editorRef, id: `${prefix}-content`, rows: 12, spellCheck: false, value: editor.content, disabled: disabled, "aria-invalid": rawInvalid || (invalid && !idInvalid) || undefined, "aria-describedby": `${prefix}-content-hint ${prefix}-structural-hint${invalid && !idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editContent(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-content-hint`, className: "dsmm-hint", children: t("configurationHint") }), _jsx("p", { id: `${prefix}-structural-hint`, className: "dsmm-hint", children: t("structuralHint") })] })] }), _jsx("p", { "data-dsmm-editor-state": true, children: t(state.dirty ? "dirty" : applied ? "savedApplied" : "savedNotApplied") }), _jsx("p", { id: `${prefix}-global-action`, className: "dsmm-hint", children: t("globalActionHint") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: disabled || !state.dirty || snapshot === null || state.invalidFields.length > 0, onClick: () => { void props.save(); }, children: t(state.busy === "save" ? "saving" : "save") }), _jsx(Button, { type: "button", variant: "outline", "aria-describedby": `${prefix}-global-action`, disabled: disabled || state.dirty || editor.revision === null || !reconcilable || (applied && !selectionConflict), onClick: () => { void props.apply(); }, children: t(state.busy === "apply" ? "applying" : "apply") }), editor.revision !== null && _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => { void props.reload(); }, children: t("reload") })] })] }), state.issue !== null && _jsxs("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: [_jsx("p", { children: t(issueKey(state.issue)) }), state.issue.kind === "domain" && state.issue.message !== undefined && _jsxs("p", { children: [t("details"), ": ", state.issue.message] })] }), snapshot?.selectionError !== undefined && _jsxs("div", { className: "dsmm-issue", children: [_jsxs("p", { children: [t("details"), ": ", snapshot.selectionError.message] }), _jsx("p", { children: t(selectionConflict ? "selectionConflict" : "retry") })] }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.busy === "refresh" && snapshot === null ? t("loading") : state.busy === "read" ? t("reading") : notice })] });
61
65
  }
62
66
  //# sourceMappingURL=ProfilesSection.js.map
@@ -0,0 +1,19 @@
1
+ import type { InjectFace, PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
2
+ import type { ProfilesActions, ProfilesController, ProfilesViewSnapshot } from "./controller.js";
3
+ type Injected = ProfilesActions & {
4
+ hooks: {
5
+ profiles: ProfilesController["store"];
6
+ };
7
+ };
8
+ export type SessionProfilesProps = InjectFace<Injected> & PropsLocale<"settings.dsmm-profiles"> & {
9
+ sessionId?: string;
10
+ };
11
+ export declare function SessionScope({ state, actions, t, compact }: PropsLocale<"settings.dsmm-profiles"> & {
12
+ state: ProfilesViewSnapshot;
13
+ actions: ProfilesActions;
14
+ compact?: boolean;
15
+ }): import("react").JSX.Element;
16
+ /** Additive native header contribution; never operates on a different view seat. */
17
+ export declare function SessionProfiles(props: SessionProfilesProps): import("react").JSX.Element | null;
18
+ export {};
19
+ //# sourceMappingURL=SessionProfiles.d.ts.map
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { Button } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ import { sessionProfileLabels } from "./session-labels.js";
5
+ export function SessionScope({ state, actions, t, compact = false }) {
6
+ const prefix = useId();
7
+ const session = state.session;
8
+ const labels = session === null ? null : sessionProfileLabels(session, t);
9
+ const selected = state.snapshot?.profiles.find((profile) => profile.id === state.sessionChoice);
10
+ const disabled = state.busy !== null || state.pendingEditor !== null || state.sessionBusy !== null || state.dirty;
11
+ const allowed = session !== null && session.switchAllowed && /^[a-f0-9]{64}$|^absent$/u.test(session.selection.selectionRevision);
12
+ const status = state.sessionNotice === null ? "" : t(state.sessionNotice === "applied-with-model" ? "sessionAppliedWithModel" : state.sessionNotice === "applied" ? "sessionApplied" : "sessionResetDone");
13
+ return _jsxs("div", { className: "dsmm-session-scope", "aria-busy": state.sessionBusy !== null, "data-dsmm-session-scope": true, children: [!compact && _jsx("h3", { children: t("sessionScope") }), state.currentSessionId === null ? _jsx("p", { className: "dsmm-hint", children: t("noSession") }) : _jsxs(_Fragment, { children: [labels !== null && _jsx("p", { "data-dsmm-session-state": true, children: labels.admitted }), labels !== null && !compact && _jsx("p", { className: "dsmm-hint", "data-dsmm-session-future-default": true, children: labels.futureDefault }), session !== null && !session.switchAllowed && _jsx("p", { className: "dsmm-hint", children: t("sessionBusy", { reason: session.switchUnavailableReason ?? "unavailable" }) }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: disabled || !allowed, onChange: (event) => actions.chooseSessionProfile(event.currentTarget.value || null), children: [_jsx("option", { value: "", children: t("sessionBaseline") }), state.sessionChoice !== null && selected === undefined && _jsx("option", { value: state.sessionChoice, children: state.sessionChoice }), state.snapshot?.profiles.map((profile) => _jsx("option", { value: profile.id, disabled: profile.revision === null || profile.error !== undefined, children: profile.label === undefined ? profile.id : `${profile.label} (${profile.id})` }, profile.id))] })] }), state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed || (state.sessionChoice !== null && selected?.revision == null), onClick: () => { void actions.applySession(); }, children: t(state.sessionBusy === "apply" ? "sessionApplying" : "sessionApply") }), !compact && _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed, onClick: () => { void actions.resetSession(); }, children: t(state.sessionBusy === "reset" ? "sessionResetting" : "sessionReset") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.sessionBusy !== null || state.busy !== null || state.pendingEditor !== null, onClick: () => { void actions.refreshSession(); }, children: t("sessionRefresh") })] }), !compact && session?.rolePolicy !== undefined && _jsx("p", { "data-dsmm-session-policy": true, children: t("roleState", { route: session.rolePolicy.route === undefined ? t("inheritRoute") : `${session.rolePolicy.route.provider}/${session.rolePolicy.route.model}${session.rolePolicy.route.reasoningEffort === undefined ? "" : ` (${session.rolePolicy.route.reasoningEffort})`}`, strategy: session.rolePolicy.strategy, retries: session.rolePolicy.retries, failures: session.rolePolicy.rateLimitFailures, switches: session.rolePolicy.switches, delay: session.rolePolicy.totalDelayMs }) })] }), state.sessionIssue !== null && _jsx("p", { role: "alert", children: state.sessionIssue.source === "profile-model" ? t(state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed")
14
+ : state.sessionIssue.code === "conflict" ? t("sessionConflict")
15
+ : ["busy", "maintenance", "disposed", "not-owned"].includes(state.sessionIssue.code) ? t("sessionBusy", { reason: state.sessionIssue.code })
16
+ : t(state.sessionIssue.code === "validation" ? "validation" : "sessionUnavailable") }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.sessionBusy === "read" ? t("reading") : status })] });
17
+ }
18
+ /** Additive native header contribution; never operates on a different view seat. */
19
+ export function SessionProfiles(props) {
20
+ const prefix = useId();
21
+ const state = props.useProfiles((snapshot) => snapshot);
22
+ if (props.sessionId !== state.currentSessionId)
23
+ return null;
24
+ const { t } = props;
25
+ const session = state.session;
26
+ const admission = session?.admittedSelection ?? (session?.scope === "global-default" ? undefined : session?.selection);
27
+ const unknownCaptured = session !== null && admission === undefined;
28
+ const current = session === null ? "__dsmm_session_unavailable__" : unknownCaptured ? "__dsmm_captured_default__" : admission?.selectedId ?? "";
29
+ const profiles = state.snapshot?.profiles ?? [];
30
+ const currentSaved = profiles.find((profile) => profile.id === current);
31
+ const committing = state.sessionBusy !== null;
32
+ const disabled = committing || state.busy !== null || state.pendingEditor !== null || state.dirty || state.invalidFields.length > 0
33
+ || session === null || !session.switchAllowed || state.snapshot === null;
34
+ let feedback = "";
35
+ if (state.sessionIssue !== null)
36
+ feedback = t(state.sessionIssue.source === "profile-model" ? state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed" : state.sessionIssue.code === "conflict" ? "headerConflict" : "headerRefused");
37
+ else if (committing)
38
+ feedback = t(state.sessionBusy === "read" ? "headerLoading" : "headerApplying");
39
+ else if (state.dirty || state.invalidFields.length > 0 || state.pendingEditor !== null)
40
+ feedback = t("headerDraft");
41
+ else if (session === null || state.snapshot === null)
42
+ feedback = t("headerUnavailable");
43
+ else if (!session.switchAllowed)
44
+ feedback = t("headerBusy");
45
+ else if (state.sessionNotice !== null)
46
+ feedback = t(state.sessionNotice === "applied-with-model" ? "headerAppliedWithModel" : "headerApplied");
47
+ const capturedSuffix = session?.scope === "global-default" && !unknownCaptured ? ` — ${t("headerCaptured")}` : "";
48
+ return _jsxs("div", { className: "dsmm-profiles dsmm-header-profiles", "data-dsmm-header-profile": true, "aria-busy": committing, children: [_jsx("label", { htmlFor: `${prefix}-profile`, children: t("headerProfile") }), _jsxs("select", { id: `${prefix}-profile`, "aria-label": t("headerProfileLabel"), title: t("headerModelDefaultHint"), "aria-describedby": feedback === "" ? undefined : `${prefix}-feedback`, value: current, disabled: disabled, onChange: (event) => {
49
+ const value = event.currentTarget.value;
50
+ const useProfileModel = value.startsWith("@model:");
51
+ props.chooseSessionProfile((useProfileModel ? value.slice("@model:".length) : value) || null);
52
+ void props.applySession(useProfileModel ? { useProfileModel: true } : undefined);
53
+ }, children: [session === null && _jsx("option", { value: "__dsmm_session_unavailable__", disabled: true, children: t("headerUnavailable") }), unknownCaptured && _jsx("option", { value: "__dsmm_captured_default__", disabled: true, children: t("headerCaptured") }), admission?.selectedId != null && currentSaved === undefined && _jsxs("option", { value: admission.selectedId, disabled: true, children: [admission.selectedId, " \u2014 ", t("headerSavedUnavailable"), capturedSuffix] }), _jsxs("optgroup", { label: t("headerKeepModelGroup"), children: [_jsxs("option", { value: "", children: [t("sessionBaseline"), current === "" ? capturedSuffix : ""] }), profiles.map((profile) => _jsxs("option", { value: profile.id, disabled: profile.revision === null || profile.error !== undefined, children: [profile.label ?? profile.id, profile.id === current ? capturedSuffix : "", profile.error === undefined && profile.revision !== null ? "" : ` — ${t("headerSavedUnavailable")}`] }, profile.id))] }), _jsxs("optgroup", { label: t("headerUseModelGroup"), children: [_jsx("option", { value: "@model:", children: t("sessionBaseline") }), profiles.map((profile) => _jsxs("option", { value: `@model:${profile.id}`, disabled: profile.revision === null || profile.error !== undefined, children: [profile.label ?? profile.id, profile.error === undefined && profile.revision !== null ? "" : ` — ${t("headerSavedUnavailable")}`] }, profile.id))] })] }), feedback !== "" && _jsx("span", { id: `${prefix}-feedback`, role: state.sessionIssue === null ? "status" : "alert", "aria-live": "polite", children: feedback })] });
54
+ }
55
+ //# sourceMappingURL=SessionProfiles.js.map
@@ -0,0 +1,11 @@
1
+ import type { PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
2
+ import type { ProfilesActions, ProfilesViewSnapshot } from "./controller.js";
3
+ type Locale = PropsLocale<"settings.dsmm-profiles">;
4
+ /** The same raw draft drives every control; there is no form-to-document rewrite. */
5
+ export declare function StructuredEditor({ state, actions, disabled, t }: Locale & {
6
+ state: ProfilesViewSnapshot;
7
+ actions: ProfilesActions;
8
+ disabled: boolean;
9
+ }): import("react").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=StructuredEditor.d.ts.map
@@ -0,0 +1,74 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useState } from "react";
3
+ import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ import { DSMM_RATE_LIMIT_BOUNDS, normalizeRateLimitPolicy } from "../routing-policy.js";
5
+ import { structuredDocument } from "./structured.js";
6
+ import { RETRY_FIELD_LABEL_KEYS } from "./locales.js";
7
+ const MANUAL = "__dsmm_manual__";
8
+ function RetryNumber({ id, name, field, value, inherited, path, disabled, actions, t }) {
9
+ const [draft, setDraft] = useState(value === undefined ? "" : String(value));
10
+ const [invalid, setInvalid] = useState(false);
11
+ const [min, max] = DSMM_RATE_LIMIT_BOUNDS[field];
12
+ const key = path.join(".");
13
+ useEffect(() => { setDraft(value === undefined ? "" : String(value)); setInvalid(false); }, [value]);
14
+ useEffect(() => { actions.setFieldInvalid(key, invalid); return () => actions.setFieldInvalid(key, false); }, [actions.setFieldInvalid, key, invalid]);
15
+ return _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: id, children: t("retryField", { name, field: t(RETRY_FIELD_LABEL_KEYS[field]) }) }), _jsx(Input, { id: id, "data-dsmm-policy-field": field, className: "dsmm-input", type: "number", inputMode: "numeric", min: min, max: max, step: 1, disabled: disabled, value: draft, placeholder: inherited === undefined ? t("unknownDefault") : t("inheritNumber", { value: inherited }), "aria-invalid": invalid || undefined, "aria-describedby": `${id}-hint${invalid ? ` ${id}-invalid` : ""}`, onChange: (event) => {
16
+ const input = event.currentTarget;
17
+ setDraft(input.value);
18
+ const valid = input.validity.valid && (input.value === "" || Number.isSafeInteger(input.valueAsNumber));
19
+ setInvalid(!valid);
20
+ actions.setFieldInvalid(key, !valid);
21
+ if (valid)
22
+ actions.editPath(path, input.value === "" ? undefined : input.valueAsNumber);
23
+ } }), _jsx("p", { className: "dsmm-hint", id: `${id}-hint`, children: t("retryBounds", { min, max, value: inherited ?? t("unknownDefault") }) }), invalid && _jsx("p", { id: `${id}-invalid`, children: t("invalidNumber") })] });
24
+ }
25
+ function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t }) {
26
+ const prefix = useId();
27
+ const providers = catalog?.groups ?? [];
28
+ const group = providers.find((candidate) => candidate.id === value.provider);
29
+ const model = group?.models.find((candidate) => candidate.id === value.model);
30
+ const efforts = model?.reasoning?.efforts ?? [];
31
+ const providerListed = group !== undefined;
32
+ const modelListed = model !== undefined;
33
+ const updateModel = (provider, modelId) => {
34
+ // This is an explicit user change, not a catalog refresh. Clear only this
35
+ // route's adapter-owned effort; do not save or touch the native model default.
36
+ editRoute(path, provider, modelId);
37
+ };
38
+ return _jsxs("div", { className: "dsmm-route-fields", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-provider`, children: t("routeProvider", { name }) }), _jsxs("select", { id: `${prefix}-provider`, disabled: disabled, value: providerListed ? value.provider : MANUAL, onChange: (event) => updateModel(event.currentTarget.value === MANUAL ? "" : event.currentTarget.value, ""), children: [_jsx("option", { value: MANUAL, children: providerListed ? t("manual") : t("manualValue", { value: value.provider || t("unset") }) }), providers.map((provider) => _jsxs("option", { value: provider.id, children: [provider.name, " (", provider.id, ")"] }, provider.id))] }), !providerListed && _jsx(Input, { "aria-label": t("manualProvider", { name }), className: "dsmm-input", value: value.provider, disabled: disabled, onChange: (event) => updateModel(event.currentTarget.value, value.model) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-model`, children: t("routeModel", { name }) }), _jsxs("select", { id: `${prefix}-model`, disabled: disabled, value: modelListed ? value.model : MANUAL, onChange: (event) => updateModel(value.provider, event.currentTarget.value === MANUAL ? "" : event.currentTarget.value), children: [_jsx("option", { value: MANUAL, children: modelListed ? t("manual") : t("manualValue", { value: value.model || t("unset") }) }), group?.models.map((candidate) => _jsxs("option", { value: candidate.id, children: [candidate.name, " (", candidate.id, ")"] }, candidate.id))] }), !modelListed && _jsx(Input, { "aria-label": t("manualModel", { name }), className: "dsmm-input", value: value.model, disabled: disabled, onChange: (event) => updateModel(value.provider, event.currentTarget.value) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-effort`, children: t("routeEffort", { name }) }), _jsxs("select", { id: `${prefix}-effort`, disabled: disabled, value: value.reasoningEffort ?? "", onChange: (event) => edit([...path, "reasoningEffort"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("effortDefault") }), value.reasoningEffort !== undefined && !efforts.some((effort) => effort.id === value.reasoningEffort) && _jsx("option", { value: value.reasoningEffort, children: t("manualValue", { value: value.reasoningEffort }) }), efforts.map((effort) => _jsxs("option", { value: effort.id, children: [effort.name, " (", effort.id, ")"] }, effort.id))] }), _jsx(Input, { "aria-label": t("manualEffort", { name }), className: "dsmm-input", value: value.reasoningEffort ?? "", disabled: disabled, placeholder: t("effortDefault"), onChange: (event) => edit([...path, "reasoningEffort"], event.currentTarget.value || undefined) })] })] });
39
+ }
40
+ function PolicyFields({ value, inherited, path, name, disabled, actions, t }) {
41
+ const prefix = useId();
42
+ return _jsxs("div", { className: "dsmm-policy-fields", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-strategy`, children: t("strategy", { name }) }), _jsxs("select", { id: `${prefix}-strategy`, disabled: disabled, value: value.strategy ?? "", onChange: (event) => actions.editPath([...path, "strategy"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inheritStrategy", { value: inherited?.strategy ?? t("unknownDefault") }) }), _jsx("option", { value: "startup-lock", children: t("startupLock") }), _jsx("option", { value: "rate-limit-fallback", children: t("rateFallback") })] })] }), _jsx("p", { className: "dsmm-hint", children: t("strategyHint") }), _jsx("div", { className: "dsmm-route-fields", children: Object.keys(DSMM_RATE_LIMIT_BOUNDS).map((field) => _jsx(RetryNumber, { id: `${prefix}-${field}`, t: t, name: name, field: field, value: value.rateLimit?.[field], inherited: inherited?.rateLimit[field], path: [...path, "rateLimit", field], disabled: disabled, actions: actions }, field)) })] });
43
+ }
44
+ /** The same raw draft drives every control; there is no form-to-document rewrite. */
45
+ export function StructuredEditor({ state, actions, disabled, t }) {
46
+ const prefix = useId();
47
+ const [selectedRole, setSelectedRole] = useState("dsmm-orchestrator");
48
+ const document = state.editor === null ? null : structuredDocument(state.editor.content);
49
+ if (document === null)
50
+ return _jsx("p", { className: "dsmm-hint", "data-dsmm-structured-invalid": true, children: t("rawInvalid") });
51
+ const roles = state.snapshot?.roles ?? [];
52
+ const role = roles.find((candidate) => candidate.id === selectedRole) ?? roles[0];
53
+ const policy = role === undefined ? undefined : document.roleRouting[role.id] ?? {};
54
+ const baseline = state.snapshot?.editorDefaults;
55
+ let inherited;
56
+ try {
57
+ if (baseline !== undefined) {
58
+ const profileDefaults = { strategy: document.runtimePolicy.strategy ?? baseline.strategy, rateLimit: normalizeRateLimitPolicy(document.runtimePolicy.rateLimit, baseline.rateLimit) };
59
+ inherited = { strategy: role?.runtimePolicy?.strategy ?? profileDefaults.strategy, rateLimit: normalizeRateLimitPolicy(role?.runtimePolicy?.rateLimit, profileDefaults.rateLimit) };
60
+ }
61
+ }
62
+ catch { /* Invalid effective values remain a raw/Host validation error. */ }
63
+ const rolePath = ["settings", "roleRouting", role?.id ?? ""];
64
+ return _jsxs("div", { className: "dsmm-structured", "data-dsmm-structured": true, children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-label`, children: t("profileLabel") }), _jsx(Input, { id: `${prefix}-label`, className: "dsmm-input", value: document.label ?? "", disabled: disabled, onChange: (event) => actions.editPath(["label"], event.currentTarget.value || undefined) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-active`, children: t("defaultActive") }), _jsxs("select", { id: `${prefix}-active`, disabled: disabled, value: document.settings.defaultActive === undefined ? "" : String(document.settings.defaultActive), onChange: (event) => actions.editPath(["settings", "defaultActive"], event.currentTarget.value === "" ? undefined : event.currentTarget.value === "true"), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "true", children: t("enabled") }), _jsx("option", { value: "false", children: t("disabled") })] }), _jsx("p", { className: "dsmm-hint", children: t("activeHint") })] }), _jsxs("fieldset", { children: [_jsx("legend", { children: t("profileDefaults") }), _jsx(PolicyFields, { t: t, value: document.runtimePolicy, inherited: baseline, path: ["settings", "runtimePolicy"], name: t("profileDefaults"), disabled: disabled, actions: actions })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-role`, children: t("roleSelect") }), _jsxs("select", { id: `${prefix}-role`, disabled: disabled || roles.length === 0 || state.invalidFields.length > 0, value: role?.id ?? "", onChange: (event) => setSelectedRole(event.currentTarget.value), children: [roles.length === 0 && _jsx("option", { value: "", children: t("rolesUnavailable") }), roles.map((candidate) => _jsxs("option", { value: candidate.id, children: [candidate.label, candidate.enabled ? "" : ` — ${t("roleDisabled")}`] }, candidate.id))] })] }), role !== undefined && policy !== undefined && _jsxs("fieldset", { "data-dsmm-role": role.id, children: [_jsx("legend", { children: role.label }), _jsx("p", { className: "dsmm-hint", children: t(role.enabled ? "roleEnabled" : "roleDisabled") }), _jsx(PolicyFields, { t: t, value: policy, inherited: inherited, path: rolePath, name: role.label, disabled: disabled, actions: actions }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-primary-mode`, children: t("primaryMode", { name: role.label }) }), _jsxs("select", { id: `${prefix}-primary-mode`, disabled: disabled, value: policy.primary === undefined ? "inherit" : "explicit", onChange: (event) => actions.editPath([...rolePath, "primary"], event.currentTarget.value === "inherit" ? undefined : { provider: "", model: "" }), children: [_jsx("option", { value: "inherit", children: t("inheritRoute") }), _jsx("option", { value: "explicit", children: t("configuredRoute") })] })] }), policy.primary !== undefined && _jsx(RouteFields, { t: t, value: policy.primary, path: [...rolePath, "primary"], name: t("primaryName", { name: role.label }), catalog: state.catalog, disabled: disabled, edit: actions.editPath, editRoute: actions.editRoute }), _jsx("p", { className: "dsmm-hint", children: t("effortChangeHint") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-fallback-mode`, children: t("fallbackMode", { name: role.label }) }), _jsxs("select", { id: `${prefix}-fallback-mode`, disabled: disabled, value: policy.fallbackRoutes === undefined ? "inherit" : "explicit", onChange: (event) => actions.editPath([...rolePath, "fallbackRoutes"], event.currentTarget.value === "inherit" ? undefined : []), children: [_jsx("option", { value: "inherit", children: t("inheritChain") }), _jsx("option", { value: "explicit", children: t("configuredChain") })] })] }), policy.fallbackRoutes?.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("emptyChain") }), policy.fallbackRoutes?.map((candidate, index) => {
65
+ const name = t("fallbackName", { name: role.label, index: index + 1 });
66
+ return _jsxs("fieldset", { children: [_jsx("legend", { children: name }), _jsx(RouteFields, { t: t, value: candidate, path: [...rolePath, "fallbackRoutes", index], name: name, catalog: state.catalog, disabled: disabled, edit: actions.editPath, editRoute: actions.editRoute }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || index === 0, onClick: () => actions.moveFallback(role.id, index, index - 1), children: t("moveUp", { name }) }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || index === policy.fallbackRoutes.length - 1, onClick: () => actions.moveFallback(role.id, index, index + 1), children: t("moveDown", { name }) }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => actions.editPath([...rolePath, "fallbackRoutes", index], undefined), children: t("removeFallback", { name }) })] })] }, index);
67
+ }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || (policy.fallbackRoutes?.length ?? 0) >= 32, onClick: () => {
68
+ if (policy.fallbackRoutes === undefined)
69
+ actions.editPath([...rolePath, "fallbackRoutes"], [{ provider: "", model: "" }]);
70
+ else
71
+ actions.editPath([...rolePath, "fallbackRoutes", policy.fallbackRoutes.length], { provider: "", model: "" });
72
+ }, children: t("addFallback", { name: role.label }) })] })] });
73
+ }
74
+ //# sourceMappingURL=StructuredEditor.js.map
@@ -1,5 +1,12 @@
1
+ import type { RemoteResult } from "@deepseek-ai/dsh-typert-protocol";
2
+ import type { HostObservable } from "@deepseek-ai/dsh-client-ui-slots";
3
+ import type { SessionEventSource } from "@deepseek-ai/dsh-api-session-controller/client";
4
+ import type { ModelDirectoryState } from "@deepseek-ai/dsh-client-ui-model-selection/client";
1
5
  import type { DsmmProfilesRemote } from "../profile-remote.js";
2
6
  import type { ProfileErrorInfo, ProfileReadResult, ProfileSnapshot } from "../profile-types.js";
7
+ import type { SessionProfileSnapshot } from "../profile-types.js";
8
+ import type { ModelCatalog, SessionSelectModelRequest, SessionSelectModelValue } from "@deepseek-ai/dsh-api-session-controller";
9
+ import type { JsonPath } from "./structured.js";
3
10
  export interface ProfileEditor {
4
11
  id: string;
5
12
  content: string;
@@ -14,7 +21,10 @@ export interface ProfilesIssue {
14
21
  code: string;
15
22
  message?: string;
16
23
  field?: string;
17
- source?: "selection";
24
+ source?: "selection" | "profile-model";
25
+ }
26
+ export interface SessionApplyOptions {
27
+ useProfileModel?: boolean;
18
28
  }
19
29
  export interface ProfilesViewSnapshot {
20
30
  snapshot: ProfileSnapshot | null;
@@ -24,6 +34,17 @@ export interface ProfilesViewSnapshot {
24
34
  issue: ProfilesIssue | null;
25
35
  notice: ProfilesNotice | null;
26
36
  pendingEditor: string | null;
37
+ catalog: ModelCatalog | null;
38
+ catalogBusy: boolean;
39
+ catalogUnavailable: boolean;
40
+ currentSessionId: string | null;
41
+ session: SessionProfileSnapshot | null;
42
+ sessionChoice: string | null;
43
+ sessionBusy: "read" | "apply" | "reset" | null;
44
+ sessionIssue: ProfilesIssue | null;
45
+ sessionNotice: "applied" | "reset" | "applied-with-model" | null;
46
+ invalidFields: string[];
47
+ editorEpoch: number;
27
48
  }
28
49
  export interface ProfilesActions {
29
50
  refresh(): Promise<void>;
@@ -37,7 +58,23 @@ export interface ProfilesActions {
37
58
  reset(): Promise<void>;
38
59
  discardAndOpen(): Promise<void>;
39
60
  cancelDiscard(): void;
61
+ editPath(path: JsonPath, value: unknown): void;
62
+ editRoute(path: JsonPath, provider: string, model: string): void;
63
+ moveFallback(role: string, from: number, to: number): void;
64
+ refreshCatalog(): Promise<void>;
65
+ refreshSession(): Promise<void>;
66
+ chooseSessionProfile(id: string | null): void;
67
+ applySession(options?: SessionApplyOptions): Promise<void>;
68
+ resetSession(): Promise<void>;
69
+ setFieldInvalid(field: string, invalid: boolean): void;
70
+ }
71
+ export interface ModelCatalogRemote {
72
+ modelCatalog(): Promise<RemoteResult<ModelCatalog>>;
73
+ }
74
+ export interface ProfileModelSelectorRemote {
75
+ selectModel(request: SessionSelectModelRequest): Promise<RemoteResult<SessionSelectModelValue>>;
40
76
  }
77
+ type ModelInteractionSource = HostObservable<Pick<ModelDirectoryState, "status">>;
41
78
  export declare const NEW_PROFILE_CONTENT = "{\n \"version\": 1,\n \"id\": \"new-profile\",\n \"label\": \"New profile\",\n \"settings\": {\n // Runtime overlay only. Omitted fields inherit the deployment baseline.\n \"defaultActive\": true\n }\n}\n";
42
79
  /** A valid external CAS conflict is reconcilable; corruption is never reset implicitly. */
43
80
  export declare function canReconcileSelection(snapshot: ProfileSnapshot | null): boolean;
@@ -49,6 +86,24 @@ export declare class ProfilesController {
49
86
  private listeners;
50
87
  private generation;
51
88
  private disposed;
89
+ private sessionGeneration;
90
+ private catalogGeneration;
91
+ private catalogRemote;
92
+ private modelSelectorGeneration;
93
+ private modelSelector;
94
+ private modelSelectionSource;
95
+ private modelSelectionSessionId;
96
+ private modelSelectionGeneration;
97
+ private stopModelSelection;
98
+ private modelEvents;
99
+ private modelEventsSessionId;
100
+ private modelEventsGeneration;
101
+ private modelEventsWatermark;
102
+ private stopModelEvents;
103
+ private modelInteraction;
104
+ private modelInteractionSessionId;
105
+ private modelInteractionGeneration;
106
+ private stopModelInteraction;
52
107
  readonly store: {
53
108
  getSnapshot: () => ProfilesViewSnapshot;
54
109
  subscribe: (listener: () => void) => (() => void);
@@ -56,6 +111,15 @@ export declare class ProfilesController {
56
111
  readonly actions: ProfilesActions;
57
112
  constructor(remote: DsmmProfilesRemote);
58
113
  dispose(): void;
114
+ attachModelSelector(remote: ProfileModelSelectorRemote | null): void;
115
+ attachModelSelectionSource(sessionId: string | null, source: HostObservable<unknown> | null): void;
116
+ attachModelEventSource(sessionId: string | null, source: SessionEventSource | null): void;
117
+ attachModelInteractionSource(sessionId: string | null, source: ModelInteractionSource | null): void;
118
+ attachCatalog(remote: ModelCatalogRemote | null): void;
119
+ setSession(id: string | null): void;
120
+ refreshCatalog(): Promise<void>;
121
+ refreshSession(): Promise<void>;
122
+ private selectSession;
59
123
  private publish;
60
124
  private accept;
61
125
  private unwrap;
@@ -68,6 +132,9 @@ export declare class ProfilesController {
68
132
  discardAndOpen(): Promise<void>;
69
133
  private editId;
70
134
  private editContent;
135
+ private editPath;
136
+ private editRoute;
137
+ private editFallbackOrder;
71
138
  save(): Promise<void>;
72
139
  apply(): Promise<void>;
73
140
  reset(): Promise<void>;