pi-better-server 0.4.0 → 0.6.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 (597) hide show
  1. package/package.json +8 -1
  2. package/scripts/copy-pi-test-providers.mjs +10 -0
  3. package/scripts/event-publication/README.md +26 -0
  4. package/scripts/event-publication/commit.mjs +21 -0
  5. package/scripts/event-publication/measure.mjs +87 -0
  6. package/scripts/event-publication/writer.mjs +6 -0
  7. package/scripts/measure-full-runtime/frontend.ts +24 -0
  8. package/scripts/measure-full-runtime/hosted-extension.ts +28 -0
  9. package/scripts/measure-full-runtime/probe.mjs +29 -0
  10. package/scripts/measure-full-runtime/recovery-trace-loader.mjs +51 -0
  11. package/scripts/measure-full-runtime/recovery-trace.mjs +16 -0
  12. package/scripts/measure-full-runtime.mjs +146 -0
  13. package/scripts/measure-shared-reads/probe.mjs +26 -2
  14. package/scripts/measure-shared-reads.mjs +44 -9
  15. package/scripts/private-runtime/package-lock.json +66 -4
  16. package/scripts/private-runtime/package.json +10 -2
  17. package/scripts/source-provenance.mjs +31 -0
  18. package/scripts/test-on-pi.sh +3 -9
  19. package/src/handshake.ts +1 -1
  20. package/src/hosted-session.ts +32 -4
  21. package/src/maintenance.ts +35 -7
  22. package/src/registry.ts +28 -4
  23. package/src/runtime/attempt-invalidation.ts +54 -0
  24. package/src/runtime/background-history.ts +151 -45
  25. package/src/runtime/background-policy.ts +27 -0
  26. package/src/runtime/background-tools.ts +389 -0
  27. package/src/runtime/background.ts +410 -48
  28. package/src/runtime/cancellation.ts +28 -7
  29. package/src/runtime/catalog-sources.ts +199 -0
  30. package/src/runtime/catalog.ts +53 -21
  31. package/src/runtime/client.ts +22 -2
  32. package/src/runtime/domain/assignment-inbox.mjs +119 -0
  33. package/src/runtime/domain/assignment-observation.d.mts +1 -1
  34. package/src/runtime/domain/assignment-observation.mjs +71 -33
  35. package/src/runtime/domain/background/process-identity.mjs +20 -2
  36. package/src/runtime/domain/background/process.mjs +3 -3
  37. package/src/runtime/domain/background/registry.mjs +89 -4
  38. package/src/runtime/domain/background/types.mjs +1 -0
  39. package/src/runtime/domain/background-service/adapter-contract.domain.mjs +83 -0
  40. package/src/runtime/domain/background-service/adapter-contract.ts +70 -0
  41. package/src/runtime/domain/background-service/batch.domain.mjs +91 -0
  42. package/src/runtime/domain/background-service/batch.ts +111 -0
  43. package/src/runtime/domain/background-service/conditions.domain.mjs +94 -0
  44. package/src/runtime/domain/background-service/conditions.ts +99 -0
  45. package/src/runtime/domain/background-service/delivery-observer.domain.mjs +37 -0
  46. package/src/runtime/domain/background-service/delivery-observer.ts +42 -0
  47. package/src/runtime/domain/background-service/failures.domain.mjs +209 -0
  48. package/src/runtime/domain/background-service/failures.ts +212 -0
  49. package/src/runtime/domain/background-service/goal-provider.domain.mjs +193 -0
  50. package/src/runtime/domain/background-service/goal-provider.ts +209 -0
  51. package/src/runtime/domain/background-service/index.domain.mjs +54 -0
  52. package/src/runtime/domain/background-service/index.ts +55 -0
  53. package/src/runtime/domain/background-service/logs.domain.mjs +129 -0
  54. package/src/runtime/domain/background-service/logs.ts +134 -0
  55. package/src/runtime/domain/background-service/maintenance.domain.mjs +95 -0
  56. package/src/runtime/domain/background-service/maintenance.ts +98 -0
  57. package/src/runtime/domain/background-service/managed-authority.domain.mjs +32 -0
  58. package/src/runtime/domain/background-service/managed-authority.ts +30 -0
  59. package/src/runtime/domain/background-service/managed-client.domain.mjs +79 -0
  60. package/src/runtime/domain/background-service/managed-client.ts +73 -0
  61. package/src/runtime/domain/background-service/managed-frontend.domain.mjs +225 -0
  62. package/src/runtime/domain/background-service/managed-frontend.ts +176 -0
  63. package/src/runtime/domain/background-service/navigator-provider.domain.mjs +492 -0
  64. package/src/runtime/domain/background-service/navigator-provider.ts +485 -0
  65. package/src/runtime/domain/background-service/observed-wait-client.domain.mjs +6 -0
  66. package/src/runtime/domain/background-service/observed-wait-client.ts +10 -0
  67. package/src/runtime/domain/background-service/observed-waits.domain.mjs +4080 -0
  68. package/src/runtime/domain/background-service/observed-waits.ts +4513 -0
  69. package/src/runtime/domain/background-service/output.domain.mjs +867 -0
  70. package/src/runtime/domain/background-service/output.ts +952 -0
  71. package/src/runtime/domain/background-service/process-identity.domain.mjs +129 -0
  72. package/src/runtime/domain/background-service/process-identity.ts +134 -0
  73. package/src/runtime/domain/background-service/process.domain.mjs +512 -0
  74. package/src/runtime/domain/background-service/process.ts +532 -0
  75. package/src/runtime/domain/background-service/prompt.domain.mjs +58 -0
  76. package/src/runtime/domain/background-service/prompt.ts +72 -0
  77. package/src/runtime/domain/background-service/registry.domain.mjs +460 -0
  78. package/src/runtime/domain/background-service/registry.ts +450 -0
  79. package/src/runtime/domain/background-service/remote-task-preset.domain.mjs +67 -0
  80. package/src/runtime/domain/background-service/remote-task-preset.ts +127 -0
  81. package/src/runtime/domain/background-service/runtime.domain.mjs +1511 -0
  82. package/src/runtime/domain/background-service/runtime.ts +1636 -0
  83. package/src/runtime/domain/background-service/sandbox.domain.mjs +735 -0
  84. package/src/runtime/domain/background-service/sandbox.ts +913 -0
  85. package/src/runtime/domain/background-service/shared-callback-batcher.domain.mjs +777 -0
  86. package/src/runtime/domain/background-service/shared-callback-batcher.ts +956 -0
  87. package/src/runtime/domain/background-service/shared-execution-policy.domain.mjs +50 -0
  88. package/src/runtime/domain/background-service/shared-execution-policy.ts +61 -0
  89. package/src/runtime/domain/background-service/shared-failure-observations.domain.mjs +1078 -0
  90. package/src/runtime/domain/background-service/shared-failure-observations.ts +1166 -0
  91. package/src/runtime/domain/background-service/shared-harness-settings.domain.mjs +126 -0
  92. package/src/runtime/domain/background-service/shared-harness-settings.ts +116 -0
  93. package/src/runtime/domain/background-service/shared-log-utils.domain.mjs +1223 -0
  94. package/src/runtime/domain/background-service/shared-log-utils.ts +1492 -0
  95. package/src/runtime/domain/background-service/shared-navigator-panels.domain.mjs +289 -0
  96. package/src/runtime/domain/background-service/shared-navigator-panels.ts +272 -0
  97. package/src/runtime/domain/background-service/shared-navigator.domain.mjs +1930 -0
  98. package/src/runtime/domain/background-service/shared-navigator.ts +1962 -0
  99. package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-inbox.mjs +144 -0
  100. package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-observation.mjs +189 -0
  101. package/src/runtime/domain/background-service/shared-operation-coordinator/index.domain.mjs +51 -0
  102. package/src/runtime/domain/background-service/shared-operation-coordinator/index.ts +122 -0
  103. package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
  104. package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.ts +73 -0
  105. package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
  106. package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
  107. package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
  108. package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
  109. package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
  110. package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.ts +90 -0
  111. package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
  112. package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.ts +139 -0
  113. package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.domain.mjs +12 -0
  114. package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.ts +79 -0
  115. package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.domain.mjs +342 -0
  116. package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.ts +513 -0
  117. package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
  118. package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.ts +458 -0
  119. package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
  120. package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.ts +55 -0
  121. package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
  122. package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts +140 -0
  123. package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs +280 -0
  124. package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.ts +442 -0
  125. package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +420 -0
  126. package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +441 -0
  127. package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
  128. package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.ts +239 -0
  129. package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +275 -0
  130. package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +585 -0
  131. package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
  132. package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.ts +142 -0
  133. package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
  134. package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.ts +224 -0
  135. package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.domain.mjs +25 -0
  136. package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.ts +707 -0
  137. package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
  138. package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.ts +22 -0
  139. package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.domain.mjs +234 -0
  140. package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.ts +241 -0
  141. package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.domain.mjs +851 -0
  142. package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.ts +1424 -0
  143. package/src/runtime/domain/background-service/shared-permission-blocker.domain.mjs +40 -0
  144. package/src/runtime/domain/background-service/shared-permission-blocker.ts +48 -0
  145. package/src/runtime/domain/background-service/shared-render-scheduler.domain.mjs +41 -0
  146. package/src/runtime/domain/background-service/shared-render-scheduler.ts +47 -0
  147. package/src/runtime/domain/background-service/shared-sandbox-core.domain.mjs +1531 -0
  148. package/src/runtime/domain/background-service/shared-sandbox-core.ts +1757 -0
  149. package/src/runtime/domain/background-service/shared-sandbox-diagnostics.domain.mjs +591 -0
  150. package/src/runtime/domain/background-service/shared-sandbox-diagnostics.ts +491 -0
  151. package/src/runtime/domain/background-service/shared-ssh-core/index.domain.mjs +698 -0
  152. package/src/runtime/domain/background-service/shared-ssh-core/index.ts +979 -0
  153. package/src/runtime/domain/background-service/shared-stall-detector.domain.mjs +37 -0
  154. package/src/runtime/domain/background-service/shared-stall-detector.ts +69 -0
  155. package/src/runtime/domain/background-service/shared-work-client.mjs +303 -0
  156. package/src/runtime/domain/background-service/stall-attention.domain.mjs +29 -0
  157. package/src/runtime/domain/background-service/stall-attention.ts +31 -0
  158. package/src/runtime/domain/background-service/stall.domain.mjs +57 -0
  159. package/src/runtime/domain/background-service/stall.ts +57 -0
  160. package/src/runtime/domain/background-service/supervisor/README.md +111 -0
  161. package/src/runtime/domain/background-service/supervisor/emit-runner.mjs +90 -0
  162. package/src/runtime/domain/background-service/supervisor/generated/conditions.mjs +96 -0
  163. package/src/runtime/domain/background-service/supervisor/generated/identity.mjs +95 -0
  164. package/src/runtime/domain/background-service/supervisor/generated/process-identity.mjs +131 -0
  165. package/src/runtime/domain/background-service/supervisor/generated/process.mjs +514 -0
  166. package/src/runtime/domain/background-service/supervisor/generated/runner.mjs +872 -0
  167. package/src/runtime/domain/background-service/supervisor/generated/store.mjs +609 -0
  168. package/src/runtime/domain/background-service/supervisor/generated/types.mjs +50 -0
  169. package/src/runtime/domain/background-service/supervisor/identity.domain.mjs +93 -0
  170. package/src/runtime/domain/background-service/supervisor/identity.ts +99 -0
  171. package/src/runtime/domain/background-service/supervisor/index.domain.mjs +22 -0
  172. package/src/runtime/domain/background-service/supervisor/index.ts +37 -0
  173. package/src/runtime/domain/background-service/supervisor/invocation.domain.mjs +30 -0
  174. package/src/runtime/domain/background-service/supervisor/invocation.ts +44 -0
  175. package/src/runtime/domain/background-service/supervisor/runner.domain.mjs +870 -0
  176. package/src/runtime/domain/background-service/supervisor/runner.ts +982 -0
  177. package/src/runtime/domain/background-service/supervisor/store.domain.mjs +605 -0
  178. package/src/runtime/domain/background-service/supervisor/store.ts +651 -0
  179. package/src/runtime/domain/background-service/supervisor/supervisor.domain.mjs +721 -0
  180. package/src/runtime/domain/background-service/supervisor/supervisor.ts +804 -0
  181. package/src/runtime/domain/background-service/supervisor/types.domain.mjs +48 -0
  182. package/src/runtime/domain/background-service/supervisor/types.ts +394 -0
  183. package/src/runtime/domain/background-service/task-diagnostics.domain.mjs +60 -0
  184. package/src/runtime/domain/background-service/task-diagnostics.ts +71 -0
  185. package/src/runtime/domain/background-service/tools.domain.mjs +1050 -0
  186. package/src/runtime/domain/background-service/tools.ts +1142 -0
  187. package/src/runtime/domain/background-service/types.domain.mjs +5 -0
  188. package/src/runtime/domain/background-service/types.ts +236 -0
  189. package/src/runtime/domain/background-service/work-observation.domain.mjs +176 -0
  190. package/src/runtime/domain/background-service/work-observation.ts +144 -0
  191. package/src/runtime/domain/catalog/catalog-store.d.mts +9 -1
  192. package/src/runtime/domain/catalog/catalog-store.mjs +20 -22
  193. package/src/runtime/domain/coordinator/src/assignment-changes.mjs +75 -0
  194. package/src/runtime/domain/coordinator/src/assignment-outcomes.mjs +2 -0
  195. package/src/runtime/domain/coordinator/src/background-parent-callbacks.mjs +65 -0
  196. package/src/runtime/domain/coordinator/src/background-requests.mjs +86 -0
  197. package/src/runtime/domain/coordinator/src/discovery.mjs +4 -2
  198. package/src/runtime/domain/coordinator/src/operations.mjs +44 -4
  199. package/src/runtime/domain/coordinator/src/result-supervision.mjs +12 -0
  200. package/src/runtime/domain/coordinator/src/rows.mjs +2 -0
  201. package/src/runtime/domain/coordinator/src/schema.mjs +73 -21
  202. package/src/runtime/domain/coordinator/src/store.mjs +32 -3
  203. package/src/runtime/domain/coordinator/src/subagent-launch.mjs +119 -0
  204. package/src/runtime/domain/coordinator/src/types.mjs +1 -1
  205. package/src/runtime/domain/coordinator/src/upgrade.mjs +22 -0
  206. package/src/runtime/domain/health-observation.d.mts +3 -1
  207. package/src/runtime/domain/health-observation.mjs +189 -190
  208. package/src/runtime/domain/log-cursor.d.mts +2 -0
  209. package/src/runtime/domain/log-cursor.mjs +85 -16
  210. package/src/runtime/domain/parse.d.mts +4 -1
  211. package/src/runtime/domain/parse.mjs +50 -5
  212. package/src/runtime/domain/sandbox-policy/README.md +633 -0
  213. package/src/runtime/domain/sandbox-policy/background-admission.domain.mjs +83 -0
  214. package/src/runtime/domain/sandbox-policy/background-admission.ts +75 -0
  215. package/src/runtime/domain/sandbox-policy/commands.domain.mjs +245 -0
  216. package/src/runtime/domain/sandbox-policy/commands.ts +336 -0
  217. package/src/runtime/domain/sandbox-policy/deny-rules.domain.mjs +440 -0
  218. package/src/runtime/domain/sandbox-policy/deny-rules.ts +620 -0
  219. package/src/runtime/domain/sandbox-policy/diagnostics-command.domain.mjs +30 -0
  220. package/src/runtime/domain/sandbox-policy/diagnostics-command.ts +27 -0
  221. package/src/runtime/domain/sandbox-policy/events.domain.mjs +49 -0
  222. package/src/runtime/domain/sandbox-policy/events.ts +85 -0
  223. package/src/runtime/domain/sandbox-policy/files.domain.mjs +153 -0
  224. package/src/runtime/domain/sandbox-policy/files.ts +224 -0
  225. package/src/runtime/domain/sandbox-policy/index.domain.mjs +289 -0
  226. package/src/runtime/domain/sandbox-policy/index.ts +386 -0
  227. package/src/runtime/domain/sandbox-policy/package.json +66 -0
  228. package/src/runtime/domain/sandbox-policy/permission-settings.domain.mjs +36 -0
  229. package/src/runtime/domain/sandbox-policy/permission-settings.ts +46 -0
  230. package/src/runtime/domain/sandbox-policy/permissions-page.domain.mjs +309 -0
  231. package/src/runtime/domain/sandbox-policy/permissions-page.ts +295 -0
  232. package/src/runtime/domain/sandbox-policy/permissions.domain.mjs +98 -0
  233. package/src/runtime/domain/sandbox-policy/permissions.ts +125 -0
  234. package/src/runtime/domain/sandbox-policy/policy.domain.mjs +80 -0
  235. package/src/runtime/domain/sandbox-policy/policy.ts +102 -0
  236. package/src/runtime/domain/sandbox-policy/preferences.domain.mjs +55 -0
  237. package/src/runtime/domain/sandbox-policy/preferences.ts +82 -0
  238. package/src/runtime/domain/sandbox-policy/rules-page.domain.mjs +138 -0
  239. package/src/runtime/domain/sandbox-policy/rules-page.ts +176 -0
  240. package/src/runtime/domain/sandbox-policy/session-permissions.domain.mjs +22 -0
  241. package/src/runtime/domain/sandbox-policy/session-permissions.ts +24 -0
  242. package/src/runtime/domain/sandbox-policy/shared-harness-settings.domain.mjs +126 -0
  243. package/src/runtime/domain/sandbox-policy/shared-harness-settings.ts +116 -0
  244. package/src/runtime/domain/sandbox-policy/shared-permission-blocker.domain.mjs +40 -0
  245. package/src/runtime/domain/sandbox-policy/shared-permission-blocker.ts +48 -0
  246. package/src/runtime/domain/sandbox-policy/shared-sandbox-core.domain.mjs +1531 -0
  247. package/src/runtime/domain/sandbox-policy/shared-sandbox-core.ts +1757 -0
  248. package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.domain.mjs +591 -0
  249. package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.ts +491 -0
  250. package/src/runtime/domain/sandbox-policy/shared-task-application.domain.mjs +185 -0
  251. package/src/runtime/domain/sandbox-policy/shared-task-application.ts +185 -0
  252. package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.domain.mjs +416 -0
  253. package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.ts +409 -0
  254. package/src/runtime/domain/sandbox-policy/shared-task-exec.domain.mjs +325 -0
  255. package/src/runtime/domain/sandbox-policy/shared-task-exec.ts +335 -0
  256. package/src/runtime/domain/sandbox-policy/shared-task-files.domain.mjs +346 -0
  257. package/src/runtime/domain/sandbox-policy/shared-task-files.ts +342 -0
  258. package/src/runtime/domain/sandbox-policy/shared-task-process-identity.domain.mjs +140 -0
  259. package/src/runtime/domain/sandbox-policy/shared-task-process-identity.ts +126 -0
  260. package/src/runtime/domain/sandbox-policy/shared-task-process-list.domain.mjs +220 -0
  261. package/src/runtime/domain/sandbox-policy/shared-task-process-list.ts +209 -0
  262. package/src/runtime/domain/sandbox-policy/shared-task-sandbox.domain.mjs +227 -0
  263. package/src/runtime/domain/sandbox-policy/shared-task-sandbox.ts +224 -0
  264. package/src/runtime/domain/sandbox-policy/shared-task-tools.domain.mjs +92 -0
  265. package/src/runtime/domain/sandbox-policy/shared-task-tools.ts +123 -0
  266. package/src/runtime/domain/sandbox-policy/shell.domain.mjs +93 -0
  267. package/src/runtime/domain/sandbox-policy/shell.ts +129 -0
  268. package/src/runtime/domain/sandbox-policy/state.domain.mjs +307 -0
  269. package/src/runtime/domain/sandbox-policy/state.ts +408 -0
  270. package/src/runtime/domain/sandbox-policy/status.domain.mjs +64 -0
  271. package/src/runtime/domain/sandbox-policy/status.ts +76 -0
  272. package/src/runtime/domain/sandbox-policy/subagent-admission.domain.mjs +69 -0
  273. package/src/runtime/domain/sandbox-policy/subagent-admission.ts +60 -0
  274. package/src/runtime/domain/subagents/CONTEXT.md +202 -0
  275. package/src/runtime/domain/subagents/PRODUCT.md +49 -0
  276. package/src/runtime/domain/subagents/README.md +201 -0
  277. package/src/runtime/domain/subagents/agent-catalog.mjs +64 -0
  278. package/src/runtime/domain/subagents/agent-commands.domain.mjs +822 -0
  279. package/src/runtime/domain/subagents/agent-commands.ts +905 -0
  280. package/src/runtime/domain/subagents/agent-inspection.domain.mjs +398 -0
  281. package/src/runtime/domain/subagents/agent-inspection.ts +574 -0
  282. package/src/runtime/domain/subagents/agent-operations.domain.mjs +40 -0
  283. package/src/runtime/domain/subagents/agent-operations.ts +61 -0
  284. package/src/runtime/domain/subagents/agent-session-settings.domain.mjs +112 -0
  285. package/src/runtime/domain/subagents/agent-session-settings.ts +118 -0
  286. package/src/runtime/domain/subagents/agents-catalog-tool.domain.mjs +84 -0
  287. package/src/runtime/domain/subagents/agents-catalog-tool.ts +118 -0
  288. package/src/runtime/domain/subagents/assignment-outcomes.domain.mjs +276 -0
  289. package/src/runtime/domain/subagents/assignment-outcomes.ts +212 -0
  290. package/src/runtime/domain/subagents/assignment-projection.mjs +261 -0
  291. package/src/runtime/domain/subagents/assignment-report.domain.mjs +174 -0
  292. package/src/runtime/domain/subagents/assignment-report.ts +156 -0
  293. package/src/runtime/domain/subagents/batch.mjs +275 -0
  294. package/src/runtime/domain/subagents/callback-fields.domain.mjs +72 -0
  295. package/src/runtime/domain/subagents/callback-fields.ts +95 -0
  296. package/src/runtime/domain/subagents/capacity.mjs +108 -0
  297. package/src/runtime/domain/subagents/catalog-editor.domain.mjs +98 -0
  298. package/src/runtime/domain/subagents/catalog-editor.ts +125 -0
  299. package/src/runtime/domain/subagents/catalog-host-admission.domain.mjs +104 -0
  300. package/src/runtime/domain/subagents/catalog-host-admission.ts +85 -0
  301. package/src/runtime/domain/subagents/catalog-identity.domain.mjs +222 -0
  302. package/src/runtime/domain/subagents/catalog-identity.ts +258 -0
  303. package/src/runtime/domain/subagents/catalog-overlay.domain.mjs +9 -0
  304. package/src/runtime/domain/subagents/catalog-overlay.ts +10 -0
  305. package/src/runtime/domain/subagents/catalog-preferences.domain.mjs +164 -0
  306. package/src/runtime/domain/subagents/catalog-preferences.ts +139 -0
  307. package/src/runtime/domain/subagents/catalog-resolver.domain.mjs +366 -0
  308. package/src/runtime/domain/subagents/catalog-resolver.ts +540 -0
  309. package/src/runtime/domain/subagents/catalog-runtime.domain.mjs +570 -0
  310. package/src/runtime/domain/subagents/catalog-runtime.ts +680 -0
  311. package/src/runtime/domain/subagents/catalog-schema.domain.mjs +1331 -0
  312. package/src/runtime/domain/subagents/catalog-schema.ts +1563 -0
  313. package/src/runtime/domain/subagents/catalog-skill-edits.domain.mjs +95 -0
  314. package/src/runtime/domain/subagents/catalog-skill-edits.ts +116 -0
  315. package/src/runtime/domain/subagents/catalog-store.domain.mjs +808 -0
  316. package/src/runtime/domain/subagents/catalog-store.ts +1006 -0
  317. package/src/runtime/domain/subagents/catalog-ui.domain.mjs +651 -0
  318. package/src/runtime/domain/subagents/catalog-ui.ts +611 -0
  319. package/src/runtime/domain/subagents/child-apply-patch.domain.mjs +13 -0
  320. package/src/runtime/domain/subagents/child-apply-patch.ts +13 -0
  321. package/src/runtime/domain/subagents/child-codemode.domain.mjs +16 -0
  322. package/src/runtime/domain/subagents/child-codemode.ts +17 -0
  323. package/src/runtime/domain/subagents/child-dependencies.mjs +193 -0
  324. package/src/runtime/domain/subagents/child-incidents.domain.mjs +170 -0
  325. package/src/runtime/domain/subagents/child-incidents.ts +169 -0
  326. package/src/runtime/domain/subagents/child-operations.domain.mjs +986 -0
  327. package/src/runtime/domain/subagents/child-operations.ts +1191 -0
  328. package/src/runtime/domain/subagents/child-ownership.domain.mjs +205 -0
  329. package/src/runtime/domain/subagents/child-ownership.ts +160 -0
  330. package/src/runtime/domain/subagents/child-preflight.mjs +38 -0
  331. package/src/runtime/domain/subagents/child-process-list.domain.mjs +7 -0
  332. package/src/runtime/domain/subagents/child-process-list.ts +8 -0
  333. package/src/runtime/domain/subagents/child-runtime.mjs +67 -0
  334. package/src/runtime/domain/subagents/child-steer.domain.mjs +109 -0
  335. package/src/runtime/domain/subagents/child-steer.ts +102 -0
  336. package/src/runtime/domain/subagents/cleanup.domain.mjs +818 -0
  337. package/src/runtime/domain/subagents/cleanup.ts +1017 -0
  338. package/src/runtime/domain/subagents/codex-import.domain.mjs +575 -0
  339. package/src/runtime/domain/subagents/codex-import.ts +717 -0
  340. package/src/runtime/domain/subagents/completion.domain.mjs +6 -0
  341. package/src/runtime/domain/subagents/completion.mjs +152 -0
  342. package/src/runtime/domain/subagents/completion.ts +11 -0
  343. package/src/runtime/domain/subagents/config.domain.mjs +248 -0
  344. package/src/runtime/domain/subagents/config.json +15 -0
  345. package/src/runtime/domain/subagents/config.ts +328 -0
  346. package/src/runtime/domain/subagents/continuation-authority.domain.mjs +38 -0
  347. package/src/runtime/domain/subagents/continuation-authority.ts +31 -0
  348. package/src/runtime/domain/subagents/continuation-runtime.domain.mjs +89 -0
  349. package/src/runtime/domain/subagents/continuation-runtime.ts +88 -0
  350. package/src/runtime/domain/subagents/continuation.domain.mjs +942 -0
  351. package/src/runtime/domain/subagents/continuation.ts +1051 -0
  352. package/src/runtime/domain/subagents/delegation.domain.mjs +19 -0
  353. package/src/runtime/domain/subagents/delegation.ts +24 -0
  354. package/src/runtime/domain/subagents/effective-settings.domain.mjs +130 -0
  355. package/src/runtime/domain/subagents/effective-settings.ts +184 -0
  356. package/src/runtime/domain/subagents/extensions.domain.mjs +6 -0
  357. package/src/runtime/domain/subagents/extensions.mjs +164 -0
  358. package/src/runtime/domain/subagents/extensions.ts +19 -0
  359. package/src/runtime/domain/subagents/failures.domain.mjs +362 -0
  360. package/src/runtime/domain/subagents/failures.ts +319 -0
  361. package/src/runtime/domain/subagents/finalization.domain.mjs +168 -0
  362. package/src/runtime/domain/subagents/finalization.ts +218 -0
  363. package/src/runtime/domain/subagents/git-remotes.domain.mjs +351 -0
  364. package/src/runtime/domain/subagents/git-remotes.ts +413 -0
  365. package/src/runtime/domain/subagents/git-workspace.domain.mjs +337 -0
  366. package/src/runtime/domain/subagents/git-workspace.ts +430 -0
  367. package/src/runtime/domain/subagents/goal-provider.domain.mjs +125 -0
  368. package/src/runtime/domain/subagents/goal-provider.ts +132 -0
  369. package/src/runtime/domain/subagents/health-observation.domain.mjs +617 -0
  370. package/src/runtime/domain/subagents/health-observation.ts +818 -0
  371. package/src/runtime/domain/subagents/health-surface.mjs +284 -0
  372. package/src/runtime/domain/subagents/health.domain.mjs +261 -0
  373. package/src/runtime/domain/subagents/health.ts +343 -0
  374. package/src/runtime/domain/subagents/historical-attention.domain.mjs +37 -0
  375. package/src/runtime/domain/subagents/historical-attention.ts +35 -0
  376. package/src/runtime/domain/subagents/incident-model.domain.mjs +322 -0
  377. package/src/runtime/domain/subagents/incident-model.ts +358 -0
  378. package/src/runtime/domain/subagents/index.domain.mjs +4731 -0
  379. package/src/runtime/domain/subagents/index.ts +4781 -0
  380. package/src/runtime/domain/subagents/launch-abort.domain.mjs +13 -0
  381. package/src/runtime/domain/subagents/launch-abort.ts +21 -0
  382. package/src/runtime/domain/subagents/launch-context.domain.mjs +24 -0
  383. package/src/runtime/domain/subagents/launch-context.ts +23 -0
  384. package/src/runtime/domain/subagents/launch-digest.mjs +6 -0
  385. package/src/runtime/domain/subagents/lifecycle.domain.mjs +265 -0
  386. package/src/runtime/domain/subagents/lifecycle.ts +360 -0
  387. package/src/runtime/domain/subagents/list.domain.mjs +2 -0
  388. package/src/runtime/domain/subagents/list.mjs +152 -0
  389. package/src/runtime/domain/subagents/list.ts +19 -0
  390. package/src/runtime/domain/subagents/log-cursor.domain.mjs +217 -0
  391. package/src/runtime/domain/subagents/log-cursor.ts +268 -0
  392. package/src/runtime/domain/subagents/managed-background-capability.domain.mjs +10 -0
  393. package/src/runtime/domain/subagents/managed-background-capability.ts +9 -0
  394. package/src/runtime/domain/subagents/managed-failure-worker.mjs +36 -0
  395. package/src/runtime/domain/subagents/managed-launch-bootstrap.mjs +48 -0
  396. package/src/runtime/domain/subagents/managed-launch-client.domain.mjs +75 -0
  397. package/src/runtime/domain/subagents/managed-launch-client.ts +59 -0
  398. package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +627 -0
  399. package/src/runtime/domain/subagents/managed-launch-host.ts +504 -0
  400. package/src/runtime/domain/subagents/managed-launch-journal.mjs +17 -0
  401. package/src/runtime/domain/subagents/managed-launch-ownership.domain.mjs +29 -0
  402. package/src/runtime/domain/subagents/managed-launch-ownership.ts +22 -0
  403. package/src/runtime/domain/subagents/managed-launch-port.domain.mjs +2 -0
  404. package/src/runtime/domain/subagents/managed-launch-port.ts +25 -0
  405. package/src/runtime/domain/subagents/managed-launch-recovery.domain.mjs +29 -0
  406. package/src/runtime/domain/subagents/managed-launch-recovery.ts +45 -0
  407. package/src/runtime/domain/subagents/managed-worker-bridge.domain.mjs +63 -0
  408. package/src/runtime/domain/subagents/managed-worker-bridge.ts +48 -0
  409. package/src/runtime/domain/subagents/managed-worker.mjs +13 -0
  410. package/src/runtime/domain/subagents/model-resolution-core.domain.mjs +822 -0
  411. package/src/runtime/domain/subagents/model-resolution-core.ts +1074 -0
  412. package/src/runtime/domain/subagents/model-resolution.domain.mjs +22 -0
  413. package/src/runtime/domain/subagents/model-resolution.ts +32 -0
  414. package/src/runtime/domain/subagents/navigator.domain.mjs +6 -0
  415. package/src/runtime/domain/subagents/navigator.mjs +1233 -0
  416. package/src/runtime/domain/subagents/navigator.ts +39 -0
  417. package/src/runtime/domain/subagents/operation-bridge-types.domain.mjs +1012 -0
  418. package/src/runtime/domain/subagents/operation-bridge-types.ts +1156 -0
  419. package/src/runtime/domain/subagents/outage-observations.domain.mjs +84 -0
  420. package/src/runtime/domain/subagents/outage-observations.ts +73 -0
  421. package/src/runtime/domain/subagents/output-payload.domain.mjs +767 -0
  422. package/src/runtime/domain/subagents/output-payload.ts +987 -0
  423. package/src/runtime/domain/subagents/owned-exit.domain.mjs +12 -0
  424. package/src/runtime/domain/subagents/owned-exit.ts +12 -0
  425. package/src/runtime/domain/subagents/package.json +86 -0
  426. package/src/runtime/domain/subagents/park-checkpoint.domain.mjs +55 -0
  427. package/src/runtime/domain/subagents/park-checkpoint.ts +61 -0
  428. package/src/runtime/domain/subagents/parse.domain.mjs +1218 -0
  429. package/src/runtime/domain/subagents/parse.ts +1451 -0
  430. package/src/runtime/domain/subagents/permission-policy.domain.mjs +232 -0
  431. package/src/runtime/domain/subagents/permission-policy.ts +291 -0
  432. package/src/runtime/domain/subagents/process-identity.mjs +33 -0
  433. package/src/runtime/domain/subagents/registry.domain.mjs +1584 -0
  434. package/src/runtime/domain/subagents/registry.ts +1904 -0
  435. package/src/runtime/domain/subagents/role-assignment.domain.mjs +104 -0
  436. package/src/runtime/domain/subagents/role-assignment.ts +141 -0
  437. package/src/runtime/domain/subagents/roles/role.architect.md +13 -0
  438. package/src/runtime/domain/subagents/roles/role.developer.md +16 -0
  439. package/src/runtime/domain/subagents/roles/role.explorer.md +13 -0
  440. package/src/runtime/domain/subagents/roles/role.product-manager.md +13 -0
  441. package/src/runtime/domain/subagents/roles/role.researcher.md +13 -0
  442. package/src/runtime/domain/subagents/roles/role.reviewer.md +13 -0
  443. package/src/runtime/domain/subagents/roles/role.writer.md +12 -0
  444. package/src/runtime/domain/subagents/sandbox.domain.mjs +64 -0
  445. package/src/runtime/domain/subagents/sandbox.ts +92 -0
  446. package/src/runtime/domain/subagents/session-selection.domain.mjs +32 -0
  447. package/src/runtime/domain/subagents/session-selection.ts +35 -0
  448. package/src/runtime/domain/subagents/session-store.domain.mjs +489 -0
  449. package/src/runtime/domain/subagents/session-store.ts +468 -0
  450. package/src/runtime/domain/subagents/settings-page.domain.mjs +313 -0
  451. package/src/runtime/domain/subagents/settings-page.ts +363 -0
  452. package/src/runtime/domain/subagents/shared-callback-batcher.domain.mjs +777 -0
  453. package/src/runtime/domain/subagents/shared-callback-batcher.ts +956 -0
  454. package/src/runtime/domain/subagents/shared-catalog.domain.mjs +70 -0
  455. package/src/runtime/domain/subagents/shared-catalog.ts +61 -0
  456. package/src/runtime/domain/subagents/shared-execution-policy.domain.mjs +50 -0
  457. package/src/runtime/domain/subagents/shared-execution-policy.ts +61 -0
  458. package/src/runtime/domain/subagents/shared-failure-observations.domain.mjs +1078 -0
  459. package/src/runtime/domain/subagents/shared-failure-observations.ts +1166 -0
  460. package/src/runtime/domain/subagents/shared-harness-settings.domain.mjs +126 -0
  461. package/src/runtime/domain/subagents/shared-harness-settings.ts +116 -0
  462. package/src/runtime/domain/subagents/shared-log-utils.domain.mjs +1223 -0
  463. package/src/runtime/domain/subagents/shared-log-utils.ts +1492 -0
  464. package/src/runtime/domain/subagents/shared-navigator-panels.domain.mjs +289 -0
  465. package/src/runtime/domain/subagents/shared-navigator-panels.ts +272 -0
  466. package/src/runtime/domain/subagents/shared-navigator.domain.mjs +1930 -0
  467. package/src/runtime/domain/subagents/shared-navigator.ts +1962 -0
  468. package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-inbox.mjs +144 -0
  469. package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-observation.mjs +189 -0
  470. package/src/runtime/domain/subagents/shared-operation-coordinator/index.domain.mjs +51 -0
  471. package/src/runtime/domain/subagents/shared-operation-coordinator/index.ts +122 -0
  472. package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
  473. package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.ts +73 -0
  474. package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
  475. package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
  476. package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
  477. package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
  478. package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
  479. package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.ts +90 -0
  480. package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
  481. package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.ts +139 -0
  482. package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.domain.mjs +12 -0
  483. package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.ts +79 -0
  484. package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.domain.mjs +342 -0
  485. package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.ts +513 -0
  486. package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
  487. package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.ts +458 -0
  488. package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
  489. package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.ts +55 -0
  490. package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
  491. package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.ts +140 -0
  492. package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.domain.mjs +280 -0
  493. package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.ts +442 -0
  494. package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +420 -0
  495. package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +441 -0
  496. package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
  497. package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.ts +239 -0
  498. package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +275 -0
  499. package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +585 -0
  500. package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
  501. package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.ts +142 -0
  502. package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
  503. package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.ts +224 -0
  504. package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.domain.mjs +25 -0
  505. package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.ts +707 -0
  506. package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
  507. package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.ts +22 -0
  508. package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.domain.mjs +234 -0
  509. package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.ts +241 -0
  510. package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.domain.mjs +851 -0
  511. package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.ts +1424 -0
  512. package/src/runtime/domain/subagents/shared-permission-blocker.domain.mjs +40 -0
  513. package/src/runtime/domain/subagents/shared-permission-blocker.ts +48 -0
  514. package/src/runtime/domain/subagents/shared-render-scheduler.domain.mjs +41 -0
  515. package/src/runtime/domain/subagents/shared-render-scheduler.ts +47 -0
  516. package/src/runtime/domain/subagents/shared-sandbox-core.domain.mjs +1531 -0
  517. package/src/runtime/domain/subagents/shared-sandbox-core.ts +1757 -0
  518. package/src/runtime/domain/subagents/shared-sandbox-diagnostics.domain.mjs +591 -0
  519. package/src/runtime/domain/subagents/shared-sandbox-diagnostics.ts +491 -0
  520. package/src/runtime/domain/subagents/shared-stall-detector.domain.mjs +37 -0
  521. package/src/runtime/domain/subagents/shared-stall-detector.ts +69 -0
  522. package/src/runtime/domain/subagents/shared-task-application.domain.mjs +185 -0
  523. package/src/runtime/domain/subagents/shared-task-application.ts +185 -0
  524. package/src/runtime/domain/subagents/shared-task-apply-patch.domain.mjs +416 -0
  525. package/src/runtime/domain/subagents/shared-task-apply-patch.ts +409 -0
  526. package/src/runtime/domain/subagents/shared-task-exec.domain.mjs +325 -0
  527. package/src/runtime/domain/subagents/shared-task-exec.ts +335 -0
  528. package/src/runtime/domain/subagents/shared-task-files.domain.mjs +346 -0
  529. package/src/runtime/domain/subagents/shared-task-files.ts +342 -0
  530. package/src/runtime/domain/subagents/shared-task-process-identity.domain.mjs +140 -0
  531. package/src/runtime/domain/subagents/shared-task-process-identity.ts +126 -0
  532. package/src/runtime/domain/subagents/shared-task-process-list.domain.mjs +220 -0
  533. package/src/runtime/domain/subagents/shared-task-process-list.ts +209 -0
  534. package/src/runtime/domain/subagents/shared-task-sandbox.domain.mjs +227 -0
  535. package/src/runtime/domain/subagents/shared-task-sandbox.ts +224 -0
  536. package/src/runtime/domain/subagents/shared-task-tools.domain.mjs +92 -0
  537. package/src/runtime/domain/subagents/shared-task-tools.ts +123 -0
  538. package/src/runtime/domain/subagents/shared-work-client.mjs +303 -0
  539. package/src/runtime/domain/subagents/shared-worktree-context.domain.mjs +142 -0
  540. package/src/runtime/domain/subagents/shared-worktree-context.ts +158 -0
  541. package/src/runtime/domain/subagents/skill-picker.domain.mjs +316 -0
  542. package/src/runtime/domain/subagents/skill-picker.ts +353 -0
  543. package/src/runtime/domain/subagents/skills.domain.mjs +138 -0
  544. package/src/runtime/domain/subagents/skills.ts +183 -0
  545. package/src/runtime/domain/subagents/spawn.domain.mjs +72 -0
  546. package/src/runtime/domain/subagents/spawn.ts +80 -0
  547. package/src/runtime/domain/subagents/stop.domain.mjs +184 -0
  548. package/src/runtime/domain/subagents/stop.ts +217 -0
  549. package/src/runtime/domain/subagents/subagent-tools.domain.mjs +101 -0
  550. package/src/runtime/domain/subagents/subagent-tools.ts +137 -0
  551. package/src/runtime/domain/subagents/task-guard.domain.mjs +163 -0
  552. package/src/runtime/domain/subagents/task-guard.ts +144 -0
  553. package/src/runtime/domain/subagents/task-policy.domain.mjs +201 -0
  554. package/src/runtime/domain/subagents/task-policy.ts +236 -0
  555. package/src/runtime/domain/subagents/task-runtime.mjs +53 -0
  556. package/src/runtime/domain/subagents/task-tool-owner.domain.mjs +18 -0
  557. package/src/runtime/domain/subagents/task-tool-owner.ts +21 -0
  558. package/src/runtime/domain/subagents/thinking.domain.mjs +22 -0
  559. package/src/runtime/domain/subagents/thinking.ts +28 -0
  560. package/src/runtime/domain/subagents/tier-policy.domain.mjs +75 -0
  561. package/src/runtime/domain/subagents/tier-policy.ts +126 -0
  562. package/src/runtime/domain/subagents/timing-notifications.domain.mjs +51 -0
  563. package/src/runtime/domain/subagents/timing-notifications.ts +37 -0
  564. package/src/runtime/domain/subagents/timing.domain.mjs +487 -0
  565. package/src/runtime/domain/subagents/timing.ts +634 -0
  566. package/src/runtime/domain/subagents/tools.domain.mjs +558 -0
  567. package/src/runtime/domain/subagents/tools.ts +629 -0
  568. package/src/runtime/domain/subagents/widget.domain.mjs +6 -0
  569. package/src/runtime/domain/subagents/widget.mjs +246 -0
  570. package/src/runtime/domain/subagents/widget.ts +30 -0
  571. package/src/runtime/domain/subagents/work-observation.domain.mjs +316 -0
  572. package/src/runtime/domain/subagents/work-observation.ts +248 -0
  573. package/src/runtime/domain/subagents/worker-catalog.domain.mjs +120 -0
  574. package/src/runtime/domain/subagents/worker-catalog.ts +162 -0
  575. package/src/runtime/domain/subagents/worker-operations-host.domain.mjs +1009 -0
  576. package/src/runtime/domain/subagents/worker-operations-host.ts +1238 -0
  577. package/src/runtime/domain/subagents/worker-waits.domain.mjs +2336 -0
  578. package/src/runtime/domain/subagents/worker-waits.ts +2878 -0
  579. package/src/runtime/domain/subagents/workspace-scope.domain.mjs +52 -0
  580. package/src/runtime/domain/subagents/workspace-scope.ts +50 -0
  581. package/src/runtime/health-config.ts +27 -11
  582. package/src/runtime/log-checkpoints.ts +117 -0
  583. package/src/runtime/mutation-store.ts +5 -4
  584. package/src/runtime/queries.ts +27 -3
  585. package/src/runtime/query-executor.ts +178 -34
  586. package/src/runtime/query-worker.mjs +119 -22
  587. package/src/runtime/read-model.ts +939 -113
  588. package/src/runtime/read-watchdog-probe.ts +4 -0
  589. package/src/runtime/result-supervision.ts +188 -16
  590. package/src/runtime/source-watch.ts +175 -0
  591. package/src/runtime/subagent-launch.ts +73 -0
  592. package/src/runtime/work-budget.ts +130 -0
  593. package/src/runtime/work-client.d.mts +8 -0
  594. package/src/runtime/work-client.mjs +150 -7
  595. package/src/server.ts +185 -22
  596. package/src/session-activity.ts +26 -4
  597. package/src/version.ts +1 -1
