@michengai/dsh-im-connect 0.1.77 → 1.0.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/client.js CHANGED
@@ -9,10 +9,16 @@ window.__ModuleLoader__.load({
9
9
  const React = require("react");
10
10
  const { useState, useEffect, useLayoutEffect, useCallback, useRef, useSyncExternalStore } = React;
11
11
  const ReactDOM = require("react-dom");
12
- const primitives = require("@deepseek-ai/dsh-client-ui-primitives");
13
- const HostMenu = typeof primitives.Menu === "function" ? primitives.Menu : function MissingHostMenu(props) { return props.anchor || null; };
14
- const HostModal = typeof primitives.Modal === "function" ? primitives.Modal : function MissingHostModal() { return null; };
15
- const HostButton = typeof primitives.Button === "function" ? primitives.Button : function MissingHostButton(props) { return h("button", { type: "button", className: props && props.className, disabled: props && props.disabled, onClick: props && props.onClick }, props && props.children); };
12
+ const primitives = typeof require === "function" ? (function () { try { return require("@deepseek-ai/dsh-client-ui-primitives"); } catch { return {}; } })() : {};
13
+ const PrimitiveButton = primitives.Button;
14
+ const HostMenu = primitives.Menu;
15
+ const HostModal = primitives.Modal;
16
+ // 宿主 Button 由 forwardRef 包成对象,typeof 是 object,不是 function。
17
+ function isHostComponent(component) {
18
+ return typeof component === "function" || (!!component && typeof component === "object" && typeof component.render === "function");
19
+ }
20
+ // 只关最上层。下层监听先注册,不是顶层就放行,避免一次 Escape 关掉弹窗和宿主设置。
21
+ const modalLayers = [];
16
22
  // 0.1.7 把尺寸从图标名里拿掉了(IconEditOutlineRegular)。旧宿主仍导出 *16/*20。
17
23
  function pickHostIcon(...names) {
18
24
  for (const name of names) {
@@ -63,15 +69,419 @@ window.__ModuleLoader__.load({
63
69
  const IconFolderClose = pickHostIcon("IconFolderCloseRegular", "IconFolderClose16", "IconFolderClose");
64
70
  const IconClockOutline = pickHostIcon("IconClockOutlineRegular", "IconClockOutline16");
65
71
  const IconFlatListOutline = pickHostIcon("IconFlatListOutlineRegular");
66
- const antd = require("antd");
67
- const { ConfigProvider, theme, Modal, Select, Switch, Button: AntdButton, Input, Progress, Checkbox, Segmented, Tag, Alert } = antd;
68
- function Button(props) {
69
- return React.createElement(AntdButton, Object.assign({ shape: "round", size: "middle" }, props));
70
- }
71
- const zhCN = require("antd/locale/zh_CN");
72
- const enUS = require("antd/locale/en_US");
73
- const antdZh = zhCN && zhCN.default ? zhCN.default : zhCN;
74
- const antdEn = enUS && enUS.default ? enUS.default : enUS;
72
+ function alertIcon(type) {
73
+ if (type === "success") {
74
+ return React.createElement("svg", { viewBox: "0 0 16 16", width: 14, height: 14, fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round" },
75
+ React.createElement("path", { d: "m3 8.5 3.5 3.5 6.5-7" })
76
+ );
77
+ }
78
+ if (type === "error") {
79
+ return React.createElement("svg", { viewBox: "0 0 16 16", width: 14, height: 14, fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round" },
80
+ React.createElement("circle", { cx: 8, cy: 8, r: 6 }),
81
+ React.createElement("path", { d: "m8 5v3.5M8 11.5h.01" })
82
+ );
83
+ }
84
+ return React.createElement("svg", { viewBox: "0 0 16 16", width: 14, height: 14, fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round" },
85
+ React.createElement("circle", { cx: 8, cy: 8, r: 6 }),
86
+ React.createElement("path", { d: "M8 7.5v3.5M8 5h.01" })
87
+ );
88
+ }
89
+ function Alert({ type = "info", message, className, role, showIcon }) {
90
+ return React.createElement("div", {
91
+ role: role || (type === "error" ? "alert" : undefined),
92
+ className: ["ima-alert", "ima-alert-" + type, className].filter(Boolean).join(" "),
93
+ },
94
+ showIcon && React.createElement("span", { className: "ima-alert-icon" }, alertIcon(type)),
95
+ React.createElement("span", { className: "ima-alert-message" }, message)
96
+ );
97
+ }
98
+ function Tag({ color, children, icon, className, bordered, ...props }) {
99
+ const colorCls = color ? "ima-tag-" + color : "";
100
+ return React.createElement("span", {
101
+ ...props,
102
+ className: ["ima-tag", colorCls, className].filter(Boolean).join(" "),
103
+ }, icon && React.createElement("span", { className: "ima-tag-icon", style: { display: "inline-flex", alignItems: "center", marginRight: children ? 4 : 0 } }, icon), children);
104
+ }
105
+ function Input(props) {
106
+ const { className, type = "text", ...rest } = props;
107
+ return React.createElement("input", {
108
+ type,
109
+ ...rest,
110
+ className: ["ima-input", className].filter(Boolean).join(" "),
111
+ });
112
+ }
113
+ function TextArea(props) {
114
+ const { autoSize, className, rows, ...rest } = props;
115
+ return React.createElement("textarea", {
116
+ ...rest,
117
+ className: ["ima-input ima-textarea", className].filter(Boolean).join(" "),
118
+ rows: autoSize?.minRows || rows || 4,
119
+ });
120
+ }
121
+ Input.TextArea = TextArea;
122
+ function Checkbox({ checked, onChange, children, className, disabled, ...props }) {
123
+ return React.createElement("label", {
124
+ className: ["ima-checkbox-label", disabled ? "is-disabled" : "", className].filter(Boolean).join(" "),
125
+ },
126
+ React.createElement("input", {
127
+ type: "checkbox",
128
+ checked: Boolean(checked),
129
+ disabled,
130
+ onChange,
131
+ className: "ima-checkbox",
132
+ ...props,
133
+ }),
134
+ children ? React.createElement("span", { className: "ima-checkbox-text" }, children) : null
135
+ );
136
+ }
137
+ function Segmented({ options = [], value, onChange, disabled, block, className }) {
138
+ return React.createElement("div", {
139
+ role: "radiogroup",
140
+ className: ["ima-segmented", block ? "is-block" : "", className].filter(Boolean).join(" "),
141
+ }, options.map((opt) => {
142
+ const val = typeof opt === "object" ? opt.value : opt;
143
+ const lbl = typeof opt === "object" ? opt.label : opt;
144
+ const active = val === value;
145
+ return React.createElement("button", {
146
+ key: String(val),
147
+ type: "button",
148
+ role: "radio",
149
+ "aria-checked": active,
150
+ disabled,
151
+ className: ["ima-segmented-item", active ? "is-active" : ""].filter(Boolean).join(" "),
152
+ onClick: () => { if (!disabled && onChange) onChange(val); },
153
+ }, lbl);
154
+ }));
155
+ }
156
+ function hostModalButton(label, onClick, kind, extra) {
157
+ const options = extra || {};
158
+ const isDanger = kind === "danger" || options.danger;
159
+ const variant = isDanger ? "outline" : (kind === "primary" ? "primary" : "outline");
160
+ const dangerClass = isDanger ? "ima-btn-danger" : "";
161
+ const className = [options.className, dangerClass].filter(Boolean).join(" ") || undefined;
162
+ if (isHostComponent(PrimitiveButton)) {
163
+ return React.createElement(PrimitiveButton, {
164
+ variant,
165
+ disabled: options.disabled,
166
+ className,
167
+ onClick,
168
+ type: "button",
169
+ }, label);
170
+ }
171
+ return React.createElement(Button, {
172
+ variant,
173
+ disabled: options.disabled,
174
+ className,
175
+ onClick,
176
+ }, label);
177
+ }
178
+ function Modal(props) {
179
+ const { open, title, onCancel, onOk, okText, cancelText, okButtonProps, confirmLoading, width = 640, zIndex = 1100, children, footer, className, keyboard, maskClosable, closeLabel, description } = props;
180
+ const requestClose = onCancel || props.onClose;
181
+ const closeRef = useRef(requestClose);
182
+ closeRef.current = requestClose;
183
+ const layerRef = useRef(null);
184
+ if (!layerRef.current) layerRef.current = { owner: props.layerOwner || "modal" };
185
+ useEffect(() => {
186
+ if (!open) return undefined;
187
+ const layer = layerRef.current;
188
+ modalLayers.push(layer);
189
+ const onKey = (event) => {
190
+ if (event.key !== "Escape") return;
191
+ if (modalLayers[modalLayers.length - 1] !== layer) return;
192
+ event.preventDefault();
193
+ event.stopPropagation();
194
+ if (typeof event.stopImmediatePropagation === "function") event.stopImmediatePropagation();
195
+ if (keyboard === false) return;
196
+ if (closeRef.current) closeRef.current();
197
+ };
198
+ window.addEventListener("keydown", onKey, true);
199
+ return () => {
200
+ window.removeEventListener("keydown", onKey, true);
201
+ const index = modalLayers.lastIndexOf(layer);
202
+ if (index >= 0) modalLayers.splice(index, 1);
203
+ };
204
+ }, [open, keyboard]);
205
+ if (!open) return null;
206
+ const handleClose = () => { if (closeRef.current) closeRef.current(); };
207
+ const handleOk = () => { if (onOk) onOk(); };
208
+ const actionRow = footer === null ? null : (footer || React.createElement(React.Fragment, null,
209
+ hostModalButton(cancelText || "取消", handleClose, "outline"),
210
+ hostModalButton(okText || "确定", handleOk, okButtonProps?.danger ? "danger" : "primary", { disabled: okButtonProps?.disabled || confirmLoading, danger: okButtonProps?.danger })
211
+ ));
212
+ const footerNode = Array.isArray(actionRow)
213
+ ? React.createElement(React.Fragment, null, actionRow)
214
+ : actionRow;
215
+ const hostDescription = typeof description === "string" && description !== "" ? { description } : {};
216
+ if (typeof HostModal === "function") {
217
+ return h(HostModal, {
218
+ open: true,
219
+ title,
220
+ onClose: handleClose,
221
+ closeLabel: closeLabel || "Close",
222
+ className,
223
+ footer: footerNode,
224
+ ...hostDescription,
225
+ }, children);
226
+ }
227
+ const allowMask = maskClosable !== false && modalLayers[modalLayers.length - 1] === layerRef.current;
228
+ return React.createElement("div", { className: "ima-modal-root", style: { zIndex } },
229
+ React.createElement("div", { className: "ima-modal-mask", onClick: allowMask ? handleClose : undefined }),
230
+ React.createElement("div", { className: ["ima-modal-wrap", className].filter(Boolean).join(" ") },
231
+ React.createElement("div", { className: "ima-modal-panel", style: { width } },
232
+ React.createElement("div", { className: "ima-modal-header" },
233
+ React.createElement("div", { className: "ima-modal-title" }, title),
234
+ React.createElement("button", { type: "button", className: "ima-modal-close", "aria-label": closeLabel || "Close", onClick: handleClose },
235
+ React.createElement("svg", { viewBox: "0 0 16 16", width: 14, height: 14, fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round" },
236
+ React.createElement("path", { d: "m4 4 8 8M12 4 4 12" })
237
+ )
238
+ )
239
+ ),
240
+ React.createElement("div", { className: "ima-modal-body" },
241
+ description ? React.createElement("p", { className: "ima-confirm-content" }, description) : null,
242
+ children),
243
+ footerNode && React.createElement("div", { className: "ima-modal-footer-wrap" }, footerNode)
244
+ )
245
+ )
246
+ );
247
+ }
248
+ function useModal() {
249
+ const [config, setConfig] = React.useState(null);
250
+ const confirm = (opts) => { setConfig(opts); };
251
+ const holder = config ? React.createElement(Modal, {
252
+ open: true,
253
+ title: config.title,
254
+ width: 480,
255
+ description: config.description,
256
+ onCancel: () => { setConfig(null); },
257
+ onOk: () => {
258
+ const p = config.onOk?.();
259
+ if (p && typeof p.then === "function") {
260
+ p.then(() => setConfig(null));
261
+ } else {
262
+ setConfig(null);
263
+ }
264
+ },
265
+ okText: config.okText,
266
+ cancelText: config.cancelText,
267
+ okButtonProps: config.okButtonProps,
268
+ }, config.content ? React.createElement("p", { className: "ima-confirm-content" }, config.content) : null) : null;
269
+ return [{ confirm }, holder];
270
+ }
271
+ Modal.useModal = useModal;
272
+ function Switch(props) {
273
+ const on = Boolean(props.checked);
274
+ return React.createElement("button", {
275
+ type: "button",
276
+ role: "switch",
277
+ "aria-checked": on,
278
+ "aria-label": props["aria-label"],
279
+ title: props.title,
280
+ disabled: props.disabled,
281
+ className: "ima-enable-switch" + (props.className ? " " + props.className : ""),
282
+ onClick: function (event) {
283
+ if (event && typeof event.stopPropagation === "function") event.stopPropagation();
284
+ if (!props.disabled && props.onChange) props.onChange(!on);
285
+ },
286
+ }, React.createElement("span", { className: "ima-enable-switch-thumb", "aria-hidden": "true" }));
287
+ }
288
+ function Select(props) {
289
+ const [open, setOpen] = useState(false);
290
+ const rootRef = useRef(null);
291
+
292
+ useEffect(() => {
293
+ if (!open) return undefined;
294
+ const updateWidth = () => {
295
+ const width = rootRef.current?.getBoundingClientRect().width ?? 0;
296
+ if (width > 0) document.documentElement.style.setProperty("--ima-menu-width", `${Math.round(width)}px`);
297
+ };
298
+ updateWidth();
299
+ window.addEventListener("resize", updateWidth);
300
+ return () => {
301
+ window.removeEventListener("resize", updateWidth);
302
+ document.documentElement.style.removeProperty("--ima-menu-width");
303
+ };
304
+ }, [open]);
305
+
306
+ useEffect(() => {
307
+ if (!open || typeof window === "undefined") return undefined;
308
+ const layer = { owner: "select" };
309
+ modalLayers.push(layer);
310
+ function onKey(event) {
311
+ if (event.key !== "Escape") return;
312
+ if (modalLayers[modalLayers.length - 1] !== layer) return;
313
+ event.preventDefault();
314
+ event.stopPropagation();
315
+ event.stopImmediatePropagation();
316
+ setOpen(false);
317
+ }
318
+ window.addEventListener("keydown", onKey, true);
319
+ return () => {
320
+ window.removeEventListener("keydown", onKey, true);
321
+ const index = modalLayers.lastIndexOf(layer);
322
+ if (index >= 0) modalLayers.splice(index, 1);
323
+ };
324
+ }, [open]);
325
+
326
+ const items = React.useMemo(() => {
327
+ const list = [];
328
+ (props.options || []).forEach((opt, idx) => {
329
+ if (Array.isArray(opt.options)) {
330
+ list.push({ type: "label", id: "group-" + idx, text: opt.label || "" });
331
+ opt.options.forEach((sub) => {
332
+ list.push({ id: String(sub.value), label: sub.label, disabled: sub.disabled, danger: sub.danger });
333
+ });
334
+ } else {
335
+ list.push({ id: String(opt.value), label: opt.label, disabled: opt.disabled, danger: opt.danger });
336
+ }
337
+ });
338
+ return list;
339
+ }, [props.options]);
340
+
341
+ const footer = React.useMemo(() => {
342
+ if (!Array.isArray(props.footer) || props.footer.length === 0) return undefined;
343
+ return props.footer.map((item) => ({
344
+ id: String(item.value),
345
+ label: item.label,
346
+ disabled: item.disabled,
347
+ danger: item.danger,
348
+ }));
349
+ }, [props.footer]);
350
+
351
+ const selectedOption = React.useMemo(() => {
352
+ for (const opt of props.options || []) {
353
+ if (Array.isArray(opt.options)) {
354
+ const found = opt.options.find((sub) => String(sub.value) === String(props.value));
355
+ if (found) return found;
356
+ } else if (String(opt.value) === String(props.value)) {
357
+ return opt;
358
+ }
359
+ }
360
+ return null;
361
+ }, [props.options, props.value]);
362
+
363
+ const currentText = selectedOption ? selectedOption.label : (props.placeholder || props["aria-label"] || "");
364
+
365
+ return React.createElement("div", {
366
+ ref: rootRef,
367
+ className: "ima-menu-select-wrap " + (props.className || ""),
368
+ style: props.style,
369
+ },
370
+ React.createElement(HostMenu, {
371
+ open: open,
372
+ listClassName: ["ima-form-menu", props.listClassName].filter(Boolean).join(" "),
373
+ onClose: () => setOpen(false),
374
+ onSelect: (id) => {
375
+ if (props.footer && props.footer.some((item) => String(item.value) === id)) {
376
+ if (typeof props.onFooter === "function") props.onFooter(id);
377
+ setOpen(false);
378
+ return;
379
+ }
380
+ if (props.onChange) props.onChange(id);
381
+ setOpen(false);
382
+ },
383
+ selectedId: props.value != null ? String(props.value) : undefined,
384
+ align: "start",
385
+ portal: true,
386
+ dense: true,
387
+ anchor: React.createElement(Button, {
388
+ variant: "outline",
389
+ size: "sm",
390
+ role: "combobox",
391
+ "aria-label": props["aria-label"] || props.placeholder,
392
+ "aria-expanded": open,
393
+ disabled: props.disabled,
394
+ className: "ima-menu-select-trigger" + (open ? " is-open" : ""),
395
+ onClick: () => { if (!props.disabled) setOpen((prev) => !prev); },
396
+ },
397
+ React.createElement("span", { className: "ima-menu-select-label" }, currentText),
398
+ React.createElement("svg", {
399
+ className: "ima-menu-select-arrow",
400
+ viewBox: "0 0 16 16",
401
+ width: 12,
402
+ height: 12,
403
+ fill: "none",
404
+ stroke: "currentColor",
405
+ strokeWidth: 1.8,
406
+ strokeLinecap: "round",
407
+ strokeLinejoin: "round",
408
+ style: { marginLeft: 4, transition: "transform 150ms ease", transform: open ? "rotate(180deg)" : "none" },
409
+ }, React.createElement("path", { d: "m4 6 4 4 4-4" }))
410
+ ),
411
+ items: items,
412
+ ...(footer ? { footer } : {}),
413
+ })
414
+ );
415
+ }
416
+ function createSpinner() {
417
+ return React.createElement("svg", {
418
+ className: "ima-btn-spinner",
419
+ viewBox: "0 0 16 16",
420
+ width: 14,
421
+ height: 14,
422
+ fill: "none",
423
+ stroke: "currentColor",
424
+ strokeWidth: 2,
425
+ strokeLinecap: "round",
426
+ style: { marginRight: 6, display: "inline-block", verticalAlign: "-2px", animation: "ima-spin 0.8s linear infinite" },
427
+ "aria-hidden": "true",
428
+ }, React.createElement("path", { d: "M8 1.5a6.5 6.5 0 1 0 6.5 6.5" }));
429
+ }
430
+ function Button({ variant, type, danger, loading, block, size, shape, className, children, href, target, rel, icon, ...props }) {
431
+ let mappedVariant = variant ?? "outline";
432
+ if (type === "primary") mappedVariant = "primary";
433
+ else if (type === "text" || type === "link") mappedVariant = "ghost";
434
+
435
+ const isPrimary = mappedVariant === "primary";
436
+ const mappedSize = (size === "small" || size === "sm") ? "sm" : "md";
437
+
438
+ const classes = [
439
+ "ima-btn",
440
+ href ? "ima-link-btn" : "",
441
+ className,
442
+ isPrimary ? "is-primary" : "",
443
+ danger ? "is-danger ima-btn-danger" : "",
444
+ (danger && isPrimary) ? "ima-btn-danger-primary" : "",
445
+ block ? "is-block" : "",
446
+ loading ? "is-loading" : "",
447
+ ].filter(Boolean).join(" ");
448
+
449
+ const iconElement = loading
450
+ ? createSpinner()
451
+ : (icon ? React.createElement("span", {
452
+ key: "icon",
453
+ className: "ima-btn-icon",
454
+ style: { display: "inline-flex", alignItems: "center" },
455
+ }, icon) : null);
456
+ const content = [iconElement, children];
457
+
458
+ if (href) {
459
+ return React.createElement("a", Object.assign({}, props, {
460
+ href,
461
+ target,
462
+ rel: rel || (target === "_blank" ? "noreferrer" : undefined),
463
+ className: classes || undefined,
464
+ "aria-label": props["aria-label"],
465
+ style: props.style,
466
+ }), content);
467
+ }
468
+
469
+ if (isHostComponent(PrimitiveButton)) {
470
+ return React.createElement(PrimitiveButton, Object.assign({}, props, {
471
+ variant: mappedVariant,
472
+ size: mappedSize,
473
+ className: [className, danger ? "ima-btn-danger" : ""].filter(Boolean).join(" ") || undefined,
474
+ disabled: props.disabled || loading,
475
+ icon: loading ? undefined : icon,
476
+ }), loading ? createSpinner() : children);
477
+ }
478
+
479
+ return React.createElement("button", Object.assign({}, props, {
480
+ type: "button",
481
+ className: classes || undefined,
482
+ disabled: props.disabled || loading,
483
+ }), content);
484
+ }
75
485
  const HoverCard = primitives.HoverCard;
76
486
  const StateDot = primitives.StateDot;
77
487
  const IconSettingsOutline16 = pickHostIcon("IconSettingsOutlineRegular", "IconSettingsOutline16");
@@ -419,7 +829,7 @@ window.__ModuleLoader__.load({
419
829
  "qr.weixin": "请使用微信扫描二维码完成绑定", "qr.feishu": "请使用飞书扫描二维码,将自动创建机器人", "qr.lark": "请使用 Lark 扫描二维码完成配对", "qr.wecom": "请使用企业微信扫描二维码,快捷绑定机器人", "qr.dingtalk": "请使用钉钉扫描二维码,自动创建机器人", "qr.qq": "请使用手机 QQ 扫描二维码,创建开放平台机器人", "qr.default": "请使用对应 App 扫描二维码",
420
830
  "status.connected": "已连接", "action.more": "{channel} 更多",
421
831
  "error.loadAssistant": "无法加载账号配置", "error.noModels": "当前 Host 还没有可用模型,请先在网页里配置提供商", "error.save": "保存失败", "error.chooseWorkspace": "请选择工作区目录", "error.workspaceUnavailable": "当前 Host 无法新增工作区", "error.addWorkspace": "新增工作区失败", "error.load": "加载失败", "error.connection": "无法连接本机 IM 助理接口", "error.request": "请求失败", "error.action": "操作失败", "error.qr": "无法生成二维码", "error.detailsInLog": "操作失败,请查看服务器日志。",
422
- "composer.noWorkspaces": "暂无工作区", "composer.addWorkspace": "添加工作区…", "composer.workspaceRequired": "请先添加工作区,否则无法保存", "composer.permission": "权限", "composer.noModels": "暂无模型", "composer.workspacePath": "工作区路径", "action.cancel": "取消", "action.adding": "添加中…",
832
+ "composer.noWorkspaces": "暂无工作区", "composer.addWorkspace": "添加工作区…", "composer.workspaceRequired": "请先添加工作区,否则无法保存", "composer.permission": "权限", "composer.noModels": "暂无模型", "action.cancel": "取消",
423
833
  "permission.readOnly": "只读", "permission.workspaceWrite": "工作区写入", "permission.fullAccess": "完全访问",
424
834
  "rail.workspace": "工作区", "rail.sessions": "会话", "rail.search": "搜索", "rail.searchPlaceholder": "搜索会话...", "rail.clearSearch": "清除搜索", "rail.filter": "筛选", "rail.group": "分组方式", "rail.byWorkspace": "按工作区", "rail.list": "单列表", "rail.byWorkspaceTree": "按工作区树", "rail.sort": "排序方式", "rail.recent": "最近更新", "rail.showArchived": "显示已归档", "rail.onlyArchived": "仅显示已归档", "rail.running": "运行中", "rail.idle": "空闲", "rail.waitingApproval": "等待审批", "rail.planReview": "计划待审", "rail.waitingAnswer": "等待回答", "rail.subagents": "{n} 个子代理运行中", "rail.completed": "已完成", "rail.archived": "已归档", "rail.compactApproval": "待审批", "rail.compactPlan": "计划待审", "rail.compactAnswer": "待回答", "rail.renameAria": "重命名会话", "rail.rename": "重命名", "rail.fork": "分叉会话", "rail.archive": "归档会话", "rail.unarchive": "恢复会话", "rail.stopArchive": "停止并归档", "rail.stopArchiveDescription": "会话“{name}”仍在运行。停止后才能归档。", "rail.stopArchiveConfirm": "停止并归档", "rail.stopArchivePending": "正在停止并归档…", "rail.stopArchiveGroupDescription": "“{name}”下仍有运行中的会话。停止这些会话后才能归档整组。", "rail.archiveFailed": "归档失败,未移除会话。请稍后重试或检查宿主日志。", "rail.deleteSession": "删除会话", "rail.deleteSessionConfirm": "删除会话", "rail.deleteSessionDescription": "将永久删除会话“{name}”及其子代理(含正在运行的)和全部记录(对话内容、统计、缓存),此操作不可恢复。", "rail.deleteSessionPending": "正在删除会话…", "rail.deleteSessionFailed": "删除会话失败:{message}", "rail.deleteSessionClose": "关闭", "rail.deleteSessionCancel": "取消", "rail.groupActions": "“{name}”的频道操作", "rail.channelSettings": "渠道设置", "rail.archiveGroup": "归档整组会话", "rail.archiveGroupConfirm": "确认归档", "rail.archiveGroupDescription": "将归档“{name}”下的 {count} 个会话。归档后可以在“设置 → 已归档”中恢复。", "rail.archiveGroupPending": "正在归档整组会话…", "rail.archiveGroupFailed": "部分会话归档失败:{message}", "rail.archiveGroupClose": "关闭", "rail.archiveGroupCancel": "取消", "rail.empty": "还没有频道会话。先在设置 → IM助理 里连接渠道,并给机器人发一条消息。", "rail.noTasks": "暂无网页任务", "rail.ungrouped": "未分组", "rail.tabsAria": "工作区分类", "rail.tasks": "任务", "rail.channels": "频道",
425
835
  "time.now": "刚刚", "time.minutes": "{n}分钟", "time.hours": "{n}小时", "time.days": "{n}天", "time.months": "{n}个月", "time.years": "{n}年", "time.ago": "{t}前",
@@ -448,7 +858,7 @@ window.__ModuleLoader__.load({
448
858
  "qr.weixin": "Scan the QR code with WeChat to connect", "qr.feishu": "Scan with Feishu; a bot will be created automatically", "qr.lark": "Scan with Lark to pair", "qr.wecom": "Scan with WeCom to quickly connect a bot", "qr.dingtalk": "Scan with DingTalk; a bot will be created automatically", "qr.qq": "Scan with mobile QQ to create an Open Platform bot", "qr.default": "Scan the QR code with the corresponding app",
449
859
  "status.connected": "Connected", "action.more": "More options for {channel}",
450
860
  "error.loadAssistant": "Could not load account settings", "error.noModels": "No models are available in the Host. Configure a provider in the web app first.", "error.save": "Could not save", "error.chooseWorkspace": "Choose a workspace directory", "error.workspaceUnavailable": "This Host cannot create workspaces", "error.addWorkspace": "Could not add workspace", "error.load": "Could not load", "error.connection": "Could not connect to the local IM Assistant API", "error.request": "Request failed", "error.action": "Action failed", "error.qr": "Could not generate a QR code", "error.detailsInLog": "The operation failed. Check the server logs for details.",
451
- "composer.noWorkspaces": "No workspaces", "composer.addWorkspace": "Add workspace…", "composer.workspaceRequired": "Add a workspace before saving.", "composer.permission": "Permission", "composer.noModels": "No models", "composer.workspacePath": "Workspace path", "action.cancel": "Cancel", "action.adding": "Adding…",
861
+ "composer.noWorkspaces": "No workspaces", "composer.addWorkspace": "Add workspace…", "composer.workspaceRequired": "Add a workspace before saving.", "composer.permission": "Permission", "composer.noModels": "No models", "action.cancel": "Cancel",
452
862
  "permission.readOnly": "Read Only", "permission.workspaceWrite": "Workspace Write", "permission.fullAccess": "Full access",
453
863
  "rail.workspace": "Workspaces", "rail.sessions": "Sessions", "rail.search": "Search", "rail.searchPlaceholder": "Search sessions...", "rail.clearSearch": "Clear search", "rail.filter": "Filter", "rail.group": "Group by", "rail.byWorkspace": "By workspace", "rail.list": "Single list", "rail.byWorkspaceTree": "Workspace Tree", "rail.sort": "Sort by", "rail.recent": "Recently updated", "rail.showArchived": "Show archived", "rail.onlyArchived": "Archived only", "rail.running": "Running", "rail.idle": "Idle", "rail.waitingApproval": "Waiting for approval", "rail.planReview": "Plan to review", "rail.waitingAnswer": "Waiting for an answer", "rail.subagents": "{n} subagents running", "rail.completed": "Completed", "rail.archived": "Archived", "rail.compactApproval": "Approval", "rail.compactPlan": "Plan review", "rail.compactAnswer": "Answer", "rail.renameAria": "Rename session", "rail.rename": "Rename", "rail.fork": "Fork session", "rail.archive": "Archive session", "rail.unarchive": "Restore session", "rail.stopArchive": "Stop and archive", "rail.stopArchiveDescription": "Session “{name}” is still running. Stop it before archiving.", "rail.stopArchiveConfirm": "Stop and archive", "rail.stopArchivePending": "Stopping and archiving…", "rail.stopArchiveGroupDescription": "Some conversations in “{name}” are still running. Stop them before archiving the group.", "rail.archiveFailed": "Archive failed. The session was kept. Retry or check the Host logs.", "rail.deleteSession": "Delete session", "rail.deleteSessionConfirm": "Delete session", "rail.deleteSessionDescription": "This permanently deletes session “{name}”, its child agents (including any that are still running), and all of its records (conversation, stats, cache). This cannot be undone.", "rail.deleteSessionPending": "Deleting session…", "rail.deleteSessionFailed": "Could not delete the session: {message}", "rail.deleteSessionClose": "Close", "rail.deleteSessionCancel": "Cancel", "rail.groupActions": "Actions for {name}", "rail.channelSettings": "Channel settings", "rail.archiveGroup": "Archive all conversations", "rail.archiveGroupConfirm": "Archive all", "rail.archiveGroupDescription": "Archive all {count} conversations for “{name}”. You can restore them later in Settings → Archived.", "rail.archiveGroupPending": "Archiving conversations…", "rail.archiveGroupFailed": "Some conversations could not be archived: {message}", "rail.archiveGroupClose": "Close", "rail.archiveGroupCancel": "Cancel", "rail.empty": "No channel sessions yet. Connect a channel in Settings → IM Assistant, then send the bot a message.", "rail.noTasks": "No web tasks", "rail.ungrouped": "Ungrouped", "rail.tabsAria": "Workspace categories", "rail.tasks": "Tasks", "rail.channels": "Channels",
454
864
  "time.now": "now", "time.minutes": "{n}min", "time.hours": "{n}h", "time.days": "{n}d", "time.months": "{n}mo", "time.years": "{n}y", "time.ago": "{t} ago",
@@ -485,18 +895,8 @@ window.__ModuleLoader__.load({
485
895
  }, []);
486
896
  return dark;
487
897
  }
488
- function AntdProvider({ children, locale }) {
489
- const dark = useHostDark();
490
- const lang = locale || currentUiLang();
491
- return h(ConfigProvider, {
492
- locale: lang === "en" ? antdEn : antdZh,
493
- theme: {
494
- algorithm: dark ? theme.darkAlgorithm : theme.defaultAlgorithm,
495
- token: { fontFamily: "inherit" },
496
- components: { Button: { borderRadius: 8 } },
497
- },
498
- button: { autoInsertSpace: false },
499
- }, children);
898
+ function HostThemeProvider({ children }) {
899
+ return children;
500
900
  }
501
901
 
502
902
  const CSS = `
@@ -504,12 +904,31 @@ window.__ModuleLoader__.load({
504
904
  .ima-page{box-sizing:border-box;max-width:none;width:100%;margin:0;padding:0 0 32px;color:var(--ima-text)}
505
905
  .ima-head{display:flex;flex-direction:column;align-items:stretch;gap:12px;margin-bottom:12px}
506
906
  .ima-heading h2,.ima-title{margin:0;font-size:24px;line-height:32px;font-weight:600;letter-spacing:-.4px;white-space:nowrap;text-align:left}
507
- .ima-title-row{display:flex;align-items:center;gap:8px;min-width:0;flex-wrap:wrap}
508
- .ima-title-links{display:inline-flex;align-items:center;gap:8px;min-width:0;flex-wrap:wrap}
509
- .ima-title-links .ant-btn{flex:none}
907
+ .ima-title-row{display:flex;align-items:center;gap:8px 12px;min-width:0;flex-wrap:wrap}
908
+ .ima-title-links{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
909
+ .ima-title-links>span[data-mpi-check]{display:inline-flex;align-items:center}
910
+ .ima-btn{display:inline-flex;align-items:center;justify-content:center;gap:4px;height:32px;padding:0 12px;border:0.5px solid var(--dsw-alias-border-l3,#555);border-radius:var(--dsw-radius-sm,8px);background:transparent;color:var(--dsw-alias-label-primary,#eee);font:inherit;font-size:13px;line-height:20px;cursor:pointer;user-select:none;box-sizing:border-box;text-decoration:none;transition:border-color 120ms ease,color 120ms ease,background 120ms ease}
911
+ .ima-btn:not(.is-primary):not(.ima-btn-danger){color:var(--dsw-alias-label-primary,#eee)!important}
912
+ .ima-btn:hover:not(:disabled):not(.ima-btn-danger){border-color:var(--dsw-alias-border-l3,#666)!important;color:var(--dsw-alias-label-primary,#fff)!important;background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))!important}
913
+ .ima-btn:focus-visible{outline:var(--dsw-focus-ring-width,1px) solid var(--dsw-focus-ring-color,var(--dsw-alias-brand-primary,#4b7cff))!important;outline-offset:0!important}
914
+ .ima-btn:disabled,.ima-btn.is-disabled{opacity:.4!important;cursor:not-allowed!important;pointer-events:none!important}
915
+ .ima-btn.is-primary,.ima-bind-ready .ima-btn.is-primary{background:var(--dsw-alias-button-primary-fill,#f9fafb)!important;border-color:transparent!important;color:var(--dsw-alias-label-primary-foreground,#0f1115)!important}
916
+ .ima-btn.is-primary *,.ima-bind-ready .ima-btn.is-primary *{color:inherit!important;fill:currentColor!important}
917
+ .ima-btn.is-primary:hover:not(:disabled),.ima-bind-ready .ima-btn.is-primary:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover,#ebeef2)!important;color:var(--dsw-alias-label-primary-foreground,#0f1115)!important}
918
+ .ima-btn.is-primary:disabled,.ima-bind-ready .ima-btn.is-primary:disabled{opacity:.4!important;cursor:not-allowed!important}
919
+ .ima-btn.is-block{width:100%!important}
920
+ .ima-link-btn{height:28px!important;padding:0 10px!important;font-size:12px!important}
510
921
  .ima-sub{margin:12px 0 0;max-width:none;color:var(--ima-muted);font-size:14px;line-height:22px;text-align:left}
511
922
  .ima-error{color:var(--ima-danger);font-size:12px;margin:0 0 12px}
512
- .ima-pending,.ima-page>.ant-alert,.ima-inspector .ant-alert{margin:0 0 12px}
923
+ .ima-pending,.ima-page>.ima-alert,.ima-inspector .ima-alert{margin:0 0 12px}
924
+ .ima-alert{display:flex;align-items:flex-start;gap:8px;padding:10px 14px;border-radius:var(--dsw-radius-sm,8px);font-size:13px;line-height:20px;border:0.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1))}
925
+ .ima-alert-error{background:color-mix(in srgb, var(--dsw-alias-state-error-primary,#f85149) 12%, transparent);border-color:color-mix(in srgb, var(--dsw-alias-state-error-primary,#f85149) 30%, transparent);color:var(--dsw-alias-label-primary,#eee)}
926
+ .ima-alert-error .ima-alert-icon{color:var(--dsw-alias-state-error-primary,#f85149)}
927
+ .ima-alert-success{background:color-mix(in srgb, var(--dsw-alias-state-success-primary,#3fb950) 12%, transparent);border-color:color-mix(in srgb, var(--dsw-alias-state-success-primary,#3fb950) 30%, transparent);color:var(--dsw-alias-label-primary,#eee)}
928
+ .ima-alert-success .ima-alert-icon{color:var(--dsw-alias-state-success-primary,#3fb950)}
929
+ .ima-alert-info{background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.08));color:var(--dsw-alias-label-primary,#eee)}
930
+ .ima-alert-icon{display:inline-flex;align-items:center;flex:none;margin-top:3px}
931
+ .ima-alert-message{flex:1;min-width:0;word-break:break-word}
513
932
  .ima-pending-row{display:flex;gap:8px;align-items:center;margin-top:8px}
514
933
  .ima-wrap{display:flex;flex-direction:column;min-height:0;flex:1;height:100%;overflow:hidden}.ima-official-tree{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.ima-native.ima-rail,.ima-rail.dcu-wb{box-sizing:border-box;overflow:hidden}
515
934
  .ima-tabs{display:flex;gap:18px;padding:4px 12px 0;border-bottom:1px solid var(--ima-line)}
@@ -528,10 +947,43 @@ window.__ModuleLoader__.load({
528
947
  .ima-logo.sm[data-brand="wecom"]{border-radius:4px;box-shadow:none;background:transparent}
529
948
  .ima-qrbox{display:flex;flex-direction:column;align-items:center;gap:10px;padding:8px 0 4px}
530
949
  .ima-qrbox img{width:200px;height:200px;background:#fff;border:1px solid var(--ima-line);border-radius:12px;object-fit:contain}
531
- .ima-bind-ready{display:flex;flex-direction:column;align-items:center;gap:14px;padding:12px 0 4px}.ima-bind-ready .ant-btn{min-width:136px}.ima-bind-status{min-height:40px;display:grid;place-items:center;color:var(--ima-muted);font-size:13px;text-align:center}
950
+ .ima-bind-ready{display:flex;flex-direction:column;align-items:center;gap:14px;padding:12px 0 4px}.ima-bind-ready .ima-btn{min-width:136px}.ima-bind-status{min-height:40px;display:grid;place-items:center;color:var(--ima-muted);font-size:13px;text-align:center}
532
951
  .ima-hint{margin:0;color:var(--ima-muted);font-size:13px;text-align:center;line-height:1.6}
533
952
  .ima-field{display:flex;flex-direction:column;gap:6px;margin-bottom:12px;font-size:13px}
534
- .ima-field .ant-input,.ima-field input{width:100%}
953
+ .ima-field .ima-input,.ima-field input{width:100%}
954
+ .ima-input,.ima-account-remark-input,.ima-field input,.ima-rename,.ima-n-search-input{box-sizing:border-box!important;height:36px!important;padding:0 12px!important;border:0.5px solid var(--dsw-alias-border-l2,#494949)!important;border-radius:var(--dsw-radius-sm,8px)!important;background:var(--dsw-alias-bg-layer-1,transparent)!important;color:var(--dsw-alias-label-primary,#eee)!important;font:inherit!important;font-size:13px!important;line-height:20px!important;transition:border-color 120ms ease,background 120ms ease!important}
955
+ .ima-textarea{height:auto!important;min-height:80px;padding:8px 12px!important;resize:vertical}
956
+ .ima-input:hover:not(:disabled),.ima-account-remark-input:hover:not(:disabled),.ima-field input:hover:not(:disabled),.ima-rename:hover,.ima-n-search-input:hover{border-color:var(--dsw-alias-border-l3,#666)!important}
957
+ .ima-input:focus,.ima-account-remark-input:focus,.ima-field input:focus,.ima-rename:focus,.ima-n-search-input:focus{border-color:var(--dsw-alias-brand-primary,#4b7cff)!important;outline:var(--dsw-focus-ring-width,1px) solid var(--dsw-focus-ring-color,var(--dsw-alias-brand-primary,#4b7cff))!important;outline-offset:0!important}
958
+ .ima-input::placeholder,.ima-account-remark-input::placeholder,.ima-field input::placeholder,.ima-n-search-input::placeholder{color:var(--dsw-alias-label-tertiary,#888)!important}
959
+ .ima-input:disabled,.ima-account-remark-input:disabled{opacity:.5!important;cursor:not-allowed!important}
960
+ .ima-checkbox-label{display:inline-flex;align-items:center;gap:8px;font-size:13px;color:var(--dsw-alias-label-primary,#eee);cursor:pointer;user-select:none}
961
+ .ima-checkbox-label.is-disabled{opacity:.5;cursor:not-allowed}
962
+ .ima-checkbox{width:16px;height:16px;margin:0;accent-color:var(--dsw-alias-state-business-primary,#4176e6);cursor:inherit}
963
+ .ima-segmented{display:inline-flex;background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.1));padding:2px;border-radius:var(--dsw-radius-sm,8px);gap:2px;border:0.5px solid var(--dsw-alias-border-l1,rgba(255,255,255,.06))}
964
+ .ima-segmented.is-block{display:flex;width:100%}
965
+ .ima-segmented-item{flex:1;min-width:0;height:28px;padding:0 12px;border:none;border-radius:calc(var(--dsw-radius-sm,8px) - 2px);background:transparent;color:var(--dsw-alias-label-secondary,#a0a0a0);font:inherit;font-size:12px;font-weight:500;cursor:pointer;transition:all 120ms ease;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
966
+ .ima-segmented-item:hover:not(:disabled){color:var(--dsw-alias-label-primary,#eee)}
967
+ .ima-segmented-item.is-active{background:var(--dsw-alias-bg-layer-1,#222);color:var(--dsw-alias-label-primary,#fff);box-shadow:0 1px 3px rgba(0,0,0,.2)}
968
+ .ima-tag{display:inline-flex!important;align-items:center!important;gap:4px!important;height:22px!important;padding:0 8px!important;font-size:12px!important;line-height:20px!important;border-radius:var(--dsw-radius-sm,6px)!important;font-weight:500!important;box-sizing:border-box!important;vertical-align:middle!important;background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.12));color:var(--dsw-alias-label-secondary,#b9b9b9);border:none}
969
+ .ima-tag .ima-btn-spinner{width:11px!important;height:11px!important;margin-right:2px!important;vertical-align:0!important}
970
+ .ima-tag-info,.ima-tag-processing,.ima-tag.is-busy{background:color-mix(in srgb,var(--dsw-alias-state-business-primary,#4176e6) 14%,transparent)!important;color:var(--dsw-alias-state-business-primary,#4176e6)!important}
971
+ .ima-tag-success{background:color-mix(in srgb,var(--dsw-alias-state-success-primary,#3fb950) 14%,transparent)!important;color:var(--dsw-alias-state-success-primary,#3fb950)!important}
972
+ .ima-tag-warning{background:color-mix(in srgb,var(--dsw-alias-state-warn-primary,#d29922) 14%,transparent)!important;color:var(--dsw-alias-state-warn-primary,#d29922)!important}
973
+ .ima-tag-error{background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#f85149) 14%,transparent)!important;color:var(--dsw-alias-state-error-primary,#f85149)!important}
974
+ .ima-modal-root{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;z-index:1100}
975
+ .ima-modal-mask{position:absolute;inset:0;background:rgba(0,0,0,.45);backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px)}
976
+ .ima-modal-wrap{position:relative;max-width:calc(100vw - 32px);max-height:calc(100vh - 48px);overflow:auto;display:flex}
977
+ .ima-modal-panel{position:relative;isolation:isolate;box-sizing:border-box;padding:24px 28px 28px;border-radius:var(--dsw-radius-panel,28px);background:var(--dsw-specific-menu,var(--dsw-alias-bg-layer-1));backdrop-filter:var(--dsw-menu-backdrop-filter,blur(20px));-webkit-backdrop-filter:var(--dsw-menu-backdrop-filter,blur(20px));border:0.5px solid var(--dsw-alias-border-l1,rgba(255,255,255,.1));box-shadow:var(--dsw-elevation-panel,0 20px 48px -12px rgba(0,0,0,.35));color:var(--dsw-alias-label-primary,#eee);display:flex;flex-direction:column;gap:16px}
978
+ .ima-modal-header{display:flex;align-items:center;justify-content:space-between;min-height:24px}
979
+ .ima-modal-title{font-size:17px;font-weight:600;line-height:24px;color:var(--dsw-alias-label-primary,#eee)}
980
+ .ima-modal-close{width:28px;height:28px;display:flex;align-items:center;justify-content:center;border:none;border-radius:var(--dsw-radius-sm,8px);background:transparent;color:var(--dsw-alias-label-tertiary,#888);cursor:pointer;transition:all 120ms ease}
981
+ .ima-modal-close:hover{color:var(--dsw-alias-label-primary,#fff);background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.12))}
982
+ .ima-modal-body{min-height:0;overflow:visible;display:flex;flex-direction:column;gap:12px}
983
+ .ima-modal-actions{display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px}
984
+ .ima-modal-footer-wrap{display:flex;justify-content:flex-end;margin-top:12px;padding-top:16px}
985
+ .ima-inspector-actions>button{flex:none;white-space:nowrap}
986
+ .ima-confirm-content{margin:8px 0 0;font-size:13px;line-height:22px;color:var(--dsw-alias-label-secondary,#b9b9b9)}
535
987
  .ima-page.ima-account-page{container-type:inline-size;min-width:0;max-width:1080px;width:100%;margin:0 auto;padding:0 0 32px}
536
988
  .ima-account-shell,.ima-account-shell *{box-sizing:border-box}
537
989
  .ima-account-shell{display:block;min-height:0;border:0;border-radius:0;overflow:visible;background:transparent}
@@ -548,19 +1000,50 @@ window.__ModuleLoader__.load({
548
1000
  .ima-account-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto auto;align-items:center;gap:12px;width:100%;min-height:48px;padding:10px 12px;border:0;border-radius:8px;background:color-mix(in srgb,var(--ima-text) 7%,transparent);color:inherit;text-align:left}
549
1001
  .ima-account-row:hover{background:var(--ima-card-hover)}
550
1002
  .ima-platform-head:focus-visible,.ima-account-row:focus-visible{outline:2px solid var(--ima-accent);outline-offset:2px}
551
- .ima-account-copy{min-width:0}.ima-account-name{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:500}.ima-account-rename-button{width:100%;padding:0;border:0;background:transparent;color:inherit;text-align:left;cursor:text}.ima-account-rename-button:hover,.ima-account-rename-button:focus-visible{color:var(--ima-accent)}.ima-account-rename,.ima-account-remark-input{box-sizing:border-box;width:100%;height:32px;padding:4px 8px;border:1px solid var(--ima-line);border-radius:6px;background:transparent;color:inherit;font:inherit}.ima-account-id{display:block;margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ima-muted);font-size:11px}.ima-account-row .ant-tag{margin-inline-end:0}
1003
+ .ima-account-copy{min-width:0}.ima-account-name{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:500}.ima-account-rename-button{width:100%;padding:0;border:0;background:transparent;color:inherit;text-align:left;cursor:text}.ima-account-rename-button:hover,.ima-account-rename-button:focus-visible{color:var(--ima-accent)}.ima-account-rename,.ima-account-remark-input{box-sizing:border-box;width:100%;height:32px;padding:4px 8px;border:1px solid var(--ima-line);border-radius:6px;background:transparent;color:inherit;font:inherit}.ima-account-id{display:block;margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ima-muted);font-size:11px}
1004
+ .ima-account-row .ima-tag{margin-inline-end:0}
552
1005
  .ima-account-receive{display:inline-flex;align-items:center;justify-content:flex-end;gap:8px;white-space:nowrap;font-size:12px;color:var(--ima-muted)}
553
1006
  .ima-inspector{padding:22px 24px 26px;min-width:0}.ima-inspector-head{display:flex;align-items:flex-start;gap:12px;padding-bottom:18px;border-bottom:1px solid var(--ima-line)}.ima-inspector-head-copy{min-width:0;flex:1}.ima-inspector-title{margin:1px 0 3px;font-size:17px;line-height:24px}.ima-inspector-title-row{display:flex;align-items:center;gap:12px;min-width:0}.ima-inspector-title-row .ima-inspector-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0}.ima-inspector-title-row .ima-inspector-status{flex:none;white-space:nowrap;font-size:11px}.ima-inspector-head-copy>.ima-account-id{margin-top:5px}
554
1007
  .ima-inspector-status{flex:none}
555
1008
  .ima-form{display:flex;flex-direction:column;gap:16px;padding-top:20px}
556
1009
  .ima-command-permissions{min-width:0;margin:0;padding:0;border:0}
557
- .ima-diagnostic-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.ima-inspector-title-row .ant-tag{margin-inline-end:0}.ima-bind-modal .ant-segmented{width:100%;margin:0 0 16px}.ima-bind-modal .ant-alert{margin-bottom:12px}.ima-connection-check{display:grid;gap:6px;padding:12px;border:1px solid var(--ima-line);border-radius:8px;font-size:12px;line-height:1.6;overflow-wrap:anywhere;color:var(--ima-muted)}.ima-connection-check strong{color:var(--ima-text)}.ima-diagnostic-item{padding:8px 0;border-top:1px solid var(--ima-line)}
558
- .ima-inspector-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:6px;padding-top:18px;border-top:1px solid var(--ima-line)}.ima-inspector-actions .ant-btn{flex:none;white-space:nowrap}.ima-inspector-actions .ant-btn-dangerous{margin-left:auto}
559
- .ima-account-settings{display:grid;grid-template-columns:1fr 1fr;gap:12px 16px}.ima-account-settings.compact{grid-template-columns:1fr}.ima-account-settings .ant-select{width:100%;min-width:0}.ima-account-settings .ant-select-selector{min-height:36px}
560
- .ima-picker-field{display:flex;min-width:0;flex-direction:column;gap:6px}.ima-picker-field.wide,.ima-picker-note,.ima-model-effort{grid-column:1/-1}.ima-model-effort{display:grid;grid-template-columns:1fr 1fr;gap:12px 16px;min-width:0}.ima-account-settings.compact .ima-model-effort{grid-template-columns:1fr}.ima-picker-label{color:var(--ima-muted);font-size:12px;font-weight:550}.ima-picker-note{color:var(--ima-muted);font-size:11px;line-height:1.5}.ima-picker-note.warning{color:var(--ima-warning)}
1010
+ .ima-diagnostic-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.ima-inspector-title-row .ima-tag{margin-inline-end:0}.ima-bind-modal .ima-segmented{width:100%;margin:0 0 16px}.ima-bind-modal .ima-alert{margin-bottom:12px}.ima-connection-check{display:grid;gap:6px;padding:12px;border:1px solid var(--ima-line);border-radius:8px;font-size:12px;line-height:1.6;overflow-wrap:anywhere;color:var(--ima-muted)}.ima-connection-check strong{color:var(--ima-text)}.ima-diagnostic-item{padding:8px 0;border-top:1px solid var(--ima-line)}
1011
+ .ima-inspector-actions{display:flex!important;flex-wrap:wrap!important;align-items:center!important;justify-content:flex-end!important;gap:8px!important;margin-top:16px!important;padding-top:16px!important;padding-bottom:4px!important}
1012
+ .ima-account-modal .ima-inspector{padding:0 0 16px 0}
1013
+ .ima-bind-modal,.ima-account-modal{width:min(720px,100%) !important;max-height:100%}
1014
+ .ima-account-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 16px;width:100%;box-sizing:border-box}
1015
+ .ima-account-settings.compact{grid-template-columns:1fr}
1016
+ .ima-picker-field{display:flex;min-width:0;width:100%;flex-direction:column;gap:6px;box-sizing:border-box}
1017
+ .ima-picker-field.wide,.ima-picker-note,.ima-model-effort{grid-column:1/-1}
1018
+ .ima-model-effort{display:grid;grid-template-columns:1fr 1fr;gap:14px 16px;min-width:0;width:100%;box-sizing:border-box}
1019
+ .ima-account-settings.compact .ima-model-effort{grid-template-columns:1fr}
1020
+ .ima-picker-label{color:var(--dsw-alias-label-secondary,var(--ima-muted));font-size:12px;font-weight:550;line-height:16px}
1021
+ .ima-picker-note{color:var(--dsw-alias-label-tertiary,var(--ima-muted));font-size:11px;line-height:1.6;margin-top:2px}
1022
+ .ima-picker-note.warning{color:var(--ima-warning)}
561
1023
  .ima-save-note{color:var(--ima-muted);font-size:11px}.ima-save-note.ok{color:var(--ima-ok)}
562
- .ima-account-modal .ima-inspector,.ima-bind-modal .ima-setup-section{padding:0}.ima-setup-section{margin:0 0 14px;padding-bottom:14px;border-bottom:1px solid var(--ima-line)}
1024
+ .ima-bind-modal .ima-setup-section{padding:16px!important;margin:0 0 16px!important;border-radius:var(--dsw-radius-md,12px)!important;background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.04))!important;border:0.5px solid var(--dsw-alias-border-l1,rgba(255,255,255,.06))!important}
1025
+ .ima-bind-ready{display:flex!important;flex-direction:column!important;align-items:center!important;gap:14px!important;padding:20px 16px!important;border-radius:var(--dsw-radius-md,12px)!important;background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.04))!important;border:0.5px solid var(--dsw-alias-border-l1,rgba(255,255,255,.06))!important}
1026
+ .ima-bind-ready .ima-btn{min-width:140px!important;height:36px!important}
563
1027
  .ima-account-picker{width:100%}
1028
+ .ima-enable-switch{box-sizing:border-box;position:relative;flex:0 0 auto;width:36px;height:20px;padding:2px;border:0;border-radius:999px;corner-shape:round;background:var(--dsw-alias-border-l3,#555);cursor:pointer}
1029
+ .ima-enable-switch[aria-checked=true]{background:var(--dsw-alias-brand-primary)}
1030
+ .ima-enable-switch:disabled{cursor:default;opacity:.5}
1031
+ .ima-enable-switch:focus-visible{outline:var(--dsw-focus-ring-width,1px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
1032
+ .ima-enable-switch-thumb{display:block;width:16px;height:16px;border-radius:50%;corner-shape:round;background:var(--dsw-alias-label-primary-foreground,#fff);transition:transform 120ms ease;pointer-events:none}
1033
+ .ima-enable-switch[aria-checked=false] .ima-enable-switch-thumb{background:var(--dsw-alias-switch-thumb,#fff)}
1034
+ .ima-enable-switch[aria-checked=true] .ima-enable-switch-thumb{transform:translateX(16px)}
1035
+ .ima-form-menu{box-sizing:border-box;width:max(var(--ima-menu-width,144px),144px)!important;min-width:max(var(--ima-menu-width,144px),144px)!important;max-width:100%!important}
1036
+ .ima-menu-select-wrap,.ima-menu-select-wrap > *,.ima-menu-select-wrap span[class*="_root_"],.ima-menu-select-wrap .ima-menu-select-trigger,.ima-account-picker{display:flex!important;width:100%!important;min-width:0!important;box-sizing:border-box!important}
1037
+ .ima-menu-select-trigger{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:6px!important;width:100%!important;height:36px!important;padding:0 12px!important;border:0.5px solid var(--dsw-alias-border-l2,#494949)!important;border-radius:var(--dsw-radius-sm,8px)!important;background:var(--dsw-alias-bg-layer-1,transparent)!important;color:var(--dsw-alias-label-primary,#eee)!important;font:inherit!important;font-size:13px!important;cursor:pointer!important;user-select:none!important;box-sizing:border-box!important;transition:border-color 120ms ease,background 120ms ease!important}
1038
+ .ima-menu-select-trigger:hover:not(:disabled){border-color:var(--dsw-alias-border-l3,#666)!important;background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))!important}
1039
+ .ima-menu-select-trigger.is-open{border-color:var(--dsw-alias-brand-primary,#4b7cff)!important;outline:var(--dsw-focus-ring-width,1px) solid var(--dsw-focus-ring-color,var(--dsw-alias-brand-primary,#4b7cff))!important}
1040
+ .ima-menu-select-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;text-align:left}
1041
+ .ima-menu-select-arrow{flex:none;opacity:0.6}
1042
+ .ima-btn-spinner{display:inline-block;vertical-align:-2px;animation:ima-spin 0.8s linear infinite}
1043
+ @keyframes ima-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
1044
+ .ima-btn-danger{color:var(--dsw-alias-state-error-primary,var(--ima-danger))!important;border-color:var(--dsw-alias-state-error-primary,var(--ima-danger))!important}
1045
+ .ima-btn-danger:hover:not(:disabled){color:var(--dsw-alias-state-error-primary,var(--ima-danger))!important;border-color:var(--dsw-alias-state-error-primary,var(--ima-danger))!important;background:rgba(239,68,68,.12)!important}
1046
+ .ima-btn-danger-primary,.ima-btn-danger.ima-btn-danger-primary{background:var(--dsw-alias-state-error-primary,var(--ima-danger))!important;border-color:var(--dsw-alias-state-error-primary,var(--ima-danger))!important;color:#fff!important}
564
1047
  @container (max-width:480px){.ima-account-row{grid-template-columns:minmax(0,1fr) auto auto;gap:8px;padding:10px}.ima-account-receive>span{display:none}.ima-platform-head{padding:10px 12px}.ima-account-list{padding:0 12px 12px}}
565
1048
 
566
1049
  `;
@@ -936,10 +1419,32 @@ window.__ModuleLoader__.load({
936
1419
  }
937
1420
  return false;
938
1421
  }
1422
+ function parsePickedPath(value) {
1423
+ if (typeof value === "string" && value.trim() !== "") return value;
1424
+ if (value === null || typeof value !== "object") return undefined;
1425
+ if (value.canceled === true) return undefined;
1426
+ if (typeof value.path === "string" && value.path.trim() !== "") return value.path;
1427
+ const first = Array.isArray(value.filePaths) ? value.filePaths[0] : undefined;
1428
+ return typeof first === "string" && first.trim() !== "" ? first : undefined;
1429
+ }
939
1430
  function pickHostDirectory(ctx) {
1431
+ const host = typeof globalThis !== "undefined" ? globalThis.__DSH_DIRECTORY_PICKER__ : undefined;
1432
+ if (host && typeof host.pick === "function") {
1433
+ return Promise.resolve(host.pick()).then(parsePickedPath);
1434
+ }
940
1435
  const uiWorkspace = probeService(ctx, "uiWorkspace");
941
- if (uiWorkspace && typeof uiWorkspace.pickDirectory === "function") return uiWorkspace.pickDirectory();
942
- if (ctx.workspaces && typeof ctx.workspaces.pickDirectory === "function") return ctx.workspaces.pickDirectory();
1436
+ if (uiWorkspace && typeof uiWorkspace.pickDirectory === "function") return Promise.resolve(uiWorkspace.pickDirectory()).then(parsePickedPath);
1437
+ const dialog = probeService(ctx, "dialog");
1438
+ if (dialog && typeof dialog.pickDirectory === "function") return Promise.resolve(dialog.pickDirectory()).then(parsePickedPath);
1439
+ if (ctx && ctx.workspaces && typeof ctx.workspaces.pickDirectory === "function") return Promise.resolve(ctx.workspaces.pickDirectory()).then(parsePickedPath);
1440
+ // 全部来源都不可用时必须显式拒绝:调用方据此提示“当前 Host 无法新增工作区”,
1441
+ // 否则点击“添加工作区…”会静默无响应(取消选择由 resolve(undefined) 表示,二者不能混淆)。
1442
+ return Promise.reject(workspacePickerUnavailable());
1443
+ }
1444
+ function workspacePickerUnavailable() {
1445
+ const error = new Error("workspace picker unavailable");
1446
+ error.code = "workspace/picker-unavailable";
1447
+ return error;
943
1448
  }
944
1449
  function activeSessionRefusal(error) {
945
1450
  const reason = error && (error.reason || error);
@@ -1154,6 +1659,7 @@ window.__ModuleLoader__.load({
1154
1659
  onCloseRef.current = onClose;
1155
1660
  useEffect(() => {
1156
1661
  const onKeyDown = (event) => {
1662
+ if (modalLayers.length && modalLayers[modalLayers.length - 1].owner !== "bind") return;
1157
1663
  if (event.key !== "Escape") return;
1158
1664
  event.preventDefault();
1159
1665
  event.stopPropagation();
@@ -1208,14 +1714,17 @@ window.__ModuleLoader__.load({
1208
1714
  open: true,
1209
1715
  className: "ima-bind-modal",
1210
1716
  title: t("bind.title", { channel: channelLabel(ch, t) }),
1211
- width: 640,
1717
+ width: 720,
1212
1718
  zIndex: 1100,
1213
1719
  destroyOnHidden: true,
1720
+ layerOwner: "bind",
1214
1721
  maskClosable: !saving,
1215
- keyboard: false,
1216
1722
  onCancel: close,
1217
1723
  footer: tab === "manual" && hasManual
1218
- ? [h(Button, { key: "save", type: "primary", disabled: busy || !workspaceIsListed(settings.cwd, workspaces), onClick: saveManual }, busy ? t("action.saving") : t("action.confirm"))]
1724
+ ? h("div", { className: "ima-modal-actions" },
1725
+ hostModalButton(t("action.cancel"), close, "outline", { disabled: busy }),
1726
+ hostModalButton(busy ? t("action.saving") : t("action.confirm"), saveManual, "primary", { disabled: busy || !workspaceIsListed(settings.cwd, workspaces) }),
1727
+ )
1219
1728
  : null,
1220
1729
  },
1221
1730
  hasQr && hasManual && h(Segmented, {
@@ -1264,13 +1773,13 @@ window.__ModuleLoader__.load({
1264
1773
  remain > 0 && h("p", { className: "ima-hint" }, t("bind.expire", { time: Math.floor(remain / 60) + ":" + String(remain % 60).padStart(2, "0") })),
1265
1774
  status === "scanned" && h("p", { className: "ima-hint" }, t("bind.scanned")),
1266
1775
  (status === "expired" || status === "failed") && h("p", { className: "ima-error" }, serverText(pairing && pairing.error, t) || t("bind.retry")),
1267
- h(Button, { disabled: busy, onClick: () => startQr(true) }, t("bind.refresh")),
1776
+ hostModalButton(t("bind.refresh"), () => startQr(true), "outline", { disabled: busy }),
1268
1777
  )
1269
1778
  : h("div", { className: "ima-bind-ready" },
1270
1779
  h("p", { className: "ima-hint" }, hintOf(ch, t)),
1271
1780
  (busy || status === "starting") && h("div", { className: "ima-bind-status" }, t("bind.generating")),
1272
1781
  (status === "expired" || status === "failed") && h("div", { className: "ima-error" }, serverText(pairing && pairing.error, t) || t("bind.retry")),
1273
- h(Button, { type: "primary", disabled: busy || !workspaceIsListed(settings.cwd, workspaces) || !settings.provider || !settings.model || !settings.permission, onClick: () => startQr(qrStarted) }, busy ? t("bind.generating") : qrStarted ? t("bind.refresh") : t("action.generateQr")),
1782
+ hostModalButton(busy ? t("bind.generating") : qrStarted ? t("bind.refresh") : t("action.generateQr"), () => startQr(qrStarted), "primary", { disabled: busy || !workspaceIsListed(settings.cwd, workspaces) || !settings.provider || !settings.model || !settings.permission }),
1274
1783
  )
1275
1784
  ),
1276
1785
  tab === "manual" && hasManual && h("div", null,
@@ -1319,14 +1828,35 @@ window.__ModuleLoader__.load({
1319
1828
  );
1320
1829
  }
1321
1830
 
1831
+ function formatProviderLabel(provider, defaultLabel, modelT) {
1832
+ if (provider === "deepseek-account") {
1833
+ const localized = modelT("provider.account");
1834
+ if (localized && localized !== "provider.account") return localized;
1835
+ }
1836
+ return defaultLabel;
1837
+ }
1838
+
1839
+ function orderProviders(left, right) {
1840
+ const leftRank = left === "deepseek-account" ? 0 : left === "deepseek-official" ? 1 : 2;
1841
+ const rightRank = right === "deepseek-account" ? 0 : right === "deepseek-official" ? 1 : 2;
1842
+ return leftRank - rightRank;
1843
+ }
1844
+
1845
+ function renderModelOptionLabel(item) {
1846
+ const isOfficialFlash = (item.provider === "deepseek-account" || item.provider === "deepseek-official") && item.model === "deepseek-flash";
1847
+ if (!isOfficialFlash) return item.label;
1848
+ return React.createElement("span", { style: { display: "inline-flex", alignItems: "center", gap: 6 } },
1849
+ React.createElement("span", null, item.label),
1850
+ React.createElement(Tag, { color: "info" }, "1017")
1851
+ );
1852
+ }
1853
+
1322
1854
  function AccountSettingsPicker(props) {
1323
1855
  const t = props.t || fallbackT;
1324
1856
  const modelT = props.modelT || ((key) => key);
1325
1857
  const permissionT = props.permissionT || ((key) => key);
1326
1858
  const presetT = props.presetT || ((key) => key);
1327
1859
  const value = props.value || {};
1328
- const [adding, setAdding] = useState(false);
1329
- const [addPath, setAddPath] = useState("");
1330
1860
  const [addBusy, setAddBusy] = useState(false);
1331
1861
  const [hint, setHint] = useState("");
1332
1862
  const [confirmingFullAccess, setConfirmingFullAccess] = useState(false);
@@ -1341,19 +1871,22 @@ window.__ModuleLoader__.load({
1341
1871
  const permission = value.permission || "";
1342
1872
  const privateAccess = value.privateAccess === "all" ? "all" : "approved";
1343
1873
  const workspace = items.find((item) => item.path === cwd);
1344
- const modelGroups = providers.map((item) => ({
1345
- id: item.id,
1346
- name: item.name || item.id,
1347
- models: (item.models || []).map((entry) => ({
1348
- value: item.id + "::" + entry.id,
1349
- provider: item.id,
1350
- providerName: item.name || item.id,
1351
- model: entry.id,
1352
- label: entry.name || entry.id,
1353
- description: entry.description,
1354
- reasoning: entry.reasoning,
1355
- })),
1356
- })).filter((item) => item.models.length > 0);
1874
+ const modelGroups = providers.map((item) => {
1875
+ const providerName = formatProviderLabel(item.id, item.name || item.id, modelT);
1876
+ return {
1877
+ id: item.id,
1878
+ name: providerName,
1879
+ models: (item.models || []).map((entry) => ({
1880
+ value: item.id + "::" + entry.id,
1881
+ provider: item.id,
1882
+ providerName: providerName,
1883
+ model: entry.id,
1884
+ label: entry.name || entry.id,
1885
+ description: entry.description,
1886
+ reasoning: entry.reasoning,
1887
+ })),
1888
+ };
1889
+ }).filter((item) => item.models.length > 0).sort((left, right) => orderProviders(left.id, right.id));
1357
1890
  const models = modelGroups.flatMap((item) => item.models);
1358
1891
  const currentModel = models.find((item) => item.provider === provider && item.model === model);
1359
1892
  const reasoning = currentModel && currentModel.reasoning;
@@ -1382,21 +1915,31 @@ window.__ModuleLoader__.load({
1382
1915
  return Promise.resolve(props.createWorkspace({ path: next })).then((created) => {
1383
1916
  const cwdPath = (created && (created.path || created.cwd)) || next;
1384
1917
  update({ cwd: cwdPath });
1385
- setAdding(false);
1386
- setAddPath("");
1387
1918
  }).catch((error) => setHint((error && error.message) || t("error.addWorkspace")))
1388
1919
  .finally(() => setAddBusy(false));
1389
1920
  };
1390
1921
  const onAddWorkspace = () => {
1391
1922
  setHint("");
1392
- setAdding(true);
1393
- setAddPath("");
1394
- if (typeof props.pickDirectory === "function") {
1395
- // Web 宿主可能返回空路径;始终保留可见的手动输入入口。
1396
- return Promise.resolve().then(() => props.pickDirectory()).then(picked => {
1397
- if (typeof picked === "string" && picked.trim()) return addWorkspace(picked);
1398
- }).catch(() => { setAdding(true); });
1923
+ if (typeof props.pickDirectory !== "function") {
1924
+ setHint(t("error.workspaceUnavailable"));
1925
+ return Promise.resolve();
1399
1926
  }
1927
+ setAddBusy(true);
1928
+ return Promise.resolve()
1929
+ .then(() => props.pickDirectory())
1930
+ .then((picked) => {
1931
+ if (typeof picked === "string" && picked.trim()) {
1932
+ return addWorkspace(picked);
1933
+ }
1934
+ })
1935
+ .catch((error) => {
1936
+ setHint(error && error.code === "workspace/picker-unavailable"
1937
+ ? t("error.workspaceUnavailable")
1938
+ : (error && error.message) || t("error.addWorkspace"));
1939
+ })
1940
+ .finally(() => {
1941
+ setAddBusy(false);
1942
+ });
1400
1943
  };
1401
1944
  const selectPermission = (next) => {
1402
1945
  if (next === permission) return;
@@ -1415,7 +1958,7 @@ window.__ModuleLoader__.load({
1415
1958
  return h("div", { className: "ima-account-settings" + (props.compact ? " compact" : "") },
1416
1959
  field("workspace", props.workspaceLabel || t("account.workspace"), items.length === 0
1417
1960
  ? h("div", null,
1418
- h(Button, { type: "primary", icon: h(PlusIcon), onClick: onAddWorkspace }, t("composer.addWorkspace")),
1961
+ h(Button, { variant: "primary", icon: h(PlusIcon), disabled: addBusy, onClick: onAddWorkspace }, t("composer.addWorkspace")),
1419
1962
  h("div", { className: "ima-picker-note warning" }, t("composer.workspaceRequired")),
1420
1963
  )
1421
1964
  : h(Select, {
@@ -1425,13 +1968,10 @@ window.__ModuleLoader__.load({
1425
1968
  "aria-label": props.workspaceLabel || t("account.workspace"),
1426
1969
  popupMatchSelectWidth: false,
1427
1970
  options: items.map((item) => ({ value: item.path, label: item.title || item.path })),
1971
+ footer: [{ value: "add-workspace", label: t("composer.addWorkspace"), disabled: addBusy }],
1972
+ onFooter: () => { onAddWorkspace(); },
1428
1973
  notFoundContent: t("composer.noWorkspaces"),
1429
1974
  onChange: (next) => update({ cwd: next }),
1430
- dropdownRender: (menu) => h("div", null,
1431
- menu,
1432
- h("div", { style: { height: 1, margin: "6px 8px", background: "var(--dsw-alias-border-l2,rgba(255,255,255,.1))" } }),
1433
- h(Button, { type: "link", icon: h(PlusIcon), onClick: onAddWorkspace }, t("composer.addWorkspace")),
1434
- ),
1435
1975
  })),
1436
1976
  field("agentPreset", presetT("nav"), h(Select, {
1437
1977
  className: "ima-account-picker",
@@ -1458,7 +1998,7 @@ window.__ModuleLoader__.load({
1458
1998
  popupMatchSelectWidth: false,
1459
1999
  options: modelGroups.map((group) => ({
1460
2000
  label: group.name,
1461
- options: group.models.map((item) => ({ value: item.value, label: item.label })),
2001
+ options: group.models.map((item) => ({ value: item.value, label: renderModelOptionLabel(item) })),
1462
2002
  })),
1463
2003
  notFoundContent: modelT("empty.models"),
1464
2004
  onChange: (next) => {
@@ -1497,20 +2037,9 @@ window.__ModuleLoader__.load({
1497
2037
  privateAccess === "all" && h("div", { className: "ima-picker-note warning" }, t("settings.publicChatNotice")),
1498
2038
  hint && h("div", { className: "ima-picker-note" }, hint),
1499
2039
  props.showAutoNameNote && h("div", { className: "ima-picker-note" }, t("account.autoNameNote")),
1500
- h(Modal, {
1501
- open: adding,
1502
- title: t("composer.addWorkspace"),
1503
- onCancel: () => { setAdding(false); setAddPath(""); },
1504
- onOk: () => addWorkspace(addPath),
1505
- okButtonProps: { disabled: addBusy || !addPath.trim() },
1506
- confirmLoading: addBusy,
1507
- okText: addBusy ? t("action.adding") : t("action.confirm"),
1508
- cancelText: t("action.cancel"),
1509
- },
1510
- h(Input, { autoFocus: true, value: addPath, placeholder: t("composer.workspacePath"), "aria-label": t("composer.workspacePath"), onChange: (event) => setAddPath(event.target.value) }),
1511
- ),
1512
2040
  h(Modal, {
1513
2041
  open: confirmingFullAccess,
2042
+ layerOwner: "full-access",
1514
2043
  title: permissionT("confirm.title"),
1515
2044
  keyboard: false,
1516
2045
  maskClosable: false,
@@ -1680,12 +2209,12 @@ window.__ModuleLoader__.load({
1680
2209
  h(CommandPermissionSettings, { value: draft.commandPermissions, onSave: commandPermissions => save({ commandPermissions }), t }),
1681
2210
  note && h("div", { className: note === "status.saved" ? "ima-save-note ok" : "ima-save-note" }, t(note)),
1682
2211
  h("div", { className: "ima-inspector-actions" },
1683
- h(Button, { disabled: Boolean(busy) || checking, onClick: check }, t(checking ? "connection.checking" : "action.checkConnection")),
1684
- h(Button, { disabled: Boolean(busy) || checking, onClick: () => { setCheckResult(null); return onAction(account.id, "reconnect"); } }, t("action.reconnectAccount")),
1685
- h(Button, { danger: true, disabled: Boolean(busy) || checking, onClick: () => {
2212
+ h(Button, { variant: "outline", disabled: Boolean(busy) || checking, onClick: check }, t(checking ? "connection.checking" : "action.checkConnection")),
2213
+ h(Button, { variant: "outline", disabled: Boolean(busy) || checking, onClick: () => { setCheckResult(null); return onAction(account.id, "reconnect"); } }, t("action.reconnectAccount")),
2214
+ h(Button, { variant: "outline", danger: true, disabled: Boolean(busy) || checking, onClick: () => {
1686
2215
  modal.confirm({
1687
2216
  title: t("action.removeAccount"),
1688
- content: t("account.removeConfirm"),
2217
+ description: t("account.removeConfirm"),
1689
2218
  okText: t("action.removeAccount"),
1690
2219
  cancelText: t("action.cancel"),
1691
2220
  okButtonProps: { danger: true },
@@ -1769,6 +2298,11 @@ window.__ModuleLoader__.load({
1769
2298
  h("path", { fill: "currentColor", d: "M8 0a8 8 0 0 0-2.53 15.59c.4.074.547-.173.547-.385 0-.19-.007-.693-.01-1.36-2.226.484-2.695-1.073-2.695-1.073-.364-.924-.89-1.17-.89-1.17-.726-.496.055-.486.055-.486.803.056 1.225.824 1.225.824.714 1.223 1.872.87 2.328.665.072-.517.28-.87.508-1.07-1.777-.202-3.645-.888-3.645-3.956 0-.874.31-1.588.823-2.148-.083-.202-.357-1.017.078-2.12 0 0 .672-.215 2.2.82A7.65 7.65 0 0 1 8 4.8c.68.003 1.365.092 2.004.27 1.527-1.035 2.197-.82 2.197-.82.437 1.103.162 1.918.08 2.12.513.56.822 1.274.822 2.148 0 3.076-1.872 3.752-3.654 3.95.288.248.544.735.544 1.482 0 1.07-.01 1.932-.01 2.195 0 .214.144.463.55.384A8.001 8.001 0 0 0 8 0Z" }),
1770
2299
  );
1771
2300
  }
2301
+ function FeedbackIcon() {
2302
+ return h("svg", { viewBox: "0 0 16 16", width: 16, height: 16, "aria-hidden": true, focusable: "false" },
2303
+ h("path", { fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", d: "M9.5 2.5 13.5 6.5 6 14H2v-4z" }),
2304
+ );
2305
+ }
1772
2306
 
1773
2307
  function SettingsPage(props) {
1774
2308
  const t = props.t || fallbackT;
@@ -1817,8 +2351,9 @@ window.__ModuleLoader__.load({
1817
2351
  useEffect(() => {
1818
2352
  if (!settingsAccount) return undefined;
1819
2353
  const onKey = (event) => {
2354
+ if (modalLayers.length && modalLayers[modalLayers.length - 1].owner !== "settings-account") return;
1820
2355
  if (event.key !== "Escape") return;
1821
- if (document.querySelector(".ant-select-dropdown:not(.ant-select-dropdown-hidden), .ant-dropdown:not(.ant-dropdown-hidden)")) return;
2356
+ if (document.querySelector("[role='listbox'], [role='menu'], .ima-menu-select-dropdown")) return;
1822
2357
  event.preventDefault();
1823
2358
  event.stopPropagation();
1824
2359
  if (typeof event.stopImmediatePropagation === "function") event.stopImmediatePropagation();
@@ -1887,8 +2422,20 @@ window.__ModuleLoader__.load({
1887
2422
  h("div", { className: "ima-title-row" },
1888
2423
  h("h2", { className: "ima-title" }, t("settings.title")),
1889
2424
  h("div", { className: "ima-title-links" },
1890
- h(Button, { size: "small", shape: "default", href: "https://github.com/MichengAI/dsh-im-connect", target: "_blank", rel: "noreferrer", "aria-label": t("settings.viewProject"), icon: h(GithubMark16) }, t("settings.viewProject")),
1891
- h(Button, { size: "small", shape: "default", href: "https://github.com/MichengAI/dsh-im-connect/issues", target: "_blank", rel: "noreferrer", "aria-label": t("settings.feedback"), icon: h(IconListPenOutline16, { size: 16 }) }, t("settings.feedback")),
2425
+ h(PrimitiveButton, {
2426
+ variant: "outline",
2427
+ size: "sm",
2428
+ "aria-label": t("settings.viewProject"),
2429
+ icon: h(GithubMark16),
2430
+ onClick: () => { window.open("https://github.com/MichengAI/dsh-im-connect", "_blank", "noreferrer"); }
2431
+ }, t("settings.viewProject")),
2432
+ h(PrimitiveButton, {
2433
+ variant: "outline",
2434
+ size: "sm",
2435
+ "aria-label": t("settings.feedback"),
2436
+ icon: h(FeedbackIcon),
2437
+ onClick: () => { window.open("https://github.com/MichengAI/dsh-im-connect/issues", "_blank", "noreferrer"); }
2438
+ }, t("settings.feedback")),
1892
2439
  ),
1893
2440
  ),
1894
2441
  h("p", { className: "ima-sub" }, t("settings.description")),
@@ -1902,8 +2449,8 @@ window.__ModuleLoader__.load({
1902
2449
  message: t("pending.notice"),
1903
2450
  description: pending.map((p) => h("div", { key: p.channelId + p.userId, className: "ima-pending-row" },
1904
2451
  h("span", { style: { flex: 1 } }, (p.username || p.userId) + " · " + (accountLabel(allAccounts.find((item) => item.id === p.channelId), t) || p.channelId)),
1905
- h(Button, { onClick: () => onAction(p.channelId, "approve", { userId: p.userId }) }, t("action.approve")),
1906
- h(Button, { onClick: () => onAction(p.channelId, "deny", { userId: p.userId }) }, t("action.deny")),
2452
+ h(Button, { variant: "primary", size: "sm", onClick: () => onAction(p.channelId, "approve", { userId: p.userId }) }, t("action.approve")),
2453
+ h(Button, { variant: "outline", size: "sm", danger: true, onClick: () => onAction(p.channelId, "deny", { userId: p.userId }) }, t("action.deny")),
1907
2454
  )),
1908
2455
  }),
1909
2456
  channels == null
@@ -1928,8 +2475,10 @@ window.__ModuleLoader__.load({
1928
2475
  ...(ch.accounts || []).map((account) => h("div", { key: account.id, className: "ima-account-row" },
1929
2476
  h("span", { className: "ima-account-copy" }, h(AccountRemarkEditor, { account, t, disabled: Boolean(busy[account.id]), onSave: (name) => onAction(account.id, "settings", { name }) })),
1930
2477
  h(Tag, {
1931
- color: busy[account.id] ? "default" : account.receiveConfigured === false ? "warning" : account.connectionState === "connected" ? "success" : "warning",
2478
+ color: busy[account.id] ? "processing" : account.receiveConfigured === false ? "warning" : account.connectionState === "connected" ? "success" : "warning",
1932
2479
  bordered: false,
2480
+ className: "ima-account-status-tag" + (busy[account.id] ? " is-busy" : ""),
2481
+ icon: busy[account.id] ? createSpinner() : undefined,
1933
2482
  }, busy[account.id] ? t("account.statusProcessing") : t(account.receiveConfigured === false ? "connection.paused" : "connection." + (account.connectionState || "unknown"))),
1934
2483
  h("div", { className: "ima-account-receive", title: t("account.receiveDescription") },
1935
2484
  h("span", null, t("account.receive")),
@@ -1945,10 +2494,10 @@ window.__ModuleLoader__.load({
1945
2494
  open: true,
1946
2495
  className: "ima-account-modal",
1947
2496
  title: t("action.settings"),
1948
- width: 640,
2497
+ width: 720,
1949
2498
  zIndex: 1100,
2499
+ layerOwner: "settings-account",
1950
2500
  destroyOnHidden: true,
1951
- keyboard: false,
1952
2501
  onCancel: () => setSettingsAccount(null),
1953
2502
  footer: null,
1954
2503
  },
@@ -2044,11 +2593,8 @@ window.__ModuleLoader__.load({
2044
2593
  .ima-n-menu button.danger:hover{background:var(--dsw-alias-interactive-bg-hover-danger,rgba(248,81,73,.12))}
2045
2594
  .ima-n-rename{flex:1;min-width:0;margin:0 6px 0 4px;border:.5px solid var(--dsw-alias-border-l4);border-radius:4px;outline:none;background:var(--dsw-alias-button-elevated-fill,rgba(255,255,255,.04));color:inherit;padding:0 2px;font-size:14px;line-height:20px}
2046
2595
  .ima-n-dialog-actions{display:flex;justify-content:flex-end;gap:8px}
2047
- .ima-n-dialog-copy{margin:0;color:var(--dsw-alias-label-secondary);font-size:14px;line-height:22px}
2048
2596
  .ima-n-dialog-status{margin-top:12px;color:var(--dsw-alias-label-secondary);font-size:13px;line-height:20px}
2049
2597
  .ima-n-dialog-error{margin-top:12px;color:var(--dsw-alias-state-error-primary,#f85149);font-size:13px;line-height:20px}
2050
- .ima-n-danger-button{color:var(--dsw-alias-state-error-primary,#f85149)!important}
2051
- .ima-n-danger-button:hover{background:var(--dsw-alias-interactive-bg-hover-danger,rgba(248,81,73,.12))!important}
2052
2598
  .ima-n-restore{flex:none;border:0;background:transparent;color:var(--dsw-alias-label-secondary,#c9cdd4);font:12px/16px inherit;padding:2px 4px;cursor:pointer}`;
2053
2599
 
2054
2600
  function NativeSvg(viewBox, size, children) {
@@ -2747,45 +3293,48 @@ window.__ModuleLoader__.load({
2747
3293
  }),
2748
3294
  ),
2749
3295
  ),
2750
- h(HostModal, {
3296
+ h(Modal, {
2751
3297
  open: !!archiveGroupTarget,
3298
+ layerOwner: "sidebar-archive",
2752
3299
  onClose: () => { if (!archiveGroupBusy) { setArchiveGroupTarget(undefined); setArchiveGroupError(undefined); } },
2753
3300
  closeLabel: t("rail.archiveGroupClose"),
2754
3301
  title: t("rail.archiveGroup"),
2755
- footer: h("div", { className: "ima-n-dialog-actions" },
2756
- h(HostButton, { variant: "outline", disabled: archiveGroupBusy, onClick: () => { setArchiveGroupTarget(undefined); setArchiveGroupError(undefined); } }, t("rail.archiveGroupCancel")),
2757
- h(HostButton, { variant: "outline", className: "ima-n-danger-button", disabled: archiveGroupBusy, onClick: confirmArchiveGroup }, t("rail.archiveGroupConfirm")),
3302
+ description: archiveGroupTarget ? t("rail.archiveGroupDescription", { name: archiveGroupTarget.name, count: archiveGroupTarget.sessionIds.length }) : "",
3303
+ footer: h(React.Fragment, null,
3304
+ hostModalButton(t("rail.archiveGroupCancel"), () => { setArchiveGroupTarget(undefined); setArchiveGroupError(undefined); }, "outline", { disabled: archiveGroupBusy }),
3305
+ hostModalButton(t("rail.archiveGroupConfirm"), confirmArchiveGroup, "primary", { disabled: archiveGroupBusy }),
2758
3306
  ),
2759
3307
  },
2760
- h("p", { className: "ima-n-dialog-copy" }, archiveGroupTarget ? t("rail.archiveGroupDescription", { name: archiveGroupTarget.name, count: archiveGroupTarget.sessionIds.length }) : ""),
2761
3308
  archiveGroupBusy && h("div", { className: "ima-n-dialog-status", role: "status" }, t("rail.archiveGroupPending")),
2762
3309
  archiveGroupError && h("div", { className: "ima-n-dialog-error", role: "alert" }, t("rail.archiveGroupFailed", { message: archiveGroupError })),
2763
3310
  ),
2764
- h(HostModal, {
3311
+ h(Modal, {
2765
3312
  open: !!stopArchiveTarget,
3313
+ layerOwner: "sidebar-stop",
2766
3314
  onClose: () => { if (!stopArchiveBusy) { setStopArchiveTarget(undefined); setStopArchiveError(undefined); } },
2767
3315
  closeLabel: t("action.cancel"),
2768
3316
  title: t("rail.stopArchive"),
2769
- footer: h("div", { className: "ima-n-dialog-actions" },
2770
- h(HostButton, { variant: "outline", disabled: stopArchiveBusy, onClick: () => { setStopArchiveTarget(undefined); setStopArchiveError(undefined); } }, t("action.cancel")),
2771
- h(HostButton, { variant: "outline", className: "ima-n-danger-button", disabled: stopArchiveBusy, onClick: confirmStopArchive }, t("rail.stopArchiveConfirm")),
3317
+ description: stopArchiveTarget ? t(stopArchiveTarget.group ? "rail.stopArchiveGroupDescription" : "rail.stopArchiveDescription", { name: stopArchiveTarget.title }) : "",
3318
+ footer: h(React.Fragment, null,
3319
+ hostModalButton(t("action.cancel"), () => { setStopArchiveTarget(undefined); setStopArchiveError(undefined); }, "outline", { disabled: stopArchiveBusy }),
3320
+ hostModalButton(t("rail.stopArchiveConfirm"), confirmStopArchive, "primary", { disabled: stopArchiveBusy }),
2772
3321
  ),
2773
3322
  },
2774
- h("p", { className: "ima-n-dialog-copy" }, stopArchiveTarget ? t(stopArchiveTarget.group ? "rail.stopArchiveGroupDescription" : "rail.stopArchiveDescription", { name: stopArchiveTarget.title }) : ""),
2775
3323
  stopArchiveBusy && h("div", { className: "ima-n-dialog-status", role: "status" }, t("rail.stopArchivePending")),
2776
3324
  stopArchiveError && h("div", { className: "ima-n-dialog-error", role: "alert" }, t("rail.archiveFailed")),
2777
3325
  ),
2778
- h(HostModal, {
3326
+ h(Modal, {
2779
3327
  open: !!deleteTarget,
3328
+ layerOwner: "sidebar-delete",
2780
3329
  onClose: () => { if (!deleteBusy) { setDeleteTarget(undefined); setDeleteError(undefined); } },
2781
3330
  closeLabel: t("rail.deleteSessionClose"),
2782
3331
  title: t("rail.deleteSession"),
2783
- footer: h("div", { className: "ima-n-dialog-actions" },
2784
- h(HostButton, { variant: "outline", disabled: deleteBusy, onClick: () => { setDeleteTarget(undefined); setDeleteError(undefined); } }, t("rail.deleteSessionCancel")),
2785
- h(HostButton, { variant: "outline", className: "ima-n-danger-button", disabled: deleteBusy, onClick: confirmDelete }, t("rail.deleteSessionConfirm")),
3332
+ description: deleteTarget ? t("rail.deleteSessionDescription", { name: deleteTarget.title }) : "",
3333
+ footer: h(React.Fragment, null,
3334
+ hostModalButton(t("rail.deleteSessionCancel"), () => { setDeleteTarget(undefined); setDeleteError(undefined); }, "outline", { disabled: deleteBusy }),
3335
+ hostModalButton(t("rail.deleteSessionConfirm"), confirmDelete, "primary", { disabled: deleteBusy }),
2786
3336
  ),
2787
3337
  },
2788
- h("p", { className: "ima-n-dialog-copy" }, deleteTarget ? t("rail.deleteSessionDescription", { name: deleteTarget.title }) : ""),
2789
3338
  deleteBusy && h("div", { className: "ima-n-dialog-status", role: "status" }, t("rail.deleteSessionPending")),
2790
3339
  deleteError && h("div", { className: "ima-n-dialog-error", role: "alert" }, t("rail.deleteSessionFailed", { message: deleteError })),
2791
3340
  ),
@@ -3149,15 +3698,15 @@ window.__ModuleLoader__.load({
3149
3698
  };
3150
3699
  function LocalizedChannelRail(props) {
3151
3700
  useSyncExternalStore(subscribeLocale, localeSnapshot, localeSnapshot);
3152
- return h(AntdProvider, null, h(ChannelRail, Object.assign({}, props, { t, openChannelSettings })));
3701
+ return h(HostThemeProvider, null, h(ChannelRail, Object.assign({}, props, { t, openChannelSettings })));
3153
3702
  }
3154
3703
  function LocalizedSessionSwitcher(props) {
3155
3704
  useSyncExternalStore(subscribeLocale, localeSnapshot, localeSnapshot);
3156
- return h(AntdProvider, null, h(SessionSwitcher, Object.assign({}, props, { t, officialT: props.t, openChannelSettings })));
3705
+ return h(HostThemeProvider, null, h(SessionSwitcher, Object.assign({}, props, { t, officialT: props.t, openChannelSettings })));
3157
3706
  }
3158
3707
  function LocalizedSettingsPage(props) {
3159
3708
  useSyncExternalStore(subscribeLocale, localeSnapshot, localeSnapshot);
3160
- return h(AntdProvider, null, h(SettingsPage, Object.assign({}, props, { t, permissionT, modelT, presetT, readMainSessionModel: () => readMainSessionModel(ctx) })));
3709
+ return h(HostThemeProvider, null, h(SettingsPage, Object.assign({}, props, { t, permissionT, modelT, presetT, readMainSessionModel: () => readMainSessionModel(ctx) })));
3161
3710
  }
3162
3711
  openImSession = (id) => {
3163
3712
  try {
@@ -3166,6 +3715,95 @@ window.__ModuleLoader__.load({
3166
3715
  try { return openHostSession(ctx, id); }
3167
3716
  catch (error) { console.warn("[dsh-im-connect] 无法打开会话", id, error); return false; }
3168
3717
  };
3718
+
3719
+ const NAV_ICON_MARKER = "data-ima-nav-icon";
3720
+ const NAV_ICON_ORIGINAL = "data-ima-nav-original";
3721
+ const NAV_ROW_SELECTOR = '[role="dialog"] nav button';
3722
+ const IM_NAV_PATHS = '<path fill="currentColor" d="M2.15 2.9h11.7v8.2H6.42L2.15 13.85V2.9Zm1.4 1.4v6.62l1.78-1.12h7.12V4.3H3.55Z"/>';
3723
+
3724
+ function isOwnNavRow(rowText, wantedLabel) {
3725
+ const wanted = String(wantedLabel ?? "").trim();
3726
+ if (wanted.length === 0) return false;
3727
+ const current = String(rowText ?? "").trim();
3728
+ return current === wanted;
3729
+ }
3730
+
3731
+ function applySettingsNavIcon(button, wantedLabel) {
3732
+ if (!isOwnNavRow(button.textContent, wantedLabel())) return false;
3733
+ const svg = button.querySelector("svg");
3734
+ if (!svg) return false;
3735
+ if (svg.getAttribute("data-ima-nav-icon") === "assistant") return false;
3736
+
3737
+ if (!svg.getAttribute(NAV_ICON_ORIGINAL)) {
3738
+ svg.setAttribute(NAV_ICON_ORIGINAL, JSON.stringify({
3739
+ innerHTML: svg.innerHTML,
3740
+ viewBox: svg.getAttribute("viewBox"),
3741
+ fill: svg.getAttribute("fill"),
3742
+ }));
3743
+ }
3744
+ svg.setAttribute("data-ima-nav-icon", "assistant");
3745
+ svg.setAttribute("viewBox", "0 0 16 16");
3746
+ svg.setAttribute("fill", "none");
3747
+ svg.innerHTML = IM_NAV_PATHS;
3748
+ button.setAttribute(NAV_ICON_MARKER, "");
3749
+ return true;
3750
+ }
3751
+
3752
+ function restoreSettingsNavIcon(button) {
3753
+ const svg = button.querySelector("svg");
3754
+ button.removeAttribute(NAV_ICON_MARKER);
3755
+ if (!svg) return false;
3756
+ const raw = svg.getAttribute(NAV_ICON_ORIGINAL);
3757
+ svg.removeAttribute("data-ima-nav-icon");
3758
+ svg.removeAttribute(NAV_ICON_ORIGINAL);
3759
+ if (!raw) return false;
3760
+ try {
3761
+ const saved = JSON.parse(raw);
3762
+ svg.innerHTML = saved.innerHTML;
3763
+ if (saved.viewBox == null) svg.removeAttribute("viewBox");
3764
+ else svg.setAttribute("viewBox", saved.viewBox);
3765
+ if (saved.fill == null) svg.removeAttribute("fill");
3766
+ else svg.setAttribute("fill", saved.fill);
3767
+ } catch { /* ignore */ }
3768
+ return true;
3769
+ }
3770
+
3771
+ function installSettingsNavIcon(targetCtx, resolveLabel) {
3772
+ if (typeof document === "undefined") return;
3773
+ targetCtx.effect(() => {
3774
+ let disposed = false;
3775
+ let scheduled = false;
3776
+
3777
+ const sync = () => {
3778
+ scheduled = false;
3779
+ if (disposed) return;
3780
+ for (const row of document.querySelectorAll(NAV_ROW_SELECTOR)) {
3781
+ applySettingsNavIcon(row, resolveLabel);
3782
+ }
3783
+ };
3784
+
3785
+ const schedule = () => {
3786
+ if (scheduled || disposed) return;
3787
+ scheduled = true;
3788
+ queueMicrotask(sync);
3789
+ };
3790
+
3791
+ sync();
3792
+ const observer = new MutationObserver(schedule);
3793
+ observer.observe(document.body, { childList: true, subtree: true, characterData: true });
3794
+
3795
+ return () => {
3796
+ disposed = true;
3797
+ observer.disconnect();
3798
+ for (const row of document.querySelectorAll(`[${NAV_ICON_MARKER}]`)) {
3799
+ restoreSettingsNavIcon(row);
3800
+ }
3801
+ };
3802
+ }, "im-connect: settings nav icon");
3803
+ }
3804
+
3805
+ installSettingsNavIcon(ctx, () => t("settings.label"));
3806
+
3169
3807
  ctx.slots.inject("settings.section", () => ctx.slots.register({
3170
3808
  name: "settings.section",
3171
3809
  id: "im-assistant",