@pi-unipi/unipi 3.0.0-alpha.2 → 3.0.0-alpha.21

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.
Files changed (359) hide show
  1. package/CHANGELOG.md +292 -0
  2. package/README.md +8 -11
  3. package/docs/prefix-cache-architecture.md +14 -0
  4. package/package.json +22 -24
  5. package/packages/ask-user/README.md +55 -107
  6. package/packages/ask-user/ask-ui.ts +306 -732
  7. package/packages/ask-user/clipboard.ts +50 -0
  8. package/packages/ask-user/config.ts +74 -78
  9. package/packages/ask-user/package.json +2 -2
  10. package/packages/ask-user/questions.ts +151 -0
  11. package/packages/ask-user/skills/ask-user/SKILL.md +59 -133
  12. package/packages/ask-user/tools.ts +198 -432
  13. package/packages/autocomplete/package.json +1 -1
  14. package/packages/autocomplete/src/constants.ts +38 -43
  15. package/packages/autocomplete/src/sorting.ts +8 -0
  16. package/packages/background-tasks/package.json +2 -2
  17. package/packages/background-tasks/src/config.ts +0 -73
  18. package/packages/background-tasks/src/index.ts +20 -16
  19. package/packages/background-tasks/src/registry.ts +1 -171
  20. package/packages/background-tasks/src/types.ts +0 -32
  21. package/packages/btw/README.md +13 -56
  22. package/packages/btw/extensions/btw.ts +403 -1796
  23. package/packages/btw/package.json +5 -2
  24. package/packages/btw/skills/btw/SKILL.md +7 -143
  25. package/packages/compactor/README.md +56 -287
  26. package/packages/compactor/package.json +5 -9
  27. package/packages/compactor/skills/compactor/SKILL.md +13 -20
  28. package/packages/compactor/src/card.ts +90 -0
  29. package/packages/compactor/src/commands/index.ts +73 -130
  30. package/packages/compactor/src/compaction/compact-args.ts +5 -3
  31. package/packages/compactor/src/compaction/filter-noise.ts +1 -1
  32. package/packages/compactor/src/compaction/hooks.ts +487 -311
  33. package/packages/compactor/src/compaction/source.ts +178 -0
  34. package/packages/compactor/src/compaction/summarize.ts +586 -52
  35. package/packages/compactor/src/config/manager.ts +130 -127
  36. package/packages/compactor/src/config/schema.ts +32 -48
  37. package/packages/compactor/src/index.ts +40 -431
  38. package/packages/compactor/src/info-screen.ts +44 -190
  39. package/packages/compactor/src/session/recall-blocks.ts +1 -1
  40. package/packages/compactor/src/stats.ts +76 -0
  41. package/packages/compactor/src/tools/context-budget.ts +17 -34
  42. package/packages/compactor/src/tools/ctx-doctor.ts +45 -36
  43. package/packages/compactor/src/tools/register.ts +29 -269
  44. package/packages/compactor/src/types.ts +47 -186
  45. package/packages/core/README.md +25 -0
  46. package/packages/core/child-agent.ts +1 -0
  47. package/packages/core/command-echo.ts +63 -0
  48. package/packages/core/compaction-context.ts +41 -0
  49. package/packages/core/constants.ts +8 -38
  50. package/packages/core/events.ts +0 -53
  51. package/packages/core/fusion-status.ts +4 -0
  52. package/packages/core/global.d.ts +10 -0
  53. package/packages/core/harness-messages.ts +392 -0
  54. package/packages/core/index.ts +14 -0
  55. package/packages/core/kanboard-status.ts +49 -0
  56. package/packages/core/long-horizon-owner-status.ts +46 -0
  57. package/packages/core/model-cache.ts +81 -7
  58. package/packages/core/package.json +6 -3
  59. package/packages/core/src/attach/detect.ts +163 -0
  60. package/packages/core/src/child-agent/child-args.ts +31 -0
  61. package/packages/core/src/child-agent/delivery.ts +41 -0
  62. package/packages/core/src/child-agent/index.ts +5 -0
  63. package/packages/core/src/child-agent/readers.ts +203 -0
  64. package/packages/core/src/child-agent/runtime.ts +584 -0
  65. package/packages/core/src/evidence.ts +78 -0
  66. package/packages/core/src/hints/browser.ts +278 -0
  67. package/packages/core/src/hints/crab-data.ts +19 -0
  68. package/packages/core/src/hints/index.ts +865 -0
  69. package/packages/core/src/hints/lines.ts +607 -0
  70. package/packages/core/src/hints/store.ts +120 -0
  71. package/packages/core/src/jev/chatter.ts +24 -0
  72. package/packages/core/src/jev/settings.ts +177 -14
  73. package/packages/core/src/package-colors.ts +2 -0
  74. package/packages/core/src/settings/catalog.ts +39 -15
  75. package/packages/core/src/settings/engine.ts +48 -2
  76. package/packages/core/src/settings/hub.ts +83 -20
  77. package/packages/core/src/settings/open.ts +49 -0
  78. package/packages/core/src/settings/schema.ts +27 -7
  79. package/packages/core/src/tui/hub-kit.ts +18 -5
  80. package/packages/core/src/tui/kit.ts +198 -0
  81. package/packages/core/src/tui/progress.ts +73 -0
  82. package/packages/core/src/turn/arbiter.ts +290 -0
  83. package/packages/footer/README.md +4 -6
  84. package/packages/footer/package.json +3 -3
  85. package/packages/footer/src/glance-editor.ts +19 -11
  86. package/packages/footer/src/help.ts +1 -1
  87. package/packages/footer/src/index.ts +36 -3
  88. package/packages/footer/src/presets.ts +3 -4
  89. package/packages/footer/src/rendering/icons.ts +0 -20
  90. package/packages/footer/src/segments/compactor.ts +52 -142
  91. package/packages/footer/src/segments/status-ext.ts +0 -1
  92. package/packages/fusion/README.md +14 -4
  93. package/packages/fusion/package.json +4 -3
  94. package/packages/fusion/src/child-args.ts +1 -0
  95. package/packages/fusion/src/index.ts +161 -8
  96. package/packages/fusion/src/pi-settings.ts +57 -0
  97. package/packages/fusion/src/picker.ts +186 -51
  98. package/packages/fusion/src/preset.ts +56 -2
  99. package/packages/fusion/src/prompts.ts +1 -1
  100. package/packages/fusion/src/sidekick-runtime.ts +1 -420
  101. package/packages/fusion/src/tools.ts +107 -128
  102. package/packages/fusion/src/transcript.ts +27 -85
  103. package/packages/info-screen/package.json +2 -2
  104. package/packages/input-shortcuts/README.md +18 -30
  105. package/packages/input-shortcuts/package.json +2 -2
  106. package/packages/input-shortcuts/src/burst.ts +88 -0
  107. package/packages/input-shortcuts/src/chord-overlay.ts +20 -70
  108. package/packages/input-shortcuts/src/cleared-input.ts +97 -0
  109. package/packages/input-shortcuts/src/index.ts +99 -193
  110. package/packages/input-shortcuts/src/last-response.ts +40 -0
  111. package/packages/input-shortcuts/src/registers.ts +8 -23
  112. package/packages/input-shortcuts/src/types.ts +4 -16
  113. package/packages/input-shortcuts/src/undo-redo.ts +59 -47
  114. package/packages/kanboard/README.md +51 -47
  115. package/packages/kanboard/index.ts +293 -55
  116. package/packages/kanboard/package.json +8 -8
  117. package/packages/kanboard/skills/kanboard/SKILL.md +61 -27
  118. package/packages/kanboard/src/badges.ts +93 -0
  119. package/packages/kanboard/src/bin.ts +4 -2
  120. package/packages/kanboard/src/commands.ts +218 -84
  121. package/packages/kanboard/src/debug.ts +20 -0
  122. package/packages/kanboard/src/guard.ts +267 -109
  123. package/packages/kanboard/src/monitor.ts +330 -0
  124. package/packages/kanboard/src/notice-buffer.ts +74 -0
  125. package/packages/kanboard/src/progress.ts +27 -0
  126. package/packages/kanboard/src/reminders.ts +234 -0
  127. package/packages/kanboard/src/settings.ts +69 -15
  128. package/packages/kanboard/src/shapes.ts +5 -0
  129. package/packages/long-horizon/index.ts +190 -13
  130. package/packages/long-horizon/package.json +3 -3
  131. package/packages/long-horizon/src/commands.ts +103 -7
  132. package/packages/long-horizon/src/compaction-brief.ts +35 -0
  133. package/packages/long-horizon/src/engine/continuation.ts +84 -15
  134. package/packages/long-horizon/src/engine/goal-state.ts +64 -13
  135. package/packages/long-horizon/src/engine/nudge-stash.ts +71 -0
  136. package/packages/long-horizon/src/engine/ralph.ts +3 -2
  137. package/packages/long-horizon/src/engine/runaway.ts +68 -11
  138. package/packages/long-horizon/src/engine/verifier.ts +19 -0
  139. package/packages/long-horizon/src/gate.ts +37 -12
  140. package/packages/long-horizon/src/judge/resolve.ts +1 -0
  141. package/packages/long-horizon/src/owner.ts +35 -2
  142. package/packages/long-horizon/src/progress.ts +87 -0
  143. package/packages/long-horizon/src/prompts/goal.ts +1 -1
  144. package/packages/long-horizon/src/runtime.ts +172 -18
  145. package/packages/long-horizon/src/settings.ts +54 -39
  146. package/packages/long-horizon/src/tools/goal.ts +6 -0
  147. package/packages/long-horizon/src/tools/graph.ts +1 -1
  148. package/packages/long-horizon/src/tools/swarm.ts +3 -3
  149. package/packages/mcp/package.json +2 -2
  150. package/packages/memory/commands.ts +7 -2
  151. package/packages/memory/index.ts +210 -32
  152. package/packages/memory/package.json +3 -3
  153. package/packages/memory/save-session.ts +264 -0
  154. package/packages/memory/settings.ts +17 -0
  155. package/packages/memory/tools.ts +253 -203
  156. package/packages/notify/package.json +2 -2
  157. package/packages/skill-registry/README.md +53 -16
  158. package/packages/skill-registry/index.ts +230 -0
  159. package/packages/skill-registry/package.json +19 -8
  160. package/packages/skill-registry/src/editor.ts +206 -0
  161. package/packages/skill-registry/src/judge.ts +289 -0
  162. package/packages/skill-registry/src/registry.ts +87 -0
  163. package/packages/skill-registry/src/settings.ts +259 -0
  164. package/packages/skill-registry/src/vault.ts +80 -0
  165. package/packages/subagents/README.md +39 -119
  166. package/packages/subagents/package.json +6 -13
  167. package/packages/subagents/skills/subagents/SKILL.md +18 -42
  168. package/packages/subagents/src/agents.ts +213 -0
  169. package/packages/subagents/src/cards.ts +182 -0
  170. package/packages/subagents/src/index.ts +609 -1084
  171. package/packages/subagents/src/manager.ts +429 -0
  172. package/packages/subagents/src/profiles.ts +130 -0
  173. package/packages/subagents/src/transcript.ts +154 -0
  174. package/packages/subagents/src/ui.ts +389 -0
  175. package/packages/unipi/bundled.js +39756 -45569
  176. package/packages/unipi/index.ts +55 -10
  177. package/packages/updater/package.json +2 -2
  178. package/packages/utility/README.md +76 -69
  179. package/packages/utility/package.json +2 -2
  180. package/packages/utility/skills/image/SKILL.md +37 -0
  181. package/packages/utility/skills/utility/SKILL.md +17 -60
  182. package/packages/utility/src/answer/extract.ts +128 -0
  183. package/packages/utility/src/answer/index.ts +213 -0
  184. package/packages/utility/src/answer/reply.ts +133 -0
  185. package/packages/utility/src/answer/web.ts +167 -0
  186. package/packages/utility/src/attach/index.ts +205 -0
  187. package/packages/utility/src/commands.ts +38 -142
  188. package/packages/utility/src/diagnostics/engine.ts +50 -5
  189. package/packages/utility/src/image/index.ts +33 -0
  190. package/packages/utility/src/image/models.ts +221 -0
  191. package/packages/{image/src → utility/src/image}/recognize.ts +2 -2
  192. package/packages/utility/src/image/settings.ts +178 -0
  193. package/packages/{image/src/image-source.ts → utility/src/image/source.ts} +1 -1
  194. package/packages/utility/src/image/tools.ts +168 -0
  195. package/packages/utility/src/image/transports.ts +186 -0
  196. package/packages/utility/src/index.ts +68 -389
  197. package/packages/utility/src/lifecycle/cleanup.ts +116 -311
  198. package/packages/utility/src/rename/gate.ts +102 -0
  199. package/packages/utility/src/rename/index.ts +191 -0
  200. package/packages/utility/src/rename/session.ts +170 -0
  201. package/packages/utility/src/render/delegated.ts +285 -0
  202. package/packages/utility/src/render/harness.ts +683 -0
  203. package/packages/utility/src/render/parse.ts +156 -0
  204. package/packages/utility/src/render/pi-settings.ts +38 -0
  205. package/packages/utility/src/render/reply-bg.ts +307 -0
  206. package/packages/utility/src/render/simple.ts +724 -0
  207. package/packages/utility/src/render/spacing.ts +235 -0
  208. package/packages/utility/src/render/styled.ts +251 -0
  209. package/packages/utility/src/render/tools.ts +353 -0
  210. package/packages/utility/src/settings.ts +166 -233
  211. package/packages/utility/src/types.ts +1 -222
  212. package/packages/watchdog/index.ts +17 -6
  213. package/packages/watchdog/package.json +3 -3
  214. package/packages/watchdog/src/config.ts +3 -2
  215. package/packages/web-api/package.json +2 -2
  216. package/packages/workflow/README.md +3 -0
  217. package/packages/workflow/index.ts +0 -2
  218. package/packages/workflow/package.json +2 -2
  219. package/packages/workflow/src/permission/decide.ts +6 -4
  220. package/packages/workflow/src/permission/index.ts +17 -7
  221. package/packages/workflow/src/permission/settings.ts +39 -4
  222. package/packages/workflow/src/plan/index.ts +19 -4
  223. package/packages/background-tasks/extensions/delegate-child.ts +0 -1
  224. package/packages/background-tasks/src/context-parent-snapshot.ts +0 -142
  225. package/packages/background-tasks/src/context-token-budget.ts +0 -903
  226. package/packages/background-tasks/src/context-visible-conversation-v2.ts +0 -551
  227. package/packages/background-tasks/src/delegate/artifacts.ts +0 -487
  228. package/packages/background-tasks/src/delegate/budget.ts +0 -415
  229. package/packages/background-tasks/src/delegate/hook-contract-evidence.json +0 -18
  230. package/packages/background-tasks/src/delegate/hook-contract.ts +0 -154
  231. package/packages/background-tasks/src/delegate/launch.ts +0 -484
  232. package/packages/background-tasks/src/delegate/result-package.ts +0 -459
  233. package/packages/background-tasks/src/delegate/runner.ts +0 -430
  234. package/packages/background-tasks/src/delegate/seed.ts +0 -423
  235. package/packages/background-tasks/src/delegate/types.ts +0 -323
  236. package/packages/background-tasks/src/delegate-child-extension.ts +0 -978
  237. package/packages/background-tasks/src/delegate-extension.ts +0 -654
  238. package/packages/background-tasks/src/fixtures/delegate-context-incident.json +0 -17
  239. package/packages/compactor/skills/compactor-detail/SKILL.md +0 -116
  240. package/packages/compactor/skills/compactor-doctor/SKILL.md +0 -71
  241. package/packages/compactor/skills/compactor-stats/SKILL.md +0 -51
  242. package/packages/compactor/src/compaction/build-sections.ts +0 -76
  243. package/packages/compactor/src/compaction/extract/goals.ts +0 -36
  244. package/packages/compactor/src/compaction/extract/preferences.ts +0 -40
  245. package/packages/compactor/src/compaction/format.ts +0 -53
  246. package/packages/compactor/src/compaction/merge.ts +0 -143
  247. package/packages/compactor/src/config/presets.ts +0 -160
  248. package/packages/compactor/src/executor/executor.ts +0 -233
  249. package/packages/compactor/src/executor/runtime.ts +0 -115
  250. package/packages/compactor/src/security/evaluator.ts +0 -89
  251. package/packages/compactor/src/security/policy.ts +0 -96
  252. package/packages/compactor/src/security/scanner.ts +0 -65
  253. package/packages/compactor/src/session/auto-inject.ts +0 -60
  254. package/packages/compactor/src/session/db.ts +0 -325
  255. package/packages/compactor/src/session/extract.ts +0 -144
  256. package/packages/compactor/src/session/resume-inject.ts +0 -64
  257. package/packages/compactor/src/session/snapshot.ts +0 -327
  258. package/packages/compactor/src/tools/ctx-batch-execute.ts +0 -41
  259. package/packages/compactor/src/tools/ctx-execute-file.ts +0 -23
  260. package/packages/compactor/src/tools/ctx-execute.ts +0 -23
  261. package/packages/compactor/src/tools/ctx-stats.ts +0 -96
  262. package/packages/image/README.md +0 -99
  263. package/packages/image/package.json +0 -61
  264. package/packages/image/skills/image/SKILL.md +0 -76
  265. package/packages/image/src/generate.ts +0 -256
  266. package/packages/image/src/index.ts +0 -135
  267. package/packages/image/src/models.ts +0 -519
  268. package/packages/image/src/openai-images-api.ts +0 -282
  269. package/packages/image/src/register-providers.ts +0 -209
  270. package/packages/image/src/settings.ts +0 -173
  271. package/packages/image/src/tools.ts +0 -326
  272. package/packages/input-shortcuts/src/clipboard.ts +0 -119
  273. package/packages/kanboard/src/runner.ts +0 -817
  274. package/packages/skill-registry/skills/auto/SKILL.md +0 -465
  275. package/packages/skill-registry/skills/brainstorm/SKILL.md +0 -219
  276. package/packages/skill-registry/skills/chore-create/SKILL.md +0 -315
  277. package/packages/skill-registry/skills/chore-execute/SKILL.md +0 -314
  278. package/packages/skill-registry/skills/consolidate/SKILL.md +0 -142
  279. package/packages/skill-registry/skills/consultant/SKILL.md +0 -97
  280. package/packages/skill-registry/skills/debug/SKILL.md +0 -228
  281. package/packages/skill-registry/skills/document/SKILL.md +0 -120
  282. package/packages/skill-registry/skills/fix/SKILL.md +0 -212
  283. package/packages/skill-registry/skills/gather-context/SKILL.md +0 -145
  284. package/packages/skill-registry/skills/plan/SKILL.md +0 -231
  285. package/packages/skill-registry/skills/quick-fix/SKILL.md +0 -135
  286. package/packages/skill-registry/skills/quick-work/SKILL.md +0 -110
  287. package/packages/skill-registry/skills/research/SKILL.md +0 -251
  288. package/packages/skill-registry/skills/review-work/SKILL.md +0 -187
  289. package/packages/skill-registry/skills/scan-issues/SKILL.md +0 -195
  290. package/packages/skill-registry/skills/work/SKILL.md +0 -218
  291. package/packages/skill-registry/skills/worktree-create/SKILL.md +0 -69
  292. package/packages/skill-registry/skills/worktree-list/SKILL.md +0 -78
  293. package/packages/skill-registry/skills/worktree-merge/SKILL.md +0 -89
  294. package/packages/subagents/agents/delegate.md +0 -14
  295. package/packages/subagents/agents/oracle.md +0 -78
  296. package/packages/subagents/agents/researcher.md +0 -52
  297. package/packages/subagents/agents/reviewer.md +0 -80
  298. package/packages/subagents/agents/scout.md +0 -50
  299. package/packages/subagents/agents/worker.md +0 -59
  300. package/packages/subagents/prompts/council.md +0 -48
  301. package/packages/subagents/prompts/gather-context-and-clarify.md +0 -13
  302. package/packages/subagents/prompts/parallel-cleanup.md +0 -59
  303. package/packages/subagents/prompts/parallel-research.md +0 -50
  304. package/packages/subagents/prompts/parallel-review.md +0 -54
  305. package/packages/subagents/prompts/review-loop.md +0 -43
  306. package/packages/subagents/skills/council-mode/SKILL.md +0 -230
  307. package/packages/subagents/skills/subagents/references/constraints-and-recipes.md +0 -259
  308. package/packages/subagents/skills/subagents/references/execution-controls.md +0 -454
  309. package/packages/subagents/skills/subagents/references/management-authoring-rpc.md +0 -161
  310. package/packages/subagents/skills/subagents/references/multi-lane-orchestration.md +0 -39
  311. package/packages/subagents/skills/subagents/references/prompting-and-roles.md +0 -267
  312. package/packages/subagents/src/acceptance.ts +0 -331
  313. package/packages/subagents/src/agent-manager.ts +0 -405
  314. package/packages/subagents/src/agent-memory.ts +0 -300
  315. package/packages/subagents/src/agent-overrides.ts +0 -183
  316. package/packages/subagents/src/agent-runner.ts +0 -271
  317. package/packages/subagents/src/async-runner.ts +0 -422
  318. package/packages/subagents/src/authority-policy.ts +0 -47
  319. package/packages/subagents/src/budgets.ts +0 -285
  320. package/packages/subagents/src/child-safety.ts +0 -140
  321. package/packages/subagents/src/config.ts +0 -249
  322. package/packages/subagents/src/conversation-viewer.ts +0 -281
  323. package/packages/subagents/src/core-compat.ts +0 -94
  324. package/packages/subagents/src/custom-agents.ts +0 -343
  325. package/packages/subagents/src/file-system-retry.ts +0 -50
  326. package/packages/subagents/src/fleet-data.ts +0 -105
  327. package/packages/subagents/src/fleet-view.ts +0 -322
  328. package/packages/subagents/src/foreground-detach.ts +0 -59
  329. package/packages/subagents/src/fork-context.ts +0 -285
  330. package/packages/subagents/src/global.d.ts +0 -7
  331. package/packages/subagents/src/guide.ts +0 -129
  332. package/packages/subagents/src/mission-state.ts +0 -133
  333. package/packages/subagents/src/mission-store.ts +0 -436
  334. package/packages/subagents/src/output-limits.ts +0 -142
  335. package/packages/subagents/src/parity-types.ts +0 -315
  336. package/packages/subagents/src/pi-args.ts +0 -167
  337. package/packages/subagents/src/result-files.ts +0 -232
  338. package/packages/subagents/src/result-watcher.ts +0 -221
  339. package/packages/subagents/src/retained-children.ts +0 -176
  340. package/packages/subagents/src/run-fanout-budget.ts +0 -356
  341. package/packages/subagents/src/scheduled-runs.ts +0 -349
  342. package/packages/subagents/src/schemas.ts +0 -263
  343. package/packages/subagents/src/slash-commands.ts +0 -80
  344. package/packages/subagents/src/supervisor-channel.ts +0 -249
  345. package/packages/subagents/src/tool-handler.ts +0 -1144
  346. package/packages/subagents/src/types.ts +0 -238
  347. package/packages/subagents/src/widget.ts +0 -457
  348. package/packages/subagents/src/workflow-script.ts +0 -737
  349. package/packages/subagents/src/workflow-worker.ts +0 -384
  350. package/packages/subagents/src/worktree.ts +0 -614
  351. package/packages/utility/src/analytics/collector.ts +0 -293
  352. package/packages/utility/src/info-screen.ts +0 -80
  353. package/packages/utility/src/lifecycle/process.ts +0 -162
  354. package/packages/utility/src/prefix-cache.ts +0 -263
  355. package/packages/utility/src/skill-discovery.ts +0 -542
  356. package/packages/utility/src/tools/env.ts +0 -113
  357. package/packages/utility/src/tui/name-badge-state.ts +0 -315
  358. package/packages/utility/src/tui/name-badge.ts +0 -109
  359. /package/packages/{subagents/src → core/src/child-agent}/pi-spawn.ts +0 -0
