@dsmm/dsmm 0.1.4 → 0.1.5
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.
- package/README.md +12 -12
- package/docs/compatibility.md +8 -6
- package/docs/migration-from-ocmm.md +8 -0
- package/docs/model-routing.md +19 -5
- package/docs/profiles.md +21 -9
- package/docs/releasing.md +23 -15
- package/docs/runtime-recovery.md +39 -14
- package/docs/settings-status.md +7 -7
- package/lib/client/ProfilesSection.js +7 -3
- package/lib/client/SessionProfiles.d.ts +19 -0
- package/lib/client/SessionProfiles.js +24 -0
- package/lib/client/StructuredEditor.d.ts +11 -0
- package/lib/client/StructuredEditor.js +74 -0
- package/lib/client/controller.d.ts +38 -0
- package/lib/client/controller.js +153 -11
- package/lib/client/index.d.ts +2 -0
- package/lib/client/index.js +20 -0
- package/lib/client/locales.d.ts +89 -0
- package/lib/client/locales.js +45 -2
- package/lib/client/session-labels.d.ts +8 -0
- package/lib/client/session-labels.js +13 -0
- package/lib/client/structured.d.ts +18 -0
- package/lib/client/structured.js +98 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +12 -1
- package/lib/client.js +969 -74
- package/lib/commands.js +1 -0
- package/lib/dsh-types.d.ts +16 -0
- package/lib/index.js +27 -1
- package/lib/model-routing.js +93 -23
- package/lib/profile-remote.d.ts +7 -1
- package/lib/profile-remote.js +115 -2
- package/lib/profile-rpc.d.ts +9 -1
- package/lib/profile-rpc.js +99 -2
- package/lib/profile-runtime.d.ts +24 -5
- package/lib/profile-runtime.js +182 -31
- package/lib/profile-store.d.ts +19 -1
- package/lib/profile-store.js +120 -10
- package/lib/profile-types.d.ts +41 -1
- package/lib/profiles.d.ts +1 -1
- package/lib/profiles.js +34 -2
- package/lib/role-providers.js +12 -2
- package/lib/role-routing.d.ts +37 -3
- package/lib/role-routing.js +107 -35
- package/lib/routing-policy.d.ts +32 -0
- package/lib/routing-policy.js +92 -0
- package/lib/runtime-recovery.js +213 -52
- package/lib/settings.d.ts +27 -1
- package/lib/settings.js +29 -7
- package/lib/status.d.ts +9 -1
- package/lib/status.js +29 -8
- package/package.json +5 -1
package/docs/settings-status.md
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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,11 +42,11 @@ 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
|
|
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. Startup lock is the default; rate-limit rollover is explicit per role. Native catalog/form controls edit JSONC paths without changing native global model defaults. 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
|
|
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
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.
|
|
52
52
|
|
|
@@ -60,4 +60,4 @@ 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
|
|
63
|
+
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,24 @@
|
|
|
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" ? "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.code === "conflict" ? t("sessionConflict")
|
|
14
|
+
: ["busy", "maintenance", "disposed", "not-owned"].includes(state.sessionIssue.code) ? t("sessionBusy", { reason: state.sessionIssue.code })
|
|
15
|
+
: 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 })] });
|
|
16
|
+
}
|
|
17
|
+
/** Additive native header contribution; never operates on a different view seat. */
|
|
18
|
+
export function SessionProfiles(props) {
|
|
19
|
+
const state = props.useProfiles((snapshot) => snapshot);
|
|
20
|
+
if (props.sessionId !== state.currentSessionId)
|
|
21
|
+
return null;
|
|
22
|
+
return _jsx("div", { className: "dsmm-profiles dsmm-header-profiles", children: _jsxs("details", { children: [_jsx("summary", { children: props.t("title") }), _jsx(SessionScope, { state: state, actions: props, t: props.t, compact: true })] }) });
|
|
23
|
+
}
|
|
24
|
+
//# 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,9 @@
|
|
|
1
|
+
import type { RemoteResult } from "@deepseek-ai/dsh-typert-protocol";
|
|
1
2
|
import type { DsmmProfilesRemote } from "../profile-remote.js";
|
|
2
3
|
import type { ProfileErrorInfo, ProfileReadResult, ProfileSnapshot } from "../profile-types.js";
|
|
4
|
+
import type { SessionProfileSnapshot } from "../profile-types.js";
|
|
5
|
+
import type { ModelCatalog } from "@deepseek-ai/dsh-api-session-controller";
|
|
6
|
+
import type { JsonPath } from "./structured.js";
|
|
3
7
|
export interface ProfileEditor {
|
|
4
8
|
id: string;
|
|
5
9
|
content: string;
|
|
@@ -24,6 +28,17 @@ export interface ProfilesViewSnapshot {
|
|
|
24
28
|
issue: ProfilesIssue | null;
|
|
25
29
|
notice: ProfilesNotice | null;
|
|
26
30
|
pendingEditor: string | null;
|
|
31
|
+
catalog: ModelCatalog | null;
|
|
32
|
+
catalogBusy: boolean;
|
|
33
|
+
catalogUnavailable: boolean;
|
|
34
|
+
currentSessionId: string | null;
|
|
35
|
+
session: SessionProfileSnapshot | null;
|
|
36
|
+
sessionChoice: string | null;
|
|
37
|
+
sessionBusy: "read" | "apply" | "reset" | null;
|
|
38
|
+
sessionIssue: ProfilesIssue | null;
|
|
39
|
+
sessionNotice: "applied" | "reset" | null;
|
|
40
|
+
invalidFields: string[];
|
|
41
|
+
editorEpoch: number;
|
|
27
42
|
}
|
|
28
43
|
export interface ProfilesActions {
|
|
29
44
|
refresh(): Promise<void>;
|
|
@@ -37,6 +52,18 @@ export interface ProfilesActions {
|
|
|
37
52
|
reset(): Promise<void>;
|
|
38
53
|
discardAndOpen(): Promise<void>;
|
|
39
54
|
cancelDiscard(): void;
|
|
55
|
+
editPath(path: JsonPath, value: unknown): void;
|
|
56
|
+
editRoute(path: JsonPath, provider: string, model: string): void;
|
|
57
|
+
moveFallback(role: string, from: number, to: number): void;
|
|
58
|
+
refreshCatalog(): Promise<void>;
|
|
59
|
+
refreshSession(): Promise<void>;
|
|
60
|
+
chooseSessionProfile(id: string | null): void;
|
|
61
|
+
applySession(): Promise<void>;
|
|
62
|
+
resetSession(): Promise<void>;
|
|
63
|
+
setFieldInvalid(field: string, invalid: boolean): void;
|
|
64
|
+
}
|
|
65
|
+
export interface ModelCatalogRemote {
|
|
66
|
+
modelCatalog(): Promise<RemoteResult<ModelCatalog>>;
|
|
40
67
|
}
|
|
41
68
|
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
69
|
/** A valid external CAS conflict is reconcilable; corruption is never reset implicitly. */
|
|
@@ -49,6 +76,9 @@ export declare class ProfilesController {
|
|
|
49
76
|
private listeners;
|
|
50
77
|
private generation;
|
|
51
78
|
private disposed;
|
|
79
|
+
private sessionGeneration;
|
|
80
|
+
private catalogGeneration;
|
|
81
|
+
private catalogRemote;
|
|
52
82
|
readonly store: {
|
|
53
83
|
getSnapshot: () => ProfilesViewSnapshot;
|
|
54
84
|
subscribe: (listener: () => void) => (() => void);
|
|
@@ -56,6 +86,11 @@ export declare class ProfilesController {
|
|
|
56
86
|
readonly actions: ProfilesActions;
|
|
57
87
|
constructor(remote: DsmmProfilesRemote);
|
|
58
88
|
dispose(): void;
|
|
89
|
+
attachCatalog(remote: ModelCatalogRemote | null): void;
|
|
90
|
+
setSession(id: string | null): void;
|
|
91
|
+
refreshCatalog(): Promise<void>;
|
|
92
|
+
refreshSession(): Promise<void>;
|
|
93
|
+
private selectSession;
|
|
59
94
|
private publish;
|
|
60
95
|
private accept;
|
|
61
96
|
private unwrap;
|
|
@@ -68,6 +103,9 @@ export declare class ProfilesController {
|
|
|
68
103
|
discardAndOpen(): Promise<void>;
|
|
69
104
|
private editId;
|
|
70
105
|
private editContent;
|
|
106
|
+
private editPath;
|
|
107
|
+
private editRoute;
|
|
108
|
+
private editFallbackOrder;
|
|
71
109
|
save(): Promise<void>;
|
|
72
110
|
apply(): Promise<void>;
|
|
73
111
|
reset(): Promise<void>;
|
package/lib/client/controller.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { applyEdits, modify } from "jsonc-parser";
|
|
2
1
|
import { isProfileId } from "../profile-remote.js";
|
|
2
|
+
import { editStructuredPath, moveFallback } from "./structured.js";
|
|
3
3
|
const NEW_EDITOR = "";
|
|
4
4
|
export 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';
|
|
5
5
|
/** A valid external CAS conflict is reconcilable; corruption is never reset implicitly. */
|
|
@@ -10,11 +10,15 @@ export function canReconcileSelection(snapshot) {
|
|
|
10
10
|
/** Stable native Store seat, with no filesystem or transport authority. */
|
|
11
11
|
export class ProfilesController {
|
|
12
12
|
remote;
|
|
13
|
-
current = { snapshot: null, editor: null, dirty: false, busy: null, issue: null, notice: null, pendingEditor: null
|
|
13
|
+
current = { snapshot: null, editor: null, dirty: false, busy: null, issue: null, notice: null, pendingEditor: null,
|
|
14
|
+
catalog: null, catalogBusy: false, catalogUnavailable: true, currentSessionId: null, session: null, sessionChoice: null, sessionBusy: null, sessionIssue: null, sessionNotice: null, invalidFields: [], editorEpoch: 0 };
|
|
14
15
|
accepted = null;
|
|
15
16
|
listeners = new Set();
|
|
16
17
|
generation = 0;
|
|
17
18
|
disposed = false;
|
|
19
|
+
sessionGeneration = 0;
|
|
20
|
+
catalogGeneration = 0;
|
|
21
|
+
catalogRemote = null;
|
|
18
22
|
store = {
|
|
19
23
|
getSnapshot: () => this.current,
|
|
20
24
|
subscribe: (listener) => {
|
|
@@ -27,11 +31,116 @@ export class ProfilesController {
|
|
|
27
31
|
editId: (id) => this.editId(id), editContent: (content) => this.editContent(content),
|
|
28
32
|
save: () => this.save(), apply: () => this.apply(), reset: () => this.reset(),
|
|
29
33
|
discardAndOpen: () => this.discardAndOpen(), cancelDiscard: () => this.publish({ pendingEditor: null }),
|
|
34
|
+
editPath: (path, value) => this.editPath(path, value), moveFallback: (role, from, to) => this.editFallbackOrder(role, from, to),
|
|
35
|
+
editRoute: (path, provider, model) => this.editRoute(path, provider, model),
|
|
36
|
+
refreshCatalog: () => this.refreshCatalog(), refreshSession: () => this.refreshSession(),
|
|
37
|
+
chooseSessionProfile: (id) => { if (!this.disposed && this.current.sessionBusy === null && this.current.busy === null && !this.current.dirty)
|
|
38
|
+
this.publish({ sessionChoice: id, sessionNotice: null }); },
|
|
39
|
+
applySession: () => this.selectSession(false), resetSession: () => this.selectSession(true),
|
|
40
|
+
setFieldInvalid: (field, invalid) => {
|
|
41
|
+
if (this.disposed)
|
|
42
|
+
return;
|
|
43
|
+
const invalidFields = this.current.invalidFields.filter((candidate) => candidate !== field);
|
|
44
|
+
if (invalid)
|
|
45
|
+
invalidFields.push(field);
|
|
46
|
+
if (invalidFields.join("\n") !== this.current.invalidFields.join("\n"))
|
|
47
|
+
this.publish({ invalidFields, ...(invalid ? { dirty: true } : {}) });
|
|
48
|
+
},
|
|
30
49
|
};
|
|
31
50
|
constructor(remote) {
|
|
32
51
|
this.remote = remote;
|
|
33
52
|
}
|
|
34
|
-
dispose() { this.disposed = true; this.generation += 1; this.listeners.clear(); }
|
|
53
|
+
dispose() { this.disposed = true; this.generation += 1; this.sessionGeneration += 1; this.catalogGeneration += 1; this.catalogRemote = null; this.listeners.clear(); }
|
|
54
|
+
attachCatalog(remote) {
|
|
55
|
+
if (this.disposed)
|
|
56
|
+
return;
|
|
57
|
+
this.catalogGeneration += 1;
|
|
58
|
+
this.catalogRemote = remote;
|
|
59
|
+
this.publish({ catalogBusy: false, catalogUnavailable: remote === null });
|
|
60
|
+
if (remote !== null)
|
|
61
|
+
void this.refreshCatalog();
|
|
62
|
+
}
|
|
63
|
+
setSession(id) {
|
|
64
|
+
if (this.disposed || id === this.current.currentSessionId)
|
|
65
|
+
return;
|
|
66
|
+
this.sessionGeneration += 1;
|
|
67
|
+
this.publish({ currentSessionId: id, session: null, sessionChoice: null, sessionBusy: null, sessionIssue: null, sessionNotice: null });
|
|
68
|
+
if (id !== null)
|
|
69
|
+
void this.refreshSession();
|
|
70
|
+
}
|
|
71
|
+
async refreshCatalog() {
|
|
72
|
+
if (this.disposed || this.current.catalogBusy || this.catalogRemote === null)
|
|
73
|
+
return;
|
|
74
|
+
const remote = this.catalogRemote, generation = ++this.catalogGeneration;
|
|
75
|
+
this.publish({ catalogBusy: true });
|
|
76
|
+
try {
|
|
77
|
+
const catalog = await this.unwrap(remote.modelCatalog());
|
|
78
|
+
if (!this.disposed && generation === this.catalogGeneration)
|
|
79
|
+
this.publish({ catalog, catalogUnavailable: false });
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
if (!this.disposed && generation === this.catalogGeneration)
|
|
83
|
+
this.publish({ catalogUnavailable: true });
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
if (!this.disposed && generation === this.catalogGeneration)
|
|
87
|
+
this.publish({ catalogBusy: false });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async refreshSession() {
|
|
91
|
+
const id = this.current.currentSessionId;
|
|
92
|
+
if (this.disposed || id === null || this.current.sessionBusy !== null)
|
|
93
|
+
return;
|
|
94
|
+
const generation = ++this.sessionGeneration;
|
|
95
|
+
const live = () => !this.disposed && generation === this.sessionGeneration && id === this.current.currentSessionId;
|
|
96
|
+
this.publish({ sessionBusy: "read", sessionIssue: null, sessionNotice: null });
|
|
97
|
+
try {
|
|
98
|
+
const session = await this.unwrap(this.remote.describeSession(id));
|
|
99
|
+
if (session.sessionId !== id)
|
|
100
|
+
throw { kind: "assembly", code: "unavailable" };
|
|
101
|
+
if (live())
|
|
102
|
+
this.publish({ session, sessionChoice: session.selection.selectedId });
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (live())
|
|
106
|
+
this.publish({ sessionIssue: this.issue(error) });
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
if (live())
|
|
110
|
+
this.publish({ sessionBusy: null });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async selectSession(reset) {
|
|
114
|
+
const { currentSessionId: id, session, sessionChoice, snapshot } = this.current;
|
|
115
|
+
if (this.disposed || id === null || session === null || !session.switchAllowed || this.current.sessionBusy !== null
|
|
116
|
+
|| this.current.busy !== null || this.current.dirty || this.current.pendingEditor !== null)
|
|
117
|
+
return;
|
|
118
|
+
const selectedId = reset ? null : sessionChoice;
|
|
119
|
+
const revision = snapshot?.profiles.find((profile) => profile.id === selectedId)?.revision;
|
|
120
|
+
if (selectedId !== null && revision == null)
|
|
121
|
+
return;
|
|
122
|
+
const generation = ++this.sessionGeneration;
|
|
123
|
+
const live = () => !this.disposed && generation === this.sessionGeneration && id === this.current.currentSessionId;
|
|
124
|
+
this.publish({ sessionBusy: reset ? "reset" : "apply", sessionIssue: null, sessionNotice: null });
|
|
125
|
+
try {
|
|
126
|
+
const accepted = await this.unwrap(this.remote.selectSession(id, {
|
|
127
|
+
sessionId: id, id: selectedId, ...(selectedId === null ? {} : { expectedRevision: revision }),
|
|
128
|
+
expectedSelectionRevision: session.selection.selectionRevision, expectedAdmissionEpoch: session.admissionEpoch,
|
|
129
|
+
}));
|
|
130
|
+
if (accepted.sessionId !== id)
|
|
131
|
+
throw { kind: "assembly", code: "unavailable" };
|
|
132
|
+
if (live())
|
|
133
|
+
this.publish({ session: accepted, sessionChoice: accepted.selection.selectedId, sessionNotice: reset ? "reset" : "applied" });
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (live())
|
|
137
|
+
this.publish({ sessionIssue: this.issue(error) });
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
if (live())
|
|
141
|
+
this.publish({ sessionBusy: null });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
35
144
|
publish(patch) {
|
|
36
145
|
if (this.disposed)
|
|
37
146
|
return;
|
|
@@ -41,7 +150,7 @@ export class ProfilesController {
|
|
|
41
150
|
}
|
|
42
151
|
accept(document) {
|
|
43
152
|
this.accepted = { ...document };
|
|
44
|
-
this.publish({ editor: { ...document }, dirty: false, pendingEditor: null });
|
|
153
|
+
this.publish({ editor: { ...document }, dirty: false, pendingEditor: null, invalidFields: [], editorEpoch: this.current.editorEpoch + 1 });
|
|
45
154
|
}
|
|
46
155
|
async unwrap(request, field) {
|
|
47
156
|
const result = await request;
|
|
@@ -61,7 +170,7 @@ export class ProfilesController {
|
|
|
61
170
|
return { kind: "assembly", code: "unavailable" };
|
|
62
171
|
}
|
|
63
172
|
async perform(busy, operation) {
|
|
64
|
-
if (this.disposed || this.current.busy !== null || this.current.pendingEditor !== null)
|
|
173
|
+
if (this.disposed || this.current.busy !== null || this.current.sessionBusy === "apply" || this.current.sessionBusy === "reset" || this.current.pendingEditor !== null)
|
|
65
174
|
return;
|
|
66
175
|
const generation = ++this.generation;
|
|
67
176
|
const live = () => !this.disposed && generation === this.generation;
|
|
@@ -109,7 +218,7 @@ export class ProfilesController {
|
|
|
109
218
|
async loadEditor(id) {
|
|
110
219
|
if (id === NEW_EDITOR) {
|
|
111
220
|
this.accepted = null;
|
|
112
|
-
this.publish({ editor: { id: "new-profile", content: NEW_PROFILE_CONTENT, revision: null }, dirty: true, issue: null, notice: null, pendingEditor: null });
|
|
221
|
+
this.publish({ editor: { id: "new-profile", content: NEW_PROFILE_CONTENT, revision: null }, dirty: true, issue: null, notice: null, pendingEditor: null, invalidFields: [], editorEpoch: this.current.editorEpoch + 1 });
|
|
113
222
|
return;
|
|
114
223
|
}
|
|
115
224
|
await this.perform("read", async (live) => {
|
|
@@ -136,11 +245,11 @@ export class ProfilesController {
|
|
|
136
245
|
const editor = this.current.editor;
|
|
137
246
|
if (editor === null || editor.revision !== null || this.current.busy !== null || this.current.pendingEditor !== null)
|
|
138
247
|
return;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
248
|
+
const content = editStructuredPath(editor.content, ["id"], id);
|
|
249
|
+
if (content === null) {
|
|
250
|
+
this.publish({ issue: { kind: "domain", code: "validation", field: "content" }, notice: null });
|
|
251
|
+
return;
|
|
142
252
|
}
|
|
143
|
-
catch { /* Keep invalid JSONC intact; the Host explains validation on save. */ }
|
|
144
253
|
this.publish({ editor: { ...editor, id, content }, dirty: true, issue: null, notice: null });
|
|
145
254
|
}
|
|
146
255
|
editContent(content) {
|
|
@@ -149,9 +258,42 @@ export class ProfilesController {
|
|
|
149
258
|
return;
|
|
150
259
|
this.publish({ editor: { ...editor, content }, dirty: this.accepted === null || this.accepted.content !== content || this.accepted.id !== editor.id, issue: null, notice: null });
|
|
151
260
|
}
|
|
261
|
+
editPath(path, value) {
|
|
262
|
+
const editor = this.current.editor;
|
|
263
|
+
if (editor === null || this.current.busy !== null || this.current.pendingEditor !== null)
|
|
264
|
+
return;
|
|
265
|
+
const content = editStructuredPath(editor.content, path, value);
|
|
266
|
+
if (content === null) {
|
|
267
|
+
this.publish({ issue: { kind: "domain", code: "validation", field: "content" }, notice: null });
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
this.editContent(content);
|
|
271
|
+
}
|
|
272
|
+
editRoute(path, provider, model) {
|
|
273
|
+
const editor = this.current.editor;
|
|
274
|
+
if (editor === null || this.current.busy !== null || this.current.pendingEditor !== null)
|
|
275
|
+
return;
|
|
276
|
+
let content = editor.content;
|
|
277
|
+
for (const [key, value] of [["provider", provider], ["model", model], ["reasoningEffort", undefined]]) {
|
|
278
|
+
content = editStructuredPath(content, [...path, key], value);
|
|
279
|
+
if (content === null) {
|
|
280
|
+
this.publish({ issue: { kind: "domain", code: "validation", field: "content" }, notice: null });
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
this.editContent(content);
|
|
285
|
+
}
|
|
286
|
+
editFallbackOrder(role, from, to) {
|
|
287
|
+
const editor = this.current.editor;
|
|
288
|
+
if (editor === null || this.current.busy !== null || this.current.pendingEditor !== null)
|
|
289
|
+
return;
|
|
290
|
+
const content = moveFallback(editor.content, role, from, to);
|
|
291
|
+
if (content !== null)
|
|
292
|
+
this.editContent(content);
|
|
293
|
+
}
|
|
152
294
|
async save() {
|
|
153
295
|
const editor = this.current.editor;
|
|
154
|
-
if (editor === null || !this.current.dirty || this.current.snapshot === null || this.current.busy !== null || this.current.pendingEditor !== null)
|
|
296
|
+
if (editor === null || !this.current.dirty || this.current.snapshot === null || this.current.busy !== null || this.current.pendingEditor !== null || this.current.invalidFields.length > 0)
|
|
155
297
|
return;
|
|
156
298
|
if (!isProfileId(editor.id)) {
|
|
157
299
|
this.publish({ issue: { kind: "domain", code: "validation", field: "id" }, notice: null });
|
package/lib/client/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export { ProfilesSection } from "./ProfilesSection.js";
|
|
|
5
5
|
export type { ProfilesSectionProps, ProfilesInjected } from "./ProfilesSection.js";
|
|
6
6
|
export { NS, en, zh } from "./locales.js";
|
|
7
7
|
export { TYPERT_REMOTE } from "../profile-remote.js";
|
|
8
|
+
export { SessionProfiles } from "./SessionProfiles.js";
|
|
9
|
+
export { structuredDocument, editStructuredPath, moveFallback } from "./structured.js";
|
|
8
10
|
/** No self-dependency on a namespace that this contribution has not mounted. */
|
|
9
11
|
export declare const inject: readonly ["slots", "locale", "remote"];
|
|
10
12
|
export declare function apply(ctx: Context): Promise<void>;
|