@animalabs/agent-framework 0.27.0 → 0.29.0

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 (344) hide show
  1. package/README.md +145 -41
  2. package/dist/src/agent.d.ts +29 -2
  3. package/dist/src/agent.d.ts.map +1 -1
  4. package/dist/src/agent.js +73 -12
  5. package/dist/src/agent.js.map +1 -1
  6. package/dist/src/api/mcp-server-core.d.ts.map +1 -1
  7. package/dist/src/api/mcp-server-core.js +3 -12
  8. package/dist/src/api/mcp-server-core.js.map +1 -1
  9. package/dist/src/api/server.d.ts.map +1 -1
  10. package/dist/src/api/server.js +11 -5
  11. package/dist/src/api/server.js.map +1 -1
  12. package/dist/src/auto-continue.d.ts +5 -2
  13. package/dist/src/auto-continue.d.ts.map +1 -1
  14. package/dist/src/auto-continue.js +9 -5
  15. package/dist/src/auto-continue.js.map +1 -1
  16. package/dist/src/code-execution/isolate/runner.d.ts +7 -5
  17. package/dist/src/code-execution/isolate/runner.d.ts.map +1 -1
  18. package/dist/src/code-execution/isolate/runner.js +7 -5
  19. package/dist/src/code-execution/isolate/runner.js.map +1 -1
  20. package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
  21. package/dist/src/code-execution/isolate/scripts.js +3 -2
  22. package/dist/src/code-execution/isolate/scripts.js.map +1 -1
  23. package/dist/src/cut-off-round.d.ts +24 -0
  24. package/dist/src/cut-off-round.d.ts.map +1 -0
  25. package/dist/src/cut-off-round.js +87 -0
  26. package/dist/src/cut-off-round.js.map +1 -0
  27. package/dist/src/framework.d.ts +468 -125
  28. package/dist/src/framework.d.ts.map +1 -1
  29. package/dist/src/framework.js +3651 -1111
  30. package/dist/src/framework.js.map +1 -1
  31. package/dist/src/gate/event-gate.d.ts +133 -13
  32. package/dist/src/gate/event-gate.d.ts.map +1 -1
  33. package/dist/src/gate/event-gate.js +654 -59
  34. package/dist/src/gate/event-gate.js.map +1 -1
  35. package/dist/src/gate/index.d.ts +3 -2
  36. package/dist/src/gate/index.d.ts.map +1 -1
  37. package/dist/src/gate/index.js +2 -1
  38. package/dist/src/gate/index.js.map +1 -1
  39. package/dist/src/gate/reply-judge.d.ts +116 -0
  40. package/dist/src/gate/reply-judge.d.ts.map +1 -0
  41. package/dist/src/gate/reply-judge.js +467 -0
  42. package/dist/src/gate/reply-judge.js.map +1 -0
  43. package/dist/src/gate/types.d.ts +173 -2
  44. package/dist/src/gate/types.d.ts.map +1 -1
  45. package/dist/src/heartbeat/heartbeat.d.ts +202 -0
  46. package/dist/src/heartbeat/heartbeat.d.ts.map +1 -0
  47. package/dist/src/heartbeat/heartbeat.js +778 -0
  48. package/dist/src/heartbeat/heartbeat.js.map +1 -0
  49. package/dist/src/heartbeat/reminder-time.d.ts +5 -0
  50. package/dist/src/heartbeat/reminder-time.d.ts.map +1 -0
  51. package/dist/src/heartbeat/reminder-time.js +107 -0
  52. package/dist/src/heartbeat/reminder-time.js.map +1 -0
  53. package/dist/src/held-writes.d.ts +3 -3
  54. package/dist/src/held-writes.js +3 -3
  55. package/dist/src/host-presentation.d.ts +170 -0
  56. package/dist/src/host-presentation.d.ts.map +1 -0
  57. package/dist/src/host-presentation.js +561 -0
  58. package/dist/src/host-presentation.js.map +1 -0
  59. package/dist/src/index.d.ts +5 -1
  60. package/dist/src/index.d.ts.map +1 -1
  61. package/dist/src/index.js +3 -1
  62. package/dist/src/index.js.map +1 -1
  63. package/dist/src/line-reader.d.ts +4 -0
  64. package/dist/src/line-reader.d.ts.map +1 -0
  65. package/dist/src/line-reader.js +59 -0
  66. package/dist/src/line-reader.js.map +1 -0
  67. package/dist/src/mcpl/capability-mask.d.ts.map +1 -1
  68. package/dist/src/mcpl/capability-mask.js +3 -2
  69. package/dist/src/mcpl/capability-mask.js.map +1 -1
  70. package/dist/src/mcpl/channel-registry.d.ts +34 -6
  71. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  72. package/dist/src/mcpl/channel-registry.js +133 -54
  73. package/dist/src/mcpl/channel-registry.js.map +1 -1
  74. package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
  75. package/dist/src/mcpl/conversation-router.js +2 -1
  76. package/dist/src/mcpl/conversation-router.js.map +1 -1
  77. package/dist/src/mcpl/convert-block.d.ts +1 -0
  78. package/dist/src/mcpl/convert-block.d.ts.map +1 -1
  79. package/dist/src/mcpl/convert-block.js +16 -4
  80. package/dist/src/mcpl/convert-block.js.map +1 -1
  81. package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
  82. package/dist/src/mcpl/hook-orchestrator.js +4 -3
  83. package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
  84. package/dist/src/mcpl/inbound-source.d.ts +29 -11
  85. package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
  86. package/dist/src/mcpl/inbound-source.js +43 -70
  87. package/dist/src/mcpl/inbound-source.js.map +1 -1
  88. package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
  89. package/dist/src/mcpl/modern-connection.js +11 -7
  90. package/dist/src/mcpl/modern-connection.js.map +1 -1
  91. package/dist/src/mcpl/protocol-family.d.ts +3 -2
  92. package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
  93. package/dist/src/mcpl/protocol-family.js +25 -3
  94. package/dist/src/mcpl/protocol-family.js.map +1 -1
  95. package/dist/src/mcpl/push-handler.js +2 -2
  96. package/dist/src/mcpl/push-handler.js.map +1 -1
  97. package/dist/src/mcpl/references.d.ts +12 -40
  98. package/dist/src/mcpl/references.d.ts.map +1 -1
  99. package/dist/src/mcpl/references.js +29 -23
  100. package/dist/src/mcpl/references.js.map +1 -1
  101. package/dist/src/mcpl/server-connection.d.ts +18 -8
  102. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  103. package/dist/src/mcpl/server-connection.js +70 -30
  104. package/dist/src/mcpl/server-connection.js.map +1 -1
  105. package/dist/src/mcpl/skip-reply-wake.d.ts +25 -0
  106. package/dist/src/mcpl/skip-reply-wake.d.ts.map +1 -1
  107. package/dist/src/mcpl/skip-reply-wake.js +25 -0
  108. package/dist/src/mcpl/skip-reply-wake.js.map +1 -1
  109. package/dist/src/mcpl/tags.d.ts +9 -2
  110. package/dist/src/mcpl/tags.d.ts.map +1 -1
  111. package/dist/src/mcpl/tags.js +12 -2
  112. package/dist/src/mcpl/tags.js.map +1 -1
  113. package/dist/src/mcpl/tool-presence.d.ts +66 -14
  114. package/dist/src/mcpl/tool-presence.d.ts.map +1 -1
  115. package/dist/src/mcpl/tool-presence.js +150 -80
  116. package/dist/src/mcpl/tool-presence.js.map +1 -1
  117. package/dist/src/mcpl/tool-signature.d.ts +10 -3
  118. package/dist/src/mcpl/tool-signature.d.ts.map +1 -1
  119. package/dist/src/mcpl/tool-signature.js +60 -30
  120. package/dist/src/mcpl/tool-signature.js.map +1 -1
  121. package/dist/src/mcpl/toolset-host.d.ts +88 -55
  122. package/dist/src/mcpl/toolset-host.d.ts.map +1 -1
  123. package/dist/src/mcpl/toolset-host.js +220 -111
  124. package/dist/src/mcpl/toolset-host.js.map +1 -1
  125. package/dist/src/mcpl/toolsets-module.d.ts +27 -35
  126. package/dist/src/mcpl/toolsets-module.d.ts.map +1 -1
  127. package/dist/src/mcpl/toolsets-module.js +313 -91
  128. package/dist/src/mcpl/toolsets-module.js.map +1 -1
  129. package/dist/src/mcpl/transport.d.ts +1 -1
  130. package/dist/src/mcpl/transport.d.ts.map +1 -1
  131. package/dist/src/mcpl/transport.js +16 -16
  132. package/dist/src/mcpl/transport.js.map +1 -1
  133. package/dist/src/mcpl/types.d.ts +31 -13
  134. package/dist/src/mcpl/types.d.ts.map +1 -1
  135. package/dist/src/mcpl/types.js.map +1 -1
  136. package/dist/src/module-registry.d.ts +10 -8
  137. package/dist/src/module-registry.d.ts.map +1 -1
  138. package/dist/src/module-registry.js +15 -9
  139. package/dist/src/module-registry.js.map +1 -1
  140. package/dist/src/modules/api/index.d.ts.map +1 -1
  141. package/dist/src/modules/api/index.js +4 -2
  142. package/dist/src/modules/api/index.js.map +1 -1
  143. package/dist/src/modules/discord/index.d.ts.map +1 -1
  144. package/dist/src/modules/discord/index.js +33 -25
  145. package/dist/src/modules/discord/index.js.map +1 -1
  146. package/dist/src/modules/history/index.d.ts.map +1 -1
  147. package/dist/src/modules/history/index.js +30 -17
  148. package/dist/src/modules/history/index.js.map +1 -1
  149. package/dist/src/modules/sender-name.d.ts +7 -0
  150. package/dist/src/modules/sender-name.d.ts.map +1 -0
  151. package/dist/src/modules/sender-name.js +10 -0
  152. package/dist/src/modules/sender-name.js.map +1 -0
  153. package/dist/src/modules/workspace/answers.d.ts +26 -0
  154. package/dist/src/modules/workspace/answers.d.ts.map +1 -0
  155. package/dist/src/modules/workspace/answers.js +138 -0
  156. package/dist/src/modules/workspace/answers.js.map +1 -0
  157. package/dist/src/modules/workspace/branch-intent.d.ts +5 -3
  158. package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -1
  159. package/dist/src/modules/workspace/branch-intent.js +6 -2
  160. package/dist/src/modules/workspace/branch-intent.js.map +1 -1
  161. package/dist/src/modules/workspace/direct-write.d.ts +3 -0
  162. package/dist/src/modules/workspace/direct-write.d.ts.map +1 -1
  163. package/dist/src/modules/workspace/direct-write.js +59 -24
  164. package/dist/src/modules/workspace/direct-write.js.map +1 -1
  165. package/dist/src/modules/workspace/disk-agreement.d.ts +33 -11
  166. package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
  167. package/dist/src/modules/workspace/disk-agreement.js +48 -17
  168. package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
  169. package/dist/src/modules/workspace/edit-text.d.ts +2 -1
  170. package/dist/src/modules/workspace/edit-text.d.ts.map +1 -1
  171. package/dist/src/modules/workspace/edit-text.js +4 -2
  172. package/dist/src/modules/workspace/edit-text.js.map +1 -1
  173. package/dist/src/modules/workspace/effects.d.ts +4 -2
  174. package/dist/src/modules/workspace/effects.d.ts.map +1 -1
  175. package/dist/src/modules/workspace/effects.js +67 -50
  176. package/dist/src/modules/workspace/effects.js.map +1 -1
  177. package/dist/src/modules/workspace/index.d.ts +63 -51
  178. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  179. package/dist/src/modules/workspace/index.js +980 -547
  180. package/dist/src/modules/workspace/index.js.map +1 -1
  181. package/dist/src/modules/workspace/observe.d.ts +125 -82
  182. package/dist/src/modules/workspace/observe.d.ts.map +1 -1
  183. package/dist/src/modules/workspace/observe.js +465 -241
  184. package/dist/src/modules/workspace/observe.js.map +1 -1
  185. package/dist/src/modules/workspace/read-page.d.ts.map +1 -1
  186. package/dist/src/modules/workspace/read-page.js +7 -1
  187. package/dist/src/modules/workspace/read-page.js.map +1 -1
  188. package/dist/src/modules/workspace/reconcile.d.ts +7 -1
  189. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
  190. package/dist/src/modules/workspace/reconcile.js +156 -50
  191. package/dist/src/modules/workspace/reconcile.js.map +1 -1
  192. package/dist/src/modules/workspace/result-text.d.ts +1 -0
  193. package/dist/src/modules/workspace/result-text.d.ts.map +1 -1
  194. package/dist/src/modules/workspace/result-text.js.map +1 -1
  195. package/dist/src/modules/workspace/sync.d.ts +9 -0
  196. package/dist/src/modules/workspace/sync.d.ts.map +1 -1
  197. package/dist/src/modules/workspace/sync.js +14 -0
  198. package/dist/src/modules/workspace/sync.js.map +1 -1
  199. package/dist/src/modules/workspace/types.d.ts +96 -43
  200. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  201. package/dist/src/modules/workspace/types.js.map +1 -1
  202. package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
  203. package/dist/src/modules/workspace/watcher.js +8 -3
  204. package/dist/src/modules/workspace/watcher.js.map +1 -1
  205. package/dist/src/notice-tags.d.ts +79 -0
  206. package/dist/src/notice-tags.d.ts.map +1 -0
  207. package/dist/src/notice-tags.js +83 -0
  208. package/dist/src/notice-tags.js.map +1 -0
  209. package/dist/src/prose-drafts.d.ts +4 -3
  210. package/dist/src/prose-drafts.d.ts.map +1 -1
  211. package/dist/src/prose-drafts.js +3 -2
  212. package/dist/src/prose-drafts.js.map +1 -1
  213. package/dist/src/reasoning-loss-notice.d.ts +23 -0
  214. package/dist/src/reasoning-loss-notice.d.ts.map +1 -0
  215. package/dist/src/reasoning-loss-notice.js +52 -0
  216. package/dist/src/reasoning-loss-notice.js.map +1 -0
  217. package/dist/src/reasoning-loss.d.ts +24 -0
  218. package/dist/src/reasoning-loss.d.ts.map +1 -0
  219. package/dist/src/reasoning-loss.js +102 -0
  220. package/dist/src/reasoning-loss.js.map +1 -0
  221. package/dist/src/send-tools.d.ts +3 -2
  222. package/dist/src/send-tools.d.ts.map +1 -1
  223. package/dist/src/send-tools.js +3 -2
  224. package/dist/src/send-tools.js.map +1 -1
  225. package/dist/src/sent-rows.js +1 -1
  226. package/dist/src/silent-heartbeat.d.ts +1 -53
  227. package/dist/src/silent-heartbeat.d.ts.map +1 -1
  228. package/dist/src/silent-heartbeat.js +56 -3
  229. package/dist/src/silent-heartbeat.js.map +1 -1
  230. package/dist/src/supplied-text.d.ts +35 -0
  231. package/dist/src/supplied-text.d.ts.map +1 -0
  232. package/dist/src/supplied-text.js +141 -0
  233. package/dist/src/supplied-text.js.map +1 -0
  234. package/dist/src/thinking-drops.d.ts +4 -11
  235. package/dist/src/thinking-drops.d.ts.map +1 -1
  236. package/dist/src/thinking-drops.js +7 -14
  237. package/dist/src/thinking-drops.js.map +1 -1
  238. package/dist/src/tool-args.d.ts +12 -0
  239. package/dist/src/tool-args.d.ts.map +1 -1
  240. package/dist/src/tool-args.js +39 -4
  241. package/dist/src/tool-args.js.map +1 -1
  242. package/dist/src/tool-image-ledger.d.ts.map +1 -1
  243. package/dist/src/tool-image-ledger.js +2 -1
  244. package/dist/src/tool-image-ledger.js.map +1 -1
  245. package/dist/src/tool-presentation.d.ts.map +1 -1
  246. package/dist/src/tool-presentation.js +5 -4
  247. package/dist/src/tool-presentation.js.map +1 -1
  248. package/dist/src/tool-result-guard.d.ts +8 -4
  249. package/dist/src/tool-result-guard.d.ts.map +1 -1
  250. package/dist/src/tool-result-guard.js +23 -11
  251. package/dist/src/tool-result-guard.js.map +1 -1
  252. package/dist/src/tune-out/coordinator.d.ts +3 -2
  253. package/dist/src/tune-out/coordinator.d.ts.map +1 -1
  254. package/dist/src/tune-out/coordinator.js +24 -26
  255. package/dist/src/tune-out/coordinator.js.map +1 -1
  256. package/dist/src/tune-out/tools.d.ts +4 -1
  257. package/dist/src/tune-out/tools.d.ts.map +1 -1
  258. package/dist/src/types/agent.d.ts +63 -18
  259. package/dist/src/types/agent.d.ts.map +1 -1
  260. package/dist/src/types/events.d.ts +18 -8
  261. package/dist/src/types/events.d.ts.map +1 -1
  262. package/dist/src/types/framework.d.ts +58 -0
  263. package/dist/src/types/framework.d.ts.map +1 -1
  264. package/dist/src/types/module.d.ts +27 -13
  265. package/dist/src/types/module.d.ts.map +1 -1
  266. package/dist/src/types/trace.d.ts +34 -1
  267. package/dist/src/types/trace.d.ts.map +1 -1
  268. package/package.json +3 -3
  269. package/src/agent.ts +76 -12
  270. package/src/api/mcp-server-core.ts +3 -14
  271. package/src/api/server.ts +11 -5
  272. package/src/auto-continue.ts +12 -5
  273. package/src/code-execution/isolate/runner.ts +7 -5
  274. package/src/code-execution/isolate/scripts.ts +3 -2
  275. package/src/cut-off-round.ts +98 -0
  276. package/src/framework.ts +3772 -1138
  277. package/src/gate/event-gate.ts +705 -60
  278. package/src/gate/index.ts +9 -1
  279. package/src/gate/reply-judge.ts +512 -0
  280. package/src/gate/types.ts +176 -3
  281. package/src/heartbeat/heartbeat.ts +843 -0
  282. package/src/heartbeat/reminder-time.ts +107 -0
  283. package/src/held-writes.ts +3 -3
  284. package/src/host-presentation.ts +605 -0
  285. package/src/index.ts +5 -1
  286. package/src/line-reader.ts +58 -0
  287. package/src/mcpl/capability-mask.ts +3 -2
  288. package/src/mcpl/channel-registry.ts +139 -53
  289. package/src/mcpl/conversation-router.ts +2 -1
  290. package/src/mcpl/convert-block.ts +17 -4
  291. package/src/mcpl/hook-orchestrator.ts +4 -3
  292. package/src/mcpl/inbound-source.ts +45 -70
  293. package/src/mcpl/modern-connection.ts +11 -7
  294. package/src/mcpl/protocol-family.ts +24 -3
  295. package/src/mcpl/push-handler.ts +2 -2
  296. package/src/mcpl/references.ts +31 -23
  297. package/src/mcpl/server-connection.ts +76 -34
  298. package/src/mcpl/skip-reply-wake.ts +35 -0
  299. package/src/mcpl/tags.ts +13 -2
  300. package/src/mcpl/tool-presence.ts +149 -82
  301. package/src/mcpl/tool-signature.ts +64 -32
  302. package/src/mcpl/toolset-host.ts +212 -110
  303. package/src/mcpl/toolsets-module.ts +277 -91
  304. package/src/mcpl/transport.ts +18 -14
  305. package/src/mcpl/types.ts +32 -13
  306. package/src/module-registry.ts +14 -9
  307. package/src/modules/api/index.ts +4 -2
  308. package/src/modules/discord/index.ts +37 -25
  309. package/src/modules/history/index.ts +30 -18
  310. package/src/modules/sender-name.ts +9 -0
  311. package/src/modules/workspace/answers.ts +151 -0
  312. package/src/modules/workspace/branch-intent.ts +10 -5
  313. package/src/modules/workspace/direct-write.ts +59 -23
  314. package/src/modules/workspace/disk-agreement.ts +52 -21
  315. package/src/modules/workspace/edit-text.ts +7 -5
  316. package/src/modules/workspace/effects.ts +69 -50
  317. package/src/modules/workspace/index.ts +966 -556
  318. package/src/modules/workspace/observe.ts +497 -242
  319. package/src/modules/workspace/read-page.ts +7 -1
  320. package/src/modules/workspace/reconcile.ts +184 -49
  321. package/src/modules/workspace/result-text.ts +2 -0
  322. package/src/modules/workspace/sync.ts +16 -0
  323. package/src/modules/workspace/types.ts +96 -43
  324. package/src/modules/workspace/watcher.ts +8 -3
  325. package/src/notice-tags.ts +84 -0
  326. package/src/prose-drafts.ts +4 -3
  327. package/src/reasoning-loss-notice.ts +64 -0
  328. package/src/reasoning-loss.ts +120 -0
  329. package/src/send-tools.ts +3 -2
  330. package/src/sent-rows.ts +1 -1
  331. package/src/silent-heartbeat.ts +4 -3
  332. package/src/supplied-text.ts +154 -0
  333. package/src/thinking-drops.ts +10 -16
  334. package/src/tool-args.ts +38 -4
  335. package/src/tool-image-ledger.ts +2 -1
  336. package/src/tool-presentation.ts +5 -4
  337. package/src/tool-result-guard.ts +26 -11
  338. package/src/tune-out/coordinator.ts +25 -27
  339. package/src/tune-out/tools.ts +4 -1
  340. package/src/types/agent.ts +63 -18
  341. package/src/types/events.ts +18 -8
  342. package/src/types/framework.ts +59 -0
  343. package/src/types/module.ts +28 -13
  344. package/src/types/trace.ts +36 -1
