dsh-team-bots 0.2.347 → 0.2.393

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.
Files changed (52) hide show
  1. package/README.md +12 -2
  2. package/docs/README.zh.md +12 -2
  3. package/docs/assets/global-config.png +0 -0
  4. package/docs/assets/global-config.zh.png +0 -0
  5. package/docs/assets/tasks.png +0 -0
  6. package/docs/assets/tasks.zh.png +0 -0
  7. package/docs/assets/usage.png +0 -0
  8. package/docs/assets/usage.zh.png +0 -0
  9. package/index.js +2 -0
  10. package/package.json +2 -1
  11. package/src/config.js +55 -10
  12. package/src/db-migrations.js +144 -9
  13. package/src/paths.js +12 -0
  14. package/src/services/approvals.js +12 -2
  15. package/src/services/core.js +2 -1
  16. package/src/services/notify.js +71 -1
  17. package/src/services/proposals.js +36 -1
  18. package/src/services/questions.js +16 -3
  19. package/src/services/run-finish.js +18 -3
  20. package/src/services/runs.js +369 -34
  21. package/src/services/runtime/prompt.js +135 -88
  22. package/src/services/runtime/session.js +260 -72
  23. package/src/services/scheduler.js +135 -97
  24. package/src/services/task-dispatch.js +112 -5
  25. package/src/services/task-review.js +19 -1
  26. package/src/services/task-runs.js +53 -15
  27. package/src/services/tasks.js +81 -0
  28. package/src/services/wechat.js +23 -21
  29. package/src/subagent-ledger.js +165 -0
  30. package/src/tools.js +5 -5
  31. package/src/wechat/commands.js +3 -1
  32. package/ui/app.js +4 -14
  33. package/ui/i18n/en/chat.js +11 -11
  34. package/ui/i18n/en/common.js +0 -12
  35. package/ui/i18n/en/nav.js +0 -4
  36. package/ui/i18n/en/settings.js +14 -9
  37. package/ui/i18n/en/tasks.js +0 -1
  38. package/ui/i18n/en/usage.js +4 -7
  39. package/ui/i18n/zh/chat.js +11 -11
  40. package/ui/i18n/zh/common.js +0 -12
  41. package/ui/i18n/zh/nav.js +0 -4
  42. package/ui/i18n/zh/settings.js +13 -9
  43. package/ui/i18n/zh/tasks.js +0 -1
  44. package/ui/i18n/zh/usage.js +4 -7
  45. package/ui/modules/cards.js +19 -5
  46. package/ui/modules/composer.js +16 -3
  47. package/ui/modules/i18n.js +10 -0
  48. package/ui/modules/modal-forms.js +15 -8
  49. package/ui/modules/settings.js +9 -0
  50. package/ui/modules/util.js +0 -2
  51. package/ui/styles/frame.css +0 -28
  52. package/ui/styles/wide.css +0 -3
@@ -58,6 +58,63 @@ export function ensureTaskTerminalTimeBackfill(store) {
58
58
  store.run('INSERT INTO schema_migrations(name, applied_at) VALUES (?, ?) ON CONFLICT(name) DO NOTHING', 'tasks_terminal_time_backfill', nowIso())
59
59
  }
60
60
 
