@clinebot/core 0.0.35 → 0.0.37

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 (441) hide show
  1. package/README.md +1 -2
  2. package/dist/ClineCore.d.ts +362 -39
  3. package/dist/ClineCore.d.ts.map +1 -1
  4. package/dist/account/cline-account-service.d.ts.map +1 -1
  5. package/dist/account/index.d.ts +1 -1
  6. package/dist/account/index.d.ts.map +1 -1
  7. package/dist/account/rpc.d.ts +6 -6
  8. package/dist/account/rpc.d.ts.map +1 -1
  9. package/dist/cron/cron-event-ingress.d.ts +38 -0
  10. package/dist/cron/cron-event-ingress.d.ts.map +1 -0
  11. package/dist/cron/cron-materializer.d.ts +36 -0
  12. package/dist/cron/cron-materializer.d.ts.map +1 -0
  13. package/dist/cron/cron-reconciler.d.ts +62 -0
  14. package/dist/cron/cron-reconciler.d.ts.map +1 -0
  15. package/dist/cron/cron-report-writer.d.ts +41 -0
  16. package/dist/cron/cron-report-writer.d.ts.map +1 -0
  17. package/dist/cron/cron-runner.d.ts +43 -0
  18. package/dist/cron/cron-runner.d.ts.map +1 -0
  19. package/dist/cron/cron-schema.d.ts +3 -0
  20. package/dist/cron/cron-schema.d.ts.map +1 -0
  21. package/dist/cron/cron-service.d.ts +57 -0
  22. package/dist/cron/cron-service.d.ts.map +1 -0
  23. package/dist/cron/cron-spec-parser.d.ts +27 -0
  24. package/dist/cron/cron-spec-parser.d.ts.map +1 -0
  25. package/dist/cron/cron-watcher.d.ts +23 -0
  26. package/dist/cron/cron-watcher.d.ts.map +1 -0
  27. package/dist/cron/resource-limiter.d.ts +9 -0
  28. package/dist/cron/resource-limiter.d.ts.map +1 -0
  29. package/dist/cron/schedule-command-service.d.ts +10 -0
  30. package/dist/cron/schedule-command-service.d.ts.map +1 -0
  31. package/dist/cron/schedule-service.d.ts +100 -0
  32. package/dist/cron/schedule-service.d.ts.map +1 -0
  33. package/dist/cron/scheduler.d.ts +68 -0
  34. package/dist/cron/scheduler.d.ts.map +1 -0
  35. package/dist/cron/sqlite-cron-store.d.ts +230 -0
  36. package/dist/cron/sqlite-cron-store.d.ts.map +1 -0
  37. package/dist/cron/sqlite-schedule-store.d.ts +52 -0
  38. package/dist/cron/sqlite-schedule-store.d.ts.map +1 -0
  39. package/dist/extensions/config/agent-config-loader.d.ts +4 -3
  40. package/dist/extensions/config/agent-config-loader.d.ts.map +1 -1
  41. package/dist/extensions/config/runtime-commands.d.ts +1 -0
  42. package/dist/extensions/config/runtime-commands.d.ts.map +1 -1
  43. package/dist/extensions/config/user-instruction-config-loader.d.ts +1 -0
  44. package/dist/extensions/config/user-instruction-config-loader.d.ts.map +1 -1
  45. package/dist/extensions/context/agentic-compaction.d.ts +2 -2
  46. package/dist/extensions/context/agentic-compaction.d.ts.map +1 -1
  47. package/dist/extensions/context/compaction-shared.d.ts +5 -4
  48. package/dist/extensions/context/compaction-shared.d.ts.map +1 -1
  49. package/dist/extensions/context/compaction.d.ts.map +1 -1
  50. package/dist/extensions/plugin/plugin-config-loader.d.ts +15 -2
  51. package/dist/extensions/plugin/plugin-config-loader.d.ts.map +1 -1
  52. package/dist/extensions/plugin/plugin-loader.d.ts +13 -7
  53. package/dist/extensions/plugin/plugin-loader.d.ts.map +1 -1
  54. package/dist/extensions/plugin/plugin-module-import.d.ts.map +1 -1
  55. package/dist/extensions/plugin/plugin-sandbox.d.ts +21 -2
  56. package/dist/extensions/plugin/plugin-sandbox.d.ts.map +1 -1
  57. package/dist/extensions/plugin/plugin-targeting.d.ts +7 -0
  58. package/dist/extensions/plugin/plugin-targeting.d.ts.map +1 -0
  59. package/dist/extensions/plugin-sandbox-bootstrap.js +237 -276
  60. package/dist/extensions/tools/constants.d.ts +1 -0
  61. package/dist/extensions/tools/constants.d.ts.map +1 -1
  62. package/dist/extensions/tools/definitions.d.ts +3 -4
  63. package/dist/extensions/tools/definitions.d.ts.map +1 -1
  64. package/dist/extensions/tools/executors/apply-patch.d.ts +3 -1
  65. package/dist/extensions/tools/executors/apply-patch.d.ts.map +1 -1
  66. package/dist/extensions/tools/executors/editor.d.ts.map +1 -1
  67. package/dist/extensions/tools/executors/search.d.ts +1 -1
  68. package/dist/extensions/tools/executors/search.d.ts.map +1 -1
  69. package/dist/extensions/tools/helpers.d.ts +1 -0
  70. package/dist/extensions/tools/helpers.d.ts.map +1 -1
  71. package/dist/extensions/tools/index.d.ts +3 -2
  72. package/dist/extensions/tools/index.d.ts.map +1 -1
  73. package/dist/extensions/tools/presets.d.ts +27 -44
  74. package/dist/extensions/tools/presets.d.ts.map +1 -1
  75. package/dist/extensions/tools/runtime.d.ts +25 -0
  76. package/dist/extensions/tools/runtime.d.ts.map +1 -0
  77. package/dist/extensions/tools/schemas.d.ts +25 -3
  78. package/dist/extensions/tools/schemas.d.ts.map +1 -1
  79. package/dist/extensions/tools/team/delegated-agent.d.ts +2 -2
  80. package/dist/extensions/tools/team/delegated-agent.d.ts.map +1 -1
  81. package/dist/extensions/tools/team/multi-agent.d.ts +7 -3
  82. package/dist/extensions/tools/team/multi-agent.d.ts.map +1 -1
  83. package/dist/extensions/tools/team/team-tools.d.ts +1 -0
  84. package/dist/extensions/tools/team/team-tools.d.ts.map +1 -1
  85. package/dist/extensions/tools/types.d.ts +0 -5
  86. package/dist/extensions/tools/types.d.ts.map +1 -1
  87. package/dist/hooks/hook-bridge.d.ts +118 -0
  88. package/dist/hooks/hook-bridge.d.ts.map +1 -0
  89. package/dist/hooks/hook-file-hooks.d.ts +6 -2
  90. package/dist/hooks/hook-file-hooks.d.ts.map +1 -1
  91. package/dist/hooks/hook-registry.d.ts +16 -0
  92. package/dist/hooks/hook-registry.d.ts.map +1 -0
  93. package/dist/hooks/index.d.ts +0 -1
  94. package/dist/hooks/index.d.ts.map +1 -1
  95. package/dist/hooks/subprocess.d.ts +8 -1
  96. package/dist/hooks/subprocess.d.ts.map +1 -1
  97. package/dist/hub/browser-websocket.d.ts +18 -0
  98. package/dist/hub/browser-websocket.d.ts.map +1 -0
  99. package/dist/hub/client.d.ts +51 -0
  100. package/dist/hub/client.d.ts.map +1 -0
  101. package/dist/hub/connect.d.ts +15 -0
  102. package/dist/hub/connect.d.ts.map +1 -0
  103. package/dist/hub/daemon-entry.d.ts +2 -0
  104. package/dist/hub/daemon-entry.d.ts.map +1 -0
  105. package/dist/hub/daemon-entry.js +1305 -0
  106. package/dist/hub/daemon.d.ts +5 -0
  107. package/dist/hub/daemon.d.ts.map +1 -0
  108. package/dist/hub/defaults.d.ts +17 -0
  109. package/dist/hub/defaults.d.ts.map +1 -0
  110. package/dist/hub/discovery.d.ts +29 -0
  111. package/dist/hub/discovery.d.ts.map +1 -0
  112. package/dist/hub/index.d.ts +15 -0
  113. package/dist/hub/index.d.ts.map +1 -0
  114. package/dist/hub/index.js +1294 -0
  115. package/dist/hub/native-transport.d.ts +17 -0
  116. package/dist/hub/native-transport.d.ts.map +1 -0
  117. package/dist/hub/runtime-handlers.d.ts +11 -0
  118. package/dist/hub/runtime-handlers.d.ts.map +1 -0
  119. package/dist/hub/server.d.ts +104 -0
  120. package/dist/hub/server.d.ts.map +1 -0
  121. package/dist/hub/session-client.d.ts +90 -0
  122. package/dist/hub/session-client.d.ts.map +1 -0
  123. package/dist/hub/start-shared-server.d.ts +19 -0
  124. package/dist/hub/start-shared-server.d.ts.map +1 -0
  125. package/dist/hub/transport.d.ts +8 -0
  126. package/dist/hub/transport.d.ts.map +1 -0
  127. package/dist/hub/ui-client.d.ts +45 -0
  128. package/dist/hub/ui-client.d.ts.map +1 -0
  129. package/dist/hub/workspace.d.ts +4 -0
  130. package/dist/hub/workspace.d.ts.map +1 -0
  131. package/dist/index.d.ts +29 -16
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.js +782 -471
  134. package/dist/llms/cline-recommended-models.d.ts +20 -0
  135. package/dist/llms/cline-recommended-models.d.ts.map +1 -0
  136. package/dist/llms/configured-provider-registry.d.ts +28 -0
  137. package/dist/llms/configured-provider-registry.d.ts.map +1 -0
  138. package/dist/llms/handler-factory.d.ts +16 -0
  139. package/dist/llms/handler-factory.d.ts.map +1 -0
  140. package/dist/llms/provider-defaults.d.ts +27 -0
  141. package/dist/llms/provider-defaults.d.ts.map +1 -0
  142. package/dist/llms/provider-settings.d.ts +245 -0
  143. package/dist/llms/provider-settings.d.ts.map +1 -0
  144. package/dist/llms/runtime-config.d.ts +4 -0
  145. package/dist/llms/runtime-config.d.ts.map +1 -0
  146. package/dist/llms/runtime-registry.d.ts +20 -0
  147. package/dist/llms/runtime-registry.d.ts.map +1 -0
  148. package/dist/llms/runtime-types.d.ts +85 -0
  149. package/dist/llms/runtime-types.d.ts.map +1 -0
  150. package/dist/runtime/agent-config-adapter.d.ts +148 -0
  151. package/dist/runtime/agent-config-adapter.d.ts.map +1 -0
  152. package/dist/runtime/agent-runtime-config-builder.d.ts +96 -0
  153. package/dist/runtime/agent-runtime-config-builder.d.ts.map +1 -0
  154. package/dist/runtime/history.d.ts +6 -0
  155. package/dist/runtime/history.d.ts.map +1 -1
  156. package/dist/runtime/host.d.ts +1 -2
  157. package/dist/runtime/host.d.ts.map +1 -1
  158. package/dist/runtime/loop-detection.d.ts +59 -0
  159. package/dist/runtime/loop-detection.d.ts.map +1 -0
  160. package/dist/runtime/mistake-tracker.d.ts +69 -0
  161. package/dist/runtime/mistake-tracker.d.ts.map +1 -0
  162. package/dist/runtime/rules.d.ts +1 -0
  163. package/dist/runtime/rules.d.ts.map +1 -1
  164. package/dist/runtime/runtime-builder.d.ts.map +1 -1
  165. package/dist/runtime/runtime-event-adapter.d.ts +102 -0
  166. package/dist/runtime/runtime-event-adapter.d.ts.map +1 -0
  167. package/dist/runtime/runtime-host.d.ts +49 -26
  168. package/dist/runtime/runtime-host.d.ts.map +1 -1
  169. package/dist/runtime/runtime-oauth-token-manager.d.ts.map +1 -1
  170. package/dist/runtime/session-runtime-orchestrator.d.ts +261 -0
  171. package/dist/runtime/session-runtime-orchestrator.d.ts.map +1 -0
  172. package/dist/runtime/session-runtime.d.ts +16 -21
  173. package/dist/runtime/session-runtime.d.ts.map +1 -1
  174. package/dist/runtime/user-input-builder.d.ts +24 -0
  175. package/dist/runtime/user-input-builder.d.ts.map +1 -0
  176. package/dist/services/global-settings.d.ts +12 -0
  177. package/dist/services/global-settings.d.ts.map +1 -0
  178. package/dist/services/index.js +28 -0
  179. package/dist/services/local-runtime-bootstrap.d.ts +9 -3
  180. package/dist/services/local-runtime-bootstrap.d.ts.map +1 -1
  181. package/dist/services/plugin-tools.d.ts +16 -0
  182. package/dist/services/plugin-tools.d.ts.map +1 -0
  183. package/dist/services/providers/local-provider-registry.d.ts +199 -23
  184. package/dist/services/providers/local-provider-registry.d.ts.map +1 -1
  185. package/dist/services/providers/local-provider-service.d.ts +15 -13
  186. package/dist/services/providers/local-provider-service.d.ts.map +1 -1
  187. package/dist/services/session-data.d.ts +1 -1
  188. package/dist/services/session-data.d.ts.map +1 -1
  189. package/dist/services/session-telemetry.d.ts +7 -2
  190. package/dist/services/session-telemetry.d.ts.map +1 -1
  191. package/dist/services/storage/file-team-store.d.ts.map +1 -1
  192. package/dist/services/storage/provider-settings-legacy-migration.d.ts +1 -1
  193. package/dist/services/storage/provider-settings-legacy-migration.d.ts.map +1 -1
  194. package/dist/services/storage/provider-settings-manager.d.ts +1 -0
  195. package/dist/services/storage/provider-settings-manager.d.ts.map +1 -1
  196. package/dist/services/storage/sqlite-team-store.d.ts.map +1 -1
  197. package/dist/services/workspace-manifest.d.ts +11 -0
  198. package/dist/services/workspace-manifest.d.ts.map +1 -1
  199. package/dist/session/conversation-store.d.ts +30 -0
  200. package/dist/session/conversation-store.d.ts.map +1 -0
  201. package/dist/session/message-builder.d.ts +65 -0
  202. package/dist/session/message-builder.d.ts.map +1 -0
  203. package/dist/session/persistence-service.d.ts +11 -23
  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-manifest.d.ts +1 -1
  208. package/dist/session/session-row.d.ts +93 -0
  209. package/dist/session/session-row.d.ts.map +1 -0
  210. package/dist/session/session-service.d.ts +2 -102
  211. package/dist/session/session-service.d.ts.map +1 -1
  212. package/dist/session/subagent-session-manager.d.ts +36 -0
  213. package/dist/session/subagent-session-manager.d.ts.map +1 -0
  214. package/dist/session/team-persistence-store.d.ts +24 -0
  215. package/dist/session/team-persistence-store.d.ts.map +1 -0
  216. package/dist/transports/hub.d.ts +58 -0
  217. package/dist/transports/hub.d.ts.map +1 -0
  218. package/dist/transports/local.d.ts +23 -9
  219. package/dist/transports/local.d.ts.map +1 -1
  220. package/dist/transports/remote.d.ts +10 -0
  221. package/dist/transports/remote.d.ts.map +1 -0
  222. package/dist/transports/runtime-host-support.d.ts +3 -2
  223. package/dist/transports/runtime-host-support.d.ts.map +1 -1
  224. package/dist/types/chat-schema.d.ts +15 -17
  225. package/dist/types/chat-schema.d.ts.map +1 -1
  226. package/dist/types/config.d.ts +17 -7
  227. package/dist/types/config.d.ts.map +1 -1
  228. package/dist/types/events.d.ts +7 -6
  229. package/dist/types/events.d.ts.map +1 -1
  230. package/dist/types/provider-settings.d.ts +4 -5
  231. package/dist/types/provider-settings.d.ts.map +1 -1
  232. package/dist/types/session.d.ts +7 -3
  233. package/dist/types/session.d.ts.map +1 -1
  234. package/dist/types.d.ts +11 -4
  235. package/dist/types.d.ts.map +1 -1
  236. package/package.json +20 -6
  237. package/src/ClineCore.ts +757 -44
  238. package/src/account/cline-account-service.ts +44 -6
  239. package/src/account/index.ts +3 -3
  240. package/src/account/rpc.ts +12 -12
  241. package/src/cron/cron-event-ingress.ts +357 -0
  242. package/src/cron/cron-materializer.ts +97 -0
  243. package/src/cron/cron-reconciler.ts +241 -0
  244. package/src/cron/cron-report-writer.ts +153 -0
  245. package/src/cron/cron-runner.ts +495 -0
  246. package/src/cron/cron-schema.ts +127 -0
  247. package/src/cron/cron-service.ts +163 -0
  248. package/src/cron/cron-spec-parser.ts +489 -0
  249. package/src/cron/cron-watcher.ts +102 -0
  250. package/src/cron/index.ts +15 -0
  251. package/src/cron/resource-limiter.ts +46 -0
  252. package/src/cron/schedule-command-service.ts +193 -0
  253. package/src/cron/schedule-service.ts +703 -0
  254. package/src/cron/scheduler.ts +772 -0
  255. package/src/cron/sqlite-cron-store.ts +1286 -0
  256. package/src/cron/sqlite-schedule-store.ts +708 -0
  257. package/src/extensions/config/agent-config-loader.ts +17 -7
  258. package/src/extensions/config/runtime-commands.ts +6 -0
  259. package/src/extensions/config/user-instruction-config-loader.ts +1 -0
  260. package/src/extensions/context/agentic-compaction.ts +3 -3
  261. package/src/extensions/context/basic-compaction.ts +2 -2
  262. package/src/extensions/context/compaction-shared.ts +5 -4
  263. package/src/extensions/context/compaction.ts +3 -3
  264. package/src/extensions/plugin/plugin-config-loader.ts +37 -2
  265. package/src/extensions/plugin/plugin-loader.ts +69 -9
  266. package/src/extensions/plugin/plugin-module-import.ts +0 -2
  267. package/src/extensions/plugin/plugin-sandbox-bootstrap.ts +243 -39
  268. package/src/extensions/plugin/plugin-sandbox.ts +173 -29
  269. package/src/extensions/plugin/plugin-targeting.ts +32 -0
  270. package/src/extensions/tools/constants.ts +2 -0
  271. package/src/extensions/tools/definitions.ts +61 -71
  272. package/src/extensions/tools/executors/apply-patch.ts +69 -80
  273. package/src/extensions/tools/executors/editor.ts +4 -3
  274. package/src/extensions/tools/executors/search.ts +195 -3
  275. package/src/extensions/tools/helpers.ts +24 -0
  276. package/src/extensions/tools/index.ts +11 -2
  277. package/src/extensions/tools/presets.ts +32 -47
  278. package/src/extensions/tools/runtime.ts +261 -0
  279. package/src/extensions/tools/schemas.ts +17 -20
  280. package/src/extensions/tools/team/delegated-agent.ts +8 -3
  281. package/src/extensions/tools/team/multi-agent.ts +135 -19
  282. package/src/extensions/tools/team/team-tools.ts +172 -91
  283. package/src/extensions/tools/types.ts +0 -6
  284. package/src/hooks/hook-bridge.ts +489 -0
  285. package/src/hooks/hook-file-hooks.ts +66 -5
  286. package/src/hooks/hook-registry.ts +257 -0
  287. package/src/hooks/index.ts +0 -7
  288. package/src/hooks/subprocess-runner.ts +1 -1
  289. package/src/hooks/subprocess.ts +9 -0
  290. package/src/hub/browser-websocket.ts +159 -0
  291. package/src/hub/client.ts +633 -0
  292. package/src/hub/connect.ts +156 -0
  293. package/src/hub/daemon-entry.ts +122 -0
  294. package/src/hub/daemon.ts +284 -0
  295. package/src/hub/defaults.ts +70 -0
  296. package/src/hub/discovery.ts +247 -0
  297. package/src/hub/index.ts +14 -0
  298. package/src/hub/native-transport.ts +31 -0
  299. package/src/hub/runtime-handlers.ts +141 -0
  300. package/src/hub/server.ts +2317 -0
  301. package/src/hub/session-client.ts +502 -0
  302. package/src/hub/start-shared-server.ts +61 -0
  303. package/src/hub/transport.ts +14 -0
  304. package/src/hub/ui-client.ts +126 -0
  305. package/src/hub/workspace.ts +19 -0
  306. package/src/index.ts +169 -68
  307. package/src/llms/cline-recommended-models.ts +167 -0
  308. package/src/llms/configured-provider-registry.ts +193 -0
  309. package/src/llms/handler-factory.ts +56 -0
  310. package/src/llms/provider-defaults.ts +653 -0
  311. package/src/llms/provider-settings.ts +310 -0
  312. package/src/llms/runtime-config.ts +43 -0
  313. package/src/llms/runtime-registry.ts +172 -0
  314. package/src/llms/runtime-types.ts +121 -0
  315. package/src/runtime/agent-config-adapter.ts +636 -0
  316. package/src/runtime/agent-runtime-config-builder.ts +205 -0
  317. package/src/runtime/error-feedback.ts +142 -0
  318. package/src/runtime/history.ts +137 -0
  319. package/src/runtime/host.ts +127 -267
  320. package/src/runtime/index.ts +1 -0
  321. package/src/runtime/loop-detection.ts +162 -0
  322. package/src/runtime/mistake-tracker.ts +221 -0
  323. package/src/runtime/rules.ts +12 -0
  324. package/src/runtime/runtime-builder.ts +85 -13
  325. package/src/runtime/runtime-event-adapter.ts +412 -0
  326. package/src/runtime/runtime-host.ts +134 -62
  327. package/src/runtime/runtime-oauth-token-manager.ts +11 -15
  328. package/src/runtime/session-runtime-orchestrator.ts +1253 -0
  329. package/src/runtime/session-runtime.ts +16 -26
  330. package/src/runtime/user-input-builder.ts +167 -0
  331. package/src/services/global-settings.ts +122 -0
  332. package/src/services/local-runtime-bootstrap.ts +175 -31
  333. package/src/services/plugin-tools.ts +86 -0
  334. package/src/services/providers/local-provider-registry.ts +277 -61
  335. package/src/services/providers/local-provider-service.ts +109 -44
  336. package/src/services/session-data.ts +18 -10
  337. package/src/services/session-telemetry.ts +6 -15
  338. package/src/services/storage/file-team-store.ts +1 -5
  339. package/src/services/storage/provider-settings-legacy-migration.ts +14 -51
  340. package/src/services/storage/provider-settings-manager.ts +17 -2
  341. package/src/services/storage/sqlite-team-store.ts +1 -5
  342. package/src/services/workspace-manifest.ts +18 -0
  343. package/src/session/conversation-store.ts +77 -0
  344. package/src/session/file-session-service.ts +1 -1
  345. package/src/session/index.ts +6 -27
  346. package/src/session/message-builder.ts +941 -0
  347. package/src/session/persistence-service.ts +119 -504
  348. package/src/session/session-manifest-store.ts +158 -0
  349. package/src/session/session-row.ts +199 -0
  350. package/src/session/session-service.ts +17 -376
  351. package/src/session/session-team-coordination.ts +1 -1
  352. package/src/session/subagent-session-manager.ts +397 -0
  353. package/src/session/team-persistence-store.ts +176 -0
  354. package/src/transports/hub.ts +1081 -0
  355. package/src/transports/local.ts +419 -93
  356. package/src/transports/remote.ts +27 -0
  357. package/src/transports/runtime-host-support.ts +63 -9
  358. package/src/types/chat-schema.ts +4 -5
  359. package/src/types/config.ts +17 -7
  360. package/src/types/events.ts +8 -6
  361. package/src/types/index.ts +3 -0
  362. package/src/types/provider-settings.ts +18 -7
  363. package/src/types/session.ts +7 -6
  364. package/src/types.ts +42 -2
  365. package/dist/hooks/persistent.d.ts +0 -64
  366. package/dist/hooks/persistent.d.ts.map +0 -1
  367. package/dist/runtime/rpc-runtime-ensure.d.ts +0 -65
  368. package/dist/runtime/rpc-runtime-ensure.d.ts.map +0 -1
  369. package/dist/runtime/rpc-spawn-lease.d.ts +0 -8
  370. package/dist/runtime/rpc-spawn-lease.d.ts.map +0 -1
  371. package/dist/services/telemetry/index.js +0 -15
  372. package/dist/session/rpc-session-service.d.ts +0 -16
  373. package/dist/session/rpc-session-service.d.ts.map +0 -1
  374. package/dist/session/sqlite-rpc-session-backend.d.ts +0 -31
  375. package/dist/session/sqlite-rpc-session-backend.d.ts.map +0 -1
  376. package/dist/transports/rpc.d.ts +0 -51
  377. package/dist/transports/rpc.d.ts.map +0 -1
  378. package/src/ClineCore.test.ts +0 -226
  379. package/src/account/cline-account-service.test.ts +0 -185
  380. package/src/account/featurebase-token.test.ts +0 -175
  381. package/src/account/rpc.test.ts +0 -63
  382. package/src/auth/bounded-ttl-cache.test.ts +0 -38
  383. package/src/auth/client.test.ts +0 -69
  384. package/src/auth/cline.test.ts +0 -267
  385. package/src/auth/codex.test.ts +0 -170
  386. package/src/auth/oca.test.ts +0 -340
  387. package/src/auth/server.test.ts +0 -287
  388. package/src/auth/utils.test.ts +0 -128
  389. package/src/extensions/config/agent-config-loader.test.ts +0 -236
  390. package/src/extensions/config/hooks-config-loader.test.ts +0 -20
  391. package/src/extensions/config/runtime-commands.test.ts +0 -115
  392. package/src/extensions/config/unified-config-file-watcher.test.ts +0 -196
  393. package/src/extensions/config/user-instruction-config-loader.test.ts +0 -246
  394. package/src/extensions/context/compaction.test.ts +0 -483
  395. package/src/extensions/mcp/config-loader.test.ts +0 -238
  396. package/src/extensions/mcp/manager.test.ts +0 -105
  397. package/src/extensions/plugin/plugin-config-loader.test.ts +0 -184
  398. package/src/extensions/plugin/plugin-loader.test.ts +0 -292
  399. package/src/extensions/plugin/plugin-sandbox.test.ts +0 -423
  400. package/src/extensions/tools/definitions.test.ts +0 -780
  401. package/src/extensions/tools/executors/bash.test.ts +0 -87
  402. package/src/extensions/tools/executors/editor.test.ts +0 -35
  403. package/src/extensions/tools/executors/file-read.test.ts +0 -125
  404. package/src/extensions/tools/model-tool-routing.test.ts +0 -86
  405. package/src/extensions/tools/presets.test.ts +0 -70
  406. package/src/extensions/tools/team/multi-agent.lifecycle.test.ts +0 -455
  407. package/src/extensions/tools/team/spawn-agent-tool.test.ts +0 -381
  408. package/src/extensions/tools/team/team-tools.test.ts +0 -918
  409. package/src/hooks/checkpoint-hooks.test.ts +0 -168
  410. package/src/hooks/hook-file-hooks.test.ts +0 -311
  411. package/src/hooks/persistent.ts +0 -661
  412. package/src/runtime/history.test.ts +0 -114
  413. package/src/runtime/host.test.ts +0 -230
  414. package/src/runtime/rpc-runtime-ensure.test.ts +0 -123
  415. package/src/runtime/rpc-runtime-ensure.ts +0 -659
  416. package/src/runtime/rpc-spawn-lease.test.ts +0 -81
  417. package/src/runtime/rpc-spawn-lease.ts +0 -156
  418. package/src/runtime/runtime-builder.team-persistence.test.ts +0 -245
  419. package/src/runtime/runtime-builder.test.ts +0 -615
  420. package/src/runtime/runtime-oauth-token-manager.test.ts +0 -137
  421. package/src/runtime/runtime-parity.test.ts +0 -143
  422. package/src/services/providers/local-provider-service.test.ts +0 -1062
  423. package/src/services/session-data.test.ts +0 -160
  424. package/src/services/storage/provider-settings-legacy-migration.test.ts +0 -424
  425. package/src/services/storage/provider-settings-manager.test.ts +0 -191
  426. package/src/services/telemetry/OpenTelemetryAdapter.test.ts +0 -157
  427. package/src/services/telemetry/OpenTelemetryProvider.test.ts +0 -326
  428. package/src/services/telemetry/TelemetryLoggerSink.test.ts +0 -42
  429. package/src/services/telemetry/TelemetryService.test.ts +0 -134
  430. package/src/services/telemetry/distinct-id.test.ts +0 -57
  431. package/src/services/workspace/file-indexer.d.ts +0 -11
  432. package/src/services/workspace/file-indexer.test.ts +0 -156
  433. package/src/services/workspace/mention-enricher.test.ts +0 -106
  434. package/src/session/persistence-service.test.ts +0 -300
  435. package/src/session/rpc-session-service.ts +0 -114
  436. package/src/session/session-service.team-persistence.test.ts +0 -48
  437. package/src/session/sqlite-rpc-session-backend.ts +0 -301
  438. package/src/transports/local.e2e.test.ts +0 -380
  439. package/src/transports/local.test.ts +0 -2559
  440. package/src/transports/rpc.test.ts +0 -82
  441. package/src/transports/rpc.ts +0 -665
