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/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 = []
|
|
@@ -1155,9 +1258,11 @@ export async function askOrCommandChief(deps, {
|
|
|
1155
1258
|
text = '',
|
|
1156
1259
|
forcedTarget = '',
|
|
1157
1260
|
forcedMode = 'steer',
|
|
1261
|
+
quickAction = '',
|
|
1158
1262
|
images = [],
|
|
1159
1263
|
_resumeCtx = null,
|
|
1160
1264
|
_fromLeadRequest = false,
|
|
1265
|
+
_wallBlockerEscalation = false,
|
|
1161
1266
|
}) {
|
|
1162
1267
|
const rawInput = cleanMultiline(text, 2000)
|
|
1163
1268
|
const rawImages = Array.isArray(images) ? images : []
|
|
@@ -1217,6 +1322,8 @@ export async function askOrCommandChief(deps, {
|
|
|
1217
1322
|
pendingApprovalList = [],
|
|
1218
1323
|
target = '',
|
|
1219
1324
|
forceReceipt = false,
|
|
1325
|
+
thinkingEffort = '',
|
|
1326
|
+
thinkingEffortMode = '',
|
|
1220
1327
|
}) => {
|
|
1221
1328
|
const cleanActions = Array.isArray(actions) ? actions.filter(Boolean) : []
|
|
1222
1329
|
const isReceipt = Boolean(isResumeTurn || _fromLeadRequest || forceReceipt || elevationObj || pendingApprovalList.length > 0 || cleanActions.length > 0)
|
|
@@ -1292,6 +1399,8 @@ export async function askOrCommandChief(deps, {
|
|
|
1292
1399
|
role: 'chief',
|
|
1293
1400
|
kind: isReceipt ? 'receipt' : 'qa',
|
|
1294
1401
|
...(attachedTaskId ? { resumeTaskId: attachedTaskId } : {}),
|
|
1402
|
+
...(thinkingEffort ? { thinkingEffort } : {}),
|
|
1403
|
+
...(thinkingEffortMode ? { thinkingEffortMode } : {}),
|
|
1295
1404
|
text: chiefText,
|
|
1296
1405
|
actions: finalActions,
|
|
1297
1406
|
at: Date.now(),
|
|
@@ -1445,39 +1554,48 @@ export async function askOrCommandChief(deps, {
|
|
|
1445
1554
|
}
|
|
1446
1555
|
}
|
|
1447
1556
|
|
|
1448
|
-
// Watch
|
|
1557
|
+
// Watch session & hooked global archives in background (cold vault is 100% isolated from Chief & Lead!)
|
|
1449
1558
|
const visibleArchives = collectChiefVisibleArchives(deps, rootId, state)
|
|
1450
1559
|
const watchLines = []
|
|
1451
|
-
const fmtWatchTag = (label, it) => `[${label}${it.id ? ` | id=${it.id}` : ''}] 《${clamp(it.title, 36)}》:${clamp(it.summary, 80)}`
|
|
1560
|
+
const fmtWatchTag = (label, it) => `[${label}${it.id ? ` | id=${it.id}` : ''}] 《${clamp(it.title, 36)}》:${clamp(it.summary || it.hookCue, 80)}`
|
|
1452
1561
|
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.
|
|
1562
|
+
...visibleArchives.deskSessionItems.map(it => fmtWatchTag('桌面·本局(主与参谋共阅)', it)),
|
|
1563
|
+
...visibleArchives.deskGlobalItems.map(it => fmtWatchTag('桌面·全局(主与参谋共阅)', it)),
|
|
1564
|
+
...visibleArchives.deskFlippedItems.map(it => fmtWatchTag('桌面·冷藏已翻牌(主与参谋共阅)', it)),
|
|
1565
|
+
...visibleArchives.mountedGlobalItems.map(it => fmtWatchTag('全局已拉阅·主隐', it)),
|
|
1566
|
+
...((visibleArchives.sessionItems || []).filter(it => !it.takenOut).slice(0, 8).map(it => `[本局档案·参谋随时可读${it.hasHook ? ' 🪝已织钩' : ' (未织钩)'} | id=${it.id}] 《${clamp(it.title, 36)}》:${clamp(it.summary, 70)}`)),
|
|
1567
|
+
...((visibleArchives.recentlyUnpinnedWatch || []).slice(0, 4).map(w => `[刚撤下桌面·待观察归位 | id=${w.id}] 《${clamp(w.title, 36)}》`)),
|
|
1568
|
+
...((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
1569
|
]
|
|
1461
1570
|
if (watchEntries.length > 0) {
|
|
1462
|
-
watchLines.push('', '## 9.
|
|
1571
|
+
watchLines.push('', '## 9. 参谋长档案馆线索与认知桌面(冷库严密隔离;桌面主对话可见;全局仅暴露已织钩子)', ...watchEntries.map(x => '- ' + x))
|
|
1463
1572
|
}
|
|
1464
1573
|
|
|
1465
|
-
// On-demand lazy archive lookup ONLY when the user explicitly asks Chief about archives (
|
|
1466
|
-
const asksArchiveExplicitly = /(
|
|
1574
|
+
// On-demand lazy archive lookup ONLY when the user explicitly asks Chief about archives (searches Session + Hooked Global Vault; unhooked Global/Cold blocked)
|
|
1575
|
+
const asksArchiveExplicitly = /(?:档案|卷宗|归档|以前|历史记录|工程坐标|老笔记|全局|查一下.*(?:怎么|路径|命令|配置))/.test(input)
|
|
1467
1576
|
const onDemandArchiveLines = []
|
|
1468
1577
|
if (asksArchiveExplicitly) {
|
|
1469
1578
|
const sessionTarget = rootId && rootId !== 'global' ? archiveTargetForRoot(deps, rootId, { vaultScope: 'session' }) : null
|
|
1470
1579
|
const globalTarget = archiveTargetForRoot(deps, rootId, { vaultScope: 'global' })
|
|
1471
1580
|
const foundSess = sessionTarget ? searchArchives(input, { limit: 3, vaultScope: 'session' }, sessionTarget) : { ok: true, hits: [] }
|
|
1472
|
-
const
|
|
1581
|
+
const foundGlobRaw = searchGlobalVaultForChief(input, { limit: 5 }, globalTarget)
|
|
1582
|
+
const pulledOrDeskGlobIds = new Set([
|
|
1583
|
+
...(visibleArchives.mountedGlobalItems || []).map(x => x.id),
|
|
1584
|
+
...(visibleArchives.deskGlobalItems || []).map(x => x.id),
|
|
1585
|
+
])
|
|
1586
|
+
const foundGlobHits = (Array.isArray(foundGlobRaw.hits) ? foundGlobRaw.hits : []).filter(h => h && h.hasHook === true).slice(0, 3)
|
|
1473
1587
|
const combinedHits = [
|
|
1474
|
-
...(Array.isArray(foundSess.hits) ? foundSess.hits.map(h => ({ ...h, _scopeLabel: '本会话档案', _target: sessionTarget })) : []),
|
|
1475
|
-
...
|
|
1588
|
+
...(Array.isArray(foundSess.hits) ? foundSess.hits.map(h => ({ ...h, _scope: 'session', _scopeLabel: '本会话档案', _target: sessionTarget })) : []),
|
|
1589
|
+
...foundGlobHits.map(h => ({ ...h, _scope: 'global', _scopeLabel: '系统全局档案(已织钩)', _target: globalTarget })),
|
|
1476
1590
|
]
|
|
1477
1591
|
if (combinedHits.length > 0) {
|
|
1478
|
-
onDemandArchiveLines.push('', '## 7.
|
|
1592
|
+
onDemandArchiveLines.push('', '## 7. 按需检索到的档案卷宗(仅本局与已织钩全局;未拉阅全局仅展示钩子)')
|
|
1479
1593
|
for (let i = 0; i < combinedHits.length; i += 1) {
|
|
1480
1594
|
const hit = combinedHits[i]
|
|
1595
|
+
if (hit._scope === 'global' && !pulledOrDeskGlobIds.has(hit.id)) {
|
|
1596
|
+
onDemandArchiveLines.push(`- 🪝 [全局钩子待拉阅/${hit.folderLabel} | id=${hit.id}] 《${hit.title}》 关键词=[${(hit.hookKeywords || []).join('·')}] ${clamp(hit.hookCue || hit.summary, 90)}(如需详情可输出 archiveOps pull_global)`)
|
|
1597
|
+
continue
|
|
1598
|
+
}
|
|
1481
1599
|
onDemandArchiveLines.push(`- 📎 [${hit._scopeLabel}/${hit.folderLabel}] 《${hit.title}》:${hit.summary}`)
|
|
1482
1600
|
if (i < 3) {
|
|
1483
1601
|
const det = getArchiveDetail(hit.id, rootId, hit._target)
|
|
@@ -1594,8 +1712,17 @@ export async function askOrCommandChief(deps, {
|
|
|
1594
1712
|
|
|
1595
1713
|
const isBlankContext = liveDigest.summaryLines.length === 0 && !board.objective && !(board.plan || []).length
|
|
1596
1714
|
const resolvedCwd = deps && typeof deps.getSessionCwd === 'function' ? deps.getSessionCwd(rootId) : ''
|
|
1715
|
+
const cwdForPromptWalls = resolveSessionWorkspaceCwd(deps, rootId) || resolvedCwd
|
|
1716
|
+
const activeDynamicWalls = listGuardWalls({ cwd: cwdForPromptWalls }).filter(w => w && w.scope !== 'paused')
|
|
1717
|
+
if (activeDynamicWalls.length > 0) {
|
|
1718
|
+
promptLines.push(
|
|
1719
|
+
'',
|
|
1720
|
+
'## 6.8 当前生效动态物理驻墙参考(仅作阻断排查,严禁私拆;仅代理撞墙无法绕过上报且确无法继续时才可请示审批)',
|
|
1721
|
+
...activeDynamicWalls.slice(0, 8).map(w => `- [${w.id}] (${w.scope}/${w.ruleType}) ${w.title} :: ${Array.isArray(w.patterns) ? w.patterns.join(', ') : ''}`),
|
|
1722
|
+
)
|
|
1723
|
+
}
|
|
1597
1724
|
const explicitCompactReq = !imageBlocks.length && isExplicitCompactCommand(input)
|
|
1598
|
-
const statusOnlyInquiry = !imageBlocks.length && !explicitCompactReq && isPureStatusInquiry(input)
|
|
1725
|
+
const statusOnlyInquiry = !imageBlocks.length && !explicitCompactReq && quickAction !== 'consult_chief' && !_wallBlockerEscalation && isPureStatusInquiry(input)
|
|
1599
1726
|
const userExplicitDirect = /(?:参谋长.*?(?:亲自|自己|直接|别找主)|你自己(?:动手|改|跑|查|写)|别派发|勿转主对话)/.test(input)
|
|
1600
1727
|
const hasLiveLead = Boolean(
|
|
1601
1728
|
deps
|
|
@@ -1616,6 +1743,16 @@ export async function askOrCommandChief(deps, {
|
|
|
1616
1743
|
const effectiveSystem = [
|
|
1617
1744
|
ASK_CHIEF_SYSTEM,
|
|
1618
1745
|
...(isConciseBrief ? [CONCISE_BRIEF_ASK_EXTRA] : []),
|
|
1746
|
+
...(quickAction === 'consult_chief' ? [CONSULT_CHIEF_EXTRA] : []),
|
|
1747
|
+
...(_wallBlockerEscalation
|
|
1748
|
+
? [
|
|
1749
|
+
'',
|
|
1750
|
+
'🧱 【当前正在评估主/子代理提交的“撞墙阻断上报”】:',
|
|
1751
|
+
'- 请严格核对代理是否真的撞到了上述动态物理驻墙,以及**是否真的没有任何合法替代途径继续完成任务**;',
|
|
1752
|
+
'- 若有替代做法(如改用只读核查、调整目标路径/命令或分步处理),**绝不申请拆墙**,直接在 `reply` 中给出合法绕行路径即可;',
|
|
1753
|
+
'- 只有确认确被某堵动态墙彻底卡死无法推进时,才可在 `"wallRemovalProposals"` 中提出针对该精确 `wallId` 的暂挂/拆墙申请单供人类逐项批示!',
|
|
1754
|
+
]
|
|
1755
|
+
: []),
|
|
1619
1756
|
...(isBlankContext
|
|
1620
1757
|
? [
|
|
1621
1758
|
'',
|
|
@@ -1642,6 +1779,14 @@ export async function askOrCommandChief(deps, {
|
|
|
1642
1779
|
const upsertArchiveFn = buildChiefArchiveUpsertFn(deps, rootId)
|
|
1643
1780
|
const compactNowFn = buildChiefCompactFn(deps, rootId)
|
|
1644
1781
|
|
|
1782
|
+
const askReasonKind = statusOnlyInquiry
|
|
1783
|
+
? 'quick_status'
|
|
1784
|
+
: (/筑墙|物理墙|guard.?wall/i.test(input)
|
|
1785
|
+
? 'craft_wall'
|
|
1786
|
+
: (isBlankContext
|
|
1787
|
+
? 'blank_explore'
|
|
1788
|
+
: ((effCfg.tacticalModes && effCfg.tacticalModes.intervention) ? 'strong_intervention' : 'ask_chat')))
|
|
1789
|
+
|
|
1645
1790
|
const loopRes = await runChiefAgenticLoop(deps, {
|
|
1646
1791
|
rootId,
|
|
1647
1792
|
sessionId: rootId,
|
|
@@ -1655,9 +1800,9 @@ export async function askOrCommandChief(deps, {
|
|
|
1655
1800
|
board,
|
|
1656
1801
|
maxSteps: statusOnlyInquiry ? 1 : 4,
|
|
1657
1802
|
readOnlyToolsOnly: false,
|
|
1658
|
-
disableTools: statusOnlyInquiry,
|
|
1803
|
+
disableTools: statusOnlyInquiry || (_wallBlockerEscalation && permRank < 3),
|
|
1659
1804
|
lazyDeferWorkspaceWritesToLead,
|
|
1660
|
-
callLlmFn: (callOpts) => callChiefLlm(deps, { ...callOpts, maxTokens: SUMMARY_MAX_TOKENS }),
|
|
1805
|
+
callLlmFn: (callOpts) => callChiefLlm(deps, { reasonKind: askReasonKind, ...callOpts, maxTokens: SUMMARY_MAX_TOKENS }),
|
|
1661
1806
|
extractJsonFn: extractJsonObject,
|
|
1662
1807
|
upsertArchiveFn,
|
|
1663
1808
|
compactNowFn,
|
|
@@ -1935,6 +2080,8 @@ export async function askOrCommandChief(deps, {
|
|
|
1935
2080
|
elevationObj: autoElevOut,
|
|
1936
2081
|
pendingApprovalList: queuedApprovals,
|
|
1937
2082
|
forceReceipt: true,
|
|
2083
|
+
thinkingEffort: llmRes.thinkingEffort || '',
|
|
2084
|
+
thinkingEffortMode: llmRes.thinkingEffortMode || effCfg.thinkingEffort || 'auto',
|
|
1938
2085
|
})
|
|
1939
2086
|
})
|
|
1940
2087
|
return {
|
|
@@ -1980,7 +2127,7 @@ export async function askOrCommandChief(deps, {
|
|
|
1980
2127
|
conciseBrief: isConciseBrief,
|
|
1981
2128
|
})
|
|
1982
2129
|
const replyText = isConciseBrief ? sanitizeConciseBriefText(rawFallbackReply) : rawFallbackReply
|
|
1983
|
-
const fallbackBounds = permRank >= 1 ? extractFallbackBoundProposalsFromText(rawFallbackReply, input) : []
|
|
2130
|
+
const fallbackBounds = (permRank >= 1 && quickAction !== 'consult_chief') ? extractFallbackBoundProposalsFromText(rawFallbackReply, input) : []
|
|
1984
2131
|
const createdFallbackBounds = []
|
|
1985
2132
|
const BOUND_COL_LABEL_FB = { forbidden: '禁止红线', allowed: '必做事项', notes: '注意事项' }
|
|
1986
2133
|
|
|
@@ -2018,6 +2165,8 @@ export async function askOrCommandChief(deps, {
|
|
|
2018
2165
|
elevationObj: fallbackElev,
|
|
2019
2166
|
pendingApprovalList: queuedApprovals,
|
|
2020
2167
|
forceReceipt: createdFallbackBounds.length > 0,
|
|
2168
|
+
thinkingEffort: llmRes.thinkingEffort || '',
|
|
2169
|
+
thinkingEffortMode: llmRes.thinkingEffortMode || effCfg.thinkingEffort || 'auto',
|
|
2021
2170
|
})
|
|
2022
2171
|
})
|
|
2023
2172
|
return {
|
|
@@ -2142,9 +2291,30 @@ export async function askOrCommandChief(deps, {
|
|
|
2142
2291
|
: (Array.isArray(parsed.boundaryProposals) && parsed.boundaryProposals.length > 0
|
|
2143
2292
|
? parsed.boundaryProposals
|
|
2144
2293
|
: extractFallbackBoundProposalsFromText(parsed.reply || '', input))
|
|
2294
|
+
const rawArchiveOps = Array.isArray(parsed.archiveOps) ? parsed.archiveOps.slice(0, 8) : []
|
|
2295
|
+
const rawEffortOps = Array.isArray(parsed.effortOps) ? parsed.effortOps.slice(0, 6) : []
|
|
2296
|
+
const internalArchiveOps = []
|
|
2297
|
+
const mainInjectArchiveOps = []
|
|
2298
|
+
for (const opItem of rawArchiveOps) {
|
|
2299
|
+
if (!opItem || typeof opItem !== 'object') continue
|
|
2300
|
+
const normOp = normalizeArchiveOpName(opItem.op)
|
|
2301
|
+
const sc = opItem.vaultScope === 'precipitated'
|
|
2302
|
+
? 'precipitated'
|
|
2303
|
+
: (opItem.vaultScope === 'global' ? 'global' : 'session')
|
|
2304
|
+
if (sc === 'precipitated' || normOp === 'pull_precipitated') {
|
|
2305
|
+
internalArchiveOps.push(opItem)
|
|
2306
|
+
} else if (MAIN_INJECT_ARCHIVE_OPS.has(normOp)) {
|
|
2307
|
+
mainInjectArchiveOps.push({ ...opItem, op: normOp, vaultScope: sc })
|
|
2308
|
+
} else if (normOp === 'save' && opItem.takeOut) {
|
|
2309
|
+
internalArchiveOps.push({ ...opItem, takeOut: false })
|
|
2310
|
+
mainInjectArchiveOps.push({ op: 'pin_to_desktop', vaultScope: sc, title: opItem.title, instruction: opItem.summary || '' })
|
|
2311
|
+
} else {
|
|
2312
|
+
internalArchiveOps.push(opItem)
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2145
2315
|
const hasSystemOps = Boolean(
|
|
2146
2316
|
(Array.isArray(parsed.boardOps) && parsed.boardOps.length > 0)
|
|
2147
|
-
||
|
|
2317
|
+
|| internalArchiveOps.length > 0
|
|
2148
2318
|
|| (Array.isArray(parsed.networkOps) && parsed.networkOps.length > 0)
|
|
2149
2319
|
|| (Array.isArray(parsed.memoryChanges) && parsed.memoryChanges.length > 0)
|
|
2150
2320
|
|| rawBoundListSrc.length > 0
|
|
@@ -2161,6 +2331,9 @@ export async function askOrCommandChief(deps, {
|
|
|
2161
2331
|
let executedBoardOps = []
|
|
2162
2332
|
let executedArchiveOps = []
|
|
2163
2333
|
let executedNetworkOps = []
|
|
2334
|
+
let executedEffortOps = []
|
|
2335
|
+
const pendingArchiveSuggestions = []
|
|
2336
|
+
const pendingEffortSuggestions = []
|
|
2164
2337
|
let appliedFacts = []
|
|
2165
2338
|
const proposedBounds = []
|
|
2166
2339
|
const existingBounds = (board && board.bounds) || { allowed: [], forbidden: [], notes: [] }
|
|
@@ -2184,7 +2357,7 @@ export async function askOrCommandChief(deps, {
|
|
|
2184
2357
|
executedBoardOps = applyBoardOps(deps, rootId, parsed.boardOps, { callerOrigin: 'chief_llm' })
|
|
2185
2358
|
for (const b of executedBoardOps) actionBadges.push(b)
|
|
2186
2359
|
|
|
2187
|
-
const archiveExec = await applyArchiveOps(deps, rootId,
|
|
2360
|
+
const archiveExec = await applyArchiveOps(deps, rootId, internalArchiveOps, { input, allowPinToDesktop: false })
|
|
2188
2361
|
executedArchiveOps = archiveExec.executed || []
|
|
2189
2362
|
for (const a of executedArchiveOps) actionBadges.push(a)
|
|
2190
2363
|
|
|
@@ -2205,6 +2378,161 @@ export async function askOrCommandChief(deps, {
|
|
|
2205
2378
|
}
|
|
2206
2379
|
}
|
|
2207
2380
|
|
|
2381
|
+
// Dual-channel main injection from archives (Channel A: desktop pin/unpin, Channel B: deliver_to_lead)
|
|
2382
|
+
// L0/L1 -> Suggestion pill; L2 -> Approval card + TaskLedger; L3 -> Direct execution
|
|
2383
|
+
for (const item of mainInjectArchiveOps) {
|
|
2384
|
+
const scopeLabel = item.vaultScope === 'global' ? '全局档案柜' : '本局档案柜'
|
|
2385
|
+
const refText = item.title ? `《${clamp(item.title, 28)}》` : `#${item.id || item.archiveId || '?'}`
|
|
2386
|
+
const opDesc = item.op === 'pin_to_desktop'
|
|
2387
|
+
? `将${scopeLabel}档案置顶桌面`
|
|
2388
|
+
: (item.op === 'unpin_from_desktop' ? `将${scopeLabel}档案撤回抽屉` : `向主对话递送${scopeLabel}档案`)
|
|
2389
|
+
if (relayGate.decision === 'deny_mode' || relayGate.decision === 'deny_unacknowledged_l3' || relayGate.decision === 'deny_policy_plugin') {
|
|
2390
|
+
if (relayGate.decision !== 'deny_policy_plugin' && permRank < 2) {
|
|
2391
|
+
pendingArchiveSuggestions.push({
|
|
2392
|
+
kind: 'archive_op',
|
|
2393
|
+
fromAgent: '📌 参谋档案馆通道',
|
|
2394
|
+
title: `${opDesc}:${refText}`,
|
|
2395
|
+
reason: clamp(item.instruction || `当前处于 L${permRank} 只读/助手档,后台不直接注入主会话;点「执行建议」即刻落位。`, 180),
|
|
2396
|
+
target: item.target || 'lead',
|
|
2397
|
+
targetLabel: item.op === 'deliver_to_lead' ? '主对话 (@lead)' : '📌 认知桌面',
|
|
2398
|
+
mode: 'steer',
|
|
2399
|
+
draftText: `${opDesc} ${refText}${item.instruction ? ' — ' + item.instruction : ''}`,
|
|
2400
|
+
archiveSpec: {
|
|
2401
|
+
op: item.op,
|
|
2402
|
+
vaultScope: item.vaultScope,
|
|
2403
|
+
id: item.id || item.archiveId || '',
|
|
2404
|
+
title: item.title || '',
|
|
2405
|
+
target: item.target || 'lead',
|
|
2406
|
+
instruction: item.instruction || '',
|
|
2407
|
+
},
|
|
2408
|
+
})
|
|
2409
|
+
actionBadges.push(`💡 建议档案注入:${refText}`)
|
|
2410
|
+
} else {
|
|
2411
|
+
workflowBlockedNeedsElevation = workflowBlockedNeedsElevation || relayGate.decision !== 'deny_policy_plugin'
|
|
2412
|
+
actionBadges.push(relayGate.badge || '🔒 权限禁注档案')
|
|
2413
|
+
}
|
|
2414
|
+
continue
|
|
2415
|
+
}
|
|
2416
|
+
if (relayGate.decision === 'require_approval') {
|
|
2417
|
+
const apr = queueChiefApproval(rootId, {
|
|
2418
|
+
category: 'main_workflow',
|
|
2419
|
+
operationLabel: opDesc,
|
|
2420
|
+
targetLabel: `${scopeLabel} · ${refText}`,
|
|
2421
|
+
reason: clamp(item.instruction || 'L2 参谋模式:向主对话桌面或正文注入档案前需逐项确认', 140),
|
|
2422
|
+
impact: item.op === 'deliver_to_lead' ? '将把该卷宗摘要与要点投递至主对话并唤醒查收' : '将调整主对话共享认知桌面置顶列表(受 2400 Tokens/6 份预算约束)',
|
|
2423
|
+
preview: clamp(`${opDesc} ${refText}${item.instruction ? '\n附言:' + item.instruction : ''}`, 240),
|
|
2424
|
+
kind: 'archive_op',
|
|
2425
|
+
capabilityScope: buildCapabilityScope({ kind: 'archive_op', tool: 'archive_op', target: refText }),
|
|
2426
|
+
payload: {
|
|
2427
|
+
op: item.op,
|
|
2428
|
+
vaultScope: item.vaultScope,
|
|
2429
|
+
id: item.id || item.archiveId || '',
|
|
2430
|
+
title: item.title || '',
|
|
2431
|
+
target: item.target || 'lead',
|
|
2432
|
+
instruction: item.instruction || '',
|
|
2433
|
+
},
|
|
2434
|
+
by: 'chief',
|
|
2435
|
+
})
|
|
2436
|
+
if (apr) queuedApprovals.push(apr)
|
|
2437
|
+
actionBadges.push(`🛡️ 待确认档案注入:${refText}`)
|
|
2438
|
+
appendChiefAuditLog(rootId, { mode: permissionMode, stage: 'permission_gate', decision: 'pending_approval', operation: opDesc, target: refText, reason: clamp(input, 120), outcome: 'pending', by: 'chief' })
|
|
2439
|
+
continue
|
|
2440
|
+
}
|
|
2441
|
+
const execOut = await executeChiefArchiveInjectionOp(deps, rootId, item, { input })
|
|
2442
|
+
if (execOut && execOut.ok) {
|
|
2443
|
+
executedArchiveOps.push(execOut.actionText)
|
|
2444
|
+
actionBadges.push(execOut.actionText)
|
|
2445
|
+
appendChiefAuditLog(rootId, { mode: permissionMode, stage: 'executor', decision: 'executed', operation: opDesc, target: refText, reason: clamp(input, 120), outcome: 'ok', by: 'chief' })
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
// Hot reasoning-effort shifting (`effortOps`) with 4-tier permission gate + teamEffortMode + per-agent user 🔒 veto lock
|
|
2450
|
+
const userLocks = (effCfg && effCfg.lockedModelEfforts && typeof effCfg.lockedModelEfforts === 'object') ? effCfg.lockedModelEfforts : {}
|
|
2451
|
+
const isManualTeamEffort = Boolean(effCfg && effCfg.teamEffortMode === 'manual')
|
|
2452
|
+
if (isManualTeamEffort && rawEffortOps.length > 0) {
|
|
2453
|
+
actionBadges.push('✋ 团队思考强度已设为手动,跳过自动调挡')
|
|
2454
|
+
appendChiefAuditLog(rootId, {
|
|
2455
|
+
mode: permissionMode,
|
|
2456
|
+
stage: 'model_effort_lock',
|
|
2457
|
+
decision: 'blocked',
|
|
2458
|
+
operation: '调节模型思考强度',
|
|
2459
|
+
target: rawEffortOps.map(ef => String((ef && (ef.target || ef.agent)) || 'lead').replace(/^@/, '')).join(','),
|
|
2460
|
+
reason: '团队思考强度处于「手动」模式,已跳过自动调挡',
|
|
2461
|
+
outcome: 'blocked',
|
|
2462
|
+
by: 'chief',
|
|
2463
|
+
})
|
|
2464
|
+
}
|
|
2465
|
+
for (const ef of (isManualTeamEffort ? [] : rawEffortOps)) {
|
|
2466
|
+
if (!ef || typeof ef !== 'object') continue
|
|
2467
|
+
const efTarget = clamp(String(ef.target || ef.agent || 'lead').trim().replace(/^@/, ''), 64) || 'lead'
|
|
2468
|
+
const rawEf = String(ef.effort || ef.reasoningEffort || 'medium').trim().toLowerCase()
|
|
2469
|
+
const efVal = ['off', 'low', 'medium', 'high', 'xhigh'].includes(rawEf) ? rawEf : 'medium'
|
|
2470
|
+
const efReason = clamp(String(ef.reason || '按任务复杂度协同调节模型思考强度').trim(), 180)
|
|
2471
|
+
const shortEfTarget = efTarget.split('/').pop()
|
|
2472
|
+
const isUserLocked = Boolean(userLocks[efTarget] === true || userLocks[shortEfTarget] === true)
|
|
2473
|
+
if (isUserLocked) {
|
|
2474
|
+
actionBadges.push(`🔒 用户已锁挡 @${efTarget}`)
|
|
2475
|
+
appendChiefAuditLog(rootId, { mode: permissionMode, stage: 'model_effort_lock', decision: 'blocked', operation: '调节模型思考强度', target: efTarget, reason: `用户开启「🔒 锁挡」,阻止调为 ${efVal}`, outcome: 'blocked', by: 'chief' })
|
|
2476
|
+
continue
|
|
2477
|
+
}
|
|
2478
|
+
if (relayGate.decision === 'deny_mode' || relayGate.decision === 'deny_unacknowledged_l3' || relayGate.decision === 'deny_policy_plugin') {
|
|
2479
|
+
if (relayGate.decision !== 'deny_policy_plugin' && permRank < 2) {
|
|
2480
|
+
pendingEffortSuggestions.push({
|
|
2481
|
+
kind: 'model_effort',
|
|
2482
|
+
fromAgent: '🧠 思考强度建议',
|
|
2483
|
+
title: `建议调挡 @${efTarget} → ${efVal}`,
|
|
2484
|
+
reason: efReason,
|
|
2485
|
+
target: efTarget,
|
|
2486
|
+
targetLabel: efTarget === 'lead' ? '主对话 (@lead)' : `@${efTarget}`,
|
|
2487
|
+
mode: 'silent',
|
|
2488
|
+
draftText: `将 @${efTarget} 思考强度设为 ${efVal}(${efReason})`,
|
|
2489
|
+
effortSpec: { target: efTarget, effort: efVal, reason: efReason },
|
|
2490
|
+
})
|
|
2491
|
+
actionBadges.push(`💡 建议调挡 @${efTarget}→${efVal}`)
|
|
2492
|
+
} else {
|
|
2493
|
+
workflowBlockedNeedsElevation = workflowBlockedNeedsElevation || relayGate.decision !== 'deny_policy_plugin'
|
|
2494
|
+
actionBadges.push(relayGate.badge || '🔒 权限禁调档位')
|
|
2495
|
+
}
|
|
2496
|
+
continue
|
|
2497
|
+
}
|
|
2498
|
+
if (relayGate.decision === 'require_approval') {
|
|
2499
|
+
const apr = queueChiefApproval(rootId, {
|
|
2500
|
+
category: 'main_workflow',
|
|
2501
|
+
operationLabel: '调节模型思考强度',
|
|
2502
|
+
targetLabel: efTarget === 'lead' ? '主对话 (@lead)' : `@${efTarget}`,
|
|
2503
|
+
reason: efReason,
|
|
2504
|
+
impact: `批准后将静默热调节 @${efTarget} 的推理思考深度为 ${efVal}`,
|
|
2505
|
+
preview: `@${efTarget} → ${efVal}`,
|
|
2506
|
+
kind: 'model_effort',
|
|
2507
|
+
capabilityScope: buildCapabilityScope({ kind: 'model_effort', tool: 'model_effort', target: efTarget }),
|
|
2508
|
+
payload: { target: efTarget, reasoningEffort: efVal, reason: efReason },
|
|
2509
|
+
by: 'chief',
|
|
2510
|
+
})
|
|
2511
|
+
if (apr) queuedApprovals.push(apr)
|
|
2512
|
+
actionBadges.push(`🛡️ 待确认调挡 @${efTarget}→${efVal}`)
|
|
2513
|
+
appendChiefAuditLog(rootId, { mode: permissionMode, stage: 'permission_gate', decision: 'pending_approval', operation: '调节模型思考强度', target: efTarget, reason: efReason, outcome: 'pending', by: 'chief' })
|
|
2514
|
+
continue
|
|
2515
|
+
}
|
|
2516
|
+
if (deps && typeof deps.controlMainAgent === 'function') {
|
|
2517
|
+
const ctrlRes = await deps.controlMainAgent({
|
|
2518
|
+
rootId,
|
|
2519
|
+
sessionId: rootId,
|
|
2520
|
+
op: 'set_effort',
|
|
2521
|
+
target: efTarget,
|
|
2522
|
+
reasoningEffort: efVal,
|
|
2523
|
+
reason: efReason,
|
|
2524
|
+
byUser: false,
|
|
2525
|
+
}).catch(e => ({ ok: false, error: (e && e.message) || 'effort-control-failed' }))
|
|
2526
|
+
if (ctrlRes && ctrlRes.ok) {
|
|
2527
|
+
const tag = `🧠 调挡 @${efTarget} → ${ctrlRes.reasoningEffort || efVal}`
|
|
2528
|
+
executedEffortOps.push(tag)
|
|
2529
|
+
actionBadges.push(tag)
|
|
2530
|
+
} else if (ctrlRes && ctrlRes.lockedByUser) {
|
|
2531
|
+
actionBadges.push(`🔒 用户已锁挡 @${efTarget}`)
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2208
2536
|
// Handle explicit model elevationRequest OR auto-generate when an action hit mode wall
|
|
2209
2537
|
let finalElevation = queuedElevations[0] || null
|
|
2210
2538
|
if (parsed.elevationRequest && typeof parsed.elevationRequest === 'object' && parsed.elevationRequest.targetMode) {
|
|
@@ -2275,10 +2603,102 @@ export async function askOrCommandChief(deps, {
|
|
|
2275
2603
|
const BOUND_COL_LABEL = { forbidden: '禁止红线', allowed: '必做事项', notes: '注意事项' }
|
|
2276
2604
|
const createdInquiries = []
|
|
2277
2605
|
const proposedWalls = []
|
|
2606
|
+
const proposedWallRemovals = []
|
|
2278
2607
|
const cwdForWall = resolveSessionWorkspaceCwd(deps, rootId)
|
|
2608
|
+
const rawWallRemovalProposals = Array.isArray(parsed.wallRemovalProposals) ? parsed.wallRemovalProposals.slice(0, 2) : []
|
|
2279
2609
|
|
|
2280
2610
|
mutateChiefState((s) => {
|
|
2281
2611
|
const ws = ensureWorkspace(s, rootId)
|
|
2612
|
+
|
|
2613
|
+
// Ultra-strict, all-tier (L0-L3) Human Approval Wall-Removal Proposal Gate
|
|
2614
|
+
if (rawWallRemovalProposals.length > 0) {
|
|
2615
|
+
const hasWallBlockLog = (Array.isArray(ws.auditLog) ? ws.auditLog : [])
|
|
2616
|
+
.some(e => e && e.stage === 'guard_wall' && e.outcome === 'blocked')
|
|
2617
|
+
const mentionsBlocker = /(?:撞墙|物理驻墙|物理墙|无法绕过|事前物理拦截|guard_wall|wall-)/i.test(input)
|
|
2618
|
+
const hasWallBlockerEvidence = Boolean(_wallBlockerEscalation || (hasWallBlockLog && mentionsBlocker))
|
|
2619
|
+
if (!hasWallBlockerEvidence) {
|
|
2620
|
+
pushAuditToWs(ws, {
|
|
2621
|
+
mode: permissionMode,
|
|
2622
|
+
stage: 'guard_wall',
|
|
2623
|
+
rule: 'wall_removal_denied_no_blocker_evidence',
|
|
2624
|
+
decision: 'rejected',
|
|
2625
|
+
operation: '拦截无依据拆墙提议',
|
|
2626
|
+
target: 'guard_walls',
|
|
2627
|
+
reason: '未收到主/子代理真实撞墙且无法绕过阻断上报,拒绝生成拆墙申请',
|
|
2628
|
+
outcome: 'rejected',
|
|
2629
|
+
by: 'chief',
|
|
2630
|
+
}, rootId)
|
|
2631
|
+
} else {
|
|
2632
|
+
const activeWalls = listGuardWalls({ cwd: cwdForWall }).filter(w => w && w.scope !== 'paused')
|
|
2633
|
+
for (const rawWr of rawWallRemovalProposals) {
|
|
2634
|
+
if (!rawWr || typeof rawWr !== 'object') continue
|
|
2635
|
+
const reqId = String(rawWr.wallId || rawWr.id || '').trim()
|
|
2636
|
+
const reqTitle = String(rawWr.wallTitle || rawWr.title || '').trim()
|
|
2637
|
+
const matchedWall = activeWalls.find(w =>
|
|
2638
|
+
(reqId && w.id === reqId)
|
|
2639
|
+
|| (reqTitle && w.title === reqTitle),
|
|
2640
|
+
)
|
|
2641
|
+
if (!matchedWall) continue
|
|
2642
|
+
const blockerEv = cleanMultiline(rawWr.blockerEvidence || rawWr.evidence || '', 260)
|
|
2643
|
+
const removeReason = cleanMultiline(rawWr.reason || '', 220)
|
|
2644
|
+
if (!blockerEv || !removeReason) continue
|
|
2645
|
+
const dupWr = ws.suggestions.some(ex =>
|
|
2646
|
+
ex
|
|
2647
|
+
&& ex.status === 'pending'
|
|
2648
|
+
&& ex.kind === 'wall_removal'
|
|
2649
|
+
&& ex.wallRemovalSpec
|
|
2650
|
+
&& ex.wallRemovalSpec.wallId === matchedWall.id,
|
|
2651
|
+
)
|
|
2652
|
+
if (dupWr) continue
|
|
2653
|
+
const actMode = String(rawWr.action || '').trim().toLowerCase() === 'remove' ? 'remove' : 'pause'
|
|
2654
|
+
const patStr = Array.isArray(matchedWall.patterns) ? matchedWall.patterns.join(', ') : ''
|
|
2655
|
+
const sug = normalizeSuggestion({
|
|
2656
|
+
kind: 'wall_removal',
|
|
2657
|
+
fromAgent: '⚠️ 参谋请示拆墙(极低概率 · 阻断复核)',
|
|
2658
|
+
title: `请示${actMode === 'remove' ? '拆除' : '暂挂'}物理墙:${clamp(matchedWall.title, 28)}`,
|
|
2659
|
+
reason: clamp(removeReason, 200),
|
|
2660
|
+
target: 'guard_walls',
|
|
2661
|
+
targetLabel: clamp(matchedWall.title, 36),
|
|
2662
|
+
mode: 'silent',
|
|
2663
|
+
draftText: [
|
|
2664
|
+
`目标物理驻墙:${matchedWall.title} (${matchedWall.id})`,
|
|
2665
|
+
`拦截规则:[${matchedWall.ruleType}] ${patStr}`,
|
|
2666
|
+
`代理阻断依据:${blockerEv}`,
|
|
2667
|
+
`拟批准操作:${actMode === 'remove' ? '永久移除该物理驻墙' : '暂挂休眠该物理驻墙(可随时恢复)'}`,
|
|
2668
|
+
].join('\n'),
|
|
2669
|
+
evidence: blockerEv,
|
|
2670
|
+
wallRemovalSpec: {
|
|
2671
|
+
wallId: matchedWall.id,
|
|
2672
|
+
wallTitle: matchedWall.title,
|
|
2673
|
+
action: actMode,
|
|
2674
|
+
patterns: matchedWall.patterns || [],
|
|
2675
|
+
reason: removeReason,
|
|
2676
|
+
blockerEvidence: blockerEv,
|
|
2677
|
+
reportedBy: _fromLeadRequest ? 'lead/subagent' : 'chief_review',
|
|
2678
|
+
},
|
|
2679
|
+
popup: true,
|
|
2680
|
+
urgency: 'high',
|
|
2681
|
+
})
|
|
2682
|
+
if (sug) {
|
|
2683
|
+
ws.suggestions.push(sug)
|
|
2684
|
+
if (ws.suggestions.length > SUGGESTIONS_CAP) ws.suggestions = ws.suggestions.slice(-SUGGESTIONS_CAP)
|
|
2685
|
+
proposedWallRemovals.push(sug)
|
|
2686
|
+
actionBadges.push(`⚠️ 请示拆墙:${clamp(matchedWall.title, 18)}`)
|
|
2687
|
+
pushAuditToWs(ws, {
|
|
2688
|
+
mode: permissionMode,
|
|
2689
|
+
stage: 'guard_wall',
|
|
2690
|
+
rule: 'wall_removal_requested',
|
|
2691
|
+
decision: 'pending_approval',
|
|
2692
|
+
operation: '参谋呈报人工审批拆墙',
|
|
2693
|
+
target: `${matchedWall.title} (${matchedWall.id})`,
|
|
2694
|
+
reason: clamp(removeReason, 180),
|
|
2695
|
+
outcome: 'pending',
|
|
2696
|
+
by: 'chief',
|
|
2697
|
+
}, rootId)
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2282
2702
|
for (const rawInq of rawInquiries) {
|
|
2283
2703
|
if (!rawInq || typeof rawInq !== 'object') continue
|
|
2284
2704
|
const qText = cleanMultiline(rawInq.question || rawInq.text || '', 500)
|
|
@@ -2412,18 +2832,32 @@ export async function askOrCommandChief(deps, {
|
|
|
2412
2832
|
}
|
|
2413
2833
|
}
|
|
2414
2834
|
|
|
2835
|
+
for (const rawSug of [...pendingArchiveSuggestions, ...pendingEffortSuggestions]) {
|
|
2836
|
+
const sug = normalizeSuggestion(rawSug)
|
|
2837
|
+
if (!sug) continue
|
|
2838
|
+
const dup = ws.suggestions.some(ex => ex && ex.status === 'pending' && ex.kind === sug.kind && ex.title === sug.title)
|
|
2839
|
+
if (!dup) {
|
|
2840
|
+
ws.suggestions.push(sug)
|
|
2841
|
+
if (ws.suggestions.length > SUGGESTIONS_CAP) ws.suggestions = ws.suggestions.slice(-SUGGESTIONS_CAP)
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2415
2845
|
persistTurnChatAndResume(ws, {
|
|
2416
2846
|
chiefText: replyText,
|
|
2417
2847
|
actions: actionBadges,
|
|
2418
2848
|
elevationObj: finalElevation,
|
|
2419
2849
|
pendingApprovalList: queuedApprovals,
|
|
2850
|
+
thinkingEffort: llmRes.thinkingEffort || '',
|
|
2851
|
+
thinkingEffortMode: llmRes.thinkingEffortMode || effCfg.thinkingEffort || 'auto',
|
|
2420
2852
|
forceReceipt: Boolean(
|
|
2421
2853
|
relayResults.length > 0
|
|
2422
2854
|
|| createdInquiries.length > 0
|
|
2423
2855
|
|| proposedWalls.length > 0
|
|
2856
|
+
|| proposedWallRemovals.length > 0
|
|
2424
2857
|
|| appliedFacts.length > 0
|
|
2425
2858
|
|| executedBoardOps.length > 0
|
|
2426
2859
|
|| executedArchiveOps.length > 0
|
|
2860
|
+
|| executedEffortOps.length > 0
|
|
2427
2861
|
|| executedNetworkOps.length > 0
|
|
2428
2862
|
|| loopToolRecords.some(r => {
|
|
2429
2863
|
const tName = r && ((r.call && (r.call.tool || r.call.name)) || (r.result && r.result.tool) || r.tool || '')
|
|
@@ -2495,14 +2929,18 @@ export async function askOrCommandChief(deps, {
|
|
|
2495
2929
|
relays: relayResults,
|
|
2496
2930
|
inquiries: createdInquiries,
|
|
2497
2931
|
wallProposals: proposedWalls,
|
|
2932
|
+
wallRemovalProposals: proposedWallRemovals,
|
|
2498
2933
|
actionBadges,
|
|
2499
2934
|
memoryChanges: appliedFacts,
|
|
2500
2935
|
boardOps: executedBoardOps,
|
|
2501
2936
|
archiveOps: executedArchiveOps,
|
|
2937
|
+
effortOps: executedEffortOps,
|
|
2502
2938
|
networkOps: executedNetworkOps,
|
|
2503
2939
|
boundProposals: proposedBounds,
|
|
2504
2940
|
toolRecords: loopToolRecords,
|
|
2505
2941
|
pendingApprovals: queuedApprovals,
|
|
2942
|
+
thinkingEffort: llmRes.thinkingEffort || '',
|
|
2943
|
+
thinkingEffortMode: llmRes.thinkingEffortMode || effCfg.thinkingEffort || 'auto',
|
|
2506
2944
|
...(finalElevation ? { elevationRequested: finalElevation } : {}),
|
|
2507
2945
|
permissionMode,
|
|
2508
2946
|
...(freshBoard ? { board: freshBoard } : {}),
|
|
@@ -2826,6 +3264,32 @@ export async function handleLeadDirectRequestToChief(deps, {
|
|
|
2826
3264
|
const summaryTitle = clamp(subject || cleanBody, 48)
|
|
2827
3265
|
let ledgerTaskId = ''
|
|
2828
3266
|
|
|
3267
|
+
// 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
|
|
3268
|
+
const combinedReqText = `${subject || ''} ${cleanBody}`
|
|
3269
|
+
const isWallBlockerEscalation = /(?:撞墙阻断|物理驻墙|物理墙|无法绕过|事前物理拦截|guard_wall|wall-[a-z0-9]+)/i.test(combinedReqText)
|
|
3270
|
+
if (isWallBlockerEscalation) {
|
|
3271
|
+
const cwdNow = resolveSessionWorkspaceCwd(deps, rootId)
|
|
3272
|
+
const activeWallsNow = listGuardWalls({ cwd: cwdNow }).filter(w => w && w.scope !== 'paused')
|
|
3273
|
+
if (activeWallsNow.length > 0) {
|
|
3274
|
+
const evalRes = await askOrCommandChief(deps, {
|
|
3275
|
+
sessionId: rootId,
|
|
3276
|
+
text: `[来自 ${fromLabel} 的撞墙阻断上报 · ${subject || '物理墙评估'}]\n${cleanBody}`,
|
|
3277
|
+
_fromLeadRequest: true,
|
|
3278
|
+
_wallBlockerEscalation: true,
|
|
3279
|
+
})
|
|
3280
|
+
if (evalRes && Array.isArray(evalRes.wallRemovalProposals) && evalRes.wallRemovalProposals.length > 0) {
|
|
3281
|
+
return {
|
|
3282
|
+
ok: true,
|
|
3283
|
+
mode: permissionMode,
|
|
3284
|
+
actionTaken: 'wall_removal_requested',
|
|
3285
|
+
wallRemovalProposals: evalRes.wallRemovalProposals,
|
|
3286
|
+
reply: evalRes.reply || '',
|
|
3287
|
+
...(evalRes.view ? { view: evalRes.view } : {}),
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
|
|
2829
3293
|
mutateChiefState((s) => {
|
|
2830
3294
|
const ws = ensureWorkspace(s, rootId)
|
|
2831
3295
|
const entry = upsertTaskLedgerOnWs(ws, {
|