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-archives.js
CHANGED
|
@@ -30,6 +30,9 @@ import {
|
|
|
30
30
|
stripCheckpointNoise,
|
|
31
31
|
isInternalCheckpointNoise,
|
|
32
32
|
extractJsonObject,
|
|
33
|
+
beginChiefActiveWork,
|
|
34
|
+
endChiefActiveWork,
|
|
35
|
+
getChiefActiveWork,
|
|
33
36
|
} from './chief-state.js'
|
|
34
37
|
import { callChiefLlm } from './chief-models.js'
|
|
35
38
|
import { deliverCrossMessage } from './chief-network.js'
|
|
@@ -131,6 +134,10 @@ export async function organizeArchivesWithChief(deps, {
|
|
|
131
134
|
const selected = candidates.slice(0, MAX_ITEMS_PER_RUN)
|
|
132
135
|
const remainingCount = Math.max(0, candidates.length - selected.length)
|
|
133
136
|
|
|
137
|
+
const orgWorkId = getChiefActiveWork(rootId)
|
|
138
|
+
? ''
|
|
139
|
+
: beginChiefActiveWork(rootId, { tone: 'archive', tab: 'archive', label: '参谋长正在整理档案中...' })
|
|
140
|
+
try {
|
|
134
141
|
const folderLines = store.folders.map(f => `- "${f.id}": ${f.label}(${f.hint || ''})`)
|
|
135
142
|
const allCurations = []
|
|
136
143
|
const allNewFolders = []
|
|
@@ -247,6 +254,9 @@ export async function organizeArchivesWithChief(deps, {
|
|
|
247
254
|
archives: refreshedList,
|
|
248
255
|
view: await getChiefView(deps, rootId, { autoSummarize: false }),
|
|
249
256
|
}
|
|
257
|
+
} finally {
|
|
258
|
+
if (orgWorkId) endChiefActiveWork(rootId, orgWorkId)
|
|
259
|
+
}
|
|
250
260
|
}
|
|
251
261
|
|
|
252
262
|
const HARVEST_ARCHIVE_SYSTEM = [
|
|
@@ -358,6 +368,14 @@ export async function harvestTurnDetailsToArchive(deps, {
|
|
|
358
368
|
return { ok: false, error: '当前为空白新对话(未绑定会话 ID),请先发送一条消息或切至「🌐 全局档案柜」再抢救归档' }
|
|
359
369
|
}
|
|
360
370
|
const targetOpt = archiveTargetForRoot(deps, rootId, { cabinetId, vaultScope: effScope })
|
|
371
|
+
const harvWorkId = getChiefActiveWork(rootId)
|
|
372
|
+
? ''
|
|
373
|
+
: beginChiefActiveWork(rootId, {
|
|
374
|
+
tone: 'archive',
|
|
375
|
+
tab: 'archive',
|
|
376
|
+
label: trigger === 'pre-compaction' ? '参谋长正在压缩前抢救归档中...' : '参谋长正在抢救归档中...',
|
|
377
|
+
})
|
|
378
|
+
try {
|
|
361
379
|
const evidence = collectRawSessionEvidence(deps, { sessionId: sessionId || rootId, rootId, agent })
|
|
362
380
|
const bodySource = [
|
|
363
381
|
focusHint ? `【抢救焦点提示】${cleanMultiline(focusHint, 240)}` : '',
|
|
@@ -435,6 +453,9 @@ export async function harvestTurnDetailsToArchive(deps, {
|
|
|
435
453
|
cabinetId: targetOpt.cabinetId || verify.cabinetId || '',
|
|
436
454
|
archives: listArchiveHeaders(rootId, { includePrecipitated: trigger === 'manual' }, targetOpt),
|
|
437
455
|
}
|
|
456
|
+
} finally {
|
|
457
|
+
if (harvWorkId) endChiefActiveWork(rootId, harvWorkId)
|
|
458
|
+
}
|
|
438
459
|
}
|
|
439
460
|
|
|
440
461
|
const PRECIPITATE_EXPERIENCE_SYSTEM = [
|
|
@@ -492,6 +513,10 @@ export async function precipitateExperienceWithChief(deps, {
|
|
|
492
513
|
return { ok: false, error: '当前选定范围暂无工作档案可沉淀' }
|
|
493
514
|
}
|
|
494
515
|
|
|
516
|
+
const precWorkId = getChiefActiveWork(rootId)
|
|
517
|
+
? ''
|
|
518
|
+
: beginChiefActiveWork(rootId, { tone: 'archive', tab: 'archive', label: '参谋长正在沉淀经验入库中...' })
|
|
519
|
+
try {
|
|
495
520
|
const promptBody = selectedItems.slice(0, 12).map((it, idx) => [
|
|
496
521
|
`--- 工作档案 #${idx + 1}: 《${it.title}》 (drawer=${it.folder}, clip=${it.paperclip}) ---`,
|
|
497
522
|
`提要: ${it.summary || '无'}`,
|
|
@@ -589,6 +614,9 @@ export async function precipitateExperienceWithChief(deps, {
|
|
|
589
614
|
clearedSource,
|
|
590
615
|
archives: listArchiveHeaders(rootId, { includePrecipitated: true }, targetOpt),
|
|
591
616
|
}
|
|
617
|
+
} finally {
|
|
618
|
+
if (precWorkId) endChiefActiveWork(rootId, precWorkId)
|
|
619
|
+
}
|
|
592
620
|
}
|
|
593
621
|
|
|
594
622
|
const DISTILL_TO_GLOBAL_SYSTEM = [
|
|
@@ -644,6 +672,10 @@ export async function distillSessionArchivesToGlobal(deps, {
|
|
|
644
672
|
return { ok: false, error: '当前本会话档案柜暂无可供提炼的档案条目' }
|
|
645
673
|
}
|
|
646
674
|
|
|
675
|
+
const distWorkId = getChiefActiveWork(rootId)
|
|
676
|
+
? ''
|
|
677
|
+
: beginChiefActiveWork(rootId, { tone: 'archive', tab: 'archive', label: '参谋长正在提炼全局档案中...' })
|
|
678
|
+
try {
|
|
647
679
|
// Prioritize reusable engineering anchors/clips first
|
|
648
680
|
const clipRank = { gold: 0, silver: 1, copper: 2 }
|
|
649
681
|
selected = [...selected].sort((a, b) => (clipRank[a.paperclip] ?? 1) - (clipRank[b.paperclip] ?? 1))
|
|
@@ -779,6 +811,9 @@ export async function distillSessionArchivesToGlobal(deps, {
|
|
|
779
811
|
globalArchives: listArchiveHeaders(rootId, { vaultScope: 'global', includePrecipitated: true, flippedIds }, globalOpt),
|
|
780
812
|
view: await getChiefView(deps, rootId, { autoSummarize: false }),
|
|
781
813
|
}
|
|
814
|
+
} finally {
|
|
815
|
+
if (distWorkId) endChiefActiveWork(rootId, distWorkId)
|
|
816
|
+
}
|
|
782
817
|
}
|
|
783
818
|
|
|
784
819
|
export function buildChiefArchiveUpsertFn(deps, rootId) {
|