dsh-wecom-bot 0.0.0-stage → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -2
  3. package/cordis.patch.yml +4 -0
  4. package/dist/client.js +1298 -0
  5. package/dist/host/bridge/commands.js +164 -0
  6. package/dist/host/bridge/commands.js.map +1 -0
  7. package/dist/host/bridge/directory.js +79 -0
  8. package/dist/host/bridge/directory.js.map +1 -0
  9. package/dist/host/bridge/format.js +89 -0
  10. package/dist/host/bridge/format.js.map +1 -0
  11. package/dist/host/bridge/inbound.js +81 -0
  12. package/dist/host/bridge/inbound.js.map +1 -0
  13. package/dist/host/bridge/index.js +408 -0
  14. package/dist/host/bridge/index.js.map +1 -0
  15. package/dist/host/bridge/interactions.js +98 -0
  16. package/dist/host/bridge/interactions.js.map +1 -0
  17. package/dist/host/bridge/notices.js +131 -0
  18. package/dist/host/bridge/notices.js.map +1 -0
  19. package/dist/host/bridge/outbox.js +74 -0
  20. package/dist/host/bridge/outbox.js.map +1 -0
  21. package/dist/host/bridge/policy.js +21 -0
  22. package/dist/host/bridge/policy.js.map +1 -0
  23. package/dist/host/bridge/selection.js +18 -0
  24. package/dist/host/bridge/selection.js.map +1 -0
  25. package/dist/host/catalog.js +128 -0
  26. package/dist/host/catalog.js.map +1 -0
  27. package/dist/host/config.js +72 -0
  28. package/dist/host/config.js.map +1 -0
  29. package/dist/host/dsh.js +10 -0
  30. package/dist/host/dsh.js.map +1 -0
  31. package/dist/host/index.js +50 -0
  32. package/dist/host/index.js.map +1 -0
  33. package/dist/host/journal.js +188 -0
  34. package/dist/host/journal.js.map +1 -0
  35. package/dist/host/observation.js +81 -0
  36. package/dist/host/observation.js.map +1 -0
  37. package/dist/host/rounds.js +112 -0
  38. package/dist/host/rounds.js.map +1 -0
  39. package/dist/host/routes.js +30 -0
  40. package/dist/host/routes.js.map +1 -0
  41. package/dist/host/runtime.js +200 -0
  42. package/dist/host/runtime.js.map +1 -0
  43. package/dist/host/status.js +27 -0
  44. package/dist/host/status.js.map +1 -0
  45. package/dist/host/turns.js +89 -0
  46. package/dist/host/turns.js.map +1 -0
  47. package/dist/shared/protocol.js +16 -0
  48. package/dist/shared/protocol.js.map +1 -0
  49. package/icon.svg +14 -0
  50. package/package.json +79 -4
