@animalabs/agent-framework 0.21.0 → 0.22.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 (271) hide show
  1. package/README.md +43 -0
  2. package/dist/src/agent.d.ts +17 -4
  3. package/dist/src/agent.d.ts.map +1 -1
  4. package/dist/src/agent.js +102 -42
  5. package/dist/src/agent.js.map +1 -1
  6. package/dist/src/code-execution/py-runner.d.ts +22 -1
  7. package/dist/src/code-execution/py-runner.d.ts.map +1 -1
  8. package/dist/src/code-execution/py-runner.js +64 -9
  9. package/dist/src/code-execution/py-runner.js.map +1 -1
  10. package/dist/src/code-execution/runtime-py.d.ts +4 -0
  11. package/dist/src/code-execution/runtime-py.d.ts.map +1 -1
  12. package/dist/src/code-execution/runtime-py.js +215 -38
  13. package/dist/src/code-execution/runtime-py.js.map +1 -1
  14. package/dist/src/framework.d.ts +250 -39
  15. package/dist/src/framework.d.ts.map +1 -1
  16. package/dist/src/framework.js +1602 -371
  17. package/dist/src/framework.js.map +1 -1
  18. package/dist/src/gate/event-gate.d.ts +21 -0
  19. package/dist/src/gate/event-gate.d.ts.map +1 -1
  20. package/dist/src/gate/event-gate.js +40 -7
  21. package/dist/src/gate/event-gate.js.map +1 -1
  22. package/dist/src/index.d.ts +5 -0
  23. package/dist/src/index.d.ts.map +1 -1
  24. package/dist/src/index.js +4 -0
  25. package/dist/src/index.js.map +1 -1
  26. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  27. package/dist/src/mcpl/channel-registry.js +26 -3
  28. package/dist/src/mcpl/channel-registry.js.map +1 -1
  29. package/dist/src/mcpl/conversation-router.d.ts +28 -1
  30. package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
  31. package/dist/src/mcpl/conversation-router.js +17 -0
  32. package/dist/src/mcpl/conversation-router.js.map +1 -1
  33. package/dist/src/mcpl/feature-set-manager.d.ts +11 -0
  34. package/dist/src/mcpl/feature-set-manager.d.ts.map +1 -1
  35. package/dist/src/mcpl/feature-set-manager.js +31 -7
  36. package/dist/src/mcpl/feature-set-manager.js.map +1 -1
  37. package/dist/src/mcpl/index.d.ts +2 -0
  38. package/dist/src/mcpl/index.d.ts.map +1 -1
  39. package/dist/src/mcpl/index.js +1 -0
  40. package/dist/src/mcpl/index.js.map +1 -1
  41. package/dist/src/mcpl/prose-stream-router.d.ts +27 -6
  42. package/dist/src/mcpl/prose-stream-router.d.ts.map +1 -1
  43. package/dist/src/mcpl/prose-stream-router.js +85 -22
  44. package/dist/src/mcpl/prose-stream-router.js.map +1 -1
  45. package/dist/src/mcpl/push-coalescer.d.ts +32 -4
  46. package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
  47. package/dist/src/mcpl/push-coalescer.js +46 -13
  48. package/dist/src/mcpl/push-coalescer.js.map +1 -1
  49. package/dist/src/mcpl/push-handler.d.ts +5 -3
  50. package/dist/src/mcpl/push-handler.d.ts.map +1 -1
  51. package/dist/src/mcpl/push-handler.js +41 -11
  52. package/dist/src/mcpl/push-handler.js.map +1 -1
  53. package/dist/src/mcpl/server-connection.d.ts +4 -0
  54. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  55. package/dist/src/mcpl/server-connection.js +45 -8
  56. package/dist/src/mcpl/server-connection.js.map +1 -1
  57. package/dist/src/mcpl/server-registry.d.ts +5 -2
  58. package/dist/src/mcpl/server-registry.d.ts.map +1 -1
  59. package/dist/src/mcpl/server-registry.js +25 -7
  60. package/dist/src/mcpl/server-registry.js.map +1 -1
  61. package/dist/src/mcpl/tool-lifecycle.d.ts +52 -2
  62. package/dist/src/mcpl/tool-lifecycle.d.ts.map +1 -1
  63. package/dist/src/mcpl/tool-lifecycle.js +47 -1
  64. package/dist/src/mcpl/tool-lifecycle.js.map +1 -1
  65. package/dist/src/mcpl/tool-pattern-check.d.ts +51 -0
  66. package/dist/src/mcpl/tool-pattern-check.d.ts.map +1 -0
  67. package/dist/src/mcpl/tool-pattern-check.js +79 -0
  68. package/dist/src/mcpl/tool-pattern-check.js.map +1 -0
  69. package/dist/src/mcpl/types.d.ts +15 -5
  70. package/dist/src/mcpl/types.d.ts.map +1 -1
  71. package/dist/src/mcpl/types.js.map +1 -1
  72. package/dist/src/mcpl/visible-content.d.ts +39 -0
  73. package/dist/src/mcpl/visible-content.d.ts.map +1 -0
  74. package/dist/src/mcpl/visible-content.js +54 -0
  75. package/dist/src/mcpl/visible-content.js.map +1 -0
  76. package/dist/src/module-registry.d.ts +81 -3
  77. package/dist/src/module-registry.d.ts.map +1 -1
  78. package/dist/src/module-registry.js +257 -16
  79. package/dist/src/module-registry.js.map +1 -1
  80. package/dist/src/modules/workspace/branch-intent.d.ts +72 -0
  81. package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -0
  82. package/dist/src/modules/workspace/branch-intent.js +83 -0
  83. package/dist/src/modules/workspace/branch-intent.js.map +1 -0
  84. package/dist/src/modules/workspace/disk-agreement.d.ts +167 -0
  85. package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -0
  86. package/dist/src/modules/workspace/disk-agreement.js +259 -0
  87. package/dist/src/modules/workspace/disk-agreement.js.map +1 -0
  88. package/dist/src/modules/workspace/effects.d.ts +84 -0
  89. package/dist/src/modules/workspace/effects.d.ts.map +1 -0
  90. package/dist/src/modules/workspace/effects.js +368 -0
  91. package/dist/src/modules/workspace/effects.js.map +1 -0
  92. package/dist/src/modules/workspace/index.d.ts +155 -17
  93. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  94. package/dist/src/modules/workspace/index.js +1059 -424
  95. package/dist/src/modules/workspace/index.js.map +1 -1
  96. package/dist/src/modules/workspace/observe.d.ts +278 -0
  97. package/dist/src/modules/workspace/observe.d.ts.map +1 -0
  98. package/dist/src/modules/workspace/observe.js +805 -0
  99. package/dist/src/modules/workspace/observe.js.map +1 -0
  100. package/dist/src/modules/workspace/reconcile.d.ts +224 -0
  101. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -0
  102. package/dist/src/modules/workspace/reconcile.js +901 -0
  103. package/dist/src/modules/workspace/reconcile.js.map +1 -0
  104. package/dist/src/modules/workspace/sync.d.ts +6 -59
  105. package/dist/src/modules/workspace/sync.d.ts.map +1 -1
  106. package/dist/src/modules/workspace/sync.js +6 -257
  107. package/dist/src/modules/workspace/sync.js.map +1 -1
  108. package/dist/src/modules/workspace/types.d.ts +77 -10
  109. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  110. package/dist/src/modules/workspace/types.js.map +1 -1
  111. package/dist/src/record-journal.d.ts +127 -0
  112. package/dist/src/record-journal.d.ts.map +1 -0
  113. package/dist/src/record-journal.js +202 -0
  114. package/dist/src/record-journal.js.map +1 -0
  115. package/dist/src/shutdown.d.ts +13 -0
  116. package/dist/src/shutdown.d.ts.map +1 -0
  117. package/dist/src/shutdown.js +46 -0
  118. package/dist/src/shutdown.js.map +1 -0
  119. package/dist/src/silent-heartbeat.d.ts +74 -0
  120. package/dist/src/silent-heartbeat.d.ts.map +1 -0
  121. package/dist/src/silent-heartbeat.js +77 -0
  122. package/dist/src/silent-heartbeat.js.map +1 -0
  123. package/dist/src/tool-presentation.d.ts +50 -0
  124. package/dist/src/tool-presentation.d.ts.map +1 -0
  125. package/dist/src/tool-presentation.js +235 -0
  126. package/dist/src/tool-presentation.js.map +1 -0
  127. package/dist/src/tool-result-guard.d.ts +125 -6
  128. package/dist/src/tool-result-guard.d.ts.map +1 -1
  129. package/dist/src/tool-result-guard.js +310 -35
  130. package/dist/src/tool-result-guard.js.map +1 -1
  131. package/dist/src/tool-result-history.d.ts +13 -0
  132. package/dist/src/tool-result-history.d.ts.map +1 -1
  133. package/dist/src/tool-result-history.js +21 -1
  134. package/dist/src/tool-result-history.js.map +1 -1
  135. package/dist/src/types/agent.d.ts +18 -2
  136. package/dist/src/types/agent.d.ts.map +1 -1
  137. package/dist/src/types/events.d.ts +4 -0
  138. package/dist/src/types/events.d.ts.map +1 -1
  139. package/dist/src/types/framework.d.ts +12 -0
  140. package/dist/src/types/framework.d.ts.map +1 -1
  141. package/dist/src/types/module.d.ts +14 -0
  142. package/dist/src/types/module.d.ts.map +1 -1
  143. package/dist/src/types/trace.d.ts +73 -0
  144. package/dist/src/types/trace.d.ts.map +1 -1
  145. package/dist/test/batched-wake-locus.test.d.ts +2 -0
  146. package/dist/test/batched-wake-locus.test.d.ts.map +1 -0
  147. package/dist/test/batched-wake-locus.test.js +166 -0
  148. package/dist/test/batched-wake-locus.test.js.map +1 -0
  149. package/dist/test/code-execution.test.js +386 -2
  150. package/dist/test/code-execution.test.js.map +1 -1
  151. package/dist/test/component-defaults.test.d.ts +2 -0
  152. package/dist/test/component-defaults.test.d.ts.map +1 -0
  153. package/dist/test/component-defaults.test.js +54 -0
  154. package/dist/test/component-defaults.test.js.map +1 -0
  155. package/dist/test/conversation-routing.test.js +57 -1
  156. package/dist/test/conversation-routing.test.js.map +1 -1
  157. package/dist/test/ephemeral-settle.test.js +3 -0
  158. package/dist/test/ephemeral-settle.test.js.map +1 -1
  159. package/dist/test/event-gate.test.js +118 -0
  160. package/dist/test/event-gate.test.js.map +1 -1
  161. package/dist/test/explicit-prose-routing.test.js +977 -0
  162. package/dist/test/explicit-prose-routing.test.js.map +1 -1
  163. package/dist/test/helpers/pytc-stop-rows.d.ts +11 -0
  164. package/dist/test/helpers/pytc-stop-rows.d.ts.map +1 -0
  165. package/dist/test/helpers/pytc-stop-rows.js +143 -0
  166. package/dist/test/helpers/pytc-stop-rows.js.map +1 -0
  167. package/dist/test/mcpl-coalescing.test.js +19 -6
  168. package/dist/test/mcpl-coalescing.test.js.map +1 -1
  169. package/dist/test/mcpl-config-diagnostics.test.d.ts +2 -0
  170. package/dist/test/mcpl-config-diagnostics.test.d.ts.map +1 -0
  171. package/dist/test/mcpl-config-diagnostics.test.js +449 -0
  172. package/dist/test/mcpl-config-diagnostics.test.js.map +1 -0
  173. package/dist/test/mcpl-empty-content.test.d.ts +2 -0
  174. package/dist/test/mcpl-empty-content.test.d.ts.map +1 -0
  175. package/dist/test/mcpl-empty-content.test.js +368 -0
  176. package/dist/test/mcpl-empty-content.test.js.map +1 -0
  177. package/dist/test/mcpl-tool-lifecycle-emitter.test.js +106 -1
  178. package/dist/test/mcpl-tool-lifecycle-emitter.test.js.map +1 -1
  179. package/dist/test/mcpl-tool-lifecycle-script.test.d.ts +2 -0
  180. package/dist/test/mcpl-tool-lifecycle-script.test.d.ts.map +1 -0
  181. package/dist/test/mcpl-tool-lifecycle-script.test.js +288 -0
  182. package/dist/test/mcpl-tool-lifecycle-script.test.js.map +1 -0
  183. package/dist/test/prose-stream-router.test.js +41 -0
  184. package/dist/test/prose-stream-router.test.js.map +1 -1
  185. package/dist/test/record-journal.test.d.ts +6 -0
  186. package/dist/test/record-journal.test.d.ts.map +1 -0
  187. package/dist/test/record-journal.test.js +269 -0
  188. package/dist/test/record-journal.test.js.map +1 -0
  189. package/dist/test/save-recent-image.test.js +102 -0
  190. package/dist/test/save-recent-image.test.js.map +1 -1
  191. package/dist/test/shutdown-errors.test.d.ts +2 -0
  192. package/dist/test/shutdown-errors.test.d.ts.map +1 -0
  193. package/dist/test/shutdown-errors.test.js +662 -0
  194. package/dist/test/shutdown-errors.test.js.map +1 -0
  195. package/dist/test/silent-heartbeat-rows.test.d.ts +2 -0
  196. package/dist/test/silent-heartbeat-rows.test.d.ts.map +1 -0
  197. package/dist/test/silent-heartbeat-rows.test.js +451 -0
  198. package/dist/test/silent-heartbeat-rows.test.js.map +1 -0
  199. package/dist/test/silent-heartbeat.test.js +49 -38
  200. package/dist/test/silent-heartbeat.test.js.map +1 -1
  201. package/dist/test/stop-with-work-in-flight.test.d.ts +23 -0
  202. package/dist/test/stop-with-work-in-flight.test.d.ts.map +1 -0
  203. package/dist/test/stop-with-work-in-flight.test.js +672 -0
  204. package/dist/test/stop-with-work-in-flight.test.js.map +1 -0
  205. package/dist/test/tool-batch-hook.test.d.ts +8 -0
  206. package/dist/test/tool-batch-hook.test.d.ts.map +1 -0
  207. package/dist/test/tool-batch-hook.test.js +275 -0
  208. package/dist/test/tool-batch-hook.test.js.map +1 -0
  209. package/dist/test/tool-presentation.test.d.ts +2 -0
  210. package/dist/test/tool-presentation.test.d.ts.map +1 -0
  211. package/dist/test/tool-presentation.test.js +268 -0
  212. package/dist/test/tool-presentation.test.js.map +1 -0
  213. package/dist/test/tool-result-guard.test.js +2330 -18
  214. package/dist/test/tool-result-guard.test.js.map +1 -1
  215. package/dist/test/tool-result-history.test.js +2 -1
  216. package/dist/test/tool-result-history.test.js.map +1 -1
  217. package/dist/test/turn-trigger-provenance.test.js +35 -0
  218. package/dist/test/turn-trigger-provenance.test.js.map +1 -1
  219. package/dist/test/unconvertible-tool-result.test.d.ts +2 -0
  220. package/dist/test/unconvertible-tool-result.test.d.ts.map +1 -0
  221. package/dist/test/unconvertible-tool-result.test.js +358 -0
  222. package/dist/test/unconvertible-tool-result.test.js.map +1 -0
  223. package/dist/test/workspace-materialize-freshness.test.d.ts +16 -0
  224. package/dist/test/workspace-materialize-freshness.test.d.ts.map +1 -0
  225. package/dist/test/workspace-materialize-freshness.test.js +252 -0
  226. package/dist/test/workspace-materialize-freshness.test.js.map +1 -0
  227. package/dist/test/workspace-three-way.test.d.ts +12 -0
  228. package/dist/test/workspace-three-way.test.d.ts.map +1 -0
  229. package/dist/test/workspace-three-way.test.js +3079 -0
  230. package/dist/test/workspace-three-way.test.js.map +1 -0
  231. package/dist/tsconfig.tsbuildinfo +1 -1
  232. package/package.json +3 -3
  233. package/src/agent.ts +120 -44
  234. package/src/code-execution/py-runner.ts +66 -9
  235. package/src/code-execution/runtime-py.ts +215 -38
  236. package/src/framework.ts +1661 -363
  237. package/src/gate/event-gate.ts +59 -7
  238. package/src/index.ts +11 -0
  239. package/src/mcpl/channel-registry.ts +24 -3
  240. package/src/mcpl/conversation-router.ts +34 -1
  241. package/src/mcpl/feature-set-manager.ts +36 -11
  242. package/src/mcpl/index.ts +2 -0
  243. package/src/mcpl/prose-stream-router.ts +79 -23
  244. package/src/mcpl/push-coalescer.ts +62 -13
  245. package/src/mcpl/push-handler.ts +41 -12
  246. package/src/mcpl/server-connection.ts +41 -10
  247. package/src/mcpl/server-registry.ts +24 -7
  248. package/src/mcpl/tool-lifecycle.ts +77 -2
  249. package/src/mcpl/tool-pattern-check.ts +106 -0
  250. package/src/mcpl/types.ts +15 -5
  251. package/src/mcpl/visible-content.ts +57 -0
  252. package/src/module-registry.ts +252 -16
  253. package/src/modules/workspace/branch-intent.ts +123 -0
  254. package/src/modules/workspace/disk-agreement.ts +325 -0
  255. package/src/modules/workspace/effects.ts +362 -0
  256. package/src/modules/workspace/index.ts +1058 -446
  257. package/src/modules/workspace/observe.ts +839 -0
  258. package/src/modules/workspace/reconcile.ts +1136 -0
  259. package/src/modules/workspace/sync.ts +6 -336
  260. package/src/modules/workspace/types.ts +75 -10
  261. package/src/record-journal.ts +246 -0
  262. package/src/shutdown.ts +49 -0
  263. package/src/silent-heartbeat.ts +141 -0
  264. package/src/tool-presentation.ts +188 -0
  265. package/src/tool-result-guard.ts +335 -33
  266. package/src/tool-result-history.ts +25 -1
  267. package/src/types/agent.ts +18 -2
  268. package/src/types/events.ts +4 -0
  269. package/src/types/framework.ts +12 -0
  270. package/src/types/module.ts +15 -0
  271. package/src/types/trace.ts +80 -0
