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