dsh-qq-affinity 1.0.3 → 1.5.6

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 CHANGED
@@ -20,7 +20,7 @@ window.__ModuleLoader__.load({
20
20
  * This bundle's version. The Host reports its own; when the two differ the
21
21
  * panel says so, because a stale bundle otherwise looks like a broken button.
22
22
  */
23
- const VERSION = '1.0.2'
23
+ const VERSION = '1.5.5'
24
24
 
25
25
  // ---------------------------------------------------------------- palette
26
26
 
@@ -1218,7 +1218,18 @@ window.__ModuleLoader__.load({
1218
1218
  }, [
1219
1219
  h('div', { key: 'top', style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } }, [
1220
1220
  h(Chip, { key: 's', color: OUTBOX_COLOR(row.status) }, OUTBOX_LABEL[row.status] ?? row.status),
1221
+ row.kind === 'excuse' ? h(Chip, { key: 'k', color: C.warn }, '推辞(到上限)') : null,
1222
+ row.personaId === undefined || row.personaId === '' ? null : h(Chip, {
1223
+ key: 'p',
1224
+ color: row.personaId === 'default' ? C.idle : C.brand,
1225
+ title: row.personaId === 'default' ? '用你自己的口吻写的' : `用「${row.personaName || row.personaId}」这个人设写的`,
1226
+ }, row.personaId === 'default' ? '默认人设' : (row.personaName || row.personaId)),
1221
1227
  h('span', { key: 't', style: { fontSize: 10.5, color: C.label2, fontVariantNumeric: 'tabular-nums' } }, fmtTime(row.createdAt)),
1228
+ row.promptChars > 0 ? h('span', {
1229
+ key: 'size',
1230
+ title: '这次请求发给模型的字数(上限 6000 字,单条消息最多 500 字);越大越费 token',
1231
+ style: { fontSize: 10.5, color: C.label2, fontVariantNumeric: 'tabular-nums' },
1232
+ }, `输入 ${row.promptChars} 字`) : null,
1222
1233
  nameOf === undefined ? null : h('span', {
1223
1234
  key: 'to',
1224
1235
  style: { fontSize: 10.5, color: C.label2 },
@@ -1260,13 +1271,18 @@ window.__ModuleLoader__.load({
1260
1271
  }
1261
1272
 
1262
1273
  /** Per-person automatic reply settings. */
1263
- function CarePanel({ person, channel, careEnabled, busy, usage, onChange }) {
1274
+ function CarePanel({ person, channel, careEnabled, busy, usage, personas, onChange, onAddPersona, onDeletePersona, onResetCount }) {
1264
1275
  const care = person.care
1265
1276
  const [cap, setCap] = useState(String(care.hourlyCap))
1266
1277
  const [chars, setChars] = useState(String(care.maxReplyChars))
1267
1278
  const [quietFrom, setQuietFrom] = useState(care.quietFrom)
1268
1279
  const [quietTo, setQuietTo] = useState(care.quietTo)
1280
+ const [delay, setDelay] = useState(String(care.replyDelaySeconds ?? 5))
1269
1281
  const [clockError, setClockError] = useState('')
1282
+ // The "+ 新人设" form: name + description, saved through the open interface.
1283
+ const [personaForm, setPersonaForm] = useState(false)
1284
+ const [draftName, setDraftName] = useState('')
1285
+ const [draftPrompt, setDraftPrompt] = useState('')
1270
1286
 
1271
1287
  const channelReady = channel !== undefined && channel.available === true && channel.enabled === true
1272
1288
  const commitNumber = (field, value, min, max, reset) => {
@@ -1326,6 +1342,78 @@ window.__ModuleLoader__.load({
1326
1342
  style: { fontSize: 11, color: C.label2, lineHeight: 1.6 },
1327
1343
  }, '注意:托管总开关现在是关的,这里打开也不会生效。到「设置」里打开总开关。') : null,
1328
1344
 
1345
+ (() => {
1346
+ const list = Array.isArray(personas) ? personas : []
1347
+ const currentId = care.persona ?? 'default'
1348
+ const current = list.find(entry => entry.id === currentId) ?? list[0]
1349
+ return h('div', { key: 'persona', style: { display: 'flex', flexDirection: 'column', gap: 6 } }, [
1350
+ h('div', { key: 'row', style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' } }, [
1351
+ h('span', { key: 'l', style: { fontSize: 11.5, color: C.label2 } }, '说话人设'),
1352
+ h('select', {
1353
+ key: 'sel',
1354
+ 'aria-label': '回复人设',
1355
+ // A persona that no longer exists must not leave the select blank.
1356
+ value: current === undefined ? 'default' : current.id,
1357
+ disabled: busy,
1358
+ onChange: (event) => onChange({ persona: event.target.value }),
1359
+ style: { ...inputStyle, width: 'auto', minWidth: 190, cursor: 'pointer' },
1360
+ }, list.map(entry => h('option', { key: entry.id, value: entry.id }, entry.name))),
1361
+ h(Btn, {
1362
+ key: 'new',
1363
+ kind: 'quiet',
1364
+ style: { padding: '2px 8px', fontSize: 11 },
1365
+ onClick: () => setPersonaForm(open => !open),
1366
+ }, personaForm ? '取消' : '+ 新人设'),
1367
+ current !== undefined && current.custom === true && typeof onDeletePersona === 'function' ? h(Btn, {
1368
+ key: 'del',
1369
+ kind: 'quiet',
1370
+ disabled: busy,
1371
+ style: { padding: '2px 8px', fontSize: 11, color: C.error },
1372
+ title: '删除这个人设;用到它的人会回到默认人设',
1373
+ onClick: () => onDeletePersona(current.id),
1374
+ }, '删除这个人设') : null,
1375
+ ]),
1376
+ current === undefined ? null : h('div', {
1377
+ key: 'about',
1378
+ style: { fontSize: 11, color: C.label2, lineHeight: 1.65 },
1379
+ }, current.summary ?? String(current.prompt ?? '').slice(0, 160)),
1380
+ personaForm ? h('div', {
1381
+ key: 'form',
1382
+ style: { display: 'flex', flexDirection: 'column', gap: 6, padding: '8px 10px', background: C.layer1, border: `1px solid ${C.border1}`, borderRadius: 8 },
1383
+ }, [
1384
+ h(Field, { key: 'n', label: '人设名(会出现在下拉里)' }, h('input', {
1385
+ value: draftName,
1386
+ placeholder: '例如:隔壁老王',
1387
+ onChange: (event) => setDraftName(event.target.value.slice(0, 40)),
1388
+ style: inputStyle,
1389
+ })),
1390
+ h(Field, { key: 'p', label: '这个人怎么说话(描述越具体越像)' }, h('textarea', {
1391
+ value: draftPrompt,
1392
+ rows: 4,
1393
+ placeholder: '例如:说话直白、爱用短句、习惯反问;对熟人会损两句,但分寸很稳。',
1394
+ onChange: (event) => setDraftPrompt(event.target.value.slice(0, 2000)),
1395
+ style: { ...inputStyle, resize: 'vertical', lineHeight: 1.6, fontFamily: 'inherit' },
1396
+ })),
1397
+ h('div', { key: 'b', style: { display: 'flex', gap: 8, alignItems: 'center' } }, [
1398
+ h(Btn, {
1399
+ key: 'save',
1400
+ kind: 'primary',
1401
+ disabled: busy || draftName.trim() === '' || draftPrompt.trim() === '',
1402
+ onClick: () => {
1403
+ if (typeof onAddPersona !== 'function') return
1404
+ onAddPersona({ name: draftName.trim(), prompt: draftPrompt.trim() })
1405
+ setDraftName('')
1406
+ setDraftPrompt('')
1407
+ setPersonaForm(false)
1408
+ },
1409
+ }, '保存人设'),
1410
+ h('span', { key: 'h', style: { fontSize: 10.5, color: C.label2, lineHeight: 1.5 } },
1411
+ '保存后会自动选中它。人设只影响措辞,不会改变好感度的判断口径。'),
1412
+ ]),
1413
+ ]) : null,
1414
+ ])
1415
+ })(),
1416
+
1329
1417
  h('div', { key: 'mode', style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' } }, [
1330
1418
  h('span', { key: 'l', style: { fontSize: 11.5, color: C.label2 } }, '方式'),
1331
1419
  h(Btn, {
@@ -1348,7 +1436,7 @@ window.__ModuleLoader__.load({
1348
1436
  ]),
1349
1437
 
1350
1438
  h('div', { key: 'limits', style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(120px, 1fr))', gap: 8 } }, [
1351
- h(Field, { key: 'cap', label: '每小时最多几条' }, h('input', {
1439
+ h(Field, { key: 'cap', label: '每小时最多回几次' }, h('input', {
1352
1440
  value: cap,
1353
1441
  inputMode: 'numeric',
1354
1442
  onChange: (event) => setCap(event.target.value.replace(/\D/g, '').slice(0, 2)),
@@ -1362,8 +1450,20 @@ window.__ModuleLoader__.load({
1362
1450
  onBlur: () => commitNumber('maxReplyChars', chars, 10, 300, () => setChars(String(care.maxReplyChars))),
1363
1451
  style: inputStyle,
1364
1452
  })),
1453
+ h(Field, { key: 'delay', label: '等几秒再回(0 = 立刻回)' }, h('input', {
1454
+ value: delay,
1455
+ inputMode: 'numeric',
1456
+ onChange: (event) => setDelay(event.target.value.replace(/\D/g, '').slice(0, 3)),
1457
+ onBlur: () => commitNumber('replyDelaySeconds', delay, 0, 300, () => setDelay(String(care.replyDelaySeconds))),
1458
+ style: inputStyle,
1459
+ })),
1365
1460
  ]),
1366
1461
 
1462
+ h('div', {
1463
+ key: 'delay-note',
1464
+ style: { fontSize: 11, color: C.label2, lineHeight: 1.7 },
1465
+ }, `等 ${care.replyDelaySeconds ?? 5} 秒再回:这段时间里 TA 再发消息就重新计时,等安静下来才一次性回完上面所有内容。想直接回就把这里填 0。`),
1466
+
1367
1467
  h('div', { key: 'quiet', style: { display: 'flex', gap: 8, alignItems: 'flex-end', flexWrap: 'wrap' } }, [
1368
1468
  h(Field, { key: 'f', label: '免打扰开始(留空 = 不启用)' }, h('input', {
1369
1469
  value: quietFrom,
@@ -1407,7 +1507,39 @@ window.__ModuleLoader__.load({
1407
1507
  usage === undefined ? null : h('div', {
1408
1508
  key: 'usage',
1409
1509
  style: { fontSize: 11, color: C.label2 },
1410
- }, `最近一小时自动回复 ${usage.lastHour} 条,最后一条 ${fmtTime(usage.lastAt)}。`),
1510
+ }, `最近一小时自动回复 ${usage.lastHour} 次${usage.coveredMessages > usage.lastHour ? `(覆盖 TA 的 ${usage.coveredMessages} 条消息)` : ''},最后一条 ${fmtTime(usage.lastAt)}。`),
1511
+
1512
+ h('div', {
1513
+ key: 'cap-note',
1514
+ style: { fontSize: 11, color: C.label2, lineHeight: 1.7 },
1515
+ }, `到上限(每小时 ${care.hourlyCap} 次)之后,插件会先用一句得体的借口把这次聊天收尾(「我先去忙了」这类),然后这一小时内不再回复。同一小时只推辞一次,不会反复刷理由。`),
1516
+
1517
+ h('div', {
1518
+ key: 'cap-note-2',
1519
+ style: { fontSize: 11, color: C.label2, lineHeight: 1.7 },
1520
+ }, `「一次」= 一条自动回复。如果 TA 连着发好几条、被上面那几秒的等待攒成一批,那也只算一次。`),
1521
+
1522
+ typeof onResetCount === 'function' ? h('div', {
1523
+ key: 'reset',
1524
+ style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' },
1525
+ }, [
1526
+ h(Btn, {
1527
+ key: 'b',
1528
+ kind: 'outline',
1529
+ disabled: busy,
1530
+ title: '把这个人这一小时的回复计数清零,托管立刻恢复回复',
1531
+ onClick: () => {
1532
+ const spent = usage === undefined ? '' : `(这一小时已经回复 ${usage.lastHour} 条)`
1533
+ if (!window.confirm(`把「${person.names?.slice(-1)[0] ?? person.uin}」这一小时的自动回复计数清零?${spent}之后托管会立刻恢复回复。`)) return
1534
+ onResetCount()
1535
+ },
1536
+ style: { padding: '3px 9px', fontSize: 11.5 },
1537
+ }, '重置这一小时的计数'),
1538
+ h('span', {
1539
+ key: 'h',
1540
+ style: { fontSize: 10.5, color: C.label2, lineHeight: 1.5 },
1541
+ }, '推辞记录也会作废,所以重新超限时会再推辞一次。'),
1542
+ ]) : null,
1411
1543
  ])
1412
1544
  }
1413
1545
 
@@ -1910,6 +2042,61 @@ window.__ModuleLoader__.load({
1910
2042
  }
1911
2043
  }
1912
2044
 
2045
+ /** Analyse one group as a room: topics, mood, core members. */
2046
+ const analyzeGroupChat = async (conversationId, force = false) => {
2047
+ setBusy(`group:${conversationId}`)
2048
+ setPanelError(null)
2049
+ try {
2050
+ const result = await api('group', { method: 'POST', body: { conversationId, force } })
2051
+ if (!alive.current) return
2052
+ setState(result.state)
2053
+ if (result.group?.reused === true) notify('群里没有新消息,直接沿用了上次的分析(没有消耗模型调用)。')
2054
+ else if (result.group?.basedOn?.incremental === true) notify(`群聊分析已更新:只看了新增的 ${result.group.basedOn.deltaMessages} 条。`)
2055
+ else notify('群聊分析已完成。')
2056
+ } catch (failure) {
2057
+ if (!alive.current) return
2058
+ setPanelError({ where: `group:${conversationId}`, message: failure.message })
2059
+ } finally {
2060
+ if (alive.current) setBusy('')
2061
+ }
2062
+ }
2063
+
2064
+ /** Save a user-defined reply persona. */
2065
+ const addReplyPersona = async (draft) => {
2066
+ try {
2067
+ const result = await api('personas', { method: 'POST', body: { action: 'add', name: draft.name, prompt: draft.prompt } })
2068
+ if (!alive.current) return
2069
+ setState(result.state)
2070
+ notify(`人设「${result.persona.name}」已保存。`)
2071
+ } catch (failure) {
2072
+ if (alive.current) notify(failure.message)
2073
+ }
2074
+ }
2075
+
2076
+ /** Remove one custom reply persona; anyone using it falls back to default. */
2077
+ const deleteReplyPersona = async (id) => {
2078
+ try {
2079
+ const result = await api('personas', { method: 'POST', body: { action: 'delete', id } })
2080
+ if (!alive.current) return
2081
+ setState(result.state)
2082
+ notify('人设已删除,用到它的人回到默认人设。')
2083
+ } catch (failure) {
2084
+ if (alive.current) notify(failure.message)
2085
+ }
2086
+ }
2087
+
2088
+ /** Zero one person's hourly reply count, so托管 can answer again right away. */
2089
+ const resetCareCount = async (uin) => {
2090
+ try {
2091
+ const result = await api('care', { method: 'POST', body: { uin, action: 'reset-count' } })
2092
+ if (!alive.current) return
2093
+ setState(result.state)
2094
+ notify('这一小时的计数已清零,托管会立刻恢复回复。')
2095
+ } catch (failure) {
2096
+ if (alive.current) notify(failure.message)
2097
+ }
2098
+ }
2099
+
1913
2100
  const suggest = async (id) => {
1914
2101
  const result = await run(`suggest:${id}`, () => api('suggest', { method: 'POST', body: { conversationId: id } }))
1915
2102
  if (result === undefined) return
@@ -2920,6 +3107,12 @@ window.__ModuleLoader__.load({
2920
3107
  h(Btn, { key: 'del', kind: 'danger', onClick: () => void removeConversation(row.id) }, '删除数据'),
2921
3108
  ]) : null,
2922
3109
 
3110
+ row.enabled && row.kind === 'group' ? h(Section, {
3111
+ key: 'group-analysis',
3112
+ title: '群聊分析',
3113
+ extra: groupHeaderExtra(row),
3114
+ }, groupBody(row)) : null,
3115
+
2923
3116
  row.enabled && row.kind === 'group' ? h('div', {
2924
3117
  key: 'members',
2925
3118
  style: { fontSize: 11.5, color: C.label2, lineHeight: 1.8, display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' },
@@ -3237,6 +3430,160 @@ window.__ModuleLoader__.load({
3237
3430
  return h('div', { style: { display: 'flex', flexDirection: 'column', gap: 12 } }, [errorBox, header])
3238
3431
  }
3239
3432
 
3433
+ /** Header chip for the group analysis section. */
3434
+ function groupHeaderExtra(row) {
3435
+ const group = row.groupProfile
3436
+ if (group === null || group === undefined) return h(Chip, { key: 'c', color: C.idle }, '未分析')
3437
+ return h('div', { key: 'c', style: { display: 'flex', gap: 6, alignItems: 'center' } }, [
3438
+ group.atmosphere?.label === undefined || group.atmosphere.label === ''
3439
+ ? null
3440
+ : h(Chip, { key: 'a', color: C.brand }, group.atmosphere.label),
3441
+ h(Chip, { key: 'b', mono: true }, `置信 ${Math.round((group.confidence ?? 0) * 100)}%`),
3442
+ ])
3443
+ }
3444
+
3445
+ /** One labelled bar, used for topic shares and member shares. */
3446
+ function shareBar(share, color) {
3447
+ return h('div', {
3448
+ 'aria-hidden': true,
3449
+ style: { height: 4, borderRadius: 999, background: C.layer2, overflow: 'hidden', flex: '0 0 64px' },
3450
+ }, h('div', { style: { width: `${Math.round(Math.min(1, share) * 100)}%`, height: '100%', background: color } }))
3451
+ }
3452
+
3453
+ /** The group analysis body: empty state or the full picture. */
3454
+ function groupBody(row) {
3455
+ const group = row.groupProfile
3456
+ const working = busy === `group:${row.id}`
3457
+ const button = (key, label, kind, onClick, title) => h(Btn, {
3458
+ key, kind, title, disabled: working, onClick,
3459
+ }, working ? '正在分析…' : label)
3460
+ if (group === null || group === undefined) {
3461
+ return h('div', { style: { display: 'flex', flexDirection: 'column', gap: 10 } }, [
3462
+ h('div', { style: { fontSize: 12, color: C.label2, lineHeight: 1.85 } },
3463
+ '分析这个群主要在聊什么、气氛怎么样、谁在撑场子、怎么开口更容易被接住。需要至少 20 条记录。'),
3464
+ h('div', { key: 'b', style: { display: 'flex', gap: 8, alignItems: 'center' } }, [
3465
+ button('run', '分析这个群', 'primary', () => void analyzeGroupChat(row.id)),
3466
+ h('span', { key: 'n', style: { fontSize: 11, color: C.label2 } }, `${row.messageCount} 条记录`),
3467
+ ]),
3468
+ panelError !== null && panelError.where === `group:${row.id}` ? h('div', {
3469
+ key: 'err',
3470
+ style: { fontSize: 11.5, color: C.error, lineHeight: 1.7, whiteSpace: 'pre-wrap' },
3471
+ }, panelError.message) : null,
3472
+ ])
3473
+ }
3474
+ const stats = group.stats ?? {}
3475
+ const atmosphere = group.atmosphere ?? {}
3476
+ return h('div', { style: { display: 'flex', flexDirection: 'column', gap: 12 } }, [
3477
+ h('div', { key: 'sum', style: { fontSize: 13, lineHeight: 1.8, color: C.label } }, group.summary),
3478
+
3479
+ // Numbers the model cannot count, measured from the transcript.
3480
+ h('div', {
3481
+ key: 'stats',
3482
+ style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(120px, 1fr))', gap: 8 },
3483
+ }, [
3484
+ h('div', { key: 's1', style: { fontSize: 11.5, color: C.label2 } }, [
3485
+ h('div', { key: 'v', style: { color: C.label, fontSize: 15, fontWeight: 600, fontVariantNumeric: 'tabular-nums' } }, String(stats.activeSpeakers ?? '—')),
3486
+ h('div', { key: 'l' }, '常驻说话的人'),
3487
+ ]),
3488
+ h('div', { key: 's2', style: { fontSize: 11.5, color: C.label2 } }, [
3489
+ h('div', { key: 'v', style: { color: C.label, fontSize: 15, fontWeight: 600, fontVariantNumeric: 'tabular-nums' } }, `${Math.round((stats.topThreeShare ?? 0) * 100)}%`),
3490
+ h('div', { key: 'l' }, '前三人占发言'),
3491
+ ]),
3492
+ h('div', { key: 's3', style: { fontSize: 11.5, color: C.label2 } }, [
3493
+ h('div', { key: 'v', style: { color: C.label, fontSize: 15, fontWeight: 600, fontVariantNumeric: 'tabular-nums' } }, String(stats.messagesPerActiveDay ?? '—')),
3494
+ h('div', { key: 'l' }, '日均消息'),
3495
+ ]),
3496
+ h('div', { key: 's4', style: { fontSize: 11.5, color: C.label2 } }, [
3497
+ h('div', { key: 'v', style: { color: C.label, fontSize: 15, fontWeight: 600, fontVariantNumeric: 'tabular-nums' } }, `${Math.round((stats.myShare ?? 0) * 100)}%`),
3498
+ h('div', { key: 'l' }, '我的发言占'),
3499
+ ]),
3500
+ h('div', { key: 's5', style: { fontSize: 11.5, color: C.label2 } }, [
3501
+ h('div', { key: 'v', style: { color: C.label, fontSize: 15, fontWeight: 600, fontVariantNumeric: 'tabular-nums' } }, String(stats.atMeMessages ?? 0)),
3502
+ h('div', { key: 'l' }, '被 @ 次数'),
3503
+ ]),
3504
+ h('div', { key: 's6', style: { fontSize: 11.5, color: C.label2 } }, [
3505
+ h('div', { key: 'v', style: { color: C.label, fontSize: 15, fontWeight: 600 } },
3506
+ (stats.peakHours ?? []).length === 0 ? '—' : (stats.peakHours ?? []).map(hour => `${hour}点`).join(' ')),
3507
+ h('div', { key: 'l' }, '最活跃时段'),
3508
+ ]),
3509
+ ]),
3510
+
3511
+ (group.topics ?? []).length === 0 ? null : h('div', { key: 'topics', style: { display: 'flex', flexDirection: 'column', gap: 6 } }, [
3512
+ h('div', { key: 'h', style: { fontSize: 12, color: C.label2, marginBottom: 2 } }, '主要在聊什么'),
3513
+ ...group.topics.map((topic, index) => h('div', {
3514
+ key: index,
3515
+ style: { display: 'flex', alignItems: 'center', gap: 8, fontSize: 12 },
3516
+ }, [
3517
+ h('span', { key: 'l', style: { flex: '0 0 auto', color: C.label, minWidth: 64 } }, topic.label),
3518
+ shareBar(topic.share, C.brand),
3519
+ h('span', { key: 's', style: { fontSize: 11, color: C.label2, fontVariantNumeric: 'tabular-nums' } }, `${Math.round(topic.share * 100)}%`),
3520
+ h('span', { key: 'e', style: { flex: 1, minWidth: 0, fontSize: 11, color: C.label2, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: topic.evidence }, topic.evidence),
3521
+ ])),
3522
+ ]),
3523
+
3524
+ h('div', { key: 'mood', style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(150px, 1fr))', gap: 10 } }, [
3525
+ h(Meter, { key: 'e', label: '热闹程度', value: atmosphere.energy }),
3526
+ h(Meter, { key: 'w', label: '亲密度', value: atmosphere.warmth }),
3527
+ h(Meter, { key: 'o', label: '有序程度', value: atmosphere.order }),
3528
+ h(Meter, { key: 's', label: '正经事占比', value: atmosphere.seriousness }),
3529
+ ]),
3530
+ (atmosphere.evidence ?? []).length === 0 ? null : h('ul', {
3531
+ key: 'mood-ev',
3532
+ style: { margin: 0, paddingLeft: 18, fontSize: 11.5, color: C.label2, lineHeight: 1.8 },
3533
+ }, (atmosphere.evidence ?? []).map((line, index) => h('li', { key: index }, line))),
3534
+
3535
+ (group.coreMembers ?? []).length === 0 ? null : h('div', { key: 'core', style: { display: 'flex', flexDirection: 'column', gap: 5 } }, [
3536
+ h('div', { key: 'h', style: { fontSize: 12, color: C.label2 } }, '谁在撑这个群'),
3537
+ ...group.coreMembers.map((member, index) => {
3538
+ const known = (stats.speakers ?? []).find(speaker => speaker.uin === member.uin)
3539
+ return h('div', { key: index, style: { display: 'flex', alignItems: 'center', gap: 8, fontSize: 12 } }, [
3540
+ h('span', { key: 'n', style: { minWidth: 80, color: C.label } }, member.name === '' ? `QQ ${member.uin}` : member.name),
3541
+ h(Chip, { key: 'r', color: C.brand }, member.role === '' ? '活跃' : member.role),
3542
+ known === undefined ? null : shareBar(known.share, C.success),
3543
+ known === undefined ? null : h('span', { key: 's', style: { fontSize: 11, color: C.label2, fontVariantNumeric: 'tabular-nums' } }, `${Math.round(known.share * 100)}%`),
3544
+ h('span', { key: 'e', style: { flex: 1, minWidth: 0, fontSize: 11, color: C.label2, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: member.evidence }, member.evidence),
3545
+ ])
3546
+ }),
3547
+ ]),
3548
+
3549
+ (group.norms ?? []).length === 0 && (group.cautions ?? []).length === 0 ? null : h('div', {
3550
+ key: 'rules',
3551
+ style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))', gap: 10 },
3552
+ }, [
3553
+ (group.norms ?? []).length === 0 ? null : h('div', { key: 'n', style: { fontSize: 11.5, color: C.label2, lineHeight: 1.9 } }, [
3554
+ h('div', { key: 'h', style: { color: C.label, fontWeight: 600, marginBottom: 2 } }, '群里的默契'),
3555
+ ...(group.norms ?? []).map((line, index) => h('div', { key: index }, `· ${line}`)),
3556
+ ]),
3557
+ (group.cautions ?? []).length === 0 ? null : h('div', { key: 'c', style: { fontSize: 11.5, color: C.label2, lineHeight: 1.9 } }, [
3558
+ h('div', { key: 'h', style: { color: C.label, fontWeight: 600, marginBottom: 2 } }, '说话要小心'),
3559
+ ...(group.cautions ?? []).map((line, index) => h('div', { key: index }, `· ${line}`)),
3560
+ ]),
3561
+ ]),
3562
+
3563
+ (group.howToJoin ?? []).length === 0 ? null : h('div', { key: 'join', style: { fontSize: 11.5, color: C.label2, lineHeight: 1.9 } }, [
3564
+ h('div', { key: 'h', style: { color: C.label, fontWeight: 600, marginBottom: 2 } }, '怎么开口更容易被接住'),
3565
+ ...(group.howToJoin ?? []).map((line, index) => h('div', { key: index }, `· ${line}`)),
3566
+ ]),
3567
+
3568
+ h('div', {
3569
+ key: 'meta',
3570
+ style: { fontSize: 10.5, color: C.label2, display: 'flex', gap: 14, flexWrap: 'wrap', alignItems: 'center' },
3571
+ }, [
3572
+ h('span', { key: 'a' }, `依据 ${group.basedOn?.totalMessages ?? 0} 条消息`),
3573
+ h('span', { key: 'b' }, `更新于 ${fmtTime(group.updatedAt)}`),
3574
+ h('span', { key: 'c' }, analysisMode(group)),
3575
+ h('span', { key: 'd' }, `本次 ${tokenCost(group.usage)} tokens`),
3576
+ h('div', { key: 'sp', style: { flex: 1 } }),
3577
+ button('again', '增量更新', 'outline', () => void analyzeGroupChat(row.id)),
3578
+ button('force', '完整重算', 'quiet', () => void analyzeGroupChat(row.id, true), '忽略上次结论,从头读完全部记录'),
3579
+ ]),
3580
+ panelError !== null && panelError.where === `group:${row.id}` ? h('div', {
3581
+ key: 'err',
3582
+ style: { fontSize: 11.5, color: C.error, lineHeight: 1.7, whiteSpace: 'pre-wrap' },
3583
+ }, panelError.message) : null,
3584
+ ])
3585
+ }
3586
+
3240
3587
  function personDetail(row) {
3241
3588
  const stored = row.score
3242
3589
  const persona = row.persona ?? null
@@ -3639,7 +3986,11 @@ window.__ModuleLoader__.load({
3639
3986
  careEnabled,
3640
3987
  busy: busy === `care:${row.uin}`,
3641
3988
  usage: state.careUsage?.[row.uin],
3989
+ personas: state.replyPersonas ?? [],
3642
3990
  onChange: (patch) => void setCare(row.uin, patch),
3991
+ onAddPersona: addReplyPersona,
3992
+ onDeletePersona: deleteReplyPersona,
3993
+ onResetCount: () => void resetCareCount(row.uin),
3643
3994
  })),
3644
3995
 
3645
3996
  h(Section, { key: 'care-log', title: '这个人的自动回复记录' }, h(OutboxList, {