@@ -9,6 +9,13 @@ import { Agent, type RenderStats } from './agent.js';
9
9
  import { type ToolClass, type ToolClassSource } from './mcpl/tool-classes.js';
10
10
  import { ChannelRegistry } from './mcpl/channel-registry.js';
11
11
  import { ConversationRouter } from './mcpl/conversation-router.js';
12
+ /**
13
+ * The framework's own tools that belong to the host's built-in toolset
14
+ * ("settings", host-presentation.ts) rather than the tool list: the ones an
15
+ * agent reaches for rarely. Modules place theirs with Module.toolPlacement,
16
+ * and every module utility is there too.
17
+ */
18
+ export declare const BUILTIN_TOOLSET_TOOLS: ReadonlySet<string>;
12
19
  import type { SessionUsageSnapshot } from './usage/types.js';
13
20
  import { type DiscordAwarenessView, type DiscordAwarenessCancelReceipt, type DiscordAwarenessMarks, type DiscordAwarenessRetractReceipt } from './recovery/discord-awareness-outbox.js';
14
21
  import { type SurgeryMarkerReceipt, type SurgeryMarksPreview, type OperatorLogEntry, type OperatorLogInput, type OperatorRequester } from './operator-log.js';
@@ -88,11 +95,15 @@ export interface HostModeStatus {
88
95
  * is false until it has. A parked continuation of a turn is counted here
89
96
  * and, as a turn alive, in `activeTurns` and `activeTurnAgents`. */
90
97
  parkedAdmissions: number;
91
- /** Inference requests parked by the quiesce wake gate (while quiesced), or
92
- * simply queued (while serving — non-zero right after a resume until the
93
- * scheduler's next pass consumes them). Continuations of a held turn
94
- * (budget restart, tool results) and a held turn's retry, which a quiesce
95
- * lets through, are never counted. */
98
+ /** Inference requests waiting to start: queued (parked by the quiesce wake
99
+ * gate while quiesced, or, while serving, until the scheduler's next pass
100
+ * takes them), in a scheduler pass's hands, or held by a provider hold (an
101
+ * acceleration or host hold, or a provider's stated wait). There, a start
102
+ * that carries a turn on counts as the wakes merged into it. A start parked
103
+ * on provider admission behind an auxiliary call counts once in
104
+ * `parkedAdmissions` instead, however many wakes are merged into it.
105
+ * Continuations of a turn (budget restart, tool results) and a held turn's
106
+ * retry, which a quiesce lets through, are never counted. */
96
107
  gatedRequests: number;
97
108
  /** code_execution scripts still running that no call is waiting on: left
98
109
  * running after a yield, outside any turn. Quiesce does NOT stop them —
@@ -106,11 +117,12 @@ export interface HostModeStatus {
106
117
  * turn token held with no stream to cancel and no check ahead to stop it
107
118
  * at (a puppet tool turn, a store surgery's reservation, a turn finishing
108
119
  * its last delivery), or a turn with no stream that hasn't reached its
109
- * next check, such as one in a hook that hasn't returned. A turn whose
110
- * stream the abandon cancelled isn't listed, even one still running when
111
- * the grace runs out, as one whose tool-result guard waits on its speech
112
- * may be. Present only after an abandon that left such turns behind, while
113
- * the host stays quiesced. */
120
+ * next check, such as one in a hook that hasn't returned, or a turn whose
121
+ * stream's cancel threw with no check ahead, so that its stream goes on.
122
+ * A turn whose stream the abandon cancelled isn't listed, even one still
123
+ * running when the grace runs out, as one whose tool-result guard waits on
124
+ * its speech may be. Present only after an abandon that left such turns
125
+ * behind, while the host stays quiesced. */
114
126
  unabandonable?: string[];
115
127
  }
