dsh-team-bots 0.2.395 → 0.2.460

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 (72) hide show
  1. package/package.json +4 -1
  2. package/scripts/doctor.mjs +14 -3
  3. package/src/api.js +30 -3
  4. package/src/config.js +108 -0
  5. package/src/db-migrations.js +24 -0
  6. package/src/db.js +5 -0
  7. package/src/feishu/channel.js +702 -0
  8. package/src/feishu/commands.js +20 -0
  9. package/src/feishu/format.js +56 -0
  10. package/src/feishu/index.js +19 -0
  11. package/src/feishu/store.js +205 -0
  12. package/src/http.js +11 -5
  13. package/src/service.js +7 -0
  14. package/src/services/bots.js +42 -0
  15. package/src/services/chat.js +19 -10
  16. package/src/services/core.js +153 -8
  17. package/src/services/external-trigger-schema.js +61 -0
  18. package/src/services/feishu.js +181 -0
  19. package/src/services/github-source.js +157 -0
  20. package/src/services/memory.js +122 -34
  21. package/src/services/projects.js +2 -0
  22. package/src/services/reason-codes.js +63 -0
  23. package/src/services/review-watchdog.js +30 -8
  24. package/src/services/run-finish.js +33 -9
  25. package/src/services/runs.js +48 -7
  26. package/src/services/runtime/context-window.js +53 -0
  27. package/src/services/runtime/prompt.js +165 -139
  28. package/src/services/runtime/sandbox-policy.js +65 -0
  29. package/src/services/runtime/session-continuity.js +38 -0
  30. package/src/services/runtime/session.js +148 -4
  31. package/src/services/scheduler.js +9 -2
  32. package/src/services/system.js +51 -3
  33. package/src/services/task-dispatch.js +43 -4
  34. package/src/services/task-notify.js +13 -8
  35. package/src/services/tasks.js +12 -4
  36. package/src/services/wechat-trigger-schema.js +62 -0
  37. package/src/services/wechat.js +129 -19
  38. package/src/services/write-scopes.js +38 -0
  39. package/src/tools.js +13 -3
  40. package/src/wechat/channel.js +130 -26
  41. package/src/wechat/commands.js +13 -1
  42. package/src/wechat/store.js +69 -18
  43. package/ui/app.js +8 -3
  44. package/ui/i18n/en/chat.js +1 -0
  45. package/ui/i18n/en/nav.js +5 -0
  46. package/ui/i18n/en/settings.js +25 -5
  47. package/ui/i18n/en/tasks.js +12 -0
  48. package/ui/i18n/en/wechat.js +25 -3
  49. package/ui/i18n/zh/chat.js +1 -0
  50. package/ui/i18n/zh/nav.js +5 -0
  51. package/ui/i18n/zh/settings.js +25 -5
  52. package/ui/i18n/zh/tasks.js +12 -0
  53. package/ui/i18n/zh/wechat.js +25 -3
  54. package/ui/modules/api.js +23 -1
  55. package/ui/modules/cards.js +15 -0
  56. package/ui/modules/chat.js +43 -2
  57. package/ui/modules/dom-morph.js +14 -7
  58. package/ui/modules/events-board.js +73 -23
  59. package/ui/modules/events-click.js +16 -0
  60. package/ui/modules/file-preview.js +89 -0
  61. package/ui/modules/global-pages.js +138 -10
  62. package/ui/modules/modal-forms.js +8 -9
  63. package/ui/modules/modal-layer.js +2 -0
  64. package/ui/modules/settings.js +51 -9
  65. package/ui/modules/state.js +2 -0
  66. package/ui/modules/tasks.js +20 -0
  67. package/ui/modules/util.js +39 -0
  68. package/ui/styles/base.css +13 -13
  69. package/ui/styles/chat-cards.css +28 -0
  70. package/ui/styles/frame.css +27 -3
  71. package/ui/styles/global-config.css +28 -3
  72. package/ui/styles/surfaces.css +2 -0
@@ -40,7 +40,9 @@ export class WechatStore {
40
40
  created_at TEXT NOT NULL,
41
41
  sent_at TEXT,
42
42
  attempts INTEGER NOT NULL DEFAULT 0,
43
- gave_up_at TEXT
43
+ gave_up_at TEXT,
44
+ receipt_key TEXT,
45
+ last_error TEXT
44
46
  );
