dsh-wecom-bot 0.2.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +159 -54
  2. package/dist/client.js +1462 -613
  3. package/dist/host/bridge/commands.js +315 -48
  4. package/dist/host/bridge/commands.js.map +1 -1
  5. package/dist/host/bridge/directory.js +33 -10
  6. package/dist/host/bridge/directory.js.map +1 -1
  7. package/dist/host/bridge/format.js +23 -0
  8. package/dist/host/bridge/format.js.map +1 -1
  9. package/dist/host/bridge/index.js +219 -104
  10. package/dist/host/bridge/index.js.map +1 -1
  11. package/dist/host/bridge/interactions.js +2 -2
  12. package/dist/host/bridge/interactions.js.map +1 -1
  13. package/dist/host/bridge/notices.js +229 -46
  14. package/dist/host/bridge/notices.js.map +1 -1
  15. package/dist/host/bridge/outbox.js.map +1 -1
  16. package/dist/host/bridge/policy.js +16 -16
  17. package/dist/host/bridge/policy.js.map +1 -1
  18. package/dist/host/bridge/selection.js +1 -0
  19. package/dist/host/bridge/selection.js.map +1 -1
  20. package/dist/host/catalog.js +70 -7
  21. package/dist/host/catalog.js.map +1 -1
  22. package/dist/host/config.js +31 -12
  23. package/dist/host/config.js.map +1 -1
  24. package/dist/host/groups-view.js +308 -0
  25. package/dist/host/groups-view.js.map +1 -0
  26. package/dist/host/index.js +21 -11
  27. package/dist/host/index.js.map +1 -1
  28. package/dist/host/models.js +106 -0
  29. package/dist/host/models.js.map +1 -0
  30. package/dist/host/observation.js +53 -60
  31. package/dist/host/observation.js.map +1 -1
  32. package/dist/host/presets.js +49 -0
  33. package/dist/host/presets.js.map +1 -0
  34. package/dist/host/routes.js +76 -4
  35. package/dist/host/routes.js.map +1 -1
  36. package/dist/host/routing-store.js +349 -0
  37. package/dist/host/routing-store.js.map +1 -0
  38. package/dist/host/routing.js +71 -0
  39. package/dist/host/routing.js.map +1 -0
  40. package/dist/host/runtime.js +177 -7
  41. package/dist/host/runtime.js.map +1 -1
  42. package/dist/host/session-ops.js +100 -0
  43. package/dist/host/session-ops.js.map +1 -0
  44. package/dist/host/sessions.js +140 -0
  45. package/dist/host/sessions.js.map +1 -0
  46. package/dist/host/workspaces.js +154 -0
  47. package/dist/host/workspaces.js.map +1 -0
  48. package/dist/shared/protocol.js +23 -0
  49. package/dist/shared/protocol.js.map +1 -1
  50. package/package.json +3 -2
