@clinebot/core 0.0.34 → 0.0.36

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 (546) hide show
  1. package/README.md +13 -10
  2. package/dist/ClineCore.d.ts +96 -63
  3. package/dist/ClineCore.d.ts.map +1 -1
  4. package/dist/account/index.d.ts +1 -1
  5. package/dist/account/index.d.ts.map +1 -1
  6. package/dist/account/rpc.d.ts +6 -6
  7. package/dist/account/rpc.d.ts.map +1 -1
  8. package/dist/cron/index.d.ts +6 -0
  9. package/dist/cron/index.d.ts.map +1 -0
  10. package/dist/cron/resource-limiter.d.ts +9 -0
  11. package/dist/cron/resource-limiter.d.ts.map +1 -0
  12. package/dist/cron/schedule-command-service.d.ts +10 -0
  13. package/dist/cron/schedule-command-service.d.ts.map +1 -0
  14. package/dist/cron/schedule-service.d.ts +100 -0
  15. package/dist/cron/schedule-service.d.ts.map +1 -0
  16. package/dist/cron/scheduler.d.ts +66 -0
  17. package/dist/cron/scheduler.d.ts.map +1 -0
  18. package/dist/cron/sqlite-schedule-store.d.ts +52 -0
  19. package/dist/cron/sqlite-schedule-store.d.ts.map +1 -0
  20. package/dist/extensions/config/agent-config-loader.d.ts +6 -5
  21. package/dist/extensions/config/agent-config-loader.d.ts.map +1 -1
  22. package/dist/extensions/config/agent-config-parser.d.ts +1 -1
  23. package/dist/extensions/config/agent-config-parser.d.ts.map +1 -1
  24. package/dist/extensions/config/hooks-config-loader.d.ts +2 -2
  25. package/dist/extensions/config/hooks-config-loader.d.ts.map +1 -1
  26. package/dist/extensions/config/index.d.ts +3 -3
  27. package/dist/extensions/config/index.d.ts.map +1 -1
  28. package/dist/extensions/config/runtime-commands.d.ts +1 -0
  29. package/dist/extensions/config/runtime-commands.d.ts.map +1 -1
  30. package/dist/extensions/config/user-instruction-config-loader.d.ts +3 -2
  31. package/dist/extensions/config/user-instruction-config-loader.d.ts.map +1 -1
  32. package/dist/extensions/context/agentic-compaction.d.ts +2 -2
  33. package/dist/extensions/context/agentic-compaction.d.ts.map +1 -1
  34. package/dist/extensions/context/compaction-shared.d.ts +5 -4
  35. package/dist/extensions/context/compaction-shared.d.ts.map +1 -1
  36. package/dist/extensions/context/compaction.d.ts.map +1 -1
  37. package/dist/extensions/plugin/plugin-config-loader.d.ts +9 -2
  38. package/dist/extensions/plugin/plugin-config-loader.d.ts.map +1 -1
  39. package/dist/extensions/plugin/plugin-loader.d.ts +5 -3
  40. package/dist/extensions/plugin/plugin-loader.d.ts.map +1 -1
  41. package/dist/extensions/plugin/plugin-module-import.d.ts.map +1 -1
  42. package/dist/extensions/plugin/plugin-sandbox.d.ts +15 -2
  43. package/dist/extensions/plugin/plugin-sandbox.d.ts.map +1 -1
  44. package/dist/extensions/plugin/plugin-targeting.d.ts +7 -0
  45. package/dist/extensions/plugin/plugin-targeting.d.ts.map +1 -0
  46. package/dist/extensions/plugin-sandbox-bootstrap.js +253 -253
  47. package/dist/extensions/tools/constants.d.ts.map +1 -0
  48. package/dist/{tools → extensions/tools}/definitions.d.ts +1 -1
  49. package/dist/extensions/tools/definitions.d.ts.map +1 -0
  50. package/dist/extensions/tools/executors/apply-patch-parser.d.ts.map +1 -0
  51. package/dist/{tools → extensions/tools}/executors/apply-patch.d.ts +3 -1
  52. package/dist/extensions/tools/executors/apply-patch.d.ts.map +1 -0
  53. package/dist/extensions/tools/executors/bash.d.ts.map +1 -0
  54. package/dist/extensions/tools/executors/editor.d.ts.map +1 -0
  55. package/dist/extensions/tools/executors/file-read.d.ts.map +1 -0
  56. package/dist/extensions/tools/executors/index.d.ts.map +1 -0
  57. package/dist/{tools → extensions/tools}/executors/search.d.ts +1 -1
  58. package/dist/extensions/tools/executors/search.d.ts.map +1 -0
  59. package/dist/extensions/tools/executors/web-fetch.d.ts.map +1 -0
  60. package/dist/extensions/tools/helpers.d.ts.map +1 -0
  61. package/dist/{tools → extensions/tools}/index.d.ts +2 -0
  62. package/dist/extensions/tools/index.d.ts.map +1 -0
  63. package/dist/{tools → extensions/tools}/model-tool-routing.d.ts +1 -1
  64. package/dist/extensions/tools/model-tool-routing.d.ts.map +1 -0
  65. package/dist/{tools → extensions/tools}/presets.d.ts +26 -44
  66. package/dist/extensions/tools/presets.d.ts.map +1 -0
  67. package/dist/extensions/tools/runtime.d.ts +25 -0
  68. package/dist/extensions/tools/runtime.d.ts.map +1 -0
  69. package/dist/extensions/tools/schemas.d.ts.map +1 -0
  70. package/dist/extensions/tools/team/delegated-agent.d.ts.map +1 -0
  71. package/dist/extensions/tools/team/index.d.ts.map +1 -0
  72. package/dist/{team → extensions/tools/team}/multi-agent.d.ts +1 -3
  73. package/dist/extensions/tools/team/multi-agent.d.ts.map +1 -0
  74. package/dist/extensions/tools/team/projections.d.ts.map +1 -0
  75. package/dist/extensions/tools/team/runtime.d.ts.map +1 -0
  76. package/dist/{team → extensions/tools/team}/spawn-agent-tool.d.ts +0 -1
  77. package/dist/extensions/tools/team/spawn-agent-tool.d.ts.map +1 -0
  78. package/dist/extensions/tools/team/subagent-prompts.d.ts.map +1 -0
  79. package/dist/{team → extensions/tools/team}/team-tools.d.ts +1 -0
  80. package/dist/extensions/tools/team/team-tools.d.ts.map +1 -0
  81. package/dist/{tools → extensions/tools}/types.d.ts +4 -3
  82. package/dist/extensions/tools/types.d.ts.map +1 -0
  83. package/dist/{runtime → hooks}/checkpoint-hooks.d.ts +7 -0
  84. package/dist/hooks/checkpoint-hooks.d.ts.map +1 -0
  85. package/dist/{runtime → hooks}/hook-file-hooks.d.ts +4 -3
  86. package/dist/hooks/hook-file-hooks.d.ts.map +1 -0
  87. package/dist/hooks/index.d.ts +0 -1
  88. package/dist/hooks/index.d.ts.map +1 -1
  89. package/dist/hooks/subprocess.d.ts +10 -130
  90. package/dist/hooks/subprocess.d.ts.map +1 -1
  91. package/dist/hub/browser-websocket.d.ts +18 -0
  92. package/dist/hub/browser-websocket.d.ts.map +1 -0
  93. package/dist/hub/client.d.ts +45 -0
  94. package/dist/hub/client.d.ts.map +1 -0
  95. package/dist/hub/connect.d.ts +15 -0
  96. package/dist/hub/connect.d.ts.map +1 -0
  97. package/dist/hub/daemon-entry.d.ts +2 -0
  98. package/dist/hub/daemon-entry.d.ts.map +1 -0
  99. package/dist/hub/daemon-entry.js +1045 -0
  100. package/dist/hub/daemon.d.ts +5 -0
  101. package/dist/hub/daemon.d.ts.map +1 -0
  102. package/dist/hub/defaults.d.ts +13 -0
  103. package/dist/hub/defaults.d.ts.map +1 -0
  104. package/dist/hub/discovery.d.ts +29 -0
  105. package/dist/hub/discovery.d.ts.map +1 -0
  106. package/dist/hub/index.d.ts +15 -0
  107. package/dist/hub/index.d.ts.map +1 -0
  108. package/dist/hub/index.js +1044 -0
  109. package/dist/hub/native-transport.d.ts +17 -0
  110. package/dist/hub/native-transport.d.ts.map +1 -0
  111. package/dist/hub/runtime-handlers.d.ts +11 -0
  112. package/dist/hub/runtime-handlers.d.ts.map +1 -0
  113. package/dist/hub/server.d.ts +86 -0
  114. package/dist/hub/server.d.ts.map +1 -0
  115. package/dist/hub/session-client.d.ts +87 -0
  116. package/dist/hub/session-client.d.ts.map +1 -0
  117. package/dist/hub/start-shared-server.d.ts +19 -0
  118. package/dist/hub/start-shared-server.d.ts.map +1 -0
  119. package/dist/hub/transport.d.ts +8 -0
  120. package/dist/hub/transport.d.ts.map +1 -0
  121. package/dist/hub/ui-client.d.ts +44 -0
  122. package/dist/hub/ui-client.d.ts.map +1 -0
  123. package/dist/hub/workspace.d.ts +4 -0
  124. package/dist/hub/workspace.d.ts.map +1 -0
  125. package/dist/index.d.ts +52 -39
  126. package/dist/index.d.ts.map +1 -1
  127. package/dist/index.js +557 -533
  128. package/dist/llms/configured-provider-registry.d.ts +28 -0
  129. package/dist/llms/configured-provider-registry.d.ts.map +1 -0
  130. package/dist/llms/provider-defaults.d.ts +27 -0
  131. package/dist/llms/provider-defaults.d.ts.map +1 -0
  132. package/dist/llms/provider-settings.d.ts +202 -0
  133. package/dist/llms/provider-settings.d.ts.map +1 -0
  134. package/dist/llms/runtime-config.d.ts +4 -0
  135. package/dist/llms/runtime-config.d.ts.map +1 -0
  136. package/dist/llms/runtime-registry.d.ts +20 -0
  137. package/dist/llms/runtime-registry.d.ts.map +1 -0
  138. package/dist/llms/runtime-types.d.ts +85 -0
  139. package/dist/llms/runtime-types.d.ts.map +1 -0
  140. package/dist/runtime/history.d.ts +4 -0
  141. package/dist/runtime/history.d.ts.map +1 -0
  142. package/dist/runtime/host.d.ts +8 -0
  143. package/dist/runtime/host.d.ts.map +1 -0
  144. package/dist/runtime/rules.d.ts +1 -0
  145. package/dist/runtime/rules.d.ts.map +1 -1
  146. package/dist/runtime/runtime-builder.d.ts.map +1 -1
  147. package/dist/runtime/runtime-host.d.ts +103 -0
  148. package/dist/runtime/runtime-host.d.ts.map +1 -0
  149. package/dist/{session → runtime}/runtime-oauth-token-manager.d.ts +1 -1
  150. package/dist/{session → runtime}/runtime-oauth-token-manager.d.ts.map +1 -1
  151. package/dist/runtime/session-runtime.d.ts +3 -21
  152. package/dist/runtime/session-runtime.d.ts.map +1 -1
  153. package/dist/{session/session-agent-events.d.ts → services/agent-events.d.ts} +4 -4
  154. package/dist/services/agent-events.d.ts.map +1 -0
  155. package/dist/services/config.d.ts +3 -0
  156. package/dist/services/config.d.ts.map +1 -0
  157. package/dist/services/global-settings.d.ts +12 -0
  158. package/dist/services/global-settings.d.ts.map +1 -0
  159. package/dist/services/local-runtime-bootstrap.d.ts +47 -0
  160. package/dist/services/local-runtime-bootstrap.d.ts.map +1 -0
  161. package/dist/services/plugin-tools.d.ts +16 -0
  162. package/dist/services/plugin-tools.d.ts.map +1 -0
  163. package/dist/{providers → services/providers}/local-provider-registry.d.ts +4 -4
  164. package/dist/services/providers/local-provider-registry.d.ts.map +1 -0
  165. package/dist/{providers → services/providers}/local-provider-service.d.ts +13 -13
  166. package/dist/services/providers/local-provider-service.d.ts.map +1 -0
  167. package/dist/{session → services}/session-artifacts.d.ts +0 -4
  168. package/dist/services/session-artifacts.d.ts.map +1 -0
  169. package/dist/{session/utils/helpers.d.ts → services/session-data.d.ts} +19 -27
  170. package/dist/services/session-data.d.ts.map +1 -0
  171. package/dist/{session → services}/session-telemetry.d.ts +2 -2
  172. package/dist/services/session-telemetry.d.ts.map +1 -0
  173. package/dist/{storage → services/storage}/file-team-store.d.ts +2 -2
  174. package/dist/services/storage/file-team-store.d.ts.map +1 -0
  175. package/dist/{storage → services/storage}/provider-settings-legacy-migration.d.ts +1 -1
  176. package/dist/services/storage/provider-settings-legacy-migration.d.ts.map +1 -0
  177. package/dist/{storage → services/storage}/provider-settings-manager.d.ts +1 -1
  178. package/dist/services/storage/provider-settings-manager.d.ts.map +1 -0
  179. package/dist/{storage → services/storage}/sqlite-session-store.d.ts +3 -3
  180. package/dist/services/storage/sqlite-session-store.d.ts.map +1 -0
  181. package/dist/{storage → services/storage}/sqlite-team-store.d.ts +2 -2
  182. package/dist/services/storage/sqlite-team-store.d.ts.map +1 -0
  183. package/dist/{storage → services/storage}/team-store.d.ts +1 -1
  184. package/dist/services/storage/team-store.d.ts.map +1 -0
  185. package/dist/services/telemetry/ITelemetryAdapter.d.ts.map +1 -0
  186. package/dist/services/telemetry/OpenTelemetryAdapter.d.ts.map +1 -0
  187. package/dist/services/telemetry/OpenTelemetryProvider.d.ts.map +1 -0
  188. package/dist/services/telemetry/TelemetryLoggerSink.d.ts.map +1 -0
  189. package/dist/services/telemetry/TelemetryService.d.ts.map +1 -0
  190. package/dist/services/telemetry/core-events.d.ts.map +1 -0
  191. package/dist/services/telemetry/distinct-id.d.ts.map +1 -0
  192. package/dist/services/telemetry/index.d.ts.map +1 -0
  193. package/dist/services/telemetry/index.js +28 -0
  194. package/dist/{session/utils → services}/usage.d.ts +1 -1
  195. package/dist/services/usage.d.ts.map +1 -0
  196. package/dist/services/workspace/file-indexer.d.ts.map +1 -0
  197. package/dist/services/workspace/index.d.ts.map +1 -0
  198. package/dist/services/workspace/mention-enricher.d.ts.map +1 -0
  199. package/dist/services/workspace-manifest.d.ts +16 -0
  200. package/dist/services/workspace-manifest.d.ts.map +1 -0
  201. package/dist/session/file-session-service.d.ts +4 -1
  202. package/dist/session/file-session-service.d.ts.map +1 -1
  203. package/dist/session/persistence-service.d.ts +15 -25
  204. package/dist/session/persistence-service.d.ts.map +1 -1
  205. package/dist/session/session-manifest-store.d.ts +22 -0
  206. package/dist/session/session-manifest-store.d.ts.map +1 -0
  207. package/dist/session/session-row.d.ts +93 -0
  208. package/dist/session/session-row.d.ts.map +1 -0
  209. package/dist/session/session-service.d.ts +8 -109
  210. package/dist/session/session-service.d.ts.map +1 -1
  211. package/dist/session/session-team-coordination.d.ts +4 -4
  212. package/dist/session/session-team-coordination.d.ts.map +1 -1
  213. package/dist/session/subagent-session-manager.d.ts +36 -0
  214. package/dist/session/subagent-session-manager.d.ts.map +1 -0
  215. package/dist/session/team-persistence-store.d.ts +24 -0
  216. package/dist/session/team-persistence-store.d.ts.map +1 -0
  217. package/dist/transports/hub.d.ts +47 -0
  218. package/dist/transports/hub.d.ts.map +1 -0
  219. package/dist/{session/default-session-manager.d.ts → transports/local.d.ts} +30 -16
  220. package/dist/transports/local.d.ts.map +1 -0
  221. package/dist/transports/remote.d.ts +10 -0
  222. package/dist/transports/remote.d.ts.map +1 -0
  223. package/dist/transports/runtime-host-support.d.ts +22 -0
  224. package/dist/transports/runtime-host-support.d.ts.map +1 -0
  225. package/dist/{chat → types}/chat-schema.d.ts +10 -12
  226. package/dist/types/chat-schema.d.ts.map +1 -0
  227. package/dist/types/config.d.ts +10 -9
  228. package/dist/types/config.d.ts.map +1 -1
  229. package/dist/types/provider-settings.d.ts +4 -5
  230. package/dist/types/provider-settings.d.ts.map +1 -1
  231. package/dist/{session/utils/types.d.ts → types/session.d.ts} +16 -6
  232. package/dist/types/session.d.ts.map +1 -0
  233. package/dist/types/sessions.d.ts +19 -0
  234. package/dist/types/sessions.d.ts.map +1 -1
  235. package/dist/types/storage.d.ts +1 -3
  236. package/dist/types/storage.d.ts.map +1 -1
  237. package/dist/types.d.ts +14 -6
  238. package/dist/types.d.ts.map +1 -1
  239. package/package.json +22 -13
  240. package/src/ClineCore.ts +183 -85
  241. package/src/account/index.ts +3 -3
  242. package/src/account/rpc.ts +12 -12
  243. package/src/auth/cline.ts +1 -1
  244. package/src/auth/codex.ts +1 -1
  245. package/src/auth/oca.ts +1 -1
  246. package/src/cron/index.ts +5 -0
  247. package/src/cron/resource-limiter.ts +46 -0
  248. package/src/cron/schedule-command-service.ts +193 -0
  249. package/src/cron/schedule-service.ts +703 -0
  250. package/src/cron/scheduler.ts +637 -0
  251. package/src/cron/sqlite-schedule-store.ts +708 -0
  252. package/src/extensions/config/agent-config-loader.ts +18 -12
  253. package/src/extensions/config/agent-config-parser.ts +1 -1
  254. package/src/extensions/config/hooks-config-loader.ts +1 -2
  255. package/src/extensions/config/index.ts +0 -4
  256. package/src/extensions/config/runtime-commands.ts +6 -0
  257. package/src/extensions/config/user-instruction-config-loader.ts +1 -4
  258. package/src/extensions/context/agentic-compaction.ts +3 -3
  259. package/src/extensions/context/basic-compaction.ts +2 -2
  260. package/src/extensions/context/compaction-shared.ts +5 -4
  261. package/src/extensions/context/compaction.ts +3 -3
  262. package/src/extensions/plugin/plugin-config-loader.ts +17 -2
  263. package/src/extensions/plugin/plugin-loader.ts +48 -4
  264. package/src/extensions/plugin/plugin-module-import.ts +0 -2
  265. package/src/extensions/plugin/plugin-sandbox-bootstrap.ts +93 -39
  266. package/src/extensions/plugin/plugin-sandbox.ts +47 -27
  267. package/src/extensions/plugin/plugin-targeting.ts +32 -0
  268. package/src/{tools → extensions/tools}/definitions.ts +31 -50
  269. package/src/{tools → extensions/tools}/executors/apply-patch.ts +69 -80
  270. package/src/{tools → extensions/tools}/executors/file-read.ts +29 -4
  271. package/src/{tools → extensions/tools}/executors/search.ts +196 -4
  272. package/src/{tools → extensions/tools}/index.ts +10 -0
  273. package/src/{tools → extensions/tools}/model-tool-routing.ts +1 -1
  274. package/src/{tools → extensions/tools}/presets.ts +31 -47
  275. package/src/extensions/tools/runtime.ts +261 -0
  276. package/src/{tools → extensions/tools}/schemas.ts +4 -2
  277. package/src/{team → extensions/tools/team}/multi-agent.ts +80 -17
  278. package/src/{team → extensions/tools/team}/spawn-agent-tool.ts +1 -7
  279. package/src/{team → extensions/tools/team}/subagent-prompts.ts +2 -2
  280. package/src/{team → extensions/tools/team}/team-tools.ts +84 -53
  281. package/src/{tools → extensions/tools}/types.ts +5 -3
  282. package/src/{runtime → hooks}/checkpoint-hooks.ts +27 -0
  283. package/src/{runtime → hooks}/hook-file-hooks.ts +14 -13
  284. package/src/hooks/index.ts +0 -7
  285. package/src/hooks/subprocess-runner.ts +1 -1
  286. package/src/hooks/subprocess.ts +57 -257
  287. package/src/hub/browser-websocket.ts +137 -0
  288. package/src/hub/client.ts +574 -0
  289. package/src/hub/connect.ts +156 -0
  290. package/src/hub/daemon-entry.ts +87 -0
  291. package/src/hub/daemon.ts +181 -0
  292. package/src/hub/defaults.ts +43 -0
  293. package/src/hub/discovery.ts +247 -0
  294. package/src/hub/index.ts +14 -0
  295. package/src/hub/native-transport.ts +31 -0
  296. package/src/hub/runtime-handlers.ts +140 -0
  297. package/src/hub/server.ts +1888 -0
  298. package/src/hub/session-client.ts +460 -0
  299. package/src/hub/start-shared-server.ts +58 -0
  300. package/src/hub/transport.ts +14 -0
  301. package/src/hub/ui-client.ts +122 -0
  302. package/src/hub/workspace.ts +19 -0
  303. package/src/index.ts +264 -199
  304. package/src/llms/configured-provider-registry.ts +193 -0
  305. package/src/llms/provider-defaults.ts +637 -0
  306. package/src/llms/provider-settings.ts +263 -0
  307. package/src/llms/runtime-config.ts +43 -0
  308. package/src/llms/runtime-registry.ts +171 -0
  309. package/src/llms/runtime-types.ts +121 -0
  310. package/src/runtime/history.ts +237 -0
  311. package/src/runtime/host.ts +200 -0
  312. package/src/runtime/index.ts +1 -0
  313. package/src/runtime/rules.ts +12 -0
  314. package/src/runtime/runtime-builder.ts +37 -29
  315. package/src/runtime/runtime-host.ts +206 -0
  316. package/src/{session → runtime}/runtime-oauth-token-manager.ts +12 -16
  317. package/src/runtime/session-runtime.ts +2 -26
  318. package/src/{session/session-agent-events.ts → services/agent-events.ts} +7 -7
  319. package/src/services/config.ts +5 -0
  320. package/src/services/global-settings.ts +122 -0
  321. package/src/services/local-runtime-bootstrap.ts +318 -0
  322. package/src/services/plugin-tools.ts +85 -0
  323. package/src/{providers → services/providers}/local-provider-registry.ts +6 -6
  324. package/src/{providers → services/providers}/local-provider-service.ts +46 -41
  325. package/src/{session → services}/session-artifacts.ts +7 -19
  326. package/src/{session/utils/helpers.ts → services/session-data.ts} +90 -80
  327. package/src/{session → services}/session-telemetry.ts +7 -9
  328. package/src/services/storage/artifact-store.ts +1 -0
  329. package/src/{storage → services/storage}/file-team-store.ts +2 -2
  330. package/src/{storage → services/storage}/provider-settings-legacy-migration.ts +6 -4
  331. package/src/{storage → services/storage}/provider-settings-manager.ts +3 -3
  332. package/src/services/storage/session-store.ts +1 -0
  333. package/src/{storage → services/storage}/sqlite-session-store.ts +7 -12
  334. package/src/{storage → services/storage}/sqlite-team-store.ts +4 -4
  335. package/src/{storage → services/storage}/team-store.ts +1 -1
  336. package/src/{session/utils → services}/usage.ts +1 -1
  337. package/src/{input → services/workspace}/file-indexer.ts +26 -2
  338. package/src/{input → services/workspace}/mention-enricher.ts +1 -1
  339. package/src/{session → services}/workspace-manifest.ts +18 -0
  340. package/src/session/file-session-service.ts +10 -8
  341. package/src/session/index.ts +10 -23
  342. package/src/session/persistence-service.ts +144 -528
  343. package/src/session/session-manifest-store.ts +158 -0
  344. package/src/session/session-row.ts +199 -0
  345. package/src/session/session-service.ts +43 -389
  346. package/src/session/session-team-coordination.ts +14 -7
  347. package/src/session/subagent-session-manager.ts +397 -0
  348. package/src/session/team-persistence-store.ts +176 -0
  349. package/src/session/workspace-manager.ts +1 -1
  350. package/src/transports/hub.ts +656 -0
  351. package/src/{session/default-session-manager.ts → transports/local.ts} +263 -200
  352. package/src/transports/remote.ts +26 -0
  353. package/src/transports/runtime-host-support.ts +140 -0
  354. package/src/{chat → types}/chat-schema.ts +4 -5
  355. package/src/types/config.ts +10 -9
  356. package/src/types/provider-settings.ts +11 -7
  357. package/src/{session/utils/types.ts → types/session.ts} +16 -5
  358. package/src/types/sessions.ts +21 -0
  359. package/src/types/storage.ts +1 -6
  360. package/src/types.ts +52 -19
  361. package/dist/chat/chat-schema.d.ts.map +0 -1
  362. package/dist/hooks/persistent.d.ts +0 -64
  363. package/dist/hooks/persistent.d.ts.map +0 -1
  364. package/dist/input/file-indexer.d.ts.map +0 -1
  365. package/dist/input/index.d.ts.map +0 -1
  366. package/dist/input/mention-enricher.d.ts.map +0 -1
  367. package/dist/prompt/default-system.d.ts +0 -2
  368. package/dist/prompt/default-system.d.ts.map +0 -1
  369. package/dist/providers/local-provider-registry.d.ts.map +0 -1
  370. package/dist/providers/local-provider-service.d.ts.map +0 -1
  371. package/dist/runtime/checkpoint-hooks.d.ts.map +0 -1
  372. package/dist/runtime/hook-file-hooks.d.ts.map +0 -1
  373. package/dist/session/default-session-manager.d.ts.map +0 -1
  374. package/dist/session/rpc-runtime-ensure.d.ts +0 -53
  375. package/dist/session/rpc-runtime-ensure.d.ts.map +0 -1
  376. package/dist/session/rpc-session-service.d.ts +0 -13
  377. package/dist/session/rpc-session-service.d.ts.map +0 -1
  378. package/dist/session/rpc-spawn-lease.d.ts +0 -8
  379. package/dist/session/rpc-spawn-lease.d.ts.map +0 -1
  380. package/dist/session/session-agent-events.d.ts.map +0 -1
  381. package/dist/session/session-artifacts.d.ts.map +0 -1
  382. package/dist/session/session-config-builder.d.ts +0 -16
  383. package/dist/session/session-config-builder.d.ts.map +0 -1
  384. package/dist/session/session-host.d.ts +0 -15
  385. package/dist/session/session-host.d.ts.map +0 -1
  386. package/dist/session/session-manager.d.ts +0 -62
  387. package/dist/session/session-manager.d.ts.map +0 -1
  388. package/dist/session/session-telemetry.d.ts.map +0 -1
  389. package/dist/session/sqlite-rpc-session-backend.d.ts +0 -31
  390. package/dist/session/sqlite-rpc-session-backend.d.ts.map +0 -1
  391. package/dist/session/utils/helpers.d.ts.map +0 -1
  392. package/dist/session/utils/types.d.ts.map +0 -1
  393. package/dist/session/utils/usage.d.ts.map +0 -1
  394. package/dist/session/workspace-manifest.d.ts +0 -5
  395. package/dist/session/workspace-manifest.d.ts.map +0 -1
  396. package/dist/storage/file-team-store.d.ts.map +0 -1
  397. package/dist/storage/provider-settings-legacy-migration.d.ts.map +0 -1
  398. package/dist/storage/provider-settings-manager.d.ts.map +0 -1
  399. package/dist/storage/sqlite-session-store.d.ts.map +0 -1
  400. package/dist/storage/sqlite-team-store.d.ts.map +0 -1
  401. package/dist/storage/team-store.d.ts.map +0 -1
  402. package/dist/team/delegated-agent.d.ts.map +0 -1
  403. package/dist/team/index.d.ts.map +0 -1
  404. package/dist/team/multi-agent.d.ts.map +0 -1
  405. package/dist/team/projections.d.ts.map +0 -1
  406. package/dist/team/runtime.d.ts.map +0 -1
  407. package/dist/team/spawn-agent-tool.d.ts.map +0 -1
  408. package/dist/team/subagent-prompts.d.ts.map +0 -1
  409. package/dist/team/team-tools.d.ts.map +0 -1
  410. package/dist/telemetry/ITelemetryAdapter.d.ts.map +0 -1
  411. package/dist/telemetry/OpenTelemetryAdapter.d.ts.map +0 -1
  412. package/dist/telemetry/OpenTelemetryProvider.d.ts.map +0 -1
  413. package/dist/telemetry/TelemetryLoggerSink.d.ts.map +0 -1
  414. package/dist/telemetry/TelemetryService.d.ts.map +0 -1
  415. package/dist/telemetry/core-events.d.ts.map +0 -1
  416. package/dist/telemetry/distinct-id.d.ts.map +0 -1
  417. package/dist/telemetry/index.d.ts.map +0 -1
  418. package/dist/telemetry/index.js +0 -15
  419. package/dist/tools/constants.d.ts.map +0 -1
  420. package/dist/tools/definitions.d.ts.map +0 -1
  421. package/dist/tools/executors/apply-patch-parser.d.ts.map +0 -1
  422. package/dist/tools/executors/apply-patch.d.ts.map +0 -1
  423. package/dist/tools/executors/bash.d.ts.map +0 -1
  424. package/dist/tools/executors/editor.d.ts.map +0 -1
  425. package/dist/tools/executors/file-read.d.ts.map +0 -1
  426. package/dist/tools/executors/index.d.ts.map +0 -1
  427. package/dist/tools/executors/search.d.ts.map +0 -1
  428. package/dist/tools/executors/web-fetch.d.ts.map +0 -1
  429. package/dist/tools/helpers.d.ts.map +0 -1
  430. package/dist/tools/index.d.ts.map +0 -1
  431. package/dist/tools/model-tool-routing.d.ts.map +0 -1
  432. package/dist/tools/presets.d.ts.map +0 -1
  433. package/dist/tools/schemas.d.ts.map +0 -1
  434. package/dist/tools/types.d.ts.map +0 -1
  435. package/src/ClineCore.test.ts +0 -150
  436. package/src/account/cline-account-service.test.ts +0 -185
  437. package/src/account/featurebase-token.test.ts +0 -175
  438. package/src/account/rpc.test.ts +0 -63
  439. package/src/auth/bounded-ttl-cache.test.ts +0 -38
  440. package/src/auth/client.test.ts +0 -69
  441. package/src/auth/cline.test.ts +0 -267
  442. package/src/auth/codex.test.ts +0 -170
  443. package/src/auth/oca.test.ts +0 -340
  444. package/src/auth/server.test.ts +0 -287
  445. package/src/auth/utils.test.ts +0 -128
  446. package/src/extensions/config/agent-config-loader.test.ts +0 -236
  447. package/src/extensions/config/hooks-config-loader.test.ts +0 -20
  448. package/src/extensions/config/runtime-commands.test.ts +0 -115
  449. package/src/extensions/config/unified-config-file-watcher.test.ts +0 -196
  450. package/src/extensions/config/user-instruction-config-loader.test.ts +0 -246
  451. package/src/extensions/context/compaction.test.ts +0 -483
  452. package/src/extensions/mcp/config-loader.test.ts +0 -238
  453. package/src/extensions/mcp/manager.test.ts +0 -105
  454. package/src/extensions/plugin/plugin-config-loader.test.ts +0 -182
  455. package/src/extensions/plugin/plugin-loader.test.ts +0 -292
  456. package/src/extensions/plugin/plugin-sandbox.test.ts +0 -423
  457. package/src/hooks/persistent.ts +0 -661
  458. package/src/input/file-indexer.d.ts +0 -11
  459. package/src/input/file-indexer.test.ts +0 -127
  460. package/src/input/mention-enricher.test.ts +0 -85
  461. package/src/prompt/default-system.ts +0 -21
  462. package/src/providers/local-provider-service.test.ts +0 -1062
  463. package/src/runtime/checkpoint-hooks.test.ts +0 -168
  464. package/src/runtime/hook-file-hooks.test.ts +0 -311
  465. package/src/runtime/runtime-builder.team-persistence.test.ts +0 -242
  466. package/src/runtime/runtime-builder.test.ts +0 -616
  467. package/src/runtime/runtime-parity.test.ts +0 -143
  468. package/src/session/default-session-manager.e2e.test.ts +0 -384
  469. package/src/session/default-session-manager.test.ts +0 -2473
  470. package/src/session/persistence-service.test.ts +0 -241
  471. package/src/session/rpc-runtime-ensure.ts +0 -521
  472. package/src/session/rpc-session-service.ts +0 -107
  473. package/src/session/rpc-spawn-lease.test.ts +0 -49
  474. package/src/session/rpc-spawn-lease.ts +0 -122
  475. package/src/session/runtime-oauth-token-manager.test.ts +0 -137
  476. package/src/session/session-config-builder.ts +0 -172
  477. package/src/session/session-host.test.ts +0 -89
  478. package/src/session/session-host.ts +0 -213
  479. package/src/session/session-manager.ts +0 -74
  480. package/src/session/session-service.team-persistence.test.ts +0 -48
  481. package/src/session/sqlite-rpc-session-backend.ts +0 -303
  482. package/src/session/utils/helpers.test.ts +0 -160
  483. package/src/storage/artifact-store.ts +0 -1
  484. package/src/storage/provider-settings-legacy-migration.test.ts +0 -424
  485. package/src/storage/provider-settings-manager.test.ts +0 -191
  486. package/src/storage/session-store.ts +0 -1
  487. package/src/team/multi-agent.lifecycle.test.ts +0 -201
  488. package/src/team/spawn-agent-tool.test.ts +0 -387
  489. package/src/team/team-tools.test.ts +0 -906
  490. package/src/telemetry/OpenTelemetryAdapter.test.ts +0 -157
  491. package/src/telemetry/OpenTelemetryProvider.test.ts +0 -326
  492. package/src/telemetry/TelemetryLoggerSink.test.ts +0 -42
  493. package/src/telemetry/TelemetryService.test.ts +0 -134
  494. package/src/telemetry/distinct-id.test.ts +0 -57
  495. package/src/tools/definitions.test.ts +0 -780
  496. package/src/tools/executors/bash.test.ts +0 -87
  497. package/src/tools/executors/editor.test.ts +0 -35
  498. package/src/tools/executors/file-read.test.ts +0 -49
  499. package/src/tools/model-tool-routing.test.ts +0 -86
  500. package/src/tools/presets.test.ts +0 -70
  501. /package/dist/{tools → extensions/tools}/constants.d.ts +0 -0
  502. /package/dist/{tools → extensions/tools}/executors/apply-patch-parser.d.ts +0 -0
  503. /package/dist/{tools → extensions/tools}/executors/bash.d.ts +0 -0
  504. /package/dist/{tools → extensions/tools}/executors/editor.d.ts +0 -0
  505. /package/dist/{tools → extensions/tools}/executors/file-read.d.ts +0 -0
  506. /package/dist/{tools → extensions/tools}/executors/index.d.ts +0 -0
  507. /package/dist/{tools → extensions/tools}/executors/web-fetch.d.ts +0 -0
  508. /package/dist/{tools → extensions/tools}/helpers.d.ts +0 -0
  509. /package/dist/{tools → extensions/tools}/schemas.d.ts +0 -0
  510. /package/dist/{team → extensions/tools/team}/delegated-agent.d.ts +0 -0
  511. /package/dist/{team → extensions/tools/team}/index.d.ts +0 -0
  512. /package/dist/{team → extensions/tools/team}/projections.d.ts +0 -0
  513. /package/dist/{team → extensions/tools/team}/runtime.d.ts +0 -0
  514. /package/dist/{team → extensions/tools/team}/subagent-prompts.d.ts +0 -0
  515. /package/dist/{telemetry → services/telemetry}/ITelemetryAdapter.d.ts +0 -0
  516. /package/dist/{telemetry → services/telemetry}/OpenTelemetryAdapter.d.ts +0 -0
  517. /package/dist/{telemetry → services/telemetry}/OpenTelemetryProvider.d.ts +0 -0
  518. /package/dist/{telemetry → services/telemetry}/TelemetryLoggerSink.d.ts +0 -0
  519. /package/dist/{telemetry → services/telemetry}/TelemetryService.d.ts +0 -0
  520. /package/dist/{telemetry → services/telemetry}/core-events.d.ts +0 -0
  521. /package/dist/{telemetry → services/telemetry}/distinct-id.d.ts +0 -0
  522. /package/dist/{telemetry → services/telemetry}/index.d.ts +0 -0
  523. /package/dist/{input → services/workspace}/file-indexer.d.ts +0 -0
  524. /package/dist/{input → services/workspace}/index.d.ts +0 -0
  525. /package/dist/{input → services/workspace}/mention-enricher.d.ts +0 -0
  526. /package/src/{tools → extensions/tools}/constants.ts +0 -0
  527. /package/src/{tools → extensions/tools}/executors/apply-patch-parser.ts +0 -0
  528. /package/src/{tools → extensions/tools}/executors/bash.ts +0 -0
  529. /package/src/{tools → extensions/tools}/executors/editor.ts +0 -0
  530. /package/src/{tools → extensions/tools}/executors/index.ts +0 -0
  531. /package/src/{tools → extensions/tools}/executors/web-fetch.ts +0 -0
  532. /package/src/{tools → extensions/tools}/helpers.ts +0 -0
  533. /package/src/{team → extensions/tools/team}/delegated-agent.ts +0 -0
  534. /package/src/{team → extensions/tools/team}/index.ts +0 -0
  535. /package/src/{team → extensions/tools/team}/projections.ts +0 -0
  536. /package/src/{team → extensions/tools/team}/runtime.ts +0 -0
  537. /package/src/{storage → services/storage}/index.ts +0 -0
  538. /package/src/{telemetry → services/telemetry}/ITelemetryAdapter.ts +0 -0
  539. /package/src/{telemetry → services/telemetry}/OpenTelemetryAdapter.ts +0 -0
  540. /package/src/{telemetry → services/telemetry}/OpenTelemetryProvider.ts +0 -0
  541. /package/src/{telemetry → services/telemetry}/TelemetryLoggerSink.ts +0 -0
  542. /package/src/{telemetry → services/telemetry}/TelemetryService.ts +0 -0
  543. /package/src/{telemetry → services/telemetry}/core-events.ts +0 -0
  544. /package/src/{telemetry → services/telemetry}/distinct-id.ts +0 -0
  545. /package/src/{telemetry → services/telemetry}/index.ts +0 -0
  546. /package/src/{input → services/workspace}/index.ts +0 -0