@@ -0,0 +1,368 @@
1
+ /**
2
+ * Visibly-empty MCPL content never becomes a wake (agent-framework#235 F2).
3
+ *
4
+ * An empty push or channel message is stripped before the model sees it, so
5
+ * a wake queued for it shows the model `[Continue]` or an older message as
6
+ * the newest — a wake with no visible cause. The MCPL boundary rejects such
7
+ * content (-32602 on push/event, an itemized result on channels/incoming);
8
+ * only a coalescing retraction and the exact silent-heartbeat marker may be
9
+ * empty. The store/wake site drops anything that gets past the boundary.
10
+ *
11
+ * Run: node --import tsx --test test/mcpl-empty-content.test.ts
12
+ */
13
+ import { test } from 'node:test';
14
+ import assert from 'node:assert/strict';
15
+ import { mkdtempSync, rmSync } from 'node:fs';
16
+ import { tmpdir } from 'node:os';
17
+ import { join } from 'node:path';
18
+ import { AgentFramework } from '../src/index.js';
19
+ import { PushHandler } from '../src/mcpl/push-handler.js';
20
+ import { ChannelRegistry } from '../src/mcpl/channel-registry.js';
21
+ import { CapabilityGrant, ALL_CAPABILITY_PATHS } from '../src/mcpl/capability-grant.js';
22
+ import { isSilentHeartbeatMarker, isVisiblyEmptyContent } from '../src/mcpl/visible-content.js';
23
+ import { MockMembrane, createMockResponse } from './helpers/mock-membrane.js';
24
+ import { fixture, TS } from './helpers/coalescing-fixture.js';
25
+ const EMPTY_SHAPES = [
26
+ ['[]', []],
27
+ ["''", [{ type: 'text', text: '' }]],
28
+ ['whitespace-only text', [{ type: 'text', text: ' \n\t ' }]],
29
+ ['several blank text blocks', [{ type: 'text', text: '' }, { type: 'text', text: ' ' }]],
30
+ ];
31
+ const IMAGE = { type: 'image', data: 'AAAA', mimeType: 'image/png' };
32
+ const MARKER_ORIGIN = { source: 'heartbeat', reason: 'schedule', silent: true };
33
+ // ---------------------------------------------------------------------------
34
+ // The shared predicates
35
+ // ---------------------------------------------------------------------------
36
+ test('isVisiblyEmptyContent: blank text is empty; any non-text block or real text is not', () => {
37
+ for (const [, content] of EMPTY_SHAPES)
38
+ assert.equal(isVisiblyEmptyContent(content), true);
39
+ assert.equal(isVisiblyEmptyContent([{ type: 'text', text: 7 }]), true, 'non-string text is stripped downstream');
40
+ assert.equal(isVisiblyEmptyContent([IMAGE]), false);
41
+ assert.equal(isVisiblyEmptyContent([{ type: 'text', text: ' ' }, { type: 'text', text: 'x' }]), false);
42
+ });
43
+ test('isSilentHeartbeatMarker matches only the exact marker', () => {
44
+ const marker = { serverId: 'heartbeat', featureSet: 'heartbeat', origin: MARKER_ORIGIN, content: [] };
45
+ assert.equal(isSilentHeartbeatMarker(marker), true);
46
+ assert.equal(isSilentHeartbeatMarker({ ...marker, serverId: 'other' }), false);
47
+ assert.equal(isSilentHeartbeatMarker({ ...marker, featureSet: 'other' }), false);
48
+ assert.equal(isSilentHeartbeatMarker({ ...marker, origin: { ...MARKER_ORIGIN, source: 'reminder' } }), false);
49
+ assert.equal(isSilentHeartbeatMarker({ ...marker, origin: { ...MARKER_ORIGIN, silent: 'true' } }), false);
50
+ assert.equal(isSilentHeartbeatMarker({ ...marker, content: [{ type: 'text', text: '' }] }), false, 'blank text is not the marker');
51
+ });
52
+ // ---------------------------------------------------------------------------
53
+ // push/event boundary (PushHandler)
54
+ // ---------------------------------------------------------------------------
55
+ function pushHarness(handleCoalesced) {
56
+ const pushed = [];
57
+ const traces = [];
58
+ const handler = new PushHandler({ validateInbound() { } }, (e) => { pushed.push(e); }, (t) => { traces.push(t); }, undefined, handleCoalesced);
59
+ const send = async (serverId, params, legacy = false) => {
60
+ const out = {};
61
+ await handler.handlePushEvent(serverId, { featureSet: 'fs', eventId: `e-${Math.random()}`, timestamp: TS, ...params }, {
62
+ respond: (r) => { out.result = r; },
63
+ ...(legacy ? {} : { respondError: (code, message, data) => { out.error = { code, message, data }; } }),
64
+ });
65
+ return out;
66
+ };
67
+ return { pushed, traces, send };
68
+ }
69
+ for (const [label, content] of EMPTY_SHAPES) {
70
+ test(`push/event with ${label} content is rejected -32602 with the field, and queues nothing`, async () => {
71
+ const h = pushHarness();
72
+ const out = await h.send('editor', { payload: { content } });
73
+ assert.equal(out.result, undefined);
74
+ assert.equal(out.error?.code, -32602);
75
+ assert.deepEqual(out.error?.data, { field: 'payload.content' });
76
+ assert.equal(h.pushed.length, 0, 'no event queued');
77
+ assert.ok(h.traces.some((t) => t.type === 'mcpl:push-event-rejected' && t.reason === 'empty-content' && t.serverId === 'editor'));
78
+ });
79
+ }
80
+ test('a rejected empty push does not burn its eventId for a corrected retry', async () => {
81
+ const h = pushHarness();
82
+ const first = await h.send('editor', { eventId: 'same', payload: { content: [] } });
83
+ assert.equal(first.error?.code, -32602);
84
+ const retry = await h.send('editor', { eventId: 'same', payload: { content: [{ type: 'text', text: 'now with words' }] } });
85
+ assert.equal(retry.result?.accepted, true);
86
+ assert.equal(h.pushed.length, 1);
87
+ });
88
+ test('a legacy responder without an error path gets accepted:false, reason empty-content', async () => {
89
+ const h = pushHarness();
90
+ const out = await h.send('editor', { payload: { content: [] } }, true);
91
+ assert.deepEqual(out.result, { accepted: false, reason: 'empty-content' });
92
+ assert.equal(h.pushed.length, 0);
93
+ });
94
+ test('image-only push content is accepted', async () => {
95
+ const h = pushHarness();
96
+ const out = await h.send('editor', { payload: { content: [IMAGE] } });
97
+ assert.equal(out.result?.accepted, true);
98
+ assert.equal(h.pushed.length, 1);
99
+ assert.equal(h.pushed[0].content[0].type, 'image');
100
+ });
101
+ test('the exact silent-heartbeat marker is accepted with its empty payload', async () => {
102
+ const h = pushHarness();
103
+ const out = await h.send('heartbeat', { featureSet: 'heartbeat', origin: MARKER_ORIGIN, payload: { content: [] } });
104
+ assert.equal(out.result?.accepted, true);
105
+ assert.equal(h.pushed.length, 1);
106
+ assert.deepEqual(h.pushed[0].content, []);
107
+ });
108
+ test('the marker from another server, or with blank text instead of no content, is rejected', async () => {
109
+ const h = pushHarness();
110
+ const spoofed = await h.send('other', { featureSet: 'heartbeat', origin: MARKER_ORIGIN, payload: { content: [] } });
111
+ assert.equal(spoofed.error?.code, -32602);
112
+ const blank = await h.send('heartbeat', { featureSet: 'heartbeat', origin: MARKER_ORIGIN, payload: { content: [{ type: 'text', text: ' ' }] } });
113
+ assert.equal(blank.error?.code, -32602);
114
+ assert.equal(h.pushed.length, 0);
115
+ });
116
+ test('coalescing: an empty retraction is exempt; an empty plain occurrence is rejected before the coalescer', async () => {
117
+ const seen = [];
118
+ const h = pushHarness(async (_s, params) => { seen.push(params); return { accepted: true, coalesce: { outcome: 'consumed' } }; });
119
+ const retract = await h.send('editor', { coalesce: { key: 'k', retract: true }, payload: { content: [] } });
120
+ assert.equal(retract.result?.accepted, true);
121
+ assert.equal(seen.length, 1, 'retraction reached the coalescer');
122
+ const plain = await h.send('editor', { coalesce: { key: 'k' }, payload: { content: [{ type: 'text', text: '' }] } });
123
+ assert.equal(plain.error?.code, -32602);
124
+ assert.deepEqual(plain.error?.data, { field: 'payload.content' });
125
+ assert.equal(seen.length, 1, 'the empty plain occurrence never reached the coalescer');
126
+ });
127
+ // ---------------------------------------------------------------------------
128
+ // channels/incoming boundary (ChannelRegistry)
129
+ // ---------------------------------------------------------------------------
130
+ function channelHarness() {
131
+ const pushed = [];
132
+ const traces = [];
133
+ const server = { grant: new CapabilityGrant(new Set(ALL_CAPABILITY_PATHS), []) };
134
+ const registry = new ChannelRegistry({ getServer: () => server }, {}, (e) => { pushed.push(e); }, (t) => { traces.push(t); });
135
+ registry.channels
136
+ .set('discord:chan', { serverId: 'discord', descriptor: { id: 'chan', type: 'discord', label: 'chan' }, open: false });
137
+ const send = async (...contents) => {
138
+ let response;
139
+ await registry.handleIncoming('discord', {
140
+ messages: contents.map((content, i) => ({
141
+ channelId: 'chan', messageId: `m${i}`, author: { id: 'u', name: 'User' }, timestamp: TS, content,
142
+ })),
143
+ }, { respond: (r) => { response = r; } });
144
+ return response.results;
145
+ };
146
+ return { pushed, traces, send };
147
+ }
148
+ for (const [label, content] of EMPTY_SHAPES) {
149
+ test(`channels/incoming with ${label} content is rejected per message and queues nothing`, async () => {
150
+ const h = channelHarness();
151
+ const results = await h.send(content);
152
+ assert.deepEqual(results, [{ messageId: 'm0', accepted: false, reason: 'empty_content' }]);
153
+ assert.equal(h.pushed.length, 0);
154
+ assert.ok(h.traces.some((t) => t.type === 'mcpl:channel-incoming-rejected' && t.reason === 'empty-content'));
155
+ });
156
+ }
157
+ test('channels/incoming: an empty message fails alone; its siblings and image-only messages are accepted', async () => {
158
+ const h = channelHarness();
159
+ const results = await h.send([], [{ type: 'text', text: 'hello' }], [IMAGE]);
160
+ assert.deepEqual(results.map((r) => r.accepted), [false, true, true]);
161
+ assert.equal(h.pushed.length, 2);
162
+ });
163
+ // ---------------------------------------------------------------------------
164
+ // Wire level, including coalescing retractions
165
+ // ---------------------------------------------------------------------------
166
+ test('wire: an empty push/event gets a -32602 error, stores nothing and wakes nobody', async (t) => {
167
+ const f = await fixture();
168
+ t.after(f.close);
169
+ // Typed listener, no casts: the rejection is a TraceEvent union member.
170
+ const rejected = [];
171
+ f.framework.onTrace((e) => {
172
+ if (e.type === 'mcpl:push-event-rejected')
173
+ rejected.push({ serverId: e.serverId, featureSet: e.featureSet, reason: e.reason });
174
+ });
175
+ const before = f.framework.getAgent('agent').getContextManager().getMessageCount();
176
+ for (const [, content] of EMPTY_SHAPES) {
177
+ const r = await f.send('push/event', { featureSet: 'doc', eventId: `e-${Math.random()}`, timestamp: TS, payload: { content } });
178
+ assert.equal(r.error?.code, -32602);
179
+ assert.equal(r.error?.data?.field, 'payload.content');
180
+ }
181
+ await f.framework.runUntilIdle();
182
+ assert.equal(f.framework.getAgent('agent').getContextManager().getMessageCount(), before);
183
+ assert.equal(f.membrane.calls.length, 0, 'no inference');
184
+ assert.deepEqual(rejected, EMPTY_SHAPES.map(() => ({ serverId: 'editor', featureSet: 'doc', reason: 'empty-content' })));
185
+ });
186
+ test('wire: an empty deferred notice is rejected (its fallback must be self-contained, RFC-006 §5.1)', async (t) => {
187
+ const f = await fixture();
188
+ t.after(f.close);
189
+ const r = await f.send('push/event', f.params('1', '', { deferred: true }));
190
+ assert.equal(r.error?.code, -32602);
191
+ await f.framework.runUntilIdle();
192
+ assert.equal(f.renders.length, 0);
193
+ assert.equal(f.membrane.calls.length, 0);
194
+ });
195
+ test('wire: a coalesced channel message with no content is rejected; an empty retraction is not', async (t) => {
196
+ const f = await fixture();
197
+ t.after(f.close);
198
+ await f.register();
199
+ const rejected = [];
200
+ f.framework.onTrace((e) => {
201
+ if (e.type === 'mcpl:channel-incoming-rejected')
202
+ rejected.push({ channelId: e.channelId, messageId: e.messageId, reason: e.reason });
203
+ });
204
+ const empty = await f.send('channels/incoming', { messages: [f.channel('a', '', { initial: true })] });
205
+ assert.deepEqual(empty.result.results, [{ messageId: 'm', accepted: false, reason: 'empty_content' }]);
206
+ assert.deepEqual(rejected, [{ channelId: 'chat', messageId: 'm', reason: 'empty-content' }]);
207
+ await f.send('channels/incoming', { messages: [f.channel('b', 'original_text', { initial: true })] });
208
+ await f.framework.runUntilIdle();
209
+ const count = f.framework.getAgent('agent').getContextManager().getMessageCount();
210
+ const retract = await f.send('channels/incoming', { messages: [f.channel('c', '', { retract: true })] });
211
+ assert.equal(retract.result.results[0].accepted, true);
212
+ assert.equal(retract.result.results[0].coalesce.outcome, 'consumed');
213
+ assert.equal(f.framework.getAgent('agent').getContextManager().getMessageCount(), count);
214
+ });
215
+ test('wire: a retraction whose notice is only blank text appends nothing ("consumed")', async (t) => {
216
+ const f = await fixture();
217
+ t.after(f.close);
218
+ await f.send('push/event', f.params('1', 'read_original', { initial: true }));
219
+ await f.framework.runUntilIdle();
220
+ const calls = f.membrane.calls.length;
221
+ const count = f.framework.getAgent('agent').getContextManager().getMessageCount();
222
+ const r = await f.send('push/event', f.params('2', ' ', { retract: true }));
223
+ assert.equal(r.result.coalesce.outcome, 'consumed');
224
+ await f.framework.runUntilIdle();
225
+ assert.equal(f.framework.getAgent('agent').getContextManager().getMessageCount(), count);
226
+ assert.equal(f.membrane.calls.length, calls, 'no wake');
227
+ });
228
+ for (const [label, rendered] of [['only blank text', [{ type: 'text', text: ' ' }]], ['no content', []]]) {
229
+ test(`wire: a render of ${label} appends nothing and, as the only wake cause, starts no inference (RFC-006 §5.2)`, async (t) => {
230
+ const f = await fixture();
231
+ t.after(f.close);
232
+ f.renderer(async () => ({ content: rendered }));
233
+ await f.send('push/event', f.params('1', 'fallback_text', { deferred: true }));
234
+ await f.framework.runUntilIdle();
235
+ assert.equal(f.renders.length, 1);
236
+ assert(!f.context().includes('fallback_text'), 'an empty render is not a failed render: no fallback');
237
+ assert(!f.context().includes('coalescingSubject'), 'no materialized occurrence was stored');
238
+ assert.equal(f.membrane.calls.length, 0, 'no model call for a wake whose only cause rendered nothing');
239
+ });
240
+ }
241
+ test('wire: two deferred batches that both render nothing start no inference', async (t) => {
242
+ const f = await fixture();
243
+ t.after(f.close);
244
+ f.renderer(async (p) => ({ content: p.key === 'a' ? [] : [{ type: 'text', text: ' ' }] }));
245
+ await f.send('push/event', f.params('1', 'fallback_a', { deferred: true, key: 'a' }));
246
+ await f.send('push/event', f.params('2', 'fallback_b', { deferred: true, key: 'b' }));
247
+ await f.framework.runUntilIdle();
248
+ assert.equal(f.renders.length, 2);
249
+ assert.equal(f.membrane.calls.length, 0);
250
+ assert(!f.context().includes('coalescingSubject'));
251
+ });
252
+ test('wire: of two deferred batches, one with content keeps the turn', async (t) => {
253
+ const f = await fixture();
254
+ t.after(f.close);
255
+ f.renderer(async (p) => ({ content: p.key === 'a' ? [] : [{ type: 'text', text: 'b_changed' }] }));
256
+ await f.send('push/event', f.params('1', 'fallback_a', { deferred: true, key: 'a' }));
257
+ await f.send('push/event', f.params('2', 'fallback_b', { deferred: true, key: 'b' }));
258
+ await f.framework.runUntilIdle();
259
+ assert.equal(f.renders.length, 2);
260
+ assert.equal(f.membrane.calls.length, 1);
261
+ assert(f.lastRequest().includes('b_changed') && !f.lastRequest().includes('fallback_a'));
262
+ });
263
+ test('wire: content from a batch that was not among the turn\'s causes keeps the turn', async (t) => {
264
+ const f = await fixture();
265
+ t.after(f.close);
266
+ f.renderer(async (p) => ({ content: p.key === 'a' ? [] : [{ type: 'text', text: 'ambient_b' }] }));
267
+ await f.send('push/event', f.params('1', 'fallback_a', { deferred: true, key: 'a' }));
268
+ await f.send('push/event', f.params('2', 'fallback_b', { deferred: true, key: 'b' }));
269
+ // As if b never qualified for a wake: only a's wake remains, but b still
270
+ // renders at this turn's assembly.
271
+ const internals = f.framework;
272
+ internals.pendingRequests = internals.pendingRequests.filter((r) => !r.coalescingSubject?.endsWith(',"b"]'));
273
+ await f.framework.runUntilIdle();
274
+ assert.equal(f.renders.length, 2);
275
+ assert.equal(f.membrane.calls.length, 1);
276
+ assert(f.lastRequest().includes('ambient_b'));
277
+ });
278
+ test('wire: an empty render does not cancel a turn that has another cause', async (t) => {
279
+ const f = await fixture();
280
+ t.after(f.close);
281
+ await f.register();
282
+ f.renderer(async () => ({ content: [{ type: 'text', text: ' ' }] }));
283
+ await f.send('push/event', f.params('1', 'fallback_text', { deferred: true }));
284
+ await f.send('push/event', { featureSet: 'doc', eventId: 'plain', timestamp: TS, payload: { content: [{ type: 'text', text: 'real_news' }] } });
285
+ await f.framework.runUntilIdle();
286
+ assert.equal(f.renders.length, 1);
287
+ assert.equal(f.membrane.calls.length, 1, 'the ordinary push still gets its turn');
288
+ assert(f.lastRequest().includes('real_news'));
289
+ });
290
+ test('wire: a rendered batch still starts its turn', async (t) => {
291
+ const f = await fixture();
292
+ t.after(f.close);
293
+ await f.send('push/event', f.params('1', 'fallback_text', { deferred: true }));
294
+ await f.framework.runUntilIdle();
295
+ assert.equal(f.renders.length, 1);
296
+ assert.equal(f.membrane.calls.length, 1);
297
+ assert(f.lastRequest().includes('document_diff'));
298
+ });
299
+ // ---------------------------------------------------------------------------
300
+ // Framework backstop at the store/wake site
301
+ // ---------------------------------------------------------------------------
302
+ async function frameworkHarness() {
303
+ const dir = mkdtempSync(join(tmpdir(), 'empty-content-af-'));
304
+ const membrane = new MockMembrane();
305
+ const framework = await AgentFramework.create({
306
+ storePath: join(dir, 'store'), membrane: membrane.asMembrane(),
307
+ agents: [{ name: 'assistant', model: 'test', systemPrompt: 'test' }],
308
+ modules: [],
309
+ });
310
+ const added = [];
311
+ const dropped = [];
312
+ let starts = 0;
313
+ framework.onTrace((e) => {
314
+ if (e.type === 'message:added')
315
+ added.push(e.source);
316
+ if (e.type === 'mcpl:empty-content-dropped')
317
+ dropped.push(e);
318
+ if (e.type === 'inference:started')
319
+ starts++;
320
+ });
321
+ return {
322
+ framework, membrane, added, dropped, starts: () => starts,
323
+ close: async () => { await framework.stop(); rmSync(dir, { recursive: true, force: true }); },
324
+ };
325
+ }
326
+ test('backstop: an empty push that reaches the framework stores no row and queues no wake', async (t) => {
327
+ const x = await frameworkHarness();
328
+ t.after(x.close);
329
+ x.membrane.pushResponse(createMockResponse([{ type: 'text', text: 'invented cause' }]));
330
+ for (const [, content] of EMPTY_SHAPES) {
331
+ x.framework.handleMcplPushEvent({
332
+ type: 'mcpl:push-event', serverId: 'module', featureSet: 'fs', eventId: `e-${Math.random()}`,
333
+ content, timestamp: TS, inferenceId: 'i', triggerInference: true,
334
+ });
335
+ }
336
+ await x.framework.runUntilIdle();
337
+ assert.deepEqual(x.added, []);
338
+ assert.equal(x.starts(), 0);
339
+ assert.equal(x.dropped.length, EMPTY_SHAPES.length);
340
+ assert.ok(x.dropped.every((d) => d.lane === 'push' && d.serverId === 'module'));
341
+ });
342
+ test('backstop: an empty channel message that reaches the framework stores no row and queues no wake', async (t) => {
343
+ const x = await frameworkHarness();
344
+ t.after(x.close);
345
+ x.membrane.pushResponse(createMockResponse([{ type: 'text', text: 'invented cause' }]));
346
+ await x.framework.handleMcplChannelIncoming({
347
+ type: 'mcpl:channel-incoming', serverId: 'discord', channelId: 'discord:g:c', messageId: 'm1',
348
+ author: { id: 'u', name: 'User' }, content: [{ type: 'text', text: ' ' }], timestamp: TS, triggerInference: true,
349
+ });
350
+ await x.framework.runUntilIdle();
351
+ assert.deepEqual(x.added, []);
352
+ assert.equal(x.starts(), 0);
353
+ assert.deepEqual(x.dropped.map((d) => [d.lane, d.messageId]), [['channel', 'm1']]);
354
+ });
355
+ test('backstop: image-only push content is stored and wakes', async (t) => {
356
+ const x = await frameworkHarness();
357
+ t.after(x.close);
358
+ x.membrane.pushResponse(createMockResponse([{ type: 'text', text: 'saw it' }]));
359
+ x.framework.handleMcplPushEvent({
360
+ type: 'mcpl:push-event', serverId: 'camera', featureSet: 'fs', eventId: 'img',
361
+ content: [{ type: 'image', source: { type: 'base64', data: 'AAAA', mediaType: 'image/png' } }],
362
+ timestamp: TS, inferenceId: 'i', triggerInference: true,
363
+ });
364
+ await x.framework.runUntilIdle();
365
+ assert.deepEqual(x.added, ['mcpl:push-event']);
366
+ assert.equal(x.starts(), 1);
367
+ });
368
+ //# sourceMappingURL=mcpl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CAAC,EAAE,EAAE;IACxE,MAAM,CAAC,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAmB,CAAC,CAAC,CAAC;IACjG,CAAC,CAAC,SAAiB,CAAC,mBAAmB,CAAC;QACvC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK;QAC7E,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,CAAC;QAC9F,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAI;KACxD,CAAC,CAAC;IACH,MAAM,CAAC,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;IACjC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC/C,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC"}
@@ -10,7 +10,7 @@
10
10
  import { test, describe } from 'node:test';