package/src/ClineCore.ts CHANGED
@@ -1,51 +1,152 @@
1
1
  import type {
2
2
  AgentConfig,
3
+ AgentExtensionAutomationContext,
4
+ AgentResult,
5
+ AutomationEventEnvelope,
3
6
  BasicLogger,
7
+ ChatRunTurnRequest,
8
+ ChatStartSessionRequest,
9
+ ChatTurnResult,
10
+ ExtensionContext,
4
11
  ITelemetryService,
5
12
  ToolApprovalRequest,
6
13
  ToolApprovalResult,
7
14
  } from "@clinebot/shared";
15
+ import type {
16
+ CronEventIngressResult,
17
+ CronEventSuppression,
18
+ } from "./cron/cron-event-ingress";
19
+ import { CronService } from "./cron/cron-service";
20
+ import type { HubScheduleRuntimeHandlers } from "./cron/schedule-service";
21
+ import type {
22
+ CronEventLogRecord,
23
+ CronRunRecord,
24
+ CronSpecRecord,
25
+ } from "./cron/sqlite-cron-store";
8
26
  import type { ToolExecutors } from "./extensions/tools";
9
- import { hydrateSessionHistory } from "./runtime/history";
27
+ import { normalizeProviderId } from "./llms/provider-settings";
28
+ import type { SessionHistoryListOptions } from "./runtime/history";
29
+ import { listSessionHistory } from "./runtime/history";
10
30
  import type { SessionBackend } from "./runtime/host";
