@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,54 @@
1
+ /**
2
+ * The harness's own reading of why the model says it is stuck.
3
+ *
4
+ * The model's account of its own difficulty is the one piece of evidence it
5
+ * has an interest in. So this is computed beside it, from things that were
6
+ * counted rather than described, and both are shown: to the user before an
7
+ * approval, and to the expert in the brief, where a disagreement between the
8
+ * two is itself worth reading.
9
+ *
10
+ * Every line here is a measurement with a known error rate, taken from the
11
+ * replay of 360 harness runs that produced the trigger next door. What is
12
+ * deliberately absent is a verdict: none of these separates a hard task from a
13
+ * stuck model on its own, and a line that said "this model cannot do it" would
14
+ * be claiming a precision nothing in the study supports.
15
+ */
16
+ import type { StruggleSignals } from "../safety/struggle-detector";
17
+ export interface EscalationAssessmentInput {
18
+ /** Where the run is, so the reader can weigh the rest. */
19
+ iteration?: number;
20
+ /** The struggle detector's window, whether or not it fired. */
21
+ signals?: StruggleSignals;
22
+ transactions?: {
23
+ /** Transactions opened so far, including the one that is open. */
24
+ opened: number;
25
+ /** Judged and rolled back. */
26
+ discarded: number;
27
+ /** Judged, not kept, and left on disk because the check's answer moved. */
28
+ carried?: number;
29
+ };
30
+ /** A terminal guard has already stood down once for this task. */
31
+ guardStoodDown?: boolean;
32
+ /**
33
+ * What the complexity walker made of the files in play, already worded.
34
+ *
35
+ * A tiebreaker and nothing more. It measures how hard the code is to read,
36
+ * not how likely this model is to fix it, and each line says so where it is
37
+ * read -- the same discipline `check_file` keeps about its own bound.
38
+ */
39
+ complexity?: readonly string[];
40
+ /**
41
+ * An outside scorer's reading of the task, already worded -- Jev's
42
+ * complexity and "stuck" scores, where the host configured it. Each line
43
+ * says whose reading it is and what it saw; it is not one of the counts.
44
+ */
45
+ appraisal?: readonly string[];
46
+ }
47
+ /**
48
+ * Render the assessment, or nothing when nothing was measured.
49
+ *
50
+ * Nothing is a real answer: an escalation on turn three has no window behind
51
+ * it, and a section reading "0 failures, no transactions" would be presented
52
+ * as evidence of health when it is evidence of a run that has not started.
53
+ */
54
+ export declare function buildEscalationAssessment(input: EscalationAssessmentInput): string | undefined;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The one message that starts an escalation.
3
+ *
4
+ * The expert gets the brief, not the transcript. That is a decision, and worth
5
+ * stating: handing over the conversation would be cheaper to write and worse in
6
+ * both directions — it is the most expensive thing this feature can send, it
7
+ * arrives as thousands of tokens of a stuck model's reasoning, and a fresh
8
+ * model reading another model's dead ends adopts them. What the expert needs is
9
+ * the task, the goal, the standard it will be held to, and the record of what
10
+ * has already been tried and thrown away. Everything else it can read for
11
+ * itself: it has the same tools.
12
+ *
13
+ * The record is the part that is not obvious. A discarded transaction leaves no
14
+ * trace on disk — the files are byte-for-byte as they were before it — so an
15
+ * expert told only "it is still broken" will re-derive the plan that was just
16
+ * rolled back. The base model's own prompt carries this record for exactly that
17
+ * reason; so does this.
18
+ */
19
+ import { type Oracle } from "../atomic/oracle";
20
+ import type { TransactionOutcome } from "../atomic/protocol";
21
+ /** What the open transaction looks like, when the change protocol is on. */
22
+ export interface EscalationTransactionState {
23
+ /** One-based number of the open transaction. */
24
+ transaction: number;
25
+ maxTransactions: number;
26
+ maxChanges: number;
27
+ /** Changes already declared in it, when the host is counting them. */
28
+ changesUsed?: number;
29
+ /** The check the transaction will be judged by, when there is one. */
30
+ oracle?: Oracle;
31
+ /** What the base model said it would change in this transaction. */
32
+ plan?: string;
33
+ /** Transactions already tried and settled. */
34
+ history: readonly TransactionOutcome[];
35
+ }
36
+ export interface EscalationBriefInput {
37
+ /** What the base model wants done, in its own words. */
38
+ goal: string;
39
+ /** What it will accept as a correct delivery, in its own words. */
40
+ expectation?: string;
41
+ /** The task as the user stated it. */
42
+ task?: string;
43
+ workspaceRoot?: string;
44
+ /** Files the base model has been working in, as workspace-relative paths. */
45
+ filesInPlay?: readonly string[];
46
+ transaction?: EscalationTransactionState;
47
+ /**
48
+ * The harness's own reading of the code, when it has one.
49
+ *
50
+ * Attributed to the harness rather than folded into the goal, because it is
51
+ * the one piece of evidence here the base model did not write.
52
+ */
53
+ assessment?: string;
54
+ /** Which escalation this is, and how many this task gets. */
55
+ escalation: {
56
+ index: number;
57
+ of: number;
58
+ };
59
+ /** Follow-ups available after this delivery. */
60
+ followUpsAllowed: number;
61
+ /**
62
+ * Whether escalation took a snapshot of the workspace before handing over.
63
+ *
64
+ * Only with the change protocol off. With it on, the open transaction's own
65
+ * snapshot already covers the expert's edits and a second one would be a
66
+ * copy of a copy.
67
+ */
68
+ snapshotTaken?: boolean;
69
+ }
70
+ export declare function buildEscalationBrief(input: EscalationBriefInput): string;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * `escalate` — hand the task to a better model, and pay for it.
3
+ *
4
+ * The description below is the whole feature as far as the model is concerned,
5
+ * and it has to hold two things at once that pull in opposite directions.
6
+ *
7
+ * The expert costs more. It is a bigger model, often on a metered account, often
8
+ * shared, and always slower; a model that reads `escalate` as "ask for help"
9
+ * calls it on its first failed edit and the account pays for a question it could
10
+ * have answered by reading the file.
11
+ *
12
+ * And an expert nobody calls is worth nothing. The measured failure this feature
13
+ * exists for is not over-asking — it is a model looping until a guard ends the
14
+ * run: 25 of 61 jackod4ac runs broken and 5 timed out, with the loop guard
15
+ * ending more of them than any other cohort in the study. A description that
16
+ * only warns about cost produces a model that never escalates and stops anyway,
17
+ * having spent the same hours to fail.
18
+ *
19
+ * So it says both, in that order, and gives concrete conditions rather than a
20
+ * disposition: what to try first, and what being stuck actually looks like.
21
+ */
22
+ import { type AgentTool } from "@cerebriline/shared";
23
+ export declare const ESCALATE_TOOL_NAME = "escalate";
24
+ export declare const ESCALATE_TOOL_DESCRIPTION = "Hand this task to the expert: a larger, more capable model that works in this same workspace and can edit it directly.\n\nWHAT IT COSTS. The expert is more expensive than you are. It may be a paid, metered account, a limited allowance, or hardware shared with other people, and it is slower than you. Your task gets a small, fixed number of escalations and no more. So do not escalate to save yourself reading a file, running the check, or thinking a problem through \u2014 that is the work, and it is yours.\n\nWHEN TO USE IT ANYWAY. The expert is there to help, and not calling it is not a virtue. You are not being scored on doing this alone: a task that runs out of turns and stops is a worse outcome than one that cost an escalation and worked. Escalate when you are actually stuck, which looks like this \u2014 the same fix attempted and rolled back more than once; a symptom you have read the code for and still cannot explain; a check that keeps failing for a reason you cannot name; or a piece of the task that needs knowledge you do not have. When one of those is true, escalate now rather than after three more attempts: the earlier you hand over, the more budget is left to act on what comes back.\n\nHOW TO USE IT. Say what you want done (`goal`) and how you will know it is right (`expectation`). Be specific \u2014 the expert starts with none of your conversation, only what you write here plus the task, the workspace state and what has already been tried and discarded. Name the files you have been working in (`files`).\n\nWHAT COMES BACK. The expert's own account of what it changed and what it ran, as its reply. Read it and check it: run the check yourself, look at the files it says it edited, and satisfy yourself the change is a fix rather than a way around the symptom. You are still the one accountable for this task.\n\nIf the delivery does not hold up, say so \u2014 call this tool again with `message` to push back, quote what you found, and ask for the specific thing that is wrong. That is what the conversation is for, and it is much cheaper than a second escalation. When you are satisfied, call it once more with `finished: true` to end the exchange and release the expert.";
25
+ export declare const ESCALATE_TOOL_INPUT_SCHEMA: {
26
+ readonly type: "object";
27
+ readonly properties: {
28
+ readonly goal: {
29
+ readonly type: "string";
30
+ readonly description: "What you want the expert to achieve, in your own words. Required when you are starting an escalation. Be concrete: the symptom, what you have already established, and what you want done about it.";
31
+ };
32
+ readonly expectation: {
33
+ readonly type: "string";
34
+ readonly description: "What you will accept as a correct delivery, and how you intend to check it. The expert is told this, so it knows what it is being held to.";
35
+ };
36
+ readonly files: {
37
+ readonly type: "array";
38
+ readonly items: {
39
+ readonly type: "string";
40
+ };
41
+ readonly description: "Files you have been working in, as paths relative to the workspace root. A starting point for the expert, not a boundary.";
42
+ };
43
+ readonly message: {
44
+ readonly type: "string";
45
+ readonly description: "Your reply to the expert, once an escalation is open: a push-back on what it delivered, an answer to a question it asked, or a narrower follow-up. Quote what you actually found.";
46
+ };
47
+ readonly finished: {
48
+ readonly type: "boolean";
49
+ readonly description: "Set when you are done with the expert. Ends the exchange and releases it. Nothing else ends it, and an exchange left open holds the expert's slot for the rest of the task.";
50
+ };
51
+ };
52
+ readonly required: readonly [];
53
+ };
54
+ /** What the model asked for, after the input has been read. */
55
+ export interface EscalationRequest {
56
+ /** The goal, when this call is opening an escalation. */
57
+ goal?: string;
58
+ expectation?: string;
59
+ files?: string[];
60
+ /** The model's reply, when an exchange is already open. */
61
+ message?: string;
62
+ /** The model says it is done with the expert. */
63
+ finished?: boolean;
64
+ }
65
+ export interface EscalationExchangeResult {
66
+ /** What the expert said. */
67
+ reply: string;
68
+ /** Whether this call opened an escalation rather than continuing one. */
69
+ opened: boolean;
70
+ followUpsLeft: number;
71
+ escalationsLeft: number;
72
+ /** Whether the exchange is over — because the model said so, or the host. */
73
+ closed?: boolean;
74
+ /**
75
+ * The expert has the work and is still doing it.
76
+ *
77
+ * The non-blocking hand-over. `reply` is then the hand-over notice rather
78
+ * than a delivery, and wrapping it in "check this before you build on it"
79
+ * would have the base model checking work that has not happened yet.
80
+ */
81
+ handedOver?: boolean;
82
+ }
83
+ export interface EscalateToolOptions {
84
+ /**
85
+ * Runs the exchange: budget, brief, the expert's conversation, and the
86
+ * accounting. Owned by the session, as `submit_transaction`'s settle is,
87
+ * because everything it touches outlives one tool call.
88
+ */
89
+ consult: (request: EscalationRequest) => Promise<EscalationExchangeResult>;
90
+ onError?: (message: string, error: unknown) => void;
91
+ }
92
+ export declare function readEscalationRequest(input: unknown): EscalationRequest;
93
+ export declare function createEscalateTool(options: EscalateToolOptions): AgentTool;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * What a task is allowed to spend on the expert, and what happens to the
3
+ * conversation between escalations.
4
+ *
5
+ * Two bounds, and they answer different questions. The follow-up cap inside
6
+ * {@link ExpertSession} stops one exchange running away — two models talking to
7
+ * each other until something times out. This one stops a *task* running away:
8
+ * three hand-overs is a model that has been given real help three times and is
9
+ * still stuck, and a fourth is not what that task needs.
10
+ *
11
+ * Running out is not a failure state that needs explaining away. It restores
12
+ * exactly the behaviour every build before this one had: the guards stop the
13
+ * run. The message says so, because a model told only "denied" will spend its
14
+ * remaining turns trying to find the wording that works.
15
+ */
16
+ import type { ExpertSession, ExpertUsage } from "./expert-session";
17
+ export interface EscalationControllerOptions {
18
+ /** Hand-overs allowed in this task. */
19
+ maxEscalations: number;
20
+ /**
21
+ * Release the expert's conversation at the end of each escalation.
22
+ *
23
+ * See {@link ExpertSession} for why both answers are right on different
24
+ * hardware. Off means hold.
25
+ */
26
+ closeAfterEscalation: boolean;
27
+ /** Builds a fresh expert conversation. Called only when one is needed. */
28
+ createSession: () => ExpertSession;
29
+ }
30
+ export interface EscalationController {
31
+ /** Hand-overs made so far. */
32
+ readonly used: number;
33
+ /** Hand-overs still allowed. */
34
+ readonly remaining: number;
35
+ /** The conversation now open, if any. */
36
+ readonly session: ExpertSession | undefined;
37
+ /** Everything the expert has spent in this task, open conversations included. */
38
+ readonly usage: ExpertUsage;
39
+ /** Spends one escalation and returns the conversation to ask through. */
40
+ begin(): ExpertSession;
41
+ /**
42
+ * Gives back an escalation that bought nothing.
43
+ *
44
+ * A hand-over is charged at {@link begin}, before the expert has been asked
45
+ * anything, because that is the only place that can refuse one. When the ask
46
+ * then fails outright -- the endpoint is down, the model is unavailable, the
47
+ * run finished on `error` -- no expert saw the task and the budget must not
48
+ * record that it did. Floors at zero: refunding what was never spent would
49
+ * hand the task a fourth escalation out of a budget of three.
50
+ *
51
+ * The conversation goes with it when it has delivered nothing. A held
52
+ * session that never opened still reads as live to the next `escalate`,
53
+ * which would then arrive as a follow-up -- the model's raw goal, into an
54
+ * empty context, instead of the brief a hand-over builds.
55
+ */
56
+ refund(): Promise<void>;
57
+ /** Ends the current escalation: closes the conversation, or holds it. */
58
+ end(): Promise<void>;
59
+ /** Task teardown. Releases whatever is held, whatever the setting says. */
60
+ dispose(): Promise<void>;
61
+ }
62
+ export declare function createEscalationController(options: EscalationControllerOptions): EscalationController;
@@ -0,0 +1,241 @@
1
+ /**
2
+ * The escalation path, assembled: the tool, the budget, the brief, and what
3
+ * happens to the workspace while a second model is editing it.
4
+ *
5
+ * Built the way the atomic protocol is built — decorated onto a session at
6
+ * construction rather than registered as a default tool — for the same reason.
7
+ * A default tool has to be declared in six places, is offered to every session
8
+ * whether or not the feature is configured, and would answer "no expert is
9
+ * configured" to a model that is stuck, which is the one state in which it will
10
+ * keep calling. Here the tool exists only where an expert does.
11
+ *
12
+ * Three things this owns that nothing else can:
13
+ *
14
+ * the budget a stuck model with an unmetered escalate is a stuck model
15
+ * with a larger bill. See `escalation-controller.ts`.
16
+ * the read drop the expert moves lines the base model has already read,
17
+ * and the editor's read-before-edit guard is all that stands
18
+ * between a stale line number and the file on disk.
19
+ * the snapshot the expert edits. With the change protocol on, the open
20
+ * transaction already covers that. With it off, nothing did
21
+ * until this: handing edit rights to a second model with no
22
+ * way back is not a feature, it is a liability.
23
+ */
24
+ import type { AgentEvent, AgentTool } from "@cerebriline/shared";
25
+ import type { AgentSlotGate } from "../../extensions/tools/team/agent-slot-gate";
26
+ import type { CoreEscalationConfig } from "../../types/config";
27
+ import { type RestoreReport, type Snapshot } from "../atomic/snapshot";
28
+ import type { EscalationTransactionState } from "./brief";
29
+ import type { ExpertMailbox } from "./expert-mailbox";
30
+ import type { ExpertNotes } from "./expert-notes";
31
+ import type { ExpertRevisions } from "./expert-revisions";
32
+ import { type ExpertRuntime, type ExpertUsage } from "./expert-session";
33
+ import { type StandDown } from "./stand-down";
34
+ /** Escalations one task gets. */
35
+ export declare const DEFAULT_MAX_ESCALATIONS = 3;
36
+ /** Follow-ups within one escalation, after the first delivery. */
37
+ export declare const DEFAULT_MAX_FOLLOW_UPS = 20;
38
+ /**
39
+ * What the host is told, as it happens.
40
+ *
41
+ * Events rather than log lines because the exchange belongs in the chat: the
42
+ * user is paying for this model and is entitled to read what it was asked and
43
+ * what it said, in the transcript, beside the work it produced.
44
+ */
45
+ export type EscalationEvent = {
46
+ type: "escalation_started";
47
+ index: number;
48
+ of: number;
49
+ brief: string;
50
+ } | {
51
+ type: "expert_asked";
52
+ message: string;
53
+ } | {
54
+ type: "expert_replied";
55
+ reply: string;
56
+ /** Workspace-relative paths the expert changed. */
57
+ changed: string[];
58
+ usage: ExpertUsage;
59
+ } | {
60
+ type: "expert_said";
61
+ index: number;
62
+ of: number;
63
+ kind: "thinking" | "message";
64
+ text: string;
65
+ } | {
66
+ type: "expert_progress";
67
+ index: number;
68
+ of: number;
69
+ toolCalls: number;
70
+ lastTool?: string;
71
+ usage: ExpertUsage;
72
+ } | {
73
+ type: "escalation_ended";
74
+ held: boolean;
75
+ usage: ExpertUsage;
76
+ } | {
77
+ /**
78
+ * The expert's run failed. Before this nothing reached the chat: the
79
+ * base model read the failure in its tool result, and the user's
80
+ * "working" row spun on (Chris's .213 session, a usage limit after
81
+ * 70 minutes).
82
+ */
83
+ type: "escalation_failed";
84
+ index: number;
85
+ of: number;
86
+ reason: string;
87
+ /** Workspace-relative paths the expert changed before it failed. */
88
+ changed: string[];
89
+ /** What the failed turn had spent, as its last progress report said. */
90
+ usage?: ExpertUsage;
91
+ /** The provider refused for the account's usage limit. */
92
+ limitReached: boolean;
93
+ };
94
+ /**
95
+ * What the user said when the escalation was put to them.
96
+ *
97
+ * A bare boolean is still accepted because a host with only a yes/no to offer
98
+ * should not have to wrap it, and every host did exactly that until the
99
+ * approval moved out of a modal dialog and into the chat, where there is room
100
+ * to say why.
101
+ */
102
+ export type EscalationApproval = boolean | {
103
+ approved: boolean;
104
+ feedback?: string;
105
+ };
106
+ export interface EscalationSessionOptions {
107
+ workspaceRoot: string;
108
+ config: CoreEscalationConfig | undefined;
109
+ /** Builds the expert's runtime on the escalation connection. */
110
+ openExpert: (context: {
111
+ onEvent: (event: AgentEvent) => void;
112
+ }) => Promise<ExpertRuntime>;
113
+ /** The open transaction, read at hand-over. Absent means the protocol is off. */
114
+ readTransaction?: () => EscalationTransactionState | undefined;
115
+ /** The task as the user stated it. */
116
+ readTask?: () => string | undefined;
117
+ /**
118
+ * The harness's own reading of the run, and of the code in play.
119
+ *
120
+ * Given the files the model named so the reading can cover them, and the
121
+ * model's goal and reason so a scorer can read what is being handed over.
122
+ * What comes back is opaque text for the brief and the approval dialog.
123
+ */
124
+ assess?: (context: {
125
+ files?: readonly string[];
126
+ goal?: string;
127
+ reason?: string;
128
+ }) => Promise<string | undefined>;
129
+ /** Retires what the base model had read about a file the expert changed. */
130
+ forgetReads?: (absolutePath: string) => void;
131
+ /**
132
+ * Where the expert's writes are recorded, when the host wired one up.
133
+ *
134
+ * Opened on the first ask of an escalation and purged when that escalation
135
+ * ends. The session owns the lifecycle because it is the only thing that
136
+ * knows both -- the host builds the log and decorates the expert's tools
137
+ * with it, but it never sees an escalation begin or finish.
138
+ */
139
+ revisions?: ExpertRevisions;
140
+ /**
141
+ * The base model's stand-down, and with it the non-blocking hand-over.
142
+ *
143
+ * Its presence is the switch. Given one, `escalate` returns as soon as the
144
+ * expert has been handed the work and the base model stays live, watching
145
+ * through `wait_for_expert` and barred from writing. Left out, the tool
146
+ * blocks until the expert delivers, which is what it did before any of this
147
+ * existed and what the "alternate usage" setting asks for: one model in
148
+ * memory at a time, and no supervision to pay for.
149
+ */
150
+ standDown?: StandDown;
151
+ /** Where the expert's activity is collected for the base model. */
152
+ notes?: ExpertNotes;
153
+ /**
154
+ * The guards watching the expert's own channels, for their reset.
155
+ *
156
+ * The session owns the reset for the same reason it owns the revision
157
+ * log's: it is the only thing that knows an escalation has ended, and
158
+ * evidence carried from one escalation into the next would have the base
159
+ * model told the expert is looping before it has done anything.
160
+ */
161
+ guards?: {
162
+ reset(): void;
163
+ };
164
+ /**
165
+ * Where a message for a still-working expert waits for its next turn.
166
+ *
167
+ * Without one, `escalate` with a `message` during a hand-over can only say
168
+ * "it is still working" -- which is true and useless, because the two
169
+ * things the base model is watching for are exactly the two that cannot
170
+ * wait for the delivery: a question the expert asked, and an expert going
171
+ * round in circles that should stop now rather than in forty turns.
172
+ */
173
+ mailbox?: ExpertMailbox;
174
+ /** How long `wait_for_expert` sleeps between looks. Tests override it. */
175
+ watchTickMs?: number;
176
+ /** Overridable for tests; the real one is a timer. */
177
+ wait?: (ms: number) => Promise<void>;
178
+ /**
179
+ * Takes whatever the user has typed since it was last asked, if anything.
180
+ *
181
+ * The same queue the turn boundary drains, drained here because that
182
+ * boundary will not come round: while the expert is working the base model
183
+ * is blocked inside a tool call, so a steering message would otherwise wait
184
+ * out the entire exchange it was written about.
185
+ */
186
+ takeSteering?: () => string | undefined;
187
+ /**
188
+ * Puts the escalation to the user before it happens.
189
+ *
190
+ * Only consulted where the host set `requireApproval`. A refusal spends
191
+ * nothing: the budget rations the model, and a person saying no is not the
192
+ * model overspending.
193
+ */
194
+ approve?: (request: {
195
+ brief: string;
196
+ index: number;
197
+ of: number;
198
+ }) => Promise<EscalationApproval>;
199
+ /** The escalation endpoint's slot gate, when the host resolved one. */
200
+ gate?: Pick<AgentSlotGate, "run" | "active">;
201
+ onEvent?: (event: EscalationEvent) => void;
202
+ logger?: {
203
+ log?: (message: string) => void;
204
+ };
205
+ /** Overridable for tests; the real ones read and write the workspace. */
206
+ takeSnapshot?: (root: string) => Promise<Snapshot>;
207
+ restoreSnapshot?: (snapshot: Snapshot) => Promise<RestoreReport>;
208
+ }
209
+ export interface EscalationSession {
210
+ /** `escalate`, where an expert is configured. Empty where none is. */
211
+ readonly tools: AgentTool[];
212
+ /** Escalations made. */
213
+ readonly used: number;
214
+ /**
215
+ * Escalations still available.
216
+ *
217
+ * Read by the struggle detector's offer, which must not suggest a tool call
218
+ * the budget would refuse -- an offer the model takes and is turned down on
219
+ * is worse than no offer.
220
+ */
221
+ readonly remaining: number;
222
+ /** What the expert has spent in this task. */
223
+ readonly usage: ExpertUsage;
224
+ /**
225
+ * Puts the workspace back as the first escalation found it.
226
+ *
227
+ * Only meaningful where escalation took a snapshot — that is, where the
228
+ * change protocol was off. Undefined when there is nothing to go back to.
229
+ */
230
+ restore(): Promise<RestoreReport | undefined>;
231
+ /** Task teardown. Releases a held expert. */
232
+ dispose(): Promise<void>;
233
+ }
234
+ /**
235
+ * The provider refused because the account ran out of allowance.
236
+ *
237
+ * Ollama's cloud says "you have reached your session usage limit" (and 402 on
238
+ * the wire); hosted APIs say quota or limit with a 402 or 429.
239
+ */
240
+ export declare function isUsageLimit(reason: string): boolean;
241
+ export declare function createEscalationSession(options: EscalationSessionOptions): EscalationSession;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The expert's run failing after it had already written files.
3
+ */
4
+ /**
5
+ * An expert run that failed, with the files it changed before it did.
6
+ *
7
+ * `changed` holds workspace-relative paths. The escalate and wait tools read it
8
+ * so that "the escalation did not happen" is not followed by "nothing has
9
+ * changed" when the expert had in fact written files.
10
+ */
11
+ export declare class ExpertRunFailedError extends Error {
12
+ readonly changed: string[];
13
+ constructor(message: string, changed: string[], options?: ErrorOptions);
14
+ }
15
+ /**
16
+ * What the base is told about a failed expert run's edits.
17
+ *
18
+ * Empty when the run changed nothing, so the caller can keep saying so.
19
+ */
20
+ export declare function describeFailedExpertChanges(error: unknown): string;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The same guards that decide the base model is stuck, run on the expert.
3
+ *
4
+ * The escalation path has always had one direction. A guard notices the base
5
+ * model going round in circles and offers it an expert; nothing then watches
6
+ * the expert, and the measured failure that motivated this is an expert doing
7
+ * exactly what the base was doing -- the nemotron 3 nano run the user named,
8
+ * which rewrote the same file over and over while the base sat blocked inside
9
+ * a tool call with no way to see it or stop it.
10
+ *
11
+ * So the guards run in both directions (user, 2026-09-14: "the same that
12
+ * triggered an escalation can be used on the expert to trigger deescalation").
13
+ * What comes out is NOT a decision. These verdicts do not end the expert's run,
14
+ * do not cancel the escalation and do not roll anything back: they become a
15
+ * note, the note wakes the base model, and the base model -- which can read the
16
+ * files, run the check and see what the expert actually delivered -- decides.
17
+ * That is deliberate. A guard that ended an expert's run would be the same
18
+ * automation the base model is there to replace, and every threshold here has a
19
+ * known false-positive rate that is fine for a nudge and not fine for a kill.
20
+ *
21
+ * THE WORDING IS FOR THE READER, NOT THE SUBJECT. Both detectors write their
22
+ * messages at the model being measured -- "this call was refused, move on to
23
+ * the next thing". Handed to the base model unchanged, that reads as an
24
+ * instruction to the base about its own work, which it is not doing. Each
25
+ * verdict is re-framed here as an observation about somebody else.
26
+ */
27
+ import type { AgentEvent } from "@cerebriline/shared";
28
+ import { type StruggleThresholds } from "../safety/struggle-detector";
29
+ export interface ExpertGuardVerdict {
30
+ /** Which guard spoke. */
31
+ kind: "loop" | "struggle";
32
+ /** Worded for the base model, as an observation about the expert. */
33
+ text: string;
34
+ }
35
+ export interface ExpertGuardOptions {
36
+ onVerdict: (verdict: ExpertGuardVerdict) => void;
37
+ /** The struggle detector's operating point, where the host sets one. */
38
+ thresholds?: Partial<StruggleThresholds>;
39
+ }
40
+ export interface ExpertGuards {
41
+ /** Fold one of the expert's events in. */
42
+ observe(event: AgentEvent): void;
43
+ /** A new escalation is a new question. Forget the last one's evidence. */
44
+ reset(): void;
45
+ }
46
+ export declare function createExpertGuards(options: ExpertGuardOptions): ExpertGuards;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * What the base model says to the expert while the expert is still working.
3
+ *
4
+ * The escalation already had a channel in one direction and at one moment: the
5
+ * base asks, the expert answers, and between those two points neither could say
6
+ * anything to the other. That was tolerable while `escalate` blocked -- the base
7
+ * was not running, so it had nothing to say -- and it is not tolerable now. The
8
+ * base is live, it is being told what the expert is doing, and the two things it
9
+ * is there for both require a channel: answering a question the expert asked,
10
+ * and telling an expert that is going round in circles to stop.
11
+ *
12
+ * This is the same shape as the team mailbox next door in `multi-agent.ts`,
13
+ * built separately rather than reused because that one is keyed by agent id
14
+ * across a roster of teammates and carries a notification telling the recipient
15
+ * to go and read its messages with a tool. There is exactly one expert, it has
16
+ * no mailbox tool, and the message has to arrive in the turn rather than as an
17
+ * invitation to fetch it.
18
+ *
19
+ * THE LABEL IS THE POINT. The expert reads this in the middle of its own work,
20
+ * where an unlabelled paragraph is indistinguishable from the user speaking --
21
+ * and a correction from the person who owns the task is worth more than one the
22
+ * supervising model inferred from a note. Both are worth acting on and they are
23
+ * not worth the same, so they are never merged. When the base is passing on
24
+ * something the user said, it says so in its own words, inside its own message.
25
+ */
26
+ export interface ExpertMailbox {
27
+ /** Queue something for the expert's next turn. */
28
+ send(text: string): void;
29
+ /** Everything waiting, labelled and cleared. Nothing when empty. */
30
+ take(): string | undefined;
31
+ /** The escalation is over; nothing waiting is worth delivering. */
32
+ clear(): void;
33
+ }
34
+ export declare function createExpertMailbox(): ExpertMailbox;