package/dist/client.js CHANGED
@@ -35,13 +35,17 @@ window.__ModuleLoader__.load({
35
35
  var CONFIG_NAMESPACE = "wecom-bot";
36
36
  var DEFAULT_SECRET_REF = "WECOM_BOT_SECRET";
37
37
  var STATE_ROUTE = "/api/wecom-bot/state";
38
+ var ROUTING_ROUTE = "/api/wecom-bot/routing";
38
39
 
39
40
  // src/client/components/SettingsPage.tsx
40
- var import_react6 = require("react");
41
- var import_dsh_client_ui_primitives8 = require("@deepseek-ai/dsh-client-ui-primitives");
41
+ var import_react7 = require("react");
42
+
43
+ // src/client/hooks.ts
44
+ var import_react = require("react");
42
45
 
43
46
  // src/client/api.ts
44
47
  var STATE_URL = STATE_ROUTE.replace(/^\//, "");
48
+ var ROUTING_URL = ROUTING_ROUTE.replace(/^\//, "");
45
49
  async function fetchState(refresh, signal) {
46
50
  const response = await fetch(`${STATE_URL}${refresh ? "?refresh=1" : ""}`, {
47
51
  credentials: "same-origin",
@@ -53,6 +57,30 @@ window.__ModuleLoader__.load({
53
57
  if (!response.ok) throw new Error(`插件状态读取失败(HTTP ${response.status})。`);
54
58
  return await response.json();
55
59
  }
60
+ async function postRouting(ops) {
61
+ let response;
62
+ try {
63
+ response = await fetch(ROUTING_URL, {
64
+ method: "POST",
65
+ credentials: "same-origin",
66
+ cache: "no-store",
67
+ headers: { "content-type": "application/json" },
68
+ body: JSON.stringify({ ops })
69
+ });
70
+ } catch {
71
+ throw new Error("无法连接插件后台,请确认 DSH 仍在运行。");
72
+ }
73
+ if (response.status === 401 || response.status === 403) throw new Error("DSH 登录已失效,请刷新页面。");
74
+ if (response.status === 404) throw new Error("插件后台尚未加载新版本,请重启 DSH 后再试。");
75
+ let body;
76
+ try {
77
+ body = await response.json();
78
+ } catch {
79
+ throw new Error(`修改失败(HTTP ${response.status})。`);
80
+ }
81
+ if (!body.ok) throw new Error(body.error ?? `修改失败(HTTP ${response.status})。`);
82
+ return body;
83
+ }
56
84
  function unwrap(result) {
57
85
  if (result && typeof result === "object" && "ok" in result && typeof result.ok === "boolean") {
58
86
  const envelope = result;
@@ -71,121 +99,47 @@ window.__ModuleLoader__.load({
71
99
  if (result !== void 0) unwrap(result);
72
100
  }
73
101
 
74
- // src/client/hooks.ts
75
- var import_react = require("react");
76
- function useFormSnapshot(scope) {
77
- return (0, import_react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
78
- }
79
- function useBridgeState(intervalMs = 5e3) {
80
- const [data, setData] = (0, import_react.useState)();
81
- const [error, setError] = (0, import_react.useState)();
82
- const [loading, setLoading] = (0, import_react.useState)(true);
83
- const [refreshing, setRefreshing] = (0, import_react.useState)(false);
84
- const tick = (0, import_react.useRef)(() => {
85
- });
86
- (0, import_react.useEffect)(() => {
87
- let active = true;
88
- const controller = new AbortController();
89
- let inflight = false;
90
- async function load(force) {
91
- if (inflight || !force && typeof document !== "undefined" && document.visibilityState === "hidden") return;
92
- inflight = true;
93
- if (force) setRefreshing(true);
94
- try {
95
- const next = await fetchState(force, controller.signal);
96
- if (!active) return;
97
- setData(next);
98
- setError(void 0);
99
- } catch (cause) {
100
- if (active && !controller.signal.aborted) setError(cause instanceof Error ? cause.message : String(cause));
101
- } finally {
102
- inflight = false;
103
- if (active) {
104
- setLoading(false);
105
- setRefreshing(false);
106
- }
107
- }
108
- }
109
- tick.current = (force) => {
110
- void load(force);
111
- };
112
- void load(true);
113
- const timer = setInterval(() => {
114
- void load(false);
115
- }, intervalMs);
116
- return () => {
117
- active = false;
118
- controller.abort();
119
- clearInterval(timer);
120
- };
121
- }, [intervalMs]);
122
- const refresh = (0, import_react.useCallback)((force = true) => tick.current(force), []);
123
- return { data, error, loading, refreshing, refresh };
124
- }
125
- function useSecretStatus(remote, ref) {
126
- const [configured, setConfigured] = (0, import_react.useState)(false);
127
- const [known, setKnown] = (0, import_react.useState)(false);
128
- const [version, setVersion] = (0, import_react.useState)(0);
129
- const refresh = (0, import_react.useCallback)(() => setVersion((v) => v + 1), []);
130
- (0, import_react.useEffect)(() => {
131
- let active = true;
132
- describeCredential(remote?.credentials, ref).then((info) => {
133
- if (active) {
134
- setConfigured(Boolean(info?.configured));
135
- setKnown(info !== void 0);
136
- }
137
- }).catch(() => {
138
- if (active) {
139
- setConfigured(false);
140
- setKnown(false);
141
- }
142
- });
143
- return () => {
144
- active = false;
145
- };
146
- }, [remote, ref, version]);
147
- (0, import_react.useEffect)(() => remote?.$on?.("credentials/reference-updated", (updated) => {
148
- if (updated === ref) refresh();
149
- }), [remote, ref, refresh]);
150
- return { configured, known, refresh };
151
- }
152
-
153
102
  // src/client/model.ts
154
103
  var DEFAULTS = {
155
104
  botId: "",
156
105
  secretEnv: DEFAULT_SECRET_REF,
157
- chatIds: [],
158
- sessionIds: [],
159
- allowedUserIds: [],
106
+ adminUserIds: [],
107
+ adminWorkspaces: [],
160
108
  wsUrl: "",
161
109
  questionTimeoutMs: 6e4,
162
110
  remoteApprovals: false,
163
111
  logEnabled: true,
164
112
  logRetentionDays: 14
165
113
  };
166
- var LIST_KEYS = ["chatIds", "sessionIds", "allowedUserIds"];
167
- var SCALAR_KEYS = ["botId", "wsUrl", "questionTimeoutMs", "remoteApprovals", "logEnabled", "logRetentionDays"];
114
+ var LIST_KEYS = ["adminUserIds", "adminWorkspaces"];
115
+ var SCALAR_KEYS = [
116
+ "botId",
117
+ "wsUrl",
118
+ "questionTimeoutMs",
119
+ "remoteApprovals",
120
+ "logEnabled",
121
+ "logRetentionDays"
122
+ ];
168
123
  function list(value) {
169
124
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
170
125
  }
126
+ function text(value, fallback = "") {
127
+ return typeof value === "string" ? value : fallback;
128
+ }
171
129
  function storedFrom(value) {
172
130
  const v = value ?? {};
173
131
  return {
174
- botId: typeof v.botId === "string" ? v.botId : DEFAULTS.botId,
175
- secretEnv: typeof v.secretEnv === "string" && v.secretEnv.trim() ? v.secretEnv : DEFAULTS.secretEnv,
176
- chatIds: list(v.chatIds),
177
- sessionIds: list(v.sessionIds),
178
- allowedUserIds: list(v.allowedUserIds),
179
- wsUrl: typeof v.wsUrl === "string" ? v.wsUrl : DEFAULTS.wsUrl,
132
+ botId: text(v.botId),
133
+ secretEnv: text(v.secretEnv).trim() || DEFAULTS.secretEnv,
134
+ adminUserIds: list(v.adminUserIds),
135
+ adminWorkspaces: list(v.adminWorkspaces),
136
+ wsUrl: text(v.wsUrl),
180
137
  questionTimeoutMs: typeof v.questionTimeoutMs === "number" ? v.questionTimeoutMs : DEFAULTS.questionTimeoutMs,
181
138
  remoteApprovals: v.remoteApprovals === true,
182
139
  logEnabled: v.logEnabled !== false,
183
140
  logRetentionDays: typeof v.logRetentionDays === "number" ? v.logRetentionDays : DEFAULTS.logRetentionDays
184
141
  };
185
142
  }
186
- function draftFrom(stored) {
187
- return { ...stored, chatIds: [...stored.chatIds], sessionIds: [...stored.sessionIds], allowedUserIds: [...stored.allowedUserIds], secret: "" };
188
- }
189
143
  function normalizedList(values) {
190
144
  return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
191
145
  }
@@ -209,13 +163,14 @@ window.__ModuleLoader__.load({
209
163
  }
210
164
  return ops;
211
165
  }
212
- function isDirty(draft, base) {
213
- return Boolean(draft.secret.trim()) || changedOperations(draft, base).length > 0;
214
- }
215
- function validate(draft, secretConfigured) {
166
+ function validateCredentials(draft, secretConfigured) {
216
167
  const errors = {};
217
168
  if (!draft.botId.trim()) errors.botId = "请填写企业微信 Bot ID。";
218
169
  if (!draft.secret.trim() && !secretConfigured) errors.secret = "首次配置需要填写 Bot Secret。";
170
+ return errors;
171
+ }
172
+ function validateAdvanced(draft) {
173
+ const errors = {};
219
174
  const wsUrl = draft.wsUrl.trim();
220
175
  if (wsUrl) {
221
176
  try {
@@ -233,39 +188,109 @@ window.__ModuleLoader__.load({
233
188
  }
234
189
  return errors;
235
190
  }
236
- function accessSummary(draft) {
237
- const unrestricted = [];
238
- if (!normalizedList(draft.sessionIds).length) unrestricted.push("sessions");
239
- if (!normalizedList(draft.chatIds).length) unrestricted.push("chats");
240
- if (!normalizedList(draft.allowedUserIds).length) unrestricted.push("users");
241
- return { level: unrestricted.length === 3 ? "open" : unrestricted.length ? "partial" : "restricted", unrestricted };
242
- }
243
191
  function toggle(values, id, on) {
244
192
  const has = values.includes(id);
245
193
  const want = on ?? !has;
246
194
  if (want === has) return [...values];
247
195
  return want ? [...values, id] : values.filter((value) => value !== id);
248
196
  }
249
- function setAll(values, ids, on) {
250
- if (on) return [.../* @__PURE__ */ new Set([...values, ...ids])];
251
- const remove = new Set(ids);
252
- return values.filter((value) => !remove.has(value));
197
+ function scopeIncludes(values, path) {
198
+ return values.length === 0 || values.includes(path);
253
199
  }
254
- function matches(session, group, needle) {
255
- return [session.title ?? "", session.sessionId, group.title, group.path ?? ""].some((text) => text.toLowerCase().includes(needle));
200
+ function toggleScope(values, allPaths, path, on) {
201
+ const next = new Set(values.length ? values : allPaths);
202
+ if (on) next.add(path);
203
+ else next.delete(path);
204
+ if (next.size >= allPaths.length) return [];
205
+ return allPaths.filter((item) => next.has(item));
256
206
  }
257
- function filterGroups(groups, query, selected) {
258
- const needle = query.trim().toLowerCase();
259
- return groups.map((group) => ({
260
- ...group,
261
- sessions: group.sessions.filter((session) => (!needle || matches(session, group, needle)) && (!selected || selected.has(session.sessionId)))
262
- })).filter((group) => group.sessions.length > 0);
207
+ function modelKey(provider, model) {
208
+ return provider && model ? `${provider}\0${model}` : "";
209
+ }
210
+ function parseModelKey(key) {
211
+ const [provider = "", model = ""] = key.split("\0");
212
+ return { provider, model };
213
+ }
214
+ function choiceLabel(choice) {
215
+ return choice.name === choice.model ? choice.model : `${choice.name}(${choice.model})`;
263
216
  }
264
- function identityRows(observed, configured) {
265
- const rows = observed.map((entry) => ({ id: entry.id, observed: entry }));
266
- const known = new Set(observed.map((entry) => entry.id));
267
- for (const id of configured) if (!known.has(id)) rows.push({ id });
268
- return rows;
217
+ function effortsFor(catalog, provider, model) {
218
+ const choice = catalog?.choices.find((item) => item.provider === provider && item.model === model);
219
+ return choice?.efforts ?? [];
220
+ }
221
+ function modelLabel(catalog, selection) {
222
+ if (!selection) return "";
223
+ const choice = catalog?.choices.find((item) => item.provider === selection.provider && item.model === selection.model);
224
+ return choice ? choiceLabel(choice) : `${selection.provider}/${selection.model}`;
225
+ }
226
+ function modelName(catalog, selection) {
227
+ if (!selection) return "";
228
+ const choice = catalog?.choices.find((item) => item.provider === selection.provider && item.model === selection.model);
229
+ return choice ? choice.name : selection.model;
230
+ }
231
+ function effortLabel(catalog, selection) {
232
+ const effort = selection?.reasoningEffort;
233
+ if (!effort) return "";
234
+ const choice = catalog?.choices.find((item) => item.provider === selection.provider && item.model === selection.model);
235
+ return choice?.efforts?.find((item) => item.id === effort)?.name ?? effort;
236
+ }
237
+ var BUILT_IN_PRESET_NAME = {
238
+ standard: "标准",
239
+ ptc: "PTC",
240
+ minimal: "极简",
241
+ cordis: "Cordis"
242
+ };
243
+ function presetName(preset) {
244
+ return preset.name || BUILT_IN_PRESET_NAME[preset.id] || preset.id;
245
+ }
246
+ function presetLabel(presets, id) {
247
+ if (!id) {
248
+ const fallback = presets?.presets.find((preset) => preset.isDefault);
249
+ return fallback ? `跟随 DSH 默认(${presetName(fallback)})` : "跟随 DSH 默认";
250
+ }
251
+ const found = presets?.presets.find((preset) => preset.id === id);
252
+ return found ? presetName(found) : id;
253
+ }
254
+ function presetSummaryLabel(presets, id) {
255
+ if (id) return presetLabel(presets, id);
256
+ const fallback = presets?.presets.find((preset) => preset.isDefault);
257
+ return fallback ? `${presetName(fallback)}(DSH 默认)` : "DSH 默认";
258
+ }
259
+ function formatTokens(value) {
260
+ if (value < 1e3) return String(Math.round(value));
261
+ if (value < 1e5) return `${(value / 1e3).toFixed(1)}k`;
262
+ if (value < 1e6) return `${Math.round(value / 1e3)}k`;
263
+ return `${(value / 1e6).toFixed(1)}M`;
264
+ }
265
+ function contextLabel(context) {
266
+ if (!context) return "";
267
+ const used = formatTokens(context.used);
268
+ if (!context.window) return used;
269
+ return `${used} / ${formatTokens(context.window)}(${Math.round(context.used / context.window * 100)}%)`;
270
+ }
271
+ function dshDefaultLabel(catalog) {
272
+ const value = catalog?.dshDefault;
273
+ if (!value) return "跟随 DSH 默认模型";
274
+ return `跟随 DSH 默认模型(${modelName(catalog, value)})`;
275
+ }
276
+ var BINDING_KIND_LABEL = { user: "个人", group: "群聊" };
277
+ var SESSION_STATE_LABEL = {
278
+ bound: "已绑定",
279
+ auto: "待创建",
280
+ blank: "待使用",
281
+ missing: "会话不存在",
282
+ archived: "会话已归档",
283
+ unusable: "会话不可用"
284
+ };
285
+ function personKey(kind, id) {
286
+ return `${kind}:${id}`;
287
+ }
288
+ function groupModelSummary(catalog, group) {
289
+ if (group.effectiveProvider && group.effectiveModel) {
290
+ return modelName(catalog, { provider: group.effectiveProvider, model: group.effectiveModel });
291
+ }
292
+ const fallback = catalog?.dshDefault;
293
+ return fallback ? `${modelName(catalog, fallback)}(DSH 默认)` : "DSH 默认";
269
294
  }
270
295
  function displayPath(path) {
271
296
  return (path ?? "").replace(/^(\/Users|\/home)\/[^/]+(?=\/|$)/, "~").replace(/^[A-Za-z]:\\Users\\[^\\]+(?=\\|$)/, "~");
@@ -279,109 +304,603 @@ window.__ModuleLoader__.load({
279
304
  if (diff < 30 * 864e5) return `${Math.floor(diff / 864e5)} 天前`;
280
305
  return new Date(at).toLocaleDateString();
281
306
  }
307
+ function addGroup(name) {
308
+ return { op: "group.add", ...name ? { name } : {} };
309
+ }
310
+ function updateGroup(id, patch) {
311
+ return { op: "group.update", id, patch };
312
+ }
313
+ function deleteGroup(id) {
314
+ return { op: "group.delete", id };
315
+ }
316
+ function addMember(groupId, kind, id, label) {
317
+ return { op: "member.add", groupId, kind, id, ...label ? { label } : {} };
318
+ }
319
+ function updateMember(key, patch) {
320
+ return { op: "member.update", key, patch };
321
+ }
322
+ function setLabel(key, label) {
323
+ return { op: "label.set", key, label };
324
+ }
325
+ function removeMember(key) {
326
+ return { op: "member.remove", key };
327
+ }
328
+ function archiveMember(key) {
329
+ return { op: "member.archive", key };
330
+ }
282
331
 
283
- // src/client/components/AccessBanner.tsx
284
- var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
285
- var import_jsx_runtime = require("react/jsx-runtime");
286
- var DIMENSION_LABEL = {
287
- sessions: "DSH 会话:全部未归档会话",
288
- chats: "企微会话:所有单聊与群聊",
289
- users: "企微用户:任何人"
290
- };
291
- function AccessBanner({ summary }) {
292
- if (summary.level === "restricted") {
293
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-banner", "data-tone": "success", role: "status", children: [
294
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-banner-icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconCheckCircleOutlineRegular, { size: 18 }) }),
295
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
296
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-banner-title", children: "已启用三重白名单" }),
297
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-banner-body", children: "只有勾选的企微用户、在勾选的会话里,才能操作勾选的 DSH 会话。被拒绝的消息不会得到任何回复,但会出现在下方列表中供你审核。" })
298
- ] })
299
- ] });
300
- }
301
- const open = summary.level === "open";
302
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-banner", "data-tone": open ? "danger" : "warning", role: "alert", children: [
303
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-banner-icon", children: open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconWarningTriangleOutlineRegular, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconShieldOutlineRegular, { size: 18 }) }),
304
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
305
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-banner-title", children: open ? "安全风险:尚未设置任何白名单" : "部分范围未限制" }),
306
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-banner-body", children: [
307
- open ? "只要能给机器人发消息,任何企业微信用户都可以读取本轮回复、向你的 DSH 会话发送指令(可能触发命令执行和文件修改)。" : "以下范围留空,表示对该范围全部允许:",
308
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-chips", children: summary.unrestricted.map((dimension) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: open ? "danger" : "warning", children: DIMENSION_LABEL[dimension] }, dimension)) }),
309
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ol", { children: [
310
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "在下方「企业微信来源」中只勾选你自己的 userid,以及你与机器人的单聊。" }),
311
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "在「DSH 会话」中只勾选需要远程操作的会话。" }),
312
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "群聊里的通知对所有群成员可见,请谨慎授权群聊。" })
313
- ] })
314
- ] })
315
- ] })
316
- ] });
332
+ // src/client/hooks.ts
333
+ function useFormSnapshot(scope) {
334
+ return (0, import_react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
335
+ }
336
+ function useBridgeState(intervalMs = 5e3) {
337
+ const [data, setData] = (0, import_react.useState)();
338
+ const [error, setError] = (0, import_react.useState)();
339
+ const [loading, setLoading] = (0, import_react.useState)(true);
340
+ const [refreshing, setRefreshing] = (0, import_react.useState)(false);
341
+ const tick = (0, import_react.useRef)(() => {
342
+ });
343
+ (0, import_react.useEffect)(() => {
344
+ let active = true;
345
+ const controller = new AbortController();
346
+ let inflight = false;
347
+ async function load(force) {
348
+ if (inflight || !force && typeof document !== "undefined" && document.visibilityState === "hidden") return;
349
+ inflight = true;
350
+ if (force) setRefreshing(true);
351
+ try {
352
+ const next = await fetchState(force, controller.signal);
353
+ if (!active) return;
354
+ setData(next);
355
+ setError(void 0);
356
+ } catch (cause) {
357
+ if (active && !controller.signal.aborted) setError(cause instanceof Error ? cause.message : String(cause));
358
+ } finally {
359
+ inflight = false;
360
+ if (active) {
361
+ setLoading(false);
362
+ setRefreshing(false);
363
+ }
364
+ }
365
+ }
366
+ tick.current = (force) => {
367
+ void load(force);
368
+ };
369
+ void load(true);
370
+ const timer = setInterval(() => {
371
+ void load(false);
372
+ }, intervalMs);
373
+ return () => {
374
+ active = false;
375
+ controller.abort();
376
+ clearInterval(timer);
377
+ };
378
+ }, [intervalMs]);
379
+ const refresh = (0, import_react.useCallback)((force = true) => tick.current(force), []);
380
+ return { data, error, loading, refreshing, refresh };
381
+ }
382
+ function useSecretStatus(remote, ref) {
383
+ const [configured, setConfigured] = (0, import_react.useState)(false);
384
+ const [known, setKnown] = (0, import_react.useState)(false);
385
+ const [version, setVersion] = (0, import_react.useState)(0);
386
+ const refresh = (0, import_react.useCallback)(() => setVersion((v) => v + 1), []);
387
+ (0, import_react.useEffect)(() => {
388
+ let active = true;
389
+ describeCredential(remote?.credentials, ref).then((info) => {
390
+ if (active) {
391
+ setConfigured(Boolean(info?.configured));
392
+ setKnown(info !== void 0);
393
+ }
394
+ }).catch(() => {
395
+ if (active) {
396
+ setConfigured(false);
397
+ setKnown(false);
398
+ }
399
+ });
400
+ return () => {
401
+ active = false;
402
+ };
403
+ }, [remote, ref, version]);
404
+ (0, import_react.useEffect)(() => remote?.$on?.("credentials/reference-updated", (updated) => {
405
+ if (updated === ref) refresh();
406
+ }), [remote, ref, refresh]);
407
+ return { configured, known, refresh };
408
+ }
409
+ function useRoutingApply(onChanged) {
410
+ const [busy, setBusy] = (0, import_react.useState)("");
411
+ const [error, setError] = (0, import_react.useState)();
412
+ const apply2 = (0, import_react.useCallback)(async (key, ops) => {
413
+ setBusy(key);
414
+ setError(void 0);
415
+ try {
416
+ const response = await postRouting(ops);
417
+ onChanged();
418
+ return response;
419
+ } catch (cause) {
420
+ setError(cause instanceof Error ? cause.message : String(cause));
421
+ return void 0;
422
+ } finally {
423
+ setBusy("");
424
+ }
425
+ }, [onChanged]);
426
+ const dismiss = (0, import_react.useCallback)(() => setError(void 0), []);
427
+ return { busy, error, apply: apply2, dismiss };
428
+ }
429
+ function useConfigSave(scope, onSaved) {
430
+ const [saving, setSaving] = (0, import_react.useState)(false);
431
+ const [error, setError] = (0, import_react.useState)();
432
+ const [saved, setSaved] = (0, import_react.useState)(false);
433
+ const timer = (0, import_react.useRef)();
434
+ (0, import_react.useEffect)(() => () => {
435
+ if (timer.current) clearTimeout(timer.current);
436
+ }, []);
437
+ const save = (0, import_react.useCallback)(async (patch) => {
438
+ setSaving(true);
439
+ setError(void 0);
440
+ if (timer.current) clearTimeout(timer.current);
441
+ try {
442
+ for (let attempt = 0; attempt < 3; attempt++) {
443
+ const latest = scope.getSnapshot();
444
+ const stored = storedFrom(latest.value);
445
+ const ops = changedOperations({ ...stored, ...patch }, stored);
446
+ if (!ops.length) break;
447
+ if (await scope.mutate(ops, latest.revision)) break;
448
+ if (attempt === 2) throw new Error("配置已在别处被修改,请刷新页面后重试。");
449
+ }
450
+ setSaved(true);
451
+ timer.current = setTimeout(() => setSaved(false), 2e3);
452
+ onSaved();
453
+ return true;
454
+ } catch (cause) {
455
+ setError(cause instanceof Error ? cause.message : String(cause));
456
+ return false;
457
+ } finally {
458
+ setSaving(false);
459
+ }
460
+ }, [scope, onSaved]);
461
+ return { saving, error, saved, save };
317
462
  }
318
463
 
319
- // src/client/components/AdvancedCard.tsx
320
- var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
464
+ // src/client/components/AdminCard.tsx
321
465
  var import_react2 = require("react");
466
+ var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
322
467
 
323
468
  // src/client/components/ui.tsx
324
- var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
325
- var import_jsx_runtime2 = require("react/jsx-runtime");
469
+ var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
470
+ var import_jsx_runtime = require("react/jsx-runtime");
471
+ function Select({ className, ...rest }) {
472
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { ...rest, className: ["wcb-select", className].filter(Boolean).join(" ") });
473
+ }
326
474
  function Card(props) {
327
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "wcb-card", children: [
328
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CardHead, { ...props }),
475
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "wcb-card", children: [
476
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardHead, { ...props }),
329
477
  props.children
330
478
  ] });
331
479
  }
