dsh-colophon 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +321 -181
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -40,8 +40,10 @@ window.__ModuleLoader__.load({
|
|
|
40
40
|
settingsLabel: '卷末 Colophon',
|
|
41
41
|
settingsIntro: '规则引擎只读本地日志,不调用模型、不花 token;API 摘要为可选项。',
|
|
42
42
|
engine: '摘要引擎',
|
|
43
|
-
engineRules: '
|
|
44
|
-
|
|
43
|
+
engineRules: '本地规则',
|
|
44
|
+
engineRulesHint: '0 token · 本地生成',
|
|
45
|
+
engineApi: 'API 摘要',
|
|
46
|
+
engineApiHint: '按次调用模型',
|
|
45
47
|
enabled: '启用卷末',
|
|
46
48
|
triggers: '触发时机',
|
|
47
49
|
onIdle: '会话空闲时',
|
|
@@ -90,6 +92,18 @@ window.__ModuleLoader__.load({
|
|
|
90
92
|
statusOff: '已暂停',
|
|
91
93
|
settingsSubtitle: '把每次对话的最终结论留在本地;重开会话时先看结论,不必重读整段历史。',
|
|
92
94
|
saveHint: '保存后立即生效,无需重启。',
|
|
95
|
+
note: '注意',
|
|
96
|
+
unitSessions: '个会话',
|
|
97
|
+
unitMessages: '条',
|
|
98
|
+
unitPrice: '元 / 百万 token',
|
|
99
|
+
perSummaryCapHint: '单次调用超过此金额则按右侧策略处理',
|
|
100
|
+
dailyBudgetHint: '每天累计消耗的上限',
|
|
101
|
+
overCapHint: '达到单次/每日上限后的动作',
|
|
102
|
+
minMessagesHint: '低于该消息数的会话不生成',
|
|
103
|
+
minTokensHint: '低于该 token 数的会话不生成',
|
|
104
|
+
queueReason: '原因:{reason}',
|
|
105
|
+
saving: '保存中…',
|
|
106
|
+
rangeEmptyHint: '可查询任意自定义区间;结束时间留空表示到当前时刻。',
|
|
93
107
|
enabledHint: '关闭后不再采集新会话;已有摘要仍可查看。',
|
|
94
108
|
engineHint: 'rules 完全本地,0 token;api 每次生成会调用模型,并受下方预算限制。',
|
|
95
109
|
onIdleHint: '智能体停止后几秒内写出摘要。',
|
|
@@ -121,8 +135,10 @@ window.__ModuleLoader__.load({
|
|
|
121
135
|
settingsLabel: 'Colophon',
|
|
122
136
|
settingsIntro: 'The rules engine only reads local logs — no model call, no token spend. API summaries are optional.',
|
|
123
137
|
engine: 'Summary engine',
|
|
124
|
-
engineRules: 'Local rules
|
|
125
|
-
|
|
138
|
+
engineRules: 'Local rules',
|
|
139
|
+
engineRulesHint: '0 tokens · local',
|
|
140
|
+
engineApi: 'API summary',
|
|
141
|
+
engineApiHint: 'Calls a model per digest',
|
|
126
142
|
enabled: 'Enable Colophon',
|
|
127
143
|
triggers: 'Triggers',
|
|
128
144
|
onIdle: 'When a session goes idle',
|
|
@@ -171,6 +187,18 @@ window.__ModuleLoader__.load({
|
|
|
171
187
|
statusOff: 'Paused',
|
|
172
188
|
settingsSubtitle: 'Keep every conversation’s final conclusion locally. Reopen a session and read the conclusion first — no need to replay the whole history.',
|
|
173
189
|
saveHint: 'Changes take effect immediately after saving.',
|
|
190
|
+
note: 'Note',
|
|
191
|
+
unitSessions: 'sessions',
|
|
192
|
+
unitMessages: 'messages',
|
|
193
|
+
unitPrice: 'CNY / 1M tokens',
|
|
194
|
+
perSummaryCapHint: 'Above this per-call cost, the policy on the right applies',
|
|
195
|
+
dailyBudgetHint: 'Daily token ceiling',
|
|
196
|
+
overCapHint: 'What to do after hitting a cap',
|
|
197
|
+
minMessagesHint: 'Sessions below this are skipped',
|
|
198
|
+
minTokensHint: 'Sessions below this are skipped',
|
|
199
|
+
queueReason: 'Reason: {reason}',
|
|
200
|
+
saving: 'Saving…',
|
|
201
|
+
rangeEmptyHint: 'Any custom range; leave the end empty to use now.',
|
|
174
202
|
enabledHint: 'When off, new sessions are no longer captured; existing digests stay readable.',
|
|
175
203
|
engineHint: 'Local rules cost 0 tokens. The API engine calls a model per digest and is capped by the budgets below.',
|
|
176
204
|
onIdleHint: 'Write the digest a few seconds after the agent stops.',
|
|
@@ -236,7 +264,7 @@ window.__ModuleLoader__.load({
|
|
|
236
264
|
banner: {
|
|
237
265
|
position: 'fixed', top: 12, left: '50%', transform: 'translateX(-50%)', zIndex: 70,
|
|
238
266
|
display: 'flex', alignItems: 'center', gap: 10, padding: '8px 12px',
|
|
239
|
-
background: 'rgba(
|
|
267
|
+
background: 'rgba(24,28,38,0.97)', color: '#dfe7f7', border: '1px solid rgba(109,151,255,0.4)',
|
|
240
268
|
borderRadius: 10, fontSize: 12, boxShadow: '0 8px 24px rgba(0,0,0,0.35)',
|
|
241
269
|
},
|
|
242
270
|
field: { display: 'flex', flexDirection: 'column', gap: 3, minWidth: 120 },
|
|
@@ -255,81 +283,111 @@ window.__ModuleLoader__.load({
|
|
|
255
283
|
warn: { color: '#ffd27a', fontSize: 11 },
|
|
256
284
|
ok: { color: '#4cc38a', fontSize: 11 },
|
|
257
285
|
|
|
258
|
-
// ----
|
|
259
|
-
|
|
286
|
+
// ---- Design tokens: one palette + one spacing scale for every control ----
|
|
287
|
+
// text / muted / faint -> three text contrast levels
|
|
288
|
+
// accent -> the only "selected / action" color
|
|
289
|
+
// amber / green / red -> status only, always paired with an icon dot
|
|
290
|
+
page: { display: 'flex', flexDirection: 'column', gap: 12, fontSize: 13, maxWidth: 780, paddingBottom: 6, color: '#e9edf3', lineHeight: 1.55 },
|
|
260
291
|
headCard: {
|
|
261
|
-
display: 'flex', flexDirection: 'column', gap:
|
|
292
|
+
display: 'flex', flexDirection: 'column', gap: 8, padding: '18px 18px 16px', borderRadius: 12,
|
|
262
293
|
border: '1px solid rgba(255,255,255,0.08)',
|
|
263
|
-
background: 'linear-gradient(135deg, rgba(
|
|
294
|
+
background: 'linear-gradient(135deg, rgba(109,151,255,0.18), rgba(109,151,255,0.03) 58%, rgba(255,255,255,0.015))',
|
|
264
295
|
},
|
|
265
|
-
headTitle: {
|
|
266
|
-
headSub: { fontSize: 12.5, lineHeight: 1.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
296
|
+
headTitle: { fontSize: 17, fontWeight: 650, letterSpacing: '-0.01em' },
|
|
297
|
+
headSub: { fontSize: 12.5, lineHeight: 1.65, color: '#9aa4b5', maxWidth: 600 },
|
|
298
|
+
headMeta: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap', marginTop: 2 },
|
|
299
|
+
pill: { display: 'inline-flex', alignItems: 'center', gap: 6, height: 22, padding: '0 10px', borderRadius: 999, fontSize: 11.5, fontWeight: 600, whiteSpace: 'nowrap', border: '1px solid transparent' },
|
|
300
|
+
pillOn: { background: 'rgba(127,215,162,0.12)', color: '#7fd7a2', borderColor: 'rgba(127,215,162,0.32)' },
|
|
301
|
+
pillOff: { background: 'rgba(255,255,255,0.05)', color: '#9aa4b5', borderColor: 'rgba(255,255,255,0.12)' },
|
|
302
|
+
pillCount: { background: 'rgba(109,151,255,0.12)', color: '#9db9ff', borderColor: 'rgba(109,151,255,0.3)' },
|
|
303
|
+
pillDot: { width: 6, height: 6, borderRadius: 999, display: 'inline-block' },
|
|
304
|
+
card: { borderRadius: 12, border: '1px solid rgba(255,255,255,0.08)', background: 'rgba(255,255,255,0.026)', overflow: 'hidden' },
|
|
305
|
+
cardHead: { display: 'flex', alignItems: 'center', gap: 8, padding: '11px 14px', borderBottom: '1px solid rgba(255,255,255,0.07)' },
|
|
306
|
+
cardTitle: { display: 'inline-flex', alignItems: 'center', gap: 8, fontSize: 13, fontWeight: 600 },
|
|
307
|
+
accentBar: { width: 3, height: 12, borderRadius: 2, background: '#6d97ff', display: 'inline-block' },
|
|
308
|
+
cardMeta: { marginLeft: 'auto', fontSize: 11.5, color: '#76819a' },
|
|
309
|
+
row: { display: 'flex', alignItems: 'center', gap: 16, padding: '12px 14px', minHeight: 46, borderBottom: '1px solid rgba(255,255,255,0.07)', boxSizing: 'border-box' },
|
|
310
|
+
rowLast: { borderBottom: 'none' },
|
|
311
|
+
labelBlock: { display: 'flex', flexDirection: 'column', gap: 3, flex: '1 1 180px', minWidth: 0 },
|
|
312
|
+
label: { fontSize: 13, color: '#e9edf3' },
|
|
313
|
+
hint: { fontSize: 11.5, lineHeight: 1.6, color: '#9aa4b5' },
|
|
314
|
+
control: { display: 'flex', alignItems: 'center', gap: 8, flex: '0 0 auto', flexWrap: 'wrap', justifyContent: 'flex-end' },
|
|
315
|
+
input: {
|
|
316
|
+
height: 34, boxSizing: 'border-box', padding: '0 10px', borderRadius: 8,
|
|
317
|
+
border: '1px solid rgba(255,255,255,0.14)', background: 'rgba(0,0,0,0.28)',
|
|
318
|
+
color: '#e9edf3', fontSize: 12.5, outline: 'none',
|
|
319
|
+
},
|
|
320
|
+
inputNum: { width: 112, textAlign: 'right', fontVariantNumeric: 'tabular-nums' },
|
|
321
|
+
inputText: { width: 168 },
|
|
322
|
+
unit: { fontSize: 11.5, color: '#76819a', whiteSpace: 'nowrap' },
|
|
323
|
+
selectWrap: { position: 'relative', display: 'inline-flex', alignItems: 'center' },
|
|
324
|
+
select: {
|
|
325
|
+
appearance: 'none', WebkitAppearance: 'none', height: 34, boxSizing: 'border-box',
|
|
326
|
+
padding: '0 26px 0 10px', borderRadius: 8, border: '1px solid rgba(255,255,255,0.14)',
|
|
327
|
+
background: 'rgba(0,0,0,0.28)', color: '#e9edf3', fontSize: 12.5, cursor: 'pointer', outline: 'none',
|
|
328
|
+
},
|
|
329
|
+
chevron: { position: 'absolute', right: 10, pointerEvents: 'none', fontSize: 9, color: '#9aa4b5' },
|
|
330
|
+
segmented: { display: 'inline-flex', gap: 3, padding: 3, borderRadius: 9, background: 'rgba(0,0,0,0.25)', border: '1px solid rgba(255,255,255,0.1)' },
|
|
331
|
+
segItem: {
|
|
332
|
+
appearance: 'none', border: '1px solid transparent', background: 'transparent', color: '#9aa4b5',
|
|
333
|
+
borderRadius: 7, padding: '5px 11px', cursor: 'pointer', display: 'inline-flex', flexDirection: 'column',
|
|
334
|
+
alignItems: 'flex-start', gap: 1, minWidth: 108, textAlign: 'left',
|
|
273
335
|
},
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
336
|
+
segItemOn: { background: 'rgba(109,151,255,0.16)', borderColor: 'rgba(109,151,255,0.5)', color: '#bcd0ff' },
|
|
337
|
+
segTitle: { fontSize: 12.5, fontWeight: 550 },
|
|
338
|
+
segHint: { fontSize: 10.5, color: '#76819a' },
|
|
339
|
+
segHintOn: { color: 'rgba(188,208,255,0.75)' },
|
|
278
340
|
switchRow: {
|
|
279
|
-
display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap:
|
|
280
|
-
padding: '
|
|
281
|
-
|
|
341
|
+
display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16,
|
|
342
|
+
padding: '12px 14px', minHeight: 52, borderBottom: '1px solid rgba(255,255,255,0.07)',
|
|
343
|
+
cursor: 'pointer', boxSizing: 'border-box', outline: 'none',
|
|
282
344
|
},
|
|
283
|
-
switchRowOn: {
|
|
345
|
+
switchRowOn: { background: 'rgba(109,151,255,0.05)' },
|
|
284
346
|
switchTrack: {
|
|
285
|
-
position: 'relative', flex: '0 0 auto', width:
|
|
286
|
-
background: 'rgba(255,255,255,0.
|
|
347
|
+
position: 'relative', flex: '0 0 auto', width: 40, height: 23, borderRadius: 999,
|
|
348
|
+
background: 'rgba(255,255,255,0.16)', transition: 'background 140ms ease',
|
|
287
349
|
},
|
|
288
|
-
switchTrackOn: { background: '#
|
|
350
|
+
switchTrackOn: { background: '#5b8cff' },
|
|
289
351
|
switchKnob: {
|
|
290
|
-
position: 'absolute', top: 3, left: 3, width:
|
|
291
|
-
background: '#fff', transition: 'transform
|
|
352
|
+
position: 'absolute', top: 3, left: 3, width: 17, height: 17, borderRadius: 999,
|
|
353
|
+
background: '#fff', transition: 'transform 140ms ease', boxShadow: '0 1px 3px rgba(0,0,0,0.45)',
|
|
292
354
|
},
|
|
293
|
-
switchKnobOn: { transform: 'translateX(
|
|
294
|
-
callout: {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
background: 'rgba(0,0,0,0.3)', color: 'inherit', border: '1px solid rgba(255,255,255,0.14)',
|
|
302
|
-
borderRadius: 8, height: 34, padding: '0 10px', fontSize: 13, width: '100%', boxSizing: 'border-box',
|
|
303
|
-
},
|
|
304
|
-
row2: { display: 'flex', gap: 12, flexWrap: 'wrap', alignItems: 'flex-end' },
|
|
305
|
-
actionsBar: { display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: 10, paddingTop: 2 },
|
|
355
|
+
switchKnobOn: { transform: 'translateX(17px)' },
|
|
356
|
+
callout: { display: 'flex', gap: 8, alignItems: 'flex-start', margin: '10px 14px', padding: '9px 11px', borderRadius: 8, fontSize: 11.5, lineHeight: 1.6, border: '1px solid transparent' },
|
|
357
|
+
calloutInfo: { background: 'rgba(109,151,255,0.08)', borderColor: 'rgba(109,151,255,0.28)', color: '#c7d7ff' },
|
|
358
|
+
calloutWarn: { background: 'rgba(238,207,148,0.10)', borderColor: 'rgba(238,207,148,0.34)', color: '#eed7a6' },
|
|
359
|
+
calloutError: { background: 'rgba(255,130,130,0.10)', borderColor: 'rgba(255,130,130,0.30)', color: '#ffb3b3' },
|
|
360
|
+
calloutOk: { background: 'rgba(127,215,162,0.10)', borderColor: 'rgba(127,215,162,0.30)', color: '#8fe0b1' },
|
|
361
|
+
calloutDot: { width: 6, height: 6, borderRadius: 999, marginTop: 6, flex: '0 0 auto' },
|
|
362
|
+
calloutLabel: { fontWeight: 600, marginRight: 4 },
|
|
306
363
|
buttonPrimary: {
|
|
307
|
-
display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6,
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
364
|
+
display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6, height: 36,
|
|
365
|
+
minWidth: 108, padding: '0 18px', borderRadius: 9, border: '1px solid #5b8cff',
|
|
366
|
+
background: '#4f7cff', color: '#fff', fontSize: 13, fontWeight: 650, cursor: 'pointer',
|
|
367
|
+
boxShadow: '0 2px 10px rgba(79,124,255,0.35)', boxSizing: 'border-box',
|
|
311
368
|
},
|
|
312
369
|
buttonSecondary: {
|
|
313
|
-
display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6,
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
},
|
|
318
|
-
buttonDisabled: { opacity: 0.45, cursor: 'not-allowed', boxShadow: 'none' },
|
|
319
|
-
usageGrid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(150px, 1fr))', gap: 10 },
|
|
320
|
-
usageCard: {
|
|
321
|
-
display: 'flex', flexDirection: 'column', gap: 2, padding: '12px 14px', borderRadius: 12,
|
|
322
|
-
border: '1px solid rgba(255,255,255,0.08)', background: 'rgba(0,0,0,0.18)',
|
|
370
|
+
display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6, height: 34,
|
|
371
|
+
minWidth: 84, padding: '0 14px', borderRadius: 8, border: '1px solid rgba(255,255,255,0.2)',
|
|
372
|
+
background: 'rgba(255,255,255,0.045)', color: '#e9edf3', fontSize: 12.5, fontWeight: 550,
|
|
373
|
+
cursor: 'pointer', boxSizing: 'border-box',
|
|
323
374
|
},
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
padding: '14px 12px', borderRadius: 10, border: '1px dashed rgba(255,255,255,0.16)',
|
|
331
|
-
color: 'rgba(255,255,255,0.5)', fontSize: 12, textAlign: 'center',
|
|
375
|
+
buttonDisabled: { opacity: 0.4, cursor: 'not-allowed', boxShadow: 'none' },
|
|
376
|
+
actionsBar: { display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: 10, padding: '10px 14px' },
|
|
377
|
+
footer: {
|
|
378
|
+
display: 'flex', alignItems: 'center', gap: 12, padding: '10px 14px', borderRadius: 10,
|
|
379
|
+
border: '1px solid rgba(255,255,255,0.08)', background: 'rgba(20,23,30,0.94)',
|
|
380
|
+
backdropFilter: 'blur(8px)', position: 'sticky', bottom: 0, zIndex: 2,
|
|
332
381
|
},
|
|
382
|
+
footerText: { flex: '1 1 auto', fontSize: 11.5, color: '#76819a', minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
|
|
383
|
+
usageGrid: { display: 'grid', gridTemplateColumns: 'repeat(4, minmax(0, 1fr))', gap: 8, padding: '12px 14px 0' },
|
|
384
|
+
usageCard: { display: 'flex', flexDirection: 'column', gap: 2, padding: '11px 12px', borderRadius: 10, border: '1px solid rgba(255,255,255,0.07)', background: 'rgba(0,0,0,0.2)' },
|
|
385
|
+
usageLabel: { fontSize: 11, color: '#9aa4b5' },
|
|
386
|
+
usageValue: { fontSize: 18, fontWeight: 650, letterSpacing: '-0.01em', fontVariantNumeric: 'tabular-nums' },
|
|
387
|
+
usageMeta: { fontSize: 10.5, color: '#76819a' },
|
|
388
|
+
listRow: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap', padding: '8px 10px', borderRadius: 8, background: 'rgba(0,0,0,0.2)', fontSize: 12 },
|
|
389
|
+
emptyBox: { margin: '12px 14px 4px', padding: '14px 12px', borderRadius: 9, border: '1px dashed rgba(255,255,255,0.16)', color: '#76819a', fontSize: 11.5, textAlign: 'center' },
|
|
390
|
+
grid2: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12, padding: '12px 14px' },
|
|
333
391
|
}
|
|
334
392
|
|
|
335
393
|
/** Read/persist the crash banner acknowledgement. */
|
|
@@ -450,60 +508,110 @@ window.__ModuleLoader__.load({
|
|
|
450
508
|
return h(React.Fragment, null, h(CrashBanner), h('div', null, chip), panel)
|
|
451
509
|
}
|
|
452
510
|
|
|
453
|
-
/**
|
|
454
|
-
function
|
|
455
|
-
return h('
|
|
456
|
-
h('span', { style: styles.label }, label),
|
|
457
|
-
h('input', {
|
|
458
|
-
style: styles.inputWide,
|
|
459
|
-
type: 'number',
|
|
460
|
-
step: step ?? 1,
|
|
461
|
-
value: value ?? '',
|
|
462
|
-
onChange: event => onChange(Number(event.target.value)),
|
|
463
|
-
}))
|
|
511
|
+
/** A labelled row: text block on the left, control on the right. */
|
|
512
|
+
function Row({ children, last }) {
|
|
513
|
+
return h('div', { style: last ? { ...styles.row, ...styles.rowLast } : styles.row }, children)
|
|
464
514
|
}
|
|
465
515
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
h('
|
|
470
|
-
h('span', null, label))
|
|
516
|
+
function LabelBlock({ label, hint }) {
|
|
517
|
+
return h('div', { style: styles.labelBlock },
|
|
518
|
+
h('span', { style: styles.label }, label),
|
|
519
|
+
hint ? h('span', { style: styles.hint }, hint) : null)
|
|
471
520
|
}
|
|
472
521
|
|
|
473
|
-
/** One card section on the settings page. */
|
|
474
|
-
function Card({ title,
|
|
475
|
-
return h('div', { style: styles.
|
|
522
|
+
/** One card section on the settings page: accent bar + title + optional meta. */
|
|
523
|
+
function Card({ title, meta, children }) {
|
|
524
|
+
return h('div', { style: styles.card },
|
|
476
525
|
h('div', { style: styles.cardHead },
|
|
477
526
|
h('div', { style: styles.cardTitle }, h('span', { style: styles.accentBar }), title),
|
|
478
|
-
|
|
527
|
+
meta ? h('span', { style: styles.cardMeta }, meta) : null),
|
|
479
528
|
children)
|
|
480
529
|
}
|
|
481
530
|
|
|
482
531
|
/** A full-row toggle: the whole row is the click target, the knob is obvious. */
|
|
483
|
-
function SwitchRow({ label, hint, checked, onChange }) {
|
|
532
|
+
function SwitchRow({ label, hint, checked, onChange, last }) {
|
|
484
533
|
const on = checked === true
|
|
485
534
|
const toggle = () => onChange(!on)
|
|
486
535
|
return h('div', {
|
|
487
536
|
role: 'switch',
|
|
488
537
|
'aria-checked': on,
|
|
489
538
|
tabIndex: 0,
|
|
490
|
-
style: on ? { ...styles.switchRow, ...styles.switchRowOn } : styles.switchRow,
|
|
539
|
+
style: on ? { ...styles.switchRow, ...styles.switchRowOn, ...(last ? styles.rowLast : null) } : { ...styles.switchRow, ...(last ? styles.rowLast : null) },
|
|
491
540
|
onClick: toggle,
|
|
492
|
-
onKeyDown: event => {
|
|
493
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
494
|
-
event.preventDefault()
|
|
495
|
-
toggle()
|
|
496
|
-
}
|
|
497
|
-
},
|
|
541
|
+
onKeyDown: event => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); toggle() } },
|
|
498
542
|
},
|
|
499
543
|
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 3, minWidth: 0 } },
|
|
500
|
-
h('span', { style:
|
|
544
|
+
h('span', { style: styles.label }, label),
|
|
501
545
|
hint ? h('span', { style: styles.hint }, hint) : null),
|
|
502
546
|
h('div', { style: on ? { ...styles.switchTrack, ...styles.switchTrackOn } : styles.switchTrack },
|
|
503
547
|
h('div', { style: on ? { ...styles.switchKnob, ...styles.switchKnobOn } : styles.switchKnob })))
|
|
504
548
|
}
|
|
505
549
|
|
|
506
|
-
/**
|
|
550
|
+
/** Two-option (or N-option) segmented control, used instead of native selects for the mode fields. */
|
|
551
|
+
function Segmented({ options, value, onChange }) {
|
|
552
|
+
return h('div', { style: styles.segmented, role: 'tablist' },
|
|
553
|
+
options.map(option => {
|
|
554
|
+
const on = option.value === value
|
|
555
|
+
return h('button', {
|
|
556
|
+
key: option.value, type: 'button', role: 'tab', 'aria-selected': on,
|
|
557
|
+
style: on ? { ...styles.segItem, ...styles.segItemOn } : styles.segItem,
|
|
558
|
+
onClick: () => onChange(option.value),
|
|
559
|
+
},
|
|
560
|
+
h('span', { style: styles.segTitle }, option.label),
|
|
561
|
+
option.hint ? h('span', { style: on ? { ...styles.segHint, ...styles.segHintOn } : styles.segHint }, option.hint) : null)
|
|
562
|
+
}))
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function Select({ value, onChange, children, width }) {
|
|
566
|
+
return h('div', { style: styles.selectWrap },
|
|
567
|
+
h('select', { style: { ...styles.select, width: width ?? 168 }, value, onChange: event => onChange(event.target.value) }, children),
|
|
568
|
+
h('span', { style: styles.chevron, 'aria-hidden': 'true' }, '▾'))
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/** Exactly one numeric input with a trailing unit; used by every numeric setting. */
|
|
572
|
+
function NumberRow({ label, hint, value, onChange, step, unit, last }) {
|
|
573
|
+
return h(Row, { last },
|
|
574
|
+
h(LabelBlock, { label, hint }),
|
|
575
|
+
h('div', { style: styles.control },
|
|
576
|
+
h('input', {
|
|
577
|
+
style: { ...styles.input, ...styles.inputNum }, type: 'number', step: step ?? 1,
|
|
578
|
+
value: value ?? '', onChange: event => onChange(Number(event.target.value)),
|
|
579
|
+
}),
|
|
580
|
+
unit ? h('span', { style: styles.unit }, unit) : null))
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function TextRow({ label, hint, value, onChange, placeholder, width, last }) {
|
|
584
|
+
return h(Row, { last },
|
|
585
|
+
h(LabelBlock, { label, hint }),
|
|
586
|
+
h('div', { style: styles.control },
|
|
587
|
+
h('input', {
|
|
588
|
+
style: { ...styles.input, ...styles.inputText, width: width ?? styles.inputText.width },
|
|
589
|
+
value: value ?? '', placeholder, onChange: event => onChange(event.target.value),
|
|
590
|
+
})))
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/** Inline status message with one consistent shape: a colored dot + readable text. */
|
|
594
|
+
function Callout({ tone = 'info', label, children }) {
|
|
595
|
+
const palette = {
|
|
596
|
+
info: [styles.calloutInfo, '#6d97ff'],
|
|
597
|
+
warn: [styles.calloutWarn, '#eecf94'],
|
|
598
|
+
error: [styles.calloutError, '#ff9b9b'],
|
|
599
|
+
ok: [styles.calloutOk, '#7fd7a2'],
|
|
600
|
+
}[tone] || [styles.calloutInfo, '#6d97ff']
|
|
601
|
+
return h('div', { style: { ...styles.callout, ...palette[0] }, role: tone === 'error' ? 'alert' : 'status' },
|
|
602
|
+
h('span', { style: { ...styles.calloutDot, background: palette[1] } }),
|
|
603
|
+
h('span', { style: { minWidth: 0 } },
|
|
604
|
+
label ? h('span', { style: styles.calloutLabel }, label) : null,
|
|
605
|
+
children))
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function StatusPill({ on, onText, offText }) {
|
|
609
|
+
return h('span', { style: on ? { ...styles.pill, ...styles.pillOn } : { ...styles.pill, ...styles.pillOff } },
|
|
610
|
+
h('span', { style: { ...styles.pillDot, background: on ? '#7fd7a2' : 'rgba(255,255,255,0.35)' } }),
|
|
611
|
+
on ? onText : offText)
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** Settings page section: unified controls, one palette, one spacing scale. */
|
|
507
615
|
function ColophonSettings() {
|
|
508
616
|
const [form, setForm] = useState(null)
|
|
509
617
|
const [status, setStatus] = useState(null)
|
|
@@ -511,6 +619,7 @@ window.__ModuleLoader__.load({
|
|
|
511
619
|
const [range, setRange] = useState({ from: '', to: '' })
|
|
512
620
|
const [message, setMessage] = useState('')
|
|
513
621
|
const [failed, setFailed] = useState('')
|
|
622
|
+
const [saving, setSaving] = useState(false)
|
|
514
623
|
|
|
515
624
|
useEffect(() => {
|
|
516
625
|
let alive = true
|
|
@@ -530,8 +639,7 @@ window.__ModuleLoader__.load({
|
|
|
530
639
|
const update = (section, key, value) => {
|
|
531
640
|
setForm(current => {
|
|
532
641
|
if (!current) return current
|
|
533
|
-
|
|
534
|
-
return next
|
|
642
|
+
return { ...current, [section]: { ...current[section], [key]: value } }
|
|
535
643
|
})
|
|
536
644
|
setMessage('')
|
|
537
645
|
}
|
|
@@ -542,6 +650,7 @@ window.__ModuleLoader__.load({
|
|
|
542
650
|
|
|
543
651
|
const save = async () => {
|
|
544
652
|
if (!form) return
|
|
653
|
+
setSaving(true)
|
|
545
654
|
setFailed('')
|
|
546
655
|
try {
|
|
547
656
|
const patch = {
|
|
@@ -557,6 +666,8 @@ window.__ModuleLoader__.load({
|
|
|
557
666
|
setMessage(tr('saved'))
|
|
558
667
|
} catch (cause) {
|
|
559
668
|
setFailed(tr('saveFailed', { message: String(cause?.message ?? cause) }))
|
|
669
|
+
} finally {
|
|
670
|
+
setSaving(false)
|
|
560
671
|
}
|
|
561
672
|
}
|
|
562
673
|
|
|
@@ -582,45 +693,51 @@ window.__ModuleLoader__.load({
|
|
|
582
693
|
}
|
|
583
694
|
|
|
584
695
|
if (!form) {
|
|
585
|
-
return h('div', { style: styles.
|
|
696
|
+
return h('div', { style: { ...styles.page, padding: 14 } },
|
|
586
697
|
h(CrashBanner),
|
|
587
|
-
h('div', { style:
|
|
698
|
+
h('div', { style: { fontSize: 12, color: '#9aa4b5' } }, failed || tr('loading')))
|
|
588
699
|
}
|
|
589
700
|
|
|
590
701
|
const usage = status?.usage ?? {}
|
|
591
|
-
const usageCard = (label,
|
|
592
|
-
h('div', { style: styles.
|
|
593
|
-
h('div', { style: styles.usageValue }, money(
|
|
594
|
-
h('div', { style: styles.
|
|
702
|
+
const usageCard = (label, slot) => h('div', { style: styles.usageCard },
|
|
703
|
+
h('div', { style: styles.usageLabel }, label),
|
|
704
|
+
h('div', { style: styles.usageValue }, money(slot?.costCNY)),
|
|
705
|
+
h('div', { style: styles.usageMeta }, tr('tokensLabel', { tokens: integer(slot?.tokens) }), ' · ', tr('calls', { count: slot?.calls ?? 0 })))
|
|
595
706
|
|
|
596
707
|
const queueItems = status?.queueItems ?? []
|
|
597
708
|
const queueCount = Number(status?.queueCount ?? status?.queue ?? 0) || 0
|
|
598
709
|
const enabled = form.enabled === true
|
|
599
710
|
const apiOn = form.engine === 'api'
|
|
600
|
-
const
|
|
601
|
-
h('span', { style: { width: 6, height: 6, borderRadius: 999, background: on ? '#6fe0a8' : 'rgba(255,255,255,0.4)' } }),
|
|
602
|
-
on ? onText : offText)
|
|
711
|
+
const batchOn = form.triggers.closeBatch === true
|
|
603
712
|
|
|
604
713
|
return h('div', { style: styles.page },
|
|
605
714
|
h(CrashBanner),
|
|
606
715
|
h('div', { style: styles.headCard },
|
|
607
|
-
h('div', { style:
|
|
608
|
-
'卷末
|
|
609
|
-
|
|
716
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
|
|
717
|
+
h('span', { style: styles.headTitle }, '卷末 Colophon'),
|
|
718
|
+
h(StatusPill, { on: enabled, onText: tr('statusOn'), offText: tr('statusOff') })),
|
|
610
719
|
h('div', { style: styles.headSub }, tr('settingsSubtitle')),
|
|
611
|
-
h('div', { style: styles.
|
|
720
|
+
h('div', { style: styles.headMeta },
|
|
721
|
+
h('span', { style: styles.hint }, tr('saveHint')),
|
|
722
|
+
status ? h('span', { style: { ...styles.hint, marginLeft: 'auto' } }, tr('dataRoot'), ':', status.dataRoot) : null)),
|
|
723
|
+
|
|
612
724
|
h(Card, { title: tr('basicTitle') },
|
|
613
725
|
h(SwitchRow, {
|
|
614
726
|
label: tr('enabled'), hint: tr('enabledHint'), checked: enabled,
|
|
615
|
-
onChange: value => updateTop('enabled', value),
|
|
727
|
+
onChange: value => updateTop('enabled', value), last: true,
|
|
616
728
|
}),
|
|
617
|
-
h(
|
|
618
|
-
h(
|
|
619
|
-
|
|
620
|
-
h(
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
729
|
+
h(Row, { last: true },
|
|
730
|
+
h(LabelBlock, { label: tr('engine'), hint: tr('engineHint') }),
|
|
731
|
+
h('div', { style: styles.control },
|
|
732
|
+
h(Segmented, {
|
|
733
|
+
value: form.engine,
|
|
734
|
+
onChange: value => updateTop('engine', value),
|
|
735
|
+
options: [
|
|
736
|
+
{ value: 'rules', label: tr('engineRules'), hint: tr('engineRulesHint') },
|
|
737
|
+
{ value: 'api', label: tr('engineApi'), hint: tr('engineApiHint') },
|
|
738
|
+
],
|
|
739
|
+
})))),
|
|
740
|
+
|
|
624
741
|
h(Card, { title: tr('triggers') },
|
|
625
742
|
h(SwitchRow, {
|
|
626
743
|
label: tr('onIdle'), hint: tr('onIdleHint'), checked: form.triggers.onIdle === true,
|
|
@@ -631,52 +748,75 @@ window.__ModuleLoader__.load({
|
|
|
631
748
|
onChange: value => update('triggers', 'onSwitch', value),
|
|
632
749
|
}),
|
|
633
750
|
h(SwitchRow, {
|
|
634
|
-
label: tr('closeBatch'), checked:
|
|
751
|
+
label: tr('closeBatch'), checked: batchOn, last: !batchOn,
|
|
635
752
|
onChange: value => update('triggers', 'closeBatch', value),
|
|
636
753
|
}),
|
|
637
|
-
h('div',
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
},
|
|
646
|
-
h(
|
|
647
|
-
h('
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
h('
|
|
652
|
-
h('
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
754
|
+
batchOn ? h('div', null,
|
|
755
|
+
h(NumberRow, {
|
|
756
|
+
label: tr('closeBatchMax'), unit: tr('unitSessions'), step: 1,
|
|
757
|
+
value: form.triggers.closeBatchMaxSessions, last: true,
|
|
758
|
+
onChange: value => update('triggers', 'closeBatchMaxSessions', value),
|
|
759
|
+
}),
|
|
760
|
+
h(Callout, { tone: 'warn', label: tr('note') }, tr('closeBatchWarn'))) : null),
|
|
761
|
+
|
|
762
|
+
h(Card, { title: tr('apiSection'), meta: h(StatusPill, { on: apiOn, onText: tr('apiOn'), offText: tr('apiOff') }) },
|
|
763
|
+
h(Callout, { tone: 'info' }, tr('apiNote')),
|
|
764
|
+
h(TextRow, { label: tr('provider'), hint: 'deepseek-official', value: form.api.provider, width: 200, onChange: value => update('api', 'provider', value) }),
|
|
765
|
+
h(TextRow, { label: tr('model'), hint: 'deepseek-chat', value: form.api.model, width: 200, onChange: value => update('api', 'model', value) }),
|
|
766
|
+
h(Row, null,
|
|
767
|
+
h(LabelBlock, { label: tr('priceIn'), hint: tr('unitPrice') }),
|
|
768
|
+
h('div', { style: styles.control },
|
|
769
|
+
h('input', {
|
|
770
|
+
style: { ...styles.input, ...styles.inputNum }, type: 'number', step: 0.1,
|
|
771
|
+
value: form.api.priceInCNYPerM ?? '', onChange: event => update('api', 'priceInCNYPerM', Number(event.target.value)),
|
|
772
|
+
}),
|
|
773
|
+
h('span', { style: styles.unit }, '元')),
|
|
774
|
+
),
|
|
775
|
+
h(NumberRow, {
|
|
776
|
+
label: tr('priceOut'), hint: tr('unitPrice'), step: 0.1, unit: '元',
|
|
777
|
+
value: form.api.priceOutCNYPerM, onChange: value => update('api', 'priceOutCNYPerM', value),
|
|
778
|
+
}),
|
|
779
|
+
h(NumberRow, {
|
|
780
|
+
label: tr('perSummaryCap'), hint: tr('perSummaryCapHint'), step: 0.01, unit: '元',
|
|
781
|
+
value: form.api.maxCostPerSummaryCNY, onChange: value => update('api', 'maxCostPerSummaryCNY', value),
|
|
782
|
+
}),
|
|
783
|
+
h(NumberRow, {
|
|
784
|
+
label: tr('dailyBudget'), hint: tr('dailyBudgetHint'), step: 1000, unit: 'tokens',
|
|
785
|
+
value: form.api.dailyTokenBudget, onChange: value => update('api', 'dailyTokenBudget', value),
|
|
786
|
+
}),
|
|
787
|
+
h(Row, { last: !(apiOn && status && status.apiAvailable === false) },
|
|
788
|
+
h(LabelBlock, { label: tr('overCap'), hint: tr('overCapHint') }),
|
|
789
|
+
h('div', { style: styles.control },
|
|
790
|
+
h(Segmented, {
|
|
791
|
+
value: form.api.overCap,
|
|
792
|
+
onChange: value => update('api', 'overCap', value),
|
|
793
|
+
options: [
|
|
794
|
+
{ value: 'queue', label: tr('overCapQueue') },
|
|
795
|
+
{ value: 'skip', label: tr('overCapSkip') },
|
|
796
|
+
],
|
|
797
|
+
}))),
|
|
665
798
|
apiOn && status && status.apiAvailable === false
|
|
666
|
-
? h(
|
|
799
|
+
? h(Callout, { tone: 'warn', label: tr('note') }, tr('apiUnavailable'))
|
|
667
800
|
: null),
|
|
801
|
+
|
|
668
802
|
h(Card, { title: tr('filter') },
|
|
669
|
-
h(
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
h(
|
|
803
|
+
h(NumberRow, {
|
|
804
|
+
label: tr('minMessages'), hint: tr('minMessagesHint'), unit: tr('unitMessages'),
|
|
805
|
+
value: form.filter.minMessages, onChange: value => update('filter', 'minMessages', value),
|
|
806
|
+
}),
|
|
807
|
+
h(NumberRow, {
|
|
808
|
+
label: tr('minTokens'), hint: tr('minTokensHint'), unit: 'tokens', step: 500, last: true,
|
|
809
|
+
value: form.filter.minTokens, onChange: value => update('filter', 'minTokens', value),
|
|
810
|
+
})),
|
|
811
|
+
|
|
812
|
+
h(Card, { title: tr('queueTitle'), meta: h(StatusPill, { on: queueCount > 0, onText: `${queueCount}`, offText: `0` }) },
|
|
813
|
+
h('div', { style: { ...styles.hint, padding: '10px 14px 2px' } }, tr('queueHint')),
|
|
674
814
|
queueItems.length === 0
|
|
675
815
|
? h('div', { style: styles.emptyBox }, tr('queueEmpty'))
|
|
676
|
-
: h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
816
|
+
: h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6, padding: '10px 14px 2px' } },
|
|
677
817
|
queueItems.map(item => h('div', { key: item.sessionId, style: styles.listRow },
|
|
678
818
|
h('span', { style: { fontWeight: 600 } }, String(item.sessionId).slice(0, 14)),
|
|
679
|
-
h('span', { style: styles.hint }, item.reason),
|
|
819
|
+
h('span', { style: styles.hint }, tr('queueReason', { reason: item.reason })),
|
|
680
820
|
h('span', { style: { ...styles.hint, marginLeft: 'auto' } }, new Date(item.at).toLocaleString())))),
|
|
681
821
|
h('div', { style: styles.actionsBar },
|
|
682
822
|
h('button', {
|
|
@@ -693,36 +833,36 @@ window.__ModuleLoader__.load({
|
|
|
693
833
|
}
|
|
694
834
|
},
|
|
695
835
|
}, tr('queueProcess')))),
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
extra: h('span', { style: styles.hint }, tr('localZero')),
|
|
699
|
-
},
|
|
836
|
+
|
|
837
|
+
h(Card, { title: tr('usage'), meta: h('span', { style: styles.hint }, tr('localZero')) },
|
|
700
838
|
h('div', { style: styles.usageGrid },
|
|
701
839
|
usageCard(tr('usageHour'), usage.hour),
|
|
702
840
|
usageCard(tr('usageDay'), usage.day),
|
|
703
841
|
usageCard(tr('usageWeek'), usage.week),
|
|
704
|
-
usageCard(tr('usageMonth'), usage.month),
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
h('
|
|
710
|
-
|
|
711
|
-
onChange: event => setRange(current => ({ ...current, from: event.target.value })),
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
h('
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
842
|
+
usageCard(tr('usageMonth'), usage.month)),
|
|
843
|
+
custom ? h('div', { style: { ...styles.usageGrid, gridTemplateColumns: 'repeat(1, minmax(0,1fr))', paddingTop: 8 } },
|
|
844
|
+
usageCard(tr('usageCustom'), custom)) : null,
|
|
845
|
+
h('div', { style: { display: 'flex', alignItems: 'flex-end', gap: 10, flexWrap: 'wrap', padding: '12px 14px 4px' } },
|
|
846
|
+
h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
847
|
+
h('span', { style: styles.unit }, tr('from')),
|
|
848
|
+
h('input', { style: styles.input, type: 'datetime-local', value: range.from,
|
|
849
|
+
onChange: event => setRange(current => ({ ...current, from: event.target.value })) })),
|
|
850
|
+
h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
851
|
+
h('span', { style: styles.unit }, tr('to')),
|
|
852
|
+
h('input', { style: styles.input, type: 'datetime-local', value: range.to,
|
|
853
|
+
onChange: event => setRange(current => ({ ...current, to: event.target.value })) })),
|
|
854
|
+
h('button', { style: styles.buttonSecondary, onClick: () => void applyRange() }, tr('apply')),
|
|
855
|
+
custom ? null : h('span', { style: styles.unit }, tr('customHint'))),
|
|
856
|
+
h('div', { style: { padding: '0 14px 12px' } }, h('span', { style: styles.unit }, tr('rangeEmptyHint')))),
|
|
857
|
+
|
|
858
|
+
h('div', { style: styles.footer },
|
|
859
|
+
failed
|
|
860
|
+
? h('span', { style: { ...styles.footerText, color: '#ffb3b3' } }, failed)
|
|
861
|
+
: message
|
|
862
|
+
? h('span', { style: { ...styles.footerText, color: '#8fe0b1' } }, message)
|
|
863
|
+
: h('span', { style: styles.footerText }, tr('saveHint')),
|
|
864
|
+
h('button', { style: saving ? { ...styles.buttonPrimary, opacity: 0.7 } : styles.buttonPrimary, disabled: saving, onClick: () => void save() },
|
|
865
|
+
saving ? tr('saving') : tr('save'))))
|
|
726
866
|
}
|
|
727
867
|
|
|
728
868
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-colophon",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Colophon(卷末)— keep a local, token-free conclusion digest for every conversation, so reopening an old session starts from its final state instead of its full history.",
|
|
5
5
|
"documentation": "README.md",
|
|
6
6
|
"license": "MIT",
|