@animalabs/agent-framework 0.27.0 → 0.28.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 (234) hide show
  1. package/README.md +56 -15
  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 +69 -11
  5. package/dist/src/agent.js.map +1 -1
  6. package/dist/src/api/server.d.ts.map +1 -1
  7. package/dist/src/api/server.js +4 -2
  8. package/dist/src/api/server.js.map +1 -1
  9. package/dist/src/auto-continue.d.ts +3 -2
  10. package/dist/src/auto-continue.d.ts.map +1 -1
  11. package/dist/src/auto-continue.js +4 -3
  12. package/dist/src/auto-continue.js.map +1 -1
  13. package/dist/src/cut-off-round.d.ts +24 -0
  14. package/dist/src/cut-off-round.d.ts.map +1 -0
  15. package/dist/src/cut-off-round.js +87 -0
  16. package/dist/src/cut-off-round.js.map +1 -0
  17. package/dist/src/framework.d.ts +304 -89
  18. package/dist/src/framework.d.ts.map +1 -1
  19. package/dist/src/framework.js +2577 -678
  20. package/dist/src/framework.js.map +1 -1
  21. package/dist/src/gate/event-gate.d.ts +99 -3
  22. package/dist/src/gate/event-gate.d.ts.map +1 -1
  23. package/dist/src/gate/event-gate.js +538 -13
  24. package/dist/src/gate/event-gate.js.map +1 -1
  25. package/dist/src/gate/index.d.ts +2 -1
  26. package/dist/src/gate/index.d.ts.map +1 -1
  27. package/dist/src/gate/index.js +1 -0
  28. package/dist/src/gate/index.js.map +1 -1
  29. package/dist/src/gate/reply-judge.d.ts +116 -0
  30. package/dist/src/gate/reply-judge.d.ts.map +1 -0
  31. package/dist/src/gate/reply-judge.js +467 -0
  32. package/dist/src/gate/reply-judge.js.map +1 -0
  33. package/dist/src/gate/types.d.ts +161 -0
  34. package/dist/src/gate/types.d.ts.map +1 -1
  35. package/dist/src/heartbeat/heartbeat.d.ts +184 -0
  36. package/dist/src/heartbeat/heartbeat.d.ts.map +1 -0
  37. package/dist/src/heartbeat/heartbeat.js +752 -0
  38. package/dist/src/heartbeat/heartbeat.js.map +1 -0
  39. package/dist/src/heartbeat/reminder-time.d.ts +5 -0
  40. package/dist/src/heartbeat/reminder-time.d.ts.map +1 -0
  41. package/dist/src/heartbeat/reminder-time.js +107 -0
  42. package/dist/src/heartbeat/reminder-time.js.map +1 -0
  43. package/dist/src/index.d.ts +4 -0
  44. package/dist/src/index.d.ts.map +1 -1
  45. package/dist/src/index.js +2 -0
  46. package/dist/src/index.js.map +1 -1
  47. package/dist/src/mcpl/capability-mask.d.ts.map +1 -1
  48. package/dist/src/mcpl/capability-mask.js +3 -2
  49. package/dist/src/mcpl/capability-mask.js.map +1 -1
  50. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  51. package/dist/src/mcpl/channel-registry.js +2 -1
  52. package/dist/src/mcpl/channel-registry.js.map +1 -1
  53. package/dist/src/mcpl/inbound-source.d.ts +26 -10
  54. package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
  55. package/dist/src/mcpl/inbound-source.js +40 -69
  56. package/dist/src/mcpl/inbound-source.js.map +1 -1
  57. package/dist/src/mcpl/server-connection.d.ts +18 -8
  58. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  59. package/dist/src/mcpl/server-connection.js +50 -10
  60. package/dist/src/mcpl/server-connection.js.map +1 -1
  61. package/dist/src/mcpl/tags.d.ts +9 -2
  62. package/dist/src/mcpl/tags.d.ts.map +1 -1
  63. package/dist/src/mcpl/tags.js +12 -2
  64. package/dist/src/mcpl/tags.js.map +1 -1
  65. package/dist/src/mcpl/tool-presence.d.ts +66 -14
  66. package/dist/src/mcpl/tool-presence.d.ts.map +1 -1
  67. package/dist/src/mcpl/tool-presence.js +134 -65
  68. package/dist/src/mcpl/tool-presence.js.map +1 -1
  69. package/dist/src/mcpl/tool-signature.d.ts +10 -3
  70. package/dist/src/mcpl/tool-signature.d.ts.map +1 -1
  71. package/dist/src/mcpl/tool-signature.js +47 -18
  72. package/dist/src/mcpl/tool-signature.js.map +1 -1
  73. package/dist/src/mcpl/toolset-host.d.ts +88 -37
  74. package/dist/src/mcpl/toolset-host.d.ts.map +1 -1
  75. package/dist/src/mcpl/toolset-host.js +207 -108
  76. package/dist/src/mcpl/toolset-host.js.map +1 -1
  77. package/dist/src/mcpl/toolsets-module.d.ts +14 -11
  78. package/dist/src/mcpl/toolsets-module.d.ts.map +1 -1
  79. package/dist/src/mcpl/toolsets-module.js +141 -49
  80. package/dist/src/mcpl/toolsets-module.js.map +1 -1
  81. package/dist/src/mcpl/types.d.ts +3 -1
  82. package/dist/src/mcpl/types.d.ts.map +1 -1
  83. package/dist/src/mcpl/types.js.map +1 -1
  84. package/dist/src/module-registry.d.ts +4 -1
  85. package/dist/src/module-registry.d.ts.map +1 -1
  86. package/dist/src/module-registry.js +9 -2
  87. package/dist/src/module-registry.js.map +1 -1
  88. package/dist/src/modules/history/index.d.ts.map +1 -1
  89. package/dist/src/modules/history/index.js +22 -11
  90. package/dist/src/modules/history/index.js.map +1 -1
  91. package/dist/src/modules/workspace/answers.d.ts +22 -0
  92. package/dist/src/modules/workspace/answers.d.ts.map +1 -0
  93. package/dist/src/modules/workspace/answers.js +123 -0
  94. package/dist/src/modules/workspace/answers.js.map +1 -0
  95. package/dist/src/modules/workspace/branch-intent.d.ts +5 -3
  96. package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -1
  97. package/dist/src/modules/workspace/branch-intent.js +6 -2
  98. package/dist/src/modules/workspace/branch-intent.js.map +1 -1
  99. package/dist/src/modules/workspace/direct-write.d.ts +3 -0
  100. package/dist/src/modules/workspace/direct-write.d.ts.map +1 -1
  101. package/dist/src/modules/workspace/direct-write.js +57 -24
  102. package/dist/src/modules/workspace/direct-write.js.map +1 -1
  103. package/dist/src/modules/workspace/disk-agreement.d.ts +33 -11
  104. package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
  105. package/dist/src/modules/workspace/disk-agreement.js +48 -17
  106. package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
  107. package/dist/src/modules/workspace/edit-text.d.ts +2 -1
  108. package/dist/src/modules/workspace/edit-text.d.ts.map +1 -1
  109. package/dist/src/modules/workspace/edit-text.js +4 -2
  110. package/dist/src/modules/workspace/edit-text.js.map +1 -1
  111. package/dist/src/modules/workspace/effects.d.ts.map +1 -1
  112. package/dist/src/modules/workspace/effects.js +20 -13
  113. package/dist/src/modules/workspace/effects.js.map +1 -1
  114. package/dist/src/modules/workspace/index.d.ts +62 -51
  115. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  116. package/dist/src/modules/workspace/index.js +934 -531
  117. package/dist/src/modules/workspace/index.js.map +1 -1
  118. package/dist/src/modules/workspace/observe.d.ts +75 -63
  119. package/dist/src/modules/workspace/observe.d.ts.map +1 -1
  120. package/dist/src/modules/workspace/observe.js +366 -180
  121. package/dist/src/modules/workspace/observe.js.map +1 -1
  122. package/dist/src/modules/workspace/read-page.d.ts.map +1 -1
  123. package/dist/src/modules/workspace/read-page.js +7 -1
  124. package/dist/src/modules/workspace/read-page.js.map +1 -1
  125. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
  126. package/dist/src/modules/workspace/reconcile.js +26 -16
  127. package/dist/src/modules/workspace/reconcile.js.map +1 -1
  128. package/dist/src/modules/workspace/result-text.d.ts +1 -0
  129. package/dist/src/modules/workspace/result-text.d.ts.map +1 -1
  130. package/dist/src/modules/workspace/result-text.js.map +1 -1
  131. package/dist/src/modules/workspace/sync.d.ts +9 -0
  132. package/dist/src/modules/workspace/sync.d.ts.map +1 -1
  133. package/dist/src/modules/workspace/sync.js +14 -0
  134. package/dist/src/modules/workspace/sync.js.map +1 -1
  135. package/dist/src/modules/workspace/types.d.ts +96 -43
  136. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  137. package/dist/src/modules/workspace/types.js.map +1 -1
  138. package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
  139. package/dist/src/modules/workspace/watcher.js +8 -3
  140. package/dist/src/modules/workspace/watcher.js.map +1 -1
  141. package/dist/src/prose-drafts.d.ts +4 -3
  142. package/dist/src/prose-drafts.d.ts.map +1 -1
  143. package/dist/src/prose-drafts.js +3 -2
  144. package/dist/src/prose-drafts.js.map +1 -1
  145. package/dist/src/reasoning-loss-notice.d.ts +23 -0
  146. package/dist/src/reasoning-loss-notice.d.ts.map +1 -0
  147. package/dist/src/reasoning-loss-notice.js +50 -0
  148. package/dist/src/reasoning-loss-notice.js.map +1 -0
  149. package/dist/src/reasoning-loss.d.ts +24 -0
  150. package/dist/src/reasoning-loss.d.ts.map +1 -0
  151. package/dist/src/reasoning-loss.js +102 -0
  152. package/dist/src/reasoning-loss.js.map +1 -0
  153. package/dist/src/send-tools.d.ts +3 -2
  154. package/dist/src/send-tools.d.ts.map +1 -1
  155. package/dist/src/send-tools.js +3 -2
  156. package/dist/src/send-tools.js.map +1 -1
  157. package/dist/src/sent-rows.js +1 -1
  158. package/dist/src/thinking-drops.d.ts +4 -11
  159. package/dist/src/thinking-drops.d.ts.map +1 -1
  160. package/dist/src/thinking-drops.js +7 -14
  161. package/dist/src/thinking-drops.js.map +1 -1
  162. package/dist/src/tool-args.d.ts +12 -0
  163. package/dist/src/tool-args.d.ts.map +1 -1
  164. package/dist/src/tool-args.js +35 -1
  165. package/dist/src/tool-args.js.map +1 -1
  166. package/dist/src/tool-result-guard.d.ts +8 -4
  167. package/dist/src/tool-result-guard.d.ts.map +1 -1
  168. package/dist/src/tool-result-guard.js +23 -11
  169. package/dist/src/tool-result-guard.js.map +1 -1
  170. package/dist/src/tune-out/tools.d.ts +4 -1
  171. package/dist/src/tune-out/tools.d.ts.map +1 -1
  172. package/dist/src/types/agent.d.ts +40 -9
  173. package/dist/src/types/agent.d.ts.map +1 -1
  174. package/dist/src/types/events.d.ts +18 -8
  175. package/dist/src/types/events.d.ts.map +1 -1
  176. package/dist/src/types/framework.d.ts +15 -0
  177. package/dist/src/types/framework.d.ts.map +1 -1
  178. package/dist/src/types/module.d.ts +5 -2
  179. package/dist/src/types/module.d.ts.map +1 -1
  180. package/dist/src/types/trace.d.ts +34 -1
  181. package/dist/src/types/trace.d.ts.map +1 -1
  182. package/package.json +3 -3
  183. package/src/agent.ts +72 -11
  184. package/src/api/server.ts +4 -2
  185. package/src/auto-continue.ts +4 -3
  186. package/src/cut-off-round.ts +98 -0
  187. package/src/framework.ts +2694 -700
  188. package/src/gate/event-gate.ts +579 -15
  189. package/src/gate/index.ts +8 -0
  190. package/src/gate/reply-judge.ts +512 -0
  191. package/src/gate/types.ts +164 -1
  192. package/src/heartbeat/heartbeat.ts +804 -0
  193. package/src/heartbeat/reminder-time.ts +107 -0
  194. package/src/index.ts +4 -0
  195. package/src/mcpl/capability-mask.ts +3 -2
  196. package/src/mcpl/channel-registry.ts +2 -1
  197. package/src/mcpl/inbound-source.ts +42 -69
  198. package/src/mcpl/server-connection.ts +56 -16
  199. package/src/mcpl/tags.ts +13 -2
  200. package/src/mcpl/tool-presence.ts +133 -67
  201. package/src/mcpl/tool-signature.ts +51 -20
  202. package/src/mcpl/toolset-host.ts +197 -107
  203. package/src/mcpl/toolsets-module.ts +143 -49
  204. package/src/mcpl/types.ts +3 -1
  205. package/src/module-registry.ts +8 -2
  206. package/src/modules/history/index.ts +22 -12
  207. package/src/modules/workspace/answers.ts +133 -0
  208. package/src/modules/workspace/branch-intent.ts +10 -5
  209. package/src/modules/workspace/direct-write.ts +58 -23
  210. package/src/modules/workspace/disk-agreement.ts +52 -21
  211. package/src/modules/workspace/edit-text.ts +7 -5
  212. package/src/modules/workspace/effects.ts +21 -12
  213. package/src/modules/workspace/index.ts +927 -541
  214. package/src/modules/workspace/observe.ts +381 -177
  215. package/src/modules/workspace/read-page.ts +7 -1
  216. package/src/modules/workspace/reconcile.ts +27 -15
  217. package/src/modules/workspace/result-text.ts +2 -0
  218. package/src/modules/workspace/sync.ts +16 -0
  219. package/src/modules/workspace/types.ts +96 -43
  220. package/src/modules/workspace/watcher.ts +8 -3
  221. package/src/prose-drafts.ts +4 -3
  222. package/src/reasoning-loss-notice.ts +62 -0
  223. package/src/reasoning-loss.ts +120 -0
  224. package/src/send-tools.ts +3 -2
  225. package/src/sent-rows.ts +1 -1
  226. package/src/thinking-drops.ts +10 -16
  227. package/src/tool-args.ts +34 -1
  228. package/src/tool-result-guard.ts +26 -11
  229. package/src/tune-out/tools.ts +4 -1
  230. package/src/types/agent.ts +40 -9
  231. package/src/types/events.ts +18 -8
  232. package/src/types/framework.ts +15 -0
  233. package/src/types/module.ts +5 -2
  234. package/src/types/trace.ts +36 -1