@@ -1,94 +1,62 @@
1
- import {
2
- appendFileSync,
3
- existsSync,
4
- readFileSync,
5
- writeFileSync,
6
- } from "node:fs";
7
1
  import { dirname } from "node:path";
8
2
  import type * as LlmsProviders from "@clinebot/llms";
9
3
  import type { AgentResult } from "@clinebot/shared";
10
- import { resolveRootSessionId } from "@clinebot/shared";
11
4
  import { nanoid } from "nanoid";
12
- import { z } from "zod";
13
- import type { HookEventPayload } from "../hooks";
14
- import type { SubAgentEndContext, SubAgentStartContext } from "../team";
15
- import { SessionSource, type SessionStatus } from "../types/common";
16
- import { nowIso, SessionArtifacts, unlinkIfExists } from "./session-artifacts";
17
- import {
18
- deriveSubsessionStatus,
19
- makeSubSessionId,
20
- makeTeamTaskSubSessionId,
21
- } from "./session-graph";
22
- import {
23
- type SessionManifest,
24
- SessionManifestSchema,
25
- } from "./session-manifest";
26
5
  import type {
27
- CreateRootSessionWithArtifactsInput,
28
- RootSessionArtifacts,
29
- SessionRow,
30
- UpsertSubagentInput,
31
- } from "./session-service";
6
+ SubAgentEndContext,
7
+ SubAgentStartContext,
8
+ } from "../extensions/tools/team";
9
+ import type { HookEventPayload } from "../hooks";
10
+ import { deleteCheckpointRefs } from "../hooks/checkpoint-hooks";
11
+ import { nowIso, unlinkIfExists } from "../services/session-artifacts";
32
12
  import {
33
13
  buildManifestFromRow,
34
- buildMessagesFilePayload,
35
14
  deriveTitleFromPrompt,
36
15
  normalizeStoredMessagesForPersistence,
37
16
  normalizeTitle,
38
- resolveMessagesFileContext,
39
17
  resolveMetadataWithTitle,
40
18
  sanitizeMetadata,
41
19
  withLatestAssistantTurnMetadata,
42
20
  withOccRetry,
43
- writeEmptyMessagesFile,
44
- } from "./utils/helpers";
21
+ } from "../services/session-data";
22
+ import type { SessionStatus } from "../types/common";
45
23
  import type {
46
24
  PersistedSessionUpdateInput,
25
+ SessionMessagesArtifactUploader,
47
26
  SessionPersistenceAdapter,
48
27
  StoredMessageWithMetadata,
49
- } from "./utils/types";
28
+ } from "../types/session";
29
+ import { SessionManifestStore } from "./session-manifest-store";
30
+ import type { SessionRow } from "./session-row";
31
+ import { SubagentSessionManager } from "./subagent-session-manager";
50
32
 