61
+ // 任务级死线 schema(DSHBOTS-274):tasks.budget_updated_at 记最近一次 time_budget_minutes
62
+ // 实改时刻,标记新预算生效点(死线长度随新预算重算;基准锚点见 taskDeadlineInfo=最新派发)。
63
+ export function ensureTaskDeadlineSchema(store) {
64
+ if (store.get('SELECT 1 AS ok FROM schema_migrations WHERE name = ?', 'tasks_budget_updated_at')) return
65
+ const columns = store.all('PRAGMA table_info(tasks)').map(row => row.name)
66
+ if (!columns.includes('budget_updated_at')) {
67
+ store.exec('ALTER TABLE tasks ADD COLUMN budget_updated_at TEXT')
68
+ }
69
+ store.run('INSERT INTO schema_migrations(name, applied_at) VALUES (?, ?) ON CONFLICT(name) DO NOTHING', 'tasks_budget_updated_at', nowIso())
70
+ }
71
+
72
+ // 允许轮数(DSHBOTS-274):整卡死线 = 派发基准 + time_budget_minutes × TASK_BUDGET_ROUNDS。
73
+ export const TASK_BUDGET_ROUNDS = 2
74
+
75
+ // 任务级死线纯计算(DSHBOTS-274 立卡,DSHBOTS-281 基准升级):
76
+ // 治「time_budget_minutes 只约束单运行、多轮派发各自重置预算、累计耗时无上限」。
77
+ // - 派发基准 = 最新一次派发(latestDispatchAt):重派即新窗口——重派动作本身视为预算决策,
78
+ // 存量老卡重派不再立即升级,也无需先实改 time_budget_minutes 延期;
79
+ // - 延期阀兼容:owner 实改预算后死线按新预算×轮数从最新派发基准重算;改后尚未重派时
80
+ // 基准仍取最新派发(不早于旧口径的「退回首次派发」),budget_updated_at 只标记新预算生效;
81
+ // - 真超时仍拦截:新窗口内预算×轮数耗尽后,下一次领取照常升级(escalateTaskPastDeadline);
82
+ // - 无预算(NULL/≤0)或无派发记录返回 null,死线不约束(与 D-131 无时效口径一致)。
83
+ export const taskDeadlineMs = ({ budgetMinutes, firstDispatchAt, latestDispatchAt }) => {
84
+ const minutes = Number(budgetMinutes)
85
+ if (!Number.isFinite(minutes) || minutes <= 0) return null
86
+ const baseRaw = latestDispatchAt ?? firstDispatchAt
87
+ const base = baseRaw ? Date.parse(baseRaw) : NaN
88
+ if (!Number.isFinite(base)) return null
89
+ return base + minutes * TASK_BUDGET_ROUNDS * 60_000
90
+ }
91
+
92
+ // 任务级死线信息(DSHBOTS-274;DSHBOTS-281 基准=最新派发):派发时刻口径 = runs 表
93
+ // kind='task' 的 queued_at(入队即派发;started_at 领取后才写,未被领取过的派发拿不到
94
+ // 时刻,故不用 started_at)。review/handle 等派生运行 kind!=='task' 天然不计入派发史。
95
+ export function taskDeadlineInfo(store, task) {
96
+ ensureTaskDeadlineSchema(store)
97
+ const firstDispatchAt = store.get(
98
+ "SELECT MIN(queued_at) AS v FROM runs WHERE task_id = ? AND kind = 'task'",
99
+ task.id,
100
+ )?.v ?? null
101
+ // 重派即新窗口:每次派发都把死线基准推到本次 queued_at,重派(含无主卡领取)自动重置,
102
+ // 不依赖任何显式预算实改(与 D-274「改后首个派发」同构,把重派本身视为预算决策)。
103
+ const latestDispatchAt = store.get(
104
+ "SELECT MAX(queued_at) AS v FROM runs WHERE task_id = ? AND kind = 'task'",
105
+ task.id,
106
+ )?.v ?? null
107
+ return {
108
+ deadlineMs: taskDeadlineMs({
109
+ budgetMinutes: task.time_budget_minutes,
110
+ firstDispatchAt,
111
+ latestDispatchAt,
112
+ }),
113
+ firstDispatchAt,
114
+ latestDispatchAt,
115
+ }
116
+ }
117
+
61
118
  export const tasksMethods = {
62
119
  // 缺省任务预算(DSHBOTS-198):env > 无进展看门狗(分钟)生效值 > 兜底 20,
63
120
  // 建档补挂与重派补挂共用同一缺省链。
@@ -273,6 +330,18 @@ export const tasksMethods = {
273
330
  }
274
331
  if (patch.assigneeBotId !== undefined) {
275
332
  if (patch.assigneeBotId) this.assertDispatchTarget(task.project_id, patch.assigneeBotId)
333
+ // 共享板无主卡声明闸门(DSHBOTS-270):无主卡经编辑表单获得 owner,与 assignTask
334
+ // 领取是同一条「获得 owner 即将进施工」链路,同口径过闸;同一次 patch 里补的
335
+ // write_scopes / 描述「写范围:」行一并纳入判定——补声明后放行。
336
+ if (patch.assigneeBotId && !task.assignee_bot_id) {
337
+ this.assertClaimScopes({
338
+ ...task,
339
+ write_scopes: patch.writeScopes === undefined
340
+ ? task.write_scopes
341
+ : JSON.stringify(parseWriteScopes(patch.writeScopes)),
342
+ description: patch.description === undefined ? task.description : text(patch.description, 40_000),
343
+ }, this.projectRow(task.project_id))
344
+ }
276
345
  updates.assignee_bot_id = patch.assigneeBotId || null
277
346
  }
278
347
  if (patch.position !== undefined) updates.position = Number(patch.position) || 0
@@ -281,6 +350,18 @@ export const tasksMethods = {
281
350
  if (patch.writeScopes !== undefined) {
282
351
  updates.write_scopes = JSON.stringify(parseWriteScopes(patch.writeScopes))
283
352
  }
353
+ // 延期阀(DSHBOTS-274):update_task 实改 time_budget_minutes 后整卡死线按新预算重算——
354
+ // 记 budget_updated_at 标记新预算生效;派发基准统一为最新派发(DSHBOTS-281 重派即新窗口),
355
+ // 改预算与重派各自独立生效,改后重派拿到「新预算 × 新窗口」。
356
+ if (patch.timeBudgetMinutes !== undefined || patch.time_budget_minutes !== undefined) {
357
+ const rawBudget = patch.timeBudgetMinutes ?? patch.time_budget_minutes
358
+ const budget = Number(rawBudget) > 0 ? clampNumber(rawBudget, 1, 10_080, null) : null
359
+ if (budget !== task.time_budget_minutes) {
360
+ ensureTaskDeadlineSchema(this.store)
361
+ updates.time_budget_minutes = budget
362
+ updates.budget_updated_at = nowIso()
363
+ }
364
+ }
284
365
  if (patch.status !== undefined) {
285
366
  if (!TASK_STATUSES.has(patch.status)) throw badRequest('任务状态无效')
286
367
  this.assertTransition(task.status, patch.status)
@@ -6,7 +6,7 @@
6
6
  import { createRequire } from 'node:module'
7
7
  import { AppError, conflict } from '../errors.js'
8
8
  import { WechatIlinkError } from '../wechat/commands.js'
9
- import { jsonParse, parseMentions } from '../util.js'
9
+ import { jsonParse } from '../util.js'
10
10
  import { answerFailed, answerReceipt, approvalCard, questionCard, wechatToken } from '../wechat/format.js'
11
11
 
12
12
  // 微信登录二维码:服务端直接出 SVG,UI 注入即可,无需前端 QR 库(vendor/qrcode,MIT)。
@@ -127,14 +127,15 @@ export const wechatMethods = {
127
127
  },
128
128
 
129
129
  /**
130
- * 微信直达对话(DSHBOTS-208 起,258 四次拍板后收敛为绝对二值路由):
131
- * /tr 显式转发(key 非空)→ 消息以工作台用户身份插入项目群聊并触发 chat 运行,
132
- * 运行结束的 bot 回复由 run-finish 按 trigger_type='wechat' 推回微信管理员;
133
- * 自由文本(key 为空)→ 一律投项目外 director 专属工作区单聊(不随 direct_project_key
134
- * 绑定、active 项目数变化,路由层无绑定/项目数判断分支),返回
135
- * { director, messageId, firstContact };解析不到 director(通道异常)→ { error: 'no_director' }。
136
- * 项目无可定向 Bot(无 mention 且总监不可用)→ { error: 'no_owner', project };
137
- * 群聊直达成功 → { project, messageId, runBots };显式 key 未命中 → null。
130
+ * 微信直达对话(DSHBOTS-208 起,258 四次拍板,299 会话域三分后收敛为单一去向):
131
+ * 微信通道一律落 director 专属工作区 solo 会话(A 口径:微信=用户↔director 直接通信)——
132
+ * 自由文本(key 为空)与 /tr <key> 显式转发(key 非空)都投 director 的 solo_messages
133
+ * 并触发 solo_chat 运行(trigger_type='wechat',运行收尾按此把回复推回微信管理员,
134
+ * run-finish 回程链路对 chat/solo 两类同门禁,语义不回退);
135
+ * /tr 的 key 命中项目后在正文携带 [项目 KEY] 上下文,director 自行把工作派进对应项目,
136
+ * 不再以工作台用户身份插项目群聊触发 chat 运行(原路径 trigger_type='wechat' 的
137
+ * chat 运行落项目控制面会话,违反三分域);key 未命中 → null;解析不到 director
138
+ * (通道异常)→ { error: 'no_director' }。
138
139
  */
139
140
  async wechatChat(key, body) {
140
141
  let project = null
@@ -146,22 +147,23 @@ export const wechatMethods = {
146
147
  if (!project) return null
147
148
  } else {
148
149
  // DSHBOTS-258 绝对口径:自由文本永远走 director 专属工作区,用户不直接进群。
149
- // 路由层不出现 direct_project_key 绑定判断,也不出现 active 项目数量判断——
150
- // 唯一分流条件是 /tr 显式转发(key 非空)。解析不到 director 属通道异常,
151
- // 独立 no_director 出口(不复用 no_target:那是「需要用户选项目」的语义链)。
152
150
  const director = this.wechatDirectorBot()
153
151
  if (director) return this.wechatDirectorChat(director, String(body ?? ''))
154
152
  return { error: 'no_director' }
155
153
  }
156
- const members = this.membersOf(project.id).filter(bot => bot.status === 'active')
157
- const text = String(body ?? '')
158
- // 无 mention 时 sendMessage 兜底定向 owner_bot_id:总监必须可用,否则消息发出无人接。
159
- if (parseMentions(text, members).length === 0
160
- && !members.some(bot => bot.id === project.owner_bot_id)) {
161
- return { error: 'no_owner', project }
162
- }
163
- const result = await this.sendMessage(project.id, text, { type: 'user', id: this.localUserId }, null, [], { origin: 'wechat' })
164
- return { project, ...result }
154
+ // DSHBOTS-299 A 口径:/tr 显式转发同落 director 专属工作区——正文带 [项目 KEY]
155
+ // 上下文(与自由文本的 [微信管理员] 前缀同链路),由 director 以团队工具派单进项目。
156
+ const director = this.wechatDirectorBot()
157
+ if (!director) return { error: 'no_director', project }
158
+ const adminPeerId = this.wechat?.status?.()?.adminPeerId ?? null
159
+ const result = await this.sendSoloMessage(
160
+ director.id,
161
+ `${WECHAT_SOLO_SOURCE_MARK}[项目 ${project.key}] ${String(body ?? '')}`,
162
+ { type: 'user', id: adminPeerId ?? 'user:wechat' },
163
+ [],
164
+ { origin: 'wechat' },
165
+ )
166
+ return { project, director, messageId: result?.messageId ?? null }
165
167
  },
166
168
 
167
169
  /**
@@ -0,0 +1,165 @@
1
+ // DSHBOTS-294 子代理账本(ADR §4.2.1):宿主事件缝 → 所属 task 运行的 run_events。
2
+ // 双缝互补:tools 瀑布带 caller agent(父归属权威源,任务号标签在参数里);
3
+ // subagent/start|end 带 stopReason+lastAssistantMessage(终态摘要源,载荷无父身份,
4
+ // 靠 tools/result 配对或唯一 running task 运行兜底归属)。子代理不占 runs 行(§4.2)。
5
+ import { id, nowIso } from './util.js'
6
+
7
+ const SUBAGENT_TOOLS = new Set(['subagent', 'subagent_fork'])
8
+ const SUMMARY_LIMIT = 400
9
+ const STASH_LIMIT = 64
10
+
11
+ // 任务号标签(DSHBOTS-292 约定标签=任务号,如 DSHBOTS-294):优先 description,其次 prompt。
12
+ export function taskLabelOf(args) {
13
+ const source = typeof args?.description === 'string' ? args.description
14
+ : typeof args?.prompt === 'string' ? args.prompt : ''
15
+ const match = source.match(/\b[A-Z][A-Z0-9]{1,10}-\d{1,6}\b/)
16
+ if (match) return match[0]
17
+ const trimmed = source.trim()
18
+ return trimmed ? trimmed.slice(0, 60) : null
19
+ }
20
+
21
+ const truncate = (text) => {
22
+ const value = typeof text === 'string' ? text : text == null ? '' : JSON.stringify(text)
23
+ return value.length > SUMMARY_LIMIT ? `${value.slice(0, SUMMARY_LIMIT)}…` : value
24
+ }
25
+
26
+ // 在插件根 ctx 注册事件监听(根级注册面实测见 tests/subagent-ledger.test.ts)。
27
+ export function installSubagentLedger(ctx, store, logger) {
28
+ // callId → 派发时快照(tools/result 按 callId 配对父归属)
29
+ const byCall = new Map()
30
+ // botId → 未消费的标签栈(subagent/end 兜底归属时取最近一次派发的标签)
31
+ const labelsByBot = new Map()
32
+ // 暂存 subagent/end 载荷:childId → info,tools/result 到达时按 id 出现在结果 JSON 里配对
33
+ const endsByChild = new Map()
34
+
35
+ const ownerRunOf = (agentSessionId) => {
36
+ const binding = agentSessionId
37
+ ? store.get('SELECT * FROM session_bindings WHERE session_id = ?', agentSessionId)
38
+ : undefined
39
+ if (!binding?.bot_id) return null
40
+ const run = store.get(
41
+ "SELECT id FROM runs WHERE bot_id = ? AND kind = 'task' AND status = 'running' ORDER BY started_at DESC LIMIT 1",
42
+ binding.bot_id,
43
+ )
44
+ return run ? { botId: binding.bot_id, runId: run.id } : null
45
+ }
46
+
47
+ const record = (runId, type, message) => store.run(
48
+ 'INSERT INTO run_events(id, run_id, type, message, created_at) VALUES (?, ?, ?, ?, ?)',
49
+ id('rev'), runId, type, message, nowIso(),
50
+ )
51
+
52
+ const stashLabel = (botId, label) => {
53
+ const list = labelsByBot.get(botId) ?? []
54
+ list.push(label)
55
+ if (list.length > STASH_LIMIT) list.shift()
56
+ labelsByBot.set(botId, list)
57
+ }
58
+
59
+ const takeLabel = (botId) => {
60
+ const list = labelsByBot.get(botId)
61
+ const label = list?.shift()
62
+ if (list && list.length === 0) labelsByBot.delete(botId)
63
+ return label ?? null
64
+ }
65
+
66
+ const endsAt = (childId, info) => {
67
+ if (endsByChild.size >= STASH_LIMIT) endsByChild.delete(endsByChild.keys().next().value)
68
+ endsByChild.set(childId, info)
69
+ }
70
+
71
+ // subagent/end 的兜底归属:事件时刻全库恰好一个 bot 有 running task 运行、且该 bot
72
+ // 无待配对的工具瀑布调用(tools/result 会按 callId 精确落账,优先于兜底)才落账。
73
+ const soleRunningTaskRun = () => {
74
+ const rows = store.all("SELECT bot_id, id FROM runs WHERE kind = 'task' AND status = 'running'")
75
+ return rows.length === 1 ? rows[0] : null
76
+ }
77
+
78
+ const resultSummary = (result) => {
79
+ if (result == null) return '-'
80
+ if (typeof result === 'string') return truncate(result)
81
+ const parts = []
82
+ for (const key of ['stopReason', 'status', 'error', 'code', 'message']) {
83
+ if (result[key] != null) parts.push(`${key}=${truncate(String(result[key]))}`)
84
+ }
85
+ return parts.length > 0 ? parts.join(' ') : truncate(result)
86
+ }
87
+
88
+ const offs = []
89
+ const on = (name, listener) => {
90
+ const off = ctx.on?.(name, listener)
91
+ if (off) offs.push(off)
92
+ return off
93
+ }
94
+
95
+ on('tools/pre-execute', async (exec, next) => {
96
+ try {
97
+ if (SUBAGENT_TOOLS.has(exec?.name)) {
98
+ const owner = ownerRunOf(exec?.agent?.session?.id)
99
+ if (owner) {
100
+ const label = taskLabelOf(exec?.arguments)
101
+ record(owner.runId, 'subagent_spawned', `${exec.name} label=${label ?? '-'} bot=${owner.botId}`)
102
+ byCall.set(exec.callId, { ...owner, label })
103
+ stashLabel(owner.botId, label)
104
+ }
105
+ }
106
+ } catch (error) {
107
+ logger?.warn?.('dsh-team: subagent ledger pre-execute: %s', (error )?.message ?? error)
108
+ }
109
+ return next()
110
+ })
111
+
112
+ on('subagent/start', (info) => {
113
+ try {
114
+ if (info?.id) endsAt(info.id, { started: true })
115
+ } catch {}
116
+ })
117
+
118
+ on('subagent/end', (info) => {
119
+ try {
120
+ if (!info?.id) return
121
+ endsAt(info.id, info)
122
+ const sole = soleRunningTaskRun()
123
+ const pendingCall = sole ? [...byCall.values()].some(entry => entry.botId === sole.bot_id) : false
124
+ if (!sole || pendingCall) return
125
+ endsByChild.delete(info.id)
126
+ const label = takeLabel(sole.bot_id)
127
+ record(sole.id, 'subagent_result',
128
+ `label=${label ?? '-'} stop=${info.stopReason ?? '-'} summary=${truncate(info.lastAssistantMessage ?? '')}`)
129
+ } catch (error) {
130
+ logger?.warn?.('dsh-team: subagent ledger end: %s', (error )?.message ?? error)
131
+ }
132
+ })
133
+
134
+ on('tools/result', (exec, result) => {
135
+ try {
136
+ if (!SUBAGENT_TOOLS.has(exec?.name)) return
137
+ const entry = byCall.get(exec?.callId)
138
+ if (!entry) return
139
+ byCall.delete(exec?.callId)
140
+ // 配对暂存的 subagent/end:child id 出现在结果 JSON 里即认领其终态摘要
141
+ let matched = null
142
+ const haystack = JSON.stringify(result ?? {})
143
+ for (const [childId, info] of endsByChild) {
144
+ if (haystack.includes(childId)) {
145
+ matched = info
146
+ endsByChild.delete(childId)
147
+ break
148
+ }
149
+ }
150
+ const stop = matched?.stopReason
151
+ const summary = matched?.lastAssistantMessage ?? resultSummary(result?.value ?? result)
152
+ record(entry.runId, 'subagent_result',
153
+ `label=${entry.label ?? '-'} stop=${stop ?? '-'} summary=${truncate(summary ?? '')}`)
154
+ } catch (error) {
155
+ logger?.warn?.('dsh-team: subagent ledger result: %s', (error )?.message ?? error)
156
+ }
157
+ })
158
+
159
+ return () => {
160
+ for (const off of offs) off()
161
+ byCall.clear()
162
+ labelsByBot.clear()
163
+ endsByChild.clear()
164
+ }
165
+ }
package/src/tools.js CHANGED
@@ -70,7 +70,7 @@ export function installTeamTools(ctx, service) {
70
70
 
71
71
  ctx.tools.register({
72
72
  name: 'team_assign_task',
73
- description: 'Assign a task to a project bot. Only the project owner bot may use this. With `task` it re-dispatches that existing task (retry to the same bot, or hand it to a different bot); passing title/description/priority alongside `task` amends the card — the assignee is immediately notified to correct course per the new card. Without `task`, creates a new task that starts automatically. A new task whose write scopes exactly match an unfinished task in the same project is rejected as a duplicate dispatch; merge the cards into the existing task instead, or pass force_duplicate to override (audited). Consolidate before dispatch: one requirement goes into one card — amend and re-dispatch the existing card (or add subtask cards with parent_task_id for genuinely independent parts) instead of opening several sibling cards for the same need.',
73
+ description: 'The regular path to dispatch project work to a bot: create a new task card or re-dispatch/amend an existing one. Only the project owner bot may use this. With `task` it re-dispatches that existing task (retry to the same bot, or hand it to a different bot); passing title/description/priority alongside `task` amends the card — the assignee is immediately notified to correct course per the new card. Without `task`, creates a new task that starts automatically. A new task whose write scopes exactly match an unfinished task in the same project is rejected as a duplicate dispatch; merge the cards into the existing task instead, or pass force_duplicate to override (audited). Consolidate before dispatch: one requirement goes into one card — amend and re-dispatch the existing card (or add subtask cards with parent_task_id for genuinely independent parts) instead of opening several sibling cards for the same need.',
74
74
  parameters: {
75
75
  type: 'object',
76
76
  properties: {
@@ -101,7 +101,7 @@ export function installTeamTools(ctx, service) {
101
101
 
102
102
  ctx.tools.register({
103
103
  name: 'team_block_task',
104
- description: 'Force-move an in-progress task to blocked and abort its queued/running runs. Only the project owner bot may use this. The stop rides the existing abort chain and is audited as task.force_blocked (run error code TASK_FORCE_BLOCKED). Use it to stop a runaway or wrong-headed execution; typically followed by re-dispatching the same task with an amended card.',
104
+ description: 'The regular path to force-stop a task: force-move an in-progress task to blocked and abort its queued/running runs. Only the project owner bot may use this. The stop rides the existing abort chain and is audited as task.force_blocked (run error code TASK_FORCE_BLOCKED). Use it to stop a runaway or wrong-headed execution; typically followed by re-dispatching the same task with an amended card.',
105
105
  parameters: {
106
106
  type: 'object',
107
107
  properties: {
@@ -120,7 +120,7 @@ export function installTeamTools(ctx, service) {
120
120
 
121
121
  ctx.tools.register({
122
122
  name: 'team_review_task',
123
- description: 'Accept or return a delivered task that is waiting for owner review. Only the project owner bot may use this. `accept` marks the task done; `return` sends it back to the assignee for rework (a reason is required).',
123
+ description: 'The one and only regular path to close or return a delivered task: `accept` marks a waiting-for-review card done; `return` sends it back to the assignee for rework (a reason is required). Hand-editing the store or any side door does not close a card — when the delivery is not reviewable yet, wait for the assignee to deliver, or amend and re-dispatch it with team_assign_task. Only the project owner bot may use this.',
124
124
  parameters: {
125
125
  type: 'object',
126
126
  properties: {
@@ -343,14 +343,14 @@ export function installTeamTools(ctx, service) {
343
343
 
344
344
  ctx.tools.register({
345
345
  name: 'team_propose_evolution',
346
- description: 'Propose a versioned change to your own instructions or to the shared skill library. A human must review and approve it; this tool never applies the change.',
346
+ description: 'Facts/preferences go to memory first (team_remember); propose evolution only for structural instruction/skill changes whose benefit clearly exceeds memory. Propose a versioned change to your own instructions or to the shared skill library. A human must review and approve it; this tool never applies the change.',
347
347
  parameters: {
348
348
  type: 'object',
349
349
  properties: {
350
350
  kind: { type: 'string', enum: ['bot_update', 'skill'], description: 'bot_update changes your role/instructions; skill publishes a reusable skill proposal' },
351
351
  title: { type: 'string', description: 'Short proposal title' },
352
352
  rationale: { type: 'string', description: 'Why this change is useful and what evidence supports it' },
353
- instructions: { type: 'string', description: 'For bot_update: the complete replacement instructions' },
353
+ instructions: { type: 'string', description: 'For bot_update: 进化指令必须是原指令+新增内容的融合稿:保留原有指令全文再写改动,不是全新替换稿也不是增量补丁(保留率低于 60% 会被系统拒绝)' },
354
354
  slug: { type: 'string', description: 'For skill: lowercase skill slug' },
355
355
  name: { type: 'string', description: 'For skill: display name' },
356
356
  description: { type: 'string', description: 'For skill: one-line description' },
@@ -154,7 +154,9 @@ async function handleFixedCommand(service, body, ctx) {
154
154
  const message = match[2].trim()
155
155
  const chat = await service.wechatChat(key, message)
156
156
  if (!chat) return projectNotFound(key, service.stateView().projects ?? [])
157
- if (chat.error === 'no_owner') return noOwner(chat.project)
157
+ // DSHBOTS-299:/tr 转发一律落 director 专属工作区(携带 [项目 KEY] 上下文),
158
+ // 总监不可用属通道异常,独立出口;no_owner 出口随项目群直达一并退役。
159
+ if (chat.error === 'no_director') return noDirector()
158
160
  ctx?.bind?.(chat.project.key)
159
161
  return connectedReceipt(chat.project, 'dispatch')
160
162
  }
package/ui/app.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { state, STATUS, STATUS_ORDER, PRIORITY, PROPOSAL_STATUS, COLORS, COLOR_NAMES, BOT_STATUS, RUN_STATUS, RUN_KIND, CHAT_PAGE_SIZE, CHAT_ACTIVE_TASK_LIMIT, SKILL_STATUS, MEMORY_STATUS, PROPOSAL_KIND, TERMINAL_STATUS, CREATOR_TYPE, EFFORT, FILE_POLICY, DEFAULT_FILE_POLICY, VIEW_ACTION, NAV, SOLO_NAV } from './modules/state.js'
2
2
  import { icon } from './modules/icons.js'
3
- import { applyUiScale, applyUiTheme, esc, attr, pathCode, costValue, clamp, botById, shortRefId, actorLabel, taskById, activeProject, inSoloContext, pageProject, activeBots, formatNumber, CURRENCY_SYMBOL, formatCost, timeAgo, formatTime, duration, avatar, statusPill, runDot, memberRunDot, runDotHtml, MEMBER_STATUS_TEXT, memorySource, toast, filePolicyOptions } from './modules/util.js'
3
+ import { applyUiScale, applyUiTheme, esc, attr, pathCode, costValue, clamp, botById, shortRefId, actorLabel, taskById, activeProject, inSoloContext, pageProject, activeBots, formatNumber, CURRENCY_SYMBOL, formatCost, timeAgo, formatTime, duration, avatar, statusPill, runDot, memberRunDot, runDotHtml, memorySource, toast, filePolicyOptions } from './modules/util.js'
4
4
  import { richText, mdPlainSummary, mdChatScope } from './modules/markdown.js'
5
5
  import { api, loadState, markVisibleChatRead } from './modules/api.js'
6
6
  import { t, setLanguage } from './modules/i18n.js'
@@ -225,8 +225,6 @@ function renderShell() {
225
225
  const pendingApprovals = data?.pendingApprovals ?? { count: 0, items: [] }
226
226
  // 跨项目待答提问(DSHBOTS-116):与审批同口径,顶层全局聚合。
227
227
  const pendingQuestions = data?.pendingQuestions ?? { count: 0, items: [] }
228
- // 侧栏状态行任务口径(DSHBOTS-105):全库任务 in_progress 计数,不随群聊/单聊上下文跳变;topbar 仍按项目口径。
229
- const activeTasks = Number(data?.activeTasks ?? 0)
230
228
  const projectRunning = project?.stats?.running ?? 0
231
229
  const tokenTotal = usageTotals('project').totalTokens ?? 0
232
230
  // 全局一级视图(DSHBOTS-197 起含迁移落点页 通道/密钥):无项目 tab 导航,侧栏直达。四页页壳页(DSHBOTS-216)冗余 topbar 不渲染,页头由 global-head 唯一承担(总览bots 仍走 topbar);无横幅时 main-head 整块不渲染,避免空粘头残影。
@@ -352,14 +350,6 @@ function renderShell() {
352
350
  <a class="global-config dsh-official-link" href="/index.html" title="${t('sidebar.switchToDsh')}">
353
351
  ${icon('external')}<span>${t('sidebar.dshNative')}</span>
354
352
  </a>
355
- <div class="sidebar-meta">
356
- <span class="dot ${activeTasks ? 'amber' : ''}"></span>
357
- <span>${activeTasks ? t('sidebar.tasksActive', { count: activeTasks }) : t('sidebar.idle')}</span>
358
- <span class="sidebar-meta-sep">·</span>
359
- <span>${t('sidebar.botsCount', { count: activeBots.length })}</span>
360
- <span class="sidebar-meta-sep">·</span>
361
- <span>${t('sidebar.pendingReviews', { count: pendingProposals() })}</span>
362
- </div>
363
353
  </div>
364
354
  </aside>
365
355
  <main class="main">
@@ -711,11 +701,11 @@ window.addEventListener('error', (event) => {
711
701
  const url = new URL(img.getAttribute('src') ?? '', location.href)
712
702
  name = url.searchParams.get('path')?.split('/').pop() ?? url.pathname.split('/').pop() ?? ''
713
703
  } catch { name = '' }
714
- if (!name) name = img.alt?.trim() || '图片'
704
+ if (!name) name = img.alt?.trim() || t('chat.imageFallback')
715
705
  const chip = document.createElement('span')
716
706
  chip.className = 'md-img-missing'
717
- chip.textContent = `${name}(图片未能加载)`
718
- chip.title = '工作区里找不到该图片,或类型/大小不在白名单内'
707
+ chip.textContent = `${name}${t('chat.imageMissingSuffix')}`
708
+ chip.title = t('chat.imageMissingHint')
719
709
  img.replaceWith(chip)
720
710
  }, true)
721
711
 
@@ -10,7 +10,10 @@ export default {
10
10
  "chat.emptyBody": "Messages go to the owner bot by default; use <strong>@Bot</strong> to mention a member, or type <strong>/task @Bot title</strong> to create a task directly.",
11
11
  "chat.typingQueued": "Queued for reply…",
12
12
  "chat.typingRunning": "Thinking & replying…",
13
- "chat.botFallback": "Bot",
13
+ // Image-load failure placeholder chip (md-img-missing in app.ts)
14
+ "chat.imageFallback": "Image",
15
+ "chat.imageMissingSuffix": " (image failed to load)",
16
+ "chat.imageMissingHint": "The image was not found in the workspace, or its type/size is not on the allowlist",
14
17
  // Message history pagination
15
18
  "chat.loadingOlder": "Loading…",
16
19
  "chat.loadOlder": "Load ${count} earlier",
@@ -68,6 +71,13 @@ export default {
68
71
  "solo.noRuns": "No dispatch runs yet.",
69
72
  "solo.workspace": "Dedicated workspace",
70
73
  // DSHBOTS-220: ui/modules copy
74
+ "等待审批": "Waiting for approval",
75
+ "已允许一次": "Allowed once",
76
+ "已拒绝": "Rejected",
77
+ "已超时": "Timed out",
78
+ "已取消": "Canceled",
79
+ "等待回答": "Waiting for answer",
80
+ "已回答": "Answered",
71
81
  "${head}:${summary}": "${head}: ${summary}",
72
82
  "${source}|${head}:${summary}": "${source} | ${head}: ${summary}",
73
83
  "${minutes} 分 ${seconds} 秒后自动拒绝": "Auto-rejects in ${minutes}m ${seconds}s",
@@ -99,14 +109,6 @@ export default {
99
109
  "图片预览": "Image preview",
100
110
  "图片预览不可用": "Image preview unavailable",
101
111
  "失败": "Failed",
102
- "已允许一次": "Allowed once",
103
- "已取消": "Canceled",
104
- "已回复": "Replied",
105
- "已回答": "Answered",
106
- "已拒绝": "Rejected",
107
- "已超时": "Timed out",
108
- "已送达": "Delivered",
109
- "待回复": "Awaiting reply",
110
112
  "待回答提问": "Questions awaiting answers",
111
113
  "待处理审批": "Pending approvals",
112
114
  "排队等待回复…": "Queued, waiting for reply…",
@@ -120,8 +122,6 @@ export default {
120
122
  "清空本群全部聊天记录?清除后不可恢复(任务与记忆保留)。": "Clear all chat history in this group? This cannot be undone (tasks and memories are kept).",
121
123
  "清空聊天": "Clear chat",
122
124
  "的全部对话记录?清除后不可恢复(记忆保留)。": "? This cannot be undone (memories are kept).",
123
- "等待回答": "Awaiting answer",
124
- "等待审批": "Pending approval",
125
125
  "补充说明(可选)": "Additional notes (optional)",
126
126
  "计划评审": "Plan review",
127
127
  "请求使用": "requests to use",
@@ -74,17 +74,7 @@ export default {
74
74
  "filePolicy.read-only": "Read-only",
75
75
  "filePolicy.workspace-write": "Workspace write",
76
76
  "filePolicy.danger-full-access": "Full access",
77
- "approvalStatus.pending": "Waiting for approval",
78
- "approvalStatus.allowed": "Allowed once",
79
- "approvalStatus.rejected": "Rejected",
80
- "approvalStatus.timeout": "Timed out",
81
- "approvalStatus.cancelled": "Cancelled",
82
- "questionStatus.pending": "Waiting for answer",
83
- "questionStatus.answered": "Answered",
84
- "questionStatus.expired": "Cancelled",
85
- "questionStatus.timeout": "Timed out",
86
77
  // DSHBOTS-220: ui/modules copy
87
- "<span class=\\\"pill amber\\\">${pending} 条待审</span>": "${pending} pending",
88
78
  "Bot 已归档": "Bot archived",
89
79
  "」关闭": "\\\", disabled",
90
80
  "」恢复": "\\\", enabled",
@@ -153,10 +143,8 @@ export default {
153
143
  "该成员": "this member",
154
144
  "请先选择负责人": "Select an owner first",
155
145
  "请求失败,请稍后重试。": "Request failed. Please try again later.",
156
- "运行失败": "Run failed",
157
146
  "运行已取消": "Run canceled",
158
147
  "运行沉淀": "Run capture",
159
- "限流等待": "Rate-limit wait",
160
148
  "限流等待,约 ${waitMin} 分钟后自动重试": "Rate-limited; auto-retrying in about ${waitMin} minutes",
161
149
  "项目已再开,恢复为进行中": "Project reopened and restored to in progress",
162
150
  "项目已归档": "Project archived",
package/ui/i18n/en/nav.js CHANGED
@@ -74,10 +74,6 @@ export default {
74
74
  "sidebar.globalConfig": "Global settings",
75
75
  "sidebar.switchToDsh": "Switch to the native DSH web UI",
76
76
  "sidebar.dshNative": "Native DSH UI",
77
- "sidebar.tasksActive": "${count} tasks in progress",
78
- "sidebar.idle": "Team idle",
79
- "sidebar.botsCount": "${count} bots",
80
- "sidebar.pendingReviews": "${count} in review",
81
77
  // Topbar stats & actions
82
78
  "topbar.taskOne": "task",
83
79
  "topbar.taskMany": "tasks",
@@ -35,6 +35,8 @@ export default {
35
35
  "global.stallOff": "Watchdog off",
36
36
  "global.stallMinutes": "${minutes} min watchdog",
37
37
  "global.runTimeoutLabel": "Timeout abort (minutes)",
38
+ "global.approvalTimeoutLabel": "Approval wait timeout (minutes)",
39
+ "global.questionTimeoutLabel": "Question handoff timeout (minutes)",
38
40
  "global.stallWatchdogLabel": "No-progress watchdog (minutes)",
39
41
  "global.runLimitsHint1": "Timeout abort = the maximum duration of a single run (1–360 minutes); no-progress watchdog = how long a run may produce no output before it is considered stuck (0–360 minutes, 0 disables it).",
40
42
  "global.reviewIdleLabel": "Review idle threshold (minutes)",
@@ -81,6 +83,10 @@ export default {
81
83
  "secrets.sectionListDesc": "Team- and project-level keys; values are stored encrypted.",
82
84
  "secrets.sectionAdd": "Add key",
83
85
  "secrets.sectionAddDesc": "Values are never shown again after saving; the same name in the same scope overwrites the old value.",
86
+ // Thinking trail (run trajectory): the backend stores Chinese originals; the UI strips the
87
+ // subject out and rebuilds the label in the current language.
88
+ "完成": "Completed",
89
+ "中止": "Aborted",
84
90
  "不可用": "Unavailable",
85
91
  "桌面通知": "Desktop notifications",
86
92
  "当前环境不支持桌面通知(需 HTTPS 或 localhost)。": "This environment does not support desktop notifications (HTTPS or localhost required).",
@@ -94,6 +100,14 @@ export default {
94
100
  "新值只对之后启动的运行生效,进行中的运行不追溯。": "New values apply only to runs started afterwards; runs already in progress are not affected.",
95
101
  "可升级": "Update available",
96
102
  // DSHBOTS-220: ui/modules copy
103
+ "(失败)": " (failed)",
104
+ "第 ${n} 轮开始": "Turn ${n} started",
105
+ "运行结束": "Run finished",
106
+ "运行结束(${label})": "Run finished (${label})",
107
+ "工具 ${name} 返回": "Tool ${name} returned",
108
+ "调用工具 ${name}": "Called tool ${name}",
109
+ "回复": "Reply",
110
+ "思考": "Thinking",
97
111
  "Bot 配置": "Bot settings",
98
112
  "、": ", ",
99
113
  "。": ".",
@@ -166,7 +180,6 @@ export default {
166
180
  "可用": "Available",
167
181
  "同时移除项目生产目录": "Also remove the project production directory",
168
182
  "名称": "Name",
169
- "回复": "Reply",
170
183
  "回滚": "Roll back",
171
184
  "团队": "Team",
172
185
  "团队级无需选择": "Not needed at team level",
@@ -195,8 +208,6 @@ export default {
195
208
  "尚未提供模型": "No model provided",
196
209
  "工作区路径": "Workspace path",
197
210
  "工具": "Tool",
198
- "工具 ${title} 返回": "Tool ${title} returned",
199
- "工具返回": "Tool result",
200
211
  "已停用": "Disabled",
201
212
  "已归档": "Archived",
202
213
  "已归档项目停止新运行,工作区文件保留。项目再开会恢复为进行中;移除追踪会清理本项目的管理数据。": "Archived projects stop new runs and keep workspace files. Reopening restores them to in progress; removing tracking cleans up this project's management data.",
@@ -205,7 +216,6 @@ export default {
205
216
  "归档项目": "Archive project",
206
217
  "当前生效": "Currently active",
207
218
  "待审": "Pending",
208
- "思考": "Thinking",
209
219
  "思考过程": "Thinking process",
210
220
  "总监": "Director",
211
221
  "总监优先": "Director first",
@@ -277,7 +287,6 @@ export default {
277
287
  "移除追踪 · 后果确认": "Remove tracking · consequences",
278
288
  "移除追踪 · 确认执行": "Remove tracking · confirm",
279
289
  "移除追踪后不能恢复,该 Bot 也不能再被修改或重新启用。": "Once tracking is removed it cannot be restored, and the Bot can no longer be modified or re-enabled.",
280
- "第": "Turn ",
281
290
  "管理员": "Administrator",
282
291
  "管理数据": "Management data",
283
292
  "紧急": "Urgent",
@@ -302,17 +311,13 @@ export default {
302
311
  "请先进入一个项目": "Open a project first",
303
312
  "请求": "Request",
304
313
  "读取思考过程失败": "Failed to read the thinking process",
305
- "调用工具": "Called tool",
306
- "调用工具 ${title}": "Called tool ${title}",
307
314
  "负责人": "Owner",
308
315
  "超出预算时项目会提示预算已用尽。成本预算与模型价格使用同一币种计价。": "When the budget is exceeded, the project warns that the budget is used up. Cost budgets and model prices use the same currency.",
309
- "轮": "round",
310
316
  "输入 Bot 名称「": "Enter Bot name \\\"",
311
317
  "输入项目名「": "Enter project name \\\"",
312
318
  "运行中": "Running",
313
319
  "运行总数": "Total runs",
314
320
  "运行次数": "Runs",
315
- "运行结束": "Run finished",
316
321
  "运行记录": "Run records",
317
322
  "运行记录、单聊消息、版本历史与专属工作区目录": "Run records, direct messages, version history, and dedicated workspace directory",
318
323
  "还没有密钥。": "No keys yet.",
@@ -49,7 +49,6 @@ export default {
49
49
  "task.time7d": "Last 7 days",
50
50
  "task.time30d": "Last 30 days",
51
51
  "task.timeAll": "All time",
52
- "task.sortLabel": "Task sort",
53
52
  "task.sortCreatedDesc": "Created new → old",
54
53
  "task.sortCreatedAsc": "Created old → new",
55
54
  "task.sortCompletedDesc": "Completed new → old",