package/README.md CHANGED
@@ -448,36 +448,75 @@ framework registers a `toolsets` module with four constant tools:
448
448
  - `toolsets--act {server?, tool, instance?, args?}` calls a dynamic tool down
449
449
  the same path as a direct call of it (the agent's `allowedTools`, the
450
450
  server's tool policy, the state exchange, the reading of its result, RFC-007
451
- observers, who see the server's tool), with only the instance added, in
451
+ observers and RFC-008 class rules, which see the server's tool and its class),
452
+ with only the instance added, in
452
453
  `_meta["mcpl/instance"]`. It first checks `args` against the definition in
453
454
  force for that instance; that check is bounded, and leaves `pattern` and
454
455
  anything nested or branching too far to the server, which checks every
455
456
  call itself;
456
457
  - `toolsets--look {server?, toolset?, instance?, tool?}` restates what is open
457
- and what can be opened, or one tool's whole definition;
458
+ and what can be opened, or one tool's signature, description, class and
459
+ input schema. It
460
+ re-reads each server that presents toolsets first, and says so when it
461
+ couldn't; what that changed
462
+ is in the answer when look restates everything, and otherwise told as a
463
+ notice;
458
464
  - `toolsets--close {server?, toolset?, instance?}` closes it.
459
465
 
460
- `server` can be left out when only one server has the name. Hint changes apply
466
+ `server` can be left out when only one server has the name. By our reading of
467
+ the code, a server with no toolsets stops presenting them once its latest `tools/list` has no dynamic
468
+ tool, so until the rebuild, act takes its last one only with `server` named.
469
+ Hint changes apply
461
470
  as their message is read, in `rev` order, whatever becomes of the message (a
462
- refused push, a result that came after its timeout). A skipped rev re-reads
463
- `tools/list` and then `toolsets/list`, which the host also reads after every
464
- (re)connect, adopting what the server kept open and never re-opening anything.
471
+ refused push, a result that came after its timeout). A move between static and
472
+ dynamic takes effect when the server's `tools/list` states it, and the tool
473
+ list follows at its next rebuild that lists the server, whichever refresh
474
+ brings it (a move is no reason to rebuild the tool list early). Until then the
475
+ tool is called at either place, where the tool list shows it or where the
476
+ server's latest list put it (RFC-014 §4.2 keeps it working where it is until
477
+ the move applies), and
478
+ once that rebuild has published the list, a notice says where it went. A list
479
+ read while a rebuild is under way can undo a move that rebuild then publishes;
480
+ neither is told, and the next rebuild puts the tool back.
481
+ A skipped rev re-reads `tools/list` and then `toolsets/list`, which the host
482
+ also reads after every (re)connect, adopting what the server kept open and
483
+ never re-opening anything.
465
484
  What changed is told where it happened: after a call's own result, after the
