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/CHANGELOG.md +42 -12
- package/README.en.md +143 -116
- package/README.md +134 -142
- package/api-routes.js +19 -2
- package/board-actions.js +72 -1
- package/board-schema.js +1 -1
- package/chief-approvals.js +241 -81
- package/chief-archives.js +35 -0
- package/chief-commands.js +615 -108
- package/chief-executor.js +279 -555
- package/chief-network.js +157 -8
- package/chief-review.js +33 -1
- package/chief-state.js +497 -81
- package/chief-view.js +21 -6
- package/client.js +1953 -506
- package/model-tools.js +78 -2
- package/package.json +35 -24
- package/runtime-hooks.js +108 -2
- package/safety/audit-log.js +95 -0
- package/safety/command-analyzer.js +339 -0
- package/safety/guard-walls.js +993 -0
- package/safety/index.js +78 -0
- package/safety/invariant-guards.js +280 -0
- package/safety/path-guard.js +227 -0
- package/safety/policy-engine.js +387 -0
- package/safety/policy-plugin.js +391 -0
- package/safety/tool-gate.js +278 -0
- package/subagent-runtime.js +9 -2
package/chief-view.js
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import crypto from 'node:crypto'
|
|
8
|
-
import { stripToolCallMarkup } from './chief-executor.js'
|
|
8
|
+
import { stripToolCallMarkup, listGuardWalls } from './chief-executor.js'
|
|
9
9
|
import {
|
|
10
10
|
AUTO_SUMMARY_COOLDOWN_MS,
|
|
11
|
+
CHAT_OPPORTUNISTIC_SUMMARY_COOLDOWN_MS,
|
|
11
12
|
SUMMARY_MAX_TOKENS,
|
|
12
13
|
collectChiefVisibleArchives,
|
|
14
|
+
resolveSessionWorkspaceCwd,
|
|
13
15
|
clamp,
|
|
14
16
|
resolveWorkspaceConfig,
|
|
15
17
|
loadChiefState,
|
|
@@ -20,6 +22,9 @@ import {
|
|
|
20
22
|
shortAgentBriefName,
|
|
21
23
|
stripCheckpointNoise,
|
|
22
24
|
isInternalCheckpointNoise,
|
|
25
|
+
beginChiefActiveWork,
|
|
26
|
+
endChiefActiveWork,
|
|
27
|
+
getChiefActiveWork,
|
|
23
28
|
} from './chief-state.js'
|
|
24
29
|
import { listChiefModels, callChiefLlm } from './chief-models.js'
|
|
25
30
|
import { collectClusterPeerProgress, listPeerDirectory } from './chief-network.js'
|
|
@@ -357,7 +362,7 @@ function buildFallbackNarrative({ board, facts, targets, peerProgress = [], conc
|
|
|
357
362
|
|
|
358
363
|
export const summarizingLocks = new Map()
|
|
359
364
|
|
|
360
|
-
export async function getChiefView(deps, sessionId, { regenerate = false, autoSummarize = false, syncHandoff = undefined, _skipAutoPilotCheck = false } = {}) {
|
|
365
|
+
export async function getChiefView(deps, sessionId, { regenerate = false, autoSummarize = false, chatTriggered = false, syncHandoff = undefined, _skipAutoPilotCheck = false } = {}) {
|
|
361
366
|
const rootId = deps.resolveRootSessionId(sessionId) || String(sessionId || 'global')
|
|
362
367
|
const directory = await listPeerDirectory(deps, rootId)
|
|
363
368
|
const board = deps.boardForSession(deps.boardFileFor(rootId))
|
|
@@ -396,11 +401,16 @@ export async function getChiefView(deps, sessionId, { regenerate = false, autoSu
|
|
|
396
401
|
const lastSummaryAt = Number((view.narrative && view.narrative.at) || 0)
|
|
397
402
|
const isFresh = !rawInput || (hasSaved && view.narrative.hash === inputHash)
|
|
398
403
|
const cooledForAuto = Date.now() - lastSummaryAt >= AUTO_SUMMARY_COOLDOWN_MS
|
|
404
|
+
const cooledForChat = Date.now() - lastSummaryAt >= CHAT_OPPORTUNISTIC_SUMMARY_COOLDOWN_MS
|
|
399
405
|
const allowBackgroundSummary = paceMode === 'auto' && autoSummarize && !isFresh && cooledForAuto
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
//
|
|
403
|
-
|
|
406
|
+
const allowChatSummary = Boolean(chatTriggered) && !isFresh && cooledForChat
|
|
407
|
+
|
|
408
|
+
// Opportunistically refresh stale narrative in background after Chief chats (60s debounce),
|
|
409
|
+
// explicitly on Regenerate, or on autoSummarize cooldown.
|
|
410
|
+
if (rawInput && (regenerate || allowBackgroundSummary || allowChatSummary) && modelsInfo.available && !summarizingLocks.has(rootId)) {
|
|
411
|
+
const bgSummaryWorkId = getChiefActiveWork(rootId)
|
|
412
|
+
? ''
|
|
413
|
+
: beginChiefActiveWork(rootId, { tone: 'neon', tab: 'chief', label: '参谋长正在自动提炼全局摘要中...' })
|
|
404
414
|
const job = (async () => {
|
|
405
415
|
const sysPrompt = isConciseBrief
|
|
406
416
|
? (NARRATIVE_SYSTEM + CONCISE_BRIEF_NARRATIVE_EXTRA)
|
|
@@ -428,6 +438,7 @@ export async function getChiefView(deps, sessionId, { regenerate = false, autoSu
|
|
|
428
438
|
}
|
|
429
439
|
})().finally(() => {
|
|
430
440
|
summarizingLocks.delete(rootId)
|
|
441
|
+
if (bgSummaryWorkId) endChiefActiveWork(rootId, bgSummaryWorkId)
|
|
431
442
|
})
|
|
432
443
|
summarizingLocks.set(rootId, job)
|
|
433
444
|
if (regenerate) {
|
|
@@ -548,6 +559,10 @@ export async function getChiefView(deps, sessionId, { regenerate = false, autoSu
|
|
|
548
559
|
chiefRiskAck: ownWs.chiefRiskAck ? { ...ownWs.chiefRiskAck } : null,
|
|
549
560
|
pendingApprovals: (Array.isArray(ownWs.pendingApprovals) ? ownWs.pendingApprovals : []).slice(-15).reverse(),
|
|
550
561
|
pendingElevation: ownWs.pendingElevation ? { ...ownWs.pendingElevation } : null,
|
|
562
|
+
taskLedger: (Array.isArray(ownWs.taskLedger) ? ownWs.taskLedger : []).slice(-15).reverse(),
|
|
563
|
+
inquiries: (Array.isArray(ownWs.inquiries) ? ownWs.inquiries : []).slice(-12).reverse(),
|
|
564
|
+
guardWalls: listGuardWalls({ cwd: resolveSessionWorkspaceCwd(deps, rootId) }),
|
|
565
|
+
activeWork: getChiefActiveWork(rootId),
|
|
551
566
|
auditLog: (Array.isArray(ownWs.auditLog) ? ownWs.auditLog : []).slice(-50).reverse(),
|
|
552
567
|
}
|
|
553
568
|
}
|