@cerebriline/core 4.100.240

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 (479) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +16 -0
  3. package/assets/office-oxide/LICENSE-APACHE +176 -0
  4. package/assets/office-oxide/LICENSE-MIT +25 -0
  5. package/assets/office-oxide/office_oxide_bg.wasm +0 -0
  6. package/assets/prompt-templates/claude.md +516 -0
  7. package/assets/prompt-templates/deepseek.md +331 -0
  8. package/assets/prompt-templates/default.md +386 -0
  9. package/assets/prompt-templates/gemma.md +352 -0
  10. package/assets/prompt-templates/glm.md +334 -0
  11. package/assets/prompt-templates/kimi-k3.md +408 -0
  12. package/assets/prompt-templates/kimi.md +402 -0
  13. package/assets/prompt-templates/minimax.md +473 -0
  14. package/assets/prompt-templates/nemotron.md +358 -0
  15. package/assets/prompt-templates/qwen.md +612 -0
  16. package/dist/ClineCore.d.ts +365 -0
  17. package/dist/account/cline-account-service.d.ts +41 -0
  18. package/dist/account/index.d.ts +3 -0
  19. package/dist/account/rpc.d.ts +40 -0
  20. package/dist/account/types.d.ts +122 -0
  21. package/dist/auth/bounded-ttl-cache.d.ts +13 -0
  22. package/dist/auth/client.d.ts +30 -0
  23. package/dist/auth/cline.d.ts +71 -0
  24. package/dist/auth/codex.d.ts +40 -0
  25. package/dist/auth/oca.d.ts +21 -0
  26. package/dist/auth/provider-auth-registry.d.ts +52 -0
  27. package/dist/auth/server.d.ts +54 -0
  28. package/dist/auth/types.d.ts +103 -0
  29. package/dist/auth/utils.d.ts +31 -0
  30. package/dist/cline-core/automation.d.ts +34 -0
  31. package/dist/cline-core/runtime-services.d.ts +5 -0
  32. package/dist/cline-core/start-input.d.ts +10 -0
  33. package/dist/cline-core/telemetry.d.ts +10 -0
  34. package/dist/cline-core/types.d.ts +236 -0
  35. package/dist/cron/events/cron-event-ingress.d.ts +37 -0
  36. package/dist/cron/reports/cron-report-writer.d.ts +42 -0
  37. package/dist/cron/runner/cron-materializer.d.ts +35 -0
  38. package/dist/cron/runner/cron-runner.d.ts +60 -0
  39. package/dist/cron/runner/resource-limiter.d.ts +8 -0
  40. package/dist/cron/schedule/scheduler.d.ts +12 -0
  41. package/dist/cron/service/cron-service.d.ts +56 -0
  42. package/dist/cron/service/schedule-command-service.d.ts +14 -0
  43. package/dist/cron/service/schedule-service.d.ts +116 -0
  44. package/dist/cron/service/schedule-tool.d.ts +81 -0
  45. package/dist/cron/specs/cron-reconciler.d.ts +61 -0
  46. package/dist/cron/specs/cron-spec-parser.d.ts +26 -0
  47. package/dist/cron/specs/cron-watcher.d.ts +22 -0
  48. package/dist/cron/store/cron-schema.d.ts +2 -0
  49. package/dist/cron/store/sqlite-cron-store.d.ts +261 -0
  50. package/dist/extensions/agent-plugin/agent-skill.d.ts +21 -0
  51. package/dist/extensions/agent-plugin/index.d.ts +4 -0
  52. package/dist/extensions/agent-plugin/loader.d.ts +10 -0
  53. package/dist/extensions/agent-plugin/types.d.ts +67 -0
  54. package/dist/extensions/complexity/grammars.d.ts +92 -0
  55. package/dist/extensions/complexity/walker.d.ts +115 -0
  56. package/dist/extensions/config/builtin-templates.d.ts +10 -0
  57. package/dist/extensions/config/builtin-templates.generated.d.ts +5 -0
  58. package/dist/extensions/config/index.d.ts +15 -0
  59. package/dist/extensions/config/prompt-template-compaction.d.ts +92 -0
  60. package/dist/extensions/config/prompt-template-delta.d.ts +107 -0
  61. package/dist/extensions/config/prompt-template-hooks.d.ts +47 -0
  62. package/dist/extensions/config/prompt-template-loader.d.ts +79 -0
  63. package/dist/extensions/config/prompt-template-parser.d.ts +56 -0
  64. package/dist/extensions/config/prompt-template-review.d.ts +327 -0
  65. package/dist/extensions/config/prompt-template-session.d.ts +46 -0
  66. package/dist/extensions/config/runtime-commands.d.ts +23 -0
  67. package/dist/extensions/config/shipped-tool-signatures.d.ts +36 -0
  68. package/dist/extensions/config/skill-frontmatter-toggle.d.ts +11 -0
  69. package/dist/extensions/config/unified-config-file-watcher.d.ts +77 -0
  70. package/dist/extensions/config/user-instruction-config-loader.d.ts +77 -0
  71. package/dist/extensions/config/user-instruction-plugin.d.ts +26 -0
  72. package/dist/extensions/config/user-instruction-service.d.ts +31 -0
  73. package/dist/extensions/context/agentic-compaction.d.ts +129 -0
  74. package/dist/extensions/context/basic-compaction.d.ts +19 -0
  75. package/dist/extensions/context/budget-projection/index.d.ts +2 -0
  76. package/dist/extensions/context/budget-projection/project.d.ts +4 -0
  77. package/dist/extensions/context/budget-projection/types.d.ts +58 -0
  78. package/dist/extensions/context/capped-thinking.d.ts +195 -0
  79. package/dist/extensions/context/compaction-cause.d.ts +27 -0
  80. package/dist/extensions/context/compaction-journal.d.ts +65 -0
  81. package/dist/extensions/context/compaction-revisions.d.ts +72 -0
  82. package/dist/extensions/context/compaction-shared.d.ts +608 -0
  83. package/dist/extensions/context/compaction.d.ts +161 -0
  84. package/dist/extensions/context/context-minimum-warning.d.ts +27 -0
  85. package/dist/extensions/context/continuation-compaction.d.ts +260 -0
  86. package/dist/extensions/context/council-compaction.d.ts +262 -0
  87. package/dist/extensions/context/full-compaction.d.ts +44 -0
  88. package/dist/extensions/context/kv-pressure.d.ts +258 -0
  89. package/dist/extensions/context/polykv-session.d.ts +372 -0
  90. package/dist/extensions/context/replay-compaction.d.ts +90 -0
  91. package/dist/extensions/context/tool-ledger.d.ts +198 -0
  92. package/dist/extensions/context/work-digest.d.ts +92 -0
  93. package/dist/extensions/index.d.ts +7 -0
  94. package/dist/extensions/mcp/client.d.ts +28 -0
  95. package/dist/extensions/mcp/config-loader.d.ts +102 -0
  96. package/dist/extensions/mcp/index.d.ts +15 -0
  97. package/dist/extensions/mcp/manager.d.ts +23 -0
  98. package/dist/extensions/mcp/name-transform.d.ts +2 -0
  99. package/dist/extensions/mcp/oauth.d.ts +68 -0
  100. package/dist/extensions/mcp/plugin-server-registration.d.ts +18 -0
  101. package/dist/extensions/mcp/policies.d.ts +14 -0
  102. package/dist/extensions/mcp/remote-proxy.d.ts +9 -0
  103. package/dist/extensions/mcp/timeout.d.ts +2 -0
  104. package/dist/extensions/mcp/tools.d.ts +3 -0
  105. package/dist/extensions/mcp/types.d.ts +133 -0
  106. package/dist/extensions/plugin/plugin-config-loader.d.ts +44 -0
  107. package/dist/extensions/plugin/plugin-load-report.d.ts +18 -0
  108. package/dist/extensions/plugin/plugin-loader.d.ts +23 -0
  109. package/dist/extensions/plugin/plugin-module-import.d.ts +4 -0
  110. package/dist/extensions/plugin/plugin-sandbox.d.ts +82 -0
  111. package/dist/extensions/plugin/plugin-targeting.d.ts +6 -0
  112. package/dist/extensions/plugin-sandbox-bootstrap.js +1 -0
  113. package/dist/extensions/tools/ask-lsp.d.ts +150 -0
  114. package/dist/extensions/tools/audio-tools.d.ts +156 -0
  115. package/dist/extensions/tools/browser.d.ts +137 -0
  116. package/dist/extensions/tools/check-file.d.ts +218 -0
  117. package/dist/extensions/tools/check-on-failure.d.ts +49 -0
  118. package/dist/extensions/tools/code-intel.d.ts +131 -0
  119. package/dist/extensions/tools/command-guard-extension.d.ts +22 -0
  120. package/dist/extensions/tools/command-guard.d.ts +29 -0
  121. package/dist/extensions/tools/constants.d.ts +28 -0
  122. package/dist/extensions/tools/definitions.d.ts +178 -0
  123. package/dist/extensions/tools/delimiter-balance.d.ts +121 -0
  124. package/dist/extensions/tools/edit-verification.d.ts +86 -0
  125. package/dist/extensions/tools/error-locations.d.ts +53 -0
  126. package/dist/extensions/tools/executors/apply-patch-parser.d.ts +68 -0
  127. package/dist/extensions/tools/executors/apply-patch.d.ts +48 -0
  128. package/dist/extensions/tools/executors/awk-parser.d.ts +163 -0
  129. package/dist/extensions/tools/executors/awk.d.ts +41 -0
  130. package/dist/extensions/tools/executors/bash.d.ts +119 -0
  131. package/dist/extensions/tools/executors/document/assets.d.ts +22 -0
  132. package/dist/extensions/tools/executors/document/ebook.d.ts +11 -0
  133. package/dist/extensions/tools/executors/document/formats.d.ts +83 -0
  134. package/dist/extensions/tools/executors/document/images.d.ts +73 -0
  135. package/dist/extensions/tools/executors/document/legacy.d.ts +20 -0
  136. package/dist/extensions/tools/executors/document/ocr.d.ts +67 -0
  137. package/dist/extensions/tools/executors/document/office-oxide.d.ts +19 -0
  138. package/dist/extensions/tools/executors/document/office-oxide.generated.d.ts +82 -0
  139. package/dist/extensions/tools/executors/document/office.d.ts +10 -0
  140. package/dist/extensions/tools/executors/document/pdf.d.ts +6 -0
  141. package/dist/extensions/tools/executors/document/pdfjs.d.ts +30 -0
  142. package/dist/extensions/tools/executors/document/range.d.ts +18 -0
  143. package/dist/extensions/tools/executors/document/recognition.d.ts +67 -0
  144. package/dist/extensions/tools/executors/document-extract.d.ts +55 -0
  145. package/dist/extensions/tools/executors/editor.d.ts +68 -0
  146. package/dist/extensions/tools/executors/file-locks.d.ts +41 -0
  147. package/dist/extensions/tools/executors/file-read.d.ts +136 -0
  148. package/dist/extensions/tools/executors/grep.d.ts +35 -0
  149. package/dist/extensions/tools/executors/index.d.ts +97 -0
  150. package/dist/extensions/tools/executors/line-endings.d.ts +23 -0
  151. package/dist/extensions/tools/executors/output-limits.d.ts +58 -0
  152. package/dist/extensions/tools/executors/overlay-receipts.d.ts +25 -0
  153. package/dist/extensions/tools/executors/posix-regex.d.ts +52 -0
  154. package/dist/extensions/tools/executors/read-receipts.d.ts +93 -0
  155. package/dist/extensions/tools/executors/run-command-execution-controller.d.ts +16 -0
  156. package/dist/extensions/tools/executors/search.d.ts +50 -0
  157. package/dist/extensions/tools/executors/sed.d.ts +92 -0
  158. package/dist/extensions/tools/executors/unchanged-reads.d.ts +55 -0
  159. package/dist/extensions/tools/executors/web-fetch.d.ts +58 -0
  160. package/dist/extensions/tools/helpers.d.ts +59 -0
  161. package/dist/extensions/tools/image-edit.d.ts +76 -0
  162. package/dist/extensions/tools/image-generation.d.ts +183 -0
  163. package/dist/extensions/tools/index.d.ts +68 -0
  164. package/dist/extensions/tools/jev.d.ts +336 -0
  165. package/dist/extensions/tools/list-files.d.ts +128 -0
  166. package/dist/extensions/tools/media-endpoint.d.ts +160 -0
  167. package/dist/extensions/tools/media-tools.d.ts +140 -0
  168. package/dist/extensions/tools/model-tool-routing.d.ts +33 -0
  169. package/dist/extensions/tools/presets.d.ts +154 -0
  170. package/dist/extensions/tools/qa-credentials.d.ts +133 -0
  171. package/dist/extensions/tools/runtime.d.ts +39 -0
  172. package/dist/extensions/tools/schemas.d.ts +845 -0
  173. package/dist/extensions/tools/task-progress.d.ts +217 -0
  174. package/dist/extensions/tools/team/agent-admission.d.ts +127 -0
  175. package/dist/extensions/tools/team/agent-check.d.ts +152 -0
  176. package/dist/extensions/tools/team/agent-controls.d.ts +55 -0
  177. package/dist/extensions/tools/team/agent-file.d.ts +28 -0
  178. package/dist/extensions/tools/team/agent-iteration-cap.d.ts +328 -0
  179. package/dist/extensions/tools/team/agent-names.d.ts +29 -0
  180. package/dist/extensions/tools/team/agent-node-placement.d.ts +160 -0
  181. package/dist/extensions/tools/team/agent-placement-queue.d.ts +199 -0
  182. package/dist/extensions/tools/team/agent-placement.d.ts +118 -0
  183. package/dist/extensions/tools/team/agent-reports.d.ts +53 -0
  184. package/dist/extensions/tools/team/agent-rounds.d.ts +666 -0
  185. package/dist/extensions/tools/team/agent-sandbox-executors.d.ts +79 -0
  186. package/dist/extensions/tools/team/agent-slot-gate.d.ts +186 -0
  187. package/dist/extensions/tools/team/agent-status.d.ts +84 -0
  188. package/dist/extensions/tools/team/agent-trouble.d.ts +91 -0
  189. package/dist/extensions/tools/team/background-delegations.d.ts +106 -0
  190. package/dist/extensions/tools/team/batch-report.d.ts +151 -0
  191. package/dist/extensions/tools/team/configured-agent-config.d.ts +37 -0
  192. package/dist/extensions/tools/team/configured-agent-tool.d.ts +135 -0
  193. package/dist/extensions/tools/team/create-agent-tool.d.ts +45 -0
  194. package/dist/extensions/tools/team/delegate-to-agent.d.ts +105 -0
  195. package/dist/extensions/tools/team/delegated-agent.d.ts +272 -0
  196. package/dist/extensions/tools/team/delegated-sandboxes.d.ts +125 -0
  197. package/dist/extensions/tools/team/delegated-tools.d.ts +40 -0
  198. package/dist/extensions/tools/team/delegation-call-hooks.d.ts +30 -0
  199. package/dist/extensions/tools/team/engine-evictions.d.ts +38 -0
  200. package/dist/extensions/tools/team/index.d.ts +20 -0
  201. package/dist/extensions/tools/team/lead-agent-tools.d.ts +92 -0
  202. package/dist/extensions/tools/team/multi-agent.d.ts +364 -0
  203. package/dist/extensions/tools/team/node-reachability.d.ts +53 -0
  204. package/dist/extensions/tools/team/node-throughput.d.ts +40 -0
  205. package/dist/extensions/tools/team/placed-run.d.ts +114 -0
  206. package/dist/extensions/tools/team/projections.d.ts +8 -0
  207. package/dist/extensions/tools/team/runtime.d.ts +6 -0
  208. package/dist/extensions/tools/team/session-window-retry.d.ts +28 -0
  209. package/dist/extensions/tools/team/spawn-agent-tool.d.ts +450 -0
  210. package/dist/extensions/tools/team/spawn-sampling.d.ts +188 -0
  211. package/dist/extensions/tools/team/spawn-swarm-tool.d.ts +330 -0
  212. package/dist/extensions/tools/team/subagent-cancellation.d.ts +188 -0
  213. package/dist/extensions/tools/team/subagent-layout.d.ts +90 -0
  214. package/dist/extensions/tools/team/subagent-output.d.ts +73 -0
  215. package/dist/extensions/tools/team/subagent-progress.d.ts +211 -0
  216. package/dist/extensions/tools/team/subagent-prompts.d.ts +3 -0
  217. package/dist/extensions/tools/team/team-state-dates.d.ts +10 -0
  218. package/dist/extensions/tools/team/team-tools.d.ts +56 -0
  219. package/dist/extensions/tools/team/teammates-off.d.ts +14 -0
  220. package/dist/extensions/tools/team/token-split.d.ts +28 -0
  221. package/dist/extensions/tools/team/turn-fault-recovery.d.ts +71 -0
  222. package/dist/extensions/tools/types.d.ts +410 -0
  223. package/dist/extensions/tools/video-generation.d.ts +94 -0
  224. package/dist/hooks/checkpoint-hooks.d.ts +39 -0
  225. package/dist/hooks/hook-extension.d.ts +2 -0
  226. package/dist/hooks/hook-file-config.d.ts +24 -0
  227. package/dist/hooks/hook-file-hooks.d.ts +22 -0
  228. package/dist/hooks/index.d.ts +5 -0
  229. package/dist/hooks/subprocess-runner.d.ts +21 -0
  230. package/dist/hooks/subprocess.d.ts +74 -0
  231. package/dist/hub/client/connect.d.ts +14 -0
  232. package/dist/hub/client/index.d.ts +146 -0
  233. package/dist/hub/client/managed-hub-build-watcher.d.ts +62 -0
  234. package/dist/hub/client/session-client.d.ts +138 -0
  235. package/dist/hub/client/ui-client.d.ts +52 -0
  236. package/dist/hub/daemon/entry.d.ts +15 -0
  237. package/dist/hub/daemon/entry.js +2033 -0
  238. package/dist/hub/daemon/index.d.ts +125 -0
  239. package/dist/hub/daemon/runtime-handlers.d.ts +12 -0
  240. package/dist/hub/daemon/shutdown-coordinator.d.ts +31 -0
  241. package/dist/hub/daemon/start-shared-server.d.ts +18 -0
  242. package/dist/hub/daemon/telemetry.d.ts +19 -0
  243. package/dist/hub/discovery/defaults.d.ts +16 -0
  244. package/dist/hub/discovery/index.d.ts +139 -0
  245. package/dist/hub/discovery/instance-lock.d.ts +51 -0
  246. package/dist/hub/discovery/workspace.d.ts +13 -0
  247. package/dist/hub/index.d.ts +38 -0
  248. package/dist/hub/index.js +2023 -0
  249. package/dist/hub/runtime-host/hub-runtime-host.d.ts +83 -0
  250. package/dist/hub/runtime-host/remote-runtime-host.d.ts +9 -0
  251. package/dist/hub/server/browser-websocket.d.ts +22 -0
  252. package/dist/hub/server/command-transport.d.ts +29 -0
  253. package/dist/hub/server/handlers/approval-handlers.d.ts +24 -0
  254. package/dist/hub/server/handlers/capability-handlers.d.ts +12 -0
  255. package/dist/hub/server/handlers/client-handlers.d.ts +6 -0
  256. package/dist/hub/server/handlers/connector-handlers.d.ts +20 -0
  257. package/dist/hub/server/handlers/context.d.ts +98 -0
  258. package/dist/hub/server/handlers/run-handlers.d.ts +6 -0
  259. package/dist/hub/server/handlers/run-queue-handlers.d.ts +33 -0
  260. package/dist/hub/server/handlers/session-event-projector.d.ts +7 -0
  261. package/dist/hub/server/handlers/session-handlers.d.ts +30 -0
  262. package/dist/hub/server/hub-client-contributions.d.ts +19 -0
  263. package/dist/hub/server/hub-event-log.d.ts +57 -0
  264. package/dist/hub/server/hub-notifications.d.ts +7 -0
  265. package/dist/hub/server/hub-run-queue.d.ts +82 -0
  266. package/dist/hub/server/hub-schedule-events.d.ts +2 -0
  267. package/dist/hub/server/hub-server-logging.d.ts +2 -0
  268. package/dist/hub/server/hub-server-options.d.ts +94 -0
  269. package/dist/hub/server/hub-server-transport.d.ts +71 -0
  270. package/dist/hub/server/hub-session-records.d.ts +9 -0
  271. package/dist/hub/server/hub-websocket-server.d.ts +12 -0
  272. package/dist/hub/server/index.d.ts +4 -0
  273. package/dist/hub/server/native-transport.d.ts +25 -0
  274. package/dist/hub/server/task-command-service.d.ts +11 -0
  275. package/dist/index.d.ts +172 -0
  276. package/dist/index.js +5435 -0
  277. package/dist/logging/early-logger.d.ts +37 -0
  278. package/dist/remote-config/integration.d.ts +17 -0
  279. package/dist/runtime/atomic/base-revision-reads.d.ts +106 -0
  280. package/dist/runtime/atomic/base-revision.d.ts +77 -0
  281. package/dist/runtime/atomic/check-first-edits.d.ts +79 -0
  282. package/dist/runtime/atomic/file-revisions.d.ts +268 -0
  283. package/dist/runtime/atomic/oracle.d.ts +178 -0
  284. package/dist/runtime/atomic/page-check.d.ts +39 -0
  285. package/dist/runtime/atomic/plan-capture.d.ts +40 -0
  286. package/dist/runtime/atomic/plan-text.d.ts +33 -0
  287. package/dist/runtime/atomic/plan-tool.d.ts +159 -0
  288. package/dist/runtime/atomic/proposal.d.ts +112 -0
  289. package/dist/runtime/atomic/propose-check-tool.d.ts +76 -0
  290. package/dist/runtime/atomic/protocol.d.ts +233 -0
  291. package/dist/runtime/atomic/restore-file-tool.d.ts +196 -0
  292. package/dist/runtime/atomic/revision-capture.d.ts +75 -0
  293. package/dist/runtime/atomic/run-check-tool.d.ts +64 -0
  294. package/dist/runtime/atomic/session-protocol.d.ts +304 -0
  295. package/dist/runtime/atomic/session-revisions.d.ts +77 -0
  296. package/dist/runtime/atomic/snapshot.d.ts +77 -0
  297. package/dist/runtime/atomic/stalled-checks.d.ts +106 -0
  298. package/dist/runtime/atomic/submit-transaction-tool.d.ts +50 -0
  299. package/dist/runtime/atomic/tool-activity.d.ts +15 -0
  300. package/dist/runtime/atomic/transaction-controller.d.ts +364 -0
  301. package/dist/runtime/atomic/unparseable-change.d.ts +35 -0
  302. package/dist/runtime/capabilities/index.d.ts +2 -0
  303. package/dist/runtime/capabilities/normalize-runtime-capabilities.d.ts +2 -0
  304. package/dist/runtime/capabilities/runtime-capabilities.d.ts +18 -0
  305. package/dist/runtime/config/agent-message-codec.d.ts +6 -0
  306. package/dist/runtime/config/agent-runtime-config-builder.d.ts +93 -0
  307. package/dist/runtime/config/connection-update.d.ts +40 -0
  308. package/dist/runtime/escalation/a2a.d.ts +109 -0
  309. package/dist/runtime/escalation/assessment.d.ts +54 -0
  310. package/dist/runtime/escalation/brief.d.ts +70 -0
  311. package/dist/runtime/escalation/escalate-tool.d.ts +93 -0
  312. package/dist/runtime/escalation/escalation-controller.d.ts +62 -0
  313. package/dist/runtime/escalation/escalation-session.d.ts +241 -0
  314. package/dist/runtime/escalation/expert-failure.d.ts +20 -0
  315. package/dist/runtime/escalation/expert-guards.d.ts +46 -0
  316. package/dist/runtime/escalation/expert-mailbox.d.ts +34 -0
  317. package/dist/runtime/escalation/expert-notes.d.ts +115 -0
  318. package/dist/runtime/escalation/expert-prompt.d.ts +29 -0
  319. package/dist/runtime/escalation/expert-revisions.d.ts +62 -0
  320. package/dist/runtime/escalation/expert-session.d.ts +164 -0
  321. package/dist/runtime/escalation/expert-transcript.d.ts +32 -0
  322. package/dist/runtime/escalation/forced-escalation.d.ts +58 -0
  323. package/dist/runtime/escalation/stand-down.d.ts +66 -0
  324. package/dist/runtime/escalation/struggle-offer.d.ts +100 -0
  325. package/dist/runtime/escalation/watch-tool.d.ts +34 -0
  326. package/dist/runtime/host/history.d.ts +19 -0
  327. package/dist/runtime/host/host.d.ts +7 -0
  328. package/dist/runtime/host/local/agent-event-bridge.d.ts +50 -0
  329. package/dist/runtime/host/local/session-record.d.ts +6 -0
  330. package/dist/runtime/host/local/session-service-invoker.d.ts +4 -0
  331. package/dist/runtime/host/local/spawn-tool.d.ts +57 -0
  332. package/dist/runtime/host/local/user-files.d.ts +1 -0
  333. package/dist/runtime/host/local-runtime-host.d.ts +298 -0
  334. package/dist/runtime/host/runtime-host-support.d.ts +39 -0
  335. package/dist/runtime/host/runtime-host.d.ts +280 -0
  336. package/dist/runtime/host/steer-side-turn.d.ts +119 -0
  337. package/dist/runtime/orchestration/runtime-builder.d.ts +14 -0
  338. package/dist/runtime/orchestration/runtime-event-adapter.d.ts +104 -0
  339. package/dist/runtime/orchestration/runtime-oauth-token-manager.d.ts +28 -0
  340. package/dist/runtime/orchestration/session-runtime-orchestrator.d.ts +339 -0
  341. package/dist/runtime/orchestration/session-runtime.d.ts +118 -0
  342. package/dist/runtime/orchestration/user-input-builder.d.ts +15 -0
  343. package/dist/runtime/process-start-token.d.ts +23 -0
  344. package/dist/runtime/safety/loop-detection.d.ts +160 -0
  345. package/dist/runtime/safety/mistake-tracker.d.ts +84 -0
  346. package/dist/runtime/safety/rules.d.ts +6 -0
  347. package/dist/runtime/safety/struggle-detector.d.ts +414 -0
  348. package/dist/runtime/safety/worker-struggle-stop.d.ts +20 -0
  349. package/dist/runtime/safety/worker-struggle.d.ts +166 -0
  350. package/dist/runtime/sandbox/agent-sandbox.d.ts +111 -0
  351. package/dist/runtime/sandbox/overlay-fs.d.ts +71 -0
  352. package/dist/runtime/sandbox/sandbox-binaries.d.ts +10 -0
  353. package/dist/runtime/tools/subprocess-sandbox-lifecycle.d.ts +9 -0
  354. package/dist/runtime/tools/subprocess-sandbox.d.ts +62 -0
  355. package/dist/runtime/tools/tool-approval.d.ts +9 -0
  356. package/dist/runtime/turn-queue/harness-notes.d.ts +18 -0
  357. package/dist/runtime/turn-queue/pending-prompt-service.d.ts +117 -0
  358. package/dist/services/agent-events.d.ts +59 -0
  359. package/dist/services/config.d.ts +2 -0
  360. package/dist/services/connectors/active-connectors.d.ts +2 -0
  361. package/dist/services/connectors/connector-autostart.d.ts +33 -0
  362. package/dist/services/connectors/connector-child-env.d.ts +14 -0
  363. package/dist/services/connectors/connector-cleanup.d.ts +20 -0
  364. package/dist/services/connectors/connector-supervisor.d.ts +134 -0
  365. package/dist/services/connectors/daemon-connector-reconnect.d.ts +15 -0
  366. package/dist/services/feature-flags/FeatureFlagsService.d.ts +49 -0
  367. package/dist/services/feature-flags/index.d.ts +2 -0
  368. package/dist/services/feature-flags/posthog.d.ts +24 -0
  369. package/dist/services/feature-flags/posthog.js +1 -0
  370. package/dist/services/feature-flags/providers.d.ts +7 -0
  371. package/dist/services/global-settings.d.ts +113 -0
  372. package/dist/services/llms/apihandler-agent-model-adapter.d.ts +26 -0
  373. package/dist/services/llms/cline-recommended-models.d.ts +62 -0
  374. package/dist/services/llms/configured-provider-registry.d.ts +27 -0
  375. package/dist/services/llms/handler-factory.d.ts +23 -0
  376. package/dist/services/llms/provider-defaults.d.ts +36 -0
  377. package/dist/services/llms/provider-settings.d.ts +420 -0
  378. package/dist/services/llms/runtime-config.d.ts +3 -0
  379. package/dist/services/llms/runtime-registry.d.ts +19 -0
  380. package/dist/services/llms/runtime-types.d.ts +84 -0
  381. package/dist/services/llms/session-budget.d.ts +88 -0
  382. package/dist/services/local-runtime-bootstrap.d.ts +62 -0
  383. package/dist/services/marketplace.d.ts +41 -0
  384. package/dist/services/mcp-install.d.ts +35 -0
  385. package/dist/services/plugin-install.d.ts +52 -0
  386. package/dist/services/plugin-mcp-settings.d.ts +31 -0
  387. package/dist/services/plugin-tools.d.ts +40 -0
  388. package/dist/services/plugin-uninstall.d.ts +13 -0
  389. package/dist/services/providers/local-provider-registry.d.ts +354 -0
  390. package/dist/services/providers/local-provider-service.d.ts +101 -0
  391. package/dist/services/providers/model-source.d.ts +3 -0
  392. package/dist/services/providers/provider-config-fields.d.ts +37 -0
  393. package/dist/services/providers/provider-readiness.d.ts +10 -0
  394. package/dist/services/session-artifacts.d.ts +18 -0
  395. package/dist/services/session-data.d.ts +61 -0
  396. package/dist/services/session-import/claude-code.d.ts +16 -0
  397. package/dist/services/session-import/codex.d.ts +34 -0
  398. package/dist/services/session-import/index.d.ts +6 -0
  399. package/dist/services/session-import/opencode.d.ts +25 -0
  400. package/dist/services/session-import/sanitize.d.ts +16 -0
  401. package/dist/services/session-import/service.d.ts +31 -0
  402. package/dist/services/session-import/types.d.ts +87 -0
  403. package/dist/services/session-telemetry.d.ts +15 -0
  404. package/dist/services/storage/file-team-store.d.ts +32 -0
  405. package/dist/services/storage/provider-settings-legacy-migration.d.ts +38 -0
  406. package/dist/services/storage/provider-settings-manager.d.ts +31 -0
  407. package/dist/services/storage/sqlite-session-store.d.ts +35 -0
  408. package/dist/services/storage/sqlite-team-store.d.ts +42 -0
  409. package/dist/services/storage/team-events-retention.d.ts +25 -0
  410. package/dist/services/storage/team-store.d.ts +16 -0
  411. package/dist/services/telemetry/ITelemetryAdapter.d.ts +54 -0
  412. package/dist/services/telemetry/OpenTelemetryAdapter.d.ts +43 -0
  413. package/dist/services/telemetry/OpenTelemetryProvider.d.ts +99 -0
  414. package/dist/services/telemetry/TelemetryLoggerSink.d.ts +27 -0
  415. package/dist/services/telemetry/TelemetryService.d.ts +40 -0
  416. package/dist/services/telemetry/core-events.d.ts +396 -0
  417. package/dist/services/telemetry/distinct-id.d.ts +2 -0
  418. package/dist/services/telemetry/index.d.ts +4 -0
  419. package/dist/services/telemetry/index.js +1 -0
  420. package/dist/services/usage.d.ts +19 -0
  421. package/dist/services/workspace/agent-schedules-workspace.d.ts +8 -0
  422. package/dist/services/workspace/chat-workspace.d.ts +9 -0
  423. package/dist/services/workspace/file-indexer.d.ts +5 -0
  424. package/dist/services/workspace/index.d.ts +6 -0
  425. package/dist/services/workspace/mention-enricher.d.ts +13 -0
  426. package/dist/services/workspace/workspace-manager.d.ts +27 -0
  427. package/dist/services/workspace/workspace-manifest.d.ts +42 -0
  428. package/dist/services/workspace/workspace-telemetry.d.ts +18 -0
  429. package/dist/session/checkpoint-diff.d.ts +25 -0
  430. package/dist/session/checkpoint-restore.d.ts +34 -0
  431. package/dist/session/display-messages.d.ts +28 -0
  432. package/dist/session/history-origin.d.ts +19 -0
  433. package/dist/session/models/session-compaction.d.ts +22 -0
  434. package/dist/session/models/session-graph.d.ts +15 -0
  435. package/dist/session/models/session-manifest.d.ts +32 -0
  436. package/dist/session/models/session-row.d.ts +107 -0
  437. package/dist/session/persisted-tool-result-content.d.ts +8 -0
  438. package/dist/session/search/index.d.ts +1 -0
  439. package/dist/session/search/session-history-search.d.ts +51 -0
  440. package/dist/session/services/file-session-service.d.ts +10 -0
  441. package/dist/session/services/message-builder.d.ts +208 -0
  442. package/dist/session/services/persistence-service.d.ts +92 -0
  443. package/dist/session/services/read-overlap.d.ts +40 -0
  444. package/dist/session/services/session-service.d.ts +15 -0
  445. package/dist/session/session-snapshot.d.ts +59 -0
  446. package/dist/session/session-versioning-service.d.ts +50 -0
  447. package/dist/session/stores/atomic-file.d.ts +1 -0
  448. package/dist/session/stores/conversation-store.d.ts +29 -0
  449. package/dist/session/stores/session-manifest-store.d.ts +49 -0
  450. package/dist/session/stores/team-persistence-store.d.ts +23 -0
  451. package/dist/session/team/index.d.ts +2 -0
  452. package/dist/session/team/team-child-session-manager.d.ts +35 -0
  453. package/dist/session/team/team-session-coordinator.d.ts +13 -0
  454. package/dist/session/user-run-messages.d.ts +20 -0
  455. package/dist/settings/index.d.ts +2 -0
  456. package/dist/settings/settings-service.d.ts +8 -0
  457. package/dist/settings/types.d.ts +83 -0
  458. package/dist/tasks/agenda-task-api.d.ts +20 -0
  459. package/dist/tasks/agenda-task-manager.d.ts +109 -0
  460. package/dist/tasks/agenda-task-tool.d.ts +94 -0
  461. package/dist/tasks/index.d.ts +9 -0
  462. package/dist/tasks/specs/task-spec-file-store.d.ts +38 -0
  463. package/dist/tasks/specs/task-spec-parser.d.ts +65 -0
  464. package/dist/tasks/store/sqlite-task-store.d.ts +73 -0
  465. package/dist/tasks/store/task-schema.d.ts +2 -0
  466. package/dist/tasks/task-location.d.ts +14 -0
  467. package/dist/tasks/task-tool.d.ts +143 -0
  468. package/dist/types/chat-schema.d.ts +194 -0
  469. package/dist/types/common.d.ts +35 -0
  470. package/dist/types/config.d.ts +994 -0
  471. package/dist/types/events.d.ts +102 -0
  472. package/dist/types/provider-settings.d.ts +29 -0
  473. package/dist/types/session.d.ts +187 -0
  474. package/dist/types/sessions.d.ts +42 -0
  475. package/dist/types/storage.d.ts +36 -0
  476. package/dist/types.d.ts +34 -0
  477. package/dist/version.d.ts +1 -0
  478. package/package.json +98 -0
  479. package/scripts/document-reader-assets.mjs +161 -0