466
485
  push that explains it, or as a notice (`kind: 'mcpl-toolsets'`, which wakes
467
486
  nothing) for a standalone `tools/hints`, a late result, an adoption, a
468
- recovery, or a call whose result doesn't go to the agent (one the framework or
469
- a module makes itself). Notices need the server's `pushEvents` grant, like any delivery. A
470
- new tool's first sentence is told the first time its definition appears.
471
- Suggestions are shown, never acted on. Each `ended` id is told once. When an
487
+ recovery, or a call whose result may not reach the agent (a script's, a
488
+ module's or a host's, or one the framework makes itself); an open, close or
489
+ look made that way also shows its caller the change, unless the change has
490
+ already gone as a notice (below). A dynamic tool's change also goes as a notice
491
+ when it wouldn't fit whole within its result's inline cap, or when its call
492
+ fails after the result was read. A call's change also goes as a notice, ahead of its
493
+ result, when a later change goes to the agent before the call's caller has
494
+ taken it, so changes are told in the order they were read (the agent's window
495
+ can still show a call's result, a push's event, or a change its taker couldn't
496
+ show after a change read later). The model's own call's change counts as told
497
+ once its result is handed back: if the turn is stopped while the call is out
498
+ (or, by our reading of the code, the agent is gone), the result is dropped and the change with it, and
499
+ `toolsets--look` shows the state it left. Notices and reminders
500
+ need the server's `pushEvents` grant, like any delivery; without it, a change
501
+ that would go as a notice is dropped, and `toolsets--look` shows the state. A new tool's first sentence is told with its
502
+ definition until text describing it has reached the model, except that, by our reading of the code, a puppet's
503
+ open, close or look whose result the store refuses has already counted it. Suggestions are shown, never acted on. Each
504
+ `ended` id is told once while the
505
+ host runs (told ids are kept in memory), short of rare interleavings, such as a
506
+ `toolsets--look` overlapping other reads of the same server, that can tell one
507
+ twice. When an
472
508
  open toolset's announcements have left an agent's context (compressed or out
473
509
  of the window), the module's `gatherContext` restates what is open, as a
