@narumitw/pi-subagents 2.1.4 → 3.0.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.
Files changed (312) hide show
  1. package/README.md +187 -1228
  2. package/dist/child-communication-bridge.ts +136 -0
  3. package/dist/child-communication-bridge.ts.map +7 -0
  4. package/dist/chunks/chunk-UKTWUQRM.js +667 -0
  5. package/dist/chunks/chunk-UKTWUQRM.js.map +7 -0
  6. package/dist/index.ts +1448 -1614
  7. package/dist/index.ts.map +4 -4
  8. package/docs/design-principles.md +31 -0
  9. package/docs/ipc-transport-idea.md +103 -0
  10. package/docs/tools.md +109 -0
  11. package/package.json +11 -19
  12. package/src/broker-credentials.ts +71 -0
  13. package/src/child-communication-bridge.ts +153 -0
  14. package/src/child-communication-tools.ts +147 -0
  15. package/src/completion-renderer.ts +60 -0
  16. package/src/index.ts +1 -1
  17. package/src/message-broker.ts +628 -0
  18. package/src/model-output.ts +42 -0
  19. package/src/process.ts +688 -0
  20. package/src/runtime.ts +538 -0
  21. package/src/subagents.ts +33 -34
  22. package/src/tools.ts +416 -0
  23. package/src/types.ts +85 -0
  24. package/src/widget.ts +130 -0
  25. package/dist/chunks/auto-transport-FUUKFDIG.ts +0 -109
  26. package/dist/chunks/auto-transport-FUUKFDIG.ts.map +0 -7
  27. package/dist/chunks/capability-grant-PR72SWWS.ts +0 -19
  28. package/dist/chunks/capability-grant-PR72SWWS.ts.map +0 -7
  29. package/dist/chunks/child-peer-bridge.ts +0 -108
  30. package/dist/chunks/child-peer-bridge.ts.map +0 -7
  31. package/dist/chunks/chunk-2LMJU25E.ts +0 -1641
  32. package/dist/chunks/chunk-2LMJU25E.ts.map +0 -7
  33. package/dist/chunks/chunk-47SK2QYC.ts +0 -56
  34. package/dist/chunks/chunk-47SK2QYC.ts.map +0 -7
  35. package/dist/chunks/chunk-4AQSF7AS.ts +0 -29
  36. package/dist/chunks/chunk-4AQSF7AS.ts.map +0 -7
  37. package/dist/chunks/chunk-5DGRMKNV.ts +0 -126
  38. package/dist/chunks/chunk-5DGRMKNV.ts.map +0 -7
  39. package/dist/chunks/chunk-6H6TBBED.ts +0 -108
  40. package/dist/chunks/chunk-6H6TBBED.ts.map +0 -7
  41. package/dist/chunks/chunk-6KJ34M6S.ts +0 -159
  42. package/dist/chunks/chunk-6KJ34M6S.ts.map +0 -7
  43. package/dist/chunks/chunk-6NSJVPXX.ts +0 -480
  44. package/dist/chunks/chunk-6NSJVPXX.ts.map +0 -7
  45. package/dist/chunks/chunk-7AAJEUSL.ts +0 -238
  46. package/dist/chunks/chunk-7AAJEUSL.ts.map +0 -7
  47. package/dist/chunks/chunk-BFK2Z4ZF.ts +0 -189
  48. package/dist/chunks/chunk-BFK2Z4ZF.ts.map +0 -7
  49. package/dist/chunks/chunk-BOAXY55Y.ts +0 -153
  50. package/dist/chunks/chunk-BOAXY55Y.ts.map +0 -7
  51. package/dist/chunks/chunk-D4CR7T73.ts +0 -353
  52. package/dist/chunks/chunk-D4CR7T73.ts.map +0 -7
  53. package/dist/chunks/chunk-FEVPWRMU.ts +0 -300
  54. package/dist/chunks/chunk-FEVPWRMU.ts.map +0 -7
  55. package/dist/chunks/chunk-G6VZTCFH.ts +0 -70
  56. package/dist/chunks/chunk-G6VZTCFH.ts.map +0 -7
  57. package/dist/chunks/chunk-H3FP6DLR.ts +0 -160
  58. package/dist/chunks/chunk-H3FP6DLR.ts.map +0 -7
  59. package/dist/chunks/chunk-HA36LPCO.ts +0 -130
  60. package/dist/chunks/chunk-HA36LPCO.ts.map +0 -7
  61. package/dist/chunks/chunk-HOP5FXDT.ts +0 -27
  62. package/dist/chunks/chunk-HOP5FXDT.ts.map +0 -7
  63. package/dist/chunks/chunk-IGAMVWFN.ts +0 -139
  64. package/dist/chunks/chunk-IGAMVWFN.ts.map +0 -7
  65. package/dist/chunks/chunk-ILEQ27AL.ts +0 -45
  66. package/dist/chunks/chunk-ILEQ27AL.ts.map +0 -7
  67. package/dist/chunks/chunk-ITVWPNU4.ts +0 -819
  68. package/dist/chunks/chunk-ITVWPNU4.ts.map +0 -7
  69. package/dist/chunks/chunk-IWC32VPY.ts +0 -172
  70. package/dist/chunks/chunk-IWC32VPY.ts.map +0 -7
  71. package/dist/chunks/chunk-JSZIP73U.ts +0 -362
  72. package/dist/chunks/chunk-JSZIP73U.ts.map +0 -7
  73. package/dist/chunks/chunk-JU6LUNLP.ts +0 -380
  74. package/dist/chunks/chunk-JU6LUNLP.ts.map +0 -7
  75. package/dist/chunks/chunk-KMGKCEO4.ts +0 -38
  76. package/dist/chunks/chunk-KMGKCEO4.ts.map +0 -7
  77. package/dist/chunks/chunk-LASD73CM.ts +0 -339
  78. package/dist/chunks/chunk-LASD73CM.ts.map +0 -7
  79. package/dist/chunks/chunk-LEOYDZI3.ts +0 -22
  80. package/dist/chunks/chunk-LEOYDZI3.ts.map +0 -7
  81. package/dist/chunks/chunk-LL4LP2T7.ts +0 -737
  82. package/dist/chunks/chunk-LL4LP2T7.ts.map +0 -7
  83. package/dist/chunks/chunk-N2T5IN4X.ts +0 -18
  84. package/dist/chunks/chunk-N2T5IN4X.ts.map +0 -7
  85. package/dist/chunks/chunk-N7BLVXKK.ts +0 -73
  86. package/dist/chunks/chunk-N7BLVXKK.ts.map +0 -7
  87. package/dist/chunks/chunk-NLT67IZS.ts +0 -322
  88. package/dist/chunks/chunk-NLT67IZS.ts.map +0 -7
  89. package/dist/chunks/chunk-NTRPLF46.ts +0 -63
  90. package/dist/chunks/chunk-NTRPLF46.ts.map +0 -7
  91. package/dist/chunks/chunk-ONDTY4EL.ts +0 -91
  92. package/dist/chunks/chunk-ONDTY4EL.ts.map +0 -7
  93. package/dist/chunks/chunk-OVPHFGKO.ts +0 -1769
  94. package/dist/chunks/chunk-OVPHFGKO.ts.map +0 -7
  95. package/dist/chunks/chunk-P7OH4XMF.ts +0 -60
  96. package/dist/chunks/chunk-P7OH4XMF.ts.map +0 -7
  97. package/dist/chunks/chunk-PBZMBTNJ.ts +0 -422
  98. package/dist/chunks/chunk-PBZMBTNJ.ts.map +0 -7
  99. package/dist/chunks/chunk-PGLSFLYW.ts +0 -52
  100. package/dist/chunks/chunk-PGLSFLYW.ts.map +0 -7
  101. package/dist/chunks/chunk-RRR66UWR.ts +0 -28
  102. package/dist/chunks/chunk-RRR66UWR.ts.map +0 -7
  103. package/dist/chunks/chunk-RSUXZD6S.ts +0 -275
  104. package/dist/chunks/chunk-RSUXZD6S.ts.map +0 -7
  105. package/dist/chunks/chunk-RTCVYIZA.ts +0 -221
  106. package/dist/chunks/chunk-RTCVYIZA.ts.map +0 -7
  107. package/dist/chunks/chunk-RY2AEGMZ.ts +0 -34
  108. package/dist/chunks/chunk-RY2AEGMZ.ts.map +0 -7
  109. package/dist/chunks/chunk-SWGQLFSD.ts +0 -60
  110. package/dist/chunks/chunk-SWGQLFSD.ts.map +0 -7
  111. package/dist/chunks/chunk-TM2R67J3.ts +0 -52
  112. package/dist/chunks/chunk-TM2R67J3.ts.map +0 -7
  113. package/dist/chunks/chunk-TMZRHIIK.ts +0 -497
  114. package/dist/chunks/chunk-TMZRHIIK.ts.map +0 -7
  115. package/dist/chunks/chunk-TZ34IQ3M.ts +0 -59
  116. package/dist/chunks/chunk-TZ34IQ3M.ts.map +0 -7
  117. package/dist/chunks/chunk-UMBPMVJW.ts +0 -22
  118. package/dist/chunks/chunk-UMBPMVJW.ts.map +0 -7
  119. package/dist/chunks/chunk-VDG7LTYE.ts +0 -80
  120. package/dist/chunks/chunk-VDG7LTYE.ts.map +0 -7
  121. package/dist/chunks/chunk-X4NMONPE.ts +0 -73
  122. package/dist/chunks/chunk-X4NMONPE.ts.map +0 -7
  123. package/dist/chunks/chunk-YPJEN6NU.ts +0 -65
  124. package/dist/chunks/chunk-YPJEN6NU.ts.map +0 -7
  125. package/dist/chunks/chunk-YU53SHA7.ts +0 -328
  126. package/dist/chunks/chunk-YU53SHA7.ts.map +0 -7
  127. package/dist/chunks/completion-delivery-RSJU6BXL.ts +0 -17
  128. package/dist/chunks/completion-delivery-RSJU6BXL.ts.map +0 -7
  129. package/dist/chunks/config-status-FKGDECZ3.ts +0 -35
  130. package/dist/chunks/config-status-FKGDECZ3.ts.map +0 -7
  131. package/dist/chunks/config-ui-ABHYNGQ7.ts +0 -1212
  132. package/dist/chunks/config-ui-ABHYNGQ7.ts.map +0 -7
  133. package/dist/chunks/consult-LJU3IQY5.ts +0 -519
  134. package/dist/chunks/consult-LJU3IQY5.ts.map +0 -7
  135. package/dist/chunks/context-QDKLVQXE.ts +0 -11
  136. package/dist/chunks/context-QDKLVQXE.ts.map +0 -7
  137. package/dist/chunks/create-stateful-transport-JWC2EFYL.ts +0 -130
  138. package/dist/chunks/create-stateful-transport-JWC2EFYL.ts.map +0 -7
  139. package/dist/chunks/cwd-policy-NB6XZ5GF.ts +0 -17
  140. package/dist/chunks/cwd-policy-NB6XZ5GF.ts.map +0 -7
  141. package/dist/chunks/delegation-contract-LA56I5DT.ts +0 -24
  142. package/dist/chunks/delegation-contract-LA56I5DT.ts.map +0 -7
  143. package/dist/chunks/discovery-MIFB2U4Y.ts +0 -12
  144. package/dist/chunks/discovery-MIFB2U4Y.ts.map +0 -7
  145. package/dist/chunks/execution-Q2JZLKJA.ts +0 -4037
  146. package/dist/chunks/execution-Q2JZLKJA.ts.map +0 -7
  147. package/dist/chunks/in-process-transport-HJ6TZXC3.ts +0 -39
  148. package/dist/chunks/in-process-transport-HJ6TZXC3.ts.map +0 -7
  149. package/dist/chunks/inspect-UH2TKH6E.ts +0 -634
  150. package/dist/chunks/inspect-UH2TKH6E.ts.map +0 -7
  151. package/dist/chunks/peer-communication-KL36Z6CO.ts +0 -294
  152. package/dist/chunks/peer-communication-KL36Z6CO.ts.map +0 -7
  153. package/dist/chunks/persistence-UY3PY6E5.ts +0 -348
  154. package/dist/chunks/persistence-UY3PY6E5.ts.map +0 -7
  155. package/dist/chunks/registry-BT54L6CY.ts +0 -1445
  156. package/dist/chunks/registry-BT54L6CY.ts.map +0 -7
  157. package/dist/chunks/retained-semantic-state-GM75FZGE.ts +0 -81
  158. package/dist/chunks/retained-semantic-state-GM75FZGE.ts.map +0 -7
  159. package/dist/chunks/rpc-transport-7R7DVCEB.ts +0 -1222
  160. package/dist/chunks/rpc-transport-7R7DVCEB.ts.map +0 -7
  161. package/dist/chunks/runtime-policy-5YELCOVC.ts +0 -15
  162. package/dist/chunks/runtime-policy-5YELCOVC.ts.map +0 -7
  163. package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts +0 -19
  164. package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts.map +0 -7
  165. package/dist/chunks/spawn-idempotency-BNHOSMZW.ts +0 -13
  166. package/dist/chunks/spawn-idempotency-BNHOSMZW.ts.map +0 -7
  167. package/dist/chunks/stateful-lifecycle-JAR6K55H.ts +0 -15
  168. package/dist/chunks/stateful-lifecycle-JAR6K55H.ts.map +0 -7
  169. package/dist/chunks/subprocess-transport-VHZJRBTW.ts +0 -160
  170. package/dist/chunks/subprocess-transport-VHZJRBTW.ts.map +0 -7
  171. package/dist/chunks/usage-recording-store-CW3EH2SZ.ts +0 -164
  172. package/dist/chunks/usage-recording-store-CW3EH2SZ.ts.map +0 -7
  173. package/dist/chunks/workspace-WDKLN72J.ts +0 -11
  174. package/dist/chunks/workspace-WDKLN72J.ts.map +0 -7
  175. package/docs/async-runtime-protocol.md +0 -84
  176. package/docs/implementation-notes/pi-subagents-capability-matrix.md +0 -62
  177. package/docs/implementation-notes/pi-subagents-current-direction.md +0 -99
  178. package/docs/implementation-notes/pi-subagents-rpc-v1.md +0 -139
  179. package/docs/pi-subagents-diagrams.md +0 -183
  180. package/src/adaptive-scheduler.ts +0 -224
  181. package/src/admission-policy.ts +0 -78
  182. package/src/agent-projection.ts +0 -53
  183. package/src/agents/built-ins.ts +0 -71
  184. package/src/agents/catalog.ts +0 -241
  185. package/src/agents/discovery.ts +0 -265
  186. package/src/agents/types.ts +0 -100
  187. package/src/agents.ts +0 -51
  188. package/src/auto-transport.ts +0 -121
  189. package/src/blocking-status.ts +0 -63
  190. package/src/cached-module-loader.ts +0 -18
  191. package/src/capabilities.ts +0 -145
  192. package/src/capability-grant.ts +0 -115
  193. package/src/capability-router.ts +0 -107
  194. package/src/child-peer-bridge.ts +0 -124
  195. package/src/child-peer-tools.ts +0 -132
  196. package/src/completion-delivery.ts +0 -409
  197. package/src/completion-render.ts +0 -190
  198. package/src/completion-requirement.ts +0 -479
  199. package/src/completion-routing.ts +0 -24
  200. package/src/config-registration.ts +0 -114
  201. package/src/config-status.ts +0 -217
  202. package/src/config-ui.ts +0 -983
  203. package/src/consult-policy.ts +0 -15
  204. package/src/consult-registration.ts +0 -125
  205. package/src/consult-render.ts +0 -194
  206. package/src/consult-resources.ts +0 -51
  207. package/src/consult-tool.ts +0 -95
  208. package/src/consult.ts +0 -566
  209. package/src/context.ts +0 -126
  210. package/src/create-stateful-transport.ts +0 -157
  211. package/src/cwd-policy.ts +0 -183
  212. package/src/delegation-contract.ts +0 -463
  213. package/src/execution/budget.ts +0 -56
  214. package/src/execution/runtime-policy.ts +0 -19
  215. package/src/execution-plan.ts +0 -322
  216. package/src/execution-ui.ts +0 -259
  217. package/src/execution.ts +0 -1679
  218. package/src/in-process-transport.ts +0 -941
  219. package/src/inspect-registration.ts +0 -64
  220. package/src/inspect-render.ts +0 -334
  221. package/src/inspect-tool.ts +0 -45
  222. package/src/inspect.ts +0 -769
  223. package/src/integration-controller.ts +0 -98
  224. package/src/limits.ts +0 -75
  225. package/src/orchestration-metrics.ts +0 -116
  226. package/src/outcome.ts +0 -61
  227. package/src/panel-child-group.ts +0 -35
  228. package/src/panel-contract.ts +0 -343
  229. package/src/panel-evidence.ts +0 -59
  230. package/src/panel-execution.ts +0 -769
  231. package/src/panel-failure.ts +0 -56
  232. package/src/panel-planning.ts +0 -175
  233. package/src/panel-presets.ts +0 -3
  234. package/src/panel-prompts.ts +0 -132
  235. package/src/panel-reconciliation.ts +0 -57
  236. package/src/panel-render.ts +0 -103
  237. package/src/parallel-limit-ui.ts +0 -113
  238. package/src/params.ts +0 -278
  239. package/src/peer-communication.ts +0 -352
  240. package/src/peer-transport.ts +0 -49
  241. package/src/persistence.ts +0 -522
  242. package/src/pi-args.ts +0 -43
  243. package/src/pi-invocation.ts +0 -168
  244. package/src/process-control.ts +0 -43
  245. package/src/prompt-resources.ts +0 -38
  246. package/src/prompt-source-safety.ts +0 -48
  247. package/src/protocol.ts +0 -76
  248. package/src/registry-types.ts +0 -204
  249. package/src/registry.ts +0 -1698
  250. package/src/render-common.ts +0 -252
  251. package/src/render.ts +0 -704
  252. package/src/result-contract.ts +0 -431
  253. package/src/retained-semantic-state.ts +0 -100
  254. package/src/rpc-timeout-finalization.ts +0 -207
  255. package/src/rpc-transport-metadata.ts +0 -65
  256. package/src/rpc-transport.ts +0 -1035
  257. package/src/rpc-turn-capture.ts +0 -217
  258. package/src/runner-outcome.ts +0 -31
  259. package/src/runner-result.ts +0 -55
  260. package/src/runner-types.ts +0 -102
  261. package/src/runner-usage.ts +0 -48
  262. package/src/runner.ts +0 -866
  263. package/src/safe-text.ts +0 -67
  264. package/src/semantic-snapshot.ts +0 -214
  265. package/src/session-guidance-contract.ts +0 -399
  266. package/src/settings/inspection.ts +0 -302
  267. package/src/settings/schema.ts +0 -195
  268. package/src/settings-reader.ts +0 -215
  269. package/src/settings.ts +0 -452
  270. package/src/spawn-idempotency.ts +0 -68
  271. package/src/stateful-agent-view.ts +0 -85
  272. package/src/stateful-config.ts +0 -13
  273. package/src/stateful-guidance.ts +0 -29
  274. package/src/stateful-lifecycle.ts +0 -74
  275. package/src/stateful-limit-ui.ts +0 -249
  276. package/src/stateful-limits.ts +0 -96
  277. package/src/stateful-prompt.ts +0 -49
  278. package/src/stateful-registration.ts +0 -1320
  279. package/src/stateful-render.ts +0 -318
  280. package/src/stateful-safety.ts +0 -47
  281. package/src/stateful-tool-params.ts +0 -215
  282. package/src/stateful.ts +0 -12
  283. package/src/subagent-details.ts +0 -43
  284. package/src/subagents-extension.ts +0 -372
  285. package/src/subprocess-transport.ts +0 -145
  286. package/src/supervision.ts +0 -104
  287. package/src/task-path.ts +0 -65
  288. package/src/timeout-checkpoint.ts +0 -305
  289. package/src/timeout-finalization.ts +0 -75
  290. package/src/tool-schema-compatibility.ts +0 -73
  291. package/src/transport-types.ts +0 -74
  292. package/src/transport-ui.ts +0 -135
  293. package/src/transport.ts +0 -43
  294. package/src/turn-budget.ts +0 -109
  295. package/src/usage-format.ts +0 -42
  296. package/src/usage-recording-config.ts +0 -13
  297. package/src/usage-recording-store.ts +0 -183
  298. package/src/usage-recording.ts +0 -478
  299. package/src/verification-harness.ts +0 -516
  300. package/src/verification-policy.ts +0 -67
  301. package/src/verification-receipt.ts +0 -275
  302. package/src/verified-execution-benchmark.ts +0 -86
  303. package/src/verified-execution-contract.ts +0 -191
  304. package/src/verified-execution-schema.ts +0 -32
  305. package/src/work-item-ledger.ts +0 -1404
  306. package/src/work-item-persistence.ts +0 -254
  307. package/src/workflow-completion-controller.ts +0 -397
  308. package/src/workflow-planning.ts +0 -172
  309. package/src/workflow-tree-identity.ts +0 -289
  310. package/src/workflow-ui.ts +0 -69
  311. package/src/workflow-verification.ts +0 -296
  312. package/src/workspace.ts +0 -174