332
480
  function CardHead({ step, title, description, aside }) {
333
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-card-head", children: [
334
- step !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-step", children: step }),
335
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-card-titles", children: [
336
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-card-title", children: title }),
337
- description && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-card-desc", children: description })
481
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-card-head", children: [
482
+ step !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-step", children: step }),
483
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-card-titles", children: [
484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-card-title", children: title }),
485
+ description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-card-desc", children: description })
338
486
  ] }),
339
- aside && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-card-aside", children: aside })
487
+ aside && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-card-aside", children: aside })
488
+ ] });
489
+ }
490
+ function Collapse({ open, onToggle, title, summary, actions, children, className }) {
491
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: ["wcb-group", className].filter(Boolean).join(" "), "data-open": open ? "" : void 0, children: [
492
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-group-head", children: [
493
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "wcb-group-toggle", "aria-expanded": open, onClick: onToggle, children: [
494
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-chevron", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 14 }) }),
495
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-title", children: title }),
496
+ summary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-summary", children: summary })
497
+ ] }),
498
+ actions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-actions", children: actions })
499
+ ] }),
500
+ open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-group-body", children })
340
501
  ] });
341
502
  }
342
503
  function Field({ label, required, hint, error, children }) {
343
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-field", "data-invalid": error ? "" : void 0, children: [
344
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-field-label", children: [
504
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-field", "data-invalid": error ? "" : void 0, children: [
505
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-field-label", children: [
345
506
  label,
346
- required && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-required", "aria-label": "必填", children: "*" })
507
+ required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-required", "aria-label": "必填", children: "*" })
347
508
  ] }),
348
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-field-control", children: [
509
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-field-control", children: [
349
510
  children,
350
- error ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-field-error", role: "alert", children: error }) : hint && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-hint", children: hint })
511
+ error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-field-error", role: "alert", children: error }) : hint && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-hint", children: hint })
351
512
  ] })
352
513
  ] });
353
514
  }
354
- function ScopeTag({ count }) {
355
- return count ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_dsh_client_ui_primitives2.Tag, { tone: "info", children: [
356
- "已选 ",
357
- count
358
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Tag, { tone: "warning", children: "未限制 · 全部允许" });
515
+ function CheckRow({ checked, onToggle, label, children, meta, disabled }) {
516
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "wcb-row", "data-selected": checked ? "" : void 0, children: [
517
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
518
+ "input",
519
+ {
520
+ type: "checkbox",
521
+ className: "wcb-check",
522
+ checked,
523
+ disabled,
524
+ "aria-label": label,
525
+ onChange: (event) => onToggle(event.target.checked)
526
+ }
527
+ ),
528
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-row-main", children }),
529
+ meta && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-row-meta", children: meta })
530
+ ] });
531
+ }
532
+ function KindBadge({ kind, plain }) {
533
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-avatar", "data-kind": kind, "data-plain": plain ? "" : void 0, "aria-hidden": "true", children: kind === "group" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconUsersOutlineRegular, { size: 15 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconUserOutlineRegular, { size: 15 }) });
534
+ }
535
+ function PersonAvatar({ kind, label, disabled, onClick }) {
536
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
537
+ "button",
538
+ {
539
+ type: "button",
540
+ className: "wcb-avatar",
541
+ "data-kind": kind,
542
+ "data-button": "",
543
+ "aria-label": label,
544
+ title: "查看详情、编辑备注",
545
+ disabled,
546
+ onClick,
547
+ children: [
548
+ kind === "group" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconUsersOutlineRegular, { size: 15 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconUserOutlineRegular, { size: 15 }),
549
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-avatar-pencil", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconEditOutlineRegular, { size: 9 }) })
550
+ ]
551
+ }
552
+ );
553
+ }
554
+ function PersonRow({ kind, title, meta, label, disabled, onOpen }) {
555
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-person-head", children: [
556
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PersonAvatar, { kind, label, disabled, onClick: onOpen }),
557
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-row-title", title: typeof title === "string" ? title : void 0, children: title }),
558
+ meta && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-person-meta", children: meta })
559
+ ] });
560
+ }
561
+ function Fact({ name, children, mono }) {
562
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-fact", children: [
563
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-fact-key", children: name }),
564
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: ["wcb-fact-value", mono ? "wcb-mono" : ""].filter(Boolean).join(" "), children })
565
+ ] });
566
+ }
567
+ function PersonDialog({ open, onClose, title, typeLabel, id, label, noteLabel, disabled, onNote, children, footer }) {
568
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
569
+ import_dsh_client_ui_primitives.Modal,
570
+ {
571
+ open,
572
+ onClose,
573
+ title,
574
+ closeLabel: "关闭",
575
+ className: "wcb-modal",
576
+ contentClassName: "wcb-modal-content",
577
+ children: [
578
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-person-facts", children: [
579
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "类型", children: typeLabel }),
580
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "企微 ID", mono: true, children: id }),
581
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-fact", children: [
582
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-fact-key", children: "备注" }),
583
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
584
+ import_dsh_client_ui_primitives.Input,
585
+ {
586
+ defaultValue: label,
587
+ placeholder: id,
588
+ disabled,
589
+ "aria-label": noteLabel,
590
+ className: "wcb-fact-input",
591
+ onBlur: (event) => {
592
+ const next = event.target.value.trim();
593
+ if (next !== label) onNote(next);
594
+ },
595
+ onKeyDown: (event) => {
596
+ if (event.key === "Enter") event.currentTarget.blur();
597
+ }
598
+ },
599
+ label
600
+ )
601
+ ] })
602
+ ] }),
603
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-hint", children: "备注即时生效,会代替企微 ID 显示;它属于这个人,移出分组后仍然保留。" }),
604
+ children,
605
+ footer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-dialog-actions", children: footer })
606
+ ]
607
+ }
608
+ );
609
+ }
610
+ function SaveBar({ dirty, saving, saved, error, disabled, onSave, onDiscard }) {
611
+ if (!dirty && !saved && !error) return null;
612
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-savebar", children: [
613
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-savebar-msg", "data-tone": error ? "error" : saved && !dirty ? "success" : dirty ? "dirty" : void 0, role: "status", children: error ?? (saved && !dirty ? "已保存。" : "有未保存的更改") }),
614
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "ghost", size: "sm", disabled: disabled || saving || !dirty, onClick: onDiscard, children: "放弃" }),
615
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "primary", size: "sm", disabled: disabled || saving || !dirty, onClick: onSave, children: saving ? "保存中…" : "保存" })
616
+ ] });
617
+ }
618
+ function ConfirmDialog({ open, title, children, confirmLabel, busy, disabled, onCancel, onConfirm }) {
619
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dsh_client_ui_primitives.Modal, { open, onClose: onCancel, title, closeLabel: "关闭", className: "wcb-modal", contentClassName: "wcb-modal-content", children: [
620
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-confirm-body", children }),
621
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-dialog-actions", children: [
622
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "ghost", size: "sm", disabled: busy, onClick: onCancel, children: "取消" }),
623
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "primary", size: "sm", disabled: busy || disabled, onClick: onConfirm, children: busy ? "处理中…" : confirmLabel })
624
+ ] })
625
+ ] });
626
+ }
627
+ function Empty({ children }) {
628
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-empty", children });
629
+ }
630
+ function CountTag({ count, noun, tone }) {
631
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dsh_client_ui_primitives.Tag, { tone: tone ?? (count ? "info" : "quiet"), children: [
632
+ count,
633
+ " ",
634
+ noun
635
+ ] });
636
+ }
637
+
638
+ // src/client/components/AdminCard.tsx
639
+ var import_jsx_runtime2 = require("react/jsx-runtime");
640
+ function AdminCard({ scope, base, state, disabled, onChanged }) {
641
+ const [draft, setDraft] = (0, import_react2.useState)(() => ({
642
+ adminUserIds: [...base.adminUserIds],
643
+ adminWorkspaces: [...base.adminWorkspaces]
644
+ }));
645
+ const [picking, setPicking] = (0, import_react2.useState)(false);
646
+ const [query, setQuery] = (0, import_react2.useState)("");
647
+ const [scopeOpen, setScopeOpen] = (0, import_react2.useState)(false);
648
+ const save = useConfigSave(scope, onChanged);
649
+ const routing = useRoutingApply(onChanged);
650
+ const admins = state?.admins ?? [];
651
+ const workspaces = state?.workspaces ?? [];
652
+ const all = draft.adminWorkspaces.length === 0;
653
+ (0, import_react2.useEffect)(() => {
654
+ setDraft({ adminUserIds: [...base.adminUserIds], adminWorkspaces: [...base.adminWorkspaces] });
655
+ }, [base]);
656
+ const dirty = changedOperations({ ...base, ...draft }, base).length > 0;
657
+ const known = new Map(admins.map((admin) => [admin.id, admin]));
658
+ const candidates = (0, import_react2.useMemo)(() => {
659
+ const rows = /* @__PURE__ */ new Map();
660
+ for (const sender of state?.rejected ?? []) {
661
+ if (sender.kind !== "user") continue;
662
+ rows.set(sender.id, {
663
+ id: sender.id,
664
+ name: sender.label || sender.id,
665
+ hint: sender.label ? `未授权用户 · ${sender.id}` : "未授权用户(刚给机器人发过消息)"
666
+ });
667
+ }
668
+ for (const group of state?.routing?.groups ?? []) {
669
+ for (const member of group.members) {
670
+ if (member.kind !== "user") continue;
671
+ rows.set(member.id, {
672
+ id: member.id,
673
+ name: member.displayName,
674
+ hint: member.label ? `分组:${group.name} · ${member.id}` : `分组:${group.name}`
675
+ });
676
+ }
677
+ }
678
+ for (const id of draft.adminUserIds) rows.delete(id);
679
+ return [...rows.values()].sort((left, right) => left.name.localeCompare(right.name));
680
+ }, [state, draft.adminUserIds]);
681
+ const needle = query.trim().toLowerCase();
682
+ const matches = needle ? candidates.filter((row) => row.name.toLowerCase().includes(needle) || row.id.toLowerCase().includes(needle)) : candidates;
683
+ const typed = query.trim();
684
+ const addAdmin = (id) => {
685
+ setDraft((current) => ({ ...current, adminUserIds: toggle(current.adminUserIds, id, true) }));
686
+ setQuery("");
687
+ setPicking(false);
688
+ };
689
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
690
+ Card,
691
+ {
692
+ step: 4,
693
+ title: "管理员",
694
+ description: "只有这里列出的 userid 可以切换会话(/sessions、/use、/new、/workspaces)、在单聊里审批工具调用,并按下面的范围接收通知。其它用户永远只能访问自己专属的会话。",
695
+ aside: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
696
+ draft.adminUserIds.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_dsh_client_ui_primitives2.Tag, { tone: "success", children: [
697
+ draft.adminUserIds.length,
698
+ " 人"
699
+ ] }),
700
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
701
+ import_dsh_client_ui_primitives2.Button,
702
+ {
703
+ variant: "outline",
704
+ size: "sm",
705
+ icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconPlusOutlineRegular, {}),
706
+ disabled,
707
+ "aria-label": "添加管理员",
708
+ onClick: () => setPicking(true),
709
+ children: "添加"
710
+ }
711
+ )
712
+ ] }),
713
+ children: [
714
+ routing.error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-banner", "data-tone": "danger", role: "status", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-banner-body", children: routing.error }) }) }),
715
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-panel", children: draft.adminUserIds.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { padding: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Empty, { children: [
716
+ "还没有管理员:没有人可以切换会话、审批工具调用或接收他人会话的通知。",
717
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { marginTop: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconPlusOutlineRegular, {}), disabled, onClick: () => setPicking(true), children: "添加管理员" }) })
718
+ ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-panel-scroll", children: draft.adminUserIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
719
+ AdminRow,
720
+ {
721
+ id,
722
+ label: known.get(id)?.label ?? "",
723
+ groupName: known.get(id)?.groupName,
724
+ disabled: disabled || routing.busy === personKey("user", id),
725
+ onNote: (next) => {
726
+ void routing.apply(personKey("user", id), [setLabel(personKey("user", id), next)]);
727
+ },
728
+ onRemove: () => setDraft((current) => ({ ...current, adminUserIds: toggle(current.adminUserIds, id, false) }))
729
+ },
730
+ id
731
+ )) }) }),
732
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { marginTop: 14 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
733
+ Collapse,
734
+ {
735
+ open: scopeOpen,
736
+ onToggle: () => setScopeOpen((value) => !value),
737
+ title: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
738
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconShieldOutlineRegular, { size: 15 }),
739
+ " 可接收通知的 Workspace"
740
+ ] }),
741
+ summary: all ? "全部 Workspace" : `${draft.adminWorkspaces.length} / ${workspaces.length || draft.adminWorkspaces.length} 个 Workspace`,
742
+ actions: all ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setDraft((current) => ({ ...current, adminWorkspaces: [] })), children: "全选" }),
743
+ children: workspaces.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Empty, { children: "还没有注册任何 Workspace。默认分组的 Workspace 会在创建会话时注册。" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-panel", children: [
744
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-panel-scroll", children: workspaces.map((workspace) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
745
+ CheckRow,
746
+ {
747
+ checked: scopeIncludes(draft.adminWorkspaces, workspace.path),
748
+ label: `管理员接收 ${workspace.title} 的通知`,
749
+ disabled,
750
+ onToggle: (on) => setDraft((current) => ({
751
+ ...current,
752
+ adminWorkspaces: toggleScope(current.adminWorkspaces, workspaces.map((item) => item.path), workspace.path, on)
753
+ })),
754
+ meta: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-meta", children: workspace.sessionCount ? `${workspace.sessionCount} 个会话` : "暂无会话" }),
755
+ children: [
756
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-title", children: workspace.title }),
757
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-sub wcb-mono wcb-ellipsis", title: workspace.path, children: displayPath(workspace.path) })
758
+ ]
759
+ },
760
+ workspace.path
761
+ )) }),
762
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-add", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "wcb-grow wcb-hint", children: [
763
+ all ? "未限定(全部勾选):管理员会收到所有这些 Workspace 中会话的通知。取消勾选任意一项即改为只收勾选的 Workspace。" : "管理员只接收已勾选 Workspace 中会话的通知(外加他们自己绑定的会话)。",
764
+ " ",
765
+ "只有归档会话的 Workspace 也会列出。"
766
+ ] }) })
767
+ ] })
768
+ }
769
+ ) }),
770
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
771
+ SaveBar,
772
+ {
773
+ dirty,
774
+ saving: save.saving,
775
+ saved: save.saved,
776
+ error: save.error,
777
+ disabled,
778
+ onSave: () => {
779
+ void save.save(draft);
780
+ },
781
+ onDiscard: () => setDraft({ adminUserIds: [...base.adminUserIds], adminWorkspaces: [...base.adminWorkspaces] })
782
+ }
783
+ ),
784
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
785
+ import_dsh_client_ui_primitives2.Modal,
786
+ {
787
+ open: picking,
788
+ onClose: () => setPicking(false),
789
+ title: "添加管理员",
790
+ closeLabel: "关闭",
791
+ className: "wcb-modal",
792
+ contentClassName: "wcb-modal-content",
793
+ children: [
794
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
795
+ import_dsh_client_ui_primitives2.Input,
796
+ {
797
+ value: query,
798
+ autoFocus: true,
799
+ placeholder: "搜索备注名或企微 userid",
800
+ "aria-label": "搜索已知用户",
801
+ onChange: (event) => setQuery(event.target.value)
802
+ }
803
+ ),
804
+ matches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-picker-list", role: "listbox", "aria-label": "已知用户", children: matches.map((row) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
805
+ "button",
806
+ {
807
+ type: "button",
808
+ className: "wcb-picker-row",
809
+ role: "option",
810
+ "aria-selected": false,
811
+ onClick: () => addAdmin(row.id),
812
+ children: [
813
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-title", children: row.name }),
814
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-picker-hint", children: row.hint })
815
+ ]
816
+ },
817
+ row.id
818
+ )) }),
819
+ typed && !candidates.some((row) => row.id === typed) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-picker-row", "data-manual": true, children: [
820
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "wcb-row-title", children: [
821
+ "直接添加「",
822
+ typed,
823
+ "」"
824
+ ] }),
825
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-picker-hint", children: "按 userid 添加一个还没给机器人发过消息的人" }),
826
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => addAdmin(typed), children: "添加" })
827
+ ] }),
828
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-hint", children: "名单来自未授权用户和已授权成员,优先显示备注名;没有备注时显示企微 userid。改动在点「保存」后生效。" })
829
+ ]
830
+ }
831
+ )
832
+ ]
833
+ }
834
+ );
359
835
  }
