@oyasmi/pipiclaw 0.9.4-beta.2 → 0.9.5-beta.2

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 (405) hide show
  1. package/README.en.md +28 -22
  2. package/README.md +27 -21
  3. package/dist/agent/builtin-commands.d.ts +7 -2
  4. package/dist/agent/builtin-commands.js +19 -23
  5. package/dist/agent/channel-runner.d.ts +13 -13
  6. package/dist/agent/channel-runner.js +93 -76
  7. package/dist/agent/maintenance-context.d.ts +6 -5
  8. package/dist/agent/maintenance-context.js +15 -15
  9. package/dist/agent/prompt/manifest.js +1 -1
  10. package/dist/agent/prompt/resources.d.ts +1 -1
  11. package/dist/agent/prompt/resources.js +1 -1
  12. package/dist/agent/prompt/sections.js +4 -4
  13. package/dist/agent/runner-factory.d.ts +6 -6
  14. package/dist/agent/runner-factory.js +6 -7
  15. package/dist/agent/session/compaction-input.d.ts +6 -0
  16. package/dist/agent/session/compaction-input.js +75 -0
  17. package/dist/agent/session/compaction-snapshot.d.ts +30 -0
  18. package/dist/agent/session/compaction-snapshot.js +154 -0
  19. package/dist/agent/session/compaction-summary.d.ts +39 -0
  20. package/dist/agent/session/compaction-summary.js +158 -0
  21. package/dist/agent/session/compaction.d.ts +35 -0
  22. package/dist/agent/session/compaction.js +294 -0
  23. package/dist/agent/session/context-input.d.ts +15 -0
  24. package/dist/agent/session/context-input.js +82 -0
  25. package/dist/agent/session/context-snapshot.d.ts +11 -0
  26. package/dist/agent/session/context-snapshot.js +72 -0
  27. package/dist/agent/session/event-guards.d.ts +2 -0
  28. package/dist/agent/session/event-guards.js +4 -0
  29. package/dist/agent/session/request-tools.d.ts +3 -0
  30. package/dist/agent/session/request-tools.js +20 -0
  31. package/dist/agent/session/session-adapter.d.ts +2 -1
  32. package/dist/agent/session/session-adapter.js +6 -3
  33. package/dist/agent/session/session-events.d.ts +5 -4
  34. package/dist/agent/session/session-events.js +46 -59
  35. package/dist/agent/session/session-host.d.ts +29 -41
  36. package/dist/agent/session/session-host.js +86 -69
  37. package/dist/agent/session/settings-diagnostics.d.ts +5 -0
  38. package/dist/agent/session/settings-diagnostics.js +21 -0
  39. package/dist/agent/status-render.js +5 -2
  40. package/dist/{runtime → agent}/stop-watchdog.d.ts +3 -1
  41. package/dist/{runtime → agent}/stop-watchdog.js +7 -3
  42. package/dist/agent/turn/progress-formatter.d.ts +1 -3
  43. package/dist/agent/turn/progress-formatter.js +3 -22
  44. package/dist/agent/turn/task-digest.d.ts +4 -2
  45. package/dist/agent/turn/task-digest.js +7 -4
  46. package/dist/agent/turn/turn-context.d.ts +11 -7
  47. package/dist/agent/turn/turn-context.js +26 -18
  48. package/dist/agent/turn/turn-finish.d.ts +17 -5
  49. package/dist/agent/turn/turn-finish.js +51 -77
  50. package/dist/agent/turn/turn-input.d.ts +2 -2
  51. package/dist/agent/turn/turn-input.js +4 -3
  52. package/dist/agent/turn/turn-output.d.ts +19 -0
  53. package/dist/agent/turn/turn-output.js +41 -0
  54. package/dist/agent/turn/turn-pipeline.d.ts +11 -8
  55. package/dist/agent/turn/turn-pipeline.js +54 -55
  56. package/dist/agent/turn/turn-prompt.d.ts +1 -1
  57. package/dist/agent/turn/turn-recovery.d.ts +11 -10
  58. package/dist/agent/turn/turn-recovery.js +14 -29
  59. package/dist/agent/types.d.ts +31 -12
  60. package/dist/agent/types.js +2 -1
  61. package/dist/app/auth-command.js +1 -1
  62. package/dist/app/home.js +31 -15
  63. package/dist/channel/active-session-store.d.ts +14 -12
  64. package/dist/channel/active-session-store.js +29 -25
  65. package/dist/channel/attachments.d.ts +25 -0
  66. package/dist/channel/attachments.js +56 -0
  67. package/dist/channel/channel-context.d.ts +87 -96
  68. package/dist/channel/channel-context.js +1 -66
  69. package/dist/channel/channel-event.d.ts +51 -41
  70. package/dist/channel/channel-event.js +6 -11
  71. package/dist/channel/channel-id.d.ts +22 -0
  72. package/dist/channel/channel-id.js +13 -0
  73. package/dist/channel/channel-index.d.ts +17 -34
  74. package/dist/channel/channel-index.js +41 -80
  75. package/dist/channel/config.d.ts +10 -0
  76. package/dist/channel/config.js +55 -0
  77. package/dist/channel/ingress.d.ts +101 -0
  78. package/dist/channel/ingress.js +5 -0
  79. package/dist/channel/store.d.ts +13 -15
  80. package/dist/channel/store.js +21 -25
  81. package/dist/channel/transport.d.ts +99 -0
  82. package/dist/channel/turn-context.d.ts +23 -0
  83. package/dist/channel/turn-context.js +1 -0
  84. package/dist/commands/catalog.d.ts +4 -7
  85. package/dist/commands/catalog.js +24 -31
  86. package/dist/commands/router.d.ts +23 -12
  87. package/dist/commands/router.js +22 -24
  88. package/dist/config/settings.d.ts +5 -4
  89. package/dist/desk/bindings.d.ts +6 -0
  90. package/dist/desk/bindings.js +105 -0
  91. package/dist/desk/commands.d.ts +81 -0
  92. package/dist/desk/commands.js +145 -0
  93. package/dist/desk/default.d.ts +4 -0
  94. package/dist/desk/default.js +11 -0
  95. package/dist/desk/paths.d.ts +41 -0
  96. package/dist/desk/paths.js +81 -0
  97. package/dist/desk/registry.d.ts +17 -0
  98. package/dist/desk/registry.js +191 -0
  99. package/dist/desk/startup-error.d.ts +4 -0
  100. package/dist/desk/startup-error.js +7 -0
  101. package/dist/desk/types.d.ts +72 -0
  102. package/dist/desk/types.js +7 -0
  103. package/dist/dingtalk/bot.d.ts +18 -35
  104. package/dist/dingtalk/bot.js +21 -204
  105. package/dist/dingtalk/channel-ids.d.ts +15 -0
  106. package/dist/dingtalk/channel-ids.js +39 -0
  107. package/dist/dingtalk/config.d.ts +6 -3
  108. package/dist/dingtalk/config.js +13 -25
  109. package/dist/dingtalk/connection.d.ts +1 -0
  110. package/dist/dingtalk/connection.js +5 -4
  111. package/dist/dingtalk/conversation-meta.d.ts +10 -5
  112. package/dist/dingtalk/conversation-meta.js +72 -50
  113. package/dist/dingtalk/delivery.d.ts +30 -14
  114. package/dist/dingtalk/delivery.js +189 -62
  115. package/dist/dingtalk/inbound-media.d.ts +2 -18
  116. package/dist/dingtalk/inbound-media.js +0 -53
  117. package/dist/dingtalk/inbound.d.ts +10 -11
  118. package/dist/dingtalk/inbound.js +12 -19
  119. package/dist/dingtalk/media.d.ts +9 -11
  120. package/dist/dingtalk/media.js +18 -31
  121. package/dist/dingtalk/progress.d.ts +8 -0
  122. package/dist/dingtalk/progress.js +20 -0
  123. package/dist/dingtalk/response-mode.d.ts +13 -0
  124. package/dist/dingtalk/response-mode.js +31 -0
  125. package/dist/dingtalk/transport.d.ts +47 -0
  126. package/dist/dingtalk/transport.js +71 -0
  127. package/dist/events/commands.d.ts +7 -2
  128. package/dist/events/commands.js +40 -22
  129. package/dist/events/pre-action-error.d.ts +10 -0
  130. package/dist/events/pre-action-error.js +10 -0
  131. package/dist/events/types.d.ts +20 -2
  132. package/dist/events/watcher.d.ts +14 -7
  133. package/dist/events/watcher.js +49 -26
  134. package/dist/index.d.ts +4 -2
  135. package/dist/jobs/completion-wake.d.ts +14 -0
  136. package/dist/jobs/completion-wake.js +36 -0
  137. package/dist/jobs/manager.d.ts +27 -22
  138. package/dist/jobs/manager.js +58 -91
  139. package/dist/jobs/record.d.ts +2 -0
  140. package/dist/jobs/record.js +2 -0
  141. package/dist/log.d.ts +0 -1
  142. package/dist/log.js +1 -1
  143. package/dist/main.js +10 -3
  144. package/dist/memory/boundary-work.d.ts +17 -0
  145. package/dist/memory/boundary-work.js +162 -0
  146. package/dist/memory/commands.d.ts +4 -3
  147. package/dist/memory/commands.js +16 -16
  148. package/dist/memory/desk-memory-queue.d.ts +18 -0
  149. package/dist/memory/desk-memory-queue.js +33 -0
  150. package/dist/memory/index-budget.d.ts +3 -3
  151. package/dist/memory/index-budget.js +3 -3
  152. package/dist/memory/journal.d.ts +6 -6
  153. package/dist/memory/journal.js +14 -14
  154. package/dist/memory/lifecycle.d.ts +14 -21
  155. package/dist/memory/lifecycle.js +73 -103
  156. package/dist/memory/maintenance-state.d.ts +14 -15
  157. package/dist/memory/maintenance-state.js +43 -42
  158. package/dist/memory/reflect-job.d.ts +5 -4
  159. package/dist/memory/reflect-job.js +21 -15
  160. package/dist/memory/reflect.d.ts +2 -1
  161. package/dist/memory/reflect.js +13 -12
  162. package/dist/memory/render.d.ts +1 -1
  163. package/dist/memory/render.js +2 -2
  164. package/dist/memory/review-log.d.ts +4 -4
  165. package/dist/memory/review-log.js +5 -5
  166. package/dist/memory/scheduler.d.ts +12 -19
  167. package/dist/memory/scheduler.js +28 -64
  168. package/dist/memory/session-corpus.d.ts +4 -1
  169. package/dist/memory/session-corpus.js +70 -29
  170. package/dist/memory/session-search.d.ts +11 -3
  171. package/dist/memory/session-search.js +14 -11
  172. package/dist/memory/sidecar-worker.d.ts +1 -0
  173. package/dist/memory/sidecar-worker.js +57 -76
  174. package/dist/memory/source-window.d.ts +0 -6
  175. package/dist/memory/source-window.js +0 -20
  176. package/dist/memory/store.d.ts +12 -12
  177. package/dist/memory/store.js +44 -44
  178. package/dist/paths.d.ts +2 -0
  179. package/dist/paths.js +2 -0
  180. package/dist/playbooks/agent-delegation.md +16 -16
  181. package/dist/playbooks/background-jobs.md +5 -3
  182. package/dist/playbooks/event-scheduling.md +7 -5
  183. package/dist/playbooks/memory-and-learning.md +16 -12
  184. package/dist/playbooks/outbound-media.md +1 -1
  185. package/dist/playbooks/runtime-orientation.md +35 -23
  186. package/dist/playbooks/task-lead.md +13 -11
  187. package/dist/runtime/bootstrap.d.ts +36 -13
  188. package/dist/runtime/bootstrap.js +310 -138
  189. package/dist/runtime/channel-queue.d.ts +23 -0
  190. package/dist/{dingtalk → runtime}/channel-queue.js +20 -9
  191. package/dist/runtime/daemon-lock.d.ts +12 -0
  192. package/dist/runtime/daemon-lock.js +28 -0
  193. package/dist/runtime/desk-runtime.d.ts +131 -0
  194. package/dist/runtime/desk-runtime.js +402 -0
  195. package/dist/runtime/durable-dispatch.d.ts +11 -5
  196. package/dist/runtime/durable-dispatch.js +20 -8
  197. package/dist/runtime/inbound-images.d.ts +32 -10
  198. package/dist/runtime/inbound-images.js +95 -21
  199. package/dist/runtime/ingress-busy.d.ts +26 -0
  200. package/dist/runtime/ingress-busy.js +211 -0
  201. package/dist/runtime/ingress-commands.d.ts +7 -0
  202. package/dist/runtime/ingress-commands.js +162 -0
  203. package/dist/runtime/ingress-deps.d.ts +62 -0
  204. package/dist/runtime/ingress-deps.js +1 -0
  205. package/dist/runtime/ingress.d.ts +22 -0
  206. package/dist/runtime/ingress.js +376 -0
  207. package/dist/runtime/request-execution.d.ts +19 -0
  208. package/dist/runtime/request-execution.js +88 -0
  209. package/dist/runtime/shutdown.d.ts +13 -5
  210. package/dist/runtime/shutdown.js +10 -4
  211. package/dist/runtime/task-driver.d.ts +38 -22
  212. package/dist/runtime/task-driver.js +142 -116
  213. package/dist/runtime/task-spawn.d.ts +4 -4
  214. package/dist/runtime/task-spawn.js +6 -5
  215. package/dist/runtime/task-wake.d.ts +6 -4
  216. package/dist/runtime/task-wake.js +7 -7
  217. package/dist/runtime/transports.d.ts +32 -0
  218. package/dist/runtime/transports.js +101 -0
  219. package/dist/runtime/turn-run.d.ts +18 -9
  220. package/dist/runtime/turn-run.js +302 -71
  221. package/dist/runtime/wake-coalescing.d.ts +11 -3
  222. package/dist/runtime/wake-coalescing.js +10 -0
  223. package/dist/security/config.js +5 -10
  224. package/dist/security/logger.js +1 -1
  225. package/dist/security/path-guard.js +7 -63
  226. package/dist/security/types.d.ts +27 -30
  227. package/dist/security/types.js +0 -1
  228. package/dist/shared/atomic-file.d.ts +2 -0
  229. package/dist/shared/atomic-file.js +14 -1
  230. package/dist/shared/file-lock.d.ts +35 -0
  231. package/dist/shared/file-lock.js +195 -0
  232. package/dist/shared/with-timeout.d.ts +2 -0
  233. package/dist/shared/with-timeout.js +21 -0
  234. package/dist/skills/loader.d.ts +1 -1
  235. package/dist/skills/loader.js +2 -2
  236. package/dist/skills/workspace.js +2 -2
  237. package/dist/subagents/completion-wake.d.ts +11 -2
  238. package/dist/subagents/completion-wake.js +22 -9
  239. package/dist/subagents/discovery.js +1 -1
  240. package/dist/subagents/dispatch.d.ts +0 -10
  241. package/dist/subagents/dispatch.js +10 -28
  242. package/dist/subagents/external/dispatch.js +1 -1
  243. package/dist/subagents/external/run.d.ts +1 -1
  244. package/dist/subagents/external/run.js +3 -3
  245. package/dist/subagents/internal/run.js +1 -1
  246. package/dist/subagents/internal/worker.js +6 -14
  247. package/dist/subagents/run-archive.d.ts +11 -0
  248. package/dist/subagents/run-archive.js +49 -0
  249. package/dist/subagents/run-record.d.ts +9 -8
  250. package/dist/subagents/run-record.js +3 -3
  251. package/dist/subagents/run-registry.d.ts +5 -3
  252. package/dist/subagents/run-registry.js +22 -45
  253. package/dist/subagents/runs.d.ts +23 -13
  254. package/dist/subagents/runs.js +75 -82
  255. package/dist/subagents/task-envelope.js +9 -11
  256. package/dist/subagents/types.d.ts +6 -5
  257. package/dist/tasks/board.d.ts +1 -1
  258. package/dist/tasks/board.js +2 -2
  259. package/dist/tasks/bound-work.d.ts +2 -2
  260. package/dist/tasks/bound-work.js +7 -7
  261. package/dist/tasks/brief.d.ts +1 -1
  262. package/dist/tasks/brief.js +9 -9
  263. package/dist/tasks/commands.d.ts +11 -2
  264. package/dist/tasks/commands.js +66 -41
  265. package/dist/tasks/contract.d.ts +0 -2
  266. package/dist/tasks/contract.js +1 -3
  267. package/dist/tasks/create.d.ts +3 -1
  268. package/dist/tasks/create.js +10 -4
  269. package/dist/tasks/frontmatter.d.ts +6 -2
  270. package/dist/tasks/frontmatter.js +10 -10
  271. package/dist/tasks/loop-log.d.ts +7 -13
  272. package/dist/tasks/loop-log.js +14 -17
  273. package/dist/tasks/mutation-lock.d.ts +7 -5
  274. package/dist/tasks/mutation-lock.js +32 -9
  275. package/dist/tasks/session-path.d.ts +3 -3
  276. package/dist/tasks/session-path.js +5 -5
  277. package/dist/tasks/steer.d.ts +5 -5
  278. package/dist/tasks/steer.js +42 -40
  279. package/dist/tasks/store.d.ts +11 -11
  280. package/dist/tasks/store.js +32 -29
  281. package/dist/tools/bash.d.ts +5 -5
  282. package/dist/tools/bash.js +19 -18
  283. package/dist/tools/contract/names.d.ts +7 -0
  284. package/dist/tools/contract/names.js +22 -0
  285. package/dist/tools/edit.js +1 -1
  286. package/dist/tools/event-manage.d.ts +3 -1
  287. package/dist/tools/event-manage.js +34 -33
  288. package/dist/tools/glob.js +5 -5
  289. package/dist/tools/grep.js +2 -2
  290. package/dist/tools/index.d.ts +9 -8
  291. package/dist/tools/index.js +12 -16
  292. package/dist/tools/job.d.ts +4 -2
  293. package/dist/tools/job.js +11 -8
  294. package/dist/tools/memory-manage.d.ts +5 -3
  295. package/dist/tools/memory-manage.js +24 -24
  296. package/dist/tools/read.js +1 -1
  297. package/dist/tools/registry.d.ts +12 -8
  298. package/dist/tools/registry.js +13 -9
  299. package/dist/tools/send-media.d.ts +2 -2
  300. package/dist/tools/send-media.js +3 -3
  301. package/dist/tools/session-search.d.ts +3 -1
  302. package/dist/tools/session-search.js +8 -6
  303. package/dist/tools/subagent-manage.d.ts +2 -8
  304. package/dist/tools/subagent-manage.js +19 -15
  305. package/dist/tools/subagent.js +1 -1
  306. package/dist/tools/task-manage/create.js +1 -1
  307. package/dist/tools/task-manage/factory.js +2 -2
  308. package/dist/tools/task-manage/lifecycle.js +3 -1
  309. package/dist/tools/task-manage/log-view.js +2 -2
  310. package/dist/tools/task-manage/shared.js +3 -3
  311. package/dist/tools/task-manage/step-end.js +3 -3
  312. package/dist/tools/task-manage/types.d.ts +8 -3
  313. package/dist/tools/web-cache.d.ts +3 -3
  314. package/dist/tools/web-cache.js +12 -12
  315. package/dist/tools/web-fetch.d.ts +2 -2
  316. package/dist/tools/web-fetch.js +7 -7
  317. package/dist/tools/write-content.js +1 -1
  318. package/dist/tui/cli.d.ts +17 -5
  319. package/dist/tui/cli.js +90 -27
  320. package/dist/tui/client.d.ts +26 -0
  321. package/dist/tui/client.js +157 -0
  322. package/dist/tui/colors.d.ts +0 -1
  323. package/dist/tui/colors.js +0 -1
  324. package/dist/tui/commands.d.ts +10 -51
  325. package/dist/tui/commands.js +16 -39
  326. package/dist/tui/frontend.d.ts +2 -2
  327. package/dist/tui/frontend.js +2 -2
  328. package/dist/tui/pitui-frontend.d.ts +0 -2
  329. package/dist/tui/pitui-frontend.js +1 -6
  330. package/dist/tui/render.d.ts +62 -0
  331. package/dist/tui/render.js +123 -0
  332. package/dist/tui/session.d.ts +92 -0
  333. package/dist/tui/session.js +317 -0
  334. package/dist/usage/ledger.d.ts +5 -0
  335. package/dist/usage/ledger.js +2 -0
  336. package/dist/usage/render.d.ts +6 -1
  337. package/dist/usage/render.js +18 -13
  338. package/dist/webapi/auth.d.ts +13 -0
  339. package/dist/webapi/auth.js +29 -0
  340. package/dist/webapi/config.d.ts +29 -0
  341. package/dist/webapi/config.js +100 -0
  342. package/dist/webapi/errors.d.ts +39 -0
  343. package/dist/webapi/errors.js +32 -0
  344. package/dist/webapi/http.d.ts +25 -0
  345. package/dist/webapi/http.js +4 -0
  346. package/dist/webapi/ids.d.ts +9 -0
  347. package/dist/webapi/ids.js +20 -0
  348. package/dist/webapi/input.d.ts +17 -0
  349. package/dist/webapi/input.js +229 -0
  350. package/dist/webapi/items.d.ts +37 -0
  351. package/dist/webapi/items.js +48 -0
  352. package/dist/webapi/key-command.d.ts +2 -0
  353. package/dist/webapi/key-command.js +110 -0
  354. package/dist/webapi/limits.d.ts +47 -0
  355. package/dist/webapi/limits.js +48 -0
  356. package/dist/webapi/request-policy.d.ts +17 -0
  357. package/dist/webapi/request-policy.js +160 -0
  358. package/dist/webapi/response-record.d.ts +68 -0
  359. package/dist/webapi/response-record.js +58 -0
  360. package/dist/webapi/response-state.d.ts +90 -0
  361. package/dist/webapi/response-state.js +347 -0
  362. package/dist/webapi/routes/conversations.d.ts +8 -0
  363. package/dist/webapi/routes/conversations.js +80 -0
  364. package/dist/webapi/routes/models.d.ts +3 -0
  365. package/dist/webapi/routes/models.js +12 -0
  366. package/dist/webapi/routes/responses.d.ts +8 -0
  367. package/dist/webapi/routes/responses.js +118 -0
  368. package/dist/webapi/routes/websocket.d.ts +9 -0
  369. package/dist/webapi/routes/websocket.js +328 -0
  370. package/dist/webapi/server.d.ts +24 -0
  371. package/dist/webapi/server.js +229 -0
  372. package/dist/webapi/service.d.ts +130 -0
  373. package/dist/webapi/service.js +588 -0
  374. package/dist/webapi/store.d.ts +46 -0
  375. package/dist/webapi/store.js +245 -0
  376. package/dist/webapi/stream.d.ts +13 -0
  377. package/dist/webapi/stream.js +76 -0
  378. package/dist/webapi/transport.d.ts +43 -0
  379. package/dist/webapi/transport.js +100 -0
  380. package/package.json +9 -2
  381. package/dist/channel/channel-paths.d.ts +0 -16
  382. package/dist/channel/channel-paths.js +0 -53
  383. package/dist/channel/commands.d.ts +0 -32
  384. package/dist/channel/commands.js +0 -109
  385. package/dist/channel/project-scope-store.d.ts +0 -51
  386. package/dist/channel/project-scope-store.js +0 -112
  387. package/dist/dingtalk/channel-queue.d.ts +0 -19
  388. package/dist/dingtalk/handler.d.ts +0 -90
  389. package/dist/memory/channel-maintenance-queue.d.ts +0 -5
  390. package/dist/memory/channel-maintenance-queue.js +0 -8
  391. package/dist/runtime/task-migration.d.ts +0 -30
  392. package/dist/runtime/task-migration.js +0 -465
  393. package/dist/runtime/turn-handler.d.ts +0 -47
  394. package/dist/runtime/turn-handler.js +0 -318
  395. package/dist/security/project-scope.d.ts +0 -45
  396. package/dist/security/project-scope.js +0 -105
  397. package/dist/tui/app.d.ts +0 -16
  398. package/dist/tui/app.js +0 -166
  399. package/dist/tui/terminal-context.d.ts +0 -27
  400. package/dist/tui/terminal-context.js +0 -84
  401. package/dist/tui/terminal-media-sender.d.ts +0 -9
  402. package/dist/tui/terminal-media-sender.js +0 -15
  403. package/dist/tui/turn-controller.d.ts +0 -64
  404. package/dist/tui/turn-controller.js +0 -311
  405. /package/dist/{dingtalk/handler.js → channel/transport.js} +0 -0
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Delegation dispatch, shared by `subagent` and `subagent_inline` (spec 046 D2.5): prepare the run
3
- * (working directory, project boundary, artifact directory), admit it (verify rules, workspace write
3
+ * (working directory, artifact directory), admit it (verify rules, workspace write
4
4
  * lease), then fork to the internal or external runtime.
5
5
  */
6
6
  import { realpathSync, statSync } from "node:fs";
7
7
  import { mkdir } from "node:fs/promises";
8
8
  import { join, resolve } from "node:path";
9
+ import { getSubAgentArtifactsDir } from "../desk/paths.js";
9
10
  import { RecoverableToolError } from "../shared/recoverable-error.js";
10
11
  import { findTaskItem, parseTaskItems } from "../tasks/contract.js";
11
12
  import { readStoredTask } from "../tasks/store.js";
@@ -18,12 +19,12 @@ const TASK_ID_PATTERN = /^[A-Za-z0-9._-]+$/;
18
19
  function safeRunSegment(value) {
19
20
  return value.replace(/[^A-Za-z0-9._-]/g, "-").slice(0, 48) || "run";
20
21
  }
21
- function getSubAgentArtifactsRoot(channelDir) {
22
- return join(channelDir, "subagent-artifacts");
22
+ function getSubAgentArtifactsRoot(deskDir) {
23
+ return getSubAgentArtifactsDir(deskDir);
23
24
  }
24
25
  /** Every run gets its own artifact directory (spec 032 D4), independent of `returns` mode. */
25
- async function prepareArtifactDir(channelDir, runId) {
26
- const artifactDir = join(getSubAgentArtifactsRoot(channelDir), safeRunSegment(runId));
26
+ async function prepareArtifactDir(deskDir, runId) {
27
+ const artifactDir = join(getSubAgentArtifactsRoot(deskDir), safeRunSegment(runId));
27
28
  await mkdir(artifactDir, { recursive: true });
28
29
  return artifactDir;
29
30
  }
@@ -44,27 +45,11 @@ function realpathOrSelf(path) {
44
45
  return path;
45
46
  }
46
47
  }
47
- /**
48
- * D6.2's boundary check, hardened against symlinks (review 2026-08-23 §2.3): a plain
49
- * `resolve()` + string-prefix comparison only judges the *requested* path, so `<projectRoot
50
- * >/link -> /somewhere/else` passes the check and then everything downstream — the internal
51
- * agent's own `securityContext.projectRoot`, an external process's `cwd` (which bypasses the
52
- * path guard entirely) — trusts that escaped target. Comparing realpaths closes it, matching
53
- * `project-scope.ts` and `workspaceLeaseKey`, the two other places in the tree that already do
54
- * this.
55
- */
56
- export function assertWithinProjectBoundary(target, base, requested) {
57
- const realBase = realpathOrSelf(base);
58
- const realTarget = realpathOrSelf(target);
59
- if (realTarget !== realBase && !realTarget.startsWith(`${realBase}/`)) {
60
- throw new RecoverableToolError(`workingDirectory "${requested}" must be inside the project root (${base}).`);
61
- }
62
- }
63
48
  function resolveRunWorkingDirectory(requested, options) {
64
49
  const base = resolve(options.workingDirectory ?? process.cwd());
65
50
  const trimmed = requested?.trim();
66
- // Resolve the project root once as well. Returning an alias here would leave the later lease,
67
- // executor, subject hash, and external cwd exposed to a symlink swap after admission.
51
+ // Canonicalize once: returning an alias here would leave the later lease, executor, subject
52
+ // hash, and external cwd exposed to a symlink swap after admission.
68
53
  const canonicalBase = realpathOrSelf(base);
69
54
  if (!trimmed)
70
55
  return canonicalBase;
@@ -78,9 +63,6 @@ function resolveRunWorkingDirectory(requested, options) {
78
63
  catch {
79
64
  throw new RecoverableToolError(`workingDirectory "${requested}" is not an existing directory.`);
80
65
  }
81
- if (options.projectBoundary === "project") {
82
- assertWithinProjectBoundary(canonicalTarget, canonicalBase, requested ?? trimmed);
83
- }
84
66
  return canonicalTarget;
85
67
  }
86
68
  async function prepareRunContext(runId, params, options) {
@@ -100,7 +82,7 @@ async function prepareRunContext(runId, params, options) {
100
82
  if (taskId && !TASK_ID_PATTERN.test(taskId))
101
83
  throw new RecoverableToolError(`Invalid taskId: ${taskId}`);
102
84
  if (taskId) {
103
- const task = await readStoredTask(options.channelDir, taskId);
85
+ const task = await readStoredTask(options.deskDir, taskId);
104
86
  if (!task) {
105
87
  throw new RecoverableToolError(`Task ${taskId} does not exist. Create it with task_create before delegating task-owned work.`);
106
88
  }
@@ -111,7 +93,7 @@ async function prepareRunContext(runId, params, options) {
111
93
  throw new RecoverableToolError(`Task ${taskId} has no Work Item "${item}"${known ? ` (known: ${known})` : " (it has no Work Items yet — add one with task_update first)"}.`);
112
94
  }
113
95
  }
114
- const artifactDir = await prepareArtifactDir(options.channelDir, runId);
96
+ const artifactDir = await prepareArtifactDir(options.deskDir, runId);
115
97
  const workingDirectory = resolveRunWorkingDirectory(params.workingDirectory, options);
116
98
  return { runId, purpose, taskId, item, workingDirectory, artifactDir };
117
99
  }
@@ -24,7 +24,7 @@ export async function dispatchExternalRun(input) {
24
24
  runManager: input.runManager,
25
25
  runId: runContext.runId,
26
26
  channelId: options.runtimeContext.channelId,
27
- channelDir: options.channelDir,
27
+ deskDir: options.deskDir,
28
28
  label: runLabel,
29
29
  agent: config.name,
30
30
  source: config.source,
@@ -21,7 +21,7 @@ export interface LaunchExternalRunInput {
21
21
  runId: string;
22
22
  channelId: string;
23
23
  /** Where a task-bound run logs its dispatch and settlement (spec 052, D4). */
24
- channelDir?: string;
24
+ deskDir?: string;
25
25
  label: string;
26
26
  agent: string;
27
27
  source: "predefined" | "inline";
@@ -146,7 +146,7 @@ export async function launchExternalRun(input) {
146
146
  });
147
147
  const spawnedArgv = [invocation.executable, ...invocation.args];
148
148
  // Spec 042 D11: admission (inside register(), including the concurrency-limit checks) happens
149
- // *before* the audit write, not after — previously a run rejected for being over the per-channel
149
+ // *before* the audit write, not after — previously a run rejected for being over the per-desk
150
150
  // or host-wide cap still left behind an `external-agent` audit record claiming a process that
151
151
  // never existed. `external-agent` records what was *executed* (D8.1), so the record must not
152
152
  // precede the point where this run is actually admitted to run.
@@ -166,7 +166,7 @@ export async function launchExternalRun(input) {
166
166
  item: input.item,
167
167
  workingDirectory: input.workingDirectory,
168
168
  artifactDir: input.artifactDir,
169
- channelDir: input.channelDir,
169
+ deskDir: input.deskDir,
170
170
  leaseKey: input.leaseKey,
171
171
  mutates: input.mutates,
172
172
  workspaceBaseline: input.workspaceBaseline,
@@ -291,7 +291,7 @@ export async function launchExternalRun(input) {
291
291
  // with an inaccurate timeout message and an unestimatable duration.
292
292
  maxWallTimeSec: input.maxWallTimeSec,
293
293
  processStartedAt,
294
- channelDir: input.channelDir,
294
+ deskDir: input.deskDir,
295
295
  invocationWarnings: mergeInvocationWarnings(invocation.warnings, envFilterResult.dropped),
296
296
  // Spec 042 D12: distinguishes "the target CLI's schema drifted" from "the agent failed".
297
297
  parserVersion: harness.parserVersion,
@@ -47,7 +47,7 @@ export async function dispatchInternalRun(input) {
47
47
  item: runContext.item,
48
48
  workingDirectory: runContext.workingDirectory,
49
49
  artifactDir: runContext.artifactDir,
50
- channelDir: options.channelDir,
50
+ deskDir: options.deskDir,
51
51
  leaseKey,
52
52
  mutates: config.mutates,
53
53
  workspaceBaseline: input.workspaceBaseline,
@@ -6,7 +6,7 @@ import { Agent } from "@earendil-works/pi-agent-core";
6
6
  import { clampThinkingLevel, streamSimple } from "@earendil-works/pi-ai/compat";
7
7
  import { convertToLlm } from "@earendil-works/pi-coding-agent";
8
8
  import { getJournalDir } from "../../memory/journal.js";
9
- import { getChannelMemoryDir, getChannelMemoryIndexPath } from "../../memory/store.js";
9
+ import { getMemoryDir, getMemoryIndexPath } from "../../memory/store.js";
10
10
  import { DEFAULT_SECURITY_CONFIG } from "../../security/config.js";
11
11
  import { describeToolCall } from "../../tools/contract/presentation.js";
12
12
  import { addUsage } from "../../usage/totals.js";
@@ -48,12 +48,8 @@ export function getLastAssistantMessage(messages) {
48
48
  * stray write/edit here would race the shared memory serial queue (channel-maintenance-queue)
49
49
  * and silently corrupt durable memory.
50
50
  */
51
- function withSubagentMemoryWriteDeny(securityConfig, channelDir, workspaceDir) {
52
- const protectedPaths = [
53
- getChannelMemoryDir(channelDir),
54
- getJournalDir(channelDir),
55
- getChannelMemoryIndexPath(channelDir),
56
- ];
51
+ function withSubagentMemoryWriteDeny(securityConfig, deskDir, workspaceDir) {
52
+ const protectedPaths = [getMemoryDir(deskDir), getJournalDir(deskDir), getMemoryIndexPath(deskDir)];
57
53
  // The role directory gets the same structural denial (spec 040, D8.1): a sub-agent's write/edit
58
54
  // tools are exactly as capable of writing a self-authorizing `runtime: external` role file as
59
55
  // the main agent's are.
@@ -70,22 +66,18 @@ function withSubagentMemoryWriteDeny(securityConfig, channelDir, workspaceDir) {
70
66
  * whitelist: files + web), with its own security context and per-invocation bash timeout.
71
67
  */
72
68
  export function buildSubagentTools(executor, bashTimeoutSec, options, runContext) {
73
- const securityConfig = withSubagentMemoryWriteDeny(options.securityConfig ?? DEFAULT_SECURITY_CONFIG, options.channelDir, options.workspaceDir);
69
+ const securityConfig = withSubagentMemoryWriteDeny(options.securityConfig ?? DEFAULT_SECURITY_CONFIG, options.deskDir, options.workspaceDir);
74
70
  return options
75
71
  .buildWorkerTools({
76
72
  executor,
77
73
  fileStore: options.fileStore,
78
74
  securityConfig,
79
75
  securityContext: {
80
- // No `channelDir`: a sub-agent receives channel state through its injected context
81
- // blocks, not by reading the channel's own files, so it does not inherit the parent's
82
- // channel-directory exception (see security/types.ts).
83
76
  agentWorkspaceDir: options.workspaceDir,
84
- projectRoot: runContext.workingDirectory,
85
- boundary: options.projectBoundary,
77
+ cwd: runContext.workingDirectory,
86
78
  },
87
79
  channelId: options.runtimeContext.channelId,
88
- channelDir: options.channelDir,
80
+ deskDir: options.deskDir,
89
81
  workspaceDir: options.workspaceDir,
90
82
  webConfig: options.webConfig,
91
83
  rtkEnabled: options.rtkEnabled,
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The two observability records a settled run leaves behind: its usage-ledger entry and its
3
+ * `subagent-runs.jsonl` archive entry. Pure shaping only — *when* they are written, and the
4
+ * idempotency marker that keeps a replayed settlement from writing them twice, stay with
5
+ * `SubAgentRunManager.settle`.
6
+ */
7
+ import type { LoggedSubAgentRun } from "../channel/store.js";
8
+ import type { UsageLedgerEntry } from "../usage/ledger.js";
9
+ import type { RunRecord, SettleInput } from "./run-record.js";
10
+ export declare function runLedgerEntry(desk: string, record: RunRecord, input: SettleInput): Omit<UsageLedgerEntry, "ts">;
11
+ export declare function runArchiveEntry(record: RunRecord, input: SettleInput, status: SettleInput["status"]): LoggedSubAgentRun;
@@ -0,0 +1,49 @@
1
+ /** Archived output is capped; the full text is in the run's `output.md`. */
2
+ const ARCHIVED_OUTPUT_MAX_CHARS = 16_000;
3
+ export function runLedgerEntry(desk, record, input) {
4
+ return {
5
+ channelId: record.channelId,
6
+ desk,
7
+ kind: "subagent",
8
+ model: record.model ?? "unknown",
9
+ label: record.label,
10
+ runId: record.runId,
11
+ taskId: record.taskId,
12
+ usage: {
13
+ input: input.usage.input,
14
+ output: input.usage.output,
15
+ cacheRead: input.usage.cacheRead,
16
+ cacheWrite: input.usage.cacheWrite,
17
+ total: input.usage.total,
18
+ },
19
+ cost: { ...input.usage.cost },
20
+ usageKnown: input.usageKnown,
21
+ costKnown: input.costKnown,
22
+ };
23
+ }
24
+ export function runArchiveEntry(record, input, status) {
25
+ const truncated = input.outputText.length > ARCHIVED_OUTPUT_MAX_CHARS;
26
+ return {
27
+ date: new Date().toISOString(),
28
+ toolCallId: record.runId,
29
+ label: record.label,
30
+ agent: record.agent,
31
+ source: record.source,
32
+ model: record.model ?? "unknown",
33
+ tools: record.tools,
34
+ turns: input.turns,
35
+ toolCalls: input.toolCalls,
36
+ durationMs: input.durationMs,
37
+ failed: input.status !== "completed",
38
+ failureReason: input.failureReason,
39
+ output: truncated ? input.outputText.slice(0, ARCHIVED_OUTPUT_MAX_CHARS) : input.outputText,
40
+ outputTruncated: truncated,
41
+ usage: { ...input.usage, cost: { ...input.usage.cost } },
42
+ runId: record.runId,
43
+ runtime: record.runtime,
44
+ harness: record.harness,
45
+ status,
46
+ taskId: record.taskId,
47
+ artifactDir: record.artifactDir,
48
+ };
49
+ }
@@ -108,9 +108,9 @@ export interface RunRecord extends RunUsage {
108
108
  /** Spec 042 D1: the real process start time (`setLaunched` time), as opposed to `startedAt`
109
109
  * (registration time) — restart reconciliation's duration estimate is measured from here. */
110
110
  processStartedAt?: number;
111
- /** This run's channel directory, so settlement (including restart reconciliation) can reach the
111
+ /** This run's desk directory, so settlement (including restart reconciliation) can reach the
112
112
  * owning task's log (spec 052, D4). */
113
- channelDir?: string;
113
+ deskDir?: string;
114
114
  /** True when `durationMs` is a restart-reconciliation estimate rather than a measured process
115
115
  * lifetime (spec 042 D1) — display surfaces prefix it with "≈". */
116
116
  durationEstimated?: boolean;
@@ -144,10 +144,10 @@ export interface RegisterRunInput {
144
144
  item?: string;
145
145
  workingDirectory: string;
146
146
  artifactDir: string;
147
- /** This run's channel directory — where its owning task lives. Set at registration for every
147
+ /** This run's desk directory — where its owning task lives. Set at registration for every
148
148
  * runtime, so settlement can credit the task whether the run was internal or external; the
149
149
  * external launch path re-persists it with the rest of its info. */
150
- channelDir?: string;
150
+ deskDir?: string;
151
151
  /** Set only when the caller already holds a workspace write lease for this run (D10.1). */
152
152
  leaseKey?: string;
153
153
  mutates?: RunMutates;
@@ -194,10 +194,11 @@ export interface RunNotice {
194
194
  /** Only set for `kind: "stalled"`: how long the run has written no output. */
195
195
  silentMs?: number;
196
196
  }
197
- export type RunNotifier = (channelId: string, notice: RunNotice) => void | Promise<void>;
198
- /** D10.2: per-channel cap on concurrently running delegation runs. */
199
- export declare const MAX_RUNNING_SUBAGENT_RUNS_PER_CHANNEL = 6;
200
- /** D10.2: host-wide cap across every channel. Bounds unbounded process/worker growth only —
197
+ /** Sends a notice to the run's own channel; `desk` lets the runtime refuse a channel bound elsewhere (D7). */
198
+ export type RunNotifier = (desk: string, channelId: string, notice: RunNotice) => void | Promise<void>;
199
+ /** D10.2: per-desk cap on concurrently running delegation runs (one run manager per desk, spec 058). */
200
+ export declare const MAX_RUNNING_SUBAGENT_RUNS_PER_DESK = 6;
201
+ /** D10.2: host-wide cap across every desk. Bounds unbounded process/worker growth only —
201
202
  * not the full cross-subsystem (task/job/sidecar) admission scheme the design doc leaves open. */
202
203
  export declare const MAX_RUNNING_SUBAGENT_RUNS_PER_HOST = 20;
203
204
  /**
@@ -4,9 +4,9 @@
4
4
  * so the run manager and the external-run helpers can share it without an import cycle (spec 054 D9/D12).
5
5
  */
6
6
  import { isRecord } from "../shared/type-guards.js";
7
- /** D10.2: per-channel cap on concurrently running delegation runs. */
8
- export const MAX_RUNNING_SUBAGENT_RUNS_PER_CHANNEL = 6;
9
- /** D10.2: host-wide cap across every channel. Bounds unbounded process/worker growth only —
7
+ /** D10.2: per-desk cap on concurrently running delegation runs (one run manager per desk, spec 058). */
8
+ export const MAX_RUNNING_SUBAGENT_RUNS_PER_DESK = 6;
9
+ /** D10.2: host-wide cap across every desk. Bounds unbounded process/worker growth only —
10
10
  * not the full cross-subsystem (task/job/sidecar) admission scheme the design doc leaves open. */
11
11
  export const MAX_RUNNING_SUBAGENT_RUNS_PER_HOST = 20;
12
12
  /**
@@ -1,7 +1,9 @@
1
1
  import { type RunManagerOptions, SubAgentRunManager } from "./runs.js";
2
- /** Owns this application's channel managers and their maintenance timer. */
3
- export declare function createSubAgentRuntime(options?: RunManagerOptions): {
4
- get: (channelId: string) => SubAgentRunManager;
2
+ /** Owns this application's desk managers and their maintenance timer. */
3
+ export declare function createSubAgentRuntime(options: RunManagerOptions & {
4
+ workspaceDir: string;
5
+ }): {
6
+ get: (desk: string) => SubAgentRunManager;
5
7
  restore: () => Promise<number>;
6
8
  start: () => void;
7
9
  stop: () => void;
@@ -1,43 +1,18 @@
1
1
  /**
2
- * The application's registry of per-channel run managers: lazy creation, the host-wide admission
3
- * count, startup restore across every persisted channel, and the daily garbage-collection timer.
2
+ * The application's registry of per-desk run managers: lazy creation, the host-wide admission
3
+ * count, startup restore across every persisted desk, and the daily garbage-collection timer.
4
4
  */
5
- import { mkdir, readdir, readFile } from "node:fs/promises";
6
- import { join } from "node:path";
7
- import { isChannelId } from "../channel/channel-paths.js";
5
+ import { mkdir, readdir } from "node:fs/promises";
6
+ import { getDeskDir, isDeskName } from "../desk/paths.js";
8
7
  import * as log from "../log.js";
9
8
  import { errorMessage } from "../shared/text-utils.js";
10
- import { parseRunRecord } from "./run-record.js";
11
9
  import { SubAgentRunManager } from "./runs.js";
12
- async function listRecordChannelIds(stateDir) {
13
- const channelIds = [];
14
- for (const entry of await readdir(stateDir, { withFileTypes: true })) {
15
- if (!entry.isDirectory())
16
- continue;
17
- const dir = join(stateDir, entry.name);
18
- let channelId;
19
- try {
20
- for (const filename of (await readdir(dir)).filter((name) => name.endsWith(".json"))) {
21
- channelId = parseRunRecord(await readFile(join(dir, filename), "utf-8"))?.channelId;
22
- if (channelId)
23
- break;
24
- }
25
- }
26
- catch {
27
- channelId = undefined;
28
- }
29
- const resolved = channelId && isChannelId(channelId) ? channelId : entry.name;
30
- if (isChannelId(resolved))
31
- channelIds.push(resolved);
32
- }
33
- return channelIds;
34
- }
35
- /** Owns this application's channel managers and their maintenance timer. */
36
- export function createSubAgentRuntime(options = {}) {
37
- const config = { ...options };
10
+ /** Owns this application's desk managers and their maintenance timer. */
11
+ export function createSubAgentRuntime(options) {
12
+ const { workspaceDir, ...config } = options;
38
13
  const managers = new Map();
39
14
  let stopped = false;
40
- /** Host-wide running count for the D10.2 admission check, summed across every known channel. */
15
+ /** Host-wide running count for the D10.2 admission check, summed across every known desk. */
41
16
  function totalRunningSubAgentRuns() {
42
17
  let total = 0;
43
18
  for (const manager of managers.values()) {
@@ -81,38 +56,40 @@ export function createSubAgentRuntime(options = {}) {
81
56
  garbageCollectionTimer = undefined;
82
57
  }
83
58
  }
84
- function get(channelId) {
85
- let manager = managers.get(channelId);
59
+ function get(desk) {
60
+ let manager = managers.get(desk);
86
61
  if (!manager) {
87
- manager = new SubAgentRunManager(channelId, { ...config, runningCount: totalRunningSubAgentRuns });
88
- managers.set(channelId, manager);
62
+ manager = new SubAgentRunManager({ desk, deskDir: getDeskDir(workspaceDir, desk) }, { ...config, runningCount: totalRunningSubAgentRuns });
63
+ managers.set(desk, manager);
89
64
  if (stopped)
90
65
  manager.stop();
91
66
  }
92
67
  return manager;
93
68
  }
94
69
  /**
95
- * Re-adopt every channel's persisted runs at startup, settling any internal run still marked
96
- * `running` as `lost` (D10.3). Channels are discovered from the state directory itself, exactly
97
- * like `restoreChannelJobs` — but by reading the records rather than trusting directory names,
98
- * so a channel is adopted under the id the rest of the runtime can act on.
70
+ * Re-adopt every desk's persisted runs at startup, settling any internal run still marked
71
+ * `running` as `lost` (D10.3). Desks are the record directories themselves — a desk name *is* the
72
+ * directory name — and restore does not depend on bindings (spec 058, D6): a run still going
73
+ * when its desk went dormant still has an owner to adopt and settle it.
99
74
  */
100
75
  async function restore() {
101
76
  const stateDir = config.stateDir;
102
77
  if (!stateDir)
103
78
  return 0;
104
- let channelIds;
79
+ let desks;
105
80
  try {
106
81
  await mkdir(stateDir, { recursive: true });
107
- channelIds = await listRecordChannelIds(stateDir);
82
+ desks = (await readdir(stateDir, { withFileTypes: true }))
83
+ .filter((entry) => entry.isDirectory() && isDeskName(entry.name))
84
+ .map((entry) => entry.name);
108
85
  }
109
86
  catch (error) {
110
87
  log.logWarn("subagent.scan.failed", "Persisted run scan failed", { reason: errorMessage(error) });
111
88
  return 0;
112
89
  }
113
90
  let restored = 0;
114
- for (const channelId of channelIds) {
115
- restored += await get(channelId).restore();
91
+ for (const desk of desks) {
92
+ restored += await get(desk).restore();
116
93
  }
117
94
  // Reclaim stale runs once as a host-wide startup batch; subsequent batches run daily.
118
95
  await collectGarbageAllChannels();
@@ -1,14 +1,13 @@
1
- import type { ChannelEvent } from "../channel/channel-event.js";
1
+ import type { WakeEvent } from "../channel/channel-event.js";
2
2
  import type { ChannelStore } from "../channel/store.js";
3
3
  import type { UsageLedger } from "../usage/ledger.js";
4
4
  import { type RegisterRunInput, type RunNotifier, type RunRecord, type RunResolution, type RunStatus, type SettleInput } from "./run-record.js";
5
5
  export interface RunManagerOptions {
6
- /**
7
- * Root of the per-channel record directories (`<stateDir>/<escaped channelId>/`, escaped by
8
- * `getChannelDir`). Omit to skip persistence.
9
- */
6
+ /** Root of the per-desk record directories (`<stateDir>/<desk>/`). Omit to skip persistence. */
10
7
  stateDir?: string;
11
- dispatch?: (event: ChannelEvent) => boolean | Promise<boolean>;
8
+ /** Is a run's channel still bound to this desk (spec 058, D7)? Omitted (TUI, tests): always. */
9
+ isBoundTo?: (channelId: string, desk: string) => boolean;
10
+ dispatch?: (event: WakeEvent) => boolean | Promise<boolean>;
12
11
  /** Best-effort out-of-band notice sink (see `RunNotice`). Never awaited by settlement or the
13
12
  * progress tail — a slow or failing notifier must not delay either. */
14
13
  notify?: RunNotifier;
@@ -18,13 +17,13 @@ export interface RunManagerOptions {
18
17
  runningCount?: () => number;
19
18
  }
20
19
  /**
21
- * Per-channel manager for delegation runs — the single settlement/usage/wake authority for both
20
+ * Per-desk manager for delegation runs — the single settlement/usage/wake authority for both
22
21
  * internal sub-agents and (once wired) external harnesses (D7). Modeled directly on
23
- * `ChannelJobManager`; the two are not unified because a run's terminal status depends on a
22
+ * `DeskJobManager`; the two are not unified because a run's terminal status depends on a
24
23
  * protocol verdict, not just process exit (D4), so the state machines genuinely differ.
25
24
  */
26
25
  export declare class SubAgentRunManager {
27
- private readonly channelId;
26
+ private readonly target;
28
27
  private readonly options;
29
28
  private readonly runs;
30
29
  /** In-memory cancel handles for runs alive in *this* process (internal worker abort or live
@@ -46,7 +45,13 @@ export declare class SubAgentRunManager {
46
45
  * external tail does. Created on first report, dropped at settlement. */
47
46
  private readonly internalProgressPacers;
48
47
  private readonly queue;
49
- constructor(channelId: string, options: RunManagerOptions);
48
+ /** `target` owns these runs; each run's own `channelId` is where it reports back. */
49
+ constructor(target: {
50
+ desk: string;
51
+ deskDir: string;
52
+ }, options: RunManagerOptions);
53
+ /** The completion wake's dispatch id — the only id `beginWakeConsumption` accepts for it. */
54
+ private wakeDispatchId;
50
55
  /** Release observation timers without cancelling dispatched work or its settlement. */
51
56
  stop(): void;
52
57
  private recordDir;
@@ -75,8 +80,6 @@ export declare class SubAgentRunManager {
75
80
  private forget;
76
81
  get(runId: string): RunRecord | undefined;
77
82
  list(): RunRecord[];
78
- /** Task ids a still-running delegation on this channel will eventually wake. Feeds `/tasks doctor`. */
79
- runningTaskIds(): Set<string>;
80
83
  runningCount(): number;
81
84
  /** Mint a short, human-typeable run id (spec 041). Retried against currently known records;
82
85
  * the id space (30^6 ≈ 7.3e8) makes a real collision astronomically unlikely, so this is a
@@ -108,7 +111,7 @@ export declare class SubAgentRunManager {
108
111
  * would, not a thinner subset. */
109
112
  maxWallTimeSec?: number;
110
113
  processStartedAt?: number;
111
- channelDir?: string;
114
+ deskDir?: string;
112
115
  /** Spec 042 D10: non-fatal invocation warnings from argv assembly (e.g. a dropped
113
116
  * placeholder token), so they survive on the run rather than only ever hitting a log line. */
114
117
  invocationWarnings?: string[];
@@ -159,6 +162,13 @@ export declare class SubAgentRunManager {
159
162
  * harmless — this is the same fix as jobs/manager's `announce()` reordering (D7).
160
163
  */
161
164
  private announce;
165
+ /**
166
+ * Spec 058, D8: the run's channel left this desk, so the wake has no recipient. Settlement and the
167
+ * task's settle record already happened; the wake is dropped (marker set, never replayed), and the
168
+ * `work` ticket it would have redeemed is redeemed here via `redeemTicket`, so the suspended task
169
+ * resumes as soon as its delivery channel is bound again.
170
+ */
171
+ private suppressWake;
162
172
  /** Explicit cancel (`subagent_run op=cancel`, spec 040 D6). Does not wake — it is the model's own decision. */
163
173
  cancel(runId: string): Promise<RunStatus | "not_found">;
164
174
  /**