dsh-chief 1.4.0 → 1.5.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/CHANGELOG.md +42 -0
- package/README.en.md +66 -50
- package/README.md +67 -50
- package/api-routes.js +165 -3
- package/archive-core.js +136 -8
- package/archive-dossiers.js +450 -20
- package/archive-precipitated.js +115 -36
- package/auto-continue.js +13 -5
- package/board-actions.js +59 -4
- package/board-schema.js +1 -1
- package/chief-approvals.js +176 -11
- package/chief-archives.js +157 -30
- package/chief-commands.js +565 -101
- package/chief-models.js +158 -28
- package/chief-review.js +211 -70
- package/chief-state.js +362 -32
- package/chief-view.js +17 -14
- package/client.js +3744 -2207
- package/digest.js +18 -9
- package/model-tools.js +15 -5
- package/package.json +9 -4
- package/runtime-hooks.js +115 -12
- package/subagent-runtime.js +257 -1
package/digest.js
CHANGED
|
@@ -325,13 +325,16 @@ function linkedPeersLines(extras, limit = 4) {
|
|
|
325
325
|
|
|
326
326
|
function takenOutArchiveLines(extras, limit, budget) {
|
|
327
327
|
const taken = extras && Array.isArray(extras.takenOutArchives) ? extras.takenOutArchives : []
|
|
328
|
-
const
|
|
329
|
-
if (!taken.length && !
|
|
328
|
+
const hooks = extras && Array.isArray(extras.sessionHookedArchives) ? extras.sessionHookedArchives : []
|
|
329
|
+
if (!taken.length && !hooks.length) return []
|
|
330
330
|
const linesOut = []
|
|
331
|
+
const total = Number.isFinite(budget) ? Math.max(220, budget) : ANCHOR_BUDGET
|
|
331
332
|
if (taken.length) {
|
|
332
|
-
const shown = taken.slice(0, limit ||
|
|
333
|
-
const
|
|
334
|
-
|
|
333
|
+
const shown = taken.slice(0, limit || 6)
|
|
334
|
+
const tokLabel = Number.isFinite(Number(extras && extras.desktopUsedTokens)) && Number(extras.desktopUsedTokens) > 0
|
|
335
|
+
? ` · ${Number(extras.desktopUsedTokens)}/2400 Tokens`
|
|
336
|
+
: ''
|
|
337
|
+
const header = `📌 桌面在读档案(主代理与参谋同看 · 唯一正文注入源 · ${taken.length} 份${tokLabel}):`
|
|
335
338
|
const build = perItem =>
|
|
336
339
|
[header].concat(
|
|
337
340
|
shown.map(item => {
|
|
@@ -348,10 +351,16 @@ function takenOutArchiveLines(extras, limit, budget) {
|
|
|
348
351
|
}
|
|
349
352
|
linesOut.push(...lines)
|
|
350
353
|
}
|
|
351
|
-
if (
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
354
|
+
if (hooks.length) {
|
|
355
|
+
const shownHooks = hooks.slice(0, 6)
|
|
356
|
+
linesOut.push('🪝 本局档案柜可用钩子(参谋已整理 · 需看正文请调 chief_board({ action: "archive.pull", id: "档案ID" }) 拉出):')
|
|
357
|
+
for (const hItem of shownHooks) {
|
|
358
|
+
const kws = Array.isArray(hItem.hookKeywords) && hItem.hookKeywords.length
|
|
359
|
+
? ' ' + hItem.hookKeywords.slice(0, 4).map(k => '#' + clamp(k, 14)).join(' ')
|
|
360
|
+
: ''
|
|
361
|
+
const cue = hItem.hookCue ? ' — ' + clamp(hItem.hookCue, 34) : ''
|
|
362
|
+
linesOut.push(` · [${hItem.id}] 《${clamp(hItem.title || '未命名', 30)}》${kws}${cue}`)
|
|
363
|
+
}
|
|
355
364
|
}
|
|
356
365
|
return linesOut
|
|
357
366
|
}
|
package/model-tools.js
CHANGED
|
@@ -91,6 +91,7 @@ export function createModelTools(deps) {
|
|
|
91
91
|
'note.remove',
|
|
92
92
|
'note.read',
|
|
93
93
|
'archive.search',
|
|
94
|
+
'archive.pull',
|
|
94
95
|
'archive.read',
|
|
95
96
|
'archive.save',
|
|
96
97
|
'context.compact',
|
|
@@ -107,11 +108,12 @@ export function createModelTools(deps) {
|
|
|
107
108
|
+ 'Use "graph.plan" (or "task.batch") to plan a hierarchical/DAG task graph in one call (supports parentId, blockedBy, owner/subagent, intent, evidence). '
|
|
108
109
|
+ 'Use "task.dispatch" to spawn or message a subagent, "team.steer" to steer a subagent, and "mail.send" to relay messages across lead/subagents/sessions. '
|
|
109
110
|
+ 'Use "inquiry.reply" (inquiryId, text) whenever you see a priority [INQUIRY #id] from DSH Chief — answer accurately and continue your current work immediately without stopping. '
|
|
110
|
-
+ 'Use "chief.request" (subject, text) to ask DSH Chief for cross-session coordination, permission elevation,
|
|
111
|
+
+ 'Use "chief.request" (subject, text) to ask DSH Chief for cross-session coordination, permission elevation, to report exploration & planning results, or when blocked by an insurmountable guard wall that cannot be bypassed safely. '
|
|
111
112
|
+ 'Use "wall.list" (read-only) to inspect currently active persistent guard walls defending high-risk paths/commands. '
|
|
112
113
|
+ 'Use "bounds.propose" (field: "forbidden"|"allowed"|"notes", item, reason) when hitting a permission/sandbox/environment wall or summarizing boundaries ("allowed" = 必做事项, "forbidden" = 禁止红线, "notes" = 注意事项) so DSH Chief can request user approval. '
|
|
113
114
|
+ 'Use "permission.request" (targetMode: "assistant"|"strategist"|"chief", reason) when requesting higher DSH Chief permission tier from the user. '
|
|
114
|
-
+ 'Session Engineering Archives ("archive.search", "archive.read", "archive.save") access ONLY the current conversation\'s Session Cabinet (never Global Cabinet or unflipped Precipitated cold vault). '
|
|
115
|
+
+ 'Session Engineering Archives ("archive.search", "archive.pull", "archive.read", "archive.save") access ONLY the current conversation\'s Session Cabinet (never Global Cabinet or unflipped Precipitated cold vault). '
|
|
116
|
+
+ 'When you see a hook 🪝 in the digest, call "archive.pull" (with id or title) to read that curated dossier on demand. '
|
|
115
117
|
+ 'When Smart Co-Managed Compaction ("✦ 智选") is enabled, call "context.compact" with a concise phase-summary in "text" at clean phase boundaries to ask DSH Chief to harvest details into this session\'s cabinet and compact.',
|
|
116
118
|
},
|
|
117
119
|
tasks: {
|
|
@@ -176,10 +178,10 @@ export function createModelTools(deps) {
|
|
|
176
178
|
enum: ['plan', 'goal'],
|
|
177
179
|
description: 'mode.set: how this board is run. plan = a list of steps being ticked off. goal = one persistent objective steered toward.',
|
|
178
180
|
},
|
|
179
|
-
id: { type: 'string', description: 'Task id for update/claim/release/remove/dispatch/verify, or archive id for archive.read / archive.save.' },
|
|
181
|
+
id: { type: 'string', description: 'Task id for update/claim/release/remove/dispatch/verify, or archive id for archive.pull / archive.read / archive.save.' },
|
|
180
182
|
inquiryId: { type: 'string', description: 'Inquiry id (e.g. inq_xxx) when action is "inquiry.reply".' },
|
|
181
183
|
noteId: { type: 'string', description: 'Note id for note.write / note.pin / note.unpin / note.remove; omit to create a new note.' },
|
|
182
|
-
archiveId: { type: 'string', description: 'Archive dossier id for archive.read / archive.save (on-demand
|
|
184
|
+
archiveId: { type: 'string', description: 'Archive dossier id for archive.pull / archive.read / archive.save (on-demand session cabinet lookup/pull).' },
|
|
183
185
|
query: { type: 'string', description: 'Keyword query for archive.search (searched only on explicit user demand).' },
|
|
184
186
|
folder: { type: 'string', description: 'Filing cabinet drawer id for archive.search / archive.save (coords / incidents / contracts / ops / plans / inbox).' },
|
|
185
187
|
paperclip: { type: 'string', enum: ['gold', 'silver', 'copper'], description: 'Paperclip importance badge for archive.save ("gold" anchor, "silver" verified, "copper" historical).' },
|
|
@@ -268,6 +270,11 @@ export function createModelTools(deps) {
|
|
|
268
270
|
description: 'mail.send: delivery posture ("steer" cuts into next step boundary, "followup" queues/wakes next turn, "silent" drops into chief inbox for next pre-step).',
|
|
269
271
|
},
|
|
270
272
|
unreadOnly: { type: 'boolean', description: 'mail.inbox: when true, returns only unread messages.' },
|
|
273
|
+
reasoningEffort: {
|
|
274
|
+
type: 'string',
|
|
275
|
+
enum: ['off', 'low', 'medium', 'high', 'xhigh'],
|
|
276
|
+
description: 'task.dispatch: optional model reasoning effort hint (respects user 🔒 lock).',
|
|
277
|
+
},
|
|
271
278
|
by: { type: 'string', description: 'Who acts: an agent label or a user name. Defaults to "agent".' },
|
|
272
279
|
session: { type: 'string', description: 'Session id that owns the change; the GUI fills it automatically.' },
|
|
273
280
|
scope: { type: 'string', enum: ['session', 'shared'], description: 'Board to hit. Default "session" = the caller\'s own (or root tree) board; "shared" = the machine-wide anchor board.' },
|
|
@@ -304,7 +311,10 @@ export function createModelTools(deps) {
|
|
|
304
311
|
}
|
|
305
312
|
if (view.archiveItem) {
|
|
306
313
|
const it = view.archiveItem
|
|
307
|
-
|
|
314
|
+
const hooks = Array.isArray(it.hookKeywords) && it.hookKeywords.length ? ` 🪝[${it.hookKeywords.join(' · ')}]` : ''
|
|
315
|
+
const pulledTag = Array.isArray(it.leadPulledSessions) && it.leadPulledSessions.length ? ' · 📖 主代理已拉阅' : ''
|
|
316
|
+
lines.push('📎 archive «' + it.title + '» [' + it.folder + ' · ' + it.paperclip + pulledTag + '] (' + it.id + ')' + hooks)
|
|
317
|
+
if (it.hookCue) lines.push('hookCue: ' + it.hookCue)
|
|
308
318
|
lines.push('summary: ' + (it.summary || ''))
|
|
309
319
|
for (const pt of Array.isArray(it.points) ? it.points : []) {
|
|
310
320
|
lines.push(' • ' + pt.title + ': ' + (pt.detail || pt.cue || ''))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-chief",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"icon": "icon.svg",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Right-sidebar supervisor for DeepSeek Harness (DSH): prevents context-compaction amnesia, monitors subagent DAGs, gates file edits and shell commands behind per-action approvals, breaks runaway loops, and hands off long sessions without bloating prompt tokens.",
|
|
@@ -50,7 +50,12 @@
|
|
|
50
50
|
"防死循环",
|
|
51
51
|
"只读护栏",
|
|
52
52
|
"ai-manager",
|
|
53
|
-
"superagent"
|
|
53
|
+
"superagent",
|
|
54
|
+
"cognitive-desktop",
|
|
55
|
+
"thinking-effort",
|
|
56
|
+
"dream-roam",
|
|
57
|
+
"认知桌面",
|
|
58
|
+
"物理驻墙"
|
|
54
59
|
],
|
|
55
60
|
"engines": {
|
|
56
61
|
"node": ">=22.13.0",
|
|
@@ -61,8 +66,8 @@
|
|
|
61
66
|
"build:client": "node ./scripts/build-client.mjs",
|
|
62
67
|
"check:client": "node ./scripts/build-client.mjs --check",
|
|
63
68
|
"check:syntax": "node -e \"const fs=require('fs'),path=require('path'),cp=require('child_process');const walk=d=>{for(const e of fs.readdirSync(d,{withFileTypes:true})){const p=path.join(d,e.name);if(e.isDirectory()&&(e.name==='safety'||e.name==='src'||e.name==='client'))walk(p);else if(e.isFile()&&e.name.endsWith('.js'))cp.execFileSync(process.execPath,['--check',p]);}};walk('.');\"",
|
|
64
|
-
"test:ci": "npm run check:client && npm run check:syntax && node ./tests/verify-v130-release-gate.mjs && node ./tests/verify-v140-safety-gate.mjs && node ./tests/verify-v140-collab-gate.mjs",
|
|
65
|
-
"test": "node ./tests/verify-v130-release-gate.mjs && node ./tests/verify-v140-safety-gate.mjs && node ./tests/verify-v140-collab-gate.mjs && node -e \"const fs=require('fs'),path=require('path'),cp=require('child_process');if(fs.existsSync('../tools')){for(const s of ['verify-chief-facade-split.mjs','verify-index-modular-split.mjs','verify-archives-modular-split.mjs','verify-client-modular-build.mjs','verify-v121-permissions-and-ui.mjs','verify-compaction-and-blank-chat.mjs','check-action-surface.mjs','verify-v130-four-chains.mjs']){cp.execFileSync(process.execPath,[path.resolve('..','tools',s)],{stdio:'inherit'});}}\""
|
|
69
|
+
"test:ci": "npm run check:client && npm run check:syntax && node ./tests/verify-v130-release-gate.mjs && node ./tests/verify-v140-safety-gate.mjs && node ./tests/verify-v140-collab-gate.mjs && node ./tests/verify-v150-final-gate.mjs",
|
|
70
|
+
"test": "node ./tests/verify-v130-release-gate.mjs && node ./tests/verify-v140-safety-gate.mjs && node ./tests/verify-v140-collab-gate.mjs && node ./tests/verify-v150-final-gate.mjs && node -e \"const fs=require('fs'),path=require('path'),cp=require('child_process');if(fs.existsSync('../tools')){for(const s of ['verify-chief-facade-split.mjs','verify-index-modular-split.mjs','verify-archives-modular-split.mjs','verify-client-modular-build.mjs','verify-v121-permissions-and-ui.mjs','verify-compaction-and-blank-chat.mjs','check-action-surface.mjs','verify-v130-four-chains.mjs']){cp.execFileSync(process.execPath,[path.resolve('..','tools',s)],{stdio:'inherit'});}}\""
|
|
66
71
|
},
|
|
67
72
|
"exports": {
|
|
68
73
|
".": "./index.js",
|
package/runtime-hooks.js
CHANGED
|
@@ -31,9 +31,16 @@ import {
|
|
|
31
31
|
queueChiefApproval,
|
|
32
32
|
appendChiefAuditLog,
|
|
33
33
|
} from './chief.js'
|
|
34
|
+
import {
|
|
35
|
+
touchWorkspaceActivity,
|
|
36
|
+
upsertTaskLedgerOnWs,
|
|
37
|
+
normalizeSuggestion,
|
|
38
|
+
ensureWorkspace,
|
|
39
|
+
SUGGESTIONS_CAP,
|
|
40
|
+
} from './chief-state.js'
|
|
34
41
|
import { createAutoContinueEngine } from './auto-continue.js'
|
|
35
42
|
import { bootstrapArchivesFromSharedBoard } from './archives.js'
|
|
36
|
-
import { normalizePermissionMode, evaluatePreExecuteDefense } from './chief-executor.js'
|
|
43
|
+
import { normalizePermissionMode, evaluatePreExecuteDefense, evaluateSafetyGuardHardRules, listGuardWalls } from './chief-executor.js'
|
|
37
44
|
import {
|
|
38
45
|
newId,
|
|
39
46
|
nowMs,
|
|
@@ -170,7 +177,7 @@ export function createRuntimeHooks(deps) {
|
|
|
170
177
|
const st = loadChiefState()
|
|
171
178
|
const rk = resolveRootSessionId(rootKey || sid) || rootKey || sid
|
|
172
179
|
const cfg = resolveWorkspaceConfig(st, rk)
|
|
173
|
-
return Boolean(cfg.stopped || cfg.paceMode === 'stopped')
|
|
180
|
+
return Boolean(cfg.stopped || cfg.paceMode === 'stopped' || cfg.runMode === 'off')
|
|
174
181
|
} catch {
|
|
175
182
|
return false
|
|
176
183
|
}
|
|
@@ -200,28 +207,88 @@ export function createRuntimeHooks(deps) {
|
|
|
200
207
|
const state = loadChiefState()
|
|
201
208
|
const ws = state && state.workspaces && state.workspaces[key] ? state.workspaces[key] : null
|
|
202
209
|
const effCfg = resolveWorkspaceConfig(state, key)
|
|
210
|
+
const runMode = effCfg && effCfg.runMode ? effCfg.runMode : 'off'
|
|
211
|
+
if ((effCfg && effCfg.stopped) || (runMode !== 'patrol' && runMode !== 'managed')) {
|
|
212
|
+
return { allowed: false, skipped: 'run-mode-off', logMessage: '参谋处于「⏸ 关停」模式,仅 patrol/managed 模式允许 Auto continue 唤醒' }
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Check forbidden bounds and active guard walls BEFORE continuing
|
|
216
|
+
const cwdForCheck = (key && key !== 'global' && getSessionCwd(runtime, key)) || process.cwd()
|
|
217
|
+
const board = key && key !== 'global' ? boardForSession(boardFileFor(key)) : null
|
|
218
|
+
const detailSample = `${trigger || ''} ${detail || ''}`.trim()
|
|
219
|
+
const safetyGuard = evaluateSafetyGuardHardRules({ tool: 'relay', opClass: 'workflow', command: detailSample, board })
|
|
220
|
+
if (safetyGuard && safetyGuard.blocked) {
|
|
221
|
+
appendChiefAuditLog(key, {
|
|
222
|
+
mode: effCfg.permissionMode || 'advisor',
|
|
223
|
+
stage: 'safety_guard',
|
|
224
|
+
rule: safetyGuard.rule || 'auto_continue_blocked',
|
|
225
|
+
decision: 'blocked',
|
|
226
|
+
operation: '断线续跑边界检查',
|
|
227
|
+
target: sessionId,
|
|
228
|
+
reason: safetyGuard.reason,
|
|
229
|
+
outcome: 'blocked',
|
|
230
|
+
by: 'auto-continue',
|
|
231
|
+
})
|
|
232
|
+
return { allowed: false, skipped: 'guard-wall-blocked', logMessage: `安全护栏阻断自动续跑:${safetyGuard.reason}` }
|
|
233
|
+
}
|
|
234
|
+
const activeWalls = listGuardWalls(cwdForCheck)
|
|
235
|
+
if (detail && Array.isArray(activeWalls) && activeWalls.some(w => w && w.enabled && w.mode === 'deny' && Array.isArray(w.patterns) && w.patterns.some(p => p && detail.includes(p)))) {
|
|
236
|
+
return { allowed: false, skipped: 'guard-wall-blocked', logMessage: '触发动态物理墙保护红线,已暂停自动续跑等待人工确认' }
|
|
237
|
+
}
|
|
238
|
+
|
|
203
239
|
const hasAck = hasValidChiefRiskAck(ws)
|
|
204
240
|
const mode = normalizePermissionMode(effCfg && effCfg.permissionMode, {
|
|
205
241
|
requireAck: true,
|
|
206
242
|
hasChiefRiskAck: hasAck,
|
|
207
243
|
})
|
|
208
244
|
if (mode === 'advisor') {
|
|
209
|
-
return { allowed: false, skipped: 'advisor-readonly', logMessage: 'L0
|
|
245
|
+
return { allowed: false, skipped: 'advisor-readonly', logMessage: 'L0 顾问模式(只读):检测到断流仅作提示,不向主对话发送续跑请求' }
|
|
210
246
|
}
|
|
211
247
|
if (mode === 'assistant') {
|
|
212
|
-
|
|
248
|
+
mutateChiefState((s) => {
|
|
249
|
+
const w = ensureWorkspace(s, key)
|
|
250
|
+
const sug = normalizeSuggestion({
|
|
251
|
+
kind: 'advice',
|
|
252
|
+
fromAgent: '⚡ 断流检测提醒',
|
|
253
|
+
title: `主对话断流待手动续跑(${trigger})`,
|
|
254
|
+
reason: detail ? String(detail).slice(0, 160) : 'L1 助手模式不接管主对话工作流,点此一键下发续跑请求。',
|
|
255
|
+
target: 'lead',
|
|
256
|
+
targetLabel: '主对话 (@lead)',
|
|
257
|
+
mode: 'followup',
|
|
258
|
+
draftText: `[EXECUTION_REQUEST] 检测到上一轮中断(${trigger}),请核查进度后继续推进。`,
|
|
259
|
+
})
|
|
260
|
+
if (sug && !w.suggestions.some(x => x && x.status === 'pending' && x.title === sug.title)) {
|
|
261
|
+
w.suggestions.push(sug)
|
|
262
|
+
if (w.suggestions.length > SUGGESTIONS_CAP) w.suggestions = w.suggestions.slice(-SUGGESTIONS_CAP)
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
return { allowed: false, skipped: 'assistant-no-workflow', logMessage: 'L1 助手模式:已记入建议卡提醒断流,跳过主对话工作流续跑' }
|
|
213
266
|
}
|
|
214
267
|
if (mode === 'strategist') {
|
|
268
|
+
let ledgerId = ''
|
|
269
|
+
mutateChiefState((s) => {
|
|
270
|
+
const w = ensureWorkspace(s, key)
|
|
271
|
+
const entry = upsertTaskLedgerOnWs(w, {
|
|
272
|
+
kind: 'auto_continue',
|
|
273
|
+
status: 'awaiting_approval',
|
|
274
|
+
originalText: `[断线续跑 · ${trigger}] ${detail ? String(detail).slice(0, 160) : '异常中断恢复'}`,
|
|
275
|
+
forcedTarget: 'lead',
|
|
276
|
+
lastReceipt: '等待 L2 逐项授权唤醒主对话',
|
|
277
|
+
})
|
|
278
|
+
if (entry) ledgerId = entry.taskId || entry.id
|
|
279
|
+
})
|
|
215
280
|
const apr = queueChiefApproval(key, {
|
|
216
281
|
category: 'main_workflow',
|
|
217
282
|
operationLabel: '断线自动续跑主对话',
|
|
218
283
|
targetLabel: '主对话 (@lead)',
|
|
219
|
-
reason: `检测到会话中断或未收口(${trigger}
|
|
220
|
-
impact: '
|
|
284
|
+
reason: `检测到会话中断或未收口(${trigger}),已核验安全边界与物理墙,L2 参谋模式需您允许后唤醒续跑`,
|
|
285
|
+
impact: '点击「允许本次操作」后将发出 [EXECUTION_REQUEST] 信封唤醒主对话继续推进',
|
|
221
286
|
preview: detail ? String(detail).slice(0, 220) : `触发原因:${trigger}`,
|
|
222
287
|
dedupeKey: `autocont:${sessionId}:${trigger}:${Math.floor(Date.now() / 15_000)}`,
|
|
223
288
|
kind: 'auto_continue',
|
|
224
|
-
|
|
289
|
+
taskId: ledgerId,
|
|
290
|
+
resumeTaskId: ledgerId,
|
|
291
|
+
payload: { sessionId, trigger, detail: detail || '', taskId: ledgerId },
|
|
225
292
|
by: 'auto-continue',
|
|
226
293
|
})
|
|
227
294
|
appendChiefAuditLog(key, {
|
|
@@ -238,10 +305,23 @@ export function createRuntimeHooks(deps) {
|
|
|
238
305
|
allowed: false,
|
|
239
306
|
skipped: 'pending-approval',
|
|
240
307
|
approvalId: apr && apr.id,
|
|
308
|
+
taskId: ledgerId,
|
|
241
309
|
logMessage: `L2 参谋模式:已提交断线续跑逐项授权弹窗(${trigger})`,
|
|
242
310
|
}
|
|
243
311
|
}
|
|
244
|
-
|
|
312
|
+
let l3TaskId = ''
|
|
313
|
+
mutateChiefState((s) => {
|
|
314
|
+
const w = ensureWorkspace(s, key)
|
|
315
|
+
const entry = upsertTaskLedgerOnWs(w, {
|
|
316
|
+
kind: 'auto_continue',
|
|
317
|
+
status: 'running',
|
|
318
|
+
originalText: `[L3 断线自动续跑 · ${trigger}] ${detail ? String(detail).slice(0, 160) : '异常中断自动恢复'}`,
|
|
319
|
+
forcedTarget: 'lead',
|
|
320
|
+
lastReceipt: '已过边界与物理墙核验,准备下发 [EXECUTION_REQUEST]',
|
|
321
|
+
})
|
|
322
|
+
if (entry) l3TaskId = entry.taskId || entry.id
|
|
323
|
+
})
|
|
324
|
+
return { allowed: true, taskId: l3TaskId }
|
|
245
325
|
} catch {
|
|
246
326
|
return { allowed: false, skipped: 'permission-error' }
|
|
247
327
|
}
|
|
@@ -329,7 +409,8 @@ export function createRuntimeHooks(deps) {
|
|
|
329
409
|
linkedPeersCount: linked.linkedPeersCount,
|
|
330
410
|
linkedPeersProgress: linked.linkedPeersProgress,
|
|
331
411
|
takenOutArchives: archCtx.takenOutArchives,
|
|
332
|
-
|
|
412
|
+
sessionHookedArchives: archCtx.sessionHookedArchives,
|
|
413
|
+
desktopUsedTokens: archCtx.desktopUsedTokens,
|
|
333
414
|
smartCompactActive: archCtx.smartCompactActive,
|
|
334
415
|
chiefPermissionMode: archCtx.chiefPermissionMode,
|
|
335
416
|
})
|
|
@@ -414,6 +495,10 @@ export function createRuntimeHooks(deps) {
|
|
|
414
495
|
try {
|
|
415
496
|
if (!event || !session || !session.id) return
|
|
416
497
|
const id = String(session.id)
|
|
498
|
+
const rootIdForAct = resolveRootSessionId(id) || id
|
|
499
|
+
if (event.type === 'turn/start' || event.type === 'message/user' || event.type === 'tool/call' || event.type === 'turn/end') {
|
|
500
|
+
touchWorkspaceActivity(rootIdForAct)
|
|
501
|
+
}
|
|
417
502
|
if (event.type === 'tool/call' && event.data) {
|
|
418
503
|
const turn = event.data.turn
|
|
419
504
|
noteToolCall(id, turn)
|
|
@@ -427,17 +512,25 @@ export function createRuntimeHooks(deps) {
|
|
|
427
512
|
const reason = String(rawReason && typeof rawReason === 'object' ? (rawReason.kind || '') : (rawReason || '')).toLowerCase()
|
|
428
513
|
const nestedReason = String(rawReason && typeof rawReason === 'object' && rawReason.reason && typeof rawReason.reason === 'object' ? (rawReason.reason.kind || '') : '').toLowerCase()
|
|
429
514
|
const isStoppedByUserOrPolicy = reason === 'aborted' || reason === 'blocked' || nestedReason === 'aborted' || nestedReason === 'blocked'
|
|
515
|
+
const abnormalTrig = (reason === 'error' || nestedReason === 'error')
|
|
516
|
+
? 'turn_error'
|
|
517
|
+
: ((reason === 'interrupted' || nestedReason === 'interrupted' || reason === 'max-tokens' || reason === 'no-visible-output') ? 'stream_interrupted' : '')
|
|
430
518
|
const turnNum = Number(event.data && event.data.turn)
|
|
431
519
|
const steerKey = `${id}:${turnNum}`
|
|
432
520
|
const steeredAt = deps.hostState.autoSteeredTurns.get(steerKey) || 0
|
|
433
521
|
if (steeredAt) deps.hostState.autoSteeredTurns.delete(steerKey)
|
|
434
522
|
if (!isStoppedByUserOrPolicy && !(steeredAt && Date.now() - steeredAt < 30_000)) {
|
|
435
523
|
const rootId = resolveRootSessionId(id) || id
|
|
436
|
-
if (!isRootStopped(rootId, id)) {
|
|
524
|
+
if (!isRootStopped(rootId, id) || abnormalTrig) {
|
|
437
525
|
const agents = runtime && runtime.get ? runtime.get('agents') : null
|
|
438
526
|
const liveAgent = agents && typeof agents.get === 'function' ? agents.get(id) : null
|
|
439
527
|
if (liveAgent) {
|
|
440
|
-
scheduleChiefTurnReview(makeChiefDeps(runtime), {
|
|
528
|
+
scheduleChiefTurnReview(makeChiefDeps(runtime), {
|
|
529
|
+
agent: liveAgent,
|
|
530
|
+
sessionId: id,
|
|
531
|
+
turn: event.data && event.data.turn,
|
|
532
|
+
...(abnormalTrig ? { abnormalTrigger: abnormalTrig } : {}),
|
|
533
|
+
})
|
|
441
534
|
}
|
|
442
535
|
}
|
|
443
536
|
}
|
|
@@ -672,9 +765,19 @@ export function createRuntimeHooks(deps) {
|
|
|
672
765
|
})
|
|
673
766
|
})
|
|
674
767
|
}
|
|
768
|
+
if (effCfg && (effCfg.runMode === 'patrol' || effCfg.runMode === 'managed') && !effCfg.stopped) {
|
|
769
|
+
scheduleChiefTurnReview(makeChiefDeps(runtime), {
|
|
770
|
+
agent: caller,
|
|
771
|
+
sessionId: sid || rootId,
|
|
772
|
+
abnormalTrigger: 'guard_wall_blocked',
|
|
773
|
+
})
|
|
774
|
+
}
|
|
775
|
+
const escalationCue = verdict.wallId
|
|
776
|
+
? `(严禁尝试命令或路径变形绕过物理墙 [${verdict.wallId}];仅当你确认无任何合法替代方案可继续任务时,可调用 chief_board({ action: "chief.request", subject: "撞墙阻断上报", text: "说明被拦截墙(${verdict.wallId})、为何无法绕过及当前卡点" }) 上报参谋长评估)`
|
|
777
|
+
: ''
|
|
675
778
|
return {
|
|
676
779
|
kind: 'deny',
|
|
677
|
-
reason: `[DSH 安全卫兵事前物理拦截] ${verdict.reason}`,
|
|
780
|
+
reason: `[DSH 安全卫兵事前物理拦截] ${verdict.reason}${escalationCue}`,
|
|
678
781
|
info: { stage: verdict.stage, rule: verdict.rule, wallId: verdict.wallId || '' },
|
|
679
782
|
}
|
|
680
783
|
} else if (verdict && verdict.decision === 'ask') {
|