@liuchen64/dsh-session-cost 0.0.0-stage → 0.2.3

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.
@@ -0,0 +1,8 @@
1
+ # 会话金额预估插件:在输入框下方显示本轮 / 本会话金额
2
+ #
3
+ # 这里只声明一行 Host 插件;config 由 apply(ctx, config) 接收。
4
+ # 插件生效后仍显示在「插件」列表里,可用 set_plugin 禁用。
5
+ - insert:
6
+ - id: session-cost
7
+ name: "@liuchen64/dsh-session-cost"
8
+ config: {}
package/dist/client.js ADDED
@@ -0,0 +1,613 @@
1
+ // 由 scripts/build-client.mjs 生成,请勿手改
2
+ window.__ModuleLoader__.load({
3
+ id: "@liuchen64/dsh-session-cost",
4
+ factory(require) {
5
+ const module = { exports: {} };
6
+ const exports = module.exports;
7
+ const __defs = {
8
+ "packages/plugin-ui/dist/button.js": function (module, exports, __require) {
9
+ "use strict";
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.Button = Button;
12
+ const react_1 = require("react");
13
+ const h = react_1.createElement;
14
+ const VARIANT_CLASS = {
15
+ ghost: 'pui-btn',
16
+ outline: 'pui-btn pui-btnOutline',
17
+ primary: 'pui-btn pui-btnPrimary',
18
+ };
19
+ /** 36px 高的按钮,hover/禁用与设置面板一致 */
20
+ function Button(props) {
21
+ return h('button', {
22
+ type: 'button',
23
+ className: VARIANT_CLASS[props.variant ?? 'ghost'],
24
+ disabled: props.disabled === true,
25
+ onClick: props.onClick,
26
+ }, props.children);
27
+ }
28
+ //# sourceMappingURL=button.js.map
29
+ },
30
+ "packages/plugin-ui/dist/card.js": function (module, exports, __require) {
31
+ "use strict";
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.Card = Card;
34
+ exports.Hint = Hint;
35
+ const react_1 = require("react");
36
+ const h = react_1.createElement;
37
+ /** 警示卡片:需要用户决策时用(如本地与远端不一致) */
38
+ function Card(props) {
39
+ return h('div', { className: 'pui-card' }, props.title === undefined ? null : h('div', { className: 'pui-cardTitle' }, props.title), props.children);
40
+ }
41
+ /** 12px 三级色说明文字 */
42
+ function Hint(props) {
43
+ return h('p', { className: 'pui-hint' }, props.children);
44
+ }
45
+ //# sourceMappingURL=card.js.map
46
+ },
47
+ "packages/plugin-ui/dist/controls.js": function (module, exports, __require) {
48
+ "use strict";
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.Select = Select;
51
+ exports.TextInput = TextInput;
52
+ const react_1 = require("react");
53
+ const h = react_1.createElement;
54
+ /** 行右侧的下拉:灰底药丸 + 自绘箭头,和设置里的选择器一致 */
55
+ function Select(props) {
56
+ return h('span', { className: 'pui-selectWrap' }, h('select', {
57
+ className: 'pui-select',
58
+ value: props.value,
59
+ 'aria-label': props.ariaLabel ?? props.value,
60
+ onChange: (event) => props.onChange(event.currentTarget.value),
61
+ }, ...props.options.map((option) => h('option', { key: option.value, value: option.value }, option.label))), h('span', { className: 'pui-caret', 'aria-hidden': 'true' }));
62
+ }
63
+ /** 行右侧的文本框:与下拉同高同圆角 */
64
+ function TextInput(props) {
65
+ return h('span', {
66
+ className: 'pui-inputWrap',
67
+ style: props.width === undefined ? undefined : { width: `${props.width}px` },
68
+ }, h('input', {
69
+ className: 'pui-input',
70
+ value: props.value,
71
+ placeholder: props.placeholder ?? '',
72
+ 'aria-label': props.ariaLabel ?? props.placeholder ?? props.value,
73
+ onChange: (event) => props.onChange(event.currentTarget.value),
74
+ }));
75
+ }
76
+ //# sourceMappingURL=controls.js.map
77
+ },
78
+ "packages/plugin-ui/dist/style-sheet.js": function (module, exports, __require) {
79
+ "use strict";
80
+ Object.defineProperty(exports, "__esModule", { value: true });
81
+ exports.StyleSheet = StyleSheet;
82
+ const react_1 = require("react");
83
+ const h = react_1.createElement;
84
+ /** 把一段 CSS 插到当前子树里;插件自己的补充样式也走这里 */
85
+ function StyleSheet(props) {
86
+ return h('style', null, props.css);
87
+ }
88
+ //# sourceMappingURL=style-sheet.js.map
89
+ },
90
+ "packages/plugin-ui/src/styles.css": function (module, exports, __require) {
91
+ module.exports = { default: "/*\n * plugin-ui 样式表:尺寸、字号、间距与配色对齐 DSH 设置面板\n * (SettingsRoot / 设置表单)。全部取 --dsw-* 主题 token,深浅色自动跟随。\n *\n * 构建时由 scripts/build-client.mjs 作为字符串内联进各插件的 client.js,\n * 组件用 <StyleSheet css={STYLES} /> 注入一次。\n */\n\n.pui-overlay {\n position: fixed;\n inset: 0;\n z-index: 1000;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.pui-mask {\n position: absolute;\n inset: 0;\n background: var(--dsw-alias-bg-mask-1, rgba(0, 0, 0, 0.24));\n backdrop-filter: var(--dsw-mask-blur, none);\n}\n.pui-panel {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n width: 560px;\n max-width: calc(100vw - 48px);\n max-height: calc(100vh - 96px);\n overflow: hidden;\n border-radius: var(--dsw-radius-panel, 28px);\n background: var(--dsw-alias-bg-layer-2, Canvas);\n box-shadow: var(--dsw-elevation-prominent, 0 12px 40px rgba(0, 0, 0, 0.2));\n color: var(--dsw-alias-label-primary, CanvasText);\n font-family: inherit;\n font-size: 14px;\n line-height: 22px;\n --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);\n --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);\n}\n.pui-panel:focus {\n outline: none;\n}\n.pui-header {\n flex: none;\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 22px 14px 10px 24px;\n}\n.pui-title {\n flex: 1;\n min-width: 0;\n font-size: 16px;\n line-height: 24px;\n font-weight: 500;\n color: var(--dsw-alias-label-primary, inherit);\n}\n.pui-state {\n flex: none;\n display: inline-flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary, inherit);\n white-space: nowrap;\n}\n.pui-dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n}\n.pui-close {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n border: none;\n border-radius: var(--dsw-radius-sm, 8px);\n background: transparent;\n color: var(--dsw-alias-label-primary, inherit);\n font: inherit;\n font-size: 13px;\n line-height: 1;\n cursor: pointer;\n}\n.pui-close:hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));\n}\n.pui-body {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n padding: 0 24px;\n}\n.pui-footer {\n flex: none;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n padding: 14px 24px 18px;\n border-top: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08));\n}\n\n.pui-row {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 16px 0;\n border-bottom: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08));\n}\n.pui-row:last-child {\n border-bottom: none;\n}\n.pui-rowText {\n display: flex;\n flex-direction: column;\n flex: 1;\n gap: 4px;\n min-width: 0;\n padding-right: 16px;\n}\n.pui-rowLabel {\n font-size: 14px;\n font-weight: 500;\n line-height: 22px;\n color: var(--dsw-alias-label-primary, inherit);\n}\n.pui-rowHint {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary, inherit);\n overflow-wrap: anywhere;\n}\n.pui-control {\n flex: none;\n display: inline-flex;\n align-items: center;\n gap: 8px;\n}\n\n.pui-selectWrap {\n position: relative;\n display: inline-flex;\n}\n.pui-select {\n appearance: none;\n box-sizing: border-box;\n height: 36px;\n padding: 0 34px 0 14px;\n border: none;\n border-radius: var(--dsw-radius-md, 12px);\n background: var(--dsw-specific-selector, rgba(127, 127, 127, 0.12));\n color: var(--dsw-alias-label-primary, inherit);\n font: inherit;\n font-size: 14px;\n line-height: 22px;\n cursor: pointer;\n}\n.pui-select:hover {\n background: var(--dsw-alias-interactive-bg-hover-solid, rgba(127, 127, 127, 0.18));\n}\n.pui-select:focus-visible {\n outline: 2px solid\n var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary, currentColor));\n outline-offset: 1px;\n}\n.pui-caret {\n position: absolute;\n top: 50%;\n right: 14px;\n width: 7px;\n height: 7px;\n margin-top: -5px;\n border-right: 1.5px solid var(--dsw-alias-label-secondary, currentColor);\n border-bottom: 1.5px solid var(--dsw-alias-label-secondary, currentColor);\n transform: rotate(45deg);\n pointer-events: none;\n}\n.pui-input {\n box-sizing: border-box;\n width: 100%;\n height: 36px;\n padding: 0 12px;\n border: 0.5px solid var(--dsw-alias-border-l4, rgba(0, 0, 0, 0.16));\n border-radius: var(--dsw-radius-md, 12px);\n background: var(--dsw-alias-bg-layer-3, transparent);\n font: inherit;\n font-size: 14px;\n line-height: 22px;\n color: var(--dsw-alias-label-primary, inherit);\n}\n.pui-input::placeholder {\n color: var(--dsw-alias-label-dimmed, inherit);\n}\n.pui-input:focus-visible {\n outline: none;\n border-color: var(--dsw-alias-state-business-primary, currentColor);\n}\n.pui-inputWrap {\n flex: none;\n display: inline-flex;\n}\n\n.pui-btn {\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n height: 36px;\n padding: 0 14px;\n border: none;\n border-radius: var(--dsw-radius-md, 12px);\n background: transparent;\n color: var(--dsw-alias-label-primary, inherit);\n font: inherit;\n font-size: 14px;\n line-height: 22px;\n cursor: pointer;\n}\n.pui-btnOutline {\n box-shadow: inset 0 0 0 var(--dsh-hairline-width, 0.5px)\n var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12));\n}\n.pui-btnPrimary {\n background: var(--dsw-alias-button-primary-fill, #4169e1);\n color: var(--dsw-alias-label-primary-foreground, #fff);\n}\n.pui-btn:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));\n}\n.pui-btnPrimary:hover:not(:disabled) {\n background: var(--dsw-alias-button-primary-hover, #3557c7);\n}\n\n.pui-card {\n display: flex;\n flex-direction: column;\n gap: 10px;\n margin: 12px 0 4px;\n padding: 12px 14px;\n border: 0.5px solid var(--dsw-alias-state-warn-secondary, rgba(0, 0, 0, 0.12));\n border-radius: var(--dsw-radius-md, 12px);\n background: var(--dsw-alias-state-warn-tertiary, transparent);\n}\n.pui-cardTitle {\n font-size: 13px;\n font-weight: 500;\n line-height: 1.5;\n color: var(--dsw-alias-state-warn-label, inherit);\n}\n.pui-hint {\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary, inherit);\n overflow-wrap: anywhere;\n}\n\n.pui-entry {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n height: 42px;\n margin: 4px 0;\n padding: 0 12px;\n border: none;\n border-radius: var(--dsw-radius-md, 12px);\n background: transparent;\n color: var(--dsw-alias-label-primary, inherit);\n font: inherit;\n font-size: 14px;\n line-height: 22px;\n text-align: left;\n cursor: pointer;\n}\n.pui-entry:hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));\n}\n.pui-entryRail {\n flex: none;\n justify-content: center;\n gap: 0;\n width: 36px;\n height: 36px;\n margin: 8px 0 10px;\n padding: 0;\n}\n.pui-entryLabel {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.pui-entryState {\n flex: none;\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary, inherit);\n white-space: nowrap;\n}\n\n/*\n * 浮层通用外观:悬停面板、气泡这类挂在 body 上的小块。\n * 位置与尺寸(left/bottom/width/max-height)由插件按锚点补,用行内 style。\n */\n.pui-surface {\n box-sizing: border-box;\n border: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.12));\n border-radius: var(--dsw-radius-lg, 12px);\n background: var(--dsw-alias-bg-layer-2, Canvas);\n color: var(--dsw-alias-label-primary, CanvasText);\n box-shadow: var(--dsw-elevation-prominent, 0 10px 28px rgba(0, 0, 0, 0.24));\n font-size: 12px;\n line-height: 1.5;\n}\n" };
92
+ },
93
+ "packages/plugin-ui/dist/dialog.js": function (module, exports, __require) {
94
+ "use strict";
95
+ var __importDefault = (this && this.__importDefault) || function (mod) {
96
+ return (mod && mod.__esModule) ? mod : { "default": mod };
97
+ };
98
+ Object.defineProperty(exports, "__esModule", { value: true });
99
+ exports.Dialog = Dialog;
100
+ const react_1 = require("react");
101
+ const style_sheet_1 = __require("./style-sheet");
102
+ const styles_css_1 = __importDefault(__require("./styles.css"));
103
+ const h = react_1.createElement;
104
+ /** 固定的回调 ref:只在挂载时聚焦面板,避免每次渲染抢走输入框焦点 */
105
+ function focusPanel(element) {
106
+ if (element !== null)
107
+ element.focus();
108
+ }
109
+ /**
110
+ * 设置风格的面板:遮罩 + 圆角面板 + 标题行(标题、状态、关闭)+ 内容 + 底栏。
111
+ * 尺寸与配色对齐 DSH 设置面板,深浅色跟随主题。Esc、遮罩点击由调用方决定。
112
+ */
113
+ function Dialog(props) {
114
+ const state = props.state;
115
+ return h('div', { className: 'pui-overlay', role: 'presentation' }, h(style_sheet_1.StyleSheet, { css: styles_css_1.default }), h('div', { className: 'pui-mask', 'aria-hidden': 'true', onClick: props.onClose }), h('div', {
116
+ className: 'pui-panel',
117
+ role: 'dialog',
118
+ 'aria-modal': 'true',
119
+ 'aria-label': props.title,
120
+ tabIndex: -1,
121
+ style: props.width === undefined ? undefined : { width: `${props.width}px` },
122
+ ref: focusPanel,
123
+ }, h('div', { className: 'pui-header' }, h('div', { className: 'pui-title' }, props.title), state === undefined
124
+ ? null
125
+ : h('span', { className: 'pui-state', style: { color: state.color } }, h('span', { className: 'pui-dot' }), state.text), h('button', { type: 'button', className: 'pui-close', onClick: props.onClose, 'aria-label': '关闭' }, '✕')), h('div', { className: 'pui-body' }, props.children), props.footer === undefined ? null : h('div', { className: 'pui-footer' }, props.footer)));
126
+ }
127
+ //# sourceMappingURL=dialog.js.map
128
+ },
129
+ "packages/plugin-ui/dist/row.js": function (module, exports, __require) {
130
+ "use strict";
131
+ Object.defineProperty(exports, "__esModule", { value: true });
132
+ exports.Row = Row;
133
+ const react_1 = require("react");
134
+ const h = react_1.createElement;
135
+ /**
136
+ * 设置风格的一行:左边标签 + 说明,右边控件,行之间用 .5px 分隔线。
137
+ * 标签 14/500,说明 12px 三级色。
138
+ */
139
+ function Row(props) {
140
+ return h('div', { className: 'pui-row' }, h('div', { className: 'pui-rowText' }, h('div', { className: 'pui-rowLabel' }, props.label), props.hint === undefined ? null : h('div', { className: 'pui-rowHint' }, props.hint)), props.control === undefined ? null : h('div', { className: 'pui-control' }, props.control));
141
+ }
142
+ //# sourceMappingURL=row.js.map
143
+ },
144
+ "packages/plugin-ui/dist/sidebar-entry.js": function (module, exports, __require) {
145
+ "use strict";
146
+ var __importDefault = (this && this.__importDefault) || function (mod) {
147
+ return (mod && mod.__esModule) ? mod : { "default": mod };
148
+ };
149
+ Object.defineProperty(exports, "__esModule", { value: true });
150
+ exports.SidebarEntry = SidebarEntry;
151
+ const react_1 = require("react");
152
+ const style_sheet_1 = __require("./style-sheet");
153
+ const styles_css_1 = __importDefault(__require("./styles.css"));
154
+ const h = react_1.createElement;
155
+ /**
156
+ * 侧边栏底部动作入口:与设置入口同尺寸(42px 高、--dsw-radius-md、hover 用
157
+ * interactive-bg-hover),左侧状态圆点、右侧一句话状态,窄栏收成 36×36。
158
+ */
159
+ function SidebarEntry(props) {
160
+ const wide = props.wide !== false;
161
+ return h('div', { style: { position: 'relative', width: '100%' } }, h(style_sheet_1.StyleSheet, { css: styles_css_1.default }), h('button', {
162
+ type: 'button',
163
+ className: wide ? 'pui-entry' : 'pui-entry pui-entryRail',
164
+ onClick: props.onClick,
165
+ title: `${props.label}:${props.state.text}`,
166
+ 'aria-label': `${props.label},${props.state.text}`,
167
+ 'aria-haspopup': 'dialog',
168
+ 'aria-expanded': props.expanded === true,
169
+ }, h('span', { className: 'pui-dot', style: { color: props.state.color, flex: 'none' } }), wide ? h('span', { className: 'pui-entryLabel' }, props.label) : null, wide ? h('span', { className: 'pui-entryState' }, props.state.text) : null));
170
+ }
171
+ //# sourceMappingURL=sidebar-entry.js.map
172
+ },
173
+ "packages/plugin-ui/dist/index.js": function (module, exports, __require) {
174
+ "use strict";
175
+ var __importDefault = (this && this.__importDefault) || function (mod) {
176
+ return (mod && mod.__esModule) ? mod : { "default": mod };
177
+ };
178
+ Object.defineProperty(exports, "__esModule", { value: true });
179
+ exports.STYLES = exports.StyleSheet = exports.SidebarEntry = exports.Row = exports.Dialog = exports.TextInput = exports.Select = exports.Hint = exports.Card = exports.Button = void 0;
180
+ /**
181
+ * @liuchen64/dsh-plugin-ui — DSH 插件共用的客户端 UI 组件
182
+ *
183
+ * 样式在 src/styles.css,构建时由 scripts/build-client.mjs 作为字符串内联进
184
+ * 各插件的 client.js;组件只带类名,根节点渲染一次 <StyleSheet css={STYLES} />
185
+ * (Dialog 与 SidebarEntry 会自己渲染)。全部取 --dsw-* 主题 token,深浅色跟随主题。
186
+ */
187
+ var button_1 = __require("./button");
188
+ Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return button_1.Button; } });
189
+ var card_1 = __require("./card");
190
+ Object.defineProperty(exports, "Card", { enumerable: true, get: function () { return card_1.Card; } });
191
+ Object.defineProperty(exports, "Hint", { enumerable: true, get: function () { return card_1.Hint; } });
192
+ var controls_1 = __require("./controls");
193
+ Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return controls_1.Select; } });
194
+ Object.defineProperty(exports, "TextInput", { enumerable: true, get: function () { return controls_1.TextInput; } });
195
+ var dialog_1 = __require("./dialog");
196
+ Object.defineProperty(exports, "Dialog", { enumerable: true, get: function () { return dialog_1.Dialog; } });
197
+ var row_1 = __require("./row");
198
+ Object.defineProperty(exports, "Row", { enumerable: true, get: function () { return row_1.Row; } });
199
+ var sidebar_entry_1 = __require("./sidebar-entry");
200
+ Object.defineProperty(exports, "SidebarEntry", { enumerable: true, get: function () { return sidebar_entry_1.SidebarEntry; } });
201
+ var style_sheet_1 = __require("./style-sheet");
202
+ Object.defineProperty(exports, "StyleSheet", { enumerable: true, get: function () { return style_sheet_1.StyleSheet; } });
203
+ var styles_css_1 = __require("./styles.css");
204
+ Object.defineProperty(exports, "STYLES", { enumerable: true, get: function () { return __importDefault(styles_css_1).default; } });
205
+ //# sourceMappingURL=index.js.map
206
+ },
207
+ "packages/plugin-utils/dist/number.js": function (module, exports, __require) {
208
+ "use strict";
209
+ /**
210
+ * number.ts — 数字展示
211
+ */
212
+ Object.defineProperty(exports, "__esModule", { value: true });
213
+ exports.formatCny = formatCny;
214
+ /**
215
+ * 人民币金额:0 显示两位;小于 0.01 显示四位,避免整段显示成 ¥0.00;
216
+ * 非法值显示破折号。
217
+ */
218
+ function formatCny(value) {
219
+ if (typeof value !== 'number' || !Number.isFinite(value))
220
+ return '—';
221
+ if (value === 0)
222
+ return '¥0.00';
223
+ return value < 0.01 ? `¥${value.toFixed(4)}` : `¥${value.toFixed(2)}`;
224
+ }
225
+ //# sourceMappingURL=number.js.map
226
+ },
227
+ "packages/plugin-utils/dist/text.js": function (module, exports, __require) {
228
+ "use strict";
229
+ /**
230
+ * text.ts — 文本切分、拼接与单行截取
231
+ *
232
+ * 插件配置里「逗号分隔的路径列表」「只取 stderr 首行」这类需求很常见,
233
+ * 统一在这里实现,避免每个插件各写一份 trim/filter 链。
234
+ */
235
+ Object.defineProperty(exports, "__esModule", { value: true });
236
+ exports.trimOrUndefined = trimOrUndefined;
237
+ exports.splitList = splitList;
238
+ exports.joinList = joinList;
239
+ exports.firstLine = firstLine;
240
+ exports.truncate = truncate;
241
+ exports.classNames = classNames;
242
+ /** 去掉首尾空白,空串返回 undefined,方便写 `?? 默认值` */
243
+ function trimOrUndefined(value) {
244
+ if (typeof value !== 'string')
245
+ return undefined;
246
+ const trimmed = value.trim();
247
+ return trimmed === '' ? undefined : trimmed;
248
+ }
249
+ /** 按分隔符切成去空白、去空项的列表;结果空数组表示没有有效项 */
250
+ function splitList(text, separator = ',') {
251
+ return text
252
+ .split(separator)
253
+ .map((item) => item.trim())
254
+ .filter((item) => item !== '');
255
+ }
256
+ /** 列表拼回一行文本,默认逗号 + 空格 */
257
+ function joinList(items, separator = ', ') {
258
+ return items.join(separator);
259
+ }
260
+ /** 取首行,避免把整段 stderr / 堆栈甩到界面上 */
261
+ function firstLine(text) {
262
+ return text.trim().split(/\r?\n/)[0] ?? '';
263
+ }
264
+ /** 超长文本截断,超出时补省略号(默认按字符数) */
265
+ function truncate(text, maxLength, suffix = '…') {
266
+ if (maxLength <= 0)
267
+ return '';
268
+ if (text.length <= maxLength)
269
+ return text;
270
+ return `${text.slice(0, maxLength)}${suffix}`;
271
+ }
272
+ /** 拼 className:过滤假值,用空格连接 */
273
+ function classNames(...parts) {
274
+ return parts.filter((part) => typeof part === 'string' && part !== '').join(' ');
275
+ }
276
+ //# sourceMappingURL=text.js.map
277
+ },
278
+ "packages/plugin-utils/dist/validate.js": function (module, exports, __require) {
279
+ "use strict";
280
+ /**
281
+ * validate.ts — 从 unknown 里安全取值
282
+ *
283
+ * 插件配置、磁盘上的 JSON、RPC 请求体都是 unknown,逐个字段手写
284
+ * `typeof x === 'string'` 既啰嗦又容易漏。这里统一成「取不到就是 undefined,
285
+ * 由调用方决定默认值」的小函数。
286
+ */
287
+ Object.defineProperty(exports, "__esModule", { value: true });
288
+ exports.isRecord = isRecord;
289
+ exports.asString = asString;
290
+ exports.asNonEmptyString = asNonEmptyString;
291
+ exports.asStringList = asStringList;
292
+ exports.asBoolean = asBoolean;
293
+ exports.asFiniteNumber = asFiniteNumber;
294
+ /** 普通对象(排除 null 与数组) */
295
+ function isRecord(value) {
296
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
297
+ }
298
+ /** 取字符串;非字符串返回 undefined */
299
+ function asString(value) {
300
+ return typeof value === 'string' ? value : undefined;
301
+ }
302
+ /** 取非空字符串(会 trim);空串、纯空白、非字符串都返回 undefined */
303
+ function asNonEmptyString(value) {
304
+ if (typeof value !== 'string')
305
+ return undefined;
306
+ const trimmed = value.trim();
307
+ return trimmed === '' ? undefined : trimmed;
308
+ }
309
+ /** 取字符串数组,逐项 trim 并丢掉空项;不是数组或含非字符串项返回 undefined */
310
+ function asStringList(value) {
311
+ if (!Array.isArray(value))
312
+ return undefined;
313
+ const items = [];
314
+ for (const item of value) {
315
+ if (typeof item !== 'string')
316
+ return undefined;
317
+ const trimmed = item.trim();
318
+ if (trimmed !== '')
319
+ items.push(trimmed);
320
+ }
321
+ return items;
322
+ }
323
+ /** 取布尔;非布尔返回 undefined */
324
+ function asBoolean(value) {
325
+ return typeof value === 'boolean' ? value : undefined;
326
+ }
327
+ /** 取有限数字;NaN / Infinity / 非数字返回 undefined */
328
+ function asFiniteNumber(value) {
329
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
330
+ }
331
+ //# sourceMappingURL=validate.js.map
332
+ },
333
+ "packages/plugin-utils/dist/time.js": function (module, exports, __require) {
334
+ "use strict";
335
+ Object.defineProperty(exports, "__esModule", { value: true });
336
+ exports.formatDateTime = formatDateTime;
337
+ exports.nowIso = nowIso;
338
+ /**
339
+ * time.ts — 时间展示
340
+ *
341
+ * 界面上只显示到分钟就够了;「从未」「无记录」这类业务文案留给调用方。
342
+ */
343
+ const validate_1 = __require("./validate");
344
+ /** ISO 时间 → `YYYY-MM-DD HH:mm`;解析不出来返回 undefined */
345
+ function formatDateTime(value) {
346
+ const text = (0, validate_1.asString)(value);
347
+ if (text === undefined)
348
+ return undefined;
349
+ const date = new Date(text);
350
+ if (Number.isNaN(date.getTime()))
351
+ return undefined;
352
+ const pad = (n) => String(n).padStart(2, '0');
353
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
354
+ }
355
+ /** 当前时间的 ISO 字符串,写状态用 */
356
+ function nowIso() {
357
+ return new Date().toISOString();
358
+ }
359
+ //# sourceMappingURL=time.js.map
360
+ },
361
+ "packages/plugin-utils/dist/index.js": function (module, exports, __require) {
362
+ "use strict";
363
+ /**
364
+ * @liuchen64/dsh-plugin-utils — DSH 插件的通用小工具
365
+ *
366
+ * 只放与业务无关的东西:配置校验(unknown 取值)、文本切分与拼接、
367
+ * 时间与金额格式化。Host 侧直接依赖本包;客户端由
368
+ * scripts/build-client.mjs 内联进 client.js,运行时不需要额外安装。
369
+ */
370
+ Object.defineProperty(exports, "__esModule", { value: true });
371
+ exports.isRecord = exports.asStringList = exports.asString = exports.asNonEmptyString = exports.asFiniteNumber = exports.asBoolean = exports.nowIso = exports.formatDateTime = exports.truncate = exports.trimOrUndefined = exports.splitList = exports.joinList = exports.firstLine = exports.classNames = exports.formatCny = void 0;
372
+ var number_1 = __require("./number");
373
+ Object.defineProperty(exports, "formatCny", { enumerable: true, get: function () { return number_1.formatCny; } });
374
+ var text_1 = __require("./text");
375
+ Object.defineProperty(exports, "classNames", { enumerable: true, get: function () { return text_1.classNames; } });
376
+ Object.defineProperty(exports, "firstLine", { enumerable: true, get: function () { return text_1.firstLine; } });
377
+ Object.defineProperty(exports, "joinList", { enumerable: true, get: function () { return text_1.joinList; } });
378
+ Object.defineProperty(exports, "splitList", { enumerable: true, get: function () { return text_1.splitList; } });
379
+ Object.defineProperty(exports, "trimOrUndefined", { enumerable: true, get: function () { return text_1.trimOrUndefined; } });
380
+ Object.defineProperty(exports, "truncate", { enumerable: true, get: function () { return text_1.truncate; } });
381
+ var time_1 = __require("./time");
382
+ Object.defineProperty(exports, "formatDateTime", { enumerable: true, get: function () { return time_1.formatDateTime; } });
383
+ Object.defineProperty(exports, "nowIso", { enumerable: true, get: function () { return time_1.nowIso; } });
384
+ var validate_1 = __require("./validate");
385
+ Object.defineProperty(exports, "asBoolean", { enumerable: true, get: function () { return validate_1.asBoolean; } });
386
+ Object.defineProperty(exports, "asFiniteNumber", { enumerable: true, get: function () { return validate_1.asFiniteNumber; } });
387
+ Object.defineProperty(exports, "asNonEmptyString", { enumerable: true, get: function () { return validate_1.asNonEmptyString; } });
388
+ Object.defineProperty(exports, "asString", { enumerable: true, get: function () { return validate_1.asString; } });
389
+ Object.defineProperty(exports, "asStringList", { enumerable: true, get: function () { return validate_1.asStringList; } });
390
+ Object.defineProperty(exports, "isRecord", { enumerable: true, get: function () { return validate_1.isRecord; } });
391
+ //# sourceMappingURL=index.js.map
392
+ },
393
+ "plugins/session-cost/dist/client/format.js": function (module, exports, __require) {
394
+ "use strict";
395
+ Object.defineProperty(exports, "__esModule", { value: true });
396
+ exports.formatCny = void 0;
397
+ exports.titleOf = titleOf;
398
+ /** 金额展示统一用共享工具,避免每个插件各写一份 */
399
+ var dsh_plugin_utils_1 = __require("@liuchen64/dsh-plugin-utils");
400
+ Object.defineProperty(exports, "formatCny", { enumerable: true, get: function () { return dsh_plugin_utils_1.formatCny; } });
401
+ /** 标题为空时退回轮次编号 */
402
+ function titleOf(entry) {
403
+ return entry.title !== '' ? entry.title : `第 ${entry.turn} 轮`;
404
+ }
405
+ },
406
+ "plugins/session-cost/dist/client/layout.js": function (module, exports, __require) {
407
+ "use strict";
408
+ Object.defineProperty(exports, "__esModule", { value: true });
409
+ exports.VIEWPORT_MARGIN = exports.PANEL_WIDTH = void 0;
410
+ exports.panelPosition = panelPosition;
411
+ exports.tipPosition = tipPosition;
412
+ /** 明细面板与浮层的宽度上限、视口留白 */
413
+ exports.PANEL_WIDTH = 300;
414
+ exports.VIEWPORT_MARGIN = 8;
415
+ /** 明细面板的位置与最大高度:贴着触发器上方,夹在视口内 */
416
+ function panelPosition(anchor) {
417
+ return {
418
+ position: 'fixed',
419
+ left: `${anchor.left}px`,
420
+ bottom: `${anchor.bottom}px`,
421
+ width: `${anchor.width}px`,
422
+ maxHeight: `${anchor.maxHeight}px`,
423
+ };
424
+ }
425
+ /** 标题浮层的位置 */
426
+ function tipPosition(tip) {
427
+ return {
428
+ position: 'fixed',
429
+ left: `${tip.left}px`,
430
+ bottom: `${tip.bottom}px`,
431
+ width: `${tip.width}px`,
432
+ };
433
+ }
434
+ },
435
+ "plugins/session-cost/src/client/session-cost.css": function (module, exports, __require) {
436
+ module.exports = { default: "/*\n * session-cost 的客户端样式。浮层外观(底色、描边、阴影、圆角、字号)用\n * plugin-ui 的 .pui-surface,这里只写本插件独有的排版与尺寸。\n */\n\n/* 触发器:本轮 / 本会话两段金额 */\n.sc-trigger {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n line-height: 1.4;\n color: inherit;\n opacity: 0.75;\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n cursor: default;\n}\n\n/* 每轮明细面板:位置与尺寸走行内 style,其余用类 */\n.sc-panel {\n padding: 8px 10px;\n overflow-y: auto;\n}\n\n.sc-panelHead {\n opacity: 0.7;\n margin-bottom: 6px;\n}\n\n.sc-empty {\n opacity: 0.6;\n}\n\n.sc-turn {\n display: flex;\n align-items: baseline;\n gap: 10px;\n padding: 2px 0;\n}\n\n/* 标题单行省略,悬停出完整问题 */\n.sc-turnTitle {\n flex: 1;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n cursor: default;\n}\n\n.sc-turnCost {\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n opacity: 0.85;\n}\n\n/* 标题浮层:最多三行,超出省略,不挡鼠标 */\n.sc-tip {\n padding: 6px 8px;\n border-radius: var(--dsw-radius-md, 8px);\n pointer-events: none;\n display: -webkit-box;\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n" };
437
+ },
438
+ "plugins/session-cost/dist/client/title-tip.js": function (module, exports, __require) {
439
+ "use strict";
440
+ Object.defineProperty(exports, "__esModule", { value: true });
441
+ exports.TitleTip = TitleTip;
442
+ const react_1 = require("react");
443
+ const react_dom_1 = require("react-dom");
444
+ const layout_1 = __require("./layout");
445
+ const h = react_1.createElement;
446
+ /** 悬停标题时的完整问题,最多三行 */
447
+ function TitleTip(props) {
448
+ return (0, react_dom_1.createPortal)(h('div', { className: 'pui-surface sc-tip', style: (0, layout_1.tipPosition)(props.tip) }, props.tip.text), document.body);
449
+ }
450
+ },
451
+ "plugins/session-cost/dist/client/turn-panel.js": function (module, exports, __require) {
452
+ "use strict";
453
+ Object.defineProperty(exports, "__esModule", { value: true });
454
+ exports.TurnPanel = TurnPanel;
455
+ const react_1 = require("react");
456
+ const react_dom_1 = require("react-dom");
457
+ const format_1 = __require("./format");
458
+ const layout_1 = __require("./layout");
459
+ const h = react_1.createElement;
460
+ /** 每轮金额明细:从早到晚排列,最新一轮在最下面 */
461
+ function TurnPanel(props) {
462
+ const { anchor, turns } = props;
463
+ return (0, react_dom_1.createPortal)(h('div', {
464
+ ref: (element) => {
465
+ props.panelRef.current = element;
466
+ },
467
+ className: 'pui-surface sc-panel',
468
+ style: (0, layout_1.panelPosition)(anchor),
469
+ onMouseEnter: props.onEnter,
470
+ onMouseLeave: props.onLeave,
471
+ }, h('div', { className: 'sc-panelHead' }, `每轮金额 · 共 ${turns.length} 轮`), turns.length === 0
472
+ ? h('div', { className: 'sc-empty' }, '还没有可显示的轮次')
473
+ : turns.map((entry) => h('div', { key: `turn-${entry.turn}`, className: 'sc-turn' }, h('span', {
474
+ className: 'sc-turnTitle',
475
+ onMouseEnter: (event) => props.onTitleEnter(event, (0, format_1.titleOf)(entry)),
476
+ onMouseLeave: props.onTitleLeave,
477
+ }, (0, format_1.titleOf)(entry)), h('span', { className: 'sc-turnCost' }, (0, format_1.formatCny)(entry.cost))))), document.body);
478
+ }
479
+ },
480
+ "plugins/session-cost/dist/client/session-cost.js": function (module, exports, __require) {
481
+ "use strict";
482
+ var __importDefault = (this && this.__importDefault) || function (mod) {
483
+ return (mod && mod.__esModule) ? mod : { "default": mod };
484
+ };
485
+ Object.defineProperty(exports, "__esModule", { value: true });
486
+ exports.SessionCost = SessionCost;
487
+ const dsh_plugin_ui_1 = __require("@liuchen64/dsh-plugin-ui");
488
+ const react_1 = require("react");
489
+ const format_1 = __require("./format");
490
+ const layout_1 = __require("./layout");
491
+ const session_cost_css_1 = __importDefault(__require("./session-cost.css"));
492
+ const title_tip_1 = __require("./title-tip");
493
+ const turn_panel_1 = __require("./turn-panel");
494
+ /** 鼠标离开触发器后留的时间,方便移进面板 */
495
+ const CLOSE_DELAY_MS = 150;
496
+ /** 面板最大高度上限 */
497
+ const PANEL_MAX_HEIGHT = 300;
498
+ /** 标题浮层与触发器之间的间隙 */
499
+ const TIP_GAP = 4;
500
+ const h = react_1.createElement;
501
+ /** 共享库样式 + 本插件的样式,一次性注入 */
502
+ const STYLES = dsh_plugin_ui_1.STYLES + session_cost_css_1.default;
503
+ /** 明细面板与标题浮层共用的横向定位:夹在视口内 */
504
+ function clampLeft(rect, width) {
505
+ const left = rect.getBoundingClientRect().left;
506
+ return Math.min(Math.max(layout_1.VIEWPORT_MARGIN, left), window.innerWidth - width - layout_1.VIEWPORT_MARGIN);
507
+ }
508
+ function SessionCost(props) {
509
+ const useProjection = props.useProjection;
510
+ const projected = typeof useProjection === 'function' ? useProjection('sessionCost') : null;
511
+ const turns = projected !== null && projected !== undefined && Array.isArray(projected.turns)
512
+ ? projected.turns
513
+ : [];
514
+ const [anchor, setAnchor] = (0, react_1.useState)(null);
515
+ const [tip, setTip] = (0, react_1.useState)(null);
516
+ /** 定时器句柄:浏览器里是 number,Node 的类型下是 Timeout,用 ReturnType 两头都对 */
517
+ const closeTimer = (0, react_1.useRef)(null);
518
+ /** 明细面板本身,打开或新增轮次时滚到最底部 */
519
+ const panelRef = (0, react_1.useRef)(null);
520
+ (0, react_1.useEffect)(() => {
521
+ const element = panelRef.current;
522
+ if (element !== null)
523
+ element.scrollTop = element.scrollHeight;
524
+ }, [anchor, turns.length]);
525
+ const cancelClose = () => {
526
+ if (closeTimer.current !== null) {
527
+ clearTimeout(closeTimer.current);
528
+ closeTimer.current = null;
529
+ }
530
+ };
531
+ const closeNow = () => {
532
+ cancelClose();
533
+ setAnchor(null);
534
+ setTip(null);
535
+ };
536
+ const closeLater = () => {
537
+ cancelClose();
538
+ closeTimer.current = setTimeout(closeNow, CLOSE_DELAY_MS);
539
+ };
540
+ (0, react_1.useEffect)(() => cancelClose, []);
541
+ const openPanel = (event) => {
542
+ cancelClose();
543
+ const rect = event.currentTarget.getBoundingClientRect();
544
+ const width = Math.min(layout_1.PANEL_WIDTH, window.innerWidth - layout_1.VIEWPORT_MARGIN * 2);
545
+ setAnchor({
546
+ left: clampLeft(event.currentTarget, width),
547
+ width,
548
+ bottom: window.innerHeight - rect.top + layout_1.VIEWPORT_MARGIN,
549
+ maxHeight: Math.max(0, Math.min(PANEL_MAX_HEIGHT, rect.top - layout_1.VIEWPORT_MARGIN * 2)),
550
+ });
551
+ };
552
+ const showTip = (event, text) => {
553
+ const width = Math.min(layout_1.PANEL_WIDTH, window.innerWidth - layout_1.VIEWPORT_MARGIN * 2);
554
+ setTip({
555
+ text,
556
+ width,
557
+ left: clampLeft(event.currentTarget, width),
558
+ bottom: window.innerHeight - event.currentTarget.getBoundingClientRect().top + TIP_GAP,
559
+ });
560
+ };
561
+ return h('div', {
562
+ className: 'sc-trigger',
563
+ onMouseEnter: openPanel,
564
+ onMouseLeave: closeLater,
565
+ title: '悬停查看每一轮的金额',
566
+ }, h(dsh_plugin_ui_1.StyleSheet, { css: STYLES }), h('span', null, `本轮 ${(0, format_1.formatCny)(projected?.turn)}`), h('span', { 'aria-hidden': true }, '·'), h('span', null, `本会话 ${(0, format_1.formatCny)(projected?.session)}`), anchor === null
567
+ ? null
568
+ : h(turn_panel_1.TurnPanel, {
569
+ anchor,
570
+ turns,
571
+ panelRef,
572
+ onEnter: cancelClose,
573
+ onLeave: closeLater,
574
+ onTitleEnter: showTip,
575
+ onTitleLeave: () => setTip(null),
576
+ }), tip === null ? null : h(title_tip_1.TitleTip, { tip }));
577
+ }
578
+ },
579
+ "plugins/session-cost/dist/client/index.js": function (module, exports, __require) {
580
+ "use strict";
581
+ Object.defineProperty(exports, "__esModule", { value: true });
582
+ exports.inject = void 0;
583
+ exports.apply = apply;
584
+ const session_cost_1 = __require("./session-cost");
585
+ exports.inject = ['slots'];
586
+ /** 入口:把「本轮 / 本会话」金额注册到输入卡片左侧 */
587
+ function apply(ctx) {
588
+ ctx.slots.inject('conversation.input.left', () => ctx.slots.register({
589
+ name: 'conversation.input.left',
590
+ id: 'session-cost',
591
+ order: 5,
592
+ }, session_cost_1.SessionCost));
593
+ }
594
+ }
595
+ };
596
+ const __deps = {"packages/plugin-ui/dist/button.js":{},"packages/plugin-ui/dist/card.js":{},"packages/plugin-ui/dist/controls.js":{},"packages/plugin-ui/dist/style-sheet.js":{},"packages/plugin-ui/src/styles.css":{},"packages/plugin-ui/dist/dialog.js":{"./style-sheet":"packages/plugin-ui/dist/style-sheet.js","./styles.css":"packages/plugin-ui/src/styles.css"},"packages/plugin-ui/dist/row.js":{},"packages/plugin-ui/dist/sidebar-entry.js":{"./style-sheet":"packages/plugin-ui/dist/style-sheet.js","./styles.css":"packages/plugin-ui/src/styles.css"},"packages/plugin-ui/dist/index.js":{"./button":"packages/plugin-ui/dist/button.js","./card":"packages/plugin-ui/dist/card.js","./controls":"packages/plugin-ui/dist/controls.js","./dialog":"packages/plugin-ui/dist/dialog.js","./row":"packages/plugin-ui/dist/row.js","./sidebar-entry":"packages/plugin-ui/dist/sidebar-entry.js","./style-sheet":"packages/plugin-ui/dist/style-sheet.js","./styles.css":"packages/plugin-ui/src/styles.css"},"packages/plugin-utils/dist/number.js":{},"packages/plugin-utils/dist/text.js":{},"packages/plugin-utils/dist/validate.js":{},"packages/plugin-utils/dist/time.js":{"./validate":"packages/plugin-utils/dist/validate.js"},"packages/plugin-utils/dist/index.js":{"./number":"packages/plugin-utils/dist/number.js","./text":"packages/plugin-utils/dist/text.js","./time":"packages/plugin-utils/dist/time.js","./validate":"packages/plugin-utils/dist/validate.js"},"plugins/session-cost/dist/client/format.js":{"@liuchen64/dsh-plugin-utils":"packages/plugin-utils/dist/index.js"},"plugins/session-cost/dist/client/layout.js":{},"plugins/session-cost/src/client/session-cost.css":{},"plugins/session-cost/dist/client/title-tip.js":{"./layout":"plugins/session-cost/dist/client/layout.js"},"plugins/session-cost/dist/client/turn-panel.js":{"./format":"plugins/session-cost/dist/client/format.js","./layout":"plugins/session-cost/dist/client/layout.js"},"plugins/session-cost/dist/client/session-cost.js":{"@liuchen64/dsh-plugin-ui":"packages/plugin-ui/dist/index.js","./format":"plugins/session-cost/dist/client/format.js","./layout":"plugins/session-cost/dist/client/layout.js","./session-cost.css":"plugins/session-cost/src/client/session-cost.css","./title-tip":"plugins/session-cost/dist/client/title-tip.js","./turn-panel":"plugins/session-cost/dist/client/turn-panel.js"},"plugins/session-cost/dist/client/index.js":{"./session-cost":"plugins/session-cost/dist/client/session-cost.js"}};
597
+ const __cache = {};
598
+ function __load(id) {
599
+ const cached = __cache[id];
600
+ if (cached !== undefined) return cached.exports;
601
+ const record = { exports: {} };
602
+ __cache[id] = record;
603
+ const map = __deps[id] ?? {};
604
+ __defs[id](record, record.exports, (specifier) => {
605
+ const local = map[specifier];
606
+ return local === undefined ? require(specifier) : __load(local);
607
+ });
608
+ return record.exports;
609
+ }
610
+ module.exports = __load("plugins/session-cost/dist/client/index.js");
611
+ return module.exports;
612
+ },
613
+ });