dsh-chief 1.6.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,
@@ -840,16 +841,68 @@ export function createSubagentRuntime(deps) {
840
841
  }
841
842
 
842
843
  function linkedPeersForSession(runtime, rootId) {
843
- 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
844
852
  const state = loadChiefState()
845
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
+ }
846
898
  if (!Array.isArray(cluster) || cluster.length <= 1) {
847
- return { linkedPeersCount: 0, linkedPeersProgress: [] }
899
+ return { linkedPeersCount: 0, linkedPeersProgress: [], bubbleSquad }
848
900
  }
849
- const linkedPeersProgress = collectClusterPeerProgress(makeChiefDeps(runtime), cluster, rootId)
901
+ const linkedPeersProgress = collectClusterPeerProgress(makeChiefDeps(rt), cluster, rootId)
850
902
  return {
851
903
  linkedPeersCount: Math.max(0, cluster.length - 1),
852
904
  linkedPeersProgress,
905
+ bubbleSquad,
853
906
  }
854
907
  }
855
908
 
@@ -920,6 +973,7 @@ export function createSubagentRuntime(deps) {
920
973
  const rt = runtime || deps.hostState.activeRuntime
921
974
  return {
922
975
  runtime: rt,
976
+ hostState: deps.hostState,
923
977
  getLlm: () => deps.hostState.activeLlm || (rt ? rt.get('llm') : null),
924
978
  getAttachments: () => safe(() => (rt ? rt.get('attachments') : null), null),
925
979
  getSessionCwd: (sid) => getSessionCwd(rt, sid),