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/archive-precipitated.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
POINTS_CAP,
|
|
11
11
|
PRECIPITATED_CAP,
|
|
12
12
|
SECRET_PATTERN,
|
|
13
|
+
DEFAULT_ARCHIVE_FOLDERS,
|
|
13
14
|
nextId,
|
|
14
15
|
str,
|
|
15
16
|
clamp,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
normalizeTags,
|
|
27
28
|
firstMeaningfulSentence,
|
|
28
29
|
extractStructuredPoints,
|
|
30
|
+
deriveHookFromStructuredItem,
|
|
29
31
|
invokeArchiveMutatorHook,
|
|
30
32
|
} from './archive-core.js'
|
|
31
33
|
import { loadGlobalVaultRaw, loadArchiveStore } from './archive-cabinets.js'
|
|
@@ -42,6 +44,17 @@ export function hasAnyPrecipitatedFilesOnDisk(targetOpt) {
|
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
function mapPrecipitatedCategoryToFolder(category = '', rawFolder = '') {
|
|
48
|
+
const f = str(rawFolder, '').trim()
|
|
49
|
+
if (f) return f.slice(0, 64)
|
|
50
|
+
const cat = str(category, '').trim().toLowerCase()
|
|
51
|
+
if (cat === 'coords' || cat === 'env') return 'coords'
|
|
52
|
+
if (cat === 'incidents' || cat === 'troubleshooting' || cat === 'pitfalls') return 'incidents'
|
|
53
|
+
if (cat === 'contracts' || cat === 'architecture' || cat === 'contract') return 'contracts'
|
|
54
|
+
if (cat === 'plans' || cat === 'workflow') return 'plans'
|
|
55
|
+
return 'ops'
|
|
56
|
+
}
|
|
57
|
+
|
|
45
58
|
function normalizePrecipitatedEntry(raw) {
|
|
46
59
|
if (!raw || typeof raw !== 'object') return null
|
|
47
60
|
const title = clamp(raw.title || '', 180)
|
|
@@ -51,8 +64,22 @@ function normalizePrecipitatedEntry(raw) {
|
|
|
51
64
|
.map((p, idx) => normalizePoint(p, idx))
|
|
52
65
|
.filter(Boolean)
|
|
53
66
|
.slice(0, POINTS_CAP)
|
|
54
|
-
const validCategories = ['coords', 'incidents', 'contracts', 'ops', 'plans', 'architecture', 'env', 'contract', 'troubleshooting', 'workflow', 'general']
|
|
67
|
+
const validCategories = ['coords', 'incidents', 'contracts', 'ops', 'plans', 'architecture', 'env', 'contract', 'troubleshooting', 'workflow', 'patterns', 'pitfalls', 'toolchain', 'general']
|
|
55
68
|
const category = validCategories.includes(raw.category) ? raw.category : 'general'
|
|
69
|
+
const folder = mapPrecipitatedCategoryToFolder(category, raw.folder)
|
|
70
|
+
const paperclip = ['gold', 'silver', 'copper'].includes(raw.paperclip) ? raw.paperclip : 'gold'
|
|
71
|
+
const tags = normalizeTags(Array.isArray(raw.tags) ? raw.tags : [])
|
|
72
|
+
const summary = clamp(raw.summary || (points[0] && points[0].cue) || firstMeaningfulSentence(rawBody) || title, 180)
|
|
73
|
+
const normPoints = points.length ? points : extractStructuredPoints(title, rawBody)
|
|
74
|
+
const hook = deriveHookFromStructuredItem({
|
|
75
|
+
...raw,
|
|
76
|
+
title: title || '跨会话可复用工程经验',
|
|
77
|
+
summary,
|
|
78
|
+
folder,
|
|
79
|
+
tags,
|
|
80
|
+
points: normPoints,
|
|
81
|
+
body: rawBody,
|
|
82
|
+
}, true)
|
|
56
83
|
const flippedOutSessions = Array.isArray(raw.flippedOutSessions)
|
|
57
84
|
? [...new Set(raw.flippedOutSessions.map(s => str(s, '').trim()).filter(Boolean))].slice(0, 32)
|
|
58
85
|
: []
|
|
@@ -61,15 +88,20 @@ function normalizePrecipitatedEntry(raw) {
|
|
|
61
88
|
id: str(raw.id, '').trim() || nextId('prec'),
|
|
62
89
|
title: title || '跨会话可复用工程经验',
|
|
63
90
|
category,
|
|
64
|
-
|
|
65
|
-
|
|
91
|
+
folder,
|
|
92
|
+
paperclip,
|
|
93
|
+
summary,
|
|
94
|
+
points: normPoints,
|
|
66
95
|
rawBody,
|
|
67
96
|
purified: raw.purified !== false,
|
|
68
97
|
sourceCabinetId: str(raw.sourceCabinetId || raw.sourceCabinet, '').trim(),
|
|
69
98
|
sourceDrawer: str(raw.sourceDrawer, '').trim(),
|
|
70
99
|
sourceSession: str(raw.sourceSession, '').trim(),
|
|
71
100
|
sourceTitles: Array.isArray(raw.sourceTitles) ? raw.sourceTitles.map(t => clamp(t, 80)).slice(0, 40) : [],
|
|
72
|
-
tags
|
|
101
|
+
tags,
|
|
102
|
+
hasHook: true,
|
|
103
|
+
hookKeywords: hook.hookKeywords,
|
|
104
|
+
hookCue: hook.hookCue,
|
|
73
105
|
flippedOutSessions,
|
|
74
106
|
by: clamp(raw.by || 'chief', 40),
|
|
75
107
|
createdAt: Number(raw.createdAt) || Date.now(),
|
|
@@ -249,15 +281,21 @@ export function copyPrecipitatedToVault(projectKey = 'proj-default', payload = {
|
|
|
249
281
|
}
|
|
250
282
|
}
|
|
251
283
|
|
|
252
|
-
/**
|
|
253
|
-
|
|
284
|
+
/**
|
|
285
|
+
* Listed ONLY for Chief background hook/sealed-archive watch (never injected into Lead prompt unless placed on desk).
|
|
286
|
+
* Three-tier hook contract:
|
|
287
|
+
* - Session vault: Chief always sees session sealed entries (Lead sees only Chief-curated hooks).
|
|
288
|
+
* - Global vault: Chief sees ONLY entries that already have Chief-curated hooks (`hasHook === true`), zero raw leak!
|
|
289
|
+
* - Precipitated vault: 100% human-only (0 disk read, 0 hook leak to Chief or Lead).
|
|
290
|
+
*/
|
|
291
|
+
export function collectSealedWatchSummary(rootSessionId = '', _projectKey = 'proj-default', targetOpt, opts = {}) {
|
|
254
292
|
const sid = cleanRootSessionId(rootSessionId)
|
|
255
293
|
const base = resolveTargetOpts(targetOpt)
|
|
256
294
|
const capPerVault = Math.max(2, Math.min(Number(opts.limitPerVault) || 8, 16))
|
|
257
295
|
|
|
258
296
|
let sessionSealed = []
|
|
259
297
|
let globalSealed = []
|
|
260
|
-
|
|
298
|
+
const precipSealed = []
|
|
261
299
|
|
|
262
300
|
if (sid) {
|
|
263
301
|
try {
|
|
@@ -273,7 +311,16 @@ export function collectSealedWatchSummary(rootSessionId = '', projectKey = 'proj
|
|
|
273
311
|
sessionSealed = (sStore.items || [])
|
|
274
312
|
.filter(it => !Array.isArray(it.takenOutSessions) || !it.takenOutSessions.includes(sid))
|
|
275
313
|
.slice(0, capPerVault)
|
|
276
|
-
.map(it => ({
|
|
314
|
+
.map(it => ({
|
|
315
|
+
id: it.id,
|
|
316
|
+
scope: 'session',
|
|
317
|
+
title: it.title,
|
|
318
|
+
folder: it.folder,
|
|
319
|
+
summary: it.summary,
|
|
320
|
+
hasHook: Boolean(it.hasHook),
|
|
321
|
+
hookKeywords: Array.isArray(it.hookKeywords) ? it.hookKeywords : [],
|
|
322
|
+
hookCue: it.hookCue || '',
|
|
323
|
+
}))
|
|
277
324
|
}
|
|
278
325
|
} catch {}
|
|
279
326
|
}
|
|
@@ -281,21 +328,28 @@ export function collectSealedWatchSummary(rootSessionId = '', projectKey = 'proj
|
|
|
281
328
|
try {
|
|
282
329
|
const gStore = loadGlobalVaultRaw(base)
|
|
283
330
|
globalSealed = (gStore.items || [])
|
|
284
|
-
.filter(it =>
|
|
331
|
+
.filter(it =>
|
|
332
|
+
it.hasHook === true
|
|
333
|
+
&& (!sid || !Array.isArray(it.takenOutSessions) || !it.takenOutSessions.includes(sid))
|
|
334
|
+
)
|
|
285
335
|
.slice(0, capPerVault)
|
|
286
|
-
.map(it => ({
|
|
336
|
+
.map(it => ({
|
|
337
|
+
id: it.id,
|
|
338
|
+
scope: 'global',
|
|
339
|
+
title: it.title,
|
|
340
|
+
folder: it.folder,
|
|
341
|
+
hasHook: true,
|
|
342
|
+
hookKeywords: Array.isArray(it.hookKeywords) ? it.hookKeywords : [],
|
|
343
|
+
hookCue: it.hookCue || '',
|
|
344
|
+
chiefMounted: Boolean(
|
|
345
|
+
sid && (
|
|
346
|
+
(Array.isArray(it.chiefMountedSessions) && it.chiefMountedSessions.includes(sid))
|
|
347
|
+
|| (Array.isArray(it.chiefPulledSessions) && it.chiefPulledSessions.includes(sid))
|
|
348
|
+
)
|
|
349
|
+
),
|
|
350
|
+
}))
|
|
287
351
|
} catch {}
|
|
288
352
|
|
|
289
|
-
if (hasAnyPrecipitatedFilesOnDisk(base)) {
|
|
290
|
-
try {
|
|
291
|
-
const pStore = loadPrecipitatedStoreRaw(projectKey || base.projectKey || 'proj-default', base)
|
|
292
|
-
precipSealed = (pStore.items || [])
|
|
293
|
-
.filter(it => !sid || !Array.isArray(it.flippedOutSessions) || !it.flippedOutSessions.includes(sid))
|
|
294
|
-
.slice(0, capPerVault)
|
|
295
|
-
.map(it => ({ id: it.id, scope: 'precipitated', title: it.title, category: it.category, summary: it.summary }))
|
|
296
|
-
} catch {}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
353
|
return { sessionSealed, globalSealed, precipSealed }
|
|
300
354
|
}
|
|
301
355
|
|
|
@@ -305,22 +359,33 @@ export function listPrecipitatedHeaders(projectKey = 'proj-default', rootSession
|
|
|
305
359
|
if (!fs.existsSync(file)) return []
|
|
306
360
|
const sid = str(rootSessionId, '').trim()
|
|
307
361
|
const store = loadPrecipitatedStoreRaw(projectKey, targetOpt)
|
|
308
|
-
return store.items.map(it =>
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
362
|
+
return store.items.map(it => {
|
|
363
|
+
const flippedOut = Boolean(sid && Array.isArray(it.flippedOutSessions) && it.flippedOutSessions.includes(sid))
|
|
364
|
+
return {
|
|
365
|
+
id: it.id,
|
|
366
|
+
title: it.title,
|
|
367
|
+
category: it.category,
|
|
368
|
+
folder: it.folder || mapPrecipitatedCategoryToFolder(it.category),
|
|
369
|
+
paperclip: it.paperclip || 'gold',
|
|
370
|
+
summary: it.summary,
|
|
371
|
+
hasHook: true,
|
|
372
|
+
hookKeywords: Array.isArray(it.hookKeywords) ? it.hookKeywords : [],
|
|
373
|
+
hookCue: it.hookCue || '',
|
|
374
|
+
purified: it.purified,
|
|
375
|
+
sourceCabinetId: it.sourceCabinetId,
|
|
376
|
+
sourceDrawer: it.sourceDrawer,
|
|
377
|
+
sourceTitles: it.sourceTitles,
|
|
378
|
+
tags: it.tags,
|
|
379
|
+
pointCount: Array.isArray(it.points) ? it.points.length : 0,
|
|
380
|
+
flippedOut,
|
|
381
|
+
viewerStatus: flippedOut
|
|
382
|
+
? { code: 'human_unsealed', tone: 'amber', label: '🔓 人类已翻出 · 仅本局参阅' }
|
|
383
|
+
: { code: 'human_only', tone: 'ice', label: '🧊 仅人类可见 · 钩子速览' },
|
|
384
|
+
points: (it.points || []).map(p => ({ id: p.id, title: p.title, cue: p.cue, detail: p.detail })),
|
|
385
|
+
createdAt: it.createdAt,
|
|
386
|
+
updatedAt: it.updatedAt,
|
|
387
|
+
}
|
|
388
|
+
})
|
|
324
389
|
}
|
|
325
390
|
|
|
326
391
|
export function getPrecipitatedDetail(projectKey = 'proj-default', id = '', rootSessionId = '', targetOpt) {
|
|
@@ -412,6 +477,20 @@ export function mutatePrecipitated(projectKey = 'proj-default', payload = {}, ta
|
|
|
412
477
|
return { ok: true, removedId: removed.id, title: removed.title }
|
|
413
478
|
}
|
|
414
479
|
|
|
480
|
+
if (op === 'moveFolder' || op === 'setFolder') {
|
|
481
|
+
const item = store.items.find(it => it.id === id)
|
|
482
|
+
if (!item) return { ok: false, error: '未找到沉淀经验:' + id }
|
|
483
|
+
const folder = str(payload.folder, '').trim()
|
|
484
|
+
if (!folder) return { ok: false, error: '请选择目标抽屉' }
|
|
485
|
+
item.folder = folder.slice(0, 64)
|
|
486
|
+
if (['gold', 'silver', 'copper'].includes(payload.paperclip)) {
|
|
487
|
+
item.paperclip = payload.paperclip
|
|
488
|
+
}
|
|
489
|
+
item.updatedAt = Date.now()
|
|
490
|
+
savePrecipitatedStoreRaw(resolvedKey, store, targetOpt)
|
|
491
|
+
return { ok: true, id: item.id, folder: item.folder, item }
|
|
492
|
+
}
|
|
493
|
+
|
|
415
494
|
if (op === 'updatePrecipitated') {
|
|
416
495
|
const item = store.items.find(it => it.id === id)
|
|
417
496
|
if (!item) return { ok: false, error: '未找到沉淀经验:' + id }
|
package/auto-continue.js
CHANGED
|
@@ -183,7 +183,7 @@ export function classifyTurnEndReason(reason, eventData = null) {
|
|
|
183
183
|
return { kind, nestedKind, failure }
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
function buildContinuePrompt(trigger, toolSummary = {}, failure = null) {
|
|
186
|
+
function buildContinuePrompt(trigger, toolSummary = {}, failure = null, taskId = '') {
|
|
187
187
|
const pendingCount = Number(toolSummary.pendingCount) || 0
|
|
188
188
|
const doneCount = Number(toolSummary.doneCount) || 0
|
|
189
189
|
|
|
@@ -216,7 +216,8 @@ function buildContinuePrompt(trigger, toolSummary = {}, failure = null) {
|
|
|
216
216
|
guardText = `\n[幂等安全提醒] 上一轮已有工具调用完成${doneList},请先核实已有产出,切勿重复执行会覆盖或叠加副作用的步骤。`
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
const envelopeTag = taskId ? `[EXECUTION_REQUEST #${taskId}] ` : '[EXECUTION_REQUEST] '
|
|
220
|
+
return `${envelopeTag}[DSH 参谋长 · 断线续跑执行请求] ${lead}${guardText}`
|
|
220
221
|
}
|
|
221
222
|
|
|
222
223
|
/**
|
|
@@ -322,12 +323,18 @@ export function createAutoContinueEngine(options = {}) {
|
|
|
322
323
|
return { ok: false, skipped: 'chief-stopped' }
|
|
323
324
|
}
|
|
324
325
|
|
|
326
|
+
let verdict = null
|
|
325
327
|
if (!bypassGate && typeof canAutoContinue === 'function') {
|
|
326
|
-
|
|
328
|
+
verdict = await Promise.resolve(canAutoContinue({ sessionId, rootId, trigger, detail }))
|
|
327
329
|
if (verdict && verdict.allowed === false) {
|
|
328
330
|
st.stats.skippedStopped += 1
|
|
329
331
|
if (verdict.logMessage) onLog(sessionId, verdict.logMessage)
|
|
330
|
-
return {
|
|
332
|
+
return {
|
|
333
|
+
ok: false,
|
|
334
|
+
skipped: verdict.skipped || 'permission-mode',
|
|
335
|
+
approvalId: verdict.approvalId,
|
|
336
|
+
...(verdict.taskId ? { taskId: verdict.taskId } : {}),
|
|
337
|
+
}
|
|
331
338
|
}
|
|
332
339
|
}
|
|
333
340
|
|
|
@@ -349,7 +356,8 @@ export function createAutoContinueEngine(options = {}) {
|
|
|
349
356
|
return { ok: false, skipped: 'no-followup' }
|
|
350
357
|
}
|
|
351
358
|
|
|
352
|
-
const
|
|
359
|
+
const envelopeTaskId = (verdict && verdict.taskId) ? String(verdict.taskId) : ''
|
|
360
|
+
const text = buildContinuePrompt(trigger, st.lastToolSummary, st.lastFailure, envelopeTaskId) + (detail ? `\n补充上下文:${clampText(detail, 180)}` : '')
|
|
353
361
|
const fallbackId = `ac-${Date.now().toString(36)}-${crypto.randomBytes(3).toString('hex')}`
|
|
354
362
|
let envelope = null
|
|
355
363
|
if (typeof createMessage === 'function') {
|
package/board-actions.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
} from './chief.js'
|
|
17
17
|
import {
|
|
18
18
|
resolveProjectKey,
|
|
19
|
+
listArchiveHeaders,
|
|
19
20
|
getArchiveDetail,
|
|
20
21
|
searchArchives,
|
|
21
22
|
mutateArchive,
|
|
@@ -143,6 +144,7 @@ export function createBoardActions(deps) {
|
|
|
143
144
|
|| action === 'memory.ask'
|
|
144
145
|
|| action === 'archive.search'
|
|
145
146
|
|| action === 'archive.read'
|
|
147
|
+
|| action === 'archive.pull'
|
|
146
148
|
|| action === 'archive.save'
|
|
147
149
|
) {
|
|
148
150
|
return runActionUnlocked(args)
|
|
@@ -186,13 +188,46 @@ export function createBoardActions(deps) {
|
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
190
|
|
|
191
|
+
if (action === 'archive.pull') {
|
|
192
|
+
const target = str(args.archiveId !== undefined ? args.archiveId : (args.id !== undefined ? args.id : args.title), '').trim()
|
|
193
|
+
if (!target) return { ok: false, error: 'archive.pull requires archiveId, id, or title' }
|
|
194
|
+
const reqScope = str(args.vaultScope || args.scope, 'session').trim().toLowerCase()
|
|
195
|
+
if (reqScope === 'global' || reqScope === 'precipitated' || reqScope === 'cold') {
|
|
196
|
+
return { ok: false, denied: true, error: '主代理禁止直接拉取全局或冷藏档案柜卷宗,请仅拉取本局档案柜带钩子卷宗' }
|
|
197
|
+
}
|
|
198
|
+
const rootSid = resolveRootSessionId(session) || session
|
|
199
|
+
if (!rootSid) return { ok: false, error: '当前未绑定对话会话,无法拉取本局档案柜' }
|
|
200
|
+
const res = mutateArchive({
|
|
201
|
+
op: 'pullByLead',
|
|
202
|
+
vaultScope: 'session',
|
|
203
|
+
rootSessionId: rootSid,
|
|
204
|
+
id: target,
|
|
205
|
+
archiveId: target,
|
|
206
|
+
title: target,
|
|
207
|
+
}, archiveTarget(deps.hostState.activeRuntime, rootSid, { cabinetId: str(args.cabinetId, ''), vaultScope: 'session' }))
|
|
208
|
+
if (!res || !res.ok) return { ok: false, error: (res && res.error) || '拉取本局档案失败' }
|
|
209
|
+
return {
|
|
210
|
+
ok: true,
|
|
211
|
+
archiveItem: res.item,
|
|
212
|
+
board: session ? loadBoard(file) : emptyBoard(),
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
189
216
|
if (action === 'archive.read') {
|
|
190
217
|
const target = str(args.archiveId !== undefined ? args.archiveId : (args.id !== undefined ? args.id : args.title), '').trim()
|
|
191
218
|
if (!target) return { ok: false, error: 'archive.read requires archiveId, id, or title' }
|
|
219
|
+
const reqScope = str(args.vaultScope || args.scope, 'session').trim().toLowerCase()
|
|
220
|
+
if (reqScope === 'global' || reqScope === 'precipitated' || reqScope === 'cold') {
|
|
221
|
+
return { ok: false, denied: true, error: '主代理禁止跨柜读取全局或冷藏档案柜' }
|
|
222
|
+
}
|
|
192
223
|
const rootSid = resolveRootSessionId(session) || session
|
|
193
224
|
if (!rootSid) return { ok: false, error: '当前未绑定对话会话,无法读取本会话档案柜' }
|
|
194
|
-
const
|
|
225
|
+
const archOpt = archiveTarget(deps.hostState.activeRuntime, rootSid, { cabinetId: str(args.cabinetId, ''), vaultScope: 'session' })
|
|
226
|
+
const res = getArchiveDetail(target, rootSid, archOpt)
|
|
195
227
|
if (!res.ok) return { ok: false, error: res.error }
|
|
228
|
+
if (res.item && res.item.hasHook) {
|
|
229
|
+
mutateArchive({ op: 'pullByLead', vaultScope: 'session', rootSessionId: rootSid, id: res.item.id }, archOpt)
|
|
230
|
+
}
|
|
196
231
|
return {
|
|
197
232
|
ok: true,
|
|
198
233
|
archiveItem: res.item,
|
|
@@ -1513,10 +1548,30 @@ export function createBoardActions(deps) {
|
|
|
1513
1548
|
return [...working, ...takenGlobal, ...mappedFlipped]
|
|
1514
1549
|
}
|
|
1515
1550
|
|
|
1516
|
-
/** Collect digest-safe archive context for Lead/Subagent prompt: ONLY desk-spotlight items
|
|
1551
|
+
/** Collect digest-safe archive context for Lead/Subagent prompt: ONLY desk-spotlight items + Chief-curated session hooks (0 raw/global/cold leak!). */
|
|
1517
1552
|
function collectDigestArchiveContext(runtime, rootId, cabinetId = '') {
|
|
1518
1553
|
const takenOutArchives = rootId ? collectTakenOutAndFlipped(runtime, rootId, cabinetId) : []
|
|
1519
|
-
|
|
1554
|
+
let sessionHookedArchives = []
|
|
1555
|
+
let desktopUsedTokens = 0
|
|
1556
|
+
if (rootId && rootId !== 'global') {
|
|
1557
|
+
try {
|
|
1558
|
+
const targetOpt = archiveTarget(runtime, rootId, { cabinetId, vaultScope: 'session' })
|
|
1559
|
+
const hdrRes = listArchiveHeaders(rootId, { vaultScope: 'session', includeCounts: false }, targetOpt)
|
|
1560
|
+
if (hdrRes && hdrRes.ok) {
|
|
1561
|
+
desktopUsedTokens = Number(hdrRes.desktop && hdrRes.desktop.usedTokens) || 0
|
|
1562
|
+
sessionHookedArchives = (Array.isArray(hdrRes.items) ? hdrRes.items : [])
|
|
1563
|
+
.filter(it => it && it.hasHook && !it.takenOut)
|
|
1564
|
+
.slice(0, 6)
|
|
1565
|
+
.map(it => ({
|
|
1566
|
+
id: it.id,
|
|
1567
|
+
title: it.title,
|
|
1568
|
+
folder: it.folder,
|
|
1569
|
+
hookKeywords: Array.isArray(it.hookKeywords) ? it.hookKeywords : [],
|
|
1570
|
+
hookCue: it.hookCue || '',
|
|
1571
|
+
}))
|
|
1572
|
+
}
|
|
1573
|
+
} catch {}
|
|
1574
|
+
}
|
|
1520
1575
|
let smartCompactActive = false
|
|
1521
1576
|
let chiefPermissionMode = DEFAULT_CHIEF_PERMISSION_MODE
|
|
1522
1577
|
if (rootId) {
|
|
@@ -1532,7 +1587,7 @@ export function createBoardActions(deps) {
|
|
|
1532
1587
|
})
|
|
1533
1588
|
} catch {}
|
|
1534
1589
|
}
|
|
1535
|
-
return { takenOutArchives,
|
|
1590
|
+
return { takenOutArchives, sessionHookedArchives, desktopUsedTokens, smartCompactActive, chiefPermissionMode }
|
|
1536
1591
|
}
|
|
1537
1592
|
|
|
1538
1593
|
/* ------------------------------------------------------------------- auto sync */
|