474
510
  stored `afterUser` injection (namespace `mcpl-toolsets`), at that agent's next
475
511
  start.
476
512
 
477
513
  A dynamic tool called by its prefixed name is refused, pointing at
478
- `toolsets--act`. Calls to an undeclared toolset's tools are refused while the
479
- host has that group closed (RFC-014 §5.4). Projection and surface mode are not
480
- implemented: a `surface` server's static tools are listed like any server's.
514
+ `toolsets--act`, unless the tool list or the server's latest list shows it as
515
+ static (a move waiting for its rebuild). Calls to an undeclared toolset's
516
+ tools are refused while the host has that group closed (RFC-014 §5.4), except
517
+ by a tool's listed name until the rebuild that publishes its move into the
518
+ group. Projection and surface mode are not implemented: a `surface` server's
519
+ static tools are listed like any server's.
481
520
 
482
521
  #### Per-channel conversation routing (deprecated)
483
522
 
@@ -501,9 +540,11 @@ framework.abortInference('assistant', 'user requested stop');
501
540
 
502
541
  The non-streaming path uses `AbortSignal` forwarded to `membrane.stream()`, which returns an `AbortedResponse` with partial content. The streaming path cancels the `YieldingStream` directly.
503
542
 
504
- A turn whose stream is cancelled this way, or by `agent.cancelStream()`, ends as a stop, whether the stream reports the cancel as `aborted`, as an `error`, or by just closing: one `inference:aborted` carrying the caller's reason (`user` when none was given), a `[turn-interrupted]` note in the agent's context, and never `inference:exhausted`, which is for failed inferences. A stream that membrane aborts on its own, at a deadline or on an error (reason `timeout` or `error`), is a failed inference. `stop()` and an operator's quiesce abandon end a turn as a stop too, with their own reasons, `shutdown` and `quiesce_abandoned`, and write no note. A stopped stream still writes its inference-log row, with `success: false`.
543
+ A turn whose stream is cancelled this way, or by `agent.cancelStream()`, ends as a stop, whether the stream reports the cancel as `aborted`, as an `error`, or by just closing: one `inference:aborted` carrying the caller's reason (`user` when none was given), a `[turn-interrupted]` note in the agent's context, and never `inference:exhausted`, which is for failed inferences. A stream that membrane aborts on its own, at a deadline or on an error (reason `timeout` or `error`), is a failed inference. `stop()` and an operator's quiesce abandon end a turn as a stop too, with their own reasons, `shutdown` and `quiesce_abandoned`, and write no note, except the `[speech-not-posted]` notice when the turn's rounds left speech unposted (XML tool mode, or a membrane without `roundContent`; see below). A stopped stream still writes its inference-log row, with `success: false`.
505
544
 
