@edspencer/paddock 0.0.1 → 0.56.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 (294) hide show
  1. package/README.md +69 -0
  2. package/install-notice.mjs +29 -0
  3. package/package.json +58 -5
  4. package/packages/server/dist/adoptable.d.ts +127 -0
  5. package/packages/server/dist/adoptable.js +315 -0
  6. package/packages/server/dist/app.d.ts +67 -0
  7. package/packages/server/dist/app.js +325 -0
  8. package/packages/server/dist/archive.d.ts +42 -0
  9. package/packages/server/dist/archive.js +125 -0
  10. package/packages/server/dist/attachments-config.d.ts +114 -0
  11. package/packages/server/dist/attachments-config.js +165 -0
  12. package/packages/server/dist/attachments-hint.d.ts +53 -0
  13. package/packages/server/dist/attachments-hint.js +140 -0
  14. package/packages/server/dist/attachments.d.ts +33 -0
  15. package/packages/server/dist/attachments.js +117 -0
  16. package/packages/server/dist/auth.d.ts +84 -0
  17. package/packages/server/dist/auth.js +247 -0
  18. package/packages/server/dist/background.d.ts +36 -0
  19. package/packages/server/dist/background.js +137 -0
  20. package/packages/server/dist/bind-safety.d.ts +56 -0
  21. package/packages/server/dist/bind-safety.js +51 -0
  22. package/packages/server/dist/brand.d.ts +44 -0
  23. package/packages/server/dist/brand.js +88 -0
  24. package/packages/server/dist/chat-dto.d.ts +210 -0
  25. package/packages/server/dist/chat-dto.js +308 -0
  26. package/packages/server/dist/cli/import-chats.d.ts +21 -0
  27. package/packages/server/dist/cli/import-chats.js +197 -0
  28. package/packages/server/dist/cli/paddock.d.ts +2 -0
  29. package/packages/server/dist/cli/paddock.js +247 -0
  30. package/packages/server/dist/concurrency.d.ts +57 -0
  31. package/packages/server/dist/concurrency.js +71 -0
  32. package/packages/server/dist/config.d.ts +512 -0
  33. package/packages/server/dist/config.js +593 -0
  34. package/packages/server/dist/curation-config.d.ts +55 -0
  35. package/packages/server/dist/curation-config.js +64 -0
  36. package/packages/server/dist/event-bus.d.ts +87 -0
  37. package/packages/server/dist/event-bus.js +48 -0
  38. package/packages/server/dist/git.d.ts +128 -0
  39. package/packages/server/dist/git.js +446 -0
  40. package/packages/server/dist/github-auth.d.ts +44 -0
  41. package/packages/server/dist/github-auth.js +169 -0
  42. package/packages/server/dist/herdctl-agent-config.d.ts +98 -0
  43. package/packages/server/dist/herdctl-agent-config.js +331 -0
  44. package/packages/server/dist/herdctl-agent-names.d.ts +172 -0
  45. package/packages/server/dist/herdctl-agent-names.js +228 -0
  46. package/packages/server/dist/herdctl-jobs-index.d.ts +65 -0
  47. package/packages/server/dist/herdctl-jobs-index.js +225 -0
  48. package/packages/server/dist/herdctl-jobs.d.ts +98 -0
  49. package/packages/server/dist/herdctl-jobs.js +225 -0
  50. package/packages/server/dist/herdctl.d.ts +572 -0
  51. package/packages/server/dist/herdctl.js +1218 -0
  52. package/packages/server/dist/hook-config.d.ts +217 -0
  53. package/packages/server/dist/hook-config.js +224 -0
  54. package/packages/server/dist/http-bytes.d.ts +24 -0
  55. package/packages/server/dist/http-bytes.js +52 -0
  56. package/packages/server/dist/index.d.ts +1 -0
  57. package/packages/server/dist/index.js +14 -0
  58. package/packages/server/dist/instance-config.d.ts +135 -0
  59. package/packages/server/dist/instance-config.js +345 -0
  60. package/packages/server/dist/localcommand.d.ts +23 -0
  61. package/packages/server/dist/localcommand.js +140 -0
  62. package/packages/server/dist/management-auth.d.ts +99 -0
  63. package/packages/server/dist/management-auth.js +165 -0
  64. package/packages/server/dist/management-config.d.ts +164 -0
  65. package/packages/server/dist/management-config.js +286 -0
  66. package/packages/server/dist/management-mcp-server.d.ts +20 -0
  67. package/packages/server/dist/management-mcp-server.js +95 -0
  68. package/packages/server/dist/management-metadata.d.ts +67 -0
  69. package/packages/server/dist/management-metadata.js +56 -0
  70. package/packages/server/dist/management-ops.d.ts +110 -0
  71. package/packages/server/dist/management-ops.js +449 -0
  72. package/packages/server/dist/management-policy.d.ts +172 -0
  73. package/packages/server/dist/management-policy.js +259 -0
  74. package/packages/server/dist/message-provenance.d.ts +112 -0
  75. package/packages/server/dist/message-provenance.js +260 -0
  76. package/packages/server/dist/models.d.ts +164 -0
  77. package/packages/server/dist/models.js +208 -0
  78. package/packages/server/dist/openapi.d.ts +66 -0
  79. package/packages/server/dist/openapi.js +183 -0
  80. package/packages/server/dist/parent-detach.d.ts +30 -0
  81. package/packages/server/dist/parent-detach.js +109 -0
  82. package/packages/server/dist/preload.d.ts +43 -0
  83. package/packages/server/dist/preload.js +55 -0
  84. package/packages/server/dist/project-files.d.ts +76 -0
  85. package/packages/server/dist/project-files.js +191 -0
  86. package/packages/server/dist/project-mime.d.ts +35 -0
  87. package/packages/server/dist/project-mime.js +55 -0
  88. package/packages/server/dist/project-paths.d.ts +88 -0
  89. package/packages/server/dist/project-paths.js +126 -0
  90. package/packages/server/dist/project-types.d.ts +316 -0
  91. package/packages/server/dist/project-types.js +48 -0
  92. package/packages/server/dist/projects.d.ts +202 -0
  93. package/packages/server/dist/projects.js +894 -0
  94. package/packages/server/dist/queued-message.d.ts +35 -0
  95. package/packages/server/dist/queued-message.js +116 -0
  96. package/packages/server/dist/read-state.d.ts +46 -0
  97. package/packages/server/dist/read-state.js +139 -0
  98. package/packages/server/dist/recovery-config.d.ts +111 -0
  99. package/packages/server/dist/recovery-config.js +105 -0
  100. package/packages/server/dist/recovery.d.ts +262 -0
  101. package/packages/server/dist/recovery.js +490 -0
  102. package/packages/server/dist/resume-drain.d.ts +122 -0
  103. package/packages/server/dist/resume-drain.js +158 -0
  104. package/packages/server/dist/route-context.d.ts +168 -0
  105. package/packages/server/dist/route-context.js +39 -0
  106. package/packages/server/dist/route-errors.d.ts +8 -0
  107. package/packages/server/dist/route-errors.js +13 -0
  108. package/packages/server/dist/routes/chats.d.ts +12 -0
  109. package/packages/server/dist/routes/chats.js +1406 -0
  110. package/packages/server/dist/routes/git.d.ts +13 -0
  111. package/packages/server/dist/routes/git.js +236 -0
  112. package/packages/server/dist/routes/mcp.d.ts +83 -0
  113. package/packages/server/dist/routes/mcp.js +250 -0
  114. package/packages/server/dist/routes/meta.d.ts +15 -0
  115. package/packages/server/dist/routes/meta.js +447 -0
  116. package/packages/server/dist/routes/projects.d.ts +25 -0
  117. package/packages/server/dist/routes/projects.js +736 -0
  118. package/packages/server/dist/routes/triggers.d.ts +21 -0
  119. package/packages/server/dist/routes/triggers.js +324 -0
  120. package/packages/server/dist/routes/workspace-mount.d.ts +48 -0
  121. package/packages/server/dist/routes/workspace-mount.js +32 -0
  122. package/packages/server/dist/routes.d.ts +26 -0
  123. package/packages/server/dist/routes.js +29 -0
  124. package/packages/server/dist/run-provenance.d.ts +109 -0
  125. package/packages/server/dist/run-provenance.js +206 -0
  126. package/packages/server/dist/runs.d.ts +92 -0
  127. package/packages/server/dist/runs.js +72 -0
  128. package/packages/server/dist/schedule-config.d.ts +68 -0
  129. package/packages/server/dist/schedule-config.js +75 -0
  130. package/packages/server/dist/schedule-session.d.ts +34 -0
  131. package/packages/server/dist/schedule-session.js +120 -0
  132. package/packages/server/dist/self-mcp-descriptions.d.ts +20 -0
  133. package/packages/server/dist/self-mcp-descriptions.js +145 -0
  134. package/packages/server/dist/self-mcp-read.d.ts +15 -0
  135. package/packages/server/dist/self-mcp-read.js +97 -0
  136. package/packages/server/dist/self-mcp-triggers.d.ts +30 -0
  137. package/packages/server/dist/self-mcp-triggers.js +144 -0
  138. package/packages/server/dist/self-mcp-types.d.ts +248 -0
  139. package/packages/server/dist/self-mcp-types.js +10 -0
  140. package/packages/server/dist/self-mcp-util.d.ts +73 -0
  141. package/packages/server/dist/self-mcp-util.js +157 -0
  142. package/packages/server/dist/self-mcp-write.d.ts +35 -0
  143. package/packages/server/dist/self-mcp-write.js +215 -0
  144. package/packages/server/dist/self-mcp.d.ts +95 -0
  145. package/packages/server/dist/self-mcp.js +448 -0
  146. package/packages/server/dist/send-file-mcp.d.ts +46 -0
  147. package/packages/server/dist/send-file-mcp.js +281 -0
  148. package/packages/server/dist/session-hub.d.ts +186 -0
  149. package/packages/server/dist/session-hub.js +291 -0
  150. package/packages/server/dist/spawn-capability.d.ts +99 -0
  151. package/packages/server/dist/spawn-capability.js +106 -0
  152. package/packages/server/dist/star.d.ts +26 -0
  153. package/packages/server/dist/star.js +94 -0
  154. package/packages/server/dist/start.d.ts +1 -0
  155. package/packages/server/dist/start.js +21 -0
  156. package/packages/server/dist/subagents.d.ts +337 -0
  157. package/packages/server/dist/subagents.js +626 -0
  158. package/packages/server/dist/sweep.d.ts +122 -0
  159. package/packages/server/dist/sweep.js +696 -0
  160. package/packages/server/dist/tooldetails.d.ts +33 -0
  161. package/packages/server/dist/tooldetails.js +466 -0
  162. package/packages/server/dist/transcribe.d.ts +69 -0
  163. package/packages/server/dist/transcribe.js +119 -0
  164. package/packages/server/dist/transcripts.d.ts +42 -0
  165. package/packages/server/dist/transcripts.js +164 -0
  166. package/packages/server/dist/trigger-config.d.ts +278 -0
  167. package/packages/server/dist/trigger-config.js +417 -0
  168. package/packages/server/dist/trigger-runtime.d.ts +94 -0
  169. package/packages/server/dist/trigger-runtime.js +82 -0
  170. package/packages/server/dist/trigger-session.d.ts +34 -0
  171. package/packages/server/dist/trigger-session.js +122 -0
  172. package/packages/server/dist/triggers.d.ts +83 -0
  173. package/packages/server/dist/triggers.js +124 -0
  174. package/packages/server/dist/trusted-proxy.d.ts +57 -0
  175. package/packages/server/dist/trusted-proxy.js +157 -0
  176. package/packages/server/dist/turn-notice.d.ts +154 -0
  177. package/packages/server/dist/turn-notice.js +271 -0
  178. package/packages/server/dist/unread.d.ts +36 -0
  179. package/packages/server/dist/unread.js +123 -0
  180. package/packages/server/dist/usage.d.ts +66 -0
  181. package/packages/server/dist/usage.js +243 -0
  182. package/packages/server/dist/wake-injection.d.ts +156 -0
  183. package/packages/server/dist/wake-injection.js +136 -0
  184. package/packages/server/dist/whisper-local.d.ts +9 -0
  185. package/packages/server/dist/whisper-local.js +122 -0
  186. package/packages/server/dist/ws-context.d.ts +158 -0
  187. package/packages/server/dist/ws-context.js +1 -0
  188. package/packages/server/dist/ws-protocol.d.ts +423 -0
  189. package/packages/server/dist/ws-protocol.js +251 -0
  190. package/packages/server/dist/ws-self-mcp.d.ts +52 -0
  191. package/packages/server/dist/ws-self-mcp.js +28 -0
  192. package/packages/server/dist/ws-triggers.d.ts +29 -0
  193. package/packages/server/dist/ws-triggers.js +261 -0
  194. package/packages/server/dist/ws-turn.d.ts +86 -0
  195. package/packages/server/dist/ws-turn.js +751 -0
  196. package/packages/server/dist/ws.d.ts +62 -0
  197. package/packages/server/dist/ws.js +1024 -0
  198. package/packages/server/package.json +6 -0
  199. package/packages/web/dist/assets/InstanceConfigPage-4cQGTj9Y.js +2 -0
  200. package/packages/web/dist/assets/MarkdownRenderer-CJZFLj_8.js +30 -0
  201. package/packages/web/dist/assets/ProjectRedirect-BHwVbbqB.js +2 -0
  202. package/packages/web/dist/assets/ProjectView-BOvuAITg.js +13 -0
  203. package/packages/web/dist/assets/ProjectsGrid-BCojZOGY.js +2 -0
  204. package/packages/web/dist/assets/arc-BVyxvnkl.js +2 -0
  205. package/packages/web/dist/assets/architectureDiagram-3BPJPVTR-Cd9Puqg1.js +37 -0
  206. package/packages/web/dist/assets/bash-I8pq0VWm.js +2 -0
  207. package/packages/web/dist/assets/blockDiagram-GPEHLZMM-B_AQt_Rx.js +133 -0
  208. package/packages/web/dist/assets/c-D2F1sQUL.js +2 -0
  209. package/packages/web/dist/assets/c4Diagram-AAUBKEIU-7e0TQtXB.js +11 -0
  210. package/packages/web/dist/assets/channel-C_1aISNn.js +2 -0
  211. package/packages/web/dist/assets/chunk-2J33WTMH-Dz4WZmUZ.js +2 -0
  212. package/packages/web/dist/assets/chunk-4BX2VUAB-DVWYldo6.js +2 -0
  213. package/packages/web/dist/assets/chunk-55IACEB6-BIMrizQd.js +2 -0
  214. package/packages/web/dist/assets/chunk-727SXJPM-CL2q9fF1.js +207 -0
  215. package/packages/web/dist/assets/chunk-AQP2D5EJ-BSq3HlQ9.js +232 -0
  216. package/packages/web/dist/assets/chunk-FMBD7UC4-Bgt64pLE.js +16 -0
  217. package/packages/web/dist/assets/chunk-ND2GUHAM-C8Pr2A38.js +2 -0
  218. package/packages/web/dist/assets/chunk-QZHKN3VN-BAOqh-MN.js +2 -0
  219. package/packages/web/dist/assets/classDiagram-4FO5ZUOK-B8JE7cHJ.js +2 -0
  220. package/packages/web/dist/assets/classDiagram-v2-Q7XG4LA2-B8JE7cHJ.js +2 -0
  221. package/packages/web/dist/assets/core-lJeGACQg.js +4 -0
  222. package/packages/web/dist/assets/cose-bilkent-S5V4N54A-BF4tameA.js +2 -0
  223. package/packages/web/dist/assets/cpp-Bm3ii6kY.js +2 -0
  224. package/packages/web/dist/assets/csharp-BNpuYZMG.js +2 -0
  225. package/packages/web/dist/assets/css-DazXZka4.js +2 -0
  226. package/packages/web/dist/assets/cytoscape.esm-CUqq0XTU.js +332 -0
  227. package/packages/web/dist/assets/dagre-BM42HDAG-DdsLM6ql.js +5 -0
  228. package/packages/web/dist/assets/defaultLocale-DX6XiGOO.js +2 -0
  229. package/packages/web/dist/assets/diagram-2AECGRRQ-BQ78S_RM.js +44 -0
  230. package/packages/web/dist/assets/diagram-5GNKFQAL-CAKE6nHE.js +11 -0
  231. package/packages/web/dist/assets/diagram-KO2AKTUF-fEvHRXgr.js +4 -0
  232. package/packages/web/dist/assets/diagram-LMA3HP47-CtWsgeSm.js +25 -0
  233. package/packages/web/dist/assets/diagram-OG6HWLK6-Buog8k7_.js +25 -0
  234. package/packages/web/dist/assets/erDiagram-TEJ5UH35-CWvVVPZS.js +86 -0
  235. package/packages/web/dist/assets/flowDiagram-I6XJVG4X-DsCGXtp4.js +163 -0
  236. package/packages/web/dist/assets/format-DamJQ9LO.js +2 -0
  237. package/packages/web/dist/assets/ganttDiagram-6RSMTGT7-CsdwIvvC.js +293 -0
  238. package/packages/web/dist/assets/gitGraphDiagram-PVQCEYII-hZvrX1sD.js +107 -0
  239. package/packages/web/dist/assets/go-BPx_y7j8.js +2 -0
  240. package/packages/web/dist/assets/graph-BlwPajkw.js +2 -0
  241. package/packages/web/dist/assets/index-CGbZdrm8.js +71 -0
  242. package/packages/web/dist/assets/index-DJDQ210-.css +1 -0
  243. package/packages/web/dist/assets/infoDiagram-5YYISTIA-nE_Vtz_l.js +3 -0
  244. package/packages/web/dist/assets/ini-B3BVgEsG.js +2 -0
  245. package/packages/web/dist/assets/init-Gi6I4Gst.js +2 -0
  246. package/packages/web/dist/assets/ishikawaDiagram-YF4QCWOH-2Nlqs0oH.js +71 -0
  247. package/packages/web/dist/assets/java-B5VKqtH2.js +2 -0
  248. package/packages/web/dist/assets/javascript-BKRaQes9.js +2 -0
  249. package/packages/web/dist/assets/journeyDiagram-JHISSGLW-mjU1fMc4.js +140 -0
  250. package/packages/web/dist/assets/json-DIYVocXf.js +2 -0
  251. package/packages/web/dist/assets/kanban-definition-UN3LZRKU-C_9xNaa3.js +90 -0
  252. package/packages/web/dist/assets/katex-C5jXJg4s.js +258 -0
  253. package/packages/web/dist/assets/kotlin-Cw-eF_bm.js +3 -0
  254. package/packages/web/dist/assets/lastTab-CU1zsF0j.js +2 -0
  255. package/packages/web/dist/assets/layout-Boy8vhSP.js +2 -0
  256. package/packages/web/dist/assets/linear-BxKd91ho.js +2 -0
  257. package/packages/web/dist/assets/mermaid.core-C-CuhD8I.js +310 -0
  258. package/packages/web/dist/assets/mindmap-definition-RKZ34NQL-Bs6yfcZv.js +97 -0
  259. package/packages/web/dist/assets/ordinal-Cboi1Yqb.js +2 -0
  260. package/packages/web/dist/assets/php-CRdd4dfS.js +3 -0
  261. package/packages/web/dist/assets/pieDiagram-4H26LBE5-DNdqX7O5.js +31 -0
  262. package/packages/web/dist/assets/python-kSlZHhJb.js +2 -0
  263. package/packages/web/dist/assets/quadrantDiagram-W4KKPZXB-ZMJl9OdZ.js +8 -0
  264. package/packages/web/dist/assets/queued-LamEU0GH.js +2 -0
  265. package/packages/web/dist/assets/requirementDiagram-4Y6WPE33-RmxMdm2q.js +85 -0
  266. package/packages/web/dist/assets/ruby-7T4ktxyv.js +2 -0
  267. package/packages/web/dist/assets/rust-HC3MBUhY.js +2 -0
  268. package/packages/web/dist/assets/sankeyDiagram-5OEKKPKP-OAAhWcfK.js +41 -0
  269. package/packages/web/dist/assets/scss-DZLA7YXz.js +2 -0
  270. package/packages/web/dist/assets/sequenceDiagram-3UESZ5HK-BWF7rCyN.js +163 -0
  271. package/packages/web/dist/assets/sql-BC88IN-V.js +2 -0
  272. package/packages/web/dist/assets/stateDiagram-AJRCARHV-M3b_zqqo.js +2 -0
  273. package/packages/web/dist/assets/stateDiagram-v2-BHNVJYJU-CI7saFDa.js +2 -0
  274. package/packages/web/dist/assets/swift-Dn8kKO_1.js +2 -0
  275. package/packages/web/dist/assets/timeline-definition-PNZ67QCA-BpOCh63N.js +121 -0
  276. package/packages/web/dist/assets/typescript-C2FFdlUC.js +2 -0
  277. package/packages/web/dist/assets/vennDiagram-CIIHVFJN-D_iPH45Q.js +35 -0
  278. package/packages/web/dist/assets/wardley-L42UT6IY-DVD9I2Om.js +174 -0
  279. package/packages/web/dist/assets/wardleyDiagram-YWT4CUSO-Bn1IKwjn.js +79 -0
  280. package/packages/web/dist/assets/xml-BXBhIUeX.js +2 -0
  281. package/packages/web/dist/assets/xychartDiagram-2RQKCTM6-DwtI0bkR.js +8 -0
  282. package/packages/web/dist/assets/yaml-drsDnIKT.js +2 -0
  283. package/packages/web/dist/favicon.ico +0 -0
  284. package/packages/web/dist/fonts/inter-latin.woff2 +0 -0
  285. package/packages/web/dist/fonts/jetbrains-mono-latin.woff2 +0 -0
  286. package/packages/web/dist/icons/apple-touch-icon.png +0 -0
  287. package/packages/web/dist/icons/favicon-16.png +0 -0
  288. package/packages/web/dist/icons/favicon-32.png +0 -0
  289. package/packages/web/dist/icons/icon-192.png +0 -0
  290. package/packages/web/dist/icons/icon-512.png +0 -0
  291. package/packages/web/dist/icons/maskable-512.png +0 -0
  292. package/packages/web/dist/index.html +56 -0
  293. package/packages/web/dist/manifest.webmanifest +32 -0
  294. package/packages/web/dist/sw.js +139 -0