360
- function CheckRow({ checked, onToggle, label, children, meta, disabled }) {
361
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "wcb-row", "data-selected": checked ? "" : void 0, children: [
836
+ function AdminRow({ id, label, groupName, disabled, onNote, onRemove }) {
837
+ const [details, setDetails] = (0, import_react2.useState)(false);
838
+ const name = label || id;
839
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-member", children: [
362
840
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
363
- "input",
841
+ PersonRow,
364
842
  {
365
- type: "checkbox",
366
- className: "wcb-check",
367
- checked,
843
+ kind: "user",
844
+ title: name,
845
+ label: `${name} 的详情`,
368
846
  disabled,
369
- "aria-label": label,
370
- onChange: (event) => onToggle(event.target.checked)
847
+ onOpen: () => setDetails(true),
848
+ meta: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
849
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Tag, { tone: "success", children: "管理员" }),
850
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-sub", children: groupName ? `分组:${groupName}` : "不在任何分组" })
851
+ ] })
371
852
  }
372
853
  ),
373
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-row-main", children }),
374
- meta && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-row-meta", children: meta })
854
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
855
+ PersonDialog,
856
+ {
857
+ open: details,
858
+ onClose: () => setDetails(false),
859
+ title: name,
860
+ typeLabel: "管理员(个人 userid)",
861
+ id,
862
+ label,
863
+ noteLabel: `管理员 ${id} 的备注`,
864
+ disabled,
865
+ onNote,
866
+ footer: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
867
+ import_dsh_client_ui_primitives2.Button,
868
+ {
869
+ variant: "ghost",
870
+ size: "sm",
871
+ icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconTrashOutlineRegular, {}),
872
+ disabled,
873
+ "aria-label": `移除管理员 ${id}`,
874
+ onClick: onRemove,
875
+ children: "移除管理员"
876
+ }
877
+ ),
878
+ children: [
879
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-person-facts", children: [
880
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Fact, { name: "授权来源", children: "插件设置里的管理员列表(点本卡片的「保存」后生效)" }),
881
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Fact, { name: "所属分组", children: groupName ?? "不在任何分组" })
882
+ ] }),
883
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-hint", children: "备注即时生效;加入或移出管理员名单需要点「保存」。" })
884
+ ]
885
+ }
886
+ )
375
887
  ] });
376
888
  }
377
- function Empty({ children }) {
378
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-empty", children });
379
- }
380
889
 
381
890
  // src/client/components/AdvancedCard.tsx
891
+ var import_react3 = require("react");
892
+ var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
382
893
  var import_jsx_runtime3 = require("react/jsx-runtime");
383
- function AdvancedCard({ draft, errors, journal, disabled, onChange }) {
384
- const [copied, setCopied] = (0, import_react2.useState)(false);
894
+ function AdvancedCard({ scope, base, journal, disabled, onChanged }) {
895
+ const [draft, setDraft] = (0, import_react3.useState)(() => slice(base));
896
+ const [attempted, setAttempted] = (0, import_react3.useState)(false);
897
+ const [copied, setCopied] = (0, import_react3.useState)(false);
898
+ const save = useConfigSave(scope, onChanged);
899
+ const dirty = changedOperations({ ...base, ...draft }, base).length > 0;
900
+ const errors = attempted ? validateAdvanced(draft) : {};
901
+ (0, import_react3.useEffect)(() => {
902
+ setDraft(slice(base));
903
+ }, [base]);
385
904
  const copy = async () => {
386
905
  if (!journal?.directory) return;
387
906
  setCopied(await (0, import_dsh_client_ui_primitives3.writeClipboard)(journal.directory));
@@ -391,7 +910,7 @@ window.__ModuleLoader__.load({
391
910
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("summary", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
392
911
  CardHead,
393
912
  {
394
- step: 4,
913
+ step: 5,
395
914
  title: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
396
915
  "高级设置 ",
397
916
  draft.remoteApprovals && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Tag, { tone: "warning", children: "远程审批已开启" })
@@ -404,14 +923,14 @@ window.__ModuleLoader__.load({
404
923
  Field,
405
924
  {
406
925
  label: "远程审批工具调用",
407
- hint: "开启后,DSH 请求执行工具时会向已允许用户的单聊发送带验证码的审批消息,回复 /approve 或 /deny 即生效;群聊永远不能审批。不需要时请保持关闭。",
926
+ hint: "开启后,DSH 请求执行工具时会通知所有管理员,管理员在单聊里回复 /approve 或 /deny 即生效;群聊永远不能审批。关闭时只通知,审批仍需到 DSH 页面完成。",
408
927
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
409
928
  import_dsh_client_ui_primitives3.Switch,
410
929
  {
411
930
  checked: draft.remoteApprovals,
412
931
  disabled,
413
932
  label: "远程审批工具调用",
414
- onChange: (next) => onChange({ remoteApprovals: next })
933
+ onChange: (next) => setDraft((current) => ({ ...current, remoteApprovals: next }))
415
934
  }
416
935
  )
417
936
  }
@@ -433,7 +952,7 @@ window.__ModuleLoader__.load({
433
952
  value: Math.round(draft.questionTimeoutMs / 1e3),
434
953
  disabled,
435
954
  "aria-label": "等待企微回复的秒数",
436
- onChange: (event) => onChange({ questionTimeoutMs: Number(event.target.value) * 1e3 })
955
+ onChange: (event) => setDraft((current) => ({ ...current, questionTimeoutMs: Number(event.target.value) * 1e3 }))
437
956
  }
438
957
  )
439
958
  }
@@ -447,7 +966,7 @@ window.__ModuleLoader__.load({
447
966
  spellCheck: false,
448
967
  disabled,
449
968
  "aria-label": "WebSocket 地址",
450
- onChange: (event) => onChange({ wsUrl: event.target.value })
969
+ onChange: (event) => setDraft((current) => ({ ...current, wsUrl: event.target.value }))
451
970
  }
452
971
  ) }),
453
972
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
@@ -475,7 +994,7 @@ window.__ModuleLoader__.load({
475
994
  checked: draft.logEnabled,
476
995
  disabled,
477
996
  label: "记录对话日志",
478
- onChange: (next) => onChange({ logEnabled: next })
997
+ onChange: (next) => setDraft((current) => ({ ...current, logEnabled: next }))
479
998
  }
480
999
  ),
481
1000
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "var(--wcb-text-2)", fontSize: 13 }, children: "保留" }),
@@ -490,7 +1009,7 @@ window.__ModuleLoader__.load({
490
1009
  value: draft.logRetentionDays,
491
1010
  disabled: disabled || !draft.logEnabled,
492
1011
  "aria-label": "日志保留天数",
493
- onChange: (event) => onChange({ logRetentionDays: Number(event.target.value) })
1012
+ onChange: (event) => setDraft((current) => ({ ...current, logRetentionDays: Number(event.target.value) }))
494
1013
  }
495
1014
  ),
496
1015
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "var(--wcb-text-2)", fontSize: 13 }, children: "天" })
@@ -504,17 +1023,69 @@ window.__ModuleLoader__.load({
504
1023
  ] })
505
1024
  ]
506
1025
  }
1026
+ ),
1027
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1028
+ SaveBar,
1029
+ {
1030
+ dirty,
1031
+ saving: save.saving,
1032
+ saved: save.saved,
1033
+ error: save.error,
1034
+ disabled,
1035
+ onSave: () => {
1036
+ setAttempted(true);
1037
+ void save.save(draft);
1038
+ },
1039
+ onDiscard: () => {
1040
+ setDraft(slice(base));
1041
+ setAttempted(false);
1042
+ }
1043
+ }
507
1044
  )
508
1045
  ] });
509
1046
  }
1047
+ function slice(base) {
1048
+ return {
1049
+ remoteApprovals: base.remoteApprovals,
1050
+ questionTimeoutMs: base.questionTimeoutMs,
1051
+ wsUrl: base.wsUrl,
1052
+ logEnabled: base.logEnabled,
1053
+ logRetentionDays: base.logRetentionDays
1054
+ };
1055
+ }
510
1056
 
511
1057
  // src/client/components/CredentialsCard.tsx
512
- var import_react3 = require("react");
1058
+ var import_react4 = require("react");
513
1059
  var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
514
1060
  var import_jsx_runtime4 = require("react/jsx-runtime");
515
- function CredentialsCard({ draft, errors, secretConfigured, disabled, onChange }) {
516
- const [reveal, setReveal] = (0, import_react3.useState)(false);
517
- const ready = Boolean(draft.botId.trim()) && (secretConfigured || Boolean(draft.secret.trim()));
1061
+ function CredentialsCard({ scope, base, disabled, remote, onChanged }) {
1062
+ const [reveal, setReveal] = (0, import_react4.useState)(false);
1063
+ const [secret, setSecret] = (0, import_react4.useState)("");
1064
+ const [botId, setBotId] = (0, import_react4.useState)(base.botId);
1065
+ const [error, setError] = (0, import_react4.useState)();
1066
+ const [attempted, setAttempted] = (0, import_react4.useState)(false);
1067
+ const save = useConfigSave(scope, onChanged);
1068
+ const status = useSecretStatus(remote, base.secretEnv);
1069
+ const ready = Boolean(botId.trim()) && (status.configured || Boolean(secret.trim()));
1070
+ const dirty = botId.trim() !== base.botId || Boolean(secret.trim());
1071
+ const errors = attempted ? validateCredentials({ botId, secret }, status.configured) : {};
1072
+ (0, import_react4.useEffect)(() => {
1073
+ setBotId(base.botId);
1074
+ }, [base.botId]);
1075
+ async function onSave() {
1076
+ setAttempted(true);
1077
+ setError(void 0);
1078
+ if (Object.keys(validateCredentials({ botId, secret }, status.configured)).length) return;
1079
+ if (!await save.save({ botId: botId.trim() })) return;
1080
+ if (!secret.trim()) return;
1081
+ try {
1082
+ await storeCredential(remote?.credentials, base.secretEnv, secret.trim());
1083
+ setSecret("");
1084
+ status.refresh();
1085
+ } catch (cause) {
1086
+ setError(`其它配置已保存,但 Secret 保存失败:${cause instanceof Error ? cause.message : String(cause)}`);
1087
+ }
1088
+ }
518
1089
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
519
1090
  Card,
520
1091
  {
@@ -527,26 +1098,26 @@ window.__ModuleLoader__.load({
527
1098
  import_dsh_client_ui_primitives4.Input,
528
1099
  {
529
1100
  className: "wcb-grow",
530
- value: draft.botId,
1101
+ value: botId,
531
1102
  placeholder: "例如 aib0xxxxxxxxxxxx",
532
1103
  spellCheck: false,
533
1104
  autoComplete: "off",
534
1105
  disabled,
535
1106
  "aria-label": "Bot ID",
536
- onChange: (event) => onChange({ botId: event.target.value })
1107
+ onChange: (event) => setBotId(event.target.value)
537
1108
  }
538
1109
  ) }),
539
1110
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
540
1111
  Field,
541
1112
  {
542
1113
  label: "Bot Secret",
543
- required: !secretConfigured,
1114
+ required: !status.configured,
544
1115
  error: errors.secret,
545
1116
  hint: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
546
1117
  "保存到 DSH 凭据库(引用名 ",
547
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "wcb-code", children: draft.secretEnv }),
1118
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "wcb-code", children: base.secretEnv }),
548
1119
  "),不会写入插件配置,也不会回显。",
549
- secretConfigured ? "留空表示保持当前 Secret。" : ""
1120
+ status.configured ? "留空表示保持当前 Secret。" : ""
550
1121
  ] }),