@@ -0,0 +1,867 @@
1
+ // Generated fixed launch domain from packages/pi-better-background-tasks/src/output.ts. Do not edit directly.
2
+ import { actionableFailures, failureRevision, formatFailureLines, formatFailureSummary, formatIncidentSummary, historyTailLine, incidentCursorScope, incidentPageHeading, incidentResource, incidentVerbatimPage, isIncidentCursor, pendingAttentionNote, pendingFailureAttention, quietFailureLine, readFailureState, terminalFailureParts, scopedFailures, } from "./shared-failure-observations.domain.mjs";
3
+ import { assemblePriorityEnvelope, clampBudgetBytes, cursorKind, formatUnchangedEvidence, inspectStatusRevision, lifecycleContentRevision, pageRows, pageVerbatimText, revisionOf, sessionScopeKey, sliceUtf8Bytes, utf8ByteLength, OUTPUT_BUDGET_BYTES, OUTPUT_BUDGET_MAX_BYTES, OUTPUT_PAGE_DEFAULTS, } from "./shared-log-utils.domain.mjs";
4
+ import { failurePath } from "./failures.domain.mjs";
5
+ import { captureGapsFor, pageTaskLog, readLog } from "./logs.domain.mjs";
6
+ import { belongsToOrigin, inspectMeta, listTaskRecords, originOf } from "./registry.domain.mjs";
7
+ import { formatBackgroundTaskStall, observeBackgroundTaskStall } from "./stall.domain.mjs";
8
+ /**
9
+ * Issue #312 consumer budgets. Defaults follow OUTPUT-POLICY / shared
10
+ * `OUTPUT_BUDGET_BYTES`. Explicit larger pages clamp to `OUTPUT_BUDGET_MAX_BYTES`
11
+ * (hard caps). Totals are UTF-8 bytes of the whole model-facing `content`,
12
+ * including headers, failures, gaps, and continuation.
13
+ */
14
+ export const BACKGROUND_OUTPUT_BUDGET_BYTES = {
15
+ status: OUTPUT_BUDGET_BYTES.status,
16
+ log: OUTPUT_BUDGET_BYTES.log,
17
+ list: OUTPUT_BUDGET_BYTES.list,
18
+ rawPage: OUTPUT_BUDGET_BYTES.rawPage,
19
+ };
20
+ export const BACKGROUND_OUTPUT_HARD_CAP_BYTES = {
21
+ status: OUTPUT_BUDGET_MAX_BYTES.status,
22
+ log: OUTPUT_BUDGET_MAX_BYTES.log,
23
+ list: OUTPUT_BUDGET_MAX_BYTES.list,
24
+ rawPage: OUTPUT_BUDGET_MAX_BYTES.rawPage,
25
+ };
26
+ export const DEFAULT_LOG_TAIL_ROWS = OUTPUT_PAGE_DEFAULTS.logLines;
27
+ export const DEFAULT_LIST_ENTRIES = OUTPUT_PAGE_DEFAULTS.listEntries;
28
+ const MAX_LIST_ENTRIES = 100;
29
+ const STATUS_EXCERPT_ROWS = 3;
30
+ /** Longest incident preview a list lead-in may show; the rest is on bg_task_status. */
31
+ const LIST_LEAD_PREVIEW_BYTES = 200;
32
+ export function backgroundBudget(surface, requested) {
33
+ const fallback = BACKGROUND_OUTPUT_BUDGET_BYTES[surface];
34
+ const hard = BACKGROUND_OUTPUT_HARD_CAP_BYTES[surface];
35
+ return Math.min(clampBudgetBytes(requested, fallback), hard);
36
+ }
37
+ function oneLine(value, maxLength) {
38
+ const raw = typeof value === "string" ? value : JSON.stringify(value);
39
+ const single = String(raw ?? "").replace(/\s+/g, " ").trim();
40
+ return single.length <= maxLength ? single : `${single.slice(0, Math.max(0, maxLength - 1))}…`;
41
+ }
42
+ function formatDuration(ms) {
43
+ const seconds = Math.max(0, Math.round(ms / 1000));
44
+ if (seconds < 60)
45
+ return `${seconds}s`;
46
+ const minutes = Math.floor(seconds / 60);
47
+ const rest = seconds % 60;
48
+ return `${minutes}m${rest.toString().padStart(2, "0")}s`;
49
+ }
50
+ function stringifyObserved(value) {
51
+ if (value === undefined)
52
+ return "undefined";
53
+ if (typeof value === "string")
54
+ return oneLine(value, 200);
55
+ try {
56
+ return oneLine(JSON.stringify(value), 200);
57
+ }
58
+ catch {
59
+ return oneLine(String(value), 200);
60
+ }
61
+ }
62
+ /** Cursor scope: pagination and revision cursors never cross session scopes. */
63
+ function scopeKey(options) {
64
+ return sessionScopeKey({ all: options.all, unavailable: options.sessionUnavailable, origin: options.origin, processId: process.pid });
65
+ }
66
+ function taskGaps(meta) {
67
+ const gaps = [];
68
+ if (meta.logDiscardedBytes) {
69
+ gaps.push({
70
+ kind: "retention",
71
+ bytes: meta.logDiscardedBytes,
72
+ detail: `${meta.logRetentionEvents ?? 1} compaction(s); discarded bytes are not recoverable`,
73
+ });
74
+ }
75
+ for (const gap of captureGapsFor(meta)) {
76
+ gaps.push({ kind: "capture", bytes: gap.bytes, detail: gap.detail });
77
+ }
78
+ return gaps;
79
+ }
80
+ function failureStateFor(id) {
81
+ return readFailureState(failurePath(id));
82
+ }
83
+ /**
84
+ * Failure section computed for the exact bytes the envelope grants it: whole
85
+ * incident rows when they fit, otherwise a count line (total / shown /
86
+ * omitted) with an incident cursor that resumes at the first byte not shown.
87
+ */
88
+ function incidentSection(id, options, state = failureStateFor(id), detail = "compact") {
89
+ // Only what needs action is listed; history (expected, closed) is one count line without a cursor.
90
+ if (!formatIncidentSummary(state, { maxBytes: Number.MAX_SAFE_INTEGER }).text)
91
+ return undefined;
92
+ const resource = incidentResource(scopeKey(options), id);
93
+ return (budget) => formatIncidentSummary(state, {
94
+ maxBytes: budget,
95
+ resource,
96
+ retrieval: `pass as cursor to bg_task_status id=${id}`,
97
+ detail,
98
+ }).text || undefined;
99
+ }
100
+ function assembleIncidentPage(meta, options) {
101
+ const state = failureStateFor(meta.id);
102
+ const resource = incidentResource(scopeKey(options), meta.id);
103
+ const cursor = isIncidentCursor(options.cursor) ? options.cursor : undefined;
104
+ const scope = options.history ? "all" : incidentCursorScope(cursor) ?? "actionable";
105
+ return assembleBackgroundContent({
106
+ surface: "status",
107
+ maxBytes: options.maxBytes,
108
+ sections: {
109
+ identity: `${identityLine(meta)} ${incidentPageHeading(scopedFailures(state, scope).length, scope)}`,
110
+ decision: formatDecision(meta),
111
+ },
112
+ verbatim: (budget) => incidentVerbatimPage(state, { cursor, scope, maxBytes: budget, resource }),
113
+ });
114
+ }
115
+ function formatCondition(condition, observed) {
116
+ switch (condition.type) {
117
+ case "exit_code":
118
+ return `Condition matched: exit_code = ${condition.equals}\nobserved: ${stringifyObserved(observed ?? condition.equals)}`;
119
+ case "json_path_equals":
120
+ return `Condition matched: ${condition.path} = ${stringifyObserved(condition.value)}\nobserved: ${stringifyObserved(observed)}`;
121
+ case "json_path_exists":
122
+ return `Condition matched: ${condition.path} exists\nobserved: ${stringifyObserved(observed)}`;
123
+ case "stdout_contains":
124
+ return `Condition matched: stdout_contains ${JSON.stringify(condition.value)}`;
125
+ case "stderr_contains":
126
+ return `Condition matched: stderr_contains ${JSON.stringify(condition.value)}`;
127
+ }
128
+ }
129
+ function resultFields(meta) {
130
+ if (!meta.result || typeof meta.result !== "object")
131
+ return {};
132
+ return meta.result;
133
+ }
134
+ /** Decision facts: stop error, matched condition and observed value, exit/signal, recorded error. */
135
+ function formatDecision(meta) {
136
+ const lines = [];
137
+ if (meta.status === "running" && meta.stopError) {
138
+ lines.push(`stop failed: ${oneLine(meta.stopError, 300)}`);
139
+ lines.push("The task may still be executing.");
140
+ }
141
+ const result = resultFields(meta);
142
+ if (result.matchedCondition) {
143
+ lines.push(formatCondition(result.matchedCondition, result.matchedValue));
144
+ }
145
+ if (meta.lastExitCode !== undefined || meta.lastSignal) {
146
+ // A gated task's exit can be a failing step's code rather than the last command's (#619).
147
+ const gate = meta.stepGateFailure ? " (step gate)" : "";
148
+ lines.push(`exit=${meta.lastExitCode ?? "null"}${meta.lastSignal ? ` signal=${meta.lastSignal}` : ""}${gate}`);
149
+ }
150
+ if (meta.stepGateFailure) {
151
+ // "stopped at that step" is the usual errexit case; a differing shell exit means the
152
+ // command disabled errexit and the gate's EXIT override or the command decided the exit.
153
+ const gate = meta.stepGateFailure;
154
+ const ending = gate.shellExitCode === null
155
+ ? "the shell exit is unknown"
156
+ : gate.shellExitCode === gate.stepExitCode
157
+ ? "the shell stopped at that step"
158
+ : `the shell's own exit was ${gate.shellExitCode}`;
159
+ lines.push(`step gate: ${oneLine(gate.command || "a chained step", 120)} exited ${gate.stepExitCode}; ${ending}`);
160
+ }
161
+ if (result.reason && !result.matchedCondition)
162
+ lines.push(oneLine(result.reason, 240));
163
+ if (meta.error && meta.error !== meta.stopError && meta.error !== result.reason) {
164
+ lines.push(`error: ${oneLine(meta.error, 300)}`);
165
+ }
166
+ return lines.length ? lines.join("\n") : undefined;
167
+ }
168
+ /**
169
+ * Completion-callback facts (no env/command dump). Incident rows are passed
170
+ * whole so the batch can count exactly which it shows.
171
+ */
172
+ export function formatCallbackFacts(meta) {
173
+ const state = failureStateFor(meta.id);
174
+ const pending = pendingFailureAttention(state, Date.now(), { terminal: true });
175
+ const incidents = pending?.incidents ?? [];
176
+ const rows = terminalFailureParts(state, incidents).rows;
177
+ const gapLines = [
178
+ meta.logDiscardedBytes ? `retention discarded ${meta.logDiscardedBytes} bytes; not recoverable` : undefined,
179
+ meta.captureDiscardedBytes ? `capture overflow discarded ${meta.captureDiscardedBytes} bytes; not full history` : undefined,
180
+ ].filter((line) => Boolean(line));
181
+ // History (expected and closed incidents) is not a row, but the callback still says it exists, so a
182
+ // declared expected exit is not read as a plain failure. It leads the decision: a tight callback
183
+ // budget keeps a prefix of the decision, and this short line must survive it (#332).
184
+ const history = actionableFailures(state).length ? historyTailLine(state) : quietFailureLine(state);
185
+ const decision = [history, pendingAttentionNote(state, incidents), formatDecision(meta), ...gapLines].filter(Boolean).join("\n") || undefined;
186
+ return {
187
+ outcome: meta.status,
188
+ ...(rows.length ? { failureRows: rows, incidentCount: rows.length } : {}),
189
+ decision,
190
+ };
191
+ }
192
+ function formatDiagnostics(meta, extra = []) {
193
+ const lines = [...extra];
194
+ if (meta.ssh)
195
+ lines.push(`remote: ${meta.ssh.target}`);
196
+ if (meta.remote?.session)
197
+ lines.push(`remote mode: ${meta.remote.session}`);
198
+ if (meta.remote?.sessionName)
199
+ lines.push(`remote session: ${meta.remote.sessionName}`);
200
+ if (meta.remote?.bootstrapMessage)
201
+ lines.push(`remote setup: ${oneLine(meta.remote.bootstrapMessage, 180)}`);
202
+ if (meta.remote?.warning)
203
+ lines.push(`warning: ${oneLine(meta.remote.warning, 180)}`);
204
+ if (meta.remote?.stopMessage)
205
+ lines.push(`remote stop: ${oneLine(meta.remote.stopMessage, 180)}`);
206
+ if (meta.logDiscardedBytes) {
207
+ lines.push(`retention discarded ${meta.logDiscardedBytes} bytes in ${meta.logRetentionEvents ?? 1} compaction(s); not recoverable`);
208
+ }
209
+ if (meta.captureDiscardedBytes) {
210
+ lines.push(`capture overflow discarded ${meta.captureDiscardedBytes} bytes in ${meta.captureOverflowEvents ?? 1} event(s); not full history`);
211
+ }
212
+ return lines.length ? lines.join("\n") : undefined;
213
+ }
214
+ function formatProcessDiagnostics(diagnostics) {
215
+ if (!diagnostics)
216
+ return undefined;
217
+ const facts = diagnostics.availability === "available" && diagnostics.identity === "matches"
218
+ ? `identity matches; state=${diagnostics.state}; CPU=${diagnostics.cpuTime}; wait=${diagnostics.waitChannel}`
219
+ : diagnostics.reason ?? diagnostics.availability;
220
+ return `process diagnostics: ${facts}\nA snapshot cannot prove useful work or a hang.`;
221
+ }
222
+ function formatStepGate(meta) {
223
+ if (!meta.requireSuccessfulSteps)
224
+ return undefined;
225
+ return "step gate: on; the command runs under bash errexit, so its first unhandled failing step ends the task.";
226
+ }
227
+ function formatLaunchSandbox(meta) {
228
+ const sandbox = meta.sandbox;
229
+ if (!sandbox)
230
+ return "sandbox: unknown; launch-time policy was not recorded.";
231
+ const backend = sandbox.backend ? `; ${oneLine(sandbox.backend, 40)}` : "";
232
+ return `sandbox: ${sandbox.confinement}${backend}; source: ${oneLine(sandbox.policySource, 80)}; later changes do not affect this task.`;
233
+ }
234
+ function formatStaleProgress(stall) {
235
+ if (!stall)
236
+ return undefined;
237
+ const summary = formatBackgroundTaskStall(stall);
238
+ if (!summary)
239
+ return undefined;
240
+ return `progress: ${summary}; last observed: ${new Date(stall.observedAt).toISOString()}.\nSilence alone does not prove the task is hung.`;
241
+ }
242
+ function formatProgress(meta) {
243
+ const lines = [`kind: ${meta.kind}`];
244
+ if (meta.name)
245
+ lines.push(`name: ${oneLine(meta.name, 80)}`);
246
+ lines.push(`elapsed: ${formatDuration((meta.endedAt ?? Date.now()) - meta.startedAt)}`);
247
+ if (meta.deadlineAt && meta.status === "running") {
248
+ lines.push(`deadline: ${formatDuration(meta.deadlineAt - Date.now())} left`);
249
+ }
250
+ if (meta.lastCheckedAt)
251
+ lines.push(`last check: ${formatDuration(Date.now() - meta.lastCheckedAt)} ago`);
252
+ if (meta.lastState !== undefined)
253
+ lines.push(`last state: ${oneLine(meta.lastState, 120)}`);
254
+ return lines.join("\n");
255
+ }
256
+ function identityLine(meta) {
257
+ const stop = meta.status === "running" && meta.stopError ? " · stop failed" : "";
258
+ return `Background task ${meta.id} is ${meta.status}${stop}.`;
259
+ }
260
+ /** Lifecycle, result, and retained-log facts. A deleted or rewritten log is a change. */
261
+ function contentRevision(meta, stall) {
262
+ return lifecycleContentRevision([
263
+ stall ? [stall.state, stall.observedAt ?? null] : null,
264
+ meta.sandbox ?? null,
265
+ meta.status,
266
+ meta.endedAt ?? null,
267
+ meta.lastCheckedAt ?? null,
268
+ meta.lastProgressAt ?? null,
269
+ meta.lastExitCode ?? null,
270
+ meta.lastSignal ?? null,
271
+ meta.requireSuccessfulSteps ?? null,
272
+ meta.stepGateFailure ?? null,
273
+ meta.error ?? null,
274
+ meta.stopError ?? null,
275
+ meta.logGeneration ?? 0,
276
+ meta.logDiscardedBytes ?? 0,
277
+ meta.captureDiscardedBytes ?? 0,
278
+ meta.result ?? null,
279
+ meta.lastState ?? null,
280
+ meta.remote?.bootstrapStatus ?? null,
281
+ meta.remote?.stopMessage ?? null,
282
+ ], meta.logPath);
283
+ }
284
+ export function assembleBackgroundContent(input) {
285
+ const maxBytes = backgroundBudget(input.surface, input.maxBytes);
286
+ return assemblePriorityEnvelope({
287
+ maxBytes,
288
+ sections: input.sections,
289
+ verbatim: input.verbatim,
290
+ // Explicit evidence pages always advance: half the page is held for bytes.
291
+ // Explicit evidence pages and list rows always get room: half the page
292
+ // is held back from failure/diagnostic sections.
293
+ verbatimReserve: input.surface === "rawPage" || input.surface === "list" ? Math.floor(maxBytes / 2) : undefined,
294
+ gaps: input.gaps,
295
+ statusCursor: input.statusCursor,
296
+ // ADR 0006 surface contract: background summaries lead with failures.
297
+ failureFirst: true,
298
+ }).text;
299
+ }
300
+ export function formatMissingTask(inspection, options = {}) {
301
+ if (inspection.found || inspection.error) {
302
+ return assembleBackgroundContent({
303
+ surface: "status",
304
+ maxBytes: options.maxBytes,
305
+ sections: {
306
+ identity: `Background task ${inspection.id} metadata is unreadable.`,
307
+ diagnostics: [
308
+ inspection.error ?? "metadata could not be read",
309
+ "Cannot treat this as an empty or nonexistent task.",
310
+ ].join("\n"),
311
+ },
312
+ gaps: [{ kind: "read", detail: inspection.error ?? "unreadable metadata" }],
313
+ });
314
+ }
315
+ return assembleBackgroundContent({
316
+ surface: "status",
317
+ maxBytes: options.maxBytes,
318
+ sections: {
319
+ identity: `No background task found for id ${inspection.id}.`,
320
+ },
321
+ });
322
+ }
323
+ function formatOwnershipGap(id, kind, options) {
324
+ const detail = kind === "foreign"
325
+ ? "This task belongs to another session. Pass all:true to inspect it."
326
+ : options.sessionUnavailable
327
+ ? "The current session identity is unavailable, so ownership cannot be verified. Cannot treat this as nonexistent or healthy. Pass all:true to inspect."
328
+ : "Task ownership is unavailable or unreadable. Cannot treat this as nonexistent or healthy. Pass all:true to inspect.";
329
+ return assembleBackgroundContent({
330
+ surface: "status",
331
+ maxBytes: options.maxBytes,
332
+ sections: {
333
+ identity: `Background task ${id} is outside the current session scope.`,
334
+ diagnostics: detail,
335
+ },
336
+ gaps: [{ kind: "read", detail: kind === "foreign" ? "foreign-session" : "ownership-unavailable" }],
337
+ });
338
+ }
339
+ /**
340
+ * Refusal for a mutation (stop, clear) of a task outside the current session
341
+ * scope. Mutations use the same ownership rule as reads (#322): only an owned
342
+ * task changes; nothing about a foreign or unverifiable task is disclosed.
343
+ */
344
+ export function formatMutationRefusal(id, kind, action, options) {
345
+ const verb = action === "stop" ? "stopped" : "dismissed";
346
+ const detail = kind === "foreign"
347
+ ? `This task belongs to another session, so it was not ${verb}. Pass all:true to ${action} it explicitly.`
348
+ : options.sessionUnavailable
349
+ ? `The current session identity is unavailable, so ownership cannot be verified and the task was not ${verb}. Pass all:true to ${action} it explicitly.`
350
+ : `Task ownership is unavailable or unreadable, so the task was not ${verb}. Pass all:true to ${action} it explicitly.`;
351
+ return assembleBackgroundContent({
352
+ surface: "status",
353
+ maxBytes: options.maxBytes,
354
+ sections: {
355
+ identity: `Background task ${id} is outside the current session scope; not ${verb}.`,
356
+ diagnostics: detail,
357
+ },
358
+ gaps: [{ kind: "read", detail: kind === "foreign" ? "foreign-session" : "ownership-unavailable" }],
359
+ });
360
+ }
361
+ /**
362
+ * Current-session ownership, shared by reads and mutations. Without a current
363
+ * session id, ownership is only verified for a task this process launched with
364
+ * the same sessionless origin; a legacy task with no recorded origin is never
365
+ * assumed to be ours.
366
+ */
367
+ export function classifyOwnership(meta, options) {
368
+ if (options.all === true)
369
+ return "allow";
370
+ if (options.sessionUnavailable)
371
+ return "unknown";
372
+ const origin = options.origin;
373
+ if (!origin)
374
+ return "allow";
375
+ if (!origin.sessionId) {
376
+ const recorded = meta.callbackOrigin;
377
+ if (!recorded)
378
+ return "unknown";
379
+ if (recorded.cwd === origin.cwd && !recorded.sessionId && meta.spawnPid === process.pid)
380
+ return "allow";
381
+ return recorded.sessionId ? "foreign" : "unknown";
382
+ }
383
+ if (belongsToOrigin(meta, origin))
384
+ return "allow";
385
+ const taskOrigin = originOf(meta);
386
+ if (!meta.callbackOrigin || (!taskOrigin.sessionId && origin.sessionId))
387
+ return "unknown";
388
+ return "foreign";
389
+ }
390
+ function asInspection(inspection, idOrOptions) {
391
+ if (!inspection) {
392
+ return { id: typeof idOrOptions === "string" ? idOrOptions : "", found: false, readable: false };
393
+ }
394
+ if (typeof inspection === "object" && ("found" in inspection || "readable" in inspection)) {
395
+ return inspection;
396
+ }
397
+ const meta = inspection;
398
+ return { id: meta.id, meta, found: true, readable: true };
399
+ }
400
+ /**
401
+ * Launch result. For a watch, `firstCheck` reports its first check (#359): the check's result,
402
+ * or why the launch stopped waiting while it was still running.
403
+ *
404
+ * The first check gets whatever the status budget leaves after the rest of the launch text, so
405
+ * nothing else is clipped for it. The log path is kept whole or dropped whole: a clipped path
406
+ * looks valid but points nowhere.
407
+ */
408
+ export function formatLaunch(meta, firstCheck) {
409
+ const label = meta.name ? `${meta.name} (${meta.id})` : meta.id;
410
+ const remoteLines = [
411
+ ...(meta.ssh ? [`Remote: ${meta.ssh.target}${meta.remote?.session ? ` mode=${meta.remote.session}` : ""}${meta.remote?.sessionName ? ` session=${meta.remote.sessionName}` : ""}.`] : []),
412
+ ...(meta.remote?.bootstrapMessage ? [`Remote setup: ${meta.remote.bootstrapMessage}`] : []),
413
+ ...(meta.remote?.warning ? [`Warning: ${meta.remote.warning}`] : []),
414
+ ];
415
+ const logLine = `Log: ${meta.logPath}`;
416
+ const build = (checkText, withLog) => assembleBackgroundContent({
417
+ surface: "status",
418
+ sections: {
419
+ identity: `Started background ${meta.kind} ${label}. Status: ${meta.status}.`,
420
+ failure: incidentSection(meta.id, {}),
421
+ decision: formatDecision(meta),
422
+ diagnostics: [formatLaunchSandbox(meta), formatStepGate(meta), ...remoteLines, ...(checkText ? [checkText] : [])].filter(Boolean).join("\n") || undefined,
423
+ progress: withLog ? logLine : undefined,
424
+ },
425
+ gaps: taskGaps(meta),
426
+ });
427
+ let checkText;
428
+ if (firstCheck) {
429
+ const room = backgroundBudget("status") - utf8ByteLength(build(undefined, true)) - 1;
430
+ checkText = formatFirstWatchCheck(meta, firstCheck, room);
431
+ }
432
+ const text = build(checkText, true);
433
+ return text.includes(logLine) ? text : build(checkText, false);
434
+ }
435
+ const FIRST_CHECK_TAIL_LINES = 3;
436
+ const FIRST_CHECK_LINE_CHARS = 200;
437
+ function tailLines(text) {
438
+ return text.split(/\r?\n/).map((line) => line.replace(/\s+/g, " ").trim()).filter(Boolean)
439
+ .slice(-FIRST_CHECK_TAIL_LINES)
440
+ .map((line) => line.length > FIRST_CHECK_LINE_CHARS ? `${line.slice(0, FIRST_CHECK_LINE_CHARS - 1)}…` : line);
441
+ }
442
+ function pendingFirstCheckText(check) {
443
+ switch (check.pending) {
444
+ case "aborted":
445
+ return "First check still running; stopped waiting because the tool call was cancelled. The watch continues in the background; check it later with bg_task_status.";
446
+ case "suspended":
447
+ return "First check still running when the session shut down. The watch continues when its session resumes; check it later with bg_task_status.";
448
+ default:
449
+ return `First check still running after ${formatDuration(check.waitedMs)}; the watch continues in the background. Check it later with bg_task_status.`;
450
+ }
451
+ }
452
+ /**
453
+ * The first check of a watch in at most `maxBytes` (#359). What matters most is kept first: the
454
+ * outcome, the exit-0-with-stderr warning, the newest stderr lines, then the newest stdout lines,
455
+ * so stdout is cut first. Lines are shown oldest to newest.
456
+ */
457
+ export function formatFirstWatchCheck(meta, check, maxBytes = Number.MAX_SAFE_INTEGER) {
458
+ if ("pending" in check)
459
+ return pendingFirstCheckText(check);
460
+ if (check.error)
461
+ return `First check could not run: ${oneLine(check.error, 300)}`;
462
+ const outcome = check.timedOut ? "timed out" : check.signal ? `signal ${check.signal}` : `exit ${check.exitCode ?? "unknown"}`;
463
+ const took = check.durationMs < 1000 ? `${check.durationMs}ms` : formatDuration(check.durationMs);
464
+ const header = `First check: ${outcome} in ${took}.`;
465
+ const stdout = tailLines(check.stdout);
466
+ const stderr = tailLines(check.stderr);
467
+ const warning = check.exitCode === 0 && stderr.length && meta.status === "running"
468
+ ? "The check exited 0 but wrote stderr: if it is broken, the watch cannot tell. Let errors exit non-zero."
469
+ : undefined;
470
+ const keptErr = [];
471
+ const keptOut = [];
472
+ let keptEmptyStdout = false;
473
+ const render = () => [
474
+ header,
475
+ ...(warning ? [warning] : []),
476
+ ...(keptErr.length ? [`stderr tail:\n${keptErr.map((line) => ` ${line}`).join("\n")}`] : []),
477
+ ...(keptOut.length ? [`stdout tail:\n${keptOut.map((line) => ` ${line}`).join("\n")}`] : []),
478
+ ...(keptEmptyStdout ? ["stdout: (empty)"] : []),
479
+ ].join("\n");
480
+ const omissionNote = () => {
481
+ const omitted = (stderr.length - keptErr.length) + (stdout.length - keptOut.length);
482
+ return omitted > 0 ? `(${omitted} output line${omitted === 1 ? "" : "s"} omitted; see bg_task_log)` : undefined;
483
+ };
484
+ const fits = () => utf8ByteLength([render(), omissionNote()].filter(Boolean).join("\n")) <= maxBytes;
485
+ // Newest first within each stream; each kept line goes in front to stay in order.
486
+ for (const line of [...stderr].reverse()) {
487
+ keptErr.unshift(line);
488
+ if (!fits()) {
489
+ keptErr.shift();
490
+ break;
491
+ }
492
+ }
493
+ for (const line of [...stdout].reverse()) {
494
+ keptOut.unshift(line);
495
+ if (!fits()) {
496
+ keptOut.shift();
497
+ break;
498
+ }
499
+ }
500
+ if (!stdout.length) {
501
+ keptEmptyStdout = true;
502
+ if (!fits())
503
+ keptEmptyStdout = false;
504
+ }
505
+ return [render(), omissionNote()].filter(Boolean).join("\n");
506
+ }
507
+ function redactedVerbose(meta, options) {
508
+ const { env, ...rest } = meta;
509
+ const state = failureStateFor(meta.id);
510
+ const observations = Object.values(state.observations);
511
+ const body = {
512
+ ...rest,
513
+ sandbox: meta.sandbox ?? { confinement: "unknown", policySummary: "Launch-time policy was not recorded." },
514
+ ...(options.processDiagnostics ? { processDiagnostics: options.processDiagnostics } : {}),
515
+ ...(env ? { env: { omitted: true, keyCount: Object.keys(env).length } } : {}),
516
+ };
517
+ if (!observations.length)
518
+ return body;
519
+ return {
520
+ failureSummary: formatFailureSummary(state),
521
+ failureJournal: failurePath(meta.id),
522
+ failureObservations: observations.map((observation) => ({
523
+ ...observation,
524
+ attentionDeliveredAt: state.delivered[observation.id],
525
+ })),
526
+ ...body,
527
+ };
528
+ }
529
+ /**
530
+ * Verbose metadata is explicit evidence under the raw-page budget. When the
531
+ * whole document fits it is returned as plain JSON; otherwise it is paged
532
+ * with a caller cursor like any other retained evidence.
533
+ */
534
+ /** Bounded raw metadata for canonical supervisor tasks. These records contain no
535
+ * environment values and do not invent legacy process ownership fields. */
536
+ export function formatDurableStatusMetadata(meta, options) {
537
+ const json = JSON.stringify(meta, null, 2);
538
+ if (!options.cursor && utf8ByteLength(json) <= backgroundBudget("rawPage", options.maxBytes))
539
+ return json;
540
+ return assembleBackgroundContent({
541
+ surface: "rawPage", maxBytes: options.maxBytes,
542
+ sections: { identity: `Background task ${meta.id} metadata (environment values omitted).` },
543
+ verbatim: budget => pageVerbatimText(json, { cursor: options.cursor, maxBytes: budget, resource: `verbose:${scopeKey(options)}:${meta.id}` }),
544
+ });
545
+ }
546
+ function formatVerbose(meta, options) {
547
+ const json = JSON.stringify(redactedVerbose(meta, options), null, 2);
548
+ const resource = `verbose:${scopeKey(options)}:${meta.id}`;
549
+ if (!options.cursor && utf8ByteLength(json) <= backgroundBudget("rawPage", options.maxBytes))
550
+ return json;
551
+ // Live process samples are not part of the paged document: CPU/state changes
552
+ // must not invalidate continuation, even when diagnostics is omitted next time.
553
+ const stableJson = JSON.stringify(redactedVerbose(meta, { ...options, processDiagnostics: undefined }), null, 2);
554
+ return assembleBackgroundContent({
555
+ surface: "rawPage",
556
+ maxBytes: options.maxBytes,
557
+ sections: {
558
+ identity: `Background task ${meta.id} metadata (environment values omitted).`,
559
+ diagnostics: formatProcessDiagnostics(options.processDiagnostics),
560
+ },
561
+ verbatim: (budget) => pageVerbatimText(stableJson, { cursor: options.cursor, maxBytes: budget, resource }),
562
+ });
563
+ }
564
+ /** Retained raw log pages for this task in this scope. */
565
+ function rawLogPage(meta, options, cursor, budget) {
566
+ return pageTaskLog(meta, { cursor, maxBytes: budget, resource: `log:${scopeKey(options)}:${meta.id}` });
567
+ }
568
+ /**
569
+ * A compact newest-rows excerpt. When earlier rows, older bytes, or a long
570
+ * line's prefix are not shown, the page says so and its cursor starts a raw
571
+ * page at the oldest retained byte (bg_task_log), so nothing is hidden.
572
+ */
573
+ function excerptPage(meta, options, log, budget) {
574
+ const text = log.text || "(log is empty)";
575
+ const encoded = utf8ByteLength(text);
576
+ let body = text;
577
+ if (encoded > budget) {
578
+ const slice = sliceUtf8Bytes(text, encoded - budget, budget, false);
579
+ body = slice.bytes <= budget ? slice.text : "";
580
+ if (slice.startByte > 0) {
581
+ const newline = body.indexOf("\n");
582
+ if (newline >= 0 && newline < body.length - 1)
583
+ body = body.slice(newline + 1);
584
+ }
585
+ }
586
+ const shownBytes = log.text ? utf8ByteLength(body) : 0;
587
+ const omittedSomething = Boolean(log.truncated) || shownBytes < utf8ByteLength(log.text);
588
+ if (!omittedSomething)
589
+ return { text: body, hasMore: false, omittedBytes: 0 };
590
+ const start = rawLogPage(meta, options, undefined, 0);
591
+ const rows = log.omittedRows ? `; ${log.omittedRows} earlier display row(s)` : "";
592
+ return {
593
+ text: body,
594
+ hasMore: true,
595
+ omittedBytes: Math.max(0, (log.totalBytes ?? 0) - shownBytes),
596
+ nextCursor: start.nextCursor,
597
+ via: `pass to bg_task_log id=${meta.id}: raw pages from the oldest retained byte${rows}`,
598
+ };
599
+ }
600
+ export function formatStatus(inspection, idOrOptions, maybeOptions) {
601
+ const inspectionValue = asInspection(inspection, idOrOptions);
602
+ const options = (typeof idOrOptions === "string" ? maybeOptions : idOrOptions) ?? {};
603
+ if (!inspectionValue.meta)
604
+ return formatMissingTask(inspectionValue, options);
605
+ const meta = inspectionValue.meta;
606
+ const ownership = classifyOwnership(meta, options);
607
+ if (ownership !== "allow")
608
+ return formatOwnershipGap(meta.id, ownership, options);
609
+ if (isIncidentCursor(options.cursor) || options.history)
610
+ return assembleIncidentPage(meta, options);
611
+ // A page cursor from another view of this task continues that view instead
612
+ // of resetting a status revision (#323): a raw/file cursor pages the log,
613
+ // a text cursor pages verbose metadata.
614
+ const pageKind = cursorKind(options.cursor);
615
+ if (pageKind === "f")
616
+ return formatLog(meta.id, { ...options, raw: true });
617
+ if (pageKind === "t")
618
+ return formatVerbose(meta, options);
619
+ if (options.verbose)
620
+ return formatVerbose(meta, options);
621
+ // A bg_task_list page cursor pages the list, not this task: say so rather than report it as a
622
+ // stale status cursor (#332).
623
+ const listCursor = pageKind === "l";
624
+ const state = failureStateFor(meta.id);
625
+ const stall = meta.status === "running" ? observeBackgroundTaskStall(meta) : undefined;
626
+ const staleProgress = formatStaleProgress(stall);
627
+ const sandbox = formatLaunchSandbox(meta);
628
+ const resource = `status:${scopeKey(options)}:${meta.id}`;
629
+ const revision = inspectStatusRevision({
630
+ resource,
631
+ contentRevision: contentRevision(meta, stall),
632
+ failureRevision: failureRevision(state),
633
+ cursor: listCursor ? undefined : options.cursor,
634
+ });
635
+ if (options.cursor && revision.change === "none") {
636
+ return assembleBackgroundContent({
637
+ surface: "status",
638
+ maxBytes: options.maxBytes,
639
+ sections: {
640
+ identity: `${identityLine(meta)} · unchanged`,
641
+ failure: actionableFailures(state).length
642
+ ? `${actionableFailures(state).length} active failure observation(s), unchanged.`
643
+ : undefined,
644
+ decision: [staleProgress, formatUnchangedEvidence(options.cursor)].filter(Boolean).join("\n"),
645
+ diagnostics: sandbox,
646
+ },
647
+ statusCursor: revision.nextCursor,
648
+ });
649
+ }
650
+ const log = readLog(meta.logPath, STATUS_EXCERPT_ROWS);
651
+ // Change/reset and read-gap facts are short and decision-relevant: they are
652
+ // budgeted with the decision section, ahead of long incident rows.
653
+ const changeFacts = [
654
+ ...(listCursor ? ["cursor ignored: it is a bg_task_list page cursor; pass it to bg_task_list, or pass this status's statusCursor here."] : []),
655
+ ...(revision.change === "failure" ? ["change=failure"] : []),
656
+ ...(revision.reset ? [`reset=${revision.reset}`] : []),
657
+ ...(log.error ? [`log unreadable: ${oneLine(log.error, 200)}; cannot treat this as an empty healthy log.`] : []),
658
+ ];
659
+ return assembleBackgroundContent({
660
+ surface: "status",
661
+ maxBytes: options.maxBytes,
662
+ sections: {
663
+ identity: identityLine(meta),
664
+ failure: incidentSection(meta.id, options, state),
665
+ decision: [...changeFacts, formatDecision(meta), staleProgress].filter(Boolean).join("\n") || undefined,
666
+ diagnostics: formatDiagnostics(meta, [formatProcessDiagnostics(options.processDiagnostics), sandbox].filter((line) => !!line)),
667
+ progress: formatProgress(meta),
668
+ },
669
+ verbatim: log.error ? undefined : (budget) => excerptPage(meta, options, log, budget),
670
+ gaps: [
671
+ ...taskGaps(meta),
672
+ ...(log.error ? [{ kind: "read", detail: log.error }] : []),
673
+ ],
674
+ statusCursor: revision.nextCursor,
675
+ });
676
+ }
677
+ export function formatLog(id, options = {}) {
678
+ const inspection = inspectMeta(id);
679
+ if (!inspection.meta)
680
+ return formatMissingTask(inspection, options);
681
+ const meta = inspection.meta;
682
+ const ownership = classifyOwnership(meta, options);
683
+ if (ownership !== "allow")
684
+ return formatOwnershipGap(meta.id, ownership, options);
685
+ const fileCursor = cursorKind(options.cursor) === "f";
686
+ const raw = options.raw === true || options.tailLines === 0 || fileCursor;
687
+ // Raw evidence keeps whole excerpts and evidence paths.
688
+ const failure = incidentSection(id, options, undefined, raw ? "full" : "compact");
689
+ if (raw) {
690
+ return assembleBackgroundContent({
691
+ surface: "rawPage",
692
+ maxBytes: options.maxBytes,
693
+ sections: {
694
+ identity: `${meta.id} raw log (${meta.status})`,
695
+ failure,
696
+ decision: formatDecision(meta),
697
+ diagnostics: formatDiagnostics(meta, [
698
+ "Raw retained bytes; capture/retention loss is not recoverable as full history.",
699
+ ]),
700
+ },
701
+ verbatim: (budget) => rawLogPage(meta, options, options.cursor, budget),
702
+ });
703
+ }
704
+ const tailLines = options.tailLines && options.tailLines > 0 ? Math.floor(options.tailLines) : DEFAULT_LOG_TAIL_ROWS;
705
+ const log = readLog(meta.logPath, tailLines);
706
+ const staleCursor = options.cursor ? ["reset=stale-cursor (compact tails have no cursor; pass a raw nextCursor or lines:0)"] : [];
707
+ if (log.error) {
708
+ return assembleBackgroundContent({
709
+ surface: "log",
710
+ maxBytes: options.maxBytes,
711
+ sections: {
712
+ identity: `${meta.id} log (${meta.status})`,
713
+ failure,
714
+ diagnostics: [...staleCursor, `log unreadable: ${log.error}`, "Cannot treat this as an empty healthy log."].join("\n"),
715
+ },
716
+ gaps: [{ kind: "read", detail: log.error }, ...taskGaps(meta)],
717
+ });
718
+ }
719
+ return assembleBackgroundContent({
720
+ surface: "log",
721
+ maxBytes: options.maxBytes,
722
+ sections: {
723
+ identity: `${meta.id} log (${meta.status}) · newest ${tailLines} display row${tailLines === 1 ? "" : "s"}`,
724
+ failure,
725
+ decision: formatDecision(meta),
726
+ diagnostics: formatDiagnostics(meta, staleCursor),
727
+ },
728
+ verbatim: (budget) => excerptPage(meta, options, log, budget),
729
+ gaps: taskGaps(meta),
730
+ });
731
+ }
732
+ function compactRow(meta, incidents) {
733
+ const age = formatDuration((meta.endedAt ?? Date.now()) - meta.startedAt);
734
+ const remote = meta.ssh ? ` ${oneLine(meta.ssh.target, 60)}${meta.remote?.session ? ` ${meta.remote.session}` : ""}` : "";
735
+ const incident = incidents > 0 ? ` · ${incidents} incident${incidents === 1 ? "" : "s"}` : "";
736
+ const label = meta.name ? ` ${oneLine(meta.name, 60)}` : "";
737
+ const waits = meta.waits?.length;
738
+ return `${meta.id} ${meta.status} ${meta.kind} ${age}${incident}${remote}${label}${waits ? ` waits=${waits}` : ""}`;
739
+ }
740
+ export function formatList(options = {}, index = listTaskRecords()) {
741
+ if (index.indexError) {
742
+ return assembleBackgroundContent({
743
+ surface: "list",
744
+ maxBytes: options.maxBytes,
745
+ sections: {
746
+ identity: "Cannot list background tasks.",
747
+ diagnostics: `Task index is unreadable: ${index.indexError}. Cannot treat the registry as empty.`,
748
+ },
749
+ gaps: [{ kind: "read", detail: index.indexError }],
750
+ });
751
+ }
752
+ if (!options.all && !options.origin) {
753
+ return assembleBackgroundContent({
754
+ surface: "list",
755
+ maxBytes: options.maxBytes,
756
+ sections: {
757
+ identity: "Current session is unavailable.",
758
+ diagnostics: "Pass all:true to list tasks across sessions. Cannot treat the registry as empty.",
759
+ },
760
+ gaps: [{ kind: "read", detail: "session scope unavailable" }],
761
+ });
762
+ }
763
+ const wanted = options.statuses && options.statuses.length > 0 ? new Set(options.statuses) : undefined;
764
+ let unreadable = index.page?.unreadable ?? 0;
765
+ let unknown = index.page?.unknown ?? 0;
766
+ const allowed = [];
767
+ for (const record of index.records) {
768
+ if (!record.meta) {
769
+ if (record.found)
770
+ unreadable += 1;
771
+ continue;
772
+ }
773
+ const ownership = classifyOwnership(record.meta, options);
774
+ if (ownership === "allow") {
775
+ if (!wanted || wanted.has(record.meta.status) || wanted.has("running") && record.meta.durable
776
+ && record.meta.active)
777
+ allowed.push(record.meta);
778
+ }
779
+ else if (ownership === "unknown") {
780
+ unknown += 1;
781
+ }
782
+ }
783
+ const scope = scopeKey(options);
784
+ const statusesKey = [...(options.statuses ?? [])].sort().join(",");
785
+ const resource = `list:${scope}:${statusesKey}`;
786
+ const limit = Math.max(1, Math.min(Math.floor(options.limit ?? DEFAULT_LIST_ENTRIES), MAX_LIST_ENTRIES));
787
+ const total = index.page?.total ?? allowed.length;
788
+ const states = new Map(allowed.map((meta) => [meta.id, failureStateFor(meta.id)]));
789
+ const incidentsOf = (id) => actionableFailures(states.get(id)).length;
790
+ const revision = inspectStatusRevision({
791
+ resource,
792
+ contentRevision: index.page?.contentRevision ?? revisionOf(allowed.map((meta) => [meta.id, meta.status, meta.endedAt ?? null])),
793
+ failureRevision: revisionOf([index.page?.failureRevision, allowed.map((meta) => [meta.id, failureRevision(states.get(meta.id))])]),
794
+ cursor: cursorKind(options.cursor) === "s" ? options.cursor : undefined,
795
+ });
796
+ const scopeLabel = options.all ? "all sessions" : "current session";
797
+ if (options.cursor && cursorKind(options.cursor) === "s" && revision.change === "none") {
798
+ return assembleBackgroundContent({
799
+ surface: "list",
800
+ maxBytes: options.maxBytes,
801
+ sections: {
802
+ identity: `${total} background task${total === 1 ? "" : "s"} (${scopeLabel}) · unchanged`,
803
+ decision: formatUnchangedEvidence(options.cursor),
804
+ },
805
+ statusCursor: revision.nextCursor,
806
+ });
807
+ }
808
+ const failing = allowed.filter((meta) => incidentsOf(meta.id) > 0);
809
+ const withIncidents = failing.length;
810
+ // One leading incident (the newest failing task's top row), then a count:
811
+ // failures lead the surface without repeating a paragraph per task.
812
+ const listFailure = (budget) => {
813
+ const newest = failing[0];
814
+ if (!newest)
815
+ return undefined;
816
+ const count = `${withIncidents} task${withIncidents === 1 ? "" : "s"}${index.page ? " on this page" : ""} with unresolved incidents; newest ${newest.id} has ${incidentsOf(newest.id)}. Full incidents: bg_task_status id=${newest.id}.`;
817
+ const top = formatFailureLines(states.get(newest.id))[0] ?? "";
818
+ // The lead-in is a pointer, not the incident page: at most a short preview.
819
+ const room = Math.min(LIST_LEAD_PREVIEW_BYTES, budget - utf8ByteLength(count) - 1);
820
+ if (room < 48 || !top)
821
+ return count;
822
+ const shown = utf8ByteLength(top) <= room ? top : `${sliceUtf8Bytes(top, 0, room - 12, false).text} (clipped)`;
823
+ return `${shown}\n${count}`;
824
+ };
825
+ const notes = [
826
+ ...(unreadable ? [`${unreadable} task record(s) with unreadable metadata; cannot treat as empty or healthy`] : []),
827
+ ...(unknown ? [`${unknown} task(s) with unavailable ownership hidden; pass all:true to inspect`] : []),
828
+ ...(revision.change === "failure" ? ["change=failure"] : []),
829
+ ];
830
+ const gaps = [
831
+ ...(unreadable ? [{ kind: "read", detail: `${unreadable} unreadable metadata file(s)` }] : []),
832
+ ...(unknown ? [{ kind: "read", detail: `${unknown} task(s) with unverifiable ownership` }] : []),
833
+ ];
834
+ const pageCursor = options.cursor && cursorKind(options.cursor) !== "s" ? options.cursor : undefined;
835
+ return assembleBackgroundContent({
836
+ surface: "list",
837
+ maxBytes: options.maxBytes,
838
+ sections: {
839
+ identity: options.sessionUnavailable && !options.all
840
+ ? "Current session identity is unavailable; task ownership cannot be verified."
841
+ : total === 0
842
+ ? `No background tasks found (${scopeLabel}).`
843
+ : `${total} background task${total === 1 ? "" : "s"} (${scopeLabel}), newest first${allowed.some(meta => meta.durable) ? "; durable background operations included" : ""}`,
844
+ failure: withIncidents ? listFailure : undefined,
845
+ diagnostics: notes.join("\n") || undefined,
846
+ },
847
+ verbatim: allowed.length === 0 && !pageCursor
848
+ ? undefined
849
+ : (budget) => pageRows(allowed, {
850
+ cursor: pageCursor,
851
+ resource,
852
+ limit,
853
+ maxBytes: budget,
854
+ ...(index.page ? { indexed: { total, before: index.page.before } } : {}),
855
+ keyOf: (meta) => ({ time: meta.startedAt, id: meta.id }),
856
+ render: (meta) => compactRow(meta, incidentsOf(meta.id)),
857
+ }),
858
+ gaps,
859
+ statusCursor: revision.nextCursor,
860
+ });
861
+ }
862
+ export function formatStopResult(inspection, options = {}) {
863
+ if (!inspection.meta)
864
+ return formatMissingTask(inspection, options);
865
+ return formatStatus(inspection, options);
866
+ }
867
+ export { inspectMeta, utf8ByteLength };