11
11
  import assert from 'node:assert/strict';
12
12
  import { CapabilityGrant, computeGrant } from '../src/mcpl/capability-grant.js';
13
- import { ToolLifecycleEmitter, openingFor, parseToolObserveParams, } from '../src/mcpl/tool-lifecycle.js';
13
+ import { SCRIPT_PARENT_META_KEY, ToolLifecycleEmitter, openingFor, parseToolObserveParams, } from '../src/mcpl/tool-lifecycle.js';
14
14
  const OBSERVE = 'toolLifecycle.observe';
15
15
  const INPUTS = 'toolLifecycle.inputs';
16
16
  function observer(id, paths, filter = null) {
@@ -249,6 +249,111 @@ describe('ToolLifecycleEmitter', () => {
249
249
  assert.ok(!JSON.stringify(o.sent).includes('import bpy'));
250
250
  });
251
251
  });
252
+ // ── Calls made by a code_execution script (issue #235 F4) ───────────────────
253
+ describe('ToolLifecycleEmitter: script-inner calls', () => {
254
+ /**
255
+ * What the framework does: the code_execution call is dispatched like any
256
+ * model call, and while it is (between register and open) it reads the
257
+ * origin its script's calls inherit.
258
+ */
259
+ function runScript(emitter, agent, inferenceId, id) {
260
+ emitter.register(agent, inferenceId, { id, name: 'code_execution', input: { code: '...' } });
261
+ const origin = emitter.scriptOrigin(agent, id);
262
+ emitter.open(agent, id);
263
+ return origin;
264
+ }
265
+ function scriptCall(emitter, agent, origin, call, refusedByHost = false) {
266
+ emitter.registerScriptCall(agent, origin, call);
267
+ if (refusedByHost)
268
+ emitter.refuse(agent, call.id);
269
+ emitter.open(agent, call.id);
270
+ }
271
+ test('reported under the inner tool, the parent inference, and the parent call in _meta', () => {
272
+ const o = observer('obs', [OBSERVE]);
273
+ const { emitter, tick } = harness({ observers: [o], classes: { code_execution: ['shell'], 'chat--send': ['comms'] } });
274
+ const origin = runScript(emitter, 'scout', 'inf_1', TOOLU(50));
275
+ assert.deepEqual(origin, { inferenceId: 'inf_1', parentToolCallId: TOOLU(50) });
276
+ scriptCall(emitter, 'scout', origin, { id: 'pytc-1', name: 'chat--send', input: { text: 'hi' } });
277
+ tick(120);
278
+ emitter.onResult('scout', 'pytc-1', { success: true });
279
+ emitter.onResult('scout', TOOLU(50), { success: true });
280
+ const inner = o.sent.filter((p) => p.tool === 'chat--send');
281
+ assert.deepEqual(inner.map((p) => p.phase), ['started', 'completed']);
282
+ for (const p of inner) {
283
+ assert.deepEqual(p.class, ['comms']);
284
+ assert.equal(p.serverTool, 'send');
285
+ assert.equal(p.inferenceId, 'inf_1');
286
+ assert.deepEqual(p._meta, { [SCRIPT_PARENT_META_KEY]: TOOLU(50) });
287
+ }
288
+ assert.equal(inner[0].toolCallId, inner[1].toolCallId);
289
+ assert.notEqual(inner[0].toolCallId, TOOLU(50));
290
+ assert.equal(inner[1].durationMs, 120);
291
+ // The model's own call carries no attribution.
292
+ for (const p of o.sent.filter((p) => p.tool === 'code_execution'))
293
+ assert.equal('_meta' in p, false);
294
+ });
295
+ test("the inner tool's own class decides filters and the inputs class exclusion", () => {
296
+ const o = observer('obs', [OBSERVE, INPUTS], rules([{ match: { class: 'comms' }, input: true }]));
297
+ const { emitter } = harness({
298
+ observers: [o],
299
+ config: { obs: { observe: {}, inputs: { tools: ['*'] } } },
300
+ classes: { code_execution: ['shell'], 'chat--send': ['comms'], 'computer--click': ['computer'] },
301
+ });
302
+ const origin = runScript(emitter, 'scout', 'inf_1', TOOLU(51));
303
+ scriptCall(emitter, 'scout', origin, { id: 'pytc-2', name: 'computer--click', input: { x: 1 } });
304
+ scriptCall(emitter, 'scout', origin, { id: 'pytc-3', name: 'chat--send', input: { text: 'private words' } });
305
+ emitter.onResult('scout', 'pytc-2', { success: true });
306
+ emitter.onResult('scout', 'pytc-3', { success: true });
307
+ assert.deepEqual(o.sent.map((p) => `${p.tool}:${p.phase}`), ['chat--send:started', 'chat--send:completed']);
308
+ assert.equal(o.sent[0].inputWithheld, true, 'comms never carries arguments, from a script either');
309
+ assert.ok(!JSON.stringify(o.sent).includes('private words'));
310
+ });
311
+ test('an error result is completed+isError; a refusal produces nothing; a lost result is failed', () => {
312
+ const o = observer('obs', [OBSERVE]);
313
+ const { emitter } = harness({ observers: [o] });
314
+ const origin = runScript(emitter, 'scout', 'inf_1', TOOLU(52));
315
+ scriptCall(emitter, 'scout', origin, { id: 'pytc-4', name: 'prov--run', input: {} });
316
+ emitter.onResult('scout', 'pytc-4', { success: false, isError: true });
317
+ scriptCall(emitter, 'scout', origin, { id: 'pytc-5', name: 'gone--run', input: {} }, true);
318
+ emitter.onResult('scout', 'pytc-5', { success: false, isError: true });
319
+ scriptCall(emitter, 'scout', origin, { id: 'pytc-6', name: 'prov--hang', input: {} });
320
+ emitter.markDispatchFailure('scout', 'pytc-6'); // the host gave up waiting
321
+ emitter.onResult('scout', 'pytc-6', undefined);
322
+ const inner = o.sent.filter((p) => p.tool !== 'code_execution');
323
+ assert.deepEqual(inner.map((p) => `${p.tool}:${p.phase}:${p.isError}`), [
324
+ 'prov--run:started:undefined', 'prov--run:completed:true',
325
+ 'prov--hang:started:undefined', 'prov--hang:failed:undefined',
326
+ ]);
327
+ });
328
+ test("a stream's end does not abort a script's calls: an orphaned call ends with its own result", () => {
329
+ const o = observer('obs', [OBSERVE]);
330
+ const { emitter } = harness({ observers: [o] });
331
+ const origin = runScript(emitter, 'scout', 'inf_1', TOOLU(53));
332
+ scriptCall(emitter, 'scout', origin, { id: 'pytc-7', name: 'prov--slow', input: {} });
333
+ dispatch(emitter, 'scout', 'inf_1', { id: TOOLU(54), name: 'prov--model', input: {} });
334
+ emitter.abortOpen('scout', ['inf_1']); // turn over; the script and the code_execution call are gone
335
+ emitter.onResult('scout', 'pytc-7', { success: true });
336
+ const phases = (tool) => o.sent.filter((p) => p.tool === tool).map((p) => p.phase);
337
+ assert.deepEqual(phases('code_execution'), ['started', 'aborted']);
338
+ assert.deepEqual(phases('prov--model'), ['started', 'aborted'], 'model calls are aborted as before');
339
+ assert.deepEqual(phases('prov--slow'), ['started', 'completed']);
340
+ assert.equal(emitter.openCount, 0);
341
+ });
342
+ test('a parent nothing observed: its inner calls keep its inference, without a parent id', () => {
343
+ const o = observer('obs', []);
344
+ const { emitter } = harness({ observers: [o] });
345
+ const origin = runScript(emitter, 'scout', 'inf_9', TOOLU(55));
346
+ assert.deepEqual(origin, { inferenceId: 'inf_9' });
347
+ o.grant = new CapabilityGrant(new Set([OBSERVE]), []); // granted while the script runs
348
+ scriptCall(emitter, 'scout', origin, { id: 'pytc-8', name: 'prov--a', input: {} });
349
+ emitter.onResult('scout', 'pytc-8', { success: true });
350
+ assert.deepEqual(o.sent.map((p) => `${p.tool}:${p.phase}:${p.inferenceId}`), [
351
+ 'prov--a:started:inf_9', 'prov--a:completed:inf_9',
352
+ ]);
353
+ assert.equal('_meta' in o.sent[0], false);
354
+ assert.equal(emitter.scriptOrigin('scout', 'not-dispatching'), undefined, 'only the call being dispatched');
355
+ });
356
+ });
252
357
  // ── Grant computation and config robustness ─────────────────────────────────
253
358
  describe('toolLifecycle grant', () => {
254
359
  const caps = (o) => ({ version: '0.5', ...o });