@@ -1,238 +0,0 @@
1
- /**
2
- * @pi-unipi/subagents — Type definitions
3
- */
4
-
5
- import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
6
- import type { AgentSession } from "@earendil-works/pi-coding-agent";
7
-
8
- export type { ThinkingLevel };
9
-
10
- /** Agent type name: built-in or user-defined. */
11
- export type AgentType = string;
12
-
13
- /** Built-in agent type names. */
14
- export const BUILTIN_TYPES = ["explore", "work"] as const;
15
-
16
- /** Read-only tool names for explore agents. */
17
- const READ_ONLY_TOOLS = ["read", "bash", "grep", "find", "ls"];
18
-
19
- /** All write-capable tool names. */
20
- const ALL_TOOLS = ["read", "bash", "edit", "write", "grep", "find", "ls"];
21
-
22
- /** Built-in agent configurations. */
23
- export const BUILTIN_CONFIGS: Record<string, AgentConfig> = {
24
- explore: {
25
- name: "explore",
26
- displayName: "Explore",
27
- description: "Read-only exploration agent for parallel file reads and searches.",
28
- builtinToolNames: READ_ONLY_TOOLS,
29
- disallowedTools: ["edit", "write"],
30
- extensions: false,
31
- skills: false,
32
- systemPrompt: "You are an explore agent. Read files, search code, and report findings. Do NOT modify any files.",
33
- promptMode: "append",
34
- source: "builtin",
35
- },
36
- work: {
37
- name: "work",
38
- displayName: "Worker",
39
- description: "Write-capable worker agent with transparent file locking.",
40
- builtinToolNames: ALL_TOOLS,
41
- extensions: false,
42
- skills: false,
43
- systemPrompt: "You are a worker agent. Implement changes, write code, and complete tasks. Use the provided tools to make the requested modifications.",
44
- promptMode: "append",
45
- source: "builtin",
46
- },
47
- "name-gen": {
48
- name: "name-gen",
49
- displayName: "Name Generator",
50
- description: "Minimal agent for generating session names from conversation context.",
51
- builtinToolNames: [],
52
- extensions: false,
53
- skills: false,
54
- systemPrompt: "You are a session name generator. Generate concise titles from conversation context. Reply with ONLY the title.",
55
- promptMode: "replace",
56
- source: "builtin",
57
- },
58
- } as const;
59
-
60
- /** Memory scope for persistent agent memory. */
61
- export type MemoryScope = "user" | "project" | "local";
62
-
63
- /** Structured per-agent memory config (reference parity). */
64
- export interface AgentMemoryConfig {
65
- scope: "user" | "project";
66
- path: string;
67
- }
68
-
69
- /** Unified agent configuration. */
70
- export interface AgentConfig {
71
- name: string;
72
- displayName?: string;
73
- description: string;
74
- /** Alias names resolving to this agent (reference parity). */
75
- aliases?: string[];
76
- builtinToolNames?: string[];
77
- disallowedTools?: string[];
78
- extensions: true | string[] | false;
79
- skills: true | string[] | false;
80
- /** Extra skill directories to load for this agent. */
81
- skillPath?: string[];
82
- model?: string;
83
- /** Ordered fallback models (reference parity; resolved Phase 2). */
84
- fallbackModels?: string[];
85
- thinking?: ThinkingLevel | string | false;
86
- maxTurns?: number;
87
- systemPrompt: string;
88
- promptMode: "replace" | "append";
89
- /** Reference alias for promptMode. */
90
- systemPromptMode?: "replace" | "append";
91
- /** Whether the child inherits project context (AGENTS.md etc.). Default: delegate only. */
92
- inheritProjectContext?: boolean;
93
- /** Whether the child inherits skills. Default: false. */
94
- inheritSkills?: boolean;
95
- /** Default context for launches that omit context. */
96
- defaultContext?: "fresh" | "fork";
97
- runInBackground?: boolean;
98
- isolated?: boolean;
99
- /** Agent-level default run deadline. */
100
- timeoutMs?: number;
101
- /** Agent-level default hard per-tool deadline. */
102
- toolTimeoutMs?: number;
103
- /** Nested-delegation cap for this agent's children. */
104
- maxSubagentDepth?: number;
105
- /** Output file for this agent's result. */
106
- output?: string;
107
- /** inline (default) or file-only result reference. */
108
- outputMode?: "inline" | "file-only";
109
- /** Files to read before running. */
110
- defaultReads?: string[];
111
- /** Maintain progress.md during runs. */
112
- defaultProgress?: boolean;
113
- memory?: MemoryScope | AgentMemoryConfig;
114
- isDefault?: boolean;
115
- enabled?: boolean;
116
- source?: "builtin" | "project" | "global";
117
- /** Unknown frontmatter fields preserved for later phases. */
118
- extraFields?: Record<string, string>;
119
- }
120
-
121
- /** Agent record — tracks a running agent. */
122
- export interface AgentRecord {
123
- id: string;
124
- type: AgentType;
125
- description: string;
126
- status: "queued" | "running" | "completed" | "aborted" | "stopped" | "error";
127
- result?: string;
128
- /** Private artifact holding the complete result when model-visible output is bounded. */
129
- resultArtifactPath?: string;
130
- error?: string;
131
- toolUses: number;
132
- startedAt: number;
133
- completedAt?: number;
134
- session?: AgentSession;
135
- abortController?: AbortController;
136
- promise?: Promise<string>;
137
- /** Set when result consumed via get_result — suppresses notification. */
138
- resultConsumed?: boolean;
139
- }
140
-
141
- /** Extension config. */
142
- export interface SubagentsConfig {
143
- maxConcurrent: number;
144
- enabled: boolean;
145
- types: Record<string, { enabled?: boolean }>;
146
-
147
- // ---- pi-subagents parity keys (optional; defaults follow the reference) ----
148
- /** Background execution for launches that omit run_in_background. Default: true (their asyncByDefault). */
149
- asyncByDefault?: boolean;
150
- /** Context for launches that omit context. "fresh" | "fork". */
151
- defaultSubagentContext?: "fresh" | "fork";
152
- /** Force depth-0 runs into background mode and bypass launch UI. Default: false. */
153
- forceTopLevelAsync?: boolean;
154
- /** Global default runtime deadline (ms). Replaces the 30-minute foreground backstop. */
155
- timeoutMs?: number;
156
- /** Optional hard per-tool-call deadline (ms). Precedence: call > agent frontmatter > this > env. */
157
- toolTimeoutMs?: number;
158
- /** Cap on simultaneously running children within durable multi-child runs. Default: 20. */
159
- globalConcurrencyLimit?: number;
160
- /** Cumulative child launches per parent session. Unset/0 = unlimited. */
161
- maxSubagentSpawnsPerSession?: number;
162
- /** Cumulative logical-child cap for one top-level run tree. Default: 64. */
163
- maxSubagentSpawnsPerRun?: number;
164
- /** Concurrently active top-level async runs per parent session. Unset/0 = unlimited. */
165
- maxActiveAsyncRunsPerSession?: number;
166
- /** Nested delegation depth cap. Default: 2. */
167
- maxSubagentDepth?: number;
168
- /** Parallel fanout caps. maxTasks default 8; concurrency default 4. */
169
- parallel?: { maxTasks?: number; concurrency?: number };
170
- /** Default output limits for child results. Default: 200KB / 5000 lines. */
171
- maxOutput?: { bytes?: number; lines?: number };
172
- /** Session directory for child sessions. `~/` expanded. */
173
- defaultSessionDir?: string;
174
- /** Show the persistent fleet panel. Default: true. */
175
- fleetView?: boolean;
176
- /** Fleet panel placement. Default: "belowEditor". */
177
- fleetViewPlacement?: "belowEditor" | "aboveEditor";
178
- /** Inline chat rendering for spawn_helper results. "rich" | "summary". Default: rich. */
179
- inlineToolDisplay?: "rich" | "summary";
180
- /** Main chat renderer density controls. */
181
- mainWindowRenderer?: { horizontalSpacing?: number; compactResultMaxLines?: number };
182
- /** How slow async result scans are logged. "all" | "activity" | "off". Default: all. */
183
- resultScanLogging?: "all" | "activity" | "off";
184
- /** Shortcut detaching the active foreground single run without terminating it. */
185
- foregroundDetachShortcut?: string;
186
- /** Keep get_helper_result registered but make direct calls non-blocking. Default: true. */
187
- waitTool?: boolean | { enabled?: boolean };
188
- /** Base directory for worktree-isolated runs. Default: OS temp. */
189
- worktreeBaseDir?: string;
190
- /** Hook run once per created worktree. */
191
- worktreeSetupHook?: string;
192
- /** Timeout for the worktree setup hook in ms. Default: 30000. */
193
- worktreeSetupHookTimeoutMs?: number;
194
- /** Missions store config. */
195
- missions?: {
196
- enabled?: boolean;
197
- directory?: string;
198
- globalIndex?: boolean;
199
- globalIndexDir?: string;
200
- retainTerminal?: number;
201
- };
202
- /** Scheduled runs config. */
203
- scheduledRuns?: { enabled?: boolean; maxPending?: number; storeRoot?: string };
204
- /** Authority policy for operational actions. */
205
- authorityPolicy?: {
206
- discardWorktree?: "confirm" | "auto";
207
- destructiveCleanup?: "confirm" | "auto";
208
- spawnBudgetGrant?: "confirm" | "auto";
209
- scheduleCreate?: "confirm" | "auto";
210
- };
211
- }
212
-
213
- /** Agent activity for widget display. */
214
- export interface AgentActivity {
215
- activeTools: Map<string, string>;
216
- toolUses: number;
217
- turnCount: number;
218
- maxTurns?: number;
219
- tokens: string;
220
- responseText: string;
221
- session?: AgentSession;
222
- }
223
-
224
- /** Details attached to custom notification messages for visual rendering. */
225
- export interface NotificationDetails {
226
- id: string;
227
- description: string;
228
- status: string;
229
- toolUses: number;
230
- turnCount: number;
231
- maxTurns?: number;
232
- totalTokens: number;
233
- durationMs: number;
234
- error?: string;
235
- resultPreview: string;
236
- /** Additional agents in a group notification. */
237
- others?: NotificationDetails[];
238
- }
@@ -1,457 +0,0 @@
1
- /**
2
- * @pi-unipi/subagents — Live widget
3
- *
4
- * Shows running/completed agents above the editor with:
5
- * - Animated braille spinners
6
- * - Finished agent lingering (1 turn success, 2 turns error)
7
- * - Priority-based overflow (running > queued > finished)
8
- * - Status bar integration
9
- * - Activity description grouping
10
- * - ANSI-aware truncation via pi-tui
11
- */
12
-
13
- import { truncateToWidth } from "@earendil-works/pi-tui";
14
- import type { ExtensionUIContext } from "@earendil-works/pi-coding-agent";
15
- import type { AgentManager } from "./agent-manager.js";
16
- import type { AgentActivity } from "./types.js";
17
-
18
- // ---- Constants ----
19
-
20
- /** Maximum lines the widget may render. */
21
- const MAX_WIDGET_LINES = 12;
22
-
23
- /** Braille spinner frames. */
24
- export const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
25
-
26
- /** Statuses that indicate error/non-success (for linger behavior). */
27
- const ERROR_STATUSES = new Set(["error", "aborted", "stopped"]);
28
-
29
- /** Tool name → human-readable action for activity descriptions. */
30
- export const TOOL_DISPLAY: Record<string, string> = {
31
- read: "reading",
32
- bash: "running command",
33
- edit: "editing",
34
- write: "writing",
35
- grep: "searching",
36
- find: "finding files",
37
- ls: "listing",
38
- };
39
-
40
- // ---- Formatting helpers ----
41
-
42
- /** Format duration. */
43
- export function formatMs(ms: number): string {
44
- if (ms >= 60_000) return `${(ms / 60_000).toFixed(1)}m`;
45
- if (ms >= 1_000) return `${(ms / 1_000).toFixed(1)}s`;
46
- return `${ms}ms`;
47
- }
48
-
49
- /** Format turns with optional max limit: "⟳5≤30" or "⟳5". */
50
- export function formatTurns(turn: number, max?: number): string {
51
- return max != null ? `⟳${turn}≤${max}` : `⟳${turn}`;
52
- }
53
-
54
- /**
55
- * Build a human-readable activity string from currently-running tools.
56
- * Groups by tool type with counts: "reading 3 files, searching 2 patterns".
57
- */
58
- export function describeActivity(activeTools: Map<string, string>, responseText?: string): string {
59
- if (activeTools.size > 0) {
60
- const groups = new Map<string, number>();
61
- for (const toolName of activeTools.values()) {
62
- const action = TOOL_DISPLAY[toolName] ?? toolName;
63
- groups.set(action, (groups.get(action) ?? 0) + 1);
64
- }
65
-
66
- const parts: string[] = [];
67
- for (const [action, count] of groups) {
68
- if (count > 1) {
69
- parts.push(`${action} ${count} ${action === "searching" ? "patterns" : "files"}`);
70
- } else {
71
- parts.push(action);
72
- }
73
- }
74
- return parts.join(", ") + "…";
75
- }
76
-
77
- if (responseText && responseText.trim().length > 0) {
78
- const lastLine = responseText.split("\n").find((l) => l.trim())?.trim() ?? "";
79
- if (lastLine.length > 60) return lastLine.slice(0, 60) + "…";
80
- if (lastLine.length > 0) return lastLine;
81
- }
82
-
83
- return "thinking…";
84
- }
85
-
86
- // ---- Widget ----
87
-
88
- export class AgentWidget {
89
- private spinnerFrame = 0;
90
- private timer?: ReturnType<typeof setInterval>;
91
- private uiCtx?: ExtensionUIContext;
92
- private tui?: import("@earendil-works/pi-tui").TUI;
93
- private widgetRegistered = false;
94
- /** Last content key — skips requestRender when only spinner changed. */
95
- private lastContentKey = "";
96
-
97
- /** Tracks how many turns each finished agent has survived. */
98
- private finishedTurnAge = new Map<string, number>();
99
- /** How many extra turns error/aborted agents linger. */
100
- private static readonly ERROR_LINGER_TURNS = 2;
101
- /** Last status bar text for dedup. */
102
- private lastStatusText: string | undefined;
103
-
104
- constructor(
105
- private manager: AgentManager,
106
- private activity: Map<string, AgentActivity>,
107
- ) {}
108
-
109
- setUICtx(ctx: ExtensionUIContext) {
110
- if (ctx !== this.uiCtx) {
111
- this.uiCtx = ctx;
112
- this.widgetRegistered = false;
113
- this.tui = undefined;
114
- this.lastStatusText = undefined;
115
- }
116
- }
117
-
118
- /**
119
- * Called on each new turn (tool_execution_start).
120
- * Ages finished agents and clears those that have lingered long enough.
121
- */
122
- onTurnStart() {
123
- for (const [id, age] of this.finishedTurnAge) {
124
- this.finishedTurnAge.set(id, age + 1);
125
- }
126
- this.update();
127
- }
128
-
129
- ensureTimer() {
130
- if (this.timer) return;
131
- this.timer = setInterval(() => {
132
- this.spinnerFrame = (this.spinnerFrame + 1) % SPINNER.length;
133
- if (!this.lastContentKey) return;
134
- // triggerRender() deliberately skips requestRender when only the
135
- // spinner changed (content key excludes it), which froze the spinner
136
- // between real updates. Content diffing still happens there; here we
137
- // just keep the animation alive while anything is running.
138
- this.triggerRender();
139
- if (this.hasRunningAgents()) this.tui?.requestRender?.();
140
- }, 80);
141
- }
142
-
143
- private hasRunningAgents(): boolean {
144
- return this.manager.listAgents().some((a) => a.status === "running" || a.status === "queued");
145
- }
146
-
147
- /** Record an agent as finished (call when agent completes). */
148
- markFinished(agentId: string) {
149
- if (!this.finishedTurnAge.has(agentId)) {
150
- this.finishedTurnAge.set(agentId, 0);
151
- }
152
- }
153
-
154
- update() {
155
- this.triggerRender();
156
- }
157
-
158
- /** Check if a finished agent should still be shown. */
159
- private shouldShowFinished(agentId: string, status: string): boolean {
160
- const age = this.finishedTurnAge.get(agentId) ?? 0;
161
- const maxAge = ERROR_STATUSES.has(status) ? AgentWidget.ERROR_LINGER_TURNS : 1;
162
- return age < maxAge;
163
- }
164
-
165
- /**
166
- * Build a content key capturing what's actually visible.
167
- * Excludes spinner — spinner-only changes skip requestRender.
168
- */
169
- private buildContentKey(): string {
170
- const allAgents = this.manager.listAgents();
171
- const parts: string[] = [];
172
- for (const a of allAgents) {
173
- if (a.status === "running" || a.status === "queued") {
174
- const act = this.activity.get(a.id);
175
- parts.push(
176
- `${a.id}:${a.status}:${a.toolUses}:${act?.turnCount ?? 0}:${act?.tokens ?? ""}:${describeActivity(act?.activeTools ?? new Map(), act?.responseText ?? "")}`,
177
- );
178
- } else if (a.completedAt && this.shouldShowFinished(a.id, a.status)) {
179
- parts.push(`${a.id}:${a.status}:${a.toolUses}:finished`);
180
- }
181
- }
182
- return parts.join("|");
183
- }
184
-
185
- private triggerRender() {
186
- if (!this.uiCtx) return;
187
-
188
- const contentKey = this.buildContentKey();
189
- const hasContent = contentKey.length > 0;
190
-
191
- // Nothing to show — clear widget
192
- if (!hasContent) {
193
- if (this.widgetRegistered) {
194
- this.uiCtx.setWidget("unipi-agents", undefined);
195
- this.widgetRegistered = false;
196
- this.tui = undefined;
197
- this.lastContentKey = "";
198
- }
199
- if (this.lastStatusText !== undefined) {
200
- this.uiCtx.setStatus?.("subagents", undefined);
201
- this.lastStatusText = undefined;
202
- }
203
- // Clean up stale finished entries
204
- const allAgents = this.manager.listAgents();
205
- for (const [id] of this.finishedTurnAge) {
206
- if (!allAgents.some((a) => a.id === id)) this.finishedTurnAge.delete(id);
207
- }
208
- return;
209
- }
210
-
211
- // Status bar
212
- this.updateStatusBar();
213
-
214
- // Register widget callback once
215
- if (!this.widgetRegistered) {
216
- this.uiCtx.setWidget(
217
- "unipi-agents",
218
- (tui: any, theme: any) => {
219
- this.tui = tui;
220
- return {
221
- render: (width: number) => this.renderWidget(tui, theme, width),
222
- invalidate: () => {
223
- this.widgetRegistered = false;
224
- this.tui = undefined;
225
- },
226
- };
227
- },
228
- { placement: "aboveEditor" },
229
- );
230
- this.widgetRegistered = true;
231
- this.lastContentKey = "";
232
- }
233
-
234
- // Only request render when content actually changed
235
- if (contentKey !== this.lastContentKey) {
236
- this.lastContentKey = contentKey;
237
- this.tui?.requestRender?.();
238
- }
239
- }
240
-
241
- private updateStatusBar() {
242
- if (!this.uiCtx?.setStatus) return;
243
- const allAgents = this.manager.listAgents();
244
- let runningCount = 0;
245
- let queuedCount = 0;
246
- for (const a of allAgents) {
247
- if (a.status === "running") runningCount++;
248
- else if (a.status === "queued") queuedCount++;
249
- }
250
-
251
- let newStatusText: string | undefined;
252
- if (runningCount > 0 || queuedCount > 0) {
253
- const parts: string[] = [];
254
- if (runningCount > 0) parts.push(`${runningCount} running`);
255
- if (queuedCount > 0) parts.push(`${queuedCount} queued`);
256
- const total = runningCount + queuedCount;
257
- newStatusText = `${parts.join(", ")} agent${total === 1 ? "" : "s"}`;
258
- }
259
-
260
- if (newStatusText !== this.lastStatusText) {
261
- this.uiCtx.setStatus("subagents", newStatusText);
262
- this.lastStatusText = newStatusText;
263
- }
264
- }
265
-
266
- /** Render a finished agent line. */
267
- private renderFinishedLine(
268
- a: { id: string; type: string; status: string; description: string; toolUses: number; startedAt: number; completedAt?: number; error?: string },
269
- theme: any,
270
- w: number,
271
- ): string {
272
- const duration = formatMs((a.completedAt ?? Date.now()) - a.startedAt);
273
-
274
- let icon: string;
275
- let statusText: string;
276
- if (a.status === "completed") {
277
- icon = theme.fg("success", "✓");
278
- statusText = "";
279
- } else if (a.status === "stopped") {
280
- icon = theme.fg("dim", "■");
281
- statusText = theme.fg("dim", " stopped");
282
- } else if (a.status === "error") {
283
- icon = theme.fg("error", "✗");
284
- const errMsg = a.error ? `: ${a.error.slice(0, 40)}` : "";
285
- statusText = theme.fg("error", ` error${errMsg}`);
286
- } else {
287
- // aborted
288
- icon = theme.fg("error", "✗");
289
- statusText = theme.fg("warning", " aborted");
290
- }
291
-
292
- const parts: string[] = [];
293
- const act = this.activity.get(a.id);
294
- if (act) parts.push(formatTurns(act.turnCount, act.maxTurns));
295
- if (a.toolUses > 0) parts.push(`${a.toolUses} tool use${a.toolUses === 1 ? "" : "s"}`);
296
- parts.push(duration);
297
-
298
- const line =
299
- theme.fg("dim", "├─") +
300
- " " +
301
- icon +
302
- " " +
303
- theme.fg("dim", a.type) +
304
- " " +
305
- theme.fg("dim", a.description) +
306
- " " +
307
- theme.fg("dim", "·") +
308
- " " +
309
- theme.fg("dim", parts.join(" · ")) +
310
- statusText;
311
-
312
- return truncateToWidth(line, w);
313
- }
314
-
315
- private renderWidget(tui: any, theme: any, width?: number): string[] {
316
- const allAgents = this.manager.listAgents();
317
- const running = allAgents.filter((a) => a.status === "running");
318
- const queued = allAgents.filter((a) => a.status === "queued");
319
- const finished = allAgents.filter(
320
- (a) =>
321
- a.status !== "running" &&
322
- a.status !== "queued" &&
323
- a.completedAt &&
324
- this.shouldShowFinished(a.id, a.status),
325
- );
326
-
327
- const hasActive = running.length > 0 || queued.length > 0;
328
- const hasFinished = finished.length > 0;
329
- if (!hasActive && !hasFinished) return [];
330
-
331
- const w = width ?? tui.terminal?.columns ?? 80;
332
- const frame = SPINNER[this.spinnerFrame % SPINNER.length];
333
- const headingColor = hasActive ? "accent" : "dim";
334
- const headingIcon = hasActive ? "●" : "○";
335
-
336
- // Build sections: finished (1 line each), running (2 lines each), queued (1 line)
337
- const finishedLines: string[] = finished.map((a) => this.renderFinishedLine(a, theme, w));
338
-
339
- const runningLines: string[][] = running.map((a) => {
340
- const act = this.activity.get(a.id);
341
- const toolCount = a.toolUses;
342
- const tokens = act?.tokens ?? "";
343
- const elapsed = formatMs(Date.now() - a.startedAt);
344
- const activity = act ? describeActivity(act.activeTools, act.responseText) : "starting…";
345
-
346
- const parts: string[] = [];
347
- if (act?.turnCount) parts.push(formatTurns(act.turnCount, act.maxTurns));
348
- if (toolCount > 0) parts.push(`${toolCount} tool use${toolCount === 1 ? "" : "s"}`);
349
- if (tokens) parts.push(tokens);
350
- parts.push(elapsed);
351
-
352
- return [
353
- truncateToWidth(
354
- theme.fg("dim", "├─") +
355
- ` ${theme.fg("accent", frame)} ${theme.bold(a.type)} ${theme.fg("dim", a.description)} ${theme.fg("dim", "·")} ${theme.fg("dim", parts.join(" · "))}`,
356
- w,
357
- ),
358
- truncateToWidth(theme.fg("dim", "│ ") + theme.fg("dim", ` ⎿ ${activity}`), w),
359
- ];
360
- });
361
-
362
- const queuedLine =
363
- queued.length > 0
364
- ? truncateToWidth(
365
- theme.fg("dim", "├─") + ` ${theme.fg("muted", "◦")} ${theme.fg("dim", `${queued.length} queued`)}`,
366
- w,
367
- )
368
- : undefined;
369
-
370
- // Assemble with overflow cap
371
- const maxBody = MAX_WIDGET_LINES - 1; // heading takes 1 line
372
- const totalBody = finishedLines.length + runningLines.length * 2 + (queuedLine ? 1 : 0);
373
-
374
- const lines: string[] = [truncateToWidth(theme.fg(headingColor, headingIcon) + " " + theme.fg(headingColor, "Agents"), w)];
375
-
376
- if (totalBody <= maxBody) {
377
- // Everything fits
378
- lines.push(...finishedLines);
379
- for (const pair of runningLines) lines.push(...pair);
380
- if (queuedLine) lines.push(queuedLine);
381
-
382
- // Fix last connector: ├─ → └─
383
- if (lines.length > 1) {
384
- const last = lines.length - 1;
385
- lines[last] = lines[last].replace("├─", "└─");
386
- if (runningLines.length > 0 && !queuedLine && last >= 2) {
387
- lines[last - 1] = lines[last - 1].replace("├─", "└─");
388
- lines[last] = lines[last].replace("│ ", " ");
389
- }
390
- }
391
- } else {
392
- // Overflow — prioritize: running > queued > finished
393
- let budget = maxBody - 1; // reserve 1 for overflow indicator
394
- let hiddenRunning = 0;
395
- let hiddenFinished = 0;
396
-
397
- // 1. Running agents (2 lines each)
398
- for (const pair of runningLines) {
399
- if (budget >= 2) {
400
- lines.push(...pair);
401
- budget -= 2;
402
- } else {
403
- hiddenRunning++;
404
- }
405
- }
406
-
407
- // 2. Queued
408
- if (queuedLine && budget >= 1) {
409
- lines.push(queuedLine);
410
- budget--;
411
- }
412
-
413
- // 3. Finished
414
- for (const fl of finishedLines) {
415
- if (budget >= 1) {
416
- lines.push(fl);
417
- budget--;
418
- } else {
419
- hiddenFinished++;
420
- }
421
- }
422
-
423
- // Overflow summary
424
- const overflowParts: string[] = [];
425
- if (hiddenRunning > 0) overflowParts.push(`${hiddenRunning} running`);
426
- if (hiddenFinished > 0) overflowParts.push(`${hiddenFinished} finished`);
427
- if (overflowParts.length > 0) {
428
- lines.push(
429
- truncateToWidth(
430
- theme.fg("dim", "└─") + ` ${theme.fg("dim", `+${hiddenRunning + hiddenFinished} more (${overflowParts.join(", ")})`)}`,
431
- w,
432
- ),
433
- );
434
- }
435
- }
436
-
437
- return lines;
438
- }
439
-
440
- dispose() {
441
- if (this.timer) {
442
- clearInterval(this.timer);
443
- this.timer = undefined;
444
- }
445
- if (this.uiCtx) {
446
- if (this.widgetRegistered) {
447
- this.uiCtx.setWidget("unipi-agents", undefined);
448
- }
449
- if (this.lastStatusText !== undefined) {
450
- this.uiCtx.setStatus?.("subagents", undefined);
451
- }
452
- }
453
- this.widgetRegistered = false;
454
- this.tui = undefined;
455
- this.lastStatusText = undefined;
456
- }
457
- }