551
1122
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "wcb-field-row", children: [
552
1123
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
@@ -554,343 +1125,572 @@ window.__ModuleLoader__.load({
554
1125
  {
555
1126
  className: "wcb-grow",
556
1127
  type: reveal ? "text" : "password",
557
- value: draft.secret,
558
- placeholder: secretConfigured ? "已保存 · 输入新值以替换" : "粘贴 Bot Secret",
1128
+ value: secret,
1129
+ placeholder: status.configured ? "已保存 · 输入新值以替换" : "粘贴 Bot Secret",
559
1130
  autoComplete: "new-password",
560
1131
  spellCheck: false,
561
1132
  disabled,
562
1133
  "aria-label": "Bot Secret",
563
- onChange: (event) => onChange({ secret: event.target.value })
1134
+ onChange: (event) => setSecret(event.target.value)
564
1135
  }
565
1136
  ),
566
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Button, { variant: "ghost", size: "sm", type: "button", onClick: () => setReveal((value) => !value), disabled: !draft.secret, children: reveal ? "隐藏" : "显示" }),
567
- secretConfigured ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Tag, { tone: "success", children: "已保存" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Tag, { tone: "warning", children: "未设置" })
1137
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Button, { variant: "ghost", size: "sm", type: "button", onClick: () => setReveal((value) => !value), disabled: !secret, children: reveal ? "隐藏" : "显示" }),
1138
+ status.configured ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Tag, { tone: "success", children: "已保存" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Tag, { tone: "warning", children: "未设置" })
568
1139
  ] })
569
1140
  }
1141
+ ),
1142
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1143
+ SaveBar,
1144
+ {
1145
+ dirty,
1146
+ saving: save.saving,
1147
+ saved: save.saved,
1148
+ error: error ?? save.error,
1149
+ disabled,
1150
+ onSave: () => {
1151
+ void onSave();
1152
+ },
1153
+ onDiscard: () => {
1154
+ setBotId(base.botId);
1155
+ setSecret("");
1156
+ setError(void 0);
1157
+ setAttempted(false);
1158
+ }
1159
+ }
570
1160
  )
571
1161
  ]
572
1162
  }
573
1163
  );
574
1164
  }
575
1165
 
576
- // src/client/components/IdentityPicker.tsx
577
- var import_react4 = require("react");
1166
+ // src/client/components/GroupsCard.tsx
1167
+ var import_react5 = require("react");
578
1168
  var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
579
1169
  var import_jsx_runtime5 = require("react/jsx-runtime");
580
- var REASON = {
581
- user: "用户不在白名单",
582
- chat: "会话不在白名单",
583
- "user+chat": "用户和会话都不在白名单"
584
- };
585
- function IdentityPicker({ observed, chatIds, userIds, disabled, connected, onChange }) {
586
- const rejected = (observed?.users ?? []).filter((user) => user.decision === "rejected").length;
1170
+ function GroupsCard({ state, error, disabled, refreshing, onRefresh, onChanged }) {
1171
+ const { busy, error: applyError, apply: apply2 } = useRoutingApply(onChanged);
1172
+ const [freshId, setFreshId] = (0, import_react5.useState)();
1173
+ const view = state?.routing;
1174
+ (0, import_react5.useEffect)(() => {
1175
+ if (freshId && view?.groups.some((group) => group.id === freshId)) setFreshId(void 0);
1176
+ }, [freshId, view]);
1177
+ const add = async () => {
1178
+ const response = await apply2("group:new", [addGroup()]);
1179
+ if (response?.createdGroupId) setFreshId(response.createdGroupId);
1180
+ };
587
1181
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
588
1182
  Card,
589
1183
  {
590
- step: 3,
591
- title: "企业微信来源",
592
- description: "这里只列出最近 24 小时内真正给机器人发过消息的 ID,包括被白名单拒绝的。勾选即加入白名单;某一列不勾选表示该项不限制。",
593
- aside: rejected ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_dsh_client_ui_primitives5.Tag, { tone: "danger", children: [
594
- rejected,
595
- " 个用户被拒绝"
596
- ] }) : void 0,
1184
+ step: 2,
1185
+ title: "用户分组",
1186
+ description: "每个分组决定成员在哪个 Workspace、用哪个模型与 preset;把企微用户或群聊放进分组即为授权。改动即时生效。",
1187
+ aside: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1188
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CountTag, { count: view?.groups.length ?? 0, noun: "个分组", tone: "quiet" }),
1189
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CountTag, { count: view?.total ?? 0, noun: "位成员" })
1190
+ ] }),
597
1191
  children: [
598
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-columns", children: [
599
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
600
- IdentityPanel,
601
- {
602
- kind: "users",
603
- title: "允许的用户",
604
- hint: "企业微信 userid",
605
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconUserOutlineRegular, { size: 16 }),
606
- observed: observed?.users ?? [],
607
- selected: userIds,
608
- disabled,
609
- connected,
610
- onChange: (next) => onChange({ allowedUserIds: next })
611
- }
612
- ),
613
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
614
- IdentityPanel,
615
- {
616
- kind: "chats",
617
- title: "允许的会话",
618
- hint: "单聊 = 对方 userid;群聊 = chatid",
619
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconUsersOutlineRegular, { size: 16 }),
620
- observed: observed?.chats ?? [],
621
- selected: chatIds,
622
- disabled,
623
- connected,
624
- onChange: (next) => onChange({ chatIds: next })
625
- }
626
- )
1192
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-toolbar", children: [
1193
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-grow wcb-hint", children: "没有分组的用户无法与机器人对话;他们发消息后会出现在「未授权用户」卡片里,加入分组即完成授权。" }),
1194
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconRefreshOutlineRegular, {}), disabled: refreshing, onClick: onRefresh, children: refreshing ? "刷新中" : "刷新" }),
1195
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "outline", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconPlusOutlineRegular, {}), disabled: disabled || busy === "group:new", onClick: () => {
1196
+ void add();
1197
+ }, children: "添加分组" })
627
1198
  ] }),
628
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-list-foot", children: [
629
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "ID 列表保存在内存中,DSH 重启后需要重新收到消息才会出现。" }),
630
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
631
- "在企业微信里发送 ",
632
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-code", children: "/whoami" }),
633
- " 也可查看自己的 ID(仅限已允许的用户)。"
634
- ] })
635
- ] })
1199
+ applyError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-banner", "data-tone": "danger", role: "status", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-banner-body", children: applyError }) }) }),
1200
+ !view ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Empty, { children: error ?? state?.routingError ?? "正在读取分组信息…" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-groups", children: view.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1201
+ GroupPanel,
1202
+ {
1203
+ group,
1204
+ state,
1205
+ startEditing: group.id === freshId,
1206
+ disabled: disabled || busy.startsWith(`group:${group.id}`),
1207
+ onApply: apply2
1208
+ },
1209
+ group.id
1210
+ )) })
636
1211
  ]
637
1212
  }
638
1213
  );
639
1214
  }
640
- function IdentityPanel({ kind, title, hint, icon, observed, selected, disabled, connected, onChange }) {
641
- const [manual, setManual] = (0, import_react4.useState)("");
642
- const rows = identityRows(observed, selected);
643
- const add = () => {
644
- const id = manual.trim();
645
- if (!id) return;
646
- onChange(toggle(selected, id, true));
647
- setManual("");
1215
+ function draftOf(group) {
1216
+ return {
1217
+ name: group.name,
1218
+ workspace: group.workspace,
1219
+ provider: group.provider,
1220
+ model: group.model,
1221
+ effort: group.reasoningEffort ?? "",
1222
+ preset: group.preset
648
1223
  };
649
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
650
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-subhead", children: [
651
- icon,
652
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-subhead-title", children: title }),
653
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-subhead-hint", children: hint }),
654
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-card-aside", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ScopeTag, { count: selected.length }) })
1224
+ }
1225
+ function patchOf(group, draft) {
1226
+ const patch = {};
1227
+ const name = draft.name.trim();
1228
+ if (name && name !== group.name) patch.name = name;
1229
+ if (draft.workspace !== group.workspace) patch.workspace = draft.workspace;
1230
+ if (draft.provider !== group.provider || draft.model !== group.model) {
1231
+ patch.provider = draft.provider;
1232
+ patch.model = draft.model;
1233
+ patch.reasoningEffort = "";
1234
+ } else if (draft.effort !== (group.reasoningEffort ?? "")) {
1235
+ patch.reasoningEffort = draft.effort;
1236
+ }
1237
+ if (draft.preset !== group.preset) patch.preset = draft.preset;
1238
+ return patch;
1239
+ }
1240
+ function GroupPanel({ group, state, startEditing, disabled, onApply }) {
1241
+ const [open, setOpen] = (0, import_react5.useState)(startEditing);
1242
+ const [editing, setEditing] = (0, import_react5.useState)(startEditing);
1243
+ const [draft, setDraft] = (0, import_react5.useState)(() => draftOf(group));
1244
+ const [confirming, setConfirming] = (0, import_react5.useState)(false);
1245
+ const catalog = state?.models;
1246
+ const presets = state?.presets;
1247
+ const workspaces = state?.workspaces ?? [];
1248
+ const key = `group:${group.id}`;
1249
+ const effort = group.reasoningEffort ? effortLabel(catalog, {
1250
+ provider: group.effectiveProvider,
1251
+ model: group.effectiveModel,
1252
+ reasoningEffort: group.reasoningEffort
1253
+ }) || group.reasoningEffort : "默认";
1254
+ const summary = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1255
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1256
+ group.memberCount,
1257
+ " 位成员"
655
1258
  ] }),
656
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-panel", children: [
657
- rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { padding: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Empty, { children: [
658
- connected ? "还没有收到消息。" : "机器人尚未在线。",
659
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ol", { children: [
660
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: "填写 Bot ID 与 Secret 并保存;" }),
661
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: "在企业微信里给机器人发一条消息(群聊里请 @机器人);" }),
662
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: "几秒后 ID 会自动出现在这里。" })
663
- ] })
664
- ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-panel-scroll", children: rows.map(({ id, observed: entry }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
665
- CheckRow,
666
- {
667
- checked: selected.includes(id),
668
- label: `允许${kind === "users" ? "用户" : "会话"} ${id}`,
669
- disabled,
670
- onToggle: (on) => onChange(toggle(selected, id, on)),
671
- meta: entry ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DecisionTag, { entry }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "quiet", children: "手动添加" }),
672
- children: [
673
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-row-title wcb-mono", style: { fontSize: 13 }, title: id, children: id }),
674
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-row-sub", children: entry ? describe(kind, entry) : "24 小时内未收到消息" })
675
- ]
676
- },
677
- id
678
- )) }),
679
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-add", children: [
680
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
681
- import_dsh_client_ui_primitives5.Input,
682
- {
683
- className: "wcb-grow",
684
- value: manual,
685
- placeholder: kind === "users" ? "手动添加 userid" : "手动添加 chatid / userid",
686
- "aria-label": kind === "users" ? "手动添加 userid" : "手动添加会话 ID",
687
- disabled,
688
- onChange: (event) => setManual(event.target.value),
689
- onKeyDown: (event) => {
690
- if (event.key === "Enter") {
691
- event.preventDefault();
692
- add();
693
- }
694
- }
695
- }
696
- ),
697
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "outline", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconPlusOutlineRegular, {}), disabled: disabled || !manual.trim(), onClick: add, children: "添加" })
698
- ] })
1259
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1260
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "Workspace" }),
1261
+ group.workspaceTitle
1262
+ ] }),
1263
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1264
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "模型" }),
1265
+ groupModelSummary(catalog, group)
1266
+ ] }),
1267
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1268
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "effort" }),
1269
+ effort
1270
+ ] }),
1271
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1272
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "preset" }),
1273
+ presetSummaryLabel(presets, group.preset)
699
1274
  ] })
700
1275
  ] });
701
- }
702
- function describe(kind, entry) {
703
- const parts = [`${relativeTime(entry.lastSeenAt)}`, `${entry.messages} 条消息`];
704
- if (kind === "chats") parts.unshift(entry.chatType === "group" ? "群聊" : "单聊");
705
- if (kind === "chats" && entry.chatType === "group" && entry.via) parts.push(`最近发言 ${entry.via}`);
706
- if (kind === "users" && entry.via && entry.via !== entry.id) parts.push(`来自群 ${entry.via}`);
707
- return parts.join(" · ");
708
- }
709
- function DecisionTag({ entry }) {
710
- return entry.decision === "rejected" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { title: entry.reason ? REASON[entry.reason] : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "danger", children: "上次被拒绝" }) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "success", children: "上次已接受" });
711
- }
712
-
713
- // src/client/components/SessionPicker.tsx
714
- var import_react5 = require("react");
715
- var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
716
- var import_jsx_runtime6 = require("react/jsx-runtime");
717
- var HIDDEN_REASON = {
718
- archived: "已归档",
719
- subagent: "子代理会话",
720
- blank: "空会话",
721
- missing: "已删除或不可见"
722
- };
723
- var UNTITLED = "未命名会话";
724
- function SessionPicker({ catalog, error, loading, refreshing, selected, disabled, onChange, onRefresh }) {
725
- const [query, setQuery] = (0, import_react5.useState)("");
726
- const [onlySelected, setOnlySelected] = (0, import_react5.useState)(false);
727
- const [open, setOpen] = (0, import_react5.useState)({});
728
- const selectedSet = (0, import_react5.useMemo)(() => new Set(selected), [selected]);
729
- const groups = (0, import_react5.useMemo)(
730
- () => filterGroups(catalog?.groups ?? [], query, onlySelected ? selectedSet : void 0),
731
- [catalog, query, onlySelected, selectedSet]
732
- );
733
- const shown = groups.reduce((sum, group) => sum + group.sessions.length, 0);
734
- const searching = Boolean(query.trim()) || onlySelected;
735
- const isOpen = (group, index) => searching || (open[group.key] ?? (index < 2 || group.sessions.some((session) => selectedSet.has(session.sessionId))));
736
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
737
- Card,
1276
+ (0, import_react5.useEffect)(() => {
1277
+ if (!editing) setDraft(draftOf(group));
1278
+ }, [group, editing]);
1279
+ const efforts = effortsFor(catalog, draft.provider || group.effectiveProvider, draft.model || group.effectiveModel);
1280
+ const update = (patch) => setDraft((current) => ({ ...current, ...patch }));
1281
+ const startEdit = () => {
1282
+ setDraft(draftOf(group));
1283
+ setEditing(true);
1284
+ setOpen(true);
1285
+ };
1286
+ const save = async () => {
1287
+ const patch = patchOf(group, draft);
1288
+ if (!Object.keys(patch).length) {
1289
+ setEditing(false);
1290
+ return;
1291
+ }
1292
+ const response = await onApply(key, [updateGroup(group.id, patch)]);
1293
+ if (response) setEditing(false);
1294
+ };
1295
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1296
+ Collapse,
738
1297
  {
739
- step: 2,
740
- title: "DSH 会话范围",
741
- description: "勾选允许从企业微信查看与操作的会话;不勾选表示所有未归档会话都可操作。已归档、子代理和空会话不会显示。",
742
- aside: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ScopeTag, { count: selected.length }),
743
- children: [
744
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-toolbar", children: [
745
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
746
- import_dsh_client_ui_primitives6.Input,
1298
+ open,
1299
+ onToggle: () => setOpen((value) => !value),
1300
+ title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1301
+ group.name,
1302
+ group.isDefault && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "quiet", children: "默认" })
1303
+ ] }),
1304
+ summary,
1305
+ actions: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1306
+ editing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1307
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => {
1308
+ setEditing(false);
1309
+ setDraft(draftOf(group));
1310
+ }, children: "取消" }),
1311
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "primary", size: "sm", disabled, onClick: () => {
1312
+ void save();
1313
+ }, children: "保存" })
1314
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, "aria-label": `编辑 ${group.name}`, onClick: startEdit, children: "编辑" }),
1315
+ !group.isDefault && (confirming ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1316
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setConfirming(false), children: "取消" }),
1317
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1318
+ import_dsh_client_ui_primitives5.Button,
747
1319
  {
748
- className: "wcb-search",
749
- icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconSearchOutlineRegular, {}),
750
- value: query,
751
- placeholder: "搜索会话名称、ID 或工作区",
752
- "aria-label": "搜索会话",
753
- onChange: (event) => setQuery(event.target.value)
1320
+ variant: "ghost",
1321
+ size: "sm",
1322
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}),
1323
+ disabled,
1324
+ onClick: () => {
1325
+ void onApply(key, [deleteGroup(group.id)]);
1326
+ },
1327
+ children: "确认删除"
754
1328
  }