506
- A caller's stop and an operator's quiesce abandon also reach a turn that has no live stream: one running its modules' `gatherContext`, its MCPL hooks or its compile, one waiting to retry a failed inference or compile (`abortInference()` and an operator's abandon end the wait, and a stop through `Agent.cancelStream()` waits for it to run out), and one whose tool-result guard is waiting to retry after a refusal, which holds only the round's finished stream. The turn ends at its next check, before it sends anything more, as a stop on a live stream ends it, and a turn whose compile fails after the stop ends at the failure, before a provider hold, the error policy's retry or `inference:exhausted`. A caller's stop leaves the note saying the turn was stopped before it sent anything or before it finished, and an operator's abandon leaves none. `abortInference()` returns `true` for such a turn. In the guard's wait, `stop()` ends the turn as a stop with reason `shutdown`, and an operator's abandon ends it as the abandon, even when a caller's stop came first; with both, it ends as `stop()`'s. `stop()` drops a turn in its hooks, its compile or a wait to retry before it sends anything, as before, and drops one whose compile fails while it runs, once a caller's stop has reached it, rather than ending it as that stop. While the failure of a turn's stream is reported (`inference:failed`), the agent no longer holds that stream, so `abortInference()` from a listener reports `false`. A failure to build a turn's request is reported while the turn's check is still ahead, so there `abortInference()` reports `true`, and the turn ends at that check. A caller's stop made where no check of a turn is ahead stops nothing, and doesn't end the agent's next turn: while the agent is idle, while a turn finishes its last delivery, and while a non-streaming turn's tool results wait to start the turn's next call. A turn whose continuation (a budget restart's, or a tool-result guard's retry) waits to start, or whose failed call a provider-capacity hold or a provider's stated wait keeps for its retry, is ended by `abortInference()`, by an operator's quiesce abandon and by `stop()`: the continuation or retry is dropped, and the turn ends with the caller's reason, `quiesce_abandoned` or `shutdown`. After `abortInference()` or an abandon, wakes that arrived meanwhile still run (after the abandon, once the host resumes): those a hold keeps beside the retry, and those the scheduler merged into the retry's or the continuation's start before that start began, which the stop or the abandon puts back in the queue. A stop through `Agent.cancelStream()` stops nothing there.
545
+ A caller's stop and an operator's quiesce abandon also reach a turn that has no live stream: one running its modules' `gatherContext`, its MCPL hooks or its compile, one waiting to retry a failed inference or compile (`abortInference()` and an operator's abandon end the wait, and a stop through `Agent.cancelStream()` waits for it to run out), and one whose tool-result guard is waiting to retry after a refusal, which holds only the round's finished stream. The turn ends at its next check, before it sends anything more, as a stop on a live stream ends it, and a turn whose compile fails after the stop ends at the failure, before a provider hold, the error policy's retry or `inference:exhausted`. A caller's stop leaves the note saying the turn was stopped before it sent anything or before it finished, and an operator's abandon leaves none, except the `[speech-not-posted]` notice when the turn's rounds left speech unposted. `abortInference()` returns `true` for such a turn. In the guard's wait, `stop()` ends the turn as a stop with reason `shutdown`, and an operator's abandon ends it as the abandon, even when a caller's stop came first; with both, it ends as `stop()`'s. `stop()` drops a turn in its hooks, its compile or a wait to retry before it sends anything, as before, and drops one whose compile fails while it runs, once a caller's stop has reached it, rather than ending it as that stop. While the failure of a turn's stream is reported (`inference:failed`), the agent no longer holds that stream, so `abortInference()` from a listener reports `false`. A failure to build a turn's request is reported while the turn's check is still ahead, so there `abortInference()` reports `true`, and the turn ends at that check. A caller's stop made where no check of a turn is ahead stops nothing, and doesn't end the agent's next turn: while the agent is idle, while a turn finishes its last delivery, and while a non-streaming turn's tool results wait to start the turn's next call. A turn whose continuation (a budget restart's, or a tool-result guard's retry) waits to start, or whose failed call a provider-capacity hold or a provider's stated wait keeps for its retry, is ended by `abortInference()`, by an operator's quiesce abandon and by `stop()`: the continuation or retry is dropped, and the turn ends with the caller's reason, `quiesce_abandoned` or `shutdown`. After `abortInference()` or an abandon, wakes that arrived meanwhile still run (after the abandon, once the host resumes): those a hold keeps beside the retry, and those the scheduler merged into the retry's or the continuation's start before that start began, which the stop or the abandon puts back in the queue. A stop through `Agent.cancelStream()` stops nothing there.
546
+
547
+ In XML tool mode, or with a membrane that gives a tool round no `roundContent`, such a round's speech reaches a channel only when its stream completes. When the stream ends any other way (a failure, a stop, a tool that ends the turn, an error policy's retry, a context-budget or tool-result-guard restart, a quiesce abandon or `stop()`), the rounds' words are already in the agent's context, and a `[speech-not-posted]` notice tells the agent that nothing it wrote before its tool calls in those rounds was posted, so it can send what should go out again. It's written once for those rounds: where the turn ends, or before a retry's or a restart's request is sent. A turn its own `skip_reply` ends, a silent turn, a round still waiting on its tools when its stream ends (which never reaches the context) and the rounds of a stream that completes get none. In XML tool mode with thinking on, a round whose text was only thinking gets the notice too, since the framework has only the round's raw text there. A failed turn's `[inference-failed]` note says that its earlier rounds ran when any round reached the context with its results, and that a round's tool calls were started and may have taken effect when any of its streams ended before that round's results came back; a caller's stop says the latter in its `[turn-interrupted]` note too. A turn that fails, or that a caller stops, writes no `[delivered]` receipt, so when its rounds' plain speech was delivered live (native tool mode, in locus or hybrid routing), its `[inference-failed]` note, or the stop's `[turn-interrupted]` note, says that speech was handed on for delivery as written and that no `[delivered]` line was written for it. When some of its speech was still being routed as the turn ended, the note also says it may yet be posted and to check the channel before sending it again. A delivery that finished undelivered gets neither: a channel delivery's `[discord-send-failed]` note, or a refused `>>>` envelope's bounce, already says what happened. A quiesce abandon and `stop()` write neither note.
507
548
 