@@ -0,0 +1,337 @@
1
+ import { type ChatMessage, type ChatToolCall } from "@herdctl/core";
2
+ import type { MessageSender } from "./message-provenance.js";
3
+ import type { TurnNotice } from "./turn-notice.js";
4
+ import { type SessionTokenUsage } from "./usage.js";
5
+ /** Tool names that launch a sub-agent. `Task` = classic Claude Code, `Agent` = Agent SDK. */
6
+ export declare const SUBAGENT_TOOL_NAMES: Set<string>;
7
+ /**
8
+ * A `Task`/`Agent` launch recovered LIVE from a raw SDK message's `tool_use`
9
+ * block (issue #429). `subagentType`/`description` come straight from the tool
10
+ * INPUT the launching assistant message carries — so a consumer can enrich the
11
+ * live tool card with the real sub-agent type + title the instant it starts,
12
+ * WITHOUT waiting for the history-path subagent-join (which only runs on reload).
13
+ */
14
+ export interface SubagentLaunch {
15
+ toolUseId: string;
16
+ subagentType?: string;
17
+ description?: string;
18
+ }
19
+ /**
20
+ * Extract every `Task`/`Agent` `tool_use` block from a single raw SDK message,
21
+ * with `subagent_type` + `description` read directly from the tool input. Returns
22
+ * [] for any message that carries no sub-agent launch (the common case). This is
23
+ * the live counterpart to {@link readTaskToolUses} (which recovers the same fields
24
+ * from the transcript on disk): it lets ws-turn enrich the live `chat:tool_start`
25
+ * / `chat:tool_call` frames as the launch streams, closing the "generic launch-ack
26
+ * live, only enriches on refresh" gap (#429). The message shape is loosely typed
27
+ * in core, so every field access is guarded.
28
+ */
29
+ export declare function extractSubagentLaunches(m: unknown): SubagentLaunch[];
30
+ /** Both sessionId and toolUseId are path segments — keep them inside `.chats/`. */
31
+ export declare const SAFE_SEGMENT: RegExp;
32
+ /**
33
+ * Max files retained per mtime cache.
34
+ *
35
+ * Was 64, which a real project blows straight through: one live-scale project
36
+ * holds 514 transcript files across 234 chats, so a single sweep of
37
+ * `/chats/usage` evicted every entry before the next sweep could reuse one — the
38
+ * cache was pure overhead. Measured on that corpus (issue #537), raising the cap
39
+ * took the warm full-project usage call from ~440ms to ~29ms.
40
+ *
41
+ * The entries are token tallies and tool-use records, not transcript text, so
42
+ * this is cheap: forcing every one of the 1,515 sessions in that corpus through
43
+ * both the usage and sub-agent-listing paths and then running GC retained
44
+ * **1.4 MB** at this cap versus **1.3 MB** at 64 — a ~0.1 MB difference for a
45
+ * 15× speedup.
46
+ */
47
+ export declare const MTIME_CACHE_MAX = 1024;
48
+ export type MtimeCache<T> = Map<string, {
49
+ mtimeMs: number;
50
+ value: T;
51
+ }>;
52
+ /** The file's mtime in epoch ms, or undefined if it can't be stat'd. */
53
+ export declare function statMtimeMs(file: string): Promise<number | undefined>;
54
+ /** Return the cached value if the recorded mtime still matches (LRU-touch on hit). */
55
+ export declare function mtimeCacheGet<T>(cache: MtimeCache<T>, file: string, mtimeMs: number): {
56
+ hit: true;
57
+ value: T;
58
+ } | {
59
+ hit: false;
60
+ };
61
+ /** Store a value against the file's mtime, evicting the least-recently-used past the cap. */
62
+ export declare function mtimeCacheSet<T>(cache: MtimeCache<T>, file: string, mtimeMs: number, value: T): void;
63
+ /** The parent-turn view of a sub-agent launch, recovered from the main transcript. */
64
+ export interface TaskToolUse {
65
+ toolUseId: string;
66
+ subagentType?: string;
67
+ description?: string;
68
+ prompt?: string;
69
+ }
70
+ /** A sub-agent's `.meta.json` sidecar, plus the resolved path to its transcript. */
71
+ export interface SubagentMeta {
72
+ toolUseId: string;
73
+ agentType?: string;
74
+ description?: string;
75
+ spawnDepth?: number;
76
+ /**
77
+ * This sub-agent's own agent id (the `<hex>` of its `agent-<hex>` transcript),
78
+ * and — when it was itself spawned by another sub-agent — that parent sub-agent's
79
+ * agent id (`parentAgentId` in the sidecar; absent for a depth-1 sub-agent whose
80
+ * parent is the main session). Together these form the sub-agent tree used for the
81
+ * recursive per-card cost rollup (see {@link subagentCosts}).
82
+ */
83
+ agentId?: string;
84
+ parentAgentId?: string;
85
+ /** Absolute path to the sibling `agent-<hex>.jsonl`. */
86
+ transcriptPath: string;
87
+ }
88
+ /**
89
+ * A paddock-enriched tool call: core's `ChatToolCall` plus the sub-agent fields
90
+ * we recover for `Task`/`Agent` blocks. All additive and optional, so non-Task
91
+ * tool calls (and older transcripts) are unaffected.
92
+ */
93
+ export type EnrichedToolCall = ChatToolCall & {
94
+ toolUseId?: string;
95
+ subagentType?: string;
96
+ description?: string;
97
+ prompt?: string;
98
+ /** True when a sub-agent transcript exists on disk for this tool_use. */
99
+ hasSubagent?: boolean;
100
+ /**
101
+ * The sub-agent's actual run time (first→last transcript timestamp), in ms.
102
+ * The tool call's own `durationMs` only measures how long the *launch* took —
103
+ * the Task/Agent tool returns immediately ("launched successfully") while the
104
+ * sub-agent runs on — so this is the meaningful figure to surface.
105
+ */
106
+ subagentDurationMs?: number;
107
+ /**
108
+ * The sub-agent's estimated API-rate cost in USD (issue #166), as the RECURSIVE
109
+ * total of this sub-agent plus every sub-agent it (transitively) spawned — priced
110
+ * per-model from the merged token usage of its whole subtree (see
111
+ * {@link subagentCosts}). `null` when the entire subtree has no priceable usage;
112
+ * `undefined` for a non-sub-agent tool. Cost only: {@link subagentDurationMs}
113
+ * stays per-agent because nested children run in parallel (overlapping wall-clock),
114
+ * so summing durations would mislead — dollars are additive regardless.
115
+ */
116
+ subagentCostUsd?: number | null;
117
+ /** True when this tool ran detached: a `run_in_background` launch, `Monitor`,
118
+ * or a background-task op (`BashOutput`/`TaskOutput`/`TaskStop`/`KillShell`). */
119
+ background?: boolean;
120
+ /** The background task id, parsed from the launch output (bg `Bash` / `Monitor`). */
121
+ taskId?: string;
122
+ /** Terminal state of the linked task: "completed" | "killed" | "timed out" |
123
+ * "persistent" | "running". Derived from the matching `<task-notification>`. */
124
+ taskStatus?: string;
125
+ /** The completion `<summary>` folded in from the matching task-notification
126
+ * (e.g. `Background command "…" completed (exit code 0)`). */
127
+ taskResultSummary?: string;
128
+ /** For `Monitor`: the streamed `<event>` lines, in order, grouped by task id. */
129
+ monitorEvents?: string[];
130
+ /** Inline diff for an `Edit`/`MultiEdit`/`Write` (issue #232 → #237), now sourced
131
+ * from `toolUseResult.structuredPatch` (real file line numbers). */
132
+ editDiff?: EditDiff;
133
+ /** File + line-range for a `Read` — drives the `basename · lines a–b of N` header. */
134
+ readInfo?: ReadInfo;
135
+ /** Split stdout/stderr + status affordances for a `Bash` (issue #237). */
136
+ bashDetails?: BashDetails;
137
+ /** Match/file counts for a `Grep`/`Glob` (issue #237). */
138
+ searchInfo?: SearchInfo;
139
+ /** Status transition for a `TaskUpdate` (issue #237). */
140
+ taskUpdate?: TaskUpdateInfo;
141
+ /** Subject/description for a `TaskCreate` (issue #237). */
142
+ taskCreate?: TaskCreateInfo;
143
+ };
144
+ /**
145
+ * One line of a rendered diff: added (`+`), removed (`-`), or unchanged context,
146
+ * with the real source line numbers recovered from the transcript's git-style
147
+ * hunks (issue #237). `oldLine` is set on context + deletions, `newLine` on
148
+ * context + additions.
149
+ */
150
+ export interface DiffLine {
151
+ t: "+" | "-" | " ";
152
+ text: string;
153
+ oldLine?: number;
154
+ newLine?: number;
155
+ }
156
+ /** One git-style hunk with real file offsets (`@@ -oldStart,oldLines +newStart,newLines @@`). */
157
+ export interface DiffHunk {
158
+ oldStart: number;
159
+ oldLines: number;
160
+ newStart: number;
161
+ newLines: number;
162
+ lines: DiffLine[];
163
+ }
164
+ /**
165
+ * A structured diff for an edit tool call (issue #232 → generalized #237). Sourced
166
+ * from `toolUseResult.structuredPatch` — the git-style hunks Claude Code already
167
+ * computed, with **real file line numbers** — so the hand-rolled LCS diff is gone.
168
+ * `Edit`/`MultiEdit` carry one hunk per changed region; `Write` carries the
169
+ * whole-file create as additions.
170
+ */
171
+ export interface EditDiff {
172
+ filePath?: string;
173
+ kind: "edit" | "multiedit" | "write";
174
+ additions: number;
175
+ deletions: number;
176
+ hunks: DiffHunk[];
177
+ /** True when a hunk was truncated for size; the stats still reflect the full edit. */
178
+ truncated?: boolean;
179
+ /** True when the file changed between the read and the edit (`toolUseResult.userModified`). */
180
+ userModified?: boolean;
181
+ }
182
+ /** File + line-range recovered for a `Read` (issue #237). */
183
+ export interface ReadInfo {
184
+ filePath?: string;
185
+ basename?: string;
186
+ /** 1-based first line returned. */
187
+ startLine?: number;
188
+ /** Number of lines returned. */
189
+ numLines?: number;
190
+ /** Total lines in the file. */
191
+ totalLines?: number;
192
+ /** True when the read target is an image file (by extension) — issue #239. */
193
+ isImage?: boolean;
194
+ /**
195
+ * The read target's path relative to the project dir, set only when it's an
196
+ * image that resolves INSIDE the project dir so the web can render it inline via
197
+ * the raw file endpoint (issue #239). Absent for a non-image read, an image
198
+ * outside the project dir.
199
+ */
200
+ projectRelPath?: string;
201
+ }
202
+ /** Split output + status affordances recovered for a `Bash` (issue #237). */
203
+ export interface BashDetails {
204
+ /** Present (with `stderr`) only when there IS stderr to split out; else undefined
205
+ * and the generic merged `output` renders. */
206
+ stdout?: string;
207
+ stderr?: string;
208
+ interrupted?: boolean;
209
+ /** Human-readable exit hint, e.g. "No matches found". */
210
+ returnCodeInterpretation?: string;
211
+ /** Short git affordance from `gitOperation`, e.g. "push → main". */
212
+ gitHint?: string;
213
+ }
214
+ /** Match/file counts recovered for a `Grep`/`Glob` (issue #237). */
215
+ export interface SearchInfo {
216
+ kind: "grep" | "glob";
217
+ numFiles?: number;
218
+ /** Grep content-mode: number of matching lines. */
219
+ numLines?: number;
220
+ /** Glob: total matches found (may exceed the returned/`truncated` set). */
221
+ totalMatches?: number;
222
+ truncated?: boolean;
223
+ }
224
+ /** Status transition recovered for a `TaskUpdate` (issue #237). */
225
+ export interface TaskUpdateInfo {
226
+ taskId?: string;
227
+ updatedFields?: string[];
228
+ from?: string;
229
+ to?: string;
230
+ }
231
+ /** Subject/description recovered for a `TaskCreate` (issue #237). */
232
+ export interface TaskCreateInfo {
233
+ taskId?: string;
234
+ subject?: string;
235
+ description?: string;
236
+ }
237
+ export type EnrichedMessage = Omit<ChatMessage, "toolCall"> & {
238
+ toolCall?: EnrichedToolCall;
239
+ /** True when this `<task-notification>` was folded into a background tool block
240
+ * (issue #230), so the web suppresses the standalone status pill. */
241
+ bgConsumed?: boolean;
242
+ /** Who injected this machine-added turn (issue #290); absent ⇒ human-typed. */
243
+ sender?: MessageSender;
244
+ /** Context-window fill (tokens) as of this message — the nearest assistant
245
+ * turn's `input + cache_read + cache_creation`, forward-filled across the
246
+ * turns between (issue #451). Drives the per-message hover meter + the
247
+ * fork/revert-from-here anchor. Absent before the first assistant turn. */
248
+ contextTokens?: number;
249
+ /** A surfaced turn-ending condition (issue #329): a subscription/usage-limit
250
+ * hit recovered from the transcript on reload. Present only on the synthetic
251
+ * notice message appended by the history endpoint; the web renders it as a
252
+ * distinct notice turn instead of an assistant bubble. */
253
+ notice?: TurnNotice;
254
+ };
255
+ /**
256
+ * Task/Agent launches recovered from one transcript, split by whether the launch
257
+ * has come back yet.
258
+ *
259
+ * They are kept apart because they join to herdctl's parsed messages by DIFFERENT
260
+ * cursors: core emits one message per paired call, plus a `pending:true` message
261
+ * for each still-unpaired launch. Interleaving them in a single list is what used
262
+ * to misalign a completed sub-agent that ran in parallel with a live one.
263
+ */
264
+ export interface TaskToolUses {
265
+ /** Launches with a matching tool_result, in file order. */
266
+ paired: TaskToolUse[];
267
+ /** Launches still in flight (no tool_result yet), in file order. */
268
+ pending: TaskToolUse[];
269
+ }
270
+ /**
271
+ * Stream the main session transcript and recover, in file order, every
272
+ * `Task`/`Agent` tool_use that was **paired** with a tool_result. Pairing is
273
+ * tracked so the returned list aligns 1:1 with herdctl's parsed tool messages
274
+ * for completed calls.
275
+ *
276
+ * Paired-only by design — {@link readTaskUsesFromFile} exposes the in-flight
277
+ * launches separately, and mixing them here would break that alignment.
278
+ */
279
+ export declare function readTaskToolUses(projectDir: string, sessionId: string): Promise<TaskToolUse[]>;
280
+ /**
281
+ * Live sub-agent enrichment for a tool frame (issue #429). When the tool is a
282
+ * `Task`/`Agent` launch this turn already recovered (via {@link extractSubagentLaunches}),
283
+ * return the real sub-agent type + title plus `hasSubagent: true`, so the client
284
+ * renders the enriched, expandable card the moment the launch streams — instead of
285
+ * the generic "Agent · <ms>" launch-ack that only filled in on refresh. A safe
286
+ * spread for any non-sub-agent tool (returns an empty object). `hasSubagent` is set
287
+ * optimistically: a `Task`/`Agent` launch is expected to write a sub-agent
288
+ * transcript, and the client's expand path degrades gracefully (a "waiting…"
289
+ * placeholder) until the sidecar appears on disk.
290
+ */
291
+ export declare function subagentLaunchFields(launches: Map<string, SubagentLaunch>, toolName: string, toolUseId: string | undefined): {
292
+ subagentType?: string;
293
+ description?: string;
294
+ hasSubagent?: boolean;
295
+ };
296
+ /**
297
+ * Read the `subagents/*.meta.json` sidecars for a session, keyed by `toolUseId`.
298
+ * Returns an empty map when the session has no sub-agents (the common case) or
299
+ * the directory is missing/unreadable.
300
+ */
301
+ export declare function listSubagents(projectDir: string, sessionId: string): Promise<Map<string, SubagentMeta>>;
302
+ /**
303
+ * Parse a single sub-agent's transcript into messages, reusing core's parser.
304
+ * Returns [] when the `toolUseId` doesn't correspond to a known sub-agent or the
305
+ * transcript is missing. Both segments are validated to stay inside `.chats/`.
306
+ */
307
+ export declare function readSubagentMessages(projectDir: string, sessionId: string, toolUseId: string): Promise<EnrichedMessage[]>;
308
+ /**
309
+ * Enrich a session's parsed messages: attach the recovered sub-agent fields
310
+ * (`toolUseId`, `subagentType`, `description`, `prompt`, `hasSubagent`) to every
311
+ * `Task`/`Agent` tool message, joining by file order. Non-Task tool calls and
312
+ * sessions without sub-agents pass through unchanged (a cheap early return).
313
+ */
314
+ export declare function enrichWithSubagents(projectDir: string, sessionId: string, messages: ChatMessage[]): Promise<EnrichedMessage[]>;
315
+ /**
316
+ * A chat's cumulative token usage *including every sub-agent it spawned* (issue
317
+ * #242).
318
+ *
319
+ * The per-chat cost/token headline (issue #152) originally priced only the main
320
+ * transcript, but a chat's `Task`/`Agent` sub-agents run in their own sibling
321
+ * transcripts (`.chats/<sessionId>/subagents/agent-*.jsonl`) — so a chat that
322
+ * fanned work out to sub-agents under-reported its true spend, sometimes by ~90%.
323
+ * This folds those transcripts back in: the four token totals and the per-model
324
+ * buckets gain every sub-agent's usage, so both the token figure and the
325
+ * per-model-priced dollar estimate reflect the whole chat.
326
+ *
327
+ * `contextTokens` and `turnCount` stay main-only: those describe the parent's
328
+ * last-turn context-window fill (what the ContextMeter shows), a distinct concept
329
+ * from lifetime spend — each sub-agent has its own, separate context window.
330
+ *
331
+ * No double-counting: herdctl writes sub-agent (`isSidechain`) turns to the
332
+ * sibling files, never into the main transcript, so `main + sub-agents` is a
333
+ * clean sum. Nested sub-agents (spawnDepth > 1) sit flat in the same `subagents/`
334
+ * dir, so their usage is included too. Returns the main usage unchanged when the
335
+ * chat spawned no sub-agents (the common case — a cheap early return).
336
+ */
337
+ export declare function readSessionTokenUsageWithSubagents(projectDir: string, sessionId: string): Promise<SessionTokenUsage>;