755
- ),
756
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Button, { variant: onlySelected ? "toolbar" : "ghost", size: "sm", "aria-pressed": onlySelected, onClick: () => setOnlySelected((value) => !value), children: "仅看已选" }),
757
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Button, { variant: "ghost", size: "sm", disabled: disabled || !selected.length, onClick: () => onChange([]), children: "清空选择" }),
758
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Button, { variant: "ghost", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconRefreshOutlineRegular, {}), disabled: refreshing, onClick: onRefresh, "aria-label": "刷新会话列表", children: refreshing ? "刷新中" : "刷新" })
759
- ] }),
760
- !catalog ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { children: error ?? (loading ? "正在读取 DSH 会话列表…" : "会话列表不可用。") }) : groups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { children: searching ? "没有匹配的会话。" : "还没有可选择的会话。在 DSH 中开始一个对话后,它会出现在这里。" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "wcb-scroll", children: groups.map((group, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
761
- SessionGroup,
762
- {
763
- group,
764
- open: isOpen(group, index),
765
- selected: selectedSet,
766
- disabled,
767
- onToggleOpen: () => setOpen((state) => ({ ...state, [group.key]: !isOpen(group, index) })),
768
- onSelectGroup: (on) => onChange(setAll(selected, group.sessions.map((session) => session.sessionId), on)),
769
- onSelect: (id, on) => onChange(toggle(selected, id, on))
770
- },
771
- group.key
772
- )) }),
773
- catalog && catalog.hiddenSelections.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-hidden-list", children: [
774
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-hidden-head", children: [
775
- "已勾选但当前不可操作(",
776
- catalog.hiddenSelections.length,
777
- ")",
778
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { flex: 1 } }),
779
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
780
- import_dsh_client_ui_primitives6.Button,
1329
+ )
1330
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}), disabled, onClick: () => setConfirming(true), children: "删除分组" }))
1331
+ ] }),
1332
+ children: [
1333
+ editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-binding-controls", children: [
1334
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1335
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "分组名称" }),
1336
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1337
+ import_dsh_client_ui_primitives5.Input,
781
1338
  {
782
- variant: "ghost",
783
- size: "sm",
1339
+ value: draft.name,
784
1340
  disabled,
785
- onClick: () => onChange(setAll(selected, catalog.hiddenSelections.map((item) => item.sessionId), false)),
786
- children: "全部移除"
1341
+ "aria-label": `${group.name} 的名称`,
1342
+ onChange: (event) => update({ name: event.target.value })
787
1343
  }
788
1344
  )
789
1345
  ] }),
790
- catalog.hiddenSelections.map((item) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
791
- CheckRow,
792
- {
793
- checked: selectedSet.has(item.sessionId),
794
- label: `取消勾选 ${item.title ?? item.sessionId}`,
795
- disabled,
796
- onToggle: (on) => onChange(toggle(selected, item.sessionId, on)),
797
- meta: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Tag, { tone: "warning", children: HIDDEN_REASON[item.reason] }),
798
- children: [
799
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-row-title", "data-muted": item.title ? void 0 : "", children: item.title ?? UNTITLED }),
800
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-row-sub wcb-mono", children: item.sessionId })
801
- ]
802
- },
803
- item.sessionId
804
- ))
805
- ] }),
806
- catalog && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-list-foot", children: [
807
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
808
- "显示 ",
809
- shown,
810
- " / ",
811
- catalog.total,
812
- " 个会话"
1346
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1347
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "Workspace" }),
1348
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1349
+ Select,
1350
+ {
1351
+ value: draft.workspace,
1352
+ disabled,
1353
+ "aria-label": `${group.name} 的 Workspace`,
1354
+ onChange: (event) => update({ workspace: event.target.value }),
1355
+ children: [
1356
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: "", children: [
1357
+ "插件自带(",
1358
+ displayPath(workspaces.find((workspace) => workspace.pluginOwned)?.path),
1359
+ ")"
1360
+ ] }),
1361
+ workspaces.map((workspace) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: workspace.path, children: [
1362
+ workspace.title,
1363
+ " — ",
1364
+ displayPath(workspace.path)
1365
+ ] }, workspace.path)),
1366
+ draft.workspace && !workspaces.some((workspace) => workspace.path === draft.workspace) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: draft.workspace, children: [
1367
+ displayPath(draft.workspace),
1368
+ "(未注册)"
1369
+ ] })
1370
+ ]
1371
+ }
1372
+ )
1373
+ ] }),
1374
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1375
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "模型" }),
1376
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1377
+ Select,
1378
+ {
1379
+ value: modelKey(draft.provider, draft.model),
1380
+ disabled: disabled || !catalog,
1381
+ "aria-label": `${group.name} 的模型`,
1382
+ onChange: (event) => {
1383
+ const next = parseModelKey(event.target.value);
1384
+ update({ provider: next.provider, model: next.model, effort: "" });
1385
+ },
1386
+ children: [
1387
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: dshDefaultLabel(catalog) }),
1388
+ (catalog?.choices ?? []).map((choice) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: modelKey(choice.provider, choice.model), children: [
1389
+ choice.providerName,
1390
+ " / ",
1391
+ choiceLabel(choice)
1392
+ ] }, modelKey(choice.provider, choice.model)))
1393
+ ]
1394
+ }
1395
+ )
813
1396
  ] }),
814
- catalog.archived > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
815
- "已隐藏 ",
816
- catalog.archived,
817
- " 个已归档会话"
1397
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1398
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "effort(思考强度)" }),
1399
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1400
+ Select,
1401
+ {
1402
+ value: draft.effort,
1403
+ disabled: disabled || !efforts.length || !(draft.provider || draft.model),
1404
+ "aria-label": `${group.name} 的 effort`,
1405
+ onChange: (event) => update({ effort: event.target.value }),
1406
+ children: [
1407
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: "默认" }),
1408
+ efforts.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: item.id, children: item.name }, item.id))
1409
+ ]
1410
+ }
1411
+ )
818
1412
  ] }),
819
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
820
- "更新于 ",
821
- relativeTime(catalog.generatedAt)
1413
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1414
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "preset" }),
1415
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1416
+ Select,
1417
+ {
1418
+ value: draft.preset,
1419
+ disabled: disabled || !presets?.presets.length,
1420
+ "aria-label": `${group.name} 的 preset`,
1421
+ onChange: (event) => update({ preset: event.target.value }),
1422
+ children: [
1423
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: presetLabel(presets, "") }),
1424
+ (presets?.presets ?? []).map((preset) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: preset.id, children: [
1425
+ presetName(preset),
1426
+ preset.broken ? "(不可用)" : ""
1427
+ ] }, preset.id))
1428
+ ]
1429
+ }
1430
+ )
822
1431
  ] })
823
- ] })
1432
+ ] }),
1433
+ editing && (!efforts.length || !presets?.presets.length) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-hint", children: [
1434
+ !efforts.length && "当前模型没有可选的 effort:先选一个支持思考强度的模型,或让 DSH 默认模型决定。",
1435
+ !efforts.length && !presets?.presets.length && " ",
1436
+ !presets?.presets.length && `没有读到 DSH 的 preset 列表${state?.presetsError ? `:${state.presetsError}` : "(这个部署没有挂载 preset registry)"}。`
1437
+ ] }),
1438
+ group.workspaceError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-hint wcb-inline-error", children: group.workspaceError }),
1439
+ editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-hint", children: "更换 Workspace 后,本组成员的会话会在下一条消息时重新创建。模型与 effort 在下一条消息时安装到已有会话; preset 只影响此后新建的会话(DSH 不允许改写已经开始的会话)。" }),
1440
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-members", children: group.members.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Empty, { children: "这个分组还没有成员。让对方先给机器人发一条消息,然后在「未授权用户」里把 TA 加入本组。" }) : group.members.map((member) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1441
+ MemberRow,
1442
+ {
1443
+ member,
1444
+ group,
1445
+ groups: state?.routing?.groups ?? [],
1446
+ state,
1447
+ disabled,
1448
+ onApply
1449
+ },
1450
+ member.key
1451
+ )) })
824
1452
  ]
825
1453
  }
826
1454
  );
827
1455
  }
828
- function SessionGroup({ group, open, selected, disabled, onToggleOpen, onSelectGroup, onSelect }) {
829
- const count = group.sessions.filter((session) => selected.has(session.sessionId)).length;
830
- const all = count === group.sessions.length;
831
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-group", "data-open": open ? "" : void 0, children: [
832
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
833
- "div",
1456
+ function MemberRow({ member, group, groups, state, disabled, onApply }) {
1457
+ const [details, setDetails] = (0, import_react5.useState)(false);
1458
+ const [archiving, setArchiving] = (0, import_react5.useState)(false);
1459
+ const catalog = state?.models;
1460
+ const presets = state?.presets;
1461
+ const others = groups.filter((item) => item.id !== group.id);
1462
+ const effort = effortLabel(catalog, member.sessionModel);
1463
+ const name = member.displayName;
1464
+ const title = member.sessionId ? member.sessionTitle ?? "未命名会话" : "待创建";
1465
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-member-row", children: [
1466
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PersonAvatar, { kind: member.kind, label: `${name} 的详情`, disabled, onClick: () => setDetails(true) }),
1467
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-member-name", title: name, children: name }),
1468
+ member.admin && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "success", children: "管理员" }),
1469
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-member-facts", children: [
1470
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1471
+ member.sessionId && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.StateDot, { state: member.sessionRunning ? "ongoing" : "done", size: 8 }),
1472
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-strong", children: title }),
1473
+ member.sessionId && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: member.sessionState === "bound" || member.sessionState === "blank" ? "quiet" : "warning", children: SESSION_STATE_LABEL[member.sessionState] })
1474
+ ] }),
1475
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1476
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "preset" }),
1477
+ presetLabel(presets, member.sessionPreset)
1478
+ ] }),
1479
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1480
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "模型" }),
1481
+ member.sessionModel ? modelName(catalog, member.sessionModel) : "—"
1482
+ ] }),
1483
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1484
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "effort" }),
1485
+ effort || "—"
1486
+ ] }),
1487
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1488
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "上下文" }),
1489
+ contextLabel(member.sessionContext) || "—"
1490
+ ] })
1491
+ ] }),
1492
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-member-actions", children: member.sessionId && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1493
+ import_dsh_client_ui_primitives5.Button,
1494
+ {
1495
+ variant: "ghost",
1496
+ size: "sm",
1497
+ disabled,
1498
+ "aria-label": `归档 ${name} 的会话`,
1499
+ onClick: () => setArchiving(true),
1500
+ children: "归档会话"
1501
+ }
1502
+ ) }),
1503
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1504
+ PersonDialog,
834
1505
  {
835
- className: "wcb-group-head",
836
- role: "button",
837
- tabIndex: 0,
838
- "aria-expanded": open,
839
- onClick: onToggleOpen,
840
- onKeyDown: (event) => {
841
- if (event.target !== event.currentTarget || event.key !== "Enter" && event.key !== " ") return;
842
- event.preventDefault();
843
- onToggleOpen();
1506
+ open: details,
1507
+ onClose: () => setDetails(false),
1508
+ title: name,
1509
+ typeLabel: BINDING_KIND_LABEL[member.kind],
1510
+ id: member.id,
1511
+ label: member.label,
1512
+ noteLabel: `${member.id} 的备注`,
1513
+ disabled,
1514
+ onNote: (next) => {
1515
+ void onApply(member.key, [setLabel(member.key, next)]);
844
1516
  },
1517
+ footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RemoveMember, { member, disabled, onApply }),
845
1518
  children: [
846
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-chevron", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconChevronRightOutlineRegular, { size: 14 }) }),
847
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
848
- "input",
849
- {
850
- type: "checkbox",
851
- className: "wcb-check",
852
- checked: all,
853
- disabled,
854
- "aria-label": `选择工作区 ${group.title} 的全部会话`,
855
- ref: (element) => {
856
- if (element) element.indeterminate = count > 0 && !all;
857
- },
858
- onClick: (event) => event.stopPropagation(),
859
- onChange: (event) => onSelectGroup(event.target.checked)
860
- }
861
- ),
862
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-group-icon", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconFolderCloseRegular, { size: 16 }) }),
863
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-group-title", title: group.title, children: group.title }),
864
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-group-path", title: group.path, children: displayPath(group.path) }),
865
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "wcb-group-count", children: [
866
- count ? `${count}/` : "",
867
- group.sessions.length
1519
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-dialog-section wcb-person-facts", children: [
1520
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "所属分组", children: group.name }),
1521
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "会话", children: member.sessionId ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1522
+ member.sessionTitle ?? "未命名会话",
1523
+ " ",
1524
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-mono", children: member.sessionId.slice(-8) })
1525
+ ] }) : "尚未创建" }),
1526
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "preset", children: presetLabel(presets, member.sessionPreset) }),
1527
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "模型", children: member.sessionModel ? modelLabel(catalog, member.sessionModel) : "—" }),
1528
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "effort", children: effort || "—" }),
1529
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "上下文", children: contextLabel(member.sessionContext) || "—" }),
1530
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "消息", children: member.messages ? `${member.messages} 条 · ${relativeTime(member.lastSeenAt)}` : "尚未收到消息" })
1531
+ ] }),
1532
+ others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1533
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "移动到分组" }),
1534
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1535
+ Select,
1536
+ {
1537
+ value: "",
1538
+ disabled,
1539
+ "aria-label": `把 ${member.id} 移动到分组`,
1540
+ onChange: (event) => {
1541
+ if (!event.target.value) return;
1542
+ void onApply(member.key, [updateMember(member.key, { groupId: event.target.value })]);
1543
+ },
1544
+ children: [
1545
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: "", children: [
1546
+ "保持在「",
1547
+ group.name,
1548
+ "」"
1549
+ ] }),
1550
+ others.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: item.id, children: item.name }, item.id))
1551
+ ]
1552
+ }
1553
+ )
868
1554
  ] })