@@ -1,190 +0,0 @@
1
- import type { MessageRenderer, Theme } from "@earendil-works/pi-coding-agent";
2
- import { Box, type Component, Spacer, sliceByColumn, visibleWidth } from "@earendil-works/pi-tui";
3
- import { MAX_TOOL_MESSAGE_BYTES } from "./limits.js";
4
- import {
5
- COLLAPSED_LIST_LIMIT,
6
- expansionHint,
7
- type RenderStatus,
8
- recordList,
9
- recordValue,
10
- safeBlock,
11
- safeLine,
12
- statusBadge,
13
- } from "./render-common.js";
14
-
15
- export const SUBAGENT_COMPLETION_MESSAGE_TYPE = "pi-subagent-completion";
16
-
17
- export const renderCompletionMessage: MessageRenderer = (message, options, theme) => {
18
- const box = new Box(options.outputPad, 1, (text) => theme.bg("customMessageBg", text));
19
- if (options.expanded) {
20
- box.addChild(
21
- new ExactText(
22
- theme.fg("customMessageLabel", theme.bold(`[${SUBAGENT_COMPLETION_MESSAGE_TYPE}]`)),
23
- ),
24
- );
25
- box.addChild(new Spacer(1));
26
- box.addChild(
27
- new ExactText(
28
- safeBlock(messageText(message.content), "(no completion content)", MAX_TOOL_MESSAGE_BYTES),
29
- (text) => theme.fg("customMessageText", text),
30
- ),
31
- );
32
- return box;
33
- }
34
-
35
- box.addChild(new ExactText(collapsedCompletion(message.content, message.details, theme)));
36
- return box;
37
- };
38
-
39
- function collapsedCompletion(contentValue: unknown, detailsValue: unknown, theme: Theme): string {
40
- const content = safeBlock(messageText(contentValue), "", MAX_TOOL_MESSAGE_BYTES);
41
- const details = recordValue(detailsValue) ?? {};
42
- const completions = recordList(details.completions);
43
- if (completions.length > 0 || details.completionCount !== undefined) {
44
- return collapsedBatch(details, completions, theme);
45
- }
46
- return collapsedSingle(content, details, theme);
47
- }
48
-
49
- function collapsedSingle(content: string, details: Record<string, unknown>, theme: Theme): string {
50
- const agent = optionalLine(details.agent) || extractedField(content, "Agent") || "subagent";
51
- const state = optionalLine(details.state) || extractedField(content, "State") || "completed";
52
- const task = optionalLine(details.task) || extractedField(content, "Task");
53
- const payload = payloadPreview(content);
54
- const lines = [
55
- `${statusBadge(theme, renderStatus(state))}${theme.fg("muted", " · ")}${theme.fg("customMessageLabel", theme.bold(agent))}`,
56
- ];
57
- if (task) lines.push(`${theme.fg("muted", "Task: ")}${theme.fg("customMessageText", task)}`);
58
- if (payload) {
59
- lines.push(`${theme.fg("muted", "Payload: ")}${theme.fg("customMessageText", payload)}`);
60
- }
61
- lines.push(expansionHint());
62
- return lines.join("\n");
63
- }
64
-
65
- function collapsedBatch(
66
- details: Record<string, unknown>,
67
- completions: Record<string, unknown>[],
68
- theme: Theme,
69
- ): string {
70
- const declaredCount =
71
- typeof details.completionCount === "number" && Number.isFinite(details.completionCount)
72
- ? Math.max(0, Math.floor(details.completionCount))
73
- : completions.length;
74
- const count = Math.max(declaredCount, completions.length);
75
- const statuses = completions.map((completion) => renderStatus(optionalLine(completion.state)));
76
- const icon = statuses.includes("failed")
77
- ? theme.fg("error", "✗")
78
- : statuses.some((status) => status !== "completed" && status !== "closed")
79
- ? theme.fg("warning", "◐")
80
- : theme.fg("success", "✓");
81
- const lines = [
82
- `${icon} ${theme.fg("customMessageLabel", theme.bold(`${count} subagent completions`))}`,
83
- ];
84
- for (const completion of completions.slice(0, COLLAPSED_LIST_LIMIT)) {
85
- const agent = optionalLine(completion.agent) || "subagent";
86
- const state = optionalLine(completion.state) || "completed";
87
- const task = optionalLine(completion.task);
88
- lines.push(
89
- `${theme.fg("muted", "• ")}${theme.fg("accent", agent)} · ${statusBadge(theme, renderStatus(state))}${task ? theme.fg("dim", ` — ${task}`) : ""}`,
90
- );
91
- }
92
- const visibleCount = Math.min(completions.length, COLLAPSED_LIST_LIMIT);
93
- if (count > visibleCount) {
94
- lines.push(theme.fg("muted", `… ${count - visibleCount} more`));
95
- }
96
- lines.push(expansionHint());
97
- return lines.join("\n");
98
- }
99
-
100
- function messageText(value: unknown): string {
101
- if (typeof value === "string") return value;
102
- if (!Array.isArray(value)) return "";
103
- return value
104
- .flatMap((part) => {
105
- const record = recordValue(part);
106
- return record?.type === "text" && typeof record.text === "string" ? [record.text] : [];
107
- })
108
- .join("\n");
109
- }
110
-
111
- function extractedField(content: string, label: string): string {
112
- const prefix = `${label}:`;
113
- const line = content.split("\n").find((candidate) => candidate.startsWith(prefix));
114
- return line ? safeLine(line.slice(prefix.length), "", 512) : "";
115
- }
116
-
117
- function payloadPreview(content: string): string {
118
- const marker = "\nPayload:\n";
119
- const start = content.indexOf(marker);
120
- if (start < 0) return "";
121
- for (const line of content.slice(start + marker.length).split("\n")) {
122
- const preview = safeLine(line, "", 1024);
123
- if (preview) return preview;
124
- }
125
- return "";
126
- }
127
-
128
- function optionalLine(value: unknown): string {
129
- return typeof value === "string" ? safeLine(value, "", 512) : "";
130
- }
131
-
132
- function renderStatus(state: string): RenderStatus {
133
- switch (state) {
134
- case "failed":
135
- return "failed";
136
- case "cancelled":
137
- return "cancelled";
138
- case "interrupted":
139
- return "interrupted";
140
- case "closed":
141
- return "closed";
142
- case "partial":
143
- case "blocked":
144
- case "needs-input":
145
- case "abstained":
146
- case "stale":
147
- return "warning";
148
- default:
149
- return "completed";
150
- }
151
- }
152
-
153
- class ExactText implements Component {
154
- constructor(
155
- private readonly value: string,
156
- private readonly style: (text: string) => string = (text) => text,
157
- ) {}
158
-
159
- render(width: number): string[] {
160
- const safeWidth = Math.max(1, width);
161
- return this.value
162
- .split("\n")
163
- .flatMap((line) => hardWrapExact(line, safeWidth))
164
- .map(this.style);
165
- }
166
-
167
- invalidate(): void {}
168
- }
169
-
170
- function hardWrapExact(value: string, width: number): string[] {
171
- if (value.length === 0) return [""];
172
- const columns = visibleWidth(value);
173
- if (columns === 0) return [value];
174
- const lines: string[] = [];
175
- let column = 0;
176
- while (column < columns) {
177
- const chunk = sliceByColumn(value, column, width, true);
178
- const chunkWidth = visibleWidth(chunk);
179
- if (chunkWidth > 0) {
180
- lines.push(chunk);
181
- column += chunkWidth;
182
- continue;
183
- }
184
- const oversized = sliceByColumn(value, column, width, false);
185
- const oversizedWidth = visibleWidth(oversized);
186
- lines.push("?".repeat(width));
187
- column += Math.max(1, oversizedWidth);
188
- }
189
- return lines;
190
- }
@@ -1,479 +0,0 @@
1
- import { StringEnum } from "@earendil-works/pi-ai";
2
- import type { ContextEvent } from "@earendil-works/pi-coding-agent";
3
- import { DEFAULT_MAX_CONTEXT_BYTES, truncateUtf8 } from "./limits.js";
4
- import type { AgentLifecycleState, ManagedAgent } from "./registry-types.js";
5
-
6
- export const COMPLETION_REQUIREMENT_MODES = ["background", "required"] as const;
7
- export type CompletionRequirementMode = (typeof COMPLETION_REQUIREMENT_MODES)[number];
8
-
9
- export const CompletionRequirementModeSchema = StringEnum(COMPLETION_REQUIREMENT_MODES, {
10
- description:
11
- "Mark this exact turn as background (default) or required for the parent final answer. Required results are tracked until their exact completion becomes visible, but current Pi versions do not provide a hard pre-display final-answer barrier.",
12
- default: "background",
13
- });
14
-
15
- export const COMPLETION_REQUIREMENT_VERSION = "pi-subagents:completion-requirement:v1" as const;
16
- export const COMPLETION_REQUIREMENT_CONTEXT_TYPE = "pi-subagent-required-completions";
17
- export const COMPLETION_REQUIREMENT_TRANSITION_TYPE = "pi-subagent-required-completion-transition";
18
- export const COMPLETION_REQUIREMENT_TRANSITION_VERSION =
19
- "pi-subagents:completion-requirement-transition:v1" as const;
20
- const MAX_REQUIREMENTS_PER_AGENT = 20;
21
- export const MAX_UNRESOLVED_REQUIRED_COMPLETIONS = 64;
22
-
23
- export type CompletionRequirementState = "pending" | "available" | "visible" | "cancelled";
24
-
25
- export interface CompletionRequirementRecord {
26
- version: typeof COMPLETION_REQUIREMENT_VERSION;
27
- runId: string;
28
- generation: number;
29
- state: CompletionRequirementState;
30
- createdAt: number;
31
- updatedAt: number;
32
- completionId?: string;
33
- terminalState?: AgentLifecycleState;
34
- }
35
-
36
- export function beginCompletionRequirement(
37
- records: readonly CompletionRequirementRecord[] | undefined,
38
- input: { runId: string; generation: number; createdAt: number },
39
- ): CompletionRequirementRecord[] {
40
- const retained = (records ?? []).filter(
41
- (record) => record.runId !== input.runId || record.generation !== input.generation,
42
- );
43
- retained.push({
44
- version: COMPLETION_REQUIREMENT_VERSION,
45
- runId: input.runId,
46
- generation: input.generation,
47
- state: "pending",
48
- createdAt: input.createdAt,
49
- updatedAt: input.createdAt,
50
- });
51
- return retained.slice(-MAX_REQUIREMENTS_PER_AGENT);
52
- }
53
-
54
- export function makeCompletionAvailable(
55
- records: readonly CompletionRequirementRecord[] | undefined,
56
- input: {
57
- runId: string;
58
- generation: number;
59
- completionId: string;
60
- terminalState: AgentLifecycleState;
61
- updatedAt: number;
62
- },
63
- ): CompletionRequirementRecord[] | undefined {
64
- return updateExact(records, input.runId, input.generation, (record) => ({
65
- ...record,
66
- state: "available",
67
- completionId: input.completionId,
68
- terminalState: input.terminalState,
69
- updatedAt: input.updatedAt,
70
- }));
71
- }
72
-
73
- export function makeCompletionVisible(
74
- records: readonly CompletionRequirementRecord[] | undefined,
75
- completionId: string,
76
- updatedAt: number,
77
- ): CompletionRequirementRecord[] | undefined {
78
- if (!records?.some((record) => record.completionId === completionId)) {
79
- return records?.map((record) => ({ ...record }));
80
- }
81
- return records.map((record) =>
82
- record.completionId === completionId
83
- ? { ...record, state: "visible" as const, updatedAt }
84
- : { ...record },
85
- );
86
- }
87
-
88
- export function cancelPendingCompletionRequirements(
89
- records: readonly CompletionRequirementRecord[] | undefined,
90
- terminalState: AgentLifecycleState,
91
- updatedAt: number,
92
- ): CompletionRequirementRecord[] | undefined {
93
- if (!records?.some((record) => record.state === "pending")) {
94
- return records?.map((record) => ({ ...record }));
95
- }
96
- return records.map((record) =>
97
- record.state === "pending"
98
- ? {
99
- ...record,
100
- state: "cancelled" as const,
101
- terminalState,
102
- updatedAt,
103
- }
104
- : { ...record },
105
- );
106
- }
107
-
108
- export function requirementForCompletion(
109
- agent: Pick<ManagedAgent, "completionRequirements">,
110
- completionId: string,
111
- ): CompletionRequirementRecord | undefined {
112
- return agent.completionRequirements?.find((record) => record.completionId === completionId);
113
- }
114
-
115
- export interface BranchCompletionRequirementState {
116
- observedState: boolean;
117
- records: Map<string, CompletionRequirementRecord>;
118
- keys: Set<string>;
119
- }
120
-
121
- export function completionRequirementKey(
122
- record: Pick<CompletionRequirementRecord, "runId" | "generation">,
123
- ): string {
124
- return `${record.runId}\u0000${record.generation}`;
125
- }
126
-
127
- export function completionRequirementsFromBranch(
128
- entries: readonly unknown[],
129
- ): BranchCompletionRequirementState {
130
- const records = new Map<string, CompletionRequirementRecord>();
131
- let observedState = false;
132
- for (const entry of entries) {
133
- if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
134
- const candidate = entry as Record<string, unknown>;
135
- const message =
136
- candidate.type === "message" && candidate.message && typeof candidate.message === "object"
137
- ? (candidate.message as Record<string, unknown>)
138
- : candidate;
139
- if (
140
- message.role === "toolResult" &&
141
- ["subagent_spawn", "subagent_send", "subagent_await", "subagent_manage"].includes(
142
- String(message.toolName),
143
- )
144
- ) {
145
- observedState = true;
146
- const details = message.details;
147
- if (!details || typeof details !== "object" || Array.isArray(details)) continue;
148
- const detailsRecord = details as Record<string, unknown>;
149
- const agents = [
150
- detailsRecord.agent,
151
- ...(Array.isArray(detailsRecord.agents) ? detailsRecord.agents : []),
152
- ];
153
- for (const agent of agents) {
154
- if (!agent || typeof agent !== "object" || Array.isArray(agent)) continue;
155
- const requirements = (agent as Record<string, unknown>).completionRequirements;
156
- if (!Array.isArray(requirements)) continue;
157
- for (const requirement of requirements) {
158
- if (isCompletionRequirementRecord(requirement)) {
159
- records.set(completionRequirementKey(requirement), { ...requirement });
160
- }
161
- }
162
- }
163
- continue;
164
- }
165
- if (
166
- message.role === "custom" &&
167
- message.customType === COMPLETION_REQUIREMENT_TRANSITION_TYPE
168
- ) {
169
- const details = message.details;
170
- if (!details || typeof details !== "object" || Array.isArray(details)) continue;
171
- const detailRecord = details as Record<string, unknown>;
172
- if (detailRecord.version !== COMPLETION_REQUIREMENT_TRANSITION_VERSION) continue;
173
- const requirements = Array.isArray(detailRecord.records) ? detailRecord.records : [];
174
- for (const requirement of requirements) {
175
- if (!isCompletionRequirementRecord(requirement) || requirement.state !== "cancelled") {
176
- continue;
177
- }
178
- observedState = true;
179
- records.set(completionRequirementKey(requirement), { ...requirement });
180
- }
181
- continue;
182
- }
183
- if (message.role !== "custom" || message.customType !== "pi-subagent-completion") continue;
184
- const details = message.details;
185
- if (!details || typeof details !== "object" || Array.isArray(details)) continue;
186
- const detailRecord = details as Record<string, unknown>;
187
- const completionRecords = Array.isArray(detailRecord.completions)
188
- ? detailRecord.completions
189
- : [detailRecord];
190
- for (const completion of completionRecords) {
191
- if (!completion || typeof completion !== "object" || Array.isArray(completion)) continue;
192
- const requirement = (completion as Record<string, unknown>).completionRequirement;
193
- if (!isCompletionRequirementRecord(requirement)) continue;
194
- records.set(completionRequirementKey(requirement), {
195
- ...requirement,
196
- state: "visible",
197
- });
198
- }
199
- }
200
- return { observedState, records, keys: new Set(records.keys()) };
201
- }
202
-
203
- export function pendingRequiredCompletionCount(
204
- agent: Pick<ManagedAgent, "completionRequirements">,
205
- ): number {
206
- return (agent.completionRequirements ?? []).filter(
207
- (record) => record.state === "pending" || record.state === "available",
208
- ).length;
209
- }
210
-
211
- export function createRequiredCompletionTransition(
212
- messages: ContextEvent["messages"],
213
- agents: readonly ManagedAgent[],
214
- ) {
215
- const summarized = leadingSummaryBoundary(messages) > 0;
216
- const state = modelRequirementState(agents);
217
- const visible = completionRequirementsFromBranch(messages).records;
218
- const records = state.records.filter((record) => {
219
- if (record.state !== "cancelled") return false;
220
- const retained = visible.get(completionRequirementKey(record));
221
- if (modelRequirementStateMatches(retained, record)) return false;
222
- return !summarized || retained !== undefined;
223
- });
224
- if (records.length === 0) return undefined;
225
- return {
226
- role: "custom" as const,
227
- customType: COMPLETION_REQUIREMENT_TRANSITION_TYPE,
228
- content: requiredCompletionTransitionContent(records, state.omittedCancelled),
229
- display: false,
230
- details: {
231
- version: COMPLETION_REQUIREMENT_TRANSITION_VERSION,
232
- records: records.map((record) => ({ ...record })),
233
- },
234
- timestamp: 0,
235
- };
236
- }
237
-
238
- export function reconcileRequiredCompletionContext(
239
- messages: ContextEvent["messages"],
240
- agents: readonly ManagedAgent[],
241
- restorationPredecessors: readonly string[] = [],
242
- restoredBoundaryContent?: string,
243
- ): ContextEvent["messages"] {
244
- const existing = messages.filter(isRequiredCompletionContextMessage);
245
- const withoutPrior = messages.filter((message) => !isRequiredCompletionContextMessage(message));
246
- const state = modelRequirementState(agents);
247
- const summaryBoundary = leadingSummaryBoundary(withoutPrior);
248
- const currentContent =
249
- state.records.length > 0 && !hasModelVisibleRequirementState(withoutPrior, state.records)
250
- ? requiredCompletionContextContent(state.records, state.omittedCancelled)
251
- : undefined;
252
- const content = summaryBoundary > 0 ? (restoredBoundaryContent ?? currentContent) : undefined;
253
- let insertionBoundary = summaryBoundary;
254
- while (insertionBoundary < withoutPrior.length) {
255
- const predecessor = withoutPrior[insertionBoundary];
256
- if (
257
- predecessor?.role !== "custom" ||
258
- !restorationPredecessors.includes(predecessor.customType)
259
- ) {
260
- break;
261
- }
262
- insertionBoundary += 1;
263
- }
264
- if (
265
- content !== undefined &&
266
- existing.length === 1 &&
267
- messages[insertionBoundary] === existing[0] &&
268
- existing[0]?.content === content &&
269
- hasCompletionRequirementContextVersion(existing[0])
270
- ) {
271
- return messages;
272
- }
273
- if (existing.length === 0 && content === undefined) return messages;
274
- if (content === undefined) return withoutPrior;
275
- return [
276
- ...withoutPrior.slice(0, insertionBoundary),
277
- {
278
- role: "custom",
279
- customType: COMPLETION_REQUIREMENT_CONTEXT_TYPE,
280
- content,
281
- display: false,
282
- details: { version: COMPLETION_REQUIREMENT_VERSION },
283
- timestamp: 0,
284
- },
285
- ...withoutPrior.slice(insertionBoundary),
286
- ];
287
- }
288
-
289
- interface ModelRequirementRecord {
290
- state: CompletionRequirementState;
291
- runId: string;
292
- generation: number;
293
- terminalState: AgentLifecycleState | undefined;
294
- }
295
-
296
- function modelRequirementState(agents: readonly ManagedAgent[]): {
297
- records: CompletionRequirementRecord[];
298
- omittedCancelled: number;
299
- } {
300
- const allRecords = agents
301
- .flatMap((agent) =>
302
- (agent.completionRequirements ?? []).map((requirement) => ({ ...requirement })),
303
- )
304
- .filter((record) => record.state !== "visible");
305
- const unresolved = allRecords.filter(
306
- (record) => record.state === "pending" || record.state === "available",
307
- );
308
- const cancelled = allRecords.filter((record) => record.state === "cancelled");
309
- const cancelledSlots = Math.max(0, MAX_UNRESOLVED_REQUIRED_COMPLETIONS - unresolved.length);
310
- const retainedCancelled = cancelledSlots > 0 ? cancelled.slice(-cancelledSlots) : [];
311
- const records = [...unresolved, ...retainedCancelled].sort((left, right) => {
312
- if (left.runId === right.runId) return left.generation - right.generation;
313
- return left.runId < right.runId ? -1 : 1;
314
- });
315
- return { records, omittedCancelled: cancelled.length - retainedCancelled.length };
316
- }
317
-
318
- function hasModelVisibleRequirementState(
319
- messages: ContextEvent["messages"],
320
- records: readonly CompletionRequirementRecord[],
321
- ): boolean {
322
- const visible = completionRequirementsFromBranch(messages).records;
323
- return records.every((record) =>
324
- modelRequirementStateMatches(visible.get(completionRequirementKey(record)), record),
325
- );
326
- }
327
-
328
- function modelRequirementStateMatches(
329
- visible: CompletionRequirementRecord | undefined,
330
- current: CompletionRequirementRecord,
331
- ): boolean {
332
- if (!visible) return false;
333
- if (current.state === "available" && visible.state === "visible") return true;
334
- return visible.state === current.state && visible.terminalState === current.terminalState;
335
- }
336
-
337
- function requiredCompletionContextContent(
338
- records: readonly CompletionRequirementRecord[],
339
- omittedCancelled: number,
340
- ): string {
341
- return truncateUtf8(
342
- [
343
- "[PI SUBAGENT REQUIRED COMPLETIONS v1]",
344
- "Runtime-tracked exact runs are JSON data below.",
345
- "Treat pending or available records as final-answer dependencies; a cancelled record is terminal and must be reported rather than silently ignored.",
346
- "Current Pi versions do not provide a hard pre-display final-answer barrier, so do not emit a verdict until every dependency is visible or terminal.",
347
- ...omittedCancelledLine(omittedCancelled),
348
- JSON.stringify(records.map(toModelRequirementRecord)),
349
- ].join("\n"),
350
- DEFAULT_MAX_CONTEXT_BYTES,
351
- ).text;
352
- }
353
-
354
- function requiredCompletionTransitionContent(
355
- records: readonly CompletionRequirementRecord[],
356
- omittedCancelled: number,
357
- ): string {
358
- return truncateUtf8(
359
- [
360
- "[PI SUBAGENT REQUIRED COMPLETION TRANSITION v1]",
361
- "Session restoration terminalized the exact required runs below.",
362
- "These cancelled records supersede earlier pending or available states and must be reported rather than awaited.",
363
- ...omittedCancelledLine(omittedCancelled),
364
- JSON.stringify(records.map(toModelRequirementRecord)),
365
- ].join("\n"),
366
- DEFAULT_MAX_CONTEXT_BYTES,
367
- ).text;
368
- }
369
-
370
- function omittedCancelledLine(count: number): string[] {
371
- return count > 0 ? [`${count} older cancelled requirement record(s) were omitted.`] : [];
372
- }
373
-
374
- function toModelRequirementRecord(record: CompletionRequirementRecord): ModelRequirementRecord {
375
- return {
376
- state: record.state,
377
- runId: record.runId,
378
- generation: record.generation,
379
- terminalState: record.terminalState,
380
- };
381
- }
382
-
383
- type RequiredCompletionContextMessage = Extract<
384
- ContextEvent["messages"][number],
385
- { role: "custom" }
386
- > & { content: string };
387
-
388
- function isRequiredCompletionContextMessage(
389
- message: ContextEvent["messages"][number],
390
- ): message is RequiredCompletionContextMessage {
391
- return message.role === "custom" && message.customType === COMPLETION_REQUIREMENT_CONTEXT_TYPE;
392
- }
393
-
394
- function hasCompletionRequirementContextVersion(
395
- message: RequiredCompletionContextMessage,
396
- ): boolean {
397
- return (
398
- typeof message.details === "object" &&
399
- message.details !== null &&
400
- !Array.isArray(message.details) &&
401
- (message.details as Record<string, unknown>).version === COMPLETION_REQUIREMENT_VERSION
402
- );
403
- }
404
-
405
- function leadingSummaryBoundary(messages: ContextEvent["messages"]): number {
406
- let index = 0;
407
- while (index < messages.length) {
408
- const role = messages[index]?.role;
409
- if (role !== "compactionSummary" && role !== "branchSummary") break;
410
- index += 1;
411
- }
412
- return index;
413
- }
414
-
415
- export function isCompletionRequirementRecord(
416
- value: unknown,
417
- ): value is CompletionRequirementRecord {
418
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
419
- const record = value as Record<string, unknown>;
420
- const state = String(record.state);
421
- const hasCompletion = typeof record.completionId === "string" && record.completionId.length > 0;
422
- const hasTerminalState = isAgentLifecycleState(record.terminalState);
423
- const transitionShapeValid =
424
- state === "pending"
425
- ? record.completionId === undefined && record.terminalState === undefined
426
- : state === "available" || state === "visible"
427
- ? hasCompletion && hasTerminalState
428
- : state === "cancelled" && record.completionId === undefined && hasTerminalState;
429
- return (
430
- transitionShapeValid &&
431
- record.version === COMPLETION_REQUIREMENT_VERSION &&
432
- typeof record.runId === "string" &&
433
- record.runId.length > 0 &&
434
- record.runId.length <= 256 &&
435
- typeof record.generation === "number" &&
436
- Number.isSafeInteger(record.generation) &&
437
- record.generation >= 1 &&
438
- ["pending", "available", "visible", "cancelled"].includes(state) &&
439
- typeof record.createdAt === "number" &&
440
- Number.isFinite(record.createdAt) &&
441
- typeof record.updatedAt === "number" &&
442
- Number.isFinite(record.updatedAt) &&
443
- record.updatedAt >= record.createdAt &&
444
- (record.completionId === undefined ||
445
- (typeof record.completionId === "string" && record.completionId.length <= 256)) &&
446
- (record.terminalState === undefined || isAgentLifecycleState(record.terminalState))
447
- );
448
- }
449
-
450
- function updateExact(
451
- records: readonly CompletionRequirementRecord[] | undefined,
452
- runId: string,
453
- generation: number,
454
- update: (record: CompletionRequirementRecord) => CompletionRequirementRecord,
455
- ): CompletionRequirementRecord[] | undefined {
456
- if (!records?.some((record) => record.runId === runId && record.generation === generation)) {
457
- return records?.map((record) => ({ ...record }));
458
- }
459
- return records.map((record) =>
460
- record.runId === runId && record.generation === generation ? update(record) : { ...record },
461
- );
462
- }
463
-
464
- function isAgentLifecycleState(value: unknown): value is AgentLifecycleState {
465
- return [
466
- "starting",
467
- "running",
468
- "idle",
469
- "completed",
470
- "partial",
471
- "blocked",
472
- "needs-input",
473
- "abstained",
474
- "stale",
475
- "interrupted",
476
- "failed",
477
- "closed",
478
- ].includes(String(value));
479
- }
@@ -1,24 +0,0 @@
1
- import type { ManagedAgent, PersistedAgentCompletion } from "./registry-types.js";
2
- import { ROOT_TASK_PATH } from "./task-path.js";
3
-
4
- export type CompletionRecipient = Pick<PersistedAgentCompletion, "recipientId" | "recipientPath">;
5
-
6
- export function resolveCompletionRecipient(
7
- agent: Pick<ManagedAgent, "id" | "parentId">,
8
- getAgent: (
9
- id: string,
10
- ) => Pick<ManagedAgent, "id" | "parentId" | "state" | "taskPath"> | undefined,
11
- ): CompletionRecipient {
12
- const visited = new Set([agent.id]);
13
- let parentId = agent.parentId;
14
- while (parentId && !visited.has(parentId)) {
15
- visited.add(parentId);
16
- const parent = getAgent(parentId);
17
- if (!parent) break;
18
- if (parent.state !== "closed") {
19
- return { recipientId: parent.id, recipientPath: parent.taskPath ?? parent.id };
20
- }
21
- parentId = parent.parentId;
22
- }
23
- return { recipientId: "root", recipientPath: ROOT_TASK_PATH };
24
- }