dsh-tool-manager 1.1.1 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -13,14 +13,14 @@ window.__ModuleLoader__.load({
13
13
  ".tm_root{display:flex;flex-direction:column;gap:14px;max-width:1040px;padding:2px 0 30px;color:var(--dsw-alias-label-primary,#e7e9ed)}",
14
14
  ".tm_head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}",
15
15
  ".tm_head h2{font-size:18px;margin:0 0 5px}.tm_muted{color:var(--dsw-alias-label-secondary,#9097a4);font-size:12px;line-height:1.5}",
16
- ".tm_preset_picker{display:flex;align-items:center;gap:9px;flex-wrap:wrap}.tm_preset_picker label{font-size:12px;color:var(--dsw-alias-label-secondary,#9097a4)}.tm_preset_select,.tm_btn{appearance:none;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:8px;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.08));color:inherit;padding:7px 10px;font:inherit;font-size:12px}.tm_preset_select{min-width:min(360px,100%);cursor:pointer}.tm_preset_select option{background:var(--dsw-alias-bg-base,#17191d);color:inherit}.tm_btn{cursor:pointer}.tm_btn.primary{background:#5367e8;border-color:#5367e8;color:#fff}.tm_btn:disabled{opacity:.5;cursor:not-allowed}",
16
+ ".tm_preset_picker{display:flex;align-items:center;gap:9px;flex-wrap:wrap}.tm_preset_picker label{font-size:12px;color:var(--dsw-alias-label-secondary,#9097a4)}.tm_select_wrap{position:relative;display:inline-flex;max-width:100%}.tm_select_wrap:after{content:'';position:absolute;right:12px;top:50%;width:7px;height:7px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:translateY(-70%) rotate(45deg);pointer-events:none;opacity:.9}.tm_preset_select,.tm_btn{appearance:none;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:8px;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.08));color:inherit;padding:7px 10px;font:inherit;font-size:12px}.tm_preset_select{min-width:min(360px,100%);cursor:pointer;padding-right:34px}.tm_preset_select option{background:var(--dsw-alias-bg-base,#17191d);color:inherit}.tm_btn{cursor:pointer}.tm_btn.primary{background:#5367e8;border-color:#5367e8;color:#fff}.tm_btn:disabled{opacity:.5;cursor:not-allowed}",
17
17
  ".tm_panel{border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.24));border-radius:12px;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.06));overflow:hidden}",
18
18
  ".tm_panel_head{padding:13px 14px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2));display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap}.tm_panel_head b{font-size:14px}",
19
19
  ".tm_tools{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:0}.tm_tool{display:flex;gap:10px;align-items:flex-start;padding:11px 14px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.13))}.tm_tool_name{font:600 12px ui-monospace,SFMono-Regular,Consolas,monospace}.tm_tool_desc{font-size:11px;color:var(--dsw-alias-label-secondary,#9097a4);line-height:1.4;margin-top:3px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}",
20
20
  ".tm_row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.tm_input{box-sizing:border-box;min-width:130px;flex:1;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.3));border-radius:7px;background:var(--dsw-alias-bg-base,#17191d);color:inherit;padding:7px 9px;font:inherit;font-size:12px}.tm_code{font:11px ui-monospace,SFMono-Regular,Consolas,monospace;color:#9da8ff}.tm_notice{padding:12px;border-radius:9px;background:color-mix(in srgb,#f59e0b 12%,transparent);font-size:12px}.tm_error{padding:12px;border-radius:9px;background:color-mix(in srgb,#ef4444 12%,transparent);color:#fca5a5;font-size:12px}",
21
21
  ".tm_filters{display:flex;gap:6px;flex-wrap:wrap;align-items:center}.tm_chip{appearance:none;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:999px;background:transparent;color:inherit;padding:4px 9px;cursor:pointer;font:inherit;font-size:11px}.tm_chip.active{border-color:#7c8cff;background:color-mix(in srgb,#7c8cff 16%,transparent)}",
22
22
  ".tm_stats{display:grid;grid-template-columns:repeat(5,minmax(100px,1fr));gap:8px;padding:10px 14px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.13))}.tm_stat{min-width:0;padding:9px 10px;border-radius:8px;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.07));border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.15))}.tm_stat_value{font-size:18px;font-weight:700;line-height:1.2}.tm_stat_label{margin-top:3px;font-size:11px;color:var(--dsw-alias-label-secondary,#9097a4)}@media(max-width:720px){.tm_stats{grid-template-columns:repeat(2,minmax(100px,1fr))}}",
23
- ".tm_badge{display:inline-block;margin-left:6px;padding:1px 6px;border-radius:999px;font-size:10px;vertical-align:middle}.tm_badge.off{background:color-mix(in srgb,#ef4444 18%,transparent);color:#fca5a5}.tm_badge.cold{background:color-mix(in srgb,#6366f1 18%,transparent);color:#c7d2fe}.tm_badge.live{background:color-mix(in srgb,#22c55e 16%,transparent);color:#86efac}",
23
+ ".tm_badge{display:inline-block;margin-left:6px;padding:2px 7px;border:1px solid transparent;border-radius:999px;font-size:10px;font-weight:700;line-height:1.35;letter-spacing:.02em;vertical-align:middle;color:#fff}.tm_badge.off{background:#b42318;border-color:#d92d20;color:#fff}.tm_badge.cold{background:#4338ca;border-color:#6366f1;color:#fff}.tm_badge.live{background:#15803d;border-color:#22c55e;color:#fff}",
24
24
  ".tm_group{border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.13))}.tm_group:last-child{border-bottom:0}",
25
25
  ".tm_group_bar{display:flex;align-items:center;gap:8px;padding:11px 14px}",
26
26
  ".tm_chevron{appearance:none;border:0;background:transparent;color:inherit;width:28px;height:28px;border-radius:7px;cursor:pointer;font:16px/1 inherit;flex:0 0 auto}.tm_chevron:hover{background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.1))}",
@@ -32,9 +32,9 @@ window.__ModuleLoader__.load({
32
32
  ".tm_modal{position:fixed;inset:0;z-index:10000;display:flex;align-items:center;justify-content:center;padding:24px}",
33
33
  ".tm_modal_mask{position:absolute;inset:0;background:rgba(0,0,0,.55)}",
34
34
  ".tm_modal_card{position:relative;z-index:1;width:min(720px,100%);max-height:min(84vh,760px);display:flex;flex-direction:column;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:14px;background:var(--dsw-alias-bg-base,#17191d);box-shadow:0 24px 80px rgba(0,0,0,.45)}",
35
- ".tm_modal_head{padding:16px 16px 12px;display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.tm_modal_head h3{margin:0;font-size:16px}",
36
- ".tm_modal_body{padding:0 16px 12px;display:flex;flex-direction:column;gap:10px;min-height:0;flex:1;overflow:auto}",
37
- ".tm_modal_foot{padding:12px 16px 16px;display:flex;justify-content:flex-end;gap:8px;border-top:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.18))}",
35
+ ".tm_modal_head{padding:16px 16px 12px;display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex:0 0 auto}.tm_modal_head h3{margin:0;font-size:16px}",
36
+ ".tm_modal_body{padding:0 16px 12px;display:flex;flex-direction:column;gap:10px;min-height:0;flex:1 1 auto;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable}",
37
+ ".tm_modal_foot{padding:12px 16px 16px;display:flex;justify-content:flex-end;gap:8px;border-top:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.18));flex:0 0 auto}.tm_confirm_card{width:min(460px,100%)}.tm_timeout_field{display:flex;align-items:center;gap:8px}.tm_timeout_field .tm_input{max-width:120px;flex:0 0 120px}.tm_preview_body{padding-right:10px}.tm_preview_panel{flex:0 0 auto;overflow:visible}.tm_preview_meta{min-width:0;flex:1}.tm_preview_desc{margin-top:4px;white-space:normal;overflow-wrap:anywhere;word-break:break-word;color:var(--dsw-alias-label-secondary,#9097a4);font-size:12px;line-height:1.55}",
38
38
  ".tm_picker{min-height:180px;max-height:min(46vh,420px);overflow:auto;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.18));border-radius:8px;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.06))}",
39
39
  ".tm_pick{display:flex;gap:8px;align-items:flex-start;padding:8px 10px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.1))}.tm_pick:last-child{border-bottom:0}",
40
40
  ].join("");
@@ -97,13 +97,37 @@ window.__ModuleLoader__.load({
97
97
  function matchingTools(tools, patterns) {
98
98
  return (tools || []).filter((tool) => (patterns || []).some((pattern) => matchesPattern(tool.name, pattern)));
99
99
  }
100
- function groupedNames(preset) {
100
+ function groupedNames(preset, exceptKey) {
101
101
  const names = new Set();
102
102
  for (const group of preset.policy.groups || []) {
103
+ if (exceptKey && group._key === exceptKey) continue;
103
104
  for (const tool of matchingTools(preset.tools, group.patterns)) names.add(tool.name);
104
105
  }
105
106
  return names;
106
107
  }
108
+ function eligibleGroupTools(preset, exceptKey) {
109
+ const disabled = new Set(preset.policy.disabled || []);
110
+ const occupied = groupedNames(preset, exceptKey);
111
+ return (preset.tools || []).filter((tool) => !disabled.has(tool.name) && !occupied.has(tool.name));
112
+ }
113
+ function groupDraftIssues(preset) {
114
+ const disabled = new Set(preset.policy.disabled || []);
115
+ const owners = new Map();
116
+ const empty = [];
117
+ const disabledMembers = [];
118
+ for (const group of preset.policy.groups || []) {
119
+ const members = matchingTools(preset.tools, group.patterns);
120
+ if (!members.some((tool) => !disabled.has(tool.name))) empty.push(group.name || "未命名分组");
121
+ for (const tool of members) {
122
+ if (disabled.has(tool.name)) disabledMembers.push({ tool: tool.name, group: group.name || "未命名分组" });
123
+ const groups = owners.get(tool.name) || [];
124
+ groups.push(group.name || "未命名分组");
125
+ owners.set(tool.name, groups);
126
+ }
127
+ }
128
+ const duplicates = [...owners].filter(([, groups]) => groups.length > 1);
129
+ return { empty, disabledMembers, duplicates };
130
+ }
107
131
  function catalogStats(preset) {
108
132
  const disabled = new Set(preset.policy.disabled || []);
109
133
  const grouped = groupedNames(preset);
@@ -128,6 +152,45 @@ window.__ModuleLoader__.load({
128
152
  return name;
129
153
  }
130
154
 
155
+ function defaultAutoGroupPrompt(tools, otherGroupNames) {
156
+ const list = (tools || []).map((tool) => ({
157
+ name: String(tool.name || ""),
158
+ description: String(tool.description || "").trim().replace(/\s+/g, " "),
159
+ }));
160
+ const forbidden = (otherGroupNames && otherGroupNames.length > 0) ? otherGroupNames : ["(无)"];
161
+ return [
162
+ "请把以下尚未分组的工具按共同能力和使用场景聚类成多个按需工具组,并为每组生成中文名称和描述。",
163
+ "要求:",
164
+ "1. 每个工具最多出现在一个组;tools 必须使用输入中的精确工具名。",
165
+ "2. 不要为了覆盖全部工具而制造不合理分组;不适合归组的工具放入 ungrouped。",
166
+ "3. 避免只有一个工具的碎片组,也避免含义模糊、规模过大的杂项组;组数由工具语义决定。",
167
+ "4. 每组名称使用简洁自然的中文,建议 2 到 10 个汉字;描述用一句简洁中文概括用途。",
168
+ "5. 新组名称互不重复,且不得与这些现有分组重名:" + forbidden.join("、") + "。",
169
+ "6. 只输出一个 JSON 对象,不要输出 Markdown、解释或额外字段。",
170
+ '格式:{"groups":[{"name":"...","description":"...","tools":["exact_name"]}],"ungrouped":["exact_name"]}',
171
+ "候选工具:",
172
+ JSON.stringify(list, null, 2),
173
+ ].join("\n");
174
+ }
175
+
176
+ function defaultGroupSuggestionPrompt(tools, otherGroupNames) {
177
+ const list = (tools || []).map((tool) => ({
178
+ name: String(tool.name || ""),
179
+ description: String(tool.description || "").trim().replace(/\s+/g, " "),
180
+ }));
181
+ const forbidden = (otherGroupNames && otherGroupNames.length > 0) ? otherGroupNames : ["(无)"];
182
+ return [
183
+ "请根据以下已选择的工具,为一个按需工具组生成名称和描述。",
184
+ "要求:",
185
+ "1. 名称使用简洁自然的中文,概括共同用途,建议 2 到 10 个汉字。",
186
+ "2. 描述使用一句简洁中文,说明该组适合完成什么任务,不要逐个罗列工具。",
187
+ "3. 名称不得与这些其他分组重名:" + forbidden.join("、") + "。",
188
+ '4. 只输出一个 JSON 对象,不要输出 Markdown、解释或额外字段。格式:{"name":"...","description":"..."}',
189
+ "已选择工具:",
190
+ JSON.stringify(list, null, 2),
191
+ ].join("\n");
192
+ }
193
+
131
194
  function ToolManagerSection() {
132
195
  const [snapshot, setSnapshot] = react.useState(null);
133
196
  const [draft, setDraft] = react.useState(null);
@@ -142,6 +205,9 @@ window.__ModuleLoader__.load({
142
205
  const [autoGroupError, setAutoGroupError] = react.useState("");
143
206
  const [autoPreview, setAutoPreview] = react.useState(null);
144
207
  const [expanded, setExpanded] = react.useState({});
208
+ const [aiConfirm, setAiConfirm] = react.useState(null);
209
+ const [suggestionTimeoutSeconds, setSuggestionTimeoutSeconds] = react.useState("60");
210
+ const [autoGroupTimeoutSeconds, setAutoGroupTimeoutSeconds] = react.useState("120");
145
211
 
146
212
  const load = react.useCallback(() => {
147
213
  setBusy(true); setError("");
@@ -163,13 +229,17 @@ window.__ModuleLoader__.load({
163
229
  return () => window.removeEventListener("beforeunload", onBeforeUnload);
164
230
  }, [dirty]);
165
231
  react.useEffect(() => {
166
- if (!modal) return undefined;
232
+ if (!modal && !aiConfirm && !autoPreview) return undefined;
167
233
  function onKeyDown(event) {
168
- if (event.key === "Escape") setModal(null);
234
+ if (event.key === "Escape") {
235
+ if (aiConfirm) setAiConfirm(null);
236
+ else if (autoPreview) setAutoPreview(null);
237
+ else if (modal) setModal(null);
238
+ }
169
239
  }
170
240
  window.addEventListener("keydown", onKeyDown);
171
241
  return () => window.removeEventListener("keydown", onKeyDown);
172
- }, [modal]);
242
+ }, [modal, aiConfirm, autoPreview]);
173
243
 
174
244
  if (!draft) return h("div", { className: "tm_root" }, error ? h("div", { className: "tm_error" }, error) : h("div", { className: "tm_muted" }, "正在读取工具目录…"));
175
245
  const preset = draft.presets.find((item) => item.id === active) || draft.presets[0];
@@ -207,12 +277,13 @@ window.__ModuleLoader__.load({
207
277
  }
208
278
 
209
279
  function openEdit(group) {
280
+ const members = matchingTools(preset.tools, group.patterns || []).map((tool) => tool.name);
210
281
  setModal({
211
282
  mode: "edit",
212
283
  key: group._key,
213
284
  name: group.name || "",
214
285
  description: group.description || "",
215
- patterns: [...(group.patterns || [])],
286
+ patterns: members,
216
287
  query: "",
217
288
  generating: false,
218
289
  generateError: "",
@@ -231,6 +302,10 @@ window.__ModuleLoader__.load({
231
302
  setModal((current) => current ? { ...current, ...patch } : current);
232
303
  }
233
304
 
305
+ function patchAiConfirm(patch) {
306
+ setAiConfirm((current) => current ? { ...current, ...patch } : current);
307
+ }
308
+
234
309
  function generateGroupDetails() {
235
310
  if (!modal || modal.generating || !(modal.patterns || []).length) return;
236
311
  const key = modal.key;
@@ -238,23 +313,40 @@ window.__ModuleLoader__.load({
238
313
  .filter((group) => group._key !== key)
239
314
  .map((group) => group.name)
240
315
  .filter(Boolean);
241
- const toolNames = matchingTools(preset.tools, modal.patterns || []).map((tool) => tool.name);
316
+ const eligible = new Set(eligibleGroupTools(preset, key).map((tool) => tool.name));
317
+ const selectedTools = matchingTools(preset.tools, modal.patterns || [])
318
+ .filter((tool) => eligible.has(tool.name));
319
+ const toolNames = selectedTools.map((tool) => tool.name);
242
320
  if (!toolNames.length) {
243
321
  patchModal({ generateError: "所选模式当前没有匹配到工具,请重新勾选。" });
244
322
  return;
245
323
  }
246
- patchModal({ generating: true, generateError: "" });
247
- api("/suggest-group", {
248
- method: "POST",
249
- body: JSON.stringify({ presetId: preset.id, toolNames, otherGroupNames }),
250
- }).then((suggestion) => {
251
- setModal((current) => current && current.key === key
252
- ? { ...current, name: suggestion.name || current.name, description: suggestion.description || current.description, generating: false, generateError: "" }
253
- : current);
254
- }).catch((e) => {
255
- setModal((current) => current && current.key === key
256
- ? { ...current, generating: false, generateError: String(e.message || e) }
257
- : current);
324
+ const initialPrompt = defaultGroupSuggestionPrompt(selectedTools, otherGroupNames);
325
+ setAiConfirm({
326
+ kind: "suggest",
327
+ title: "确认自动生成名称和描述",
328
+ message: "将所选工具的名称和描述发送给当前默认模型,并产生一次模型请求。",
329
+ timeoutSeconds: suggestionTimeoutSeconds,
330
+ prompt: initialPrompt,
331
+ promptCustom: false,
332
+ showPrompt: false,
333
+ error: "",
334
+ run: (timeoutMs, _tools, prompt) => {
335
+ setSuggestionTimeoutSeconds(String(timeoutMs / 1000));
336
+ patchModal({ generating: true, generateError: "" });
337
+ api("/suggest-group", {
338
+ method: "POST",
339
+ body: JSON.stringify({ presetId: preset.id, toolNames, otherGroupNames, timeoutMs, prompt }),
340
+ }).then((suggestion) => {
341
+ setModal((current) => current && current.key === key
342
+ ? { ...current, name: suggestion.name || current.name, description: suggestion.description || current.description, generating: false, generateError: "" }
343
+ : current);
344
+ }).catch((e) => {
345
+ setModal((current) => current && current.key === key
346
+ ? { ...current, generating: false, generateError: String(e.message || e) }
347
+ : current);
348
+ });
349
+ },
258
350
  });
259
351
  }
260
352
 
@@ -262,8 +354,9 @@ window.__ModuleLoader__.load({
262
354
  if (!modal) return;
263
355
  const name = String(modal.name || "").trim().replace(/\s+/g, " ");
264
356
  const description = String(modal.description || "").trim();
265
- const patterns = [...new Set(modal.patterns || [])];
266
- if (!name) return;
357
+ const eligible = new Set(eligibleGroupTools(preset, modal.key).map((tool) => tool.name));
358
+ const patterns = [...new Set(modal.patterns || [])].filter((toolName) => eligible.has(toolName));
359
+ if (!name || patterns.length === 0) return;
267
360
  const created = modal.mode === "create";
268
361
  const key = modal.key;
269
362
  mutatePreset((target) => {
@@ -284,8 +377,8 @@ window.__ModuleLoader__.load({
284
377
  if (created) setExpanded((current) => ({ ...current, [key]: true }));
285
378
  }
286
379
 
287
- function autoGroupSignature(toolNames) {
288
- return preset.id + "\n" + [...toolNames].sort().join("\n");
380
+ function autoGroupSignature(toolNames, otherGroupNames = []) {
381
+ return preset.id + "\n" + [...toolNames].sort().join("\n") + "\n---\n" + [...otherGroupNames].sort().join("\n");
289
382
  }
290
383
 
291
384
  function startAutoGroup() {
@@ -297,29 +390,67 @@ window.__ModuleLoader__.load({
297
390
  setAutoGroupError("当前没有未分组且未关闭的工具。");
298
391
  return;
299
392
  }
300
- const toolNames = candidates.map((tool) => tool.name);
301
- const signature = autoGroupSignature(toolNames);
302
- setAutoGrouping(true); setAutoGroupError(""); setAutoPreview(null);
303
- api("/auto-group", {
304
- method: "POST",
305
- body: JSON.stringify({
306
- presetId: preset.id,
307
- toolNames,
308
- otherGroupNames: (preset.policy.groups || []).map((group) => group.name).filter(Boolean),
309
- }),
310
- }).then((result) => {
311
- setAutoPreview({ presetId: preset.id, signature, groups: result.groups || [], ungrouped: result.ungrouped || [] });
312
- }).catch((e) => setAutoGroupError(String(e.message || e))).finally(() => setAutoGrouping(false));
393
+ const allCandidateNames = candidates.map((tool) => tool.name);
394
+ const otherGroupNames = (preset.policy.groups || []).map((group) => group.name).filter(Boolean);
395
+ const initialPrompt = defaultAutoGroupPrompt(candidates, otherGroupNames);
396
+ setAiConfirm({
397
+ kind: "auto-group",
398
+ title: "确认自动分组",
399
+ message: "筛选并勾选需要分组的工具,发送给当前默认模型进行聚类。",
400
+ timeoutSeconds: autoGroupTimeoutSeconds,
401
+ query: "",
402
+ selected: allCandidateNames,
403
+ prompt: initialPrompt,
404
+ promptCustom: false,
405
+ showPrompt: false,
406
+ error: "",
407
+ run: (timeoutMs, selectedToolNames, prompt) => {
408
+ setAutoGroupTimeoutSeconds(String(timeoutMs / 1000));
409
+ setAutoGrouping(true); setAutoGroupError(""); setAutoPreview(null);
410
+ const signature = autoGroupSignature(selectedToolNames, otherGroupNames);
411
+ api("/auto-group", {
412
+ method: "POST",
413
+ body: JSON.stringify({ presetId: preset.id, toolNames: selectedToolNames, otherGroupNames, timeoutMs, prompt }),
414
+ }).then((result) => {
415
+ setAutoPreview({ presetId: preset.id, signature, selectedTools: selectedToolNames, groups: result.groups || [], ungrouped: result.ungrouped || [] });
416
+ }).catch((e) => setAutoGroupError(String(e.message || e))).finally(() => setAutoGrouping(false));
417
+ },
418
+ });
419
+ }
420
+
421
+ function confirmAiRequest() {
422
+ if (!aiConfirm) return;
423
+ const seconds = Number(aiConfirm.timeoutSeconds);
424
+ if (!Number.isInteger(seconds) || seconds < 5 || seconds > 600) {
425
+ patchAiConfirm({ error: "超时时间必须是 5 到 600 之间的整数秒。" });
426
+ return;
427
+ }
428
+ const selected = aiConfirm.selected || [];
429
+ let prompt = String(aiConfirm.prompt || "").trim();
430
+ if (!prompt) {
431
+ patchAiConfirm({ error: "提示词不能为空,请输入有效提示词或点击重置为默认。" });
432
+ return;
433
+ }
434
+ if (aiConfirm.kind === "auto-group" && selected.length === 0) {
435
+ patchAiConfirm({ error: "请至少勾选一个工具进行分组。" });
436
+ return;
437
+ }
438
+ const run = aiConfirm.run;
439
+ setAiConfirm(null);
440
+ run(seconds * 1000, selected, prompt);
313
441
  }
314
442
 
315
443
  function applyAutoGroups() {
316
444
  if (!autoPreview || autoPreview.presetId !== preset.id) return;
317
445
  const disabledNames = new Set(preset.policy.disabled || []);
318
446
  const alreadyGrouped = groupedNames(preset);
319
- const currentCandidates = (preset.tools || []).filter((tool) => !disabledNames.has(tool.name) && !alreadyGrouped.has(tool.name)).map((tool) => tool.name);
320
- if (autoPreview.signature !== autoGroupSignature(currentCandidates)) {
447
+ const allPresetToolNames = new Set((preset.tools || []).map((tool) => tool.name));
448
+ const targetTools = autoPreview.selectedTools || (preset.tools || []).filter((tool) => !disabledNames.has(tool.name) && !alreadyGrouped.has(tool.name)).map((tool) => tool.name);
449
+ const validSelected = targetTools.filter((name) => allPresetToolNames.has(name) && !disabledNames.has(name) && !alreadyGrouped.has(name));
450
+ const currentOtherGroupNames = (preset.policy.groups || []).map((group) => group.name).filter(Boolean);
451
+ if (autoPreview.signature !== autoGroupSignature(validSelected, currentOtherGroupNames)) {
321
452
  setAutoPreview(null);
322
- setAutoGroupError("工具或分组草稿已经变化,请重新自动分组。");
453
+ setAutoGroupError("所选工具或分组草稿已经变化,请重新自动分组。");
323
454
  return;
324
455
  }
325
456
  const addedKeys = [];
@@ -346,6 +477,27 @@ window.__ModuleLoader__.load({
346
477
  }
347
478
 
348
479
  function save() {
480
+ for (const item of draft.presets || []) {
481
+ if (item.broken) continue;
482
+ const issues = groupDraftIssues(item);
483
+ if (issues.disabledMembers.length) {
484
+ const issue = issues.disabledMembers[0];
485
+ setError("Preset “" + item.id + "”中的已关闭工具“" + issue.tool + "”不能加入分组“" + issue.group + "”。请从分组移除或重新开启该工具。");
486
+ setMessage("");
487
+ return;
488
+ }
489
+ if (issues.duplicates.length) {
490
+ const issue = issues.duplicates[0];
491
+ setError("Preset “" + item.id + "”中的工具“" + issue[0] + "”重复属于分组:" + issue[1].join("、") + "。每个工具只能属于一个分组。");
492
+ setMessage("");
493
+ return;
494
+ }
495
+ if (issues.empty.length) {
496
+ setError("Preset “" + item.id + "”中的分组“" + issues.empty[0] + "”没有可用工具。请为它选择至少一个工具,或删除该分组后再保存。");
497
+ setMessage("");
498
+ return;
499
+ }
500
+ }
349
501
  const settings = settingsPayload(draft);
350
502
  setBusy(true); setError(""); setMessage("");
351
503
  api("/save", { method: "POST", body: JSON.stringify({ expectedRevision: snapshot.revision, settings }) })
@@ -382,10 +534,35 @@ window.__ModuleLoader__.load({
382
534
  const orphans = (preset.policy.disabled || []).filter((name) => !(preset.tools || []).some((tool) => tool.name === name));
383
535
  const modalNeedle = String(modal && modal.query || "").trim().toLowerCase();
384
536
  const modalSelected = new Set(modal ? modal.patterns || [] : []);
385
- const pickerTools = modal ? (preset.tools || []).filter((tool) => matchesQuery(tool, modalNeedle)) : [];
537
+ const modalEligibleTools = modal ? eligibleGroupTools(preset, modal.key) : [];
538
+ const modalEligibleNames = new Set(modalEligibleTools.map((tool) => tool.name));
539
+ const pickerTools = modal ? (preset.tools || []).filter((tool) =>
540
+ (modalEligibleNames.has(tool.name) || modalSelected.has(tool.name)) && matchesQuery(tool, modalNeedle)) : [];
386
541
  const visibleSelected = pickerTools.filter((tool) => modalSelected.has(tool.name)).map((tool) => tool.name);
387
- const canConfirm = !!(modal && String(modal.name || "").trim());
542
+ const modalMatchedTools = modal ? matchingTools(preset.tools, modal.patterns || []).filter((tool) => modalEligibleNames.has(tool.name)) : [];
543
+ const modalInvalidSelected = modal ? [...modalSelected].filter((name) => !modalEligibleNames.has(name)) : [];
544
+ const canConfirm = !!(modal && String(modal.name || "").trim() && modalMatchedTools.length > 0 && modalInvalidSelected.length === 0);
388
545
  const listedGroups = showGroups ? visibleGroups : [];
546
+ const aiIsAutoGroup = !!(aiConfirm && aiConfirm.kind === "auto-group");
547
+ const aiNeedle = String(aiConfirm && aiConfirm.query || "").trim().toLowerCase();
548
+ const aiCandidates = (preset.tools || []).filter((tool) => !disabled.has(tool.name) && !grouped.has(tool.name));
549
+ const aiVisibleCandidates = aiIsAutoGroup ? aiCandidates.filter((tool) => matchesQuery(tool, aiNeedle)) : [];
550
+ const aiSelected = new Set(aiConfirm && aiConfirm.selected ? aiConfirm.selected : []);
551
+ const aiVisibleSelected = aiVisibleCandidates.filter((tool) => aiSelected.has(tool.name)).map((tool) => tool.name);
552
+ const aiPromptTrimmed = String(aiConfirm && aiConfirm.prompt || "").trim();
553
+ const aiCanConfirm = aiPromptTrimmed.length > 0 && (!aiIsAutoGroup || aiSelected.size > 0);
554
+
555
+ function updateAutoGroupSelection(nextSelectedNames) {
556
+ const nextSelected = [...new Set(nextSelectedNames)];
557
+ const patch = { selected: nextSelected, error: "" };
558
+ if (aiConfirm && !aiConfirm.promptCustom) {
559
+ const nextSelectedSet = new Set(nextSelected);
560
+ const nextTools = (preset.tools || []).filter((t) => nextSelectedSet.has(t.name));
561
+ const otherGroupNames = (preset.policy.groups || []).map((g) => g.name).filter(Boolean);
562
+ patch.prompt = defaultAutoGroupPrompt(nextTools, otherGroupNames);
563
+ }
564
+ patchAiConfirm(patch);
565
+ }
389
566
 
390
567
  function renderGroup(group) {
391
568
  const key = group._key;
@@ -408,7 +585,7 @@ window.__ModuleLoader__.load({
408
585
  h("div", { className: "tm_tool_name" }, tool.name, disabled.has(tool.name) ? h("span", { className: "tm_badge off" }, "关闭") : null),
409
586
  h("div", { className: "tm_tool_desc", title: tool.description }, tool.description),
410
587
  ))
411
- : h("div", { className: "tm_muted" }, "这个组还没有工具。点编辑勾选。"),
588
+ : h("div", { className: "tm_error" }, "无效空组:请编辑并选择至少一个可用工具,或删除该组。"),
412
589
  ) : null,
413
590
  );
414
591
  }
@@ -426,6 +603,163 @@ window.__ModuleLoader__.load({
426
603
  );
427
604
  }
428
605
 
606
+ const aiConfirmDialog = aiConfirm && typeof document !== "undefined" ? reactDom.createPortal(
607
+ h("div", { className: "tm_modal", role: "dialog", "aria-modal": "true", "aria-label": aiConfirm.title },
608
+ h("div", { className: "tm_modal_mask", onMouseDown: () => setAiConfirm(null) }),
609
+ h("div", { className: "tm_modal_card" },
610
+ h("div", { className: "tm_modal_head" },
611
+ h("div", null, h("h3", null, aiConfirm.title), h("div", { className: "tm_muted" }, aiConfirm.message)),
612
+ h("button", { className: "tm_btn", onClick: () => setAiConfirm(null) }, "关闭"),
613
+ ),
614
+ h("div", { className: "tm_modal_body" },
615
+ aiIsAutoGroup ? [
616
+ h("div", { className: "tm_row", key: "row" },
617
+ h("input", {
618
+ className: "tm_input",
619
+ value: aiConfirm.query || "",
620
+ placeholder: "筛选工具名或描述",
621
+ onChange: (e) => patchAiConfirm({ query: e.target.value }),
622
+ }),
623
+ h("button", {
624
+ className: "tm_btn",
625
+ disabled: aiVisibleCandidates.length === 0 || aiVisibleCandidates.every((tool) => aiSelected.has(tool.name)),
626
+ onClick: () => updateAutoGroupSelection([...(aiConfirm.selected || []), ...aiVisibleCandidates.map((tool) => tool.name)]),
627
+ }, "全选当前筛选"),
628
+ h("button", {
629
+ className: "tm_btn",
630
+ disabled: aiVisibleSelected.length === 0,
631
+ onClick: () => updateAutoGroupSelection((aiConfirm.selected || []).filter((name) => !aiVisibleSelected.includes(name))),
632
+ }, "清除当前筛选"),
633
+ ),
634
+ aiSelected.size === 0
635
+ ? h("div", { className: "tm_error", key: "status" }, "请至少勾选一个工具进行分组。")
636
+ : h("div", { className: "tm_muted", key: "status" }, "已勾选 " + aiSelected.size + " / " + aiCandidates.length + " 个候选工具。自动分组会调用当前默认模型,结果仍可手动修改。"),
637
+ aiVisibleCandidates.length
638
+ ? h("div", { className: "tm_picker", key: "picker" }, aiVisibleCandidates.map((tool) => h("label", { className: "tm_pick", key: tool.name },
639
+ h("input", {
640
+ type: "checkbox",
641
+ checked: aiSelected.has(tool.name),
642
+ onChange: (e) => {
643
+ const next = new Set(aiConfirm.selected || []);
644
+ if (e.target.checked) next.add(tool.name); else next.delete(tool.name);
645
+ updateAutoGroupSelection([...next]);
646
+ },
647
+ }),
648
+ h("span", null,
649
+ h("div", { className: "tm_tool_name" }, tool.name),
650
+ h("div", { className: "tm_tool_desc", title: tool.description }, tool.description),
651
+ ),
652
+ )))
653
+ : h("div", { className: "tm_muted", key: "empty", style: { padding: "12px" } }, aiCandidates.length ? "没有符合筛选的工具。" : "当前没有可分组的工具。"),
654
+ ] : null,
655
+ h("div", {
656
+ style: {
657
+ border: "1px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, .2))",
658
+ borderRadius: "8px",
659
+ padding: "10px 12px",
660
+ background: "var(--dsw-alias-bg-layer-1, rgba(128, 128, 128, .04))",
661
+ },
662
+ key: "promptSection",
663
+ },
664
+ h("div", {
665
+ style: {
666
+ display: "flex",
667
+ alignItems: "center",
668
+ justifyContent: "space-between",
669
+ gap: "8px",
670
+ flexWrap: "wrap",
671
+ },
672
+ },
673
+ h("div", { style: { display: "flex", alignItems: "center", gap: "6px" } },
674
+ h("button", {
675
+ type: "button",
676
+ className: "tm_btn",
677
+ style: { fontSize: "11px", padding: "4px 8px" },
678
+ onClick: () => patchAiConfirm({ showPrompt: !aiConfirm.showPrompt }),
679
+ }, aiConfirm.showPrompt ? "▾ 收起提示词" : "▸ 预览与编辑提示词"),
680
+ h("span", { className: "tm_muted" },
681
+ aiConfirm.promptCustom
682
+ ? "已自定义(共 " + (aiConfirm.prompt || "").length + " 字符)"
683
+ : "默认提示词(共 " + (aiConfirm.prompt || "").length + " 字符)",
684
+ ),
685
+ aiConfirm.promptCustom ? h("span", { className: "tm_badge cold" }, "已修改") : null,
686
+ ),
687
+ aiConfirm.showPrompt ? h("button", {
688
+ type: "button",
689
+ className: "tm_btn",
690
+ style: { fontSize: "11px", padding: "4px 8px" },
691
+ disabled: !aiConfirm.promptCustom,
692
+ onClick: () => {
693
+ if (aiIsAutoGroup) {
694
+ const selectedTools = (preset.tools || []).filter((t) => aiSelected.has(t.name));
695
+ const otherGroupNames = (preset.policy.groups || []).map((g) => g.name).filter(Boolean);
696
+ patchAiConfirm({
697
+ prompt: defaultAutoGroupPrompt(selectedTools, otherGroupNames),
698
+ promptCustom: false,
699
+ error: "",
700
+ });
701
+ } else if (modal) {
702
+ const key = modal.key;
703
+ const otherGroupNames = (preset.policy.groups || [])
704
+ .filter((group) => group._key !== key)
705
+ .map((group) => group.name)
706
+ .filter(Boolean);
707
+ const eligible = new Set(eligibleGroupTools(preset, key).map((tool) => tool.name));
708
+ const selectedTools = matchingTools(preset.tools, modal.patterns || [])
709
+ .filter((tool) => eligible.has(tool.name));
710
+ patchAiConfirm({
711
+ prompt: defaultGroupSuggestionPrompt(selectedTools, otherGroupNames),
712
+ promptCustom: false,
713
+ error: "",
714
+ });
715
+ }
716
+ },
717
+ }, "重置为默认提示词") : null,
718
+ ),
719
+ aiConfirm.showPrompt ? h("div", { style: { marginTop: "8px" } },
720
+ h("textarea", {
721
+ className: "tm_input",
722
+ style: {
723
+ width: "100%",
724
+ minHeight: "140px",
725
+ maxHeight: "280px",
726
+ resize: "vertical",
727
+ fontFamily: "ui-monospace, SFMono-Regular, Consolas, monospace",
728
+ fontSize: "11px",
729
+ lineHeight: "1.45",
730
+ whiteSpace: "pre-wrap",
731
+ },
732
+ value: aiConfirm.prompt || "",
733
+ placeholder: "提示词内容...",
734
+ onChange: (e) => patchAiConfirm({ prompt: e.target.value, promptCustom: true, error: "" }),
735
+ }),
736
+ !aiPromptTrimmed ? h("div", { className: "tm_error", style: { marginTop: "6px" } }, "提示词不能为空,请输入有效提示词或点击重置为默认。") : null,
737
+ ) : null,
738
+ ),
739
+ h("label", { className: "tm_timeout_field" },
740
+ h("span", null, "超时时间"),
741
+ h("input", {
742
+ className: "tm_input",
743
+ type: "number",
744
+ min: 5,
745
+ max: 600,
746
+ step: 1,
747
+ value: aiConfirm.timeoutSeconds,
748
+ onChange: (event) => patchAiConfirm({ timeoutSeconds: event.target.value, error: "" }),
749
+ }),
750
+ h("span", { className: "tm_muted" }, "秒(5–600)"),
751
+ ),
752
+ aiConfirm.error ? h("div", { className: "tm_error" }, aiConfirm.error) : null,
753
+ ),
754
+ h("div", { className: "tm_modal_foot" },
755
+ h("button", { className: "tm_btn", onClick: () => setAiConfirm(null) }, "取消"),
756
+ h("button", { className: "tm_btn primary", disabled: !aiCanConfirm, onClick: confirmAiRequest }, "确认执行"),
757
+ ),
758
+ ),
759
+ ),
760
+ document.body,
761
+ ) : null;
762
+
429
763
  const dialog = modal && typeof document !== "undefined" ? reactDom.createPortal(
430
764
  h("div", { className: "tm_modal", role: "dialog", "aria-modal": "true", "aria-label": modal.mode === "create" ? "新建按需组" : "编辑按需组" },
431
765
  h("div", { className: "tm_modal_mask", onMouseDown: () => setModal(null) }),
@@ -440,29 +774,36 @@ window.__ModuleLoader__.load({
440
774
  h("div", { className: "tm_modal_body" },
441
775
  h("div", { className: "tm_row" },
442
776
  h("input", { className: "tm_input", value: modal.name, placeholder: "名称(模型用这个打开)", onChange: (e) => patchModal({ name: e.target.value, generateError: "" }) }),
443
- h("button", { className: "tm_btn", disabled: modal.generating || modalSelected.size === 0 || matchingTools(preset.tools, modal.patterns || []).length === 0, onClick: generateGroupDetails }, modal.generating ? "生成中…" : "自动生成名称和描述"),
777
+ h("button", { className: "tm_btn", disabled: modal.generating || modalMatchedTools.length === 0 || modalInvalidSelected.length > 0, onClick: generateGroupDetails }, modal.generating ? "生成中…" : "自动生成名称和描述"),
444
778
  ),
445
779
  modal.generateError ? h("div", { className: "tm_error" }, modal.generateError) : null,
446
780
  h("textarea", { className: "tm_input", style: { width: "100%", minHeight: "72px", resize: "vertical" }, value: modal.description, placeholder: "描述(可选)", onChange: (e) => patchModal({ description: e.target.value, generateError: "" }) }),
447
781
  h("div", { className: "tm_row" },
448
782
  h("input", { className: "tm_input", value: modal.query, placeholder: "筛选工具名或描述", onChange: (e) => patchModal({ query: e.target.value }) }),
449
- h("button", { className: "tm_btn", disabled: pickerTools.length === 0, onClick: () => patchModal({ patterns: [...new Set([...(modal.patterns || []), ...pickerTools.map((tool) => tool.name)])], generateError: "" }) }, "全选当前筛选"),
783
+ h("button", { className: "tm_btn", disabled: pickerTools.every((tool) => !modalEligibleNames.has(tool.name)), onClick: () => patchModal({ patterns: [...new Set([...(modal.patterns || []), ...pickerTools.filter((tool) => modalEligibleNames.has(tool.name)).map((tool) => tool.name)])], generateError: "" }) }, "全选当前筛选"),
450
784
  h("button", { className: "tm_btn", disabled: visibleSelected.length === 0, onClick: () => patchModal({ patterns: (modal.patterns || []).filter((name) => !visibleSelected.includes(name)), generateError: "" }) }, "清除当前筛选"),
451
785
  ),
452
- h("div", { className: "tm_muted" }, "已选 " + modalSelected.size + " 个工具。自动生成会调用当前默认模型,结果仍可手动修改。"),
786
+ modalInvalidSelected.length
787
+ ? h("div", { className: "tm_error" }, "以下工具已关闭或属于其他分组,不能加入当前组:" + modalInvalidSelected.join(", ") + "。请取消选择。")
788
+ : h("div", { className: modalMatchedTools.length ? "tm_muted" : "tm_error" }, modalMatchedTools.length
789
+ ? "已选 " + modalMatchedTools.length + " 个工具。自动生成会调用当前默认模型,结果仍可手动修改。"
790
+ : "每个按需组至少需要一个未关闭且未被其他组占用的工具。"),
453
791
  pickerTools.length
454
792
  ? h("div", { className: "tm_picker" }, pickerTools.map((tool) => h("label", { className: "tm_pick", key: tool.name },
455
793
  h("input", {
456
794
  type: "checkbox",
457
795
  checked: modalSelected.has(tool.name),
796
+ disabled: !modalEligibleNames.has(tool.name) && !modalSelected.has(tool.name),
458
797
  onChange: (e) => {
459
798
  const next = new Set(modal.patterns || []);
460
- if (e.target.checked) next.add(tool.name); else next.delete(tool.name);
799
+ if (e.target.checked && modalEligibleNames.has(tool.name)) next.add(tool.name); else next.delete(tool.name);
461
800
  patchModal({ patterns: [...next], generateError: "" });
462
801
  },
463
802
  }),
464
803
  h("span", null,
465
- h("div", { className: "tm_tool_name" }, tool.name, disabled.has(tool.name) ? h("span", { className: "tm_badge off" }, "已关闭") : null),
804
+ h("div", { className: "tm_tool_name" }, tool.name,
805
+ disabled.has(tool.name) ? h("span", { className: "tm_badge off" }, "已关闭")
806
+ : (!modalEligibleNames.has(tool.name) ? h("span", { className: "tm_badge off" }, "其他组") : null)),
466
807
  h("div", { className: "tm_tool_desc", title: tool.description }, tool.description),
467
808
  ),
468
809
  )))
@@ -485,9 +826,9 @@ window.__ModuleLoader__.load({
485
826
  h("div", null, h("h3", null, "自动分组预览"), h("div", { className: "tm_muted" }, "确认后只加入页面草稿,仍需点击保存。")),
486
827
  h("button", { className: "tm_btn", onClick: () => setAutoPreview(null) }, "关闭"),
487
828
  ),
488
- h("div", { className: "tm_modal_body" },
489
- autoPreview.groups.map((group, index) => h("div", { className: "tm_panel", key: group.name + index },
490
- h("div", { className: "tm_panel_head" }, h("div", null, h("b", null, group.name), h("div", { className: "tm_muted" }, group.description)), h("span", { className: "tm_group_count" }, group.tools.length + " 个工具")),
829
+ h("div", { className: "tm_modal_body tm_preview_body" },
830
+ autoPreview.groups.map((group, index) => h("div", { className: "tm_panel tm_preview_panel", key: group.name + index },
831
+ h("div", { className: "tm_panel_head" }, h("div", { className: "tm_preview_meta" }, h("b", null, group.name), h("div", { className: "tm_preview_desc" }, group.description)), h("span", { className: "tm_group_count" }, group.tools.length + " 个工具")),
491
832
  h("div", { style: { padding: "10px 14px" } }, group.tools.map((name) => h("div", { className: "tm_member tm_tool_name", key: name }, name))),
492
833
  )),
493
834
  autoPreview.ungrouped.length ? h("div", { className: "tm_notice" }, "保持常开、未归组:", h("span", { className: "tm_code" }, autoPreview.ungrouped.join(", "))) : null,
@@ -518,13 +859,15 @@ window.__ModuleLoader__.load({
518
859
  draft.configPath ? h("div", { className: "tm_muted" }, "配置文件:", h("span", { className: "tm_code" }, draft.configPath)) : null,
519
860
  h("div", { className: "tm_preset_picker" },
520
861
  h("label", { htmlFor: "tm-preset-select" }, "Agent Preset"),
521
- h("select", {
522
- id: "tm-preset-select",
523
- className: "tm_preset_select",
524
- value: preset.id,
525
- disabled: autoGrouping,
526
- onChange: (event) => { setActive(event.target.value); setQuery(""); setFilter("all"); setModal(null); setAutoPreview(null); setAutoGroupError(""); setExpanded({}); },
527
- }, draft.presets.map((item) => h("option", { key: item.id, value: item.id }, (item.name || item.id) + " · " + (item.tools || []).length + " 个工具" + (item.isDefault ? " · 默认" : "") + (item.trust === "system" ? "" : " · 用户")))),
862
+ h("span", { className: "tm_select_wrap" },
863
+ h("select", {
864
+ id: "tm-preset-select",
865
+ className: "tm_preset_select",
866
+ value: preset.id,
867
+ disabled: autoGrouping,
868
+ onChange: (event) => { setActive(event.target.value); setQuery(""); setFilter("all"); setModal(null); setAutoPreview(null); setAutoGroupError(""); setExpanded({}); },
869
+ }, draft.presets.map((item) => h("option", { key: item.id, value: item.id }, (item.name || item.id) + " · " + (item.tools || []).length + " 个工具" + (item.isDefault ? " · 默认" : "") + (item.trust === "system" ? "" : " · 用户")))),
870
+ ),
528
871
  ),
529
872
  preset.broken ? h("div", { className: "tm_error" }, preset.broken) : null,
530
873
  autoGroupError ? h("div", { className: "tm_error" }, autoGroupError) : null,
@@ -560,6 +903,7 @@ window.__ModuleLoader__.load({
560
903
  ) : null,
561
904
  ),
562
905
  dialog,
906
+ aiConfirmDialog,
563
907
  previewDialog,
564
908
  );
565
909
  }