dsh-chief 1.4.0 → 1.6.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 +74 -0
- package/README.en.md +68 -54
- package/README.md +69 -54
- package/api-routes.js +204 -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 +120 -10
- package/board-schema.js +331 -6
- package/chief-approvals.js +176 -11
- package/chief-archives.js +158 -30
- package/chief-commands.js +567 -101
- package/chief-compaction.js +1 -0
- package/chief-models.js +264 -27
- package/chief-review.js +455 -107
- package/chief-state.js +918 -33
- package/chief-view.js +20 -14
- package/client.js +13238 -7190
- package/digest.js +22 -10
- package/idle-guard.js +233 -8
- package/locale/en.json +71 -0
- package/locale/zh.json +71 -0
- package/model-tools.js +21 -6
- package/package.json +11 -4
- package/runtime-hooks.js +358 -20
- package/safety/invariant-guards.js +2 -1
- package/subagent-runtime.js +285 -2
package/chief-commands.js
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
evaluateChiefPermissionGate,
|
|
29
29
|
buildCapabilityScope,
|
|
30
30
|
validateGuardWallInput,
|
|
31
|
+
listGuardWalls,
|
|
31
32
|
CHIEF_TOOLS_PROMPT_GUIDE,
|
|
32
33
|
runChiefAgenticLoop,
|
|
33
34
|
stripToolCallMarkup,
|
|
@@ -51,6 +52,7 @@ import {
|
|
|
51
52
|
normalizeSuggestion,
|
|
52
53
|
resolveWorkspaceConfig,
|
|
53
54
|
appendChiefAuditLog,
|
|
55
|
+
pushAuditToWs,
|
|
54
56
|
queueChiefApproval,
|
|
55
57
|
requestChiefElevation,
|
|
56
58
|
upsertTaskLedgerOnWs,
|
|
@@ -121,6 +123,15 @@ const ASK_CHIEF_SYSTEM = [
|
|
|
121
123
|
' "reason": "手搓这堵物理墙的原因"',
|
|
122
124
|
' }',
|
|
123
125
|
' ],',
|
|
126
|
+
' "wallRemovalProposals": [',
|
|
127
|
+
' {',
|
|
128
|
+
' "wallId": "阻塞任务的动态物理驻墙 ID(必须精确匹配上下文清单中的 wallId,极低概率仅在确认无替代路时填写)",',
|
|
129
|
+
' "wallTitle": "对应物理驻墙名称",',
|
|
130
|
+
' "action": "pause|remove",',
|
|
131
|
+
' "blockerEvidence": "主/子代理撞墙且确无绕过可能的实测证据(必填)",',
|
|
132
|
+
' "reason": "为何必须申请暂挂/拆除这堵物理墙才能继续当前任务"',
|
|
133
|
+
' }',
|
|
134
|
+
' ],',
|
|
124
135
|
' "memoryChanges": [',
|
|
125
136
|
' { "op": "add", "category": "discipline|architecture|progress|preference|team", "text": "一句独立完整的持久事实或规矩(不超过200字,绝不存密钥密码)" },',
|
|
126
137
|
' { "op": "edit", "index": 2, "text": "替换第2条的新内容" },',
|
|
@@ -150,10 +161,15 @@ const ASK_CHIEF_SYSTEM = [
|
|
|
150
161
|
' { "op": "bounds.remove", "field": "forbidden|allowed|notes", "item": "要移除的旧边界条文", "pinGlobal": false }',
|
|
151
162
|
' ],',
|
|
152
163
|
' "archiveOps": [',
|
|
153
|
-
' { "op": "organize", "vaultScope": "session|global", "scope": "unorganized|all", "instruction": "
|
|
164
|
+
' { "op": "organize", "vaultScope": "session|global", "scope": "unorganized|all", "instruction": "整理分类并织就钩子要求" },',
|
|
154
165
|
' { "op": "distill_to_global", "ids": ["可选:指定本局档案ID,留空自动筛选可复用本局经验"], "instruction": "提炼入全局要求" },',
|
|
155
|
-
' { "op": "
|
|
156
|
-
' { "op": "
|
|
166
|
+
' { "op": "pull_global", "id": "全局钩子档案ID", "title": "或标题关键词(参谋见全局钩子后按需拉阅全文)" },',
|
|
167
|
+
' { "op": "pin_to_desktop|unpin_from_desktop|deliver_to_lead", "vaultScope": "session|global", "id": "档案ID", "title": "或标题关键词", "target": "lead", "instruction": "可选附言(仅本局/已织钩全局;严禁触碰冷藏柜)" },',
|
|
168
|
+
' { "op": "copy_to_global|copy_to_session|move_folder|delete", "vaultScope": "session|global", "id": "目标档案ID", "title": "或标题关键词", "folder": "可选抽屉ID" },',
|
|
169
|
+
' { "op": "save", "vaultScope": "session|global", "title": "档案标题", "folder": "inbox|coords|incidents|contracts|ops|plans", "summary": "摘要", "body": "正文", "takeOut": false }',
|
|
170
|
+
' ],',
|
|
171
|
+
' "effortOps": [',
|
|
172
|
+
' { "target": "lead 或子代理名(如 coder)", "effort": "off|low|medium|high|xhigh", "reason": "为何调整该模型思考强度" }',
|
|
157
173
|
' ],',
|
|
158
174
|
' "networkOps": [',
|
|
159
175
|
' { "op": "link|unlink", "targetSessionId": "目标独立会话ID或名称关键词" }',
|
|
@@ -163,8 +179,8 @@ const ASK_CHIEF_SYSTEM = [
|
|
|
163
179
|
'宰相参谋与行事准则:',
|
|
164
180
|
'- 【懒介入与主会话优先铁律(严禁抢活越俎代庖)】:即使你已拥有高权限,也必须遏制亲自写代码或跑项目命令的冲动!凡是修改项目源码、跑构建测试、长程勘探排障,只要主对话在线可用且用户没有明确指定“参谋长你亲自来做/别找主对话”,一律优先放在 `"relays"` 中以正式执行请求形式交由 `@lead` 动手执行!只有用户点名直办、纯参谋内务(看板/档案/记忆/边界/物理墙草案)或主对话失联卡死时才亲自调工具。',
|
|
165
181
|
'- 【优先问询渠道(缺信息就问主对话,严禁瞎猜)】:无论是在自主调配还是回答用户问题时,只要缺乏代码细节或实时状态确认,请输出 `"inquiries"` 向 `@lead` 发出优先问询,主对话会在不打断手头动作的情况下原路快答。',
|
|
166
|
-
'-
|
|
167
|
-
'-
|
|
182
|
+
'- 【手搓动态物理墙与极低概率请示拆墙】:\n 1) 当用户让你“筑一堵物理墙/锁死某个目录或仓库/禁跑某个高危命令”时,直接将大白话诉求编译成 `"wallProposals"`(跨会话常驻设 `"scope": "global"`),呈交用户一键确认落锁;\n 2) **拆墙红线(极低触发)**:任何权限下(哪怕是 L3 最高权限)你都绝无权私拆或绕过物理驻墙!仅当主代理或子代理真实撞墙并确认无法绕过、向你上报阻断情况,且你独立复核确认确因该动态物理墙导致任务彻底无法推进、无合法替代路径时,才允许填入 `"wallRemovalProposals"` 向人类提交拆墙审批申请(硬安全内核规则永远不可申请拆除);平时一切情形严禁主动填 `"wallRemovalProposals"`。',
|
|
183
|
+
'- 【许愿框全权自治与三层档案隔离】:无论整理/分类/织钩/提炼档案入全局、`pin_to_desktop` 摆上认知桌面(2400 Tokens / 6 份上限)、`deliver_to_lead` 一次性向主对话递送关键档案、还是设定边界/重编任务、`effortOps` 调配主对话/子代理思考深度,只要符合当前权限,直接输出对应 JSON ops 执行到位。严禁触碰或读取冷藏档案柜(`precipitated` 100% 人类专属);严禁越级让本局档案直接跳级沉淀,必须遵循 `本局 -> 全局 -> 冷藏` 梯度。',
|
|
168
184
|
'- 【严守当前权限与禁止红线】:绝不越过当前权限等级上限,也绝不执行触发 `禁止红线 (forbidden)` 的写操作或高危命令。',
|
|
169
185
|
'- 【问进展 / 问步骤 / 问卡点 / 求建议】:当用户询问“现在在做什么 / 处于什么步骤 / 目前进度如何 / 卡在哪里”等态势问题时,你面前的上下文已经完整包含「实时对话流快照」+「小任务板 (Plan)」+「任务图」+「断点游标」!直接用简明人话分点作答并放进 JSON 的 `reply` 字段,**严禁退化成纯工具 XML/DSML 标签输出,更严禁盲目运行 `run_command` / `list_dir` 扫盘**!只有用户明确要求去核查具体源码文件/跑命令实测时,才在 JSON `toolCalls` 里调工具。',
|
|
170
186
|
'- 【代维护看板】:当用户让你「把某任务标为完成/受阻」「记一下下一步干啥」「改总目标」时,直接通过 `boardOps`(`task.update` / `cursor.set` / `objective.set` / `task.add`)落实(若强介入已锁定核心目标,则提示先解锁或关闭强介入)。',
|
|
@@ -189,6 +205,14 @@ const CONCISE_BRIEF_ASK_EXTRA = [
|
|
|
189
205
|
'- ⚠️ JSON 顶层结构铁律:上述六句话战报只能作为顶层合法 JSON 对象内 `"reply"` 字段的字符串值!绝不允许直接裸输出 Markdown!若用户要求手搓物理驻墙或提炼/总结工作边界(或你在回复中提出了要补充/禁用的红线或边界),必须同步将完整条目填入 `"wallProposals"` 与 `"boundProposals"` 数组(JSON 字符串内的正则反斜杠须写双反斜杠 `\\\\`)。',
|
|
190
206
|
].join('\n')
|
|
191
207
|
|
|
208
|
+
const CONSULT_CHIEF_EXTRA = [
|
|
209
|
+
'',
|
|
210
|
+
'💡 【当前为「参谋页面咨询(按需给建议)」模式 — 实事求是铁律】:',
|
|
211
|
+
'- 请结合当前任务进展、最近对话、工作边界与团队状态,在 `"reply"` 中坦诚给出真正有价值的观察、风险提醒或推进建议。',
|
|
212
|
+
'- 若当前推进顺利确实暂无建议,或用户关心的事项属于人类拍板/外部事务/非参谋与代理会话能管得了的范畴:**直接如实告诉用户就行!严禁为了凑动作而硬编 `"relays"`、`"boardOps"`、`"archiveOps"`、`"boundProposals"` 或执行建议,上述动作数组务必全部留空 `[]`**!',
|
|
213
|
+
'- 仅当确实存在可落地的具体动作建议时,才填入对应 JSON 字段,并严格遵守当前四级权限(L0 仅文本分析与必要提权申请,L1–L3 按对应权限审批/执行机制运行)。',
|
|
214
|
+
].join('\n')
|
|
215
|
+
|
|
192
216
|
function extractFallbackBoundProposalsFromText(rawText = '', userInput = '') {
|
|
193
217
|
const txt = String(rawText || '')
|
|
194
218
|
if (!txt.trim()) return []
|
|
@@ -570,52 +594,156 @@ export function applyBoardOps(deps, rootId, boardOps, opts = {}) {
|
|
|
570
594
|
* while strictly preserving the upward gradient (`session -> global -> precipitated`;
|
|
571
595
|
* direct session -> precipitated jump is forbidden).
|
|
572
596
|
*/
|
|
597
|
+
const MAIN_INJECT_ARCHIVE_OPS = new Set(['pin_to_desktop', 'unpin_from_desktop', 'take_out', 'put_back', 'deliver_to_lead'])
|
|
598
|
+
|
|
599
|
+
function normalizeArchiveOpName(rawOp) {
|
|
600
|
+
const s = String(rawOp || '').trim()
|
|
601
|
+
if (s === 'take_out') return 'pin_to_desktop'
|
|
602
|
+
if (s === 'put_back') return 'unpin_from_desktop'
|
|
603
|
+
return s
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function resolveItemIdForChiefScope(scope, rawId, rawTitle, { sessionOpt, globalOpt }) {
|
|
607
|
+
const idQ = String(rawId || '').trim()
|
|
608
|
+
const titleQ = String(rawTitle || '').trim().toLowerCase()
|
|
609
|
+
const opt = scope === 'global' ? globalOpt : sessionOpt
|
|
610
|
+
if (!opt) return idQ
|
|
611
|
+
const store = loadArchiveStore(opt)
|
|
612
|
+
const items = Array.isArray(store.items) ? store.items : []
|
|
613
|
+
if (idQ) {
|
|
614
|
+
const exact = items.find(it => it.id === idQ)
|
|
615
|
+
if (exact) return exact.id
|
|
616
|
+
}
|
|
617
|
+
if (titleQ) {
|
|
618
|
+
const byTitle = items.find(it => String(it.title || '').toLowerCase().includes(titleQ))
|
|
619
|
+
if (byTitle) return byTitle.id
|
|
620
|
+
}
|
|
621
|
+
return idQ
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Shared Chief executor for main-session archive injection ops (`pin_to_desktop`, `unpin_from_desktop`, `deliver_to_lead`)
|
|
626
|
+
* and `pull_global`, enforcing strict cold-vault isolation and dual-channel injection rules.
|
|
627
|
+
*/
|
|
628
|
+
export async function executeChiefArchiveInjectionOp(deps, rootId, opItem = {}, opts = {}) {
|
|
629
|
+
const sid = rootId && rootId !== 'global' ? String(rootId).trim() : ''
|
|
630
|
+
const op = normalizeArchiveOpName(opItem.op)
|
|
631
|
+
const scope = opItem.vaultScope === 'precipitated'
|
|
632
|
+
? 'precipitated'
|
|
633
|
+
: (opItem.vaultScope === 'global' ? 'global' : 'session')
|
|
634
|
+
if (scope === 'precipitated' || op === 'pull_precipitated') {
|
|
635
|
+
return { ok: false, blocked: true, error: '冷藏档案柜 100% 归属人类专属隔离,参谋无权读档或推送。' }
|
|
636
|
+
}
|
|
637
|
+
if (!sid) {
|
|
638
|
+
return { ok: false, error: '当前为空白未绑定会话,无法推上桌面或递送主对话。' }
|
|
639
|
+
}
|
|
640
|
+
const globalOpt = archiveTargetForRoot(deps, sid, { vaultScope: 'global' })
|
|
641
|
+
const sessionOpt = archiveTargetForRoot(deps, sid, { vaultScope: 'session' })
|
|
642
|
+
const hitId = resolveItemIdForChiefScope(scope, opItem.id || opItem.archiveId, opItem.title, { sessionOpt, globalOpt })
|
|
643
|
+
if (!hitId) {
|
|
644
|
+
return { ok: false, error: '未匹配到目标工程档案。' }
|
|
645
|
+
}
|
|
646
|
+
const targetOpt = scope === 'global' ? globalOpt : sessionOpt
|
|
647
|
+
|
|
648
|
+
if (op === 'pin_to_desktop' || op === 'unpin_from_desktop') {
|
|
649
|
+
const mOp = op === 'pin_to_desktop' ? 'pinToDesktop' : 'unpinFromDesktop'
|
|
650
|
+
const r = mutateArchive({
|
|
651
|
+
op: mOp,
|
|
652
|
+
vaultScope: scope,
|
|
653
|
+
rootSessionId: sid,
|
|
654
|
+
id: hitId,
|
|
655
|
+
by: opts.by || 'chief',
|
|
656
|
+
}, targetOpt)
|
|
657
|
+
if (!r || !r.ok) {
|
|
658
|
+
return { ok: false, error: (r && r.error) || '桌面调配失败' }
|
|
659
|
+
}
|
|
660
|
+
const ev = Array.isArray(r.evicted) && r.evicted.length > 0 ? `(超 2400 Tokens/6 份自动撤回:${r.evicted.map(x => `《${clamp(x.title, 18)}》`).join('、')})` : ''
|
|
661
|
+
const actionText = `${op === 'pin_to_desktop' ? '📌 摆上桌面' : '撤出桌面'} #${hitId}${ev}`
|
|
662
|
+
return { ok: true, op, scope, id: hitId, evicted: r.evicted || [], actionText }
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if (op === 'deliver_to_lead') {
|
|
666
|
+
const det = getArchiveDetail(hitId, sid, targetOpt)
|
|
667
|
+
if (!det || !det.ok || !det.item) {
|
|
668
|
+
return { ok: false, error: '未读取到待递送档案内容' }
|
|
669
|
+
}
|
|
670
|
+
const it = det.item
|
|
671
|
+
const ptLines = Array.isArray(it.points) && it.points.length > 0
|
|
672
|
+
? it.points.slice(0, 5).map(pt => `- ${pt.title}:${clamp(pt.detail || pt.cue, 180)}`)
|
|
673
|
+
: []
|
|
674
|
+
const instr = cleanMultiline(opItem.instruction || opItem.note || '', 240)
|
|
675
|
+
const msgBody = [
|
|
676
|
+
`[DSH 参谋长档案馆 · 一次性重点递送(不占桌面置顶槽)]`,
|
|
677
|
+
`来源:${scope === 'global' ? '🌐 全局档案柜(参谋核准后专递)' : '🗂️ 本局档案柜'} · 《${clamp(it.title, 48)}》 (id=${it.id})`,
|
|
678
|
+
instr ? `参谋附言:${instr}` : '',
|
|
679
|
+
it.summary ? `提要:${clamp(it.summary, 200)}` : '',
|
|
680
|
+
...(ptLines.length ? ['核心要点:', ...ptLines] : []),
|
|
681
|
+
!ptLines.length && it.body ? `正文节选:\n${clamp(it.body, 900)}` : '',
|
|
682
|
+
].filter(Boolean).join('\n')
|
|
683
|
+
|
|
684
|
+
const deliverTarget = String(opItem.target || 'lead').trim() || 'lead'
|
|
685
|
+
const deliv = await deliverCrossMessage(deps, {
|
|
686
|
+
fromSession: sid,
|
|
687
|
+
fromLabel: opts.byLabel || 'DSH 参谋长 (档案馆重点递送)',
|
|
688
|
+
target: deliverTarget,
|
|
689
|
+
subject: `档案馆递送《${clamp(it.title, 28)}》`,
|
|
690
|
+
text: msgBody,
|
|
691
|
+
mode: 'steer',
|
|
692
|
+
envelopeKind: 'execution_request',
|
|
693
|
+
recordBoardLog: true,
|
|
694
|
+
})
|
|
695
|
+
mutateArchive({ op: 'markDeliveredToLead', vaultScope: scope, rootSessionId: sid, id: hitId }, targetOpt)
|
|
696
|
+
return {
|
|
697
|
+
ok: Boolean(deliv && deliv.ok),
|
|
698
|
+
op,
|
|
699
|
+
scope,
|
|
700
|
+
id: hitId,
|
|
701
|
+
delivery: deliv,
|
|
702
|
+
actionText: deliv && deliv.ok
|
|
703
|
+
? `📨 递送档案《${clamp(it.title, 20)}》→ ${deliv.target || deliverTarget}`
|
|
704
|
+
: `递送失败:${(deliv && deliv.error) || '目标不可达'}`,
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if (op === 'pull_global') {
|
|
709
|
+
const r = mutateArchive({ op: 'pullByChief', vaultScope: 'global', rootSessionId: sid, id: hitId }, globalOpt)
|
|
710
|
+
if (r && r.ok) {
|
|
711
|
+
return { ok: true, op, scope: 'global', id: hitId, actionText: `👁️ 参谋拉阅全局档案 #${hitId}` }
|
|
712
|
+
}
|
|
713
|
+
return { ok: false, error: (r && r.error) || '全局拉阅失败' }
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
return { ok: false, error: `不支持的档案注入指令:${op}` }
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Execute Wishing-Box `archiveOps` requested by user in natural language (`整理`/`提炼入全局`/内务操作),
|
|
721
|
+
* strictly enforcing cold-vault 0-byte isolation (`precipitated` blocked) and upward gradient (`session -> global -> precipitated`).
|
|
722
|
+
*/
|
|
573
723
|
async function applyArchiveOps(deps, rootId, archiveOps, ctx = {}) {
|
|
574
724
|
const executed = []
|
|
575
725
|
if (!Array.isArray(archiveOps) || !archiveOps.length) return { executed, changed: false }
|
|
576
726
|
const sid = rootId && rootId !== 'global' ? String(rootId).trim() : ''
|
|
577
727
|
const globalOpt = archiveTargetForRoot(deps, sid || 'global', { vaultScope: 'global' })
|
|
578
728
|
const sessionOpt = sid ? archiveTargetForRoot(deps, sid, { vaultScope: 'session' }) : null
|
|
579
|
-
const projectKey = resolveProjectKey(globalOpt.cwd)
|
|
580
729
|
let changed = false
|
|
581
730
|
|
|
582
|
-
const resolveItemInScope = (scope, rawId, rawTitle) =>
|
|
583
|
-
|
|
584
|
-
const titleQ = String(rawTitle || '').trim().toLowerCase()
|
|
585
|
-
if (scope === 'precipitated') {
|
|
586
|
-
const items = listPrecipitatedHeaders(projectKey, sid, globalOpt) || []
|
|
587
|
-
if (idQ) {
|
|
588
|
-
const exact = items.find(it => it.id === idQ)
|
|
589
|
-
if (exact) return exact.id
|
|
590
|
-
}
|
|
591
|
-
if (titleQ) {
|
|
592
|
-
const byTitle = items.find(it => String(it.title || '').toLowerCase().includes(titleQ))
|
|
593
|
-
if (byTitle) return byTitle.id
|
|
594
|
-
}
|
|
595
|
-
return idQ
|
|
596
|
-
}
|
|
597
|
-
const opt = scope === 'global' ? globalOpt : sessionOpt
|
|
598
|
-
if (!opt) return idQ
|
|
599
|
-
const store = loadArchiveStore(opt)
|
|
600
|
-
const items = Array.isArray(store.items) ? store.items : []
|
|
601
|
-
if (idQ) {
|
|
602
|
-
const exact = items.find(it => it.id === idQ)
|
|
603
|
-
if (exact) return exact.id
|
|
604
|
-
}
|
|
605
|
-
if (titleQ) {
|
|
606
|
-
const byTitle = items.find(it => String(it.title || '').toLowerCase().includes(titleQ))
|
|
607
|
-
if (byTitle) return byTitle.id
|
|
608
|
-
}
|
|
609
|
-
return idQ
|
|
610
|
-
}
|
|
731
|
+
const resolveItemInScope = (scope, rawId, rawTitle) =>
|
|
732
|
+
resolveItemIdForChiefScope(scope, rawId, rawTitle, { sessionOpt, globalOpt })
|
|
611
733
|
|
|
612
734
|
for (const opItem of archiveOps.slice(0, 8)) {
|
|
613
735
|
if (!opItem || typeof opItem !== 'object') continue
|
|
614
|
-
const op =
|
|
736
|
+
const op = normalizeArchiveOpName(opItem.op)
|
|
615
737
|
const scope = opItem.vaultScope === 'precipitated'
|
|
616
738
|
? 'precipitated'
|
|
617
739
|
: (opItem.vaultScope === 'global' ? 'global' : 'session')
|
|
618
740
|
|
|
741
|
+
// Cold vault (`precipitated`) is 100% human-only: Chief may never inspect, pin, or pull from it.
|
|
742
|
+
if (scope === 'precipitated' || op === 'pull_precipitated') {
|
|
743
|
+
executed.push('🧊 已拦截:冷藏档案柜仅人类可见,参谋无权读取或调取')
|
|
744
|
+
continue
|
|
745
|
+
}
|
|
746
|
+
|
|
619
747
|
if (op === 'organize') {
|
|
620
748
|
const orgScope = opItem.vaultScope === 'global' ? 'global' : 'session'
|
|
621
749
|
if (orgScope === 'session' && !sid) continue
|
|
@@ -641,10 +769,16 @@ async function applyArchiveOps(deps, rootId, archiveOps, ctx = {}) {
|
|
|
641
769
|
changed = true
|
|
642
770
|
executed.push(`提炼入全局 ×${r.createdCount ?? 0}`)
|
|
643
771
|
}
|
|
772
|
+
} else if (op === 'pull_global') {
|
|
773
|
+
const r = await executeChiefArchiveInjectionOp(deps, rootId, { ...opItem, op: 'pull_global', vaultScope: 'global' })
|
|
774
|
+
if (r && r.ok) {
|
|
775
|
+
changed = true
|
|
776
|
+
executed.push(r.actionText)
|
|
777
|
+
}
|
|
644
778
|
} else if (op === 'save' || op === 'create') {
|
|
645
|
-
if (scope === 'precipitated') continue // strict gradient: cannot write directly into precipitated
|
|
646
779
|
if (scope === 'session' && !sid) continue
|
|
647
780
|
const targetOpt = scope === 'global' ? globalOpt : sessionOpt
|
|
781
|
+
const allowPin = Boolean(opItem.takeOut) && optsTakeOutAllowed(ctx)
|
|
648
782
|
const r = mutateArchive({
|
|
649
783
|
op: 'save',
|
|
650
784
|
vaultScope: scope,
|
|
@@ -654,37 +788,19 @@ async function applyArchiveOps(deps, rootId, archiveOps, ctx = {}) {
|
|
|
654
788
|
title: clamp(opItem.title || '参谋长工作归档', 160),
|
|
655
789
|
summary: clamp(opItem.summary || '', 400),
|
|
656
790
|
body: cleanMultiline(opItem.body || opItem.summary || opItem.title || '', 12000),
|
|
657
|
-
takeOutNow:
|
|
791
|
+
takeOutNow: allowPin,
|
|
792
|
+
organizedBy: 'chief',
|
|
658
793
|
by: 'chief',
|
|
659
794
|
}, targetOpt)
|
|
660
795
|
if (r && r.ok) {
|
|
661
796
|
changed = true
|
|
662
797
|
executed.push(`存档(${scope === 'global' ? '全局' : '本局'}):《${clamp(opItem.title || '', 24)}》`)
|
|
663
798
|
}
|
|
664
|
-
} else if (op === '
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
const pOp = op === 'take_out' ? 'flipOut' : 'sealBack'
|
|
670
|
-
const r = mutatePrecipitated(projectKey, { op: pOp, id: hitId, rootSessionId: sid }, { ...globalOpt, rootSessionId: sid })
|
|
671
|
-
if (r && r.ok) {
|
|
672
|
-
updateWorkspaceFlippedIds(sid, pOp === 'flipOut' ? { flippedId: hitId } : { sealId: hitId })
|
|
673
|
-
changed = true
|
|
674
|
-
executed.push(`${op === 'take_out' ? '摆上桌面(沉淀)' : '放回封存(沉淀)'} #${hitId}`)
|
|
675
|
-
}
|
|
676
|
-
} else {
|
|
677
|
-
const targetOpt = scope === 'global' ? globalOpt : sessionOpt
|
|
678
|
-
const r = mutateArchive({
|
|
679
|
-
op: op === 'take_out' ? 'takeOut' : 'putBack',
|
|
680
|
-
vaultScope: scope,
|
|
681
|
-
rootSessionId: sid,
|
|
682
|
-
id: hitId,
|
|
683
|
-
}, targetOpt)
|
|
684
|
-
if (r && r.ok) {
|
|
685
|
-
changed = true
|
|
686
|
-
executed.push(`${op === 'take_out' ? '摆上桌面' : '放回封存'} #${hitId}`)
|
|
687
|
-
}
|
|
799
|
+
} else if (op === 'pin_to_desktop' || op === 'unpin_from_desktop' || op === 'deliver_to_lead') {
|
|
800
|
+
const r = await executeChiefArchiveInjectionOp(deps, rootId, opItem, ctx)
|
|
801
|
+
if (r && r.ok) {
|
|
802
|
+
changed = true
|
|
803
|
+
executed.push(r.actionText)
|
|
688
804
|
}
|
|
689
805
|
} else if (op === 'mount_chief' || op === 'unmount_chief') {
|
|
690
806
|
if (!sid) continue
|
|
@@ -718,23 +834,7 @@ async function applyArchiveOps(deps, rootId, archiveOps, ctx = {}) {
|
|
|
718
834
|
changed = true
|
|
719
835
|
executed.push(`全局调入本局 #${hitId}`)
|
|
720
836
|
}
|
|
721
|
-
} else if (op === 'pull_precipitated') {
|
|
722
|
-
const targetScope = opItem.targetScope === 'global' ? 'global' : 'session'
|
|
723
|
-
if (targetScope === 'session' && !sid) continue
|
|
724
|
-
const hitId = resolveItemInScope('precipitated', opItem.id || opItem.archiveId, opItem.title)
|
|
725
|
-
if (!hitId) continue
|
|
726
|
-
const r = copyPrecipitatedToVault(projectKey, {
|
|
727
|
-
id: hitId,
|
|
728
|
-
targetScope,
|
|
729
|
-
rootSessionId: sid,
|
|
730
|
-
takeOutNow: Boolean(opItem.takeOut),
|
|
731
|
-
}, { ...globalOpt, rootSessionId: sid })
|
|
732
|
-
if (r && r.ok) {
|
|
733
|
-
changed = true
|
|
734
|
-
executed.push(`沉淀无损调入${targetScope === 'global' ? '全局' : '本局'} #${hitId}`)
|
|
735
|
-
}
|
|
736
837
|
} else if (op === 'move_folder' && opItem.folder) {
|
|
737
|
-
if (scope === 'precipitated') continue
|
|
738
838
|
if (scope === 'session' && !sid) continue
|
|
739
839
|
const targetOpt = scope === 'global' ? globalOpt : sessionOpt
|
|
740
840
|
const hitId = resolveItemInScope(scope, opItem.id || opItem.archiveId, opItem.title)
|
|
@@ -745,7 +845,6 @@ async function applyArchiveOps(deps, rootId, archiveOps, ctx = {}) {
|
|
|
745
845
|
executed.push(`移动档案分类 → ${opItem.folder}`)
|
|
746
846
|
}
|
|
747
847
|
} else if (op === 'delete' || op === 'remove') {
|
|
748
|
-
if (scope === 'precipitated') continue
|
|
749
848
|
if (scope === 'session' && !sid) continue
|
|
750
849
|
const targetOpt = scope === 'global' ? globalOpt : sessionOpt
|
|
751
850
|
const hitId = resolveItemInScope(scope, opItem.id || opItem.archiveId, opItem.title)
|
|
@@ -761,6 +860,10 @@ async function applyArchiveOps(deps, rootId, archiveOps, ctx = {}) {
|
|
|
761
860
|
return { executed, changed }
|
|
762
861
|
}
|
|
763
862
|
|
|
863
|
+
function optsTakeOutAllowed(ctx) {
|
|
864
|
+
return Boolean(ctx && ctx.allowPinToDesktop !== false)
|
|
865
|
+
}
|
|
866
|
+
|
|
764
867
|
/** Execute Wishing-Box `networkOps` to link or unlink standalone DSH sessions. */
|
|
765
868
|
function applyNetworkOps(rootId, networkOps, directory) {
|
|
766
869
|
const executed = []
|
|
@@ -1086,6 +1189,7 @@ export async function consolidateBoundsWithChief(deps, {
|
|
|
1086
1189
|
|
|
1087
1190
|
const llmRes = await callChiefLlm(deps, {
|
|
1088
1191
|
sessionId: rootId,
|
|
1192
|
+
reasonKind: 'consolidate_bounds',
|
|
1089
1193
|
system: CONSOLIDATE_BOUNDS_SYSTEM,
|
|
1090
1194
|
prompt,
|
|
1091
1195
|
maxTokens: SUMMARY_MAX_TOKENS,
|
|
@@ -1155,9 +1259,11 @@ export async function askOrCommandChief(deps, {
|
|
|
1155
1259
|
text = '',
|
|
1156
1260
|
forcedTarget = '',
|
|
1157
1261
|
forcedMode = 'steer',
|
|
1262
|
+
quickAction = '',
|
|
1158
1263
|
images = [],
|
|
1159
1264
|
_resumeCtx = null,
|
|
1160
1265
|
_fromLeadRequest = false,
|
|
1266
|
+
_wallBlockerEscalation = false,
|
|
1161
1267
|
}) {
|
|
1162
1268
|
const rawInput = cleanMultiline(text, 2000)
|
|
1163
1269
|
const rawImages = Array.isArray(images) ? images : []
|
|
@@ -1217,6 +1323,8 @@ export async function askOrCommandChief(deps, {
|
|
|
1217
1323
|
pendingApprovalList = [],
|
|
1218
1324
|
target = '',
|
|
1219
1325
|
forceReceipt = false,
|
|
1326
|
+
thinkingEffort = '',
|
|
1327
|
+
thinkingEffortMode = '',
|
|
1220
1328
|
}) => {
|
|
1221
1329
|
const cleanActions = Array.isArray(actions) ? actions.filter(Boolean) : []
|
|
1222
1330
|
const isReceipt = Boolean(isResumeTurn || _fromLeadRequest || forceReceipt || elevationObj || pendingApprovalList.length > 0 || cleanActions.length > 0)
|
|
@@ -1292,6 +1400,8 @@ export async function askOrCommandChief(deps, {
|
|
|
1292
1400
|
role: 'chief',
|
|
1293
1401
|
kind: isReceipt ? 'receipt' : 'qa',
|
|
1294
1402
|
...(attachedTaskId ? { resumeTaskId: attachedTaskId } : {}),
|
|
1403
|
+
...(thinkingEffort ? { thinkingEffort } : {}),
|
|
1404
|
+
...(thinkingEffortMode ? { thinkingEffortMode } : {}),
|
|
1295
1405
|
text: chiefText,
|
|
1296
1406
|
actions: finalActions,
|
|
1297
1407
|
at: Date.now(),
|
|
@@ -1445,39 +1555,48 @@ export async function askOrCommandChief(deps, {
|
|
|
1445
1555
|
}
|
|
1446
1556
|
}
|
|
1447
1557
|
|
|
1448
|
-
// Watch
|
|
1558
|
+
// Watch session & hooked global archives in background (cold vault is 100% isolated from Chief & Lead!)
|
|
1449
1559
|
const visibleArchives = collectChiefVisibleArchives(deps, rootId, state)
|
|
1450
1560
|
const watchLines = []
|
|
1451
|
-
const fmtWatchTag = (label, it) => `[${label}${it.id ? ` | id=${it.id}` : ''}] 《${clamp(it.title, 36)}》:${clamp(it.summary, 80)}`
|
|
1561
|
+
const fmtWatchTag = (label, it) => `[${label}${it.id ? ` | id=${it.id}` : ''}] 《${clamp(it.title, 36)}》:${clamp(it.summary || it.hookCue, 80)}`
|
|
1452
1562
|
const watchEntries = [
|
|
1453
|
-
...visibleArchives.deskSessionItems.map(it => fmtWatchTag('桌面·本局(
|
|
1454
|
-
...visibleArchives.deskGlobalItems.map(it => fmtWatchTag('桌面·全局(
|
|
1455
|
-
...visibleArchives.deskFlippedItems.map(it => fmtWatchTag('
|
|
1456
|
-
...visibleArchives.mountedGlobalItems.map(it => fmtWatchTag('
|
|
1457
|
-
...((visibleArchives.
|
|
1458
|
-
...((visibleArchives.
|
|
1459
|
-
...((visibleArchives.
|
|
1563
|
+
...visibleArchives.deskSessionItems.map(it => fmtWatchTag('桌面·本局(主与参谋共阅)', it)),
|
|
1564
|
+
...visibleArchives.deskGlobalItems.map(it => fmtWatchTag('桌面·全局(主与参谋共阅)', it)),
|
|
1565
|
+
...visibleArchives.deskFlippedItems.map(it => fmtWatchTag('桌面·冷藏已翻牌(主与参谋共阅)', it)),
|
|
1566
|
+
...visibleArchives.mountedGlobalItems.map(it => fmtWatchTag('全局已拉阅·主隐', it)),
|
|
1567
|
+
...((visibleArchives.sessionItems || []).filter(it => !it.takenOut).slice(0, 8).map(it => `[本局档案·参谋随时可读${it.hasHook ? ' 🪝已织钩' : ' (未织钩)'} | id=${it.id}] 《${clamp(it.title, 36)}》:${clamp(it.summary, 70)}`)),
|
|
1568
|
+
...((visibleArchives.recentlyUnpinnedWatch || []).slice(0, 4).map(w => `[刚撤下桌面·待观察归位 | id=${w.id}] 《${clamp(w.title, 36)}》`)),
|
|
1569
|
+
...((visibleArchives.globalHookIndex || []).slice(0, 8).map(it => `[全局钩子·参谋见钩可拉(发 pull_global) | id=${it.id}] 《${clamp(it.title, 36)}》 🪝[${(it.hookKeywords || []).slice(0, 3).join('·')}] ${clamp(it.hookCue, 60)}`)),
|
|
1460
1570
|
]
|
|
1461
1571
|
if (watchEntries.length > 0) {
|
|
1462
|
-
watchLines.push('', '## 9.
|
|
1572
|
+
watchLines.push('', '## 9. 参谋长档案馆线索与认知桌面(冷库严密隔离;桌面主对话可见;全局仅暴露已织钩子)', ...watchEntries.map(x => '- ' + x))
|
|
1463
1573
|
}
|
|
1464
1574
|
|
|
1465
|
-
// On-demand lazy archive lookup ONLY when the user explicitly asks Chief about archives (
|
|
1466
|
-
const asksArchiveExplicitly = /(
|
|
1575
|
+
// On-demand lazy archive lookup ONLY when the user explicitly asks Chief about archives (searches Session + Hooked Global Vault; unhooked Global/Cold blocked)
|
|
1576
|
+
const asksArchiveExplicitly = /(?:档案|卷宗|归档|以前|历史记录|工程坐标|老笔记|全局|查一下.*(?:怎么|路径|命令|配置))/.test(input)
|
|
1467
1577
|
const onDemandArchiveLines = []
|
|
1468
1578
|
if (asksArchiveExplicitly) {
|
|
1469
1579
|
const sessionTarget = rootId && rootId !== 'global' ? archiveTargetForRoot(deps, rootId, { vaultScope: 'session' }) : null
|
|
1470
1580
|
const globalTarget = archiveTargetForRoot(deps, rootId, { vaultScope: 'global' })
|
|
1471
1581
|
const foundSess = sessionTarget ? searchArchives(input, { limit: 3, vaultScope: 'session' }, sessionTarget) : { ok: true, hits: [] }
|
|
1472
|
-
const
|
|
1582
|
+
const foundGlobRaw = searchGlobalVaultForChief(input, { limit: 5 }, globalTarget)
|
|
1583
|
+
const pulledOrDeskGlobIds = new Set([
|
|
1584
|
+
...(visibleArchives.mountedGlobalItems || []).map(x => x.id),
|
|
1585
|
+
...(visibleArchives.deskGlobalItems || []).map(x => x.id),
|
|
1586
|
+
])
|
|
1587
|
+
const foundGlobHits = (Array.isArray(foundGlobRaw.hits) ? foundGlobRaw.hits : []).filter(h => h && h.hasHook === true).slice(0, 3)
|
|
1473
1588
|
const combinedHits = [
|
|
1474
|
-
...(Array.isArray(foundSess.hits) ? foundSess.hits.map(h => ({ ...h, _scopeLabel: '本会话档案', _target: sessionTarget })) : []),
|
|
1475
|
-
...
|
|
1589
|
+
...(Array.isArray(foundSess.hits) ? foundSess.hits.map(h => ({ ...h, _scope: 'session', _scopeLabel: '本会话档案', _target: sessionTarget })) : []),
|
|
1590
|
+
...foundGlobHits.map(h => ({ ...h, _scope: 'global', _scopeLabel: '系统全局档案(已织钩)', _target: globalTarget })),
|
|
1476
1591
|
]
|
|
1477
1592
|
if (combinedHits.length > 0) {
|
|
1478
|
-
onDemandArchiveLines.push('', '## 7.
|
|
1593
|
+
onDemandArchiveLines.push('', '## 7. 按需检索到的档案卷宗(仅本局与已织钩全局;未拉阅全局仅展示钩子)')
|
|
1479
1594
|
for (let i = 0; i < combinedHits.length; i += 1) {
|
|
1480
1595
|
const hit = combinedHits[i]
|
|
1596
|
+
if (hit._scope === 'global' && !pulledOrDeskGlobIds.has(hit.id)) {
|
|
1597
|
+
onDemandArchiveLines.push(`- 🪝 [全局钩子待拉阅/${hit.folderLabel} | id=${hit.id}] 《${hit.title}》 关键词=[${(hit.hookKeywords || []).join('·')}] ${clamp(hit.hookCue || hit.summary, 90)}(如需详情可输出 archiveOps pull_global)`)
|
|
1598
|
+
continue
|
|
1599
|
+
}
|
|
1481
1600
|
onDemandArchiveLines.push(`- 📎 [${hit._scopeLabel}/${hit.folderLabel}] 《${hit.title}》:${hit.summary}`)
|
|
1482
1601
|
if (i < 3) {
|
|
1483
1602
|
const det = getArchiveDetail(hit.id, rootId, hit._target)
|
|
@@ -1594,8 +1713,17 @@ export async function askOrCommandChief(deps, {
|
|
|
1594
1713
|
|
|
1595
1714
|
const isBlankContext = liveDigest.summaryLines.length === 0 && !board.objective && !(board.plan || []).length
|
|
1596
1715
|
const resolvedCwd = deps && typeof deps.getSessionCwd === 'function' ? deps.getSessionCwd(rootId) : ''
|
|
1716
|
+
const cwdForPromptWalls = resolveSessionWorkspaceCwd(deps, rootId) || resolvedCwd
|
|
1717
|
+
const activeDynamicWalls = listGuardWalls({ cwd: cwdForPromptWalls }).filter(w => w && w.scope !== 'paused')
|
|
1718
|
+
if (activeDynamicWalls.length > 0) {
|
|
1719
|
+
promptLines.push(
|
|
1720
|
+
'',
|
|
1721
|
+
'## 6.8 当前生效动态物理驻墙参考(仅作阻断排查,严禁私拆;仅代理撞墙无法绕过上报且确无法继续时才可请示审批)',
|
|
1722
|
+
...activeDynamicWalls.slice(0, 8).map(w => `- [${w.id}] (${w.scope}/${w.ruleType}) ${w.title} :: ${Array.isArray(w.patterns) ? w.patterns.join(', ') : ''}`),
|
|
1723
|
+
)
|
|
1724
|
+
}
|
|
1597
1725
|
const explicitCompactReq = !imageBlocks.length && isExplicitCompactCommand(input)
|
|
1598
|
-
const statusOnlyInquiry = !imageBlocks.length && !explicitCompactReq && isPureStatusInquiry(input)
|
|
1726
|
+
const statusOnlyInquiry = !imageBlocks.length && !explicitCompactReq && quickAction !== 'consult_chief' && !_wallBlockerEscalation && isPureStatusInquiry(input)
|
|
1599
1727
|
const userExplicitDirect = /(?:参谋长.*?(?:亲自|自己|直接|别找主)|你自己(?:动手|改|跑|查|写)|别派发|勿转主对话)/.test(input)
|
|
1600
1728
|
const hasLiveLead = Boolean(
|
|
1601
1729
|
deps
|
|
@@ -1616,6 +1744,16 @@ export async function askOrCommandChief(deps, {
|
|
|
1616
1744
|
const effectiveSystem = [
|
|
1617
1745
|
ASK_CHIEF_SYSTEM,
|
|
1618
1746
|
...(isConciseBrief ? [CONCISE_BRIEF_ASK_EXTRA] : []),
|
|
1747
|
+
...(quickAction === 'consult_chief' ? [CONSULT_CHIEF_EXTRA] : []),
|
|
1748
|
+
...(_wallBlockerEscalation
|
|
1749
|
+
? [
|
|
1750
|
+
'',
|
|
1751
|
+
'🧱 【当前正在评估主/子代理提交的“撞墙阻断上报”】:',
|
|
1752
|
+
'- 请严格核对代理是否真的撞到了上述动态物理驻墙,以及**是否真的没有任何合法替代途径继续完成任务**;',
|
|
1753
|
+
'- 若有替代做法(如改用只读核查、调整目标路径/命令或分步处理),**绝不申请拆墙**,直接在 `reply` 中给出合法绕行路径即可;',
|
|
1754
|
+
'- 只有确认确被某堵动态墙彻底卡死无法推进时,才可在 `"wallRemovalProposals"` 中提出针对该精确 `wallId` 的暂挂/拆墙申请单供人类逐项批示!',
|
|
1755
|
+
]
|
|
1756
|
+
: []),
|
|
1619
1757
|
...(isBlankContext
|
|
1620
1758
|
? [
|
|
1621
1759
|
'',
|
|
@@ -1642,6 +1780,14 @@ export async function askOrCommandChief(deps, {
|
|
|
1642
1780
|
const upsertArchiveFn = buildChiefArchiveUpsertFn(deps, rootId)
|
|
1643
1781
|
const compactNowFn = buildChiefCompactFn(deps, rootId)
|
|
1644
1782
|
|
|
1783
|
+
const askReasonKind = statusOnlyInquiry
|
|
1784
|
+
? 'quick_status'
|
|
1785
|
+
: (/筑墙|物理墙|guard.?wall/i.test(input)
|
|
1786
|
+
? 'craft_wall'
|
|
1787
|
+
: (isBlankContext
|
|
1788
|
+
? 'blank_explore'
|
|
1789
|
+
: ((effCfg.tacticalModes && effCfg.tacticalModes.intervention) ? 'strong_intervention' : 'ask_chat')))
|
|
1790
|
+
|
|
1645
1791
|
const loopRes = await runChiefAgenticLoop(deps, {
|
|
1646
1792
|
rootId,
|
|
1647
1793
|
sessionId: rootId,
|
|
@@ -1655,9 +1801,9 @@ export async function askOrCommandChief(deps, {
|
|
|
1655
1801
|
board,
|
|
1656
1802
|
maxSteps: statusOnlyInquiry ? 1 : 4,
|
|
1657
1803
|
readOnlyToolsOnly: false,
|
|
1658
|
-
disableTools: statusOnlyInquiry,
|
|
1804
|
+
disableTools: statusOnlyInquiry || (_wallBlockerEscalation && permRank < 3),
|
|
1659
1805
|
lazyDeferWorkspaceWritesToLead,
|
|
1660
|
-
callLlmFn: (callOpts) => callChiefLlm(deps, { ...callOpts, maxTokens: SUMMARY_MAX_TOKENS }),
|
|
1806
|
+
callLlmFn: (callOpts) => callChiefLlm(deps, { reasonKind: askReasonKind, ...callOpts, maxTokens: SUMMARY_MAX_TOKENS }),
|
|
1661
1807
|
extractJsonFn: extractJsonObject,
|
|
1662
1808
|
upsertArchiveFn,
|
|
1663
1809
|
compactNowFn,
|
|
@@ -1935,6 +2081,8 @@ export async function askOrCommandChief(deps, {
|
|
|
1935
2081
|
elevationObj: autoElevOut,
|
|
1936
2082
|
pendingApprovalList: queuedApprovals,
|
|
1937
2083
|
forceReceipt: true,
|
|
2084
|
+
thinkingEffort: llmRes.thinkingEffort || '',
|
|
2085
|
+
thinkingEffortMode: llmRes.thinkingEffortMode || effCfg.thinkingEffort || 'auto',
|
|
1938
2086
|
})
|
|
1939
2087
|
})
|
|
1940
2088
|
return {
|
|
@@ -1980,7 +2128,7 @@ export async function askOrCommandChief(deps, {
|
|
|
1980
2128
|
conciseBrief: isConciseBrief,
|
|
1981
2129
|
})
|
|
1982
2130
|
const replyText = isConciseBrief ? sanitizeConciseBriefText(rawFallbackReply) : rawFallbackReply
|
|
1983
|
-
const fallbackBounds = permRank >= 1 ? extractFallbackBoundProposalsFromText(rawFallbackReply, input) : []
|
|
2131
|
+
const fallbackBounds = (permRank >= 1 && quickAction !== 'consult_chief') ? extractFallbackBoundProposalsFromText(rawFallbackReply, input) : []
|
|
1984
2132
|
const createdFallbackBounds = []
|
|
1985
2133
|
const BOUND_COL_LABEL_FB = { forbidden: '禁止红线', allowed: '必做事项', notes: '注意事项' }
|
|
1986
2134
|
|
|
@@ -2018,6 +2166,8 @@ export async function askOrCommandChief(deps, {
|
|
|
2018
2166
|
elevationObj: fallbackElev,
|
|
2019
2167
|
pendingApprovalList: queuedApprovals,
|
|
2020
2168
|
forceReceipt: createdFallbackBounds.length > 0,
|
|
2169
|
+
thinkingEffort: llmRes.thinkingEffort || '',
|
|
2170
|
+
thinkingEffortMode: llmRes.thinkingEffortMode || effCfg.thinkingEffort || 'auto',
|
|
2021
2171
|
})
|
|
2022
2172
|
})
|
|
2023
2173
|
return {
|
|
@@ -2142,9 +2292,30 @@ export async function askOrCommandChief(deps, {
|
|
|
2142
2292
|
: (Array.isArray(parsed.boundaryProposals) && parsed.boundaryProposals.length > 0
|
|
2143
2293
|
? parsed.boundaryProposals
|
|
2144
2294
|
: extractFallbackBoundProposalsFromText(parsed.reply || '', input))
|
|
2295
|
+
const rawArchiveOps = Array.isArray(parsed.archiveOps) ? parsed.archiveOps.slice(0, 8) : []
|
|
2296
|
+
const rawEffortOps = Array.isArray(parsed.effortOps) ? parsed.effortOps.slice(0, 6) : []
|
|
2297
|
+
const internalArchiveOps = []
|
|
2298
|
+
const mainInjectArchiveOps = []
|
|
2299
|
+
for (const opItem of rawArchiveOps) {
|
|
2300
|
+
if (!opItem || typeof opItem !== 'object') continue
|
|
2301
|
+
const normOp = normalizeArchiveOpName(opItem.op)
|
|
2302
|
+
const sc = opItem.vaultScope === 'precipitated'
|
|
2303
|
+
? 'precipitated'
|
|
2304
|
+
: (opItem.vaultScope === 'global' ? 'global' : 'session')
|
|
2305
|
+
if (sc === 'precipitated' || normOp === 'pull_precipitated') {
|
|
2306
|
+
internalArchiveOps.push(opItem)
|
|
2307
|
+
} else if (MAIN_INJECT_ARCHIVE_OPS.has(normOp)) {
|
|
2308
|
+
mainInjectArchiveOps.push({ ...opItem, op: normOp, vaultScope: sc })
|
|
2309
|
+
} else if (normOp === 'save' && opItem.takeOut) {
|
|
2310
|
+
internalArchiveOps.push({ ...opItem, takeOut: false })
|
|
2311
|
+
mainInjectArchiveOps.push({ op: 'pin_to_desktop', vaultScope: sc, title: opItem.title, instruction: opItem.summary || '' })
|
|
2312
|
+
} else {
|
|
2313
|
+
internalArchiveOps.push(opItem)
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2145
2316
|
const hasSystemOps = Boolean(
|
|
2146
2317
|
(Array.isArray(parsed.boardOps) && parsed.boardOps.length > 0)
|
|
2147
|
-
||
|
|
2318
|
+
|| internalArchiveOps.length > 0
|
|
2148
2319
|
|| (Array.isArray(parsed.networkOps) && parsed.networkOps.length > 0)
|
|
2149
2320
|
|| (Array.isArray(parsed.memoryChanges) && parsed.memoryChanges.length > 0)
|
|
2150
2321
|
|| rawBoundListSrc.length > 0
|
|
@@ -2161,6 +2332,9 @@ export async function askOrCommandChief(deps, {
|
|
|
2161
2332
|
let executedBoardOps = []
|
|
2162
2333
|
let executedArchiveOps = []
|
|
2163
2334
|
let executedNetworkOps = []
|
|
2335
|
+
let executedEffortOps = []
|
|
2336
|
+
const pendingArchiveSuggestions = []
|
|
2337
|
+
const pendingEffortSuggestions = []
|
|
2164
2338
|
let appliedFacts = []
|
|
2165
2339
|
const proposedBounds = []
|
|
2166
2340
|
const existingBounds = (board && board.bounds) || { allowed: [], forbidden: [], notes: [] }
|
|
@@ -2184,7 +2358,7 @@ export async function askOrCommandChief(deps, {
|
|
|
2184
2358
|
executedBoardOps = applyBoardOps(deps, rootId, parsed.boardOps, { callerOrigin: 'chief_llm' })
|
|
2185
2359
|
for (const b of executedBoardOps) actionBadges.push(b)
|
|
2186
2360
|
|
|
2187
|
-
const archiveExec = await applyArchiveOps(deps, rootId,
|
|
2361
|
+
const archiveExec = await applyArchiveOps(deps, rootId, internalArchiveOps, { input, allowPinToDesktop: false })
|
|
2188
2362
|
executedArchiveOps = archiveExec.executed || []
|
|
2189
2363
|
for (const a of executedArchiveOps) actionBadges.push(a)
|
|
2190
2364
|
|
|
@@ -2205,6 +2379,161 @@ export async function askOrCommandChief(deps, {
|
|
|
2205
2379
|
}
|
|
2206
2380
|
}
|
|
2207
2381
|
|
|
2382
|
+
// Dual-channel main injection from archives (Channel A: desktop pin/unpin, Channel B: deliver_to_lead)
|
|
2383
|
+
// L0/L1 -> Suggestion pill; L2 -> Approval card + TaskLedger; L3 -> Direct execution
|
|
2384
|
+
for (const item of mainInjectArchiveOps) {
|
|
2385
|
+
const scopeLabel = item.vaultScope === 'global' ? '全局档案柜' : '本局档案柜'
|
|
2386
|
+
const refText = item.title ? `《${clamp(item.title, 28)}》` : `#${item.id || item.archiveId || '?'}`
|
|
2387
|
+
const opDesc = item.op === 'pin_to_desktop'
|
|
2388
|
+
? `将${scopeLabel}档案置顶桌面`
|
|
2389
|
+
: (item.op === 'unpin_from_desktop' ? `将${scopeLabel}档案撤回抽屉` : `向主对话递送${scopeLabel}档案`)
|
|
2390
|
+
if (relayGate.decision === 'deny_mode' || relayGate.decision === 'deny_unacknowledged_l3' || relayGate.decision === 'deny_policy_plugin') {
|
|
2391
|
+
if (relayGate.decision !== 'deny_policy_plugin' && permRank < 2) {
|
|
2392
|
+
pendingArchiveSuggestions.push({
|
|
2393
|
+
kind: 'archive_op',
|
|
2394
|
+
fromAgent: '📌 参谋档案馆通道',
|
|
2395
|
+
title: `${opDesc}:${refText}`,
|
|
2396
|
+
reason: clamp(item.instruction || `当前处于 L${permRank} 只读/助手档,后台不直接注入主会话;点「执行建议」即刻落位。`, 180),
|
|
2397
|
+
target: item.target || 'lead',
|
|
2398
|
+
targetLabel: item.op === 'deliver_to_lead' ? '主对话 (@lead)' : '📌 认知桌面',
|
|
2399
|
+
mode: 'steer',
|
|
2400
|
+
draftText: `${opDesc} ${refText}${item.instruction ? ' — ' + item.instruction : ''}`,
|
|
2401
|
+
archiveSpec: {
|
|
2402
|
+
op: item.op,
|
|
2403
|
+
vaultScope: item.vaultScope,
|
|
2404
|
+
id: item.id || item.archiveId || '',
|
|
2405
|
+
title: item.title || '',
|
|
2406
|
+
target: item.target || 'lead',
|
|
2407
|
+
instruction: item.instruction || '',
|
|
2408
|
+
},
|
|
2409
|
+
})
|
|
2410
|
+
actionBadges.push(`💡 建议档案注入:${refText}`)
|
|
2411
|
+
} else {
|
|
2412
|
+
workflowBlockedNeedsElevation = workflowBlockedNeedsElevation || relayGate.decision !== 'deny_policy_plugin'
|
|
2413
|
+
actionBadges.push(relayGate.badge || '🔒 权限禁注档案')
|
|
2414
|
+
}
|
|
2415
|
+
continue
|
|
2416
|
+
}
|
|
2417
|
+
if (relayGate.decision === 'require_approval') {
|
|
2418
|
+
const apr = queueChiefApproval(rootId, {
|
|
2419
|
+
category: 'main_workflow',
|
|
2420
|
+
operationLabel: opDesc,
|
|
2421
|
+
targetLabel: `${scopeLabel} · ${refText}`,
|
|
2422
|
+
reason: clamp(item.instruction || 'L2 参谋模式:向主对话桌面或正文注入档案前需逐项确认', 140),
|
|
2423
|
+
impact: item.op === 'deliver_to_lead' ? '将把该卷宗摘要与要点投递至主对话并唤醒查收' : '将调整主对话共享认知桌面置顶列表(受 2400 Tokens/6 份预算约束)',
|
|
2424
|
+
preview: clamp(`${opDesc} ${refText}${item.instruction ? '\n附言:' + item.instruction : ''}`, 240),
|
|
2425
|
+
kind: 'archive_op',
|
|
2426
|
+
capabilityScope: buildCapabilityScope({ kind: 'archive_op', tool: 'archive_op', target: refText }),
|
|
2427
|
+
payload: {
|
|
2428
|
+
op: item.op,
|
|
2429
|
+
vaultScope: item.vaultScope,
|
|
2430
|
+
id: item.id || item.archiveId || '',
|
|
2431
|
+
title: item.title || '',
|
|
2432
|
+
target: item.target || 'lead',
|
|
2433
|
+
instruction: item.instruction || '',
|
|
2434
|
+
},
|
|
2435
|
+
by: 'chief',
|
|
2436
|
+
})
|
|
2437
|
+
if (apr) queuedApprovals.push(apr)
|
|
2438
|
+
actionBadges.push(`🛡️ 待确认档案注入:${refText}`)
|
|
2439
|
+
appendChiefAuditLog(rootId, { mode: permissionMode, stage: 'permission_gate', decision: 'pending_approval', operation: opDesc, target: refText, reason: clamp(input, 120), outcome: 'pending', by: 'chief' })
|
|
2440
|
+
continue
|
|
2441
|
+
}
|
|
2442
|
+
const execOut = await executeChiefArchiveInjectionOp(deps, rootId, item, { input })
|
|
2443
|
+
if (execOut && execOut.ok) {
|
|
2444
|
+
executedArchiveOps.push(execOut.actionText)
|
|
2445
|
+
actionBadges.push(execOut.actionText)
|
|
2446
|
+
appendChiefAuditLog(rootId, { mode: permissionMode, stage: 'executor', decision: 'executed', operation: opDesc, target: refText, reason: clamp(input, 120), outcome: 'ok', by: 'chief' })
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
// Hot reasoning-effort shifting (`effortOps`) with 4-tier permission gate + teamEffortMode + per-agent user 🔒 veto lock
|
|
2451
|
+
const userLocks = (effCfg && effCfg.lockedModelEfforts && typeof effCfg.lockedModelEfforts === 'object') ? effCfg.lockedModelEfforts : {}
|
|
2452
|
+
const isManualTeamEffort = Boolean(effCfg && effCfg.teamEffortMode === 'manual')
|
|
2453
|
+
if (isManualTeamEffort && rawEffortOps.length > 0) {
|
|
2454
|
+
actionBadges.push('✋ 团队思考强度已设为手动,跳过自动调挡')
|
|
2455
|
+
appendChiefAuditLog(rootId, {
|
|
2456
|
+
mode: permissionMode,
|
|
2457
|
+
stage: 'model_effort_lock',
|
|
2458
|
+
decision: 'blocked',
|
|
2459
|
+
operation: '调节模型思考强度',
|
|
2460
|
+
target: rawEffortOps.map(ef => String((ef && (ef.target || ef.agent)) || 'lead').replace(/^@/, '')).join(','),
|
|
2461
|
+
reason: '团队思考强度处于「手动」模式,已跳过自动调挡',
|
|
2462
|
+
outcome: 'blocked',
|
|
2463
|
+
by: 'chief',
|
|
2464
|
+
})
|
|
2465
|
+
}
|
|
2466
|
+
for (const ef of (isManualTeamEffort ? [] : rawEffortOps)) {
|
|
2467
|
+
if (!ef || typeof ef !== 'object') continue
|
|
2468
|
+
const efTarget = clamp(String(ef.target || ef.agent || 'lead').trim().replace(/^@/, ''), 64) || 'lead'
|
|
2469
|
+
const rawEf = String(ef.effort || ef.reasoningEffort || 'medium').trim().toLowerCase()
|
|
2470
|
+
const efVal = ['off', 'low', 'medium', 'high', 'xhigh'].includes(rawEf) ? rawEf : 'medium'
|
|
2471
|
+
const efReason = clamp(String(ef.reason || '按任务复杂度协同调节模型思考强度').trim(), 180)
|
|
2472
|
+
const shortEfTarget = efTarget.split('/').pop()
|
|
2473
|
+
const isUserLocked = Boolean(userLocks[efTarget] === true || userLocks[shortEfTarget] === true)
|
|
2474
|
+
if (isUserLocked) {
|
|
2475
|
+
actionBadges.push(`🔒 用户已锁挡 @${efTarget}`)
|
|
2476
|
+
appendChiefAuditLog(rootId, { mode: permissionMode, stage: 'model_effort_lock', decision: 'blocked', operation: '调节模型思考强度', target: efTarget, reason: `用户开启「🔒 锁挡」,阻止调为 ${efVal}`, outcome: 'blocked', by: 'chief' })
|
|
2477
|
+
continue
|
|
2478
|
+
}
|
|
2479
|
+
if (relayGate.decision === 'deny_mode' || relayGate.decision === 'deny_unacknowledged_l3' || relayGate.decision === 'deny_policy_plugin') {
|
|
2480
|
+
if (relayGate.decision !== 'deny_policy_plugin' && permRank < 2) {
|
|
2481
|
+
pendingEffortSuggestions.push({
|
|
2482
|
+
kind: 'model_effort',
|
|
2483
|
+
fromAgent: '🧠 思考强度建议',
|
|
2484
|
+
title: `建议调挡 @${efTarget} → ${efVal}`,
|
|
2485
|
+
reason: efReason,
|
|
2486
|
+
target: efTarget,
|
|
2487
|
+
targetLabel: efTarget === 'lead' ? '主对话 (@lead)' : `@${efTarget}`,
|
|
2488
|
+
mode: 'silent',
|
|
2489
|
+
draftText: `将 @${efTarget} 思考强度设为 ${efVal}(${efReason})`,
|
|
2490
|
+
effortSpec: { target: efTarget, effort: efVal, reason: efReason },
|
|
2491
|
+
})
|
|
2492
|
+
actionBadges.push(`💡 建议调挡 @${efTarget}→${efVal}`)
|
|
2493
|
+
} else {
|
|
2494
|
+
workflowBlockedNeedsElevation = workflowBlockedNeedsElevation || relayGate.decision !== 'deny_policy_plugin'
|
|
2495
|
+
actionBadges.push(relayGate.badge || '🔒 权限禁调档位')
|
|
2496
|
+
}
|
|
2497
|
+
continue
|
|
2498
|
+
}
|
|
2499
|
+
if (relayGate.decision === 'require_approval') {
|
|
2500
|
+
const apr = queueChiefApproval(rootId, {
|
|
2501
|
+
category: 'main_workflow',
|
|
2502
|
+
operationLabel: '调节模型思考强度',
|
|
2503
|
+
targetLabel: efTarget === 'lead' ? '主对话 (@lead)' : `@${efTarget}`,
|
|
2504
|
+
reason: efReason,
|
|
2505
|
+
impact: `批准后将静默热调节 @${efTarget} 的推理思考深度为 ${efVal}`,
|
|
2506
|
+
preview: `@${efTarget} → ${efVal}`,
|
|
2507
|
+
kind: 'model_effort',
|
|
2508
|
+
capabilityScope: buildCapabilityScope({ kind: 'model_effort', tool: 'model_effort', target: efTarget }),
|
|
2509
|
+
payload: { target: efTarget, reasoningEffort: efVal, reason: efReason },
|
|
2510
|
+
by: 'chief',
|
|
2511
|
+
})
|
|
2512
|
+
if (apr) queuedApprovals.push(apr)
|
|
2513
|
+
actionBadges.push(`🛡️ 待确认调挡 @${efTarget}→${efVal}`)
|
|
2514
|
+
appendChiefAuditLog(rootId, { mode: permissionMode, stage: 'permission_gate', decision: 'pending_approval', operation: '调节模型思考强度', target: efTarget, reason: efReason, outcome: 'pending', by: 'chief' })
|
|
2515
|
+
continue
|
|
2516
|
+
}
|
|
2517
|
+
if (deps && typeof deps.controlMainAgent === 'function') {
|
|
2518
|
+
const ctrlRes = await deps.controlMainAgent({
|
|
2519
|
+
rootId,
|
|
2520
|
+
sessionId: rootId,
|
|
2521
|
+
op: 'set_effort',
|
|
2522
|
+
target: efTarget,
|
|
2523
|
+
reasoningEffort: efVal,
|
|
2524
|
+
reason: efReason,
|
|
2525
|
+
byUser: false,
|
|
2526
|
+
}).catch(e => ({ ok: false, error: (e && e.message) || 'effort-control-failed' }))
|
|
2527
|
+
if (ctrlRes && ctrlRes.ok) {
|
|
2528
|
+
const tag = `🧠 调挡 @${efTarget} → ${ctrlRes.reasoningEffort || efVal}`
|
|
2529
|
+
executedEffortOps.push(tag)
|
|
2530
|
+
actionBadges.push(tag)
|
|
2531
|
+
} else if (ctrlRes && ctrlRes.lockedByUser) {
|
|
2532
|
+
actionBadges.push(`🔒 用户已锁挡 @${efTarget}`)
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2208
2537
|
// Handle explicit model elevationRequest OR auto-generate when an action hit mode wall
|
|
2209
2538
|
let finalElevation = queuedElevations[0] || null
|
|
2210
2539
|
if (parsed.elevationRequest && typeof parsed.elevationRequest === 'object' && parsed.elevationRequest.targetMode) {
|
|
@@ -2275,10 +2604,102 @@ export async function askOrCommandChief(deps, {
|
|
|
2275
2604
|
const BOUND_COL_LABEL = { forbidden: '禁止红线', allowed: '必做事项', notes: '注意事项' }
|
|
2276
2605
|
const createdInquiries = []
|
|
2277
2606
|
const proposedWalls = []
|
|
2607
|
+
const proposedWallRemovals = []
|
|
2278
2608
|
const cwdForWall = resolveSessionWorkspaceCwd(deps, rootId)
|
|
2609
|
+
const rawWallRemovalProposals = Array.isArray(parsed.wallRemovalProposals) ? parsed.wallRemovalProposals.slice(0, 2) : []
|
|
2279
2610
|
|
|
2280
2611
|
mutateChiefState((s) => {
|
|
2281
2612
|
const ws = ensureWorkspace(s, rootId)
|
|
2613
|
+
|
|
2614
|
+
// Ultra-strict, all-tier (L0-L3) Human Approval Wall-Removal Proposal Gate
|
|
2615
|
+
if (rawWallRemovalProposals.length > 0) {
|
|
2616
|
+
const hasWallBlockLog = (Array.isArray(ws.auditLog) ? ws.auditLog : [])
|
|
2617
|
+
.some(e => e && e.stage === 'guard_wall' && e.outcome === 'blocked')
|
|
2618
|
+
const mentionsBlocker = /(?:撞墙|物理驻墙|物理墙|无法绕过|事前物理拦截|guard_wall|wall-)/i.test(input)
|
|
2619
|
+
const hasWallBlockerEvidence = Boolean(_wallBlockerEscalation || (hasWallBlockLog && mentionsBlocker))
|
|
2620
|
+
if (!hasWallBlockerEvidence) {
|
|
2621
|
+
pushAuditToWs(ws, {
|
|
2622
|
+
mode: permissionMode,
|
|
2623
|
+
stage: 'guard_wall',
|
|
2624
|
+
rule: 'wall_removal_denied_no_blocker_evidence',
|
|
2625
|
+
decision: 'rejected',
|
|
2626
|
+
operation: '拦截无依据拆墙提议',
|
|
2627
|
+
target: 'guard_walls',
|
|
2628
|
+
reason: '未收到主/子代理真实撞墙且无法绕过阻断上报,拒绝生成拆墙申请',
|
|
2629
|
+
outcome: 'rejected',
|
|
2630
|
+
by: 'chief',
|
|
2631
|
+
}, rootId)
|
|
2632
|
+
} else {
|
|
2633
|
+
const activeWalls = listGuardWalls({ cwd: cwdForWall }).filter(w => w && w.scope !== 'paused')
|
|
2634
|
+
for (const rawWr of rawWallRemovalProposals) {
|
|
2635
|
+
if (!rawWr || typeof rawWr !== 'object') continue
|
|
2636
|
+
const reqId = String(rawWr.wallId || rawWr.id || '').trim()
|
|
2637
|
+
const reqTitle = String(rawWr.wallTitle || rawWr.title || '').trim()
|
|
2638
|
+
const matchedWall = activeWalls.find(w =>
|
|
2639
|
+
(reqId && w.id === reqId)
|
|
2640
|
+
|| (reqTitle && w.title === reqTitle),
|
|
2641
|
+
)
|
|
2642
|
+
if (!matchedWall) continue
|
|
2643
|
+
const blockerEv = cleanMultiline(rawWr.blockerEvidence || rawWr.evidence || '', 260)
|
|
2644
|
+
const removeReason = cleanMultiline(rawWr.reason || '', 220)
|
|
2645
|
+
if (!blockerEv || !removeReason) continue
|
|
2646
|
+
const dupWr = ws.suggestions.some(ex =>
|
|
2647
|
+
ex
|
|
2648
|
+
&& ex.status === 'pending'
|
|
2649
|
+
&& ex.kind === 'wall_removal'
|
|
2650
|
+
&& ex.wallRemovalSpec
|
|
2651
|
+
&& ex.wallRemovalSpec.wallId === matchedWall.id,
|
|
2652
|
+
)
|
|
2653
|
+
if (dupWr) continue
|
|
2654
|
+
const actMode = String(rawWr.action || '').trim().toLowerCase() === 'remove' ? 'remove' : 'pause'
|
|
2655
|
+
const patStr = Array.isArray(matchedWall.patterns) ? matchedWall.patterns.join(', ') : ''
|
|
2656
|
+
const sug = normalizeSuggestion({
|
|
2657
|
+
kind: 'wall_removal',
|
|
2658
|
+
fromAgent: '⚠️ 参谋请示拆墙(极低概率 · 阻断复核)',
|
|
2659
|
+
title: `请示${actMode === 'remove' ? '拆除' : '暂挂'}物理墙:${clamp(matchedWall.title, 28)}`,
|
|
2660
|
+
reason: clamp(removeReason, 200),
|
|
2661
|
+
target: 'guard_walls',
|
|
2662
|
+
targetLabel: clamp(matchedWall.title, 36),
|
|
2663
|
+
mode: 'silent',
|
|
2664
|
+
draftText: [
|
|
2665
|
+
`目标物理驻墙:${matchedWall.title} (${matchedWall.id})`,
|
|
2666
|
+
`拦截规则:[${matchedWall.ruleType}] ${patStr}`,
|
|
2667
|
+
`代理阻断依据:${blockerEv}`,
|
|
2668
|
+
`拟批准操作:${actMode === 'remove' ? '永久移除该物理驻墙' : '暂挂休眠该物理驻墙(可随时恢复)'}`,
|
|
2669
|
+
].join('\n'),
|
|
2670
|
+
evidence: blockerEv,
|
|
2671
|
+
wallRemovalSpec: {
|
|
2672
|
+
wallId: matchedWall.id,
|
|
2673
|
+
wallTitle: matchedWall.title,
|
|
2674
|
+
action: actMode,
|
|
2675
|
+
patterns: matchedWall.patterns || [],
|
|
2676
|
+
reason: removeReason,
|
|
2677
|
+
blockerEvidence: blockerEv,
|
|
2678
|
+
reportedBy: _fromLeadRequest ? 'lead/subagent' : 'chief_review',
|
|
2679
|
+
},
|
|
2680
|
+
popup: true,
|
|
2681
|
+
urgency: 'high',
|
|
2682
|
+
})
|
|
2683
|
+
if (sug) {
|
|
2684
|
+
ws.suggestions.push(sug)
|
|
2685
|
+
if (ws.suggestions.length > SUGGESTIONS_CAP) ws.suggestions = ws.suggestions.slice(-SUGGESTIONS_CAP)
|
|
2686
|
+
proposedWallRemovals.push(sug)
|
|
2687
|
+
actionBadges.push(`⚠️ 请示拆墙:${clamp(matchedWall.title, 18)}`)
|
|
2688
|
+
pushAuditToWs(ws, {
|
|
2689
|
+
mode: permissionMode,
|
|
2690
|
+
stage: 'guard_wall',
|
|
2691
|
+
rule: 'wall_removal_requested',
|
|
2692
|
+
decision: 'pending_approval',
|
|
2693
|
+
operation: '参谋呈报人工审批拆墙',
|
|
2694
|
+
target: `${matchedWall.title} (${matchedWall.id})`,
|
|
2695
|
+
reason: clamp(removeReason, 180),
|
|
2696
|
+
outcome: 'pending',
|
|
2697
|
+
by: 'chief',
|
|
2698
|
+
}, rootId)
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2282
2703
|
for (const rawInq of rawInquiries) {
|
|
2283
2704
|
if (!rawInq || typeof rawInq !== 'object') continue
|
|
2284
2705
|
const qText = cleanMultiline(rawInq.question || rawInq.text || '', 500)
|
|
@@ -2412,18 +2833,32 @@ export async function askOrCommandChief(deps, {
|
|
|
2412
2833
|
}
|
|
2413
2834
|
}
|
|
2414
2835
|
|
|
2836
|
+
for (const rawSug of [...pendingArchiveSuggestions, ...pendingEffortSuggestions]) {
|
|
2837
|
+
const sug = normalizeSuggestion(rawSug)
|
|
2838
|
+
if (!sug) continue
|
|
2839
|
+
const dup = ws.suggestions.some(ex => ex && ex.status === 'pending' && ex.kind === sug.kind && ex.title === sug.title)
|
|
2840
|
+
if (!dup) {
|
|
2841
|
+
ws.suggestions.push(sug)
|
|
2842
|
+
if (ws.suggestions.length > SUGGESTIONS_CAP) ws.suggestions = ws.suggestions.slice(-SUGGESTIONS_CAP)
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2415
2846
|
persistTurnChatAndResume(ws, {
|
|
2416
2847
|
chiefText: replyText,
|
|
2417
2848
|
actions: actionBadges,
|
|
2418
2849
|
elevationObj: finalElevation,
|
|
2419
2850
|
pendingApprovalList: queuedApprovals,
|
|
2851
|
+
thinkingEffort: llmRes.thinkingEffort || '',
|
|
2852
|
+
thinkingEffortMode: llmRes.thinkingEffortMode || effCfg.thinkingEffort || 'auto',
|
|
2420
2853
|
forceReceipt: Boolean(
|
|
2421
2854
|
relayResults.length > 0
|
|
2422
2855
|
|| createdInquiries.length > 0
|
|
2423
2856
|
|| proposedWalls.length > 0
|
|
2857
|
+
|| proposedWallRemovals.length > 0
|
|
2424
2858
|
|| appliedFacts.length > 0
|
|
2425
2859
|
|| executedBoardOps.length > 0
|
|
2426
2860
|
|| executedArchiveOps.length > 0
|
|
2861
|
+
|| executedEffortOps.length > 0
|
|
2427
2862
|
|| executedNetworkOps.length > 0
|
|
2428
2863
|
|| loopToolRecords.some(r => {
|
|
2429
2864
|
const tName = r && ((r.call && (r.call.tool || r.call.name)) || (r.result && r.result.tool) || r.tool || '')
|
|
@@ -2495,14 +2930,18 @@ export async function askOrCommandChief(deps, {
|
|
|
2495
2930
|
relays: relayResults,
|
|
2496
2931
|
inquiries: createdInquiries,
|
|
2497
2932
|
wallProposals: proposedWalls,
|
|
2933
|
+
wallRemovalProposals: proposedWallRemovals,
|
|
2498
2934
|
actionBadges,
|
|
2499
2935
|
memoryChanges: appliedFacts,
|
|
2500
2936
|
boardOps: executedBoardOps,
|
|
2501
2937
|
archiveOps: executedArchiveOps,
|
|
2938
|
+
effortOps: executedEffortOps,
|
|
2502
2939
|
networkOps: executedNetworkOps,
|
|
2503
2940
|
boundProposals: proposedBounds,
|
|
2504
2941
|
toolRecords: loopToolRecords,
|
|
2505
2942
|
pendingApprovals: queuedApprovals,
|
|
2943
|
+
thinkingEffort: llmRes.thinkingEffort || '',
|
|
2944
|
+
thinkingEffortMode: llmRes.thinkingEffortMode || effCfg.thinkingEffort || 'auto',
|
|
2506
2945
|
...(finalElevation ? { elevationRequested: finalElevation } : {}),
|
|
2507
2946
|
permissionMode,
|
|
2508
2947
|
...(freshBoard ? { board: freshBoard } : {}),
|
|
@@ -2767,6 +3206,7 @@ export async function suggestCoreObjectiveWithChief(deps, {
|
|
|
2767
3206
|
try {
|
|
2768
3207
|
const llmRes = await callChiefLlm(deps, {
|
|
2769
3208
|
sessionId: rootId,
|
|
3209
|
+
reasonKind: 'suggest_objective',
|
|
2770
3210
|
system: OBJECTIVE_SUGGEST_SYSTEM,
|
|
2771
3211
|
prompt: promptLines.join('\n'),
|
|
2772
3212
|
maxTokens: 320,
|
|
@@ -2826,6 +3266,32 @@ export async function handleLeadDirectRequestToChief(deps, {
|
|
|
2826
3266
|
const summaryTitle = clamp(subject || cleanBody, 48)
|
|
2827
3267
|
let ledgerTaskId = ''
|
|
2828
3268
|
|
|
3269
|
+
// Rare path: Lead / Subagent reports an insurmountable dynamic guard-wall blocker -> read-only Chief evaluation first; any wall removal still requires explicit human approval across L0-L3
|
|
3270
|
+
const combinedReqText = `${subject || ''} ${cleanBody}`
|
|
3271
|
+
const isWallBlockerEscalation = /(?:撞墙阻断|物理驻墙|物理墙|无法绕过|事前物理拦截|guard_wall|wall-[a-z0-9]+)/i.test(combinedReqText)
|
|
3272
|
+
if (isWallBlockerEscalation) {
|
|
3273
|
+
const cwdNow = resolveSessionWorkspaceCwd(deps, rootId)
|
|
3274
|
+
const activeWallsNow = listGuardWalls({ cwd: cwdNow }).filter(w => w && w.scope !== 'paused')
|
|
3275
|
+
if (activeWallsNow.length > 0) {
|
|
3276
|
+
const evalRes = await askOrCommandChief(deps, {
|
|
3277
|
+
sessionId: rootId,
|
|
3278
|
+
text: `[来自 ${fromLabel} 的撞墙阻断上报 · ${subject || '物理墙评估'}]\n${cleanBody}`,
|
|
3279
|
+
_fromLeadRequest: true,
|
|
3280
|
+
_wallBlockerEscalation: true,
|
|
3281
|
+
})
|
|
3282
|
+
if (evalRes && Array.isArray(evalRes.wallRemovalProposals) && evalRes.wallRemovalProposals.length > 0) {
|
|
3283
|
+
return {
|
|
3284
|
+
ok: true,
|
|
3285
|
+
mode: permissionMode,
|
|
3286
|
+
actionTaken: 'wall_removal_requested',
|
|
3287
|
+
wallRemovalProposals: evalRes.wallRemovalProposals,
|
|
3288
|
+
reply: evalRes.reply || '',
|
|
3289
|
+
...(evalRes.view ? { view: evalRes.view } : {}),
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
|
|
2829
3295
|
mutateChiefState((s) => {
|
|
2830
3296
|
const ws = ensureWorkspace(s, rootId)
|
|
2831
3297
|
const entry = upsertTaskLedgerOnWs(ws, {
|