dsh-chief 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Client half of dsh-chief — 「DSH 参谋长」 (DSH Chief v1.3.0)
2
+ * Client half of dsh-chief — 「DSH 参谋长」 (DSH Chief v1.4.0)
3
3
  * Auto-generated by `pkg/scripts/build-client.mjs` from `pkg/src/client/`.
4
4
  * Do not hand-edit this generated bundle; edit source modules under `pkg/src/client/` and rebuild.
5
5
  *
@@ -27,7 +27,7 @@ window.__ModuleLoader__.load({
27
27
 
28
28
  const BRAND_NAME = 'DSH 参谋长'
29
29
 
30
- const EXPECTED_BACKEND_BUILD = '1.3.0'
30
+ const EXPECTED_BACKEND_BUILD = '1.4.0'
31
31
 
32
32
  const CHIEF_PERMISSION_LABELS = {
33
33
  advisor: 'L0 · 顾问模式',
@@ -271,6 +271,18 @@ window.__ModuleLoader__.load({
271
271
  boundSelected: { allowed: [], forbidden: [], notes: [] },
272
272
  boundConsolidating: '',
273
273
  boundSubTab: 'rules',
274
+ boundCollapsedCols: {},
275
+ wallCollapsed: false,
276
+ wallSelectedIds: [],
277
+ wallMergeError: '',
278
+ qaCollapsedTurnIds: {},
279
+ chiefWorkFx: null,
280
+ guardWalls: [],
281
+ wallFormOpen: false,
282
+ wallDraftTitle: '',
283
+ wallDraftPattern: '',
284
+ wallDraftField: 'forbid_cmd',
285
+ wallDraftScope: 'global',
274
286
  // DSH Chief state
275
287
  chiefMeta: {
276
288
  paceMode: 'manual',
@@ -311,8 +323,10 @@ window.__ModuleLoader__.load({
311
323
  factsCount: 0,
312
324
  mailboxCount: 0,
313
325
  linkedPeersCount: 0,
326
+ activeWork: null,
314
327
  backendBuild: '',
315
328
  },
329
+ seenBackendWorkIds: {},
316
330
  staleBackendDetected: false,
317
331
  staleBackendDismissed: false,
318
332
  hostCompat: null,
@@ -336,6 +350,7 @@ window.__ModuleLoader__.load({
336
350
  mailOpenDrawers: {},
337
351
  secView: null,
338
352
  secBusy: false,
353
+ chiefQuickAction: '',
339
354
  secRegenerating: false,
340
355
  secSubTab: 'digest',
341
356
  secInput: '',
@@ -1191,6 +1206,39 @@ window.__ModuleLoader__.load({
1191
1206
  */
1192
1207
 
1193
1208
 
1209
+ function syncBackendActiveWork(activeWork) {
1210
+ const cleanWork = activeWork && activeWork.id ? activeWork : null
1211
+ const prevWork = store.chiefMeta && store.chiefMeta.activeWork
1212
+ if (cleanWork) {
1213
+ const seen = store.seenBackendWorkIds || {}
1214
+ if (!store.chiefWorkFx && cleanWork.tab && !seen[cleanWork.id]) {
1215
+ patch({
1216
+ tab: cleanWork.tab,
1217
+ ...(cleanWork.boundSubTab ? { boundSubTab: cleanWork.boundSubTab } : {}),
1218
+ seenBackendWorkIds: { ...seen, [cleanWork.id]: true },
1219
+ })
1220
+ if (cleanWork.tab === 'archive' && !store.archiveLoaded) void loadArchives(false)
1221
+ } else if (cleanWork.id && !seen[cleanWork.id]) {
1222
+ patch({ seenBackendWorkIds: { ...seen, [cleanWork.id]: true } })
1223
+ }
1224
+ if (!runtimeRefs.fastWorkPollTimer && typeof setTimeout === 'function') {
1225
+ runtimeRefs.fastWorkPollTimer = setTimeout(() => {
1226
+ runtimeRefs.fastWorkPollTimer = null
1227
+ if (store.chiefMeta && store.chiefMeta.activeWork) {
1228
+ void refresh()
1229
+ }
1230
+ }, 1200)
1231
+ }
1232
+ } else if (prevWork && prevWork.id) {
1233
+ if (runtimeRefs.fastWorkPollTimer) {
1234
+ clearTimeout(runtimeRefs.fastWorkPollTimer)
1235
+ runtimeRefs.fastWorkPollTimer = null
1236
+ }
1237
+ if (prevWork.tab === 'archive') void loadArchives(true)
1238
+ void loadChiefView(false)
1239
+ }
1240
+ }
1241
+
1194
1242
  function applySecView(viewData) {
1195
1243
  if (!viewData || typeof viewData !== 'object') return
1196
1244
  const pendingSuggestions = Array.isArray(viewData.suggestions)
@@ -1221,6 +1269,7 @@ window.__ModuleLoader__.load({
1221
1269
  const patchObj = {
1222
1270
  secView: viewData,
1223
1271
  ...(viewData.models ? { secModelsCatalog: viewData.models } : {}),
1272
+ ...(Array.isArray(viewData.guardWalls) ? { guardWalls: viewData.guardWalls } : {}),
1224
1273
  chiefMeta: {
1225
1274
  ...prevMeta,
1226
1275
  paceMode: cfg.paceMode || 'manual',
@@ -1246,6 +1295,7 @@ window.__ModuleLoader__.load({
1246
1295
  factsCount,
1247
1296
  mailboxCount,
1248
1297
  linkedPeersCount,
1298
+ activeWork: viewData.activeWork !== undefined ? viewData.activeWork : (prevMeta.activeWork || null),
1249
1299
  },
1250
1300
  }
1251
1301
  const nextHazard = viewData.runtimeGuard && viewData.runtimeGuard.hazardAlert
@@ -1254,7 +1304,9 @@ window.__ModuleLoader__.load({
1254
1304
  patchObj.seenHazardAlertIds = { ...seenHazards, [nextHazard.id]: true }
1255
1305
  patchObj.hazardHaltModal = nextHazard
1256
1306
  }
1307
+ const nextWorkVal = patchObj.chiefMeta.activeWork
1257
1308
  patch(patchObj)
1309
+ syncBackendActiveWork(nextWorkVal)
1258
1310
  }
1259
1311
 
1260
1312
  async function call(path, init) {
@@ -1275,6 +1327,7 @@ window.__ModuleLoader__.load({
1275
1327
  if (value && Array.isArray(value.subagents)) patch({ subagents: value.subagents })
1276
1328
  if (value && value.agentIdentity) patch({ agentIdentity: value.agentIdentity })
1277
1329
  if (value && value.boundaries) patch({ boundaries: value.boundaries })
1330
+ if (value && Array.isArray(value.guardWalls)) patch({ guardWalls: value.guardWalls })
1278
1331
  if (value && (value.chiefMeta || value.hostCompat)) {
1279
1332
  const patchObj = {}
1280
1333
  if (value.chiefMeta) {
@@ -1295,6 +1348,9 @@ window.__ModuleLoader__.load({
1295
1348
  const compat = value.hostCompat || (value.chiefMeta && value.chiefMeta.hostCompat)
1296
1349
  if (compat) patchObj.hostCompat = compat
1297
1350
  patch(patchObj)
1351
+ if (value.chiefMeta && Object.prototype.hasOwnProperty.call(value.chiefMeta, 'activeWork')) {
1352
+ syncBackendActiveWork(value.chiefMeta.activeWork)
1353
+ }
1298
1354
  }
1299
1355
  if (value && value.archiveMeta) {
1300
1356
  const nextMeta = { ...store.archiveMeta, ...value.archiveMeta }
@@ -1608,6 +1664,9 @@ window.__ModuleLoader__.load({
1608
1664
  } else {
1609
1665
  patch({ notice: `${isPinned ? '📌 已批准并定住全局' : '已批准注入本任务'}【${label}】` })
1610
1666
  }
1667
+ } else if (sug.kind === 'guard_wall') {
1668
+ const applied = value && value.wallApplied
1669
+ patch({ notice: '🧱 已落锁物理驻墙:' + ((applied && applied.title) || sug.title || '') })
1611
1670
  } else if (sug.kind === 'advice') {
1612
1671
  patch({ notice: '💡 已采纳参谋长建议并递交 → @' + (sug.targetLabel || sug.target || '主对话') })
1613
1672
  } else {
@@ -1625,35 +1684,44 @@ window.__ModuleLoader__.load({
1625
1684
  }
1626
1685
 
1627
1686
  async function executePendingSuggestions(opts = {}) {
1628
- patch({ secBusy: true, error: '' })
1629
- try {
1630
- const value = await call('chief/suggestion', {
1631
- method: 'POST',
1632
- headers: { 'content-type': 'application/json' },
1633
- body: JSON.stringify({
1634
- session: store.sessionId,
1635
- decision: 'execute_batch',
1636
- batch: true,
1637
- ...(Array.isArray(opts.ids) && opts.ids.length ? { ids: opts.ids } : {}),
1638
- ...(typeof opts.includeGoalApproval === 'boolean' ? { includeGoalApproval: opts.includeGoalApproval } : {}),
1639
- ...(typeof opts.pinGlobalDefault === 'boolean' ? { pinGlobalDefault: opts.pinGlobalDefault } : {}),
1640
- }),
1641
- })
1642
- const execCount = Number(value && value.executedCount) || 0
1643
- const blockedCount = Number(value && value.blockedCount) || 0
1644
- const skippedGoals = Number(value && value.skippedGoalCount) || 0
1645
- const parts = [`✓ 已执行 ${execCount} 项参谋建议`]
1646
- if (blockedCount > 0) parts.push(`拦截 ${blockedCount} 项越界建议`)
1647
- if (skippedGoals > 0) parts.push(`保留 ${skippedGoals} 项结项请示单独拍板`)
1648
- patch({ notice: parts.join(' · ') })
1649
- void refresh()
1650
- return value
1651
- } catch (error) {
1652
- patch({ error: String((error && error.message) || error) })
1653
- return null
1654
- } finally {
1655
- patch({ secBusy: false })
1656
- }
1687
+ const allPending = (store.secView && Array.isArray(store.secView.suggestions))
1688
+ ? store.secView.suggestions.filter(s => s && s.status === 'pending')
1689
+ : []
1690
+ const targetList = (Array.isArray(opts.ids) && opts.ids.length)
1691
+ ? allPending.filter(s => opts.ids.includes(s.id))
1692
+ : allPending
1693
+ const fxSpec = resolveChiefSuggestionWorkFx(targetList)
1694
+ return await withChiefWorkFx({ ...fxSpec, minMs: 480 }, async () => {
1695
+ patch({ secBusy: true, error: '' })
1696
+ try {
1697
+ const value = await call('chief/suggestion', {
1698
+ method: 'POST',
1699
+ headers: { 'content-type': 'application/json' },
1700
+ body: JSON.stringify({
1701
+ session: store.sessionId,
1702
+ decision: 'execute_batch',
1703
+ batch: true,
1704
+ ...(Array.isArray(opts.ids) && opts.ids.length ? { ids: opts.ids } : {}),
1705
+ ...(typeof opts.includeGoalApproval === 'boolean' ? { includeGoalApproval: opts.includeGoalApproval } : {}),
1706
+ ...(typeof opts.pinGlobalDefault === 'boolean' ? { pinGlobalDefault: opts.pinGlobalDefault } : {}),
1707
+ }),
1708
+ })
1709
+ const execCount = Number(value && value.executedCount) || 0
1710
+ const blockedCount = Number(value && value.blockedCount) || 0
1711
+ const skippedGoals = Number(value && value.skippedGoalCount) || 0
1712
+ const parts = [`✓ 已执行 ${execCount} 项参谋建议`]
1713
+ if (blockedCount > 0) parts.push(`拦截 ${blockedCount} 项越界建议`)
1714
+ if (skippedGoals > 0) parts.push(`保留 ${skippedGoals} 项结项请示单独拍板`)
1715
+ patch({ notice: parts.join(' · ') })
1716
+ void refresh()
1717
+ return value
1718
+ } catch (error) {
1719
+ patch({ error: String((error && error.message) || error) })
1720
+ return null
1721
+ } finally {
1722
+ patch({ secBusy: false })
1723
+ }
1724
+ })
1657
1725
  }
1658
1726
 
1659
1727
  async function dismissPendingSuggestions(list = []) {
@@ -1682,38 +1750,43 @@ window.__ModuleLoader__.load({
1682
1750
  async function requestConsolidateBounds(field = '', items = []) {
1683
1751
  if (store.secBusy || store.boundConsolidating) return null
1684
1752
  const tag = field || 'all'
1685
- patch({ boundConsolidating: tag, secBusy: true, error: '' })
1686
- try {
1687
- const cleanItems = Array.isArray(items) ? items.filter(Boolean) : []
1688
- const value = await call('chief/consolidate-bounds', {
1689
- method: 'POST',
1690
- headers: { 'content-type': 'application/json' },
1691
- body: JSON.stringify({
1692
- session: store.sessionId,
1693
- field,
1694
- items: cleanItems,
1695
- }),
1696
- })
1697
- if (value && value.ok) {
1698
- const nextSel = { ...(store.boundSelected || { allowed: [], forbidden: [], notes: [] }) }
1699
- if (field && nextSel[field]) nextSel[field] = []
1700
- else {
1701
- nextSel.allowed = []
1702
- nextSel.forbidden = []
1703
- nextSel.notes = []
1753
+ return await withChiefWorkFx(
1754
+ { tone: 'bounds', tab: 'boundaries', boundSubTab: 'rules', label: '参谋长正在浓缩边界中...' },
1755
+ async () => {
1756
+ patch({ boundConsolidating: tag, secBusy: true, error: '' })
1757
+ try {
1758
+ const cleanItems = Array.isArray(items) ? items.filter(Boolean) : []
1759
+ const value = await call('chief/consolidate-bounds', {
1760
+ method: 'POST',
1761
+ headers: { 'content-type': 'application/json' },
1762
+ body: JSON.stringify({
1763
+ session: store.sessionId,
1764
+ field,
1765
+ items: cleanItems,
1766
+ }),
1767
+ })
1768
+ if (value && value.ok) {
1769
+ const nextSel = { ...(store.boundSelected || { allowed: [], forbidden: [], notes: [] }) }
1770
+ if (field && nextSel[field]) nextSel[field] = []
1771
+ else {
1772
+ nextSel.allowed = []
1773
+ nextSel.forbidden = []
1774
+ nextSel.notes = []
1775
+ }
1776
+ patch({
1777
+ boundSelected: nextSel,
1778
+ notice: '🏛 参谋长已将零散边界浓缩为 1 条,请在上方请示卡拍板',
1779
+ })
1780
+ }
1781
+ return value
1782
+ } catch (error) {
1783
+ patch({ error: String((error && error.message) || error) })
1784
+ return null
1785
+ } finally {
1786
+ patch({ boundConsolidating: '', secBusy: false })
1704
1787
  }
1705
- patch({
1706
- boundSelected: nextSel,
1707
- notice: '🏛 参谋长已将零散边界浓缩为 1 条,请在上方请示卡拍板',
1708
- })
1709
- }
1710
- return value
1711
- } catch (error) {
1712
- patch({ error: String((error && error.message) || error) })
1713
- return null
1714
- } finally {
1715
- patch({ boundConsolidating: '', secBusy: false })
1716
- }
1788
+ },
1789
+ )
1717
1790
  }
1718
1791
 
1719
1792
  function prefillSuggestion(sug) {
@@ -1778,68 +1851,201 @@ window.__ModuleLoader__.load({
1778
1851
  }
1779
1852
  }
1780
1853
 
1781
- async function submitChiefBar(overrideText = '') {
1854
+ function classifyChiefWorkFx(text, quickTag = '') {
1855
+ if (quickTag === 'craft_wall') {
1856
+ return { tone: 'wall', tab: 'boundaries', boundSubTab: 'rules', label: '参谋长正在手搓驻墙中...' }
1857
+ }
1858
+ if (quickTag === 'extract_bounds') {
1859
+ return { tone: 'bounds', tab: 'boundaries', boundSubTab: 'rules', label: '参谋长正在提炼边界中...' }
1860
+ }
1861
+ const clean = String(text || '').trim()
1862
+ const hits = []
1863
+ if (/手搓|驻墙|筑墙|物理墙|guard_?wall|wallProposals/i.test(clean)) {
1864
+ hits.push({ tone: 'wall', tab: 'boundaries', boundSubTab: 'rules', label: '参谋长正在手搓驻墙中...' })
1865
+ }
1866
+ if (/提炼.{0,4}边界|工作边界|红线|必做项|注意事项|boundProposals/i.test(clean)) {
1867
+ hits.push({ tone: 'bounds', tab: 'boundaries', boundSubTab: 'rules', label: '参谋长正在调配红线边界中...' })
1868
+ }
1869
+ if (/整理档案|档案柜|卷宗|归档|收纳入柜|桌面档案|抽屉|archive/i.test(clean)) {
1870
+ hits.push({ tone: 'archive', tab: 'archive', label: '参谋长正在整理档案中...' })
1871
+ }
1872
+ if (/任务看板|拆解任务|金字塔|子任务|graph\.plan/i.test(clean)) {
1873
+ hits.push({ tone: 'tasks', tab: 'tasks', label: '参谋长正在编排任务看板中...' })
1874
+ }
1875
+ if (/执行计划|规划步骤|交接单|handoff/i.test(clean)) {
1876
+ hits.push({ tone: 'tasks', tab: 'plan', label: '参谋长正在推演执行计划中...' })
1877
+ }
1878
+ if (/协同网络|跨窗|关联会话|子代理|广播/i.test(clean)) {
1879
+ hits.push({ tone: 'peers', tab: 'peers', label: '参谋长正在协调团队网络中...' })
1880
+ }
1881
+ if (hits.length === 1) return hits[0]
1882
+ if (hits.length >= 2) {
1883
+ const allBoundaries = hits.every(x => x.tab === 'boundaries')
1884
+ return {
1885
+ tone: 'neon',
1886
+ tab: allBoundaries ? 'boundaries' : (store.tab || 'chief'),
1887
+ ...(allBoundaries ? { boundSubTab: 'rules' } : {}),
1888
+ label: allBoundaries ? '参谋长正在手搓驻墙与边界中...' : '参谋长正在统筹操作参谋系统中...',
1889
+ }
1890
+ }
1891
+ return {
1892
+ tone: 'neon',
1893
+ tab: store.tab || 'chief',
1894
+ label: '参谋长正在推演研判中...',
1895
+ }
1896
+ }
1897
+
1898
+ function resolveChiefSuggestionWorkFx(suggestions = []) {
1899
+ const list = Array.isArray(suggestions) ? suggestions.filter(Boolean) : []
1900
+ if (!list.length) {
1901
+ return { tone: 'neon', tab: store.tab || 'chief', label: '参谋长正在统一落地参谋建议中...' }
1902
+ }
1903
+ const kinds = new Set(list.map(s => String(s.kind || '').trim()))
1904
+ if (kinds.size === 1 && kinds.has('guard_wall')) {
1905
+ return { tone: 'wall', tab: 'boundaries', boundSubTab: 'rules', label: '参谋长正在落锁物理驻墙中...' }
1906
+ }
1907
+ if (kinds.size === 1 && kinds.has('bound')) {
1908
+ return { tone: 'bounds', tab: 'boundaries', boundSubTab: 'rules', label: '参谋长正在注入红线边界中...' }
1909
+ }
1910
+ const allBoundsPage = [...kinds].every(k => k === 'guard_wall' || k === 'bound')
1911
+ return {
1912
+ tone: 'neon',
1913
+ tab: allBoundsPage ? 'boundaries' : (store.tab || 'chief'),
1914
+ ...(allBoundsPage ? { boundSubTab: 'rules' } : {}),
1915
+ label: allBoundsPage ? '参谋长正在同步落锁驻墙与边界中...' : '参谋长正在统一落地参谋建议中...',
1916
+ }
1917
+ }
1918
+
1919
+ async function withChiefWorkFx(fxSpec = {}, fn) {
1920
+ const spec = fxSpec && typeof fxSpec === 'object' ? fxSpec : {}
1921
+ const token = 'fx-' + Date.now() + '-' + Math.random().toString(36).slice(2, 6)
1922
+ const targetTab = spec.tab || store.tab || 'chief'
1923
+ const minMs = Number(spec.minMs) || 0
1924
+ const startedAt = Date.now()
1925
+ patch({
1926
+ ...(spec.tab ? { tab: spec.tab } : {}),
1927
+ ...(spec.boundSubTab ? { boundSubTab: spec.boundSubTab } : {}),
1928
+ chiefWorkFx: {
1929
+ token,
1930
+ tone: spec.tone || 'neon',
1931
+ tab: targetTab,
1932
+ label: spec.label || '参谋长正在工作中...',
1933
+ },
1934
+ })
1935
+ if (targetTab === 'archive' && !store.archiveLoaded) {
1936
+ void loadArchives(false)
1937
+ }
1938
+ let hadError = false
1939
+ try {
1940
+ return await fn()
1941
+ } catch (err) {
1942
+ hadError = true
1943
+ throw err
1944
+ } finally {
1945
+ if (!hadError && minMs > 0 && typeof window !== 'undefined') {
1946
+ const waitMs = minMs - (Date.now() - startedAt)
1947
+ if (waitMs > 24) {
1948
+ await new Promise(resolve => setTimeout(resolve, waitMs))
1949
+ }
1950
+ }
1951
+ if (store.chiefWorkFx && store.chiefWorkFx.token === token) {
1952
+ patch({ chiefWorkFx: null })
1953
+ }
1954
+ }
1955
+ }
1956
+
1957
+ async function submitChiefBar(overrideText = '', quickTag = '') {
1782
1958
  const text = String(overrideText || store.secInput || '').trim()
1783
1959
  const imgs = overrideText ? [] : (Array.isArray(store.secImages) ? store.secImages : [])
1784
1960
  if ((!text && !imgs.length) || store.secBusy) return
1785
1961
  const target = overrideText ? 'auto' : (store.secTarget || 'auto')
1786
1962
  const mode = store.secMode || 'steer'
1787
- patch({ secBusy: true, ...(overrideText ? {} : { secInput: '', secImages: [] }), error: '' })
1788
- try {
1789
- const value = await call('chief/ask', {
1790
- method: 'POST',
1791
- headers: { 'content-type': 'application/json' },
1792
- body: JSON.stringify({
1793
- session: store.sessionId,
1794
- text,
1795
- target,
1796
- mode,
1797
- images: imgs.map(({ name, mediaType, data }) => ({ name, mediaType, data })),
1798
- }),
1963
+ const fxSpec = classifyChiefWorkFx(text, quickTag)
1964
+ await withChiefWorkFx(fxSpec, async () => {
1965
+ patch({
1966
+ secBusy: true,
1967
+ chiefQuickAction: quickTag || '',
1968
+ ...(overrideText ? {} : { secInput: '', secImages: [] }),
1969
+ error: '',
1799
1970
  })
1800
- if (value) {
1801
- const actions = []
1802
- const seenActions = new Set()
1803
- const pushAction = (label) => {
1804
- const clean = typeof label === 'string' ? label.trim() : ''
1805
- if (!clean || seenActions.has(clean)) return
1806
- seenActions.add(clean)
1807
- actions.push(clean)
1808
- }
1809
- for (const b of (value.actionBadges || [])) pushAction(b)
1810
- for (const r of (value.relays || [])) {
1811
- if (r && r.ok) pushAction('→ ' + (r.target || target))
1812
- }
1813
- for (const b of (value.boardOps || [])) pushAction(b)
1814
- for (const a of (value.archiveOps || [])) pushAction(a)
1815
- for (const n of (value.networkOps || [])) pushAction(n)
1816
- for (const m of (value.memoryChanges || [])) {
1817
- if (m && m.text) pushAction((m.op === 'remove' ? '移除:' : '记入:') + clampTitle(m.text, 14))
1818
- }
1819
- for (const bp of (value.boundProposals || [])) {
1820
- if (bp && bp.draftText) pushAction('呈批边界:' + clampTitle(bp.draftText, 12))
1971
+ try {
1972
+ const value = await call('chief/ask', {
1973
+ method: 'POST',
1974
+ headers: { 'content-type': 'application/json' },
1975
+ body: JSON.stringify({
1976
+ session: store.sessionId,
1977
+ text,
1978
+ target,
1979
+ mode,
1980
+ images: imgs.map(({ name, mediaType, data }) => ({ name, mediaType, data })),
1981
+ }),
1982
+ })
1983
+ if (value) {
1984
+ const actions = []
1985
+ const seenActions = new Set()
1986
+ const pushAction = (label) => {
1987
+ const clean = typeof label === 'string' ? label.trim() : ''
1988
+ if (!clean || seenActions.has(clean)) return
1989
+ seenActions.add(clean)
1990
+ actions.push(clean)
1991
+ }
1992
+ for (const b of (value.actionBadges || [])) pushAction(b)
1993
+ for (const r of (value.relays || [])) {
1994
+ if (r && r.ok) pushAction('→ ' + (r.target || target))
1995
+ }
1996
+ for (const b of (value.boardOps || [])) pushAction(b)
1997
+ for (const a of (value.archiveOps || [])) pushAction(a)
1998
+ for (const n of (value.networkOps || [])) pushAction(n)
1999
+ for (const m of (value.memoryChanges || [])) {
2000
+ if (m && m.text) pushAction((m.op === 'remove' ? '移除:' : '记入:') + clampTitle(m.text, 14))
2001
+ }
2002
+ for (const wp of (value.wallProposals || [])) {
2003
+ if (wp && wp.title) pushAction('呈批驻墙:' + clampTitle(wp.title, 14))
2004
+ }
2005
+ for (const bp of (value.boundProposals || [])) {
2006
+ if (bp && bp.draftText) pushAction('呈批边界:' + clampTitle(bp.draftText, 12))
2007
+ }
2008
+ if (value.view) applySecView(value.view)
2009
+ const createdSugCount = (Array.isArray(value.wallProposals) ? value.wallProposals.length : 0)
2010
+ + (Array.isArray(value.boundProposals) ? value.boundProposals.length : 0)
2011
+ const autoDestTab = createdSugCount > 0
2012
+ ? 'boundaries'
2013
+ : ((Array.isArray(value.archiveOps) && value.archiveOps.length > 0 && fxSpec.tab === 'chief') ? 'archive' : '')
2014
+ patch({
2015
+ ...(autoDestTab ? { tab: autoDestTab, ...(autoDestTab === 'boundaries' ? { boundSubTab: 'rules' } : {}) } : {}),
2016
+ secLatestReply: {
2017
+ text: value.reply || '- 【已处理】已按吩咐执行完毕。',
2018
+ actions,
2019
+ at: Date.now(),
2020
+ },
2021
+ ...(createdSugCount > 0
2022
+ ? { notice: `✨ 已生成 ${createdSugCount} 项待确认提案,请点面板顶部「▶ 执行建议」一键落锁生效` }
2023
+ : {}),
2024
+ })
2025
+ if (createdSugCount > 0 && runtimeRefs.panelEl) {
2026
+ try {
2027
+ const scroller = runtimeRefs.panelEl.querySelector('.dnb-body')
2028
+ if (scroller && typeof scroller.scrollTo === 'function') {
2029
+ scroller.scrollTo({ top: 0, behavior: 'smooth' })
2030
+ } else if (typeof runtimeRefs.panelEl.scrollTo === 'function') {
2031
+ runtimeRefs.panelEl.scrollTo({ top: 0, behavior: 'smooth' })
2032
+ }
2033
+ } catch {}
2034
+ }
2035
+ if (Array.isArray(value.archiveOps) && value.archiveOps.length > 0) {
2036
+ void loadArchives(true)
2037
+ }
2038
+ if (actions.length) void refresh()
1821
2039
  }
1822
- if (value.view) applySecView(value.view)
2040
+ } catch (error) {
1823
2041
  patch({
1824
- secLatestReply: {
1825
- text: value.reply || '- 【已处理】已按吩咐执行完毕。',
1826
- actions,
1827
- at: Date.now(),
1828
- },
2042
+ ...(overrideText ? {} : { secInput: text, secImages: imgs }),
2043
+ error: String((error && error.message) || error),
1829
2044
  })
1830
- if (Array.isArray(value.archiveOps) && value.archiveOps.length > 0) {
1831
- void loadArchives(true)
1832
- }
1833
- if (actions.length) void refresh()
2045
+ } finally {
2046
+ patch({ secBusy: false, chiefQuickAction: '' })
1834
2047
  }
1835
- } catch (error) {
1836
- patch({
1837
- ...(overrideText ? {} : { secInput: text, secImages: imgs }),
1838
- error: String((error && error.message) || error),
1839
- })
1840
- } finally {
1841
- patch({ secBusy: false })
1842
- }
2048
+ })
1843
2049
  }
1844
2050
 
1845
2051
  function applyArchiveHeaders(payload, invalidateIds = null, requestedScope = '') {
@@ -2146,114 +2352,129 @@ window.__ModuleLoader__.load({
2146
2352
 
2147
2353
  async function requestOrganizeArchives(opts = {}) {
2148
2354
  if (store.archiveOrganizing) return null
2149
- patch({ archiveOrganizing: true, error: '' })
2150
- try {
2151
- const vaultScope = opts.vaultScope || (store.archiveTabScope === 'global' ? 'global' : 'session')
2152
- const value = await call('archives/organize', {
2153
- method: 'POST',
2154
- headers: { 'content-type': 'application/json' },
2155
- body: JSON.stringify({
2156
- session: store.sessionId || sessionIdFromUrl(),
2157
- vaultScope,
2158
- cabinetId: vaultScope === 'global' ? '' : (opts.cabinetId !== undefined ? opts.cabinetId : (store.archiveCabinetId || '')),
2159
- ids: Array.isArray(opts.ids) ? opts.ids : [],
2160
- folder: opts.folder || '',
2161
- scope: opts.scope || store.archiveOrganizeScope || 'unorganized',
2162
- instruction: opts.instruction !== undefined ? opts.instruction : (store.archiveOrganizePrompt || ''),
2163
- }),
2164
- })
2165
- if (value && value.ok) {
2166
- const openIds = Object.keys(store.archiveOpenFiles || {}).filter(k => store.archiveOpenFiles[k])
2167
- const nextDetails = { ...(store.archiveDetails || {}) }
2168
- for (const k of openIds) delete nextDetails[k]
2169
- patch({
2170
- archiveDetails: nextDetails,
2171
- archiveOrganizeOpen: false,
2172
- archiveOrganizePrompt: '',
2173
- notice: value.updatedCount > 0
2174
- ? `✦ 参谋长已按层次整理收纳 ${value.updatedCount} 份工程卷宗(原文 100% 无损保留)`
2175
- : '✦ 当前卷宗已分门别类,无需重复拆整',
2176
- })
2177
- void loadArchives(true, '', vaultScope)
2178
- for (const k of openIds) {
2179
- void loadArchiveDetail(k, true, { scope: vaultScope })
2355
+ return await withChiefWorkFx(
2356
+ { tone: 'archive', tab: 'archive', label: '参谋长正在整理档案中...' },
2357
+ async () => {
2358
+ patch({ archiveOrganizing: true, error: '' })
2359
+ try {
2360
+ const vaultScope = opts.vaultScope || (store.archiveTabScope === 'global' ? 'global' : 'session')
2361
+ const value = await call('archives/organize', {
2362
+ method: 'POST',
2363
+ headers: { 'content-type': 'application/json' },
2364
+ body: JSON.stringify({
2365
+ session: store.sessionId || sessionIdFromUrl(),
2366
+ vaultScope,
2367
+ cabinetId: vaultScope === 'global' ? '' : (opts.cabinetId !== undefined ? opts.cabinetId : (store.archiveCabinetId || '')),
2368
+ ids: Array.isArray(opts.ids) ? opts.ids : [],
2369
+ folder: opts.folder || '',
2370
+ scope: opts.scope || store.archiveOrganizeScope || 'unorganized',
2371
+ instruction: opts.instruction !== undefined ? opts.instruction : (store.archiveOrganizePrompt || ''),
2372
+ }),
2373
+ })
2374
+ if (value && value.ok) {
2375
+ const openIds = Object.keys(store.archiveOpenFiles || {}).filter(k => store.archiveOpenFiles[k])
2376
+ const nextDetails = { ...(store.archiveDetails || {}) }
2377
+ for (const k of openIds) delete nextDetails[k]
2378
+ patch({
2379
+ archiveDetails: nextDetails,
2380
+ archiveOrganizeOpen: false,
2381
+ archiveOrganizePrompt: '',
2382
+ notice: value.updatedCount > 0
2383
+ ? `✦ 参谋长已按层次整理收纳 ${value.updatedCount} 份工程卷宗(原文 100% 无损保留)`
2384
+ : '✦ 当前卷宗已分门别类,无需重复拆整',
2385
+ })
2386
+ void loadArchives(true, '', vaultScope)
2387
+ for (const k of openIds) {
2388
+ void loadArchiveDetail(k, true, { scope: vaultScope })
2389
+ }
2390
+ }
2391
+ return value
2392
+ } catch (error) {
2393
+ patch({ error: String((error && error.message) || error) })
2394
+ return null
2395
+ } finally {
2396
+ patch({ archiveOrganizing: false })
2180
2397
  }
2181
- }
2182
- return value
2183
- } catch (error) {
2184
- patch({ error: String((error && error.message) || error) })
2185
- return null
2186
- } finally {
2187
- patch({ archiveOrganizing: false })
2188
- }
2398
+ },
2399
+ )
2189
2400
  }
2190
2401
 
2191
2402
  async function harvestArchivesApi(focusHint = '', opts = {}) {
2192
2403
  if (store.archiveHarvesting) return null
2193
- patch({ archiveHarvesting: true, error: '' })
2194
- try {
2195
- const vaultScope = (opts && opts.vaultScope) || (store.archiveTabScope === 'global' ? 'global' : 'session')
2196
- const value = await call('archives/harvest', {
2197
- method: 'POST',
2198
- headers: { 'content-type': 'application/json' },
2199
- body: JSON.stringify({
2200
- session: store.sessionId || sessionIdFromUrl(),
2201
- vaultScope,
2202
- cabinetId: (opts && opts.cabinetId !== undefined) ? opts.cabinetId : (store.archiveCabinetId || ''),
2203
- focusHint,
2204
- }),
2205
- })
2206
- if (value && value.ok) {
2207
- patch({
2208
- notice: value.count > 0
2209
- ? `📥 已抢救 ${value.count} 份本轮对话工程细节入柜(防压缩失忆)`
2210
- : '📥 当前对话暂无新增重要工程细节',
2211
- })
2212
- void loadArchives(true)
2213
- }
2214
- return value
2215
- } catch (error) {
2216
- patch({ error: String((error && error.message) || error) })
2217
- return null
2218
- } finally {
2219
- patch({ archiveHarvesting: false })
2220
- }
2404
+ return await withChiefWorkFx(
2405
+ { tone: 'archive', tab: 'archive', label: '参谋长正在抢救归档中...' },
2406
+ async () => {
2407
+ patch({ archiveHarvesting: true, error: '' })
2408
+ try {
2409
+ const vaultScope = (opts && opts.vaultScope) || (store.archiveTabScope === 'global' ? 'global' : 'session')
2410
+ const value = await call('archives/harvest', {
2411
+ method: 'POST',
2412
+ headers: { 'content-type': 'application/json' },
2413
+ body: JSON.stringify({
2414
+ session: store.sessionId || sessionIdFromUrl(),
2415
+ vaultScope,
2416
+ cabinetId: (opts && opts.cabinetId !== undefined) ? opts.cabinetId : (store.archiveCabinetId || ''),
2417
+ focusHint,
2418
+ }),
2419
+ })
2420
+ if (value && value.ok) {
2421
+ patch({
2422
+ notice: value.count > 0
2423
+ ? `📥 已抢救 ${value.count} 份本轮对话工程细节入柜(防压缩失忆)`
2424
+ : '📥 当前对话暂无新增重要工程细节',
2425
+ })
2426
+ void loadArchives(true)
2427
+ }
2428
+ return value
2429
+ } catch (error) {
2430
+ patch({ error: String((error && error.message) || error) })
2431
+ return null
2432
+ } finally {
2433
+ patch({ archiveHarvesting: false })
2434
+ }
2435
+ },
2436
+ )
2221
2437
  }
2222
2438
 
2223
2439
  async function precipitateArchivesApi(opts = {}) {
2224
2440
  if (store.archivePrecipitating) return null
2225
- patch({ archivePrecipitating: true, error: '' })
2226
- try {
2227
- const vaultScope = opts.vaultScope || 'global'
2228
- const value = await call('archives/precipitate', {
2229
- method: 'POST',
2230
- headers: { 'content-type': 'application/json' },
2231
- body: JSON.stringify({
2232
- session: store.sessionId || sessionIdFromUrl(),
2233
- vaultScope,
2234
- op: opts.op || 'cabinet',
2235
- cabinetId: '',
2236
- folder: opts.folder || '',
2237
- ...(Array.isArray(opts.ids) && opts.ids.length > 0 ? { ids: opts.ids } : {}),
2238
- clearSource: Boolean(opts.clearSource),
2239
- }),
2240
- })
2241
- if (value && value.ok) {
2242
- patch({
2243
- precipitateModal: null,
2244
- notice: value.count > 0
2245
- ? `⏬ 已提炼 ${value.count} 条可复用经验封入冷库(默认 0 Token 隔离)`
2246
- : '⏬ 当前卷宗暂无更多可沉淀经验',
2247
- })
2248
- void loadArchives(true, '', vaultScope)
2249
- }
2250
- return value
2251
- } catch (error) {
2252
- patch({ error: String((error && error.message) || error) })
2253
- return null
2254
- } finally {
2255
- patch({ archivePrecipitating: false })
2256
- }
2441
+ return await withChiefWorkFx(
2442
+ { tone: 'archive', tab: 'archive', label: '参谋长正在沉淀经验入库中...' },
2443
+ async () => {
2444
+ patch({ archivePrecipitating: true, error: '' })
2445
+ try {
2446
+ const vaultScope = opts.vaultScope || 'global'
2447
+ const value = await call('archives/precipitate', {
2448
+ method: 'POST',
2449
+ headers: { 'content-type': 'application/json' },
2450
+ body: JSON.stringify({
2451
+ session: store.sessionId || sessionIdFromUrl(),
2452
+ vaultScope,
2453
+ op: opts.op || 'cabinet',
2454
+ cabinetId: '',
2455
+ folder: opts.folder || '',
2456
+ ...(Array.isArray(opts.ids) && opts.ids.length > 0 ? { ids: opts.ids } : {}),
2457
+ clearSource: Boolean(opts.clearSource),
2458
+ }),
2459
+ })
2460
+ if (value && value.ok) {
2461
+ patch({
2462
+ precipitateModal: null,
2463
+ notice: value.count > 0
2464
+ ? `⏬ 已提炼 ${value.count} 条可复用经验封入冷库(默认 0 Token 隔离)`
2465
+ : '⏬ 当前卷宗暂无更多可沉淀经验',
2466
+ })
2467
+ void loadArchives(true, '', vaultScope)
2468
+ }
2469
+ return value
2470
+ } catch (error) {
2471
+ patch({ error: String((error && error.message) || error) })
2472
+ return null
2473
+ } finally {
2474
+ patch({ archivePrecipitating: false })
2475
+ }
2476
+ },
2477
+ )
2257
2478
  }
2258
2479
 
2259
2480
  function toggleSelectArchive(id, vaultScope = 'session', title = '') {
@@ -2292,87 +2513,97 @@ window.__ModuleLoader__.load({
2292
2513
  if (store.relayArchivesBusy) return null
2293
2514
  const items = Array.isArray(modalState && modalState.items) ? modalState.items : []
2294
2515
  if (!items.length) return null
2295
- patch({ relayArchivesBusy: true, error: '' })
2296
- try {
2297
- const value = await call('chief/relay-archives', {
2298
- method: 'POST',
2299
- headers: { 'content-type': 'application/json' },
2300
- body: JSON.stringify({
2301
- session: store.sessionId || sessionIdFromUrl(),
2302
- cabinetId: store.archiveCabinetId || '',
2303
- items: items.map(it => ({
2304
- id: it.id,
2305
- scope: it.vaultScope || it.scope || 'session',
2306
- vaultScope: it.vaultScope || it.scope || 'session',
2307
- title: it.title || it.id,
2308
- })),
2309
- instruction: String((modalState && modalState.instruction) || '').trim(),
2310
- target: (modalState && modalState.target) || 'lead',
2311
- mode: (modalState && modalState.mode) || 'followup',
2312
- }),
2313
- })
2314
- if (value && value.ok) {
2315
- patch({
2316
- archiveRelayModal: null,
2317
- selectedArchiveMap: {},
2318
- notice: `📨 参谋长已带要求整合 ${items.length} 条档案并递交给 @${modalState.target === 'lead' || !modalState.target ? '主对话' : shortAgentName(modalState.target, true)}`,
2319
- })
2320
- void refresh()
2321
- }
2322
- return value
2323
- } catch (error) {
2324
- patch({ error: String((error && error.message) || error) })
2325
- return null
2326
- } finally {
2327
- patch({ relayArchivesBusy: false })
2328
- }
2516
+ return await withChiefWorkFx(
2517
+ { tone: 'archive', tab: 'archive', label: '参谋长正在整合递交档案中...' },
2518
+ async () => {
2519
+ patch({ relayArchivesBusy: true, error: '' })
2520
+ try {
2521
+ const value = await call('chief/relay-archives', {
2522
+ method: 'POST',
2523
+ headers: { 'content-type': 'application/json' },
2524
+ body: JSON.stringify({
2525
+ session: store.sessionId || sessionIdFromUrl(),
2526
+ cabinetId: store.archiveCabinetId || '',
2527
+ items: items.map(it => ({
2528
+ id: it.id,
2529
+ scope: it.vaultScope || it.scope || 'session',
2530
+ vaultScope: it.vaultScope || it.scope || 'session',
2531
+ title: it.title || it.id,
2532
+ })),
2533
+ instruction: String((modalState && modalState.instruction) || '').trim(),
2534
+ target: (modalState && modalState.target) || 'lead',
2535
+ mode: (modalState && modalState.mode) || 'followup',
2536
+ }),
2537
+ })
2538
+ if (value && value.ok) {
2539
+ patch({
2540
+ archiveRelayModal: null,
2541
+ selectedArchiveMap: {},
2542
+ notice: `📨 参谋长已带要求整合 ${items.length} 条档案并递交给 @${modalState.target === 'lead' || !modalState.target ? '主对话' : shortAgentName(modalState.target, true)}`,
2543
+ })
2544
+ void refresh()
2545
+ }
2546
+ return value
2547
+ } catch (error) {
2548
+ patch({ error: String((error && error.message) || error) })
2549
+ return null
2550
+ } finally {
2551
+ patch({ relayArchivesBusy: false })
2552
+ }
2553
+ },
2554
+ )
2329
2555
  }
2330
2556
 
2331
2557
  async function distillToGlobalApi(modalState) {
2332
2558
  if (store.distillBusy) return null
2333
- patch({ distillBusy: true, error: '' })
2334
- try {
2335
- const ids = Array.isArray(modalState && modalState.ids) && modalState.ids.length > 0
2336
- ? modalState.ids
2337
- : null
2338
- const value = await call('archives/distill-to-global', {
2339
- method: 'POST',
2340
- headers: { 'content-type': 'application/json' },
2341
- body: JSON.stringify({
2342
- session: store.sessionId || sessionIdFromUrl(),
2343
- cabinetId: store.archiveCabinetId || '',
2344
- ids,
2345
- clearSource: Boolean(modalState && modalState.clearSource),
2346
- instruction: String((modalState && modalState.instruction) || '').trim(),
2347
- }),
2348
- })
2349
- if (value && value.ok) {
2350
- const nextPatch = {
2351
- distillGlobalModal: null,
2352
- selectedArchiveMap: {},
2353
- globalVaultLoaded: false,
2354
- notice: value.createdCount > 0
2355
- ? `✦ 已从本局提炼 ${value.createdCount} 份可复用工程档案存入「🌐 全局档案柜」`
2356
- : '✦ 当前本局暂无更多待提炼的新增可复用经验',
2357
- }
2358
- if (value.globalArchives && Array.isArray(value.globalArchives.items)) {
2359
- nextPatch.globalVaultItems = value.globalArchives.items
2360
- nextPatch.globalVaultLoaded = true
2361
- }
2362
- if (Array.isArray(value.deskItems)) {
2363
- nextPatch.archiveDeskItems = value.deskItems
2364
- nextPatch.archiveDeskLoaded = true
2559
+ return await withChiefWorkFx(
2560
+ { tone: 'archive', tab: 'archive', label: '参谋长正在提炼全局档案中...' },
2561
+ async () => {
2562
+ patch({ distillBusy: true, error: '' })
2563
+ try {
2564
+ const ids = Array.isArray(modalState && modalState.ids) && modalState.ids.length > 0
2565
+ ? modalState.ids
2566
+ : null
2567
+ const value = await call('archives/distill-to-global', {
2568
+ method: 'POST',
2569
+ headers: { 'content-type': 'application/json' },
2570
+ body: JSON.stringify({
2571
+ session: store.sessionId || sessionIdFromUrl(),
2572
+ cabinetId: store.archiveCabinetId || '',
2573
+ ids,
2574
+ clearSource: Boolean(modalState && modalState.clearSource),
2575
+ instruction: String((modalState && modalState.instruction) || '').trim(),
2576
+ }),
2577
+ })
2578
+ if (value && value.ok) {
2579
+ const nextPatch = {
2580
+ distillGlobalModal: null,
2581
+ selectedArchiveMap: {},
2582
+ globalVaultLoaded: false,
2583
+ notice: value.createdCount > 0
2584
+ ? `✦ 已从本局提炼 ${value.createdCount} 份可复用工程档案存入「🌐 全局档案柜」`
2585
+ : '✦ 当前本局暂无更多待提炼的新增可复用经验',
2586
+ }
2587
+ if (value.globalArchives && Array.isArray(value.globalArchives.items)) {
2588
+ nextPatch.globalVaultItems = value.globalArchives.items
2589
+ nextPatch.globalVaultLoaded = true
2590
+ }
2591
+ if (Array.isArray(value.deskItems)) {
2592
+ nextPatch.archiveDeskItems = value.deskItems
2593
+ nextPatch.archiveDeskLoaded = true
2594
+ }
2595
+ patch(nextPatch)
2596
+ if (ids && modalState && modalState.clearSource) void loadArchives(true, '', 'session')
2597
+ }
2598
+ return value
2599
+ } catch (error) {
2600
+ patch({ error: String((error && error.message) || error) })
2601
+ return null
2602
+ } finally {
2603
+ patch({ distillBusy: false })
2365
2604
  }
2366
- patch(nextPatch)
2367
- if (ids && modalState && modalState.clearSource) void loadArchives(true, '', 'session')
2368
- }
2369
- return value
2370
- } catch (error) {
2371
- patch({ error: String((error && error.message) || error) })
2372
- return null
2373
- } finally {
2374
- patch({ distillBusy: false })
2375
- }
2605
+ },
2606
+ )
2376
2607
  }
2377
2608
 
2378
2609
  async function approveGoalApi() {
@@ -2901,6 +3132,112 @@ window.__ModuleLoader__.load({
2901
3132
  patch({ boundSelected: { ...curMap, [field]: next } })
2902
3133
  }
2903
3134
 
3135
+ async function saveGuardWallApi({ title, ruleType = 'forbid_cmd', pattern = '', patterns = null, scope = 'global', reason = '', writeOnly = false }) {
3136
+ const cleanTitle = String(title || '').trim()
3137
+ const cleanPattern = String(pattern || '').trim()
3138
+ const patList = Array.isArray(patterns) && patterns.length > 0
3139
+ ? patterns
3140
+ : (cleanPattern ? cleanPattern.split(/[\r\n,;,;]+/).map(s => s.trim()).filter(Boolean) : [])
3141
+ if (!cleanTitle || !patList.length) {
3142
+ patch({ error: '物理驻墙需要填写规则名称与至少 1 条匹配规则' })
3143
+ return null
3144
+ }
3145
+ const res = await act({
3146
+ action: 'wall.save',
3147
+ wall: {
3148
+ title: cleanTitle,
3149
+ ruleType,
3150
+ patterns: patList,
3151
+ scope,
3152
+ reason: String(reason || '').trim(),
3153
+ writeOnly: Boolean(writeOnly),
3154
+ source: 'manual',
3155
+ },
3156
+ })
3157
+ if (res && res.ok) {
3158
+ patch({
3159
+ wallFormOpen: false,
3160
+ wallDraftTitle: '',
3161
+ wallDraftPattern: '',
3162
+ notice: `🧱 已落锁物理驻墙「${cleanTitle}」(${scope === 'workspace' ? '仅本工程' : '🌐 全局随身'})`,
3163
+ })
3164
+ }
3165
+ return res
3166
+ }
3167
+
3168
+ async function setGuardWallScopeApi(wallId, scope) {
3169
+ if (!wallId || !scope) return null
3170
+ const res = await act({ action: 'wall.setScope', wallId, scope })
3171
+ if (res && res.ok) {
3172
+ const labelMap = { global: '🌐 全局随身', workspace: '📁 仅本工程', paused: '⏸ 暂挂停用' }
3173
+ patch({ notice: `🧱 已切换物理墙作用域 → ${labelMap[scope] || scope}` })
3174
+ }
3175
+ return res
3176
+ }
3177
+
3178
+ async function removeGuardWallApi(wallId) {
3179
+ if (!wallId) return null
3180
+ const res = await act({ action: 'wall.remove', wallId })
3181
+ if (res && res.ok) {
3182
+ const curSel = Array.isArray(store.wallSelectedIds) ? store.wallSelectedIds : []
3183
+ patch({
3184
+ wallSelectedIds: curSel.filter(id => id !== wallId),
3185
+ wallMergeError: '',
3186
+ notice: '🧱 已拆除该条物理驻墙',
3187
+ })
3188
+ }
3189
+ return res
3190
+ }
3191
+
3192
+ function toggleGuardWallSelect(wallId) {
3193
+ const id = String(wallId || '').trim()
3194
+ if (!id) return
3195
+ const prev = Array.isArray(store.wallSelectedIds) ? store.wallSelectedIds : []
3196
+ const next = prev.includes(id) ? prev.filter(x => x !== id) : prev.concat(id)
3197
+ patch({ wallSelectedIds: next, wallMergeError: '', error: '' })
3198
+ }
3199
+
3200
+ async function mergeGuardWallsApi({ wallIds = [], autoGroup = false } = {}) {
3201
+ const walls = Array.isArray(store.guardWalls) ? store.guardWalls : []
3202
+ if (!autoGroup) {
3203
+ const cleanIds = [...new Set((Array.isArray(wallIds) ? wallIds : []).filter(id => walls.some(w => w && w.id === id)))]
3204
+ if (cleanIds.length < 2) {
3205
+ const msg = '请至少勾选 2 条相同类型的物理驻墙后再合并'
3206
+ patch({ wallMergeError: msg, error: msg })
3207
+ return { ok: false, code: 'MERGE_MIN_TWO', error: msg }
3208
+ }
3209
+ const picked = walls.filter(w => cleanIds.includes(w.id))
3210
+ const ruleTypes = new Set(picked.map(w => w.ruleType))
3211
+ if (ruleTypes.size > 1) {
3212
+ const msg = '⛔ 禁止跨类型合并物理驻墙:仅允许相同拦截类型的物理驻墙合并(如「禁碰路径」只能与「禁碰路径」合并),请取消异类勾选!'
3213
+ patch({ wallMergeError: msg, error: msg })
3214
+ return { ok: false, code: 'CROSS_TYPE_MERGE_FORBIDDEN', error: msg }
3215
+ }
3216
+ }
3217
+ patch({ wallMergeError: '', error: '' })
3218
+ return await withChiefWorkFx(
3219
+ { tone: 'wall', tab: 'boundaries', boundSubTab: 'rules', label: '参谋长正在合并同类驻墙中...', minMs: 520 },
3220
+ async () => {
3221
+ const res = await act({
3222
+ action: 'wall.merge',
3223
+ wallIds: Array.isArray(wallIds) ? wallIds : [],
3224
+ autoGroup: Boolean(autoGroup),
3225
+ })
3226
+ if (!res || !res.ok) {
3227
+ const msg = (res && res.error) || store.error || '合并物理驻墙失败'
3228
+ patch({ wallMergeError: msg, error: msg })
3229
+ return res || { ok: false, error: msg }
3230
+ }
3231
+ patch({
3232
+ wallSelectedIds: [],
3233
+ wallMergeError: '',
3234
+ notice: `🧱 已将 ${res.mergedCount || 2} 条同类物理驻墙合并为 ${res.createdCount || 1} 条`,
3235
+ })
3236
+ return res
3237
+ },
3238
+ )
3239
+ }
3240
+
2904
3241
  function openTaskEditor(task) {
2905
3242
  if (!task) return
2906
3243
  patch({
@@ -2993,6 +3330,11 @@ window.__ModuleLoader__.load({
2993
3330
  archiveDetails: {},
2994
3331
  archiveOpenFolders: {},
2995
3332
  archiveOpenFiles: {},
3333
+ qaCollapsedTurnIds: {},
3334
+ wallSelectedIds: [],
3335
+ wallMergeError: '',
3336
+ chiefWorkFx: null,
3337
+ seenBackendWorkIds: {},
2996
3338
  archiveUnboundSession: true,
2997
3339
  })
2998
3340
  void refresh()
@@ -3102,6 +3444,11 @@ window.__ModuleLoader__.load({
3102
3444
  archiveDetails: {},
3103
3445
  archiveOpenFolders: {},
3104
3446
  archiveOpenFiles: {},
3447
+ qaCollapsedTurnIds: {},
3448
+ wallSelectedIds: [],
3449
+ wallMergeError: '',
3450
+ chiefWorkFx: null,
3451
+ seenBackendWorkIds: {},
3105
3452
  archiveUnboundSession: !next,
3106
3453
  }
3107
3454
  : {}),
@@ -3378,7 +3725,7 @@ window.__ModuleLoader__.load({
3378
3725
  /* iOS Inset Grouped Cards */
3379
3726
  .dnb-group {
3380
3727
  background: var(--dnb-card);
3381
- border: 1px solid var(--dnb-border);
3728
+ border: 1px solid var(--dnb-border-strong);
3382
3729
  border-radius: 14px;
3383
3730
  margin-bottom: 10px;
3384
3731
  overflow: hidden;
@@ -3566,6 +3913,10 @@ window.__ModuleLoader__.load({
3566
3913
  .dnb-switch[data-on="1"] {
3567
3914
  background: #30d158;
3568
3915
  }
3916
+ .dnb-switch[data-on="1"][data-tone="red"] {
3917
+ background: #ef4444;
3918
+ box-shadow: 0 0 8px rgba(239, 68, 68, 0.35);
3919
+ }
3569
3920
  .dnb-switch-thumb {
3570
3921
  display: block;
3571
3922
  width: 18px;
@@ -4889,8 +5240,8 @@ window.__ModuleLoader__.load({
4889
5240
  z-index: 65;
4890
5241
  border-radius: 12px;
4891
5242
  background: var(--dnb-popover);
4892
- border: 1px solid var(--dnb-border-strong);
4893
- box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
5243
+ border: 1.5px solid rgba(96, 165, 250, 0.36);
5244
+ box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
4894
5245
  padding: 10px 12px;
4895
5246
  display: flex;
4896
5247
  flex-direction: column;
@@ -4941,6 +5292,12 @@ window.__ModuleLoader__.load({
4941
5292
  background: rgba(10, 132, 255, 0.11);
4942
5293
  color: var(--dnb-accent);
4943
5294
  }
5295
+ .dnb-tac-chip[data-tone="red"] {
5296
+ border-color: rgba(248, 113, 113, 0.52);
5297
+ background: rgba(239, 68, 68, 0.15);
5298
+ color: #f87171;
5299
+ box-shadow: 0 0 10px rgba(239, 68, 68, 0.12);
5300
+ }
4944
5301
  .dnb-stop-btn {
4945
5302
  display: inline-flex;
4946
5303
  align-items: center;
@@ -5373,43 +5730,179 @@ window.__ModuleLoader__.load({
5373
5730
  background: rgba(10, 132, 255, 0.08);
5374
5731
  flex-wrap: wrap;
5375
5732
  }
5376
- .dnb-sug-meta-row {
5733
+ .dnb-sug-meta-row {
5734
+ display: flex;
5735
+ align-items: center;
5736
+ gap: 5px;
5737
+ flex-wrap: wrap;
5738
+ margin-top: 2px;
5739
+ }
5740
+ .dnb-filter-seg {
5741
+ display: inline-flex;
5742
+ align-items: center;
5743
+ gap: 2px;
5744
+ padding: 2px;
5745
+ border-radius: 8px;
5746
+ background: var(--dnb-fill);
5747
+ border: 1px solid var(--dnb-border);
5748
+ }
5749
+ .dnb-filter-btn {
5750
+ border: none;
5751
+ background: transparent;
5752
+ color: var(--dnb-text-3);
5753
+ font-size: 10.5px;
5754
+ font-weight: 600;
5755
+ padding: 2px 7px;
5756
+ border-radius: 6px;
5757
+ cursor: pointer;
5758
+ }
5759
+ .dnb-filter-btn[data-active="1"] {
5760
+ background: var(--dnb-card);
5761
+ color: var(--dnb-text);
5762
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
5763
+ }
5764
+ .dnb-qa-stream {
5765
+ display: flex;
5766
+ flex-direction: column;
5767
+ gap: 11px;
5768
+ padding: 10px;
5769
+ border-top: 1px solid var(--dnb-border);
5770
+ }
5771
+ .dnb-qa-turn-box {
5772
+ border-radius: 14px;
5773
+ border: 2px solid rgba(56, 189, 248, 0.72);
5774
+ background: linear-gradient(180deg, rgba(14, 165, 233, 0.09) 0%, var(--dnb-card) 100%);
5775
+ overflow: hidden;
5776
+ box-shadow:
5777
+ 0 6px 18px rgba(0, 0, 0, 0.24),
5778
+ 0 0 0 1px rgba(56, 189, 248, 0.20) inset,
5779
+ 0 0 14px rgba(14, 165, 233, 0.14);
5780
+ transition: border-color 0.16s ease, box-shadow 0.16s ease;
5781
+ }
5782
+ .dnb-qa-turn-box[data-turn-kind="system"] {
5783
+ border-color: rgba(16, 185, 129, 0.68);
5784
+ background: linear-gradient(180deg, rgba(16, 185, 129, 0.09) 0%, var(--dnb-card) 100%);
5785
+ box-shadow:
5786
+ 0 6px 18px rgba(0, 0, 0, 0.22),
5787
+ 0 0 0 1px rgba(16, 185, 129, 0.18) inset,
5788
+ 0 0 12px rgba(16, 185, 129, 0.12);
5789
+ }
5790
+ .dnb-turn-question {
5791
+ display: flex;
5792
+ flex-direction: column;
5793
+ gap: 4px;
5794
+ padding: 9px 12px;
5795
+ cursor: pointer;
5796
+ user-select: none;
5797
+ background: rgba(56, 189, 248, 0.12);
5798
+ border-bottom: 1.5px solid rgba(56, 189, 248, 0.36);
5799
+ transition: background 0.14s ease;
5800
+ }
5801
+ .dnb-turn-question:hover {
5802
+ background: rgba(56, 189, 248, 0.18);
5803
+ }
5804
+ .dnb-qa-turn-box[data-turn-kind="system"] .dnb-turn-question {
5805
+ background: rgba(16, 185, 129, 0.11);
5806
+ border-bottom-color: rgba(16, 185, 129, 0.34);
5807
+ }
5808
+ .dnb-qa-turn-box[data-turn-kind="system"] .dnb-turn-question:hover {
5809
+ background: rgba(16, 185, 129, 0.17);
5810
+ }
5811
+ .dnb-qa-turn-box[data-collapsed="1"] .dnb-turn-question {
5812
+ border-bottom: none;
5813
+ }
5814
+ .dnb-turn-replies {
5815
+ display: flex;
5816
+ flex-direction: column;
5817
+ gap: 8px;
5818
+ padding: 9px 12px;
5819
+ }
5820
+ .dnb-turn-reply-item {
5821
+ display: flex;
5822
+ flex-direction: column;
5823
+ align-items: flex-start;
5824
+ gap: 4px;
5825
+ padding: 7px 10px;
5826
+ border-radius: 9px;
5827
+ border: 1px solid rgba(56, 189, 248, 0.26);
5828
+ border-left: 3.5px solid #38bdf8;
5829
+ background: rgba(14, 165, 233, 0.055);
5830
+ }
5831
+ .dnb-turn-reply-item[data-role="receipt"] {
5832
+ border-color: rgba(52, 211, 153, 0.28);
5833
+ border-left: 3.5px solid #10b981;
5834
+ background: rgba(16, 185, 129, 0.06);
5835
+ }
5836
+ .dnb-qa-card {
5837
+ border-radius: 11px;
5838
+ padding: 9px 12px;
5839
+ border: 1px solid rgba(148, 163, 184, 0.30);
5840
+ border-left: 3.5px solid #94a3b8;
5841
+ background: rgba(148, 163, 184, 0.055);
5842
+ }
5843
+ .dnb-qa-stream > .dnb-qa-card + .dnb-qa-card,
5844
+ .dnb-qa-stream > .dnb-qa-card + .dnb-receipt-card,
5845
+ .dnb-qa-stream > .dnb-receipt-card + .dnb-qa-card,
5846
+ .dnb-qa-stream > .dnb-receipt-card + .dnb-receipt-card {
5847
+ border-top: 1px solid rgba(148, 163, 184, 0.30);
5848
+ }
5849
+ .dnb-qa-card[data-role="chief"] {
5850
+ border: 1px solid rgba(56, 189, 248, 0.36);
5851
+ border-left: 3.5px solid #38bdf8;
5852
+ background: rgba(14, 165, 233, 0.065);
5853
+ }
5854
+ .dnb-qa-stream > .dnb-qa-card[data-role="chief"] + .dnb-qa-card[data-role="chief"],
5855
+ .dnb-qa-stream > .dnb-cell + .dnb-qa-card[data-role="chief"] {
5856
+ border-top: 1px solid rgba(56, 189, 248, 0.36);
5857
+ }
5858
+ .dnb-receipt-card {
5859
+ border-radius: 11px;
5860
+ padding: 9px 12px;
5861
+ border: 1px solid rgba(52, 211, 153, 0.38);
5862
+ border-left: 3.5px solid #10b981;
5863
+ background: rgba(16, 185, 129, 0.065);
5864
+ }
5865
+ .dnb-qa-stream > .dnb-cell + .dnb-receipt-card {
5866
+ border-top: 1px solid rgba(52, 211, 153, 0.38);
5867
+ }
5868
+ .dnb-wall-box {
5869
+ margin-bottom: 12px;
5870
+ border-radius: 14px;
5871
+ border: 1.25px solid rgba(248, 113, 113, 0.36);
5872
+ background: rgba(239, 68, 68, 0.045);
5873
+ overflow: hidden;
5874
+ }
5875
+ .dnb-wall-item {
5876
+ display: flex;
5877
+ flex-direction: column;
5878
+ gap: 6px;
5879
+ padding: 9px 12px;
5880
+ border-top: 1px solid var(--dnb-border);
5881
+ }
5882
+ .dnb-wall-actions-row {
5377
5883
  display: flex;
5378
5884
  align-items: center;
5885
+ justify-content: flex-end;
5379
5886
  gap: 5px;
5380
- flex-wrap: wrap;
5887
+ width: 100%;
5381
5888
  margin-top: 2px;
5382
5889
  }
5383
- .dnb-filter-seg {
5384
- display: inline-flex;
5385
- align-items: center;
5386
- gap: 2px;
5387
- padding: 2px;
5388
- border-radius: 8px;
5389
- background: var(--dnb-fill);
5890
+ .dnb-wall-scope-btn {
5891
+ height: 22px;
5892
+ padding: 0 7px;
5893
+ border-radius: 99px;
5390
5894
  border: 1px solid var(--dnb-border);
5391
- }
5392
- .dnb-filter-btn {
5393
- border: none;
5394
- background: transparent;
5395
- color: var(--dnb-text-3);
5895
+ background: var(--dnb-card);
5896
+ color: var(--dnb-text-2);
5396
5897
  font-size: 10.5px;
5397
5898
  font-weight: 600;
5398
- padding: 2px 7px;
5399
- border-radius: 6px;
5400
5899
  cursor: pointer;
5900
+ transition: all 0.14s ease;
5401
5901
  }
5402
- .dnb-filter-btn[data-active="1"] {
5403
- background: var(--dnb-card);
5404
- color: var(--dnb-text);
5405
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
5406
- }
5407
- .dnb-qa-card {
5408
- border-left: 3px solid rgba(10, 132, 255, 0.45);
5409
- }
5410
- .dnb-receipt-card {
5411
- border-left: 3px solid rgba(48, 209, 88, 0.72);
5412
- background: rgba(48, 209, 88, 0.045);
5902
+ .dnb-wall-scope-btn[data-active="1"] {
5903
+ border-color: rgba(248, 113, 113, 0.55);
5904
+ background: rgba(239, 68, 68, 0.15);
5905
+ color: #f87171;
5413
5906
  }
5414
5907
  .dnb-receipt-badge {
5415
5908
  display: inline-flex;
@@ -5437,6 +5930,227 @@ window.__ModuleLoader__.load({
5437
5930
  color: var(--dnb-accent);
5438
5931
  background: rgba(10, 132, 255, 0.12);
5439
5932
  }
5933
+
5934
+ /* Chief Working Stage FX (Gradient Base + Running Border Beam + Frosted Glass + Jumping Text + Spinner) */
5935
+ @keyframes dnb-fx-neon-flow {
5936
+ 0% { background-position: 0% 50%; }
5937
+ 50% { background-position: 100% 50%; }
5938
+ 100% { background-position: 0% 50%; }
5939
+ }
5940
+ @keyframes dnb-fx-beam-spin {
5941
+ from { transform: translate(-50%, -50%) rotate(0deg); }
5942
+ to { transform: translate(-50%, -50%) rotate(360deg); }
5943
+ }
5944
+ @keyframes dnb-fx-ring-spin {
5945
+ from { transform: rotate(0deg); }
5946
+ to { transform: rotate(360deg); }
5947
+ }
5948
+ @keyframes dnb-wave-jump {
5949
+ 0%, 56%, 100% { transform: translateY(0) scale(1); }
5950
+ 24% { transform: translateY(-6.5px) scale(1.06); }
5951
+ 42% { transform: translateY(1px) scale(0.98); }
5952
+ }
5953
+ .dnb-chief-fx-border,
5954
+ .dnb-chief-fx-stage {
5955
+ --fx-color: #38bdf8;
5956
+ --fx-trail: rgba(56, 189, 248, 0.42);
5957
+ --fx-glow: rgba(56, 189, 248, 0.44);
5958
+ --fx-border: rgba(56, 189, 248, 0.72);
5959
+ --fx-grad: linear-gradient(125deg, #0ea5e9, #38bdf8, #22d3ee, #0ea5e9);
5960
+ }
5961
+ .dnb-chief-fx-border[data-tone="wall"],
5962
+ .dnb-chief-fx-stage[data-tone="wall"] {
5963
+ --fx-color: #f87171;
5964
+ --fx-trail: rgba(248, 113, 113, 0.44);
5965
+ --fx-glow: rgba(239, 68, 68, 0.50);
5966
+ --fx-border: rgba(248, 113, 113, 0.80);
5967
+ --fx-grad: linear-gradient(125deg, #ef4444, #fb7185, #f97316, #ef4444);
5968
+ }
5969
+ .dnb-chief-fx-border[data-tone="bounds"],
5970
+ .dnb-chief-fx-stage[data-tone="bounds"] {
5971
+ --fx-color: #fbbf24;
5972
+ --fx-trail: rgba(251, 191, 36, 0.44);
5973
+ --fx-glow: rgba(245, 158, 11, 0.48);
5974
+ --fx-border: rgba(251, 191, 36, 0.80);
5975
+ --fx-grad: linear-gradient(125deg, #f59e0b, #fde047, #fb923c, #f59e0b);
5976
+ }
5977
+ .dnb-chief-fx-border[data-tone="archive"],
5978
+ .dnb-chief-fx-stage[data-tone="archive"] {
5979
+ --fx-color: #38bdf8;
5980
+ --fx-trail: rgba(56, 189, 248, 0.44);
5981
+ --fx-glow: rgba(14, 165, 233, 0.48);
5982
+ --fx-border: rgba(56, 189, 248, 0.80);
5983
+ --fx-grad: linear-gradient(125deg, #0284c7, #38bdf8, #2dd4bf, #0284c7);
5984
+ }
5985
+ .dnb-chief-fx-border[data-tone="tasks"],
5986
+ .dnb-chief-fx-stage[data-tone="tasks"] {
5987
+ --fx-color: #34d399;
5988
+ --fx-trail: rgba(52, 211, 153, 0.44);
5989
+ --fx-glow: rgba(16, 185, 129, 0.48);
5990
+ --fx-border: rgba(52, 211, 153, 0.80);
5991
+ --fx-grad: linear-gradient(125deg, #10b981, #34d399, #a3e635, #10b981);
5992
+ }
5993
+ .dnb-chief-fx-border[data-tone="peers"],
5994
+ .dnb-chief-fx-stage[data-tone="peers"] {
5995
+ --fx-color: #a78bfa;
5996
+ --fx-trail: rgba(167, 139, 250, 0.44);
5997
+ --fx-glow: rgba(139, 92, 246, 0.48);
5998
+ --fx-border: rgba(167, 139, 250, 0.80);
5999
+ --fx-grad: linear-gradient(125deg, #8b5cf6, #c084fc, #60a5fa, #8b5cf6);
6000
+ }
6001
+ .dnb-chief-fx-border[data-tone="neon"],
6002
+ .dnb-chief-fx-stage[data-tone="neon"] {
6003
+ --fx-color: #f472b6;
6004
+ --fx-trail: rgba(192, 132, 252, 0.48);
6005
+ --fx-glow: rgba(168, 85, 247, 0.48);
6006
+ --fx-border: rgba(192, 132, 252, 0.82);
6007
+ --fx-grad: linear-gradient(120deg, #ff4d6d, #fbbf24, #34d399, #38bdf8, #a78bfa, #f472b6, #ff4d6d);
6008
+ }
6009
+ .dnb-chief-fx-border {
6010
+ position: absolute;
6011
+ inset: 2px;
6012
+ border-radius: 14px;
6013
+ padding: 2.5px;
6014
+ overflow: hidden;
6015
+ pointer-events: none;
6016
+ z-index: 93;
6017
+ filter: drop-shadow(0 0 9px var(--fx-glow));
6018
+ box-shadow: inset 0 0 14px var(--fx-glow);
6019
+ -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
6020
+ -webkit-mask-composite: xor;
6021
+ mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
6022
+ mask-composite: exclude;
6023
+ }
6024
+ .dnb-chief-fx-border::after {
6025
+ content: "";
6026
+ position: absolute;
6027
+ inset: 0;
6028
+ background: var(--fx-grad);
6029
+ background-size: 260% 260%;
6030
+ opacity: 0.36;
6031
+ animation: dnb-fx-neon-flow 3.2s linear infinite;
6032
+ }
6033
+ .dnb-chief-fx-border::before {
6034
+ content: "";
6035
+ position: absolute;
6036
+ top: 50%;
6037
+ left: 50%;
6038
+ width: 260%;
6039
+ aspect-ratio: 1 / 1;
6040
+ background: conic-gradient(
6041
+ from 0deg,
6042
+ transparent 0deg,
6043
+ transparent 45deg,
6044
+ var(--fx-trail) 95deg,
6045
+ var(--fx-color) 148deg,
6046
+ #ffffff 174deg,
6047
+ var(--fx-color) 180deg,
6048
+ transparent 186deg,
6049
+ transparent 225deg,
6050
+ var(--fx-trail) 275deg,
6051
+ var(--fx-color) 328deg,
6052
+ #ffffff 354deg,
6053
+ var(--fx-color) 360deg
6054
+ );
6055
+ animation: dnb-fx-beam-spin 2.25s linear infinite;
6056
+ }
6057
+ .dnb-chief-fx-border[data-tone="neon"]::before {
6058
+ background: conic-gradient(
6059
+ from 0deg,
6060
+ #ff4d6d 0deg,
6061
+ #fbbf24 54deg,
6062
+ #ffffff 84deg,
6063
+ #34d399 124deg,
6064
+ #38bdf8 180deg,
6065
+ #a78bfa 234deg,
6066
+ #ffffff 264deg,
6067
+ #f472b6 312deg,
6068
+ #ff4d6d 360deg
6069
+ );
6070
+ }
6071
+ .dnb-chief-fx-stage {
6072
+ position: absolute;
6073
+ inset: 4px;
6074
+ border-radius: 12px;
6075
+ z-index: 92;
6076
+ display: flex;
6077
+ flex-direction: column;
6078
+ align-items: center;
6079
+ justify-content: center;
6080
+ padding: 20px;
6081
+ background: rgba(15, 23, 42, 0.30);
6082
+ backdrop-filter: blur(4px) saturate(1.18);
6083
+ -webkit-backdrop-filter: blur(4px) saturate(1.18);
6084
+ box-shadow: inset 0 0 28px var(--fx-glow);
6085
+ animation: dnb-enter 0.18s ease-out;
6086
+ }
6087
+ @media (prefers-color-scheme: light) {
6088
+ .dnb-chief-fx-stage {
6089
+ background: rgba(248, 250, 252, 0.36);
6090
+ }
6091
+ }
6092
+ .dnb-chief-fx-pill {
6093
+ display: inline-flex;
6094
+ align-items: center;
6095
+ gap: 11px;
6096
+ padding: 12px 18px;
6097
+ border-radius: 16px;
6098
+ max-width: 94%;
6099
+ background: rgba(15, 23, 42, 0.78);
6100
+ border: 1.5px solid var(--fx-border);
6101
+ box-shadow:
6102
+ 0 14px 36px rgba(0, 0, 0, 0.34),
6103
+ 0 0 24px var(--fx-glow);
6104
+ backdrop-filter: blur(12px);
6105
+ -webkit-backdrop-filter: blur(12px);
6106
+ }
6107
+ .dnb-chief-fx-ring {
6108
+ width: 22px;
6109
+ height: 22px;
6110
+ border-radius: 50%;
6111
+ flex-shrink: 0;
6112
+ border: 2.5px solid rgba(255, 255, 255, 0.14);
6113
+ border-top-color: var(--fx-color);
6114
+ border-right-color: var(--fx-color);
6115
+ box-shadow: 0 0 10px var(--fx-glow);
6116
+ animation: dnb-fx-ring-spin 0.85s linear infinite;
6117
+ }
6118
+ .dnb-chief-fx-stage[data-tone="neon"] .dnb-chief-fx-ring {
6119
+ border: none;
6120
+ background: conic-gradient(from 0deg, #ff4d6d, #fbbf24, #34d399, #38bdf8, #a78bfa, #f472b6, #ff4d6d);
6121
+ -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
6122
+ mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
6123
+ }
6124
+ .dnb-chief-fx-text {
6125
+ display: flex;
6126
+ flex-wrap: wrap;
6127
+ align-items: center;
6128
+ font-size: 13.5px;
6129
+ font-weight: 700;
6130
+ line-height: 1.5;
6131
+ letter-spacing: 0.3px;
6132
+ }
6133
+ .dnb-wave-char {
6134
+ display: inline-block;
6135
+ color: var(--fx-color);
6136
+ text-shadow: 0 0 12px var(--fx-glow);
6137
+ animation: dnb-wave-jump 1.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite;
6138
+ animation-delay: calc(var(--char-i, 0) * 0.065s);
6139
+ will-change: transform;
6140
+ }
6141
+ .dnb-chief-fx-stage[data-tone="neon"] .dnb-wave-char {
6142
+ background: linear-gradient(110deg, #ff6b8b, #fbbf24, #34d399, #38bdf8, #c084fc, #ff6b8b);
6143
+ background-size: 260% 100%;
6144
+ -webkit-background-clip: text;
6145
+ background-clip: text;
6146
+ color: transparent;
6147
+ text-shadow: none;
6148
+ filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.45));
6149
+ animation:
6150
+ dnb-wave-jump 1.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite,
6151
+ dnb-fx-neon-flow 2.8s linear infinite;
6152
+ animation-delay: calc(var(--char-i, 0) * 0.065s), 0s;
6153
+ }
5440
6154
  `
5441
6155
 
5442
6156
  function Style() {
@@ -5576,6 +6290,15 @@ window.__ModuleLoader__.load({
5576
6290
  h('path', { d: 'm8 11 4 4 4-4' }),
5577
6291
  h('path', { d: 'M4 15v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3' }),
5578
6292
  )
6293
+ case 'shieldSentinel':
6294
+ return h('svg', props,
6295
+ h('path', {
6296
+ d: 'M12 2.8 4.6 5.9v5.6c0 4.9 3.2 9.1 7.4 10.7 4.2-1.6 7.4-5.8 7.4-10.7V5.9L12 2.8z',
6297
+ fill: 'currentColor',
6298
+ fillOpacity: 0.24,
6299
+ }),
6300
+ h('path', { d: 'M12 7.5v8.2M8.8 11.4h6.4' }),
6301
+ )
5579
6302
  default:
5580
6303
  return null
5581
6304
  }
@@ -5617,7 +6340,7 @@ window.__ModuleLoader__.load({
5617
6340
 
5618
6341
  /* ----------------------------------------------------- iOS Micro-Flat CSS */
5619
6342
 
5620
- function Switch({ checked, onChange, disabled = false, title = '', small = false }) {
6343
+ function Switch({ checked, onChange, disabled = false, title = '', small = false, tone = '' }) {
5621
6344
  return h(
5622
6345
  'button',
5623
6346
  {
@@ -5627,6 +6350,7 @@ window.__ModuleLoader__.load({
5627
6350
  'aria-checked': checked ? 'true' : 'false',
5628
6351
  'aria-disabled': disabled ? 'true' : 'false',
5629
6352
  'data-disabled': disabled ? '1' : '0',
6353
+ 'data-tone': tone || undefined,
5630
6354
  title: title || undefined,
5631
6355
  className: 'dnb-switch',
5632
6356
  'data-on': checked ? '1' : '0',
@@ -6300,6 +7024,42 @@ window.__ModuleLoader__.load({
6300
7024
  return groups.flat()
6301
7025
  }
6302
7026
 
7027
+ function groupChatHistoryTurnsNewestFirst(rawList) {
7028
+ const items = Array.isArray(rawList) ? rawList.filter(Boolean) : []
7029
+ const turns = []
7030
+ let activeTurn = null
7031
+ let activeSys = null
7032
+ for (const item of items) {
7033
+ if (item.role === 'user') {
7034
+ activeSys = null
7035
+ activeTurn = {
7036
+ id: 'turn-' + (item.id || turns.length),
7037
+ kind: 'turn',
7038
+ question: item,
7039
+ replies: [],
7040
+ at: item.at || 0,
7041
+ }
7042
+ turns.push(activeTurn)
7043
+ } else if (activeTurn) {
7044
+ activeTurn.replies.push(item)
7045
+ } else {
7046
+ if (!activeSys) {
7047
+ activeSys = {
7048
+ id: 'sys-' + (item.id || turns.length),
7049
+ kind: 'system',
7050
+ question: null,
7051
+ replies: [],
7052
+ at: item.at || 0,
7053
+ }
7054
+ turns.push(activeSys)
7055
+ }
7056
+ activeSys.replies.push(item)
7057
+ }
7058
+ }
7059
+ turns.reverse()
7060
+ return turns
7061
+ }
7062
+
6303
7063
  // === [module: src/client/components/modals.js] ===
6304
7064
  /**
6305
7065
  * components/modals.js
@@ -6538,6 +7298,15 @@ window.__ModuleLoader__.load({
6538
7298
  bg: 'rgba(48, 209, 88, 0.12)',
6539
7299
  }
6540
7300
  }
7301
+ if (sug.kind === 'guard_wall') {
7302
+ return {
7303
+ typeLabel: '🧱 物理驻墙提案',
7304
+ impact: `影响:${sug.targetLabel || '🌐 全局随身驻墙'}(事前物理硬拦截)`,
7305
+ expect: '预期:确认后写入 guard-walls.json,所有代理触线即刻物理阻断',
7306
+ tone: '#f87171',
7307
+ bg: 'rgba(239, 68, 68, 0.13)',
7308
+ }
7309
+ }
6541
7310
  if (sug.kind === 'bound') {
6542
7311
  const colLabel = sug.boundField === 'allowed' ? '必做事项' : (sug.boundField === 'notes' ? '注意事项' : '禁止红线')
6543
7312
  const repCount = Array.isArray(sug.replaces) ? sug.replaces.filter(Boolean).length : 0
@@ -6571,7 +7340,7 @@ window.__ModuleLoader__.load({
6571
7340
  const rawSuggestions = (view.secView && Array.isArray(view.secView.suggestions))
6572
7341
  ? view.secView.suggestions.filter(s => s && s.status === 'pending')
6573
7342
  : []
6574
- const rankSug = s => (s.kind === 'goal_approval' ? 0 : s.kind === 'bound' ? 1 : 2)
7343
+ const rankSug = s => (s.kind === 'goal_approval' ? 0 : (s.kind === 'bound' || s.kind === 'guard_wall') ? 1 : 2)
6575
7344
  const suggestions = [...rawSuggestions].sort((a, b) => rankSug(a) - rankSug(b))
6576
7345
  const [expandedId, setExpandedId] = React.useState('')
6577
7346
  const [unselectedIds, setUnselectedIds] = React.useState({})
@@ -6725,6 +7494,14 @@ window.__ModuleLoader__.load({
6725
7494
  )
6726
7495
  }
6727
7496
 
7497
+ const MODAL_WALL_TYPE_TAG = {
7498
+ forbid_cmd: '🚫 禁跑命令',
7499
+ forbid_path: '🚧 禁碰路径',
7500
+ restrict_write: '🔐 仅限目录可写',
7501
+ require_approval_cmd: '🛡️ 高危命令先请示',
7502
+ deny_tool: '⛔ 禁用工具',
7503
+ }
7504
+
6728
7505
  function InterventionConfirmModal({ view, board }) {
6729
7506
  const meta = view.chiefMeta || {}
6730
7507
  const tm = meta.tacticalModes || {}
@@ -6733,6 +7510,9 @@ window.__ModuleLoader__.load({
6733
7510
  const forbiddenList = (Array.isArray(rawBounds.forbidden) ? rawBounds.forbidden : [])
6734
7511
  .map(f => (typeof f === 'string' ? f.trim() : String((f && f.text) || '').trim()))
6735
7512
  .filter(Boolean)
7513
+ const allWalls = Array.isArray(view.guardWalls) ? view.guardWalls : []
7514
+ const activeWalls = allWalls.filter(w => w && w.scope !== 'paused' && w.activeNow !== false)
7515
+ const pausedWallsCount = allWalls.filter(w => w && w.scope === 'paused').length
6736
7516
 
6737
7517
  const [objDraft, setObjDraft] = React.useState(savedBoardObj)
6738
7518
  const [objLocked, setObjLocked] = React.useState(false)
@@ -6742,6 +7522,8 @@ window.__ModuleLoader__.load({
6742
7522
  const [lastWasAiGuess, setLastWasAiGuess] = React.useState(false)
6743
7523
  const [suggestRationale, setSuggestRationale] = React.useState('')
6744
7524
  const [confirmBusy, setConfirmBusy] = React.useState(false)
7525
+ const [wallsSecCollapsed, setWallsSecCollapsed] = React.useState(false)
7526
+ const [redlinesSecCollapsed, setRedlinesSecCollapsed] = React.useState(false)
6745
7527
 
6746
7528
  React.useEffect(() => {
6747
7529
  if (!view.interventionModalOpen) return
@@ -6753,12 +7535,20 @@ window.__ModuleLoader__.load({
6753
7535
  setLastWasAiGuess(false)
6754
7536
  setSuggestRationale('')
6755
7537
  setConfirmBusy(false)
7538
+ setWallsSecCollapsed(false)
7539
+ setRedlinesSecCollapsed(false)
6756
7540
  }, [view.interventionModalOpen])
6757
7541
 
6758
7542
  if (!view.interventionModalOpen) return null
6759
7543
  const permMode = ['advisor', 'assistant', 'strategist', 'chief'].includes(meta.permissionMode) ? meta.permissionMode : 'advisor'
6760
7544
  const trimmedDraft = String(objDraft || '').trim()
6761
- const missingPrerequisite = !trimmedDraft || forbiddenList.length === 0
7545
+ const noDefenseRules = activeWalls.length === 0 && forbiddenList.length === 0
7546
+ const allDefenseCollapsed = wallsSecCollapsed && redlinesSecCollapsed
7547
+ const toggleAllDefense = () => {
7548
+ const next = !allDefenseCollapsed
7549
+ setWallsSecCollapsed(next)
7550
+ setRedlinesSecCollapsed(next)
7551
+ }
6762
7552
 
6763
7553
  const handleSuggestObjective = async () => {
6764
7554
  if (suggestBusy) return
@@ -6896,68 +7686,185 @@ window.__ModuleLoader__.load({
6896
7686
  ? h('span', { style: { color: '#ff6961', fontWeight: 600 } }, '⚠ 尚未填写核心目标:建议直接点右上「✦ 建议」自动填充(可反复点猜意图),或自行填写。')
6897
7687
  : '后续参谋长每次介入都会对照此核心目标与「必做事项」核查完成度;开启强介入后将锁定本目标直到关闭。'),
6898
7688
  ),
6899
- // Live Redline Readback
7689
+ // Live Boundaries & Guard Walls Readback (Physical Guard Walls + Forbidden Redlines)
6900
7690
  h(
6901
7691
  'div',
6902
7692
  {
6903
7693
  style: {
6904
7694
  borderRadius: 9,
6905
7695
  padding: '8px 10px',
6906
- border: forbiddenList.length === 0 ? '1px solid rgba(255, 69, 58, 0.45)' : '1px solid var(--dnb-border)',
6907
- background: forbiddenList.length === 0 ? 'rgba(255, 69, 58, 0.08)' : 'var(--dnb-card)',
7696
+ border: noDefenseRules ? '1px solid rgba(255, 69, 58, 0.48)' : '1px solid var(--dnb-border)',
7697
+ background: noDefenseRules ? 'rgba(255, 69, 58, 0.08)' : 'var(--dnb-card)',
6908
7698
  display: 'flex',
6909
7699
  flexDirection: 'column',
6910
- gap: 5,
7700
+ gap: 6,
6911
7701
  fontSize: 11.5,
6912
7702
  },
6913
7703
  },
6914
- forbiddenList.length === 0
6915
- ? h('div', null,
6916
- h('strong', null, '已设禁止红线:'),
6917
- h('span', { style: { color: '#ff453a', fontWeight: 600 } }, '未设定(缺少禁止红线时强介入风险较高)'),
6918
- )
6919
- : h(
6920
- 'div',
6921
- { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6, flexWrap: 'wrap' } },
6922
- h('div', null,
6923
- h('strong', null, '已设禁止红线:'),
6924
- h('span', { style: { color: '#34d399', fontWeight: 700 } }, `已生效 ${forbiddenList.length} 条`),
6925
- ),
6926
- h('button', {
6927
- type: 'button',
6928
- className: 'dnb-mini-btn',
6929
- 'data-tone': 'blue',
6930
- onClick: () => patch({ interventionModalOpen: false, tab: 'boundaries', boundSubTab: 'rules' }),
6931
- }, '管理红线'),
6932
- ),
6933
- forbiddenList.length > 0
6934
- ? h(
6935
- 'div',
6936
- { style: { display: 'flex', flexDirection: 'column', gap: 3, paddingTop: 2 } },
6937
- forbiddenList.slice(0, 3).map((item, idx) =>
6938
- h('div', {
6939
- key: idx,
6940
- style: { fontSize: 11, color: 'var(--dnb-text-2)', lineHeight: 1.45, wordBreak: 'break-word' },
6941
- }, '• ' + (item.length > 88 ? item.slice(0, 88) + '…' : item)),
6942
- ),
6943
- forbiddenList.length > 3
6944
- ? h('div', { style: { fontSize: 10.5, color: 'var(--dnb-text-3)', marginTop: 1 } },
6945
- `…另有 ${forbiddenList.length - 3} 条禁止红线共同生效中`)
6946
- : null,
6947
- )
6948
- : null,
6949
- forbiddenList.length === 0
6950
- ? h(
6951
- 'div',
6952
- { style: { display: 'flex', gap: 6, marginTop: 3 } },
6953
- h('button', {
6954
- type: 'button',
6955
- className: 'dnb-mini-btn',
6956
- 'data-tone': 'amber',
6957
- onClick: () => patch({ interventionModalOpen: false, tab: 'boundaries', boundSubTab: 'rules' }),
6958
- }, '前往设定红线'),
6959
- )
6960
- : null,
7704
+ h(
7705
+ 'div',
7706
+ { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6, flexWrap: 'wrap' } },
7707
+ h(
7708
+ 'div',
7709
+ { style: { display: 'flex', alignItems: 'center', gap: 5, flexWrap: 'wrap', minWidth: 0 } },
7710
+ h('strong', null, '🛡️ 已设防线核对:'),
7711
+ noDefenseRules
7712
+ ? h('span', { style: { color: '#ff453a', fontWeight: 600 } }, '未设物理驻墙与禁止红线(强介入风险较高)')
7713
+ : h(
7714
+ React.Fragment,
7715
+ null,
7716
+ h('span', { style: { color: activeWalls.length > 0 ? '#f87171' : 'var(--dnb-text-3)', fontWeight: 700 } },
7717
+ `🧱 物理驻墙 ${activeWalls.length} 堵`),
7718
+ h('span', { style: { color: 'var(--dnb-text-3)' } }, '·'),
7719
+ h('span', { style: { color: forbiddenList.length > 0 ? '#34d399' : 'var(--dnb-text-3)', fontWeight: 700 } },
7720
+ `🚫 禁止红线 ${forbiddenList.length} 条`),
7721
+ ),
7722
+ ),
7723
+ h(
7724
+ 'div',
7725
+ { style: { display: 'inline-flex', alignItems: 'center', gap: 5, flexShrink: 0 } },
7726
+ !noDefenseRules
7727
+ ? h('button', {
7728
+ type: 'button',
7729
+ className: 'dnb-mini-btn',
7730
+ title: allDefenseCollapsed ? '一键拉开物理驻墙与禁止红线详情' : '一键收起物理驻墙与禁止红线详情',
7731
+ onClick: toggleAllDefense,
7732
+ }, allDefenseCollapsed ? '↕ 一键拉开' : '↕ 一键收起')
7733
+ : null,
7734
+ h('button', {
7735
+ type: 'button',
7736
+ className: 'dnb-mini-btn',
7737
+ 'data-tone': noDefenseRules ? 'amber' : 'blue',
7738
+ onClick: () => patch({ interventionModalOpen: false, tab: 'boundaries', boundSubTab: 'rules' }),
7739
+ }, '管理边界'),
7740
+ ),
7741
+ ),
7742
+ // Sub-section 1: Physical Guard Walls
7743
+ h(
7744
+ 'div',
7745
+ {
7746
+ style: {
7747
+ borderRadius: 7,
7748
+ border: '1px solid rgba(248, 113, 113, 0.28)',
7749
+ background: 'rgba(239, 68, 68, 0.05)',
7750
+ overflow: 'hidden',
7751
+ },
7752
+ },
7753
+ h(
7754
+ 'div',
7755
+ {
7756
+ style: {
7757
+ display: 'flex',
7758
+ alignItems: 'center',
7759
+ justifyContent: 'space-between',
7760
+ gap: 6,
7761
+ padding: '5px 8px',
7762
+ cursor: 'pointer',
7763
+ userSelect: 'none',
7764
+ },
7765
+ onClick: () => setWallsSecCollapsed(v => !v),
7766
+ },
7767
+ h('span', { style: { fontSize: 11, fontWeight: 700, color: '#f87171' } },
7768
+ `🧱 物理驻墙(事前硬拦截 · 已生效 ${activeWalls.length} 堵${pausedWallsCount > 0 ? ` · ${pausedWallsCount} 暂挂` : ''})`),
7769
+ h(Icon, {
7770
+ name: 'chevron',
7771
+ size: 12,
7772
+ style: {
7773
+ color: 'var(--dnb-text-3)',
7774
+ transform: wallsSecCollapsed ? 'none' : 'rotate(90deg)',
7775
+ transition: 'transform 0.16s ease',
7776
+ },
7777
+ }),
7778
+ ),
7779
+ !wallsSecCollapsed
7780
+ ? h(
7781
+ 'div',
7782
+ { style: { padding: '0 8px 6px', display: 'flex', flexDirection: 'column', gap: 3.5 } },
7783
+ activeWalls.length > 0
7784
+ ? [
7785
+ ...activeWalls.slice(0, 4).map(w => {
7786
+ const scopeTag = w.scope === 'workspace' ? '📁本工程' : '🌐全局'
7787
+ const typeTag = MODAL_WALL_TYPE_TAG[w.ruleType] || w.ruleType
7788
+ const patStr = Array.isArray(w.patterns) ? w.patterns.join(', ') : ''
7789
+ const previewPat = patStr.length > 52 ? patStr.slice(0, 52) + '…' : patStr
7790
+ return h(
7791
+ 'div',
7792
+ { key: w.id, style: { fontSize: 11, color: 'var(--dnb-text-2)', lineHeight: 1.45, wordBreak: 'break-word' } },
7793
+ h('span', { style: { color: '#fca5a5', fontWeight: 600 } }, `• [${scopeTag} · ${typeTag}] `),
7794
+ h('span', { style: { color: 'var(--dnb-text)', fontWeight: 600 } }, w.title || ''),
7795
+ previewPat
7796
+ ? h('span', { style: { color: 'var(--dnb-text-3)', fontFamily: 'ui-monospace, Menlo, Consolas, monospace', fontSize: 10.5 } }, ` — ${previewPat}`)
7797
+ : null,
7798
+ )
7799
+ }),
7800
+ activeWalls.length > 4
7801
+ ? h('div', { key: 'more-walls', style: { fontSize: 10.5, color: 'var(--dnb-text-3)' } },
7802
+ `…另有 ${activeWalls.length - 4} 堵物理驻墙共同生效中`)
7803
+ : null,
7804
+ ]
7805
+ : h('div', { style: { fontSize: 10.5, color: 'var(--dnb-text-3)' } },
7806
+ '暂未启用物理驻墙(可点右上「管理边界」手搓或手动驻防)'),
7807
+ )
7808
+ : null,
7809
+ ),
7810
+ // Sub-section 2: Forbidden Redlines
7811
+ h(
7812
+ 'div',
7813
+ {
7814
+ style: {
7815
+ borderRadius: 7,
7816
+ border: '1px solid var(--dnb-border)',
7817
+ background: 'rgba(148, 163, 184, 0.05)',
7818
+ overflow: 'hidden',
7819
+ },
7820
+ },
7821
+ h(
7822
+ 'div',
7823
+ {
7824
+ style: {
7825
+ display: 'flex',
7826
+ alignItems: 'center',
7827
+ justifyContent: 'space-between',
7828
+ gap: 6,
7829
+ padding: '5px 8px',
7830
+ cursor: 'pointer',
7831
+ userSelect: 'none',
7832
+ },
7833
+ onClick: () => setRedlinesSecCollapsed(v => !v),
7834
+ },
7835
+ h('span', { style: { fontSize: 11, fontWeight: 700, color: forbiddenList.length > 0 ? '#34d399' : 'var(--dnb-text-2)' } },
7836
+ `🚫 禁止红线(全局与本局边界 · 已生效 ${forbiddenList.length} 条)`),
7837
+ h(Icon, {
7838
+ name: 'chevron',
7839
+ size: 12,
7840
+ style: {
7841
+ color: 'var(--dnb-text-3)',
7842
+ transform: redlinesSecCollapsed ? 'none' : 'rotate(90deg)',
7843
+ transition: 'transform 0.16s ease',
7844
+ },
7845
+ }),
7846
+ ),
7847
+ !redlinesSecCollapsed
7848
+ ? h(
7849
+ 'div',
7850
+ { style: { padding: '0 8px 6px', display: 'flex', flexDirection: 'column', gap: 3 } },
7851
+ forbiddenList.length > 0
7852
+ ? [
7853
+ ...forbiddenList.slice(0, 4).map((item, idx) =>
7854
+ h('div', {
7855
+ key: idx,
7856
+ style: { fontSize: 11, color: 'var(--dnb-text-2)', lineHeight: 1.45, wordBreak: 'break-word' },
7857
+ }, '• ' + (item.length > 88 ? item.slice(0, 88) + '…' : item)),
7858
+ ),
7859
+ forbiddenList.length > 4
7860
+ ? h('div', { key: 'more-redlines', style: { fontSize: 10.5, color: 'var(--dnb-text-3)' } },
7861
+ `…另有 ${forbiddenList.length - 4} 条禁止红线共同生效中`)
7862
+ : null,
7863
+ ]
7864
+ : h('div', { style: { fontSize: 10.5, color: 'var(--dnb-text-3)' } }, '暂未设定禁止红线'),
7865
+ )
7866
+ : null,
7867
+ ),
6961
7868
  ),
6962
7869
  // 3 Concrete Operational Risks + 4-Tier Permission Behavior
6963
7870
  h(
@@ -6993,7 +7900,7 @@ window.__ModuleLoader__.load({
6993
7900
  style: { marginTop: 2 },
6994
7901
  onChange: e => patch({ interventionAgreed: Boolean(e.target.checked) }),
6995
7902
  }),
6996
- '我已核对当前目标与红线,理解底层模型与宿主提示词规则冲突可能带来偏离,并确认启用主动强介入。',
7903
+ '我已核对当前目标、物理驻墙与禁止红线,理解底层模型与宿主提示词规则冲突可能带来偏离,并确认启用主动强介入。',
6997
7904
  ),
6998
7905
  h(
6999
7906
  'div',
@@ -8197,9 +9104,13 @@ window.__ModuleLoader__.load({
8197
9104
  'div',
8198
9105
  { style: { display: 'flex', flexDirection: 'column', gap: 6, maxHeight: 340, overflowY: 'auto' } },
8199
9106
  logs.map(entry => {
8200
- const decisionColor = entry.decision === 'allow' || entry.decision === 'approved'
8201
- ? '#34d399'
8202
- : (entry.decision === 'prompt' ? '#60a5fa' : '#ff6961')
9107
+ const dec = String(entry.decision || '').toLowerCase()
9108
+ const isGreen = ['allow', 'approved', 'approved_by_user', 'executed', 'executed_approved', 'elevation_approved', 'mode_changed', 'reset_to_l0'].includes(dec)
9109
+ const isBlue = ['prompt', 'pending_approval', 'elevation_requested', 'pending'].includes(dec)
9110
+ const decisionColor = isGreen ? '#34d399' : (isBlue ? '#60a5fa' : '#ff6961')
9111
+ const ruleTag = entry.rule ? ` [${entry.rule}]` : ''
9112
+ const durTag = entry.durationMs > 0 ? `${entry.durationMs}ms · ` : ''
9113
+ const detailText = entry.summary || entry.reason || entry.outcome || ''
8203
9114
  return h(
8204
9115
  'div',
8205
9116
  { key: entry.id, className: 'dnb-audit-row' },
@@ -8207,14 +9118,14 @@ window.__ModuleLoader__.load({
8207
9118
  'div',
8208
9119
  { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6 } },
8209
9120
  h('span', { style: { fontWeight: 700, color: decisionColor } },
8210
- `${entry.stage || 'gate'} · ${entry.decision || ''} (${CHIEF_PERMISSION_LABELS[entry.mode] || entry.mode || 'advisor'})`),
9121
+ `${entry.stage || 'gate'} · ${entry.decision || ''}${ruleTag} (${CHIEF_PERMISSION_LABELS[entry.mode] || entry.mode || 'advisor'})`),
8211
9122
  h('span', { style: { fontSize: 10, color: 'var(--dnb-text-3)' } },
8212
- entry.at ? new Date(entry.at).toLocaleTimeString() : ''),
9123
+ `${durTag}${entry.at ? new Date(entry.at).toLocaleTimeString() : ''}`),
8213
9124
  ),
8214
9125
  h('div', { style: { color: 'var(--dnb-text)' } },
8215
9126
  `${entry.operation || ''}${entry.target ? ' · ' + entry.target : ''}`),
8216
- entry.outcome || entry.reason
8217
- ? h('div', { style: { color: 'var(--dnb-text-2)', wordBreak: 'break-word' } }, entry.outcome || entry.reason)
9127
+ detailText
9128
+ ? h('div', { style: { color: 'var(--dnb-text-2)', wordBreak: 'break-word' } }, detailText)
8218
9129
  : null,
8219
9130
  )
8220
9131
  }),
@@ -14598,20 +15509,320 @@ window.__ModuleLoader__.load({
14598
15509
  )
14599
15510
  }
14600
15511
 
14601
- /* ---------------------------------------------------------- Handoff Tab */
14602
-
14603
- // === [module: src/client/tabs/boundaries.js] ===
14604
- /**
14605
- * tabs/boundaries.js
14606
- *
14607
- * Global & session boundaries editor cards and BoundariesTab.
14608
- */
14609
-
14610
-
14611
- function BoundCard({ field, label, dot, items, pinnedItems }) {
15512
+ /* ---------------------------------------------------------- Handoff Tab */
15513
+
15514
+ // === [module: src/client/tabs/boundaries.js] ===
15515
+ /**
15516
+ * tabs/boundaries.js
15517
+ *
15518
+ * Global & session boundaries editor cards and BoundariesTab.
15519
+ */
15520
+
15521
+
15522
+ const WALL_TYPE_META = {
15523
+ forbid_cmd: { label: '🚫 禁跑命令', placeholder: '输入命令关键字或正则(如 npm publish、git push --force)…' },
15524
+ forbid_path: { label: '🚧 禁碰路径', placeholder: '输入禁止读写目录或文件(如 .github/workflows、DSHGuard)…' },
15525
+ restrict_write: { label: '🔐 仅限某目录可写', placeholder: '输入唯一允许写入的白名单目录绝对/相对路径…' },
15526
+ require_approval_cmd: { label: '🛡️ 高危命令先请示', placeholder: '输入需强制拦停审批的命令特征(如 prisma migrate)…' },
15527
+ deny_tool: { label: '⛔ 禁用工具', placeholder: '输入禁用的工具名(如 run_command、write_file)…' },
15528
+ }
15529
+
15530
+ function GuardWallsCard({ view }) {
15531
+ const walls = Array.isArray(view.guardWalls) ? view.guardWalls : []
15532
+ const activeCount = walls.filter(w => w && w.activeNow).length
15533
+ const collapsed = Boolean(view.wallCollapsed)
15534
+ const formOpen = Boolean(view.wallFormOpen)
15535
+ const draftField = WALL_TYPE_META[view.wallDraftField] ? view.wallDraftField : 'forbid_cmd'
15536
+ const draftScope = view.wallDraftScope === 'workspace' ? 'workspace' : 'global'
15537
+ const draftTitle = view.wallDraftTitle || ''
15538
+ const draftPattern = view.wallDraftPattern || ''
15539
+ const selectedIds = (Array.isArray(view.wallSelectedIds) ? view.wallSelectedIds : [])
15540
+ .filter(id => walls.some(w => w && w.id === id))
15541
+ const selectedSet = new Set(selectedIds)
15542
+
15543
+ const bucketCounts = {}
15544
+ for (const w of walls) {
15545
+ if (!w || !w.ruleType) continue
15546
+ const k = (w.scope === 'paused' ? 'paused|' : 'active|') + w.ruleType
15547
+ bucketCounts[k] = (bucketCounts[k] || 0) + 1
15548
+ }
15549
+ const hasMergeableWallGroup = Object.values(bucketCounts).some(c => c >= 2)
15550
+
15551
+ const submitNewWall = () => {
15552
+ void saveGuardWallApi({
15553
+ title: draftTitle,
15554
+ ruleType: draftField,
15555
+ pattern: draftPattern,
15556
+ scope: draftScope,
15557
+ })
15558
+ }
15559
+
15560
+ return h(
15561
+ 'div',
15562
+ { className: 'dnb-wall-box' },
15563
+ h(
15564
+ 'div',
15565
+ {
15566
+ className: 'dnb-cell dnb-cell-hover',
15567
+ style: { justifyContent: 'space-between', padding: '9px 12px', flexWrap: 'wrap', gap: 6, cursor: 'pointer' },
15568
+ onClick: () => patch({ wallCollapsed: !collapsed }),
15569
+ },
15570
+ h(
15571
+ 'div',
15572
+ { style: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 } },
15573
+ h(Icon, { name: 'shieldSentinel', size: 14, style: { color: activeCount > 0 ? '#ef4444' : '#f87171' } }),
15574
+ h('span', { style: { fontSize: 12.5, fontWeight: 700, color: 'var(--dnb-text)' } }, '物理驻墙 · 事前硬拦截'),
15575
+ h(
15576
+ 'span',
15577
+ {
15578
+ className: 'dnb-seg-dot',
15579
+ style: activeCount > 0 ? { background: 'rgba(239,68,68,0.18)', color: '#f87171' } : undefined,
15580
+ },
15581
+ `${activeCount}/${walls.length} 生效`,
15582
+ ),
15583
+ h(Icon, {
15584
+ name: 'chevron',
15585
+ size: 12.5,
15586
+ style: {
15587
+ color: 'var(--dnb-text-3)',
15588
+ transform: collapsed ? 'none' : 'rotate(90deg)',
15589
+ transition: 'transform 0.18s ease',
15590
+ },
15591
+ }),
15592
+ ),
15593
+ h(
15594
+ 'div',
15595
+ { style: { display: 'flex', alignItems: 'center', gap: 5, flexShrink: 0, flexWrap: 'wrap' }, onClick: e => e.stopPropagation() },
15596
+ selectedIds.length >= 2
15597
+ ? h('button', {
15598
+ type: 'button',
15599
+ className: 'dnb-pill',
15600
+ style: {
15601
+ height: 24,
15602
+ padding: '0 8px',
15603
+ fontSize: 11,
15604
+ fontWeight: 600,
15605
+ color: '#fff',
15606
+ background: '#dc2626',
15607
+ borderColor: 'rgba(248, 113, 113, 0.72)',
15608
+ },
15609
+ title: '合并已勾选的同类型物理驻墙(若误选了不同拦截类型会弹出错误提醒阻止合并)',
15610
+ onClick: () => void mergeGuardWallsApi({ wallIds: selectedIds }),
15611
+ }, `⇄ 合并所选 (${selectedIds.length})`)
15612
+ : (hasMergeableWallGroup
15613
+ ? h('button', {
15614
+ type: 'button',
15615
+ className: 'dnb-pill',
15616
+ style: {
15617
+ height: 24,
15618
+ padding: '0 8px',
15619
+ fontSize: 11,
15620
+ color: '#fca5a5',
15621
+ background: 'rgba(239, 68, 68, 0.14)',
15622
+ borderColor: 'rgba(248, 113, 113, 0.42)',
15623
+ },
15624
+ title: '仅按相同拦截类型自动合并多堵同类物理驻墙(禁碰路径只和禁碰路径合并,绝不跨类混并)',
15625
+ onClick: () => void mergeGuardWallsApi({ autoGroup: true }),
15626
+ }, '✦ 一键合并')
15627
+ : null),
15628
+ h('button', {
15629
+ type: 'button',
15630
+ className: 'dnb-pill',
15631
+ style: { height: 24, padding: '0 8px', fontSize: 11 },
15632
+ disabled: view.secBusy,
15633
+ title: '让参谋长按你的大白话帮你手搓物理驻墙规则并发起一键落锁确认',
15634
+ onClick: () => {
15635
+ void submitChiefBar(
15636
+ '请帮我根据当前工程重点保护目录与高危操作,手搓可复用的事前防御物理驻墙提案(wallProposals),默认 global 随身生效;若同时识别到需要补充的工作边界红线/必做项,也请一并填入 boundProposals,全部写入 JSON 数组供我一键确认落锁。',
15637
+ 'craft_wall',
15638
+ )
15639
+ },
15640
+ }, view.secBusy && view.chiefQuickAction === 'craft_wall' ? '⏳ 正在手搓筑墙…' : '✨ 参谋手搓筑墙'),
15641
+ h('button', {
15642
+ type: 'button',
15643
+ className: 'dnb-pill dnb-pill-accent',
15644
+ style: { height: 24, padding: '0 8px', fontSize: 11 },
15645
+ onClick: () => {
15646
+ const nextOpen = !formOpen
15647
+ patch({ wallFormOpen: nextOpen, ...(nextOpen ? { wallCollapsed: false } : {}) })
15648
+ },
15649
+ }, formOpen ? '收起' : '+ 手动驻墙'),
15650
+ ),
15651
+ ),
15652
+ view.wallMergeError
15653
+ ? h(
15654
+ 'div',
15655
+ {
15656
+ style: {
15657
+ padding: '7px 11px',
15658
+ borderTop: '1px solid rgba(248, 113, 113, 0.35)',
15659
+ background: 'rgba(239, 68, 68, 0.16)',
15660
+ color: '#fca5a5',
15661
+ fontSize: 11.5,
15662
+ fontWeight: 600,
15663
+ display: 'flex',
15664
+ alignItems: 'center',
15665
+ justifyContent: 'space-between',
15666
+ gap: 8,
15667
+ },
15668
+ },
15669
+ h('span', null, view.wallMergeError),
15670
+ h('span', { style: { cursor: 'pointer', paddingLeft: 6, flexShrink: 0 }, onClick: () => patch({ wallMergeError: '', error: '' }) }, '×'),
15671
+ )
15672
+ : null,
15673
+ formOpen
15674
+ ? h(
15675
+ 'div',
15676
+ { style: { padding: '8px 12px 10px', borderTop: '1px solid var(--dnb-border)', display: 'flex', flexDirection: 'column', gap: 7 } },
15677
+ h(
15678
+ 'div',
15679
+ { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
15680
+ h('input', {
15681
+ className: 'dnb-input',
15682
+ style: { flex: '1 1 140px', height: 28, fontSize: 11.5 },
15683
+ placeholder: '物理墙名称(如:锁死生产发布 / 保护核心配置)',
15684
+ value: draftTitle,
15685
+ onChange: e => patch({ wallDraftTitle: e.target.value }),
15686
+ }),
15687
+ h(
15688
+ 'select',
15689
+ {
15690
+ className: 'dnb-input',
15691
+ style: { width: 'auto', height: 28, fontSize: 11, padding: '0 8px' },
15692
+ value: draftField,
15693
+ onChange: e => patch({ wallDraftField: e.target.value }),
15694
+ },
15695
+ Object.entries(WALL_TYPE_META).map(([k, meta]) =>
15696
+ h('option', { key: k, value: k }, meta.label)),
15697
+ ),
15698
+ ),
15699
+ h('input', {
15700
+ className: 'dnb-input',
15701
+ style: { height: 28, fontSize: 11.5 },
15702
+ placeholder: (WALL_TYPE_META[draftField] && WALL_TYPE_META[draftField].placeholder) || '输入匹配规则(多项可用逗号分隔)',
15703
+ value: draftPattern,
15704
+ onChange: e => patch({ wallDraftPattern: e.target.value }),
15705
+ onKeyDown: e => { if (e.key === 'Enter') submitNewWall() },
15706
+ }),
15707
+ h(
15708
+ 'div',
15709
+ { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6, flexWrap: 'wrap' } },
15710
+ h(
15711
+ 'div',
15712
+ { style: { display: 'flex', gap: 5 } },
15713
+ h('button', {
15714
+ type: 'button',
15715
+ className: 'dnb-wall-scope-btn',
15716
+ 'data-active': draftScope === 'global' ? '1' : '0',
15717
+ onClick: () => patch({ wallDraftScope: 'global' }),
15718
+ }, '🌐 全局随身'),
15719
+ h('button', {
15720
+ type: 'button',
15721
+ className: 'dnb-wall-scope-btn',
15722
+ 'data-active': draftScope === 'workspace' ? '1' : '0',
15723
+ onClick: () => patch({ wallDraftScope: 'workspace' }),
15724
+ }, '📁 仅本工程'),
15725
+ ),
15726
+ h('button', {
15727
+ type: 'button',
15728
+ className: 'dnb-primary-btn',
15729
+ style: { height: 26, padding: '0 10px', fontSize: 11 },
15730
+ disabled: !draftTitle.trim() || !draftPattern.trim() || view.busy,
15731
+ onClick: submitNewWall,
15732
+ }, '🧱 立即驻防落锁'),
15733
+ ),
15734
+ )
15735
+ : null,
15736
+ !collapsed
15737
+ ? (walls.length > 0
15738
+ ? walls.map(w => {
15739
+ const typeMeta = WALL_TYPE_META[w.ruleType] || { label: w.ruleType }
15740
+ const patText = Array.isArray(w.patterns) ? w.patterns.join(' , ') : ''
15741
+ const isChecked = selectedSet.has(w.id)
15742
+ return h(
15743
+ 'div',
15744
+ { key: w.id, className: 'dnb-wall-item', style: w.scope === 'paused' ? { opacity: 0.62 } : undefined },
15745
+ h(
15746
+ 'div',
15747
+ { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6 } },
15748
+ h(
15749
+ 'div',
15750
+ { style: { display: 'flex', alignItems: 'center', gap: 5, minWidth: 0 } },
15751
+ h('span', { style: { fontSize: 12, fontWeight: 600, color: w.activeNow ? 'var(--dnb-text)' : 'var(--dnb-text-2)' } }, w.title),
15752
+ h('span', { className: 'dnb-tag', style: { fontSize: 10 } }, typeMeta.label),
15753
+ w.source === 'chief_crafted'
15754
+ ? h('span', { className: 'dnb-tag', style: { fontSize: 10, color: 'var(--dnb-accent)' } }, '参谋手搓')
15755
+ : null,
15756
+ ),
15757
+ h(
15758
+ 'div',
15759
+ { style: { display: 'inline-flex', alignItems: 'center', gap: 5, flexShrink: 0 } },
15760
+ walls.length >= 2
15761
+ ? h('button', {
15762
+ type: 'button',
15763
+ className: 'dnb-bound-check',
15764
+ 'data-checked': isChecked ? '1' : '0',
15765
+ title: isChecked ? '已勾选,可点击「合并所选」与同类型物理墙合并' : '勾选以合并多条同类型物理驻墙(禁跨类型合并)',
15766
+ onClick: () => toggleGuardWallSelect(w.id),
15767
+ }, h(Icon, { name: 'check', size: 10.5 }))
15768
+ : null,
15769
+ h('button', {
15770
+ type: 'button',
15771
+ className: 'dnb-icon-btn',
15772
+ style: { width: 20, height: 20, flexShrink: 0, color: 'var(--dnb-text-3)' },
15773
+ title: '人工拆除该物理墙(AI 模型无权调用拆除)',
15774
+ onClick: () => void removeGuardWallApi(w.id),
15775
+ }, h(Icon, { name: 'x', size: 11 })),
15776
+ ),
15777
+ ),
15778
+ h('code', {
15779
+ style: {
15780
+ display: 'block',
15781
+ width: '100%',
15782
+ fontSize: 11,
15783
+ lineHeight: 1.45,
15784
+ color: w.activeNow ? '#f87171' : 'var(--dnb-text-3)',
15785
+ fontFamily: 'ui-monospace, Menlo, Consolas, monospace',
15786
+ wordBreak: 'break-all',
15787
+ },
15788
+ }, patText),
15789
+ h(
15790
+ 'div',
15791
+ { className: 'dnb-wall-actions-row' },
15792
+ [
15793
+ { key: 'global', label: '🌐 全局' },
15794
+ { key: 'workspace', label: '📁 本工程' },
15795
+ { key: 'paused', label: '⏸ 暂挂' },
15796
+ ].map(opt =>
15797
+ h('button', {
15798
+ key: opt.key,
15799
+ type: 'button',
15800
+ className: 'dnb-wall-scope-btn',
15801
+ 'data-active': w.scope === opt.key ? '1' : '0',
15802
+ onClick: () => { if (w.scope !== opt.key) void setGuardWallScopeApi(w.id, opt.key) },
15803
+ }, opt.label)),
15804
+ ),
15805
+ )
15806
+ })
15807
+ : h(
15808
+ 'div',
15809
+ { style: { padding: '8px 12px', borderTop: '1px solid var(--dnb-border)', fontSize: 11, color: 'var(--dnb-text-3)' } },
15810
+ '尚未手动筑墙。全会话工具前拦截物理哨兵已就绪,点击右上角「+ 手动驻墙」或让参谋长手搓一条即可全对话随身生效。',
15811
+ ))
15812
+ : null,
15813
+ )
15814
+ }
15815
+
15816
+ function BoundCard({ field, label, dot, items, pinnedItems, view }) {
14612
15817
  const [editingItem, setEditingItem] = React.useState('')
14613
15818
  const [editingVal, setEditingVal] = React.useState('')
14614
15819
 
15820
+ const collapsedCols = (view && view.boundCollapsedCols) || store.boundCollapsedCols || {}
15821
+ const isColCollapsed = Boolean(collapsedCols[field])
15822
+ const toggleColCollapsed = () => patch({
15823
+ boundCollapsedCols: { ...collapsedCols, [field]: !isColCollapsed },
15824
+ })
15825
+
14615
15826
  const draft = (store.boundDraft && store.boundDraft[field]) || ''
14616
15827
  const pinDraft = Boolean(store.boundPinDraft && store.boundPinDraft[field])
14617
15828
  const list = Array.isArray(items) ? items : []
@@ -14644,7 +15855,12 @@ window.__ModuleLoader__.load({
14644
15855
  { style: { marginBottom: 12 } },
14645
15856
  h(
14646
15857
  'div',
14647
- { className: 'dnb-section-head' },
15858
+ {
15859
+ className: 'dnb-section-head',
15860
+ style: { cursor: 'pointer', userSelect: 'none' },
15861
+ title: isColCollapsed ? `点击拉开【${label}】` : `点击收起【${label}】`,
15862
+ onClick: toggleColCollapsed,
15863
+ },
14648
15864
  h(
14649
15865
  'span',
14650
15866
  {
@@ -14663,7 +15879,7 @@ window.__ModuleLoader__.load({
14663
15879
  ),
14664
15880
  h(
14665
15881
  'div',
14666
- { style: { display: 'inline-flex', alignItems: 'center', gap: 6 } },
15882
+ { style: { display: 'inline-flex', alignItems: 'center', gap: 6 }, onClick: e => e.stopPropagation() },
14667
15883
  list.length >= 2
14668
15884
  ? h('button', {
14669
15885
  className: 'dnb-pill',
@@ -14687,11 +15903,27 @@ window.__ModuleLoader__.load({
14687
15903
  : (selected.length >= 2 ? `${selected.length} 条合一` : '总结成一条'))
14688
15904
  : null,
14689
15905
  list.length ? h('span', null, String(list.length)) : null,
15906
+ h('button', {
15907
+ type: 'button',
15908
+ className: 'dnb-icon-btn',
15909
+ style: { width: 18, height: 18 },
15910
+ title: isColCollapsed ? `展开【${label}】` : `收起【${label}】`,
15911
+ onClick: toggleColCollapsed,
15912
+ }, h(Icon, {
15913
+ name: 'chevron',
15914
+ size: 12,
15915
+ style: {
15916
+ color: 'var(--dnb-text-3)',
15917
+ transform: isColCollapsed ? 'none' : 'rotate(90deg)',
15918
+ transition: 'transform 0.18s ease',
15919
+ },
15920
+ })),
14690
15921
  ),
14691
15922
  ),
14692
- h(
14693
- 'div',
14694
- { className: 'dnb-group' },
15923
+ !isColCollapsed
15924
+ ? h(
15925
+ 'div',
15926
+ { className: 'dnb-group' },
14695
15927
  list.map((item, idx) => {
14696
15928
  const isPinned = pinnedSet.has(item)
14697
15929
  const isChecked = selected.includes(item)
@@ -14813,7 +16045,8 @@ window.__ModuleLoader__.load({
14813
16045
  }, pinDraft ? '📌 定住添加' : '添加')
14814
16046
  : null,
14815
16047
  ),
14816
- ),
16048
+ )
16049
+ : null,
14817
16050
  )
14818
16051
  }
14819
16052
 
@@ -14824,6 +16057,20 @@ window.__ModuleLoader__.load({
14824
16057
  const pinnedBounds = (view.board && view.board.pinnedBounds) || {}
14825
16058
  const hasConsolidatableCol = BOUND_LISTS.some(b => ((bounds[b.field] || []).length >= 2))
14826
16059
  const totalPinnedCount = BOUND_LISTS.reduce((acc, b) => acc + ((pinnedBounds[b.field] || []).length), 0)
16060
+ const collapsedCols = view.boundCollapsedCols || {}
16061
+ const allSectionsCollapsed = Boolean(view.wallCollapsed)
16062
+ && BOUND_LISTS.every(b => Boolean(collapsedCols[b.field]))
16063
+ const toggleAllBoundSections = () => {
16064
+ if (allSectionsCollapsed) {
16065
+ patch({ wallCollapsed: false, boundCollapsedCols: {} })
16066
+ } else {
16067
+ setShowEnv(false)
16068
+ patch({
16069
+ wallCollapsed: true,
16070
+ boundCollapsedCols: { allowed: true, forbidden: true, notes: true },
16071
+ })
16072
+ }
16073
+ }
14827
16074
  const info = view.boundaries || {}
14828
16075
  const rows = [
14829
16076
  ['工作目录', info.sessionWorkingDirectory || info.workingDirectory],
@@ -14857,6 +16104,13 @@ window.__ModuleLoader__.load({
14857
16104
  ? h(
14858
16105
  'div',
14859
16106
  { style: { display: 'flex', alignItems: 'center', gap: 5, flexWrap: 'wrap' } },
16107
+ h('button', {
16108
+ type: 'button',
16109
+ className: 'dnb-pill',
16110
+ style: { height: 25, padding: '0 8px', fontSize: 11 },
16111
+ title: allSectionsCollapsed ? '一键拉开物理驻墙与全部工作边界分组' : '一键收起物理驻墙与全部工作边界分组',
16112
+ onClick: toggleAllBoundSections,
16113
+ }, allSectionsCollapsed ? '↕ 一键拉开' : '↕ 一键收起'),
14860
16114
  hasConsolidatableCol
14861
16115
  ? h('button', {
14862
16116
  className: 'dnb-pill',
@@ -14879,9 +16133,12 @@ window.__ModuleLoader__.load({
14879
16133
  disabled: view.secBusy,
14880
16134
  title: '让 DSH 参谋长结合当前撞墙记录与会话纪律提炼新边界,并发起请示供你拍板',
14881
16135
  onClick: () => {
14882
- void submitChiefBar('请结合当前会话的踩坑撞墙记录、工具权限约束与工作约定,简明分点总结工作边界,并向我发起边界注入请示(boundProposals)。')
16136
+ void submitChiefBar(
16137
+ '请结合当前会话的踩坑撞墙记录、工具权限约束与工作约定,简明分点总结工作边界,并务必完整填入 JSON 的 boundProposals 数组向我发起边界注入请示(若提到具体条文请每条都放进 boundProposals)。',
16138
+ 'extract_bounds',
16139
+ )
14883
16140
  },
14884
- }, h(Icon, { name: 'sparkles', size: 11.5 }), view.secBusy && !view.boundConsolidating ? '提炼中…' : '提炼新边界'),
16141
+ }, h(Icon, { name: 'sparkles', size: 11.5 }), view.secBusy && view.chiefQuickAction === 'extract_bounds' ? '⏳ 正在提炼边界…' : (view.secBusy && !view.boundConsolidating ? '提炼中…' : '提炼新边界')),
14885
16142
  )
14886
16143
  : null,
14887
16144
  ),
@@ -14906,6 +16163,7 @@ window.__ModuleLoader__.load({
14906
16163
  },
14907
16164
  `🏛 点击规则前的「小图钉戳」即可定住为跨任务全局共享(当前已定住 ${totalPinnedCount} 条);未定住规则仅在本任务跑。多条零散规则可勾选或直点「总结成一条」请参谋长浓缩合并。`,
14908
16165
  ),
16166
+ h(GuardWallsCard, { view }),
14909
16167
  BOUND_LISTS.map(b =>
14910
16168
  h(BoundCard, {
14911
16169
  key: b.field,
@@ -14914,6 +16172,7 @@ window.__ModuleLoader__.load({
14914
16172
  dot: b.dot,
14915
16173
  items: bounds[b.field] || [],
14916
16174
  pinnedItems: pinnedBounds[b.field] || [],
16175
+ view,
14917
16176
  }),
14918
16177
  ),
14919
16178
  h(
@@ -15198,15 +16457,50 @@ window.__ModuleLoader__.load({
15198
16457
  '当前会话尚未沉淀持久规矩或阶段结论。你可以在下方许愿框直接立规矩、整档案、定边界或吩咐参谋长调度。'),
15199
16458
  ),
15200
16459
 
15201
- // Partitioned Chief Q&A Conversations vs System / Execution Receipts
16460
+ // Partitioned Chief Q&A Turn Collections vs System / Execution Receipts
15202
16461
  chat.length > 0
15203
16462
  ? (() => {
15204
- const ordered = orderChatHistoryNewestFirst(chat.slice(-28))
15205
- const receiptCount = ordered.filter(it => isReceiptChatItem(it)).length
15206
- const qaCount = Math.max(0, ordered.length - receiptCount)
15207
- const filtered = chatFilter === 'receipt'
15208
- ? ordered.filter(it => isReceiptChatItem(it))
15209
- : (chatFilter === 'qa' ? ordered.filter(it => !isReceiptChatItem(it)) : ordered)
16463
+ const turns = groupChatHistoryTurnsNewestFirst(chat.slice(-32))
16464
+ const qaCount = turns.filter(t => t.kind === 'turn').length
16465
+ const receiptCount = turns.filter(t => t.replies.some(r => isReceiptChatItem(r))).length
16466
+ const filteredTurns = chatFilter === 'receipt'
16467
+ ? turns.filter(t => t.replies.some(r => isReceiptChatItem(r)))
16468
+ : (chatFilter === 'qa' ? turns.filter(t => t.kind === 'turn') : turns)
16469
+
16470
+ const renderTurnReplyCard = (item) => {
16471
+ const isReceipt = isReceiptChatItem(item)
16472
+ return h(
16473
+ 'div',
16474
+ {
16475
+ key: item.id,
16476
+ className: 'dnb-turn-reply-item',
16477
+ 'data-role': isReceipt ? 'receipt' : (item.role === 'chief' ? 'chief' : 'user'),
16478
+ },
16479
+ h(
16480
+ 'div',
16481
+ { style: { display: 'flex', width: '100%', justifyContent: 'space-between', alignItems: 'center', fontSize: 11, color: 'var(--dnb-text-3)', gap: 6 } },
16482
+ h(
16483
+ 'div',
16484
+ { style: { display: 'flex', alignItems: 'center', gap: 5 } },
16485
+ isReceipt
16486
+ ? h('span', { className: 'dnb-receipt-badge' },
16487
+ item.resumeTaskId ? '⚡ 授权续跑回执' : '📋 执行回执')
16488
+ : h('span', { className: 'dnb-qa-badge', 'data-role': 'chief' }, '✦ 参谋回答'),
16489
+ ),
16490
+ h('span', null, timeLabel(item.at)),
16491
+ ),
16492
+ renderStructuredText(item.text),
16493
+ Array.isArray(item.actions) && item.actions.length
16494
+ ? h(
16495
+ 'div',
16496
+ { style: { display: 'flex', gap: 4, flexWrap: 'wrap', marginTop: 2 } },
16497
+ item.actions.map((actTag, idx) =>
16498
+ h('span', { key: idx, className: 'dnb-tag', style: { color: isReceipt ? '#34d399' : 'var(--dnb-accent)' } }, actTag)),
16499
+ )
16500
+ : null,
16501
+ )
16502
+ }
16503
+
15210
16504
  return h(
15211
16505
  'div',
15212
16506
  { className: 'dnb-group' },
@@ -15219,109 +16513,210 @@ window.__ModuleLoader__.load({
15219
16513
  },
15220
16514
  h('span', { style: { fontSize: 12, color: 'var(--dnb-text-2)', fontWeight: 600 } },
15221
16515
  '参谋问答与执行回执'),
15222
- h(
15223
- 'div',
15224
- { style: { display: 'flex', alignItems: 'center', gap: 5 }, onClick: e => e.stopPropagation() },
15225
- h(
16516
+ (() => {
16517
+ const collapsedMap = view.qaCollapsedTurnIds || {}
16518
+ const allTurnsCollapsed = showHistory && filteredTurns.length > 0 && filteredTurns.every(t => Boolean(collapsedMap[t.id]))
16519
+ return h(
15226
16520
  'div',
15227
- { className: 'dnb-filter-seg' },
15228
- [
15229
- { key: 'all', label: `全部 (${ordered.length})` },
15230
- { key: 'qa', label: `💬 问答 (${qaCount})` },
15231
- { key: 'receipt', label: `📋 回执 (${receiptCount})` },
15232
- ].map(opt =>
15233
- h('button', {
15234
- key: opt.key,
15235
- type: 'button',
15236
- className: 'dnb-filter-btn',
15237
- 'data-active': chatFilter === opt.key ? '1' : '0',
15238
- onClick: () => {
15239
- setChatFilter(opt.key)
15240
- if (!showHistory) setShowHistory(true)
15241
- },
15242
- }, opt.label),
16521
+ { style: { display: 'flex', alignItems: 'center', gap: 5, flexWrap: 'wrap' }, onClick: e => e.stopPropagation() },
16522
+ filteredTurns.length > 0
16523
+ ? h('button', {
16524
+ type: 'button',
16525
+ className: 'dnb-pill',
16526
+ style: { height: 22, padding: '0 8px', fontSize: 10.5 },
16527
+ title: allTurnsCollapsed ? '一键拉开全部会话框' : '一键收起全部会话框',
16528
+ onClick: () => {
16529
+ if (!showHistory) {
16530
+ setShowHistory(true)
16531
+ patch({ qaCollapsedTurnIds: {} })
16532
+ return
16533
+ }
16534
+ if (allTurnsCollapsed) {
16535
+ patch({ qaCollapsedTurnIds: {} })
16536
+ } else {
16537
+ const nextMap = {}
16538
+ for (const t of filteredTurns) nextMap[t.id] = true
16539
+ patch({ qaCollapsedTurnIds: nextMap })
16540
+ }
16541
+ },
16542
+ }, allTurnsCollapsed ? '↕ 一键拉开' : '↕ 一键收起')
16543
+ : null,
16544
+ h(
16545
+ 'div',
16546
+ { className: 'dnb-filter-seg' },
16547
+ [
16548
+ { key: 'all', label: `全部 (${turns.length})` },
16549
+ { key: 'qa', label: `💬 问答 (${qaCount})` },
16550
+ { key: 'receipt', label: `📋 回执 (${receiptCount})` },
16551
+ ].map(opt =>
16552
+ h('button', {
16553
+ key: opt.key,
16554
+ type: 'button',
16555
+ className: 'dnb-filter-btn',
16556
+ 'data-active': chatFilter === opt.key ? '1' : '0',
16557
+ onClick: () => {
16558
+ setChatFilter(opt.key)
16559
+ if (!showHistory) setShowHistory(true)
16560
+ },
16561
+ }, opt.label),
16562
+ ),
15243
16563
  ),
15244
- ),
15245
- h('button', {
15246
- type: 'button',
15247
- className: 'dnb-icon-btn',
15248
- style: { width: 20, height: 20 },
15249
- onClick: () => setShowHistory(v => !v),
15250
- }, h(Icon, {
15251
- name: 'chevron',
15252
- size: 13,
15253
- style: {
15254
- color: 'var(--dnb-text-3)',
15255
- transform: showHistory ? 'rotate(90deg)' : 'none',
15256
- transition: 'transform 0.18s ease',
15257
- },
15258
- })),
15259
- ),
16564
+ h('button', {
16565
+ type: 'button',
16566
+ className: 'dnb-icon-btn',
16567
+ style: { width: 20, height: 20 },
16568
+ onClick: () => setShowHistory(v => !v),
16569
+ }, h(Icon, {
16570
+ name: 'chevron',
16571
+ size: 13,
16572
+ style: {
16573
+ color: 'var(--dnb-text-3)',
16574
+ transform: showHistory ? 'rotate(90deg)' : 'none',
16575
+ transition: 'transform 0.18s ease',
16576
+ },
16577
+ })),
16578
+ )
16579
+ })(),
15260
16580
  ),
15261
16581
  showHistory
15262
- ? (filtered.length > 0
15263
- ? filtered.map(item => {
15264
- const isReceipt = isReceiptChatItem(item)
15265
- return h(
15266
- 'div',
15267
- {
15268
- key: item.id,
15269
- className: isReceipt ? 'dnb-cell dnb-receipt-card' : 'dnb-cell dnb-qa-card',
15270
- style: { flexDirection: 'column', alignItems: 'flex-start', gap: 4 },
15271
- },
15272
- h(
16582
+ ? (filteredTurns.length > 0
16583
+ ? h(
16584
+ 'div',
16585
+ { className: 'dnb-qa-stream' },
16586
+ filteredTurns.map(turn => {
16587
+ const q = turn.question
16588
+ const repliesToShow = chatFilter === 'receipt' && turn.kind === 'system'
16589
+ ? turn.replies.filter(r => isReceiptChatItem(r))
16590
+ : turn.replies
16591
+ const collapsedMap = view.qaCollapsedTurnIds || {}
16592
+ const isTurnCollapsed = Boolean(collapsedMap[turn.id])
16593
+ const toggleTurn = () => patch({
16594
+ qaCollapsedTurnIds: {
16595
+ ...(view.qaCollapsedTurnIds || {}),
16596
+ [turn.id]: !isTurnCollapsed,
16597
+ },
16598
+ })
16599
+ return h(
15273
16600
  'div',
15274
- { style: { display: 'flex', width: '100%', justifyContent: 'space-between', alignItems: 'center', fontSize: 11, color: 'var(--dnb-text-3)', gap: 6 } },
15275
- h(
15276
- 'div',
15277
- { style: { display: 'flex', alignItems: 'center', gap: 5 } },
15278
- isReceipt
15279
- ? h('span', { className: 'dnb-receipt-badge' },
15280
- item.resumeTaskId ? '⚡ 授权续跑回执' : '📋 执行回执')
15281
- : h('span', { className: 'dnb-qa-badge', 'data-role': item.role === 'chief' ? 'chief' : 'user' },
15282
- item.role === 'chief' ? '✦ 参谋回答' : '🙋 你的提问'),
15283
- ),
15284
- h('span', null, timeLabel(item.at)),
15285
- ),
15286
- item.role === 'chief'
15287
- ? renderStructuredText(item.text)
15288
- : h(
15289
- React.Fragment,
15290
- null,
15291
- item.imageCount > 0
15292
- ? h(
16601
+ {
16602
+ key: turn.id,
16603
+ className: 'dnb-qa-turn-box',
16604
+ 'data-turn-kind': turn.kind,
16605
+ 'data-collapsed': isTurnCollapsed ? '1' : '0',
16606
+ },
16607
+ q
16608
+ ? h(
16609
+ 'div',
16610
+ {
16611
+ className: 'dnb-turn-question',
16612
+ title: isTurnCollapsed ? '点击拉开该轮对话与回执' : '点击收起该轮对话与回执',
16613
+ onClick: toggleTurn,
16614
+ },
16615
+ h(
16616
+ 'div',
16617
+ { style: { display: 'flex', width: '100%', justifyContent: 'space-between', alignItems: 'center', fontSize: 11, color: 'var(--dnb-text-3)', gap: 6 } },
16618
+ h(
16619
+ 'div',
16620
+ { style: { display: 'flex', alignItems: 'center', gap: 5 } },
16621
+ h('span', { className: 'dnb-qa-badge', 'data-role': 'user' }, '🙋 你的提问'),
16622
+ repliesToShow.length > 0
16623
+ ? h('span', { style: { fontSize: 10, color: 'var(--dnb-text-3)' } }, `含 ${repliesToShow.length} 条回复/回执`)
16624
+ : null,
16625
+ ),
16626
+ h(
15293
16627
  'div',
15294
- {
16628
+ { style: { display: 'inline-flex', alignItems: 'center', gap: 4 } },
16629
+ h('span', null, timeLabel(q.at)),
16630
+ h(Icon, {
16631
+ name: 'chevron',
16632
+ size: 12,
15295
16633
  style: {
15296
- display: 'inline-flex',
15297
- alignItems: 'center',
15298
- gap: 4,
15299
- padding: '1px 7px',
15300
- marginBottom: item.text ? 4 : 0,
15301
- borderRadius: 999,
15302
- background: 'rgba(10, 132, 255, 0.15)',
15303
- color: '#409cff',
15304
- fontSize: 10.5,
15305
- fontWeight: 600,
16634
+ color: 'var(--dnb-text-3)',
16635
+ transform: isTurnCollapsed ? 'none' : 'rotate(90deg)',
16636
+ transition: 'transform 0.16s ease',
15306
16637
  },
15307
- },
15308
- `🖼 附图 ×${item.imageCount}`,
15309
- )
15310
- : null,
15311
- item.text
15312
- ? h('div', { style: { fontSize: 12, color: 'var(--dnb-text)', lineHeight: 1.5, whiteSpace: 'pre-wrap' } }, item.text)
15313
- : null,
15314
- ),
15315
- Array.isArray(item.actions) && item.actions.length
15316
- ? h(
15317
- 'div',
15318
- { style: { display: 'flex', gap: 4, flexWrap: 'wrap', marginTop: 2 } },
15319
- item.actions.map((actTag, idx) =>
15320
- h('span', { key: idx, className: 'dnb-tag', style: { color: isReceipt ? '#34d399' : 'var(--dnb-accent)' } }, actTag)),
15321
- )
15322
- : null,
15323
- )
15324
- })
16638
+ }),
16639
+ ),
16640
+ ),
16641
+ !isTurnCollapsed && q.imageCount > 0
16642
+ ? h(
16643
+ 'div',
16644
+ {
16645
+ style: {
16646
+ display: 'inline-flex',
16647
+ alignItems: 'center',
16648
+ gap: 4,
16649
+ padding: '1px 7px',
16650
+ width: 'fit-content',
16651
+ borderRadius: 999,
16652
+ background: 'rgba(10, 132, 255, 0.15)',
16653
+ color: '#409cff',
16654
+ fontSize: 10.5,
16655
+ fontWeight: 600,
16656
+ },
16657
+ },
16658
+ `🖼 附图 ×${q.imageCount}`,
16659
+ )
16660
+ : null,
16661
+ q.text
16662
+ ? h('div', {
16663
+ style: isTurnCollapsed
16664
+ ? {
16665
+ fontSize: 12,
16666
+ color: 'var(--dnb-text)',
16667
+ lineHeight: 1.45,
16668
+ overflow: 'hidden',
16669
+ textOverflow: 'ellipsis',
16670
+ whiteSpace: 'nowrap',
16671
+ }
16672
+ : { fontSize: 12, color: 'var(--dnb-text)', lineHeight: 1.5, whiteSpace: 'pre-wrap' },
16673
+ }, q.text)
16674
+ : null,
16675
+ )
16676
+ : h(
16677
+ 'div',
16678
+ {
16679
+ className: 'dnb-turn-question',
16680
+ title: isTurnCollapsed ? '点击拉开该组回执' : '点击收起该组回执',
16681
+ onClick: toggleTurn,
16682
+ },
16683
+ h(
16684
+ 'div',
16685
+ { style: { display: 'flex', width: '100%', justifyContent: 'space-between', alignItems: 'center', fontSize: 11, color: 'var(--dnb-text-3)', gap: 6 } },
16686
+ h(
16687
+ 'div',
16688
+ { style: { display: 'flex', alignItems: 'center', gap: 5 } },
16689
+ h('span', { className: 'dnb-receipt-badge' }, '📋 系统回执集合'),
16690
+ repliesToShow.length > 0
16691
+ ? h('span', { style: { fontSize: 10, color: 'var(--dnb-text-3)' } }, `含 ${repliesToShow.length} 条回执`)
16692
+ : null,
16693
+ ),
16694
+ h(
16695
+ 'div',
16696
+ { style: { display: 'inline-flex', alignItems: 'center', gap: 4 } },
16697
+ turn.at ? h('span', null, timeLabel(turn.at)) : null,
16698
+ h(Icon, {
16699
+ name: 'chevron',
16700
+ size: 12,
16701
+ style: {
16702
+ color: 'var(--dnb-text-3)',
16703
+ transform: isTurnCollapsed ? 'none' : 'rotate(90deg)',
16704
+ transition: 'transform 0.16s ease',
16705
+ },
16706
+ }),
16707
+ ),
16708
+ ),
16709
+ ),
16710
+ !isTurnCollapsed && repliesToShow.length > 0
16711
+ ? h(
16712
+ 'div',
16713
+ { className: 'dnb-turn-replies' },
16714
+ repliesToShow.map(renderTurnReplyCard),
16715
+ )
16716
+ : null,
16717
+ )
16718
+ }),
16719
+ )
15325
16720
  : h('div', { className: 'dnb-cell', style: { fontSize: 11.5, color: 'var(--dnb-text-3)' } },
15326
16721
  chatFilter === 'receipt' ? '暂无执行与系统回执记录' : '暂无问答对话记录'))
15327
16722
  : null,
@@ -15908,10 +17303,23 @@ window.__ModuleLoader__.load({
15908
17303
  h(
15909
17304
  'div',
15910
17305
  { style: { flex: 1, minWidth: 0 } },
15911
- h('div', { style: { fontSize: 12, fontWeight: 600, color: 'var(--dnb-text)' } }, '🛡 红线越界哨兵'),
15912
- h('div', { style: { fontSize: 11, color: 'var(--dnb-text-3)', marginTop: 1 } }, '触碰禁止红线时立即发高优纠偏或拦截'),
17306
+ h(
17307
+ 'div',
17308
+ { style: { fontSize: 12, fontWeight: 600, color: tm.redlineSentinel ? '#f87171' : 'var(--dnb-text)', display: 'flex', alignItems: 'center' } },
17309
+ h(Icon, {
17310
+ name: 'shieldSentinel',
17311
+ size: 14,
17312
+ style: {
17313
+ color: tm.redlineSentinel ? '#ef4444' : 'var(--dnb-text-3)',
17314
+ marginRight: 5,
17315
+ filter: tm.redlineSentinel ? 'drop-shadow(0 0 4px rgba(239,68,68,0.45))' : undefined,
17316
+ },
17317
+ }),
17318
+ '红线越界哨兵',
17319
+ ),
17320
+ h('div', { style: { fontSize: 11, color: 'var(--dnb-text-3)', marginTop: 1 } }, '触碰禁止红线或物理驻墙时立即高优拦截'),
15913
17321
  ),
15914
- h(Switch, { checked: Boolean(tm.redlineSentinel), onChange: v => toggleTacticalField('redlineSentinel', v) }),
17322
+ h(Switch, { checked: Boolean(tm.redlineSentinel), tone: 'red', onChange: v => toggleTacticalField('redlineSentinel', v) }),
15915
17323
  ),
15916
17324
  // Row 5: Concise Brief
15917
17325
  h(
@@ -16001,8 +17409,9 @@ window.__ModuleLoader__.load({
16001
17409
  ? h('button', {
16002
17410
  type: 'button',
16003
17411
  className: 'dnb-tac-chip',
17412
+ 'data-tone': 'red',
16004
17413
  onClick: () => patch({ tacticalMenuOpen: !view.tacticalMenuOpen }),
16005
- }, '🛡 红线哨兵')
17414
+ }, h(Icon, { name: 'shieldSentinel', size: 13, style: { color: '#ef4444' } }), '红线哨兵')
16006
17415
  : null,
16007
17416
  guard.circuitBroken
16008
17417
  ? h('span', {
@@ -16840,6 +18249,41 @@ window.__ModuleLoader__.load({
16840
18249
  */
16841
18250
 
16842
18251
 
18252
+ function ChiefWorkStageOverlay({ fx }) {
18253
+ if (!fx || !fx.label) return null
18254
+ const tone = fx.tone || 'neon'
18255
+ const chars = Array.from(String(fx.label))
18256
+ return h(
18257
+ React.Fragment,
18258
+ null,
18259
+ h('div', { className: 'dnb-chief-fx-border', 'data-tone': tone, 'aria-hidden': true }),
18260
+ h(
18261
+ 'div',
18262
+ { className: 'dnb-chief-fx-stage', 'data-tone': tone, role: 'status', 'aria-live': 'polite' },
18263
+ h(
18264
+ 'div',
18265
+ { className: 'dnb-chief-fx-pill' },
18266
+ h('span', { className: 'dnb-chief-fx-ring', 'aria-hidden': true }),
18267
+ h(
18268
+ 'div',
18269
+ { className: 'dnb-chief-fx-text' },
18270
+ chars.map((ch, idx) =>
18271
+ h(
18272
+ 'span',
18273
+ {
18274
+ key: idx,
18275
+ className: 'dnb-wave-char',
18276
+ style: { '--char-i': idx },
18277
+ },
18278
+ ch === ' ' ? '\u00A0' : ch,
18279
+ ),
18280
+ ),
18281
+ ),
18282
+ ),
18283
+ ),
18284
+ )
18285
+ }
18286
+
16843
18287
  function PanelInner(props) {
16844
18288
  const view = useStore()
16845
18289
  const isPage = !!(props && props.variant === 'main')
@@ -17188,6 +18632,9 @@ window.__ModuleLoader__.load({
17188
18632
  // Persistent Bottom Chief Input & Relay Bar
17189
18633
  h(ChiefComposerBar, { view, barRef: secBarRef }),
17190
18634
 
18635
+ // Chief System Active Working Stage FX Overlay (Frontend action OR Backend auto-maintenance)
18636
+ h(ChiefWorkStageOverlay, { fx: view.chiefWorkFx || (meta && meta.activeWork) || null }),
18637
+
17191
18638
  // Scoped Modal Overlays (Strictly bounded inside .dnb-panel)
17192
18639
  h(ChiefRiskConfirmModal, { view }),
17193
18640
  h(OperationApprovalModal, { view }),