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-state.js
CHANGED
|
@@ -12,6 +12,7 @@ import { threadId } from 'node:worker_threads'
|
|
|
12
12
|
import {
|
|
13
13
|
resolveProjectKey,
|
|
14
14
|
loadArchiveStore,
|
|
15
|
+
loadGlobalVaultRaw,
|
|
15
16
|
getChiefMountedGlobalForSession,
|
|
16
17
|
getTakenOutGlobalForSession,
|
|
17
18
|
collectSealedWatchSummary,
|
|
@@ -92,6 +93,88 @@ export const CHIEF_EXEC_REQ_SOURCE = 'dsh-chief-execution-request'
|
|
|
92
93
|
|
|
93
94
|
export const CHAT_OPPORTUNISTIC_SUMMARY_COOLDOWN_MS = 60_000
|
|
94
95
|
|
|
96
|
+
export const CHIEF_RUN_MODES = ['off', 'patrol', 'managed']
|
|
97
|
+
|
|
98
|
+
export const DEFAULT_MANAGED_IDLE_TIMEOUT_MS = 15 * 60 * 1000
|
|
99
|
+
|
|
100
|
+
export const CHIEF_THINKING_EFFORTS = ['auto', 'off', 'low', 'medium', 'high', 'xhigh']
|
|
101
|
+
|
|
102
|
+
export function normalizeRunMode(raw, fallbackCfg = null) {
|
|
103
|
+
const s = typeof raw === 'string' ? raw.trim().toLowerCase() : ''
|
|
104
|
+
if (s === 'off' || s === 'patrol' || s === 'managed') return s
|
|
105
|
+
if (s === 'stopped' || s === 'manual') return 'off'
|
|
106
|
+
if (s === 'smart') return 'patrol'
|
|
107
|
+
if (s === 'auto' || s === 'autopilot') return 'managed'
|
|
108
|
+
if (fallbackCfg && typeof fallbackCfg === 'object') {
|
|
109
|
+
if (fallbackCfg.stopped || fallbackCfg.paceMode === 'stopped') return 'off'
|
|
110
|
+
if (fallbackCfg.autoPilot || fallbackCfg.paceMode === 'auto') return 'managed'
|
|
111
|
+
if (fallbackCfg.paceMode === 'smart') return 'patrol'
|
|
112
|
+
}
|
|
113
|
+
return 'off'
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function normalizeThinkingEffort(raw) {
|
|
117
|
+
const s = typeof raw === 'string' ? raw.trim().toLowerCase() : ''
|
|
118
|
+
if (CHIEF_THINKING_EFFORTS.includes(s)) return s
|
|
119
|
+
return 'auto'
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function normalizeTeamEffortMode(raw) {
|
|
123
|
+
return String(raw || '').trim().toLowerCase() === 'manual' ? 'manual' : 'auto'
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function normalizeLockedModelEfforts(raw) {
|
|
127
|
+
const out = {}
|
|
128
|
+
if (!raw || typeof raw !== 'object') return out
|
|
129
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
130
|
+
const cleanKey = String(k || '').trim().slice(0, 64)
|
|
131
|
+
if (!cleanKey) continue
|
|
132
|
+
if (v === true) out[cleanKey] = true
|
|
133
|
+
}
|
|
134
|
+
return out
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const EFFORT_ORDER_LADDER = ['off', 'low', 'medium', 'high', 'xhigh']
|
|
138
|
+
|
|
139
|
+
export function resolveAlignedModelEffort(desiredEffort, supportedEfforts = []) {
|
|
140
|
+
const list = Array.isArray(supportedEfforts)
|
|
141
|
+
? supportedEfforts.map(e => (typeof e === 'string' ? e : (e && e.id ? String(e.id) : ''))).filter(Boolean)
|
|
142
|
+
: []
|
|
143
|
+
if (!list.length) return undefined
|
|
144
|
+
const want = String(desiredEffort || '').trim().toLowerCase()
|
|
145
|
+
if (!want || want === 'auto') {
|
|
146
|
+
if (list.includes('medium')) return 'medium'
|
|
147
|
+
return list[Math.floor(list.length / 2)] || list[0]
|
|
148
|
+
}
|
|
149
|
+
if (list.includes(want)) return want
|
|
150
|
+
const wantIdx = EFFORT_ORDER_LADDER.indexOf(want)
|
|
151
|
+
if (wantIdx < 0) return list[0]
|
|
152
|
+
for (let d = 1; d < EFFORT_ORDER_LADDER.length; d += 1) {
|
|
153
|
+
if (wantIdx - d >= 0 && list.includes(EFFORT_ORDER_LADDER[wantIdx - d])) {
|
|
154
|
+
return EFFORT_ORDER_LADDER[wantIdx - d]
|
|
155
|
+
}
|
|
156
|
+
if (wantIdx + d < EFFORT_ORDER_LADDER.length && list.includes(EFFORT_ORDER_LADDER[wantIdx + d])) {
|
|
157
|
+
return EFFORT_ORDER_LADDER[wantIdx + d]
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return list[0]
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function touchWorkspaceActivity(sessionId) {
|
|
164
|
+
const sid = String(sessionId || '').trim()
|
|
165
|
+
if (!sid || sid === 'global') return false
|
|
166
|
+
try {
|
|
167
|
+
mutateChiefState((state) => {
|
|
168
|
+
const ws = ensureWorkspace(state, sid)
|
|
169
|
+
if (!ws.runtimeGuard || typeof ws.runtimeGuard !== 'object') ws.runtimeGuard = {}
|
|
170
|
+
ws.runtimeGuard.lastActivityAt = Date.now()
|
|
171
|
+
})
|
|
172
|
+
return true
|
|
173
|
+
} catch {
|
|
174
|
+
return false
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
95
178
|
const SECRET_PATTERN = /(?:sk-[a-zA-Z0-9_-]{16,}|ghp_[a-zA-Z0-9]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{30,}|Bearer\s+[A-Za-z0-9._~+/=-]{20,}|-----BEGIN [A-Z ]*PRIVATE KEY-----)/
|
|
96
179
|
|
|
97
180
|
let dshAttachmentModulePromise = null
|
|
@@ -164,10 +247,12 @@ export function archiveTargetForRoot(deps, rootId, extra = '') {
|
|
|
164
247
|
}
|
|
165
248
|
|
|
166
249
|
/**
|
|
167
|
-
* Chief-of-Staff visibility matrix (
|
|
168
|
-
* -
|
|
169
|
-
* -
|
|
170
|
-
*
|
|
250
|
+
* Chief-of-Staff visibility matrix (Three-Tier Hook Architecture):
|
|
251
|
+
* - Session Working Cabinet: Chief can always read session items + `recentlyUnpinnedWatch`.
|
|
252
|
+
* - Global Vault: Unorganized global items (without hooks) are 0-token invisible to Chief!
|
|
253
|
+
* Organized global items expose ONLY lightweight `globalHookIndex` (`hasHook: true`),
|
|
254
|
+
* until Chief explicitly pulls/mounts them (`chiefMountedSessions` / `chiefPulledSessions`).
|
|
255
|
+
* - Precipitated Cold Vault: 100% invisible to Chief (0 disk read, 0 hook leak) unless User explicitly `flippedOut`!
|
|
171
256
|
*/
|
|
172
257
|
export function collectChiefVisibleArchives(deps, rootId, stateSnapshot = null) {
|
|
173
258
|
const sid = rootId && rootId !== 'global' ? String(rootId).trim() : ''
|
|
@@ -180,6 +265,9 @@ export function collectChiefVisibleArchives(deps, rootId, stateSnapshot = null)
|
|
|
180
265
|
let deskGlobalItems = []
|
|
181
266
|
let deskFlippedItems = []
|
|
182
267
|
let mountedGlobalItems = []
|
|
268
|
+
let sessionItems = []
|
|
269
|
+
let recentlyUnpinnedWatch = []
|
|
270
|
+
let globalHookIndex = []
|
|
183
271
|
let sealedWatch = { sessionSealed: [], globalSealed: [], precipSealed: [] }
|
|
184
272
|
|
|
185
273
|
try {
|
|
@@ -187,13 +275,54 @@ export function collectChiefVisibleArchives(deps, rootId, stateSnapshot = null)
|
|
|
187
275
|
const stSess = loadArchiveStore(sessionTarget)
|
|
188
276
|
const allSess = Array.isArray(stSess.items) ? stSess.items : []
|
|
189
277
|
deskSessionItems = allSess.filter(it => Array.isArray(it.takenOutSessions) && it.takenOutSessions.includes(sid)).slice(0, 6)
|
|
278
|
+
sessionItems = allSess.slice(0, 16).map(it => ({
|
|
279
|
+
id: it.id,
|
|
280
|
+
title: it.title,
|
|
281
|
+
folder: it.folder,
|
|
282
|
+
summary: it.summary,
|
|
283
|
+
paperclip: it.paperclip,
|
|
284
|
+
hasHook: Boolean(it.hasHook),
|
|
285
|
+
hookKeywords: Array.isArray(it.hookKeywords) ? it.hookKeywords : [],
|
|
286
|
+
hookCue: it.hookCue || '',
|
|
287
|
+
takenOut: Array.isArray(it.takenOutSessions) && it.takenOutSessions.includes(sid),
|
|
288
|
+
points: Array.isArray(it.points) ? it.points.slice(0, 3) : [],
|
|
289
|
+
}))
|
|
290
|
+
recentlyUnpinnedWatch = Array.isArray(stSess.recentlyUnpinnedWatch) ? stSess.recentlyUnpinnedWatch.slice() : []
|
|
190
291
|
}
|
|
191
292
|
} catch {}
|
|
192
293
|
try {
|
|
294
|
+
const gStore = loadGlobalVaultRaw(globalTarget)
|
|
295
|
+
const gAll = Array.isArray(gStore && gStore.items) ? gStore.items : []
|
|
193
296
|
if (sid) {
|
|
194
297
|
deskGlobalItems = getTakenOutGlobalForSession(sid, globalTarget).slice(0, 6)
|
|
195
298
|
mountedGlobalItems = getChiefMountedGlobalForSession(sid, globalTarget).slice(0, 6)
|
|
299
|
+
// Also include entries Chief pulled in this session
|
|
300
|
+
const pulledSet = new Set(mountedGlobalItems.map(x => x.id))
|
|
301
|
+
for (const g of gAll) {
|
|
302
|
+
if (g && Array.isArray(g.chiefPulledSessions) && g.chiefPulledSessions.includes(sid) && !pulledSet.has(g.id)) {
|
|
303
|
+
mountedGlobalItems.push(g)
|
|
304
|
+
pulledSet.add(g.id)
|
|
305
|
+
if (mountedGlobalItems.length >= 6) break
|
|
306
|
+
}
|
|
307
|
+
}
|
|
196
308
|
}
|
|
309
|
+
globalHookIndex = gAll
|
|
310
|
+
.filter(it =>
|
|
311
|
+
it
|
|
312
|
+
&& it.hasHook === true
|
|
313
|
+
&& (!sid || (!Array.isArray(it.takenOutSessions) || !it.takenOutSessions.includes(sid)))
|
|
314
|
+
&& (!sid || (!Array.isArray(it.chiefMountedSessions) || !it.chiefMountedSessions.includes(sid)))
|
|
315
|
+
&& (!sid || (!Array.isArray(it.chiefPulledSessions) || !it.chiefPulledSessions.includes(sid)))
|
|
316
|
+
)
|
|
317
|
+
.slice(0, 12)
|
|
318
|
+
.map(it => ({
|
|
319
|
+
id: it.id,
|
|
320
|
+
title: it.title,
|
|
321
|
+
folder: it.folder,
|
|
322
|
+
paperclip: it.paperclip,
|
|
323
|
+
hookKeywords: Array.isArray(it.hookKeywords) ? it.hookKeywords : [],
|
|
324
|
+
hookCue: it.hookCue || '',
|
|
325
|
+
}))
|
|
197
326
|
} catch {}
|
|
198
327
|
try {
|
|
199
328
|
if (sid) {
|
|
@@ -214,6 +343,9 @@ export function collectChiefVisibleArchives(deps, rootId, stateSnapshot = null)
|
|
|
214
343
|
deskGlobalItems,
|
|
215
344
|
deskFlippedItems,
|
|
216
345
|
mountedGlobalItems,
|
|
346
|
+
sessionItems,
|
|
347
|
+
recentlyUnpinnedWatch,
|
|
348
|
+
globalHookIndex,
|
|
217
349
|
sealedWatch,
|
|
218
350
|
sessionTarget,
|
|
219
351
|
globalTarget,
|
|
@@ -382,7 +514,7 @@ function normalizePendingApproval(raw) {
|
|
|
382
514
|
if (!opLabel) return null
|
|
383
515
|
const validStatuses = ['pending', 'approved', 'rejected', 'executed', 'failed', 'expired']
|
|
384
516
|
const status = validStatuses.includes(raw.status) ? raw.status : 'pending'
|
|
385
|
-
const validKinds = ['tool', 'relay', 'compact', 'auto_continue']
|
|
517
|
+
const validKinds = ['tool', 'relay', 'compact', 'auto_continue', 'archive_op', 'model_effort']
|
|
386
518
|
const kind = validKinds.includes(raw.kind) ? raw.kind : 'tool'
|
|
387
519
|
const validCategories = ['workspace_file', 'system_command', 'main_workflow', 'subagent_workflow']
|
|
388
520
|
const category = validCategories.includes(raw.category) ? raw.category : 'workspace_file'
|
|
@@ -615,6 +747,9 @@ function emptyWorkspace() {
|
|
|
615
747
|
lastGoalAchievedSig: '',
|
|
616
748
|
autoPilotStartedAt: 0,
|
|
617
749
|
autoPilotHadTurn: false,
|
|
750
|
+
managedStartedAt: 0,
|
|
751
|
+
lastActivityAt: 0,
|
|
752
|
+
lastDreamRoamAt: 0,
|
|
618
753
|
lastAutoArchiveOrgAt: 0,
|
|
619
754
|
},
|
|
620
755
|
flippedPrecipitatedIds: [],
|
|
@@ -648,12 +783,19 @@ export function normalizeSuggestion(raw) {
|
|
|
648
783
|
if (!raw || typeof raw !== 'object') return null
|
|
649
784
|
const title = clamp(raw.title, 90)
|
|
650
785
|
if (!title) return null
|
|
651
|
-
const kind = ['bound', 'board', 'goal_approval', 'relay', 'advice', 'guard_wall'].includes(raw.kind) ? raw.kind : 'relay'
|
|
786
|
+
const kind = ['bound', 'board', 'goal_approval', 'relay', 'advice', 'guard_wall', 'wall_removal', 'archive_op', 'model_effort'].includes(raw.kind) ? raw.kind : 'relay'
|
|
652
787
|
const boundField = ['forbidden', 'allowed', 'notes'].includes(raw.boundField) ? raw.boundField : 'forbidden'
|
|
653
788
|
const replaces = Array.isArray(raw.replaces)
|
|
654
789
|
? raw.replaces.map(x => String(x || '').trim()).filter(Boolean).slice(0, 20)
|
|
655
790
|
: []
|
|
656
791
|
const wallSpec = raw.wallSpec && typeof raw.wallSpec === 'object' ? { ...raw.wallSpec } : null
|
|
792
|
+
const wallRemovalSpec = raw.wallRemovalSpec && typeof raw.wallRemovalSpec === 'object' ? { ...raw.wallRemovalSpec } : null
|
|
793
|
+
const archiveSpec = (raw.archiveSpec && typeof raw.archiveSpec === 'object')
|
|
794
|
+
? { ...raw.archiveSpec }
|
|
795
|
+
: ((raw.archiveOp && typeof raw.archiveOp === 'object') ? { ...raw.archiveOp } : null)
|
|
796
|
+
const effortSpec = (raw.effortSpec && typeof raw.effortSpec === 'object')
|
|
797
|
+
? { ...raw.effortSpec }
|
|
798
|
+
: ((raw.effortOp && typeof raw.effortOp === 'object') ? { ...raw.effortOp } : null)
|
|
657
799
|
return {
|
|
658
800
|
id: typeof raw.id === 'string' && raw.id ? raw.id : nextId('sug'),
|
|
659
801
|
kind,
|
|
@@ -661,18 +803,21 @@ export function normalizeSuggestion(raw) {
|
|
|
661
803
|
replaces,
|
|
662
804
|
pinGlobal: Boolean(raw.pinGlobal),
|
|
663
805
|
...(wallSpec ? { wallSpec } : {}),
|
|
806
|
+
...(wallRemovalSpec ? { wallRemovalSpec } : {}),
|
|
807
|
+
...(archiveSpec ? { archiveSpec } : {}),
|
|
808
|
+
...(effortSpec ? { effortSpec } : {}),
|
|
664
809
|
fromAgent: clamp(raw.fromAgent || '', 48),
|
|
665
810
|
title,
|
|
666
811
|
reason: clamp(raw.reason || '', 220),
|
|
667
|
-
target: clamp(raw.target || (kind === 'bound' ? 'bounds' : kind === 'guard_wall' ? 'guard_walls' : kind === 'goal_approval' ? 'board' : 'lead'), 64),
|
|
668
|
-
targetLabel: clamp(raw.targetLabel || raw.target || (kind === 'bound' ? '工作边界' : kind === 'guard_wall' ? '物理驻墙' : kind === 'goal_approval' ? '目标结项批示' : kind === 'advice' ? '参谋进言' : '主对话'), 40),
|
|
812
|
+
target: clamp(raw.target || (kind === 'bound' ? 'bounds' : (kind === 'guard_wall' || kind === 'wall_removal') ? 'guard_walls' : kind === 'goal_approval' ? 'board' : kind === 'archive_op' ? 'archive' : kind === 'model_effort' ? 'lead' : 'lead'), 64),
|
|
813
|
+
targetLabel: clamp(raw.targetLabel || raw.target || (kind === 'bound' ? '工作边界' : kind === 'guard_wall' ? '物理驻墙' : kind === 'wall_removal' ? '物理驻墙拆墙申请' : kind === 'goal_approval' ? '目标结项批示' : kind === 'advice' ? '参谋进言' : kind === 'archive_op' ? '档案与桌面调配' : kind === 'model_effort' ? '模型思考强度调节' : '主对话'), 40),
|
|
669
814
|
mode: ['steer', 'followup', 'silent'].includes(raw.mode) ? raw.mode : (kind === 'advice' ? 'followup' : 'steer'),
|
|
670
815
|
draftText: cleanMultiline(raw.draftText || '', 600),
|
|
671
816
|
evidence: cleanMultiline(raw.evidence || '', 600),
|
|
672
817
|
missing: clamp(raw.missing || '', 300),
|
|
673
818
|
boardOp: raw.boardOp && typeof raw.boardOp === 'object' ? raw.boardOp : null,
|
|
674
|
-
popup: Boolean(raw.popup || kind === 'advice'),
|
|
675
|
-
urgency: ['normal', 'high'].includes(raw.urgency) ? raw.urgency : 'normal',
|
|
819
|
+
popup: Boolean(raw.popup || kind === 'advice' || kind === 'wall_removal'),
|
|
820
|
+
urgency: ['normal', 'high'].includes(raw.urgency) ? raw.urgency : (kind === 'wall_removal' ? 'high' : 'normal'),
|
|
676
821
|
status: ['pending', 'applied', 'dismissed'].includes(raw.status) ? raw.status : 'pending',
|
|
677
822
|
createdAt: Number(raw.createdAt) || Date.now(),
|
|
678
823
|
}
|
|
@@ -763,6 +908,8 @@ function normalizeWorkspace(raw) {
|
|
|
763
908
|
const imageCount = Math.max(0, Math.round(Number(item.imageCount) || 0))
|
|
764
909
|
const kind = item.kind === 'receipt' ? 'receipt' : (item.kind === 'qa' ? 'qa' : '')
|
|
765
910
|
const resumeTaskId = item.resumeTaskId ? String(item.resumeTaskId) : ''
|
|
911
|
+
const thinkingEffort = typeof item.thinkingEffort === 'string' && item.thinkingEffort ? item.thinkingEffort : ''
|
|
912
|
+
const thinkingEffortMode = item.thinkingEffortMode === 'auto' || item.thinkingEffortMode === 'manual' ? item.thinkingEffortMode : ''
|
|
766
913
|
return {
|
|
767
914
|
id: String(item.id || nextId('chat')),
|
|
768
915
|
role: item.role === 'user' ? 'user' : 'chief',
|
|
@@ -770,6 +917,9 @@ function normalizeWorkspace(raw) {
|
|
|
770
917
|
target: item.target ? String(item.target) : '',
|
|
771
918
|
...(kind ? { kind } : {}),
|
|
772
919
|
...(resumeTaskId ? { resumeTaskId } : {}),
|
|
920
|
+
...(thinkingEffort ? { thinkingEffort } : {}),
|
|
921
|
+
...(thinkingEffortMode ? { thinkingEffortMode } : {}),
|
|
922
|
+
...(item.isOneStopReport ? { isOneStopReport: true } : {}),
|
|
773
923
|
...(imageCount > 0 ? { imageCount } : {}),
|
|
774
924
|
actions: Array.isArray(item.actions) ? item.actions.slice(0, 8) : [],
|
|
775
925
|
at: Number(item.at) || Date.now(),
|
|
@@ -810,6 +960,9 @@ function normalizeWorkspace(raw) {
|
|
|
810
960
|
lastGoalAchievedSig: String(rg.lastGoalAchievedSig || ''),
|
|
811
961
|
autoPilotStartedAt: Math.max(0, Number(rg.autoPilotStartedAt) || 0),
|
|
812
962
|
autoPilotHadTurn: Boolean(rg.autoPilotHadTurn),
|
|
963
|
+
managedStartedAt: Math.max(0, Number(rg.managedStartedAt) || Number(rg.autoPilotStartedAt) || 0),
|
|
964
|
+
lastActivityAt: Math.max(0, Number(rg.lastActivityAt) || 0),
|
|
965
|
+
lastDreamRoamAt: Math.max(0, Number(rg.lastDreamRoamAt) || 0),
|
|
813
966
|
lastAutoArchiveOrgAt: Math.max(0, Number(rg.lastAutoArchiveOrgAt) || 0),
|
|
814
967
|
}
|
|
815
968
|
base.chiefRiskAck = normalizeChiefRiskAck(src.chiefRiskAck)
|
|
@@ -836,14 +989,24 @@ function normalizeWorkspace(raw) {
|
|
|
836
989
|
const validPaces = ['manual', 'smart', 'auto', 'stopped']
|
|
837
990
|
const pm = validPaces.includes(src.config.paceMode) ? src.config.paceMode : undefined
|
|
838
991
|
const rawStopped = typeof src.config.stopped === 'boolean' ? src.config.stopped : (pm === 'stopped')
|
|
992
|
+
const rm = normalizeRunMode(src.config.runMode, { ...src.config, stopped: rawStopped, paceMode: pm })
|
|
839
993
|
const rawPerm = typeof src.config.permissionMode === 'string'
|
|
840
994
|
? normalizePermissionMode(src.config.permissionMode, { requireAck: true, hasChiefRiskAck: ackOk })
|
|
841
995
|
: DEFAULT_CHIEF_PERMISSION_MODE
|
|
842
996
|
const plugCheck = validatePolicyPluginList(src.config.policyPlugins)
|
|
843
997
|
const policyPlugins = plugCheck.ok ? plugCheck.plugins : []
|
|
998
|
+
const lockedModelEfforts = normalizeLockedModelEfforts(src.config.lockedModelEfforts)
|
|
999
|
+
const managedIdleTimeoutMs = Number.isFinite(Number(src.config.managedIdleTimeoutMs)) && Number(src.config.managedIdleTimeoutMs) >= 50
|
|
1000
|
+
? Math.min(2 * 60 * 60 * 1000, Math.round(Number(src.config.managedIdleTimeoutMs)))
|
|
1001
|
+
: DEFAULT_MANAGED_IDLE_TIMEOUT_MS
|
|
844
1002
|
base.config = {
|
|
845
1003
|
...(typeof src.config.modelRef === 'string' ? { modelRef: src.config.modelRef.trim() } : {}),
|
|
846
1004
|
permissionMode: rawPerm,
|
|
1005
|
+
runMode: rm,
|
|
1006
|
+
managedIdleTimeoutMs,
|
|
1007
|
+
...(typeof src.config.thinkingEffort === 'string' ? { thinkingEffort: normalizeThinkingEffort(src.config.thinkingEffort) } : {}),
|
|
1008
|
+
...(typeof src.config.teamEffortMode === 'string' ? { teamEffortMode: normalizeTeamEffortMode(src.config.teamEffortMode) } : {}),
|
|
1009
|
+
...(Object.keys(lockedModelEfforts).length ? { lockedModelEfforts } : {}),
|
|
847
1010
|
...(typeof src.config.stopped === 'boolean' || pm === 'stopped' ? { stopped: rawStopped } : {}),
|
|
848
1011
|
...(pm ? { paceMode: pm, autoPilot: !rawStopped && pm === 'auto', autoReview: !rawStopped && pm !== 'manual' } : {}),
|
|
849
1012
|
...(policyPlugins.length > 0 ? { policyPlugins } : {}),
|
|
@@ -955,16 +1118,42 @@ export function resolveWorkspaceConfig(state, sessionId = '') {
|
|
|
955
1118
|
})
|
|
956
1119
|
const permissionMode = resolvedRoleCaps.role
|
|
957
1120
|
const chiefRiskVerified = permissionMode === 'chief' ? ackOk : false
|
|
1121
|
+
const runMode = stopped
|
|
1122
|
+
? 'off'
|
|
1123
|
+
: (wsCfg && typeof wsCfg.runMode === 'string' && CHIEF_RUN_MODES.includes(wsCfg.runMode)
|
|
1124
|
+
? wsCfg.runMode
|
|
1125
|
+
: normalizeRunMode(undefined, { stopped, paceMode, autoPilot: paceMode === 'auto' }))
|
|
1126
|
+
const thinkingEffort = normalizeThinkingEffort(
|
|
1127
|
+
(wsCfg && typeof wsCfg.thinkingEffort === 'string' && wsCfg.thinkingEffort)
|
|
1128
|
+
|| (typeof base.thinkingEffort === 'string' && base.thinkingEffort)
|
|
1129
|
+
|| 'auto',
|
|
1130
|
+
)
|
|
1131
|
+
const teamEffortMode = normalizeTeamEffortMode(
|
|
1132
|
+
(wsCfg && typeof wsCfg.teamEffortMode === 'string' && wsCfg.teamEffortMode)
|
|
1133
|
+
|| (typeof base.teamEffortMode === 'string' && base.teamEffortMode)
|
|
1134
|
+
|| 'auto',
|
|
1135
|
+
)
|
|
1136
|
+
const lockedModelEfforts = normalizeLockedModelEfforts(wsCfg && wsCfg.lockedModelEfforts)
|
|
1137
|
+
const managedIdleTimeoutMs = wsCfg && Number.isFinite(Number(wsCfg.managedIdleTimeoutMs)) && Number(wsCfg.managedIdleTimeoutMs) >= 50
|
|
1138
|
+
? Math.min(2 * 60 * 60 * 1000, Math.round(Number(wsCfg.managedIdleTimeoutMs)))
|
|
1139
|
+
: (Number.isFinite(Number(base.managedIdleTimeoutMs)) && Number(base.managedIdleTimeoutMs) >= 50
|
|
1140
|
+
? Math.min(2 * 60 * 60 * 1000, Math.round(Number(base.managedIdleTimeoutMs)))
|
|
1141
|
+
: DEFAULT_MANAGED_IDLE_TIMEOUT_MS)
|
|
958
1142
|
return {
|
|
959
1143
|
modelRef,
|
|
960
1144
|
paceMode,
|
|
1145
|
+
runMode,
|
|
1146
|
+
managedIdleTimeoutMs,
|
|
1147
|
+
thinkingEffort,
|
|
1148
|
+
teamEffortMode,
|
|
1149
|
+
lockedModelEfforts,
|
|
961
1150
|
stopped,
|
|
962
1151
|
permissionMode,
|
|
963
1152
|
capabilities: resolvedRoleCaps.capabilities,
|
|
964
1153
|
policyPlugins,
|
|
965
1154
|
chiefRiskVerified,
|
|
966
|
-
autoPilot: !stopped &&
|
|
967
|
-
autoReview: !stopped &&
|
|
1155
|
+
autoPilot: !stopped && runMode === 'managed',
|
|
1156
|
+
autoReview: !stopped && runMode === 'managed',
|
|
968
1157
|
tacticalModes: mergedTactical,
|
|
969
1158
|
}
|
|
970
1159
|
}
|
|
@@ -1041,6 +1230,12 @@ function normalizeState(raw) {
|
|
|
1041
1230
|
config: {
|
|
1042
1231
|
modelRef: typeof cfg.modelRef === 'string' ? cfg.modelRef.trim() : '',
|
|
1043
1232
|
paceMode,
|
|
1233
|
+
runMode: stopped ? 'off' : normalizeRunMode(cfg.runMode, { stopped, paceMode }),
|
|
1234
|
+
managedIdleTimeoutMs: Number.isFinite(Number(cfg.managedIdleTimeoutMs)) && Number(cfg.managedIdleTimeoutMs) >= 50
|
|
1235
|
+
? Math.min(2 * 60 * 60 * 1000, Math.round(Number(cfg.managedIdleTimeoutMs)))
|
|
1236
|
+
: DEFAULT_MANAGED_IDLE_TIMEOUT_MS,
|
|
1237
|
+
thinkingEffort: normalizeThinkingEffort(cfg.thinkingEffort),
|
|
1238
|
+
teamEffortMode: normalizeTeamEffortMode(cfg.teamEffortMode),
|
|
1044
1239
|
stopped,
|
|
1045
1240
|
permissionMode: DEFAULT_CHIEF_PERMISSION_MODE,
|
|
1046
1241
|
autoPilot: !stopped && paceMode === 'auto',
|
|
@@ -1205,9 +1400,32 @@ export function answerChiefInquiry(sessionId = 'global', { inquiryId = '', answe
|
|
|
1205
1400
|
}
|
|
1206
1401
|
}
|
|
1207
1402
|
if (idx < 0) return { ok: false, error: `未找到待回复问询:${inquiryId || '最近未答问询'}` }
|
|
1403
|
+
const existing = ws.inquiries[idx]
|
|
1404
|
+
if (!existing || existing.status === 'answered' || (existing.status !== 'pending' && existing.status !== 'delivered')) {
|
|
1405
|
+
const prevId = (existing && existing.inquiryId) || inquiryId
|
|
1406
|
+
const prevStatus = (existing && existing.status) || 'unknown'
|
|
1407
|
+
pushAuditToWs(ws, {
|
|
1408
|
+
mode: resolveWorkspaceConfig(state, rootId).permissionMode,
|
|
1409
|
+
stage: 'inquiry_channel',
|
|
1410
|
+
rule: 'inquiry_reply_replay_rejected',
|
|
1411
|
+
decision: 'rejected',
|
|
1412
|
+
operation: '拦截重复问询答复',
|
|
1413
|
+
target: prevId,
|
|
1414
|
+
reason: `问询 #${prevId} 已结案 (status=${prevStatus}),拒绝重放覆写`,
|
|
1415
|
+
outcome: 'rejected',
|
|
1416
|
+
by: clamp(by || 'lead', 40),
|
|
1417
|
+
}, rootId)
|
|
1418
|
+
return {
|
|
1419
|
+
ok: false,
|
|
1420
|
+
alreadyAnswered: true,
|
|
1421
|
+
code: 'inquiry_already_answered',
|
|
1422
|
+
error: `问询 #${prevId} 已回复结案,拒绝重复应答`,
|
|
1423
|
+
inquiry: existing,
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1208
1426
|
const now = Date.now()
|
|
1209
1427
|
const item = {
|
|
1210
|
-
...
|
|
1428
|
+
...existing,
|
|
1211
1429
|
status: 'answered',
|
|
1212
1430
|
answer: cleanAns,
|
|
1213
1431
|
answeredBy: clamp(by || 'lead', 40),
|
|
@@ -1670,14 +1888,18 @@ export function deployChiefWorkspaceState(deps, {
|
|
|
1670
1888
|
})
|
|
1671
1889
|
if (toWs.chat.length > CHAT_CAP) toWs.chat = toWs.chat.slice(-CHAT_CAP)
|
|
1672
1890
|
|
|
1673
|
-
// Clone safe workspace chief config (model,
|
|
1891
|
+
// Clone safe workspace chief config (model, effort, tactical preferences), ALWAYS forcing intervention=false, runMode='off' & L0 advisor!
|
|
1674
1892
|
const fromCfg = resolveWorkspaceConfig(state, fromKey)
|
|
1675
1893
|
toWs.config = {
|
|
1676
1894
|
modelRef: fromCfg.modelRef || '',
|
|
1677
|
-
paceMode:
|
|
1895
|
+
paceMode: 'manual',
|
|
1896
|
+
runMode: 'off',
|
|
1897
|
+
thinkingEffort: fromCfg.thinkingEffort || 'auto',
|
|
1898
|
+
teamEffortMode: fromCfg.teamEffortMode || 'auto',
|
|
1899
|
+
managedIdleTimeoutMs: fromCfg.managedIdleTimeoutMs || DEFAULT_MANAGED_IDLE_TIMEOUT_MS,
|
|
1678
1900
|
permissionMode: DEFAULT_CHIEF_PERMISSION_MODE,
|
|
1679
|
-
autoPilot:
|
|
1680
|
-
autoReview:
|
|
1901
|
+
autoPilot: false,
|
|
1902
|
+
autoReview: false,
|
|
1681
1903
|
tacticalModes: {
|
|
1682
1904
|
...normalizeTacticalModes(fromCfg.tacticalModes),
|
|
1683
1905
|
intervention: false,
|
|
@@ -1764,6 +1986,60 @@ export function updateChiefConfig(patch) {
|
|
|
1764
1986
|
}
|
|
1765
1987
|
}
|
|
1766
1988
|
|
|
1989
|
+
// Hard gate on model thinking effort lock mutations (human UI / explicit byUser only)
|
|
1990
|
+
const callerBy = typeof safePatch.by === 'string' ? safePatch.by.trim() : ''
|
|
1991
|
+
const isHumanBy = !callerBy || /^(?:user|human|operator|ui_panel)$/i.test(callerBy)
|
|
1992
|
+
const isHumanLockCaller = safePatch._fromUiPanel === true
|
|
1993
|
+
|| (safePatch.byUser === true && isHumanBy)
|
|
1994
|
+
const wantsLockMutation = safePatch.lockedModelEfforts !== undefined
|
|
1995
|
+
|| safePatch.toggleLockAgentEffort !== undefined
|
|
1996
|
+
|| safePatch.teamEffortMode !== undefined
|
|
1997
|
+
if (wantsLockMutation && !isHumanLockCaller) {
|
|
1998
|
+
pushAuditToWs(ws, {
|
|
1999
|
+
mode: effBefore.permissionMode,
|
|
2000
|
+
stage: 'model_effort_lock',
|
|
2001
|
+
rule: 'effort_lock_human_only',
|
|
2002
|
+
decision: 'blocked',
|
|
2003
|
+
operation: '修改模型思考强度锁挡',
|
|
2004
|
+
target: sid,
|
|
2005
|
+
reason: `未授权来源 (${callerBy || 'unknown'}) 试图修改 lockedModelEfforts,仅允许人类面板显式操作`,
|
|
2006
|
+
outcome: 'rejected',
|
|
2007
|
+
by: clamp(callerBy || 'unknown', 40),
|
|
2008
|
+
}, sid)
|
|
2009
|
+
return {
|
|
2010
|
+
ok: false,
|
|
2011
|
+
blocked: true,
|
|
2012
|
+
lockedByUser: true,
|
|
2013
|
+
code: 'effort_lock_human_only',
|
|
2014
|
+
error: '思考强度锁挡 (lockedModelEfforts) 仅允许人类通过面板或显式 byUser 授权修改,已拦截越权变更',
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
if (
|
|
2018
|
+
typeof safePatch.thinkingEffort === 'string'
|
|
2019
|
+
&& effBefore.lockedModelEfforts
|
|
2020
|
+
&& effBefore.lockedModelEfforts.chief === true
|
|
2021
|
+
&& !isHumanLockCaller
|
|
2022
|
+
) {
|
|
2023
|
+
pushAuditToWs(ws, {
|
|
2024
|
+
mode: effBefore.permissionMode,
|
|
2025
|
+
stage: 'model_effort_lock',
|
|
2026
|
+
rule: 'effort_lock_human_only',
|
|
2027
|
+
decision: 'blocked',
|
|
2028
|
+
operation: '修改参谋长思考强度',
|
|
2029
|
+
target: sid,
|
|
2030
|
+
reason: `参谋长思考强度已被用户锁定 (lockedModelEfforts.chief),拒绝非人类来源 (${callerBy || 'unknown'}) 修改`,
|
|
2031
|
+
outcome: 'rejected',
|
|
2032
|
+
by: clamp(callerBy || 'unknown', 40),
|
|
2033
|
+
}, sid)
|
|
2034
|
+
return {
|
|
2035
|
+
ok: false,
|
|
2036
|
+
blocked: true,
|
|
2037
|
+
lockedByUser: true,
|
|
2038
|
+
code: 'effort_lock_human_only',
|
|
2039
|
+
error: '参谋长思考强度已被用户锁定 (lockedModelEfforts.chief),仅允许人类显式修改',
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
|
|
1767
2043
|
// Check explicit Policy Plugin list (restrict-only) BEFORE applying any changes
|
|
1768
2044
|
let validatedPlugins = null
|
|
1769
2045
|
if (safePatch.policyPlugins !== undefined) {
|
|
@@ -1845,18 +2121,22 @@ export function updateChiefConfig(patch) {
|
|
|
1845
2121
|
}
|
|
1846
2122
|
|
|
1847
2123
|
const wantsAutoPilot = Boolean(
|
|
1848
|
-
safePatch.
|
|
1849
|
-
||
|
|
2124
|
+
safePatch.runMode === 'managed'
|
|
2125
|
+
|| safePatch.paceMode === 'auto'
|
|
2126
|
+
|| (typeof safePatch.paceMode !== 'string' && typeof safePatch.runMode !== 'string' && safePatch.stopped !== true && safePatch.autoPilot === true)
|
|
1850
2127
|
)
|
|
1851
|
-
if (wantsAutoPilot && effBefore.paceMode !== 'auto' && safePatch.confirmedAutoPilot !== true) {
|
|
2128
|
+
if (wantsAutoPilot && effBefore.runMode !== 'managed' && effBefore.paceMode !== 'auto' && safePatch.confirmedAutoPilot !== true) {
|
|
1852
2129
|
return {
|
|
1853
2130
|
ok: false,
|
|
1854
2131
|
requireAutoPilotConfirm: true,
|
|
1855
|
-
error: '
|
|
2132
|
+
error: '开启「🤖 托管模式」需先确认本会话自治范围与 5 条件自动休眠保护(confirmedAutoPilot: true)',
|
|
1856
2133
|
}
|
|
1857
2134
|
}
|
|
1858
|
-
if (ws && wantsAutoPilot && effBefore.paceMode !== 'auto') {
|
|
1859
|
-
|
|
2135
|
+
if (ws && wantsAutoPilot && (effBefore.runMode !== 'managed' || effBefore.paceMode !== 'auto')) {
|
|
2136
|
+
const now = Date.now()
|
|
2137
|
+
ws.runtimeGuard.autoPilotStartedAt = now
|
|
2138
|
+
ws.runtimeGuard.managedStartedAt = now
|
|
2139
|
+
ws.runtimeGuard.lastActivityAt = now
|
|
1860
2140
|
ws.runtimeGuard.autoPilotHadTurn = false
|
|
1861
2141
|
}
|
|
1862
2142
|
|
|
@@ -1878,46 +2158,91 @@ export function updateChiefConfig(patch) {
|
|
|
1878
2158
|
}
|
|
1879
2159
|
}
|
|
1880
2160
|
|
|
1881
|
-
const applyPatchTo = (targetCfg, allowIntervention, allowAutoPilot = allowIntervention, allowPermSync = false) => {
|
|
2161
|
+
const applyPatchTo = (targetCfg, allowIntervention, allowAutoPilot = allowIntervention, allowPermSync = false, allowLocks = false) => {
|
|
1882
2162
|
if (typeof safePatch.modelRef === 'string') targetCfg.modelRef = safePatch.modelRef.trim()
|
|
2163
|
+
if (typeof safePatch.thinkingEffort === 'string') {
|
|
2164
|
+
targetCfg.thinkingEffort = normalizeThinkingEffort(safePatch.thinkingEffort)
|
|
2165
|
+
}
|
|
2166
|
+
if (allowLocks && typeof safePatch.teamEffortMode === 'string') {
|
|
2167
|
+
targetCfg.teamEffortMode = normalizeTeamEffortMode(safePatch.teamEffortMode)
|
|
2168
|
+
}
|
|
2169
|
+
if (Number.isFinite(Number(safePatch.managedIdleTimeoutMs)) && Number(safePatch.managedIdleTimeoutMs) >= 50) {
|
|
2170
|
+
targetCfg.managedIdleTimeoutMs = Math.min(2 * 60 * 60 * 1000, Math.round(Number(safePatch.managedIdleTimeoutMs)))
|
|
2171
|
+
}
|
|
2172
|
+
if (allowLocks && (
|
|
2173
|
+
(safePatch.lockedModelEfforts && typeof safePatch.lockedModelEfforts === 'object')
|
|
2174
|
+
|| (safePatch.toggleLockAgentEffort && typeof safePatch.toggleLockAgentEffort === 'object')
|
|
2175
|
+
)) {
|
|
2176
|
+
const curLocks = { ...(targetCfg.lockedModelEfforts || {}) }
|
|
2177
|
+
if (safePatch.lockedModelEfforts && typeof safePatch.lockedModelEfforts === 'object') {
|
|
2178
|
+
for (const [lk, lv] of Object.entries(safePatch.lockedModelEfforts)) {
|
|
2179
|
+
const ck = String(lk || '').trim().slice(0, 64)
|
|
2180
|
+
if (!ck) continue
|
|
2181
|
+
if (lv === true) curLocks[ck] = true
|
|
2182
|
+
else delete curLocks[ck]
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
if (safePatch.toggleLockAgentEffort && typeof safePatch.toggleLockAgentEffort === 'object') {
|
|
2186
|
+
const lk = String(safePatch.toggleLockAgentEffort.target || 'lead').trim().slice(0, 64)
|
|
2187
|
+
if (lk) {
|
|
2188
|
+
if (safePatch.toggleLockAgentEffort.locked === true) curLocks[lk] = true
|
|
2189
|
+
else delete curLocks[lk]
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
targetCfg.lockedModelEfforts = curLocks
|
|
2193
|
+
}
|
|
1883
2194
|
if (allowPermSync && normalizedReqPerm) {
|
|
1884
2195
|
targetCfg.permissionMode = normalizedReqPerm
|
|
1885
2196
|
}
|
|
1886
|
-
if (typeof safePatch.
|
|
2197
|
+
if (typeof safePatch.runMode === 'string' && CHIEF_RUN_MODES.includes(safePatch.runMode)) {
|
|
2198
|
+
const nextRun = (!allowAutoPilot && safePatch.runMode === 'managed') ? 'off' : safePatch.runMode
|
|
2199
|
+
targetCfg.runMode = nextRun
|
|
2200
|
+
targetCfg.stopped = false
|
|
2201
|
+
targetCfg.paceMode = nextRun === 'managed' ? 'auto' : (nextRun === 'patrol' ? 'smart' : 'manual')
|
|
2202
|
+
targetCfg.autoPilot = nextRun === 'managed' && allowAutoPilot
|
|
2203
|
+
targetCfg.autoReview = nextRun === 'managed' && allowAutoPilot
|
|
2204
|
+
} else if (typeof safePatch.paceMode === 'string' && ['manual', 'smart', 'auto', 'stopped'].includes(safePatch.paceMode)) {
|
|
1887
2205
|
const nextPace = (!allowAutoPilot && safePatch.paceMode === 'auto') ? 'manual' : safePatch.paceMode
|
|
1888
2206
|
targetCfg.paceMode = nextPace
|
|
1889
2207
|
const isStopped = nextPace === 'stopped'
|
|
1890
2208
|
targetCfg.stopped = isStopped
|
|
2209
|
+
targetCfg.runMode = isStopped ? 'off' : (nextPace === 'auto' ? 'managed' : (nextPace === 'smart' ? 'patrol' : 'off'))
|
|
1891
2210
|
targetCfg.autoPilot = !isStopped && nextPace === 'auto' && allowAutoPilot
|
|
1892
|
-
targetCfg.autoReview = !isStopped && nextPace
|
|
2211
|
+
targetCfg.autoReview = !isStopped && nextPace === 'auto' && allowAutoPilot
|
|
1893
2212
|
} else if (typeof safePatch.stopped === 'boolean') {
|
|
1894
2213
|
targetCfg.stopped = safePatch.stopped
|
|
1895
2214
|
if (safePatch.stopped) {
|
|
1896
2215
|
targetCfg.paceMode = 'stopped'
|
|
2216
|
+
targetCfg.runMode = 'off'
|
|
1897
2217
|
targetCfg.autoPilot = false
|
|
1898
2218
|
targetCfg.autoReview = false
|
|
1899
2219
|
} else {
|
|
1900
2220
|
if (targetCfg.paceMode === 'stopped') targetCfg.paceMode = 'manual'
|
|
1901
2221
|
if (!allowAutoPilot && targetCfg.paceMode === 'auto') targetCfg.paceMode = 'manual'
|
|
2222
|
+
targetCfg.runMode = normalizeRunMode(targetCfg.runMode, targetCfg)
|
|
1902
2223
|
targetCfg.autoPilot = targetCfg.paceMode === 'auto' && allowAutoPilot
|
|
1903
|
-
targetCfg.autoReview = targetCfg.paceMode
|
|
2224
|
+
targetCfg.autoReview = targetCfg.paceMode === 'auto' && allowAutoPilot
|
|
1904
2225
|
}
|
|
1905
2226
|
} else if (typeof safePatch.autoPilot === 'boolean') {
|
|
1906
2227
|
const nextAuto = Boolean(safePatch.autoPilot && allowAutoPilot)
|
|
1907
2228
|
targetCfg.stopped = false
|
|
1908
2229
|
targetCfg.paceMode = nextAuto ? 'auto' : 'manual'
|
|
2230
|
+
targetCfg.runMode = nextAuto ? 'managed' : 'off'
|
|
1909
2231
|
targetCfg.autoPilot = nextAuto
|
|
1910
2232
|
targetCfg.autoReview = nextAuto
|
|
1911
2233
|
}
|
|
1912
|
-
if (!allowAutoPilot && targetCfg.paceMode === 'auto') {
|
|
2234
|
+
if (!allowAutoPilot && (targetCfg.paceMode === 'auto' || targetCfg.runMode === 'managed')) {
|
|
1913
2235
|
targetCfg.paceMode = 'manual'
|
|
2236
|
+
targetCfg.runMode = 'off'
|
|
1914
2237
|
targetCfg.autoPilot = false
|
|
2238
|
+
targetCfg.autoReview = false
|
|
1915
2239
|
}
|
|
1916
|
-
if (typeof safePatch.autoReview === 'boolean' && typeof safePatch.paceMode !== 'string' && typeof safePatch.stopped !== 'boolean') {
|
|
2240
|
+
if (typeof safePatch.autoReview === 'boolean' && typeof safePatch.paceMode !== 'string' && typeof safePatch.runMode !== 'string' && typeof safePatch.stopped !== 'boolean') {
|
|
1917
2241
|
targetCfg.autoReview = safePatch.autoReview
|
|
1918
2242
|
if (!safePatch.autoReview) {
|
|
1919
2243
|
targetCfg.stopped = false
|
|
1920
2244
|
targetCfg.paceMode = 'manual'
|
|
2245
|
+
targetCfg.runMode = 'off'
|
|
1921
2246
|
}
|
|
1922
2247
|
}
|
|
1923
2248
|
if (incomingTactical) {
|
|
@@ -1936,11 +2261,16 @@ export function updateChiefConfig(patch) {
|
|
|
1936
2261
|
ws.config = {
|
|
1937
2262
|
modelRef: effBefore.modelRef || '',
|
|
1938
2263
|
paceMode: effBefore.paceMode || 'manual',
|
|
2264
|
+
runMode: effBefore.runMode || 'off',
|
|
2265
|
+
thinkingEffort: effBefore.thinkingEffort || 'auto',
|
|
2266
|
+
teamEffortMode: effBefore.teamEffortMode || 'auto',
|
|
2267
|
+
managedIdleTimeoutMs: effBefore.managedIdleTimeoutMs || DEFAULT_MANAGED_IDLE_TIMEOUT_MS,
|
|
2268
|
+
lockedModelEfforts: { ...(effBefore.lockedModelEfforts || {}) },
|
|
1939
2269
|
permissionMode: effBefore.permissionMode || DEFAULT_CHIEF_PERMISSION_MODE,
|
|
1940
2270
|
tacticalModes: { ...effBefore.tacticalModes },
|
|
1941
2271
|
}
|
|
1942
2272
|
}
|
|
1943
|
-
applyPatchTo(ws.config, true, true, true)
|
|
2273
|
+
applyPatchTo(ws.config, true, true, true, isHumanLockCaller)
|
|
1944
2274
|
if (validatedPlugins !== null) {
|
|
1945
2275
|
if (safePatch.policyPluginsScope === 'global') {
|
|
1946
2276
|
state.config.policyPlugins = validatedPlugins
|
|
@@ -1959,9 +2289,9 @@ export function updateChiefConfig(patch) {
|
|
|
1959
2289
|
by: clamp(safePatch.by || 'operator', 40),
|
|
1960
2290
|
}, sid)
|
|
1961
2291
|
}
|
|
1962
|
-
// Session permissionMode, intervention, and autoPilot NEVER leak globally across new sessions!
|
|
2292
|
+
// Session permissionMode, intervention, lockedModelEfforts, and autoPilot NEVER leak globally across new sessions!
|
|
1963
2293
|
state.config.permissionMode = DEFAULT_CHIEF_PERMISSION_MODE
|
|
1964
|
-
applyPatchTo(state.config, false, false, false)
|
|
2294
|
+
applyPatchTo(state.config, false, false, false, false)
|
|
1965
2295
|
|
|
1966
2296
|
if (normalizedReqPerm) {
|
|
1967
2297
|
if (normalizedReqPerm === 'chief' && safePatch.confirmedChiefRisk === true) {
|