869
1555
  ]
870
1556
  }
871
1557
  ),
872
- open && group.sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
873
- CheckRow,
1558
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1559
+ ConfirmDialog,
874
1560
  {
875
- checked: selected.has(session.sessionId),
876
- label: `选择会话 ${session.title ?? session.sessionId}`,
1561
+ open: archiving,
1562
+ title: `归档「${name}」的会话?`,
1563
+ confirmLabel: "确认归档",
877
1564
  disabled,
878
- onToggle: (on) => onSelect(session.sessionId, on),
879
- meta: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
880
- session.pinned && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-pin", title: "已置顶", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconPinFillRegular, { size: 12 }) }),
881
- session.running && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "wcb-running", children: [
882
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.StateDot, { state: "ongoing", size: 12 }),
883
- "运行中"
884
- ] }),
885
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: relativeTime(session.updatedAt) })
886
- ] }),
1565
+ onCancel: () => setArchiving(false),
1566
+ onConfirm: () => {
1567
+ void Promise.resolve(onApply(member.key, [archiveMember(member.key)])).then((result) => {
1568
+ if (result) setArchiving(false);
1569
+ });
1570
+ },
1571
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: "归档后这个会话不再被继续,它的历史不会再进入任何请求;下一条消息会按分组当前的 Workspace、模型与 preset 新建一个会话。DSH 的会话文件仍保留在磁盘上,需要时可到 DSH 页面查看。" })
1572
+ }
1573
+ )
1574
+ ] });
1575
+ }
1576
+ function RemoveMember({ member, disabled, onApply }) {
1577
+ const [confirming, setConfirming] = (0, import_react5.useState)(false);
1578
+ return confirming ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1579
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setConfirming(false), children: "取消" }),
1580
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1581
+ import_dsh_client_ui_primitives5.Button,
1582
+ {
1583
+ variant: "ghost",
1584
+ size: "sm",
1585
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}),
1586
+ disabled,
1587
+ onClick: () => {
1588
+ void onApply(member.key, [removeMember(member.key)]);
1589
+ },
887
1590
  children: [
888
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-row-title", "data-muted": session.title ? void 0 : "", title: session.title ?? UNTITLED, children: session.title ?? UNTITLED }),
889
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-row-sub wcb-mono wcb-ellipsis", title: session.sessionId, children: session.sessionId })
1591
+ "确认移出「",
1592
+ member.displayName,
1593
+ "」"
890
1594
  ]
891
- },
892
- session.sessionId
893
- ))
1595
+ }
1596
+ )
1597
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}), disabled, onClick: () => setConfirming(true), children: "移出分组" });
1598
+ }
1599
+
1600
+ // src/client/components/RejectedCard.tsx
1601
+ var import_react6 = require("react");
1602
+ var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
1603
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1604
+ function RejectedCard({ state, disabled, onChanged }) {
1605
+ const rows = state?.rejected ?? [];
1606
+ const groups = state?.routing?.groups ?? [];
1607
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1608
+ Card,
1609
+ {
1610
+ step: 3,
1611
+ title: "未授权用户",
1612
+ description: "给机器人发过消息、但不在任何分组里的人。选择分组并确认即完成授权;备注会代替 userid 显示。列表只保留在内存中,重启 DSH 后清空。",
1613
+ aside: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_dsh_client_ui_primitives6.Tag, { tone: rows.length ? "warning" : "quiet", children: [
1614
+ rows.length,
1615
+ " 个待处理"
1616
+ ] }),
1617
+ children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { children: "暂时没有被拒绝的用户。任何人给机器人发消息后,如果它不在任何分组里,就会出现在这里。" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "wcb-scroll", children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RejectedRow, { row, groups, disabled, onChanged }, row.key)) })
1618
+ }
1619
+ );
1620
+ }
1621
+ function RejectedRow({ row, groups, disabled, onChanged }) {
1622
+ const [open, setOpen] = (0, import_react6.useState)(false);
1623
+ const [groupId, setGroupId] = (0, import_react6.useState)(groups.find((group) => group.id === "default")?.id ?? groups[0]?.id ?? "");
1624
+ const [label, setLabel2] = (0, import_react6.useState)("");
1625
+ const [busy, setBusy] = (0, import_react6.useState)(false);
1626
+ const [error, setError] = (0, import_react6.useState)();
1627
+ async function authorize() {
1628
+ if (!groupId) {
1629
+ setError("还没有可用的分组。");
1630
+ return;
1631
+ }
1632
+ setBusy(true);
1633
+ setError(void 0);
1634
+ try {
1635
+ await postRouting([addMember(groupId, row.kind, row.id, label.trim())]);
1636
+ onChanged();
1637
+ } catch (cause) {
1638
+ setError(cause instanceof Error ? cause.message : String(cause));
1639
+ } finally {
1640
+ setBusy(false);
1641
+ }
1642
+ }
1643
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-member", children: [
1644
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-member-head", children: [
1645
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(KindBadge, { kind: row.kind, plain: true }),
1646
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-row-title", title: row.id, children: row.displayName }),
1647
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { flex: 1 } }),
1648
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "wcb-row-sub", children: [
1649
+ row.messages,
1650
+ " 次 · ",
1651
+ relativeTime(row.lastSeenAt)
1652
+ ] }),
1653
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Button, { variant: "outline", size: "sm", disabled: disabled || !groups.length, onClick: () => setOpen((value) => !value), children: open ? "收起" : "加入分组" })
1654
+ ] }),
1655
+ row.text && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "wcb-rejected-text", title: row.text, children: row.text }),
1656
+ open && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-member-edit", children: [
1657
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "wcb-binding-field", children: [
1658
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-binding-label", children: "分组" }),
1659
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1660
+ Select,
1661
+ {
1662
+ value: groupId,
1663
+ disabled: disabled || busy,
1664
+ "aria-label": `${row.id} 的分组`,
1665
+ onChange: (event) => setGroupId(event.target.value),
1666
+ children: groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: group.id, children: group.name }, group.id))
1667
+ }
1668
+ )
1669
+ ] }),
1670
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "wcb-binding-field", children: [
1671
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-binding-label", children: "备注(优先显示)" }),
1672
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1673
+ import_dsh_client_ui_primitives6.Input,
1674
+ {
1675
+ value: label,
1676
+ placeholder: row.id,
1677
+ disabled: disabled || busy,
1678
+ "aria-label": `${row.id} 的备注`,
1679
+ onChange: (event) => setLabel2(event.target.value),
1680
+ onKeyDown: (event) => {
1681
+ if (event.key === "Enter") {
1682
+ event.preventDefault();
1683
+ void authorize();
1684
+ }
1685
+ }
1686
+ }
1687
+ )
1688
+ ] }),
1689
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "wcb-member-actions", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Button, { variant: "primary", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconCheckCircleOutlineRegular, {}), disabled: disabled || busy, onClick: () => {
1690
+ void authorize();
1691
+ }, children: busy ? "授权中…" : "确认授权" }) }),
1692
+ error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "wcb-field-error", role: "alert", children: error })
1693
+ ] })
894
1694
  ] });
895
1695
  }
896
1696
 
@@ -953,115 +1753,29 @@ window.__ModuleLoader__.load({
953
1753
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SettingsEditor, { snapshot, scope, remote });
954
1754
  }
955
1755
  function SettingsEditor({ snapshot, scope, remote }) {
956
- const base = (0, import_react6.useMemo)(() => storedFrom(snapshot.value), [snapshot.revision]);
957
- const [draft, setDraft] = (0, import_react6.useState)(() => draftFrom(base));
958
- const [save, setSave] = (0, import_react6.useState)({ phase: "idle" });
959
- const [showErrors, setShowErrors] = (0, import_react6.useState)(false);
960
- const baseRef = (0, import_react6.useRef)(base);
1756
+ const base = (0, import_react7.useMemo)(() => storedFrom(snapshot.value), [snapshot.revision]);
961
1757
  const bridge = useBridgeState();
962
- const secret = useSecretStatus(remote, base.secretEnv);
963
1758
  const writable = snapshot.writable !== false;
964
- const busy = save.phase === "saving";
965
- (0, import_react6.useEffect)(() => {
966
- const previous = baseRef.current;
967
- baseRef.current = base;
968
- setDraft((current) => isDirty({ ...current, secret: "" }, previous) ? current : { ...draftFrom(base), secret: current.secret });
969
- }, [base]);
970
- const errors = validate(draft, secret.configured);
971
- const invalid = Object.keys(errors).length > 0;
972
- const dirty = isDirty(draft, base);
973
- const summary = accessSummary(draft);
974
- const update = (patch) => {
975
- setDraft((current) => ({ ...current, ...patch }));
976
- if (save.phase !== "saving") setSave({ phase: "idle" });
977
- };
978
- async function onSave() {
979
- if (invalid) {
980
- setShowErrors(true);
981
- return;
982
- }
983
- setSave({ phase: "saving" });
984
- try {
985
- const ops = changedOperations(draft, base);
986
- if (ops.length && !await scope.mutate(ops, snapshot.revision)) {
987
- throw new Error("配置已在别处被修改,请刷新页面后重试。");
988
- }
989
- if (draft.secret.trim()) {
990
- try {
991
- await storeCredential(remote?.credentials, base.secretEnv, draft.secret.trim());
992
- } catch (error) {
993
- throw new Error(`其他配置已保存,但 Secret 保存失败:${error instanceof Error ? error.message : String(error)}`);
994
- }
995
- setDraft((current) => ({ ...current, secret: "" }));
996
- secret.refresh();
997
- }
998
- setShowErrors(false);
999
- setSave({ phase: "saved" });
1000
- setTimeout(() => bridge.refresh(true), 800);
1001
- } catch (error) {
1002
- setSave({ phase: "error", message: error instanceof Error ? error.message : String(error) });
1003
- }
1004
- }
1005
- const visibleErrors = showErrors ? errors : {};
1006
- const footer = !writable ? { tone: "error", text: "此部署的设置为只读。" } : save.phase === "error" ? { tone: "error", text: save.message } : showErrors && invalid ? { tone: "error", text: "请先修正标红的字段。" } : busy ? { tone: "", text: "正在保存…" } : dirty ? { tone: "dirty", text: "有未保存的更改" } : save.phase === "saved" ? { tone: "success", text: "已保存,机器人会按新配置重新连接。" } : { tone: "", text: "所有更改均已保存。" };
1759
+ const state = bridge.data;
1760
+ const onChanged = () => bridge.refresh(true);
1007
1761
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "wcb-page", children: [
1008
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StatusHeader, { state: bridge.data, error: bridge.error }),
1009
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AccessBanner, { summary }),
1010
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1011
- CredentialsCard,
1012
- {
1013
- draft,
1014
- errors: visibleErrors,
1015
- secretConfigured: secret.configured,
1016
- disabled: !writable || busy,
1017
- onChange: update
1018
- }
1019
- ),
1762
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StatusHeader, { state, error: bridge.error }),
1763
+ state?.notices.map((notice) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "wcb-banner", "data-tone": "warning", role: "status", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "wcb-banner-body", children: notice }) }) }, notice)),
1764
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CredentialsCard, { scope, base, disabled: !writable, remote, onChanged }),
1020
1765
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1021
- SessionPicker,
1766
+ GroupsCard,
1022
1767
  {
1023
- catalog: bridge.data?.sessions,
1024
- error: bridge.data?.sessionsError ?? bridge.error,
1025
- loading: bridge.loading,
1768
+ state,
1769
+ error: bridge.error,
1770
+ disabled: !writable,
1026
1771
  refreshing: bridge.refreshing,
1027
- selected: draft.sessionIds,
1028
- disabled: !writable || busy,
1029
- onChange: (sessionIds) => update({ sessionIds }),
1030
- onRefresh: () => bridge.refresh(true)
1772
+ onRefresh: () => bridge.refresh(true),
1773
+ onChanged
1031
1774
  }
1032
1775
  ),
1033
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1034
- IdentityPicker,
1035
- {
1036
- observed: bridge.data?.observed,
1037
- chatIds: draft.chatIds,
1038
- userIds: draft.allowedUserIds,
1039
- disabled: !writable || busy,
1040
- connected: bridge.data?.connection.phase === "online",
1041
- onChange: (patch) => update(patch)
1042
- }
1043
- ),
1044
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1045
- AdvancedCard,
1046
- {
1047
- draft,
1048
- errors: visibleErrors,
1049
- journal: bridge.data?.journal,
1050
- disabled: !writable || busy,
1051
- onChange: update
1052
- }
1053
- ),
1054
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "wcb-footer", children: [
1055
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "wcb-footer-msg", "data-tone": footer.tone || void 0, role: "status", children: footer.text }),
1056
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives8.Button, { variant: "outline", size: "sm", disabled: !dirty || busy, onClick: () => {
1057
- setDraft(draftFrom(base));
1058
- setShowErrors(false);
1059
- setSave({ phase: "idle" });
1060
- }, children: "放弃更改" }),
1061
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives8.Button, { variant: "primary", size: "sm", disabled: !writable || busy || !dirty, onClick: () => {
1062
- void onSave();
1063
- }, children: busy ? "保存中…" : "保存配置" })
1064
- ] })
1776
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RejectedCard, { state, disabled: !writable, onChanged }),
1777
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AdminCard, { scope, base, state, disabled: !writable, onChanged }),
1778
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AdvancedCard, { scope, base, journal: state?.journal, disabled: !writable, onChanged })
1065
1779
  ] });