45
47
  CREATE TABLE IF NOT EXISTS peers (
46
48
  peer_id TEXT PRIMARY KEY,
@@ -51,6 +53,9 @@ export class WechatStore {
51
53
  `)
52
54
  await this.migrateOutboxColumns()
53
55
  await this.migrateChannelStateColumns()
56
+ // 幂等收据键(A3/DSHBOTS-323):同键只允许一行在库(存留期内重复推送被吸收)。
57
+ // 部分唯一索引:无键行(notify 未带 receiptKey 的旧调用形态)不参与约束。
58
+ this.db.exec('CREATE UNIQUE INDEX IF NOT EXISTS outbox_receipt_key_idx ON outbox(receipt_key) WHERE receipt_key IS NOT NULL')
54
59
  await this.secureFiles()
55
60
  return this
56
61
  }
@@ -69,8 +74,9 @@ export class WechatStore {
69
74
  }
70
75
 
71
76
  /**
72
- * 旧库补列迁移:outbox 引入重试上限(attempts)与废弃标记(gave_up_at)前的库缺这两列。
73
- * 幂等:列已存在则跳过;补列带默认值,旧行语义等价于「未重试过、未废弃」。
77
+ * 旧库补列迁移:outbox 引入重试上限(attempts)与废弃标记(gave_up_at)前的库缺这两列;
78
+ * 幂等收据键(A3/DSHBOTS-323)与最近失败原因(last_error)同批补齐。
79
+ * 幂等:列已存在则跳过;补列带默认值,旧行语义等价于「未重试过、未废弃、无收据键」。
74
80
  */
75
81
  async migrateOutboxColumns() {
76
82
  const columns = new Set(
@@ -82,6 +88,12 @@ export class WechatStore {
82
88
  if (!columns.has('gave_up_at')) {
83
89
  this.db.exec('ALTER TABLE outbox ADD COLUMN gave_up_at TEXT')
84
90
  }
91
+ if (!columns.has('receipt_key')) {
92
+ this.db.exec('ALTER TABLE outbox ADD COLUMN receipt_key TEXT')
93
+ }
94
+ if (!columns.has('last_error')) {
95
+ this.db.exec('ALTER TABLE outbox ADD COLUMN last_error TEXT')
96
+ }
85
97
  }
86
98
 
87
99
  /** 库文件与 WAL/SHM 侧文件都收紧到 0600(新建与已存在都检查,过宽则收紧)。 */
@@ -169,13 +181,46 @@ export class WechatStore {
169
181
  this.db.prepare('DELETE FROM outbox').run()
170
182
  }
171
183
 
172
- enqueue(text) {
184
+ /**
185
+ * 入队推送(A3/DSHBOTS-323):带 receiptKey 时做幂等吸收——同键在存留期内只入队一次
186
+ * (先查后插,单进程无并发入队者;部分唯一索引兜底路径性竞态,竞态冲突由调用方 catch)。
187
+ * 返回 'enqueued' | 'duplicate' | 'skipped',调用方据此留痕;不带键的旧形态行为不变。
188
+ */
189
+ enqueue(text, receiptKey = null) {
173
190
  const body = String(text ?? '').trim()
174
- if (!body) return false
191
+ if (!body) return 'skipped'
192
+ const key = receiptKey ? String(receiptKey) : null
193
+ if (!key) {
194
+ this.db.prepare(
195
+ 'INSERT INTO outbox (text, created_at) VALUES (?, ?)',
196
+ ).run(body, nowIso())
197
+ return 'enqueued'
198
+ }
199
+ const existing = this.db.prepare('SELECT id FROM outbox WHERE receipt_key = ?').get(key)
200
+ if (existing) return 'duplicate'
175
201
  this.db.prepare(
176
- 'INSERT INTO outbox (text, created_at) VALUES (?, ?)',
177
- ).run(body, nowIso())
178
- return true
202
+ 'INSERT INTO outbox (text, created_at, receipt_key) VALUES (?, ?, ?)',
203
+ ).run(body, nowIso(), key)
204
+ return 'enqueued'
205
+ }
206
+
207
+ /** 按 receipt_key 查收据终态(A3/DSHBOTS-323):sent(已发送)/ gone(已废弃)/ pending(待发)。 */
208
+ receiptStates(keys) {
209
+ const list = (Array.isArray(keys) ? keys : []).map(key => String(key)).filter(Boolean)
210
+ if (!list.length) return []
211
+ const placeholders = list.map(() => '?').join(', ')
212
+ return this.db.prepare(
213
+ `SELECT receipt_key, text, sent_at, gave_up_at, attempts, last_error, created_at
214
+ FROM outbox WHERE receipt_key IN (${placeholders}) ORDER BY id DESC`,
215
+ ).all(...list)
216
+ }
217
+
218
+ /** 近期收据流水(A3/DSHBOTS-323):带键条目按入队倒序,供运维视图追责/回放。 */
219
+ receipts(limit = 50) {
220
+ return this.db.prepare(
221
+ `SELECT receipt_key, text, sent_at, gave_up_at, attempts, last_error, created_at
222
+ FROM outbox WHERE receipt_key IS NOT NULL ORDER BY id DESC LIMIT ?`,
223
+ ).all(Math.max(1, Math.min(200, Number(limit) || 50)))
179
224
  }
180
225
 
181
226
  pendingOutbox(limit = 20) {
@@ -191,25 +236,31 @@ export class WechatStore {
191
236
  for (const id of ids) statement.run(at, id)
192
237
  }
193
238
 
194
- /** 记一次发送失败,返回该条累计尝试次数(含本次;持久化,重启不重置)。 */
195
- markAttempt(id) {
239
+ /** 记一次发送失败(可重试),返回该条累计尝试次数(含本次;持久化,重启不重置)。
240
+ * last_error 存最近一次失败原因(A3/DSHBOTS-323:废弃后可解释「为什么没收到」。 */
241
+ markAttempt(id, error = '') {
196
242
  const result = this.db.prepare(
197
- 'UPDATE outbox SET attempts = attempts + 1 WHERE id = ? AND sent_at IS NULL AND gave_up_at IS NULL',
198
- ).run(id)
243
+ "UPDATE outbox SET attempts = attempts + 1, last_error = ? WHERE id = ? AND sent_at IS NULL AND gave_up_at IS NULL",
244
+ ).run(String(error ?? '').slice(0, 500), id)
199
245
  if (!Number(result?.changes ?? 0)) return null
200
246
  const row = this.db.prepare('SELECT attempts FROM outbox WHERE id = ?').get(id)
201
247
  return Number(row?.attempts ?? 0)
202
248
  }
203
249
 
204
- /** 废弃指定待发条目:仍视为未发送,但永久不再补发(重试超限或不可重试失败)。 */
205
- giveUp(ids) {
250
+ /** 废弃指定待发条目:仍视为未发送,但永久不再补发(重试超限或不可重试失败)。
251
+ * 可带失败原因落 last_error(不带时保留既有原因,如链接重建的批量作废)。 */
252
+ giveUp(ids, error = null) {
206
253
  if (!ids.length) return 0
207
- const statement = this.db.prepare(
208
- 'UPDATE outbox SET gave_up_at = ? WHERE id = ? AND sent_at IS NULL AND gave_up_at IS NULL',
209
- )
254
+ const statement = error
255
+ ? this.db.prepare(
256
+ 'UPDATE outbox SET gave_up_at = ?, last_error = ? WHERE id = ? AND sent_at IS NULL AND gave_up_at IS NULL',
257
+ )
258
+ : this.db.prepare(
259
+ 'UPDATE outbox SET gave_up_at = ? WHERE id = ? AND sent_at IS NULL AND gave_up_at IS NULL',
260
+ )
210
261
  const at = nowIso()
211
262
  let changed = 0
212
- for (const id of ids) changed += Number(statement.run(at, id)?.changes ?? 0)
263
+ for (const id of ids) changed += Number((error ? statement.run(at, String(error).slice(0, 500), id) : statement.run(at, id))?.changes ?? 0)
213
264
  return changed
214
265
  }
215
266
 
package/ui/app.js CHANGED
@@ -1,11 +1,11 @@
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, memorySource, toast, filePolicyOptions } from './modules/util.js'
3
+ import { applyUiScale, applyUiTheme, initColorScheme, 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'
7
7
  import { typingLingerRowsHtml, applyOptimisticTyping, pruneTypingLinger } from './modules/typing-linger.js'
8
- import { renderMessage, renderDirectMessagesCard, questionBannerView, approvalBannerView, toggleDesktopNotify, focusQuestionCard, focusApprovalCard, notifyNewApprovals, questionDraftOf, questionDraftSelection, questionSelectOption, notifyToggleView, notifyOn, approvalUrgent, approvalRemainingFrom, formatApprovalCountdown, approvalProgressRatio, questionRemainingFrom, questionUrgent, formatQuestionCountdown, questionProgressRatio } from './modules/cards.js'
8
+ import { renderMessage, renderDirectMessagesCard, questionBannerView, approvalBannerView, sidebarUserNeedsView, toggleDesktopNotify, focusQuestionCard, focusApprovalCard, notifyNewApprovals, questionDraftOf, questionDraftSelection, questionSelectOption, notifyToggleView, notifyOn, approvalUrgent, approvalRemainingFrom, formatApprovalCountdown, approvalProgressRatio, questionRemainingFrom, questionUrgent, formatQuestionCountdown, questionProgressRatio } from './modules/cards.js'
9
9
  import { renderUsage, usageMode, usageViewTitle, usageTotals } from './modules/usage.js'
10
10
  import { renderSettings, renderGlobal, renderUsageGlobal, renderUsageDomain, renderUsageSolo } from './modules/settings.js'
11
11
  import { renderChannel, renderSecretsPage } from './modules/global-pages.js'
@@ -35,6 +35,7 @@ const savedScale = (() => {
35
35
  try { return Number(localStorage.getItem(UI_SCALE_KEY)) || null } catch { return null }
36
36
  })()
37
37
  if (savedScale) applyUiScale(savedScale)
38
+ initColorScheme()
38
39
  state.theme = applyUiTheme((() => {
39
40
  try { return localStorage.getItem(UI_THEME_KEY) } catch { return null }
40
41
  })())
@@ -336,8 +337,9 @@ function renderShell() {
336
337
  </div>
337
338
  </div>
338
339
  <div class="sidebar-bottom">
340
+ ${sidebarUserNeedsView({ approvals: pendingApprovals.count, questions: pendingQuestions.count, proposals: pendingProposals() })}
339
341
  <button class="global-config ${state.view === 'bots-overview' ? 'active' : ''}" data-action="nav" data-view="bots-overview">
340
- ${icon('bot')}<span>${t('sidebar.botsOverview')}</span>${pendingProposals() > 0 ? `<span class="red-dot" title="${t('sidebar.pendingProposals')}"></span>` : ''}
342
+ ${icon('bot')}<span>${t('sidebar.botsOverview')}</span>
341
343
  </button>
342
344
  <button class="global-config ${state.view === 'usage' && state.usageMode === 'global' ? 'active' : ''}" data-action="nav" data-view="usage" data-usage-mode="global">
343
345
  ${icon('chart')}<span>${t('sidebar.usage')}</span>
@@ -350,6 +352,9 @@ function renderShell() {
350
352
  <a class="global-config dsh-official-link" href="/index.html" title="${t('sidebar.switchToDsh')}">
351
353
  ${icon('external')}<span>${t('sidebar.dshNative')}</span>
352
354
  </a>
355
+ <a class="global-config github-star-link" href="https://github.com/8kugames/dsh-team-bots" target="_blank" rel="noopener noreferrer">
356
+ ${icon('external')}<span>${t('sidebar.githubStar')}</span>
357
+ </a>
353
358
  </div>
354
359
  </aside>
355
360
  <main class="main">
@@ -6,6 +6,7 @@ export default {
6
6
  "chat.ownerUnset": "not set",
7
7
  "chat.memberOne": "${count} member",
8
8
  "chat.memberMany": "${count} members",
9
+ "chat.collapseLabel": "${count} system notices",
9
10
  "chat.emptyTitle": "No messages yet",
10
11
  "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
12
  "chat.typingQueued": "Queued for reply…",
package/ui/i18n/en/nav.js CHANGED
@@ -66,6 +66,10 @@ export default {
66
66
  "tree.archived": "Archived",
67
67
  "tree.archivedEmpty": "No archived projects.",
68
68
  // Sidebar bottom
69
+ "sidebar.bubbleApprovals": "Approvals",
70
+ "sidebar.bubbleQuestions": "Questions",
71
+ "sidebar.bubbleProposals": "Proposals",
72
+ "sidebar.bubbleAria": "Items needing your attention",
69
73
  "sidebar.botsOverview": "Bots overview",
70
74
  "sidebar.pendingProposals": "Proposals awaiting approval",
71
75
  "sidebar.usage": "Usage stats",
@@ -74,6 +78,7 @@ export default {
74
78
  "sidebar.globalConfig": "Global settings",
75
79
  "sidebar.switchToDsh": "Switch to the native DSH web UI",
76
80
  "sidebar.dshNative": "Native DSH UI",
81
+ "sidebar.githubStar": "Star on GitHub",
77
82
  // Topbar stats & actions
78
83
  "topbar.taskOne": "task",
79
84
  "topbar.taskMany": "tasks",
@@ -13,14 +13,34 @@ export default {
13
13
  "settings.codeHygieneHint": "Agreed maximum lines per source file (default 800, 0 = disable). After every run, the project workspace is scanned; any file exceeding 110% of the limit triggers a system directive in the group chat asking the director to schedule a split task.",
14
14
  // Global configuration page (DSHBOTS-204)
15
15
  "global.title": "Global configuration",
16
- "global.desc": "Team-wide settings that apply across projects, grouped as \"Preferences → Runtime → About\"; changes save in place on each card.",
16
+ "global.desc": "Team-wide settings that apply across projects, grouped as \"Preferences → Runtime → Team instructions → About\"; changes save in place on each card.",
17
17
  "global.navLabel": "Configuration sections",
18
18
  "global.groupPref": "Preferences",
19
19
  "global.groupRuntime": "Runtime & budget",
20
20
  "global.groupAbout": "About & system status",
21
+ // Team instruction segments (B1/DSHBOTS-324)
22
+ "global.groupPrompts": "Team instructions",
23
+ "global.groupPromptsDesc": "Four editable instruction blocks injected into bot prompts",
24
+ "global.promptSegmentsTitle": "Team instructions",
25
+ "global.promptSegmentsMeta": "Applies to new sessions after saving; running sessions are not interrupted",
26
+ "global.promptSegCustom": "Customized",
27
+ "global.promptSegDefaultChanged": "Default updated",
28
+ "global.promptSegReset": "Use default",
29
+ "global.promptSegCommunication": "Communication discipline",
30
+ "global.promptSegCommunicationHint": "When to speak in the group: only when someone must act, one concrete question at a time, cut every removable sentence",
31
+ "global.promptSegSubtask": "Subtask discipline",
32
+ "global.promptSegSubtaskHint": "How to file product-grade subtasks when one run cannot finish or closing conditions emerge",
33
+ "global.promptSegSplitting": "Splitting for speed",
34
+ "global.promptSegSplittingHint": "Criteria for splitting one card into parallel parts (subject to the 1200-char trio budget)",
35
+ "global.promptSegSelfcheck": "Delivery self-check",
36
+ "global.promptSegSelfcheckHint": "Delivery reports must carry reproducible verification evidence",
37
+ "global.promptSegmentsHint": "Instruction text ships with releases: when an upgrade changes a default, customized segments get a \"Default updated\" badge — keep your text or switch to the new default.",
38
+ "global.save": "Save",
39
+ "团队指令已保存,新会话生效": "Team instructions saved; applies to new sessions",
40
+ "已恢复默认指令": "Restored to default",
21
41
  "global.groupPrefDesc": "Affects only how things are displayed on this machine and takes effect immediately after saving.",
22
42
  "global.groupRuntimeDesc": "Behavior and cost ceilings for every project run: timeout abort, no-progress watchdog, budget and data retention.",
23
- "global.groupAboutDesc": "Local DSH paths, DSH and plugin versions, update check and message delivery queue.",
43
+ "global.groupAboutDesc": "Local DSH paths, DSH and plugin versions, and update check.",
24
44
  "global.cardUi": "Interface",
25
45
  "global.reset": "Reset",
26
46
  "global.uiScale": "Interface font size",
@@ -41,7 +61,7 @@ export default {
41
61
  "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).",
42
62
  "global.reviewIdleLabel": "Review idle threshold (minutes)",
43
63
  "global.reviewAutoCloseLabel": "Auto close reviews",
44
- "global.reviewIdleHint": "Review idle threshold = how long an in_review card may sit with no comments and no run activity before it counts as stalled (0–1440 minutes, 0 disables the watchdog); with auto close on, the three-tier rule engine closes cards programmatically: A verifiable delivery auto-accepts, B unresponsive deliverer auto-returns, C undecidable only reminds.",
64
+ "global.reviewIdleHint": "Review idle threshold = how long an in_review card may sit with no comments and no run activity before it counts as stalled (0–1440 minutes, 0 disables the watchdog); with auto close on, the three-tier rule engine closes cards programmatically: A verifiable delivery auto-accepts, B unresponsive deliverer auto-returns, C undecidable only reminds. Observe mode evaluates by the same rules and records on the task timeline without actually closing.",
45
65
  "global.runLimitsEnv": "Environment variable(s) ${names} are set explicitly; those items follow the environment and values saved on this page are ignored.",
46
66
  "global.saveRunLimits": "Save run limits",
47
67
  "global.cardOps": "System & operations",
@@ -49,6 +69,7 @@ export default {
49
69
  "global.memoryReview": "Automatic memory review",
50
70
  "global.on": "On",
51
71
  "global.off": "Off",
72
+ "global.observe": "Observe (record only)",
52
73
  "global.tokenBudget": "Global token budget",
53
74
  "global.costBudget": "Global cost budget",
54
75
  "global.unlimited": "Unlimited",
@@ -72,8 +93,6 @@ export default {
72
93
  "global.pluginCurrentVersion": "dsh-team-bots current version",
73
94
  "global.pluginLatestVersion": "dsh-team-bots latest version",
74
95
  "global.latest": "Up to date",
75
- "global.outboxQueue": "Delivery queue",
76
- "global.outboxFailed": "${count} messages failed to deliver",
77
96
  "channel.desc": "Binding and running status of external messaging channels.",
78
97
  "secrets.desc": "Encrypted storage of team- and project-level keys, plus approval of key requests raised by bots.",
79
98
  "secrets.navLabel": "Secrets sections",
@@ -266,6 +285,7 @@ export default {
266
285
  "查看输出": "View output",
267
286
  "标题": "Title",
268
287
  "模型或强度变更会在下一次运行时生效,不会中断当前运行。": "Model or effort changes take effect on the next run and do not interrupt the current one.",
288
+ "仅保留最近 10 个版本,更早版本已归档至文件。": "Only the latest 10 versions are kept; earlier ones are archived to a file.",
269
289
  "模型默认": "Model default",
270
290
  "此操作不可恢复。": "This action cannot be undone.",
271
291
  "没有子目录": "No subdirectories",
@@ -185,6 +185,10 @@ export default {
185
185
  "移出项目": "from the project",
186
186
  "空闲中": "Idle",
187
187
  "系统设置已保存": "System settings saved",
188
+ // Settings conflict 3-way merge (B2/DSHBOTS-325)
189
+ "配置已被他人修改,以下字段双方都改过、以最新保存为准,请复核:": "Settings were changed by someone else; these fields were edited on both sides and keep the latest saved values, please review: ",
190
+ "配置已被他人修改:你的改动未与对方冲突,已合并回表单,请重新保存": "Settings were changed by someone else; your edits do not conflict and were merged back into the form, please save again",
191
+ "配置已被他人修改,本次没有待保存的改动": "Settings were changed by someone else; there was nothing pending to save",
188
192
  "终端": "Terminal",
189
193
  "缓存写": "Cache write",
190
194
  "缓存读": "Cache read",
@@ -225,4 +229,12 @@ export default {
225
229
  // DSHBOTS-246: keys added by the full t() literal audit
226
230
  "(待办不含已取消)": " (todo excludes canceled)",
227
231
  ",按": "; ",
232
+ // DSHBOTS-345: deliverables declaration on the task card
233
+ "交付产物": "Deliverables",
234
+ "核验按路径直接读文件;交付报告只引用路径,不复述正文。": "Verification reads the files at these paths; the delivery report references paths only, never file contents.",
235
+ // DSHBOTS-347: in-app preview for text-like files
236
+ "文件预览": "File preview",
237
+ "文件较大,已截断,仅显示开头部分。": "Large file; showing a truncated head only.",
238
+ "新窗口打开": "Open in new window",
239
+ "加载文件失败:": "Failed to load file: ",
228
240
  }
@@ -7,17 +7,39 @@ export default {
7
7
  "channel.sectionWechatDesc": "After scanning to authorize, task updates are pushed to the admin on WeChat.",
8
8
  // DSHBOTS-220: ui/modules copy
9
9
  "二维码已生成,请用微信扫码": "QR code generated; scan it with WeChat",
10
- "在服务端启用 wechat 通道后,这里会出现扫码绑定入口。": "Once the wechat channel is enabled on the server, a QR binding entry will appear here.",
11
10
  "已退出微信绑定": "WeChat binding removed",
12
11
  "待扫码": "Waiting to scan",
13
12
  "待输验证码": "Waiting for verification code",
14
- "微信通道未启用": "WeChat channel not enabled",
15
13
  "微信验证码": "WeChat verification code",
16
14
  "扫码后手机上的验证码": "The verification code shown on your phone after scanning",
17
- "微信扫码授权 ClawBot;确认后自动绑定授权者为管理员,任务完成主动推送。": "Scan with WeChat to authorize ClawBot; the authorizer is bound as administrator and task completion is pushed proactively.",
18
15
  "扫码绑定": "Scan to bind",
19
16
  "提交验证码": "Submit code",
20
17
  "请输入微信验证码": "Enter the WeChat verification code",
21
18
  "退出绑定后需要重新扫码才能恢复推送。确认退出?": "After unbinding, you must scan the QR code again to restore push. Unbind now?",
22
19
  "验证码已提交": "Verification code submitted",
20
+ // WeChat channel enable toggle (DSHBOTS-334)
21
+ "通道已停用,启用后可扫码绑定管理员微信接收推送。": "Channel disabled; enable it to bind the admin's WeChat and receive pushes.",
22
+ "启用通道": "Enable channel",
23
+ "停用通道": "Disable channel",
24
+ "停用后微信通道立即断开且不再推送。确认停用?": "Disabling disconnects the WeChat channel immediately and stops pushes. Disable now?",
25
+ "微信通道已启用": "WeChat channel enabled",
26
+ "微信通道已停用": "WeChat channel disabled",
27
+ // Feishu channel (DSHBOTS-327/334): interactive status card (credentials configured in-card; secret never echoed)
28
+ "channel.sectionFeishu": "Feishu channel",
29
+ "channel.sectionFeishuDesc": "Connects automatically once the app credentials are configured; task updates are pushed to the admin on Feishu.",
30
+ "连接冲突": "Connection conflict",
31
+ "检测到连接冲突:同一 App ID 在多处登录(exceed_conn_limit),请先退出其他实例。": "Connection conflict: the same App ID is signed in elsewhere (exceed_conn_limit). Sign out the other instance first.",
32
+ "机器人 ID": "Bot ID",
33
+ "App ID": "App ID",
34
+ "App Secret": "App Secret",
35
+ "飞书应用的 App ID": "Feishu app App ID",
36
+ "保存后不再回显": "Never shown again after saving",
37
+ "保存并连接": "Save and connect",
38
+ "凭据已配置": "Credentials configured",
39
+ "服务端注入": "Injected server-side",
40
+ "清除凭据": "Clear credentials",
41
+ "请输入 App ID 与 App Secret": "Enter both App ID and App Secret",
42
+ "飞书凭据已保存,正在重连": "Feishu credentials saved; reconnecting",
43
+ "清除后飞书通道将断开并回到未绑定。确认清除?": "After clearing, the Feishu channel disconnects and returns to unbound. Clear now?",
44
+ "已清除飞书凭据,通道回到未绑定": "Feishu credentials cleared; channel is unbound",
23
45
  }
@@ -6,6 +6,7 @@ export default {
6
6
  "chat.ownerUnset": "未设置",
7
7
  "chat.memberOne": "${count} 个成员",
8
8
  "chat.memberMany": "${count} 个成员",
9
+ "chat.collapseLabel": "${count} 条系统通知",
9
10
  "chat.emptyTitle": "还没有人说话",
10
11
  "chat.emptyBody": "直接发言会交给总监 Bot;用 <strong>@Bot</strong> 点名成员,或输入 <strong>/task @Bot 任务标题</strong> 直接创建任务。",
11
12
  "chat.typingQueued": "排队等待回复…",
package/ui/i18n/zh/nav.js CHANGED
@@ -66,6 +66,10 @@ export default {
66
66
  "tree.archived": "已归档",
67
67
  "tree.archivedEmpty": "没有已归档项目。",
68
68
  // 侧栏底部
69
+ "sidebar.bubbleApprovals": "提权审批",
70
+ "sidebar.bubbleQuestions": "问答",
71
+ "sidebar.bubbleProposals": "进化审批",
72
+ "sidebar.bubbleAria": "需要你处理的事项",
69
73
  "sidebar.botsOverview": "总览bots",
70
74
  "sidebar.pendingProposals": "有待审批提案",
71
75
  "sidebar.usage": "用量统计",
@@ -74,6 +78,7 @@ export default {
74
78
  "sidebar.globalConfig": "全局配置",
75
79
  "sidebar.switchToDsh": "切换到 DSH 原生 Web 界面",
76
80
  "sidebar.dshNative": "DSH 原生界面",
81
+ "sidebar.githubStar": "Star on GitHub",
77
82
  // 顶栏统计与操作
78
83
  "topbar.taskOne": "任务",
79
84
  "topbar.taskMany": "任务",
@@ -13,14 +13,34 @@ export default {
13
13
  "settings.codeHygieneHint": "约定每个源码文件的最大行数(默认 800,0 = 关闭检查)。每轮运行结束扫描项目工作区,文件超过上限的 110% 即在群聊发系统指令,要求项目总监安排拆分卡。",
14
14
  // 全局配置页(DSHBOTS-204)
15
15
  "global.title": "全局配置",
16
- "global.desc": "跨项目生效的团队设置,按「偏好 → 运行 → 关于」分组,改动在卡片内就地保存。",
16
+ "global.desc": "跨项目生效的团队设置,按「偏好 → 运行 → 团队指令 → 关于」分组,改动在卡片内就地保存。",
17
17
  "global.navLabel": "配置分组导航",
18
18
  "global.groupPref": "偏好",
19
19
  "global.groupRuntime": "运行与预算",
20
20
  "global.groupAbout": "关于与系统状态",
21
+ // 团队指令段(B1/DSHBOTS-324)
22
+ "global.groupPrompts": "团队指令",
23
+ "global.groupPromptsDesc": "注入 bot 提示词的四段可编辑指令",
24
+ "global.promptSegmentsTitle": "团队指令",
25
+ "global.promptSegmentsMeta": "保存后新会话生效,进行中会话不中断",
26
+ "global.promptSegCustom": "已自定义",
27
+ "global.promptSegDefaultChanged": "默认内容已更新",
28
+ "global.promptSegReset": "恢复默认",
29
+ "global.promptSegCommunication": "通信纪律",
30
+ "global.promptSegCommunicationHint": "何时在群里说话:只在需人时外发、一次一个具体问题、发送前逐句裁剪",
31
+ "global.promptSegSubtask": "子任务纪律",
32
+ "global.promptSegSubtaskHint": "做不完或出现新收口条件时如何立产品级子卡",
33
+ "global.promptSegSplitting": "提速拆分",
34
+ "global.promptSegSplittingHint": "把一张卡拆成并行部件的判据(与并行段合计受 1200 字符预算约束)",
35
+ "global.promptSegSelfcheck": "交付自校",
36
+ "global.promptSegSelfcheckHint": "交付报告必须自带可复现验证证据",
37
+ "global.promptSegmentsHint": "指令正文随发版升级:升级改动默认文本后,自定义段会标「默认内容已更新」,可保留现有文本或恢复新默认。",
38
+ "global.save": "保存",
39
+ "团队指令已保存,新会话生效": "团队指令已保存,新会话生效",
40
+ "已恢复默认指令": "已恢复默认指令",
21
41
  "global.groupPrefDesc": "只影响这台机器上的显示方式,保存后立即生效。",
22
42
  "global.groupRuntimeDesc": "影响所有项目运行的行为与开销上限:超时中止、无进展看门狗、预算与数据保留。",
23
- "global.groupAboutDesc": "本机 DSH 路径、DSH 与插件版本、更新检查与消息投递队列。",
43
+ "global.groupAboutDesc": "本机 DSH 路径、DSH 与插件版本、更新检查。",
24
44
  "global.cardUi": "界面",
25
45
  "global.reset": "重置",
26
46
  "global.uiScale": "界面字号",
@@ -41,7 +61,7 @@ export default {
41
61
  "global.runLimitsHint1": "超时中止 = 单次运行的最长时长(1–360 分钟);无进展看门狗 = 运行多久没有任何输出即判定卡住(0–360 分钟,0 为关闭)。",
42
62
  "global.reviewIdleLabel": "验收滞留阈值(分钟)",
43
63
  "global.reviewAutoCloseLabel": "验收自动收口",
44
- "global.reviewIdleHint": "验收滞留阈值 = in_review 卡静置多久无评论且无运行活动即判定滞留(0–1440 分钟,0 为关闭);自动收口开启后按三档规则程序化收口:A 交付可验证自动通过、B 交付方无响应自动退回、C 不可判定仅提醒。",
64
+ "global.reviewIdleHint": "验收滞留阈值 = in_review 卡静置多久无评论且无运行活动即判定滞留(0–1440 分钟,0 为关闭);自动收口三档规则:A 交付可验证自动通过、B 交付方无响应自动退回、C 不可判定仅提醒;干跑模式按同一规则只判定并在任务时间线留痕,不实际收口。",
45
65
  "global.runLimitsEnv": "环境变量 ${names} 已显式设置,对应项以环境变量为准,页面保存值不生效。",
46
66
  "global.saveRunLimits": "保存运行时效",
47
67
  "global.cardOps": "系统与运维",
@@ -49,6 +69,7 @@ export default {
49
69
  "global.memoryReview": "记忆自动审查",
50
70
  "global.on": "开启",
51
71
  "global.off": "关闭",
72
+ "global.observe": "干跑(只判定留痕)",
52
73
  "global.tokenBudget": "全局 Token 预算",
53
74
  "global.costBudget": "全局成本预算",
54
75
  "global.unlimited": "不限制",
@@ -72,8 +93,6 @@ export default {
72
93
  "global.pluginCurrentVersion": "dsh-team-bots 当前版本",
73
94
  "global.pluginLatestVersion": "dsh-team-bots 最新版本",
74
95
  "global.latest": "最新",
75
- "global.outboxQueue": "投递队列",
76
- "global.outboxFailed": "${count} 条消息投递失败",
77
96
  "channel.desc": "外部消息通道的绑定与运行状态。",
78
97
  "secrets.desc": "团队与项目两级密钥的加密存储,以及 Bot 发起的密钥请求审批。",
79
98
  "secrets.navLabel": "密钥分组导航",
@@ -265,6 +284,7 @@ export default {
265
284
  "查看输出": "查看输出",
266
285
  "标题": "标题",
267
286
  "模型或强度变更会在下一次运行时生效,不会中断当前运行。": "模型或强度变更会在下一次运行时生效,不会中断当前运行。",
287
+ "仅保留最近 10 个版本,更早版本已归档至文件。": "仅保留最近 10 个版本,更早版本已归档至文件。",
268
288
  "模型默认": "模型默认",
269
289
  "此操作不可恢复。": "此操作不可恢复。",
270
290
  "没有子目录": "没有子目录",
@@ -185,6 +185,10 @@ export default {
185
185
  "移出项目": "移出项目",
186
186
  "空闲中": "空闲中",
187
187
  "系统设置已保存": "系统设置已保存",
188
+ // 设置冲突三方合并(B2/DSHBOTS-325)
189
+ "配置已被他人修改,以下字段双方都改过、以最新保存为准,请复核:": "配置已被他人修改,以下字段双方都改过、以最新保存为准,请复核:",
190
+ "配置已被他人修改:你的改动未与对方冲突,已合并回表单,请重新保存": "配置已被他人修改:你的改动未与对方冲突,已合并回表单,请重新保存",
191
+ "配置已被他人修改,本次没有待保存的改动": "配置已被他人修改,本次没有待保存的改动",
188
192
  "终端": "终端",
189
193
  "缓存写": "缓存写",
190
194
  "缓存读": "缓存读",
@@ -225,4 +229,12 @@ export default {
225
229
  // DSHBOTS-246:全量 t() 实参清点补齐(原文即键)
226
230
  "(待办不含已取消)": "(待办不含已取消)",
227
231
  ",按": ",按",
232
+ // DSHBOTS-345:任务卡交付物路径声明
233
+ "交付产物": "交付产物",
234
+ "核验按路径直接读文件;交付报告只引用路径,不复述正文。": "核验按路径直接读文件;交付报告只引用路径,不复述正文。",
235
+ // DSHBOTS-347:文本型文件应用内预览
236
+ "文件预览": "文件预览",
237
+ "文件较大,已截断,仅显示开头部分。": "文件较大,已截断,仅显示开头部分。",
238
+ "新窗口打开": "新窗口打开",
239
+ "加载文件失败:": "加载文件失败:",
228
240
  }
@@ -7,17 +7,39 @@ export default {
7
7
  "channel.sectionWechatDesc": "扫码授权后,任务动态会推送到管理员微信。",
8
8
  // DSHBOTS-220: ui/modules 文案(原文即键)
9
9
  "二维码已生成,请用微信扫码": "二维码已生成,请用微信扫码",
10
- "在服务端启用 wechat 通道后,这里会出现扫码绑定入口。": "在服务端启用 wechat 通道后,这里会出现扫码绑定入口。",
11
10
  "已退出微信绑定": "已退出微信绑定",
12
11
  "待扫码": "待扫码",
13
12
  "待输验证码": "待输验证码",
14
- "微信通道未启用": "微信通道未启用",
15
13
  "微信验证码": "微信验证码",
16
14
  "扫码后手机上的验证码": "扫码后手机上的验证码",
17
- "微信扫码授权 ClawBot;确认后自动绑定授权者为管理员,任务完成主动推送。": "微信扫码授权 ClawBot;确认后自动绑定授权者为管理员,任务完成主动推送。",
18
15
  "扫码绑定": "扫码绑定",
19
16
  "提交验证码": "提交验证码",
20
17
  "请输入微信验证码": "请输入微信验证码",
21
18
  "退出绑定后需要重新扫码才能恢复推送。确认退出?": "退出绑定后需要重新扫码才能恢复推送。确认退出?",
22
19
  "验证码已提交": "验证码已提交",
20
+ // 微信通道启停开关(DSHBOTS-334)
21
+ "通道已停用,启用后可扫码绑定管理员微信接收推送。": "通道已停用,启用后可扫码绑定管理员微信接收推送。",
22
+ "启用通道": "启用通道",
23
+ "停用通道": "停用通道",
24
+ "停用后微信通道立即断开且不再推送。确认停用?": "停用后微信通道立即断开且不再推送。确认停用?",
25
+ "微信通道已启用": "微信通道已启用",
26
+ "微信通道已停用": "微信通道已停用",
27
+ // 飞书通道(DSHBOTS-327/334):通道页可交互状态卡(凭据在卡内配置,secret 不回显)
28
+ "channel.sectionFeishu": "飞书通道",
29
+ "channel.sectionFeishuDesc": "配置应用凭据后自动连接,任务动态会推送到管理员飞书。",
30
+ "连接冲突": "连接冲突",
31
+ "检测到连接冲突:同一 App ID 在多处登录(exceed_conn_limit),请先退出其他实例。": "检测到连接冲突:同一 App ID 在多处登录(exceed_conn_limit),请先退出其他实例。",
32
+ "机器人 ID": "机器人 ID",
33
+ "App ID": "App ID",
34
+ "App Secret": "App Secret",
35
+ "飞书应用的 App ID": "飞书应用的 App ID",
36
+ "保存后不再回显": "保存后不再回显",
37
+ "保存并连接": "保存并连接",
38
+ "凭据已配置": "凭据已配置",
39
+ "服务端注入": "服务端注入",
40
+ "清除凭据": "清除凭据",
41
+ "请输入 App ID 与 App Secret": "请输入 App ID 与 App Secret",
42
+ "飞书凭据已保存,正在重连": "飞书凭据已保存,正在重连",
43
+ "清除后飞书通道将断开并回到未绑定。确认清除?": "清除后飞书通道将断开并回到未绑定。确认清除?",
44
+ "已清除飞书凭据,通道回到未绑定": "已清除飞书凭据,通道回到未绑定",
23
45
  }
package/ui/modules/api.js CHANGED
@@ -17,7 +17,12 @@ export async function api(action, payload = {}, { quiet = false } = {}) {
17
17
  const message = body?.error?.message ?? (response.status === 401 || response.status === 403
18
18
  ? t("登录状态已失效,请回到 DSH Web 登录后重新打开。")
19
19
  : t("请求失败,请稍后重试。"))
20
- throw new Error(message)
20
+ // B2/DSHBOTS-325:错误带码与状态(如 CONFLICT/409),调用方可按错误类别接管处理
21
+ // (静默 quiet 模式下自走合并/提示路径),其余调用方不受影响。
22
+ const error = new Error(message)
23
+ error.code = body?.error?.code ?? null
24
+ error.status = response.status
25
+ throw error
21
26
  }
22
27
  return body.data
23
28
  } catch (error ) {
@@ -28,6 +33,23 @@ export async function api(action, payload = {}, { quiet = false } = {}) {
28
33
  }
29
34
  }
30
35
 
36
+ // ===== settings-merge:start =====
37
+ // 设置草稿三方合并(B2/DSHBOTS-325):base=发送时服务端值、patch=用户提交值、
38
+ // serverNow=409 后重取的服务端值。用户没改的字段不参与;对方没改的字段保留用户草稿
39
+ // (贴回表单,编辑不丢);双方都改的字段以服务端为准,字段名进 conflicts 供提示复核。
40
+ export function mergeSettingsDraft(base, patch, serverNow) {
41
+ const merged = {}
42
+ const conflicts = []
43
+ for (const [key, value] of Object.entries(patch ?? {})) {
44
+ const baseValue = String(base?.[key] ?? '')
45
+ if (String(value) === baseValue) continue
46
+ if (String(serverNow?.[key] ?? '') === baseValue) merged[key] = value
47
+ else conflicts.push(key)
48
+ }
49
+ return { merged, conflicts }
50
+ }
51
+ // ===== settings-merge:end =====
52
+
31
53
  // IM 式已读:群聊可见时把水位推到最后一条消息,服务端据此算未读数。
32
54
  // 只在群聊视图上报;切到任务/设置等 tab 不算数。
33
55
  export async function markVisibleChatRead(data) {
@@ -558,4 +558,19 @@ function renderDirectMessagesCard() {
558
558
  }
559
559
 
560
560
 
561
+ // 用户需办气泡(DSHBOTS-339):侧栏「总览bots」上方,问答/提权审批/进化审批三类需用户
562
+ // 干预事项的常驻信号;全 0 返回空串(Quiet by default)。点击复用顶部审批/提问窄条展开
563
+ // 与进化页导航;总监处理项与运维项不在此弹(分属任务板/全局设置页/通道页)。
564
+ export function sidebarUserNeedsView({ approvals, questions, proposals }) {
565
+ const items = [
566
+ { count: Number(approvals ?? 0), label: t('sidebar.bubbleApprovals'), markup: 'data-action="toggle-approvals"' },
567
+ { count: Number(questions ?? 0), label: t('sidebar.bubbleQuestions'), markup: 'data-action="toggle-questions"' },
568
+ { count: Number(proposals ?? 0), label: t('sidebar.bubbleProposals'), markup: 'data-action="nav" data-view="evolution"' },
569
+ ].filter(item => item.count > 0)
570
+ if (items.length === 0) return ''
571
+ return `<div class="sidebar-bubbles" role="status" aria-label="${t('sidebar.bubbleAria')}">
572
+ ${items.map(item => `<button class="sidebar-bubble" ${item.markup}><span>${esc(item.label)}</span><span class="unread-badge">${item.count > 99 ? '99+' : item.count}</span></button>`).join('')}
573
+ </div>`
574
+ }
575
+
561
576
  export { renderMessage, renderDirectMessagesCard, questionBannerView, approvalBannerView, toggleDesktopNotify, focusQuestionCard, focusApprovalCard, notifyNewApprovals, questionDraftOf, questionDraftSelection, questionSelectOption, notifyToggleView, notifyOn, formatApprovalRemaining, approvalUrgent, approvalRemainingFrom, formatApprovalCountdown, approvalProgressRatio, questionRemainingFrom, questionUrgent, formatQuestionCountdown, questionProgressRatio }