@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,608 @@
1
+ import type { ModelInfo, ReasoningHistoryMode, ToolResultContent } from "@cerebriline/llms";
2
+ import { resolveDefaultMaxOutputTokens } from "@cerebriline/llms";
3
+ import { CHARS_PER_TOKEN, estimateThinkingTokens, estimateTokens, type MessageWithMetadata } from "@cerebriline/shared";
4
+ export { CHARS_PER_TOKEN, estimateThinkingTokens, estimateTokens };
5
+ import type { CoreCompactionSummarizerConfig } from "../../types/config";
6
+ import type { ProviderConfig } from "../../types/provider-settings";
7
+ import type { ToolLedgerEntry } from "./tool-ledger";
8
+ export declare const DEFAULT_MAX_INPUT_TOKENS = 128000;
9
+ /** Estimate the usable input share when only a context window is reported. */
10
+ export declare const CONTEXT_WINDOW_INPUT_RATIO = 0.9;
11
+ /** Compact once the transcript consumes this share of the usable input budget. */
12
+ export declare const COMPACTION_TRIGGER_RATIO = 0.9;
13
+ export declare const DEFAULT_TARGET_RATIO = 0.7;
14
+ export declare const DEFAULT_PRESERVE_RECENT_TOKENS = 20000;
15
+ /**
16
+ * The recency floor for a given window.
17
+ *
18
+ * `DEFAULT_PRESERVE_RECENT_TOKENS` was a single number applied to every model,
19
+ * which is right for exactly one window size. Measured against the two ends it
20
+ * has to serve: on a 32k window it asks to preserve more than the compaction
21
+ * target, so compaction can reclaim nothing; on a 1M window it throws away
22
+ * everything but the last few turns of a task with room for forty times that.
23
+ */
24
+ export declare function resolvePreserveRecentTokens(input: {
25
+ contextWindow?: number;
26
+ maxInputTokens?: number;
27
+ messageTargetTokens?: number;
28
+ override?: number;
29
+ }): number;
30
+ /** Floor for a compaction summary, and the cap when no window is known. */
31
+ export declare const DEFAULT_SUMMARY_MAX_OUTPUT_TOKENS = 4096;
32
+ /**
33
+ * Ceiling for a compaction summary, however much window is free.
34
+ *
35
+ * A summary is the whole of what survives the messages it replaces, so it is
36
+ * worth spending real tokens on -- but it also becomes the context every later
37
+ * turn carries, so it cannot be allowed to grow into the space compaction just
38
+ * freed. This is the point past which a longer summary stops being a better one.
39
+ */
40
+ export declare const MAX_SUMMARY_OUTPUT_TOKENS = 8192;
41
+ /** Share of the usable input budget a summary may occupy. */
42
+ export declare const SUMMARY_OUTPUT_WINDOW_SHARE = 0.08;
43
+ export declare const TOOL_RESULT_CHAR_LIMIT = 2000;
44
+ export declare const FILE_CONTENT_CHAR_LIMIT = 2000;
45
+ export declare const MIN_TRUNCATED_MESSAGE_TOKENS = 8;
46
+ export declare function resolveSummaryMaxOutputTokens(maxInputTokens: number | undefined): number;
47
+ export interface CompactionOutputBudgets {
48
+ /** Generation of the compaction being written, 1-based. */
49
+ generation: number;
50
+ /** Summary and retrospective together. */
51
+ combinedTokens: number;
52
+ summaryMaxTokens: number;
53
+ }
54
+ export declare function resolveCompactionOutputBudgets(input: {
55
+ messageTargetTokens?: number;
56
+ maxInputTokens?: number;
57
+ generation?: number;
58
+ }): CompactionOutputBudgets;
59
+ /**
60
+ * What is left for the retrospective once the summary has been written.
61
+ *
62
+ * Measured against what the summary actually cost, not what it was allowed:
63
+ * the point of writing them in this order is that an economical summary buys
64
+ * the retrospective room rather than wasting it.
65
+ */
66
+ export declare function resolveThinkingSummaryMaxTokens(input: {
67
+ budgets: CompactionOutputBudgets;
68
+ summaryTokens: number;
69
+ }): number;
70
+ export { resolveDefaultMaxOutputTokens };
71
+ /**
72
+ * What one message costs in the context as the provider will receive it.
73
+ *
74
+ * The index comes along because the answer depends on position: under a
75
+ * `reasoningHistory` of `last` only the final assistant turn still carries its
76
+ * reasoning, and a measurer handed a message on its own cannot know whether it
77
+ * is that one.
78
+ */
79
+ export type MeasureContextTokens = (message: MessageWithMetadata, index: number) => number;
80
+ /**
81
+ * What this session's turns have actually cost, as a basis for how much of the
82
+ * window to hold back for the next one.
83
+ *
84
+ * The two models this was measured on want opposite things. One answers a tool
85
+ * call in 24 to 2,164 output tokens and never reasons at length: holding 32,000
86
+ * tokens back for it spends a fifth of the window on nothing. The other opens
87
+ * 35,000 to 45,000 characters of thinking on most turns, around 17,000 tokens,
88
+ * and a reservation sized for the first model would put it into overflow
89
+ * recovery repeatedly. No single fraction serves both, and the transcript
90
+ * already says which one is running.
91
+ *
92
+ * The high-water mark of the recent window rather than the mean: the reservation
93
+ * exists for the largest turn, and an average over a session that thinks on one
94
+ * turn in four describes none of them.
95
+ *
96
+ * **Measured from the transcript, never from the bill.** `metrics.outputTokens`
97
+ * is what the provider charged for generating the turn, and a turn whose
98
+ * reasoning has since been condensed away is still carrying its original
99
+ * invoice. Measured on pandorum 2026-09-19: a capped think billed 30,786 tokens
100
+ * and was replaced with a 624-character note the same second, and the bill went
101
+ * on reserving half a 65,536-token window for the next twelve turns -- pinning
102
+ * the trigger to its 50% floor while the turns that followed produced 130 and
103
+ * 144 tokens. `measure` is the caller's estimator for what a message costs in
104
+ * the context as it stands, which is the question the reservation is asking.
105
+ */
106
+ export declare function resolveObservedOutputTokens(messages: readonly MessageWithMetadata[], measure: MeasureContextTokens, sampleTurns?: number): number | undefined;
107
+ /**
108
+ * The largest prompt that still leaves the model room to answer.
109
+ *
110
+ * The trigger used to ask only whether the prompt fit. It does not follow that
111
+ * a reply fits: a turn needs the prompt *and* its output inside one window, and
112
+ * the output cap is up to `maxTokens`. Measured live on a 110,000-token window
113
+ * with a 32,000 cap -- the transcript was allowed to 99,000, the request path
114
+ * then found 11,000 short of what it needed and sent no cap at all, and the turn
115
+ * died on the output limit with compaction still reporting there was room.
116
+ *
117
+ * Taking the smaller of the two keeps the old ratio as an upper bound while
118
+ * making room for a full turn the binding constraint, which is what it is.
119
+ */
120
+ /**
121
+ * The tokens held back for the next reply, sized to this session's own turns.
122
+ *
123
+ * Extracted from {@link resolveCompactionTriggerTokens} so the two readers of
124
+ * this number cannot drift apart. The trigger asks it *before* a turn -- how
125
+ * much of the window must stay free -- and the starved-cap check asks it
126
+ * *after* one, against the cap the request path actually resolved. A second
127
+ * figure for the same quantity is the disagreement this file exists to end.
128
+ *
129
+ * The declared room comes from the gateway rather than being restated here: it
130
+ * synthesizes a cap in exactly this situation, and that default is a share of
131
+ * the window, so the flat 32,000 this used to be under-reserved on every window
132
+ * wider than 128k.
133
+ */
134
+ export declare function resolveOutputRoomTokens(input: {
135
+ contextWindow?: number;
136
+ modelMaxTokens?: number;
137
+ observedOutputTokens?: number;
138
+ }): number;
139
+ export declare function resolveCompactionTriggerTokens(input: {
140
+ maxInputTokens: number;
141
+ contextWindow?: number;
142
+ modelMaxTokens?: number;
143
+ /** The high-water output of recent turns, from {@link resolveObservedOutputTokens}. */
144
+ observedOutputTokens?: number;
145
+ }): number;
146
+ export interface FileOperationSummary {
147
+ readFiles: string[];
148
+ modifiedFiles: string[];
149
+ }
150
+ export interface CompactionSummaryMetadata {
151
+ kind: "compaction_summary";
152
+ displayRole: "system";
153
+ userRunSpan: number;
154
+ summary: string;
155
+ details: FileOperationSummary;
156
+ tokensBefore: number;
157
+ generatedAt: number;
158
+ /**
159
+ * How many compactions this summary is the product of, 1-based.
160
+ *
161
+ * Carried on the message because it is the only durable record of it: the
162
+ * summary chains through its own metadata, and the output budget ladder is
163
+ * indexed by this number.
164
+ */
165
+ generation: number;
166
+ /** The retrospective written alongside this summary, if there was one. */
167
+ thinkingSummary?: string;
168
+ /**
169
+ * The harness's record of the calls this summary stands for. Read by the
170
+ * chat row, and by the next compaction through `toolLedgerEntries`.
171
+ */
172
+ toolLedger?: string;
173
+ /**
174
+ * The same record, structured, so the next generation can carry it.
175
+ *
176
+ * A ledger used to live for exactly one generation, on the reasoning that
177
+ * anything fed back accumulates without bound. That is true of prose and
178
+ * false of a record: a record can be evicted, and `evictToolLedger` does
179
+ * it in the order that keeps what cannot be recovered. What the one-shot
180
+ * rule cost was the standing evidence -- after a compaction the model no
181
+ * longer knew it had a checker to run, and went back to declaring the work
182
+ * done on a reading of the source.
183
+ */
184
+ toolLedgerEntries?: ToolLedgerEntry[];
185
+ /**
186
+ * Everything the user actually typed, verbatim, oldest first.
187
+ *
188
+ * Written by the harness and never by the model, which is the whole point.
189
+ * The prompt asks for the instructions word for word and the model
190
+ * paraphrases them, and from the second generation the only copy left is
191
+ * the paraphrase inside the previous summary -- so each compaction
192
+ * paraphrases a paraphrase. Measured on pandorum session
193
+ * 1789852877349_7bbnd, where a request naming the command to run came back
194
+ * as "The user is asking me to fix the collision in `manic_miner.html`"
195
+ * and the model never ran the command again.
196
+ *
197
+ * Never evicted. It is small, and it is the one thing in a transcript that
198
+ * exists nowhere else once the messages are gone.
199
+ */
200
+ userRequests?: string[];
201
+ }
202
+ export type EstimateMessageTokens = (message: MessageWithMetadata) => number;
203
+ /**
204
+ * Measures the request a transcript would produce, for reporting.
205
+ *
206
+ * Distinct from `EstimateMessageTokens`, which sums whole serialized messages
207
+ * and so counts reasoning the provider is not sent and metadata that never
208
+ * leaves the host. That sum is the right input for a cut decision, where the
209
+ * comparison is between two transcripts measured the same way, and the wrong
210
+ * one for a number shown beside the context meter.
211
+ */
212
+ export type MeasureReportedTokens = (messages: readonly MessageWithMetadata[]) => number;
213
+ /**
214
+ * Resolve the model's usable prompt budget. A reported input limit is
215
+ * authoritative but cannot exceed the context window. When the model only
216
+ * reports a context window, retain a conservative margin for request overhead.
217
+ */
218
+ export declare function resolveEffectiveMaxInputTokens(input: Pick<ModelInfo, "maxInputTokens" | "contextWindow">): number | undefined;
219
+ export declare function truncateText(text: string, limit: number): string;
220
+ /**
221
+ * The tool outputs that carry no `type` discriminator.
222
+ *
223
+ * `read_files`, `run_commands` and `search_codebase` answer with
224
+ * `ToolOperationResult` objects -- `{query, result, success, error?}` -- and
225
+ * `toPersistedToolResultContent` stores them in the same array as text and
226
+ * file blocks, because the persisted codec "accepts a wider runtime value set
227
+ * than the public `ToolResultContent` type describes". Anything here that
228
+ * switches on `block.type` alone therefore has to say what it does with the
229
+ * rest, and returning "" is the wrong answer: it blanked 50 of the 99 tool
230
+ * results in one measured pandorum session -- 414,337 characters, every file
231
+ * read and all three of the checker's verdicts among them. The summarizer saw
232
+ * a call followed by nothing and filled the gap with what it assumed had
233
+ * happened, so a session whose checker returned `ok:false` three times was
234
+ * summarised as "the game is running" and the next context believed it.
235
+ */
236
+ export interface StructuredToolResultEntry {
237
+ query?: unknown;
238
+ result?: unknown;
239
+ success?: unknown;
240
+ error?: unknown;
241
+ }
242
+ export declare function asStructuredToolResultEntry(block: unknown): StructuredToolResultEntry | undefined;
243
+ export declare function flattenToolResultContent(content: ToolResultContent["content"]): string;
244
+ export declare function truncateToolResultContentForCompaction(content: ToolResultContent["content"]): ToolResultContent["content"];
245
+ export declare function formatToolInput(input: Record<string, unknown>): string;
246
+ export declare function serializeMessage(message: MessageWithMetadata): string;
247
+ /**
248
+ * Render the discarded reasoning against what it produced.
249
+ *
250
+ * The retrospective's whole value is the pairing. Reasoning on its own reads as
251
+ * a plan and every plan reads as sound; it is the outcome next to it that shows
252
+ * which ones were. So each turn is one block: what the model thought, what it
253
+ * then called, and how that call came back -- applied, refused as a no-op,
254
+ * failed, or refused by the loop guard.
255
+ *
256
+ * Tool results are reduced to their verdict rather than included. A retrospective
257
+ * about method has no use for the contents of a file, and on the transcripts this
258
+ * was built against the results are most of the bytes.
259
+ */
260
+ export declare function serializeReasoningWithOutcomes(messages: MessageWithMetadata[]): string;
261
+ export declare function serializeConversation(messages: MessageWithMetadata[]): string;
262
+ export declare function createTokenEstimator(): EstimateMessageTokens;
263
+ export declare function isCompactionSummaryMessage(message: MessageWithMetadata): boolean;
264
+ /**
265
+ * The compaction from which the recency tail is dropped anyway, counting from
266
+ * 1. Zero -- the default -- never drops it, so the tail policy is whatever
267
+ * `keepRecentMessages` says and does not change part-way through a run.
268
+ *
269
+ * This was 2, and that was a mistake worth recording rather than quietly
270
+ * deleting. It meant no session ever ran a single tail policy: the first
271
+ * compaction kept the tail and every later one dropped it. Two consequences
272
+ * followed, both measured.
273
+ *
274
+ * The first compaction became the weak one by construction -- over 30 first
275
+ * and 24 later compactions on pandorum, a median -30% leaving 20 messages
276
+ * against -65% leaving 4. A run then refilled to the trigger within a median
277
+ * of 12 turns and took a second compaction, which is the one the fix rate
278
+ * falls off (85% / 63% / 50% / 25% by compaction count over 335 runs).
279
+ *
280
+ * The second is that it made its own evidence unreadable. The v6 A/B that
281
+ * appeared to justify the ladder ran `--force-full-from-compaction 2` in both
282
+ * arms, so "keep" meant keep-once-then-drop and "drop" meant drop-always. That
283
+ * is not a contrast between keeping and dropping a tail, and it duly separated
284
+ * nothing on the verdict. Whatever the right tail policy is, it has to be one
285
+ * policy for a whole run before any arm can measure it.
286
+ *
287
+ * The override survives for anyone who wants the old behaviour deliberately;
288
+ * it is no longer the default. The no-tail *fallback* is unaffected -- a
289
+ * compaction that keeps the tail and still lands over the trigger retries
290
+ * without it, which is a rescue and not a schedule.
291
+ */
292
+ export declare const FORCE_FULL_FROM_COMPACTION = 0;
293
+ /**
294
+ * Whether this compaction keeps nothing, whatever `keepRecentMessages` says.
295
+ *
296
+ * `from` is the compaction index it starts at: `1` drops the tail on every
297
+ * compaction, and anything below `1` never does. Unset takes the measured
298
+ * default above.
299
+ */
300
+ export declare function dropsTailAtThisCompaction(messages: readonly MessageWithMetadata[], from: number | undefined): boolean;
301
+ export declare function getCompactionSummaryMetadata(message: MessageWithMetadata): CompactionSummaryMetadata | undefined;
302
+ export declare function isToolResultOnlyUserMessage(message: MessageWithMetadata): boolean;
303
+ export declare function isTurnStartMessage(message: MessageWithMetadata): boolean;
304
+ /**
305
+ * What the user typed, verbatim, in the order they typed it.
306
+ *
307
+ * Turn-start messages only, so a tool result and a summary the harness wrote
308
+ * are both excluded. Consecutive duplicates collapse: a resend of the same
309
+ * instruction is the same instruction.
310
+ */
311
+ /** The most any single quoted request may take before its middle is cut. */
312
+ export declare const MAX_USER_REQUEST_CHARS = 2000;
313
+ export declare function collectUserRequests(messages: readonly MessageWithMetadata[]): string[];
314
+ export declare function findFirstUserMessageIndex(messages: MessageWithMetadata[]): number;
315
+ export declare function findLastTurnStartIndex(messages: MessageWithMetadata[]): number;
316
+ export declare function findLastAssistantIndex(messages: MessageWithMetadata[]): number;
317
+ export declare function findLatestSummaryIndex(messages: MessageWithMetadata[]): number;
318
+ /**
319
+ * The share of the material after a pinned prompt that a compaction folds when
320
+ * the prompt-preservation cap would otherwise leave it nothing to do.
321
+ *
322
+ * A fraction rather than a token count, deliberately. Every absolute threshold
323
+ * in this pipeline is only as trustworthy as the token estimator feeding it,
324
+ * and that estimator drifts by multiples. "Half of what follows the prompt" is
325
+ * half of what follows the prompt no matter how the counting drifts, because
326
+ * the bias appears in both sides of the ratio and cancels.
327
+ */
328
+ export declare const PINNED_PROMPT_FOLD_RATIO = 0.5;
329
+ /**
330
+ * The share of a transcript's messages the preserved tail should reach before
331
+ * the token floor alone is allowed to end the walk.
332
+ *
333
+ * A token floor on its own says nothing about how much *conversation* survives,
334
+ * and the two come apart when messages are heavy. Measured live: a 113-message
335
+ * transcript whose recent turns carried ~3.3k tokens each satisfied a 20,000
336
+ * token floor after six messages, so a compaction with a ~73,000 token budget
337
+ * kept seven. Twenty thousand tokens of two file dumps is not a thread anyone
338
+ * can pick up.
339
+ *
340
+ * A quarter is chosen to be legible on a short transcript and irrelevant on a
341
+ * long one: 25% of 500 messages will always reach the ceiling first, so the
342
+ * ratio stops applying exactly where honouring it would be reckless.
343
+ */
344
+ export declare const DEFAULT_PRESERVE_RECENT_MESSAGES_RATIO = 0.25;
345
+ /**
346
+ * The three bounds on how much of the tail survives a compaction.
347
+ *
348
+ * Two lower bounds and one upper, because "how much is enough" and "how much is
349
+ * too much" are different questions and only the second has a budget behind it.
350
+ */
351
+ export interface RecencyBounds {
352
+ /**
353
+ * Minimum tokens to preserve; the conversation is unusable below this, and
354
+ * never more than the budget the compacted request has to fit in — a floor
355
+ * above the ceiling is not a floor, it is a refusal to compact.
356
+ */
357
+ tokenFloor: number;
358
+ /** Minimum share of the transcript's messages to preserve. */
359
+ messagesRatio: number;
360
+ /**
361
+ * The most the preserved tail may cost before the last turn stops being
362
+ * exempt from the cut.
363
+ *
364
+ * The last typed turn survives verbatim so the model keeps the request it is
365
+ * working on. That exemption is unbounded, and a long tool loop under one
366
+ * prompt is all one turn: measured live, a 250,621-byte request compacted to
367
+ * 226,763 -- ten small messages folded, 9.5 percent reclaimed -- because the
368
+ * cut was clamped to the start of a turn that was nearly the whole
369
+ * transcript, and the trigger fired again on the very next turn. Past this
370
+ * ceiling, keeping the turn whole costs more than it is worth and the cut is
371
+ * allowed into it.
372
+ */
373
+ lastTurnCeiling?: number;
374
+ /**
375
+ * Maximum tokens to preserve. Compaction computes a target for the
376
+ * post-compaction request and this is what that target buys: without it the
377
+ * floor is also the ceiling, and every compaction folds to the minimum no
378
+ * matter how much room the model actually had.
379
+ */
380
+ tokenCeiling: number;
381
+ }
382
+ export declare function resolveRecencyBounds(input: {
383
+ preserveRecentTokens: number;
384
+ preserveRecentMessagesRatio?: number;
385
+ messageTargetTokens?: number;
386
+ lastTurnCeiling?: number;
387
+ }): RecencyBounds;
388
+ export interface CompactionCutPlan {
389
+ /**
390
+ * Everything before this index is folded into the summary; the messages
391
+ * from here on survive verbatim. Zero means no cut makes progress.
392
+ */
393
+ cutIndex: number;
394
+ /**
395
+ * A typed prompt that lies *before* the cut but must still survive
396
+ * verbatim, or -1 when the cut already preserves every typed prompt.
397
+ */
398
+ pinnedIndex: number;
399
+ }
400
+ export declare function findCutPlan(messages: MessageWithMetadata[], bounds: RecencyBounds, estimateMessageTokens: EstimateMessageTokens): CompactionCutPlan;
401
+ /**
402
+ * Fold the whole transcript, keeping only the request that started the turn.
403
+ *
404
+ * The cut plan for the strategy that keeps no recency tail: the summary is the
405
+ * context, so the cut is the end of the transcript and there is nothing after
406
+ * it. None of {@link findCutPlan}'s reasoning applies, because all of it is
407
+ * about where to stop, and this stops nowhere.
408
+ *
409
+ * One message is still pinned, and it is a deliberate exception rather than a
410
+ * half-measure. The typed request that started the turn is the single thing
411
+ * whose loss is unrecoverable *and* unnoticeable: the material worked on is
412
+ * still on disk, the tool record is rebuilt by the ledger, but a summary that
413
+ * drops the request leaves the model with a detailed account of work whose
414
+ * purpose it no longer knows. That is measured, not hypothetical — a
415
+ * jackdelta-9b session compacted 322 messages to 70 and sixteen seconds later
416
+ * asked the user what the task was. It costs one message, and it is the one
417
+ * message worth a guaranteed carry rather than a requested one.
418
+ *
419
+ * Returns `pinnedIndex: -1` when there is no typed request to pin: a
420
+ * transcript that is entirely a previous summary plus a tool loop has nothing
421
+ * that qualifies, and pinning index 0 there would carry the old summary
422
+ * forward verbatim alongside the new one.
423
+ */
424
+ export declare function planFullCut(messages: MessageWithMetadata[]): CompactionCutPlan;
425
+ export declare function collectPaths(value: unknown): string[];
426
+ export declare function mergeUnique(base: string[], next: Iterable<string>): string[];
427
+ export declare function extractFileOps(messages: MessageWithMetadata[]): FileOperationSummary;
428
+ /** Commands longer than this are truncated in dropped-work summaries. */
429
+ export declare const COMMAND_SUMMARY_CHAR_LIMIT = 100;
430
+ /**
431
+ * Compact record of the tool work performed inside a span of dropped
432
+ * messages: which files were read and edited (with line ranges when
433
+ * known) and which commands ran.
434
+ */
435
+ export interface ToolActivitySummary {
436
+ readFiles: string[];
437
+ editedFiles: string[];
438
+ commands: string[];
439
+ }
440
+ export declare function hasToolActivity(summary: ToolActivitySummary): boolean;
441
+ /**
442
+ * Summarize the tool work inside a span of messages that compaction is
443
+ * dropping. Read ranges come from read_files inputs; edited ranges come
444
+ * from the numbered diff in the matching editor result when present.
445
+ */
446
+ export declare function summarizeToolActivity(messages: MessageWithMetadata[]): ToolActivitySummary;
447
+ export declare function formatToolActivitySummary(summary: ToolActivitySummary): string;
448
+ export declare function renderFilesSection(fileOps: FileOperationSummary): string;
449
+ export declare function ensureFilesSection(summary: string, fileOps: FileOperationSummary): string;
450
+ /**
451
+ * What the summarizer is asked for when nothing else is configured.
452
+ *
453
+ * The summary replaces the turns it stands for, permanently: every later turn
454
+ * reads this and never the conversation again. So the instruction that matters
455
+ * is not "be concise" -- brevity is what loses the work -- but which specific
456
+ * things must survive the compression. The old default asked for a concise,
457
+ * factual note under five headings and said nothing about identifiers, paths,
458
+ * decisions already taken or approaches already ruled out, which is exactly
459
+ * what a model needs in order not to redo them.
460
+ *
461
+ * `{{files_read}}` and `{{files_edited}}` are substituted before sending. A
462
+ * template that omits them still gets a Files section appended, because losing
463
+ * track of which files are in play is the one failure that makes a summary
464
+ * actively misleading rather than merely thin.
465
+ */
466
+ export declare const DEFAULT_COMPACTION_PROMPT = "You are writing the hand-over note for a session that is about to lose its transcript. Everything below will be discarded; only your note survives, and whoever continues this work will have nothing else to go on.\n\nWrite for that reader. Prefer specifics over summary: exact names, identifiers and paths, quoted wording, error text, commands, and numbers. Do not compress away detail that would have to be rediscovered \u2014 an over-long note costs a little context, a vague one costs the whole investigation.\n\n## Goal\nWhat is being built or fixed, in one or two sentences, including any constraint the user stated.\n\n## Done\nWhat is finished and verified, with the evidence \u2014 which files changed, what the test or command said. Be specific enough that none of it gets redone.\n\n## In progress\nWhat is underway right now, and exactly where it stopped.\n\n## Ruled out\nApproaches already tried that did not work, and why. Omit if none \u2014 but never drop one that was tried, or it will be tried again.\n\n## Key facts\nDecisions taken, values discovered, identifiers, signatures, and anything learned about the material at hand that would not be obvious to someone looking at it fresh. Omit if none.\n\n## Next\nThe immediate next steps, in order.\n\nWrite them for a reader holding no file contents. Where a step touches a file it\nmust begin by reading the part it touches, and no step may say to write, rewrite\nor restore content that this note does not itself contain \u2014 that reader would\nhave to reconstruct it from memory, and what it produces will be a worse version\nof something that is still on disk. Prefer the smallest change that achieves the\nresult over redoing the whole of anything.\n\n## Files\nRead: {{files_read}}\nEdited: {{files_edited}}";
467
+ export declare function buildSummaryRequest(options: {
468
+ previousSummary?: string;
469
+ conversationText: string;
470
+ fileOps: FileOperationSummary;
471
+ /** Overrides {@link DEFAULT_COMPACTION_PROMPT}; blank falls back to it. */
472
+ promptTemplate?: string;
473
+ /**
474
+ * What the user typed, quoted by the harness.
475
+ *
476
+ * The prompt asks the summary to open with what was asked, verbatim, and
477
+ * the transcript below does not always contain it: a prompt the cut pinned
478
+ * survives outside the span being summarized, so on the one-prompt-then-a-
479
+ * long-loop shape the summarizer was asked to quote an instruction it had
480
+ * never been shown. It did the honest thing and wrote that the
481
+ * instructions were missing from its view, into the summary, where the
482
+ * next turn reads it first.
483
+ */
484
+ userRequests?: readonly string[];
485
+ /**
486
+ * What the quoted block may spend of the summarizer's own input.
487
+ *
488
+ * Sized by the caller against the summarizer's limit rather than left at
489
+ * the default: on a small model the unbounded block is a large share of
490
+ * the whole request, and it pushed the summary over its output budget and
491
+ * into a retry -- paying a second model call to quote an instruction more
492
+ * fully than the model had room to read.
493
+ */
494
+ userRequestBudgetChars?: number;
495
+ /**
496
+ * The numbered record of the calls, for the replay to cite.
497
+ *
498
+ * Supplied so citing a number is a lookup rather than a memory feat: the
499
+ * writer is asked to put `[#7]` where a call belongs, and it can only do
500
+ * that if it can see which call is 7.
501
+ */
502
+ toolLedger?: string;
503
+ /**
504
+ * The writer already holds the transcript: it is writing as the next turn
505
+ * of the conversation (compaction as a continuation). This says which part
506
+ * of that context the replay covers, and takes the place of the
507
+ * `Conversation:` section -- repeating the transcript as text is exactly
508
+ * the prefill a continuation exists to avoid.
509
+ */
510
+ conversationInContext?: string;
511
+ }): string;
512
+ /**
513
+ * The second phase's prompt: a retrospective, not a second summary.
514
+ *
515
+ * The summary describes what happened. This describes how the work went, which
516
+ * is the part that dies with the thinking blocks compaction discards -- every
517
+ * wrong turn, every retry, every stretch spent on an approach that was never
518
+ * going to work. A model that starts from a summary alone starts with no memory
519
+ * of having been wrong, and makes the same mistakes in the same order.
520
+ *
521
+ * Written hard against verbosity, because the models this matters most for are
522
+ * the ones that ruminate: on a coder model that hits its thinking cap most
523
+ * turns, an unbounded "reflect on your reasoning" produces more of exactly the
524
+ * behaviour it is meant to flag. Hence the ban on specifics -- those are in the
525
+ * summary, and repeating them here spends the budget twice for one fact.
526
+ */
527
+ export declare const DEFAULT_THINKING_COMPACTION_PROMPT = "You are writing the retrospective that goes at the top of your own context after compaction. It is not a summary \u2014 what happened is written up separately, and repeating it here wastes the space this needs.\n\nYou are reading your own reasoning from the work about to be discarded, together with what each stretch of it produced: which tool calls landed, which were refused, which were retried unchanged, and which turns ran long.\n\nWrite the honest assessment. Be terse. Every line must be something you would want to know before starting the next hour of this task.\n\n## What worked\nApproaches that produced progress, stated as approaches rather than as events.\n\n## What did not\nApproaches that cost time and produced nothing. Name the failure mode: repeating an unchanged call, editing from a stale read, rewriting where narrowing would do, chasing a symptom.\n\n## Where the time went\nThe stretches that were expensive against what they achieved, including any turn where the reasoning ran long without converging.\n\n## Do differently\nWhat to do instead. Concrete enough to act on, short enough to remember.\n\nRules:\n- No file names, line numbers, code, identifiers or values. Those are in the summary. This is about method.\n- No narration of the sequence of events. Judgement only.\n- Leave out any section with nothing worth saying.\n- Terse throughout. A dozen short lines is a good retrospective; a page is a failed one.";
528
+ export declare function buildThinkingSummaryRequest(options: {
529
+ previousThinkingSummary?: string;
530
+ reasoningText: string;
531
+ /** Overrides {@link DEFAULT_THINKING_COMPACTION_PROMPT}; blank falls back. */
532
+ promptTemplate?: string;
533
+ }): string;
534
+ export declare function resolveSummarizerConfig(options: {
535
+ activeProviderConfig: ProviderConfig;
536
+ summarizer?: CoreCompactionSummarizerConfig;
537
+ /**
538
+ * The summarizer's usable input budget, once it is known. Left out on the
539
+ * first pass, which exists to resolve that budget from the merged model.
540
+ */
541
+ maxInputTokens?: number;
542
+ /**
543
+ * The output cap for this call, when the caller has one.
544
+ *
545
+ * The window-derived default is flat for the life of a session; the
546
+ * generation ladder is not, and the retrospective's cap is not even known
547
+ * until the summary has been written. Both are decided by the caller.
548
+ */
549
+ outputTokenCap?: number;
550
+ }): ProviderConfig;
551
+ export declare function buildSummaryMessage(options: {
552
+ summary: string;
553
+ fileOps: FileOperationSummary;
554
+ tokensBefore: number;
555
+ userRunSpan: number;
556
+ generation?: number;
557
+ /** The retrospective, prepended as this message's own reasoning. */
558
+ thinkingSummary?: string;
559
+ /**
560
+ * The measured record of the tool calls being folded, appended after the
561
+ * summary — see {@link renderToolLedger}.
562
+ *
563
+ * Deliberately not part of `metadata.summary`, which is what the next
564
+ * compaction hands the model as `previousSummary`. A ledger that fed back
565
+ * would be re-emitted into the summary that replaces it, and each
566
+ * generation would carry every earlier generation's calls: the transcript
567
+ * would shrink while the summary grew, which is the one outcome compaction
568
+ * cannot have. So a ledger lives for exactly one generation, and by the
569
+ * next one its calls are in the prose.
570
+ */
571
+ toolLedger?: string;
572
+ /** The same ledger, structured, for the generation after this one. */
573
+ toolLedgerEntries?: ToolLedgerEntry[];
574
+ /** Everything the user typed, verbatim, oldest first. */
575
+ userRequests?: string[];
576
+ /** How much room the quoted requests may take, all together. */
577
+ userRequestBudgetChars?: number;
578
+ }): MessageWithMetadata;
579
+ /**
580
+ * Recover the token calibration from a transcript that was written by an
581
+ * earlier process.
582
+ *
583
+ * Every assistant turn records what the provider counted for the request that
584
+ * produced it, so a resumed session is not actually uncalibrated — it just
585
+ * starts as if it were, because the calibration lives in process memory. That
586
+ * gap is what makes a resume compact immediately: the character estimate reads
587
+ * roughly twice the real size of a transcript (three assumed characters per
588
+ * token against a measured 5.9), and twice a normal working context is over any
589
+ * threshold.
590
+ *
591
+ * The newest turn with a recorded count is used, paired with the request that
592
+ * produced it — the messages before it, plus the system prompt and tools, which
593
+ * is the same payload {@link measureRequestInputChars} measures live. Both the
594
+ * ratio and the count are adopted, so the first decision after a resume is made
595
+ * on the same evidence the last decision before it was.
596
+ *
597
+ * Nothing happens once a live response has been observed, and nothing happens
598
+ * for a transcript that carries no counts (a fresh session, or a provider that
599
+ * reports no usage) — those keep the estimate they always had.
600
+ */
601
+ export declare function seedCalibrationFromTranscript(request: {
602
+ systemPrompt?: string;
603
+ messages: MessageWithMetadata[];
604
+ tools?: unknown[];
605
+ reasoningHistory?: ReasoningHistoryMode;
606
+ /** Whose transcript this is, so the seeded count answers only to it. */
607
+ sessionId?: string;
608
+ }): void;