dsh-chief 1.5.0 → 1.7.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.
@@ -17,6 +17,7 @@ import {
17
17
  deliverCrossMessage,
18
18
  } from './chief.js'
19
19
  import { resolveAlignedModelEffort } from './chief-state.js'
20
+ import { computeBubbleState } from './chief-network.js'
20
21
  import {
21
22
  API,
22
23
  newId,
@@ -26,6 +27,7 @@ import {
26
27
  CAP_TASK_INTENT,
27
28
  asBool,
28
29
  normalizeTask,
30
+ resolveActivePlanStepId,
29
31
  pushLog,
30
32
  safe,
31
33
  } from './board-schema.js'
@@ -514,6 +516,17 @@ export function createSubagentRuntime(deps) {
514
516
  '- **任务标题**: ' + task.title,
515
517
  ]
516
518
  if (board.objective) lines.push('- **全局目标**: ' + board.objective.slice(0, 400))
519
+ const planSteps = Array.isArray(board && board.plan) ? board.plan : []
520
+ const stepIdx = task.planStepId ? planSteps.findIndex(s => s && s.id === task.planStepId) : -1
521
+ if (stepIdx >= 0) {
522
+ const targetIdx = task.targetPlanStepId && task.targetPlanStepId !== task.planStepId
523
+ ? planSteps.findIndex(s => s && s.id === task.targetPlanStepId)
524
+ : -1
525
+ const returnHint = targetIdx >= 0
526
+ ? ';完成后成果回指第 ' + (targetIdx + 1) + ' 步「' + planSteps[targetIdx].text + '」'
527
+ : ''
528
+ lines.push('- **所属推进步骤**: 第 ' + (stepIdx + 1) + ' 步「' + planSteps[stepIdx].text + '」' + returnHint)
529
+ }
517
530
  if (task.intent) lines.push('- **任务意图 (Intent)**: ' + task.intent)
518
531
  if (task.evidence) lines.push('- **验收标准 (Expected Evidence)**: ' + task.evidence)
519
532
  if (task.note) lines.push('- **补充说明 (Note)**: ' + task.note)
@@ -828,16 +841,68 @@ export function createSubagentRuntime(deps) {
828
841
  }
829
842
 
830
843
  function linkedPeersForSession(runtime, rootId) {
831
- if (!rootId) return { linkedPeersCount: 0, linkedPeersProgress: [] }
844
+ const emptyBubble = {
845
+ locked: false,
846
+ enrolledHarnesses: [],
847
+ availableHarnesses: [],
848
+ standbySessionsCount: 0,
849
+ }
850
+ if (!rootId) return { linkedPeersCount: 0, linkedPeersProgress: [], bubbleSquad: emptyBubble }
851
+ const rt = runtime || deps.hostState.activeRuntime
832
852
  const state = loadChiefState()
833
853
  const cluster = getLinkedCluster(state, rootId)
854
+ let bubbleState = null
855
+ try {
856
+ bubbleState = computeBubbleState({ runtime: rt, hostState: deps.hostState }, rootId, state)
857
+ } catch {}
858
+ const enrolledHarnesses = (Array.isArray(bubbleState && bubbleState.enrolledHarnesses) ? bubbleState.enrolledHarnesses : [])
859
+ .filter(h => h && (h.installed !== false || h.running))
860
+ .map(h => ({
861
+ provider: String(h.provider || ''),
862
+ label: String(h.label || h.provider || ''),
863
+ role: String(h.role || h.roleHint || ''),
864
+ running: Boolean(h.running),
865
+ configured: Boolean(h.configured),
866
+ }))
867
+ const availableHarnesses = (Array.isArray(bubbleState && bubbleState.availableHarnesses) ? bubbleState.availableHarnesses : [])
868
+ .filter(h => h && h.installed !== false)
869
+ .map(h => ({
870
+ provider: String(h.provider || ''),
871
+ label: String(h.label || h.provider || ''),
872
+ role: String(h.role || h.roleHint || ''),
873
+ configured: Boolean(h.configured),
874
+ }))
875
+ const linkedSet = new Set(Array.isArray(cluster) ? cluster.map(id => String(id)) : [])
876
+ linkedSet.add(String(rootId))
877
+ let standbySessionsCount = 0
878
+ try {
879
+ const agentsSvc = rt && typeof rt.get === 'function' ? rt.get('agents') : null
880
+ const rawAgents = agentsSvc && typeof agentsSvc.list === 'function' ? agentsSvc.list() : []
881
+ const standbyRoots = new Set()
882
+ for (const ag of Array.isArray(rawAgents) ? rawAgents : []) {
883
+ if (!ag || !ag.id || ag.parentId) continue
884
+ const kind = String(ag.kind || ag.agentKind || '').toLowerCase()
885
+ if (kind === 'subagent') continue
886
+ const agRoot = resolveRootSessionId(ag.id, ag)
887
+ if (!agRoot || agRoot !== String(ag.id)) continue
888
+ if (!linkedSet.has(agRoot)) standbyRoots.add(agRoot)
889
+ }
890
+ standbySessionsCount = standbyRoots.size
891
+ } catch {}
892
+ const bubbleSquad = {
893
+ locked: Boolean(bubbleState && bubbleState.locked),
894
+ enrolledHarnesses,
895
+ availableHarnesses,
896
+ standbySessionsCount,
897
+ }
834
898
  if (!Array.isArray(cluster) || cluster.length <= 1) {
835
- return { linkedPeersCount: 0, linkedPeersProgress: [] }
899
+ return { linkedPeersCount: 0, linkedPeersProgress: [], bubbleSquad }
836
900
  }
837
- const linkedPeersProgress = collectClusterPeerProgress(makeChiefDeps(runtime), cluster, rootId)
901
+ const linkedPeersProgress = collectClusterPeerProgress(makeChiefDeps(rt), cluster, rootId)
838
902
  return {
839
903
  linkedPeersCount: Math.max(0, cluster.length - 1),
840
904
  linkedPeersProgress,
905
+ bubbleSquad,
841
906
  }
842
907
  }
843
908
 
@@ -908,6 +973,7 @@ export function createSubagentRuntime(deps) {
908
973
  const rt = runtime || deps.hostState.activeRuntime
909
974
  return {
910
975
  runtime: rt,
976
+ hostState: deps.hostState,
911
977
  getLlm: () => deps.hostState.activeLlm || (rt ? rt.get('llm') : null),
912
978
  getAttachments: () => safe(() => (rt ? rt.get('attachments') : null), null),
913
979
  getSessionCwd: (sid) => getSessionCwd(rt, sid),
@@ -1287,7 +1353,16 @@ export function createSubagentRuntime(deps) {
1287
1353
  }
1288
1354
 
1289
1355
  const requestedTarget = str(args.agent || args.subagent || args.target || targetTask.subagent || targetTask.owner, '').trim()
1290
- const brief = buildTaskDispatchBrief(boardSnapshot, targetTask, args.prompt || args.message || args.text)
1356
+ const explicitPlanStepId = typeof args.planStepId === 'string' ? args.planStepId.trim().slice(0, 120) : ''
1357
+ const explicitTargetStepId = typeof args.targetPlanStepId === 'string' ? args.targetPlanStepId.trim().slice(0, 120) : ''
1358
+ const effectivePlanStepId = explicitPlanStepId || targetTask.planStepId || resolveActivePlanStepId(boardSnapshot)
1359
+ const effectiveTargetStepId = explicitTargetStepId || targetTask.targetPlanStepId || ''
1360
+ const briefTask = {
1361
+ ...targetTask,
1362
+ planStepId: effectivePlanStepId,
1363
+ targetPlanStepId: effectiveTargetStepId,
1364
+ }
1365
+ const brief = buildTaskDispatchBrief(boardSnapshot, briefTask, args.prompt || args.message || args.text)
1291
1366
  let dispatchedName = requestedTarget
1292
1367
  let childSessionId = ''
1293
1368
  let dispatchMode = 'assigned'
@@ -1404,6 +1479,12 @@ export function createSubagentRuntime(deps) {
1404
1479
  task.subagent = dispatchedName
1405
1480
  if (childSessionId) task.session = childSessionId
1406
1481
  if (args.preset) task.preset = str(args.preset, '').slice(0, 80)
1482
+ if (explicitPlanStepId) task.planStepId = explicitPlanStepId
1483
+ else if (!task.planStepId) {
1484
+ const autoStep = resolveActivePlanStepId(board)
1485
+ if (autoStep) task.planStepId = autoStep
1486
+ }
1487
+ if (explicitTargetStepId) task.targetPlanStepId = explicitTargetStepId
1407
1488
  task.dispatchedAt = nowMs()
1408
1489
  task.updatedAt = nowMs()
1409
1490
  board.cursor = {