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
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
// 以及弹窗开关与焦点陷阱。骨架复用 modal-layer.js 的 modalShell / modalLoading / renderModalLayer。
|
|
3
|
-
import { state, STATUS, STATUS_ORDER, PRIORITY, BOT_STATUS, SKILL_STATUS, RUN_STATUS, CREATOR_TYPE, EFFORT, COLORS, COLOR_NAMES } from './state.js'
|
|
1
|
+
import { state, STATUS, STATUS_ORDER, PRIORITY, BOT_STATUS, SKILL_STATUS, RUN_STATUS, CREATOR_TYPE, EFFORT, COLORS, COLOR_NAMES, stageLabelText } from './state.js'
|
|
4
2
|
import { icon } from './icons.js'
|
|
5
3
|
import { activeBots, activeProject, attr, avatar, botById, duration, esc, filePolicyOptions, formatCost, formatNumber, formatTime, inSoloContext, pageProject, runDot, sandboxPill, timeAgo, toast } from './util.js'
|
|
6
4
|
import { api } from './api.js'
|
|
7
5
|
import { mdChatScope, richText } from './markdown.js'
|
|
8
6
|
import { t } from './i18n.js'
|
|
9
|
-
import { currentSkillVersion, skillVersions } from './tasks.js'
|
|
7
|
+
import { currentSkillVersion, skillVersions, taskUsageBlock } from './tasks.js'
|
|
10
8
|
import { ensureComposerImageInput, ensureImageViewer } from './composer.js'
|
|
11
9
|
import { app, refresh, panelAttrs, render, updateRunClocks } from '../app.js'
|
|
12
10
|
import { modalShell, modalLoading, renderModalLayer } from './modal-layer.js'
|
|
11
|
+
import { botQuotaBlock } from './bot-quota.js'
|
|
13
12
|
|
|
14
13
|
function modelOptions(provider, model) {
|
|
15
14
|
const models = state.data?.models ?? []
|
|
16
|
-
if (models.length === 0) return
|
|
15
|
+
if (models.length === 0) return `<option value="">DSH ${t("尚未提供模型")}</option>`
|
|
17
16
|
return models.map(item => `<option value="${attr(item.ref)}" ${item.provider === provider && item.model === model ? 'selected' : ''}>${esc(item.providerName)} / ${esc(item.name)}</option>`).join('')
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
function effortOptions(modelRef, current) {
|
|
21
20
|
const model = (state.data?.models ?? []).find(item => item.ref === modelRef)
|
|
22
21
|
const efforts = model?.efforts ?? []
|
|
23
|
-
if (efforts.length === 0) return `<option value=""
|
|
24
|
-
return `<option value=""
|
|
22
|
+
if (efforts.length === 0) return `<option value="">${t("模型默认")}${current ? `${t("(当前")} ${esc(EFFORT[current] ?? current)}${t(")")}` : ''}</option>`
|
|
23
|
+
return `<option value="">${t("模型默认")}</option>${efforts.map(effort => `<option value="${attr(effort.id)}" ${current === effort.id ? 'selected' : ''}>${esc(EFFORT[effort.id] ?? effort.name)}</option>`).join('')}`
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
// 备用模型下拉:首项留空即「不启用」;其余与主模型同一模型表。
|
|
28
27
|
function fallbackModelOptions(currentRef) {
|
|
29
28
|
const models = state.data?.models ?? []
|
|
30
|
-
const blank = `<option value=""${currentRef ? '' : ' selected'}
|
|
29
|
+
const blank = `<option value=""${currentRef ? '' : ' selected'}>${t("不启用(留空)")}</option>`
|
|
31
30
|
if (models.length === 0) return blank
|
|
32
31
|
return blank + models.map(item => `<option value="${attr(item.ref)}" ${item.ref === currentRef ? 'selected' : ''}>${esc(item.providerName)} / ${esc(item.name)}</option>`).join('')
|
|
33
32
|
}
|
|
@@ -50,19 +49,19 @@ function parseFallbackFields(ref, effort) {
|
|
|
50
49
|
function modalNewProject() {
|
|
51
50
|
const bots = activeBots()
|
|
52
51
|
return modalShell({
|
|
53
|
-
title:
|
|
52
|
+
title: t("新建项目空间"),
|
|
54
53
|
badge: '',
|
|
55
54
|
body: `<form data-form="create-project" id="modal-form">
|
|
56
|
-
<div class="field"><label id="new-project-name-label" for="new-project-name"
|
|
55
|
+
<div class="field"><label id="new-project-name-label" for="new-project-name">${t("项目名称")}</label><input class="input" style="width:100%" id="new-project-name" name="name" placeholder="${t("例如:官网重构")}" required maxlength="80" autofocus></div>
|
|
57
56
|
<div class="field-row">
|
|
58
|
-
<div class="field"><label id="new-project-key-label" for="new-project-key"
|
|
59
|
-
<div class="field"><label id="new-project-owner-label" for="new-project-owner"
|
|
57
|
+
<div class="field"><label id="new-project-key-label" for="new-project-key">${t("项目")} Key</label><input class="input mono" style="width:100%" id="new-project-key" name="key" placeholder="WEB" maxlength="10" pattern="[A-Za-z][A-Za-z0-9]{0,9}"><div class="hint">${t("任务的编号前缀。")}</div></div>
|
|
58
|
+
<div class="field"><label id="new-project-owner-label" for="new-project-owner">${t("总监")} Bot</label><select class="select" style="width:100%" id="new-project-owner" name="ownerBotId">${bots.map(bot => `<option value="${attr(bot.id)}">${esc(bot.name)} · ${esc(bot.role || t("成员"))}</option>`).join('')}</select></div>
|
|
60
59
|
</div>
|
|
61
|
-
<div class="field"><label id="new-project-description-label" for="new-project-description"
|
|
62
|
-
<div class="field"><label id="new-project-production-label" for="new-project-production"
|
|
63
|
-
${bots.length > 1 ? `<div class="field"><span class="field-label" id="new-project-members-label"
|
|
60
|
+
<div class="field"><label id="new-project-description-label" for="new-project-description">${t("项目说明")}</label><textarea class="textarea" id="new-project-description" name="description" placeholder="${t("项目目标、边界和验收标准")}"></textarea></div>
|
|
61
|
+
<div class="field"><label id="new-project-production-label" for="new-project-production">${t("生产目录")}</label><div style="display:flex;gap:8px"><input class="input mono" style="flex:1" id="new-project-production" name="productionDir" placeholder="/Users/you/repos/my-game${t("(可选)")}"><button class="btn" type="button" data-action="pick-dir-open" data-picker-for="new-project-production">${icon('folder')}${t("选择")}</button></div><div class="dir-picker" id="dir-picker-new-project-production" hidden></div></div>
|
|
62
|
+
${bots.length > 1 ? `<div class="field"><span class="field-label" id="new-project-members-label">${t("其他成员")}</span><div class="check-list" role="group" aria-labelledby="new-project-members-label">${bots.slice(1).map(bot => `<div class="check-row"><input type="checkbox" id="new-project-member-${attr(bot.id)}" name="memberIds" value="${attr(bot.id)}"><label for="new-project-member-${attr(bot.id)}">${avatar(bot, 'sm')} ${esc(bot.name)}</label><span class="role">${esc(bot.role || '')}</span></div>`).join('')}</div></div>` : ''}
|
|
64
63
|
</form>`,
|
|
65
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
64
|
+
footer: `<button class="btn" data-action="close-modal">${t("取消")}</button><button class="btn primary" type="submit" form="modal-form">${icon('plus')}${t("创建项目")}</button>`,
|
|
66
65
|
})
|
|
67
66
|
}
|
|
68
67
|
|
|
@@ -72,31 +71,31 @@ function modalRemoveTracking() {
|
|
|
72
71
|
const modal = state.modal
|
|
73
72
|
if (modal.step === 2) {
|
|
74
73
|
return modalShell({
|
|
75
|
-
title:
|
|
76
|
-
badge:
|
|
77
|
-
subtitle:
|
|
74
|
+
title: t("移除追踪 · 确认执行"),
|
|
75
|
+
badge: t("不可恢复"),
|
|
76
|
+
subtitle: `${t("输入项目名「")}${modal.name}${t("」以确认。")}`,
|
|
78
77
|
body: `<form data-form="remove-tracking" id="modal-form">
|
|
79
78
|
<input type="hidden" name="projectId" value="${attr(modal.projectId)}">
|
|
80
79
|
<input type="hidden" name="purge" value="${modal.purge ? '1' : ''}">
|
|
81
|
-
<div class="field"><label for="remove-tracking-name"
|
|
82
|
-
<div class="hint">${modal.purge ?
|
|
80
|
+
<div class="field"><label for="remove-tracking-name">${t("项目名称")}</label><input class="input" style="width:100%" id="remove-tracking-name" name="confirmName" placeholder="${esc(modal.name)}" autocomplete="off" autofocus></div>
|
|
81
|
+
<div class="hint">${modal.purge ? t("将删除本项目全部管理数据,并移除项目生产目录(含全部文件)。") : t("将删除本项目全部管理数据;项目生产目录保留。")}${t("此操作不可恢复。")}</div>
|
|
83
82
|
</form>`,
|
|
84
|
-
footer: `<button class="btn" data-action="remove-tracking-back" type="button"
|
|
83
|
+
footer: `<button class="btn" data-action="remove-tracking-back" type="button">${t("上一步")}</button><button class="btn danger" type="submit" form="modal-form" id="remove-tracking-submit" disabled>${t("确认移除追踪")}</button>`,
|
|
85
84
|
})
|
|
86
85
|
}
|
|
87
86
|
return modalShell({
|
|
88
|
-
title:
|
|
89
|
-
badge:
|
|
90
|
-
subtitle:
|
|
87
|
+
title: t("移除追踪 · 后果确认"),
|
|
88
|
+
badge: t("不可恢复"),
|
|
89
|
+
subtitle: `${t("将从本工作台移除已归档项目「")}${modal.name}${t("」。")}`,
|
|
91
90
|
body: `
|
|
92
91
|
<ul class="remove-tracking-list">
|
|
93
|
-
<li
|
|
94
|
-
<li
|
|
95
|
-
<li
|
|
92
|
+
<li>${t("本项目全部管理数据将删除:任务、运行记录、聊天消息、成员、记忆、提案、密钥绑定等。")}</li>
|
|
93
|
+
<li>${t("数据库中本项目的记录将一并清理,")}<strong>${t("不可恢复")}</strong>${t("。")}</li>
|
|
94
|
+
<li>${t("项目生产目录默认保留在原处。")}</li>
|
|
96
95
|
</ul>
|
|
97
|
-
<div class="check-row"><input type="checkbox" id="remove-tracking-purge"><label for="remove-tracking-purge"
|
|
98
|
-
<div class="hint"
|
|
99
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
96
|
+
<div class="check-row"><input type="checkbox" id="remove-tracking-purge"><label for="remove-tracking-purge">${t("同时移除项目生产目录")}</label></div>
|
|
97
|
+
<div class="hint">${t("勾选后将删除项目生产目录(含目录内全部文件),同样不可恢复;不确定就先不勾。")}</div>`,
|
|
98
|
+
footer: `<button class="btn" data-action="close-modal">${t("取消")}</button><button class="btn danger" data-action="remove-tracking-step2" type="button">${t("继续")}</button>`,
|
|
100
99
|
})
|
|
101
100
|
}
|
|
102
101
|
|
|
@@ -108,20 +107,20 @@ function modalRemoveBotTracking() {
|
|
|
108
107
|
const modal = state.modal
|
|
109
108
|
if (modal.step === 2) {
|
|
110
109
|
return modalShell({
|
|
111
|
-
title:
|
|
112
|
-
badge:
|
|
113
|
-
subtitle:
|
|
114
|
-
body: `<div class="field"><label for="remove-tracking-name">Bot
|
|
115
|
-
<div class="hint"
|
|
116
|
-
footer: `<button class="btn" data-action="bot-remove-tracking-back" type="button"
|
|
110
|
+
title: t("移除追踪 · 确认执行"),
|
|
111
|
+
badge: t("从列表移除"),
|
|
112
|
+
subtitle: `${t("输入 Bot 名称「")}${modal.name}${t("」以确认。")}`,
|
|
113
|
+
body: `<div class="field"><label for="remove-tracking-name">Bot ${t("名称")}</label><input class="input" style="width:100%" id="remove-tracking-name" name="confirmName" placeholder="${esc(modal.name)}" autocomplete="off" autofocus></div>
|
|
114
|
+
<div class="hint">${t("将从工作台列表移除「")}${esc(modal.name)}${t("」;运行记录、单聊消息与工作区文件全部保留,但移除后不能再恢复追踪。")}</div>`,
|
|
115
|
+
footer: `<button class="btn" data-action="bot-remove-tracking-back" type="button">${t("上一步")}</button><button class="btn danger" type="button" id="remove-tracking-submit" data-action="bot-remove-tracking-confirm" disabled>${t("确认移除追踪")}</button>`,
|
|
117
116
|
})
|
|
118
117
|
}
|
|
119
118
|
return modalShell({
|
|
120
|
-
title:
|
|
121
|
-
badge:
|
|
122
|
-
subtitle:
|
|
123
|
-
body: `<ul class="remove-tracking-list"><li
|
|
124
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
119
|
+
title: t("移除追踪 · 后果确认"),
|
|
120
|
+
badge: t("从列表移除"),
|
|
121
|
+
subtitle: `${t("将停止追踪已归档 Bot「")}${modal.name}${t("」。")}`,
|
|
122
|
+
body: `<ul class="remove-tracking-list"><li>${t("该 Bot 将从工作台 Bots 列表与单聊入口移除,不再显示。")}</li><li>${t("运行记录、单聊消息、版本历史与专属工作区目录")}<strong>${t("全部保留")}</strong>${t("(不做物理删除)。")}</li><li>${t("移除追踪后不能恢复,该 Bot 也不能再被修改或重新启用。")}</li></ul>`,
|
|
123
|
+
footer: `<button class="btn" data-action="close-modal">${t("取消")}</button><button class="btn danger" data-action="bot-remove-tracking-step2" type="button">${t("继续")}</button>`,
|
|
125
124
|
})
|
|
126
125
|
}
|
|
127
126
|
|
|
@@ -143,25 +142,18 @@ async function renderDirPicker(inputId, path) {
|
|
|
143
142
|
let error = ''
|
|
144
143
|
try {
|
|
145
144
|
data = await api('browse_dirs', { path }, { quiet: true })
|
|
146
|
-
} catch (err) {
|
|
145
|
+
} catch (err ) {
|
|
147
146
|
error = err?.message || String(err)
|
|
148
147
|
}
|
|
149
148
|
const current = data?.path ?? path ?? ''
|
|
150
|
-
const head =
|
|
151
|
-
<div style="display:flex;gap:6px;align-items:center;margin-bottom:6px">
|
|
152
|
-
<button class="btn small" type="button" data-action="pick-dir-up" data-picker-for="${attr(inputId)}" data-path="${attr(current)}" title="上一级">↑</button>
|
|
153
|
-
<button class="btn small" type="button" data-action="pick-dir-home" data-picker-for="${attr(inputId)}">主目录</button>
|
|
154
|
-
<span class="mono" style="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="${attr(current)}">${esc(current)}</span>
|
|
155
|
-
<button class="btn primary small" type="button" data-action="pick-dir-choose" data-picker-for="${attr(inputId)}" data-path="${attr(current)}">选定此目录</button>
|
|
156
|
-
<button class="btn small" type="button" data-action="pick-dir-close" data-picker-for="${attr(inputId)}" title="关闭">✕</button>
|
|
157
|
-
</div>`
|
|
149
|
+
const head = `\n <div style="display:flex;gap:6px;align-items:center;margin-bottom:6px">\n <button class="btn small" type="button" data-action="pick-dir-up" data-picker-for="${attr(inputId)}" data-path="${attr(current)}" title="${t("上一级")}">↑</button>\n <button class="btn small" type="button" data-action="pick-dir-home" data-picker-for="${attr(inputId)}">${t("主目录")}</button>\n <span class="mono" style="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="${attr(current)}">${esc(current)}</span>\n <button class="btn primary small" type="button" data-action="pick-dir-choose" data-picker-for="${attr(inputId)}" data-path="${attr(current)}">${t("选定此目录")}</button>\n <button class="btn small" type="button" data-action="pick-dir-close" data-picker-for="${attr(inputId)}" title="${t("关闭")}">✕</button>\n </div>`
|
|
158
150
|
if (error) {
|
|
159
151
|
box.innerHTML = `${head}<div class="hint" style="color:#c0392b">${esc(error)}</div>`
|
|
160
152
|
return
|
|
161
153
|
}
|
|
162
154
|
const dirs = data?.dirs ?? []
|
|
163
155
|
const list = dirs.length === 0
|
|
164
|
-
?
|
|
156
|
+
? `<div class="hint">${t("没有子目录")}</div>`
|
|
165
157
|
: dirs.map(name => `
|
|
166
158
|
<button class="btn small" type="button" style="display:block;width:100%;text-align:left;margin-bottom:4px" data-action="pick-dir-nav" data-picker-for="${attr(inputId)}" data-path="${attr(`${current.replace(/\/+$/, '')}/${name}`)}">${icon('folder')} ${esc(name)}</button>`).join('')
|
|
167
159
|
box.innerHTML = `${head}<div style="max-height:220px;overflow:auto">${list}</div>`
|
|
@@ -173,9 +165,9 @@ function modalInviteMember() {
|
|
|
173
165
|
const project = activeProject()
|
|
174
166
|
if (!project) {
|
|
175
167
|
return modalShell({
|
|
176
|
-
title:
|
|
177
|
-
body: `<div class="empty-state" style="border:0"><div class="empty-symbol">${icon('bot')}</div><h3
|
|
178
|
-
footer:
|
|
168
|
+
title: t("邀请加入"),
|
|
169
|
+
body: `<div class="empty-state" style="border:0"><div class="empty-symbol">${icon('bot')}</div><h3>${t("请先进入一个项目")}</h3><p>${t("进入项目后才能邀请成员。")}</p></div>`,
|
|
170
|
+
footer: `<button class="btn" data-action="close-modal">${t("关闭")}</button>`,
|
|
179
171
|
size: 'small',
|
|
180
172
|
})
|
|
181
173
|
}
|
|
@@ -183,29 +175,29 @@ function modalInviteMember() {
|
|
|
183
175
|
const candidates = (state.data?.bots ?? []).filter(bot => bot.status === 'active' && !memberIds.has(bot.id))
|
|
184
176
|
if (candidates.length === 0) {
|
|
185
177
|
return modalShell({
|
|
186
|
-
title:
|
|
187
|
-
subtitle:
|
|
188
|
-
body: `<div class="empty-state" style="border:0"><div class="empty-symbol">${icon('bot')}</div><h3
|
|
189
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
178
|
+
title: t("邀请加入"),
|
|
179
|
+
subtitle: `${t("项目:")}${project.name}`,
|
|
180
|
+
body: `<div class="empty-state" style="border:0"><div class="empty-symbol">${icon('bot')}</div><h3>${t("所有可用 Bot 都已在项目中")}</h3><p>${t("先新建一个 Bot,再回来邀请它加入。")}</p></div>`,
|
|
181
|
+
footer: `<button class="btn" data-action="close-modal">${t("取消")}</button><button class="btn" data-action="new-bot">${icon('plus')}${t("新建")} Bot</button>`,
|
|
190
182
|
})
|
|
191
183
|
}
|
|
192
184
|
const selected = state.modal?.botId ?? ''
|
|
193
185
|
return modalShell({
|
|
194
|
-
title:
|
|
195
|
-
subtitle:
|
|
186
|
+
title: t("邀请加入"),
|
|
187
|
+
subtitle: `${t("项目:")}${project.name}${t(",选择一个 Bot。")}`,
|
|
196
188
|
body: `<form data-form="invite-member" id="modal-form">
|
|
197
189
|
<div class="list">
|
|
198
190
|
${candidates.map(bot => `
|
|
199
|
-
<label class="list-row" title="${esc(bot.name)} · ${esc(bot.role ||
|
|
191
|
+
<label class="list-row" title="${esc(bot.name)} · ${esc(bot.role || t("成员"))}">
|
|
200
192
|
<input type="radio" name="botId" value="${attr(bot.id)}" ${bot.id === selected ? 'checked' : ''}>
|
|
201
193
|
${avatar(bot, 'sm')}
|
|
202
194
|
<div class="list-main">
|
|
203
|
-
<div class="list-title"><strong>${esc(bot.name)}</strong><span class="member-role">${esc(bot.role ||
|
|
195
|
+
<div class="list-title"><strong>${esc(bot.name)}</strong><span class="member-role">${esc(bot.role || t("成员"))}</span></div>
|
|
204
196
|
</div>
|
|
205
197
|
</label>`).join('')}
|
|
206
198
|
</div>
|
|
207
199
|
</form>`,
|
|
208
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
200
|
+
footer: `<button class="btn" data-action="close-modal">${t("取消")}</button><button class="btn primary" type="submit" form="modal-form" id="invite-member-submit" ${selected ? '' : 'disabled'}>${icon('check')}${t("确认邀请")}</button>`,
|
|
209
201
|
})
|
|
210
202
|
}
|
|
211
203
|
|
|
@@ -213,7 +205,7 @@ function modalBot(detail) {
|
|
|
213
205
|
const bot = detail?.bot ?? null
|
|
214
206
|
const modelRef = bot?.modelRef ?? state.data?.models?.[0]?.ref ?? ''
|
|
215
207
|
return modalShell({
|
|
216
|
-
title: bot ?
|
|
208
|
+
title: bot ? `${t("配置")} ${bot.name}` : t("新建 Bot"),
|
|
217
209
|
subtitle: '',
|
|
218
210
|
badge: '',
|
|
219
211
|
size: 'wide',
|
|
@@ -221,34 +213,35 @@ function modalBot(detail) {
|
|
|
221
213
|
<form data-form="${bot ? 'update-bot' : 'create-bot'}" id="modal-form">
|
|
222
214
|
<input type="hidden" name="botId" value="${attr(bot?.id ?? '')}">
|
|
223
215
|
<div class="field-row">
|
|
224
|
-
<div class="field"><label id="bot-name-label" for="bot-name"
|
|
225
|
-
<div class="field"><label id="bot-role-label" for="bot-role"
|
|
216
|
+
<div class="field"><label id="bot-name-label" for="bot-name">${t("名称")}</label><input class="input" style="width:100%" id="bot-name" name="name" value="${attr(bot?.name ?? '')}" placeholder="${t("例如:")}Builder" required maxlength="24"></div>
|
|
217
|
+
<div class="field"><label id="bot-role-label" for="bot-role">${t("角色标签")}</label><input class="input" style="width:100%" id="bot-role" name="role" value="${attr(bot?.role ?? '')}" placeholder="${t("例如:开发")}" maxlength="24"></div>
|
|
226
218
|
</div>
|
|
227
219
|
<div class="field-row">
|
|
228
|
-
<div class="field"><label id="bot-model-label" for="bot-model"
|
|
229
|
-
<div class="field"><label id="bot-effort-label" for="bot-effort"
|
|
230
|
-
<div class="field"><label id="bot-file-policy-label" for="bot-file-policy"
|
|
220
|
+
<div class="field"><label id="bot-model-label" for="bot-model">${t("模型")}</label><select class="select" style="width:100%" id="bot-model" name="modelRef" data-model-select>${modelOptions(bot?.provider, bot?.model)}</select></div>
|
|
221
|
+
<div class="field"><label id="bot-effort-label" for="bot-effort">${t("推理强度")}</label><select class="select" style="width:100%" id="bot-effort" name="effort" data-effort-select>${effortOptions(modelRef, bot?.effort)}</select></div>
|
|
222
|
+
<div class="field"><label id="bot-file-policy-label" for="bot-file-policy">${t("文件权限")}</label><select class="select" style="width:100%" id="bot-file-policy" name="filePolicy" title="Bot ${t("会话内文件操作的沙箱边界,下次运行生效")}">${filePolicyOptions(bot?.file_policy)}</select></div>
|
|
231
223
|
</div>
|
|
232
224
|
<div class="field-row">
|
|
233
|
-
<div class="field"><label id="bot-fallback-model-label" for="bot-fallback-model"
|
|
234
|
-
<div class="field"><label id="bot-fallback-effort-label" for="bot-fallback-effort"
|
|
225
|
+
<div class="field"><label id="bot-fallback-model-label" for="bot-fallback-model">${t("备用模型")}</label><select class="select" style="width:100%" id="bot-fallback-model" name="fallbackModelRef" data-fallback-model-select title="${t("主模型不可用时自动接手的备用模型,留空")} = ${t("不启用")}">${fallbackModelOptions(bot?.fallbackModelRef ?? '')}</select></div>
|
|
226
|
+
<div class="field"><label id="bot-fallback-effort-label" for="bot-fallback-effort">${t("备用推理强度")}</label><select class="select" style="width:100%" id="bot-fallback-effort" name="fallbackEffort" data-fallback-effort-select>${effortOptions(bot?.fallbackModelRef ?? '', bot?.fallback_effort)}</select></div>
|
|
235
227
|
</div>
|
|
236
|
-
<div class="field"><span class="field-label" id="bot-color-label"
|
|
237
|
-
<div class="field"><label id="bot-instructions-label" for="bot-instructions"
|
|
238
|
-
${bot ? `<div class="btn-row"><button class="btn small" type="button" data-action="archive-bot" data-bot-id="${attr(bot.id)}"
|
|
228
|
+
<div class="field"><span class="field-label" id="bot-color-label">${t("外观颜色")}</span><div class="swatch-row" role="radiogroup" aria-labelledby="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>${bot ? `<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>
|
|
229
|
+
<div class="field"><label id="bot-instructions-label" for="bot-instructions">${t("角色指令")}</label><textarea class="textarea" id="bot-instructions" name="instructions" rows="10" placeholder="${t("说明职责、工作方式、边界和交付标准")}">${esc(bot?.instructions ?? '')}</textarea></div>
|
|
230
|
+
${bot ? `<div class="btn-row"><button class="btn small" type="button" data-action="archive-bot" data-bot-id="${attr(bot.id)}">${t("归档")} Bot</button></div>` : ''}
|
|
239
231
|
</form>
|
|
240
232
|
${bot ? `<aside class="task-detail-side">
|
|
241
|
-
<div class="eyebrow" style="margin-bottom:9px"
|
|
242
|
-
${(detail.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)}"
|
|
233
|
+
<div class="eyebrow" style="margin-bottom:9px">${t("版本历史")}</div>
|
|
234
|
+
${(detail.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('') || `<div class="faint">${t("暂无版本")}</div>`}
|
|
243
235
|
<div class="divider"></div>
|
|
244
|
-
<div class="kv"><span
|
|
245
|
-
<div class="kv"><span
|
|
246
|
-
<div class="kv"><span
|
|
247
|
-
<div class="kv"><span
|
|
248
|
-
|
|
236
|
+
<div class="kv"><span>${t("运行次数")}</span><strong>${bot.stats.runs}</strong></div>
|
|
237
|
+
<div class="kv"><span>${t("成功 / 失败")}</span><strong>${bot.stats.succeeded} / ${bot.stats.failed}</strong></div>
|
|
238
|
+
<div class="kv"><span>${t("长期记忆")}</span><strong>${bot.memoryCount}</strong></div>
|
|
239
|
+
<div class="kv"><span>${t("状态")}</span><strong>${esc(BOT_STATUS[bot.status] ?? bot.status)}</strong></div>
|
|
240
|
+
${botQuotaBlock(bot)}
|
|
241
|
+
<div class="usage-note">${t("模型或强度变更会在下一次运行时生效,不会中断当前运行。")}</div>
|
|
249
242
|
</aside>` : ''}
|
|
250
243
|
</div>`,
|
|
251
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
244
|
+
footer: `<button class="btn" data-action="close-modal">${t("取消")}</button><button class="btn primary" type="submit" form="modal-form">${bot ? `${icon('check')}${t("保存新版本")}` : `${icon('plus')}${t("创建")} Bot`}</button>`,
|
|
252
245
|
})
|
|
253
246
|
}
|
|
254
247
|
|
|
@@ -279,51 +272,51 @@ function modalNewTask() {
|
|
|
279
272
|
// 派生子任务入口(D-63)带 parentTaskId 预填;常规新建不带。
|
|
280
273
|
const preselectedParent = state.modal?.parentTaskId ?? ''
|
|
281
274
|
return modalShell({
|
|
282
|
-
title:
|
|
275
|
+
title: t("新建任务"),
|
|
283
276
|
subtitle: `${project.key} · ${project.name}`,
|
|
284
277
|
badge: '',
|
|
285
278
|
body: `<form data-form="create-task" id="modal-form">
|
|
286
279
|
<input type="hidden" name="projectId" value="${attr(project.id)}">
|
|
287
|
-
<div class="field"><label id="new-task-title-label" for="new-task-title"
|
|
288
|
-
<div class="field"><label id="new-task-description-label" for="new-task-description"
|
|
280
|
+
<div class="field"><label id="new-task-title-label" for="new-task-title">${t("标题")}</label><input class="input" style="width:100%" id="new-task-title" name="title" required maxlength="240" placeholder="${t("一个可执行、可验收的结果")}" autofocus></div>
|
|
281
|
+
<div class="field"><label id="new-task-description-label" for="new-task-description">${t("描述")}</label><textarea class="textarea" id="new-task-description" name="description" rows="8" placeholder="${t("背景、范围、约束、验收标准")}"></textarea></div>
|
|
289
282
|
<div class="field-row" style="grid-template-columns:repeat(auto-fit,minmax(180px,1fr))">
|
|
290
|
-
<div class="field"><label id="new-task-assignee-label" for="new-task-assignee"
|
|
291
|
-
<div class="field"><label id="new-task-priority-label" for="new-task-priority"
|
|
292
|
-
<div class="field"><label id="new-task-time-budget-label" for="new-task-time-budget">${t('taskForm.timeBudgetLabel')}</label><input class="input" style="width:100%" id="new-task-time-budget" name="time_budget_minutes" type="number" min="1" max="10080" step="1"
|
|
283
|
+
<div class="field"><label id="new-task-assignee-label" for="new-task-assignee">${t("指派给")}</label><select class="select" style="width:100%" id="new-task-assignee" name="assigneeBotId">${project.members.map(member => `<option value="${attr(member.id)}">${esc(member.name)} · ${esc(member.bot_role || '')}</option>`).join('')}</select></div>
|
|
284
|
+
<div class="field"><label id="new-task-priority-label" for="new-task-priority">${t("优先级")}</label><select class="select" style="width:100%" id="new-task-priority" name="priority"><option value="medium">${t("中")}</option><option value="high">${t("高")}</option><option value="urgent">${t("紧急")}</option><option value="low">${t("低")}</option><option value="none">${t("无")}</option></select></div>
|
|
285
|
+
<div class="field"><label id="new-task-time-budget-label" for="new-task-time-budget">${t('taskForm.timeBudgetLabel')}</label><input class="input" style="width:100%" id="new-task-time-budget" name="time_budget_minutes" type="number" min="1" max="10080" step="1"><div class="usage-note">${t('task.timeBudgetNote')}</div></div>
|
|
293
286
|
</div>
|
|
294
287
|
<div class="field-row">
|
|
295
|
-
<div class="field"><label id="new-task-parent-label" for="new-task-parent"
|
|
296
|
-
<div class="field"><label id="new-task-blocked-label" for="new-task-blocked"
|
|
288
|
+
<div class="field"><label id="new-task-parent-label" for="new-task-parent">${t("父任务")}</label><select class="select" style="width:100%" id="new-task-parent" name="parentTaskId"><option value="">${t("无(顶层任务)")}</option>${taskRelationOptions(preselectedParent)}</select></div>
|
|
289
|
+
<div class="field"><label id="new-task-blocked-label" for="new-task-blocked">${t("依赖任务")}</label><select class="select" style="width:100%" id="new-task-blocked" name="blockedBy" multiple size="4">${taskRelationOptions()}</select></div>
|
|
297
290
|
</div>
|
|
298
|
-
<div class="usage-note"
|
|
299
|
-
<div class="check-row"><input type="checkbox" id="new-task-autostart" name="autoStart" checked><label for="new-task-autostart"
|
|
291
|
+
<div class="usage-note">${t("父任务只影响看板上的层级缩进;依赖任务未完成前,本任务不会被调度执行。")}</div>
|
|
292
|
+
<div class="check-row"><input type="checkbox" id="new-task-autostart" name="autoStart" checked><label for="new-task-autostart">${t("创建后立即进入执行队列")}</label></div>
|
|
300
293
|
</form>`,
|
|
301
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
294
|
+
footer: `<button class="btn" data-action="close-modal">${t("取消")}</button><button class="btn primary" type="submit" form="modal-form">${icon('plus')}${t("创建任务")}</button>`,
|
|
302
295
|
})
|
|
303
296
|
}
|
|
304
297
|
|
|
305
298
|
function modalSkill(detail) {
|
|
306
|
-
if (!detail) return modalLoading(
|
|
299
|
+
if (!detail) return modalLoading(t("技能详情"))
|
|
307
300
|
const project = pageProject()
|
|
308
301
|
const off = project?.disabledSkills?.includes(detail.slug) ?? false
|
|
309
302
|
return modalShell({
|
|
310
303
|
title: detail.name || detail.slug,
|
|
311
304
|
subtitle: `/${detail.slug}`,
|
|
312
|
-
badge:
|
|
305
|
+
badge: t("共享技能"),
|
|
313
306
|
size: 'wide',
|
|
314
307
|
body: `<div class="kv-grid">
|
|
315
|
-
<div><div class="eyebrow"
|
|
316
|
-
<div><div class="eyebrow"
|
|
317
|
-
<div><div class="eyebrow"
|
|
308
|
+
<div><div class="eyebrow">${t("状态")}</div><div class="pill ${detail.status === 'active' ? 'green' : 'red'}">${esc(SKILL_STATUS[detail.status] ?? detail.status)}</div></div>
|
|
309
|
+
<div><div class="eyebrow">${t("版本")}</div><div>v${esc(currentSkillVersion(detail))}</div></div>
|
|
310
|
+
<div><div class="eyebrow">${t("本项目")}</div><div>${off ? `<span class="pill">${t("已停用")}</span>` : `<span class="pill green">${t("可用")}</span>`}</div></div>
|
|
318
311
|
</div>
|
|
319
|
-
<div class="detail-block"><div class="eyebrow"
|
|
320
|
-
<div class="detail-block"><div class="eyebrow"
|
|
312
|
+
<div class="detail-block"><div class="eyebrow">${t("描述")}</div><div>${esc(detail.description || t("无描述"))}</div></div>
|
|
313
|
+
<div class="detail-block"><div class="eyebrow">${t("文件")}</div><code class="mono detail-path">${esc(detail.path || detail.sharedPath || '')}</code></div>
|
|
321
314
|
<div class="divider"></div>
|
|
322
|
-
<div class="eyebrow">SKILL.md
|
|
323
|
-
${detail.readable ? `<pre class="detail-pre">${esc(detail.content)}</pre>` :
|
|
315
|
+
<div class="eyebrow">SKILL.md ${t("全文")}</div>
|
|
316
|
+
${detail.readable ? `<pre class="detail-pre">${esc(detail.content)}</pre>` : `<div class="note">${t("技能文件当前不可读(可能已被移动或删除),可尝试重新扫描。")}</div>`}
|
|
324
317
|
${(detail.versions ?? []).length ? `<div class="divider"></div>
|
|
325
318
|
${skillVersions(detail)}` : ''}`,
|
|
326
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
319
|
+
footer: `<button class="btn" data-action="close-modal">${t("关闭")}</button>${project ? `<button class="btn ${off ? 'primary' : ''}" data-action="toggle-skill" data-slug="${attr(detail.slug)}" data-disabled="${off ? '0' : '1'}">${off ? t("在本项目恢复") : t("在本项目停用")}</button>` : ''}`,
|
|
327
320
|
})
|
|
328
321
|
}
|
|
329
322
|
|
|
@@ -348,18 +341,18 @@ function runArtifacts(state, run) {
|
|
|
348
341
|
}
|
|
349
342
|
}
|
|
350
343
|
if (!rows.length) return ''
|
|
351
|
-
return `<details style="margin-top:6px"${panelAttrs(state, `run-artifacts:${run.id}`)}><summary class="summary-link"
|
|
344
|
+
return `<details style="margin-top:6px"${panelAttrs(state, `run-artifacts:${run.id}`)}><summary class="summary-link">${t("交付产物(")}${rows.length}${t(")")}</summary><div class="artifact-list">${rows.join('')}</div></details>`
|
|
352
345
|
}
|
|
353
346
|
|
|
354
347
|
// ===== 思考过程:Bot 运行轨迹(run_trajectory)=====
|
|
355
348
|
|
|
356
|
-
const TRAJ_LABELS = { thinking:
|
|
349
|
+
const TRAJ_LABELS = { thinking: t("思考"), text: t("回复"), tool_call: t("调用工具"), tool_result: t("工具返回"), end: t("运行结束") }
|
|
357
350
|
|
|
358
351
|
function trajectoryLabel(entry) {
|
|
359
352
|
const kind = String(entry?.kind ?? '')
|
|
360
353
|
const title = String(entry?.title ?? '').trim()
|
|
361
|
-
if (kind === 'tool_call') return title ? (title.startsWith(
|
|
362
|
-
if (kind === 'tool_result') return title ? (title.startsWith(
|
|
354
|
+
if (kind === 'tool_call') return title ? (title.startsWith(t("调用工具")) ? title : t("调用工具 ${title}", { title: title })) : TRAJ_LABELS.tool_call
|
|
355
|
+
if (kind === 'tool_result') return title ? (title.startsWith(t("工具")) ? title : t("工具 ${title} 返回", { title: title })) : TRAJ_LABELS.tool_result
|
|
363
356
|
return title || TRAJ_LABELS[kind] || ''
|
|
364
357
|
}
|
|
365
358
|
|
|
@@ -369,7 +362,7 @@ function trajectoryEntry(entry, index = 0, runId = '') {
|
|
|
369
362
|
const detail = String(entry?.detail ?? '')
|
|
370
363
|
const label = trajectoryLabel(entry)
|
|
371
364
|
if (kind === 'turn') {
|
|
372
|
-
return `<div class="traj-turn"><span>${esc(title ||
|
|
365
|
+
return `<div class="traj-turn"><span>${esc(title || `${t("第")} ${entry?.turn ?? ''} ${t("轮")}`)}</span></div>`
|
|
373
366
|
}
|
|
374
367
|
if (kind === 'note') {
|
|
375
368
|
return `<div class="traj-note">${esc([title, detail].filter(Boolean).join(' · '))}</div>`
|
|
@@ -386,13 +379,13 @@ function trajectoryEntry(entry, index = 0, runId = '') {
|
|
|
386
379
|
function modalTrajectory(detail, runId) {
|
|
387
380
|
const entries = Array.isArray(detail?.entries) ? detail.entries : []
|
|
388
381
|
const body = entries.length === 0
|
|
389
|
-
?
|
|
382
|
+
? `<div class="faint">${t("这次运行没有可展示的轨迹。")}</div>`
|
|
390
383
|
: `<div class="traj-stream">${entries.map((entry, index) => trajectoryEntry(entry, index, runId)).join('')}</div>`
|
|
391
384
|
return modalShell({
|
|
392
|
-
title:
|
|
393
|
-
subtitle: entries.length ? `${entries.length}
|
|
385
|
+
title: t("思考过程"),
|
|
386
|
+
subtitle: entries.length ? `${entries.length} ${t("条轨迹记录")}` : '',
|
|
394
387
|
body,
|
|
395
|
-
footer:
|
|
388
|
+
footer: `<button class="btn" data-action="close-modal">${t("关闭")}</button>`,
|
|
396
389
|
size: 'wide',
|
|
397
390
|
})
|
|
398
391
|
}
|
|
@@ -409,7 +402,7 @@ function runClockSpan(run) {
|
|
|
409
402
|
}
|
|
410
403
|
|
|
411
404
|
function modalTask(task) {
|
|
412
|
-
if (!task) return modalLoading(
|
|
405
|
+
if (!task) return modalLoading(t("任务"))
|
|
413
406
|
const project = activeProject()
|
|
414
407
|
const activeRun = (task.runs ?? []).find(run => ['queued', 'running'].includes(run.status))
|
|
415
408
|
const latestFailed = (task.runs ?? []).find(run => ['failed', 'canceled'].includes(run.status))
|
|
@@ -429,36 +422,36 @@ function modalTask(task) {
|
|
|
429
422
|
const scopesEditable = !['done', 'canceled'].includes(task.status)
|
|
430
423
|
const scopesView = writeScopes.length
|
|
431
424
|
? `<div class="scope-chips">${writeScopes.map(scope => `<span class="approval-chip mono" title="${attr(scope)}">${esc(scope)}</span>`).join('')}</div>`
|
|
432
|
-
:
|
|
425
|
+
: `<div class="scope-empty">${t("未声明(保守串行)")}</div>`
|
|
433
426
|
const scopesEdit = `<div class="field">
|
|
434
|
-
<label id="task-write-scopes-label" for="task-write-scopes"
|
|
435
|
-
<input class="input mono" style="width:100%" id="task-write-scopes" placeholder="逗号或空格分隔路径" value="${attr(writeScopes.join(', '))}">
|
|
436
|
-
<div class="btn-row" style="margin-top:7px"><button class="btn small primary" type="button" data-action="update-scopes" data-task-id="${attr(task.id)}">${icon('check')}
|
|
437
|
-
<div class="hint" style="margin-top:6px"
|
|
427
|
+
<label id="task-write-scopes-label" for="task-write-scopes">${t("写范围路径")}</label>
|
|
428
|
+
<input class="input mono" style="width:100%" id="task-write-scopes" placeholder="${t("逗号或空格分隔路径")}" value="${attr(writeScopes.join(', '))}">
|
|
429
|
+
<div class="btn-row" style="margin-top:7px"><button class="btn small primary" type="button" data-action="update-scopes" data-task-id="${attr(task.id)}">${icon('check')}${t("保存")}</button><button class="btn small" type="button" data-action="cancel-scopes-edit">${t("取消")}</button></div>
|
|
430
|
+
<div class="hint" style="margin-top:6px">${t("保存后立即生效于排队中的运行;运行中的运行不受影响")}</div>
|
|
438
431
|
</div>`
|
|
439
432
|
return modalShell({
|
|
440
433
|
title: `${task.identifier} · ${task.title}`,
|
|
441
434
|
// 任务阶段徽标走 taskStage 查表口径(DSHBOTS-42):ended → stageLabel 为 null → 不显示。
|
|
442
|
-
badge: task.stageLabel ? esc(task.stageLabel) : endAt ? esc(`${task.status === 'done' ?
|
|
435
|
+
badge: task.stageLabel ? esc(stageLabelText(task.stageLabel)) : endAt ? esc(`${task.status === 'done' ? t("完成于") : t("取消于")} ${formatTime(endAt)}`) : '',
|
|
443
436
|
size: 'task',
|
|
444
437
|
body: `<div class="task-detail-grid">
|
|
445
438
|
<div class="task-detail-main">
|
|
446
439
|
<form data-form="update-task" id="task-form">
|
|
447
440
|
<input type="hidden" name="taskId" value="${attr(task.id)}">
|
|
448
441
|
<input type="hidden" name="version" value="${task.version}">
|
|
449
|
-
<div class="field"><label id="task-title-label" for="task-title"
|
|
450
|
-
<div class="field"><label id="task-description-label" for="task-description"
|
|
442
|
+
<div class="field"><label id="task-title-label" for="task-title">${t("标题")}</label><input class="input" style="width:100%" id="task-title" name="title" value="${attr(task.title)}" required maxlength="240"></div>
|
|
443
|
+
<div class="field"><label id="task-description-label" for="task-description">${t("描述")}</label><textarea class="textarea" id="task-description" name="description" rows="9">${esc(task.description || '')}</textarea></div>
|
|
451
444
|
<div class="field-row">
|
|
452
|
-
<div class="field"><label id="task-status-label" for="task-status"
|
|
453
|
-
<div class="field"><label id="task-priority-label" for="task-priority"
|
|
445
|
+
<div class="field"><label id="task-status-label" for="task-status">${t("状态")}</label><select class="select" style="width:100%" id="task-status" name="status">${STATUS_ORDER.map(status => `<option value="${status}" ${task.status === status ? 'selected' : ''}>${STATUS[status]}</option>`).join('')}</select></div>
|
|
446
|
+
<div class="field"><label id="task-priority-label" for="task-priority">${t("优先级")}</label><select class="select" style="width:100%" id="task-priority" name="priority">${Object.entries(PRIORITY).map(([key, label]) => `<option value="${key}" ${task.priority === key ? 'selected' : ''}>${label}</option>`).join('')}</select></div>
|
|
454
447
|
</div>
|
|
455
|
-
<div class="field"><label id="task-assignee-label" for="task-assignee"
|
|
448
|
+
<div class="field"><label id="task-assignee-label" for="task-assignee">${t("负责人")}</label><select class="select" style="width:100%" id="task-assignee" name="assigneeBotId"><option value="">${t("未指派")}</option>${project.members.map(member => `<option value="${attr(member.id)}" ${task.assignee_bot_id === member.id ? 'selected' : ''}>${esc(member.name)} · ${esc(member.bot_role || '')}</option>`).join('')}</select></div>
|
|
456
449
|
</form>
|
|
457
|
-
${(parentTask || blockedNames.length) ? `<div class="note">${parentTask ?
|
|
450
|
+
${(parentTask || blockedNames.length) ? `<div class="note">${parentTask ? `${t("父任务:")}${esc(parentTask.identifier)} · ${esc(parentTask.title)}` : ''}${parentTask && blockedNames.length ? ' · ' : ''}${blockedNames.length ? `${t("被")} ${blockedNames.length} ${t("个任务阻塞:")}${esc(blockedNames.join(t("、")))}` : ''}</div>` : ''}
|
|
458
451
|
<div class="scope-block">
|
|
459
|
-
<div class="eyebrow" style="margin-bottom:6px"
|
|
460
|
-
${editingScopes ? scopesEdit : `${scopesEditable ? `<div class="btn-row" style="margin-bottom:6px"><button class="btn small" type="button" data-action="edit-scopes" data-task-id="${attr(task.id)}">${icon('edit')}
|
|
461
|
-
<div class="hint" style="margin-top:6px"
|
|
452
|
+
<div class="eyebrow" style="margin-bottom:6px">${t("写范围")}</div>
|
|
453
|
+
${editingScopes ? scopesEdit : `${scopesEditable ? `<div class="btn-row" style="margin-bottom:6px"><button class="btn small" type="button" data-action="edit-scopes" data-task-id="${attr(task.id)}">${icon('edit')}${t("编辑")}</button></div>` : ''}${scopesView}
|
|
454
|
+
<div class="hint" style="margin-top:6px">${t("写范围是并行调度依据:同项目内路径互不重叠的任务才会并行。")}</div>`}
|
|
462
455
|
</div>
|
|
463
456
|
${task.timeBudgetMinutes ? `<div class="scope-block">
|
|
464
457
|
<div class="eyebrow" style="margin-bottom:6px">${t('taskForm.timeBudgetLabel')}</div>
|
|
@@ -466,37 +459,38 @@ function modalTask(task) {
|
|
|
466
459
|
<div class="hint" style="margin-top:6px">${t('task.timeBudgetNote')}</div>
|
|
467
460
|
</div>` : ''}
|
|
468
461
|
<div class="divider"></div>
|
|
469
|
-
<div class="eyebrow" style="margin-bottom:6px"
|
|
470
|
-
${(task.comments ?? []).length === 0 ?
|
|
471
|
-
${avatar(comment.author_type === 'bot' ? (botById(comment.author_id) ?? { name: comment.authorName, color: 'gray' }) : { name:
|
|
462
|
+
<div class="eyebrow" style="margin-bottom:6px">${t("评论")}</div>
|
|
463
|
+
${(task.comments ?? []).length === 0 ? `<div class="note">${t("还没有评论。")}</div>` : task.comments.map(comment => `<div class="comment">
|
|
464
|
+
${avatar(comment.author_type === 'bot' ? (botById(comment.author_id) ?? { name: comment.authorName, color: 'gray' }) : { name: t("我"), color: 'teal' }, 'sm')}
|
|
472
465
|
<div class="comment-main"><div class="comment-head"><strong>${esc(comment.authorName)}</strong><span>${esc(timeAgo(comment.created_at))}</span></div><div class="comment-body">${richText(comment.body, mdChatScope())}</div></div>
|
|
473
466
|
</div>`).join('')}
|
|
474
467
|
<form data-form="add-comment" style="margin-top:14px">
|
|
475
468
|
<input type="hidden" name="taskId" value="${attr(task.id)}">
|
|
476
|
-
<textarea class="textarea" id="task-comment-body" name="body" rows="3" aria-label="评论内容" placeholder="补充说明、验收意见或阻塞原因"></textarea>
|
|
477
|
-
<div class="btn-row" style="margin-top:7px"><button class="btn small" type="submit">${icon('send')}
|
|
469
|
+
<textarea class="textarea" id="task-comment-body" name="body" rows="3" aria-label="${t("评论内容")}" placeholder="${t("补充说明、验收意见或阻塞原因")}"></textarea>
|
|
470
|
+
<div class="btn-row" style="margin-top:7px"><button class="btn small" type="submit">${icon('send')}${t("添加评论")}</button></div>
|
|
478
471
|
</form>
|
|
479
472
|
</div>
|
|
480
473
|
<aside class="task-detail-side">
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
474
|
+
${taskUsageBlock(task.usage)}
|
|
475
|
+
<div class="eyebrow">${t("运行记录")}</div>
|
|
476
|
+
${(activeRun || latestFailed) ? `<div class="btn-row" style="margin:9px 0 2px">${activeRun ? `<button class="btn danger small" type="button" data-action="cancel-run" data-run-id="${attr(activeRun.id)}">${icon('stop')}${t("停止运行")}</button>` : ''}${latestFailed ? `<button class="btn small" type="button" data-action="retry-run" data-run-id="${attr(latestFailed.id)}">${icon('refresh')}${t("重试")}</button>` : ''}</div>` : ''}
|
|
477
|
+
<div style="margin-top:8px">${(task.runs ?? []).length === 0 ? `<div class="note">${t("还没有运行。")}</div>` : task.runs.map(run => `<div class="run-row">
|
|
484
478
|
<div class="run-row-top">${runDot(run.status)}<strong>#${run.attempt}</strong><span>${esc(RUN_STATUS[run.status] ?? run.status)}</span><span style="margin-left:auto">${esc(timeAgo(run.queued_at))}</span></div>
|
|
485
479
|
<div class="run-row-meta">${runClockSpan(run)}<span>${formatNumber(run.usage_input + run.usage_output)} tok</span>${run.usage_cost !== null && run.usage_cost !== undefined ? `<span>${formatCost(run.usage_cost)}</span>` : ''}${sandboxPill(run.sandboxMode)}</div>
|
|
486
480
|
${run.error_message ? `<div class="run-output error">${esc(run.error_message)}</div>` : ''}
|
|
487
|
-
${run.output ? `<details style="margin-top:6px"${panelAttrs(state, `run-output:${run.id}`)}><summary class="summary-link"
|
|
481
|
+
${run.output ? `<details style="margin-top:6px"${panelAttrs(state, `run-output:${run.id}`)}><summary class="summary-link">${t("查看输出")}</summary><div class="run-output">${esc(run.output)}</div></details>` : ''}
|
|
488
482
|
${runArtifacts(state, run)}
|
|
489
483
|
</div>`).join('')}</div>
|
|
490
484
|
<div class="divider"></div>
|
|
491
|
-
<div class="eyebrow" style="margin-bottom:7px"
|
|
492
|
-
<div class="kv"><span
|
|
493
|
-
<div class="kv"><span
|
|
494
|
-
<div class="kv"><span
|
|
495
|
-
<div class="kv"><span
|
|
496
|
-
${(task.dependencies ?? []).length ? `<div class="divider"></div><div class="eyebrow" style="margin-bottom:7px"
|
|
485
|
+
<div class="eyebrow" style="margin-bottom:7px">${t("详情")}</div>
|
|
486
|
+
<div class="kv"><span>${t("编号")}</span><strong>${esc(task.identifier)}</strong></div>
|
|
487
|
+
<div class="kv"><span>${t("负责人")}</span><strong>${esc(task.assignee_name || t("未指派"))}</strong></div>
|
|
488
|
+
<div class="kv"><span>${t("创建者")}</span><strong>${esc(CREATOR_TYPE[task.creator_type] ?? task.creator_type)}</strong></div>
|
|
489
|
+
<div class="kv"><span>${t("更新时间")}</span><strong>${esc(timeAgo(task.updated_at))}</strong></div>
|
|
490
|
+
${(task.dependencies ?? []).length ? `<div class="divider"></div><div class="eyebrow" style="margin-bottom:7px">${t("依赖")}</div>${task.dependencies.map(dep => `<div class="kv"><span>${esc(dep.title)}</span><strong>${esc(STATUS[dep.status] ?? dep.status)}</strong></div>`).join('')}` : ''}
|
|
497
491
|
</aside>
|
|
498
492
|
</div>`,
|
|
499
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
493
|
+
footer: `<button class="btn" data-action="close-modal">${t("关闭")}</button>${['done', 'canceled'].includes(task.status) ? `<button class="btn danger" type="button" data-action="reject-task" data-task-id="${attr(task.id)}" title="${t('task.rejectTitle')}">${icon('reply')}${t('task.rejectAction')}</button>` : ''}<button class="btn" type="button" data-action="derive-subtask" data-task-id="${attr(task.id)}" title="${t("以本任务为父任务新建子任务")}">${icon('branch')}${t("派生子任务")}</button>${task.status === 'in_review' ? `<button class="btn" type="button" data-action="review-delegate" data-task-id="${attr(task.id)}" title="${t("委派总监 Bot 的子代理并行核验交付,结论写回任务评论,裁决仍由您执行")}">${icon('spark')}${t("子代理核验")}</button>` : ''}<button class="btn" type="button" data-action="run-task" data-task-id="${attr(task.id)}">${icon('play')}${t("保存并运行")}</button><button class="btn primary" type="submit" form="task-form">${icon('check')}${t("保存")}</button>`,
|
|
500
494
|
})
|
|
501
495
|
}
|
|
502
496
|
|
|
@@ -507,19 +501,19 @@ function modalMemory(memory) {
|
|
|
507
501
|
const scope = soloBot
|
|
508
502
|
? `bot:${attr(soloBot.id)}`
|
|
509
503
|
: project ? `project:${attr(project.id)}` : ''
|
|
510
|
-
const disabledText = soloBot ? `Bot · ${esc(soloBot.name)}` :
|
|
504
|
+
const disabledText = soloBot ? `Bot · ${esc(soloBot.name)}` : t("项目记忆")
|
|
511
505
|
return modalShell({
|
|
512
|
-
title: memory ?
|
|
506
|
+
title: memory ? t("编辑记忆") : t("写入记忆"),
|
|
513
507
|
badge: '',
|
|
514
508
|
body: `<form data-form="${memory ? 'update-memory' : 'create-memory'}" id="modal-form">
|
|
515
509
|
<input type="hidden" name="memoryId" value="${attr(memory?.id ?? '')}">
|
|
516
|
-
<div class="field"><label id="memory-scope-label" for="memory-scope"
|
|
517
|
-
? `<input class="input" style="width:100%" id="memory-scope" value="${esc(memory.scope_type === 'project' ?
|
|
510
|
+
<div class="field"><label id="memory-scope-label" for="memory-scope">${t("作用域")}</label>${memory
|
|
511
|
+
? `<input class="input" style="width:100%" id="memory-scope" value="${esc(memory.scope_type === 'project' ? t("项目记忆") : `Bot · ${botById(memory.scope_id)?.name ?? ''}`)}" disabled>`
|
|
518
512
|
: `<input class="input" style="width:100%" id="memory-scope" value="${esc(disabledText)}" disabled>${scope ? `<input type="hidden" name="scope" value="${attr(scope)}">` : ''}`}</div>
|
|
519
|
-
<div class="field"><label id="memory-topic-label" for="memory-topic"
|
|
520
|
-
<div class="field"><label id="memory-content-label" for="memory-content"
|
|
513
|
+
<div class="field"><label id="memory-topic-label" for="memory-topic">${t("主题")}</label><input class="input" style="width:100%" id="memory-topic" name="topic" value="${attr(memory?.topic ?? '')}" maxlength="120" placeholder="${t("例如:发布流程约束")}" required></div>
|
|
514
|
+
<div class="field"><label id="memory-content-label" for="memory-content">${t("内容")}</label><textarea class="textarea" id="memory-content" name="content" rows="9" required placeholder="${t("写清楚背景、结论和适用范围")}">${esc(memory?.content ?? '')}</textarea><div class="hint">${t("密钥、密码和 token 会被自动过滤为")} [REDACTED]${t("。")}</div></div>
|
|
521
515
|
</form>`,
|
|
522
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
516
|
+
footer: `<button class="btn" data-action="close-modal">${t("取消")}</button><button class="btn primary" type="submit" form="modal-form">${memory ? `${icon('check')}${t("保存记忆")}` : `${icon('plus')}${t("写入记忆")}`}</button>`,
|
|
523
517
|
})
|
|
524
518
|
}
|
|
525
519
|
|
|
@@ -527,27 +521,27 @@ function modalProposal(kind = 'bot_update') {
|
|
|
527
521
|
// 单聊上下文发起的提案不挂任何项目(团队级提案)。
|
|
528
522
|
const project = pageProject()
|
|
529
523
|
return modalShell({
|
|
530
|
-
title:
|
|
531
|
-
subtitle:
|
|
524
|
+
title: t("新建进化提案"),
|
|
525
|
+
subtitle: t("审批通过后才会生效。"),
|
|
532
526
|
badge: '',
|
|
533
527
|
size: 'wide',
|
|
534
528
|
body: `<form data-form="create-proposal" id="modal-form">
|
|
535
529
|
<input type="hidden" name="projectId" value="${attr(project?.id ?? '')}">
|
|
536
530
|
<div class="field-row">
|
|
537
|
-
<div class="field"><label id="proposal-kind-label" for="proposal-kind"
|
|
538
|
-
<div class="field" data-field="bot"><label id="proposal-bot-label" for="proposal-bot"
|
|
531
|
+
<div class="field"><label id="proposal-kind-label" for="proposal-kind">${t("提案类型")}</label><select class="select" style="width:100%" id="proposal-kind" name="kind" data-proposal-kind><option value="bot_update" ${kind === 'bot_update' ? 'selected' : ''}>Bot ${t("指令更新")}</option><option value="skill" ${kind === 'skill' ? 'selected' : ''}>${t("共享技能")}</option></select></div>
|
|
532
|
+
<div class="field" data-field="bot"><label id="proposal-bot-label" for="proposal-bot">${t("目标")} Bot</label><select class="select" style="width:100%" id="proposal-bot" name="botId">${activeBots().map(bot => `<option value="${attr(bot.id)}">${esc(bot.name)}</option>`).join('')}</select></div>
|
|
539
533
|
</div>
|
|
540
|
-
<div class="field"><label id="proposal-title-label" for="proposal-title"
|
|
541
|
-
<div class="field"><label id="proposal-rationale-label" for="proposal-rationale"
|
|
542
|
-
<div data-section="bot"><div class="field"><label id="proposal-instructions-label" for="proposal-instructions"
|
|
534
|
+
<div class="field"><label id="proposal-title-label" for="proposal-title">${t("标题")}</label><input class="input" style="width:100%" id="proposal-title" name="title" required maxlength="200" placeholder="${t("一句话说明变更")}"></div>
|
|
535
|
+
<div class="field"><label id="proposal-rationale-label" for="proposal-rationale">${t("变更理由")}</label><textarea class="textarea" id="proposal-rationale" name="rationale" rows="4" required placeholder="${t("为什么需要变更,来自哪些失败或重复模式")}"></textarea></div>
|
|
536
|
+
<div data-section="bot"><div class="field"><label id="proposal-instructions-label" for="proposal-instructions">${t("新的角色指令")}</label><textarea class="textarea" id="proposal-instructions" name="instructions" rows="9" placeholder="${t("完整替换现有指令,而不是追加")}"></textarea></div></div>
|
|
543
537
|
<div data-section="skill" style="display:none">
|
|
544
|
-
<div class="field-row"><div class="field"><label id="proposal-slug-label" for="proposal-slug"
|
|
545
|
-
<div class="field-row"><div class="field"><label id="proposal-name-label" for="proposal-name"
|
|
546
|
-
<div class="field"><label id="proposal-content-label" for="proposal-content"
|
|
538
|
+
<div class="field-row"><div class="field"><label id="proposal-slug-label" for="proposal-slug">${t("技能标识")}</label><input class="input mono" style="width:100%" id="proposal-slug" name="slug" placeholder="${t("发布检查")}"></div><div class="field"><label id="proposal-version-label" for="proposal-version">${t("版本")}</label><input class="input" style="width:100%" id="proposal-version" name="version" value="1.0.0"></div></div>
|
|
539
|
+
<div class="field-row"><div class="field"><label id="proposal-name-label" for="proposal-name">${t("显示名称")}</label><input class="input" style="width:100%" id="proposal-name" name="name"></div><div class="field"><label id="proposal-description-label" for="proposal-description">${t("描述")}</label><input class="input" style="width:100%" id="proposal-description" name="description"></div></div>
|
|
540
|
+
<div class="field"><label id="proposal-content-label" for="proposal-content">${t("技能内容(Markdown)")}</label><textarea class="textarea" id="proposal-content" name="content" rows="10" placeholder="## When to use ..."></textarea></div>
|
|
547
541
|
</div>
|
|
548
|
-
<div class="field"><label id="proposal-evaluation-label" for="proposal-evaluation"
|
|
542
|
+
<div class="field"><label id="proposal-evaluation-label" for="proposal-evaluation">${t("评估方式")}</label><textarea class="textarea" id="proposal-evaluation" name="evaluation" rows="3" placeholder="${t("审批前如何验证:回归任务、失败案例、人工检查点")}"></textarea></div>
|
|
549
543
|
</form>`,
|
|
550
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
544
|
+
footer: `<button class="btn" data-action="close-modal">${t("取消")}</button><button class="btn primary" type="submit" form="modal-form">${icon('branch')}${t("提交提案")}</button>`,
|
|
551
545
|
})
|
|
552
546
|
}
|
|
553
547
|
|
|
@@ -560,15 +554,15 @@ function defaultPriceFor(model) {
|
|
|
560
554
|
return priceDefaults().find(item => item.model.toLowerCase() === key)
|
|
561
555
|
}
|
|
562
556
|
|
|
563
|
-
function modalPrice(seed
|
|
557
|
+
function modalPrice(seed = {}) {
|
|
564
558
|
const editing = Boolean(seed.model)
|
|
565
559
|
const catalogModels = (state.data?.models ?? []).map(item => item.model)
|
|
566
560
|
const knownModels = [...new Set([...catalogModels, ...priceDefaults().map(item => item.model)])]
|
|
567
561
|
const providers = [...new Set((state.data?.models ?? []).map(item => item.provider))]
|
|
568
562
|
const fallback = defaultPriceFor(seed.model)
|
|
569
563
|
const hint = fallback
|
|
570
|
-
?
|
|
571
|
-
: '
|
|
564
|
+
? t('price.hintDefault', { cacheRead: fallback.cacheReadPerMtok, input: fallback.inputPerMtok, output: fallback.outputPerMtok, currency: fallback.currency })
|
|
565
|
+
: t('price.hintCustom')
|
|
572
566
|
const overridden = Boolean(editing && fallback) && (
|
|
573
567
|
Number(seed.cache_read_per_mtok) !== Number(fallback.cacheReadPerMtok)
|
|
574
568
|
|| Number(seed.input_per_mtok) !== Number(fallback.inputPerMtok)
|
|
@@ -576,20 +570,20 @@ function modalPrice(seed = {}) {
|
|
|
576
570
|
|| String(seed.currency ?? fallback.currency).toUpperCase() !== String(fallback.currency).toUpperCase()
|
|
577
571
|
)
|
|
578
572
|
return modalShell({
|
|
579
|
-
title: editing ?
|
|
580
|
-
subtitle: '
|
|
573
|
+
title: editing ? t('price.modalEdit', { model: seed.model }) : t('price.modalAdd'),
|
|
574
|
+
subtitle: t('price.modalSubtitle'),
|
|
581
575
|
badge: '',
|
|
582
576
|
body: `<form data-form="save-price" id="modal-form">
|
|
583
|
-
<div class="field-row"><div class="field"><label id="price-provider-label" for="price-provider"
|
|
584
|
-
<div class="field-row"><div class="field"><label id="price-input-label" for="price-input"
|
|
585
|
-
<div class="field-row"><div class="field"><label id="price-cache-read-label" for="price-cache-read"
|
|
586
|
-
<div class="field"><label id="price-currency-label" for="price-currency"
|
|
577
|
+
<div class="field-row"><div class="field"><label id="price-provider-label" for="price-provider">${t('price.providerLabel')}</label><input class="input mono" style="width:100%" id="price-provider" name="provider" list="price-providers" value="${attr(seed.provider ?? '')}" placeholder="${t('price.providerPlaceholder')}"></div><div class="field"><label id="price-model-label" for="price-model">${t('price.modelLabel')}</label><input class="input mono" style="width:100%" id="price-model" name="model" list="price-models" value="${attr(seed.model ?? '')}" placeholder="deepseek-flash" required autofocus></div></div>
|
|
578
|
+
<div class="field-row"><div class="field"><label id="price-input-label" for="price-input">${t('price.inputLabel')}</label><input class="input" style="width:100%" type="number" min="0" step="0.0001" id="price-input" name="inputPerMtok" required value="${attr(seed.input_per_mtok ?? fallback?.inputPerMtok ?? '')}" placeholder="2"></div><div class="field"><label id="price-output-label" for="price-output">${t('price.outputLabel')}</label><input class="input" style="width:100%" type="number" min="0" step="0.0001" id="price-output" name="outputPerMtok" required value="${attr(seed.output_per_mtok ?? fallback?.outputPerMtok ?? '')}" placeholder="8"></div></div>
|
|
579
|
+
<div class="field-row"><div class="field"><label id="price-cache-read-label" for="price-cache-read">${t('price.cacheReadLabel')}</label><input class="input" style="width:100%" type="number" min="0" step="0.0001" id="price-cache-read" name="cacheReadPerMtok" value="${attr(seed.cache_read_per_mtok ?? fallback?.cacheReadPerMtok ?? '')}" placeholder="0.2"></div><div class="field"><label id="price-cache-write-label" for="price-cache-write">${t('price.cacheWriteLabel')}</label><input class="input" style="width:100%" type="number" min="0" step="0.0001" id="price-cache-write" name="cacheWritePerMtok" value="${attr(seed.cache_write_per_mtok ?? fallback?.cacheWritePerMtok ?? '')}" placeholder="0"></div></div>
|
|
580
|
+
<div class="field"><label id="price-currency-label" for="price-currency">${t('price.currencyLabel')}</label><input class="input mono" style="width:100%" id="price-currency" name="currency" value="${attr(seed.currency ?? fallback?.currency ?? 'CNY')}" placeholder="CNY"></div>
|
|
587
581
|
<div class="hint">${esc(hint)}</div>
|
|
588
|
-
${overridden ? `<div class="btn-row"><button class="btn danger" type="button" data-action="reset-price" data-model="${attr(seed.model)}" data-provider="${attr(seed.provider ?? '')}"
|
|
582
|
+
${overridden ? `<div class="btn-row"><button class="btn danger" type="button" data-action="reset-price" data-model="${attr(seed.model)}" data-provider="${attr(seed.provider ?? '')}">${t('price.reset')}</button></div>` : ''}
|
|
589
583
|
<datalist id="price-models">${knownModels.map(model => `<option value="${attr(model)}"></option>`).join('')}</datalist>
|
|
590
584
|
<datalist id="price-providers">${providers.map(provider => `<option value="${attr(provider)}"></option>`).join('')}</datalist>
|
|
591
585
|
</form>`,
|
|
592
|
-
footer: `<button class="btn" data-action="close-modal"
|
|
586
|
+
footer: `<button class="btn" data-action="close-modal">${t('price.cancel')}</button><button class="btn primary" type="submit" form="modal-form">${icon('check')}${t('price.save')}</button>`,
|
|
593
587
|
})
|
|
594
588
|
}
|
|
595
589
|
|
|
@@ -604,41 +598,41 @@ function renderPriceCard() {
|
|
|
604
598
|
&& Number(price.cache_write_per_mtok) === Number(fallback.cacheWritePerMtok)
|
|
605
599
|
&& Number(price.input_per_mtok) === Number(fallback.inputPerMtok)
|
|
606
600
|
&& Number(price.output_per_mtok) === Number(fallback.outputPerMtok)
|
|
607
|
-
const provider = price.provider ? price.provider : '
|
|
601
|
+
const provider = price.provider ? price.provider : t('price.anyProvider')
|
|
608
602
|
return `<tr>
|
|
609
|
-
<td class="price-model">${esc(price.model)}<span class="pill ${builtin ? 'green' : 'violet'}">${builtin ? '
|
|
603
|
+
<td class="price-model">${esc(price.model)}<span class="pill ${builtin ? 'green' : 'violet'}">${builtin ? t('price.builtin') : t('price.custom')}</span></td>
|
|
610
604
|
<td class="num mono">${esc(price.cache_read_per_mtok)}</td>
|
|
611
605
|
<td class="num mono">${esc(price.input_per_mtok)}</td>
|
|
612
606
|
<td class="num mono">${esc(price.output_per_mtok)}</td>
|
|
613
607
|
<td>${esc(price.currency)}</td>
|
|
614
608
|
<td>${esc(provider)}</td>
|
|
615
|
-
<td class="num"><button class="btn small" data-action="edit-price" data-model="${attr(price.model)}" data-provider="${attr(price.provider)}">${icon('edit')}
|
|
609
|
+
<td class="num"><button class="btn small" data-action="edit-price" data-model="${attr(price.model)}" data-provider="${attr(price.provider)}">${icon('edit')}${t('price.edit')}</button></td>
|
|
616
610
|
</tr>`
|
|
617
611
|
}).join('')
|
|
618
612
|
const body = prices.length
|
|
619
613
|
? `<table class="usage-table price-table">
|
|
620
614
|
<thead><tr>
|
|
621
|
-
<th class="eyebrow mono"
|
|
622
|
-
<th class="eyebrow mono num"
|
|
623
|
-
<th class="eyebrow mono num"
|
|
624
|
-
<th class="eyebrow mono num"
|
|
625
|
-
<th class="eyebrow mono"
|
|
626
|
-
<th class="eyebrow mono"
|
|
615
|
+
<th class="eyebrow mono">${t('模型')}</th>
|
|
616
|
+
<th class="eyebrow mono num">${t('price.colCacheRead')}</th>
|
|
617
|
+
<th class="eyebrow mono num">${t('price.colInput')}</th>
|
|
618
|
+
<th class="eyebrow mono num">${t('price.colOutput')}</th>
|
|
619
|
+
<th class="eyebrow mono">${t('price.colCurrency')}</th>
|
|
620
|
+
<th class="eyebrow mono">${t('price.colProvider')}</th>
|
|
627
621
|
<th class="eyebrow mono num"></th>
|
|
628
622
|
</tr></thead>
|
|
629
623
|
<tbody>${rows}</tbody>
|
|
630
624
|
</table>`
|
|
631
|
-
: `<div class="empty-state"><div class="empty-symbol">${icon('chart')}</div><h3
|
|
625
|
+
: `<div class="empty-state"><div class="empty-symbol">${icon('chart')}</div><h3>${t('price.emptyTitle')}</h3><p>${t('price.emptyDesc')}</p></div>`
|
|
632
626
|
return `<div class="card price-card">
|
|
633
627
|
<div class="card-head">
|
|
634
|
-
<h3
|
|
628
|
+
<h3>${t('price.title')}</h3>
|
|
635
629
|
<div class="btn-row">
|
|
636
|
-
<span class="meta">${prices.length}
|
|
637
|
-
<button class="btn" data-action="new-price">${icon('plus')}
|
|
630
|
+
<span class="meta">${t('price.rulesCount', { count: prices.length })}</span>
|
|
631
|
+
<button class="btn" data-action="new-price">${icon('plus')}${t('price.add')}</button>
|
|
638
632
|
</div>
|
|
639
633
|
</div>
|
|
640
634
|
${body}
|
|
641
|
-
<div class="usage-note"
|
|
635
|
+
<div class="usage-note">${t('price.note')}${missing.length ? t('price.noteMissing', { models: missing.map(item => esc(item.model)).join(t('price.modelSeparator')) }) : ''}</div>
|
|
642
636
|
</div>`
|
|
643
637
|
}
|
|
644
638
|
|
|
@@ -647,15 +641,15 @@ let lastFocused = null
|
|
|
647
641
|
|
|
648
642
|
function focusableItems(root) {
|
|
649
643
|
if (!root) return []
|
|
650
|
-
return Array.from(root.querySelectorAll(FOCUSABLE))
|
|
644
|
+
return Array.from(root.querySelectorAll(FOCUSABLE) )
|
|
651
645
|
.filter(el => el.offsetWidth > 0 || el.offsetHeight > 0 || el === document.activeElement)
|
|
652
646
|
}
|
|
653
647
|
|
|
654
648
|
function focusModal() {
|
|
655
|
-
const modal = document.querySelector('.modal')
|
|
649
|
+
const modal = document.querySelector('.modal')
|
|
656
650
|
if (!modal) return
|
|
657
651
|
const body = modal.querySelector('.modal-body')
|
|
658
|
-
const preferred = body?.querySelector('input:not([type="hidden"]):not([disabled]), textarea:not([disabled]), select:not([disabled])')
|
|
652
|
+
const preferred = body?.querySelector('input:not([type="hidden"]):not([disabled]), textarea:not([disabled]), select:not([disabled])')
|
|
659
653
|
const items = focusableItems(modal)
|
|
660
654
|
;(preferred ?? items[0] ?? modal).focus()
|
|
661
655
|
}
|
|
@@ -667,7 +661,7 @@ function restoreFocus() {
|
|
|
667
661
|
}
|
|
668
662
|
|
|
669
663
|
function trapModalFocus(event) {
|
|
670
|
-
const modal = document.querySelector('.modal')
|
|
664
|
+
const modal = document.querySelector('.modal')
|
|
671
665
|
if (!modal) return false
|
|
672
666
|
const items = focusableItems(modal)
|
|
673
667
|
if (items.length === 0) {
|
|
@@ -708,7 +702,7 @@ function closeModal() {
|
|
|
708
702
|
}
|
|
709
703
|
|
|
710
704
|
async function openTask(taskId) {
|
|
711
|
-
openModal({ type: 'task', loading: true, title:
|
|
705
|
+
openModal({ type: 'task', loading: true, title: t("任务详情") })
|
|
712
706
|
try {
|
|
713
707
|
const detail = await api('task_detail', { taskId })
|
|
714
708
|
if (state.modal?.type !== 'task') return
|
|
@@ -720,7 +714,7 @@ async function openTask(taskId) {
|
|
|
720
714
|
}
|
|
721
715
|
|
|
722
716
|
async function openSkillDetail(slug) {
|
|
723
|
-
openModal({ type: 'skill-detail', loading: true, title:
|
|
717
|
+
openModal({ type: 'skill-detail', loading: true, title: t("技能详情") })
|
|
724
718
|
try {
|
|
725
719
|
const detail = await api('skill_detail', { slug })
|
|
726
720
|
if (state.modal?.type !== 'skill-detail') return
|
|
@@ -732,20 +726,20 @@ async function openSkillDetail(slug) {
|
|
|
732
726
|
}
|
|
733
727
|
|
|
734
728
|
async function openTrajectory(runId) {
|
|
735
|
-
openModal({ type: 'trajectory', loading: true, title:
|
|
729
|
+
openModal({ type: 'trajectory', loading: true, title: t("思考过程") })
|
|
736
730
|
try {
|
|
737
731
|
const detail = await api('run_trajectory', { runId }, { quiet: true })
|
|
738
732
|
if (state.modal?.type !== 'trajectory') return
|
|
739
733
|
state.modal = { type: 'trajectory', detail, runId }
|
|
740
734
|
renderModalLayer()
|
|
741
|
-
} catch (error) {
|
|
735
|
+
} catch (error ) {
|
|
742
736
|
closeModal()
|
|
743
|
-
toast(error?.message ||
|
|
737
|
+
toast(error?.message || t("读取思考过程失败"), 'error')
|
|
744
738
|
}
|
|
745
739
|
}
|
|
746
740
|
|
|
747
741
|
async function openBot(botId) {
|
|
748
|
-
openModal({ type: 'edit-bot', loading: true, title:
|
|
742
|
+
openModal({ type: 'edit-bot', loading: true, title: t("Bot 配置") })
|
|
749
743
|
try {
|
|
750
744
|
const detail = await api('bot_detail', { botId })
|
|
751
745
|
if (state.modal?.type !== 'edit-bot') return
|
|
@@ -765,14 +759,14 @@ async function reloadTaskModal(taskId) {
|
|
|
765
759
|
}
|
|
766
760
|
|
|
767
761
|
function bindProposalForm() {
|
|
768
|
-
const kind = document.querySelector('[data-proposal-kind]')
|
|
762
|
+
const kind = document.querySelector('[data-proposal-kind]')
|
|
769
763
|
if (!kind) return
|
|
770
764
|
const apply = () => {
|
|
771
765
|
const value = kind.value
|
|
772
|
-
document.querySelectorAll('[data-section]').forEach(section => {
|
|
766
|
+
document.querySelectorAll ('[data-section]').forEach(section => {
|
|
773
767
|
section.style.display = section.dataset.section === value ? '' : 'none'
|
|
774
768
|
})
|
|
775
|
-
const botField = document.querySelector('[data-field="bot"]')
|
|
769
|
+
const botField = document.querySelector('[data-field="bot"]')
|
|
776
770
|
if (botField) botField.style.display = value === 'bot_update' ? '' : 'none'
|
|
777
771
|
}
|
|
778
772
|
kind.addEventListener('change', apply)
|
|
@@ -794,5 +788,4 @@ function updateFallbackEffortOptions(select) {
|
|
|
794
788
|
effort.innerHTML = effortOptions(select.value, '')
|
|
795
789
|
}
|
|
796
790
|
|
|
797
|
-
|
|
798
791
|
export { modalNewProject, modalRemoveTracking, modalRemoveBotTracking, modalBot, modalInviteMember, modalNewTask, modalTask, modalSkill, modalMemory, modalProposal, modalPrice, modalTrajectory, openModal, closeModal, openTask, openSkillDetail, openTrajectory, openBot, reloadTaskModal, bindProposalForm, updateEffortOptions, updateFallbackEffortOptions, trapModalFocus, renderDirPicker, closeDirPicker, parseFallbackFields, normalizeTimeBudgetMinutes, modelOptions, effortOptions, fallbackModelOptions, renderPriceCard }
|