@ericality/dsh-notice-banner 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js ADDED
@@ -0,0 +1,1928 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@ericality/dsh-notice-banner",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ var React = require("react");
7
+
8
+ // =====================================================================
9
+ // DSH 通知横幅 (dsh-notice-banner)
10
+ //
11
+ // 渲染服务端注入的 notice/banner 会话事件 (由 dsh-notify / dsh-cost-guard
12
+ // / dsh-taskqueue / dsh-balance append, 非 surface 事件 → 不进入模型历史):
13
+ // { kind, title, lines, stats, kv, metaText, advice, time, ... }
14
+ // 家族色板 (同家族同色同款, v0.3.0 起):
15
+ // 费用提醒(kind=cost) → 琥珀 💰 dsh-cost-guard
16
+ // 任务完成(kind=notify) → 绿色 ✅ dsh-notify
17
+ // 队列入队(kind=queue) → 蓝色 📋 dsh-taskqueue
18
+ // 余额费用(kind=balance) → 紫色 💳 dsh-balance (/balance /balance-detail /cost)
19
+ // 错误提示(kind=error) → 红色 ⚠️ 各命令失败/无数据
20
+ // 会话账本(kind=ledger) → 青绿 🧾 dsh-cost-ledger (v0.6.0)
21
+ // 多会话费用(kind=costs) → 天蓝 📊 dsh-sessions-cost (/sessions-cost, v0.6.2 起; v0.8.0 玫红→天蓝)
22
+ // balance 家族额外渲染 stats 统计格 + kv 键值行 (结构化运算结果)。
23
+ //
24
+ // 演进 (功能要点, 供维护者速览):
25
+ // v0.11.1: ledger 折叠行精简 = 「含树合计」+ 差值 — 折叠态去副题小字 (会话id/档位/
26
+ // 命中率, 展开态恢复); 主数字 = 第1格本会话合计 + 第4格「含子 agent」子树合计
27
+ // (账本口径, 不双计), 有子 agent 时套淡青绿胶囊底 (无文字标识, --dsh-lk-* 深浅两态),
28
+ // 无子会话 = 仅本会话合计 (观感同旧); 差值 = 第2格「本回合」较上次 (自身口径, 次级色
29
+ // 弱化); 数据 = payload stats (服务端已含, 零改动), 解析失败降级叶子形态。
30
+ // v0.11.0: 多 agent 树聚合 GUI — ledger 卡新增可折叠「委托树」区 (LedgerTree):
31
+ // 经 /cost-ledger RPC history { sessionId, includeDescendants:true } 拉取子树
32
+ // (行级明细 = 服务端 subtree.rows, 客户端零计算; RPC 失败/无 subtree → 不渲染);
33
+ // costs 卡树形分组渲染 (SessionTreeList): 服务端 sessions[] 附 treeGroup/
34
+ // windowTreeTotal (父行展开 = 自身明细 + 缩进子树折叠块, 递归孙行; 无 → 平铺)。
35
+ // v0.8.0 (液态玻璃 v2): 全家族配色定稿 — costs 玫红→天蓝 (与 queue 蓝区分);
36
+ // balance/ledger soft 色调浅色主题对比度; 边框家族色 alpha 50%→25%, 圆角 10→12,
37
+ // 内边距加宽; 玻璃拟态 (backdrop-filter blur + hover 柔和投影); 浅色主题白色渐变 +
38
+ // 家族顶部着色; 已取消标签改灰; 按钮引入 primary/success/danger 变体。
39
+ // 实现: 内联样式保持液态渐变; INJECTED_CSS (style 元素) 承载主题翻转/CSS 变量/
40
+ // hover/浅色家族着色。
41
+ // v0.6.1 (已回退): 曾试叠加主题底色+投影适配浅色壁纸, 因消息列高斯模糊图层已解决
42
+ // 文字可读性而回退, 恢复纯 liquid 渐变样式。
43
+ // v0.6.0: ledger 会话账本家族 — 回合结束自动记账, 每回合一张新卡 (独立 context
44
+ // ledger-<seq>), 默认折叠 (折叠行 = 合计+差值); 展开经 /cost-ledger RPC 实时拉取
45
+ // 共享账本, 任何旧卡片点开都与最新一致; 历史区默认 3 条 + 展开全部。
46
+ // v0.5.2: 队列面板编辑锁 — startEdit 经 RPC editstart 锁定任务 (防派发中的编辑),
47
+ // 保存/取消/卸载时 editend 释放; 锁定行显示"✎ 编辑中"。
48
+ // v0.5.0: 队列面板改手风琴卡片式 — 默认露约 3 行, 点行展开完整卡片; 状态色
49
+ // 排队中=蓝 / 已派发=绿 / 已取消=琥珀橙; 已派发/已取消弱化+划线只读。
50
+ // v0.4.0: kind=queue 横幅新增"队列"按钮 → 内嵌可编辑任务队列面板 (QueuePanel):
51
+ // 经 /queue RPC 实时拉列表, 可编辑(textarea)/保存/取消/立即派发; 已派发/已取消只读。
52
+ // =====================================================================
53
+
54
+ var PALETTE = {
55
+ cost: {
56
+ accent: "#f59e0b",
57
+ accentSoft: "#f7ad31",
58
+ bg: "linear-gradient(180deg, rgba(245,158,11,0.15), rgba(245,158,11,0.05))",
59
+ border: "rgba(245,158,11,0.25)",
60
+ badgeText: "#241a02",
61
+ body: "var(--dsw-alias-label-primary, #e8d9b8)",
62
+ meta: "var(--dsw-alias-label-secondary, #9aa3b2)"
63
+ },
64
+ notify: {
65
+ accent: "#22c55e",
66
+ accentSoft: "#4ed17e",
67
+ bg: "linear-gradient(180deg, rgba(34,197,94,0.14), rgba(34,197,94,0.05))",
68
+ border: "rgba(34,197,94,0.25)",
69
+ badgeText: "#0c1f14",
70
+ body: "var(--dsw-alias-label-primary, #d9f0e2)",
71
+ meta: "var(--dsw-alias-label-secondary, #9aa3b2)"
72
+ },
73
+ queue: {
74
+ accent: "#4176e6",
75
+ accentSoft: "#5b8bf0",
76
+ bg: "linear-gradient(180deg, rgba(65,118,230,0.16), rgba(65,118,230,0.05))",
77
+ border: "rgba(65,118,230,0.25)",
78
+ badgeText: "#0d1a33",
79
+ body: "var(--dsw-alias-label-primary, #dbe6f7)",
80
+ meta: "var(--dsw-alias-label-secondary, #9aa3b2)"
81
+ },
82
+ balance: {
83
+ accent: "#a78bfa",
84
+ accentSoft: "#8b5cf6",
85
+ bg: "linear-gradient(180deg, rgba(167,139,250,0.16), rgba(167,139,250,0.05))",
86
+ border: "rgba(167,139,250,0.25)",
87
+ badgeText: "#1b1033",
88
+ body: "var(--dsw-alias-label-primary, #e9e0fb)",
89
+ meta: "var(--dsw-alias-label-secondary, #9aa3b2)"
90
+ },
91
+ error: {
92
+ accent: "#ef4444",
93
+ accentSoft: "#f87171",
94
+ bg: "linear-gradient(180deg, rgba(239,68,68,0.15), rgba(239,68,68,0.05))",
95
+ border: "rgba(239,68,68,0.25)",
96
+ badgeText: "#2a0a0a",
97
+ body: "var(--dsw-alias-label-primary, #f3d3d3)",
98
+ meta: "var(--dsw-alias-label-secondary, #9aa3b2)"
99
+ },
100
+ ledger: {
101
+ accent: "#14b8a6",
102
+ accentSoft: "#0d9488",
103
+ bg: "linear-gradient(180deg, rgba(20,184,166,0.16), rgba(20,184,166,0.05))",
104
+ border: "rgba(20,184,166,0.25)",
105
+ badgeText: "#052e2b",
106
+ body: "var(--dsw-alias-label-primary, #d6efe9)",
107
+ meta: "var(--dsw-alias-label-secondary, #9aa3b2)"
108
+ },
109
+ costs: {
110
+ accent: "#0ea5e9",
111
+ accentSoft: "#38bdf8",
112
+ bg: "linear-gradient(180deg, rgba(14,165,233,0.16), rgba(14,165,233,0.05))",
113
+ border: "rgba(14,165,233,0.25)",
114
+ badgeText: "#082f49",
115
+ body: "var(--dsw-alias-label-primary, #d9ecf7)",
116
+ meta: "var(--dsw-alias-label-secondary, #9aa3b2)"
117
+ },
118
+ // v0.8.1: 状态迷你行 (kind=status, cost-guard "费用计算中…" 气泡) — 仿 think/bash 灰色小字, 无卡片样式
119
+ status: {
120
+ accent: "#9aa3b2",
121
+ accentSoft: "#aab3c0",
122
+ bg: "transparent",
123
+ border: "transparent",
124
+ badgeText: "#ffffff",
125
+ body: "var(--dsw-alias-label-tertiary, #9aa3b2)",
126
+ meta: "var(--dsw-alias-label-tertiary, #9aa3b2)"
127
+ },
128
+ // v0.9.0: 优雅重启 (kind=restart, dsh-graceful-restart) — 靛蓝家族, 内嵌状态+确认/取消按钮面板 (经 /graceful-restart RPC, 零 token)
129
+ restart: {
130
+ accent: "#818cf8",
131
+ accentSoft: "#6366f1",
132
+ bg: "linear-gradient(180deg, rgba(129,140,248,0.16), rgba(129,140,248,0.05))",
133
+ border: "rgba(129,140,248,0.25)",
134
+ badgeText: "#14102e",
135
+ body: "var(--dsw-alias-label-primary, #e4e2f7)",
136
+ meta: "var(--dsw-alias-label-secondary, #9aa3b2)"
137
+ }
138
+ };
139
+
140
+ /** 家族图标 (emoji, 与家族色板一一对应) */
141
+ var ICONS = { cost: "💰", notify: "✅", queue: "📋", balance: "💳", error: "⚠️", ledger: "🧾", costs: "📊", restart: "🔄" };
142
+
143
+ /** 家族徽章文字; balance 按 mode 细分 (overview=余额 / detail=余额明细 / session=会话费用 / stats=参数统计 / test=计算验证); status=状态 (迷你行不显示徽章); restart=优雅重启 */
144
+ var BADGES = { cost: "费用提醒", notify: "任务完成", queue: "任务队列", balance: "余额", error: "错误", ledger: "会话账本", costs: "多会话费用", status: "状态", restart: "优雅重启" };
145
+
146
+ /**
147
+ * v0.8.0 液态玻璃 v2: 注入的样式 (style 元素, 幂等)。
148
+ * 主题判定: 深色 = body[data-ds-dark-theme] 存在; 浅色 = body:not([data-ds-dark-theme])。
149
+ * 浅色横幅背景用 !important 压过内联家族渐变 (与预览方案一致); 小组件用 CSS 变量翻转
150
+ * (--dsh-*, 定义在 :root + body:not([data-ds-dark-theme]) 上, 内联样式 var() 引用自动随主题切换)。
151
+ */
152
+ var INJECTED_CSS = [
153
+ ":root{",
154
+ "--dsh-glass-bd:rgba(255,255,255,.08);",
155
+ "--dsh-btn-bg:rgba(255,255,255,.06);--dsh-btn-hover:rgba(255,255,255,.12);",
156
+ "--dsh-code-bg:rgba(0,0,0,.35);",
157
+ "--dsh-stat-bg:rgba(0,0,0,.15);--dsh-mode-bg:rgba(0,0,0,.12);",
158
+ "--dsh-qcard-bg:rgba(0,0,0,.18);--dsh-sc-bg:rgba(0,0,0,.18);",
159
+ "--dsh-rp-bg:rgba(0,0,0,.18);",
160
+ "--dsh-st-pending-tx:#5b8bf0;--dsh-st-pending-bd:rgba(65,118,230,.25);",
161
+ "--dsh-st-dispatch-tx:#4ed17e;--dsh-st-dispatch-bd:rgba(34,197,94,.25);",
162
+ "--dsh-st-qs-tx:#f7ad31;--dsh-st-qs-bd:rgba(245,158,11,.25);",
163
+ "--dsh-st-cancel-tx:#9ca3af;--dsh-st-cancel-bg:rgba(156,163,175,.10);--dsh-st-cancel-bd:rgba(156,163,175,.20);",
164
+ "--dsh-st-edit-tx:#f7ad31;--dsh-st-edit-bd:rgba(245,158,11,.25);",
165
+ "--dsh-btn-primary-bg:rgba(65,118,230,.15);--dsh-btn-primary-bd:rgba(65,118,230,.4);--dsh-btn-primary-tx:#5b8bf0;",
166
+ "--dsh-btn-success-bg:rgba(34,197,94,.15);--dsh-btn-success-bd:rgba(34,197,94,.4);--dsh-btn-success-tx:#4ed17e;",
167
+ "--dsh-btn-danger-bg:rgba(239,68,68,.15);--dsh-btn-danger-bd:rgba(239,68,68,.4);--dsh-btn-danger-tx:#f87171;",
168
+ /* v0.11.0: 「子 agent」徽标 / 树形线 — 青绿系深浅两态 (不新增家族色) */
169
+ "--dsh-ct-ag-bg:rgba(20,184,166,.14);--dsh-ct-ag-bd:rgba(20,184,166,.42);--dsh-ct-ag-tx:#5eead4;",
170
+ "--dsh-ct-line:rgba(20,184,166,.45);",
171
+ /* v0.11.1: ledger 折叠行「含树合计」胶囊底 (深色 = 家族 accent 字, 无文字标识) */
172
+ "--dsh-lk-bg:rgba(20,184,166,.14);--dsh-lk-bd:rgba(20,184,166,.35);--dsh-lk-tx:#14b8a6;",
173
+ "}",
174
+ "body:not([data-ds-dark-theme]){",
175
+ "--dsh-glass-bd:rgba(255,255,255,.35);",
176
+ "--dsh-btn-bg:rgba(255,255,255,.35);--dsh-btn-hover:rgba(255,255,255,.55);",
177
+ "--dsh-code-bg:rgba(0,0,0,.06);",
178
+ "--dsh-stat-bg:rgba(255,255,255,.3);--dsh-mode-bg:rgba(255,255,255,.25);",
179
+ "--dsh-qcard-bg:linear-gradient(180deg,rgba(255,255,255,.95) 0%,rgba(255,255,255,.08) 100%);",
180
+ "--dsh-sc-bg:linear-gradient(180deg,rgba(255,255,255,.95) 0%,rgba(255,255,255,.08) 100%);",
181
+ "--dsh-rp-bg:linear-gradient(180deg,rgba(255,255,255,.95) 0%,rgba(255,255,255,.08) 100%);",
182
+ "--dsh-st-pending-tx:#2563eb;--dsh-st-pending-bd:rgba(65,118,230,.35);",
183
+ "--dsh-st-dispatch-tx:#16a34a;--dsh-st-dispatch-bd:rgba(34,197,94,.35);",
184
+ "--dsh-st-qs-tx:#b45309;--dsh-st-qs-bd:rgba(245,158,11,.35);",
185
+ "--dsh-st-cancel-tx:#6b7280;--dsh-st-cancel-bg:rgba(107,114,128,.10);--dsh-st-cancel-bd:rgba(107,114,128,.30);",
186
+ "--dsh-st-edit-tx:#b45309;--dsh-st-edit-bd:rgba(245,158,11,.35);",
187
+ "--dsh-btn-primary-bg:rgba(65,118,230,.20);--dsh-btn-primary-bd:rgba(65,118,230,.5);",
188
+ "--dsh-btn-success-bg:rgba(34,197,94,.20);--dsh-btn-success-bd:rgba(34,197,94,.5);",
189
+ "--dsh-btn-danger-bg:rgba(239,68,68,.20);--dsh-btn-danger-bd:rgba(239,68,68,.5);",
190
+ /* v0.11.0: 浅色主题徽标/树形线 (青绿加深) */
191
+ "--dsh-ct-ag-bg:rgba(20,184,166,.10);--dsh-ct-ag-bd:rgba(13,148,136,.50);--dsh-ct-ag-tx:#0f766e;",
192
+ "--dsh-ct-line:rgba(13,148,136,.60);",
193
+ /* v0.11.1: 浅色主题胶囊 (青绿加深, 深字) */
194
+ "--dsh-lk-bg:rgba(13,148,136,.12);--dsh-lk-bd:rgba(13,148,136,.45);--dsh-lk-tx:#0d9488;",
195
+ "}",
196
+ /* 玻璃基座 + hover */
197
+ ".dsh-banner{backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);box-shadow:0 2px 12px rgba(0,0,0,.08);transition:box-shadow .3s ease,border-color .3s ease}",
198
+ ".dsh-banner:hover{box-shadow:0 4px 20px rgba(0,0,0,.12);border-color:rgba(255,255,255,.15)}",
199
+ /* 浅色主题: 白色渐变 + 家族顶部着色 (压内联深色渐变) */
200
+ "body:not([data-ds-dark-theme]) .dsh-banner{background:linear-gradient(180deg,rgba(255,255,255,.95) 0%,rgba(255,255,255,.05) 100%) !important;box-shadow:0 8px 32px rgba(0,0,0,.12);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}",
201
+ "body:not([data-ds-dark-theme]) .dsh-banner:hover{box-shadow:0 12px 40px rgba(0,0,0,.14)}",
202
+ "body:not([data-ds-dark-theme]) .dsh-banner[data-family=\"cost\"]{background:linear-gradient(180deg,rgba(245,158,11,.18) 0%,rgba(255,255,255,.05) 100%) !important}",
203
+ "body:not([data-ds-dark-theme]) .dsh-banner[data-family=\"notify\"]{background:linear-gradient(180deg,rgba(34,197,94,.16) 0%,rgba(255,255,255,.05) 100%) !important}",
204
+ "body:not([data-ds-dark-theme]) .dsh-banner[data-family=\"queue\"]{background:linear-gradient(180deg,rgba(65,118,230,.16) 0%,rgba(255,255,255,.05) 100%) !important}",
205
+ "body:not([data-ds-dark-theme]) .dsh-banner[data-family=\"balance\"]{background:linear-gradient(180deg,rgba(167,139,250,.18) 0%,rgba(255,255,255,.05) 100%) !important}",
206
+ "body:not([data-ds-dark-theme]) .dsh-banner[data-family=\"error\"]{background:linear-gradient(180deg,rgba(239,68,68,.16) 0%,rgba(255,255,255,.05) 100%) !important}",
207
+ "body:not([data-ds-dark-theme]) .dsh-banner[data-family=\"ledger\"]{background:linear-gradient(180deg,rgba(20,184,166,.18) 0%,rgba(255,255,255,.05) 100%) !important}",
208
+ "body:not([data-ds-dark-theme]) .dsh-banner[data-family=\"costs\"]{background:linear-gradient(180deg,rgba(14,165,233,.18) 0%,rgba(255,255,255,.05) 100%) !important}",
209
+ // v0.9.6: 优雅重启家族补浅色主题顶部着色 (此前遗漏 → 浅色下与其他家族不一致)
210
+ "body:not([data-ds-dark-theme]) .dsh-banner[data-family=\"restart\"]{background:linear-gradient(180deg,rgba(129,140,248,.18) 0%,rgba(255,255,255,.05) 100%) !important}",
211
+ /* 小组件 hover */
212
+ ".dsh-arr:hover,.dsh-qbtn:hover,.dsh-lbtn:hover{background:rgba(255,255,255,.12)}",
213
+ ".dsh-hbtn:hover,.dsh-sbtn:hover{transform:scale(1.02)}",
214
+ ".dsh-qrow:hover{background:rgba(255,255,255,.04)}",
215
+ ".dsh-sch:hover{background:rgba(255,255,255,.03)}",
216
+ /* v0.11.0: 委托树/树分组小组件 — 「子 agent」徽标 + 树行文字基线 (细节内联样式) */
217
+ ".dsh-ct-ag{display:inline-flex;align-items:center;gap:2px;flex:none;font-size:10.5px;font-weight:700;line-height:16px;padding:0 7px;border-radius:8px;background:var(--dsh-ct-ag-bg);border:1px solid var(--dsh-ct-ag-bd);color:var(--dsh-ct-ag-tx);letter-spacing:.3px;white-space:nowrap}",
218
+ ".dsh-ct-g{flex:none;color:var(--dsh-ct-line);font-family:ui-monospace,\"SF Mono\",Consolas,monospace;font-size:11.5px;white-space:pre}",
219
+ ".dsh-ct-row{display:flex;align-items:baseline;gap:6px;font-size:12px;line-height:1.9;color:var(--dsw-alias-label-primary,#eceff4);font-variant-numeric:tabular-nums;white-space:nowrap;min-width:0}",
220
+ ".dsh-ct-row .dsh-ct-lb{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600}",
221
+ ".dsh-ct-row .dsh-ct-sid{flex:none;color:var(--dsw-alias-label-secondary,#9aa3b2);font-size:10.5px;font-family:ui-monospace,\"SF Mono\",Consolas,monospace;font-weight:400}",
222
+ ".dsh-ct-row .dsh-ct-tag{flex:none;font-size:10.5px;color:var(--dsw-alias-label-secondary,#9aa3b2);font-weight:400}",
223
+ ".dsh-ct-toggle:hover{background:var(--dsh-btn-hover)}",
224
+ /* v0.8.1: 状态迷你行 — running 扫光动画 (仿工具行 sweep) + 图标旋转 */
225
+ ".dsh-status{overflow:hidden;position:relative;border-radius:6px}",
226
+ ".dsh-status[data-state=\"running\"]:after{content:\"\";position:absolute;inset-block:0;left:0;width:300px;background:linear-gradient(90deg,transparent 0%,color-mix(in srgb,var(--dsw-alias-bg-base) 55%,transparent) 50%,transparent 100%);pointer-events:none;animation:2.6s ease-out infinite dsh-status-sweep}",
227
+ "@keyframes dsh-status-sweep{0%{left:-300px}90%,to{left:100%}}",
228
+ "@keyframes dsh-status-spin{to{transform:rotate(360deg)}}"
229
+ ].join("");
230
+
231
+ /** v0.8.0: 注入玻璃样式 (幂等, style 元素) */
232
+ function injectGlassCss() {
233
+ try {
234
+ if (document.getElementById("dsh-notice-banner-glass")) return;
235
+ var st = document.createElement("style");
236
+ st.id = "dsh-notice-banner-glass";
237
+ st.textContent = INJECTED_CSS;
238
+ (document.head || document.documentElement).appendChild(st);
239
+ } catch (e) { /* 样式注入失败不影响功能 */ }
240
+ }
241
+
242
+ function fmtElapsed(ms) {
243
+ if (typeof ms !== "number" || !isFinite(ms)) return "";
244
+ var s = Math.round(ms / 1000);
245
+ return s < 60 ? s + " 秒" : Math.floor(s / 60) + " 分 " + (s % 60) + " 秒";
246
+ }
247
+
248
+ function metaOf(banner) {
249
+ if (banner.kind === "cost") {
250
+ var tier = banner.tier === "peak" ? "高峰价" : banner.tier === "offpeak" ? "低谷价" : "";
251
+ var parts = [];
252
+ if (tier) parts.push(tier);
253
+ if (banner.levelFactor) parts.push("已超 ¥" + banner.thresholdYuan + " 档位 ×" + banner.levelFactor);
254
+ if (banner.sessionShort) parts.push("会话 " + banner.sessionShort);
255
+ return {
256
+ text: parts.join(" · "),
257
+ // 生产者可给动态建议 (按结论: 切换/继续/差异不大); 缺省回退原固定文案 (兼容旧横幅)
258
+ advice: typeof banner.advice === "string" ? banner.advice : "建议完成当前任务后新建会话继续, 可显著降低上下文缓存费用"
259
+ };
260
+ }
261
+ // balance / error 家族: host 直接给 metaText / advice 纯文本
262
+ if (typeof banner.metaText === "string") {
263
+ return { text: banner.metaText, advice: typeof banner.advice === "string" ? banner.advice : "" };
264
+ }
265
+ var parts = [];
266
+ if (typeof banner.turn === "number") parts.push("回合 #" + banner.turn);
267
+ var elapsed = fmtElapsed(banner.elapsedMs);
268
+ if (elapsed) parts.push("用时 " + elapsed);
269
+ if (typeof banner.reason === "string" && banner.reason) parts.push("原因: " + banner.reason);
270
+ if (banner.sessionShort) parts.push("会话 " + banner.sessionShort);
271
+ return { text: parts.join(" · "), advice: "" };
272
+ }
273
+
274
+ /** 插件 ctx (apply 时记录), 组件内惰性取 connection 服务 (浏览器端通用 RPC) */
275
+ var pluginCtx = null;
276
+
277
+ /** 调用服务端 /queue RPC 通道 (dsh-taskqueue v0.4.0), 失败归一为 { ok:false, error } */
278
+ function queueRpc(endpoint, payload) {
279
+ var conn = pluginCtx && pluginCtx.get ? pluginCtx.get("connection") : null;
280
+ var rpc = conn && conn.rpc;
281
+ if (!rpc || typeof rpc.call !== "function") {
282
+ return Promise.resolve({ ok: false, error: { code: "unavailable", message: "connection 服务不可用" } });
283
+ }
284
+ return rpc.call("/queue", endpoint, payload || {}).then(function (result) {
285
+ return result && typeof result === "object" ? result : { ok: false, error: { code: "bad-response", message: "响应格式异常" } };
286
+ }).catch(function (err) {
287
+ return { ok: false, error: { code: "transport", message: String((err && err.message) || err) } };
288
+ });
289
+ }
290
+
291
+ /** 调用服务端 /graceful-restart RPC 通道 (dsh-graceful-restart v0.1.0), 失败归一为 { ok:false, error } */
292
+ function restartRpc(endpoint, payload) {
293
+ var conn = pluginCtx && pluginCtx.get ? pluginCtx.get("connection") : null;
294
+ var rpc = conn && conn.rpc;
295
+ if (!rpc || typeof rpc.call !== "function") {
296
+ return Promise.resolve({ ok: false, error: { code: "unavailable", message: "connection 服务不可用" } });
297
+ }
298
+ return rpc.call("/graceful-restart", endpoint, payload || {}).then(function (result) {
299
+ return result && typeof result === "object" ? result : { ok: false, error: { code: "bad-response", message: "响应格式异常" } };
300
+ }).catch(function (err) {
301
+ return { ok: false, error: { code: "transport", message: String((err && err.message) || err) } };
302
+ });
303
+ }
304
+
305
+ /** 优雅重启面板 (kind=restart 横幅内嵌, v0.9.0): 显示排程状态, 提供 [确认重启]/[取消] 按钮
306
+ * (经 /graceful-restart RPC, 零 token); 确认后服务端静默观察 10s 自然退出。
307
+ * 状态: scheduled(等待空闲) / ready(空闲待确认) / observing(静默观察中) / exiting(正在退出)
308
+ * / cancelled / timedout / error / invalid(重启前未执行已失效, v0.9.6) / none。 */
309
+ var RESTART_PHASE_TEXT = {
310
+ scheduled: "等待所有会话/子agent空闲…",
311
+ ready: "环境已空闲,等待确认",
312
+ observing: "已确认,正在等待环境静默", // v0.9.2: 倒计时在面板内实时显示
313
+ exiting: "正在优雅重启…", // v0.9.2: 最终定格文案 (GUI 将断开约 10-30s 后自动恢复)
314
+ cancelled: "已取消",
315
+ timedout: "已超时自动取消(15 分钟未确认)",
316
+ error: "退出失败(appExit 不可用),请手动重启",
317
+ invalid: "已失效(容器已重启,排程作废)", // v0.9.6: 重启前未执行的排程
318
+ none: "无进行中的重启排程"
319
+ };
320
+ /** v0.9.2: 静默观察 10s 倒计时 — client 本地每秒递减 (banner.remainSec 是排程总剩余, 非观察剩余) */
321
+ var QUIET_WINDOW_SEC = 10;
322
+ var RestartPanel = React.memo(function RestartPanel(props) {
323
+ var p = props.p;
324
+ var banner = props.banner || {};
325
+ var phase = banner.phase || "none";
326
+ var reason = typeof banner.reason === "string" && banner.reason ? banner.reason : "";
327
+ var remain = typeof banner.remainSec === "number" ? banner.remainSec : 0;
328
+ var busyState = React.useState(false);
329
+ var busy = busyState[0];
330
+ var setBusy = busyState[1];
331
+ var msgState = React.useState("");
332
+ var msg = msgState[0];
333
+ var setMsg = msgState[1];
334
+ var errState = React.useState("");
335
+ var err = errState[0];
336
+ var setErr = errState[1];
337
+ // v0.9.4: observing 倒计时 — 进入 observing 或收到新 observing replace (带 note 重置)
338
+ // 时重置倒计时起点; 每 250ms 递减到 0。到 0 不本地切换文案 — 只有服务端真实
339
+ // exiting 事件才显示"正在优雅重启…" (否则活动重置时 client 会误显示重启中)。
340
+ var countdownState = React.useState(null); // { start: ts, sec: n }
341
+ var countdown = countdownState[0];
342
+ var setCountdown = countdownState[1];
343
+ React.useEffect(function () {
344
+ if (phase === "observing") {
345
+ setCountdown({ start: Date.now(), sec: QUIET_WINDOW_SEC });
346
+ var iv = setInterval(function () {
347
+ setCountdown(function (prev) {
348
+ if (!prev) return prev;
349
+ var elapsed = Math.floor((Date.now() - prev.start) / 1000);
350
+ var left = Math.max(0, QUIET_WINDOW_SEC - elapsed);
351
+ if (left === prev.sec) return prev;
352
+ return { start: prev.start, sec: left };
353
+ });
354
+ }, 250);
355
+ return function () { clearInterval(iv); };
356
+ }
357
+ setCountdown(null);
358
+ return undefined;
359
+ }, [phase, banner.time]); // v0.9.4: banner.time 变化 (replace 重置/带 note) → 重置倒计时
360
+ function act(endpoint, okText) {
361
+ if (busy) return;
362
+ setBusy(true);
363
+ setErr("");
364
+ setMsg("");
365
+ restartRpc(endpoint, {}).then(function (result) {
366
+ setBusy(false);
367
+ if (result.ok) setMsg(okText);
368
+ else setErr((result.error && result.error.message) || "操作失败");
369
+ });
370
+ }
371
+ var canConfirm = phase === "ready" && !busy;
372
+ var canCancel = (phase === "scheduled" || phase === "ready" || phase === "observing") && !busy;
373
+ // v0.9.5: observing 显示倒计时剩余秒 (accent 色); 服务端活动重置会发带 note 的
374
+ // replace (原因文案 + 重置倒计时)。倒计时到 0 不卡住 — 显示"正在检测环境…"
375
+ // 过渡态, 等服务端结果事件 (exiting → 定格重启中 / note → 原因 + 重新倒计时)
376
+ var statusText = RESTART_PHASE_TEXT[phase] || phase;
377
+ var statusTail = null;
378
+ var countdownDone = phase === "observing" && countdown && countdown.sec === 0;
379
+ // v0.9.6: invalid (重启前未执行已失效) 用服务端 note 文案 (如有), 无按钮
380
+ if (phase === "invalid" && typeof banner.note === "string" && banner.note) {
381
+ statusText = banner.note;
382
+ } else if (phase === "observing" && typeof banner.note === "string" && banner.note) {
383
+ statusText = banner.note; // 服务端通知的原因 (活动重置)
384
+ } else if (countdownDone) {
385
+ statusText = "正在检测环境…"; // v0.9.5: 倒计时结束, 等服务端判定结果
386
+ }
387
+ if (phase === "observing" && countdown && countdown.sec > 0) {
388
+ statusTail = React.createElement(
389
+ "span",
390
+ { style: { color: p.accent, fontWeight: 700, fontVariantNumeric: "tabular-nums", flex: "none", marginLeft: 6, fontSize: 12.5 } },
391
+ countdown.sec + "s"
392
+ );
393
+ }
394
+ return React.createElement(
395
+ "div",
396
+ // v0.9.6: 内嵌面板与其他家族内嵌卡片一致 — 圆角 8 (原 10), 背景走 --dsh-rp-bg
397
+ // 变量随深浅主题翻转 (原硬编码 rgba(255,255,255,0.03) 浅色下几乎不可见)
398
+ { style: { marginTop: 8, padding: "8px 10px", border: "1px solid " + p.border, borderRadius: 8, background: "var(--dsh-rp-bg)" } },
399
+ React.createElement(
400
+ "div",
401
+ { style: { display: "flex", alignItems: "center", gap: 8, fontSize: 12.5 } },
402
+ React.createElement(
403
+ "span",
404
+ { style: { flex: "none", fontSize: 13, lineHeight: 1, animation: phase === "observing" || phase === "scheduled" ? "1.2s linear infinite dsh-status-spin" : undefined, display: "inline-block" } },
405
+ phase === "exiting" ? "✅" : phase === "cancelled" || phase === "timedout" || phase === "invalid" ? "🛑" : phase === "error" ? "⚠️" : "⟳"
406
+ ),
407
+ React.createElement(
408
+ "span",
409
+ { style: { color: p.body, flex: "1 1 auto", minWidth: 0 } },
410
+ statusText
411
+ ),
412
+ statusTail,
413
+ remain > 0 && phase !== "exiting" && phase !== "observing"
414
+ ? React.createElement("span", { style: { color: p.meta, fontSize: 11, flex: "none" } }, Math.ceil(remain / 60) + " 分钟内有效")
415
+ : null
416
+ ),
417
+ reason
418
+ ? React.createElement(
419
+ "div",
420
+ { style: { color: p.meta, fontSize: 12, marginTop: 4 } },
421
+ "原因: " + reason
422
+ )
423
+ : null,
424
+ React.createElement(
425
+ "div",
426
+ { style: { display: "flex", gap: 8, marginTop: 8, flexWrap: "wrap" } },
427
+ canConfirm
428
+ ? btn("确认重启", function () { act("confirm", "已确认,正在静默观察…"); }, false, "primary")
429
+ : null,
430
+ canCancel
431
+ ? btn("取消", function () { act("cancel", "已取消重启排程"); }, false, "default")
432
+ : null,
433
+ msg
434
+ ? React.createElement("span", { style: { color: "var(--dsw-alias-state-success-primary, #22c55e)", fontSize: 12, alignSelf: "center" } }, msg)
435
+ : null,
436
+ err
437
+ ? React.createElement("span", { style: { color: "#ef4444", fontSize: 12, alignSelf: "center" } }, err)
438
+ : null
439
+ )
440
+ );
441
+ });
442
+
443
+ /** 任务队列可编辑面板 (kind=queue 横幅内嵌, v0.4.0): 实时拉 /queue/list,
444
+ * 每个排队任务可 编辑(textarea)/保存/取消/立即派发, 操作后自动刷新并给行内反馈;
445
+ * 已派发/已取消只读展示 —— "派发前可编辑, 下发了一切方休"。零 token (不走模型回合)。
446
+ * v0.8.0: variant=primary(蓝)/success(绿)/danger(红)/默认(玻璃底)。 */
447
+ function btn(label, onClick, disabled, variant) {
448
+ var v = variant === "primary"
449
+ ? { bg: "var(--dsh-btn-primary-bg)", bd: "var(--dsh-btn-primary-bd)", tx: "var(--dsh-btn-primary-tx)" }
450
+ : variant === "success"
451
+ ? { bg: "var(--dsh-btn-success-bg)", bd: "var(--dsh-btn-success-bd)", tx: "var(--dsh-btn-success-tx)" }
452
+ : variant === "danger"
453
+ ? { bg: "var(--dsh-btn-danger-bg)", bd: "var(--dsh-btn-danger-bd)", tx: "var(--dsh-btn-danger-tx)" }
454
+ : { bg: "var(--dsh-btn-bg)", bd: "var(--dsh-glass-bd)", tx: "var(--dsw-alias-label-primary, #eceff4)" };
455
+ return React.createElement(
456
+ "button",
457
+ {
458
+ type: "button",
459
+ className: "dsh-gbtn",
460
+ "data-variant": variant || "default",
461
+ onClick: onClick,
462
+ disabled: !!disabled,
463
+ style: {
464
+ fontSize: 11.5,
465
+ padding: "0 12px",
466
+ // v0.8.2: lineHeight 必须给字符串 "26px" —— React 把数字 lineHeight
467
+ // 当无单位倍率渲染 (line-height: 26 → 26×11.5px=299px 行高, 按钮被撑成
468
+ // 301px 高, 手机横幅上"展开/刷新"等按钮非常长)。同文件其他小数
469
+ // lineHeight (1.5/1.6/1.75) 是刻意用倍率, 不受影响。
470
+ lineHeight: "26px",
471
+ borderRadius: 8,
472
+ border: "1px solid " + v.bd,
473
+ background: v.bg,
474
+ color: v.tx,
475
+ cursor: disabled ? "default" : "pointer",
476
+ opacity: disabled ? 0.5 : 1,
477
+ flex: "none",
478
+ backdropFilter: "blur(4px)",
479
+ WebkitBackdropFilter: "blur(4px)",
480
+ transition: "all .2s ease"
481
+ }
482
+ },
483
+ label
484
+ );
485
+ }
486
+
487
+ /** 任务状态标签样式 (v0.5.0 手风琴卡片; v0.8.0 液态玻璃: 排队中=蓝 / 已派发=绿 /
488
+ * 已取消=灰色系; 浅色主题颜色经 --dsh-st-* 变量自动翻转) */
489
+ var QUEUE_STATUS_STYLE = {
490
+ pending: { label: "排队中", color: "var(--dsh-st-pending-tx)", bg: "rgba(65,118,230,0.12)", border: "var(--dsh-st-pending-bd)" },
491
+ // v0.8.3: 排队发送中 —— 已派发但目标会话正忙, 消息仍在收件箱排队未执行 (可撤回取消)
492
+ queuedSending: { label: "排队发送中", color: "var(--dsh-st-qs-tx)", bg: "rgba(245,158,11,0.12)", border: "var(--dsh-st-qs-bd)" },
493
+ dispatched: { label: "已派发", color: "var(--dsh-st-dispatch-tx)", bg: "rgba(34,197,94,0.10)", border: "var(--dsh-st-dispatch-bd)" },
494
+ cancelled: { label: "已取消", color: "var(--dsh-st-cancel-tx)", bg: "var(--dsh-st-cancel-bg)", border: "var(--dsh-st-cancel-bd)" }
495
+ };
496
+
497
+ /** ISO 时间 → 北京时区 "MM-DD HH:mm" */
498
+ function beijingTime(iso) {
499
+ if (!iso) return "";
500
+ try {
501
+ return new Date(Date.parse(iso) + 8 * 3600 * 1000).toISOString().slice(5, 16).replace("T", " ");
502
+ } catch { return ""; }
503
+ }
504
+
505
+ /** 压缩连续空白为单空格 (折叠行摘要用) */
506
+ function oneLine(s) {
507
+ return String(s ?? "").replace(/\s+/g, " ").trim();
508
+ }
509
+
510
+ // =====================================================================
511
+ // v0.7 (cost v2 双模式): 填入输入框的 DOM 辅助 (官方 inputActions.setDraft
512
+ // 优先, 见 NoticeBannerView; 此处为兜底 + 读当前草稿/聚焦)
513
+ // =====================================================================
514
+ function composerTextarea() {
515
+ try {
516
+ var byPhase = document.querySelectorAll("textarea[data-phase]");
517
+ if (byPhase.length && byPhase[0]) return byPhase[0];
518
+ var all = document.querySelectorAll("textarea");
519
+ var best = null, max = 0;
520
+ for (var i = 0; i < all.length; i++) {
521
+ var r = all[i].getBoundingClientRect();
522
+ var area = r.width * r.height;
523
+ if (area > max) { max = area; best = all[i]; }
524
+ }
525
+ return best;
526
+ } catch { return null; }
527
+ }
528
+ /** 当前输入框草稿 (点击瞬间读取, 避免过期闭包) */
529
+ function composerDraftText() {
530
+ var el = composerTextarea();
531
+ return el ? (el.value || "") : "";
532
+ }
533
+ /** DOM 兜底写入: React 受控 textarea 用原生 value setter + input 事件 */
534
+ function writeComposerDom(text) {
535
+ var el = composerTextarea();
536
+ if (!el) return;
537
+ var proto = window.HTMLTextAreaElement && window.HTMLTextAreaElement.prototype;
538
+ var setter = proto && Object.getOwnPropertyDescriptor(proto, "value") && Object.getOwnPropertyDescriptor(proto, "value").set;
539
+ if (setter) setter.call(el, text); else el.value = text;
540
+ try { el.dispatchEvent(new Event("input", { bubbles: true })); } catch { /* ignore */ }
541
+ }
542
+ function focusComposer() {
543
+ var el = composerTextarea();
544
+ if (el) { try { el.focus(); } catch { /* ignore */ } }
545
+ }
546
+
547
+ /** 彩色状态标签 (v0.8.0: 尺寸/圆角按液态玻璃方案, 颜色走 --dsh-st-* 变量;
548
+ * v0.8.3: dispatched + queuedSending → "排队发送中" 琥珀标签) */
549
+ function statusTag(t) {
550
+ var stKey = t.status === "dispatched" && t.queuedSending ? "queuedSending" : t.status;
551
+ var st = QUEUE_STATUS_STYLE[stKey] || QUEUE_STATUS_STYLE.pending;
552
+ return React.createElement(
553
+ "span",
554
+ {
555
+ className: "dsh-st",
556
+ "data-state": t.status,
557
+ style: {
558
+ flex: "none", fontSize: 10.5, fontWeight: 600, letterSpacing: 0.3,
559
+ padding: "0 8px", lineHeight: "18px", borderRadius: 7,
560
+ background: st.bg, color: st.color, border: "1px solid " + st.border
561
+ }
562
+ },
563
+ st.label
564
+ );
565
+ }
566
+
567
+ /**
568
+ * 任务队列可编辑面板 (v0.5.0 手风琴卡片式): 默认只露出约 3 行任务 (maxHeight 92px),
569
+ * 点某任务行展开该任务完整卡片 (手风琴, 每次一条) —— 完整内容 + 全部控件, "打开一次
570
+ * 就能干完所有事"; 面板可整体放大 (maxHeight 380px) 滚动浏览全部任务。
571
+ * 状态色: 排队中=蓝 / 已派发=绿 / 已取消=琥珀橙; 已派发/已取消弱化+划线只读。
572
+ * 数据经 /queue RPC 实时拉取 (dsh-taskqueue v0.4.0, 零 token)。
573
+ */
574
+ var QueuePanel = React.memo(function QueuePanel(props) {
575
+ var p = props.p;
576
+ var dataState = React.useState(null);
577
+ var data = dataState[0];
578
+ var setData = dataState[1];
579
+ var loadingState = React.useState(false);
580
+ var isLoading = loadingState[0];
581
+ var setLoading = loadingState[1];
582
+ var errState = React.useState("");
583
+ var err = errState[0];
584
+ var setErr = errState[1];
585
+ var editState = React.useState(null);
586
+ var editingId = editState[0];
587
+ var setEditingId = editState[1];
588
+ var draftState = React.useState("");
589
+ var draftText = draftState[0];
590
+ var setDraft = draftState[1];
591
+ var busyState = React.useState(null);
592
+ var busyOp = busyState[0];
593
+ var setBusy = busyState[1];
594
+ var msgState = React.useState("");
595
+ var actionMsg = msgState[0];
596
+ var setMsg = msgState[1];
597
+ var openState = React.useState(null);
598
+ var expandedId = openState[0];
599
+ var setExpandedId = openState[1];
600
+ var tallState = React.useState(false);
601
+ var listTall = tallState[0];
602
+ var setListTall = tallState[1];
603
+
604
+ function load() {
605
+ setLoading(true);
606
+ setErr("");
607
+ queueRpc("list", {}).then(function (result) {
608
+ setLoading(false);
609
+ if (result.ok) setData(result.value);
610
+ else setErr((result.error && result.error.message) || "加载失败");
611
+ });
612
+ }
613
+
614
+ React.useEffect(function () {
615
+ load();
616
+ // v0.5.2: 组件卸载时释放编辑锁 (防关页面/刷新导致永久锁; 服务端还有 TTL 兜底)
617
+ return function () {
618
+ if (editingRef.current !== null) queueRpc("editend", { id: editingRef.current });
619
+ };
620
+ }, []);
621
+
622
+ var editingRef = React.useRef(null);
623
+
624
+ /** 执行一个变更操作 (edit/cancel/runnow), 成功后刷新列表 */
625
+ function act(op, payload, successText) {
626
+ if (busyOp) return;
627
+ setBusy(op);
628
+ setErr("");
629
+ setMsg("");
630
+ queueRpc(op, payload).then(function (result) {
631
+ setBusy(null);
632
+ if (result.ok) {
633
+ setMsg(successText);
634
+ load();
635
+ } else {
636
+ setErr((result.error && result.error.message) || "操作失败");
637
+ }
638
+ });
639
+ }
640
+
641
+ /** 开始编辑: 锁定任务 (防 tick 自动派发把编辑中的任务发出去) */
642
+ function startEdit(task) {
643
+ if (editingRef.current !== null && editingRef.current !== task.id) {
644
+ queueRpc("editend", { id: editingRef.current }); // 切换编辑目标, 先释放旧锁
645
+ }
646
+ editingRef.current = task.id;
647
+ setEditingId(task.id);
648
+ setDraft(task.content);
649
+ queueRpc("editstart", { id: task.id });
650
+ }
651
+
652
+ /** 取消编辑: 释放编辑锁 */
653
+ function cancelEdit() {
654
+ if (editingRef.current !== null) queueRpc("editend", { id: editingRef.current });
655
+ editingRef.current = null;
656
+ setEditingId(null);
657
+ setErr("");
658
+ }
659
+
660
+ function saveEdit() {
661
+ var text = draftText.trim();
662
+ if (!text) {
663
+ setErr("内容不能为空");
664
+ return;
665
+ }
666
+ // 保存成功后服务端 edit 端点已释放锁; 本地清引用 (卸载不再补发 editend)
667
+ act("edit", { id: editingId, content: text }, "任务 #" + editingId + " 已保存");
668
+ editingRef.current = null;
669
+ setEditingId(null);
670
+ }
671
+
672
+ /** 手风琴: 点行展开该任务 (面板自动增高可滚动); 再点收起卡片 */
673
+ function toggleTask(id) {
674
+ if (expandedId === id) setExpandedId(null);
675
+ else {
676
+ setExpandedId(id);
677
+ setListTall(true);
678
+ }
679
+ }
680
+
681
+ /** 面板整体 展开/收起 (3 行 ↔ 380px 可滚动) */
682
+ function toggleTall() {
683
+ var next = !listTall;
684
+ setListTall(next);
685
+ if (!next) setExpandedId(null);
686
+ }
687
+
688
+ var tasks = (data && data.tasks) || [];
689
+ // v0.8.3: 排队发送中 (已派发未执行) 计入"排队中"并紧跟排队中分组; 已执行/已取消归历史
690
+ function qsOf(t) { return t.status === "dispatched" && t.queuedSending; }
691
+ var pendingCount = 0;
692
+ var ordered = tasks.slice().sort(function (a, b) {
693
+ var pa = a.status === "pending" ? 0 : qsOf(a) ? 1 : 2;
694
+ var pb = b.status === "pending" ? 0 : qsOf(b) ? 1 : 2;
695
+ return pa - pb || a.id - b.id;
696
+ });
697
+ for (var i = 0; i < ordered.length; i++) if (ordered[i].status === "pending" || qsOf(ordered[i])) pendingCount++;
698
+
699
+ return React.createElement(
700
+ "div",
701
+ { style: { marginTop: 8, borderTop: "1px solid rgba(255,255,255,0.06)", paddingTop: 8 } },
702
+ React.createElement(
703
+ "div",
704
+ { style: { display: "flex", alignItems: "center", gap: 8, fontSize: 12.5, fontWeight: 600, color: "var(--dsw-alias-label-primary, #eceff4)", marginBottom: 6, flexWrap: "wrap" } },
705
+ React.createElement("span", null, "📋 任务队列"),
706
+ React.createElement(
707
+ "span",
708
+ { style: { color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontWeight: 500, fontSize: 11.5 } },
709
+ "排队中 (" + (data ? pendingCount : "…") + ")" + (data ? " · " + (data.peak ? "高峰·等低谷" : "低谷中") + " · " + data.windowSource : "")
710
+ ),
711
+ React.createElement(
712
+ "span",
713
+ { style: { marginLeft: "auto", display: "flex", gap: 6, alignItems: "center", flexWrap: "wrap" } },
714
+ btn(listTall ? "收起" : "展开", toggleTall, false),
715
+ btn(isLoading ? "…" : "刷新", load, isLoading),
716
+ actionMsg
717
+ ? React.createElement(
718
+ "span",
719
+ { style: { color: "#4ed17e", fontSize: 11.5 } },
720
+ actionMsg
721
+ )
722
+ : null
723
+ )
724
+ ),
725
+ React.createElement(
726
+ "div",
727
+ {
728
+ style: {
729
+ maxHeight: listTall ? 380 : 92,
730
+ overflowY: "auto",
731
+ transition: "max-height .25s ease",
732
+ scrollbarWidth: "thin"
733
+ }
734
+ },
735
+ isLoading && !data
736
+ ? React.createElement("div", { style: { color: p.meta, fontSize: 12, margin: "4px 6px" } }, "加载中…")
737
+ : err
738
+ ? React.createElement("div", { style: { color: "#f87171", fontSize: 12, margin: "4px 6px" } }, "⚠ " + err)
739
+ : ordered.length === 0
740
+ ? React.createElement("div", { style: { color: p.meta, fontSize: 12, margin: "4px 6px" } }, "(队列为空)")
741
+ : ordered.map(function (t) {
742
+ var isPending = t.status === "pending";
743
+ var isQSend = qsOf(t); // v0.8.3: 已派发未执行, 可撤回取消
744
+ var isOpen = expandedId === t.id;
745
+ var row = React.createElement(
746
+ "div",
747
+ {
748
+ key: "r" + t.id,
749
+ className: "dsh-qrow",
750
+ onClick: function () { toggleTask(t.id); },
751
+ style: {
752
+ display: "flex", alignItems: "center", gap: 8,
753
+ padding: "5px 8px", borderRadius: 8, cursor: "pointer",
754
+ userSelect: "none", fontSize: 12.5, whiteSpace: "nowrap",
755
+ overflow: "hidden",
756
+ background: isOpen ? "rgba(255,255,255,0.06)" : undefined,
757
+ transition: "background .2s ease"
758
+ }
759
+ },
760
+ statusTag(t),
761
+ t.locked && isPending
762
+ ? React.createElement(
763
+ "span",
764
+ { style: { flex: "none", fontSize: 10, fontWeight: 600, color: "var(--dsh-st-edit-tx)", background: "rgba(245,158,11,0.10)", border: "1px solid var(--dsh-st-edit-bd)", padding: "0 6px", lineHeight: "16px", borderRadius: 6, letterSpacing: 0.3 } },
765
+ "✎ 编辑中"
766
+ )
767
+ : null,
768
+ React.createElement(
769
+ "span",
770
+ { style: { flex: "none", fontWeight: 700, color: isPending || isQSend ? p.accent : "var(--dsw-alias-label-secondary, #9aa3b2)", fontVariantNumeric: "tabular-nums" } },
771
+ "#" + t.id
772
+ ),
773
+ React.createElement(
774
+ "span",
775
+ { style: { minWidth: 0, flex: "1 1 auto", overflow: "hidden", textOverflow: "ellipsis", color: isPending || isQSend ? p.body : p.meta, textDecoration: isPending || isQSend ? "none" : "line-through", opacity: isPending || isQSend ? 1 : 0.6 } },
776
+ oneLine(t.content)
777
+ ),
778
+ React.createElement(
779
+ "span",
780
+ { style: { flex: "none", color: p.meta, fontSize: 11 } },
781
+ t.whenText
782
+ ),
783
+ React.createElement(
784
+ "span",
785
+ { style: { flex: "none", width: 18, height: 18, borderRadius: 9, textAlign: "center", fontSize: 12, lineHeight: "18px", color: "var(--dsw-alias-label-secondary, #9aa3b2)", background: "var(--dsh-btn-bg)", border: "1px solid var(--dsh-glass-bd)" } },
786
+ isOpen ? "▴" : "▾"
787
+ )
788
+ );
789
+ if (!isOpen) return row;
790
+ return [
791
+ row,
792
+ React.createElement(
793
+ "div",
794
+ {
795
+ key: "c" + t.id,
796
+ className: "dsh-qcard",
797
+ style: { border: "1px solid " + p.border, borderRadius: 8, background: "var(--dsh-qcard-bg)", padding: "8px 10px", margin: "4px 0 6px" }
798
+ },
799
+ editingId === t.id
800
+ ? [
801
+ React.createElement("textarea", {
802
+ key: "ta",
803
+ value: draftText,
804
+ onChange: function (e) { setDraft(e.target.value); },
805
+ rows: 3,
806
+ style: {
807
+ width: "100%", minHeight: 60, fontSize: 12.5, fontFamily: "inherit", lineHeight: 1.5,
808
+ color: "var(--dsw-alias-label-primary, #eceff4)", background: "var(--dsh-code-bg)",
809
+ border: "1px solid " + p.border, borderRadius: 6, padding: "6px 8px", resize: "vertical"
810
+ }
811
+ }),
812
+ React.createElement(
813
+ "div",
814
+ { key: "ef", style: { display: "flex", gap: 6, marginTop: 6, justifyContent: "flex-end" } },
815
+ btn("保存", saveEdit, busyOp === "edit", "success"),
816
+ btn("取消", cancelEdit, false)
817
+ )
818
+ ]
819
+ : React.createElement(
820
+ "div",
821
+ { style: { whiteSpace: "pre-wrap", wordBreak: "break-word", lineHeight: 1.65, fontSize: 13, color: isPending || isQSend ? p.body : p.meta } },
822
+ t.content
823
+ ),
824
+ React.createElement(
825
+ "div",
826
+ { style: { color: p.meta, fontSize: 11.5, marginTop: 4 } },
827
+ "入队 " + beijingTime(t.createdAt) + (t.scheduledAt ? " · " + t.whenText : "") + (t.sessionShort && t.sessionShort !== "未绑定" ? " · " + t.sessionShort : "") + (t.locked ? " · ✎ 编辑中 (保存/取消后释放, 期间不可派发)" : "") + (isQSend ? " · 排队发送中 (已派发, 等待会话空闲执行)" : "")
828
+ ),
829
+ isPending || isQSend
830
+ ? React.createElement(
831
+ "div",
832
+ { style: { display: "flex", gap: 6, flexWrap: "wrap", marginTop: 8, paddingTop: 8, borderTop: "1px solid rgba(255,255,255,0.06)" } },
833
+ editingId === t.id
834
+ ? [
835
+ btn("保存", saveEdit, busyOp === "edit", "success"),
836
+ btn("取消编辑", cancelEdit, false)
837
+ ]
838
+ : isPending
839
+ ? [
840
+ btn("编辑", function () { startEdit(t); }, busyOp !== null),
841
+ btn("取消", function () { act("cancel", { id: t.id }, "任务 #" + t.id + " 已取消"); }, busyOp !== null, "danger"),
842
+ btn("立即派发", function () { act("runnow", { id: t.id }, "任务 #" + t.id + " 已派发"); }, busyOp !== null, "primary")
843
+ ]
844
+ : [
845
+ React.createElement(
846
+ "span",
847
+ { key: "qsn", style: { color: p.meta, fontSize: 11.5, marginRight: "auto", alignSelf: "center" } },
848
+ "已派发, 排队等待会话空闲执行 — 可撤回取消"
849
+ ),
850
+ btn("取消", function () { act("cancel", { id: t.id }, "任务 #" + t.id + " 已取消 (已撤回排队消息)"); }, busyOp !== null, "danger")
851
+ ]
852
+ )
853
+ : null
854
+ )
855
+ ];
856
+ })
857
+ ),
858
+ React.createElement(
859
+ "div",
860
+ { style: { marginTop: 6, color: p.meta, fontSize: 11.5 } },
861
+ "兜底目标: " + (data && data.targetSessionShort && data.targetSessionShort !== "未绑定" ? data.targetSessionShort : "未设置")
862
+ )
863
+ );
864
+ });
865
+
866
+ /** 会话账本历史区默认显示条数 (超出折叠, 点「展开全部」显示全部) */
867
+ var LEDGER_HISTORY_DEFAULT_SHOW = 3;
868
+
869
+ /**
870
+ * 会话账本历史 (v0.6.0, kind=ledger 展开态渲染): 展开卡片时经 /cost-ledger RPC
871
+ * (dsh-cost-ledger, 零 token) 实时拉取共享账本 —— 任何一张旧卡片点开都与最新卡片
872
+ * 一致; RPC 不可用时回退横幅内嵌的静态快照 (标记"快照")。
873
+ * 每行: 回合 #t · MM-DD HH:mm · ¥合计 · +差值; 默认 3 条 + 展开全部 (超高滚动)。
874
+ */
875
+ var LedgerHistory = React.memo(function LedgerHistory(props) {
876
+ var p = props.p;
877
+ var sessionId = props.sessionId;
878
+ var initial = Array.isArray(props.history) ? props.history : [];
879
+ var expandedState = React.useState(false);
880
+ var expanded = expandedState[0];
881
+ var setExpanded = expandedState[1];
882
+ var dataState = React.useState(null);
883
+ var liveData = dataState[0];
884
+ var setLiveData = dataState[1];
885
+ var liveState = React.useState(false);
886
+ var isLive = liveState[0];
887
+ var setLive = liveState[1];
888
+
889
+ function load() {
890
+ var conn = pluginCtx && pluginCtx.get ? pluginCtx.get("connection") : null;
891
+ var rpc = conn && conn.rpc;
892
+ if (!rpc || typeof rpc.call !== "function" || !sessionId) return;
893
+ rpc.call("/cost-ledger", "history", { sessionId: sessionId }).then(function (result) {
894
+ if (result && result.ok && result.value && Array.isArray(result.value.entries)) {
895
+ setLiveData(result.value.entries);
896
+ setLive(true);
897
+ }
898
+ }).catch(function () { /* 保留快照 */ });
899
+ }
900
+
901
+ React.useEffect(function () { load(); }, [sessionId]);
902
+
903
+ var entries = liveData || initial;
904
+ var count = liveData && liveData.count != null ? liveData.count : initial.length;
905
+ var shown = expanded ? entries : entries.slice(0, LEDGER_HISTORY_DEFAULT_SHOW);
906
+ var rows = shown.map(function (e, i) {
907
+ return React.createElement(
908
+ "div",
909
+ { key: i, style: { display: "flex", gap: 8, fontSize: 12, lineHeight: 1.75, fontVariantNumeric: "tabular-nums", color: "var(--dsw-alias-label-primary, #eceff4)" } },
910
+ React.createElement("span", { style: { flex: "none", color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontWeight: 600, width: 52 } }, "回合 #" + e.t),
911
+ React.createElement("span", { style: { flex: "none", color: "var(--dsw-alias-label-secondary, #9aa3b2)", width: 76 } }, e.at),
912
+ React.createElement("span", { style: { flex: 1, textAlign: "right", fontWeight: 600 } }, e.total),
913
+ React.createElement("span", { style: { flex: "none", width: 64, textAlign: "right", color: "var(--dsw-alias-label-secondary, #9aa3b2)" } }, e.delta || "")
914
+ );
915
+ });
916
+ return React.createElement(
917
+ "div",
918
+ { style: { marginTop: 8, borderTop: "1px dashed rgba(20,184,166,0.25)", paddingTop: 6 } },
919
+ React.createElement(
920
+ "div",
921
+ { style: { display: "flex", alignItems: "center", gap: 6, color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontSize: 11.5, fontWeight: 600, letterSpacing: 0.3, marginBottom: 3 } },
922
+ React.createElement("span", null, "📒 历史纪录" + (isLive ? " · 实时" : "") + " · 共 " + count + " 次"),
923
+ React.createElement(
924
+ "button",
925
+ {
926
+ className: "dsh-lbtn",
927
+ onClick: function (e) { e.stopPropagation(); setExpanded(!expanded); },
928
+ style: {
929
+ marginLeft: "auto", fontSize: 11, padding: "0 8px", lineHeight: "20px", borderRadius: 7,
930
+ background: "var(--dsh-btn-bg)", border: "1px solid var(--dsh-glass-bd)",
931
+ color: "var(--dsw-alias-label-primary, #eceff4)", cursor: "pointer", fontWeight: 600,
932
+ fontFamily: "inherit", flex: "none", transition: "all .2s ease"
933
+ }
934
+ },
935
+ expanded ? "收起" : "展开全部"
936
+ )
937
+ ),
938
+ React.createElement(
939
+ "div",
940
+ { style: expanded && entries.length > 12 ? { maxHeight: 260, overflowY: "auto", scrollbarWidth: "thin" } : undefined },
941
+ rows
942
+ )
943
+ );
944
+ });
945
+
946
+ /** 主题色 (DeepSeek 蓝, 明/暗主题自适应) — 用于标识费用等关键数字 */
947
+ var THEME_ACCENT = "var(--dsw-alias-state-business-primary, #4176e6)";
948
+
949
+ // =====================================================================
950
+ // v0.11.0: 多 agent 树聚合 GUI — ledger「委托树」区 + costs 树形分组
951
+ // 数据/口径 (服务端算好行级明细与树合计, 客户端零计算):
952
+ // - ledger 委托树: /cost-ledger RPC history { sessionId, includeDescendants:true } →
953
+ // subtree { count, ids, total, at, rows:[{sid,parentSid,depth,label,total}] } —
954
+ // **行级明细由服务端算好, 客户端零计算** (row.total=子桶最新 entry.total 账本口径);
955
+ // RPC 失败/无 subtree (旧服务端忽略 includeDescendants) → 区块不渲染 (优雅降级)。
956
+ // - costs 树分组: /sessions-cost 命令 payload sessions[] 每行附 treeGroup
957
+ // { parentSid?, childCount } + fullSid + windowTreeTotal (窗口内树合计, 服务端算);
958
+ // 无 treeGroup → 平铺 (兼容旧服务端)。
959
+ // 样式: 家族变量体系 (ledger 青绿 / costs 天蓝 / meta 附注), 「子 agent」徽标青绿深浅两态
960
+ // (CSS 变量 --dsh-ct-*), 观感同预览稿 (已确认)。
961
+ var ctMoney = function (n) {
962
+ if (typeof n !== "number" || !isFinite(n)) n = 0;
963
+ return "¥" + (Math.round(n * 100) / 100).toLocaleString("zh-CN");
964
+ };
965
+ /** 短 sid (与服务端同: session- 前缀取 [8,16), 否则取前 8 字符) */
966
+ var ctShortSid = function (sid) {
967
+ var s = String(sid || "");
968
+ return s.indexOf("session-") === 0 ? s.slice(8, 16) : s.slice(0, 8);
969
+ };
970
+ /** 金额 × → 占整树百分比文本 (whole≤0 → "") */
971
+ var ctPctText = function (part, whole) {
972
+ if (!(whole > 0) || !(part > 0)) return "";
973
+ return "占 " + Math.round((part / whole) * 100) + "%";
974
+ };
975
+ /** 树形行小按钮 (委托树/子树折叠标题右侧, 复用 .dsh-ct-toggle hover) */
976
+ function ctPill(label, onClick) {
977
+ return React.createElement(
978
+ "span",
979
+ {
980
+ role: "button",
981
+ title: label,
982
+ onClick: onClick,
983
+ className: "dsh-ct-toggle dsh-lbtn",
984
+ style: {
985
+ marginLeft: "auto", fontSize: 11, padding: "0 8px", lineHeight: "20px", borderRadius: 7, flex: "none",
986
+ background: "var(--dsh-btn-bg)", border: "1px solid var(--dsh-glass-bd)",
987
+ color: "var(--dsw-alias-label-primary, #eceff4)", cursor: "pointer", fontWeight: 600,
988
+ fontFamily: "inherit", transition: "all .2s ease"
989
+ }
990
+ },
991
+ label
992
+ );
993
+ }
994
+
995
+ /**
996
+ * ledger 卡「委托树」区: 展开态内的可折叠委托树区 —
997
+ * 挂在历史区上方; 挂载即经 /cost-ledger RPC history { sessionId, includeDescendants:true }
998
+ * 实时拉取 (零 token), **有后代才渲染区块标题**, 点标题展开/收起; 行级明细 = 服务端
999
+ * subtree.rows (label/短sid/¥/占子树%/分支合计/孙行二级 dim「计入父行」), 客户端零计算。
1000
+ * 降级: RPC 失败 / 无 subtree / rows 空 (旧服务端不识别 includeDescendants) → 返回 null 不渲染。
1001
+ */
1002
+ var LedgerTree = React.memo(function LedgerTree(props) {
1003
+ var p = props.p;
1004
+ var sessionId = props.sessionId;
1005
+ var openState = React.useState(false);
1006
+ var open = openState[0];
1007
+ var setOpen = openState[1];
1008
+ var dataState = React.useState(null); // null=加载中; { empty:true }=无子树/失败; { subtree, ownTotal }
1009
+ var data = dataState[0];
1010
+ var setData = dataState[1];
1011
+
1012
+ function load() {
1013
+ var conn = pluginCtx && pluginCtx.get ? pluginCtx.get("connection") : null;
1014
+ var rpc = conn && conn.rpc;
1015
+ if (!rpc || typeof rpc.call !== "function" || !sessionId) return;
1016
+ rpc.call("/cost-ledger", "history", { sessionId: sessionId, includeDescendants: true }).then(function (result) {
1017
+ if (!result || !result.ok || !result.value) { setData({ empty: true }); return; }
1018
+ var subtree = result.value.subtree;
1019
+ if (!subtree || !Array.isArray(subtree.rows) || subtree.rows.length === 0) { setData({ empty: true }); return; }
1020
+ var ownTotal = 0;
1021
+ var entries = Array.isArray(result.value.entries) ? result.value.entries : [];
1022
+ if (entries.length > 0) {
1023
+ var n = parseFloat(String(entries[0].total || "").replace(/[^0-9.]/g, ""));
1024
+ if (isFinite(n)) ownTotal = n;
1025
+ }
1026
+ setData({ subtree: subtree, ownTotal: ownTotal });
1027
+ }).catch(function () { setData({ empty: true }); });
1028
+ }
1029
+ React.useEffect(function () { load(); }, [sessionId]);
1030
+
1031
+ if (!data || data.empty) return null; // 失败/无子树 → 区块不显示 (旧服务端兼容)
1032
+ var rows = data.subtree.rows;
1033
+ var byId = new Map();
1034
+ for (var i = 0; i < rows.length; i++) byId.set(rows[i].sid, rows[i]);
1035
+ var kidsOf = new Map();
1036
+ var roots = [];
1037
+ for (var j = 0; j < rows.length; j++) {
1038
+ var rj = rows[j];
1039
+ var par = rj.parentSid && byId.has(rj.parentSid) ? rj.parentSid : null;
1040
+ if (par) {
1041
+ var arr = kidsOf.get(par) || [];
1042
+ arr.push(rj);
1043
+ kidsOf.set(par, arr);
1044
+ } else roots.push(rj);
1045
+ }
1046
+ /** 分支合计 = 自身子桶 + 全部后代子桶 (账本口径, 每桶只计一次) */
1047
+ function branchTotal(node) {
1048
+ var s = typeof node.total === "number" ? node.total : 0;
1049
+ var kids = kidsOf.get(node.sid);
1050
+ if (kids) for (var k = 0; k < kids.length; k++) s += branchTotal(kids[k]);
1051
+ return s;
1052
+ }
1053
+ /** 展平树 (携带祖先 last 标记) → 树形线前缀 */
1054
+ function ctFlatten(nodes, pre, out) {
1055
+ nodes.forEach(function (n, idx) {
1056
+ var last = idx === nodes.length - 1;
1057
+ out.push({ n: n, last: last, pre: pre || [] });
1058
+ var kids = kidsOf.get(n.sid);
1059
+ if (kids && kids.length) ctFlatten(kids, (pre || []).concat([last]), out);
1060
+ });
1061
+ return out;
1062
+ }
1063
+ function ctGlyph(f) {
1064
+ var s = "";
1065
+ f.pre.forEach(function (l) { s += l ? " " : "│ "; });
1066
+ s += f.last ? "└ " : "├ ";
1067
+ return s;
1068
+ }
1069
+ // 服务端 subtree.total (账本口径汇总, 摘要行 ¥b 用); 「占子树 %」分母 = **客户端 rows 合计** (Σ row.total, 需求③)
1070
+ var treeTotal = data.subtree.total;
1071
+ var rowsSum = 0;
1072
+ for (var si2 = 0; si2 < rows.length; si2++) rowsSum += typeof rows[si2].total === "number" ? rows[si2].total : 0;
1073
+ var flat = ctFlatten(roots, null, []);
1074
+ var sumAmt = data.ownTotal + (typeof treeTotal === "number" ? treeTotal : 0);
1075
+ var rowEls = flat.map(function (f, idx) {
1076
+ var n = f.n;
1077
+ var own = typeof n.total === "number" ? n.total : 0;
1078
+ var branch = branchTotal(n);
1079
+ var nested = !!n.parentSid && byId.has(n.parentSid); // 挂在其他行下 (孙级 dim)
1080
+ var kids = kidsOf.get(n.sid);
1081
+ var hasKids = !!kids && kids.length > 0;
1082
+ var short = ctShortSid(n.sid);
1083
+ var label = typeof n.label === "string" && n.label && n.label !== short ? n.label : null;
1084
+ var kids2 = [
1085
+ React.createElement("span", { key: "g", className: "dsh-ct-g" }, ctGlyph(f)),
1086
+ React.createElement("span", { key: "ag", className: "dsh-ct-ag" }, "子 agent")
1087
+ ];
1088
+ if (label) kids2.push(React.createElement("span", { key: "lb", className: "dsh-ct-lb" }, label));
1089
+ else kids2.push(React.createElement("span", { key: "lb", className: "dsh-ct-lb" }, ""));
1090
+ kids2.push(React.createElement("span", { key: "sid", className: "dsh-ct-sid" }, short));
1091
+ var tag = null;
1092
+ if (hasKids) tag = "分支合计";
1093
+ else if (nested) tag = "孙 agent · 计入父行";
1094
+ if (tag) kids2.push(React.createElement("span", { key: "tag", className: "dsh-ct-tag" }, tag));
1095
+ kids2.push(React.createElement(
1096
+ "span",
1097
+ { key: "amt", className: "dsh-ct-amt", style: nested ? { flex: "none", fontWeight: 600, color: "var(--dsw-alias-label-secondary, #9aa3b2)", opacity: 0.85 } : { flex: "none", fontWeight: 700, color: "var(--dsw-alias-label-primary, #eceff4)" } },
1098
+ nested ? ctMoney(own) : ctMoney(branch)
1099
+ ));
1100
+ if (!nested) {
1101
+ var pct = ctPctText(branch, rowsSum); // 需求③: 分母 = 客户端 rows 合计 (服务端不算百分比)
1102
+ if (pct) kids2.push(React.createElement("span", { key: "pct", className: "dsh-ct-tag" }, "(" + pct + ")"));
1103
+ }
1104
+ return React.createElement("div", { key: idx, className: "dsh-ct-row" }, kids2);
1105
+ });
1106
+ var sumLine = React.createElement(
1107
+ "div",
1108
+ { style: { fontSize: 12, lineHeight: 1.8, color: "var(--dsw-alias-label-primary, #eceff4)", fontVariantNumeric: "tabular-nums", marginBottom: 2 } },
1109
+ "本次委托树合计 ",
1110
+ React.createElement("span", { style: { color: p.accent, fontWeight: 700 } }, ctMoney(sumAmt)),
1111
+ "(自身 ",
1112
+ React.createElement("b", { style: { fontWeight: 600 } }, ctMoney(data.ownTotal)),
1113
+ " + " + roots.length + " 个子 agent ",
1114
+ React.createElement("b", { style: { fontWeight: 600 } }, ctMoney(treeTotal)),
1115
+ ")· 账本口径"
1116
+ );
1117
+ return React.createElement(
1118
+ "div",
1119
+ { style: { marginTop: 8, borderTop: "1px dashed rgba(20,184,166,0.28)", paddingTop: 6 } },
1120
+ React.createElement(
1121
+ "div",
1122
+ { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", cursor: "pointer", userSelect: "none", marginBottom: 4 }, onClick: function () { setOpen(!open); } },
1123
+ React.createElement("span", null, "🌳"),
1124
+ React.createElement("span", { style: { fontSize: 11.5, fontWeight: 700, letterSpacing: 0.3, color: "var(--dsw-alias-label-primary, #eceff4)" } }, "委托树"),
1125
+ React.createElement("span", { style: { fontSize: 11, color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontWeight: 500 } }, "含 " + roots.length + " 个子 agent · 读时聚合(/cost-ledger history includeDescendants)"),
1126
+ ctPill(open ? "收起" : "展开", function (e) { if (e && e.stopPropagation) e.stopPropagation(); setOpen(!open); })
1127
+ ),
1128
+ open ? React.createElement("div", null, sumLine, rowEls) : null
1129
+ );
1130
+ });
1131
+
1132
+ /**
1133
+ * costs 树形分组手风琴: 数据 = 服务端 sessions[] 附
1134
+ * treeGroup { parentSid?, childCount } + fullSid + windowTreeTotal (窗口内树合计, 服务端算,
1135
+ * 每行只算自己不双计)。顶层行 = 窗口内无祖先的行; 行展开 = 自身高峰/低谷明细 + 自身合计 +
1136
+ * 「子树」折叠块 (缩进子会话行: 子 agent 徽标 + 标题 + 短 sid + 金额, 子行可再展开自身明细,
1137
+ * 递归支持孙行); 整卡手风琴语义保持 (同时只展开一条 openPath, 祖先行随子行保持展开)。
1138
+ * 无窗口内嵌套的行集不会进入本组件 (SessionCostList 判定, 平铺兼容旧服务端)。
1139
+ */
1140
+ var SessionTreeList = React.memo(function SessionTreeList(props) {
1141
+ var p = props.p;
1142
+ var sessions = Array.isArray(props.sessions) ? props.sessions : [];
1143
+ var openPathState = React.useState(null);
1144
+ var openPath = openPathState[0];
1145
+ var setOpenPath = openPathState[1];
1146
+ var subClosedState = React.useState(null);
1147
+ var subClosed = subClosedState[0];
1148
+ var setSubClosed = subClosedState[1];
1149
+
1150
+ var byFull = new Map();
1151
+ for (var bi = 0; bi < sessions.length; bi++) if (sessions[bi].fullSid) byFull.set(sessions[bi].fullSid, bi);
1152
+ var kidsOf = new Map();
1153
+ var roots = [];
1154
+ for (var ci = 0; ci < sessions.length; ci++) {
1155
+ var sc = sessions[ci];
1156
+ var par = sc.treeGroup && sc.treeGroup.parentSid && byFull.has(sc.treeGroup.parentSid) ? sc.treeGroup.parentSid : null;
1157
+ if (par) {
1158
+ var arr = kidsOf.get(par) || [];
1159
+ arr.push(ci);
1160
+ kidsOf.set(par, arr);
1161
+ } else roots.push(ci);
1162
+ }
1163
+ var nodeTotal = function (c) { return typeof c.windowTreeTotal === "number" ? c.windowTreeTotal : NaN; };
1164
+ var tierBlock = function (t, keyPrefix) {
1165
+ if (!t || !Array.isArray(t.lines) || t.lines.length === 0) return null;
1166
+ return React.createElement(
1167
+ "div",
1168
+ { key: keyPrefix + "tier", style: { marginTop: 4 } },
1169
+ React.createElement(
1170
+ "div",
1171
+ { style: { color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontSize: 11, fontWeight: 700, letterSpacing: 0.3, marginBottom: 1 } },
1172
+ t.label + (t.costText ? " · " + t.costText : "")
1173
+ ),
1174
+ t.lines.map(function (ln, j) {
1175
+ return React.createElement(
1176
+ "div",
1177
+ { key: j, style: { display: "flex", gap: 8, fontSize: 12, lineHeight: 1.7 } },
1178
+ React.createElement("span", { style: { color: "var(--dsw-alias-label-secondary, #9aa3b2)", flex: "none", minWidth: 76 } }, ln.k),
1179
+ React.createElement("span", { style: { flex: 1, fontVariantNumeric: "tabular-nums" } }, ln.v)
1180
+ );
1181
+ })
1182
+ );
1183
+ };
1184
+ /** 递归渲染一行 (顶层/子会话行通用): isChild=挂父下行 (带 子 agent 徽标) */
1185
+ function renderNode(idx, path, isChild) {
1186
+ var c = sessions[idx];
1187
+ var kids = kidsOf.get(c.fullSid) || [];
1188
+ var ownOpen = openPath === path;
1189
+ var onChain = ownOpen || (openPath && openPath.indexOf(path + ":") === 0);
1190
+ var hdr = [];
1191
+ if (isChild) hdr.push(React.createElement("span", { key: "ag", className: "dsh-ct-ag" }, "子 agent"));
1192
+ else if (kids.length > 0) hdr.push(React.createElement("span", { key: "ag", className: "dsh-ct-ag" }, "含 " + kids.length + " 个子 agent"));
1193
+ hdr.push(React.createElement(
1194
+ "span",
1195
+ { key: "tt", style: { minWidth: 0, flex: "1 1 auto", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } },
1196
+ c.title
1197
+ ));
1198
+ if (typeof c.sid === "string" && c.sid) hdr.push(React.createElement("span", { key: "sid", style: { flex: "none", color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontSize: 11.5 } }, "会话 " + c.sid));
1199
+ var amtNum = nodeTotal(c);
1200
+ var amtText = isFinite(amtNum) ? ctMoney(amtNum) : (c.costText || "¥—");
1201
+ hdr.push(React.createElement("span", { key: "amt", style: { flex: "none", color: p.accent, fontWeight: 700, fontVariantNumeric: "tabular-nums" } }, amtText));
1202
+ hdr.push(React.createElement("span", { key: "chev", style: { flex: "none", color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontSize: 12 } }, onChain ? "▾" : "▸"));
1203
+
1204
+ var bodyKids = [];
1205
+ if (onChain) {
1206
+ bodyKids.push(tierBlock(c.peak, path + ":p"));
1207
+ bodyKids.push(tierBlock(c.off, path + ":o"));
1208
+ bodyKids.push(React.createElement(
1209
+ "div",
1210
+ { key: "own", style: { marginTop: 5, fontSize: 12, fontWeight: 700, color: p.accent, fontVariantNumeric: "tabular-nums" } },
1211
+ "本会话合计 " + (c.costText || "¥—")
1212
+ ));
1213
+ if (kids.length > 0) {
1214
+ var childSum = 0;
1215
+ for (var kc = 0; kc < kids.length; kc++) {
1216
+ var kn = nodeTotal(sessions[kids[kc]]);
1217
+ if (isFinite(kn)) childSum += kn;
1218
+ }
1219
+ var subOpen = subClosed !== path;
1220
+ bodyKids.push(React.createElement(
1221
+ "div",
1222
+ { key: "subtree", style: { marginTop: 5, paddingLeft: 10, borderLeft: "2px solid rgba(14,165,233,0.28)" } },
1223
+ React.createElement(
1224
+ "div",
1225
+ { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", fontSize: 11, fontWeight: 700, letterSpacing: 0.3, color: "var(--dsw-alias-label-secondary, #9aa3b2)", cursor: "pointer", userSelect: "none", margin: "5px 0 2px" }, onClick: function () { setSubClosed(subOpen ? path : null); } },
1226
+ React.createElement("span", null, "🌱"),
1227
+ React.createElement("span", { style: { color: "var(--dsw-alias-label-primary, #eceff4)" } }, "子树 · 子会话(窗口内 " + kids.length + " 个 · 树合计 +" + ctMoney(childSum) + ")"),
1228
+ ctPill(subOpen ? "收起" : "展开", function (e) { if (e && e.stopPropagation) e.stopPropagation(); setSubClosed(subOpen ? path : null); })
1229
+ ),
1230
+ subOpen
1231
+ ? React.createElement(
1232
+ "div",
1233
+ { style: { display: "flex", flexDirection: "column", gap: 4, marginTop: 2 } },
1234
+ kids.map(function (kidx, k) { return renderNode(kidx, path + ":" + kidx, true); })
1235
+ )
1236
+ : null
1237
+ ));
1238
+ }
1239
+ }
1240
+ return React.createElement(
1241
+ "div",
1242
+ { key: path, className: "dsh-sc", style: { border: "1px solid rgba(255,255,255,0.08)", borderRadius: 8, background: "var(--dsh-sc-bg)", overflow: "hidden", flex: "none" } },
1243
+ React.createElement(
1244
+ "div",
1245
+ {
1246
+ className: "dsh-sch",
1247
+ role: "button",
1248
+ title: ownOpen ? "收起" : "展开",
1249
+ onClick: function () { setOpenPath(ownOpen ? null : path); },
1250
+ style: { display: "flex", alignItems: "center", gap: 8, padding: "6px 10px", cursor: "pointer", userSelect: "none", fontSize: 12.5, fontWeight: 600, color: "var(--dsw-alias-label-primary, #eceff4)", transition: "background .2s ease" }
1251
+ },
1252
+ hdr
1253
+ ),
1254
+ onChain
1255
+ ? React.createElement(
1256
+ "div",
1257
+ { style: { padding: "0 9px 7px", color: p.body, borderTop: "1px dashed rgba(255,255,255,0.1)" } },
1258
+ bodyKids
1259
+ )
1260
+ : null
1261
+ );
1262
+ }
1263
+
1264
+ var rootEls = roots.map(function (idx) { return renderNode(idx, String(idx), false); });
1265
+ return React.createElement(
1266
+ "div",
1267
+ { style: { marginTop: 6, maxHeight: 360, overflowY: "auto", scrollbarWidth: "thin", display: "flex", flexDirection: "column", gap: 4 } },
1268
+ rootEls
1269
+ );
1270
+ });
1271
+
1272
+ /** 多会话费用明细 (kind=costs 展开态, v0.6.3): 手风琴卡片式 (状态机复用 QueuePanel
1273
+ * expandedId 模式: 同时只展开一个会话, 再点收起); 每会话展开显示高峰/低谷分组 +
1274
+ * 每种类型一行 (输入/缓存命中/输出+推理, `token × 单价 = 金额`);
1275
+ * **不省略任何会话** (全量渲染), 列表超高时 maxHeight + overflowY auto 滚动
1276
+ * (同 LedgerHistory 滚动细节); 行标题 ellipsis 截断, 金额主题色。 */
1277
+ var SessionCostList = React.memo(function SessionCostList(props) {
1278
+ var p = props.p;
1279
+ var sessions = Array.isArray(props.sessions) ? props.sessions : [];
1280
+ var openState = React.useState(null);
1281
+ var expandedId = openState[0];
1282
+ var setExpandedId = openState[1];
1283
+
1284
+ // v0.11.0: 树形分组判定 — 存在 fullSid 且其 treeGroup.parentSid 指向窗口内另一行
1285
+ // → 走 SessionTreeList 树渲染; 否则平铺 (无分组字段/旧服务端 → 现行为不变)
1286
+ var treeMode = false;
1287
+ if (sessions.length > 0) {
1288
+ var fullMap = new Map();
1289
+ for (var fi = 0; fi < sessions.length; fi++) if (sessions[fi].fullSid) fullMap.set(sessions[fi].fullSid, true);
1290
+ for (var gj = 0; gj < sessions.length && !treeMode; gj++) {
1291
+ var gs = sessions[gj];
1292
+ if (gs.treeGroup && gs.treeGroup.parentSid && fullMap.has(gs.treeGroup.parentSid)) treeMode = true;
1293
+ }
1294
+ }
1295
+ if (treeMode) return React.createElement(SessionTreeList, { p: p, sessions: sessions });
1296
+
1297
+ /** 手风琴: 点会话行展开该会话 (同时只展开一个); 再点收起 */
1298
+ function toggle(i) {
1299
+ setExpandedId(expandedId === i ? null : i);
1300
+ }
1301
+
1302
+ var rows = sessions.map(function (s, i) {
1303
+ var open = expandedId === i;
1304
+ var tierBlock = function (t) {
1305
+ if (!t || !Array.isArray(t.lines) || t.lines.length === 0) return null;
1306
+ return React.createElement(
1307
+ "div",
1308
+ { key: t.label, style: { marginTop: 4 } },
1309
+ React.createElement(
1310
+ "div",
1311
+ { style: { color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontSize: 11, fontWeight: 700, letterSpacing: 0.3, marginBottom: 1 } },
1312
+ t.label + (t.costText ? " · " + t.costText : "")
1313
+ ),
1314
+ t.lines.map(function (ln, j) {
1315
+ return React.createElement(
1316
+ "div",
1317
+ { key: j, style: { display: "flex", gap: 8, fontSize: 12, lineHeight: 1.7 } },
1318
+ React.createElement("span", { style: { color: "var(--dsw-alias-label-secondary, #9aa3b2)", flex: "none", minWidth: 76 } }, ln.k),
1319
+ React.createElement("span", { style: { flex: 1, fontVariantNumeric: "tabular-nums" } }, ln.v)
1320
+ );
1321
+ })
1322
+ );
1323
+ };
1324
+ return React.createElement(
1325
+ "div",
1326
+ { key: i, className: "dsh-sc", style: { border: "1px solid rgba(255,255,255,0.08)", borderRadius: 8, background: "var(--dsh-sc-bg)", overflow: "hidden", flex: "none" } },
1327
+ React.createElement(
1328
+ "div",
1329
+ {
1330
+ className: "dsh-sch",
1331
+ role: "button",
1332
+ title: open ? "收起" : "展开",
1333
+ onClick: function () { toggle(i); },
1334
+ style: { display: "flex", alignItems: "center", gap: 8, padding: "6px 10px", cursor: "pointer", userSelect: "none", fontSize: 12.5, fontWeight: 600, color: "var(--dsw-alias-label-primary, #eceff4)", transition: "background .2s ease" }
1335
+ },
1336
+ React.createElement("span", { style: { minWidth: 0, flex: "1 1 auto", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, s.title),
1337
+ s.peakCostText && s.offCostText
1338
+ ? React.createElement("span", { style: { flex: "none", color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontSize: 11.5 } }, "高峰 " + s.peakCostText + " + 低谷 " + s.offCostText)
1339
+ : null,
1340
+ React.createElement("span", { style: { flex: "none", color: p.accent, fontWeight: 700, fontVariantNumeric: "tabular-nums" } }, s.costText),
1341
+ React.createElement("span", { style: { flex: "none", color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontSize: 12 } }, open ? "▾" : "▸")
1342
+ ),
1343
+ open
1344
+ ? React.createElement(
1345
+ "div",
1346
+ { style: { padding: "0 9px 7px", color: p.body, borderTop: "1px dashed rgba(255,255,255,0.1)" } },
1347
+ tierBlock(s.peak),
1348
+ tierBlock(s.off),
1349
+ React.createElement(
1350
+ "div",
1351
+ { style: { marginTop: 5, fontSize: 12, fontWeight: 700, color: p.accent, fontVariantNumeric: "tabular-nums" } },
1352
+ "合计 " + s.costText + (s.peakCostText && s.offCostText ? " = 高峰 " + s.peakCostText + " + 低谷 " + s.offCostText : "")
1353
+ )
1354
+ )
1355
+ : null
1356
+ );
1357
+ });
1358
+
1359
+ return React.createElement(
1360
+ "div",
1361
+ { style: { marginTop: 6, maxHeight: 360, overflowY: "auto", scrollbarWidth: "thin", display: "flex", flexDirection: "column", gap: 4 } },
1362
+ rows
1363
+ );
1364
+ });
1365
+
1366
+
1367
+ /** 折叠状态: 按横幅 context key 存模块级 Map (会话内跨重渲染保留, 不持久化到事件) */
1368
+ var collapseByKey = new Map();
1369
+
1370
+ /** 横幅卡片 (家族同色同款: 图标 + 徽章 + 标题 + [统计格/键值行/明细] + 元信息 + 建议);
1371
+ * 点击标题行折叠/展开 (折叠后只留一行: 图标+徽章+标题+关键值+箭头, 节约空间);
1372
+ * strong 统计格/折叠关键值用主题色标识 (费用等关键信息) */
1373
+ var NoticeBannerView = React.memo(function NoticeBannerView(props) {
1374
+ var node = props.node;
1375
+ var banner = node && node.data;
1376
+ if (!banner || typeof banner !== "object") return null;
1377
+ var key = node && node.key != null ? String(node.key) : (node && node.id != null ? String(node.id) : "");
1378
+ var tick = React.useState(0);
1379
+ var setTick = tick[1];
1380
+ var kind = banner.kind === "cost" ? "cost" : banner.kind === "queue" ? "queue" : banner.kind === "balance" ? "balance" : banner.kind === "error" ? "error" : banner.kind === "ledger" ? "ledger" : banner.kind === "costs" ? "costs" : banner.kind === "status" ? "status" : banner.kind === "restart" ? "restart" : "notify";
1381
+ // v0.6.0: ledger 会话账本默认折叠 (节省空间, 多张卡不刷屏);
1382
+ // v0.6.2: costs 多会话费用 (dsh-sessions-cost) 同样默认折叠 (明细行多, 一行只露窗口合计);
1383
+ // v0.6.3: costs 展开态 = SessionCostList 手风琴 (每会话一行可展开, 每类型一行明细, 不省略, 可滚动)
1384
+ // 用户手动展开 (map=false) 后保持展开, 再次点击折叠 (map=true)
1385
+ var defaultCollapse = kind === "ledger" || (kind === "costs");
1386
+ var collapsed = key !== "" && (defaultCollapse ? collapseByKey.get(key) !== false : collapseByKey.get(key) === true);
1387
+ // 队列横幅 (kind=queue) 的可编辑面板开关 (v0.4.0): 内嵌实时任务队列,
1388
+ // 排队任务可编辑/取消/立即派发, 已派发只读。
1389
+ // v0.5.1: banner.openPanel===true (queue_list 注入) → 横幅出现即展开手风琴面板
1390
+ var panelState = React.useState(banner && banner.openPanel === true);
1391
+ var panelOpen = panelState[0];
1392
+ var setPanelOpen = panelState[1];
1393
+ var p = PALETTE[kind];
1394
+ var badge = BADGES[kind] || "通知";
1395
+ if (kind === "balance") {
1396
+ badge = banner.mode === "detail" ? "余额明细" : banner.mode === "session" ? "会话费用" : banner.mode === "stats" ? "参数统计" : banner.mode === "test" ? "计算验证" : "余额";
1397
+ }
1398
+ var icon = ICONS[kind] || "";
1399
+ var meta = metaOf(banner);
1400
+ var lines = Array.isArray(banner.lines) ? banner.lines : [];
1401
+ var stats = Array.isArray(banner.stats) ? banner.stats : [];
1402
+ var kv = Array.isArray(banner.kv) ? banner.kv : [];
1403
+ var title = banner.title || "";
1404
+ var subtitle = typeof banner.subtitle === "string" && banner.subtitle ? banner.subtitle : "";
1405
+ // 折叠摘要关键值: 优先 key 标记 (结论), 否则首个 strong, 否则首个统计格值
1406
+ var keyValue = "";
1407
+ for (var si = 0; si < stats.length; si++) {
1408
+ if (stats[si].key) { keyValue = stats[si].value; break; }
1409
+ }
1410
+ if (!keyValue) {
1411
+ for (var sj = 0; sj < stats.length; sj++) {
1412
+ if (stats[sj].strong) { keyValue = stats[sj].value; break; }
1413
+ }
1414
+ }
1415
+ if (!keyValue && stats.length > 0) keyValue = stats[0].value;
1416
+ // v0.11.1: ledger 折叠行 = 「含树合计」+ 差值 + 精简 —
1417
+ // · 折叠态去副题小字 (会话id/档位/命中率 → 展开态才显示, 见下方标题行渲染);
1418
+ // · 主数字 = 第1格「合计预估」(本会话) + 第4格「含子 agent」子树合计 (账本口径, 不双计),
1419
+ // 有树时主数字套淡青绿胶囊底 (无文字标识); 无子会话 = 仅本会话合计、无胶囊 (与旧观感一致);
1420
+ // · 差值 = 第2格「本回合」较上次 (自身口径, 与展开第2格一致; 首次记账 "—" 不显示);
1421
+ // 数据源 = banner payload stats (服务端已含, 零 RPC); 解析失败 → 降级叶子形态。
1422
+ var ledMain = null; // { text, chip, title }
1423
+ var ledDelta = null;
1424
+ if (kind === "ledger" && stats.length > 0) {
1425
+ var treeStat2 = null;
1426
+ for (var tl = 0; tl < stats.length; tl++) { if (stats[tl].label === "含子 agent") { treeStat2 = stats[tl]; break; } }
1427
+ var ownNum2 = parseFloat(String(stats[0].value || "").replace(/[^0-9.]/g, ""));
1428
+ var chip2 = null;
1429
+ if (treeStat2 && isFinite(ownNum2)) {
1430
+ var tv2 = String(treeStat2.value || "");
1431
+ var mTree = tv2.match(/树合计\s*[++−-]?\s*¥?\s*([\d.]+)/);
1432
+ var mCnt = tv2.match(/(\d+)\s*个/);
1433
+ var treeNum2 = mTree ? parseFloat(mTree[1]) : NaN;
1434
+ if (isFinite(treeNum2)) {
1435
+ chip2 = {
1436
+ sumText: "¥" + (Math.round((ownNum2 + treeNum2) * 100) / 100).toFixed(2),
1437
+ count: mCnt ? mCnt[1] : "N",
1438
+ ownText: "¥" + ownNum2.toFixed(2),
1439
+ treeText: "¥" + treeNum2.toFixed(2)
1440
+ };
1441
+ }
1442
+ }
1443
+ if (chip2) {
1444
+ ledMain = { text: chip2.sumText, chip: true, title: "合计 " + chip2.sumText + " = 本会话 " + chip2.ownText + " + " + chip2.count + " 个子 agent " + chip2.treeText + "(账本口径 · 不双计)" };
1445
+ } else {
1446
+ ledMain = { text: stats[0].value || "", chip: false, title: "" };
1447
+ }
1448
+ for (var dl = 0; dl < stats.length; dl++) { if (stats[dl].label === "本回合") { ledDelta = stats[dl].value && stats[dl].value !== "—" ? stats[dl].value : null; break; } }
1449
+ if (ledDelta == null && stats.length > 1) ledDelta = stats[1].value && stats[1].value !== "—" ? stats[1].value : null;
1450
+ keyValue = ""; // ledger 折叠行走专用簇渲染 (下方 header 分支)
1451
+ }
1452
+ // ============ v0.7: cost v2 双模式 (banner.modes 存在即 v2 布局) ============
1453
+ var v2 = kind === "cost" && Array.isArray(banner.modes) && banner.modes.length >= 2;
1454
+ var v2TitleColor = v2 ? (banner.status === "A" ? "#ef4444" : banner.status === "B" ? "#22c55e" : "#b45309") : null;
1455
+ var turnsN = typeof banner.turns === "number" ? banner.turns : 5;
1456
+ var fmtMoney2 = function (n) { return typeof n === "number" ? "¥" + (Math.round(n * 100) / 100).toFixed(2) : "—"; };
1457
+ var fmtTokens2 = function (n) { return typeof n === "number" ? Math.round(n / 1000).toLocaleString("zh-CN") + "k" : "—"; };
1458
+ var modeChip = function (conclusion) {
1459
+ // v0.7.3: 淡色背景 + 深色文字 (浅色主题友好, 深色主题同样醒目)
1460
+ return conclusion === "switch"
1461
+ ? { t: "切换", c: "#92400e", bg: "#fde68a", bd: "#d97706" }
1462
+ : { t: "继续", c: "#14532d", bg: "#bbf7d0", bd: "#16a34a" };
1463
+ };
1464
+ // 按钮: /handoff 仅在"建议切换"面板显示; /costguard-stats 常驻裸数据行右侧。
1465
+ // 填输入框: 官方 inputActions.setDraft 优先 (会话槽 props), DOM 兜底; 已有文字 → 开头插入 "text "。
1466
+ var inputActions = props && props.inputActions;
1467
+ var fillHandoff = function () {
1468
+ var cur = composerDraftText();
1469
+ var next = cur ? "/handoff " + cur : "/handoff";
1470
+ if (inputActions && typeof inputActions.setDraft === "function") inputActions.setDraft(next);
1471
+ else writeComposerDom(next);
1472
+ focusComposer();
1473
+ };
1474
+ // v0.8.1: 按钮改为 /costguard-test (计算验证, 与"是否切换"判断最相关); /costguard-stats 命令保留, 可手动调用
1475
+ var fillTest = function () {
1476
+ if (inputActions && typeof inputActions.setDraft === "function") inputActions.setDraft("/costguard-test");
1477
+ else writeComposerDom("/costguard-test");
1478
+ focusComposer();
1479
+ };
1480
+ var raw = banner.raw || {};
1481
+ var v2Body = v2 ? React.createElement("div", null,
1482
+ // 区域二: 双建议面板 (固定左右两列)
1483
+ React.createElement("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8, margin: "8px 0 6px" } },
1484
+ banner.modes.map(function (m, i) {
1485
+ var chip = modeChip(m.conclusion);
1486
+ var rows = [
1487
+ ["继续 " + turnsN + " 回合", fmtMoney2(m.continue5), "strong"],
1488
+ ["切换 " + turnsN + " 回合", fmtMoney2(m.switch5), ""],
1489
+ ["切换可省", fmtMoney2(m.diff), "diff"]
1490
+ ];
1491
+ return React.createElement("div", { key: i, className: "dsh-mode", style: { background: "var(--dsh-mode-bg)", border: "1px solid rgba(255,255,255,0.06)", borderRadius: 10, padding: "8px 10px", minWidth: 0, display: "flex", flexDirection: "column", backdropFilter: "blur(4px)", WebkitBackdropFilter: "blur(4px)" } },
1492
+ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 6, fontSize: 12.5, fontWeight: 600, color: p.body, marginBottom: 4 } },
1493
+ React.createElement("span", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, m.name + (m.tag ? "(" + m.tag + ")" : "")),
1494
+ React.createElement("span", { style: { marginLeft: "auto", flex: "none", fontSize: 12, fontWeight: 700, padding: "0 10px", lineHeight: "20px", borderRadius: 10, letterSpacing: 0.3, color: chip.c, background: chip.bg, border: "1px solid " + chip.bd, boxShadow: "0 1px 6px rgba(0,0,0,0.2)", fontVariantNumeric: "tabular-nums" } }, chip.t)
1495
+ ),
1496
+ rows.map(function (row, j) {
1497
+ return React.createElement("div", { key: j, style: { display: "flex", justifyContent: "space-between", gap: 8, fontSize: 12.5, lineHeight: 1.75, fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap" } },
1498
+ React.createElement("span", { style: { color: p.meta, flex: "none" } }, row[0]),
1499
+ React.createElement("span", { style: { fontWeight: 700, ...(row[2] === "strong" ? { color: p.accent } : row[2] === "diff" ? { color: "#b45309" } : { color: "var(--dsw-alias-label-primary, #eceff4)" }) } }, row[1])
1500
+ );
1501
+ }),
1502
+ m.conclusion === "switch"
1503
+ ? React.createElement("div", { className: "dsh-hbtn", role: "button", title: "把 /handoff 填入输入框 (执行前可编辑)", onClick: fillHandoff, style: { marginTop: 5, alignSelf: "flex-end", fontSize: 11, padding: "0 10px", lineHeight: "22px", borderRadius: 8, background: "#fde68a", border: "1px solid #d97706", color: "#92400e", boxShadow: "0 1px 6px rgba(0,0,0,0.2)", cursor: "pointer", fontWeight: 700, userSelect: "none", transition: "all .2s ease" } }, "执行 /handoff")
1504
+ : null
1505
+ );
1506
+ })
1507
+ ),
1508
+ // 区域三: 左下裸数据 + 右下 /costguard-stats 按钮
1509
+ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 10, marginTop: 4 } },
1510
+ React.createElement("div", { style: { flex: 1, minWidth: 0, color: p.meta, fontSize: 11, lineHeight: 1.6 } },
1511
+ "当前回合 ", React.createElement("b", { style: { color: p.body, fontWeight: 600, fontVariantNumeric: "tabular-nums" } }, fmtMoney2(raw.turn)),
1512
+ " · 累计 ", React.createElement("b", { style: { color: p.body, fontWeight: 600, fontVariantNumeric: "tabular-nums" } }, fmtMoney2(raw.cum)),
1513
+ " · 上下文 ", React.createElement("b", { style: { color: p.body, fontWeight: 600, fontVariantNumeric: "tabular-nums" } }, fmtTokens2(raw.ctx)),
1514
+ " · 回合 ", React.createElement("b", { style: { color: p.body, fontWeight: 600, fontVariantNumeric: "tabular-nums" } }, raw.turns)
1515
+ ),
1516
+ React.createElement("span", { className: "dsh-sbtn", role: "button", title: "查看 cost-guard 计算验证", onClick: fillTest, style: { flex: "none", fontSize: 11, padding: "0 10px", lineHeight: "22px", borderRadius: 8, background: "#fde68a", border: "1px solid #d97706", color: "#92400e", boxShadow: "0 1px 6px rgba(0,0,0,0.2)", cursor: "pointer", fontWeight: 700, userSelect: "none", transition: "all .2s ease" } }, "/costguard-test")
1517
+ ),
1518
+ // 底部辅助说明 (仅状态 C)
1519
+ banner.helper
1520
+ ? React.createElement("div", { style: { marginTop: 6, color: "#b45309", fontSize: 12, lineHeight: 1.6, borderTop: "1px dashed rgba(245,158,11,0.25)", paddingTop: 5 } }, banner.helper)
1521
+ : null
1522
+ ) : null;
1523
+ var toggle = function () {
1524
+ if (key === "") return;
1525
+ collapseByKey.set(key, !(collapseByKey.get(key) === true));
1526
+ setTick(function (v) { return v + 1; });
1527
+ };
1528
+ // v0.8.1: 状态迷你行 (kind=status, cost-guard "费用计算中…" 气泡) — 仿 think/bash 灰色小字,
1529
+ // running 态 ⟳ 旋转 + 扫光; ok 态 ✓; 无卡片样式/不可折叠, 仅一行小字。
1530
+ if (kind === "status") {
1531
+ var stRunning = banner.state === "running";
1532
+ return React.createElement(
1533
+ "div",
1534
+ {
1535
+ "data-notice-banner": "status",
1536
+ "data-family": "status",
1537
+ "data-state": stRunning ? "running" : "ok",
1538
+ className: "dsh-status",
1539
+ style: {
1540
+ display: "flex",
1541
+ alignItems: "center",
1542
+ gap: 6,
1543
+ fontSize: 12,
1544
+ lineHeight: "22px",
1545
+ color: "var(--dsw-alias-label-tertiary, #9aa3b2)",
1546
+ padding: "2px 0"
1547
+ }
1548
+ },
1549
+ React.createElement("span", { style: { flex: "none", fontSize: 12, lineHeight: 1, ...(stRunning ? { animation: "1.2s linear infinite dsh-status-spin", display: "inline-block" } : {}) } }, stRunning ? "⟳" : "✓"),
1550
+ React.createElement("span", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, banner.text || "")
1551
+ );
1552
+ }
1553
+ return React.createElement(
1554
+ "div",
1555
+ {
1556
+ "data-notice-banner": kind,
1557
+ "data-family": kind,
1558
+ "data-collapsed": collapsed ? "true" : undefined,
1559
+ className: "dsh-banner",
1560
+ style: {
1561
+ border: "1px solid " + p.border,
1562
+ background: p.bg,
1563
+ borderRadius: 12,
1564
+ padding: "12px 16px",
1565
+ fontSize: 13,
1566
+ lineHeight: 1.6,
1567
+ maxWidth: "100%",
1568
+ wordBreak: "break-word",
1569
+ boxShadow: "0 2px 12px rgba(0,0,0,0.08)",
1570
+ backdropFilter: "blur(12px)",
1571
+ WebkitBackdropFilter: "blur(12px)",
1572
+ transition: "box-shadow .3s ease, border-color .3s ease"
1573
+ }
1574
+ },
1575
+ React.createElement(
1576
+ "div",
1577
+ {
1578
+ role: "button",
1579
+ title: collapsed ? "展开" : "折叠",
1580
+ onClick: toggle,
1581
+ style: {
1582
+ display: "flex",
1583
+ alignItems: "center",
1584
+ gap: 8,
1585
+ fontWeight: 600,
1586
+ fontSize: 13.5,
1587
+ cursor: "pointer",
1588
+ userSelect: "none",
1589
+ minHeight: 30,
1590
+ marginBottom: collapsed ? 0 : 6,
1591
+ color: "var(--dsw-alias-label-primary, #e6e8ec)",
1592
+ ...(v2 ? { whiteSpace: "nowrap" } : {})
1593
+ }
1594
+ },
1595
+ icon
1596
+ ? React.createElement("span", { style: { fontSize: 16, flex: "none", lineHeight: 1 } }, icon)
1597
+ : null,
1598
+ React.createElement(
1599
+ "span",
1600
+ {
1601
+ style: {
1602
+ background: p.accent,
1603
+ color: p.badgeText,
1604
+ fontSize: 10.5,
1605
+ fontWeight: 700,
1606
+ padding: "0 10px",
1607
+ borderRadius: 10,
1608
+ letterSpacing: 0.4,
1609
+ flex: "none",
1610
+ lineHeight: "18px"
1611
+ }
1612
+ },
1613
+ badge
1614
+ ),
1615
+ React.createElement(
1616
+ "span",
1617
+ { style: v2 ? { flex: "none", whiteSpace: "nowrap", color: v2TitleColor, fontWeight: 700 } : { minWidth: 0, flex: "1 1 auto" } },
1618
+ title,
1619
+ v2
1620
+ ? banner.trigger
1621
+ ? React.createElement(
1622
+ "span",
1623
+ { style: { fontWeight: 500, color: p.meta, fontSize: 12, marginLeft: 6, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", maxWidth: "42%" } },
1624
+ banner.trigger
1625
+ )
1626
+ : null
1627
+ : subtitle && !(collapsed && kind === "ledger") // v0.11.1: ledger 折叠态去副题小字
1628
+ ? React.createElement(
1629
+ "small",
1630
+ { style: { fontWeight: 500, color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontSize: 12, marginLeft: 4 } },
1631
+ subtitle
1632
+ )
1633
+ : null
1634
+ ),
1635
+ collapsed && kind === "ledger" && ledMain && ledMain.text
1636
+ ? [
1637
+ // v0.11.1: 主数字 = 含树合计 (胶囊底, 无文字标识) / 叶子 = 本会话合计 (无胶囊)
1638
+ React.createElement(
1639
+ "span",
1640
+ { key: "lm", title: ledMain.title || undefined, style: ledMain.chip
1641
+ ? { color: "var(--dsh-lk-tx)", background: "var(--dsh-lk-bg)", border: "1px solid var(--dsh-lk-bd)", fontWeight: 700, fontSize: 13, flex: "none", padding: "0 8px", borderRadius: 8, lineHeight: "20px", fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap", cursor: "help" }
1642
+ : { color: p.accent, fontWeight: 700, flex: "none", marginLeft: 4, fontSize: 13, fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap" } },
1643
+ ledMain.text
1644
+ ),
1645
+ // 差值 = 本回合较上次 (自身口径, 次级色弱化)
1646
+ ledDelta
1647
+ ? React.createElement("span", { key: "ld", style: { color: "var(--dsw-alias-label-secondary, #9aa3b2)", fontWeight: 600, fontSize: 12, flex: "none", fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap" } }, ledDelta)
1648
+ : null
1649
+ ]
1650
+ : collapsed && keyValue
1651
+ ? React.createElement(
1652
+ "span",
1653
+ { style: { color: p.accent, fontWeight: 700, flex: "none", marginLeft: 4, fontSize: 13, fontVariantNumeric: "tabular-nums" } },
1654
+ keyValue
1655
+ )
1656
+ : null,
1657
+ kind === "queue"
1658
+ ? React.createElement(
1659
+ "span",
1660
+ {
1661
+ className: "dsh-qbtn",
1662
+ role: "button",
1663
+ title: panelOpen ? "收起任务队列" : "查看/编辑任务队列",
1664
+ onClick: function (e) {
1665
+ e.stopPropagation();
1666
+ setPanelOpen(!panelOpen);
1667
+ },
1668
+ style: {
1669
+ flex: "none",
1670
+ fontSize: 11,
1671
+ padding: "0 10px",
1672
+ lineHeight: "22px",
1673
+ borderRadius: 8,
1674
+ background: "var(--dsh-btn-bg)",
1675
+ border: "1px solid var(--dsh-glass-bd)",
1676
+ color: "var(--dsw-alias-label-primary, #eceff4)",
1677
+ cursor: "pointer",
1678
+ fontWeight: 600,
1679
+ userSelect: "none",
1680
+ backdropFilter: "blur(4px)",
1681
+ WebkitBackdropFilter: "blur(4px)",
1682
+ transition: "all .2s ease"
1683
+ }
1684
+ },
1685
+ panelOpen ? "收起" : "队列"
1686
+ )
1687
+ : null,
1688
+ React.createElement(
1689
+ "span",
1690
+ {
1691
+ className: "dsh-arr",
1692
+ style: {
1693
+ marginLeft: "auto",
1694
+ flex: "none",
1695
+ fontSize: 14,
1696
+ lineHeight: "22px",
1697
+ width: 22,
1698
+ height: 22,
1699
+ textAlign: "center",
1700
+ borderRadius: 11,
1701
+ background: "var(--dsh-btn-bg)",
1702
+ border: "1px solid var(--dsh-glass-bd)",
1703
+ color: "var(--dsw-alias-label-secondary, #9aa3b2)",
1704
+ transition: "all .25s ease"
1705
+ }
1706
+ },
1707
+ collapsed ? "▸" : "▾"
1708
+ )
1709
+ ),
1710
+ collapsed
1711
+ ? null
1712
+ : v2Body,
1713
+ collapsed
1714
+ ? null
1715
+ : !v2 && stats.length > 0
1716
+ ? React.createElement(
1717
+ "div",
1718
+ { style: { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(110px, 1fr))", gap: 6, marginBottom: 4 } },
1719
+ stats.map(function (s, i) {
1720
+ return React.createElement(
1721
+ "div",
1722
+ {
1723
+ key: i,
1724
+ className: "dsh-stat",
1725
+ style: {
1726
+ background: s.bg || "var(--dsh-stat-bg)",
1727
+ border: s.border || "1px solid rgba(255,255,255,0.06)",
1728
+ borderRadius: 8,
1729
+ padding: "5px 10px",
1730
+ backdropFilter: "blur(4px)",
1731
+ WebkitBackdropFilter: "blur(4px)"
1732
+ }
1733
+ },
1734
+ React.createElement("div", { style: { color: p.meta, fontSize: 11 } }, s.label),
1735
+ React.createElement(
1736
+ "div",
1737
+ {
1738
+ style: {
1739
+ fontSize: s.size || 14,
1740
+ fontWeight: 700,
1741
+ marginTop: 1,
1742
+ fontVariantNumeric: "tabular-nums",
1743
+ ...(s.color ? { color: s.color } : s.strong ? { color: THEME_ACCENT } : {})
1744
+ }
1745
+ },
1746
+ s.value,
1747
+ s.note
1748
+ ? React.createElement(
1749
+ "small",
1750
+ { style: { fontWeight: 500, color: p.meta, fontSize: 11, marginLeft: 3 } },
1751
+ s.note
1752
+ )
1753
+ : null
1754
+ )
1755
+ );
1756
+ })
1757
+ )
1758
+ : null,
1759
+ collapsed
1760
+ ? null
1761
+ : !v2 && kv.length > 0
1762
+ ? React.createElement(
1763
+ "div",
1764
+ { style: { color: p.body, marginTop: 4 } },
1765
+ kv.map(function (row, i) {
1766
+ return React.createElement(
1767
+ "div",
1768
+ { key: i, style: { display: "flex", gap: 8, fontSize: 12.5, marginTop: 3 } },
1769
+ React.createElement("span", { style: { color: p.meta, flex: "none", minWidth: 68 } }, row.k),
1770
+ React.createElement("span", { style: { flex: 1, fontVariantNumeric: "tabular-nums" } }, row.v)
1771
+ );
1772
+ })
1773
+ )
1774
+ : null,
1775
+ collapsed
1776
+ ? null
1777
+ : kind === "ledger" && banner.sessionId
1778
+ ? React.createElement(LedgerTree, { p: p, sessionId: banner.sessionId })
1779
+ : null,
1780
+ collapsed
1781
+ ? null
1782
+ : kind === "ledger" && (Array.isArray(banner.history) || banner.sessionId)
1783
+ ? React.createElement(LedgerHistory, { p: p, sessionId: banner.sessionId, history: banner.history })
1784
+ : null,
1785
+ collapsed
1786
+ ? null
1787
+ : kind === "costs" && Array.isArray(banner.sessions) && banner.sessions.length > 0
1788
+ ? React.createElement(SessionCostList, { p: p, sessions: banner.sessions })
1789
+ : null,
1790
+ collapsed
1791
+ ? null
1792
+ : !v2 && lines.length > 0
1793
+ ? React.createElement(
1794
+ "div",
1795
+ { style: { color: p.body, ...(stats.length > 0 || kv.length > 0 ? { marginTop: 4 } : {}) } },
1796
+ lines.map(function (line, i) {
1797
+ return React.createElement(
1798
+ "div",
1799
+ { key: i, style: { whiteSpace: "pre-wrap" } },
1800
+ line
1801
+ );
1802
+ })
1803
+ )
1804
+ : null,
1805
+ collapsed
1806
+ ? null
1807
+ : React.createElement(
1808
+ "div",
1809
+ { style: { color: p.meta, fontSize: 12, marginTop: 6 } },
1810
+ meta.text ? React.createElement("div", null, meta.text) : null,
1811
+ meta.advice
1812
+ ? React.createElement(
1813
+ "div",
1814
+ { style: { marginTop: 2, color: "#5b8bf0" } },
1815
+ meta.advice
1816
+ )
1817
+ : null
1818
+ ),
1819
+ !collapsed && kind === "queue" && panelOpen
1820
+ ? React.createElement(QueuePanel, { p: p })
1821
+ : null,
1822
+ !collapsed && kind === "restart"
1823
+ ? React.createElement(RestartPanel, { p: p, banner: banner })
1824
+ : null
1825
+ );
1826
+ });
1827
+
1828
+ /** conversation node 定义: 匹配 notice/banner 事件, 产出 kind="notice-banner" 的 chat 节点 */
1829
+ var noticeBannerDefinition = {
1830
+ kind: "notice-banner-context",
1831
+ target: "chat",
1832
+ // 费用横幅 (kind=cost) v0.10 起: **每事件独立 context** (id="cost-<seq>", role=start),
1833
+ // 含 banner-replace 也按 start 渲染 — 修复根因: 旧语义只有 rev=0 是 start (id="cost"),
1834
+ // 后续永远 banner-replace (update); 客户端会话窗口只加载末尾 50 条消息, start 在窗口外时
1835
+ // update 被 surface 静默丢弃 → 重启/换窗口后横幅永不渲染。
1836
+ // 展示节奏仍由服务端控制: A 每回合发 / C 首次发一次 / B 不发; 每次发射都可见一张卡。
1837
+ // 状态迷你行 (kind=status) v0.10 起按回合分组: 服务端每回合首条发 start (payload 带 turn),
1838
+ // id="costguard-status-<turn>", 同回合 ok 为 update 原地替换 → 每回合一条灰线;
1839
+ // 旧无 turn 的 replace 忽略 (无 start 可更新, 不堆叠历史行), 旧无 turn 的 start 用 seq 兜底。
1840
+ // notify/queue/balance/error 横幅: 每事件独立 context, 全部保留。
1841
+ // (notify/queue 沿用 "notify-<seq>" id 前缀以兼容已持久化历史; balance/error 用各自前缀)
1842
+ // v0.6.0: ledger 会话账本同样每事件独立 context (ledger-<seq>), 每回合一张不替换
1843
+ // v0.9.1: 优雅重启 (kind=restart) — context id 用排程实例 scheduleId,
1844
+ // 每次排程独立横幅 (start + 同 scheduleId 的 replace 原地更新), 不串历史排程 (v0.9.1 修复)
1845
+ match: function (event) {
1846
+ if (event.type === "notice/banner") {
1847
+ var d = event.data;
1848
+ var kind = d && d.kind;
1849
+ // v0.10: 按回合分组 (新事件带 turn); 旧无 turn 事件 (会话首条) 用 seq 兜底
1850
+ if (kind === "status") return { id: "costguard-status-" + (d && d.turn != null ? d.turn : event.seq), role: "start" };
1851
+ if (kind === "restart") return { id: "restart-" + (d && d.scheduleId ? d.scheduleId : event.seq), role: "start" };
1852
+ if (kind === "ledger") return { id: "ledger-" + event.seq, role: "start" };
1853
+ if (kind === "cost") return { id: "cost-" + event.seq, role: "start" };
1854
+ var prefix = kind === "balance" ? "balance" : kind === "error" ? "error" : kind === "costs" ? "costs" : "notify";
1855
+ return { id: prefix + "-" + event.seq, role: "start" };
1856
+ }
1857
+ if (event.type === "notice/banner-replace") {
1858
+ if (event.data && event.data.kind === "status") {
1859
+ var t = event.data.turn;
1860
+ return t != null ? { id: "costguard-status-" + t, role: "update" } : null;
1861
+ }
1862
+ if (event.data && event.data.kind === "restart") return { id: "restart-" + (event.data.scheduleId ? event.data.scheduleId : "legacy"), role: "update" };
1863
+ // v0.10: cost replace 也按独立 context start 渲染 (见上)
1864
+ return { id: "cost-" + event.seq, role: "start" };
1865
+ }
1866
+ return null;
1867
+ },
1868
+ start: function (_context, match) {
1869
+ // v0.10.1: 允许 notice/banner-replace 作为 start (cost 横幅自渲染, 见 match);
1870
+ // 修复 v0.10.0 bug: cost replace 映射 role="start" 后, 旧版 start() 只认 notice/banner,
1871
+ // 对 replace 抛错 → 会话窗口装配失败 → 历史加载失败
1872
+ if (match.event.type !== "notice/banner" && match.event.type !== "notice/banner-replace") throw new Error("notice-banner start requires notice/banner or notice/banner-replace");
1873
+ var event = match.event;
1874
+ return { seq: event.seq, time: event.time, banner: event.data };
1875
+ },
1876
+ update: function (_context, match) {
1877
+ // 新的费用提醒数据整体替换旧数据 (原地替换, anchor 移到最新事件位置)
1878
+ var event = match.event;
1879
+ return { seq: event.seq, time: event.time, banner: event.data };
1880
+ },
1881
+ buildViewNode: function (context) {
1882
+ if (context.state === void 0) return null;
1883
+ return {
1884
+ key: context.key,
1885
+ kind: "notice-banner",
1886
+ id: context.id,
1887
+ target: "chat",
1888
+ anchorSeq: context.state.seq,
1889
+ location: context.start ? context.start.location : { kind: "unresolved" },
1890
+ visibility: "visible",
1891
+ data: context.state.banner
1892
+ };
1893
+ }
1894
+ };
1895
+
1896
+ /** 运行时服务注入 (client 插件契约); connection = 浏览器端通用 RPC (队列面板用) */
1897
+ var inject = ["slots", "conversationEvents", "connection"];
1898
+
1899
+ /** client 插件主体: 注册节点定义 + 横幅渲染槽位 */
1900
+ function apply(ctx) {
1901
+ pluginCtx = ctx; // 队列面板经 ctx.get("connection").rpc 调用服务端 /queue 通道
1902
+ injectGlassCss(); // v0.8.0 液态玻璃 v2 样式 (幂等)
1903
+ ctx.conversationEvents.register(noticeBannerDefinition);
1904
+ ctx.slots.inject("conversation.chat.node", function () {
1905
+ return ctx.slots.register({
1906
+ name: "conversation.chat.node",
1907
+ key: "notice-banner"
1908
+ }, NoticeBannerView);
1909
+ });
1910
+ }
1911
+
1912
+ exports.inject = inject;
1913
+ exports.apply = apply;
1914
+ // v0.11.0: 冒烟测试专用导出 (仅 window.__DSH_SMOKE__ 置位时, 生产浏览器不置位不启用)
1915
+ if (typeof window !== "undefined" && window.__DSH_SMOKE__) {
1916
+ exports.__test = {
1917
+ NoticeBannerView: NoticeBannerView,
1918
+ LedgerTree: LedgerTree,
1919
+ SessionCostList: SessionCostList,
1920
+ SessionTreeList: SessionTreeList,
1921
+ ctMoney: ctMoney,
1922
+ ctShortSid: ctShortSid,
1923
+ ctPctText: ctPctText
1924
+ };
1925
+ }
1926
+ return module.exports;
1927
+ }
1928
+ });