package/dist/client.js ADDED
@@ -0,0 +1,1298 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "dsh-wecom-bot",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ "use strict";
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+
25
+ // src/client/index.tsx
26
+ var index_exports = {};
27
+ __export(index_exports, {
28
+ apply: () => apply,
29
+ inject: () => inject
30
+ });
31
+ module.exports = __toCommonJS(index_exports);
32
+
33
+ // src/shared/protocol.ts
34
+ var PACKAGE_NAME = "dsh-wecom-bot";
35
+ var CONFIG_NAMESPACE = "wecom-bot";
36
+ var DEFAULT_SECRET_REF = "WECOM_BOT_SECRET";
37
+ var STATE_ROUTE = "/api/wecom-bot/state";
38
+
39
+ // 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");
42
+
43
+ // src/client/api.ts
44
+ var STATE_URL = STATE_ROUTE.replace(/^\//, "");
45
+ async function fetchState(refresh, signal) {
46
+ const response = await fetch(`${STATE_URL}${refresh ? "?refresh=1" : ""}`, {
47
+ credentials: "same-origin",
48
+ cache: "no-store",
49
+ ...signal ? { signal } : {}
50
+ });
51
+ if (response.status === 401 || response.status === 403) throw new Error("DSH 登录已失效,请刷新页面。");
52
+ if (response.status === 404) throw new Error("插件后台尚未加载新版本,请重启 DSH 后再试。");
53
+ if (!response.ok) throw new Error(`插件状态读取失败(HTTP ${response.status})。`);
54
+ return await response.json();
55
+ }
56
+ function unwrap(result) {
57
+ if (result && typeof result === "object" && "ok" in result && typeof result.ok === "boolean") {
58
+ const envelope = result;
59
+ if (!envelope.ok) throw new Error(envelope.error?.message ?? "DSH 拒绝了请求");
60
+ return envelope.value;
61
+ }
62
+ return result;
63
+ }
64
+ async function describeCredential(remote, ref) {
65
+ if (!remote) return void 0;
66
+ return unwrap(await remote.describe([ref]))?.[ref];
67
+ }
68
+ async function storeCredential(remote, ref, value) {
69
+ if (!remote) throw new Error("DSH 凭据服务未连接。");
70
+ const result = await remote.set(ref, value);
71
+ if (result !== void 0) unwrap(result);
72
+ }
73
+
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
+ // src/client/model.ts
154
+ var DEFAULTS = {
155
+ botId: "",
156
+ secretEnv: DEFAULT_SECRET_REF,
157
+ chatIds: [],
158
+ sessionIds: [],
159
+ allowedUserIds: [],
160
+ wsUrl: "",
161
+ questionTimeoutMs: 6e4,
162
+ remoteApprovals: false,
163
+ logEnabled: true,
164
+ logRetentionDays: 14
165
+ };
166
+ var LIST_KEYS = ["chatIds", "sessionIds", "allowedUserIds"];
167
+ var SCALAR_KEYS = ["botId", "wsUrl", "questionTimeoutMs", "remoteApprovals", "logEnabled", "logRetentionDays"];
168
+ function list(value) {
169
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
170
+ }
171
+ function storedFrom(value) {
172
+ const v = value ?? {};
173
+ 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,
180
+ questionTimeoutMs: typeof v.questionTimeoutMs === "number" ? v.questionTimeoutMs : DEFAULTS.questionTimeoutMs,
181
+ remoteApprovals: v.remoteApprovals === true,
182
+ logEnabled: v.logEnabled !== false,
183
+ logRetentionDays: typeof v.logRetentionDays === "number" ? v.logRetentionDays : DEFAULTS.logRetentionDays
184
+ };
185
+ }
186
+ function draftFrom(stored) {
187
+ return { ...stored, chatIds: [...stored.chatIds], sessionIds: [...stored.sessionIds], allowedUserIds: [...stored.allowedUserIds], secret: "" };
188
+ }
189
+ function normalizedList(values) {
190
+ return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
191
+ }
192
+ function sameList(a, b) {
193
+ const left = normalizedList(a);
194
+ const right = normalizedList(b);
195
+ return left.length === right.length && left.every((item) => right.includes(item));
196
+ }
197
+ function normalizedScalar(key, draft) {
198
+ const value = draft[key];
199
+ return typeof value === "string" ? value.trim() : value;
200
+ }
201
+ function changedOperations(draft, base) {
202
+ const ops = [];
203
+ for (const key of SCALAR_KEYS) {
204
+ const next = normalizedScalar(key, draft);
205
+ if (next !== normalizedScalar(key, base)) ops.push({ op: "set", path: [key], value: next });
206
+ }
207
+ for (const key of LIST_KEYS) {
208
+ if (!sameList(draft[key], base[key])) ops.push({ op: "set", path: [key], value: normalizedList(draft[key]) });
209
+ }
210
+ return ops;
211
+ }
212
+ function isDirty(draft, base) {
213
+ return Boolean(draft.secret.trim()) || changedOperations(draft, base).length > 0;
214
+ }
215
+ function validate(draft, secretConfigured) {
216
+ const errors = {};
217
+ if (!draft.botId.trim()) errors.botId = "请填写企业微信 Bot ID。";
218
+ if (!draft.secret.trim() && !secretConfigured) errors.secret = "首次配置需要填写 Bot Secret。";
219
+ const wsUrl = draft.wsUrl.trim();
220
+ if (wsUrl) {
221
+ try {
222
+ const url = new URL(wsUrl);
223
+ if (url.protocol !== "wss:" || url.username || url.password) errors.wsUrl = "只接受不含账号密码的 wss:// 地址。";
224
+ } catch {
225
+ errors.wsUrl = "不是有效的 URL。";
226
+ }
227
+ }
228
+ if (!Number.isFinite(draft.questionTimeoutMs) || draft.questionTimeoutMs < 1e3 || draft.questionTimeoutMs > 3e5) {
229
+ errors.questionTimeoutMs = "请输入 1–300 秒。";
230
+ }
231
+ if (!Number.isInteger(draft.logRetentionDays) || draft.logRetentionDays < 1 || draft.logRetentionDays > 365) {
232
+ errors.logRetentionDays = "请输入 1–365 的整数天数。";
233
+ }
234
+ return errors;
235
+ }
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
+ function toggle(values, id, on) {
244
+ const has = values.includes(id);
245
+ const want = on ?? !has;
246
+ if (want === has) return [...values];
247
+ return want ? [...values, id] : values.filter((value) => value !== id);
248
+ }
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));
253
+ }
254
+ function matches(session, group, needle) {
255
+ return [session.title ?? "", session.sessionId, group.title, group.path ?? ""].some((text) => text.toLowerCase().includes(needle));
256
+ }
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);
263
+ }
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;
269
+ }
270
+ function displayPath(path) {
271
+ return (path ?? "").replace(/^(\/Users|\/home)\/[^/]+(?=\/|$)/, "~").replace(/^[A-Za-z]:\\Users\\[^\\]+(?=\\|$)/, "~");
272
+ }
273
+ function relativeTime(at, now = Date.now()) {
274
+ if (!at) return "";
275
+ const diff = Math.max(0, now - at);
276
+ if (diff < 6e4) return "刚刚";
277
+ if (diff < 36e5) return `${Math.floor(diff / 6e4)} 分钟前`;
278
+ if (diff < 864e5) return `${Math.floor(diff / 36e5)} 小时前`;
279
+ if (diff < 30 * 864e5) return `${Math.floor(diff / 864e5)} 天前`;
280
+ return new Date(at).toLocaleDateString();
281
+ }
282
+
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
+ ] });
317
+ }
318
+
319
+ // src/client/components/AdvancedCard.tsx
320
+ var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
321
+ var import_react2 = require("react");
322
+
323
+ // 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");
326
+ 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 }),
329
+ props.children
330
+ ] });
331
+ }
332
+ 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 })
338
+ ] }),
339
+ aside && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-card-aside", children: aside })
340
+ ] });
341
+ }
342
+ 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: [
345
+ label,
346
+ required && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-required", "aria-label": "必填", children: "*" })
347
+ ] }),
348
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-field-control", children: [
349
+ 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 })
351
+ ] })
352
+ ] });
353
+ }
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: "未限制 · 全部允许" });
359
+ }
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: [
362
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
363
+ "input",
364
+ {
365
+ type: "checkbox",
366
+ className: "wcb-check",
367
+ checked,
368
+ disabled,
369
+ "aria-label": label,
370
+ onChange: (event) => onToggle(event.target.checked)
371
+ }
372
+ ),
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 })
375
+ ] });
376
+ }
377
+ function Empty({ children }) {
378
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-empty", children });
379
+ }
380
+
381
+ // src/client/components/AdvancedCard.tsx
382
+ 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);
385
+ const copy = async () => {
386
+ if (!journal?.directory) return;
387
+ setCopied(await (0, import_dsh_client_ui_primitives3.writeClipboard)(journal.directory));
388
+ setTimeout(() => setCopied(false), 1500);
389
+ };
390
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("details", { className: "wcb-card wcb-details", children: [
391
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("summary", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
392
+ CardHead,
393
+ {
394
+ step: 4,
395
+ title: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
396
+ "高级设置 ",
397
+ draft.remoteApprovals && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Tag, { tone: "warning", children: "远程审批已开启" })
398
+ ] }),
399
+ description: "远程审批、等待时间、自定义连接地址与对话日志。均可保持默认。",
400
+ aside: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "wcb-chevron", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.IconChevronRightOutlineRegular, { size: 16 }) })
401
+ }
402
+ ) }),
403
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
404
+ Field,
405
+ {
406
+ label: "远程审批工具调用",
407
+ hint: "开启后,DSH 请求执行工具时会向已允许用户的单聊发送带验证码的审批消息,回复 /approve 或 /deny 即生效;群聊永远不能审批。不需要时请保持关闭。",
408
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
409
+ import_dsh_client_ui_primitives3.Switch,
410
+ {
411
+ checked: draft.remoteApprovals,
412
+ disabled,
413
+ label: "远程审批工具调用",
414
+ onChange: (next) => onChange({ remoteApprovals: next })
415
+ }
416
+ )
417
+ }
418
+ ),
419
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
420
+ Field,
421
+ {
422
+ label: "等待企微回复(秒)",
423
+ error: errors.questionTimeoutMs,
424
+ hint: "DSH 提问或审批时,先等待企业微信回复的时间;超时后回到 DSH 页面处理。",
425
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
426
+ import_dsh_client_ui_primitives3.Input,
427
+ {
428
+ className: "wcb-number",
429
+ type: "number",
430
+ min: 1,
431
+ max: 300,
432
+ step: 1,
433
+ value: Math.round(draft.questionTimeoutMs / 1e3),
434
+ disabled,
435
+ "aria-label": "等待企微回复的秒数",
436
+ onChange: (event) => onChange({ questionTimeoutMs: Number(event.target.value) * 1e3 })
437
+ }
438
+ )
439
+ }
440
+ ),
441
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "WebSocket 地址", error: errors.wsUrl, hint: "留空使用 SDK 默认地址。仅在企业私有化部署时需要,只接受 wss://。", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
442
+ import_dsh_client_ui_primitives3.Input,
443
+ {
444
+ className: "wcb-grow",
445
+ value: draft.wsUrl,
446
+ placeholder: "wss://openws.work.weixin.qq.com",
447
+ spellCheck: false,
448
+ disabled,
449
+ "aria-label": "WebSocket 地址",
450
+ onChange: (event) => onChange({ wsUrl: event.target.value })
451
+ }
452
+ ) }),
453
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
454
+ Field,
455
+ {
456
+ label: "对话日志(JSONL)",
457
+ hint: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
458
+ "每条企微消息一行 ",
459
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "wcb-code", children: "round.complete" }),
460
+ ",含原始请求、回复与元数据;另有 ",
461
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "wcb-code", children: "wecom.message" }),
462
+ "、",
463
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "wcb-code", children: "dsh.prompt" }),
464
+ "、",
465
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "wcb-code", children: "dsh.turn.end" }),
466
+ "、",
467
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "wcb-code", children: "wecom.send" }),
468
+ " 等明细行。Secret、回调 URL 与媒体密钥会被脱敏;文件权限仅当前用户可读。"
469
+ ] }),
470
+ children: [
471
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "wcb-field-row", children: [
472
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
473
+ import_dsh_client_ui_primitives3.Switch,
474
+ {
475
+ checked: draft.logEnabled,
476
+ disabled,
477
+ label: "记录对话日志",
478
+ onChange: (next) => onChange({ logEnabled: next })
479
+ }
480
+ ),
481
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "var(--wcb-text-2)", fontSize: 13 }, children: "保留" }),
482
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
483
+ import_dsh_client_ui_primitives3.Input,
484
+ {
485
+ className: "wcb-number",
486
+ type: "number",
487
+ min: 1,
488
+ max: 365,
489
+ step: 1,
490
+ value: draft.logRetentionDays,
491
+ disabled: disabled || !draft.logEnabled,
492
+ "aria-label": "日志保留天数",
493
+ onChange: (event) => onChange({ logRetentionDays: Number(event.target.value) })
494
+ }
495
+ ),
496
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "var(--wcb-text-2)", fontSize: 13 }, children: "天" })
497
+ ] }),
498
+ errors.logRetentionDays && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "wcb-field-error", children: errors.logRetentionDays }),
499
+ journal?.directory && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "wcb-field-row", style: { marginTop: 10 }, children: [
500
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "wcb-path wcb-grow", title: journal.file, children: journal.directory }),
501
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { variant: "ghost", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.IconCopyOutlineRegular, {}), onClick: () => {
502
+ void copy();
503
+ }, children: copied ? "已复制" : "复制路径" })
504
+ ] })
505
+ ]
506
+ }
507
+ )
508
+ ] });
509
+ }
510
+
511
+ // src/client/components/CredentialsCard.tsx
512
+ var import_react3 = require("react");
513
+ var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
514
+ 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()));
518
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
519
+ Card,
520
+ {
521
+ step: 1,
522
+ title: "连接机器人",
523
+ description: "在企业微信管理后台 → 智能机器人 → API 模式(长连接)中获取。这是仅有的两项必填配置。",
524
+ aside: ready ? /* @__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: "danger", children: "必填" }),
525
+ children: [
526
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Field, { label: "Bot ID", required: true, error: errors.botId, hint: "机器人的唯一标识,可公开显示。", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
527
+ import_dsh_client_ui_primitives4.Input,
528
+ {
529
+ className: "wcb-grow",
530
+ value: draft.botId,
531
+ placeholder: "例如 aib0xxxxxxxxxxxx",
532
+ spellCheck: false,
533
+ autoComplete: "off",
534
+ disabled,
535
+ "aria-label": "Bot ID",
536
+ onChange: (event) => onChange({ botId: event.target.value })
537
+ }
538
+ ) }),
539
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
540
+ Field,
541
+ {
542
+ label: "Bot Secret",
543
+ required: !secretConfigured,
544
+ error: errors.secret,
545
+ hint: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
546
+ "保存到 DSH 凭据库(引用名 ",
547
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "wcb-code", children: draft.secretEnv }),
548
+ "),不会写入插件配置,也不会回显。",
549
+ secretConfigured ? "留空表示保持当前 Secret。" : ""
550
+ ] }),
551
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "wcb-field-row", children: [
552
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
553
+ import_dsh_client_ui_primitives4.Input,
554
+ {
555
+ className: "wcb-grow",
556
+ type: reveal ? "text" : "password",
557
+ value: draft.secret,
558
+ placeholder: secretConfigured ? "已保存 · 输入新值以替换" : "粘贴 Bot Secret",
559
+ autoComplete: "new-password",
560
+ spellCheck: false,
561
+ disabled,
562
+ "aria-label": "Bot Secret",
563
+ onChange: (event) => onChange({ secret: event.target.value })
564
+ }
565
+ ),
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: "未设置" })
568
+ ] })
569
+ }
570
+ )
571
+ ]
572
+ }
573
+ );
574
+ }
575
+
576
+ // src/client/components/IdentityPicker.tsx
577
+ var import_react4 = require("react");
578
+ var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
579
+ 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;
587
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
588
+ Card,
589
+ {
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,
597
+ 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
+ )
627
+ ] }),
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
+ ] })
636
+ ]
637
+ }
638
+ );
639
+ }
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("");
648
+ };
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 }) })
655
+ ] }),
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
+ ] })
699
+ ] })
700
+ ] });
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,
738
+ {
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,
747
+ {
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)
754
+ }
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,
781
+ {
782
+ variant: "ghost",
783
+ size: "sm",
784
+ disabled,
785
+ onClick: () => onChange(setAll(selected, catalog.hiddenSelections.map((item) => item.sessionId), false)),
786
+ children: "全部移除"
787
+ }
788
+ )
789
+ ] }),
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
+ " 个会话"
813
+ ] }),
814
+ catalog.archived > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
815
+ "已隐藏 ",
816
+ catalog.archived,
817
+ " 个已归档会话"
818
+ ] }),
819
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
820
+ "更新于 ",
821
+ relativeTime(catalog.generatedAt)
822
+ ] })
823
+ ] })
824
+ ]
825
+ }
826
+ );
827
+ }
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",
834
+ {
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();
844
+ },
845
+ 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
868
+ ] })
869
+ ]
870
+ }
871
+ ),
872
+ open && group.sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
873
+ CheckRow,
874
+ {
875
+ checked: selected.has(session.sessionId),
876
+ label: `选择会话 ${session.title ?? session.sessionId}`,
877
+ 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
+ ] }),
887
+ 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 })
890
+ ]
891
+ },
892
+ session.sessionId
893
+ ))
894
+ ] });
895
+ }
896
+
897
+ // src/client/components/StatusHeader.tsx
898
+ var import_dsh_client_ui_primitives7 = require("@deepseek-ai/dsh-client-ui-primitives");
899
+ var import_jsx_runtime7 = require("react/jsx-runtime");
900
+ var PHASES = {
901
+ unconfigured: { label: "未配置", tone: "idle", dot: "idle" },
902
+ invalid: { label: "配置无效", tone: "err", dot: "error" },
903
+ connecting: { label: "连接中", tone: "warn", dot: "ongoing" },
904
+ online: { label: "在线", tone: "ok", dot: "done" },
905
+ reconnecting: { label: "重连中", tone: "warn", dot: "ongoing" },
906
+ offline: { label: "已断开", tone: "warn", dot: "warning" },
907
+ displaced: { label: "被其他连接替换", tone: "err", dot: "error" },
908
+ error: { label: "连接错误", tone: "err", dot: "error" }
909
+ };
910
+ function StatusHeader({ state, error }) {
911
+ const phase = state ? PHASES[state.connection.phase] ?? PHASES.error : void 0;
912
+ const traffic = state?.traffic;
913
+ const detail = error ?? state?.connection.detail;
914
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("header", { className: "wcb-hero", children: [
915
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "wcb-hero-mark", "aria-hidden": "true", children: "企" }),
916
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "wcb-hero-text", children: [
917
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "wcb-hero-title", children: "企业微信机器人" }),
918
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "wcb-hero-sub", children: "在企业微信里接收 DSH 的完成通知与提问,直接回复即可继续对应会话。" })
919
+ ] }),
920
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "wcb-hero-status", children: [
921
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "wcb-pill", "data-tone": error ? "err" : phase?.tone ?? "idle", role: "status", children: [
922
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives7.StateDot, { state: error ? "error" : phase?.dot ?? "ongoing" }),
923
+ error ? "状态不可用" : phase ? phase.label : "读取状态…",
924
+ state && !error && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { style: { fontWeight: 400, opacity: 0.75 }, children: [
925
+ "· ",
926
+ relativeTime(state.connection.since)
927
+ ] })
928
+ ] }),
929
+ detail && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "wcb-status-detail", children: detail })
930
+ ] }),
931
+ traffic && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "wcb-stats", "aria-label": "本次 DSH 启动以来的统计", children: [
932
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Stat, { value: traffic.received, label: `收到消息${traffic.lastMessageAt ? ` · ${relativeTime(traffic.lastMessageAt)}` : ""}` }),
933
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Stat, { value: traffic.rejected, label: "已拒绝" }),
934
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Stat, { value: traffic.prompts, label: "提交到 DSH" }),
935
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Stat, { value: traffic.notifications, label: "推送通知" })
936
+ ] })
937
+ ] });
938
+ }
939
+ function Stat({ value, label }) {
940
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "wcb-stat", children: [
941
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "wcb-stat-value", children: value }),
942
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "wcb-stat-label", children: label })
943
+ ] });
944
+ }
945
+
946
+ // src/client/components/SettingsPage.tsx
947
+ var import_jsx_runtime8 = require("react/jsx-runtime");
948
+ function SettingsPage({ scope, remote }) {
949
+ const snapshot = useFormSnapshot(scope);
950
+ if (snapshot.status !== "ready") {
951
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "wcb-page", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "wcb-card", children: snapshot.status === "loading" ? "正在加载插件配置…" : "插件配置暂不可用:请确认插件已启用。" }) });
952
+ }
953
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SettingsEditor, { snapshot, scope, remote });
954
+ }
955
+ 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);
961
+ const bridge = useBridgeState();
962
+ const secret = useSecretStatus(remote, base.secretEnv);
963
+ 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: "所有更改均已保存。" };
1007
+ 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
+ ),
1020
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1021
+ SessionPicker,
1022
+ {
1023
+ catalog: bridge.data?.sessions,
1024
+ error: bridge.data?.sessionsError ?? bridge.error,
1025
+ loading: bridge.loading,
1026
+ refreshing: bridge.refreshing,
1027
+ selected: draft.sessionIds,
1028
+ disabled: !writable || busy,
1029
+ onChange: (sessionIds) => update({ sessionIds }),
1030
+ onRefresh: () => bridge.refresh(true)
1031
+ }
1032
+ ),
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
+ ] })
1065
+ ] });
1066
+ }
1067
+
1068
+ // src/client/styles.ts
1069
+ var STYLES = (
1070
+ /* css */
1071
+ `
1072
+ .wcb-page {
1073
+ /* DSH is monochrome; the business blue is its accent for focus and info. */
1074
+ --wcb-brand: var(--dsw-alias-state-business-primary, #4176e6);
1075
+ --wcb-text: var(--dsw-alias-label-primary, #0f1115);
1076
+ --wcb-text-2: var(--dsw-alias-label-secondary, #61666b);
1077
+ --wcb-text-3: var(--dsw-alias-label-tertiary, #81858c);
1078
+ --wcb-surface: var(--dsw-alias-bg-layer-1, #fff);
1079
+ --wcb-surface-2: var(--dsw-alias-bg-module-platform, #f5f6f7);
1080
+ --wcb-line: var(--dsw-alias-border-l2, rgba(0,0,0,.1));
1081
+ --wcb-line-2: var(--dsw-alias-border-l3, rgba(0,0,0,.12));
1082
+ --wcb-ok: var(--dsw-alias-state-success-primary, #1a7f37);
1083
+ --wcb-warn: var(--dsw-alias-state-warn-primary, #bf8700);
1084
+ --wcb-err: var(--dsw-alias-state-error-primary, #cf222e);
1085
+ --wcb-hover: var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,.08));
1086
+ --wcb-mono: var(--dsw-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
1087
+ box-sizing: border-box;
1088
+ display: flex;
1089
+ flex-direction: column;
1090
+ gap: 16px;
1091
+ max-width: 960px;
1092
+ margin: 0 auto;
1093
+ padding: 4px 0 24px;
1094
+ color: var(--wcb-text);
1095
+ font-size: 14px;
1096
+ line-height: 1.5;
1097
+ }
1098
+ .wcb-page *, .wcb-page *::before, .wcb-page *::after { box-sizing: border-box; }
1099
+
1100
+ /* Hero */
1101
+ .wcb-hero {
1102
+ display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
1103
+ padding: 20px 22px; border-radius: 16px;
1104
+ border: .5px solid var(--wcb-line);
1105
+ background:
1106
+ radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--wcb-brand) 14%, transparent), transparent 60%),
1107
+ var(--wcb-surface);
1108
+ }
1109
+ .wcb-hero-mark {
1110
+ flex: none; width: 46px; height: 46px; border-radius: 14px;
1111
+ display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px;
1112
+ background: linear-gradient(135deg, #2f9bff, #2a6df4);
1113
+ box-shadow: 0 6px 18px color-mix(in srgb, #2a6df4 35%, transparent);
1114
+ }
1115
+ .wcb-hero-text { flex: 1; min-width: 220px; }
1116
+ .wcb-hero-title { font-size: 18px; font-weight: 650; letter-spacing: .2px; }
1117
+ .wcb-hero-sub { color: var(--wcb-text-2); font-size: 13px; margin-top: 2px; }
1118
+ .wcb-hero-status { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
1119
+ .wcb-pill {
1120
+ display: inline-flex; align-items: center; gap: 8px;
1121
+ padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 550;
1122
+ background: var(--wcb-surface-2); border: .5px solid var(--wcb-line);
1123
+ }
1124
+ .wcb-pill[data-tone="ok"] { color: var(--wcb-ok); background: color-mix(in srgb, var(--wcb-ok) 10%, transparent); }
1125
+ .wcb-pill[data-tone="warn"] { color: var(--wcb-warn); background: color-mix(in srgb, var(--wcb-warn) 12%, transparent); }
1126
+ .wcb-pill[data-tone="err"] { color: var(--wcb-err); background: color-mix(in srgb, var(--wcb-err) 10%, transparent); }
1127
+ .wcb-status-detail { color: var(--wcb-text-3); font-size: 12px; max-width: 320px; text-align: right; }
1128
+ .wcb-stats {
1129
+ display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
1130
+ width: 100%; margin-top: 4px; border-radius: 12px; overflow: hidden;
1131
+ background: var(--wcb-line); border: .5px solid var(--wcb-line);
1132
+ }
1133
+ .wcb-stat { background: var(--wcb-surface); padding: 10px 14px; }
1134
+ .wcb-stat-value { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
1135
+ .wcb-stat-label { color: var(--wcb-text-3); font-size: 12px; }
1136
+
1137
+ /* Banner */
1138
+ .wcb-banner {
1139
+ display: flex; gap: 12px; align-items: flex-start;
1140
+ padding: 14px 16px; border-radius: 14px; border: .5px solid var(--wcb-line);
1141
+ }
1142
+ .wcb-banner[data-tone="danger"] { border-color: color-mix(in srgb, var(--wcb-err) 40%, transparent); background: color-mix(in srgb, var(--wcb-err) 7%, var(--wcb-surface)); }
1143
+ .wcb-banner[data-tone="warning"] { border-color: color-mix(in srgb, var(--wcb-warn) 40%, transparent); background: color-mix(in srgb, var(--wcb-warn) 8%, var(--wcb-surface)); }
1144
+ .wcb-banner[data-tone="success"] { border-color: color-mix(in srgb, var(--wcb-ok) 35%, transparent); background: color-mix(in srgb, var(--wcb-ok) 6%, var(--wcb-surface)); }
1145
+ .wcb-banner-icon { flex: none; margin-top: 2px; }
1146
+ .wcb-banner[data-tone="danger"] .wcb-banner-icon { color: var(--wcb-err); }
1147
+ .wcb-banner[data-tone="warning"] .wcb-banner-icon { color: var(--wcb-warn); }
1148
+ .wcb-banner[data-tone="success"] .wcb-banner-icon { color: var(--wcb-ok); }
1149
+ .wcb-banner-title { font-weight: 650; }
1150
+ .wcb-banner-body { color: var(--wcb-text-2); font-size: 13px; margin-top: 4px; }
1151
+ .wcb-banner-body ol, .wcb-banner-body ul { margin: 6px 0 0; padding-left: 20px; }
1152
+ .wcb-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
1153
+
1154
+ /* Cards */
1155
+ .wcb-card {
1156
+ background: var(--wcb-surface); border: .5px solid var(--wcb-line);
1157
+ border-radius: 16px; padding: 18px 20px;
1158
+ }
1159
+ .wcb-card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
1160
+ .wcb-step {
1161
+ flex: none; width: 26px; height: 26px; border-radius: 50%;
1162
+ display: grid; place-items: center; font-size: 12px; font-weight: 700;
1163
+ color: var(--wcb-brand); background: color-mix(in srgb, var(--wcb-brand) 13%, transparent);
1164
+ }
1165
+ .wcb-card-titles { flex: 1; min-width: 0; }
1166
+ .wcb-card-title { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
1167
+ .wcb-card-desc { color: var(--wcb-text-2); font-size: 12.5px; margin-top: 2px; }
1168
+ .wcb-card-aside { flex: none; display: flex; gap: 6px; align-items: center; }
1169
+
1170
+ /* Fields */
1171
+ .wcb-field {
1172
+ display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 4px 18px;
1173
+ padding: 12px 0; border-top: .5px solid var(--wcb-line);
1174
+ }
1175
+ .wcb-field:first-child { border-top: none; padding-top: 2px; }
1176
+ .wcb-field-label { font-weight: 550; padding-top: 6px; }
1177
+ .wcb-required { color: var(--wcb-err); margin-left: 2px; }
1178
+ .wcb-field-control { min-width: 0; }
1179
+ .wcb-field-row { display: flex; gap: 8px; align-items: center; }
1180
+ .wcb-grow { flex: 1; min-width: 0; width: 100%; }
1181
+ .wcb-hint { color: var(--wcb-text-3); font-size: 12px; margin-top: 6px; }
1182
+ .wcb-field-error { color: var(--wcb-err); font-size: 12px; margin-top: 6px; }
1183
+ .wcb-field[data-invalid] .wcb-grow { border-color: var(--wcb-err); }
1184
+ .wcb-number { width: 120px; }
1185
+ @media (max-width: 720px) {
1186
+ .wcb-field { grid-template-columns: 1fr; }
1187
+ .wcb-field-label { padding-top: 0; }
1188
+ .wcb-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1189
+ }
1190
+
1191
+ /* Lists */
1192
+ .wcb-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
1193
+ .wcb-toolbar .wcb-search { flex: 1; min-width: 220px; }
1194
+ .wcb-scroll { max-height: 460px; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 1px; }
1195
+ .wcb-group { border: .5px solid var(--wcb-line); border-radius: 12px; overflow: hidden; background: var(--wcb-surface); }
1196
+ .wcb-group-head {
1197
+ 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;
1200
+ }
1201
+ .wcb-group-head:hover { box-shadow: inset 0 0 0 999px var(--wcb-hover); }
1202
+ .wcb-chevron { flex: none; color: var(--wcb-text-3); transition: transform .15s ease; }
1203
+ .wcb-group[data-open] .wcb-chevron { transform: rotate(90deg); }
1204
+ .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; }
1208
+ .wcb-row {
1209
+ display: flex; align-items: center; gap: 12px;
1210
+ padding: 9px 12px; border-top: .5px solid var(--wcb-line); cursor: pointer;
1211
+ }
1212
+ .wcb-row:hover { background: var(--wcb-hover); }
1213
+ .wcb-row[data-selected] { background: color-mix(in srgb, var(--wcb-brand) 7%, transparent); }
1214
+ .wcb-check { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--wcb-brand); cursor: pointer; }
1215
+ .wcb-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
1216
+ .wcb-row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
1217
+ .wcb-row-title[data-muted] { color: var(--wcb-text-3); font-weight: 400; font-style: italic; }
1218
+ .wcb-row-sub { display: flex; gap: 8px; align-items: center; color: var(--wcb-text-3); font-size: 12px; min-width: 0; }
1219
+ .wcb-mono { font-family: var(--wcb-mono); font-size: 11.5px; }
1220
+ .wcb-ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
1221
+ .wcb-row-meta { flex: none; display: flex; gap: 6px; align-items: center; color: var(--wcb-text-3); font-size: 12px; }
1222
+ .wcb-running { display: inline-flex; align-items: center; gap: 4px; color: var(--wcb-text-2); }
1223
+ .wcb-pin { color: var(--wcb-brand); display: inline-flex; }
1224
+ .wcb-list-foot { color: var(--wcb-text-3); font-size: 12px; margin-top: 10px; display: flex; gap: 12px; flex-wrap: wrap; }
1225
+ .wcb-empty {
1226
+ padding: 22px 18px; border-radius: 12px; text-align: center;
1227
+ border: 1px dashed var(--wcb-line-2); color: var(--wcb-text-2); font-size: 13px;
1228
+ }
1229
+ .wcb-empty ol { display: inline-block; text-align: left; margin: 8px 0 0; padding-left: 20px; color: var(--wcb-text-3); }
1230
+ .wcb-hidden-list { margin-top: 12px; border: .5px dashed color-mix(in srgb, var(--wcb-warn) 50%, transparent); border-radius: 12px; padding: 4px 0; }
1231
+ .wcb-hidden-head { padding: 6px 12px; font-size: 12.5px; color: var(--wcb-warn); font-weight: 600; display: flex; align-items: center; gap: 8px; }
1232
+
1233
+ /* Identities */
1234
+ .wcb-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
1235
+ @media (max-width: 820px) { .wcb-columns { grid-template-columns: 1fr; } }
1236
+ .wcb-subhead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
1237
+ .wcb-subhead-title { font-weight: 600; }
1238
+ .wcb-subhead-hint { color: var(--wcb-text-3); font-size: 12px; }
1239
+ .wcb-subhead .wcb-card-aside { margin-left: auto; }
1240
+ .wcb-panel { border: .5px solid var(--wcb-line); border-radius: 12px; overflow: hidden; }
1241
+ .wcb-panel .wcb-row:first-child { border-top: none; }
1242
+ .wcb-panel-scroll { max-height: 320px; overflow: auto; }
1243
+ .wcb-add { display: flex; gap: 8px; padding: 10px 12px; border-top: .5px solid var(--wcb-line); background: var(--wcb-surface-2); }
1244
+
1245
+ /* Advanced */
1246
+ .wcb-details > summary { list-style: none; cursor: pointer; }
1247
+ .wcb-details > summary::-webkit-details-marker { display: none; }
1248
+ .wcb-details > summary .wcb-card-head { margin-bottom: 0; }
1249
+ .wcb-details[open] > summary .wcb-card-head { margin-bottom: 14px; }
1250
+ .wcb-details[open] > summary .wcb-chevron { transform: rotate(90deg); }
1251
+ .wcb-path {
1252
+ font-family: var(--wcb-mono); font-size: 12px; padding: 7px 10px; border-radius: 8px;
1253
+ background: var(--wcb-surface-2); border: .5px solid var(--wcb-line); word-break: break-all;
1254
+ }
1255
+ .wcb-code { font-family: var(--wcb-mono); font-size: 12px; background: var(--wcb-surface-2); padding: 1px 5px; border-radius: 5px; }
1256
+
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);
1263
+ 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
+ }
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); }
1271
+ `
1272
+ );
1273
+ function insertStyles(doc = document) {
1274
+ const element = doc.createElement("style");
1275
+ element.setAttribute("data-dsh-plugin", "wecom-bot");
1276
+ element.textContent = STYLES;
1277
+ doc.head.appendChild(element);
1278
+ return () => element.remove();
1279
+ }
1280
+
1281
+ // src/client/index.tsx
1282
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1283
+ var inject = ["slots", "configForms", "remote", "remote.credentials"];
1284
+ function apply(ctx) {
1285
+ const slots = ctx.get("slots");
1286
+ const forms = ctx.get("configForms");
1287
+ const remote = ctx.get("remote");
1288
+ if (!slots || !forms) return;
1289
+ ctx.effect(() => insertStyles(), "wecom-bot: styles");
1290
+ ctx.effect(() => forms.whileServed([CONFIG_NAMESPACE], () => slots.inject("plugins.bundle.config", () => slots.register(
1291
+ { name: "plugins.bundle.config", key: PACKAGE_NAME },
1292
+ ({ view }) => view === "page" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SettingsPage, { scope: forms.get(CONFIG_NAMESPACE), remote }) : null
1293
+ ))), "wecom-bot: plugin homepage");
1294
+ }
1295
+
1296
+ return module.exports;
1297
+ }
1298
+ });