508
549
  ## API Server
509
550
 
@@ -67,12 +67,17 @@ export interface StartStreamResult {
67
67
  /** The compile's `thinkingRecordedAfter`, when it gave one: a reply stored at or below it predates the branch's
68
68
  * thinking-binding record, so the provider may drop its thinking with no strip having missed. */
69
69
  thinkingRecordedAfter?: number;
70
+ /** The key (`branchKey`) of the branch the compile read, when its provenance names one. */
71
+ thinkingBranch?: string;
70
72
  /** Tells the context manager what the stream's later rounds carried after the compiled messages, every round so
71
73
  * far in sent order, with this request's head (context-manager's `noteRequestSent`). Present only where the
72
74
  * model binds its thinking and the context manager keeps a record it can be told of. */
73
75
  noteRequestSent?: (rows: readonly SentRow[]) => boolean;
76
+ /** The stored bodies the request's compile carried, by each body's first message id (its provenance's raw bodies).
77
+ * Absent when the compile reports no provenance. */
78
+ carriedBodies?: ReadonlySet<MessageId>;
74
79
  }
75
- import type { ContextManager, TokenBudget, ContextInjection, CompileResult, MessageId, MessageMetadata, RequestIdentity } from '@animalabs/context-manager';
80
+ import type { ContextManager, TokenBudget, ContextInjection, CompileResult, MessageId, MessageMetadata, RequestIdentity, ThinkingStrip } from '@animalabs/context-manager';
76
81
  import type { AgentConfig, AgentState, SameRoundThinkTextPolicy, SameRoundThinkTextPolicySource, ToolCallId, ToolCall, ToolResult, ToolDefinition, AgentInfo, InferenceResult, InferenceOptions, AgentRuntimeSettingsPatch, AgentRuntimeSettingsSnapshot, AgentRuntimeSettingsOverrides } from './types/index.js';
77
82
  /**
78
83
  * Refuse an agent config whose `promptCaching`, `toolResultGuard`,
@@ -99,6 +104,10 @@ export declare const DEFAULT_AUTO_CONTINUE_MAX = 3;
99
104
  export declare function resolveAutoContinue(config: AgentConfig): {
100
105
  maxConsecutive: number;
101
106
  } | undefined;
107
+ export declare function branchKey(branch: {
108
+ readonly id: string;
109
+ readonly created: number;
110
+ }): string;
102
111
  /**
103
112
  * An agent wraps a context manager and manages inference state.
104
113
  */
@@ -544,6 +553,14 @@ export declare class Agent {
544
553
  * reaches here).
545
554
  */
546
555
  private applyCompileWatermark;
556
+ /**
557
+ * The branch now (`branchKey`) and its head, as `pendingWatermark` reads it: a message stored on that branch later
558
+ * has a larger sequence. Sequences are numbered per branch, so one compares with another only on the same branch.
559
+ */
560
+ branchHead(): {
561
+ branch: string;
562
+ sequence: number;
563
+ } | undefined;
547
564
  /** The watermark a successful compile will establish (taken before, applied after). */
548
565
  private pendingWatermark;
