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.
package/model-tools.js CHANGED
@@ -16,6 +16,40 @@ import {
16
16
  CHIEF_PERMISSION_META,
17
17
  } from './chief.js'
18
18
  import { normalizePermissionMode } from './chief-executor.js'
19
+ import { computeBubbleState } from './chief-network.js'
20
+
21
+ function summarizeBubbleSnapshot(secDeps, rootId, dir) {
22
+ try {
23
+ const rid = rootId || 'global'
24
+ const b = computeBubbleState(secDeps, rid, null, dir || null)
25
+ const clusterLen = Array.isArray(dir && dir.cluster) ? dir.cluster.length : 0
26
+ const linkedPeersCount = clusterLen > 0
27
+ ? Math.max(0, clusterLen - 1)
28
+ : (Array.isArray(dir && dir.targets) ? dir.targets.filter(t => t && t.kind === 'peer-session').length : 0)
29
+ return {
30
+ locked: Boolean(b && b.locked),
31
+ enrolledHarnesses: (Array.isArray(b && b.enrolledHarnesses) ? b.enrolledHarnesses : []).map(h => ({
32
+ provider: h.provider,
33
+ label: h.label || h.provider,
34
+ role: h.role || h.roleHint || '',
35
+ installed: h.installed !== false,
36
+ configured: Boolean(h.configured),
37
+ running: Boolean(h.running),
38
+ })),
39
+ availableHarnesses: (Array.isArray(b && b.availableHarnesses) ? b.availableHarnesses : [])
40
+ .filter(h => h && h.installed !== false)
41
+ .map(h => ({
42
+ provider: h.provider,
43
+ label: h.label || h.provider,
44
+ role: h.role || h.roleHint || '',
45
+ configured: Boolean(h.configured),
46
+ })),
47
+ linkedPeersCount,
48
+ }
49
+ } catch {
50
+ return { locked: false, enrolledHarnesses: [], availableHarnesses: [], linkedPeersCount: 0 }
51
+ }
52
+ }
19
53
  import {
20
54
  STATUSES,
21
55
  PRIORITIES,
@@ -105,8 +139,9 @@ export function createModelTools(deps) {
105
139
  ],
106
140
  description:
107
141
  'Board operation (MUST be called whenever recording tasks/status/conclusions or relaying messages; plain text alone does NOT update the board or notify peers). '
108
- + 'Use "graph.plan" (or "task.batch") to plan a hierarchical/DAG task graph in one call (supports parentId, blockedBy, owner/subagent, intent, evidence). '
109
- + 'Use "task.dispatch" to spawn or message a subagent, "team.steer" to steer a subagent, and "mail.send" to relay messages across lead/subagents/sessions. '
142
+ + 'Use "graph.plan" (or "task.batch") to plan a hierarchical/DAG task graph in one call (supports parentId, blockedBy, planStepId, targetPlanStepId, owner/subagent, intent, evidence). '
143
+ + 'For multi-step workflows, define ordered steps via "plan.set" first and bind tasks/subagents with "planStepId" (and optional "targetPlanStepId") so the workflow topology displays step-by-step progress and subagent return arrows. '
144
+ + 'Use "task.dispatch" to spawn or message a subagent, "team.steer" to steer a subagent, and "mail.send" to relay messages or dispatch work across lead/subagents/linked sessions/enrolled Bubble harnesses (pass provider id as target). '
110
145
  + 'Use "inquiry.reply" (inquiryId, text) whenever you see a priority [INQUIRY #id] from DSH Chief — answer accurately and continue your current work immediately without stopping. '
111
146
  + 'Use "chief.request" (subject, text) to ask DSH Chief for cross-session coordination, permission elevation, to report exploration & planning results, or when blocked by an insurmountable guard wall that cannot be bypassed safely. '
112
147
  + 'Use "wall.list" (read-only) to inspect currently active persistent guard walls defending high-risk paths/commands. '
@@ -125,6 +160,8 @@ export function createModelTools(deps) {
125
160
  id: { type: 'string', description: 'Task id or temporary symbolic key (e.g. "t1", "api-design") referenced by parentId or blockedBy.' },
126
161
  title: { type: 'string', description: 'Short task title.' },
127
162
  parentId: { type: 'string', description: 'Parent task id/key for hierarchical decomposition.' },
163
+ planStepId: { type: 'string', description: 'Optional plan step id (from board.plan) this task or subagent branch belongs to; auto-binds to the current active step if omitted.' },
164
+ targetPlanStepId: { type: 'string', description: 'Optional plan step id that this task/subagent reports back to upon completion (defaults to planStepId; set to a later step for cross-step handoff).' },
128
165
  blockedBy: { type: 'array', items: { type: 'string' }, description: 'Upstream task ids/keys that must finish (done) before this task unlocks.' },
129
166
  owner: { type: 'string', description: 'Assigned subagent name (e.g. "researcher", "coder", "verifier") or owner.' },
130
167
  subagent: { type: 'string', description: 'Subagent name to bind to this task.' },
@@ -203,7 +240,7 @@ export function createModelTools(deps) {
203
240
  },
204
241
  step: { type: 'string', description: 'cursor.set: which plan step is open right now, in your own words.' },
205
242
  next: { type: 'string', description: 'cursor.set: the very next action — concrete enough to execute without re-reading the transcript.' },
206
- blocked: { type: 'string', description: 'cursor.set: what is blocking right now, or empty when nothing is.' },
243
+ blocked: { type: 'string', description: 'cursor.set: ONLY fill when execution is genuinely stalled/cannot proceed (e.g. missing credentials, permission denied, unresolved error). MUST pass empty string "" when not blocked — NEVER put "无", "none", user preferences/rules, or resolved notes here.' },
207
244
  clear: { type: 'boolean', description: 'cursor.set: wipe step / next / blocked instead of overwriting them.' },
208
245
  expectedTaskId: { type: 'string', description: 'cursor.set: task id this cursor is working on — the panel highlights that node in the tree.' },
209
246
  memoryId: { type: 'string', description: 'Memory entry id for memory.remove.' },
@@ -227,6 +264,8 @@ export function createModelTools(deps) {
227
264
  taskId: { type: 'string', description: 'task id for task.update / task.claim / task.release / task.remove / task.verify / task.dispatch (alias for id).' },
228
265
  target: { type: 'string', description: 'task.add / task.update / task.dispatch: who this task is assigned to — visible in tree view as owner label.' },
229
266
  parentId: { type: 'string', description: 'task.add / task.update: parent task id for tree hierarchy — renders the child indented under its parent.' },
267
+ planStepId: { type: 'string', description: 'task.add / task.update / task.dispatch: optional plan step id (from board.plan) this task or subagent belongs to; auto-binds to the current active step if omitted.' },
268
+ targetPlanStepId: { type: 'string', description: 'task.add / task.update / task.dispatch: optional plan step id that this task/subagent reports back to upon completion (defaults to planStepId).' },
230
269
  status: { type: 'string', enum: STATUSES, description: 'Task status.' },
231
270
  priority: { type: 'string', enum: PRIORITIES, description: 'Task priority.' },
232
271
  field: {
@@ -421,6 +460,8 @@ export function createModelTools(deps) {
421
460
  const roster = await refreshSubagentTree(runtime, session, board)
422
461
  const svc = runtime.get('agentTeams')
423
462
  const rawTeamTasks = (svc && typeof svc.listTasks === 'function' && callerAgent) ? (svc.listTasks(callerAgent) || []) : []
463
+ const secDeps = makeChiefDeps(runtime)
464
+ const dir = await listPeerDirectory(secDeps, session || rawSession).catch(() => null)
424
465
  return {
425
466
  ok: true,
426
467
  subagents: roster,
@@ -429,6 +470,7 @@ export function createModelTools(deps) {
429
470
  owner: t.ownerName || '', blockedBy: t.blockedBy || [],
430
471
  ready: t.ready, revision: t.revision,
431
472
  })),
473
+ bubble: summarizeBubbleSnapshot(secDeps, session || rawSession, dir),
432
474
  ...summary(board, roster),
433
475
  }
434
476
  } catch (err) {
@@ -543,6 +585,7 @@ export function createModelTools(deps) {
543
585
  ok: true,
544
586
  inbox,
545
587
  peers: dir.targets,
588
+ bubble: summarizeBubbleSnapshot(secDeps, session || rawSession, dir),
546
589
  ...summary(board, roster),
547
590
  }
548
591
  }