116
128
  /**
@@ -168,25 +180,27 @@ interface InferenceToolSnapshot {
168
180
  * this policy after one send, and the framework is the one retry layer: each
169
181
  * retry is a fresh compile, a stop cancels its wait, and the wait is seen.
170
182
  * The decision is membrane's (`@animalabs/membrane/retry`), on the settings
171
- * given (membrane's defaults unless a host passes its own, e.g. from a
172
- * recipe's retry config):
183
+ * given: membrane's, with the two changes below for the turn path, unless a
184
+ * host passes its own (e.g. from a recipe's retry config), which are taken as
185
+ * they are:
173
186
  * - not retryable (400 invalid_request, 401 auth, context_length, safety,
174
187
  * a caller-code error): terminal on the first failure. Retrying them burns
175
188
  * API quota without any chance of success; production traces showed clerk +
176
189
  * reviewer wasting 4 inferences on each 400 due to blind retries.
177
190
  * - overloaded (a 529, or an overloaded error mid-stream): the overloaded
178
- * schedule, jittered (by default 7 tries, 10 s doubling to 5 min, ~10 min).
191
+ * schedule, jittered, 10 s doubling to 5 min (by default 13 tries, where
192
+ * membrane's settings have 7: about 30 min).
179
193
  * - rate limited (429): the base schedule with at least 5 tries.
180
194
  * - any other retryable failure, a stream deadline on a sent request
181
195
  * included (membrane leaves those to its caller): the base schedule (by
182
196
  * default 3 tries, 1 s then 2 s).
183
197
  * A provider's stated wait (`retryAfterMs`) is waited when it is longer than
184
- * the backoff, up to the framework's own cap (PROVIDER_ACCELERATION_MAX_
185
- * COOLDOWN_MS, ten minutes) where a schedule's ceiling is lower; past it the
186
- * turn ends here. (Before this policy runs, the framework holds a resident
187
- * for a stated wait or an acceleration 429 itself, and ends an ephemeral run
188
- * on a wait past that cap; see holdProviderAcceleration and
189
- * nonOwningProviderWait.)
198
+ * the backoff, up to the schedule's ceiling, which by default is at least the
199
+ * framework's own cap (PROVIDER_ACCELERATION_MAX_COOLDOWN_MS, ten minutes);
200
+ * past it the turn ends here. A host's own settings keep their ceilings.
201
+ * (Before this policy runs, the framework holds a resident for a stated wait
202
+ * or an acceleration 429 itself, and ends an ephemeral run on a wait past
203
+ * that cap; see holdProviderAcceleration and nonOwningProviderWait.)
190
204
  * An error that isn't a MembraneError is retried as a retryable failure, on
191
205
  * the base schedule.
192
206
  */
@@ -197,6 +211,40 @@ export declare class DefaultErrorPolicy implements ErrorPolicy {
197
211
  constructor(settings?: RetrySettings);
198
212
  onInferenceError(error: Error, _agentName: string, attempt: number): ErrorAction;
199
213
  }
214
+ export interface ReinitAlertText {
215
+ opening: string;
216
+ message: string;
217
+ }
218
+ export declare const REINIT_MOVES: readonly ['undo', 'redo', 'rollback', 'suppression', 'branch switch'];
219
+ export type ReinitMove = (typeof REINIT_MOVES)[number];
220
+ export declare function refusedWorkAlert(move: ReinitMove, cause: string): ReinitAlertText;
221
+ export declare function restoreAlert(restore: {
222
+ source: string;
223
+ now: string;
224
+ selected: boolean;
225
+ cause: string;
226
+ } & ({
227
+ move: 'rollback';
228
+ managerCurrent?: false;
229
+ } | {
230
+ move: 'suppression';
231
+ managerCurrent: boolean;
232
+ })): ReinitAlertText;
233
+ export declare function disposalAlert(disposal: {
234
+ move: ReinitMove;
235
+ heldWrites?: number;
236
+ reinitFailed?: string;
237
+ cleanupFailed?: string;
238
+ }): ReinitAlertText;
239
+ export declare function longHoldAlert(hold: {
240
+ move: string;
241
+ agentName: string;
242
+ heldSeconds: number;
243
+ queued: number;
244
+ reinitializing?: string;
245
+ waitingForMaintenance: boolean;
246
+ }): ReinitAlertText;
247
+ export declare function opsWebhookText(message: string): string;
200
248
  /**
201
249
  * Whether the poison-history breaker may shed the newest exchange for a
202
250
  * failure: an `invalid_request` at HTTP 400, 413 or 422 or with no status, or
@@ -287,6 +335,7 @@ export declare class AgentFramework {
287
335
  private stopPromise;
288
336
  private stopCompleted;
289
337
  private ownedStoreClosed;
338
+ private ownedStoreManagersClosed;
290
339
  /** Whether the latest stop() got through its teardown with nothing failed:
291
340
  * every step and every wait up to and including the one on awareness
292
341
  * drains, whatever failed after that, in the storage work that finishes
@@ -314,6 +363,8 @@ export declare class AgentFramework {
314
363
  private inferencePolicy;
315
364
  private errorPolicy;
316
365
  private pendingRequests;
366
+ private readonly exhaustedTurns;
367
+ private readonly roundTurns;
317
368
  private running;
318
369
  private loopPromise;
319
370
  /** Quiesce/maintenance mode (issue #122). DELIBERATELY separate from
@@ -365,6 +416,7 @@ export declare class AgentFramework {
365
416
  private providerWaits;
366
417
  /** Wakers for error-policy retry waits in progress: stop() ends them. */
367
418
  private retryWaitWakers;
419
+ private waitingTraceEveryMs;
368
420
  private providerAdmissionClosed;
369
421
  /** Invalidates framework turns still assembling when stop begins. */
370
422
  private lifecycleGeneration;
