@dsmm/dsmm 0.3.12 → 0.3.14
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 +2 -2
- package/docs/agent-presets.md +1 -1
- package/docs/compatibility.md +8 -2
- package/docs/deferred-native-approval-risk.md +4 -4
- package/docs/design.md +1 -1
- package/docs/lsp.md +1 -1
- package/docs/maintenance.md +9 -3
- package/docs/model-routing.md +1 -1
- package/docs/native-permissions.md +12 -2
- package/docs/profiles.md +32 -13
- package/docs/roadmap.md +67 -30
- package/docs/runtime-recovery.md +1 -1
- package/docs/safety-guards.md +1 -1
- package/docs/settings-status.md +1 -1
- package/docs/testing.md +85 -0
- package/lib/client/DeploymentPage.js +31 -2
- package/lib/client/PermissionsPanel.js +1 -1
- package/lib/client/ProfileModelsDialog.d.ts +24 -0
- package/lib/client/ProfileModelsDialog.js +353 -0
- package/lib/client/ProfilesSection.js +209 -37
- package/lib/client/RoleToolView-data.d.ts +7 -0
- package/lib/client/RoleToolView-data.js +45 -0
- package/lib/client/RoleToolView-locales.d.ts +5 -0
- package/lib/client/RoleToolView-locales.js +2 -0
- package/lib/client/RoleToolView.js +33 -8
- package/lib/client/SessionProfiles.js +24 -6
- package/lib/client/StructuredEditor.d.ts +32 -4
- package/lib/client/StructuredEditor.js +12 -40
- package/lib/client/children-locales.d.ts +1 -1
- package/lib/client/controller.d.ts +23 -1
- package/lib/client/controller.js +289 -8
- package/lib/client/diagnostics.d.ts +1 -0
- package/lib/client/diagnostics.js +9 -0
- package/lib/client/index.js +10 -2
- package/lib/client/locales.d.ts +29 -0
- package/lib/client/locales.js +54 -2
- package/lib/client/profile-blank.d.ts +43 -0
- package/lib/client/profile-blank.js +19 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +96 -32
- package/lib/client.js +2411 -1040
- package/lib/command-approval.d.ts +2 -0
- package/lib/command-approval.js +4 -1
- package/lib/index.js +2 -1
- package/lib/native-admission.d.ts +10 -3
- package/lib/native-admission.js +129 -28
- package/lib/profile-runtime.js +3 -5
- package/package.json +7 -2
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useId, useRef } from "react";
|
|
2
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
3
3
|
import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
|
|
4
4
|
import { canReconcileSelection } from "./controller.js";
|
|
5
5
|
import { AdvancedSettings, RouteFields } from "./StructuredEditor.js";
|
|
6
|
+
import { ProfileModelsDialog } from "./ProfileModelsDialog.js";
|
|
6
7
|
import { SessionScope, SessionScopeFeedback } from "./SessionProfiles.js";
|
|
7
8
|
import { sessionProfileLabels } from "./session-labels.js";
|
|
8
9
|
import { structuredDocument } from "./structured.js";
|
|
9
|
-
import { draftWarnings, IssueDetails, ProfileWarnings } from "./diagnostics.js";
|
|
10
|
+
import { draftWarnings, IssueDetails, issueKey, ProfileWarnings } from "./diagnostics.js";
|
|
10
11
|
import { configurationVersionState, sourceRelationship } from "./configuration-display.js";
|
|
11
12
|
import { DSMM_LOCALES } from "../profile-locale.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
import { DSMM_RATE_LIMIT_BOUNDS } from "../routing-policy.js";
|
|
14
|
+
function locateGlobalField(container, field) {
|
|
15
|
+
const path = field.replace(/^settings\./, "");
|
|
16
|
+
const selectors = {
|
|
17
|
+
"runtimePolicy.strategy": "select[id$='-strategy']",
|
|
18
|
+
"guards.gitWriteGuard": "select[id$='-git-guard']",
|
|
19
|
+
"guards.gitWriteScope": "select[id$='-git-scope']",
|
|
20
|
+
"subagents.toolTopology": "select[id$='-topology']",
|
|
21
|
+
};
|
|
22
|
+
const rateLimit = /^runtimePolicy\.rateLimit\.([a-zA-Z]+)$/.exec(path);
|
|
23
|
+
const selector = rateLimit && Object.hasOwn(DSMM_RATE_LIMIT_BOUNDS, rateLimit[1])
|
|
24
|
+
? `input[data-dsmm-policy-field='${rateLimit[1]}']`
|
|
25
|
+
: Object.hasOwn(selectors, path) ? selectors[path] : undefined;
|
|
26
|
+
return selector === undefined ? null : container.querySelector(selector);
|
|
20
27
|
}
|
|
21
28
|
/** One native settings.section; policy selection is never coupled to browsing. */
|
|
22
29
|
export function ProfilesSection(props) {
|
|
@@ -34,8 +41,14 @@ export function ProfilesSection(props) {
|
|
|
34
41
|
const cancelRef = useRef(null);
|
|
35
42
|
const hadConfirmation = useRef(false);
|
|
36
43
|
const initiatorRef = useRef(null);
|
|
44
|
+
const dialogInitiatorRef = useRef(null);
|
|
45
|
+
const saveBarRef = useRef(null);
|
|
37
46
|
const orchestratorRef = useRef(null);
|
|
38
47
|
const sessionScopeRef = useRef(null);
|
|
48
|
+
const [modelsDialogOpen, setModelsDialogOpen] = useState(false);
|
|
49
|
+
const [targetRole, setTargetRole] = useState(null);
|
|
50
|
+
const [targetRoleField, setTargetRoleField] = useState(null);
|
|
51
|
+
const pendingDialogFocus = useRef(null);
|
|
39
52
|
const advancedOpenRef = useRef(false);
|
|
40
53
|
const jsoncOpenRef = useRef(false);
|
|
41
54
|
const moreActionsOpenRef = useRef(false);
|
|
@@ -51,11 +64,69 @@ export function ProfilesSection(props) {
|
|
|
51
64
|
const idInvalid = invalid && state.issue?.field === "id" && state.issue.location === undefined && editor?.revision === null && !editorDisabled;
|
|
52
65
|
const structuredDoc = editor === null ? null : structuredDocument(editor.content);
|
|
53
66
|
const lastValidBasicDocRef = useRef(null);
|
|
54
|
-
if (structuredDoc !== null) {
|
|
55
|
-
lastValidBasicDocRef.current = structuredDoc;
|
|
67
|
+
if (editor !== null && structuredDoc !== null) {
|
|
68
|
+
lastValidBasicDocRef.current = { id: editor.id, epoch: state.editorEpoch, doc: structuredDoc };
|
|
56
69
|
}
|
|
57
|
-
const basicDoc = structuredDoc ?? lastValidBasicDocRef.current;
|
|
70
|
+
const basicDoc = structuredDoc ?? (lastValidBasicDocRef.current !== null && lastValidBasicDocRef.current.id === editor?.id && lastValidBasicDocRef.current.epoch === state.editorEpoch ? lastValidBasicDocRef.current.doc : null);
|
|
58
71
|
const rawInvalid = editor !== null && structuredDoc === null;
|
|
72
|
+
const canSave = !editorDisabled && state.dirty && snapshot !== null && state.invalidFields.length === 0 && !rawInvalid;
|
|
73
|
+
function focusJsonc(location) {
|
|
74
|
+
if (advancedRef.current !== null) {
|
|
75
|
+
advancedRef.current.open = true;
|
|
76
|
+
jsoncOpenRef.current = true;
|
|
77
|
+
}
|
|
78
|
+
const input = editorRef.current;
|
|
79
|
+
if (input === null)
|
|
80
|
+
return false;
|
|
81
|
+
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
82
|
+
input.scrollIntoView?.({ behavior: reducedMotion ? "auto" : "smooth", block: "nearest" });
|
|
83
|
+
input.focus();
|
|
84
|
+
if (input.ownerDocument.activeElement !== input)
|
|
85
|
+
return false;
|
|
86
|
+
if (location !== undefined && location.offset + location.length <= input.value.length) {
|
|
87
|
+
input.setSelectionRange(location.offset, location.offset + location.length);
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
function focusGlobalField(field) {
|
|
92
|
+
const container = advancedSettingsRef.current;
|
|
93
|
+
if (container === null)
|
|
94
|
+
return false;
|
|
95
|
+
const target = locateGlobalField(container, field);
|
|
96
|
+
if (target === null)
|
|
97
|
+
return false;
|
|
98
|
+
container.open = true;
|
|
99
|
+
advancedOpenRef.current = true;
|
|
100
|
+
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
101
|
+
target.scrollIntoView?.({ behavior: reducedMotion ? "auto" : "smooth", block: "nearest" });
|
|
102
|
+
target.focus();
|
|
103
|
+
return target.ownerDocument.activeElement === target;
|
|
104
|
+
}
|
|
105
|
+
function closeModelsDialog(kind) {
|
|
106
|
+
pendingDialogFocus.current = { kind, editorEpoch: state.editorEpoch, validationEpoch: state.validationEpoch,
|
|
107
|
+
issue: state.issue, trigger: dialogInitiatorRef.current };
|
|
108
|
+
setModelsDialogOpen(false);
|
|
109
|
+
setTargetRole(null);
|
|
110
|
+
setTargetRoleField(null);
|
|
111
|
+
}
|
|
112
|
+
// Passive effect cleanup restores Modal isolation before the new focus destination runs.
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (modelsDialogOpen)
|
|
115
|
+
return;
|
|
116
|
+
const pending = pendingDialogFocus.current;
|
|
117
|
+
if (pending === null)
|
|
118
|
+
return;
|
|
119
|
+
pendingDialogFocus.current = null;
|
|
120
|
+
if (pending.editorEpoch !== state.editorEpoch || pending.validationEpoch !== state.validationEpoch || pending.issue !== state.issue)
|
|
121
|
+
return;
|
|
122
|
+
if (pending.kind === "jsonc") {
|
|
123
|
+
if (focusJsonc(pending.issue?.location))
|
|
124
|
+
handledValidation.current = pending.validationEpoch;
|
|
125
|
+
}
|
|
126
|
+
else if (pending.trigger?.isConnected) {
|
|
127
|
+
pending.trigger.focus();
|
|
128
|
+
}
|
|
129
|
+
}, [modelsDialogOpen, state.editorEpoch, state.validationEpoch, state.issue]);
|
|
59
130
|
useEffect(() => {
|
|
60
131
|
if (state.pendingEditor !== null) {
|
|
61
132
|
cancelRef.current?.focus();
|
|
@@ -73,33 +144,39 @@ export function ProfilesSection(props) {
|
|
|
73
144
|
}, [state.pendingEditor]);
|
|
74
145
|
useEffect(() => {
|
|
75
146
|
if (state.busy === null && state.validationEpoch > handledValidation.current && state.issue?.kind === "domain" && state.issue.code === "validation") {
|
|
76
|
-
handledValidation.current = state.validationEpoch;
|
|
77
147
|
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
78
148
|
const scrollOpt = { behavior: reducedMotion ? "auto" : "smooth", block: "nearest" };
|
|
79
|
-
|
|
149
|
+
// Case 1: ID field
|
|
150
|
+
if (state.issue.location === undefined && (state.issue.field === "id" || state.issue.field === "newId") && inputRef.current !== null
|
|
80
151
|
&& !inputRef.current.disabled && !inputRef.current.readOnly) {
|
|
152
|
+
handledValidation.current = state.validationEpoch;
|
|
81
153
|
if (typeof inputRef.current.scrollIntoView === "function")
|
|
82
154
|
inputRef.current.scrollIntoView(scrollOpt);
|
|
83
155
|
inputRef.current.focus();
|
|
156
|
+
return;
|
|
84
157
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
input.focus();
|
|
95
|
-
const location = state.issue.location;
|
|
96
|
-
if (location !== undefined && location.offset + location.length <= input.value.length) {
|
|
97
|
-
input.setSelectionRange(location.offset, location.offset + location.length);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
158
|
+
// Case 2: Role field that maps to snapshot role
|
|
159
|
+
const field = state.issue.field ?? "";
|
|
160
|
+
const roleMatch = /^(?:settings\.)?(?:roleRouting|roles)\.([a-zA-Z0-9_-]+)(?:\.|$)/.exec(field);
|
|
161
|
+
const roleId = roleMatch?.[1];
|
|
162
|
+
if (roleId && snapshot?.roles?.some(r => r.id === roleId)) {
|
|
163
|
+
setTargetRole(roleId);
|
|
164
|
+
setTargetRoleField(field);
|
|
165
|
+
setModelsDialogOpen(true);
|
|
166
|
+
return;
|
|
100
167
|
}
|
|
168
|
+
// Case 3: Global setting in advanced settings
|
|
169
|
+
if (focusGlobalField(field)) {
|
|
170
|
+
handledValidation.current = state.validationEpoch;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// Case 4: Unmapped Host diagnostic or missing role in inventory -> JSONC fallback with UTF16 offset/length
|
|
174
|
+
if (modelsDialogOpen)
|
|
175
|
+
closeModelsDialog("jsonc");
|
|
176
|
+
else if (focusJsonc(state.issue.location))
|
|
177
|
+
handledValidation.current = state.validationEpoch;
|
|
101
178
|
}
|
|
102
|
-
}, [state.issue, state.busy, state.validationEpoch]);
|
|
179
|
+
}, [state.issue, state.busy, state.validationEpoch, snapshot?.roles]);
|
|
103
180
|
const relationship = editor?.revision != null && editor.id === snapshot?.selectedId ? sourceRelationship(snapshot, editor.revision) : "changed";
|
|
104
181
|
const applied = relationship === "current";
|
|
105
182
|
let selection = t(snapshot === null ? "unavailable" : "baseline");
|
|
@@ -108,6 +185,34 @@ export function ProfilesSection(props) {
|
|
|
108
185
|
else if (snapshot?.selectedId !== null && snapshot?.selectedId !== undefined)
|
|
109
186
|
selection = t("appliedProfile", { id: snapshot.selectedId, revision: t(configurationVersionState(snapshot.sourceRevision)) });
|
|
110
187
|
const notice = state.notice === null ? "" : t(state.notice.key === "reset" ? "resetDone" : state.notice.key, { id: state.notice.id });
|
|
188
|
+
useEffect(() => {
|
|
189
|
+
const el = saveBarRef.current;
|
|
190
|
+
if (!el)
|
|
191
|
+
return;
|
|
192
|
+
const parent = el.closest(".dsmm-editor");
|
|
193
|
+
const update = () => {
|
|
194
|
+
const height = el.offsetHeight;
|
|
195
|
+
if (parent) {
|
|
196
|
+
parent.style.setProperty("--dsmm-save-bar-offset", `${height}px`);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
update();
|
|
200
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
201
|
+
const ro = new ResizeObserver(update);
|
|
202
|
+
ro.observe(el);
|
|
203
|
+
return () => {
|
|
204
|
+
ro.disconnect();
|
|
205
|
+
if (parent) {
|
|
206
|
+
parent.style.removeProperty("--dsmm-save-bar-offset");
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return () => {
|
|
211
|
+
if (parent) {
|
|
212
|
+
parent.style.removeProperty("--dsmm-save-bar-offset");
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}, [editor?.id, state.dirty, state.invalidFields.length, rawInvalid, invalid]);
|
|
111
216
|
const warnings = editor === null ? [] : draftWarnings(editor.content);
|
|
112
217
|
return _jsxs("section", { className: "dsmm-profiles dsmm-named-profiles", "aria-label": t("title"), "aria-busy": state.busy !== null, children: [readOnly && _jsx("p", { role: "status", className: "dsmm-hint", children: t("readOnlyOrigin") }), _jsx("h2", { children: t("title") }), _jsx("p", { className: "dsmm-hint", children: t("description") }), _jsxs("div", { className: "dsmm-browse-row", children: [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) => { initiatorRef.current = event.currentTarget; if (event.currentTarget.value)
|
|
113
218
|
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?.trim() ? `${profile.label} (${profile.id})` : profile.id, profile.error === undefined ? "" : ` — ${t("invalidProfile", { id: profile.id })}`, profile.warnings?.length ? ` — ${t("warningProfile")}` : ""] }, `${index}:${profile.id}`))] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || snapshot === null, onClick: (event) => { initiatorRef.current = event.currentTarget; void props.create(); }, children: t("new") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: (event) => { initiatorRef.current = event.currentTarget; void props.refresh(); }, children: t(state.busy === "refresh" ? "refreshing" : "refresh") })] }), editor !== null && _jsx("p", { className: "dsmm-badge", "data-dsmm-editor-state": state.invalidFields.length > 0 || invalid || rawInvalid ? "invalid" : state.dirty ? "dirty" : readOnly ? "readonly" : "ready", children: t(editor.refreshRequired ? "savedRefreshRequired" : state.invalidFields.length > 0 || invalid || rawInvalid ? "validation" : state.dirty ? "dirty" : applied ? "savedApplied" : relationship === "unknown" ? "savedRelationshipUnknown" : "savedNotApplied") })] }), snapshot?.profiles.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("empty") }), snapshot !== null && snapshot.profiles.some(profile => profile.error !== undefined || profile.warnings?.length) && _jsx("ul", { className: "dsmm-profile-list", "aria-label": t("savedInventory"), children: snapshot.profiles.filter(profile => profile.error !== undefined || profile.warnings?.length).map((profile, index) => _jsxs("li", { children: [_jsx("p", { children: profile.label?.trim() ? `${profile.label} (${profile.id})` : profile.id }), _jsx(ProfileWarnings, { warnings: profile.warnings, t: t }), profile.error !== undefined && _jsx(IssueDetails, { issue: profile.error, t: t })] }, `${index}:${profile.id}`)) }), state.pendingEditor !== null && _jsxs("div", { className: "dsmm-confirm", role: "group", "aria-labelledby": `${prefix}-confirm`, onKeyDown: (event) => { if (event.key === "Escape") {
|
|
@@ -120,7 +225,71 @@ export function ProfilesSection(props) {
|
|
|
120
225
|
}
|
|
121
226
|
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
122
227
|
sessionScopeRef.current?.scrollIntoView({ behavior: reducedMotion ? "auto" : "smooth" });
|
|
123
|
-
}, children: t("locateSessionScope") })] }), _jsx(SessionScopeFeedback, { state: state, t: t }), _jsxs("details", { ref: moreActionsRef, className: "dsmm-more-actions", open: moreActionsOpenRef.current || undefined, onToggle: e => { moreActionsOpenRef.current = e.currentTarget.open; }, children: [_jsx("summary", { children: t("moreActions") }), _jsxs("div", { children: [_jsxs("div", { children: [_jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || !reconcilable || (snapshot?.selectedId === null && !selectionConflict), onClick: () => { void props.reset(); }, children: t(state.busy === "reset" ? "resetting" : "reset") }), _jsx("p", { className: "dsmm-hint", children: t("futureResetHint") })] }), _jsx("div", { ref: sessionScopeRef, children: _jsx(SessionScope, { state: state, actions: props, t: t, showFeedback: false }) })] })] })] }), editor === null && _jsx("p", { className: "dsmm-hint", children: t("noEditor") }), editor !== null && _jsxs("div", { className: "dsmm-editor", children: [
|
|
228
|
+
}, children: t("locateSessionScope") })] }), _jsx(SessionScopeFeedback, { state: state, t: t }), _jsxs("details", { ref: moreActionsRef, className: "dsmm-more-actions", open: moreActionsOpenRef.current || undefined, onToggle: e => { moreActionsOpenRef.current = e.currentTarget.open; }, children: [_jsx("summary", { children: t("moreActions") }), _jsxs("div", { children: [_jsxs("div", { children: [_jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || !reconcilable || (snapshot?.selectedId === null && !selectionConflict), onClick: () => { void props.reset(); }, children: t(state.busy === "reset" ? "resetting" : "reset") }), _jsx("p", { className: "dsmm-hint", children: t("futureResetHint") })] }), _jsx("div", { ref: sessionScopeRef, children: _jsx(SessionScope, { state: state, actions: props, t: t, showFeedback: false }) })] })] })] }), editor === null && _jsx("p", { className: "dsmm-hint", children: t("noEditor") }), editor !== null && _jsxs("div", { className: "dsmm-editor", children: [_jsxs("div", { ref: saveBarRef, className: "dsmm-save-bar", children: [_jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: !canSave, onClick: () => { void props.save(); }, children: t(state.busy === "save" ? "saving" : "save") }), _jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || (!state.dirty && state.invalidFields.length === 0), onClick: (event) => { initiatorRef.current = event.currentTarget; props.discard(); }, children: t("discard") }), editor.revision !== null && !state.dirty && _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: (event) => { initiatorRef.current = event.currentTarget; void props.reload(); }, children: t("reload") }), _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 })] }), (() => {
|
|
229
|
+
const isSaveLocked = (state.dirty || state.invalidFields.length > 0) && !editorDisabled && snapshot !== null && (state.invalidFields.length > 0 || rawInvalid || invalid);
|
|
230
|
+
if (!isSaveLocked)
|
|
231
|
+
return null;
|
|
232
|
+
return (_jsxs("div", { className: "dsmm-save-lock-reason", role: "status", children: [_jsx("span", { className: "dsmm-save-lock-text", children: rawInvalid
|
|
233
|
+
? t("rawInvalid")
|
|
234
|
+
: state.invalidFields.length > 0
|
|
235
|
+
? t("saveLockedReason", { count: state.invalidFields.length })
|
|
236
|
+
: t("validation") }), _jsxs("div", { className: "dsmm-save-lock-action", children: [rawInvalid && (_jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => {
|
|
237
|
+
if (advancedRef.current !== null) {
|
|
238
|
+
advancedRef.current.open = true;
|
|
239
|
+
jsoncOpenRef.current = true;
|
|
240
|
+
}
|
|
241
|
+
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
242
|
+
editorRef.current?.scrollIntoView({ behavior: reducedMotion ? "auto" : "smooth" });
|
|
243
|
+
editorRef.current?.focus();
|
|
244
|
+
}, children: t("jumpToJsonc") })), !rawInvalid && state.invalidFields.length > 0 && (() => {
|
|
245
|
+
const firstInvalid = state.invalidFields[0];
|
|
246
|
+
const roleMatch = /^(?:settings\.)?(?:roleRouting|roles)\.([a-zA-Z0-9_-]+)(?:\.|$)/.exec(firstInvalid);
|
|
247
|
+
const roleId = roleMatch?.[1];
|
|
248
|
+
if (roleId) {
|
|
249
|
+
return (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: (e) => {
|
|
250
|
+
dialogInitiatorRef.current = e.currentTarget;
|
|
251
|
+
setTargetRole(roleId);
|
|
252
|
+
setTargetRoleField(firstInvalid);
|
|
253
|
+
setModelsDialogOpen(true);
|
|
254
|
+
}, children: [t("jumpToField"), ": ", firstInvalid] }));
|
|
255
|
+
}
|
|
256
|
+
return (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: () => {
|
|
257
|
+
if (!focusGlobalField(firstInvalid))
|
|
258
|
+
focusJsonc(state.issue?.location);
|
|
259
|
+
}, children: [t("jumpToField"), ": ", firstInvalid] }));
|
|
260
|
+
})(), !rawInvalid && state.invalidFields.length === 0 && invalid && (() => {
|
|
261
|
+
if (state.issue?.field === "id" || state.issue?.field === "newId") {
|
|
262
|
+
return (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: () => {
|
|
263
|
+
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
264
|
+
inputRef.current?.scrollIntoView({ behavior: reducedMotion ? "auto" : "smooth" });
|
|
265
|
+
inputRef.current?.focus();
|
|
266
|
+
}, children: [t("jumpToField"), ": ID"] }));
|
|
267
|
+
}
|
|
268
|
+
const roleMatch = /^(?:settings\.)?(?:roleRouting|roles)\.([a-zA-Z0-9_-]+)(?:\.|$)/.exec(state.issue?.field ?? "");
|
|
269
|
+
const roleId = roleMatch?.[1];
|
|
270
|
+
if (roleId && snapshot?.roles?.some(r => r.id === roleId)) {
|
|
271
|
+
return (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: (e) => {
|
|
272
|
+
dialogInitiatorRef.current = e.currentTarget;
|
|
273
|
+
setTargetRole(roleId);
|
|
274
|
+
setTargetRoleField(state.issue?.field ?? null);
|
|
275
|
+
setModelsDialogOpen(true);
|
|
276
|
+
}, children: [t("jumpToRole"), ": ", roleId] }));
|
|
277
|
+
}
|
|
278
|
+
return (_jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => {
|
|
279
|
+
if (advancedRef.current !== null) {
|
|
280
|
+
advancedRef.current.open = true;
|
|
281
|
+
jsoncOpenRef.current = true;
|
|
282
|
+
}
|
|
283
|
+
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
284
|
+
editorRef.current?.scrollIntoView({ behavior: reducedMotion ? "auto" : "smooth" });
|
|
285
|
+
editorRef.current?.focus();
|
|
286
|
+
const location = state.issue?.location;
|
|
287
|
+
if (location !== undefined && editorRef.current && location.offset + location.length <= editorRef.current.value.length) {
|
|
288
|
+
editorRef.current.setSelectionRange(location.offset, location.offset + location.length);
|
|
289
|
+
}
|
|
290
|
+
}, children: t("jumpToJsonc") }));
|
|
291
|
+
})()] })] }));
|
|
292
|
+
})()] }), warnings.length > 0 && _jsxs("div", { children: [_jsx("p", { children: t("draftWarnings") }), _jsx(ProfileWarnings, { warnings: warnings, t: t })] }), editor.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("savedWarnings") }), _jsx(ProfileWarnings, { warnings: editor.warnings, t: t })] }) : null, _jsxs("div", { className: "dsmm-catalog", children: [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") })] }), _jsxs("div", { className: "dsmm-basic-settings", "data-dsmm-basic-settings": true, children: [structuredDoc === null && (_jsxs("div", { className: "dsmm-structured-invalid", "data-dsmm-structured-invalid": true, children: [_jsx("p", { children: t("rawInvalid") }), _jsx("p", { className: "dsmm-hint", children: t("rawInvalidFormDisabled") }), _jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
124
293
|
if (advancedRef.current !== null) {
|
|
125
294
|
advancedRef.current.open = true;
|
|
126
295
|
jsoncOpenRef.current = true;
|
|
@@ -128,10 +297,13 @@ export function ProfilesSection(props) {
|
|
|
128
297
|
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
129
298
|
editorRef.current?.scrollIntoView({ behavior: reducedMotion ? "auto" : "smooth" });
|
|
130
299
|
editorRef.current?.focus();
|
|
131
|
-
}, children: t("viewConfiguration") })] })), basicDoc !== null && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-label`, children: t("profileLabel") }), _jsx(Input, { ref: labelRef, id: `${prefix}-label`, className: "dsmm-input", value: basicDoc.label ?? "", disabled: editorDisabled || structuredDoc === null, onChange: (event) => props.editPath(["label"], event.currentTarget.value) }), _jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || structuredDoc === null || basicDoc.label === undefined, onClick: () => props.editPath(["label"], undefined), children: t("omitLabel") })] }), _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: editorDisabled || structuredDoc === null || 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", { ref: orchestratorRef, className: "dsmm-field", id: `${prefix}-orchestrator-primary`, children: [_jsx("label", { htmlFor: `${prefix}-orch-mode`, children: t("orchestratorModel") }), _jsx("p", { className: "dsmm-hint", children: t("orchestratorModelDesc") }), _jsxs("select", { id: `${prefix}-orch-mode`, disabled: editorDisabled || structuredDoc === null || !hasOrchestrator, "aria-describedby": !hasOrchestrator ? `${prefix}-orch-unavailable` : undefined, value: basicDoc.roleRouting["dsmm-orchestrator"]?.primary === undefined ? "inherit" : "explicit", onChange: (event) => props.editPath(["settings", "roleRouting", "dsmm-orchestrator", "primary"], event.currentTarget.value === "inherit" ? undefined : { provider: "", model: "" }), children: [_jsx("option", { value: "inherit", children: t("inheritRoute") }), _jsx("option", { value: "explicit", children: t("configuredRoute") })] }), !hasOrchestrator && _jsx("p", { className: "dsmm-hint", id: `${prefix}-orch-unavailable`, children: t("orchestratorUnavailable") }), basicDoc.roleRouting["dsmm-orchestrator"]?.primary !== undefined && (_jsx(RouteFields, { t: t, value: basicDoc.roleRouting["dsmm-orchestrator"].primary, path: ["settings", "roleRouting", "dsmm-orchestrator", "primary"], naturalLabels: true, catalog: state.catalog, disabled: editorDisabled || structuredDoc === null || !hasOrchestrator, edit: props.editPath, editRoute: props.editRoute })), _jsx("p", { className: "dsmm-hint", children: t("effortChangeHint") })] }), _jsxs("div", { className: "dsmm-field
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
300
|
+
}, children: t("viewConfiguration") })] })), basicDoc !== null && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-label`, children: t("profileLabel") }), _jsx(Input, { ref: labelRef, id: `${prefix}-label`, className: "dsmm-input", value: basicDoc.label ?? "", disabled: editorDisabled || structuredDoc === null, onChange: (event) => props.editPath(["label"], event.currentTarget.value) }), _jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || structuredDoc === null || basicDoc.label === undefined, onClick: () => props.editPath(["label"], undefined), children: t("omitLabel") })] }), _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: editorDisabled || structuredDoc === null || 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", { ref: orchestratorRef, className: "dsmm-field", id: `${prefix}-orchestrator-primary`, children: [_jsx("label", { htmlFor: `${prefix}-orch-mode`, children: t("orchestratorModel") }), _jsx("p", { className: "dsmm-hint", children: t("orchestratorModelDesc") }), _jsxs("select", { id: `${prefix}-orch-mode`, disabled: editorDisabled || structuredDoc === null || !hasOrchestrator, "aria-describedby": !hasOrchestrator ? `${prefix}-orch-unavailable` : undefined, value: basicDoc.roleRouting["dsmm-orchestrator"]?.primary === undefined ? "inherit" : "explicit", onChange: (event) => props.editPath(["settings", "roleRouting", "dsmm-orchestrator", "primary"], event.currentTarget.value === "inherit" ? undefined : { provider: "", model: "" }), children: [_jsx("option", { value: "inherit", children: t("inheritRoute") }), _jsx("option", { value: "explicit", children: t("configuredRoute") })] }), !hasOrchestrator && _jsx("p", { className: "dsmm-hint", id: `${prefix}-orch-unavailable`, children: t("orchestratorUnavailable") }), basicDoc.roleRouting["dsmm-orchestrator"]?.primary !== undefined && (_jsx(RouteFields, { t: t, value: basicDoc.roleRouting["dsmm-orchestrator"].primary, path: ["settings", "roleRouting", "dsmm-orchestrator", "primary"], naturalLabels: true, catalog: state.catalog, disabled: editorDisabled || structuredDoc === null || !hasOrchestrator, edit: props.editPath, editRoute: props.editRoute })), _jsx("p", { className: "dsmm-hint", children: t("effortChangeHint") })] }), _jsxs("div", { className: "dsmm-field dsmm-configure-models-field", children: [_jsx("label", { children: t("configureAllAgentModels") }), _jsx("p", { className: "dsmm-hint", children: t("modelsDialogDesc") }), _jsx("div", { children: _jsx(Button, { type: "button", variant: "outline", className: "dsmm-open-models-dialog-btn", disabled: editorDisabled || structuredDoc === null, onClick: (event) => {
|
|
301
|
+
dialogInitiatorRef.current = event.currentTarget;
|
|
302
|
+
setModelsDialogOpen(true);
|
|
303
|
+
}, children: t("configureAllAgentModels") }) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-locale`, children: t("businessLocale") }), _jsxs("select", { id: `${prefix}-locale`, value: String(basicDoc.settings.locale ?? ""), disabled: editorDisabled || structuredDoc === null, "aria-describedby": `${prefix}-locale-hint`, onChange: (event) => props.editPath(["settings", "locale"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inheritLocale") }), typeof basicDoc.settings.locale === "string" && !DSMM_LOCALES.includes(basicDoc.settings.locale) && (_jsx("option", { value: basicDoc.settings.locale, children: t("unsupportedLocale") })), DSMM_LOCALES.map((locale) => (_jsx("option", { value: locale, children: locale }, locale)))] }), _jsx("p", { id: `${prefix}-locale-hint`, className: "dsmm-hint", children: t("localeHint") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-active`, children: t("defaultActive") }), _jsxs("select", { id: `${prefix}-active`, disabled: editorDisabled || structuredDoc === null, value: basicDoc.settings.defaultActive === undefined ? "" : String(basicDoc.settings.defaultActive), onChange: (event) => props.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") })] })] }))] }, `basic:${state.editorEpoch}`), _jsxs("details", { ref: advancedSettingsRef, className: "dsmm-advanced-settings", open: advancedOpenRef.current || undefined, onToggle: e => { advancedOpenRef.current = e.currentTarget.open; }, children: [_jsx("summary", { children: t("advancedSettings") }), _jsx("div", { children: _jsx(AdvancedSettings, { state: state, actions: props, disabled: editorDisabled, document: basicDoc, isInvalidProjection: rawInvalid, t: t }) })] }, `advanced-settings:${state.editorEpoch}`), _jsxs("details", { ref: advancedRef, className: "dsmm-advanced", open: jsoncOpenRef.current || undefined, onToggle: e => { jsoncOpenRef.current = e.currentTarget.open; }, children: [_jsx("summary", { children: t("configuration") }), _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, readOnly: readOnly, disabled: editorDisabled, "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") })] })] }, `advanced:${state.editorEpoch}`), _jsx(ProfileModelsDialog, { open: modelsDialogOpen, onClose: () => closeModelsDialog("trigger"), state: state, actions: props, disabled: editorDisabled, document: basicDoc, isInvalidProjection: rawInvalid, targetRoleId: targetRole, targetField: targetRoleField, onTargetLocated: () => {
|
|
304
|
+
handledValidation.current = state.validationEpoch;
|
|
305
|
+
setTargetRole(null);
|
|
306
|
+
setTargetRoleField(null);
|
|
307
|
+
}, onJumpToJsonc: () => closeModelsDialog("jsonc"), canSave: canSave, t: t })] }), state.issue !== null && !modelsDialogOpen && _jsxs("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: [_jsx("p", { children: t(issueKey(state.issue)) }), _jsx(IssueDetails, { issue: state.issue, t: t })] }), editor === null && _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 })] });
|
|
136
308
|
}
|
|
137
309
|
//# sourceMappingURL=ProfilesSection.js.map
|
|
@@ -32,4 +32,11 @@ export declare function preparingRoleTool(toolName: string, args: ToolArgs): {
|
|
|
32
32
|
};
|
|
33
33
|
export declare function actualRoleTool(toolName: string, meta: unknown, failed: boolean): DsmmInvocationView | undefined;
|
|
34
34
|
export declare function roleToolDisplay(target: string): string;
|
|
35
|
+
export interface TechnicalRow {
|
|
36
|
+
property: string;
|
|
37
|
+
value: unknown;
|
|
38
|
+
isComplex: boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare function technicalTableRows(toolName: string, callId: string, rawArgs: string, meta?: unknown, routeSource?: string): TechnicalRow[];
|
|
41
|
+
export declare function technicalJsonData(toolName: string, callId: string, rawArgs: string, meta?: unknown, routeSource?: string): Record<string, unknown>;
|
|
35
42
|
//# sourceMappingURL=RoleToolView-data.d.ts.map
|
|
@@ -51,4 +51,49 @@ export function actualRoleTool(toolName, meta, failed) {
|
|
|
51
51
|
export function roleToolDisplay(target) {
|
|
52
52
|
return target.slice("dsmm-".length).split("-").map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
53
53
|
}
|
|
54
|
+
export function technicalTableRows(toolName, callId, rawArgs, meta, routeSource) {
|
|
55
|
+
const rows = [];
|
|
56
|
+
rows.push({ property: "toolName", value: toolName, isComplex: false });
|
|
57
|
+
rows.push({ property: "callId", value: callId, isComplex: false });
|
|
58
|
+
if (routeSource !== undefined) {
|
|
59
|
+
rows.push({ property: "routeSource", value: routeSource, isComplex: false });
|
|
60
|
+
}
|
|
61
|
+
const argsObj = roleToolArguments(rawArgs);
|
|
62
|
+
if (argsObj !== undefined) {
|
|
63
|
+
for (const [k, v] of Object.entries(argsObj)) {
|
|
64
|
+
const isComplex = typeof v === "object" && v !== null;
|
|
65
|
+
rows.push({ property: `args.${k}`, value: v, isComplex });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (rawArgs !== "") {
|
|
69
|
+
rows.push({ property: "args", value: rawArgs, isComplex: false });
|
|
70
|
+
}
|
|
71
|
+
if (meta !== undefined && meta !== null) {
|
|
72
|
+
if (typeof meta === "object" && !Array.isArray(meta)) {
|
|
73
|
+
for (const [k, v] of Object.entries(meta)) {
|
|
74
|
+
const isComplex = typeof v === "object" && v !== null;
|
|
75
|
+
rows.push({ property: `meta.${k}`, value: v, isComplex });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
rows.push({ property: "meta", value: meta, isComplex: typeof meta === "object" });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return rows;
|
|
83
|
+
}
|
|
84
|
+
export function technicalJsonData(toolName, callId, rawArgs, meta, routeSource) {
|
|
85
|
+
const parsedArgs = roleToolArguments(rawArgs);
|
|
86
|
+
const data = {
|
|
87
|
+
toolName,
|
|
88
|
+
callId,
|
|
89
|
+
};
|
|
90
|
+
if (routeSource !== undefined) {
|
|
91
|
+
data.routeSource = routeSource;
|
|
92
|
+
}
|
|
93
|
+
data.args = parsedArgs !== undefined ? parsedArgs : rawArgs;
|
|
94
|
+
if (meta !== undefined && meta !== null) {
|
|
95
|
+
data.meta = meta;
|
|
96
|
+
}
|
|
97
|
+
return data;
|
|
98
|
+
}
|
|
54
99
|
//# sourceMappingURL=RoleToolView-data.js.map
|
|
@@ -29,6 +29,11 @@ export declare const roleToolEn: {
|
|
|
29
29
|
readonly level: "Level";
|
|
30
30
|
readonly route: "Reported route";
|
|
31
31
|
readonly routeSource: "Route source";
|
|
32
|
+
readonly table: "Table";
|
|
33
|
+
readonly json: "JSON";
|
|
34
|
+
readonly viewMode: "View mode";
|
|
35
|
+
readonly property: "Property";
|
|
36
|
+
readonly value: "Value";
|
|
32
37
|
};
|
|
33
38
|
export declare const roleToolZh: Record<keyof typeof roleToolEn, string>;
|
|
34
39
|
declare module "@deepseek-ai/dsh-client-ui-slots" {
|
|
@@ -9,6 +9,7 @@ export const roleToolEn = {
|
|
|
9
9
|
args: "Original arguments", preparingArgs: "Arguments received so far", output: "Complete result content", failure: "Error details", metadata: "Invocation metadata",
|
|
10
10
|
inspect: "Inspect tool call", copy: "Copy", copied: "Copied", emptyArgs: "Arguments not available yet",
|
|
11
11
|
unavailable: "Actual identity unavailable; requested identity only", level: "Level", route: "Reported route", routeSource: "Route source",
|
|
12
|
+
table: "Table", json: "JSON", viewMode: "View mode", property: "Property", value: "Value",
|
|
12
13
|
};
|
|
13
14
|
export const roleToolZh = {
|
|
14
15
|
call: "调用", calling: "正在调用", unknownTarget: "DSMM 代理 · 目标待确定",
|
|
@@ -20,5 +21,6 @@ export const roleToolZh = {
|
|
|
20
21
|
args: "原始参数", preparingArgs: "目前已收到的参数", output: "完整结果内容", failure: "错误详情", metadata: "调用元数据",
|
|
21
22
|
inspect: "检查工具调用", copy: "复制", copied: "已复制", emptyArgs: "参数尚不可用",
|
|
22
23
|
unavailable: "实际身份不可用,仅显示请求身份", level: "等级", route: "报告的路由", routeSource: "路由来源",
|
|
24
|
+
table: "表格", json: "JSON", viewMode: "视图模式", property: "属性", value: "值",
|
|
23
25
|
};
|
|
24
26
|
//# sourceMappingURL=RoleToolView-locales.js.map
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Button, CodeBlock, DisclosureRow, IconAgentPresetOutlineRegular, SegmentedControl, StateDot, TextShimmer } from "@deepseek-ai/dsh-client-ui-primitives";
|
|
4
|
+
import { actualRoleTool, preparingRoleTool, requestedRoleTool, roleToolDisplay, roleToolKeys, technicalJsonData, technicalTableRows } from "./RoleToolView-data.js";
|
|
4
5
|
import { ROLE_TOOL_NS, roleToolEn, roleToolZh } from "./RoleToolView-locales.js";
|
|
5
6
|
const styles = `
|
|
6
7
|
.dsmm-role-tool{min-width:0;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);font-size:14px;line-height:22px}
|
|
7
8
|
.dsmm-role-tool .dsmm-role-heading{color:var(--dsw-alias-label-primary);height:auto;min-height:32px}
|
|
8
|
-
.dsmm-role-tool .dsmm-role-title{white-space:
|
|
9
|
-
.dsmm-role-tool
|
|
10
|
-
.dsmm-role-tool .dsmm-role-
|
|
9
|
+
.dsmm-role-tool .dsmm-role-title{white-space:nowrap;flex:none;color:inherit;font-size:inherit;line-height:inherit}
|
|
10
|
+
.dsmm-role-tool .dsmm-role-text{display:inline-flex;align-items:center;min-width:0;flex:1;overflow:hidden}
|
|
11
|
+
.dsmm-role-tool .dsmm-role-sep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}
|
|
12
|
+
.dsmm-role-tool .dsmm-role-summary{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));flex:auto;overflow:hidden;color:var(--dsw-alias-label-secondary)}
|
|
13
|
+
.dsmm-role-tool .dsmm-role-icon{flex:none;color:inherit}
|
|
11
14
|
.dsmm-role-tool .dsmm-role-body{display:flex;flex-direction:column;gap:8px;min-width:0;padding:8px 0}
|
|
12
15
|
.dsmm-role-tool p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
13
16
|
.dsmm-role-tool .dsmm-role-status{color:var(--dsw-alias-label-secondary)}
|
|
@@ -19,6 +22,15 @@ const styles = `
|
|
|
19
22
|
.dsmm-role-tool .dsmm-role-details{border-top:1px solid var(--dsw-alias-border-l2);padding-top:8px;margin-top:4px}
|
|
20
23
|
.dsmm-role-tool .dsmm-role-details summary{cursor:pointer;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;user-select:none}
|
|
21
24
|
.dsmm-role-tool .dsmm-role-details-body{display:flex;flex-direction:column;gap:8px;margin-top:8px;padding-left:8px}
|
|
25
|
+
.dsmm-role-tool .dsmm-role-details-header{display:flex;align-items:center;margin-bottom:4px}
|
|
26
|
+
.dsmm-role-tool .dsmm-role-view-switch{margin-bottom:4px}
|
|
27
|
+
.dsmm-role-tool .dsmm-role-table{width:100%;border-collapse:collapse;font-size:12px;line-height:18px;margin-top:4px}
|
|
28
|
+
.dsmm-role-tool .dsmm-role-table th,.dsmm-role-tool .dsmm-role-table td{padding:4px 8px;text-align:left;vertical-align:top;border-bottom:1px solid var(--dsw-alias-border-l1)}
|
|
29
|
+
.dsmm-role-tool .dsmm-role-table th{color:var(--dsw-alias-label-secondary);font-weight:500;border-bottom:1px solid var(--dsw-alias-border-l2)}
|
|
30
|
+
.dsmm-role-tool .dsmm-role-prop-cell{color:var(--dsw-alias-label-secondary);font-family:var(--dsw-font-family-code,monospace);word-break:break-all;width:35%;max-width:180px}
|
|
31
|
+
.dsmm-role-tool .dsmm-role-val-cell{color:var(--dsw-alias-label-primary);word-break:break-word}
|
|
32
|
+
.dsmm-role-tool .dsmm-role-cell-text{white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}
|
|
33
|
+
.dsmm-role-tool .dsmm-role-cell-code{margin:0;font-family:var(--dsw-font-family-code,monospace);font-size:11px;line-height:16px;white-space:pre-wrap;word-break:break-all;background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,0.04));padding:4px 6px;border-radius:4px}
|
|
22
34
|
.dsmm-role-tool :is(button,[role=button],summary):focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
|
23
35
|
`;
|
|
24
36
|
export function RoleToolView(props) {
|
|
@@ -35,13 +47,26 @@ export function RoleToolView(props) {
|
|
|
35
47
|
const targetLabel = target === undefined ? t("unknownTarget") : roleToolDisplay(target);
|
|
36
48
|
const rawDesc = requested.description?.trim();
|
|
37
49
|
const singleLineDesc = rawDesc ? rawDesc.replace(/\s+/gu, " ") : undefined;
|
|
38
|
-
const title =
|
|
50
|
+
const title = `${action} ${targetLabel}`;
|
|
39
51
|
const state = result?.error?.code === "interrupted" ? "stopped" : failed ? "error" : result === undefined ? props.phase === "preparing" ? "preparing" : "running" : actual?.jobId !== undefined || actual?.mode === "continuable" ? "background" : "result";
|
|
52
|
+
const isOngoing = state === "running" || props.phase === "preparing";
|
|
40
53
|
const code = (value) => _jsx(CodeBlock, { code: value, copyLabel: t("copy"), copiedLabel: t("copied") });
|
|
54
|
+
const [viewMode, setViewMode] = useState("table");
|
|
55
|
+
const controlId = `dsmm-tech-${props.callId || "call"}`;
|
|
56
|
+
const viewOptions = [
|
|
57
|
+
{ value: "table", label: t("table") },
|
|
58
|
+
{ value: "json", label: t("json") },
|
|
59
|
+
];
|
|
60
|
+
const tableRows = technicalTableRows(props.toolName, props.callId, raw, result?.meta, actual?.routeSource);
|
|
61
|
+
const jsonData = technicalJsonData(props.toolName, props.callId, raw, result?.meta, actual?.routeSource);
|
|
41
62
|
const roleDiffers = requested.target !== undefined && actual !== undefined && actual.role !== requested.target;
|
|
42
63
|
const levelDiffers = requested.level !== undefined && actual !== undefined && actual.level !== requested.level;
|
|
43
64
|
const showRequestedVsActual = roleDiffers || levelDiffers;
|
|
44
|
-
|
|
65
|
+
const collapsedContent = singleLineDesc ? _jsxs(_Fragment, { children: [_jsx("span", { className: "dsmm-role-sep", "aria-hidden": "true" }), _jsx("span", { className: "dsmm-role-summary", children: _jsx(TextShimmer, { active: isOngoing, children: singleLineDesc }) })] }) : undefined;
|
|
66
|
+
const stateDotState = state === "error" ? "error" : state === "stopped" ? "warning" : result === undefined ? "ongoing" : state === "background" ? "idle" : "done";
|
|
67
|
+
return _jsxs("div", { className: "dsmm-role-tool", "data-dsmm-role-tool": props.toolName, "data-identity": actual === undefined ? "requested" : "actual", "data-state": state, "data-expanded": expanded ? "true" : "false", children: [_jsx(DisclosureRow, { title: title, titleClassName: "dsmm-role-title", rowClassName: "dsmm-role-heading", contentClassName: "dsmm-role-text", icon: _jsx(IconAgentPresetOutlineRegular, { size: 14, className: "dsmm-role-icon" }), collapsedContent: collapsedContent, keepContentWhenOpen: true, running: isOngoing, open: expanded, expandable: true, onToggle: toggle, expandOnRowClick: true, children: _jsxs("div", { className: "dsmm-role-body", children: [_jsxs("p", { className: "dsmm-role-identity", children: [showRequestedVsActual ? _jsxs(_Fragment, { children: [_jsxs("span", { className: "dsmm-role-dim", children: [t("requested"), ": "] }), _jsxs("span", { children: [requested.target === undefined ? t("unknown") : roleToolDisplay(requested.target), requested.level ? ` (${requested.level})` : ""] }), _jsx("span", { className: "dsmm-role-dim", children: " \u2192 " }), _jsxs("span", { className: "dsmm-role-dim", children: [t("actual"), ": "] }), _jsxs("span", { children: [roleToolDisplay(actual.role), " (", actual.level, ")"] })] }) : _jsxs("span", { children: [actual !== undefined ? roleToolDisplay(actual.role) : requested.target === undefined ? t("unknownTarget") : roleToolDisplay(requested.target), (actual?.level ?? requested.level) !== undefined && ` · ${actual?.level ?? requested.level}`, result !== undefined && actual === undefined && _jsxs("span", { className: "dsmm-role-dim", children: [" \u00B7 ", t("actualUnknown")] })] }), actual?.route !== undefined && _jsxs("span", { className: "dsmm-role-model", children: [" · ", actual.route.provider, "/", actual.route.model, actual.route.reasoningEffort ? ` · ${actual.route.reasoningEffort}` : ""] })] }), requested.description !== undefined && _jsx("p", { className: "dsmm-role-task", children: requested.description }), result?.error != null && _jsxs("div", { className: "dsmm-role-failure", children: [_jsx("p", { className: "dsmm-role-section-title", children: t("failure") }), code(JSON.stringify(result.error, null, 2))] }), _jsxs("details", { className: "dsmm-role-details", children: [_jsx("summary", { children: t("technicalDetails") }), _jsxs("div", { className: "dsmm-role-details-body", children: [_jsx("div", { className: "dsmm-role-details-header", children: _jsx(SegmentedControl, { id: controlId, value: viewMode, options: viewOptions, onChange: setViewMode, label: t("viewMode"), className: "dsmm-role-view-switch" }) }), _jsx("div", { id: `${controlId}-table-panel`, role: "tabpanel", "aria-labelledby": `${controlId}-table`, hidden: viewMode !== "table", tabIndex: 0, children: viewMode === "table" && _jsxs("table", { className: "dsmm-role-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: t("property") }), _jsx("th", { scope: "col", children: t("value") })] }) }), _jsx("tbody", { children: tableRows.map(row => _jsxs("tr", { children: [_jsx("td", { className: "dsmm-role-prop-cell", children: row.property }), _jsx("td", { className: "dsmm-role-val-cell", children: row.isComplex ? _jsx("pre", { className: "dsmm-role-cell-code", children: JSON.stringify(row.value, null, 2) })
|
|
68
|
+
: typeof row.value === "string" ? _jsx("span", { className: "dsmm-role-cell-text", children: row.value })
|
|
69
|
+
: _jsx("span", { children: row.value === null ? "null" : row.value === undefined ? "undefined" : String(row.value) }) })] }, row.property)) })] }) }), _jsx("div", { id: `${controlId}-json-panel`, role: "tabpanel", "aria-labelledby": `${controlId}-json`, hidden: viewMode !== "json", tabIndex: 0, children: viewMode === "json" && code(JSON.stringify(jsonData, null, 2)) })] })] })] }) }), _jsxs("div", { className: "dsmm-role-actions", children: [_jsx(StateDot, { state: stateDotState }), _jsx("p", { className: "dsmm-role-status", role: "status", children: t(state) }), props.inspect !== undefined && _jsx(Button, { variant: "ghost", size: "sm", onClick: props.inspect, children: t("inspect") })] })] });
|
|
45
70
|
}
|
|
46
71
|
/** Called once by the parent client apply(ctx), alongside the other slot registrations. */
|
|
47
72
|
export function registerRoleToolViews(ctx) {
|