51
33
  export type { PersistedSessionUpdateInput, SessionPersistenceAdapter };
52
34
 
53
- const SUBSESSION_SOURCE = SessionSource.SUBAGENT;
54
35
  const OCC_MAX_RETRIES = 4;
55
36
 
56
- const SpawnAgentInputSchema = z.looseObject({
57
- task: z.string().optional(),
58
- systemPrompt: z.string().optional(),
59
- });
60
-
61
- // ── Service ───────────────────────────────────────────────────────────
62
-
63
37
  export class UnifiedSessionPersistenceService {
64
- private readonly teamTaskSessionsByAgent = new Map<string, string[]>();
65
- private readonly teamTaskLastHeartbeatBySession = new Map<string, number>();
66
- private readonly teamTaskLastProgressLineBySession = new Map<
67
- string,
68
- string
69
- >();
70
- protected readonly artifacts: SessionArtifacts;
38
+ private readonly manifestStore: SessionManifestStore;
39
+ private readonly subagents: SubagentSessionManager;
71
40
  private static readonly STALE_REASON = "failed_external_process_exit";
72
41
  private static readonly STALE_SOURCE = "stale_session_reconciler";
73
42
  private static readonly TEAM_HEARTBEAT_LOG_INTERVAL_MS = 30_000;
74
43
 
75
- constructor(private readonly adapter: SessionPersistenceAdapter) {
76
- this.artifacts = new SessionArtifacts(() => this.ensureSessionsDir());
77
- }
78
-
79
- ensureSessionsDir(): string {
80
- return this.adapter.ensureSessionsDir();
81
- }
82
-
83
- private initializeMessagesFile(
84
- sessionId: string,
85
- path: string,
86
- startedAt: string,
87
- ): void {
88
- writeEmptyMessagesFile(
89
- path,
90
- startedAt,
91
- resolveMessagesFileContext(sessionId),
44
+ constructor(
45
+ private readonly adapter: SessionPersistenceAdapter,
46
+ options: {
47
+ messagesArtifactUploader?: SessionMessagesArtifactUploader;
48
+ } = {},
49
+ ) {
50
+ this.manifestStore = new SessionManifestStore(
51
+ adapter,
52
+ options.messagesArtifactUploader,
53
+ );
54
+ this.subagents = new SubagentSessionManager(
55
+ adapter,
56
+ this.manifestStore,
57
+ (messages, result, previousMessages) =>
58
+ this.toPersistedMessages(messages, result, previousMessages),
59
+ UnifiedSessionPersistenceService.TEAM_HEARTBEAT_LOG_INTERVAL_MS,
92
60
  );
93
61
  }
94
62
 
@@ -109,100 +77,45 @@ export class UnifiedSessionPersistenceService {
109
77
  );
110
78
  }
111
79
 
112
- // ── Manifest I/O ──────────────────────────────────────────────────
80
+ ensureSessionsDir(): string {
81
+ return this.manifestStore.ensureSessionsDir();
82
+ }
113
83
 
114
- private writeManifestFile(
84
+ writeSessionManifest(
115
85
  manifestPath: string,
116
- manifest: SessionManifest,
86
+ manifest: import("./session-manifest").SessionManifest,
117
87
  ): void {
118
- writeFileSync(
119
- manifestPath,
120
- `${JSON.stringify(SessionManifestSchema.parse(manifest), null, 2)}\n`,
121
- "utf8",
122
- );
123
- }
124
-
125
- writeSessionManifest(manifestPath: string, manifest: SessionManifest): void {
126
- this.writeManifestFile(manifestPath, manifest);
127
- }
128
-
129
- readSessionManifest(sessionId: string): SessionManifest | undefined {
130
- return this.readManifestFile(sessionId).manifest;
131
- }
132
-
133
- private readManifestFile(sessionId: string): {
134
- path: string;
135
- manifest?: SessionManifest;
136
- } {
137
- const manifestPath = this.artifacts.sessionManifestPath(sessionId, false);
138
- if (!existsSync(manifestPath)) return { path: manifestPath };
139
- try {
140
- return {
141
- path: manifestPath,
142
- manifest: SessionManifestSchema.parse(
143
- JSON.parse(readFileSync(manifestPath, "utf8")) as SessionManifest,
144
- ),
145
- };
146
- } catch {
147
- return { path: manifestPath };
148
- }
88
+ this.manifestStore.writeSessionManifest(manifestPath, manifest);
149
89
  }
150
90
 
151
- // ── Path resolution ───────────────────────────────────────────────
152
-
153
- private async resolveArtifactPath(
91
+ readSessionManifest(
154
92
  sessionId: string,
155
- kind: "transcriptPath" | "hookPath" | "messagesPath",
156
- fallback: (id: string) => string,
157
- ): Promise<string> {
158
- const row = await this.adapter.getSession(sessionId);
159
- const value = row?.[kind];
160
- return typeof value === "string" && value.trim().length > 0
161
- ? value
162
- : fallback(sessionId);
163
- }
164
-
165
- // ── Team task queue ───────────────────────────────────────────────
166
-
167
- private teamTaskQueueKey(rootSessionId: string, agentId: string): string {
168
- return `${rootSessionId}::${agentId}`;
169
- }
170
-
171
- private activeTeamTaskSessionId(
172
- rootSessionId: string,
173
- parentAgentId: string,
174
- ): string | undefined {
175
- const queue = this.teamTaskSessionsByAgent.get(
176
- this.teamTaskQueueKey(rootSessionId, parentAgentId),
177
- );
178
- return queue?.at(-1);
93
+ ): import("./session-manifest").SessionManifest | undefined {
94
+ return this.manifestStore.readSessionManifest(sessionId);
179
95
  }
180
96
 
181
- // ── Root session ──────────────────────────────────────────────────
182
-
183
97
  async createRootSessionWithArtifacts(
184
- input: CreateRootSessionWithArtifactsInput,
185
- ): Promise<RootSessionArtifacts> {
98
+ input: import("./session-row").CreateRootSessionWithArtifactsInput,
99
+ ): Promise<import("./session-row").RootSessionArtifacts> {
186
100
  const startedAt = input.startedAt ?? nowIso();
187
101
  const providedId = input.sessionId.trim();
188
102
  const sessionId =
189
103
  providedId.length > 0 ? providedId : `${Date.now()}_${nanoid(5)}`;
190
- const transcriptPath = this.artifacts.sessionTranscriptPath(sessionId);
191
- const hookPath = this.artifacts.sessionHookPath(sessionId);
192
- const messagesPath = this.artifacts.sessionMessagesPath(sessionId);
193
- const manifestPath = this.artifacts.sessionManifestPath(sessionId);
194
-
104
+ const messagesPath =
105
+ this.manifestStore.artifacts.sessionMessagesPath(sessionId);
106
+ const manifestPath =
107
+ this.manifestStore.artifacts.sessionManifestPath(sessionId);
195
108
  const metadata = resolveMetadataWithTitle({
196
109
  metadata: input.metadata,
197
110
  prompt: input.prompt,
198
111
  });
199
- const manifest = SessionManifestSchema.parse({
200
- version: 1,
112
+ const manifest = {
113
+ version: 1 as const,
201
114
  session_id: sessionId,
202
115
  source: input.source,
203
116
  pid: input.pid,
204
117
  started_at: startedAt,
205
- status: "running",
118
+ status: "running" as const,
206
119
  interactive: input.interactive,
207
120
  provider: input.provider,
208
121
  model: input.model,
@@ -215,7 +128,7 @@ export class UnifiedSessionPersistenceService {
215
128
  prompt: input.prompt?.trim() || undefined,
216
129
  metadata,
217
130
  messages_path: messagesPath,
218
- });
131
+ };
219
132
 
220
133
  await this.adapter.upsertSession({
221
134
  sessionId,
@@ -242,19 +155,20 @@ export class UnifiedSessionPersistenceService {
242
155
  isSubagent: false,
243
156
  prompt: manifest.prompt ?? null,
244
157
  metadata: sanitizeMetadata(manifest.metadata),
245
- transcriptPath,
246
- hookPath,
158
+ hookPath: "",
247
159
  messagesPath,
248
160
  updatedAt: nowIso(),
249
161
  });
250
162
 
251
- this.initializeMessagesFile(sessionId, messagesPath, startedAt);
252
- this.writeManifestFile(manifestPath, manifest);
253
- return { manifestPath, transcriptPath, hookPath, messagesPath, manifest };
163
+ this.manifestStore.initializeMessagesFile(
164
+ sessionId,
165
+ messagesPath,
166
+ startedAt,
167
+ );
168
+ this.manifestStore.writeSessionManifest(manifestPath, manifest);
169
+ return { manifestPath, messagesPath, manifest };
254
170
  }
255
171
 
256
- // ── Session status updates ────────────────────────────────────────
257
-
258
172
  async updateSessionStatus(
259
173
  sessionId: string,
260
174
  status: SessionStatus,
@@ -263,21 +177,24 @@ export class UnifiedSessionPersistenceService {
263
177
  let endedAt: string | undefined;
264
178
  const result = await withOccRetry(
265
179
  () => this.adapter.getSession(sessionId),
266
- async (statusLock) => {
180
+ async (row) => {
267
181
  endedAt = nowIso();
268
182
  return this.adapter.updateSession({
269
183
  sessionId,
270
184
  status,
271
185
  endedAt,
272
186
  exitCode: typeof exitCode === "number" ? exitCode : null,
273
- expectedStatusLock: statusLock,
187
+ expectedStatusLock: row.statusLock,
274
188
  });
275
189
  },
276
190
  OCC_MAX_RETRIES,
277
191
  );
278
192
  if (result.updated) {
279
193
  if (status === "cancelled") {
280
- await this.applyStatusToRunningChildSessions(sessionId, "cancelled");
194
+ await this.subagents.applyStatusToRunningChildSessions(
195
+ sessionId,
196
+ "cancelled",
197
+ );
281
198
  }
282
199
  return { updated: true, endedAt };
283
200
  }
@@ -336,9 +253,8 @@ export class UnifiedSessionPersistenceService {
336
253
  });
337
254
  if (!changed.updated) continue;
338
255
 
339
- const { path: manifestPath, manifest } = this.readManifestFile(
340
- input.sessionId,
341
- );
256
+ const { path: manifestPath, manifest } =
257
+ this.manifestStore.readManifestFile(input.sessionId);
342
258
  if (manifest) {
343
259
  if (input.prompt !== undefined) {
344
260
  manifest.prompt = input.prompt ?? undefined;
@@ -350,303 +266,85 @@ export class UnifiedSessionPersistenceService {
350
266
  if (nextTitle) manifestMeta.title = nextTitle;
351
267
  manifest.metadata =
352
268
  Object.keys(manifestMeta).length > 0 ? manifestMeta : undefined;
353
- this.writeManifestFile(manifestPath, manifest);
269
+ this.manifestStore.writeSessionManifest(manifestPath, manifest);
354
270
  }
355
271
  return { updated: true };
356
272
  }
357
273
  return { updated: false };
358
274
  }
359
275
 
360
- // ── Spawn queue ───────────────────────────────────────────────────
361
-
362
- async queueSpawnRequest(event: HookEventPayload): Promise<void> {
363
- if (event.hookName !== "tool_call" || event.parent_agent_id !== null)
364
- return;
365
- if (event.tool_call?.name !== "spawn_agent") return;
366
-
367
- const rootSessionId = resolveRootSessionId(event.sessionContext);
368
- if (!rootSessionId) return;
369
-
370
- const parsed = SpawnAgentInputSchema.safeParse(event.tool_call.input);
371
- await this.adapter.enqueueSpawnRequest({
372
- rootSessionId,
373
- parentAgentId: event.agent_id,
374
- task: parsed.success ? parsed.data.task : undefined,
375
- systemPrompt: parsed.success ? parsed.data.systemPrompt : undefined,
376
- });
377
- }
378
-
379
- // ── Subagent sessions ─────────────────────────────────────────────
380
-
381
- private buildSubsessionRow(
382
- root: SessionRow,
383
- opts: {
384
- sessionId: string;
385
- parentSessionId: string;
386
- parentAgentId: string;
387
- agentId: string;
388
- conversationId?: string | null;
389
- prompt: string;
390
- startedAt: string;
391
- transcriptPath: string;
392
- hookPath: string;
393
- messagesPath: string;
394
- },
395
- ): SessionRow {
396
- return {
397
- sessionId: opts.sessionId,
398
- source: SUBSESSION_SOURCE,
399
- pid: process.ppid,
400
- startedAt: opts.startedAt,
401
- endedAt: null,
402
- exitCode: null,
403
- status: "running",
404
- statusLock: 0,
405
- interactive: false,
406
- provider: root.provider,
407
- model: root.model,
408
- cwd: root.cwd,
409
- workspaceRoot: root.workspaceRoot,
410
- teamName: root.teamName ?? null,
411
- enableTools: root.enableTools,
412
- enableSpawn: root.enableSpawn,
413
- enableTeams: root.enableTeams,
414
- parentSessionId: opts.parentSessionId,
415
- parentAgentId: opts.parentAgentId,
416
- agentId: opts.agentId,
417
- conversationId: opts.conversationId ?? null,
418
- isSubagent: true,
419
- prompt: opts.prompt,
420
- metadata: resolveMetadataWithTitle({ prompt: opts.prompt }),
421
- transcriptPath: opts.transcriptPath,
422
- hookPath: opts.hookPath,
423
- messagesPath: opts.messagesPath,
424
- updatedAt: opts.startedAt,
425
- };
276
+ queueSpawnRequest(event: HookEventPayload): Promise<void> {
277
+ return this.subagents.queueSpawnRequest(event);
426
278
  }
427
279
 
428
- async upsertSubagentSession(
429
- input: UpsertSubagentInput,
280
+ upsertSubagentSession(
281
+ input: import("./session-row").UpsertSubagentInput,
430
282
  ): Promise<string | undefined> {
431
- const rootSessionId = input.rootSessionId;
432
- if (!rootSessionId) return undefined;
433
-
434
- const root = await this.adapter.getSession(rootSessionId);
435
- if (!root) return undefined;
436
-
437
- const sessionId = makeSubSessionId(rootSessionId, input.agentId);
438
- const existing = await this.adapter.getSession(sessionId);
439
- const startedAt = nowIso();
440
- const artifactPaths = this.artifacts.subagentArtifactPaths(
441
- sessionId,
442
- input.agentId,
443
- this.activeTeamTaskSessionId(rootSessionId, input.parentAgentId),
444
- );
445
-
446
- let prompt = input.prompt ?? existing?.prompt ?? undefined;
447
- if (!prompt) {
448
- prompt =
449
- (await this.adapter.claimSpawnRequest(
450
- rootSessionId,
451
- input.parentAgentId,
452
- )) ?? `Subagent run by ${input.parentAgentId}`;
453
- }
454
-
455
- if (!existing) {
456
- await this.adapter.upsertSession(
457
- this.buildSubsessionRow(root, {
458
- sessionId,
459
- parentSessionId: rootSessionId,
460
- parentAgentId: input.parentAgentId,
461
- agentId: input.agentId,
462
- conversationId: input.conversationId,
463
- prompt,
464
- startedAt,
465
- ...artifactPaths,
466
- }),
467
- );
468
- this.initializeMessagesFile(
469
- sessionId,
470
- artifactPaths.messagesPath,
471
- startedAt,
472
- );
473
- return sessionId;
474
- }
475
-
476
- await this.adapter.updateSession({
477
- sessionId,
478
- setRunning: true,
479
- parentSessionId: rootSessionId,
480
- parentAgentId: input.parentAgentId,
481
- agentId: input.agentId,
482
- conversationId: input.conversationId,
483
- prompt: existing.prompt ?? prompt ?? null,
484
- metadata: resolveMetadataWithTitle({
485
- metadata: existing.metadata ?? undefined,
486
- prompt: existing.prompt ?? prompt ?? null,
487
- }),
488
- expectedStatusLock: existing.statusLock,
489
- });
490
- return sessionId;
283
+ return this.subagents.upsertSubagentSession(input);
491
284
  }
492
285
 
493
- async upsertSubagentSessionFromHook(
286
+ upsertSubagentSessionFromHook(
494
287
  event: HookEventPayload,
495
288
  ): Promise<string | undefined> {
496
- if (!event.parent_agent_id) return undefined;
497
-
498
- const rootSessionId = resolveRootSessionId(event.sessionContext);
499
- if (!rootSessionId) return undefined;
500
-
501
- if (event.hookName === "session_shutdown") {
502
- const sessionId = makeSubSessionId(rootSessionId, event.agent_id);
503
- const existing = await this.adapter.getSession(sessionId);
504
- return existing ? sessionId : undefined;
505
- }
506
- return await this.upsertSubagentSession({
507
- agentId: event.agent_id,
508
- parentAgentId: event.parent_agent_id,
509
- conversationId: event.taskId,
510
- rootSessionId,
511
- });
289
+ return this.subagents.upsertSubagentSessionFromHook(event);
512
290
  }
513
291
 
514
- // ── Subagent audit / transcript ───────────────────────────────────
515
-
516
- async appendSubagentHookAudit(
517
- subSessionId: string,
292
+ appendSubagentHookAudit(
293
+ _subSessionId: string,
518
294
  event: HookEventPayload,
519
295
  ): Promise<void> {
520
- const path = await this.resolveArtifactPath(
521
- subSessionId,
522
- "hookPath",
523
- (id) => this.artifacts.sessionHookPath(id),
524
- );
525
- appendFileSync(
526
- path,
527
- `${JSON.stringify({ ts: nowIso(), ...event })}\n`,
528
- "utf8",
529
- );
530
- }
531
-
532
- async appendSubagentTranscriptLine(
533
- subSessionId: string,
534
- line: string,
535
- ): Promise<void> {
536
- if (!line.trim()) return;
537
- const path = await this.resolveArtifactPath(
538
- subSessionId,
539
- "transcriptPath",
540
- (id) => this.artifacts.sessionTranscriptPath(id),
541
- );
542
- appendFileSync(path, `${line}\n`, "utf8");
296
+ this.subagents.appendSubagentHookAudit(event);
297
+ return Promise.resolve();
543
298
  }
544
299
 
545
- async persistSessionMessages(
300
+ persistSessionMessages(
546
301
  sessionId: string,
547
302
  messages: LlmsProviders.Message[],
548
303
  systemPrompt?: string,
549
304
  ): Promise<void> {
550
- const path = await this.resolveArtifactPath(
551
- sessionId,
552
- "messagesPath",
553
- (id) => this.artifacts.sessionMessagesPath(id),
554
- );
555
305
  const normalizedMessages = normalizeStoredMessagesForPersistence(
556
306
  messages as LlmsProviders.MessageWithMetadata[],
557
307
  );
558
- const payload = buildMessagesFilePayload({
559
- updatedAt: nowIso(),
560
- context: resolveMessagesFileContext(sessionId),
561
- messages: normalizedMessages,
308
+ return this.manifestStore.persistSessionMessages(
309
+ sessionId,
310
+ normalizedMessages,
562
311
  systemPrompt,
563
- });
564
- writeFileSync(path, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
312
+ );
565
313
  }
566
314
 
567
- // ── Subagent status ───────────────────────────────────────────────
568
-
569
- async applySubagentStatus(
315
+ applySubagentStatus(
570
316
  subSessionId: string,
571
317
  event: HookEventPayload,
572
318
  ): Promise<void> {
573
- await this.applySubagentStatusBySessionId(
574
- subSessionId,
575
- deriveSubsessionStatus(event),
576
- );
319
+ return this.subagents.applySubagentStatus(subSessionId, event);
577
320
  }
578
321
 
579
- async applySubagentStatusBySessionId(
322
+ applySubagentStatusBySessionId(
580
323
  subSessionId: string,
581
324
  status: SessionStatus,
582
325
  ): Promise<void> {
583
- const row = await this.adapter.getSession(subSessionId);
584
- if (!row) return;
585
-
586
- const endedAt = status === "running" ? null : nowIso();
587
- const exitCode = status === "running" ? null : status === "failed" ? 1 : 0;
588
- await this.adapter.updateSession({
589
- sessionId: subSessionId,
590
- status,
591
- endedAt,
592
- exitCode,
593
- expectedStatusLock: row.statusLock,
594
- });
326
+ return this.subagents.applySubagentStatusBySessionId(subSessionId, status);
595
327
  }
596
328
 
597
- async applyStatusToRunningChildSessions(
329
+ applyStatusToRunningChildSessions(
598
330
  parentSessionId: string,
599
331
  status: Exclude<SessionStatus, "running">,
600
332
  ): Promise<void> {
601
- if (!parentSessionId) return;
602
- const rows = await this.adapter.listSessions({
603
- limit: 2000,
333
+ return this.subagents.applyStatusToRunningChildSessions(
604
334
  parentSessionId,
605
- status: "running",
606
- });
607
- for (const row of rows) {
608
- await this.applySubagentStatusBySessionId(row.sessionId, status);
609
- }
335
+ status,
336
+ );
610
337
  }
611
338
 
612
- // ── Team tasks ────────────────────────────────────────────────────
613
-
614
- async onTeamTaskStart(
339
+ onTeamTaskStart(
615
340
  rootSessionId: string,
616
341
  agentId: string,
617
342
  message: string,
618
343
  ): Promise<void> {
619
- const root = await this.adapter.getSession(rootSessionId);
620
- if (!root) return;
621
-
622
- const sessionId = makeTeamTaskSubSessionId(rootSessionId, agentId);
623
- const startedAt = nowIso();
624
- const { transcriptPath, hookPath, messagesPath } =
625
- this.artifacts.subagentArtifactPaths(sessionId, agentId);
626
-
627
- await this.adapter.upsertSession(
628
- this.buildSubsessionRow(root, {
629
- sessionId,
630
- parentSessionId: rootSessionId,
631
- parentAgentId: "lead",
632
- agentId,
633
- prompt: message || `Team task for ${agentId}`,
634
- startedAt,
635
- transcriptPath,
636
- hookPath,
637
- messagesPath,
638
- }),
639
- );
640
- this.initializeMessagesFile(sessionId, messagesPath, startedAt);
641
- await this.appendSubagentTranscriptLine(sessionId, `[start] ${message}`);
642
-
643
- const key = this.teamTaskQueueKey(rootSessionId, agentId);
644
- const queue = this.teamTaskSessionsByAgent.get(key) ?? [];
645
- queue.push(sessionId);
646
- this.teamTaskSessionsByAgent.set(key, queue);
344
+ return this.subagents.onTeamTaskStart(rootSessionId, agentId, message);
647
345
  }
648
346
 
649
- async onTeamTaskEnd(
347
+ onTeamTaskEnd(
650
348
  rootSessionId: string,
651
349
  agentId: string,
652
350
  status: SessionStatus,
@@ -654,121 +352,44 @@ export class UnifiedSessionPersistenceService {
654
352
  result?: AgentResult,
655
353
  messages?: LlmsProviders.Message[],
656
354
  ): Promise<void> {
657
- const key = this.teamTaskQueueKey(rootSessionId, agentId);
658
- const queue = this.teamTaskSessionsByAgent.get(key);
659
- if (!queue || queue.length === 0) return;
660
-
661
- const sessionId = queue.shift();
662
- if (queue.length === 0) this.teamTaskSessionsByAgent.delete(key);
663
- if (!sessionId) return;
664
-
665
- const teammateMessages = result?.messages ?? messages;
666
- const persistedMessages = this.toPersistedMessages(
667
- teammateMessages,
355
+ return this.subagents.onTeamTaskEnd(
356
+ rootSessionId,
357
+ agentId,
358
+ status,
359
+ summary,
668
360
  result,
669
361
  messages,
670
362
  );
671
- if (persistedMessages) {
672
- await this.persistSessionMessages(sessionId, persistedMessages);
673
- }
674
- await this.appendSubagentTranscriptLine(
675
- sessionId,
676
- summary ?? `[done] ${status}`,
677
- );
678
- await this.applySubagentStatusBySessionId(sessionId, status);
679
- this.teamTaskLastHeartbeatBySession.delete(sessionId);
680
- this.teamTaskLastProgressLineBySession.delete(sessionId);
681
363
  }
682
364
 
683
- async onTeamTaskProgress(
365
+ onTeamTaskProgress(
684
366
  rootSessionId: string,
685
367
  agentId: string,
686
368
  progress: string,
687
369
  options?: { kind?: "heartbeat" | "progress" | "text" },
688
370
  ): Promise<void> {
689
- const key = this.teamTaskQueueKey(rootSessionId, agentId);
690
- const sessionId = this.teamTaskSessionsByAgent.get(key)?.[0];
691
- if (!sessionId) return;
692
-
693
- const trimmed = progress.trim();
694
- if (!trimmed) return;
695
-
696
- const kind = options?.kind ?? "progress";
697
- if (kind === "heartbeat") {
698
- const now = Date.now();
699
- const last = this.teamTaskLastHeartbeatBySession.get(sessionId) ?? 0;
700
- if (
701
- now - last <
702
- UnifiedSessionPersistenceService.TEAM_HEARTBEAT_LOG_INTERVAL_MS
703
- ) {
704
- return;
705
- }
706
- this.teamTaskLastHeartbeatBySession.set(sessionId, now);
707
- }
708
-
709
- const line =
710
- kind === "heartbeat"
711
- ? "[progress] heartbeat"
712
- : kind === "text"
713
- ? `[progress] text: ${trimmed}`
714
- : `[progress] ${trimmed}`;
715
- if (this.teamTaskLastProgressLineBySession.get(sessionId) === line) return;
716
- this.teamTaskLastProgressLineBySession.set(sessionId, line);
717
- await this.appendSubagentTranscriptLine(sessionId, line);
371
+ return this.subagents.onTeamTaskProgress(
372
+ rootSessionId,
373
+ agentId,
374
+ progress,
375
+ options,
376
+ );
718
377
  }
719
378
 
720
- // ── SubAgent lifecycle ────────────────────────────────────────────
721
-
722
- async handleSubAgentStart(
379
+ handleSubAgentStart(
723
380
  rootSessionId: string,
724
381
  context: SubAgentStartContext,
725
382
  ): Promise<void> {
726
- const subSessionId = await this.upsertSubagentSession({
727
- agentId: context.subAgentId,
728
- parentAgentId: context.parentAgentId,
729
- conversationId: context.conversationId,
730
- prompt: context.input.task,
731
- rootSessionId,
732
- });
733
- if (!subSessionId) return;
734
- await this.appendSubagentTranscriptLine(
735
- subSessionId,
736
- `[start] ${context.input.task}`,
737
- );
738
- await this.applySubagentStatusBySessionId(subSessionId, "running");
383
+ return this.subagents.handleSubAgentStart(rootSessionId, context);
739
384
  }
740
385
 
741
- async handleSubAgentEnd(
386
+ handleSubAgentEnd(
742
387
  rootSessionId: string,
743
388
  context: SubAgentEndContext,
744
389
  ): Promise<void> {
745
- const subSessionId = await this.upsertSubagentSession({
746
- agentId: context.subAgentId,
747
- parentAgentId: context.parentAgentId,
748
- conversationId: context.conversationId,
749
- prompt: context.input.task,
750
- rootSessionId,
751
- });
752
- if (!subSessionId) return;
753
-
754
- if (context.error) {
755
- await this.appendSubagentTranscriptLine(
756
- subSessionId,
757
- `[error] ${context.error.message}`,
758
- );
759
- await this.applySubagentStatusBySessionId(subSessionId, "failed");
760
- return;
761
- }
762
- const reason = context.result?.finishReason ?? "completed";
763
- await this.appendSubagentTranscriptLine(subSessionId, `[done] ${reason}`);
764
- await this.applySubagentStatusBySessionId(
765
- subSessionId,
766
- reason === "aborted" ? "cancelled" : "completed",
767
- );
390
+ return this.subagents.handleSubAgentEnd(rootSessionId, context);
768
391
  }
769
392
 
770
- // ── Stale session reconciliation ──────────────────────────────────
771
-
772
393
  private isPidAlive(pid: number): boolean {
773
394
  if (!Number.isFinite(pid) || pid <= 0) return false;
774
395
  try {
@@ -815,7 +436,10 @@ export class UnifiedSessionPersistenceService {
815
436
  });
816
437
  if (!changed.updated) continue;
817
438
 
818
- await this.applyStatusToRunningChildSessions(latest.sessionId, "failed");
439
+ await this.subagents.applyStatusToRunningChildSessions(
440
+ latest.sessionId,
441
+ "failed",
442
+ );
819
443
 
820
444
  const manifest = buildManifestFromRow(latest, {
821
445
  status: "failed",
@@ -823,27 +447,17 @@ export class UnifiedSessionPersistenceService {
823
447
  exitCode: 1,
824
448
  metadata: nextMetadata,
825
449
  });
826
- const { path: manifestPath } = this.readManifestFile(latest.sessionId);
827
- this.writeManifestFile(manifestPath, manifest);
828
-
829
- appendFileSync(
830
- latest.hookPath,
831
- `${JSON.stringify({
832
- ts: detectedAt,
833
- hookName: "session_shutdown",
834
- reason,
835
- sessionId: latest.sessionId,
836
- pid: latest.pid,
837
- source: UnifiedSessionPersistenceService.STALE_SOURCE,
838
- })}\n`,
839
- "utf8",
450
+ const { path: manifestPath } = this.manifestStore.readManifestFile(
451
+ latest.sessionId,
840
452
  );
841
- appendFileSync(
842
- latest.transcriptPath,
843
- `[shutdown] ${reason} (pid=${latest.pid})\n`,
844
- "utf8",
453
+ this.manifestStore.writeSessionManifest(manifestPath, manifest);
454
+ this.manifestStore.appendStaleSessionHookLog(
455
+ detectedAt,
456
+ latest.sessionId,
457
+ latest.pid,
458
+ reason,
459
+ UnifiedSessionPersistenceService.STALE_SOURCE,
845
460
  );
846
-
847
461
  return {
848
462
  ...latest,
849
463
  status: "failed",
@@ -857,8 +471,6 @@ export class UnifiedSessionPersistenceService {
857
471
  return await this.adapter.getSession(row.sessionId);
858
472
  }
859
473
 
860
- // ── List / reconcile / delete ─────────────────────────────────────
861
-
862
474
  async listSessions(limit = 200): Promise<SessionRow[]> {
863
475
  const requestedLimit = Math.max(1, Math.floor(limit));
864
476
  const scanLimit = Math.min(requestedLimit * 5, 2000);
@@ -867,7 +479,7 @@ export class UnifiedSessionPersistenceService {
867
479
  const rows = await this.adapter.listSessions({ limit: scanLimit });
868
480
  return rows.slice(0, requestedLimit).map((row) => {
869
481
  const meta = sanitizeMetadata(row.metadata ?? undefined);
870
- const { manifest } = this.readManifestFile(row.sessionId);
482
+ const manifest = this.manifestStore.readSessionManifest(row.sessionId);
871
483
  const manifestTitle = normalizeTitle(
872
484
  typeof manifest?.metadata?.title === "string"
873
485
  ? (manifest.metadata.title as string)
@@ -908,34 +520,38 @@ export class UnifiedSessionPersistenceService {
908
520
  parentSessionId: id,
909
521
  });
910
522
  await this.adapter.deleteSession(id, true);
911
- for (const child of children) {
912
- unlinkIfExists(child.transcriptPath);
913
- unlinkIfExists(child.hookPath);
914
- unlinkIfExists(child.messagesPath);
915
- unlinkIfExists(
916
- this.artifacts.sessionManifestPath(child.sessionId, false),
917
- );
918
- this.artifacts.removeSessionDirIfEmpty(child.sessionId);
919
- }
523
+ await Promise.allSettled(
524
+ children.map(async (child) => {
525
+ await deleteCheckpointRefs(child.cwd, child.sessionId);
526
+ unlinkIfExists(child.messagesPath);
527
+ unlinkIfExists(
528
+ this.manifestStore.artifacts.sessionManifestPath(
529
+ child.sessionId,
530
+ false,
531
+ ),
532
+ );
533
+ this.manifestStore.artifacts.removeSessionDirIfEmpty(child.sessionId);
534
+ }),
535
+ );
920
536
  }
921
537
 
922
- unlinkIfExists(row.transcriptPath);
923
- unlinkIfExists(row.hookPath);
538
+ await deleteCheckpointRefs(row.cwd, id);
539
+
924
540
  unlinkIfExists(row.messagesPath);
925
- unlinkIfExists(this.artifacts.sessionManifestPath(id, false));
541
+ unlinkIfExists(this.manifestStore.artifacts.sessionManifestPath(id, false));
926
542
  if (row.isSubagent) {
927
- this.artifacts.removeSessionDirIfEmpty(id);
543
+ this.manifestStore.artifacts.removeSessionDirIfEmpty(id);
928
544
  } else {
929
545
  const candidateDirs = new Set<string>([
930
- this.artifacts.sessionArtifactsDir(id),
546
+ this.manifestStore.artifacts.sessionArtifactsDir(id),
931
547
  ]);
932
- for (const path of [row.transcriptPath, row.hookPath, row.messagesPath]) {
548
+ for (const path of [row.messagesPath]) {
933
549
  if (typeof path === "string" && path.trim().length > 0) {
934
550
  candidateDirs.add(dirname(path));
935
551
  }
936
552
  }
937
553
  for (const dir of candidateDirs) {
938
- this.artifacts.removeDir(dir);
554
+ this.manifestStore.artifacts.removeDir(dir);
939
555
  }
940
556
  }
941
557
  return { deleted: true };