1066
1780
  }
1067
1781
 
@@ -1069,7 +1783,9 @@ window.__ModuleLoader__.load({
1069
1783
  var STYLES = (
1070
1784
  /* css */
1071
1785
  `
1072
- .wcb-page {
1786
+ /* The person dialog is portalled to document.body, outside .wcb-page, so the
1787
+ token set is declared once for both roots. */
1788
+ .wcb-page, .wcb-modal {
1073
1789
  /* DSH is monochrome; the business blue is its accent for focus and info. */
1074
1790
  --wcb-brand: var(--dsw-alias-state-business-primary, #4176e6);
1075
1791
  --wcb-text: var(--dsw-alias-label-primary, #0f1115);
@@ -1095,7 +1811,8 @@ window.__ModuleLoader__.load({
1095
1811
  font-size: 14px;
1096
1812
  line-height: 1.5;
1097
1813
  }
1098
- .wcb-page *, .wcb-page *::before, .wcb-page *::after { box-sizing: border-box; }
1814
+ .wcb-page *, .wcb-page *::before, .wcb-page *::after,
1815
+ .wcb-modal *, .wcb-modal *::before, .wcb-modal *::after { box-sizing: border-box; }
1099
1816
 
1100
1817
  /* Hero */
1101
1818
  .wcb-hero {
@@ -1192,19 +1909,32 @@ window.__ModuleLoader__.load({
1192
1909
  .wcb-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
1193
1910
  .wcb-toolbar .wcb-search { flex: 1; min-width: 220px; }
1194
1911
  .wcb-scroll { max-height: 460px; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 1px; }
1912
+ /* The group list grows with the page: nested scroll boxes inside another
1913
+ scroll box are what make a settings page impossible to scan. */
1914
+ .wcb-groups { display: flex; flex-direction: column; gap: 8px; padding: 1px; }
1195
1915
  .wcb-group { border: .5px solid var(--wcb-line); border-radius: 12px; overflow: hidden; background: var(--wcb-surface); }
1196
1916
  .wcb-group-head {
1197
1917
  display: flex; align-items: center; gap: 8px; width: 100%;
1198
- padding: 9px 12px; background: var(--wcb-surface-2);
1199
- border: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
1918
+ padding: 0 12px 0 0; background: var(--wcb-surface-2);
1919
+ }
1920
+ .wcb-group-toggle {
1921
+ flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
1922
+ padding: 9px 12px; background: none; border: none; color: inherit;
1923
+ font: inherit; text-align: left; cursor: pointer;
1200
1924
  }
1201
- .wcb-group-head:hover { box-shadow: inset 0 0 0 999px var(--wcb-hover); }
1925
+ .wcb-group-toggle:hover { box-shadow: inset 0 0 0 999px var(--wcb-hover); }
1926
+ .wcb-group-actions { flex: none; display: flex; gap: 6px; align-items: center; }
1927
+ .wcb-group-body { border-top: .5px solid var(--wcb-line); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
1202
1928
  .wcb-chevron { flex: none; color: var(--wcb-text-3); transition: transform .15s ease; }
1203
1929
  .wcb-group[data-open] .wcb-chevron { transform: rotate(90deg); }
1204
1930
  .wcb-group-icon { flex: none; color: var(--wcb-text-2); }
1205
- .wcb-group-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
1206
- .wcb-group-path { flex: 1; min-width: 0; color: var(--wcb-text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
1207
- .wcb-group-count { flex: none; color: var(--wcb-text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
1931
+ .wcb-group-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
1932
+ /* The group overview: labelled facts that wrap instead of hiding behind an ellipsis. */
1933
+ .wcb-group-summary {
1934
+ flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
1935
+ gap: 2px 10px; color: var(--wcb-text-3); font-size: 12px; text-align: right;
1936
+ }
1937
+ .wcb-group-summary .wcb-fact-inline { white-space: nowrap; }
1208
1938
  .wcb-row {
1209
1939
  display: flex; align-items: center; gap: 12px;
1210
1940
  padding: 9px 12px; border-top: .5px solid var(--wcb-line); cursor: pointer;
@@ -1254,20 +1984,139 @@ window.__ModuleLoader__.load({
1254
1984
  }
1255
1985
  .wcb-code { font-family: var(--wcb-mono); font-size: 12px; background: var(--wcb-surface-2); padding: 1px 5px; border-radius: 5px; }
1256
1986
 
1257
- /* Footer */
1258
- .wcb-footer {
1259
- position: sticky; bottom: 12px; z-index: 2;
1260
- display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
1261
- padding: 12px 14px 12px 18px; border-radius: 16px;
1262
- background: color-mix(in srgb, var(--wcb-surface) 88%, transparent);
1987
+ /* Per-section save row: a card saves itself, nothing waits at the bottom. */
1988
+ .wcb-savebar {
1989
+ display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
1990
+ margin-top: 14px; padding-top: 12px; border-top: .5px solid var(--wcb-line);
1991
+ }
1992
+ .wcb-savebar-msg { flex: 1; min-width: 160px; color: var(--wcb-text-2); font-size: 12.5px; }
1993
+ .wcb-savebar-msg[data-tone="error"] { color: var(--wcb-err); }
1994
+ .wcb-savebar-msg[data-tone="success"] { color: var(--wcb-ok); }
1995
+ .wcb-savebar-msg[data-tone="dirty"] { color: var(--wcb-warn); }
1996
+
1997
+ /* Selects and inline text */
1998
+ .wcb-select {
1999
+ min-width: 0; max-width: 100%; height: 32px; padding: 0 8px;
2000
+ border: .5px solid var(--wcb-line-2); border-radius: 8px;
2001
+ background: var(--wcb-surface); color: var(--wcb-text); font: inherit; font-size: 13px;
2002
+ cursor: pointer; appearance: auto;
2003
+ }
2004
+ .wcb-select:disabled { opacity: .55; cursor: not-allowed; }
2005
+ .wcb-muted { color: var(--wcb-text-3); }
2006
+ .wcb-inline-error { color: var(--wcb-err); }
2007
+ .wcb-link {
2008
+ border: none; background: none; padding: 0; cursor: pointer;
2009
+ color: var(--wcb-brand); font: inherit; font-size: 12px; text-decoration: underline;
2010
+ }
2011
+ .wcb-link:disabled { color: var(--wcb-text-3); cursor: not-allowed; text-decoration: none; }
2012
+ .wcb-banner-foot { margin-top: 6px; color: var(--wcb-text-3); font-size: 12px; }
2013
+ .wcb-row-meta-inner { display: inline-flex; align-items: center; gap: 6px; }
2014
+
2015
+ /* Groups and members */
2016
+ /* Name, Workspace, model, effort, preset: the model needs the most room. */
2017
+ .wcb-binding-controls {
2018
+ display: grid; gap: 8px;
2019
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1.6fr) minmax(0, .8fr) minmax(0, 1.25fr);
2020
+ }
2021
+ @media (max-width: 900px) {
2022
+ .wcb-binding-controls { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
2023
+ }
2024
+ .wcb-binding-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
2025
+ .wcb-binding-label { color: var(--wcb-text-3); font-size: 11.5px; }
2026
+ .wcb-members { display: flex; flex-direction: column; gap: 4px; padding: 4px; border: .5px solid var(--wcb-line); border-radius: 10px; }
2027
+ .wcb-member { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; border-radius: 8px; }
2028
+ .wcb-member + .wcb-member { border-top: .5px solid var(--wcb-line); border-top-left-radius: 0; border-top-right-radius: 0; }
2029
+ .wcb-member-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
2030
+
2031
+ /* A person line: the colored badge is the only thing that opens the details. */
2032
+ .wcb-person-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
2033
+ .wcb-person-meta { flex: none; display: flex; align-items: center; gap: 6px; color: var(--wcb-text-3); font-size: 12px; margin-left: auto; }
2034
+ .wcb-avatar {
2035
+ flex: none; position: relative; display: grid; place-items: center;
2036
+ width: 26px; height: 26px; padding: 0; border-radius: 50%;
2037
+ border: .5px solid transparent;
2038
+ }
2039
+ .wcb-avatar[data-kind="user"] { color: #2a6df4; background: color-mix(in srgb, #2a6df4 12%, transparent); }
2040
+ .wcb-avatar[data-kind="group"] { color: #b06f00; background: color-mix(in srgb, #bf8700 18%, transparent); }
2041
+ .wcb-avatar[data-button] { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
2042
+ .wcb-avatar[data-button]:hover:not(:disabled) {
2043
+ transform: translateY(-1px);
2044
+ box-shadow: 0 2px 8px color-mix(in srgb, var(--wcb-text) 22%, transparent);
2045
+ }
2046
+ .wcb-avatar[data-button]:active:not(:disabled) { transform: none; }
2047
+ .wcb-avatar[data-button]:focus-visible { outline: 2px solid var(--wcb-brand); outline-offset: 2px; }
2048
+ .wcb-avatar[data-button]:disabled { cursor: not-allowed; opacity: .5; }
2049
+ /* The pencil badge: "pressing this opens the details form". */
2050
+ .wcb-avatar-pencil {
2051
+ position: absolute; right: -3px; bottom: -3px;
2052
+ width: 13px; height: 13px; border-radius: 50%;
2053
+ display: grid; place-items: center;
2054
+ color: var(--wcb-text-2); background: var(--wcb-surface);
1263
2055
  border: .5px solid var(--wcb-line-2);
1264
- box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
1265
- backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
1266
2056
  }
1267
- .wcb-footer-msg { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; color: var(--wcb-text-2); font-size: 13px; }
1268
- .wcb-footer-msg[data-tone="error"] { color: var(--wcb-err); }
1269
- .wcb-footer-msg[data-tone="success"] { color: var(--wcb-ok); }
1270
- .wcb-footer-msg[data-tone="dirty"] { color: var(--wcb-warn); }
2057
+
2058
+ /* One member, one line: badge, name, the Session's facts, its 归档 action. */
2059
+ .wcb-member-row {
2060
+ display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap;
2061
+ padding: 6px 8px; border-radius: 8px;
2062
+ }
2063
+ .wcb-member-row:hover { background: var(--wcb-hover); }
2064
+ .wcb-member-name {
2065
+ font-weight: 500; white-space: nowrap; overflow: hidden;
2066
+ text-overflow: ellipsis; max-width: 140px;
2067
+ }
2068
+ .wcb-member-facts { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; min-width: 0; flex: 1; }
2069
+ .wcb-fact-inline {
2070
+ display: inline-flex; align-items: center; gap: 5px; min-width: 0;
2071
+ color: var(--wcb-text-2); font-size: 12px;
2072
+ }
2073
+ .wcb-fact-key { color: var(--wcb-text-3); font-size: 11px; }
2074
+ .wcb-fact-strong {
2075
+ color: var(--wcb-text); white-space: nowrap; overflow: hidden;
2076
+ text-overflow: ellipsis; max-width: 170px;
2077
+ }
2078
+ .wcb-member-edit {
2079
+ display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px;
2080
+ align-items: end; padding: 8px 10px; border-radius: 8px; background: var(--wcb-surface-2);
2081
+ }
2082
+ @media (max-width: 820px) { .wcb-member-edit { grid-template-columns: 1fr; } }
2083
+ .wcb-member-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
2084
+
2085
+ /* A picker list inside a dialog: one known person per row. */
2086
+ .wcb-picker-list {
2087
+ display: flex; flex-direction: column; max-height: 300px; overflow: auto;
2088
+ border: .5px solid var(--wcb-line); border-radius: 10px;
2089
+ }
2090
+ .wcb-picker-row {
2091
+ display: flex; align-items: baseline; gap: 10px; width: 100%;
2092
+ padding: 8px 12px; background: none; border: none; border-top: .5px solid var(--wcb-line);
2093
+ color: inherit; font: inherit; text-align: left; cursor: pointer;
2094
+ }
2095
+ .wcb-picker-row:first-child { border-top: none; }
2096
+ .wcb-picker-row:hover { background: var(--wcb-hover); }
2097
+ .wcb-picker-row[data-manual] { border: .5px dashed var(--wcb-line-2); border-radius: 10px; padding: 10px 12px; flex-wrap: wrap; }
2098
+ .wcb-picker-hint { color: var(--wcb-text-3); font-size: 12px; min-width: 0; }
2099
+ .wcb-confirm-body { color: var(--wcb-text-2); font-size: 13px; }
2100
+ .wcb-confirm-body p { margin: 0; }
2101
+
2102
+ /* The person dialog (portalled, so it re-declares the page tokens). */
2103
+ .wcb-modal { padding: 0; }
2104
+ .wcb-modal-content { display: flex; flex-direction: column; gap: 14px; }
2105
+ .wcb-person-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 18px; }
2106
+ .wcb-person-facts + .wcb-hint { margin-top: 0; }
2107
+ /* The session block sits under the identity facts, behind a hairline. */
2108
+ .wcb-dialog-section { border-top: .5px solid var(--wcb-line); padding-top: 14px; }
2109
+ .wcb-dialog-section .wcb-binding-field { margin-top: 12px; }
2110
+ .wcb-fact { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
2111
+ .wcb-fact-key { color: var(--wcb-text-3); font-size: 11.5px; }
2112
+ .wcb-fact-value { min-width: 0; overflow-wrap: anywhere; }
2113
+ .wcb-fact-input { width: 100%; }
2114
+ .wcb-dialog-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
2115
+ .wcb-rejected-text {
2116
+ color: var(--wcb-text-2); font-size: 12.5px; padding: 6px 10px; border-radius: 8px;
2117
+ background: var(--wcb-surface-2); border-left: 2px solid var(--wcb-line-2);
2118
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
2119
+ }
1271
2120
  `
1272
2121
  );
1273
2122
  function insertStyles(doc = document) {