@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,115 @@
1
+ /**
2
+ * What the base model is told about the expert while the expert is working.
3
+ *
4
+ * The base model is live for the whole escalation now, standing down from
5
+ * edits and watching. Watching costs it a turn every time it is woken, and on
6
+ * a 9B base against an expert that makes a hundred tool calls that is the
7
+ * whole task budget spent on narration. So notes are collected continuously
8
+ * and handed over in batches.
9
+ *
10
+ * THE CLOCK RUNS FROM THE HAND-OVER, NOT FROM THE NOTE. The base is woken at
11
+ * most once per interval, and the interval starts when it last took a batch --
12
+ * so a base that spends four minutes reviewing does not come back to eight
13
+ * batches queued behind it. It comes back to one, holding everything that
14
+ * happened while it was away (user, 2026-09-14: "if it's not done with the
15
+ * previous review gets the next batch when it ends or more than one together
16
+ * or the remaining plus the notification the expert is done").
17
+ *
18
+ * THREE THINGS JUMP THE CLOCK, because waiting on them is worse than the turn
19
+ * they cost: the expert speaking (it may be asking a question), a guard
20
+ * tripping (the expert may be going in circles), and the task reaching a state
21
+ * that is not `working` -- `input-required` owes an answer, and a terminal
22
+ * state means there is nothing left to wait for.
23
+ *
24
+ * THINKING IS NOT A NOTE, and there is deliberately no method that takes it.
25
+ * The expert's reasoning runs to tens of thousands of characters per turn and
26
+ * the base model is the smaller of the two; handing it that is how the
27
+ * supervision budget gets spent on text the base cannot use. Tool calls and
28
+ * messages are what it needs to follow the work.
29
+ *
30
+ * EVERY CHANGED FILE CARRIES THE REVISION IT CAN BE READ AT. A batch describes
31
+ * what happened up to a moment that has already passed -- by the time the base
32
+ * reads "the expert edited manic_miner.html" the expert has edited it twice
33
+ * more, and a base that opens the file on disk is checking a claim against
34
+ * evidence that has moved. The revision number is the fixed point: it names
35
+ * the exact bytes the note is about, and `read_files` with `revision` serves
36
+ * them. That is what makes "I fixed function A and the linter is quiet" a
37
+ * testable statement rather than a claim about a file that no longer exists.
38
+ */
39
+ import type { AgentToolDefinition } from "@cerebriline/shared";
40
+ import { type Part, type TaskState } from "./a2a";
41
+ /** A file the expert wrote, and the revision holding what it wrote. */
42
+ export interface ExpertFileTouch {
43
+ path: string;
44
+ /** Its index in the expert's revision log, for `read_files`. */
45
+ revision: number;
46
+ }
47
+ export interface ExpertNote {
48
+ kind: "tool" | "message" | "guard";
49
+ /** The tool's name, for `kind: "tool"`. */
50
+ tool?: string;
51
+ /** What was said, for `kind: "message"` and `kind: "guard"`. */
52
+ text?: string;
53
+ /** How many identical calls this line stands for. Always at least 1. */
54
+ count: number;
55
+ files: ExpertFileTouch[];
56
+ /** The tool's own failure, where it had one. */
57
+ error?: string;
58
+ }
59
+ export interface ExpertNoteBatch {
60
+ state: TaskState;
61
+ /** The task has ended: this is the last batch there will be. */
62
+ final: boolean;
63
+ notes: ExpertNote[];
64
+ /** The batch as the base model and the panel each need it. */
65
+ parts: Part[];
66
+ }
67
+ export interface ExpertNotesOptions {
68
+ /** How long the base is left alone between batches. */
69
+ intervalMs?: number;
70
+ now?: () => number;
71
+ }
72
+ export interface ExpertNotes {
73
+ noteTool(input: {
74
+ tool: string;
75
+ files?: readonly ExpertFileTouch[];
76
+ error?: string;
77
+ }): void;
78
+ noteMessage(text: string): void;
79
+ noteGuard(text: string): void;
80
+ setState(state: TaskState): void;
81
+ readonly state: TaskState;
82
+ /** Notes waiting to be handed over. */
83
+ readonly pending: number;
84
+ /** Whether the base should be woken now. */
85
+ due(): boolean;
86
+ /** Everything waiting, cleared. Nothing when the base should be left alone. */
87
+ take(): ExpertNoteBatch | undefined;
88
+ }
89
+ export declare const DEFAULT_NOTE_INTERVAL_MS = 30000;
90
+ export declare function createExpertNotes(options?: ExpertNotesOptions): ExpertNotes;
91
+ export interface ExpertNoteTakerOptions {
92
+ notes: ExpertNotes;
93
+ /**
94
+ * The highest revision held for each file, read either side of a call.
95
+ *
96
+ * A diff rather than a reading of the tool's input, so this needs to know
97
+ * nothing about what any particular tool's arguments mean -- and so a tool
98
+ * that writes by a route this code has never heard of still shows up. What
99
+ * moved is what was written.
100
+ */
101
+ heads: () => ReadonlyMap<string, number>;
102
+ /** Workspace-relative paths for the note, where the host can give them. */
103
+ relative?: (absolutePath: string) => string;
104
+ }
105
+ /**
106
+ * Wrap the expert's tools so every call it makes becomes a note.
107
+ *
108
+ * Outside the revision capture, so the heads it reads afterwards already hold
109
+ * what the call wrote. What it cannot see is a tool that reports its own
110
+ * failure in its result rather than by throwing -- an editor that refuses, a
111
+ * command that exits non-zero -- and that is fine: the base model is being
112
+ * given the shape of the work, not a transcript, and a refused call that
113
+ * changed nothing is exactly the kind of detail the batching exists to drop.
114
+ */
115
+ export declare function withExpertNotes<T extends AgentToolDefinition>(tools: readonly T[], options: ExpertNoteTakerOptions): T[];
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Who the expert is, for as long as the conversation lives.
3
+ *
4
+ * Separate from the brief on purpose. The brief is one escalation — a goal, a
5
+ * transaction, a record — and a held conversation gets a new one each time. This
6
+ * is the part that does not change: that the caller is a model rather than a
7
+ * user, that the expert is expected to edit rather than advise, and that what it
8
+ * hands back is going to be checked.
9
+ *
10
+ * The first of those is the one that earns its place. A model given a technical
11
+ * question by what it takes to be a user answers it: a paragraph of guidance, a
12
+ * suggested patch in a fenced block, and no edit. That is a correct response to
13
+ * the wrong situation, and it is exactly what a second opinion produced before
14
+ * this feature existed — the base model then had to transcribe the suggestion,
15
+ * which is the step it was stuck at in the first place. So this says, in the
16
+ * first line, that nobody is reading this but another model with the same tools.
17
+ */
18
+ export interface ExpertPromptInput {
19
+ workspaceRoot?: string;
20
+ /**
21
+ * The rules the session itself is working under, where the host has them.
22
+ *
23
+ * A project's own instructions apply to whoever is editing. An expert that
24
+ * does not have them writes changes the base model has to undo, and it is
25
+ * the base model that gets blamed for the result.
26
+ */
27
+ sessionInstructions?: string;
28
+ }
29
+ export declare function buildExpertPrompt(input: ExpertPromptInput): string;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Every version of every file the expert writes, for as long as the escalation
3
+ * lasts.
4
+ *
5
+ * WHY THE BASE MODEL NEEDS THIS. It is live while the expert works and it is
6
+ * told what the expert did in batches, which means every note describes a
7
+ * moment that has already passed. By the time the base reads "the expert edited
8
+ * manic_miner.html" the expert has edited it twice more, so a base that opens
9
+ * the file on disk is checking a claim against evidence that has moved under
10
+ * it. The revision number is the fixed point: it names the exact bytes the note
11
+ * was about, and `read_files` with `revision` serves them. That is what turns
12
+ * "I fixed function A and the linter is quiet" from an assertion into something
13
+ * testable (user, 2026-09-14: "this is a testable statement if run on the right
14
+ * snapshot").
15
+ *
16
+ * WHY IT IS NOT THE CHANGE PROTOCOL'S LOG. The protocol's revisions belong to
17
+ * the base model's open transaction -- its budget, its plan, its rollback --
18
+ * and the expert is not in that arrangement at all; as of this build it is not
19
+ * even given the protocol's tools. Sharing one log would mean the expert's
20
+ * writes renumbering the base model's history, and `restore_file` offering to
21
+ * put back a version the base never made.
22
+ *
23
+ * WHY IT IS PURGED AT THE END. A revision is worth holding while there is still
24
+ * a claim to check. When the escalation closes, the delivery has been made, the
25
+ * base has accepted or pushed back, and what is left is copies of files held in
26
+ * memory for a conversation that is over (user, 2026-09-14: "once the expert
27
+ * escalation is done, we purge the snapshots").
28
+ *
29
+ * The log, the de-duplication, the memory cap and the read decoration are all
30
+ * `runtime/atomic`'s, unchanged. This is the escalation's own instance of them.
31
+ */
32
+ import { type FileRevision } from "../atomic/file-revisions";
33
+ import type { RevisionCaptureSource } from "../atomic/revision-capture";
34
+ import type { Snapshot } from "../atomic/snapshot";
35
+ export interface ExpertRevisions {
36
+ /**
37
+ * What `withRevisionCapture` needs to decorate the expert's tools.
38
+ *
39
+ * Read through rather than copied: the base snapshot arrives when the
40
+ * escalation opens, which is after the expert's tools have been built.
41
+ */
42
+ readonly source: RevisionCaptureSource;
43
+ /** Begin an escalation's history at the workspace as it stands now. */
44
+ open(base: Snapshot, index: number): void;
45
+ /** Every version of one file, oldest first. #1 is as the escalation opened. */
46
+ revisions(absolutePath: string): readonly FileRevision[];
47
+ /** Files anything has been recorded for. */
48
+ tracked(): readonly string[];
49
+ /**
50
+ * The highest revision held for each file.
51
+ *
52
+ * What the note-taker diffs across a tool call to work out what that call
53
+ * wrote, without having to know what any particular tool's input means. A
54
+ * tool that writes two files in one call shows up as two entries moving,
55
+ * and a tool that writes nothing shows up as nothing moving -- which is
56
+ * also the right answer for a read.
57
+ */
58
+ heads(): ReadonlyMap<string, number>;
59
+ /** The escalation is over. Drop the history and the claim on the workspace. */
60
+ purge(): void;
61
+ }
62
+ export declare function createExpertRevisions(): ExpertRevisions;
@@ -0,0 +1,164 @@
1
+ /**
2
+ * The expert's side of an escalation: one conversation, held or closed.
3
+ *
4
+ * An escalation is not a single question. The session's model states a goal and
5
+ * a scope, the expert answers, the model checks the answer against the task and
6
+ * pushes back if it does not hold — so what the expert needs is a conversation
7
+ * that survives between calls, and what the *host* needs is a decision about
8
+ * whether to keep it.
9
+ *
10
+ * Both answers are right on different hardware, which is why the decision is a
11
+ * setting rather than a default:
12
+ *
13
+ * held a hosted provider's prompt cache stays warm and the expert still
14
+ * has the exchange in its context, so a follow-up sends one message
15
+ * rather than the whole conversation again. On a metered account that
16
+ * difference is the bill.
17
+ * closed a local server gets its slot back, which is what lets another model
18
+ * load at all. `OLLAMA_MAX_LOADED_MODELS` is usually 1 or 2, and an
19
+ * expert held open is a model the session's own cannot replace.
20
+ *
21
+ * The accounting is here rather than left to the host because the expert is the
22
+ * one model whose cost has to be separable. A total that folds the expert's
23
+ * tokens into the session's answers no question anybody has about a paid
24
+ * account, and the generation rate is the provider's own reported figure for
25
+ * the same reason the task header uses it: wall-clock over tokens would fold in
26
+ * queueing and tool time and move when the model did not.
27
+ */
28
+ import type { AgentEvent, AgentResult } from "@cerebriline/shared";
29
+ import type { AgentSlotGate } from "../../extensions/tools/team/agent-slot-gate";
30
+ /**
31
+ * What an escalation spent.
32
+ *
33
+ * Two clocks, deliberately. `generateMs` is what the provider says it spent
34
+ * generating, and is the only honest input to a tok/s figure. `wallMs` is what
35
+ * the escalation actually took, queueing and prompt processing included, and is
36
+ * what a metered account is billed for.
37
+ */
38
+ export interface ExpertUsage {
39
+ inputTokens: number;
40
+ outputTokens: number;
41
+ /** Tokens generated across the requests whose provider timed itself. */
42
+ generateTokens: number;
43
+ /** Milliseconds those requests spent generating, by the provider's clock. */
44
+ generateMs: number;
45
+ /** Wall-clock the expert was running, by ours. */
46
+ wallMs: number;
47
+ /**
48
+ * Requests the expert's provider was actually sent.
49
+ *
50
+ * This used to be the number of *turns asked of the expert*, which put two
51
+ * different denominators on one line: `inputTokens` sums the prompt of
52
+ * every request the expert's own agent loop makes, and an expert that
53
+ * works for an hour makes dozens. Run 0303 reported
54
+ * `expert_in=9,490,524 expert_requests=1` -- a prompt larger than any
55
+ * context window, over one request, which is impossible and was read as a
56
+ * broken counter rather than as two units. Now `inputTokens / requests` is
57
+ * the average prompt, which is what anyone dividing them expects.
58
+ *
59
+ * The turn count is not lost: it is `asks` below, and the harness already
60
+ * reports it separately as `expert_replies`.
61
+ */
62
+ requests: number;
63
+ /** Turns asked of the expert, the first brief included. */
64
+ asks: number;
65
+ }
66
+ /**
67
+ * What the expert has done so far in the turn that is still running.
68
+ *
69
+ * A hand-over is one tool call from the base model's point of view, so the
70
+ * chat has nothing to say between the brief and the delivery -- and an expert
71
+ * that reads a file twelve times over twenty minutes looks exactly like a hung
72
+ * request. This is what makes the difference visible while it is still true.
73
+ */
74
+ export interface ExpertProgress {
75
+ /** Tool calls the expert has completed in this turn. */
76
+ toolCalls: number;
77
+ /** The last one's name, when the event carried it. */
78
+ lastTool?: string;
79
+ /** What the turn has spent so far, wall-clock included. */
80
+ usage: ExpertUsage;
81
+ }
82
+ /**
83
+ * A block the expert finished: a stretch of thinking, or something it said.
84
+ *
85
+ * Reported per completed block rather than streamed. The block arrives whole on
86
+ * `content_end`, so a consumer that wants the whole of it -- and the thinking
87
+ * is the part worth having whole; 50,000 characters of it is normal -- gets it
88
+ * in one message instead of rebuilding it from deltas. Nothing accumulates on
89
+ * either side, which is what keeps a long escalation from re-sending the same
90
+ * text on every update.
91
+ */
92
+ export interface ExpertUtterance {
93
+ kind: "thinking" | "message";
94
+ text: string;
95
+ }
96
+ export interface ExpertReply {
97
+ text: string;
98
+ iterations: number;
99
+ finishReason?: string;
100
+ /** What this turn alone spent. */
101
+ usage: ExpertUsage;
102
+ }
103
+ /**
104
+ * The part of a session runtime an escalation uses.
105
+ *
106
+ * Narrow on purpose: `SessionRuntime` satisfies it structurally, and a test can
107
+ * satisfy it without a provider, a model or a network.
108
+ */
109
+ export interface ExpertRuntime {
110
+ run(prompt: string): Promise<AgentResult>;
111
+ shutdown?(reason?: string): Promise<void>;
112
+ abort?(reason?: unknown): void;
113
+ }
114
+ export interface ExpertSessionOptions {
115
+ /**
116
+ * Builds the expert's runtime, once, on the first ask.
117
+ *
118
+ * Deferred rather than taken as a value so that configuring an expert costs
119
+ * nothing until one is actually called — on a local server, constructing it
120
+ * is what loads the model.
121
+ */
122
+ open: (context: {
123
+ onEvent: (event: AgentEvent) => void;
124
+ }) => Promise<ExpertRuntime>;
125
+ /** Follow-ups allowed after the first delivery. */
126
+ maxFollowUps: number;
127
+ /**
128
+ * The endpoint's slot gate, when the host resolved one.
129
+ *
130
+ * A local server queues a request that finds no free slot rather than
131
+ * refusing it, and says nothing while it does, so an ungated expert call
132
+ * reads as a slow run rather than a blocked one.
133
+ */
134
+ gate?: Pick<AgentSlotGate, "run" | "active">;
135
+ /**
136
+ * Called as the expert works, not only when it answers.
137
+ *
138
+ * Fires on every completed tool call and on every usage event the provider
139
+ * sends, which is as often as the expert gives anyone anything to report.
140
+ */
141
+ onProgress?: (progress: ExpertProgress) => void;
142
+ /**
143
+ * Called as the expert thinks and speaks, block by block.
144
+ *
145
+ * Separate from `onProgress` because these are the expert's words rather
146
+ * than a measurement of it, and because they must never carry usage: the
147
+ * turn's spend is reported once, and a second copy riding on the transcript
148
+ * would be added to it.
149
+ */
150
+ onUtterance?: (utterance: ExpertUtterance) => void;
151
+ }
152
+ export interface ExpertSession {
153
+ /** Answers the expert has actually produced. A failed run is not one. */
154
+ readonly deliveries: number;
155
+ /** Deliveries after the first. The brief itself is not a follow-up. */
156
+ readonly followUps: number;
157
+ readonly closed: boolean;
158
+ /** Everything this conversation has spent so far. */
159
+ readonly usage: ExpertUsage;
160
+ ask(message: string): Promise<ExpertReply>;
161
+ /** Ends the conversation and releases the endpoint's slot. Idempotent. */
162
+ close(reason?: string): Promise<void>;
163
+ }
164
+ export declare function createExpertSession(options: ExpertSessionOptions): ExpertSession;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The expert's transcript, saved like any delegated agent's.
3
+ *
4
+ * The expert runs outside the spawn tools, so nothing reported its start or end
5
+ * to the session store, and its conversation lived only in memory. A report
6
+ * from a finished task then held every agent's transcript but the one the task
7
+ * had escalated to.
8
+ */
9
+ import type { AgentResult } from "@cerebriline/shared";
10
+ import type { SubAgentEndContext, SubAgentStartContext } from "../../extensions/tools/team/spawn-agent-tool";
11
+ import type { ExpertRuntime } from "./expert-session";
12
+ /** The parent the expert's sub-session is filed under. */
13
+ export declare const EXPERT_PARENT_AGENT_ID = "lead";
14
+ /** What `withExpertTranscript` needs of the expert's runtime. */
15
+ export interface ExpertRuntimeWithTranscript extends ExpertRuntime {
16
+ getAgentId(): string;
17
+ getConversationId(): string;
18
+ getMessages(): AgentResult["messages"];
19
+ }
20
+ export interface ExpertTranscriptSink {
21
+ start(context: SubAgentStartContext): Promise<unknown> | unknown;
22
+ end(context: SubAgentEndContext): Promise<unknown> | unknown;
23
+ }
24
+ /**
25
+ * The expert's runtime, saving its messages after every ask.
26
+ *
27
+ * The first ask files the sub-session, with the brief as its task. Each ask
28
+ * then writes the whole conversation so far, whether it answered, finished on
29
+ * `error`, or threw. A sink that fails is ignored: saving is best-effort and
30
+ * must never cost the escalation.
31
+ */
32
+ export declare function withExpertTranscript(expert: ExpertRuntimeWithTranscript, sink: ExpertTranscriptSink): ExpertRuntime;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Spending a terminal guard on an escalation instead of on a stop.
3
+ *
4
+ * The evidence is the strongest in the study behind this feature. Of the 88
5
+ * runs that did not end FIXED, 40 were ended by the repeated-call loop guard --
6
+ * 45% of all failures -- and that same guard ended 3 of 243 successful runs.
7
+ * The consecutive-mistake limit accounts for 2 more failures and no successes,
8
+ * and the reasoning-loop streak for a handful. Precision here is structural
9
+ * rather than statistical: these runs were over. Handing the task to the expert
10
+ * at that exact moment cannot cost anything that was not already lost.
11
+ *
12
+ * What it must not become is a way around the guard. Two properties hold:
13
+ *
14
+ * - **Once per task.** The second time a terminal guard fires, it fires.
15
+ * - **Deferred, never removed.** Taking the offer means calling `escalate` on
16
+ * the very next turn. A model that is given the turn and spends it on
17
+ * something else is stopped at the end of it, with the guard's own words.
18
+ *
19
+ * The second property is the one that needs machinery. The mistake limit's
20
+ * `continue` resets its counter, so without this the run would get a fresh six
21
+ * mistakes out of a guard that was about to end it.
22
+ */
23
+ import type { AgentEvent, TerminalGuardDecision } from "@cerebriline/shared";
24
+ export interface ForcedEscalationOptions {
25
+ /** Escalations still available. Zero means the guard stands as it is. */
26
+ remaining: () => number;
27
+ /** End the run, the way the guard was about to. */
28
+ stop: (message: string) => void;
29
+ logger?: {
30
+ log?: (message: string) => void;
31
+ };
32
+ }
33
+ export interface ForcedEscalation {
34
+ /**
35
+ * Answer a terminal guard, or leave it standing.
36
+ *
37
+ * `undefined` means this has nothing to offer — spent, or no budget — and
38
+ * the guard does exactly what it did before.
39
+ */
40
+ decide(input: {
41
+ /** The guard, in the model's own terms. */
42
+ guard: string;
43
+ diagnosis?: string;
44
+ }): TerminalGuardDecision | undefined;
45
+ /** Fold in one agent event, so the deferral can see whether it was taken. */
46
+ observe(event: AgentEvent): void;
47
+ /** Whether the offer has been made. */
48
+ readonly spent: boolean;
49
+ }
50
+ /** What the model is told when a guard stands down for it. */
51
+ export declare function describeForcedEscalation(input: {
52
+ guard: string;
53
+ diagnosis?: string;
54
+ remaining: number;
55
+ }): string;
56
+ /** What the run is stopped with when the turn was spent on something else. */
57
+ export declare function describeMissedEscalation(guard: string): string;
58
+ export declare function createForcedEscalation(options: ForcedEscalationOptions): ForcedEscalation;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * What the base model may do while the expert is editing its workspace.
3
+ *
4
+ * The escalation used to be a blocking call: the base model went into
5
+ * `escalate`, the tool did not return until the expert had delivered, and the
6
+ * question of what the base was allowed to do meanwhile did not arise because
7
+ * it could do nothing at all. That cost the two things the user asked for
8
+ * (2026-09-14): a base model that watches the expert and can call it off when
9
+ * it starts going in circles, and a user steer that reaches the base while the
10
+ * expert is still working rather than an hour later.
11
+ *
12
+ * Making the base live raises the problem the blocking call did not have. Two
13
+ * models now hold write access to one workspace, and nothing arbitrates
14
+ * between them: the base reads a file, the expert rewrites it, the base edits
15
+ * the lines it read and destroys the expert's work -- or, worse, both of them
16
+ * do, and neither delivery is what is on disk. That is not a rule the models
17
+ * can be trusted to keep between themselves, because each of them is correct
18
+ * about its own edit.
19
+ *
20
+ * So the base stands down. Not from the task and not from the turn: from
21
+ * CHANGES. It reads, it greps, it runs the check, it reads the versions the
22
+ * expert wrote and it messages the expert. What it cannot do is write, and
23
+ * that is enforced here rather than asked for in a prompt, because a prompt is
24
+ * a request and this is an invariant (user: "the base model should be
25
+ * instructed to stand down from changes; all editing operations prohibited
26
+ * until the expert is done").
27
+ *
28
+ * `run_commands` is the deliberate exception. The user allowed running --
29
+ * checking the expert's work is most of what the base is there for, and a base
30
+ * that cannot run anything is a base that can only take the expert's word --
31
+ * and a command can write anything, so it is warned rather than refused.
32
+ */
33
+ import type { AgentToolDefinition } from "@cerebriline/shared";
34
+ /**
35
+ * What the base model is told when it hands over.
36
+ *
37
+ * The spot-check instruction is the load-bearing sentence. The notes name
38
+ * every tool call the expert made, and a model told to verify them all will
39
+ * spend the whole escalation reading -- which is the turn economy the batching
40
+ * exists to protect (user: "instruct the base model to NOT do a systematic
41
+ * check of all tools request but overview the flow and run spot checks").
42
+ */
43
+ export declare const STAND_DOWN_NOTICE = "== YOU ARE STANDING DOWN WHILE THE EXPERT WORKS ==\n\nThe expert is editing this workspace now. You are not. Until it delivers, every tool that writes a file is refused \u2014 you cannot edit, patch, restore or submit, and there is no way to override that. This is not a judgement about your work; it is that two models writing to one workspace destroy each other's changes, and the expert has the pen.\n\nWhat you do instead is watch. You will be given notes as the expert works: what it called, what it changed, what it said. Do not audit them. Read the flow, form a view of whether the work is going somewhere, and run spot checks on the parts that matter \u2014 the file the expert says it fixed, the check it says now passes, the claim you doubt. `read_files` with a `revision` from a note shows you the exact bytes that note was about, which is the only way to check a claim against what was actually written rather than against a file that has moved on since.\n\nYou may run commands, including the check. Do not run one that changes a file. A formatter, a build step that rewrites sources, a `sed -i` \u2014 any of those lands on top of what the expert is doing, and neither of you will be able to say what happened.\n\nYou may message the expert, and you should keep it rare: a message costs it a turn and pulls it off what it is doing. Send one when you have something it needs \u2014 an answer to a question, a correction the user gave you, or the judgement only you can make: that it is going in circles and should stop. You are authorised to call it off.\n\nWhen the expert delivers, you have the pen back and the task is yours again.";
44
+ /** The stand-down, as the session drives it. */
45
+ export interface StandDown {
46
+ /** Whether the base model is standing down right now. */
47
+ readonly engaged: boolean;
48
+ /** The expert has the workspace. */
49
+ engage(): void;
50
+ /** The expert is done. The base model has the pen back. */
51
+ release(): void;
52
+ }
53
+ export declare function createStandDown(): StandDown;
54
+ /**
55
+ * Return the tool list with the writers gated on the stand-down.
56
+ *
57
+ * A decoration rather than a filter, and deliberately: a tool that vanishes
58
+ * mid-task teaches the model that the tool does not exist, and it stops
59
+ * planning with it for the rest of the run. A tool that answers "not now, and
60
+ * here is why" leaves the capability where the model can find it again.
61
+ */
62
+ export declare function withStandDown<T extends AgentToolDefinition>(tools: readonly T[], standDown: StandDown): T[];
63
+ /** Names the stand-down refuses, for the prompt and for tests. */
64
+ export declare const STAND_DOWN_REFUSED_TOOLS: readonly string[];
65
+ /** Names that stay open, stated so a reader does not have to infer them. */
66
+ export declare const STAND_DOWN_ALLOWED_TOOLS: readonly string[];
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Turning "this run is not going anywhere" into an offer of help.
3
+ *
4
+ * The detector next door measures; this words the consequence, and the split
5
+ * is deliberate. What the measurement earns depends on things the detector
6
+ * cannot see -- whether an expert is configured at all, how much of the
7
+ * escalation budget is left, whether the user asked to approve each one.
8
+ *
9
+ * Delivered on a tool result rather than appended to the conversation. The
10
+ * conversation store is snapshotted into `initialMessages` when a run starts
11
+ * and overwritten from `runResult.messages` when it ends, so a message
12
+ * appended to it mid-run reaches nothing: measured on a live session where a
13
+ * guard counted six refusals and not one of the twenty-six requests on the
14
+ * wire carried a word of the warning.
15
+ */
16
+ import type { AgentToolDefinition } from "@cerebriline/shared";
17
+ /**
18
+ * What the model is told when the detector has fired.
19
+ *
20
+ * Both halves matter, and the second one is the half that is easy to leave
21
+ * out: the expert is there to be used. A model that refuses to escalate after
22
+ * four failed attempts in ten turns wastes more than one that escalates early,
23
+ * and a paragraph that only warned about cost would produce exactly that.
24
+ *
25
+ * It never says the model must. The forcing path is a different mechanism at a
26
+ * different place, and a suggestion that reads like an order makes the run's
27
+ * one real stop indistinguishable from a nudge.
28
+ */
29
+ export declare function describeEscalationOffer(input: {
30
+ diagnosis: string;
31
+ remaining: number;
32
+ }): string;
33
+ /**
34
+ * The quieter message, one failure short of the offer above.
35
+ *
36
+ * Two things separate it from `describeEscalationOffer`. It states what was
37
+ * measured and stops -- no paragraph about cost, no "the expert exists to be
38
+ * used" -- because at this count the honest reading is usually "this is a
39
+ * normal bad patch", and a full proposal every time one would arrive would
40
+ * train the model to skip the one that matters. And it names the expert only
41
+ * when the code it is working in is genuinely hard to read, which is the one
42
+ * case where the extra help is worth raising before the trigger.
43
+ *
44
+ * The complexity lines arrive already worded, each carrying its own bound.
45
+ * Nothing here restates the number as a prediction: it says the code is hard
46
+ * to read, which is all it measures.
47
+ */
48
+ export declare function describeEscalationNudge(input: {
49
+ diagnosis: string;
50
+ complexity: readonly string[];
51
+ /**
52
+ * Whether the hardest function in any file in play lands in the top band.
53
+ *
54
+ * `extreme`, which is 60 and above -- 6.3% of files measured across
55
+ * TypeScript, C and C++. Rare enough that raising it means something.
56
+ */
57
+ high: boolean;
58
+ /** Whether a file in play no longer parses end to end. */
59
+ broken?: boolean;
60
+ /**
61
+ * Which measurement asked for this.
62
+ *
63
+ * `edit-streak` names the expert on its own, where the plain nudge names it
64
+ * only in dense code. Three refused edits in a row is not a bad patch --
65
+ * the model has tried the same thing three times and been told no three
66
+ * times -- and that is the point at which raising the expert is the useful
67
+ * thing to say rather than the premature one.
68
+ */
69
+ reason?: "failures" | "edit-streak" | "transactions";
70
+ /**
71
+ * Whether this session can hand a piece of the work to a subagent.
72
+ *
73
+ * The expert is named late because it costs money or a shared GPU. A
74
+ * subagent is this model on this endpoint, so naming it is nearly free --
75
+ * which is why it rides the nudge that was already being sent rather than
76
+ * earning a threshold of its own. The gate is the host's: `spawn_agent` off,
77
+ * or an endpoint that serves one request at a time, and there is nothing to
78
+ * suggest.
79
+ */
80
+ canDelegate?: boolean;
81
+ remaining: number;
82
+ }): string;
83
+ /** A held suggestion, taken by whichever tool result comes next. */
84
+ export interface PendingSuggestion {
85
+ hold(message: string): void;
86
+ /** What is owed, without consuming it. */
87
+ peek(): string | undefined;
88
+ take(): string | undefined;
89
+ }
90
+ export declare function createPendingSuggestion(): PendingSuggestion;
91
+ /**
92
+ * Wrap every tool so the next result carries a held suggestion.
93
+ *
94
+ * Every tool, not a chosen few: the suggestion is about the run rather than
95
+ * about any one call, and the model's next call is wherever it happens to go.
96
+ * `escalate` and `spawn_agent` are excluded — a model that has just taken the
97
+ * advice does not need to be given it again inside the answer. Neither call
98
+ * consumes the suggestion, so it is still owed to whatever runs next.
99
+ */
100
+ export declare function withStruggleSuggestion<T extends AgentToolDefinition>(tools: readonly T[], pending: PendingSuggestion): T[];