dsh-team-bots 0.2.289 → 0.2.347
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/README.md +60 -122
- package/docs/README.zh.md +61 -123
- package/docs/assets/channel-redesign.png +0 -0
- package/docs/assets/global-config-dark.png +0 -0
- package/docs/assets/global-config-light.png +0 -0
- package/docs/assets/global-config-light.zh.png +0 -0
- package/docs/assets/global-config-redesign.png +0 -0
- package/docs/assets/secrets-redesign.png +0 -0
- package/docs/assets/tasks.png +0 -0
- package/docs/assets/tasks.zh.png +0 -0
- package/docs/assets/usage-redesign-global.png +0 -0
- package/docs/assets/usage.png +0 -0
- package/docs/assets/usage.zh.png +0 -0
- package/package.json +17 -5
- package/scripts/doctor.mjs +4 -4
- package/src/api.js +6 -3
- package/src/botmsg.js +1 -1
- package/src/config.js +18 -8
- package/src/db-migrations.js +76 -9
- package/src/db.js +28 -2
- package/src/http.js +22 -3
- package/src/paths.js +32 -1
- package/src/pricing.js +2 -2
- package/src/runtime.js +1 -1
- package/src/secrets.js +4 -4
- package/src/service.js +14 -5
- package/src/services/approvals.js +109 -24
- package/src/services/backoff.js +34 -0
- package/src/services/bot-quota.js +242 -0
- package/src/services/bots.js +35 -6
- package/src/services/chat.js +15 -9
- package/src/services/core.js +33 -5
- package/src/services/hygiene.js +8 -4
- package/src/services/locale.js +17 -0
- package/src/services/memory.js +112 -1
- package/src/services/message-images.js +3 -3
- package/src/services/notify.js +169 -0
- package/src/services/projects.js +119 -10
- package/src/services/proposals.js +2 -3
- package/src/services/questions.js +75 -32
- package/src/services/review-watchdog.js +261 -30
- package/src/services/run-finish.js +186 -17
- package/src/services/runs.js +42 -13
- package/src/services/runtime/lifecycle.js +3 -1
- package/src/services/runtime/model-restore.js +5 -5
- package/src/services/runtime/prompt.js +106 -45
- package/src/services/runtime/session.js +38 -14
- package/src/services/runtime/trajectory.js +1 -1
- package/src/services/scheduler.js +146 -19
- package/src/services/secrets.js +1 -1
- package/src/services/system.js +23 -6
- package/src/services/task-dispatch.js +315 -0
- package/src/services/task-notify.js +55 -11
- package/src/services/task-runs.js +179 -0
- package/src/services/task-stage.js +4 -0
- package/src/services/tasks.js +51 -399
- package/src/services/terminal.js +2 -2
- package/src/services/vision-proxy.js +3 -3
- package/src/services/wechat.js +228 -7
- package/src/services/workspace-groups.js +4 -3
- package/src/skill-parse.js +1 -1
- package/src/skills.js +1 -1
- package/src/tools.js +275 -6
- package/src/updater.js +52 -0
- package/src/usage-reconcile.js +1 -1
- package/src/usage.js +52 -11
- package/src/wechat/channel.js +14 -20
- package/src/wechat/commands.js +129 -81
- package/src/wechat/format.js +247 -0
- package/src/wechat/store.js +30 -2
- package/ui/app.js +57 -53
- package/ui/i18n/en/chat.js +140 -0
- package/ui/i18n/en/common.js +187 -0
- package/ui/i18n/en/nav.js +89 -0
- package/ui/i18n/en/settings.js +352 -0
- package/ui/i18n/en/tasks.js +229 -0
- package/ui/i18n/en/usage.js +141 -0
- package/ui/i18n/en/wechat.js +23 -0
- package/ui/i18n/en.js +17 -237
- package/ui/i18n/zh/chat.js +140 -0
- package/ui/i18n/zh/common.js +187 -0
- package/ui/i18n/zh/nav.js +89 -0
- package/ui/i18n/zh/settings.js +352 -0
- package/ui/i18n/zh/tasks.js +229 -0
- package/ui/i18n/zh/usage.js +141 -0
- package/ui/i18n/zh/wechat.js +23 -0
- package/ui/i18n/zh.js +17 -236
- package/ui/modules/api.js +4 -3
- package/ui/modules/bot-quota.js +27 -0
- package/ui/modules/cards.js +96 -58
- package/ui/modules/chat.js +28 -30
- package/ui/modules/composer.js +41 -37
- package/ui/modules/dom-morph.js +292 -0
- package/ui/modules/events-board.js +22 -22
- package/ui/modules/events-click.js +100 -68
- package/ui/modules/events-misc.js +34 -34
- package/ui/modules/events-submit.js +28 -28
- package/ui/modules/global-pages.js +125 -116
- package/ui/modules/i18n.js +0 -5
- package/ui/modules/icons.js +0 -1
- package/ui/modules/markdown.js +1 -1
- package/ui/modules/modal-forms.js +196 -203
- package/ui/modules/modal-layer.js +6 -9
- package/ui/modules/page-shell.js +62 -0
- package/ui/modules/settings.js +211 -198
- package/ui/modules/solo-archive.js +0 -4
- package/ui/modules/state.js +57 -50
- package/ui/modules/tasks.js +167 -171
- package/ui/modules/typing-linger.js +1 -4
- package/ui/modules/usage.js +65 -78
- package/ui/modules/util.js +92 -25
- package/ui/styles/avatars.css +14 -0
- package/ui/styles/cards.css +49 -0
- package/ui/styles/chat-cards.css +17 -21
- package/ui/styles/global-config.css +56 -2
- package/ui/styles/modal.css +13 -0
- package/ui/styles/usage.css +3 -61
- package/CONTRIBUTING.md +0 -20
- package/docs/assets/usage-dark.png +0 -0
package/ui/modules/api.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { state } from './state.js'
|
|
2
2
|
import { toast } from './util.js'
|
|
3
|
+
import { t } from './i18n.js'
|
|
3
4
|
|
|
4
5
|
export async function api(action, payload = {}, { quiet = false } = {}) {
|
|
5
6
|
state.busy += 1
|
|
@@ -14,12 +15,12 @@ export async function api(action, payload = {}, { quiet = false } = {}) {
|
|
|
14
15
|
try { body = await response.json() } catch { body = null }
|
|
15
16
|
if (!response.ok || !body?.ok) {
|
|
16
17
|
const message = body?.error?.message ?? (response.status === 401 || response.status === 403
|
|
17
|
-
?
|
|
18
|
-
:
|
|
18
|
+
? t("登录状态已失效,请回到 DSH Web 登录后重新打开。")
|
|
19
|
+
: t("请求失败,请稍后重试。"))
|
|
19
20
|
throw new Error(message)
|
|
20
21
|
}
|
|
21
22
|
return body.data
|
|
22
|
-
} catch (error) {
|
|
23
|
+
} catch (error ) {
|
|
23
24
|
if (!quiet) toast(error.message || String(error), 'error')
|
|
24
25
|
throw error
|
|
25
26
|
} finally {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// DSHBOTS-241:bot 额度墙状态的展示块。
|
|
2
|
+
// 主 provider 耗尽期内派发走备用模型或排队等待;这里给出恢复时间与「解除额度耗尽」入口
|
|
3
|
+
// (立即恢复派发,服务端限 owner/总监,见 src/services/bot-quota.ts)。
|
|
4
|
+
import { attr, esc, formatTime } from './util.js'
|
|
5
|
+
import { t } from './i18n.js'
|
|
6
|
+
|
|
7
|
+
export function botQuotaBlock(bot) {
|
|
8
|
+
const quota = bot?.quota
|
|
9
|
+
const primary = quota?.primary
|
|
10
|
+
if (!primary) return ''
|
|
11
|
+
const exhausted = Boolean(quota?.exhausted)
|
|
12
|
+
const status = exhausted ? t("额度耗尽") : t("额度正常")
|
|
13
|
+
const reset = exhausted && primary.resetAt
|
|
14
|
+
? `<div class="kv"><span>${t("预计恢复")}</span><strong>${esc(formatTime(primary.resetAt))}</strong></div>`
|
|
15
|
+
: ''
|
|
16
|
+
const fallback = quota?.fallback?.exhausted
|
|
17
|
+
? `<div class="kv"><span>${t("备用模型")}</span><strong>${t("同样耗尽")}</strong></div>`
|
|
18
|
+
: ''
|
|
19
|
+
const action = exhausted
|
|
20
|
+
? `<button class="btn small" type="button" data-action="release-bot-quota" data-bot-id="${attr(bot.id)}">${t("解除额度耗尽")}</button>`
|
|
21
|
+
: ''
|
|
22
|
+
return `<div class="divider"></div>
|
|
23
|
+
<div class="eyebrow" style="margin-bottom:9px">${t("额度状态")}</div>
|
|
24
|
+
<div class="kv"><span>${t("主模型")}</span><strong>${esc(primary.provider ?? '')}</strong></div>
|
|
25
|
+
<div class="kv"><span>${t("额度")}</span><strong>${status}</strong></div>
|
|
26
|
+
${reset}${fallback}${action}`
|
|
27
|
+
}
|
package/ui/modules/cards.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// cards.js —— 消息卡片域:审批卡片(DSHBOTS-32/102/108)、提问卡片(DSHBOTS-116)、
|
|
2
|
-
// 桌面通知(DSHBOTS-86)、Bot 私信折叠面板与 renderMessage。
|
|
3
|
-
// 标记块(approval-card / approval-ux / approval-v2 / question-card / desktop-notify)随本文件迁移,
|
|
4
|
-
// 块内容原样保留;tests/desktop-notify.test.js 等按标记块抽取断言。
|
|
5
1
|
import { state } from './state.js'
|
|
6
2
|
import { attr, avatar, botById, esc, formatTime } from './util.js'
|
|
7
3
|
import { icon } from './icons.js'
|
|
@@ -21,14 +17,14 @@ function formatApprovalRemaining(remainingMs) {
|
|
|
21
17
|
const total = Math.max(0, Math.ceil((Number(remainingMs) || 0) / 1000))
|
|
22
18
|
const minutes = Math.floor(total / 60)
|
|
23
19
|
const seconds = total % 60
|
|
24
|
-
if (minutes <= 0) return
|
|
25
|
-
return seconds === 0 ?
|
|
20
|
+
if (minutes <= 0) return t("${seconds} 秒后自动拒绝", { seconds: seconds })
|
|
21
|
+
return seconds === 0 ? t("${minutes} 分后自动拒绝", { minutes: minutes }) : t("${minutes} 分 ${seconds} 秒后自动拒绝", { minutes: minutes, seconds: seconds })
|
|
26
22
|
}
|
|
27
23
|
function approvalUrgent(remainingMs) {
|
|
28
24
|
return (Number(remainingMs) || 0) <= APPROVAL_URGENT_MS
|
|
29
25
|
}
|
|
30
26
|
// 从 epoch ms 反推剩余毫秒,供 1s 局部刷新复用(与后端 approvalView 同口径)。
|
|
31
|
-
function approvalRemainingFrom(expiresMs, fallbackMs) {
|
|
27
|
+
function approvalRemainingFrom(expiresMs, fallbackMs ) {
|
|
32
28
|
const expires = Number(expiresMs)
|
|
33
29
|
return Number.isFinite(expires) ? Math.max(0, expires - Date.now()) : (Number(fallbackMs) || 0)
|
|
34
30
|
}
|
|
@@ -43,7 +39,7 @@ function approvalExpiresMs(expiresAt) {
|
|
|
43
39
|
// 五态:pending(唯一强调态)/ allowed / rejected / timeout / cancelled。
|
|
44
40
|
// pending 之外四态统一走「已决」排版:无倒计时无按钮、正文降 --ink-2、卡片回中性底;
|
|
45
41
|
// 红色只出现在 rejected 的左侧条与 pill 小点,其余中性。
|
|
46
|
-
const APPROVAL_STATUS = { pending:
|
|
42
|
+
const APPROVAL_STATUS = { pending: t("等待审批"), allowed: t("已允许一次"), rejected: t("已拒绝"), timeout: t("已超时"), cancelled: t("已取消") }
|
|
47
43
|
// 各态图标:盾牌(待批)/ 对勾(已放行)/ 叉(已拒绝)/ 时钟(超时)/ 禁止(取消)。
|
|
48
44
|
// ui/modules/icons.js 不在本卡写范围,shield 与 ban 两枚路径在此内联;check/close/clock 走既有图标表。
|
|
49
45
|
const APPROVAL_ICON_PATHS = {
|
|
@@ -61,7 +57,7 @@ function formatApprovalCountdown(remainingMs) {
|
|
|
61
57
|
const total = Math.max(0, Math.ceil((Number(remainingMs) || 0) / 1000))
|
|
62
58
|
const minutes = Math.floor(total / 60)
|
|
63
59
|
const seconds = total % 60
|
|
64
|
-
return minutes <= 0 ?
|
|
60
|
+
return minutes <= 0 ? t("剩余 ${seconds} 秒", { seconds: seconds }) : t("剩余 ${minutes} 分 ${seconds} 秒", { minutes: minutes, seconds: seconds })
|
|
65
61
|
}
|
|
66
62
|
// 进度条比例:剩余时间 ÷ 授权窗口总长,夹在 0–1(剩余越多条越长,临期变短)。
|
|
67
63
|
function approvalProgressRatio(remainingMs, windowMs) {
|
|
@@ -86,12 +82,27 @@ function approvalTargetChip(approval, summary) {
|
|
|
86
82
|
const guessed = approvalPath(summary)
|
|
87
83
|
return guessed ? { text: guessed, title: guessed } : null
|
|
88
84
|
}
|
|
89
|
-
//
|
|
85
|
+
// 来源定位行(DSHBOTS-240):仅当条目带来源信息时出现——顶部跨会话审批通知需要
|
|
86
|
+
// 「来源群聊(项目名/KEY)+ 任务 ID + 任务名」定位,让 owner 不跳转即可判断该批谁。
|
|
87
|
+
// 群聊卡片不传 showSource,来源行整段不出现(同会话里项目名冗余,任务信息由群上下文承担)。
|
|
88
|
+
function approvalSourceLine(approval) {
|
|
89
|
+
const key = String(approval?.projectKey ?? '').trim()
|
|
90
|
+
const name = String(approval?.projectName ?? '').trim()
|
|
91
|
+
const scope = key
|
|
92
|
+
? (name ? `${name} · ${key}` : key)
|
|
93
|
+
: (name || (approval?.scope === 'solo' ? t("单聊") : ''))
|
|
94
|
+
const task = String(approval?.taskIdentifier ?? '').trim()
|
|
95
|
+
const title = String(approval?.taskTitle ?? '').trim()
|
|
96
|
+
if (!scope && !task) return ''
|
|
97
|
+
const taskText = task ? (title ? `${task} ${title}` : task) : ''
|
|
98
|
+
return `<div class="approval-source">${scope ? `<span class="approval-source-scope">${esc(scope)}</span>` : ''}${taskText ? `<span class="approval-source-task">${esc(taskText)}</span>` : ''}</div>`
|
|
99
|
+
}
|
|
100
|
+
// 卡片 HTML:头部(图标 + 角色 + 工具/路径 chip)、来源定位行、正文、页脚四段;五态共用同一骨架。
|
|
90
101
|
// pending 页脚是倒计时 + 进度条 + 双按钮;已决四态页脚只有状态 pill。
|
|
91
|
-
function approvalCardMarkup(approval, deciding = false) {
|
|
102
|
+
function approvalCardMarkup(approval, deciding = false, showSource = false) {
|
|
92
103
|
const status = String(approval.status ?? '')
|
|
93
104
|
const pending = status === 'pending'
|
|
94
|
-
const summary = approval.display_reason || approval.reason ||
|
|
105
|
+
const summary = approval.display_reason || approval.reason || t("(无说明)")
|
|
95
106
|
const expiresAt = approvalExpiresMs(approval.expires_at)
|
|
96
107
|
const createdAt = Date.parse(approval.created_at)
|
|
97
108
|
const windowMs = Number.isFinite(createdAt) ? Math.max(1, expiresAt - createdAt) : 0
|
|
@@ -107,17 +118,18 @@ function approvalCardMarkup(approval, deciding = false) {
|
|
|
107
118
|
<div class="approval-head">
|
|
108
119
|
<span class="approval-icon is-${attr(status)}">${approvalIcon(APPROVAL_STATE_ICON[status] ?? 'clock')}</span>
|
|
109
120
|
<div class="approval-head-main">
|
|
110
|
-
<div class="message-meta approval-meta"><strong>${esc(approval.botName)}</strong><span class="approval-ask"
|
|
121
|
+
<div class="message-meta approval-meta"><strong>${esc(approval.botName)}</strong><span class="approval-ask">${t("请求提权")}</span><span>${esc(formatTime(approval.created_at))}</span></div>
|
|
111
122
|
<div class="approval-tools"><span class="approval-chip mono">${esc(approval.tool_name)}</span>${target ? `<span class="approval-chip mono approval-chip-path" title="${attr(target.title)}">${esc(target.text)}</span>` : ''}</div>
|
|
112
123
|
</div>
|
|
113
124
|
</div>
|
|
125
|
+
${showSource ? approvalSourceLine(approval) : ''}
|
|
114
126
|
<div class="approval-summary">${esc(summary)}</div>
|
|
115
127
|
${pending
|
|
116
128
|
? `<div class="approval-countdown${urgent ? ' urgent' : ''}" data-expires="${expiresAt}">${icon('clock')}<span class="approval-clock${approvalUrgent(approval.remainingMs) ? ' urgent' : ''}" data-expires="${expiresAt}">${esc(formatApprovalCountdown(approval.remainingMs))}</span></div>
|
|
117
129
|
<div class="approval-progress" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${percent}" data-expires="${expiresAt}" data-window="${windowMs}"><i class="approval-progress-fill" style="width:${percent}%"></i></div>
|
|
118
130
|
<div class="approval-actions">
|
|
119
|
-
<button class="btn small primary" data-action="approval-decide" data-approval-id="${attr(approval.id)}" data-decision="allow"${deciding ? ' disabled' : ''}
|
|
120
|
-
<button class="btn small danger" data-action="approval-decide" data-approval-id="${attr(approval.id)}" data-decision="reject"${deciding ? ' disabled' : ''}
|
|
131
|
+
<button class="btn small primary" data-action="approval-decide" data-approval-id="${attr(approval.id)}" data-decision="allow"${deciding ? ' disabled' : ''}>${t("允许一次")}</button>
|
|
132
|
+
<button class="btn small danger" data-action="approval-decide" data-approval-id="${attr(approval.id)}" data-decision="reject"${deciding ? ' disabled' : ''}>${t("拒绝")}</button>
|
|
121
133
|
</div>`
|
|
122
134
|
: `<div class="approval-foot"><span class="approval-pill ${pillTone}"${approval.decided_at ? ` title="${attr(formatTime(approval.decided_at))}"` : ''}>${esc(pillText)}</span></div>`}
|
|
123
135
|
</div>
|
|
@@ -139,7 +151,7 @@ function renderApprovalCard(message) {
|
|
|
139
151
|
// ===== question-card:start 提问卡片(DSHBOTS-116 UI)=====
|
|
140
152
|
// 四态:pending(唯一强调态,可作答)/ answered / expired / timeout。
|
|
141
153
|
// 与审批卡片同骨架:pending 有倒计时 + 进度条 + 作答区,已决态只留状态 pill 与答案摘要。
|
|
142
|
-
const QUESTION_STATUS = { pending:
|
|
154
|
+
const QUESTION_STATUS = { pending: t("等待回答"), answered: t("已回答"), expired: t("已取消"), timeout: t("已超时") }
|
|
143
155
|
const QUESTION_STATE_ICON = { pending: 'message', answered: 'check', expired: 'close', timeout: 'clock' }
|
|
144
156
|
const QUESTION_URGENT_MS = 15_000
|
|
145
157
|
const questionBadgeText = (count) => (Number(count) > 99 ? '99+' : String(Number(count) || 0))
|
|
@@ -147,7 +159,7 @@ function questionExpiresMs(expiresAt) {
|
|
|
147
159
|
const parsed = Date.parse(expiresAt)
|
|
148
160
|
return Number.isFinite(parsed) ? parsed : 0
|
|
149
161
|
}
|
|
150
|
-
function questionRemainingFrom(expiresMs, fallbackMs) {
|
|
162
|
+
function questionRemainingFrom(expiresMs, fallbackMs ) {
|
|
151
163
|
const expires = Number(expiresMs)
|
|
152
164
|
return Number.isFinite(expires) ? Math.max(0, expires - Date.now()) : (Number(fallbackMs) || 0)
|
|
153
165
|
}
|
|
@@ -158,7 +170,7 @@ function formatQuestionCountdown(remainingMs) {
|
|
|
158
170
|
const total = Math.max(0, Math.ceil((Number(remainingMs) || 0) / 1000))
|
|
159
171
|
const minutes = Math.floor(total / 60)
|
|
160
172
|
const seconds = total % 60
|
|
161
|
-
return minutes <= 0 ?
|
|
173
|
+
return minutes <= 0 ? t("剩余 ${seconds} 秒", { seconds: seconds }) : t("剩余 ${minutes} 分 ${seconds} 秒", { minutes: minutes, seconds: seconds })
|
|
162
174
|
}
|
|
163
175
|
function questionProgressRatio(remainingMs, windowMs) {
|
|
164
176
|
const total = Number(windowMs) || 0
|
|
@@ -217,19 +229,19 @@ function questionItemMarkup(question, item, answerMap) {
|
|
|
217
229
|
const options = Array.isArray(item.options) ? item.options : []
|
|
218
230
|
const answer = answerMap.get(item.id)
|
|
219
231
|
const custom = answer?.custom ? String(answer.custom) : ''
|
|
220
|
-
const selectedText = Array.isArray(answer?.selected) ? answer.selected.map(label => String(label)).join(
|
|
232
|
+
const selectedText = Array.isArray(answer?.selected) ? answer.selected.map(label => String(label)).join(t("、")) : ''
|
|
221
233
|
const draft = questionDraftOf(question.id)
|
|
222
234
|
const intent = item.intent?.kind === 'plan-review' ? item.intent : null
|
|
223
235
|
const answerLine = answer
|
|
224
|
-
? `<div class="question-answer-line"><span class="question-answer-tag"
|
|
236
|
+
? `<div class="question-answer-line"><span class="question-answer-tag">${t("回答")}</span>${selectedText ? `<strong>${esc(selectedText)}</strong>` : `<span class="question-answer-skip">${t("(未选择)")}</span>`}${custom ? `<span class="question-answer-custom">${esc(custom)}</span>` : ''}</div>`
|
|
225
237
|
: ''
|
|
226
238
|
return `<div class="question-item" data-question-item="${attr(item.id)}">
|
|
227
239
|
<div class="question-item-title">${item.header ? `<span class="question-item-header">${esc(item.header)}</span>` : ''}${esc(item.question)}</div>
|
|
228
240
|
${item.detail ? `<div class="question-item-detail">${esc(item.detail)}</div>` : ''}
|
|
229
|
-
${intent ? `<div class="question-item-intent">${icon('branch')}<span
|
|
241
|
+
${intent ? `<div class="question-item-intent">${icon('branch')}<span>${t("计划评审")}</span>${intent.approve ? `<span class="question-item-intent-approve">${esc(intent.approve)}</span>` : ''}</div>` : ''}
|
|
230
242
|
${question.status === 'pending'
|
|
231
243
|
? `<div class="question-options">${options.map(option => questionOptionButton(question, item, option)).join('')}</div>
|
|
232
|
-
<input class="input question-custom" type="text" data-question-custom data-question-id="${attr(question.id)}" data-item-id="${attr(item.id)}" maxlength="2000" placeholder="补充说明(可选)" value="${attr(draft.custom[item.id] ?? '')}">`
|
|
244
|
+
<input class="input question-custom" type="text" data-question-custom data-question-id="${attr(question.id)}" data-item-id="${attr(item.id)}" maxlength="2000" placeholder="${t("补充说明(可选)")}" value="${attr(draft.custom[item.id] ?? '')}">`
|
|
233
245
|
: answerLine}
|
|
234
246
|
</div>`
|
|
235
247
|
}
|
|
@@ -253,8 +265,8 @@ function questionCardMarkup(question, answering = false) {
|
|
|
253
265
|
<div class="question-head">
|
|
254
266
|
<span class="question-icon is-${attr(status)}">${icon(QUESTION_STATE_ICON[status] ?? 'clock')}</span>
|
|
255
267
|
<div class="question-head-main">
|
|
256
|
-
<div class="message-meta question-meta"><strong>${esc(question.botName)}</strong><span class="question-ask"
|
|
257
|
-
<div class="question-count">${items.length}
|
|
268
|
+
<div class="message-meta question-meta"><strong>${esc(question.botName)}</strong><span class="question-ask">${t("发起提问")}</span><span>${esc(formatTime(question.created_at))}</span></div>
|
|
269
|
+
<div class="question-count">${items.length} ${t("个问题")}</div>
|
|
258
270
|
</div>
|
|
259
271
|
</div>
|
|
260
272
|
${items.map(item => questionItemMarkup(question, item, answerMap)).join('')}
|
|
@@ -262,7 +274,7 @@ function questionCardMarkup(question, answering = false) {
|
|
|
262
274
|
? `<div class="question-countdown${urgent ? ' urgent' : ''}" data-expires="${expiresAt}">${icon('clock')}<span class="question-clock${urgent ? ' urgent' : ''}" data-expires="${expiresAt}">${esc(formatQuestionCountdown(remaining))}</span></div>
|
|
263
275
|
<div class="question-progress" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${percent}" data-expires="${expiresAt}" data-window="${windowMs}"><i class="question-progress-fill" style="width:${percent}%"></i></div>
|
|
264
276
|
<div class="question-actions">
|
|
265
|
-
<button class="btn small primary" type="button" data-action="question-submit" data-question-id="${attr(question.id)}"${answering ? ' disabled' : ''}
|
|
277
|
+
<button class="btn small primary" type="button" data-action="question-submit" data-question-id="${attr(question.id)}"${answering ? ' disabled' : ''}>${t("提交回答")}</button>
|
|
266
278
|
</div>`
|
|
267
279
|
: `<div class="question-foot"><span class="question-pill ${pillTone}"${question.answered_at ? ` title="${attr(formatTime(question.answered_at))}"` : ''}>${esc(pillText)}</span></div>`}
|
|
268
280
|
</div>
|
|
@@ -284,7 +296,7 @@ function questionBannerSummary(item) {
|
|
|
284
296
|
const items = Array.isArray(item.questions) ? item.questions : []
|
|
285
297
|
const first = items[0]?.question
|
|
286
298
|
if (!first) return ''
|
|
287
|
-
return items.length > 1 ? `${first}(共 ${items.length}
|
|
299
|
+
return items.length > 1 ? `${first}${t("(共")} ${items.length} ${t("问)")}` : first
|
|
288
300
|
}
|
|
289
301
|
function questionBannerView(pendingQuestions) {
|
|
290
302
|
const count = Number(pendingQuestions?.count ?? 0)
|
|
@@ -292,14 +304,14 @@ function questionBannerView(pendingQuestions) {
|
|
|
292
304
|
const items = pendingQuestions?.items ?? []
|
|
293
305
|
return `<div class="question-banner">
|
|
294
306
|
<button class="question-banner-btn" data-action="toggle-questions" aria-expanded="${state.questionPanelOpen ? 'true' : 'false'}">
|
|
295
|
-
${icon('message')}<span class="question-banner-text"
|
|
307
|
+
${icon('message')}<span class="question-banner-text">${t("待回答提问")}</span>
|
|
296
308
|
<span class="unread-badge">${questionBadgeText(count)}</span>
|
|
297
309
|
${icon('chevron', `chev${state.questionPanelOpen ? ' open' : ''}`)}
|
|
298
310
|
</button>
|
|
299
311
|
${state.questionPanelOpen ? `<div class="question-menu" role="menu">
|
|
300
|
-
${items.length === 0 ?
|
|
312
|
+
${items.length === 0 ? `<div class="question-menu-empty">${t("暂无明细")}</div>` : items.map(item => `
|
|
301
313
|
<button class="question-menu-item" role="menuitem" data-action="focus-question" data-question-id="${attr(item.id)}">
|
|
302
|
-
<span class="question-menu-project">${esc(item
|
|
314
|
+
<span class="question-menu-project">${esc(cardScopeLabel(item))}</span>
|
|
303
315
|
<span class="question-menu-line">${esc(item.botName || 'Bot')}</span>
|
|
304
316
|
<span class="question-menu-summary">${esc(questionBannerSummary(item))}</span>
|
|
305
317
|
<span class="question-menu-time" data-expires="${questionExpiresMs(item.expires_at)}">${esc(formatQuestionCountdown(questionRemainingFrom(questionExpiresMs(item.expires_at), item.remainingMs)))}</span>
|
|
@@ -308,11 +320,23 @@ function questionBannerView(pendingQuestions) {
|
|
|
308
320
|
</div>`
|
|
309
321
|
}
|
|
310
322
|
|
|
311
|
-
//
|
|
323
|
+
// 顶部窄条的来源标签(DSHBOTS-218):单聊会话没有项目归属,来源列显示「单聊」,不显示项目名。
|
|
324
|
+
function cardScopeLabel(item) {
|
|
325
|
+
return item.scope === 'solo' ? t("单聊") : (item.projectName || t("(未命名项目)"))
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// 点通知:聚焦窗口,跳到对应会话(项目群聊或单聊,DSHBOTS-218)并把提问卡滚动到可视区。
|
|
312
329
|
function focusQuestionCard(question) {
|
|
313
|
-
if (!question
|
|
314
|
-
|
|
315
|
-
|
|
330
|
+
if (!question) return
|
|
331
|
+
if (question.project_id) {
|
|
332
|
+
state.projectId = question.project_id
|
|
333
|
+
state.chatMode = 'group'
|
|
334
|
+
} else {
|
|
335
|
+
// 单聊卡片没有项目归属:跳到该 bot 的 1V1 会话,卡片锚点就在单聊消息流里。
|
|
336
|
+
if (!question.bot_id) return
|
|
337
|
+
state.soloBotId = question.bot_id
|
|
338
|
+
state.chatMode = 'solo'
|
|
339
|
+
}
|
|
316
340
|
state.view = 'chat'
|
|
317
341
|
refresh()
|
|
318
342
|
.then(() => {
|
|
@@ -322,27 +346,24 @@ function focusQuestionCard(question) {
|
|
|
322
346
|
.catch(() => {})
|
|
323
347
|
}
|
|
324
348
|
|
|
325
|
-
// 跨项目待审入口(DSHBOTS-102):工作台顶部一条窄条,只计 pending,99+
|
|
326
|
-
//
|
|
327
|
-
//
|
|
349
|
+
// 跨项目待审入口(DSHBOTS-102):工作台顶部一条窄条,只计 pending,99+ 封顶。
|
|
350
|
+
// 展开后直接渲染审批卡(DSHBOTS-240):与群内审批卡同一组件、同一五态骨架,含「允许一次/拒绝」
|
|
351
|
+
// 按钮,可在通知内直接决策;点卡片非按钮区仍跳到对应会话(与内联按钮并存)。
|
|
328
352
|
function approvalBannerView(pendingApprovals) {
|
|
329
353
|
const count = Number(pendingApprovals?.count ?? 0)
|
|
330
354
|
if (count <= 0) return ''
|
|
331
355
|
const items = pendingApprovals?.items ?? []
|
|
332
356
|
return `<div class="approval-banner">
|
|
333
357
|
<button class="approval-banner-btn" data-action="toggle-approvals" aria-expanded="${state.approvalPanelOpen ? 'true' : 'false'}">
|
|
334
|
-
${icon('alert')}<span class="approval-banner-text"
|
|
358
|
+
${icon('alert')}<span class="approval-banner-text">${t("待处理审批")}</span>
|
|
335
359
|
<span class="unread-badge">${approvalBadgeText(count)}</span>
|
|
336
360
|
${icon('chevron', `chev${state.approvalPanelOpen ? ' open' : ''}`)}
|
|
337
361
|
</button>
|
|
338
|
-
${state.approvalPanelOpen ? `<div class="approval-menu"
|
|
339
|
-
${items.length === 0 ?
|
|
340
|
-
<
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
<span class="approval-menu-summary">${esc(item.display_reason || item.reason || '')}</span>
|
|
344
|
-
<span class="approval-menu-time" data-expires="${approvalExpiresMs(item.expires_at)}">${esc(formatApprovalRemaining(item.remainingMs))}</span>
|
|
345
|
-
</button>`).join('')}
|
|
362
|
+
${state.approvalPanelOpen ? `<div class="approval-menu">
|
|
363
|
+
${items.length === 0 ? `<div class="approval-menu-empty">${t("暂无明细")}</div>` : items.map(item => `
|
|
364
|
+
<div class="approval-menu-card" data-action="focus-approval" data-approval-id="${attr(item.id)}">
|
|
365
|
+
${approvalCardMarkup(item, state.approvalDeciding?.has(item.id) ?? false, true)}
|
|
366
|
+
</div>`).join('')}
|
|
346
367
|
</div>` : ''}
|
|
347
368
|
</div>`
|
|
348
369
|
}
|
|
@@ -391,25 +412,42 @@ async function toggleDesktopNotify() {
|
|
|
391
412
|
// 开关显示态(全局配置页「界面」卡):不支持或被浏览器拒绝时置灰,并附一句原因。
|
|
392
413
|
function notifyToggleView() {
|
|
393
414
|
const permission = notifyPermission()
|
|
394
|
-
if (permission === 'unsupported') return { on: false, disabled: true, label:
|
|
395
|
-
if (permission === 'denied') return { on: false, disabled: true, label:
|
|
396
|
-
if (notifyOn()) return { on: true, disabled: false, label:
|
|
397
|
-
return { on: false, disabled: false, label: permission === 'granted' ?
|
|
415
|
+
if (permission === 'unsupported') return { on: false, disabled: true, label: t("不可用"), hint: t("当前环境不支持桌面通知(需 HTTPS 或 localhost)。") }
|
|
416
|
+
if (permission === 'denied') return { on: false, disabled: true, label: t("已被浏览器拒绝"), hint: t("在浏览器站点设置中允许通知后刷新页面。") }
|
|
417
|
+
if (notifyOn()) return { on: true, disabled: false, label: t("已开启"), hint: t("页面不可见或失焦时弹系统通知,需保持本页开启。") }
|
|
418
|
+
return { on: false, disabled: false, label: permission === 'granted' ? t("已关闭") : t("未开启"), hint: t("开启后新审批到达时弹系统桌面通知。") }
|
|
398
419
|
}
|
|
399
420
|
|
|
400
421
|
// 通知正文与群聊审批卡片同一口径:<bot 名> 请求使用 <工具>:<说明>;超长截断。
|
|
401
422
|
function approvalNotifyBody(approval) {
|
|
402
|
-
const head = `${approval.botName ?? 'Bot'} 请求使用 ${approval.tool_name ??
|
|
423
|
+
const head = `${approval.botName ?? 'Bot'} ${t("请求使用")} ${approval.tool_name ?? t("工具")}`
|
|
403
424
|
const summary = approval.display_reason || approval.reason || ''
|
|
404
|
-
|
|
425
|
+
// 来源定位(DSHBOTS-240):桌面通知(气泡态)正文前缀带来源群聊(项目名/KEY)+ 任务 ID/任务名,
|
|
426
|
+
// 让 owner 在通知里即可判断该批谁;无来源字段时保持原文案逐字不变。
|
|
427
|
+
const source = [
|
|
428
|
+
approval.projectKey
|
|
429
|
+
? (approval.projectName ? `${approval.projectName} · ${approval.projectKey}` : approval.projectKey)
|
|
430
|
+
: (approval.scope === 'solo' ? t("单聊") : ''),
|
|
431
|
+
approval.taskIdentifier ? (approval.taskTitle ? `${approval.taskIdentifier} ${approval.taskTitle}` : approval.taskIdentifier) : '',
|
|
432
|
+
].filter(Boolean).join(' · ')
|
|
433
|
+
const text = source
|
|
434
|
+
? t("${source}|${head}:${summary}", { source: source, head: head, summary: summary })
|
|
435
|
+
: (summary ? t("${head}:${summary}", { head: head, summary: summary }) : head)
|
|
405
436
|
return text.length > 120 ? `${text.slice(0, 119)}…` : text
|
|
406
437
|
}
|
|
407
438
|
|
|
408
|
-
//
|
|
439
|
+
// 点通知:聚焦窗口,跳到对应会话(项目群聊或单聊,DSHBOTS-218)并把审批卡滚动到可视区。
|
|
409
440
|
function focusApprovalCard(approval) {
|
|
410
|
-
if (!approval
|
|
411
|
-
|
|
412
|
-
|
|
441
|
+
if (!approval) return
|
|
442
|
+
if (approval.project_id) {
|
|
443
|
+
state.projectId = approval.project_id
|
|
444
|
+
state.chatMode = 'group'
|
|
445
|
+
} else {
|
|
446
|
+
// 单聊卡片没有项目归属:跳到该 bot 的 1V1 会话,卡片锚点就在单聊消息流里。
|
|
447
|
+
if (!approval.bot_id) return
|
|
448
|
+
state.soloBotId = approval.bot_id
|
|
449
|
+
state.chatMode = 'solo'
|
|
450
|
+
}
|
|
413
451
|
state.view = 'chat'
|
|
414
452
|
refresh()
|
|
415
453
|
.then(() => {
|
|
@@ -436,7 +474,7 @@ function notifyNewApprovals(approvals, { enabled = notifyOn(), hidden = document
|
|
|
436
474
|
if (!fresh.includes(approval.id) || notifiedApprovals.has(approval.id)) continue
|
|
437
475
|
notifiedApprovals.add(approval.id)
|
|
438
476
|
try {
|
|
439
|
-
const notification = new Notification(
|
|
477
|
+
const notification = new Notification(t("DSH 审批请求"), { body: approvalNotifyBody(approval), tag: `approval-${approval.id}` })
|
|
440
478
|
notification.onclick = () => { window.focus(); focusApprovalCard(approval); notification.close() }
|
|
441
479
|
} catch {}
|
|
442
480
|
}
|
|
@@ -456,7 +494,7 @@ function renderMessage(message) {
|
|
|
456
494
|
const bot = isUser ? null : botById(message.sender_id)
|
|
457
495
|
// 引用块:气泡顶部一行「❝ 名字:摘要」,纯展示。摘要走 mdPlainSummary 去掉 markdown 记号,
|
|
458
496
|
// 否则原文里的 **、-、` 会原样露出,还会让整条摘要挤成一行、撑破气泡宽度。
|
|
459
|
-
const quoteBlock = message.reply_to ? `<div class="msg-quote" title="${attr(t('message.quoteFrom', { name: message.reply_to.sender_name }))}">${icon('quote')}<span>${esc(message.reply_to.sender_name)}
|
|
497
|
+
const quoteBlock = message.reply_to ? `<div class="msg-quote" title="${attr(t('message.quoteFrom', { name: message.reply_to.sender_name }))}">${icon('quote')}<span>${esc(message.reply_to.sender_name)}${t(":")}${esc(mdPlainSummary(message.reply_to.excerpt, 120))}</span></div>` : ''
|
|
460
498
|
// hover 引用按钮:仅群聊;点击进入引用回复(选中该消息作为回复目标)。摘要同样去 markdown 记号。
|
|
461
499
|
const quoteBtn = state.chatMode === 'group' ? `<button class="msg-quote-btn" data-action="quote-message" data-message-id="${attr(message.id)}" data-sender-name="${attr(message.senderName)}" data-excerpt="${attr(mdPlainSummary(message.body, 120))}" title="${t('message.quoteTitle')}" aria-label="${t('message.quoteLabel')}">${icon('quote')}</button>` : ''
|
|
462
500
|
// hover 复制按钮:群聊/单聊都有,紧邻引用按钮右侧;复制消息原文 message.body(非渲染后 HTML),走统一 copy handler。
|
|
@@ -480,7 +518,7 @@ function renderMessage(message) {
|
|
|
480
518
|
|
|
481
519
|
// ===== Bot 私信(项目群聊视图的折叠面板,数据来自 state.directMessages)=====
|
|
482
520
|
|
|
483
|
-
const DM_STATUS = { pending:
|
|
521
|
+
const DM_STATUS = { pending: t("待回复"), delivered: t("已送达"), replied: t("已回复"), failed: t("失败") }
|
|
484
522
|
const DM_STATUS_TONE = { pending: '', delivered: 'violet', replied: 'green', failed: 'red' }
|
|
485
523
|
|
|
486
524
|
function renderDirectMessagesCard() {
|
package/ui/modules/chat.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// chat.js —— 聊天域:群聊 / 单聊消息流渲染、输入中状态行、历史分片加载、单聊详情与配置页。
|
|
2
|
-
// 输入区(草稿 / 图片 / 发送)在 composer.js,消息卡片在 cards.js,输入中气泡在 typing-linger.js。
|
|
3
1
|
import { state, BOT_STATUS, CHAT_ACTIVE_TASK_LIMIT, CHAT_PAGE_SIZE, COLORS, COLOR_NAMES } from './state.js'
|
|
4
2
|
import { icon } from './icons.js'
|
|
5
3
|
import { activeProject, attr, avatar, botById, duration, esc, filePolicyOptions, formatTime, memberRunDot, pathCode, runDotHtml, tildePath, timeAgo, toast } from './util.js'
|
|
@@ -23,7 +21,7 @@ function activeTypingRuns(runs, kind) {
|
|
|
23
21
|
botId: run.bot_id,
|
|
24
22
|
botName: run.botName ?? 'Bot',
|
|
25
23
|
status: run.status,
|
|
26
|
-
text: run.status === 'queued' ?
|
|
24
|
+
text: run.status === 'queued' ? t("排队等待回复…") : t("正在思考与回复…"),
|
|
27
25
|
// 耗时起点:未开始运行的从排队时刻起算
|
|
28
26
|
startedAt: run.started_at ?? run.queued_at,
|
|
29
27
|
}))
|
|
@@ -113,7 +111,7 @@ async function loadOlderMessages() {
|
|
|
113
111
|
if (!listEl || state.chatAtBottom) return
|
|
114
112
|
listEl.scrollTop = prevTop + (listEl.scrollHeight - prevHeight)
|
|
115
113
|
})
|
|
116
|
-
} catch (err) {
|
|
114
|
+
} catch (err ) {
|
|
117
115
|
toast(err?.message || t('toast.loadOlderFailed'))
|
|
118
116
|
} finally {
|
|
119
117
|
state.chatOlder.loading = false
|
|
@@ -274,7 +272,7 @@ function dispatchRunRow(run) {
|
|
|
274
272
|
return `<div class="side-row" title="${esc(`${runKindLabel(run.kind)} · ${runStatusLabel(run.status)}`)}">
|
|
275
273
|
<span class="run-dot ${attr(run.status ?? '')}"></span>
|
|
276
274
|
<strong>${esc(runKindLabel(run.kind) ?? '')}</strong>
|
|
277
|
-
<span class="side-row-title">${esc(run.projectKey == null || run.projectKey ===
|
|
275
|
+
<span class="side-row-title">${esc(run.projectKey == null || run.projectKey === t("单聊") ? t('common.soloChat') : run.projectKey)}</span>
|
|
278
276
|
<span class="run-clock" data-started="${attr(started)}">${duration(started)}</span>
|
|
279
277
|
</div>`
|
|
280
278
|
}
|
|
@@ -403,9 +401,9 @@ function renderSoloConfig() {
|
|
|
403
401
|
if (!bot) {
|
|
404
402
|
return `<div class="empty-state">
|
|
405
403
|
<div class="empty-symbol">${icon('bot')}</div>
|
|
406
|
-
<h3
|
|
407
|
-
<p
|
|
408
|
-
<button class="btn primary" data-action="nav" data-view="chat"
|
|
404
|
+
<h3>${t("还没有选择")} Bot</h3>
|
|
405
|
+
<p>${t("从左侧 Bots 树点一个 Bot 进入调度页,再点「配置」来到这里。")}</p>
|
|
406
|
+
<button class="btn primary" data-action="nav" data-view="chat">${t("返回对话")}</button>
|
|
409
407
|
</div>`
|
|
410
408
|
}
|
|
411
409
|
const revisions = state.soloDetail?.revisions ?? []
|
|
@@ -414,45 +412,45 @@ function renderSoloConfig() {
|
|
|
414
412
|
<div class="card config-card">
|
|
415
413
|
<div class="owner-row" style="margin-bottom:16px">
|
|
416
414
|
${avatar(bot, 'lg')}
|
|
417
|
-
<div class="owner-info"><strong style="font-size:var(--fs-title)">${esc(bot.name)}</strong><span>${esc(bot.role ||
|
|
415
|
+
<div class="owner-info"><strong style="font-size:var(--fs-title)">${esc(bot.name)}</strong><span>${esc(bot.role || t("团队成员"))} · ${esc(bot.modelRef ?? t("未配置模型"))} · ${esc(BOT_STATUS[bot.status] ?? bot.status)}</span></div>
|
|
418
416
|
</div>
|
|
419
417
|
<form data-form="update-bot" id="solo-config-form">
|
|
420
418
|
<input type="hidden" name="botId" value="${attr(bot.id)}">
|
|
421
419
|
<div class="field-row">
|
|
422
|
-
<div class="field"><label for="solo-bot-name"
|
|
423
|
-
<div class="field"><label for="solo-bot-role"
|
|
420
|
+
<div class="field"><label for="solo-bot-name">${t("名称")}</label><input class="input" style="width:100%" id="solo-bot-name" name="name" value="${attr(bot.name)}" placeholder="${t("例如:")}Builder" required maxlength="24"></div>
|
|
421
|
+
<div class="field"><label for="solo-bot-role">${t("角色标签")}</label><input class="input" style="width:100%" id="solo-bot-role" name="role" value="${attr(bot.role ?? '')}" placeholder="${t("例如:开发")}" maxlength="24"></div>
|
|
424
422
|
</div>
|
|
425
423
|
<div class="field-row">
|
|
426
|
-
<div class="field"><label for="solo-bot-model"
|
|
427
|
-
<div class="field"><label for="solo-bot-effort"
|
|
428
|
-
<div class="field"><label for="solo-bot-file-policy"
|
|
424
|
+
<div class="field"><label for="solo-bot-model">${t("模型")}</label><select class="select" style="width:100%" id="solo-bot-model" name="modelRef" data-model-select>${modelOptions(bot.provider, bot.model)}</select></div>
|
|
425
|
+
<div class="field"><label for="solo-bot-effort">${t("推理强度")}</label><select class="select" style="width:100%" id="solo-bot-effort" name="effort" data-effort-select>${effortOptions(bot.modelRef ?? '', bot.effort)}</select></div>
|
|
426
|
+
<div class="field"><label for="solo-bot-file-policy">${t("文件权限")}</label><select class="select" style="width:100%" id="solo-bot-file-policy" name="filePolicy" title="Bot ${t("会话内文件操作的沙箱边界,下次运行生效")}">${filePolicyOptions(bot.file_policy)}</select></div>
|
|
429
427
|
</div>
|
|
430
428
|
<div class="field-row">
|
|
431
|
-
<div class="field"><label for="solo-bot-fallback-model"
|
|
432
|
-
<div class="field"><label for="solo-bot-fallback-effort"
|
|
429
|
+
<div class="field"><label for="solo-bot-fallback-model">${t("备用模型")}</label><select class="select" style="width:100%" id="solo-bot-fallback-model" name="fallbackModelRef" data-fallback-model-select title="${t("主模型不可用时自动接手的备用模型,留空")} = ${t("不启用")}">${fallbackModelOptions(bot.fallbackModelRef ?? '')}</select></div>
|
|
430
|
+
<div class="field"><label for="solo-bot-fallback-effort">${t("备用推理强度")}</label><select class="select" style="width:100%" id="solo-bot-fallback-effort" name="fallbackEffort" data-fallback-effort-select>${effortOptions(bot.fallbackModelRef ?? '', bot.fallback_effort)}</select></div>
|
|
433
431
|
</div>
|
|
434
|
-
<div class="field"><span class="field-label" id="solo-bot-color-label"
|
|
435
|
-
<div class="field"><label for="solo-bot-instructions"
|
|
432
|
+
<div class="field"><span class="field-label" id="solo-bot-color-label">${t("外观颜色")}</span><div class="swatch-row" role="radiogroup" aria-labelledby="solo-bot-color-label">${COLORS.map(color => `<label class="swatch" title="${COLOR_NAMES[color] ?? color}"><input type="radio" name="color" value="${color}" aria-label="${COLOR_NAMES[color] ?? color}" ${(bot.color ?? COLORS[0]) === color ? 'checked' : ''}><span class="swatch-dot ${color}"></span></label>`).join('')}</div><div class="avatar-roll-row"><span class="faint">${t("像素头像")}</span><button class="btn small" type="button" data-action="roll-avatar" data-bot-id="${attr(bot.id)}">roll</button><button class="btn small" type="button" data-action="toggle-avatar" data-bot-id="${attr(bot.id)}">${bot.avatar_seed ? t("停用") : t("启用")}</button></div></div>
|
|
433
|
+
<div class="field"><label for="solo-bot-instructions">${t("角色指令")}</label><textarea class="textarea" style="width:100%" id="solo-bot-instructions" name="instructions" rows="12" placeholder="${t("说明职责、工作方式、边界和交付标准")}">${esc(bot.instructions ?? '')}</textarea></div>
|
|
436
434
|
</form>
|
|
437
435
|
<div class="divider"></div>
|
|
438
436
|
<div class="btn-row">
|
|
439
|
-
<button class="btn primary" type="submit" form="solo-config-form">${icon('check')}
|
|
440
|
-
${bot.status === 'active' ? `<button class="btn small" data-action="archive-bot" data-bot-id="${attr(bot.id)}"
|
|
441
|
-
${bot.status === 'archived' ? `<button class="btn small danger" data-action="bot-remove-tracking-open" data-bot-id="${attr(bot.id)}"
|
|
437
|
+
<button class="btn primary" type="submit" form="solo-config-form">${icon('check')}${t("保存新版本")}</button>
|
|
438
|
+
${bot.status === 'active' ? `<button class="btn small" data-action="archive-bot" data-bot-id="${attr(bot.id)}">${t("归档")} Bot</button>` : ''}
|
|
439
|
+
${bot.status === 'archived' ? `<button class="btn small danger" data-action="bot-remove-tracking-open" data-bot-id="${attr(bot.id)}">${t("移除追踪")}</button>` : ''}
|
|
442
440
|
</div>
|
|
443
441
|
</div>
|
|
444
442
|
<aside class="task-detail-side">
|
|
445
|
-
<div class="eyebrow" style="margin-bottom:9px"
|
|
446
|
-
<div class="kv"><span
|
|
447
|
-
<div class="kv"><span
|
|
448
|
-
<div class="kv"><span
|
|
443
|
+
<div class="eyebrow" style="margin-bottom:9px">${t("运行统计")}</div>
|
|
444
|
+
<div class="kv"><span>${t("运行次数")}</span><strong>${bot.stats.runs}</strong></div>
|
|
445
|
+
<div class="kv"><span>${t("成功 / 失败")}</span><strong>${bot.stats.succeeded} / ${bot.stats.failed}</strong></div>
|
|
446
|
+
<div class="kv"><span>${t("长期记忆")}</span><strong>${bot.memoryCount}</strong></div>
|
|
449
447
|
<div class="divider"></div>
|
|
450
|
-
<div class="eyebrow" style="margin-bottom:6px"
|
|
451
|
-
<div class="path-row">${pathCode(tildePath(bot.soloWorkspace))}<button class="btn icon small" data-action="copy" data-copy="${attr(bot.soloWorkspace ?? '')}" title="复制路径" aria-label="复制路径">${icon('copy')}</button></div>
|
|
448
|
+
<div class="eyebrow" style="margin-bottom:6px">${t("专属工作区")}</div>
|
|
449
|
+
<div class="path-row">${pathCode(tildePath(bot.soloWorkspace))}<button class="btn icon small" data-action="copy" data-copy="${attr(bot.soloWorkspace ?? '')}" title="${t("复制路径")}" aria-label="${t("复制路径")}">${icon('copy')}</button></div>
|
|
452
450
|
<div class="divider"></div>
|
|
453
|
-
<div class="eyebrow" style="margin-bottom:9px"
|
|
454
|
-
${revisions.length === 0 ? '<div class="faint">' + (state.soloDetail ?
|
|
455
|
-
<div class="usage-note"
|
|
451
|
+
<div class="eyebrow" style="margin-bottom:9px">${t("版本历史")}</div>
|
|
452
|
+
${revisions.length === 0 ? '<div class="faint">' + (state.soloDetail ? t("暂无版本") : t("加载中…")) + '</div>' : revisions.map(revision => `<div class="revision-row"><span class="mono">v${revision.version}</span><span class="faint">${esc(timeAgo(revision.created_at))}</span>${revision.version === bot.current_revision ? '' : `<button class="btn small" data-action="rollback-bot" data-bot-id="${attr(bot.id)}" data-revision-id="${attr(revision.id)}">${t("回滚")}</button>`}</div>`).join('')}
|
|
453
|
+
<div class="usage-note">${t("模型或强度变更会在下一次运行时生效,不会中断当前运行。")}</div>
|
|
456
454
|
</aside>
|
|
457
455
|
</div>`
|
|
458
456
|
}
|