549
566
  /** A committing compile, as for a request that is sent: the context
@@ -588,6 +605,14 @@ export declare class Agent {
588
605
  * throws is logged, and the start goes on.
589
606
  */
590
607
  onCompiledToSend?: (messages: readonly unknown[]) => void;
608
+ /**
609
+ * A host's hook, called with each committing compile's `thinkingStrip` (never a dry run's) and the key of the
610
+ * branch it read (`branchKey`), as the compile returns, whether or not its request is then sent, since the
611
+ * context manager's binding record takes the strip either way. One that throws is logged. The framework sets it
612
+ * at the agent's first stream unless a host has set one, so a host's own observer stands in for the framework's,
613
+ * whose `[reasoning]` line for the agent then isn't told.
614
+ */
615
+ onThinkingStrip?: (strip: ThinkingStrip, branch: string) => void;
591
616
  /**
592
617
  * The newest content of `namespace` among this agent's rows stored since
593
618
  * its last compile built to send (unsentSince), and whether every part of
@@ -799,7 +824,9 @@ export declare class Agent {
799
824
  * one is still ahead; otherwise the next start drops it. `reason` is
800
825
  * provenance for the framework's inference:aborted trace and marker
801
826
  * metadata (e.g. 'zombie_reclaim', 'subagent_cancel'); it never reaches
802
- * the provider.
827
+ * the provider. When the stream's cancel() throws, the throw goes on to
828
+ * the caller, and the agent still holds the stream, its cancel record as
829
+ * it was before the call.
803
830
  */
804
831
  cancelStream(reason?: string): void;