@@ -379,6 +431,7 @@ export declare class AgentFramework {
379
431
  * framework, and tests set it by cast. */
380
432
  private inboundAcceptanceObserver?;
381
433
  private streamBoundaryEnds;
434
+ private streamCarries;
382
435
  /** A tool boundary injected fresh CONVERSATIONAL input (a real message,
383
436
  * or an edit the coalescer marks as the agent's first view; not a system
384
437
  * marker or a reaction, reaction removal, edit or deletion marker) into
@@ -409,6 +462,7 @@ export declare class AgentFramework {
409
462
  * next turn.
410
463
  */
411
464
  private turnRouting;
465
+ private readonly reasoningLoss;
412
466
  /**
413
467
  * The latest link of each agent's chain of queued prose deliveries. Every
414
468
  * stream queues its own behind it, a fresh turn's included, so the agent's
@@ -478,8 +532,6 @@ export declare class AgentFramework {
478
532
  * by the object, not the run's record (ephemeralRuns), which its cleanup
479
533
  * drops before a cancelled stream may count its last usage. */
480
534
  private ephemeralAgents;
481
- /** Warn only once per Agent instance after utilities are registered. */
482
- private emptyUtilityPermissionWarnings;
483
535
  /** Physical ephemeral frames deliberately disposed by their run watchdog/caller.
484
536
  * The name is single-generation, so these frames still own their terminal
485
537
  * typing/outgoing close even after runEphemeralToCompletion deregisters them. */
@@ -488,6 +540,10 @@ export declare class AgentFramework {
488
540
  * completes (inference:completed), not when a call answers mid-turn.
489
541
  * Drives hard-down escalation — see noteInferenceExhausted. */
490
542
  private consecutiveInferenceFailures;
543
+ private turnRearmMs;
544
+ private turnRearms;
545
+ private exhaustingRearms;
546
+ private statedWaitRuns;
491
547
  /** N consecutive failed inferences ⇒ the agent is treated as hard-down and
492
548
  * escalated loudly to stderr. */
493
549
  private readonly inferenceFailureEscalationThreshold;
@@ -707,6 +763,12 @@ export declare class AgentFramework {
707
763
  * queued, and clears them. While a name is here, no other flush drains
708
764
  * its queue (drainDeferredFor). */
709
765
  private readonly releasesAfterResume;
766
+ private readonly managerReleases;
767
+ private readonly releasedByCleanup;
768
+ private readonly openManagers;
769
+ private readonly openManagerRefs;
770
+ private readonly storeSees;
771
+ private readonly collectedManagers;
710
772
  /** The coalescing commit in flight, if any (see commitCoalescingDurable). */
711
773
  private coalescingCommit;
712
774
  private inferenceRouter;
@@ -743,12 +805,13 @@ export declare class AgentFramework {
743
805
  private readonly thinkingLossIncidents;
744
806
  /** Per live stream that can be noted, its rows so far after the compiled messages (noteRoundSent). */
745
807
  private readonly streamRequestNotes;
808
+ private readonly streamCarried;
746
809
  /** Per pending round's blocks (pendingAssistantBlocks' value), what membrane held as that round's reply
747
810
  * (`roundContent`, its results left out); null where the round has no `roundContent` (XML or fallback). Keyed by
748
811
  * the blocks themselves, so it goes wherever they go. */
749
812
  private readonly pendingRoundSent;
750
- /** Per agent, a round that called code_execution and waits for those calls'
751
- * results before its prose is routed (ScriptRound). */
813
+ /** Per agent, a round that called code_execution or sent, and waits for
814
+ * those calls' results before its prose is routed (ScriptRound). */
752
815
  private scriptRounds;
753
816
  /** Each code_execution result, by the round that dispatched its call: it
754
817
  * settles only that round, even if a newer round reuses its call id. */
@@ -829,10 +892,15 @@ export declare class AgentFramework {
829
892
  /** Host capabilities advertised during the MCP handshake — stored so servers
830
893
  * can be connected at runtime (connectMcplServer) after initialization. */
831
894
  private mcplHostCapabilities;
832
- /** MCPL RFC-014: every toolHints server's tool presence, for the
895
+ /** MCPL RFC-014: every hinted server's tool presence, for the
833
896
  * `toolsets` module's meta-tools and reminders. Made when the first
834
- * server configured with `toolHints: true` is set up; null until then. */
897
+ * server with tool hints (any not configured `toolHints: false`) is set
898
+ * up; null until then. */
835
899
  private toolsetHub;
900
+ /** The host's own toolsets: the built-in "settings" and MCPL server tabs. */
901
+ private hostPresentation;
902
+ /** MCPL servers kept disconnected as closed tabs, with the configuration an open connects them with. */
903
+ private closedTabConfigMap?;
836
904
  /** Inference routing policy from FrameworkConfig — stored so the MCPL
837
905
  * subsystem can be lazily initialized by connectMcplServer when the
838
906
  * framework started with zero configured servers. */
@@ -852,6 +920,9 @@ export declare class AgentFramework {
852
920
  * scheduler, ephemeral admission and puppet entry points.
853
921
  */
854
922
  private surgeryHold;
923
+ private readonly conversationSpawnsInFlight;
924
+ private syncMoveReinit;
925
+ private holdAlertMs;
855
926
  /** Serialize per-server drains so reconnect and an online undo cannot race. */
856
927
  private discordAwarenessDrains;
857
928
  /** The servers whose running pass a later trigger joined
@@ -859,9 +930,10 @@ export declare class AgentFramework {
859
930
  * more what it had already tried. */
860
931
  private discordAwarenessDrainsJoined;
861
932
  private eventGate;
933
+ private judgeWired;
934
+ /** The heartbeat (FrameworkConfig.heartbeat), when the host turns it on. */
935
+ private heartbeat;
862
936
  private usageTracker;
863
- /** Explicit-send or private suppression carried into a tool-result-guard retry. */
864
- private guardRetryTurnSilenced;
865
937
  /** Presentation-only wall-clock zone; persistence remains UTC/epoch. */
866
938
  private readonly timeZone;
867
939
  private constructor();
@@ -879,8 +951,9 @@ export declare class AgentFramework {
879
951
  /**
880
952
  * The error a failed create() rejects with, once what it acquired is
881
953
  * released: the framework it had begun is stopped, with
882
- * FAILED_CREATE_TEARDOWN_TIMEOUT_MS as stop()'s teardownTimeoutMs, and a
883
- * store create() opened is closed even when that stop failed or timed out.
954
+ * FAILED_CREATE_TEARDOWN_TIMEOUT_MS as stop()'s teardownTimeoutMs, the
955
+ * context managers it opened are closed, and a store create() opened is
956
+ * closed even when that stop failed or timed out.
884
957
  * stop() keeps an owned store open when any of its waits fails or times
885
958
  * out, so that it can be called again, but no one can call it on a
886
959
  * framework that create() never returned. When the release doesn't finish
@@ -979,8 +1052,9 @@ export declare class AgentFramework {
979
1052
  /** What start() and addModule() pass before either begins work of a
980
1053
  * lifecycle. A stop() still running refuses both, from the moment it
981
1054
  * claims its attempt until that attempt settles. A failed stop() has
982
- * cleared its attempt, unless it closed an owned store, which is refused
983
- * first. A completed stop() is cleared, and the call goes on as before;
1055
+ * cleared its attempt, unless it closed an owned store, or the context
1056
+ * managers it closes before that store, which are refused first. A
1057
+ * completed stop() is cleared, and the call goes on as before;
984
1058
  * whether a lifecycle should begin after a stop() is #315's question. */
985
1059
  private resetCompletedStop;
986
1060
  /** Register before invoking the body, so the set holds the operation for
@@ -1052,7 +1126,77 @@ export declare class AgentFramework {
1052
1126
  * under a surgery's hold, and no failure is reported for it.
1053
1127
  */
1054
1128
  private withdrawMaintenanceWhenStopping;
1129
+ /**
1130
+ * Wakes the framework holds for `agentName` that need no new event: a
1131
+ * request already queued for it (it runs as soon as the agent is free) and
1132
+ * turns a provider cooldown holds until its end. The reply judge is told of
1133
+ * them beside the gate's own timers, so it can weigh what waiting costs.
1134
+ */
1135
+ private upcomingWakesFor;
1136
+ /**
1137
+ * The heartbeat's ticks and reminders for `agentName`, soonest first, which
1138
+ * the agent's rules decide as they decide a heartbeat push: one the rules
1139
+ * would hold back is only a "maybe" (`certain` false). Each is probed as
1140
+ * the event its delivery is judged by (deliverHeartbeat): a silent tick as
1141
+ * silent, with the text it will bring, so a rule on the content or the
1142
+ * silent flag decides the probe as it will decide the wake. None for an
1143
+ * agent the heartbeat doesn't wake. `whose` words them for the judge ("its
1144
+ * heartbeat") or for the agent ("your heartbeat").
1145
+ */
1146
+ private heartbeatWakesFor;
1147
+ /**
1148
+ * The heartbeat's wake due before a self-wake due at `selfWakeAt` (ms), for
1149
+ * the skip_reply that armed it: the soonest of its ticks and reminders that
1150
+ * the agent's rules, as they stand, let wake it. The confirmation says when
1151
+ * it's due, not that it will wake the agent (skipReplyNote), so a probe
1152
+ * that can't foresee the gate at the wake's time (a gate.js, a rate limit's
1153
+ * tokens then) leaves it true. A failure here costs only that line: the
1154
+ * self-wake is armed already, and the confirmation goes out without it.
1155
+ */
1156
+ private heartbeatWakeBefore;
1157
+ /** The agents the heartbeat wakes: the residents, not conversation forks,
1158
+ * ephemeral runs or the subconscious, which keep windows of their own. */
1159
+ private heartbeatTargets;
1160
+ /**
1161
+ * The event a heartbeat wake is to the gate: a push from the server id
1162
+ * `heartbeat`, as heartbeat-mcpl's ticks and reminders were. So the
1163
+ * agent's rules govern it as they governed those (a rule matching
1164
+ * `source: "heartbeat"`, a `defer` default), and its sleep lets it through,
1165
+ * as it lets that server id through.
1166
+ */
1167
+ private heartbeatGateEvent;
1168
+ /**
1169
+ * Deliver one of the heartbeat's wakes, as heartbeat-mcpl's push events
1170
+ * were: a message-mode tick's or a reminder's text is stored, and the gate
1171
+ * decides the wake by the agent's rules (heartbeatGateEvent), a sleep
1172
+ * letting it through as it lets that server's pushes through. A silent
1173
+ * tick stores no prompt: its turn, when the gate triggers one, is a silent
1174
+ * heartbeat (silent-heartbeat.ts), prose suppressed. As for a stored push,
1175
+ * the wake of the agent the text was delivered to is dropped once a
1176
+ * request of its own has carried and answered the text (readsWriteFor);
1177
+ * another resident's isn't tied to it.
1178
+ */
1179
+ private deliverHeartbeat;
1180
+ /** Handle a call to one of the heartbeat's tools. */
1181
+ private dispatchHeartbeatToolCall;
1182
+ /**
1183
+ * Why `agentName` may not make this heartbeat call, or null when it may.
1184
+ * The heartbeat is the agent's, and wakes its residents: a conversation
1185
+ * fork, an ephemeral run or the subconscious may look at it, but not
1186
+ * change it or set a reminder that would wake someone else. Refused before
1187
+ * the tool runs, as a fork's sleep is.
1188
+ */
1189
+ private heartbeatRefusal;
1190
+ /** Run a heartbeat call, its throw an error result. */
1191
+ private runHeartbeatTool;
1055
1192
  private auxiliaryMembraneFor;
1193
+ /**
1194
+ * The reply judge's calls. None waits: under the agent's holds a call is
1195
+ * refused without being made, and the agent's turn stops the judge. A call
1196
+ * that fails records the wait its provider states, if any, and holds
1197
+ * nothing else.
1198
+ */
1199
+ private judgeMembraneFor;
1056
1200
  /**
1057
1201
  * A conversation agent's auxiliary calls (its context manager's
1058
1202
  * compression). A conversation agent takes no provider gate: admission
@@ -1061,13 +1205,20 @@ export declare class AgentFramework {
1061
1205
  * as a resident's are, so they bind its auxiliary calls too: a held model
1062
1206
  * is refused without a call, and an auxiliary call's own stated wait is
1063
1207
  * recorded for it. (An ephemeral run records nothing, its name being
1064
- * single-use, so its context manager keeps the plain membrane.) Its
1208
+ * single-use, so its context manager's calls are only withdrawn, as below,
1209
+ * through ephemeralAuxiliaryMembraneFor.) Its
1065
1210
  * compression is the background work a resident's is, whether a
1066
1211
  * maintenance tick or a drain after a message starts it, so it is withdrawn
1067
1212
  * as a resident's is: a call made while a surgery holds the store, or once
1068
1213
  * stop() has closed provider admission, is withdrawn without being sent.
1069
1214
  */
1070
1215
  private conversationAuxiliaryMembraneFor;
1216
+ private ephemeralAuxiliaryMembraneFor;
1217
+ private withdrawnOnceReleased;
1218
+ private releaseManager;
1219
+ private trackManager;
1220
+ private closeManager;
1221
+ private closeOpenManagers;
1071
1222
  /** The framework's membrane, with each complete() call passed through
1072
1223
  * `admit` along with the model it names. */
1073
1224
  private membraneAdmitting;
@@ -1094,6 +1245,7 @@ export declare class AgentFramework {
1094
1245
  * inference on it. True = extended in place (held requests stay held). */
1095
1246
  private extendHostProviderHold;
1096
1247
  private holdProviderAcceleration;
1248
+ private rearmExhaustedTurn;
1097
1249
  /**
1098
1250
  * A provider's stated wait on a turn that doesn't own provider admission:
1099
1251
  * a conversation agent's or an ephemeral run's. Left to the error policy,
@@ -1108,7 +1260,8 @@ export declare class AgentFramework {
1108
1260
  * - An ephemeral run's name is single-use, so a wait recorded for it would
1109
1261
  * bind nothing, and its caller is waiting on it. A retryable stated wait
1110
1262
  * up to PROVIDER_ACCELERATION_MAX_COOLDOWN_MS is left to the error policy,
1111
- * slept and retried. A longer one, or one that can't be represented, ends
1263
+ * which sleeps and retries it unless it declines, as a host's own ceiling
1264
+ * can. A longer one, or one that can't be represented, ends
1112
1265
  * the run now ('fail'): it is never retried before the provider's time,
1113
1266
  * and the caller hears why at once.
1114
1267
  * Anything else is the error policy's.
@@ -1142,6 +1295,9 @@ export declare class AgentFramework {
1142
1295
  * ops alert.
1143
1296
  */
1144
1297
  private recordProviderWait;
1298
+ private noteStatedWaitRun;
1299
+ private alertStatedWaitRun;
1300
+ private endStatedWaitRun;
1145
1301
  /**
1146
1302
  * Hold this agent's primary turns for a provider wait on its model. The
1147
1303
  * requests are kept and released together, into one fresh compile, when
@@ -1496,7 +1652,6 @@ export declare class AgentFramework {
1496
1652
  private buildThinkTool;
1497
1653
  /** agent_settings tool definition with module extension fields merged in. */
1498
1654
  private buildAgentSettingsTool;
1499
- private warnEmptyUtilityPermissions;
1500
1655
  private getToolsForAgent;
1501
1656
  /** Available is independent of presentation visibility; execution callers keep this surface. */
1502
1657
  private availableToolsForPresentation;
@@ -1552,6 +1707,7 @@ export declare class AgentFramework {
1552
1707
  cancelAgentRuntimeSettingsTransition(agentName: string, opts?: {
1553
1708
  requester?: OperatorRequester;
1554
1709
  }): AgentRuntimeSettingsSnapshot;
1710
+ private refuseRuntimeSettingsChangeUnderHold;
1555
1711
  /**
1556
1712
  * Wakes that passed the scheduler and now own provider admission while
1557
1713
  * waiting for an in-flight auxiliary call to settle — no turn token yet,
@@ -1627,8 +1783,10 @@ export declare class AgentFramework {
1627
1783
  * CURRENT settings — maintenance may have moved the folded floor and the
1628
1784
  * branch generation, so verdicts are computed at resume time, never reused.
1629
1785
  * Throws ResumeBlockedError (with all failing verdicts) unless `force`.
1630
- * Unavailable previews warn and pass — refusing to resume because the
1631
- * strategy cannot preview would hold hosts hostage to a diagnostic.
1786
+ * Unavailable previews pass, with a warning naming the reason unless it is
1787
+ * `no_preview_support`, a strategy with nothing to preview — refusing to
1788
+ * resume because the strategy cannot preview would hold hosts hostage to a
1789
+ * diagnostic.
1632
1790
  */
1633
1791
  resume(opts?: {
1634
1792
  force?: boolean;
@@ -1876,7 +2034,13 @@ export declare class AgentFramework {
1876
2034
  * see `AutobiographicalStrategy.previewContext` and
1877
2035
  * `Agent.compileWithInjections`.
1878
2036
  *
1879
- * Returns null when the agent's strategy has no fold plan (non-adaptive).
2037
+ * Returns null when the agent's strategy has nothing to preview: one without
2038
+ * `previewContext`, or a non-adaptive `AutobiographicalStrategy` whose select
2039
+ * fits the budget, built from the framework's own copy of context-manager.
2040
+ * Built from another copy, such a strategy throws its `previewContext
2041
+ * requires adaptiveResolution` error here instead, since the manager
2042
+ * recognises only its own copy's `NoFoldPlanToPreviewError`. Over the
2043
+ * budget, a non-adaptive strategy's preview is an infeasible one.
1880
2044
  */
1881
2045
  previewContextSettings(agentName: string, budgetTokens: number, overrides?: Record<string, unknown>, opts?: {
1882
2046
  render?: boolean;
@@ -1897,9 +2061,9 @@ export declare class AgentFramework {
1897
2061
  *
1898
2062
  * Never throws for preview-layer reasons: strategy without previewContext,
1899
2063
  * preview overlap, stale branch generation, the hierarchical (non-
1900
- * adaptive) path, and a context manager that refuses its queries (its
1901
- * strategy's initialization pending or failed) all come back as
1902
- * `{available: false, reason}`. Unknown agent still throws, matching the
2064
+ * adaptive) path within its budget, and a context manager that refuses its
2065
+ * queries (its strategy's initialization pending or failed) all come back
2066
+ * as `{available: false, reason}`. Unknown agent still throws, matching the
1903
2067
  * sibling accessors, and so does a patch whose values the agent refuses,
1904
2068
  * whatever its context manager's state. Whether the strategy takes live
1905
2069
  * tail and pace settings is the manager's to say, so while it refuses, a
@@ -1991,7 +2155,7 @@ export declare class AgentFramework {
1991
2155
  private readAgentRuntimeSettings;
1992
2156
  private validatePersistedAgentRuntimeSettings;
1993
2157
  /** Load resident-set inline caps from framework state, dropping (loudly)
1994
- * anything that fails the same validation the live update enforces. A
2158
+ * anything Number() doesn't read as a finite number of at least 1000. A
1995
2159
  * failed read is logged and boot goes on without them: nothing is lost,
1996
2160
  * since persistToolResultInlineCap reads the stored caps again before it
1997
2161
  * writes one. */
@@ -2076,7 +2240,13 @@ export declare class AgentFramework {
2076
2240
  * `{namespace}/messages`, context log to `{namespace}/context`.
2077
2241
  *
2078
2242
  * Data persists after cleanup for investigation and cross-revert.
2079
- * Call cleanup() when done to release the ContextManager.
2243
+ * Call cleanup() when done with the agent: the agent can't run again. From
2244
+ * the run's end, or from cleanup(), its ContextManager makes no provider
2245
+ * call, and the calls it has out are aborted. It starts no new call while a
2246
+ * surgery holds the store or once stop() has begun, either; one already out
2247
+ * then runs on until stop(), with a store the framework owns, closes the
2248
+ * ContextManager, before the store. Until then the ContextManager stays
2249
+ * open.
2080
2250
  */
2081
2251
  createEphemeralAgent(config: AgentConfig): Promise<{
2082
2252
  agent: Agent;
@@ -2114,8 +2284,9 @@ export declare class AgentFramework {
2114
2284
  * framework drives the stream (emitting traces, logging, dispatching tools).
2115
2285
  * Returns the agent's speech output when it finishes (no more tool calls).
2116
2286
  * Rejects with ProviderWaitNotSleptError when the run ends rather than sleep
2117
- * a retryable failure's stated wait, and with a plain Error for any other
2118
- * ending.
2287
+ * a retryable failure's stated wait longer than the framework's ten-minute
2288
+ * cap, or one it can't represent, and with a plain Error for any other
2289
+ * ending, a stated wait its error policy declines among them.
2119
2290
  *
2120
2291
  * The caller provides a pre-created agent + contextManager (from createEphemeralAgent).
2121
2292
  * The task message should already be in the context manager.
@@ -2146,6 +2317,7 @@ export declare class AgentFramework {
2146
2317
  * hot-reloaded gate.json (same validation as load), so a rule takes effect
2147
2318
  * immediately and survives restart. */
2148
2319
  private static readonly WAKE_RULE_TOOLS;
2320
+ private static readonly JUDGED_WAKE_RULE_TOOLS;
2149
2321
  /** Discoverability for event tags (MCPL RFC-001): the reserved chat:* core,
2150
2322
  * each connected server's declared tag ontology, and gate.js status. */
2151
2323
  private static readonly EVENT_TAGS_TOOL;
@@ -2179,26 +2351,13 @@ export declare class AgentFramework {
2179
2351
  * Mark an inference refusal visibly: react on the message that holds the
2180
2352
  * refused agent's conversational locus (the most recent incoming channel
2181
2353
  * message that isn't a reaction, reaction removal, edit or deletion
2182
- * marker, apart from an edit the coalescer delivers on acceptance as the
2354
+ * marker or a chat:system notice, apart from an edit the coalescer delivers on acceptance as the
2183
2355
  * agent's first view; an ephemeral run has none, so a subagent's refusal
2184
2356
  * marks no message) with a category-specific emoji. Best-effort —
2185
2357
  * failures are logged, never thrown, and non-Discord loci are silently
2186
2358
  * skipped.
2187
2359
  */
2188
2360
  private reactToRefusal;
2189
- /**
2190
- * Shed the newest turn: remove the newest message that isn't a system
2191
- * message, whoever wrote it, with the rest of its exchange (the tool_use
2192
- * turn paired with a tool result, and the whole of a body stored in
2193
- * shards). It adds no marker; the caller keeps one consolidated marker for
2194
- * the episode (updateRewindMarker). The returned record's descriptor says
2195
- * what was removed and its size, never the content, while the raw record
2196
- * survives in the chronicle log for forensics. Returns null when only
2197
- * system messages remain.
2198
- *
2199
- * Shared by the refusal rewind, automatic or forced by `/unstick`, and by
2200
- * the shed after inference exhaustion (quarantinePoisonedHistory).
2201
- */
2202
2361
  private shedNewestTurn;
2203
2362
  /**
2204
2363
  * Maintain exactly ONE consolidated marker for the current rewind episode,
@@ -2242,8 +2401,11 @@ export declare class AgentFramework {
2242
2401
  ok: boolean;
2243
2402
  error?: string;
2244
2403
  agentName?: string;
2245
- /** Agent state at queue time — 'idle' means the turn starts on the next
2246
- * scheduler pass; anything else means it runs after the current turn. */
2404
+ /** Agent state at queue time — 'idle' means no turn holds the agent, so
2405
+ * the turn starts on the next scheduler pass unless a provider hold (a
2406
+ * provider's stated wait, or a capacity cooldown) holds it until the hold
2407
+ * ends, or a start of the agent's that waits for an auxiliary call to
2408
+ * finish goes first; anything else means it runs after the current turn. */
2247
2409
  agentStatus?: string;
2248
2410
  /** True when the host is quiesced: the wake is PARKED, not running, until resume(). */
2249
2411
  quiesced?: boolean;
@@ -2271,7 +2433,7 @@ export declare class AgentFramework {
2271
2433
  * return the snapshot; the operator lever for draining quarantine or
2272
2434
  * advancing merges during a quiesce window.
2273
2435
  *
2274
- * host-status — report the quiesce state (drained / parked wakes /
2436
+ * host-status — report the quiesce state (drained / waiting wakes /
2275
2437
  * scripts left running).
2276
2438
  *
2277
2439
  * release-provider-wait — end an agent's provider wait (a provider's
@@ -2326,6 +2488,14 @@ export declare class AgentFramework {
2326
2488
  * turn alive (no continuation or held retry of one on its way), or it is
2327
2489
  * refused (OperatorActionError 'agent-busy'), and no turn starts until the
2328
2490
  * switch is done.
2491
+ *
2492
+ * Every agent's context manager is re-initialized for the branch before
2493
+ * the store is released (reinitializeManagers). One whose
2494
+ * re-initialization fails raises an ops alert naming its agent
2495
+ * (`context-reinit-failed`), and the switch still resolves. A switch to the
2496
+ * branch the store is already on re-initializes them too, which is how a
2497
+ * manager left refusing by a failed re-initialization is recovered without
2498
+ * a restart.
2329
2499
  */
2330
2500
  switchBranch(name: string): Promise<void>;
2331
2501
  /**
@@ -2337,12 +2507,30 @@ export declare class AgentFramework {
2337
2507
  *
2338
2508
  * The undone branch is saved so `redo()` can restore it.
2339
2509
  * Returns the checkpoint that was undone, or null if nothing to undo.
2510
+ *
2511
+ * The branch moves under every agent sharing the store, so an undo
2512
+ * reserves the store as a surgery does: every agent must be idle, or it is
2513
+ * refused (OperatorActionError 'agent-busy'). It returns once the store has
2514
+ * moved, and the store stays reserved until every agent's context manager
2515
+ * is re-initialized for the new branch, so no turn starts before then. One
2516
+ * whose re-initialization fails raises an ops alert naming its agent
2517
+ * (`context-reinit-failed`). An undo or redo made before the managers are
2518
+ * done moves the store again under the same reservation, and they are
2519
+ * re-initialized for the branch the last one leaves.
2520
+ *
2521
+ * `settled`, present when the store moved, settles once that reservation
2522
+ * is released, every manager re-initialized or its failure alerted, and
2523
+ * never rejects. Await it before work that needs the store free: a
2524
+ * compile on an agent's own context manager, or a write meant to land at
2525
+ * once, which the reservation would defer. An undo or redo that moves the
2526
+ * store again under the same reservation settles with it.
2340
2527
  */
2341
2528
  undoLastTurn(agentName: string, requester?: OperatorRequester): {
2342
2529
  undone: boolean;
2343
2530
  turnIndex?: number;
2344
2531
  fromBranch?: string;
2345
2532
  toBranch?: string;
2533
+ settled?: Promise<void>;
2346
2534
  };
2347
2535
  /** undoLastTurn's work, for a host/command undo already admitted: a stop()
2348
2536
  * begun by a trace of one of its turns doesn't refuse the next. */
@@ -2352,11 +2540,15 @@ export declare class AgentFramework {
2352
2540
  *
2353
2541
  * Switches back to the branch that was active before the last undo.
2354
2542
  * Returns false if there's nothing to redo.
2543
+ *
2544
+ * It reserves the store and re-initializes every agent's context manager
2545
+ * as undoLastTurn() does, and its result's `settled` is undoLastTurn()'s.
2355
2546
  */
2356
2547
  redo(agentName: string, requester?: OperatorRequester): {
2357
2548
  redone: boolean;
2358
2549
  fromBranch?: string;
2359
2550
  toBranch?: string;
2551
+ settled?: Promise<void>;
2360
2552
  };
2361
2553
  /**
2362
2554
  * Append a record to the operator action log and broadcast it as an
@@ -2396,6 +2588,13 @@ export declare class AgentFramework {
2396
2588
  * does. Always release in `finally`: a token nobody clears wedges the fleet.
2397
2589
  */
2398
2590
  private reserveStoreForSurgery;
2591
+ private reinitializeManagers;
2592
+ private reportLongHold;
2593
+ private disposeEmptiedForks;
2594
+ private reportReinitFailures;
2595
+ private reportReinitFailure;
2596
+ private beginSyncMove;
2597
+ private reinitializeAfterSyncMove;
2399
2598
  /**
2400
2599
  * A surgery's marker batch, recorded before its body change. If it can't
2401
2600
  * be recorded, the surgery doesn't start, and the error says what the
@@ -2704,6 +2903,7 @@ export declare class AgentFramework {
2704
2903
  * the template ("trunk") is a dormant warm checkpoint, not a listener.
2705
2904
  */
2706
2905
  private routeConversationIncoming;
2906
+ private writeToFork;
2707
2907
  /**
2708
2908
  * Spawn a persistent per-channel conversation agent ("fork") from the
2709
2909
  * template agent: own ContextManager under `conversations/{name}`, seeded
@@ -2736,13 +2936,15 @@ export declare class AgentFramework {
2736
2936
  * Store the router's counters with the spawn's generation, create the fork
2737
2937
  * the decision names and bind its channel to it, registered in
2738
2938
  * conversationSpawns under the channel until it settles. The store runs
2739
- * inside the spawn's promise, still in routeConversation's synchronous
2740
- * step, so a store that throws rejects the spawn, which each caller reports
2741
- * as a failed spawn, rather than throwing out of routeConversation before
2742
- * the caller's try. routeConversation registers a spawn only when none is
2743
- * in flight for the channel, and only this spawn's settlement removes it,
2744
- * so the entry it removes is its own. It's removed before anyone waiting
2745
- * on it resumes, so a waiter that decides again doesn't find it.
2939
+ * inside the spawn's promise, after it waits out a move's hold, so the
2940
+ * counter lands on the branch the fork is created on; with no hold up, it
2941
+ * runs in routeConversation's synchronous step. Either way a store that
2942
+ * throws rejects the spawn, which each caller reports as a failed spawn,
2943
+ * rather than throwing out of routeConversation before the caller's try.
2944
+ * routeConversation registers a spawn only when none is in flight for the
2945
+ * channel, and only this spawn's settlement removes it, so the entry it
2946
+ * removes is its own. It's removed before anyone waiting on it resumes, so
2947
+ * a waiter that decides again doesn't find it.
2746
2948
  *
2747
2949
  * It binds only while the fork it created is still the agent registered
2748
2950
  * under its name. stop() ends each live fork and unbinds the channels
@@ -2810,11 +3012,6 @@ export declare class AgentFramework {
2810
3012
  * explicit-prose agent's natural plain reply bounced with nowhere to go
2811
3013
  * (Rhys's first portal mention: a 2,320-char reply stranded).
2812
3014
  *
2813
- * Wording: option 1 teaches the `>>` destination prefix, which delivers for
2814
- * BOTH legacy (host-inferred) and explicit prose-routing agents. The
2815
- * previous "simply write your reply as normal text" was a false promise
2816
- * under explicit routing (the metadata flags it set had no consumers).
2817
- *
2818
3015
  * Human-readable names wherever the surface provided them — a mind reading
2819
3016
  * this should see WHO addressed it WHERE, not a wall of snowflake ids. Raw
2820
3017
  * ids remain only inside the tool-argument instructions, where they are the
@@ -3053,7 +3250,10 @@ export declare class AgentFramework {
3053
3250
  /** Record plain-prose segments this turn suppressed without drafts (proseRouting=disabled, or a round withheld before its scripts returned). */
3054
3251
  private recordProseSuppression;
3055
3252
  /**
3056
- * Silenced plain speech: an explicit send holds it as resendable drafts; a
3253
+ * Silenced plain speech: an explicit send that may have posted where it was
3254
+ * going holds it as resendable drafts (in a round that calls `drafts` and
3255
+ * sends nothing else, 'kept', its plain speech is kept and counted
3256
+ * instead); a
3057
3257
  * deliberate silence (skip_reply, a silent turn, or a private think in
3058
3258
  * the same native round, where that policy applies: an XML-mode round has
3059
3259
  * no verbatim content to route live, so its prose is routed at the turn's
@@ -3061,9 +3261,12 @@ export declare class AgentFramework {
3061
3261
  * counted for the receipt, never drafted. `segments` are the runs exactly
3062
3262
  * as written (splitProseRuns), so a draft keeps the resident's words byte
3063
3263
  * for byte. What it holds, keeps or moves is the round's turn's
3064
- * (round.routing), whenever the hold runs.
3264
+ * (round.routing), whenever the hold runs. Hybrid speech under a send goes
3265
+ * through routeSilencedHybrid.
3065
3266
  */
3066
3267
  private holdSilencedProse;
3268
+ private routeSilencedHybrid;
3269
+ private sendHoldText;
3067
3270
  /**
3068
3271
  * Hold plain speech as drafts (src/prose-drafts.ts) instead of
3069
3272
  * letting it vanish: journaled durably and recorded for the receipt of the
@@ -3172,6 +3375,21 @@ export declare class AgentFramework {
3172
3375
  /** Why a draft can't be resent now (dismissed, or possibly already posted
3173
3376
  * without the resident's confirmation), or undefined when it can. */
3174
3377
  private resendRefusal;
3378
+ /** Why a heartbeat's turn holds its plain speech, in a held-draft notice ("because …"). */
3379
+ private static readonly HEARTBEAT_HOLD_BECAUSE;
3380
+ /**
3381
+ * Locus mode's delivery of plain speech to the turn's frozen locus. A
3382
+ * heartbeat's turn with no locus of its own (TurnRouting.heartbeat) holds
3383
+ * the words as a draft instead of failing the delivery: nobody was waiting
3384
+ * for them, and the agent may send them where it chooses.
3385
+ */
3386
+ private routeLocusSpeech;
3387
+ /** The mark a framework wake takes from a heartbeat's turn with no locus
3388
+ * of its own (InferenceRequest.heartbeatTurn), so the turn it opens is a
3389
+ * heartbeat's too; nothing for any other turn. */
3390
+ private heartbeatTurnMark;
3391
+ /** Hold a heartbeat turn's plain speech as drafts ('no-destination'), named by `round`'s notice. */
3392
+ private holdHeartbeatProse;
3175
3393
  /** Record a successful plain-prose delivery for this turn's receipt. */
3176
3394
  private recordProseDelivery;
3177
3395
  /**
@@ -3188,6 +3406,8 @@ export declare class AgentFramework {
3188
3406
  * ([discord-send-failed]); this is the success half.
3189
3407
  */
3190
3408
  private appendProseDeliveryReceipt;
3409
+ private nameUnpostedSpeech;
3410
+ private noteFailedTurnEnd;
3191
3411
  /**
3192
3412
  * The closed-channel note alone, in a send's words, at explicit mode's turn
3193
3413
  * end, which has no `[delivered]` receipt since the agent named every
@@ -3199,6 +3419,13 @@ export declare class AgentFramework {
3199
3419
  * mid-turn. No-op otherwise.
3200
3420
  */
3201
3421
  private appendClosedChannelNoteAlone;
3422
+ /**
3423
+ * Tell a heartbeat's turn, before it compiles, that its plain speech has
3424
+ * no destination (TurnRouting.heartbeat): the last `[routing]` notice may
3425
+ * name a channel, and this turn's words won't go there. It leaves the
3426
+ * announced baseline alone (announceLocusIfChanged).
3427
+ */
3428
+ private noticeHeartbeatTurn;
3202
3429
  /**
3203
3430
  * Announce-on-change locus notice (turn-frozen routing). Appends a durable
3204
3431
  * `[routing]` window message when the turn's effective outbound locus
@@ -3312,12 +3539,13 @@ export declare class AgentFramework {
3312
3539
  * more rows than that have come since the last clock; a window with no
3313
3540
  * clock row is read whole once, and then takes one (planClock). */
3314
3541
  private lastClockOf;
3542
+ private agentSees;
3315
3543
  /**
3316
3544
  * Weigh a message that no tool boundary of the agent's open logical turn
3317
3545
  * will weigh: one that would re-pin the locus becomes one of the turn's
3318
- * arrivals (TurnRouting.arrivals). A message tune-out diverted
3319
- * (metadata.tuneOut) never enters a resident's compiled view, so the agent
3320
- * won't see it, and it moves nothing.
3546
+ * arrivals (TurnRouting.arrivals). A message the agent's own view leaves
3547
+ * out, such as one a tune-out diverted (metadata.tuneOut), never enters
3548
+ * its compiled view, so the agent won't see it, and it moves nothing.
3321
3549
  */
3322
3550
  private noteArrival;
3323
3551
  /**
@@ -3340,6 +3568,7 @@ export declare class AgentFramework {
3340
3568
  * left running when it handed the turn on.
3341
3569
  */
3342
3570
  private showTurnTyping;
3571
+ private heardSince;
3343
3572
  /**
3344
3573
  * The channel of the turn's newest arrival whose message is still in the
3345
3574
  * agent's store (TurnRouting.arrivals). A message removed since it was
@@ -3387,6 +3616,7 @@ export declare class AgentFramework {
3387
3616
  * locus-eligible.
3388
3617
  */
3389
3618
  private recordChannelAutoOpenNotice;
3619
+ private tellReasoningLoss;
3390
3620
  /**
3391
3621
  * Write a builder's channel notices in order, each on its own: one that
3392
3622
  * can't be written is logged, and the rest are still written. A reader's
@@ -3637,6 +3867,7 @@ export declare class AgentFramework {
3637
3867
  private draftStateNow;
3638
3868
  /** Locus-preserving explicit publication. Source remains byte-identical in Chronicle. */
3639
3869
  private deliverHybridProse;
3870
+ private deliverHybridEnvelope;
3640
3871
  /** `>>skip_reply {{unsent}}` and its hybrid form: set the latest bounce
3641
3872
  * draft aside — unless it is being sent right now, which a dismissal
3642
3873
  * can't call back: the resident is told instead. So are a dismissal whose
@@ -3693,7 +3924,8 @@ export declare class AgentFramework {
3693
3924
  * abandon or a stop of a registered agent settles the turn as it settles a
3694
3925
  * turn's start (endStoppedStart: one inference:aborted, the turn settled,
3695
3926
  * the gate released). Any other drop ends it as a start dropped before it
3696
- * sends anything ends. That frame, if it hasn't let go of its token yet,
3927
+ * sends anything ends, and settles a registered ephemeral run's turn with
3928
+ * the drop's reason. That frame, if it hasn't let go of its token yet,
3697
3929
  * ends on its own and settles nothing. What was deferred for the agent
3698
3930
  * lands now, or at that frame's end.
3699
3931
  */
@@ -3703,8 +3935,9 @@ export declare class AgentFramework {
3703
3935
  * admission, the hold installs nothing (holdForProviderWait,
3704
3936
  * holdProviderAcceleration), so no retry follows the turn's
3705
3937
  * inference:failed, and the turn ends as a retry a stop cancelled ends, with
3706
- * an inference:aborted saying so. Nothing is written. True when it ended
3707
- * the turn.
3938
+ * an inference:aborted saying so. Nothing is written but the
3939
+ * [speech-not-posted] notice, for speech the turn's rounds left unposted.
3940
+ * True when it ended the turn.
3708
3941
  */
3709
3942
  private endFailureAtStop;
3710
3943
  /**
@@ -3739,6 +3972,42 @@ export declare class AgentFramework {
3739
3972
  * terminal, and the caller's goes with it.
3740
3973
  */
3741
3974
  private takeStartStop;
3975
+ /**
3976
+ * Cancel a stream the framework stops, under `kind`, the mark that tells
3977
+ * the stream's end apart from a caller's stop (frameworkCancelledStreams).
3978
+ * A mark records a cancel that happened, so a cancel that throws takes its
3979
+ * mark back, leaving an earlier mark of the same stream as it was, and the
3980
+ * throw goes on to the caller. With no `kind` (the agent holds no stream),
3981
+ * nothing is marked.
3982
+ */
3983
+ private cancelUnderMark;
3984
+ /**
3985
+ * Cancel a live stream the framework ends at a tool boundary (`site` says
3986
+ * where), under its mark. A cancel that throws leaves the stream going: its
3987
+ * mark is taken back (cancelUnderMark), `onFailed` undoes what the site
3988
+ * did ahead of the cancel, and the failure is logged. The stream waits for
3989
+ * the round's results, which the boundary doesn't send, and the turn holds
3990
+ * its token until the stream ends, as an abort does when its own cancel
3991
+ * goes through. Only an operator's abort or stop, or an ephemeral run's
3992
+ * idle watchdog, comes back to it, so an operator alert says so too.
3993
+ * Returns whether the cancel went through.
3994
+ */
3995
+ private cancelLiveStream;
3996
+ /**
3997
+ * Cancel a stream a start compiled and won't send (`site` says why).
3998
+ * Membrane's yielding stream starts its request when it is first iterated,
3999
+ * and this one never is, so it has sent nothing: a cancel that throws is
4000
+ * logged, and the start's cleanup goes on as if it had worked.
4001
+ */
4002
+ private cancelUnsentStream;
4003
+ /**
4004
+ * Cancel a stream that no longer owns its agent: the agent was replaced or
4005
+ * removed, or a newer stream took it. Its frame settles nothing and is
4006
+ * leaving, so a cancel that throws is logged and the frame leaves all the
4007
+ * same. Thrown on, it would reject driveStream's promise, which nothing
4008
+ * awaits but stop().
4009
+ */
4010
+ private cancelSupersededStream;
3742
4011
  /**
3743
4012
  * End a start that a stop reached before it sent anything, through the
3744
4013
  * terminal the same stop gets on a live stream: a caller's stop as
@@ -3771,8 +4040,7 @@ export declare class AgentFramework {
3771
4040
  * exists only through the private closure handed to ModuleRegistry
3772
4041
  * (ctx.callTool → executeToolCallFrom with {kind:'module'}), which is exempt
3773
4042
  * from agent allowlists. Registered agents' allowedTools is enforced at
3774
- * dispatch, including namespaced utility names; utils only grants the
3775
- * list/describe/run slot. Genuinely unidentified public callers (including
4043
+ * dispatch, including namespaced utility names. Genuinely unidentified public callers (including
3776
4044
  * unknown legacy names) remain unrestricted. Framework-created identities
3777
4045
  * are refused while unregistered, even if their configured list allows it.
3778
4046
  */
@@ -3830,10 +4098,19 @@ export declare class AgentFramework {
3830
4098
  * assembled field by field (as unit tests do) needs no setup for it.
3831
4099
  */
3832
4100
  private toolsetActCalls?;
4101
+ private puppetChanges?;
4102
+ /** RFC-014 §6.1: a change reaches the agent once, so it goes with a result
4103
+ * only where the result is stored in an agent's window (the puppet's) or
4104
+ * handed to an agent awaiting it; null where it may not reach one. */
4105
+ private changeTaker;
3833
4106
  /** A toolsets--act call resolved (resolveAct) to the call of the server's
3834
4107
  * tool it makes, under that tool's model-facing name and with its
3835
4108
  * arguments, its id kept; or the reason it can't be sent. */
3836
4109
  private resolveToolsetAct;
4110
+ /** A toolsets--act call a host toolset resolved (HostPresentation.resolveAct):
4111
+ * its refusal answered, or the tool's own call dispatched in its place,
4112
+ * with the act's id, so its result is the act's. */
4113
+ private dispatchHostAct;
3837
4114
  /**
3838
4115
  * RFC-014 §8.2: a toolsets--act call from the agent (the model's, or a
3839
4116
  * script's) goes down the path a direct call of the server's tool takes
@@ -3845,27 +4122,26 @@ export declare class AgentFramework {
3845
4122
  * before anything is sent.
3846
4123
  */
3847
4124
  private dispatchToolsetAct;
3848
- /**
3849
- * RFC-014 §6.2: a tool result that goes to the agent, with the tool change
3850
- * its hints made (applied as the result was read) told after the server's
3851
- * content; taking it means it isn't told again as a notice. The result
3852
- * itself when there's none, as for every server without toolHints.
3853
- */
3854
- private withToolsetChange;
3855
4125
  /** A programmatic call of an MCPL tool: `serverId` and `prefix` as
3856
4126
  * resolveMcplTool matched them, or as toolsets--act resolved them
3857
- * (toolsetActCalls). Its RFC-014 tool change isn't shown with its result,
3858
- * which goes to its caller, not necessarily to the agent: it's told as a
3859
- * notice (ToolsetController.tellUnlessClaimed). */
4127
+ * (toolsetActCalls). Its RFC-014 tool change goes with its result only
4128
+ * where the result is stored in an agent's window or handed to an agent
4129
+ * awaiting it (changeTaker); any other caller's
4130
+ * result may never reach one, so its change is told as a notice
4131
+ * (ToolsetController.tellUnlessClaimed). */
3860
4132
  private executeMcplToolCall;
4133
+ private withWholeChange;
4134
+ private withActStateHint;
3861
4135
  /** Event-pushing wrapper for the model-driven dispatch path. */
3862
4136
  private dispatchCodeExecutionToolCall;
4137
+ private decideWaitingRound;
3863
4138
  /**
3864
4139
  * A model-issued tool's result has arrived. When it answers the last of
3865
- * the code_execution calls a round waits on (ScriptRound), the round's
3866
- * prose is routed now, its scripts' calls counted.
4140
+ * the code_execution calls and sends a round waits on (ScriptRound), the
4141
+ * round's prose is routed now, its scripts' calls counted.
3867
4142
  */
3868
4143
  private settleScriptRound;
4144
+ private sendReachOf;
3869
4145
  /**
3870
4146
  * Whether a code_execution call watches a script that can change its
3871
4147
  * round's routing, so the round waits for the call (ScriptRound): a run's
@@ -4169,8 +4445,9 @@ export declare class AgentFramework {
4169
4445
  }>;
4170
4446
  /**
4171
4447
  * Find the MCPL server for a tool: [serverId, prefix], or null.
4172
- * The tool listing decides: the server whose tools/list offered the
4173
- * name, after its tool policy, as of the last tool refresh (a server that
4448
+ * The tool listing decides: the server whose tools/list listed the name
4449
+ * (offered to the model, or an RFC-014 dynamic tool, which dispatch then
4450
+ * refuses by that name unless the published list or the server's latest tools/list puts it as static), after its tool policy, as of the last tool refresh (a server that
4174
4451
  * closed since keeps its names until the next one). A name the listing
4175
4452
  * doesn't hold (invented by the model, or no longer listed) goes to the
4176
4453
  * longest matching prefix. Prefixes that meet, such as `foo` and
@@ -4183,10 +4460,13 @@ export declare class AgentFramework {
4183
4460
  * while unregistered. Genuine legacy caller names retain their surface. */
4184
4461
  private canAgentUseTool;
4185
4462
  private agentToolPermissionFailure;
4463
+ private markedInputFailure;
4464
+ private cutOffResults;
4186
4465
  /**
4187
- * A dispatched call answered without running its tool. RFC-007's lifecycle
4188
- * forgets it, and its result says it was refused (`ToolResult.refused`), both
4189
- * from here, so the two can't disagree.
4466
+ * A call answered without running its tool: one the dispatcher refused, or
4467
+ * one in the last round of a response the output limit cut off. RFC-007's
4468
+ * lifecycle forgets it, and its result says it was refused
4469
+ * (`ToolResult.refused`), both from here, so the two can't disagree.
4190
4470
  */
4191
4471
  private refusedResult;
4192
4472
  /**
@@ -4207,7 +4487,8 @@ export declare class AgentFramework {
4207
4487
  * A call as its round's routing counts it, made directly, or by a script
4208
4488
  * and reaching the host while a run or wait call of the round watches it
4209
4489
  * (ScriptRound). A skip_reply refused, because the agent's allowedTools
4210
- * doesn't name it or because this host can't set the wake it asks for, is
4490
+ * doesn't name it, because its arguments are refused (markedInputRefusal)
4491
+ * or because this host can't set the wake it asks for, is
4211
4492
  * marked refused: it keeps its own round private and silences nothing after
4212
4493
  * it. A refusal withholds the call's effect, not the model's choice to keep
4213
4494
  * its words private. Any other call the list refuses posted nothing, so it
@@ -4275,14 +4556,16 @@ export declare class AgentFramework {
4275
4556
  */
4276
4557
  private placeWakeLines;
4277
4558
  /** Whether `entry`'s own stored entry is the newest in `agent`'s window,
4278
- * clock rows and stored context injections after it aside: a channel
4279
- * message by its server, channel and message id, a push event by its
4280
- * server and event id, and never one a tune-out holds. Past
4559
+ * clock rows, stored context injections and rows the agent's own view
4560
+ * leaves out after it aside: a channel message by its server, channel and
4561
+ * message id, a push event by its server and event id, and never one the
4562
+ * agent's view leaves out, such as one a tune-out holds. Past
4281
4563
  * NEWEST_SCAN_ROWS such rows, it answers no. */
4282
4564
  private isNewestIn;
4283
4565
  /** Where addMessage delivers: the named agent, else the primary, else the
4284
4566
  * first registered agent. Undefined when there is no such agent. */
4285
4567
  private deliveryAgent;
4568
+ private noteSpokenTo;
4286
4569
  /** The notes addMessage takes for a message it stored: an arrival for the
4287
4570
  * agent when none of its turns is alive or the message was assembled for
4288
4571
  * the start now beginning (no tool boundary will weigh it), and one for
@@ -4804,12 +5087,9 @@ export declare class AgentFramework {
4804
5087
  * nothing new costs less than a write no wake brings the agent to read
4805
5088
  * or answer. */
4806
5089
  private deferredWriteDone;
4807
- /** The mark a wake for `agentName` takes for the write it was queued with
4808
- * (`placement`, addMessage's out-param): set only when that write was
4809
- * deferred for that agent, since a stored write's wake starts the turn
4810
- * that reads it. The scheduler drops the wake once the write needs
4811
- * nothing more of the agent (deferredWriteDone). */
4812
- private readsDeferredFor;
5090
+ private storedMessageDone;
5091
+ private writeAnswered;
5092
+ private readsWriteFor;
4813
5093
  private editMessage;
4814
5094
  private removeMessage;
4815
5095
  private getMessage;
@@ -4979,6 +5259,7 @@ export declare class AgentFramework {
4979
5259
  /** The restarts' claims (mcpRestartClaims), created on first use, as the
4980
5260
  * modern connections are. */
4981
5261
  private restartClaims;
5262
+ private closedTabConfigs;
4982
5263
  private legacyConnectAborts;
4983
5264
  /**
4984
5265
  * Hold a server id for one connect or disconnect, until `release()`.
@@ -5160,17 +5441,78 @@ export declare class AgentFramework {
5160
5441
  * logged here rather than replacing the failure the connect reports.
5161
5442
  */
5162
5443
  private closeFailedRuntimeConnect;
5444
+ /** RFC-014: who held the name `toolsets` at startup (a module given to
5445
+ * create(); a server's toolPrefix of it is refused), so a server that
5446
+ * leaves toolHints out has none for the life of this framework; null when
5447
+ * the name was free. */
5448
+ private toolsetsNameHeldAtStart;
5449
+ /** At startup: note who holds the name the meta-tools need, and say which
5450
+ * servers that leaves without hints. */
5451
+ private reserveToolsetsName;
5452
+ /**
5453
+ * RFC-014: whether a server has tool hints. Only an MCPL (legacy-family)
5454
+ * server can: a modern MCP server never has them. `true` and `false` are
5455
+ * as configured. Left out (or null) they're on, wherever the name
5456
+ * `toolsets` the meta-tools need is free: no other module holds it and no
5457
+ * server's prefix is it, now or at startup. So a configuration that loaded
5458
+ * when hints were opt-in still loads. A name held at startup stays held
5459
+ * for the framework's life.
5460
+ */
5461
+ private hintsFor;
5163
5462
  /**
5164
5463
  * The host capabilities offered to one server: the host's own, plus
5165
- * RFC-014's `toolHints` where its configuration asks for them. Without it,
5166
- * the very object every server is offered.
5464
+ * RFC-014's `toolHints` unless its configuration turns them off
5465
+ * (`toolHints: false`). With them off, the very object every server is
5466
+ * offered.
5167
5467
  */
5168
5468
  private mcplHostCapabilitiesFor;
5169
5469
  /** RFC-014: every toolHints server's presence, made on first use. */
5170
5470
  private toolsets;
5171
- /** RFC-014: the `toolsets` module (toolsets--open, --act, --look,
5172
- * --close), registered once, by the first server configured with
5173
- * toolHints. Its tools don't change after that. */
5471
+ /**
5472
+ * The host's own toolsets (host-presentation.ts): the built-in "settings"
5473
+ * toolset and each MCPL server's tab. State is kept beside the store, in
5474
+ * `config/toolsets.json`; with no store path, in memory only.
5475
+ */
5476
+ private makeHostPresentation;
5477
+ /** Whether a name is a module utility (and not a tool of its module, which takes the name). */
5478
+ private isModuleUtility;
5479
+ /** Whether an agent has the host's own toolsets: the meta-tools registered, and
5480
+ * usable by it (the subconscious keeps its own small surface). */
5481
+ /**
5482
+ * What a call of the removed `utils` is answered: where utilities went, as
5483
+ * this agent can reach them. One that can't use the built-in toolset is
5484
+ * told to call a utility by its own name and which ones it may call.
5485
+ */
5486
+ private utilsRemoved;
5487
+ private hostToolsetsFor;
5488
+ /**
5489
+ * Whether a host tool belongs to the built-in toolset: the framework's own
5490
+ * rarely-used ones (BUILTIN_TOOLSET_TOOLS), a module's that it places there
5491
+ * (Module.toolPlacement), and every module utility.
5492
+ */
5493
+ private placedInBuiltin;
5494
+ /**
5495
+ * The tool list an agent's requests carry, from the tools it may call: its
5496
+ * host presentation applied (the built-in toolset's tools, the servers it
5497
+ * has as tabs and its hidden tools left out; a utility never in it), as
5498
+ * every request of a registered agent has it (with its own tool
5499
+ * presentation, hidden tools and descriptions, applied first). For a stream that isn't
5500
+ * registered yet, such as a fork whose orientation is written before its
5501
+ * run starts, the host says whether it will be able to call
5502
+ * `toolsets--open` and `toolsets--act` (`canUseMeta`); left out, the agent
5503
+ * registered under that name is asked. Presentation it chose itself (open
5504
+ * toolsets, tabs) is read under that name, so a new name starts from the
5505
+ * configured presentation.
5506
+ */
5507
+ presentedTools(agentName: string, tools: import('./types/index.js').ToolDefinition[], canUseMeta?: boolean): import('./types/index.js').ToolDefinition[];
5508
+ /** The host presentation of a server's tools, for the tool list: the agent's
5509
+ * view, less the built-in toolset and the servers it has as tabs. */
5510
+ private headerTools;
5511
+ /** The `toolsets` module (toolsets--open, --act, --look, --close): the
5512
+ * meta-tools of the host's own toolsets and of RFC-014 servers' toolsets.
5513
+ * Registered once, at create(), unless a module given to create() holds
5514
+ * the name; a server with toolHints: true then can't have hints, and its
5515
+ * connect is refused here. Its tools don't change after that. */
5174
5516
  private ensureToolsetsModule;
5175
5517
  /** RFC-014 §5.3: after a (re)connect whose policy has settled, read what
5176
5518
  * the server holds open and adopt it. In the background: its notices are
@@ -5394,6 +5736,9 @@ export declare class AgentFramework {
5394
5736
  listMcplServers(): Array<{
5395
5737
  id: string;
5396
5738
  connected: boolean;
5739
+ /** Kept disconnected as a closed tab (host-presentation.ts) until an
5740
+ * agent's toolsets--open, an operator's connect or a restart connects it. */
5741
+ closedTab: boolean;
5397
5742
  retrying: boolean;
5398
5743
  /** Which engine serves it: `legacy` (MCP 2024-11-05 + MCPL) or `modern`
5399
5744
  * (MCP 2026-07-28), as its configuration selects; null when the
@@ -5496,7 +5841,9 @@ export declare class AgentFramework {
5496
5841
  */
5497
5842
  private refreshMcplTools;
5498
5843
  /**
5499
- * Report operator tool-name patterns that match no model-facing tool:
5844
+ * Report operator tool-name patterns that match no tool name: one the
5845
+ * model is offered, or an RFC-014 dynamic tool's listed name, which its
5846
+ * class rules and lifecycle selectors match as a direct call's would:
5500
5847
  * `toolClassOverrides` keys and each server's `toolLifecycle.observe.tools`
5501
5848
  * / `toolLifecycle.inputs.tools`. These match `<toolPrefix>--<tool>`, and
5502
5849
  * the default prefix is `mcpl--<serverId>`, so a pattern written against
@@ -5511,8 +5858,9 @@ export declare class AgentFramework {
5511
5858
  private checkToolPatterns;
5512
5859
  /** Every tool name the framework offers to anyone: the shared board plus
5513
5860
  * each agent's own surface, before presentation visibility (a hidden tool
5514
- * is still callable, so classes and lifecycle still apply to it). */
5515
- private modelFacingToolNames;
5861
+ * is still callable, so classes and lifecycle still apply to it), and
5862
+ * every name an MCPL server lists, a dynamic tool's included. */
5863
+ private patternableToolNames;
5516
5864
  /**
5517
5865
  * Handle a tools/list_changed notification with collapse logic.
5518
5866
  * At most 2 refresh cycles can be in-flight: one running and one pending.
@@ -5645,13 +5993,8 @@ export declare class AgentFramework {
5645
5993
  * authenticate bytes from another surface.
5646
5994
  */
5647
5995
  private dispatchSaveImageToolCall;
5648
- /** The `utils` meta-tool: list/describe/run over module utilities
5649
- * (Module.getUtilities). Shared by the model-facing dispatcher, which a
5650
- * running code_execution script's calls take too, and executeToolCallFrom,
5651
- * which the puppet and a host reach through executeToolCall and a module
5652
- * through callTool. */
5653
- private handleUtilsToolCall;
5654
- private dispatchUtilsToolCall;
5996
+ private readAgentSettings;
5997
+ private settingsChangedSince;
5655
5998
  private dispatchAgentSettingsToolCall;
5656
5999
  /** Aggregate the event-tag vocabulary: reserved chat:* core + each connected
5657
6000
  * server's declared tag ontology + gate.js status. */