11
31
  import { createRuntimeHost } from "./runtime/host";
12
32
  import type {
13
33
  LocalRuntimeStartOptions,
34
+ PendingPromptMutationResult,
35
+ PendingPromptsAction,
36
+ PendingPromptsDeleteInput,
37
+ PendingPromptsListInput,
38
+ PendingPromptsUpdateInput,
14
39
  RuntimeHost,
15
40
  RuntimeHostMode,
41
+ RuntimeHostSubscribeOptions,
16
42
  StartSessionInput,
17
43
  StartSessionResult,
18
44
  } from "./runtime/runtime-host";
19
45
  import { splitCoreSessionConfig } from "./runtime/runtime-host";
20
- import type { TeamToolsFactory } from "./runtime/session-runtime";
46
+ import { CORE_TELEMETRY_EVENTS } from "./services/telemetry/core-events";
47
+ import { SessionSource } from "./types/common";
21
48
  import type { CoreSessionConfig } from "./types/config";
49
+ import type { CoreSessionEvent, SessionPendingPrompt } from "./types/events";
22
50
  import type { SessionMessagesArtifactUploader } from "./types/session";
51
+ import type { SessionHistoryRecord } from "./types/sessions";
23
52
 
24
- /** Advanced options for connecting to or spawning the Cline RPC server. */
25
- export interface RpcOptions {
26
- /**
27
- * The address of the Cline RPC server to connect to.
28
- * Defaults to the `CLINE_RPC_ADDRESS` env var, or the SDK default address if unset.
29
- */
30
- address?: string;
31
- /**
32
- * When `true` (default), automatically spawns a background RPC server process if one is
33
- * not already running.
34
- */
53
+ export interface HubOptions {
54
+ endpoint?: string;
55
+ authToken?: string;
56
+ strategy?: "prefer-hub" | "require-hub";
57
+ clientType?: string;
58
+ displayName?: string;
59
+ workspaceRoot?: string;
60
+ cwd?: string;
61
+ }
62
+
63
+ export interface RemoteOptions {
64
+ endpoint: string;
65
+ authToken?: string;
66
+ clientType?: string;
67
+ displayName?: string;
68
+ workspaceRoot?: string;
69
+ cwd?: string;
70
+ }
71
+
72
+ export interface ClineCoreAutomationOptions {
73
+ /** @deprecated Use `cronSpecsDir`. */
74
+ cronDir?: string;
75
+ cronSpecsDir?: string;
76
+ /** @deprecated Reports are written under the resolved cron specs directory. */
77
+ reportsDir?: string;
78
+ cronScope?: "global" | "user" | "workspace";
79
+ workspaceRoot?: string;
80
+ dbPath?: string;
81
+ pollIntervalMs?: number;
82
+ claimLeaseSeconds?: number;
83
+ globalMaxConcurrency?: number;
84
+ watcherDebounceMs?: number;
35
85
  autoStart?: boolean;
36
- /**
37
- * Number of connection attempts made to the RPC server after it is spawned.
38
- * Defaults to `5`.
39
- */
40
- connectAttempts?: number;
41
- /**
42
- * Milliseconds to wait between RPC connection attempts. Defaults to `100`.
43
- */
44
- connectDelayMs?: number;
86
+ }
87
+
88
+ export type ClineAutomationSpec = CronSpecRecord;
89
+ export type ClineAutomationRun = CronRunRecord;
90
+ export type ClineAutomationEventLog = CronEventLogRecord;
91
+ export type ClineAutomationEventSuppression = CronEventSuppression;
92
+ export type ClineAutomationRunStatus =
93
+ | "queued"
94
+ | "running"
95
+ | "done"
96
+ | "failed"
97
+ | "cancelled";
98
+
99
+ export interface ClineAutomationListSpecsOptions {
100
+ triggerKind?: "one_off" | "schedule" | "event";
101
+ enabled?: boolean;
102
+ parseStatus?: "valid" | "invalid";
103
+ includeRemoved?: boolean;
104
+ limit?: number;
105
+ }
106
+
107
+ export interface ClineAutomationListRunsOptions {
108
+ specId?: string;
109
+ status?: ClineAutomationRunStatus | ClineAutomationRunStatus[];
110
+ limit?: number;
111
+ }
112
+
113
+ export interface ClineAutomationListEventsOptions {
114
+ eventType?: string;
115
+ source?: string;
116
+ processingStatus?:
117
+ | "received"
118
+ | "unmatched"
119
+ | "queued"
120
+ | "suppressed"
121
+ | "failed";
122
+ limit?: number;
123
+ }
124
+
125
+ export interface ClineAutomationEventIngressResult {
126
+ event: ClineAutomationEventLog;
127
+ duplicate: boolean;
128
+ matchedSpecIds: string[];
129
+ queuedRuns: ClineAutomationRun[];
130
+ suppressions: ClineAutomationEventSuppression[];
131
+ }
132
+
133
+ export interface ClineCoreAutomationApi {
134
+ start(): Promise<void>;
135
+ stop(): Promise<void>;
136
+ reconcileNow(): Promise<void>;
137
+ ingestEvent(event: any): ClineAutomationEventIngressResult;
138
+ listEvents(
139
+ options?: ClineAutomationListEventsOptions,
140
+ ): ClineAutomationEventLog[];
141
+ getEvent(eventId: string): ClineAutomationEventLog | undefined;
142
+ listSpecs(options?: ClineAutomationListSpecsOptions): ClineAutomationSpec[];
143
+ listRuns(options?: ClineAutomationListRunsOptions): ClineAutomationRun[];
45
144
  }
46
145
 
47
146
  export type { RuntimeHostMode };
48
147
 
148
+ export type ClineCoreListHistoryOptions = SessionHistoryListOptions;
149
+
49
150
  export interface ClineCoreStartInput
50
151
  extends Omit<StartSessionInput, "config" | "localRuntime"> {
51
152
  config: CoreSessionConfig;
@@ -66,16 +167,22 @@ export interface ClineCoreOptions {
66
167
  distinctId?: string;
67
168
  /**
68
169
  * Controls how the runtime host is selected:
69
- * - `"auto"` (default) — connects to a running RPC server if available, starts one in the
70
- * background if `rpc.autoStart` is true, and falls back to local in-process execution.
71
- * - `"rpc"` — requires an RPC runtime server; throws if one is not reachable.
170
+ * - `"auto"` (default) — prefers a compatible local hub when one is available and falls
171
+ * back to local in-process execution when not.
172
+ * - `"hub"` — requires a compatible websocket hub runtime; throws if one is not reachable.
173
+ * - `"remote"` — requires an explicit remote websocket hub endpoint.
72
174
  * - `"local"` — always uses local in-process execution and local SQLite/file storage.
73
175
  */
74
176
  backendMode?: RuntimeHostMode;
75
177
  /**
76
- * RPC server connection options. Only relevant when `backendMode` is `"auto"` or `"rpc"`.
178
+ * Hub runtime connection options. Used when `backendMode` is `"hub"` or when `"auto"`
179
+ * should prefer a shared local hub if available.
77
180
  */
78
- rpc?: RpcOptions;
181
+ hub?: HubOptions;
182
+ /**
183
+ * Remote hub connection options. Only relevant when `backendMode` is `"remote"`.
184
+ */
185
+ remote?: RemoteOptions;
79
186
  /**
80
187
  * Override one or more default tool executors (e.g. file I/O, shell, browser).
81
188
  * Partial — only the keys you supply are replaced; the rest use built-in implementations.
@@ -88,7 +195,7 @@ export interface ClineCoreOptions {
88
195
  telemetry?: ITelemetryService;
89
196
  /**
90
197
  * Optional structured logger for core-side operational diagnostics such as
91
- * RPC backend startup, reuse, and fallback decisions.
198
+ * runtime-host selection and fallback decisions.
92
199
  */
93
200
  logger?: BasicLogger;
94
201
  /**
@@ -109,21 +216,39 @@ export interface ClineCoreOptions {
109
216
  * Consumers can use this to mirror session transcripts into remote storage.
110
217
  */
111
218
  messagesArtifactUploader?: SessionMessagesArtifactUploader;
219
+ /**
220
+ * Enables file-based and event-driven automation through this ClineCore
221
+ * instance. When configured, callers use `cline.automation.*` instead of
222
+ * constructing cron services directly.
223
+ */
224
+ automation?: boolean | ClineCoreAutomationOptions;
225
+ /**
226
+ * Custom `fetch` implementation forwarded to the AI gateway providers used
227
+ * by local sessions. When supplied, it is threaded into each
228
+ * `ProviderConfig.fetch` built during session bootstrap, which in turn
229
+ * populates `GatewayProviderSettings.fetch` (and the top-level
230
+ * `GatewayConfig.fetch` fallback) so hosts can inject custom HTTP behavior
231
+ * such as proxies, retries, tracing, or test doubles.
232
+ *
233
+ * Per-session or per-provider overrides still win: an explicit
234
+ * `config.fetch` on `CoreSessionConfig` or a stored provider-level `fetch`
235
+ * takes precedence over this default.
236
+ *
237
+ * Applies only to sessions executed in this process (local and fallback-
238
+ * to-local auto mode). For hub and remote runtimes the HTTP call happens
239
+ * inside the process that owns the gateway, so configure `fetch` there:
240
+ * - `startHubServer({ fetch })` / `ensureHubServer({ fetch })` from
241
+ * `@clinebot/hub`
242
+ * - `createLocalHubScheduleRuntimeHandlers({ fetch })` from
243
+ * `@clinebot/core/hub` for the scheduler
244
+ */
245
+ fetch?: typeof fetch;
112
246
  /**
113
247
  * An already-constructed session backend to use instead of resolving one automatically.
114
248
  * Intended for testing or embedding a custom persistence layer.
115
249
  * @internal
116
250
  */
117
251
  sessionService?: SessionBackend;
118
- /**
119
- * Factory that creates team management tools for the multi-agent team system.
120
- * When provided, team tools are registered whenever `enableAgentTeams` is `true`
121
- * on a session config.
122
- *
123
- * Consumers that depend on `@clinebot/enterprise` can pass
124
- * `bootstrapAgentTeams` here directly.
125
- */
126
- teamToolsFactory?: TeamToolsFactory;
127
252
  /**
128
253
  * Optional hook invoked before each session starts.
129
254
  * Use this to prepare workspace-scoped runtime state and then return an
@@ -144,6 +269,102 @@ export interface StartSessionBootstrap {
144
269
  dispose?(): Promise<void> | void;
145
270
  }
146
271
 
272
+ function normalizeAutomationOptions(
273
+ options: ClineCoreOptions["automation"],
274
+ ): ClineCoreAutomationOptions | undefined {
275
+ if (options === true) return {};
276
+ if (!options) return undefined;
277
+ return options;
278
+ }
279
+
280
+ function normalizeAutomationCronScope(
281
+ scope: ClineCoreAutomationOptions["cronScope"],
282
+ ): "global" | "workspace" | undefined {
283
+ if (scope === "user") return "global";
284
+ return scope;
285
+ }
286
+
287
+ function toChatTurnResult(result: AgentResult): ChatTurnResult {
288
+ return {
289
+ text: result.text,
290
+ usage: {
291
+ inputTokens: result.usage.inputTokens,
292
+ outputTokens: result.usage.outputTokens,
293
+ cacheReadTokens: result.usage.cacheReadTokens,
294
+ cacheWriteTokens: result.usage.cacheWriteTokens,
295
+ totalCost: result.usage.totalCost,
296
+ },
297
+ inputTokens: result.usage.inputTokens,
298
+ outputTokens: result.usage.outputTokens,
299
+ iterations: result.iterations,
300
+ finishReason: result.finishReason,
301
+ toolCalls: result.toolCalls.map((call) => ({
302
+ name: call.name,
303
+ input: call.input,
304
+ output: call.output,
305
+ error: call.error,
306
+ durationMs: call.durationMs,
307
+ })),
308
+ };
309
+ }
310
+
311
+ function resolveMode(
312
+ request: ChatStartSessionRequest | ChatRunTurnRequest["config"],
313
+ ): "act" | "plan" | "yolo" {
314
+ return request.mode === "plan"
315
+ ? "plan"
316
+ : request.mode === "yolo"
317
+ ? "yolo"
318
+ : "act";
319
+ }
320
+
321
+ class ClineCoreAutomationController implements ClineCoreAutomationApi {
322
+ constructor(private readonly getService: () => CronService) {}
323
+
324
+ async start(): Promise<void> {
325
+ await this.getService().start();
326
+ }
327
+
328
+ async stop(): Promise<void> {
329
+ await this.getService().stop();
330
+ }
331
+
332
+ async reconcileNow(): Promise<void> {
333
+ await this.getService().reconcileNow();
334
+ }
335
+
336
+ ingestEvent(
337
+ event: AutomationEventEnvelope,
338
+ ): ClineAutomationEventIngressResult {
339
+ const result: CronEventIngressResult = this.getService().ingestEvent(event);
340
+ return {
341
+ event: result.event,
342
+ duplicate: result.duplicate,
343
+ matchedSpecIds: result.matchedSpecs.map((spec) => spec.specId),
344
+ queuedRuns: result.queuedRuns,
345
+ suppressions: result.suppressions,
346
+ };
347
+ }
348
+
349
+ listEvents(
350
+ options?: ClineAutomationListEventsOptions,
351
+ ): ClineAutomationEventLog[] {
352
+ return this.getService().listEventLogs(options);
353
+ }
354
+
355
+ getEvent(eventId: string): ClineAutomationEventLog | undefined {
356
+ return this.getService().getEventLog(eventId);
357
+ }
358
+
359
+ listSpecs(options?: ClineAutomationListSpecsOptions): ClineAutomationSpec[] {
360
+ return this.getService().listSpecs(options);
361
+ }
362
+
363
+ listRuns(options?: ClineAutomationListRunsOptions): ClineAutomationRun[] {
364
+ return this.getService().listRuns(options);
365
+ }
366
+ }
367
+
147
368
  /**
148
369
  * The primary entry point for the Cline Core SDK.
149
370
  *
@@ -158,8 +379,14 @@ export interface StartSessionBootstrap {
158
379
  export class ClineCore implements RuntimeHost {
159
380
  readonly clientName: string | undefined;
160
381
  readonly runtimeAddress: string | undefined;
382
+ readonly automation: ClineCoreAutomationApi;
161
383
  private readonly host: RuntimeHost;
162
384
  private readonly prepare: ClineCoreOptions["prepare"] | undefined;
385
+ private readonly defaultToolExecutors: Partial<ToolExecutors> | undefined;
386
+ private readonly logger: BasicLogger | undefined;
387
+ private readonly telemetry: ITelemetryService | undefined;
388
+ private readonly distinctId: string | undefined;
389
+ private readonly automationService: CronService | undefined;
163
390
  private readonly activeSessionBootstraps = new Map<
164
391
  string,
165
392
  StartSessionBootstrap
@@ -171,11 +398,48 @@ export class ClineCore implements RuntimeHost {
171
398
  clientName: string | undefined,
172
399
  runtimeAddress: string | undefined,
173
400
  prepare: ClineCoreOptions["prepare"],
401
+ defaultToolExecutors: Partial<ToolExecutors> | undefined,
402
+ logger: BasicLogger | undefined,
403
+ telemetry: ITelemetryService | undefined,
404
+ distinctId: string | undefined,
405
+ automationOptions:
406
+ | (ClineCoreAutomationOptions & { logger?: BasicLogger })
407
+ | undefined,
174
408
  ) {
175
409
  this.clientName = clientName;
176
410
  this.runtimeAddress = runtimeAddress;
177
411
  this.host = host;
178
412
  this.prepare = prepare;
413
+ this.defaultToolExecutors = defaultToolExecutors;
414
+ this.logger = logger;
415
+ this.telemetry = telemetry;
416
+ this.distinctId = distinctId;
417
+ this.automationService = automationOptions
418
+ ? new CronService({
419
+ workspaceRoot: automationOptions.workspaceRoot ?? process.cwd(),
420
+ specs: {
421
+ cronSpecsDir:
422
+ automationOptions.cronSpecsDir ?? automationOptions.cronDir,
423
+ scope: normalizeAutomationCronScope(automationOptions.cronScope),
424
+ workspaceRoot: automationOptions.workspaceRoot,
425
+ },
426
+ runtimeHandlers: this.createAutomationRuntimeHandlers(host),
427
+ dbPath: automationOptions.dbPath,
428
+ logger: automationOptions.logger,
429
+ pollIntervalMs: automationOptions.pollIntervalMs,
430
+ claimLeaseSeconds: automationOptions.claimLeaseSeconds,
431
+ globalMaxConcurrency: automationOptions.globalMaxConcurrency,
432
+ watcherDebounceMs: automationOptions.watcherDebounceMs,
433
+ })
434
+ : undefined;
435
+ this.automation = new ClineCoreAutomationController(() => {
436
+ if (!this.automationService) {
437
+ throw new Error(
438
+ "ClineCore automation is not enabled. Pass `automation: true` or automation options to ClineCore.create().",
439
+ );
440
+ }
441
+ return this.automationService;
442
+ });
179
443
  this.unsubscribeBootstrapCleanup = this.host.subscribe((event) => {
180
444
  if (event.type !== "ended") {
181
445
  return;
@@ -184,14 +448,155 @@ export class ClineCore implements RuntimeHost {
184
448
  });
185
449
  }
186
450
 
451
+ /**
452
+ * Creates a new ClineCore instance.
453
+ *
454
+ * This is the primary factory method for initializing the SDK. It sets up the runtime
455
+ * host (local, hub, or remote) based on the provided options and prepares the SDK for
456
+ * starting sessions.
457
+ *
458
+ * @param options Configuration options for the SDK instance
459
+ * @returns A promise that resolves to a new ClineCore instance
460
+ *
461
+ * @example
462
+ * ```ts
463
+ * const cline = await ClineCore.create({
464
+ * clientName: "my-app",
465
+ * backendMode: "local",
466
+ * });
467
+ * ```
468
+ */
187
469
  static async create(options: ClineCoreOptions = {}): Promise<ClineCore> {
188
470
  const host = await createRuntimeHost(options);
189
- return new ClineCore(
471
+ const automationOptions = normalizeAutomationOptions(options.automation);
472
+ const core = new ClineCore(
190
473
  host,
191
474
  options.clientName,
192
475
  host.runtimeAddress,
193
476
  options.prepare,
477
+ options.defaultToolExecutors,
478
+ options.logger,
479
+ options.telemetry,
480
+ options.distinctId,
481
+ automationOptions
482
+ ? { ...automationOptions, logger: options.logger }
483
+ : undefined,
194
484
  );
485
+ if (automationOptions && automationOptions.autoStart !== false) {
486
+ await core.automation.start();
487
+ }
488
+ return core;
489
+ }
490
+
491
+ private createAutomationRuntimeHandlers(
492
+ host: RuntimeHost,
493
+ ): HubScheduleRuntimeHandlers {
494
+ const core = this;
495
+ return {
496
+ async startSession(request) {
497
+ const cwd = (request.cwd?.trim() || request.workspaceRoot).trim();
498
+ const started = await host.start({
499
+ source: request.source?.trim() || SessionSource.CLI,
500
+ interactive: false,
501
+ config: {
502
+ providerId: normalizeProviderId(request.provider),
503
+ modelId: request.model,
504
+ apiKey: request.apiKey?.trim() || undefined,
505
+ cwd,
506
+ workspaceRoot: request.workspaceRoot,
507
+ systemPrompt: request.systemPrompt ?? "",
508
+ mode: resolveMode(request),
509
+ maxIterations: request.maxIterations,
510
+ enableTools: request.enableTools !== false,
511
+ enableSpawnAgent: request.enableSpawn !== false,
512
+ enableAgentTeams: request.enableTeams !== false,
513
+ disableMcpSettingsTools: request.disableMcpSettingsTools,
514
+ missionLogIntervalSteps: request.missionStepInterval,
515
+ missionLogIntervalMs: request.missionTimeIntervalMs,
516
+ },
517
+ toolPolicies: request.toolPolicies ?? {
518
+ "*": {
519
+ autoApprove: request.autoApproveTools !== false,
520
+ },
521
+ },
522
+ localRuntime: {
523
+ configOverrides: {
524
+ extensionContext: core.withAutomationExtensionContext(),
525
+ },
526
+ configExtensions: request.configExtensions,
527
+ },
528
+ });
529
+ return {
530
+ sessionId: started.sessionId,
531
+ startResult: {
532
+ sessionId: started.sessionId,
533
+ manifestPath: started.manifestPath,
534
+ messagesPath: started.messagesPath,
535
+ },
536
+ };
537
+ },
538
+ async sendSession(sessionId, request) {
539
+ const result = await host.send({
540
+ sessionId,
541
+ prompt: request.prompt,
542
+ userImages: request.attachments?.userImages,
543
+ userFiles: request.attachments?.userFiles?.map(
544
+ (file) => file.content,
545
+ ),
546
+ delivery: request.delivery,
547
+ });
548
+ if (!result) {
549
+ throw new Error("ClineCore automation runtime returned no result");
550
+ }
551
+ return { result: toChatTurnResult(result) };
552
+ },
553
+ async abortSession(sessionId) {
554
+ await host.abort(sessionId, new Error("ClineCore automation abort"));
555
+ return { applied: true };
556
+ },
557
+ async stopSession(sessionId) {
558
+ await host.stop(sessionId);
559
+ return { applied: true };
560
+ },
561
+ };
562
+ }
563
+
564
+ private createAutomationPluginContext():
565
+ | AgentExtensionAutomationContext
566
+ | undefined {
567
+ if (!this.automationService) {
568
+ return undefined;
569
+ }
570
+ return {
571
+ ingestEvent: (event: AutomationEventEnvelope) => {
572
+ this.automation.ingestEvent(event);
573
+ },
574
+ };
575
+ }
576
+
577
+ private withAutomationExtensionContext(
578
+ context?: ExtensionContext,
579
+ ): ExtensionContext | undefined {
580
+ const automation = this.createAutomationPluginContext();
581
+ const client =
582
+ context?.client ??
583
+ (this.clientName ? { name: this.clientName } : undefined);
584
+ const user =
585
+ context?.user ??
586
+ (this.distinctId ? { distinctId: this.distinctId } : undefined);
587
+ const logger = context?.logger ?? this.logger;
588
+ const telemetry = context?.telemetry ?? this.telemetry;
589
+ if (!automation && !client && !user && !logger && !telemetry) {
590
+ return context;
591
+ }
592
+ return {
593
+ ...(context ?? {}),
594
+ ...(client ? { client } : {}),
595
+ ...(user ? { user } : {}),
596
+ ...(logger ? { logger } : {}),
597
+ ...(telemetry ? { telemetry } : {}),
598
+ ...(automation ? { automation } : {}),
599
+ };
195
600
  }
196
601
 
197
602
  private async disposeSessionBootstrap(sessionId: string): Promise<void> {
@@ -226,8 +631,8 @@ export class ClineCore implements RuntimeHost {
226
631
 
227
632
  private normalizeStartInput(input: ClineCoreStartInput): StartSessionInput {
228
633
  const split = splitCoreSessionConfig(input.config);
229
- const localRuntime =
230
- split.localRuntime || input.localRuntime
634
+ let localRuntime: LocalRuntimeStartOptions | undefined =
635
+ split.localRuntime || input.localRuntime || this.defaultToolExecutors
231
636
  ? {
232
637
  ...(split.localRuntime ?? {}),
233
638
  ...(input.localRuntime ?? {}),
@@ -235,8 +640,25 @@ export class ClineCore implements RuntimeHost {
235
640
  ...(split.localRuntime?.configOverrides ?? {}),
236
641
  ...(input.localRuntime?.configOverrides ?? {}),
237
642
  },
643
+ defaultToolExecutors: {
644
+ ...(this.defaultToolExecutors ?? {}),
645
+ ...(split.localRuntime?.defaultToolExecutors ?? {}),
646
+ ...(input.localRuntime?.defaultToolExecutors ?? {}),
647
+ },
238
648
  }
239
649
  : undefined;
650
+ const automationExtensionContext = this.withAutomationExtensionContext(
651
+ localRuntime?.configOverrides?.extensionContext,
652
+ );
653
+ if (automationExtensionContext) {
654
+ localRuntime = {
655
+ ...(localRuntime ?? {}),
656
+ configOverrides: {
657
+ ...(localRuntime?.configOverrides ?? {}),
658
+ extensionContext: automationExtensionContext,
659
+ },
660
+ };
661
+ }
240
662
  return {
241
663
  ...input,
242
664
  ...split,
@@ -244,7 +666,36 @@ export class ClineCore implements RuntimeHost {
244
666
  };
245
667
  }
246
668
 
669
+ /**
670
+ * Starts a new Cline session with the provided configuration.
671
+ *
672
+ * This method initializes and begins a new agent session. It handles session setup,
673
+ * runs any preparation hooks, and returns session metadata along with event streams.
674
+ * The session continues to run until explicitly stopped or aborted.
675
+ *
676
+ * @param input The session configuration and startup parameters
677
+ * @returns A promise that resolves to session metadata and event stream
678
+ *
679
+ * @example
680
+ * ```ts
681
+ * const result = await cline.start({
682
+ * config: {
683
+ * providerId: "anthropic",
684
+ * modelId: "claude-opus-4-1",
685
+ * },
686
+ * });
687
+ *
688
+ * // Subscribe to session events
689
+ * result.subscribe((event) => {
690
+ * console.log("Session event:", event);
691
+ * });
692
+ * ```
693
+ */
247
694
  start(input: StartSessionInput): Promise<StartSessionResult>;
695
+ /**
696
+ * Starts a new Cline session with extended core-specific configuration.
697
+ * This overload allows specifying local runtime options and config overrides.
698
+ */
248
699
  start(input: ClineCoreStartInput): Promise<StartSessionResult>;
249
700
  async start(
250
701
  input: StartSessionInput | ClineCoreStartInput,
@@ -266,22 +717,154 @@ export class ClineCore implements RuntimeHost {
266
717
  await Promise.resolve(bootstrap.dispose?.());
267
718
  }
268
719
  }
720
+ this.emitSessionStartedTelemetry(preparedInput, result.sessionId);
269
721
  return result;
270
722
  } catch (error) {
271
723
  await Promise.resolve(bootstrap?.dispose?.());
272
724
  throw error;
273
725
  }
274
726
  }
727
+
728
+ private emitSessionStartedTelemetry(
729
+ input: ClineCoreStartInput,
730
+ sessionId: string,
731
+ ): void {
732
+ // Per-session telemetry override (passed via `CoreSessionConfig.telemetry`)
733
+ // takes precedence over the instance-wide telemetry service configured
734
+ // on `ClineCore.create`. Either way we fire a single `session.started`
735
+ // event here so the signal is emitted for every backend (local, hub,
736
+ // remote), not just the in-process local transport.
737
+ const telemetry = input.config.telemetry ?? this.telemetry;
738
+ if (!telemetry) {
739
+ return;
740
+ }
741
+ telemetry.capture({
742
+ event: CORE_TELEMETRY_EVENTS.SESSION.STARTED,
743
+ properties: {
744
+ sessionId,
745
+ source: input.source ?? SessionSource.CORE,
746
+ providerId: input.config.providerId,
747
+ modelId: input.config.modelId,
748
+ enableTools: input.config.enableTools,
749
+ enableSpawnAgent: input.config.enableSpawnAgent,
750
+ enableAgentTeams: input.config.enableAgentTeams,
751
+ clientName: this.clientName,
752
+ runtimeAddress: this.runtimeAddress,
753
+ },
754
+ });
755
+ }
756
+ /**
757
+ * Sends a message or command to an active session.
758
+ *
759
+ * This method communicates with a running session, allowing you to send user messages,
760
+ * tool responses, or other session input while the session is in progress.
761
+ *
762
+ * @example
763
+ * ```ts
764
+ * await cline.send(sessionId, {
765
+ * type: "user_message",
766
+ * text: "Please implement the login feature",
767
+ * });
768
+ * ```
769
+ */
275
770
  send: RuntimeHost["send"] = (...args) => this.host.send(...args);
771
+ pendingPrompts(
772
+ action: "list",
773
+ input: PendingPromptsListInput,
774
+ ): Promise<SessionPendingPrompt[]>;
775
+ pendingPrompts(
776
+ action: "update",
777
+ input: PendingPromptsUpdateInput,
778
+ ): Promise<PendingPromptMutationResult>;
779
+ pendingPrompts(
780
+ action: "delete",
781
+ input: PendingPromptsDeleteInput,
782
+ ): Promise<PendingPromptMutationResult>;
783
+ pendingPrompts(
784
+ action: PendingPromptsAction,
785
+ input:
786
+ | PendingPromptsListInput
787
+ | PendingPromptsUpdateInput
788
+ | PendingPromptsDeleteInput,
789
+ ): Promise<SessionPendingPrompt[] | PendingPromptMutationResult> {
790
+ switch (action) {
791
+ case "list":
792
+ return this.host.pendingPrompts(
793
+ "list",
794
+ input as PendingPromptsListInput,
795
+ );
796
+ case "update":
797
+ return this.host.pendingPrompts(
798
+ "update",
799
+ input as PendingPromptsUpdateInput,
800
+ );
801
+ case "delete":
802
+ return this.host.pendingPrompts(
803
+ "delete",
804
+ input as PendingPromptsDeleteInput,
805
+ );
806
+ }
807
+ }
808
+ /**
809
+ * Retrieves accumulated token and cost usage for a session.
810
+ *
811
+ * Returns metrics about the session's resource consumption, including tokens used
812
+ * across different API providers and associated costs. Useful for monitoring and billing.
813
+ *
814
+ * @example
815
+ * ```ts
816
+ * const usage = await cline.getAccumulatedUsage(sessionId);
817
+ * console.log(`Total cost: $${usage.totalCost}`);
818
+ * ```
819
+ */
276
820
  getAccumulatedUsage: RuntimeHost["getAccumulatedUsage"] = (...args) =>
277
821
  this.host.getAccumulatedUsage(...args);
822
+ /**
823
+ * Aborts an in-flight tool execution without stopping the session.
824
+ *
825
+ * Interrupts the current tool operation (e.g., file read, shell command) while keeping
826
+ * the session alive. The session can continue processing after the abort. Use this for
827
+ * cancelling long-running operations.
828
+ *
829
+ * @example
830
+ * ```ts
831
+ * // Stop the current operation but keep the session running
832
+ * await cline.abort(sessionId);
833
+ * ```
834
+ */
278
835
  abort: RuntimeHost["abort"] = (...args) => this.host.abort(...args);
836
+ /**
837
+ * Stops an active session gracefully.
838
+ *
839
+ * Terminates the session and cleans up associated resources. Unlike abort, this
840
+ * completely ends the session. The session cannot be resumed after stopping.
841
+ *
842
+ * @example
843
+ * ```ts
844
+ * // Cleanly shutdown the session
845
+ * await cline.stop(sessionId);
846
+ * ```
847
+ */
279
848
  stop: RuntimeHost["stop"] = async (sessionId) => {
280
849
  await this.host.stop(sessionId);
281
850
  await this.disposeSessionBootstrap(sessionId);
282
851
  };
852
+ /**
853
+ * Disposes the ClineCore instance and all associated resources.
854
+ *
855
+ * Shuts down the runtime host, closes connections, and cleans up all active sessions
856
+ * and bootstraps. Call this when you're done using the SDK instance, typically at
857
+ * application shutdown. After calling dispose, the instance cannot be reused.
858
+ *
859
+ * @example
860
+ * ```ts
861
+ * // Clean up when done
862
+ * await cline.dispose();
863
+ * ```
864
+ */
283
865
  dispose: RuntimeHost["dispose"] = async (...args) => {
284
866
  try {
867
+ await this.automationService?.dispose();
285
868
  await this.host.dispose(...args);
286
869
  } finally {
287
870
  this.unsubscribeBootstrapCleanup();
@@ -291,9 +874,65 @@ export class ClineCore implements RuntimeHost {
291
874
  );
292
875
  }
293
876
  };
877
+ /**
878
+ * Retrieves information about a specific session by ID.
879
+ *
880
+ * Fetches the current metadata and state of a session, including configuration,
881
+ * status, and other session details.
882
+ *
883
+ * @example
884
+ * ```ts
885
+ * const session = await cline.get(sessionId);
886
+ * console.log("Session status:", session?.status);
887
+ * ```
888
+ */
294
889
  get: RuntimeHost["get"] = (...args) => this.host.get(...args);
295
- list: RuntimeHost["list"] = async (limit = 200) =>
296
- await hydrateSessionHistory(this.host, await this.host.list(limit));
890
+ /**
891
+ * Lists recent sessions through the shared history-listing path.
892
+ */
893
+ listHistory = async (
894
+ options: ClineCoreListHistoryOptions = {},
895
+ ): Promise<SessionHistoryRecord[]> =>
896
+ await listSessionHistory(this.host, options);
897
+ /**
898
+ * Lists recent sessions with inferred history display metadata.
899
+ *
900
+ * Retrieves a paginated list of recent sessions, optionally limited by the
901
+ * provided count.
902
+ *
903
+ * @param limit Maximum number of sessions to return (defaults to 200)
904
+ * @returns A promise resolving to an array of session history records
905
+ *
906
+ * @example
907
+ * ```ts
908
+ * const sessions = await cline.list(50);
909
+ * sessions.forEach((session) => {
910
+ * console.log(`Session ${session.sessionId}: ${session.metadata?.title}`);
911
+ * });
912
+ * ```
913
+ */
914
+ list = async (
915
+ limit = 200,
916
+ options: Omit<ClineCoreListHistoryOptions, "limit"> = {},
917
+ ): Promise<SessionHistoryRecord[]> =>
918
+ await this.listHistory({ ...options, limit });
919
+ /**
920
+ * Permanently deletes a session and all its associated data.
921
+ *
922
+ * Removes the session from storage and cleans up any related resources. This is
923
+ * a destructive operation that cannot be undone.
924
+ *
925
+ * @param sessionId The ID of the session to delete
926
+ * @returns A promise that resolves to true if the session was deleted, false if not found
927
+ *
928
+ * @example
929
+ * ```ts
930
+ * const deleted = await cline.delete(sessionId);
931
+ * if (deleted) {
932
+ * console.log("Session deleted successfully");
933
+ * }
934
+ * ```
935
+ */
297
936
  delete: RuntimeHost["delete"] = async (sessionId) => {
298
937
  const deleted = await this.host.delete(sessionId);
299
938
  if (deleted) {
@@ -301,13 +940,87 @@ export class ClineCore implements RuntimeHost {
301
940
  }
302
941
  return deleted;
303
942
  };
943
+ /**
944
+ * Updates an existing session's metadata.
945
+ *
946
+ * Modifies session properties like title or other mutable metadata while preserving
947
+ * message history and other session data.
948
+ *
949
+ * @example
950
+ * ```ts
951
+ * await cline.update(sessionId, {
952
+ * title: "Updated session title",
953
+ * });
954
+ * ```
955
+ */
304
956
  update: RuntimeHost["update"] = (...args) => this.host.update(...args);
957
+ /**
958
+ * Reads message history for a session.
959
+ *
960
+ * Retrieves the full message transcript for a specific session, including all
961
+ * user messages, agent responses, and tool interactions.
962
+ *
963
+ * @example
964
+ * ```ts
965
+ * const messages = await cline.readMessages(sessionId);
966
+ * messages.forEach((msg) => {
967
+ * console.log(`${msg.role}: ${msg.content}`);
968
+ * });
969
+ * ```
970
+ */
305
971
  readMessages: RuntimeHost["readMessages"] = (...args) =>
306
972
  this.host.readMessages(...args);
973
+ /**
974
+ * Handles hook events from the runtime environment.
975
+ *
976
+ * Processes system or environment events (e.g., workspace changes, external signals)
977
+ * that may affect the current session. This is typically called by the host environment
978
+ * rather than directly by consumer code.
979
+ *
980
+ * @internal
981
+ */
307
982
  handleHookEvent: RuntimeHost["handleHookEvent"] = (...args) =>
308
983
  this.host.handleHookEvent(...args);
309
- subscribe: RuntimeHost["subscribe"] = (...args) =>
310
- this.host.subscribe(...args);
984
+ /**
985
+ * Subscribes to session events.
986
+ *
987
+ * Registers a listener for all session events (messages, state changes, errors, etc.).
988
+ * Returns an unsubscribe function to stop listening.
989
+ *
990
+ * @param listener Callback function invoked for each event
991
+ * @param options Optional configuration for the subscription
992
+ * @returns An unsubscribe function
993
+ *
994
+ * @example
995
+ * ```ts
996
+ * const unsubscribe = cline.subscribe((event) => {
997
+ * if (event.type === "message") {
998
+ * console.log("New message:", event.payload.message);
999
+ * }
1000
+ * });
1001
+ *
1002
+ * // Later, stop listening
1003
+ * unsubscribe();
1004
+ * ```
1005
+ */
1006
+ subscribe(
1007
+ listener: (event: CoreSessionEvent) => void,
1008
+ options?: RuntimeHostSubscribeOptions,
1009
+ ): () => void {
1010
+ return this.host.subscribe(listener, options);
1011
+ }
1012
+ /**
1013
+ * Updates the AI model used by an active session.
1014
+ *
1015
+ * Switches the session to use a different AI model while maintaining the session state
1016
+ * and message history. This allows you to continue a conversation with a different model.
1017
+ *
1018
+ * @example
1019
+ * ```ts
1020
+ * // Switch to a different model mid-session
1021
+ * await cline.updateSessionModel(sessionId, "claude-opus-4-1");
1022
+ * ```
1023
+ */
311
1024
  updateSessionModel: RuntimeHost["updateSessionModel"] = (...args) =>
312
1025
  this.host.updateSessionModel?.(...args) ?? Promise.resolve();
313
1026
  }