805
832
  /** Collect (and clear) the cancelStream() made while this agent held no
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE9I,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAA+C,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAK5D,OAAO,EAQL,KAAK,iBAAiB,EAEtB,KAAK,mBAAmB,EAEzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAO/E,MAAM,WAAW,wBA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CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,CAc7E;YAEa,WAAW;IAsEzB,OAAO,CAAC,yBAAyB;IAuBjC,OAAO,CAAC,uBAAuB;CA8BhC"}
package/dist/src/agent.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { heartbeatToolAlias } from './heartbeat/heartbeat.js';
1
2
  import { isAbortedResponse } from '@animalabs/membrane';
2
3
  import { ToolResultGuard } from './tool-result-guard.js';
3
4
  import { withoutTokenEstimates } from './thinking-token-stamp.js';
@@ -109,8 +110,7 @@ export function resolveAutoContinue(config) {
109
110
  }
110
111
  return { maxConsecutive: max };
111
112
  }
112
- /** A branch's key in Agent.unsentSince: its id and when it was created. */
113
- function branchKey(branch) {
113
+ export function branchKey(branch) {
114
114
  return `${branch.id}\u0000${branch.created}`;
115
115
  }
116
116
  /**
@@ -334,7 +334,14 @@ export class Agent {
334
334
  if (this.allowedTools === 'all') {
335
335
  return true;
336
336
  }
337
- return this.allowedTools.includes(toolName);
337
+ if (this.allowedTools.includes(toolName))
338
+ return true;
339
+ // A heartbeat tool is one tool under either prefix: the framework's
340
+ // `heartbeat--x` and heartbeat-mcpl's `mcpl--heartbeat--x`, which an
341
+ // allowedTools written for the server names. Only one of them is ever
342
+ // offered, since the framework refuses the server beside its heartbeat.
343
+ const alias = heartbeatToolAlias(toolName);
344
+ return alias !== undefined && this.allowedTools.includes(alias);
338
345
  }
339
346
  /**
340
347
  * Check if a source can trigger inference for this agent.
@@ -981,8 +988,9 @@ export class Agent {
981
988
  // Tolerates partial context-manager doubles (tests build Agents over
982
989
  // stubs). Without a watermark, a reader that looks for one takes its own
983
990
  // side: the coalescer counts the message as read, and the framework's
984
- // unreadNoticesForPrimary counts it as unread. A deferred write's wake
985
- // reads the answered watermark instead (deferredWriteDone).
991
+ // unreadNoticesForPrimary counts it as unread. A wake for a deferred
992
+ // write or a stored message reads the answered watermark instead
993
+ // (deferredWriteDone, storedMessageDone).
986
994
  this.consumedWatermark = this.pendingWatermark();
987
995
  this.watermarkMarks++;
988
996
  this.shownWatermark = this.consumedWatermark;
@@ -1025,6 +1033,22 @@ export class Agent {
1025
1033
  this.consumedWatermark = watermark;
1026
1034
  this.watermarkMarks++;
1027
1035
  }
1036
+ /**
1037
+ * The branch now (`branchKey`) and its head, as `pendingWatermark` reads it: a message stored on that branch later
1038
+ * has a larger sequence. Sequences are numbered per branch, so one compares with another only on the same branch.
1039
+ */
1040
+ branchHead() {
1041
+ const head = this.pendingWatermark();
1042
+ const cm = this.contextManager;
1043
+ if (!head || typeof cm.currentBranchRef !== 'function')
1044
+ return undefined;
1045
+ try {
1046
+ return { branch: branchKey(cm.currentBranchRef()), sequence: head.sequence };
1047
+ }
1048
+ catch {
1049
+ return undefined;
1050
+ }
1051
+ }
1028
1052
  /** The watermark a successful compile will establish (taken before, applied after). */
1029
1053
  pendingWatermark() {
1030
1054
  const cm = this.contextManager;
@@ -1108,6 +1132,14 @@ export class Agent {
1108
1132
  * throws is logged, and the start goes on.
1109
1133
  */
1110
1134
  onCompiledToSend;
1135
+ /**
1136
+ * A host's hook, called with each committing compile's `thinkingStrip` (never a dry run's) and the key of the
1137
+ * branch it read (`branchKey`), as the compile returns, whether or not its request is then sent, since the
1138
+ * context manager's binding record takes the strip either way. One that throws is logged. The framework sets it
1139
+ * at the agent's first stream unless a host has set one, so a host's own observer stands in for the framework's,
1140
+ * whose `[reasoning]` line for the agent then isn't told.
1141
+ */
1142
+ onThinkingStrip;
1111
1143
  /**
1112
1144
  * The newest content of `namespace` among this agent's rows stored since
1113
1145
  * its last compile built to send (unsentSince), and whether every part of
@@ -1319,6 +1351,14 @@ export class Agent {
1319
1351
  }
1320
1352
  if (watermark)
1321
1353
  this.applyCompileWatermark(watermark, marksBefore);
1354
+ if (!opts?.dryRun && result.thinkingStrip && this.onThinkingStrip) {
1355
+ try {
1356
+ this.onThinkingStrip(result.thinkingStrip, result.provenance ? branchKey(result.provenance.branch) : '');
1357
+ }
1358
+ catch (err) {
1359
+ console.error(`[agent] ${this.name}: the host's thinking-strip observer failed:`, err);
1360
+ }
1361
+ }
1322
1362
  return result;
1323
1363
  }
1324
1364
  // ==========================================================================
@@ -1805,10 +1845,10 @@ export class Agent {
1805
1845
  // ran. The stream driver collects it on that stream's terminal event, or
1806
1846
  // at the loop's end when the iterator closed without one, while the
1807
1847
  // stream still owns the agent. This clear is for the records no driver
1808
- // collects: a dropped turn's, whose stream no driver iterates; one whose
1809
- // stream's terminal came after another stream took the agent; or a
1810
- // cancel after the stream's complete event. A fresh stream must not
1811
- // inherit one and read its own later error as a deliberate stop.
1848
+ // collects: a cancel of a stream no driver iterates; one whose stream's
1849
+ // terminal came after another stream took the agent; or a cancel after
1850
+ // the stream's complete event. A fresh stream must not inherit one and
1851
+ // read its own later error as a deliberate stop.
1812
1852
  this._pendingCancel = undefined;
1813
1853
  this._inferenceStartedAt = Date.now();
1814
1854
  this.lastStreamInputTokens = 0;
@@ -1879,7 +1919,11 @@ export class Agent {
1879
1919
  // Read against the messages the stream sends, which membrane's report indexes (RoundReport's coordinates).
1880
1920
  placeDrops: (entries) => placeThinkingDrops(entries, request.messages, compiled),
1881
1921
  ...this.requestNotes(binding, compiled),
1922
+ ...(compiled.provenance
1923
+ ? { carriedBodies: new Set(compiled.provenance.messages.flatMap((m) => m.kind === 'raw' ? m.bodies.map((b) => b.messageId) : [])) }
1924
+ : {}),
1882
1925
  ...(compiled.recordedAfter !== undefined ? { thinkingRecordedAfter: compiled.recordedAfter } : {}),
1926
+ ...(compiled.provenance ? { thinkingBranch: branchKey(compiled.provenance.branch) } : {}),
1883
1927
  ...(kvEnabled
1884
1928
  ? {
1885
1929
  takeKvSubmission: () => kvQueue.shift(),
@@ -1983,12 +2027,25 @@ export class Agent {
1983
2027
  * one is still ahead; otherwise the next start drops it. `reason` is
1984
2028
  * provenance for the framework's inference:aborted trace and marker
1985
2029
  * metadata (e.g. 'zombie_reclaim', 'subagent_cancel'); it never reaches
1986
- * the provider.
2030
+ * the provider. When the stream's cancel() throws, the throw goes on to
2031
+ * the caller, and the agent still holds the stream, its cancel record as
2032
+ * it was before the call.
1987
2033
  */
1988
2034
  cancelStream(reason) {
1989
2035
  if ('stream' in this._state && this._state.stream) {
2036
+ // A cancel that throws leaves the stream going and the agent holding
2037
+ // it, so this call's record is taken back, leaving any earlier one: a
2038
+ // later end of that stream, an `error` the provider reports included,
2039
+ // is not read as this stop's.
2040
+ const earlier = this._pendingCancel;
1990
2041
  this._pendingCancel = { reason };
1991
- this._state.stream.cancel();
2042
+ try {
2043
+ this._state.stream.cancel();
2044
+ }
2045
+ catch (error) {
2046
+ this._pendingCancel = earlier;
2047
+ throw error;
2048
+ }
1992
2049
  }
1993
2050
  else {
1994
2051
  this._stopWithoutStream = { reason };
@@ -2142,6 +2199,7 @@ export class Agent {
2142
2199
  id: block.id,
2143
2200
  name: block.name,
2144
2201
  input: block.input,
2202
+ ...(block.unparseableInput !== undefined ? { unparseableInput: block.unparseableInput } : {}),
2145
2203
  });
2146
2204
  }
2147
2205
  else if (block.type === 'text') {