@@ -0,0 +1,208 @@
1
+ /**
2
+ * API-safe message builder for provider payloads.
3
+ *
4
+ * @see PLAN.md §3.1 — moved from `packages/agents/src/context/message-builder.ts`.
5
+ * @see PLAN.md §3.2.3 — public surface of `MessageBuilder`.
6
+ *
7
+ * Walks the conversation to produce provider-ready messages, handling
8
+ * tool-result truncation and outdated-file-content rewrite for compaction.
9
+ * Per-instance caches make this host state.
10
+ */
11
+ import { type MediaBudgetOptions, type Message } from "@cerebriline/shared";
12
+ export declare const DEFAULT_MAX_TOOL_RESULT_CHARS = 32000;
13
+ export declare const DEFAULT_MAX_FILE_CONTENT_CHARS = 50000;
14
+ export declare const DEFAULT_MAX_TOTAL_TEXT_BYTES = 6000000;
15
+ export declare const DEFAULT_MAX_ASSISTANT_TEXT_CHARS = 200000;
16
+ export declare const DEFAULT_MAX_ASSISTANT_TOOL_MARKUP_CHARS = 12000;
17
+ export declare const DEFAULT_MIN_OUTDATED_REWRITE_BYTES = 65536;
18
+ /**
19
+ * Share of the context window the transcript must fill, as it would be sent,
20
+ * before stale reads are rewritten at all.
21
+ *
22
+ * A rewrite breaks the prefix cache from the first rewritten read onward, and
23
+ * every server this talks to caches prefixes. Rewriting whenever a small share
24
+ * was reclaimable made it routine: on pandorum 2026-09-26, 834 of 7,465
25
+ * builds rewrote a read a few turns back -- swarm agents re-reading the file
26
+ * they were editing, at a 5,243-byte threshold on a 65,536-token window --
27
+ * and opencoti measured 499k tokens re-prefilled behind those rewrites. Now a
28
+ * turn is a pure append until the transcript is large enough for the stale
29
+ * copies to matter, and then every pending one goes at once. Well under the
30
+ * compaction trigger, since tool schemas and the system prompt, which are not
31
+ * in the transcript, share the window.
32
+ */
33
+ export declare const OUTDATED_REWRITE_PRESSURE_SHARE = 0.4;
34
+ /**
35
+ * Transcript bytes, as sent, past which stale reads are rewritten -- or
36
+ * `undefined` when the window is unknown and the byte threshold decides.
37
+ */
38
+ export declare function resolveOutdatedRewritePressureBytes(contextWindowTokens: number | undefined): number | undefined;
39
+ /**
40
+ * Scale the stale-read rewrite threshold to the model's context window.
41
+ *
42
+ * Falls back to the fixed default when the window is unknown, so a caller that
43
+ * cannot say keeps the previous behaviour rather than guessing.
44
+ */
45
+ export declare function resolveMinOutdatedRewriteBytes(contextWindowTokens: number | undefined): number;
46
+ export declare const MESSAGE_BUILDER_LIMIT_ENV: {
47
+ readonly maxToolResultChars: "CLINE_MESSAGE_BUILDER_MAX_TOOL_RESULT_CHARS";
48
+ readonly maxTotalTextBytes: "CLINE_MESSAGE_BUILDER_MAX_TOTAL_TEXT_BYTES";
49
+ readonly minOutdatedRewriteBytes: "CLINE_MESSAGE_BUILDER_MIN_OUTDATED_REWRITE_BYTES";
50
+ };
51
+ export interface MessageBuilderOptions {
52
+ maxToolResultChars?: number;
53
+ maxFileContentChars?: number;
54
+ maxTotalTextBytes?: number;
55
+ mediaBudget?: MediaBudgetOptions;
56
+ maxAssistantTextChars?: number;
57
+ maxAssistantToolMarkupChars?: number;
58
+ minOutdatedRewriteBytes?: number;
59
+ /**
60
+ * The model's context window, in tokens. Scales the stale-read rewrite
61
+ * threshold; ignored when `minOutdatedRewriteBytes` is given explicitly.
62
+ */
63
+ contextWindowTokens?: number;
64
+ }
65
+ export declare function getMessageBuilderOptionsFromEnv(env?: Record<string, string | undefined>): MessageBuilderOptions;
66
+ /**
67
+ * Builds an API-safe message copy without mutating original conversation history.
68
+ */
69
+ export declare class MessageBuilder {
70
+ private indexedMessageCount;
71
+ private indexedTailRef;
72
+ private readonly toolNameByIdCache;
73
+ private readonly readLocatorsByToolUseIdCache;
74
+ private readonly readsByPathCache;
75
+ private readOrderCounter;
76
+ private readResultLocatorCache;
77
+ private readonly maxToolResultChars;
78
+ private readonly maxFileContentChars;
79
+ private readonly maxTotalTextBytes;
80
+ private readonly mediaBudget;
81
+ private readonly maxAssistantTextChars;
82
+ private readonly maxAssistantToolMarkupChars;
83
+ private readonly minOutdatedRewriteBytes;
84
+ /** Set when the window is known and no byte threshold was named. */
85
+ private readonly outdatedRewritePressureBytes;
86
+ private readonly committedOutdatedRewrites;
87
+ private readonly duplicateReadKeys;
88
+ constructor(options?: MessageBuilderOptions);
89
+ resetConversationState(): void;
90
+ buildForApi(messages: Message[]): Message[];
91
+ private transformBlock;
92
+ private reindex;
93
+ /** Commits pending stale-read rewrites once reclaimable bytes cross the threshold. */
94
+ private commitOutdatedRewrites;
95
+ /** Estimates reclaimable bytes for stale locators inside one tool-result block. */
96
+ private estimateOutdatedReclaimBytes;
97
+ private providerBoundEntryBytes;
98
+ private addMissingToolResults;
99
+ private appendMissingToolResults;
100
+ private shouldMergeUserAfterToolResults;
101
+ private contentBlocksForUserMerge;
102
+ private collectToolResultIds;
103
+ private isToolResultOnlyMessage;
104
+ private trackMissingToolCalls;
105
+ private createMissingToolResultMessage;
106
+ private createMissingToolResultBlocks;
107
+ private formatMissingToolResultText;
108
+ private resetIndexes;
109
+ private getReadLocators;
110
+ private extractLocatorsFromReadToolInput;
111
+ private extractReadLocatorsFromToolResultContent;
112
+ private tryParseReadLocators;
113
+ private extractLocatorsFromParsedReadResult;
114
+ private extractLocatorFromReadRequest;
115
+ private extractLocatorFromResultEntry;
116
+ private extractPath;
117
+ private extractLineNumber;
118
+ private parseReadQuery;
119
+ private dedupeReadLocators;
120
+ private toReadLocatorKey;
121
+ private isFullFileRead;
122
+ /**
123
+ * Whether a later read makes an earlier one redundant.
124
+ *
125
+ * A whole-file read covers every range of that file. A range covers another
126
+ * range only when it contains it, and never covers a whole-file read: the
127
+ * file has lines the range does not, and dropping the only copy of them to
128
+ * save bytes trades a correct transcript for a smaller one.
129
+ */
130
+ private readCovers;
131
+ /**
132
+ * A read is outdated when a *later* read covers it.
133
+ *
134
+ * The recency half is what the previous "latest full read owns the path"
135
+ * check got wrong: it compared owners by identity, so a whole-file read at
136
+ * turn 5 marked a ranged read at turn 20 as outdated — the newest content
137
+ * in the transcript was replaced by a placeholder pointing at an older
138
+ * copy, and the model was left reading the file it had already superseded.
139
+ */
140
+ private isOutdatedReadLocator;
141
+ /** Records one read of one path at the next transcript position. */
142
+ private noteIndexedRead;
143
+ /**
144
+ * Whether a read only repeats a range an earlier read already covers.
145
+ *
146
+ * The mirror of `isOutdatedReadLocator`: that one asks whether something
147
+ * newer replaced this read, this one asks whether something older already
148
+ * contains it. Both describe redundancy, but they are not interchangeable —
149
+ * the newest copy of a range is never stale, so a duplicate must be labelled
150
+ * as such rather than sent to look for a newer version that does not exist.
151
+ *
152
+ * Requires the equality witness to pass. Without proof that the overlapping
153
+ * lines are unchanged, an edit may have landed between the two reads, and
154
+ * then the contained read is the only fresh copy in the transcript —
155
+ * collapsing it would hand the model source that no longer exists. A read
156
+ * whose text could not be recovered is therefore never treated as a
157
+ * duplicate.
158
+ */
159
+ /**
160
+ * Which placeholder a rewritten read should carry.
161
+ *
162
+ * Duplicates are recorded during the same pass that decides staleness, so by
163
+ * rewrite time the classification is already made; anything not recorded as
164
+ * a duplicate is superseded.
165
+ */
166
+ private placeholderForKey;
167
+ /**
168
+ * Recover each read's rendered text, keyed by locator.
169
+ *
170
+ * Best-effort: a result that is not the JSON-entry shape yields nothing, and
171
+ * a read with no recoverable text is simply never eligible to be called a
172
+ * duplicate. Failing to find the text has to mean "cannot prove", never
173
+ * "assume equal".
174
+ */
175
+ private extractReadTextByLocator;
176
+ private isDuplicateReadLocator;
177
+ private replaceOutdatedReadContent;
178
+ private countOutdatedImageEntries;
179
+ private replaceOutdatedInString;
180
+ private replaceOutdatedReadEntry;
181
+ private isReadTool;
182
+ /**
183
+ * Tool results can outlive their paired tool_use block (compacted or
184
+ * imported histories), so fall back to the name carried on the result
185
+ * itself when the id lookup misses.
186
+ */
187
+ private resolveToolName;
188
+ private truncateToolResultContent;
189
+ /**
190
+ * Deep-truncates string values inside structured tool outputs (e.g.
191
+ * `ToolOperationResult[]` from run_commands/read_files), which carry the
192
+ * payload in untyped `{query, result, ...}` fields rather than text
193
+ * blocks. Image blocks are left intact so base64 payloads survive.
194
+ */
195
+ private truncateNestedStrings;
196
+ private truncateMiddle;
197
+ private truncateAssistantText;
198
+ private hasRepeatedToolCallMarkup;
199
+ private truncateToTotalTextBudget;
200
+ private countMessageTextBytes;
201
+ private collectTruncationCandidates;
202
+ private applyMediaBudget;
203
+ private resolveMediaBudget;
204
+ private applyMediaBudgetToBlock;
205
+ private applyMediaBudgetToToolResultEntry;
206
+ private limitNestedMedia;
207
+ private limitImageContent;
208
+ }
@@ -0,0 +1,92 @@
1
+ import type * as LlmsProviders from "@cerebriline/llms";
2
+ import type { AgentResult, BasicLogger } from "@cerebriline/shared";
3
+ import type { SubAgentEndContext, SubAgentStartContext } from "../../extensions/tools/team";
4
+ import type { HookEventPayload } from "../../hooks";
5
+ import { type SessionStatus, type TerminalSessionStatus } from "../../types/common";
6
+ import type { PersistedSessionUpdateInput, SessionMessagesArtifactUploader, SessionPersistenceAdapter } from "../../types/session";
7
+ import type { SessionCompactionState } from "../models/session-compaction";
8
+ import type { SessionRow } from "../models/session-row";
9
+ export type { PersistedSessionUpdateInput, SessionPersistenceAdapter };
10
+ export declare class UnifiedSessionPersistenceService {
11
+ private readonly adapter;
12
+ private readonly manifestStore;
13
+ private readonly teamChildren;
14
+ private static readonly STALE_REASON;
15
+ private static readonly STALE_SOURCE;
16
+ private static readonly TEAM_HEARTBEAT_LOG_INTERVAL_MS;
17
+ constructor(adapter: SessionPersistenceAdapter, options?: {
18
+ messagesArtifactUploader?: SessionMessagesArtifactUploader;
19
+ logger?: BasicLogger;
20
+ });
21
+ private toPersistedMessages;
22
+ ensureSessionsDir(): string;
23
+ writeSessionManifest(manifestPath: string, manifest: import("../models/session-manifest").SessionManifest): void;
24
+ readSessionManifest(sessionId: string): import("../models/session-manifest").SessionManifest | undefined;
25
+ createRootSessionWithArtifacts(input: import("../models/session-row").CreateRootSessionWithArtifactsInput): Promise<import("../models/session-row").RootSessionArtifacts>;
26
+ /**
27
+ * Move a session to `status`, and — when that status means the session is
28
+ * live — record the process it is live in.
29
+ *
30
+ * Only the process actually running a session moves it to a non-terminal
31
+ * status, so that write is the moment its ownership is known. Recording it
32
+ * matters because the row keeps whichever pid created it, and a resumed
33
+ * session runs in a different process than the one that opened it: after a
34
+ * host restart, the reconciler tested a pid belonging to the dead host,
35
+ * concluded the live session had failed, and re-marked it on every
36
+ * `listSessions` scan. The task then offered "Resume" forever — for a
37
+ * session that had in fact completed a dozen turns since — because the
38
+ * resume affordance is chosen from exactly this status.
39
+ *
40
+ * The same write clears the reconciler's death certificate from the
41
+ * metadata, so a session that turned out to be alive does not keep carrying
42
+ * the record of having been declared dead.
43
+ */
44
+ updateSessionStatus(sessionId: string, status: SessionStatus, exitCode?: number | null, pid?: number): Promise<{
45
+ updated: boolean;
46
+ endedAt?: string;
47
+ }>;
48
+ updateSession(input: {
49
+ sessionId: string;
50
+ prompt?: string | null;
51
+ metadata?: Record<string, unknown> | null;
52
+ title?: string | null;
53
+ }): Promise<{
54
+ updated: boolean;
55
+ }>;
56
+ queueSpawnRequest(event: HookEventPayload): Promise<void>;
57
+ upsertSubagentSession(input: import("../models/session-row").UpsertSubagentInput): Promise<string | undefined>;
58
+ upsertSubagentSessionFromHook(event: HookEventPayload): Promise<string | undefined>;
59
+ appendSubagentHookAudit(_subSessionId: string, event: HookEventPayload): Promise<void>;
60
+ persistSessionMessages(sessionId: string, messages: LlmsProviders.MessageWithMetadata[], systemPrompt?: string): Promise<void>;
61
+ readSessionCompactionState(sessionId: string): Promise<SessionCompactionState | undefined>;
62
+ persistSessionCompactionState(sessionId: string, state: SessionCompactionState): Promise<void>;
63
+ deleteSessionCompactionState(sessionId: string): Promise<void>;
64
+ applySubagentStatus(subSessionId: string, event: HookEventPayload): Promise<void>;
65
+ applySubagentStatusBySessionId(subSessionId: string, status: SessionStatus): Promise<void>;
66
+ applyStatusToRunningChildSessions(parentSessionId: string, status: TerminalSessionStatus): Promise<void>;
67
+ onTeamTaskStart(rootSessionId: string, agentId: string, message: string): Promise<void>;
68
+ onTeamTaskEnd(rootSessionId: string, agentId: string, status: SessionStatus, summary?: string, result?: AgentResult, messages?: LlmsProviders.MessageWithMetadata[]): Promise<void>;
69
+ onTeamTaskProgress(rootSessionId: string, agentId: string, progress: string, options?: {
70
+ kind?: "heartbeat" | "progress" | "text";
71
+ }): Promise<void>;
72
+ handleSubAgentStart(rootSessionId: string, context: SubAgentStartContext): Promise<void>;
73
+ handleSubAgentEnd(rootSessionId: string, context: SubAgentEndContext): Promise<void>;
74
+ private isPidAlive;
75
+ private reconcileDeadRunningSession;
76
+ listSessions(limit?: number): Promise<SessionRow[]>;
77
+ /**
78
+ * Lightweight, effectively unbounded listing of session ids + metadata
79
+ * (no manifest reads, no dead-session reconciliation). listSessions caps
80
+ * its scan at 2000 rows; callers that must see every row — e.g. import
81
+ * dedup markers — use this instead.
82
+ */
83
+ listSessionMetadata(limit?: number): Promise<Array<{
84
+ sessionId: string;
85
+ metadata?: Record<string, unknown>;
86
+ }>>;
87
+ reconcileDeadSessions(limit?: number): Promise<number>;
88
+ deleteSession(sessionId: string): Promise<{
89
+ deleted: boolean;
90
+ }>;
91
+ private deleteSessionCompactionStateIfExists;
92
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Deciding whether two reads of the same file saw the same text.
3
+ *
4
+ * Read results are rendered with line numbers — `" 80 | const x = 1"` — and
5
+ * the number is padded to the width of the widest line number *in that read*
6
+ * (see `file-read.ts`). So a read of lines 80-120 renders `" 80 | "` while a
7
+ * whole-file read of a 1000-line file renders `" 80 | "` for the same source
8
+ * line. Hashing the rendered text directly would therefore report "changed"
9
+ * for two reads that saw identical content, which is exactly backwards: the
10
+ * comparison would fail closed and nothing would ever be collapsed.
11
+ *
12
+ * Everything here works on the text *after* the delimiter, keyed by line
13
+ * number, so padding cannot influence the answer.
14
+ */
15
+ /**
16
+ * Parse a rendered read result into line number → source text.
17
+ *
18
+ * Lines that do not carry a number are skipped rather than guessed at: a read
19
+ * result also contains headers and truncation markers, and treating those as
20
+ * source would make two reads of the same range compare unequal purely because
21
+ * one of them was truncated somewhere else.
22
+ */
23
+ export declare function parseNumberedLines(content: string): Map<number, string>;
24
+ /**
25
+ * Whether two reads saw identical text everywhere their ranges overlap.
26
+ *
27
+ * This is the equality witness for collapsing a redundant read. The dangerous
28
+ * case is an edit landing between the two reads: then the later read is the
29
+ * fresh one and the earlier is stale, and collapsing in the wrong direction
30
+ * feeds the model source that no longer exists. Comparing the overlap turns
31
+ * "did the file change?" from an inference into a check — and it catches edits
32
+ * made outside the agent, which scanning the transcript for editor calls
33
+ * cannot.
34
+ *
35
+ * Returns false when the overlap is empty or when either side is missing a
36
+ * line the other has. Both are "cannot prove equal", and the caller must treat
37
+ * an unproven overlap as changed — the whole point is to never collapse on a
38
+ * guess.
39
+ */
40
+ export declare function readOverlapUnchanged(earlier: string, later: string, overlapStart: number, overlapEnd: number): boolean;
@@ -0,0 +1,15 @@
1
+ import type { BasicLogger } from "@cerebriline/shared";
2
+ import type { SqliteSessionStore } from "../../services/storage/sqlite-session-store";
3
+ import type { SessionMessagesArtifactUploader } from "../../types/session";
4
+ import { type CreateRootSessionInput } from "../models/session-row";
5
+ import { UnifiedSessionPersistenceService } from "./persistence-service";
6
+ export declare class CoreSessionService extends UnifiedSessionPersistenceService {
7
+ private readonly store;
8
+ constructor(store: SqliteSessionStore, options?: {
9
+ sessionArtifactsDir?: string;
10
+ messagesArtifactUploader?: SessionMessagesArtifactUploader;
11
+ logger?: BasicLogger;
12
+ });
13
+ createRootSession(input: CreateRootSessionInput): void;
14
+ }
15
+ export type { CreateRootSessionInput, CreateRootSessionWithArtifactsInput, RootSessionArtifacts, SessionRow, UpsertSubagentInput, } from "../models/session-row";
@@ -0,0 +1,59 @@
1
+ import type * as LlmsProviders from "@cerebriline/llms";
2
+ import type { CheckpointEntry } from "../hooks/checkpoint-hooks";
3
+ import type { SessionAccumulatedUsage } from "../runtime/host/runtime-host";
4
+ import type { SessionRecord } from "../types/sessions";
5
+ export interface CoreSessionCheckpointSnapshot {
6
+ enabled?: boolean;
7
+ latest?: CheckpointEntry;
8
+ history: CheckpointEntry[];
9
+ }
10
+ export interface CoreSessionSnapshot {
11
+ version: 1;
12
+ sessionId: string;
13
+ source: SessionRecord["source"];
14
+ status: SessionRecord["status"];
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ endedAt?: string | null;
18
+ exitCode?: number | null;
19
+ interactive: boolean;
20
+ workspace: {
21
+ cwd: string;
22
+ root: string;
23
+ };
24
+ model: {
25
+ providerId: string;
26
+ modelId: string;
27
+ };
28
+ capabilities: {
29
+ enableTools: boolean;
30
+ enableSpawn: boolean;
31
+ enableTeams: boolean;
32
+ };
33
+ lineage: {
34
+ parentSessionId?: string;
35
+ parentAgentId?: string;
36
+ agentId?: string;
37
+ conversationId?: string;
38
+ isSubagent: boolean;
39
+ };
40
+ team?: {
41
+ name: string;
42
+ };
43
+ prompt?: string;
44
+ metadata?: Record<string, unknown>;
45
+ artifacts?: {
46
+ messagesPath?: string;
47
+ };
48
+ messages?: LlmsProviders.MessageWithMetadata[];
49
+ usage?: SessionAccumulatedUsage;
50
+ aggregateUsage?: SessionAccumulatedUsage;
51
+ checkpoint?: CoreSessionCheckpointSnapshot;
52
+ }
53
+ export declare function createCoreSessionSnapshot(input: {
54
+ session: SessionRecord;
55
+ messages?: LlmsProviders.MessageWithMetadata[];
56
+ usage?: SessionAccumulatedUsage;
57
+ aggregateUsage?: SessionAccumulatedUsage;
58
+ }): CoreSessionSnapshot;
59
+ export declare function coreSessionSnapshotToRecord(snapshot: CoreSessionSnapshot): SessionRecord;
@@ -0,0 +1,50 @@
1
+ import type * as LlmsProviders from "@cerebriline/llms";
2
+ import type { CheckpointEntry, CheckpointMetadata } from "../hooks/checkpoint-hooks";
3
+ import type { RestoreSessionInput } from "../runtime/host/runtime-host";
4
+ import type { SessionRecord } from "../types/sessions";
5
+ import { type CheckpointRestorePlan, type WorktreeRestoreTransaction } from "./checkpoint-restore";
6
+ import { type CoreSessionSnapshot } from "./session-snapshot";
7
+ export type SessionVersioningErrorCode = "invalid_restore" | "session_not_found" | "session_messages_not_found";
8
+ export declare class SessionVersioningError extends Error {
9
+ readonly code: SessionVersioningErrorCode;
10
+ constructor(code: SessionVersioningErrorCode, message: string);
11
+ }
12
+ export interface SessionCheckpointRestoreContext {
13
+ sourceSession: SessionRecord;
14
+ sourceMessages?: LlmsProviders.MessageWithMetadata[];
15
+ sourceSnapshot: CoreSessionSnapshot;
16
+ plan: CheckpointRestorePlan;
17
+ restoredCheckpointMetadata?: CheckpointMetadata;
18
+ initialMessages: LlmsProviders.MessageWithMetadata[];
19
+ restoreMessages: boolean;
20
+ restoreWorkspace: boolean;
21
+ checkpointRunCount: number;
22
+ }
23
+ export interface SessionCheckpointRestoreResult<TStartResult = unknown> {
24
+ sessionId?: string;
25
+ startResult?: TStartResult;
26
+ messages?: LlmsProviders.MessageWithMetadata[];
27
+ checkpoint: CheckpointEntry;
28
+ sourceSnapshot: CoreSessionSnapshot;
29
+ restoredSnapshot?: CoreSessionSnapshot;
30
+ }
31
+ export interface SessionCheckpointRestoreInput<TRestoreStartInput, TStartInput, TStartResult> {
32
+ sessionId: string;
33
+ checkpointRunCount: number;
34
+ cwd?: string;
35
+ restore?: RestoreSessionInput["restore"];
36
+ start?: TRestoreStartInput;
37
+ getSession(sessionId: string): Promise<SessionRecord | undefined>;
38
+ readMessages(sessionId: string): Promise<LlmsProviders.MessageWithMetadata[]>;
39
+ buildStartInput?: (context: SessionCheckpointRestoreContext, start: TRestoreStartInput) => TStartInput | Promise<TStartInput>;
40
+ startSession?: (input: TStartInput) => Promise<TStartResult>;
41
+ getStartedSessionId?: (result: TStartResult) => string | undefined;
42
+ cleanupStartedSession?: (result: Awaited<TStartResult>) => Promise<void>;
43
+ readRestoredSession?: (sessionId: string) => Promise<SessionRecord | undefined>;
44
+ applyWorkspaceCheckpoint?: (cwd: string, checkpoint: CheckpointEntry) => Promise<void>;
45
+ beginWorkspaceRestoreTransaction?: (cwd: string) => Promise<WorktreeRestoreTransaction>;
46
+ retainCheckpointRefs?: (cwd: string, sessionId: string, history: CheckpointEntry[]) => Promise<void>;
47
+ }
48
+ export declare class SessionVersioningService {
49
+ restoreCheckpoint<TRestoreStartInput, TStartInput, TStartResult>(input: SessionCheckpointRestoreInput<TRestoreStartInput, TStartInput, TStartResult>): Promise<SessionCheckpointRestoreResult<TStartResult>>;
50
+ }
@@ -0,0 +1 @@
1
+ export declare function writeFileAtomic(path: string, contents: string): Promise<void>;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Per-session conversation transcript store.
3
+ *
4
+ * @see PLAN.md §3.1 — moved from `packages/agents/src/runtime/conversation-store.ts`.
5
+ * @see PLAN.md §3.2.3 — public surface of `ConversationStore`.
6
+ *
7
+ * Pure port of the old agents implementation. Owns the message list,
8
+ * conversation id, and "session started" gate that today's `Agent`
9
+ * class uses to decide when to fire `session_start` hooks.
10
+ */
11
+ import type { MessageWithMetadata } from "@cerebriline/shared";
12
+ /** Generate a fresh conversation id. Exported for reuse by `SessionRuntime`. */
13
+ export declare function createConversationId(): string;
14
+ export declare class ConversationStore {
15
+ private messages;
16
+ private conversationId;
17
+ private sessionStarted;
18
+ constructor(initialMessages?: readonly MessageWithMetadata[]);
19
+ getConversationId(): string;
20
+ getMessages(): MessageWithMetadata[];
21
+ appendMessage(message: MessageWithMetadata): void;
22
+ appendMessages(messages: readonly MessageWithMetadata[]): void;
23
+ replaceMessages(messages: readonly MessageWithMetadata[]): void;
24
+ resetForRun(): void;
25
+ clearHistory(): void;
26
+ restore(messages: readonly MessageWithMetadata[]): void;
27
+ isSessionStarted(): boolean;
28
+ markSessionStarted(): void;
29
+ }
@@ -0,0 +1,49 @@
1
+ import type * as LlmsProviders from "@cerebriline/llms";
2
+ import type { BasicLogger } from "@cerebriline/shared";
3
+ import { SessionArtifacts } from "../../services/session-artifacts";
4
+ import type { SessionMessagesArtifactUploader, SessionPersistenceAdapter } from "../../types/session";
5
+ import { type SessionCompactionState } from "../models/session-compaction";
6
+ import { type SessionManifest } from "../models/session-manifest";
7
+ import type { SessionRow } from "../models/session-row";
8
+ export declare class SessionManifestStore {
9
+ private readonly adapter;
10
+ private readonly messagesArtifactUploader?;
11
+ private readonly logger?;
12
+ readonly artifacts: SessionArtifacts;
13
+ constructor(adapter: SessionPersistenceAdapter, messagesArtifactUploader?: SessionMessagesArtifactUploader | undefined, logger?: BasicLogger | undefined);
14
+ ensureSessionsDir(): string;
15
+ initializeMessagesFile(row: SessionRow, path: string, startedAt: string): void;
16
+ writeSessionManifest(manifestPath: string, manifest: SessionManifest): void;
17
+ readSessionManifest(sessionId: string): SessionManifest | undefined;
18
+ /**
19
+ * Asynchronously read only the manifest `metadata.title`.
20
+ *
21
+ * The session-listing hot path needs nothing from the manifest except the
22
+ * title, but the manifest JSON can be large (it embeds metadata and prompt
23
+ * text). This reads the file off the event-loop thread and pulls the title
24
+ * out of the parsed JSON directly, skipping the full `SessionManifestSchema`
25
+ * (Zod) validation that `readSessionManifest` performs. On any error (missing
26
+ * file, malformed JSON, non-string title) it resolves to `undefined` so
27
+ * callers fall back to the row metadata/prompt title.
28
+ */
29
+ readSessionManifestTitle(sessionId: string): Promise<string | undefined>;
30
+ readManifestFile(sessionId: string): {
31
+ path: string;
32
+ manifest?: SessionManifest;
33
+ };
34
+ /**
35
+ * Resolve the session row backing a message write, re-adopting it from the
36
+ * on-disk manifest when the DB row is missing (session artifacts restored
37
+ * or copied while the session DB was rebuilt). Sessions with neither a row
38
+ * nor a manifest throw so message writes cannot silently recreate
39
+ * orphaned session files.
40
+ */
41
+ private resolveSessionRow;
42
+ persistSessionMessages(sessionId: string, messages: LlmsProviders.MessageWithMetadata[], systemPrompt?: string): Promise<void>;
43
+ private resolveCompactionPath;
44
+ private updateCompactionPath;
45
+ readSessionCompactionState(sessionId: string): Promise<SessionCompactionState | undefined>;
46
+ persistSessionCompactionState(sessionId: string, state: SessionCompactionState): Promise<void>;
47
+ deleteSessionCompactionState(sessionId: string): Promise<void>;
48
+ appendStaleSessionHookLog(detectedAt: string, sessionId: string, pid: number, reason: string, source: string): void;
49
+ }
@@ -0,0 +1,23 @@
1
+ import type { TeamTeammateSpec } from "@cerebriline/shared";
2
+ import type { AgentTeamsRuntime, TeamEvent } from "../../extensions/tools/team";
3
+ import { type TeamRuntimeState } from "../models/session-row";
4
+ export interface FileTeamPersistenceStoreOptions {
5
+ teamName: string;
6
+ baseDir?: string;
7
+ }
8
+ export declare class FileTeamPersistenceStore {
9
+ private readonly dirPath;
10
+ private readonly statePath;
11
+ private readonly taskHistoryPath;
12
+ private readonly teammateSpecs;
13
+ constructor(options: FileTeamPersistenceStoreOptions);
14
+ loadState(): TeamRuntimeState | undefined;
15
+ getTeammateSpecs(): TeamTeammateSpec[];
16
+ upsertTeammateSpec(spec: TeamTeammateSpec): void;
17
+ removeTeammateSpec(agentId: string): void;
18
+ persist(runtime: AgentTeamsRuntime): void;
19
+ appendTaskHistory(event: TeamEvent): void;
20
+ private ensureDir;
21
+ private hasPersistableState;
22
+ private clearPersistedState;
23
+ }
@@ -0,0 +1,2 @@
1
+ export { TeamChildSessionManager } from "./team-child-session-manager";
2
+ export { buildTeamRunContinuationPrompt, dispatchTeamEventToBackend, emitTeamProgress, formatModePrompt, hasPendingTeamRunWork, notifyTeamRunWaiters, shouldAutoContinueTeamRuns, trackTeamRunState, waitForTeamRunUpdates, } from "./team-session-coordinator";
@@ -0,0 +1,35 @@
1
+ import type * as LlmsProviders from "@cerebriline/llms";
2
+ import type { AgentResult } from "@cerebriline/shared";
3
+ import type { SubAgentEndContext, SubAgentStartContext } from "../../extensions/tools/team";
4
+ import type { HookEventPayload } from "../../hooks";
5
+ import { type SessionStatus, type TerminalSessionStatus } from "../../types/common";
6
+ import type { SessionPersistenceAdapter, StoredMessageWithMetadata } from "../../types/session";
7
+ import type { UpsertSubagentInput } from "../models/session-row";
8
+ import type { SessionManifestStore } from "../stores/session-manifest-store";
9
+ export declare class TeamChildSessionManager {
10
+ private readonly adapter;
11
+ private readonly manifestStore;
12
+ private readonly toPersistedMessages;
13
+ private readonly heartbeatLogIntervalMs;
14
+ private readonly teamTaskSessionsByAgent;
15
+ private readonly teamTaskLastHeartbeatBySession;
16
+ private readonly teamTaskLastProgressLineBySession;
17
+ constructor(adapter: SessionPersistenceAdapter, manifestStore: SessionManifestStore, toPersistedMessages: (messages: LlmsProviders.MessageWithMetadata[] | undefined, result?: AgentResult, previousMessages?: LlmsProviders.MessageWithMetadata[]) => StoredMessageWithMetadata[] | undefined, heartbeatLogIntervalMs: number);
18
+ private teamTaskQueueKey;
19
+ private activeTeamTaskSessionId;
20
+ private buildSubsessionRow;
21
+ queueSpawnRequest(event: HookEventPayload): Promise<void>;
22
+ upsertSubagentSession(input: UpsertSubagentInput): Promise<string | undefined>;
23
+ upsertSubagentSessionFromHook(event: HookEventPayload): Promise<string | undefined>;
24
+ applySubagentStatus(subSessionId: string, event: HookEventPayload): Promise<void>;
25
+ applySubagentStatusBySessionId(subSessionId: string, status: SessionStatus): Promise<void>;
26
+ applyStatusToRunningChildSessions(parentSessionId: string, status: TerminalSessionStatus): Promise<void>;
27
+ onTeamTaskStart(rootSessionId: string, agentId: string, message: string): Promise<void>;
28
+ onTeamTaskEnd(rootSessionId: string, agentId: string, status: SessionStatus, _summary?: string, result?: AgentResult, messages?: LlmsProviders.MessageWithMetadata[]): Promise<void>;
29
+ onTeamTaskProgress(rootSessionId: string, agentId: string, progress: string, options?: {
30
+ kind?: "heartbeat" | "progress" | "text";
31
+ }): Promise<void>;
32
+ handleSubAgentStart(rootSessionId: string, context: SubAgentStartContext): Promise<void>;
33
+ handleSubAgentEnd(rootSessionId: string, context: SubAgentEndContext): Promise<void>;
34
+ appendSubagentHookAudit(event: HookEventPayload): void;
35
+ }
@@ -0,0 +1,13 @@
1
+ import { type AgentMode, type AgentResult } from "@cerebriline/shared";
2
+ import type { TeamEvent } from "../../extensions/tools/team";
3
+ import type { CoreSessionEvent } from "../../types/events";
4
+ import type { ActiveSession, TeamRunUpdate } from "../../types/session";
5
+ export declare function trackTeamRunState(session: ActiveSession, event: TeamEvent): void;
6
+ export declare function dispatchTeamEventToBackend(rootSessionId: string, event: TeamEvent, invokeOptional: (method: string, ...args: unknown[]) => Promise<void>): Promise<void>;
7
+ export declare function emitTeamProgress(session: ActiveSession, rootSessionId: string, event: TeamEvent, emit: (event: CoreSessionEvent) => void): void;
8
+ export declare function hasPendingTeamRunWork(session: ActiveSession): boolean;
9
+ export declare function shouldAutoContinueTeamRuns(session: ActiveSession, finishReason: AgentResult["finishReason"]): boolean;
10
+ export declare function notifyTeamRunWaiters(session: ActiveSession): void;
11
+ export declare function waitForTeamRunUpdates(session: ActiveSession): Promise<TeamRunUpdate[]>;
12
+ export declare function buildTeamRunContinuationPrompt(session: ActiveSession, updates: TeamRunUpdate[]): string;
13
+ export declare function formatModePrompt(prompt: string, mode: AgentMode | undefined): string;
@@ -0,0 +1,20 @@
1
+ export type MessageDisplayRole = "user" | "assistant" | "tool" | "system" | "status" | "error";
2
+ type MessageLike = {
3
+ role?: unknown;
4
+ content?: unknown;
5
+ metadata?: unknown;
6
+ };
7
+ /** Resolves the role a persisted message should use when presented to a user. */
8
+ export declare function resolveMessageDisplayRole(message: MessageLike): MessageDisplayRole;
9
+ /**
10
+ * Returns how many absolute root runs a persisted message represents.
11
+ *
12
+ * Compaction can fold several earlier user turns into one synthetic message.
13
+ * Its persisted span keeps later visible prompts aligned with checkpoint
14
+ * history. Tool results and system-injected user-role messages contribute no
15
+ * runs.
16
+ */
17
+ export declare function getUserRunSpan(message: MessageLike): number;
18
+ export declare function isUserRunMessage(message: MessageLike): boolean;
19
+ export declare function countUserRunMessages(messages: readonly MessageLike[] | undefined): number;
20
+ export {};
@@ -0,0 +1,2 @@
1
+ export { CoreSettingsService, createCoreSettingsService, } from "./settings-service";
2
+ export type { ClineCoreSettingsApi, CorePluginContributions, CorePluginSettingsSnapshot, CorePluginSettingsSource, CoreSettingsItem, CoreSettingsItemKind, CoreSettingsItemSource, CoreSettingsListInput, CoreSettingsMutationResult, CoreSettingsServiceOptions, CoreSettingsSnapshot, CoreSettingsToggleInput, CoreSettingsType, } from "./types";