@systemfsoftware/agent 0.0.0-stage → 0.1.0-beta.192

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 (717) hide show
  1. package/LICENSE +21 -0
  2. package/dist/ActivityStore-CEy3oY41.mjs +90 -0
  3. package/dist/ActivityStore-CEy3oY41.mjs.map +1 -0
  4. package/dist/ActivityStore-CPXWRHGz.d.mts +91 -0
  5. package/dist/Admin-BcQDrWKY.mjs +329 -0
  6. package/dist/Admin-BcQDrWKY.mjs.map +1 -0
  7. package/dist/Admin-BfolLkHj.d.mts +5678 -0
  8. package/dist/Agent-Bn3zMhDH.mjs +60 -0
  9. package/dist/Agent-Bn3zMhDH.mjs.map +1 -0
  10. package/dist/Agent-DSVEpq4e.d.mts +219 -0
  11. package/dist/AgentError-RkUaetX8.d.mts +128 -0
  12. package/dist/AgentError-yFdnS9bl.mjs +141 -0
  13. package/dist/AgentError-yFdnS9bl.mjs.map +1 -0
  14. package/dist/AgentPolicy-CI7LRBQa.mjs +116 -0
  15. package/dist/AgentPolicy-CI7LRBQa.mjs.map +1 -0
  16. package/dist/AgentPolicy-D-GmZQex.d.mts +128 -0
  17. package/dist/AgentRegistration-Dg53p6du.mjs +14 -0
  18. package/dist/AgentRegistration-Dg53p6du.mjs.map +1 -0
  19. package/dist/AgentRuntime-CoGy_5dm.d.mts +751 -0
  20. package/dist/AgentRuntime-CzP4I4RB.mjs +5249 -0
  21. package/dist/AgentRuntime-CzP4I4RB.mjs.map +1 -0
  22. package/dist/AgentUpdates-7xT0It_R.d.mts +54 -0
  23. package/dist/AgentUpdates-BS_6gR5K.mjs +66 -0
  24. package/dist/AgentUpdates-BS_6gR5K.mjs.map +1 -0
  25. package/dist/BrowserUse-C9vict2M.d.mts +196 -0
  26. package/dist/BrowserUse-DjEyFDLZ.mjs +156 -0
  27. package/dist/BrowserUse-DjEyFDLZ.mjs.map +1 -0
  28. package/dist/Budget-CXh_ChFJ.d.mts +112 -0
  29. package/dist/Budget-j1UkthgY.mjs +351 -0
  30. package/dist/Budget-j1UkthgY.mjs.map +1 -0
  31. package/dist/CodeExecutor-B_Vt1Ghy.mjs +281 -0
  32. package/dist/CodeExecutor-B_Vt1Ghy.mjs.map +1 -0
  33. package/dist/CodeExecutor-D5-Rda75.d.mts +198 -0
  34. package/dist/CodeMode-B7JvfKAD.d.mts +159 -0
  35. package/dist/CodeMode-BI7WhUkr.mjs +555 -0
  36. package/dist/CodeMode-BI7WhUkr.mjs.map +1 -0
  37. package/dist/CommittedActivity-DXyCKCtX.mjs +146 -0
  38. package/dist/CommittedActivity-DXyCKCtX.mjs.map +1 -0
  39. package/dist/CommittedActivity-LWOKXqdi.d.mts +62 -0
  40. package/dist/Compaction-C0hWAmOG.mjs +15 -0
  41. package/dist/Compaction-C0hWAmOG.mjs.map +1 -0
  42. package/dist/Compaction-e5cNeFmY.d.mts +5 -0
  43. package/dist/ContextCompactor-Chm9BLrD.d.mts +165 -0
  44. package/dist/ContextCompactor-DV4NOQvg.mjs +134 -0
  45. package/dist/ContextCompactor-DV4NOQvg.mjs.map +1 -0
  46. package/dist/ContextHistory-C80rW5M7.mjs +76 -0
  47. package/dist/ContextHistory-C80rW5M7.mjs.map +1 -0
  48. package/dist/ContextHistory-akQ1Td7a.d.mts +65 -0
  49. package/dist/ContextTools-917r7gpv.d.mts +186 -0
  50. package/dist/ContextTools-p8JDPo-W.mjs +88 -0
  51. package/dist/ContextTools-p8JDPo-W.mjs.map +1 -0
  52. package/dist/ContextWindow-BJZI4MMt.d.mts +61 -0
  53. package/dist/ContextWindow-kbFcs1IF.mjs +63 -0
  54. package/dist/ContextWindow-kbFcs1IF.mjs.map +1 -0
  55. package/dist/Digest-BDToAbaX.d.mts +25 -0
  56. package/dist/Digest-CU6IWj-2.mjs +106 -0
  57. package/dist/Digest-CU6IWj-2.mjs.map +1 -0
  58. package/dist/DurableAgentRuntime-BHXo8GPJ.mjs +8432 -0
  59. package/dist/DurableAgentRuntime-BHXo8GPJ.mjs.map +1 -0
  60. package/dist/DurableFailpoint-BD5nowNl.mjs +98 -0
  61. package/dist/DurableFailpoint-BD5nowNl.mjs.map +1 -0
  62. package/dist/DurableFailpoint-Cqi5tyof.d.mts +42 -0
  63. package/dist/DurableStep-CzVIho7y.mjs +54 -0
  64. package/dist/DurableStep-CzVIho7y.mjs.map +1 -0
  65. package/dist/DurableStep-cI_Ho_rU.d.mts +109 -0
  66. package/dist/EventSource-BwZVkEQi.mjs +66 -0
  67. package/dist/EventSource-BwZVkEQi.mjs.map +1 -0
  68. package/dist/EventSource-C0TCBeIf.d.mts +52 -0
  69. package/dist/FailureDiagnostic-DdHV2eFs.mjs +304 -0
  70. package/dist/FailureDiagnostic-DdHV2eFs.mjs.map +1 -0
  71. package/dist/FailureDiagnostic-DpzYNI8f.d.mts +232 -0
  72. package/dist/IdGenerator-BCzwV0ZI.mjs +29 -0
  73. package/dist/IdGenerator-BCzwV0ZI.mjs.map +1 -0
  74. package/dist/IdGenerator-BY8NH74o.d.mts +26 -0
  75. package/dist/Identifiers-LWd4837I.mjs +41 -0
  76. package/dist/Identifiers-LWd4837I.mjs.map +1 -0
  77. package/dist/Identifiers-qafW4EP0.d.mts +38 -0
  78. package/dist/InMemory-BrTm6XEO.mjs +57 -0
  79. package/dist/InMemory-BrTm6XEO.mjs.map +1 -0
  80. package/dist/InMemory-C3qXFT5k.d.mts +46 -0
  81. package/dist/InMemory.d.mts +2 -0
  82. package/dist/InMemory.mjs +1 -0
  83. package/dist/InteractiveBrowser-B-hlNJy5.mjs +237 -0
  84. package/dist/InteractiveBrowser-B-hlNJy5.mjs.map +1 -0
  85. package/dist/InteractiveBrowser-nnML0r7w.d.mts +258 -0
  86. package/dist/LifecyclePublication-BDc_ug5v.mjs +204 -0
  87. package/dist/LifecyclePublication-BDc_ug5v.mjs.map +1 -0
  88. package/dist/Memory-CT5bDZqi.d.mts +57 -0
  89. package/dist/Memory-Dl9ecPpm.mjs +204 -0
  90. package/dist/Memory-Dl9ecPpm.mjs.map +1 -0
  91. package/dist/MemoryNamespace-BtnlH_E6.d.mts +35 -0
  92. package/dist/MemoryNamespace-DZSpjLj9.mjs +116 -0
  93. package/dist/MemoryNamespace-DZSpjLj9.mjs.map +1 -0
  94. package/dist/MemoryNotes-4CRzkPBD.d.mts +425 -0
  95. package/dist/MemoryNotes-i41TsH11.mjs +132 -0
  96. package/dist/MemoryNotes-i41TsH11.mjs.map +1 -0
  97. package/dist/MemoryReference-Dd3KSMa7.d.mts +77 -0
  98. package/dist/MemoryReference-RFU0HQJG.mjs +108 -0
  99. package/dist/MemoryReference-RFU0HQJG.mjs.map +1 -0
  100. package/dist/MemoryRevalidation--aAh_Pfq.mjs +136 -0
  101. package/dist/MemoryRevalidation--aAh_Pfq.mjs.map +1 -0
  102. package/dist/MemoryRevalidation-FsJ8E61W.d.mts +64 -0
  103. package/dist/MemoryStore-Bg5RunTk.d.mts +187 -0
  104. package/dist/MemoryStore-E0J99hb2.mjs +245 -0
  105. package/dist/MemoryStore-E0J99hb2.mjs.map +1 -0
  106. package/dist/MessageDelivery-BE2Yf3FC.mjs +615 -0
  107. package/dist/MessageDelivery-BE2Yf3FC.mjs.map +1 -0
  108. package/dist/MessageDelivery-Dh6GZBt_.d.mts +1129 -0
  109. package/dist/Messaging-BqWHYf93.d.mts +216 -0
  110. package/dist/Messaging-DgSiv4f4.mjs +154 -0
  111. package/dist/Messaging-DgSiv4f4.mjs.map +1 -0
  112. package/dist/Messaging-DhM-APnP.d.mts +1074 -0
  113. package/dist/MessagingHost-Bm5e-kAX.mjs +117 -0
  114. package/dist/MessagingHost-Bm5e-kAX.mjs.map +1 -0
  115. package/dist/MessagingHost-CubWeYKN.d.mts +80 -0
  116. package/dist/OperationAuthorizer-VSiHCC2S.mjs +72 -0
  117. package/dist/OperationAuthorizer-VSiHCC2S.mjs.map +1 -0
  118. package/dist/OperationAuthorizer-y-F-Ox_Q.d.mts +62 -0
  119. package/dist/Output-DQ8mWcgf.mjs +7 -0
  120. package/dist/Output-DQ8mWcgf.mjs.map +1 -0
  121. package/dist/Output-SbOdlBFL.d.mts +22 -0
  122. package/dist/PageCapture-BfRURUOA.mjs +275 -0
  123. package/dist/PageCapture-BfRURUOA.mjs.map +1 -0
  124. package/dist/PageCapture-C_mE72Sd.d.mts +216 -0
  125. package/dist/PageScreenshot-BJTASs4o.mjs +53 -0
  126. package/dist/PageScreenshot-BJTASs4o.mjs.map +1 -0
  127. package/dist/PageScreenshot-CaoaH7mc.d.mts +48 -0
  128. package/dist/PersistentHistory-BrtZ0g2j.d.mts +14 -0
  129. package/dist/PersistentHistory-CTAVhHKH.mjs +147 -0
  130. package/dist/PersistentHistory-CTAVhHKH.mjs.map +1 -0
  131. package/dist/PreparedInputAdmission-Ci18uY4s.d.mts +973 -0
  132. package/dist/PreparedInputAdmission-adqVJJa6.mjs +95 -0
  133. package/dist/PreparedInputAdmission-adqVJJa6.mjs.map +1 -0
  134. package/dist/ProvisionalText-BcKpPYKQ.d.mts +70 -0
  135. package/dist/ProvisionalText-DXddTK4c.mjs +47 -0
  136. package/dist/ProvisionalText-DXddTK4c.mjs.map +1 -0
  137. package/dist/Receipt-B-FlCaNH.mjs +35 -0
  138. package/dist/Receipt-B-FlCaNH.mjs.map +1 -0
  139. package/dist/Receipt-B4feBxMY.d.mts +31 -0
  140. package/dist/RecordFormat-DoNh-AFe.mjs +79 -0
  141. package/dist/RecordFormat-DoNh-AFe.mjs.map +1 -0
  142. package/dist/RecordFormat-ZMus8Dx8.d.mts +52 -0
  143. package/dist/Records-C645aQks.mjs +1145 -0
  144. package/dist/Records-C645aQks.mjs.map +1 -0
  145. package/dist/Records-C9I1nCL9.d.mts +1423 -0
  146. package/dist/Recovery-zWy_kmZq.mjs +736 -0
  147. package/dist/Recovery-zWy_kmZq.mjs.map +1 -0
  148. package/dist/Redaction-C0zLBAn6.d.mts +28 -0
  149. package/dist/Redaction-CtyCBMEj.mjs +116 -0
  150. package/dist/Redaction-CtyCBMEj.mjs.map +1 -0
  151. package/dist/RememberingStore-BO-OnCgP.mjs +23 -0
  152. package/dist/RememberingStore-BO-OnCgP.mjs.map +1 -0
  153. package/dist/RememberingStore-DgqXmILx.d.mts +14 -0
  154. package/dist/RunContinuation-BVAHoYlN.d.mts +127 -0
  155. package/dist/RunContinuation-Bpfp087i.mjs +1060 -0
  156. package/dist/RunContinuation-Bpfp087i.mjs.map +1 -0
  157. package/dist/RunEvent-CwgDzXcH.d.mts +465 -0
  158. package/dist/RunEvent-DJxENnJi.mjs +345 -0
  159. package/dist/RunEvent-DJxENnJi.mjs.map +1 -0
  160. package/dist/RunEventSink-B8uM8bw2.mjs +22 -0
  161. package/dist/RunEventSink-B8uM8bw2.mjs.map +1 -0
  162. package/dist/RunEventSink-f-T4jbNB.d.mts +105 -0
  163. package/dist/RunHooks-Bob22Bcj.d.mts +40 -0
  164. package/dist/RunHooks-DWuLBVdU.mjs +60 -0
  165. package/dist/RunHooks-DWuLBVdU.mjs.map +1 -0
  166. package/dist/RunJournal-C_1eqQdr.mjs +1107 -0
  167. package/dist/RunJournal-C_1eqQdr.mjs.map +1 -0
  168. package/dist/RunOptions-BVSa3BO2.d.mts +560 -0
  169. package/dist/RunOptions-COEUCrx4.mjs +61 -0
  170. package/dist/RunOptions-COEUCrx4.mjs.map +1 -0
  171. package/dist/RunPolicyUsage-B-JXRZYO.mjs +25 -0
  172. package/dist/RunPolicyUsage-B-JXRZYO.mjs.map +1 -0
  173. package/dist/RunPolicyUsage-jvJo0vJp.d.mts +21 -0
  174. package/dist/RunStorage-CsQQ0Y5u.mjs +304 -0
  175. package/dist/RunStorage-CsQQ0Y5u.mjs.map +1 -0
  176. package/dist/Sandbox-37vXP0BV.d.mts +24 -0
  177. package/dist/Sandbox-Bze6pHYc.mjs +30 -0
  178. package/dist/Sandbox-Bze6pHYc.mjs.map +1 -0
  179. package/dist/Schedule-BY0lzbij.mjs +336 -0
  180. package/dist/Schedule-BY0lzbij.mjs.map +1 -0
  181. package/dist/ScheduleTransition-CjVP48I8.d.mts +22 -0
  182. package/dist/ScheduleTransition-DtNzlN9k.mjs +180 -0
  183. package/dist/ScheduleTransition-DtNzlN9k.mjs.map +1 -0
  184. package/dist/Scheduling-BpJN9E1j.mjs +699 -0
  185. package/dist/Scheduling-BpJN9E1j.mjs.map +1 -0
  186. package/dist/Scheduling-DYTM29s9.d.mts +57 -0
  187. package/dist/SemanticMemory-BRV0cuWg.mjs +300 -0
  188. package/dist/SemanticMemory-BRV0cuWg.mjs.map +1 -0
  189. package/dist/SemanticMemory-rgWlhW87.d.mts +431 -0
  190. package/dist/SemanticMemoryIndex-D7yNEWpt.d.mts +826 -0
  191. package/dist/SemanticMemoryIndex-godQDjNx.mjs +186 -0
  192. package/dist/SemanticMemoryIndex-godQDjNx.mjs.map +1 -0
  193. package/dist/SemanticMemoryRevalidation-Bm3_pfsI.d.mts +44 -0
  194. package/dist/SemanticMemoryRevalidation-D8VV-eU6.mjs +179 -0
  195. package/dist/SemanticMemoryRevalidation-D8VV-eU6.mjs.map +1 -0
  196. package/dist/Subagent-CSIRUgUo.mjs +1315 -0
  197. package/dist/Subagent-CSIRUgUo.mjs.map +1 -0
  198. package/dist/Subagent-CXEI5YZ8.d.mts +2368 -0
  199. package/dist/SubagentContract-B7vQPueI.d.mts +176 -0
  200. package/dist/SubagentContract-C-7AxTm_.mjs +187 -0
  201. package/dist/SubagentContract-C-7AxTm_.mjs.map +1 -0
  202. package/dist/SubagentHost-BEnICu7g.mjs +70 -0
  203. package/dist/SubagentHost-BEnICu7g.mjs.map +1 -0
  204. package/dist/SubagentHost-CKhz1vbH.d.mts +167 -0
  205. package/dist/SubagentReservations-BYNAHPpm.mjs +465 -0
  206. package/dist/SubagentReservations-BYNAHPpm.mjs.map +1 -0
  207. package/dist/SubagentReservations-WrmIVzO5.d.mts +185 -0
  208. package/dist/SubmissionLedger-WG0beEyt.mjs +921 -0
  209. package/dist/SubmissionLedger-WG0beEyt.mjs.map +1 -0
  210. package/dist/SubmissionStatus-CPZsOM5a.mjs +17 -0
  211. package/dist/SubmissionStatus-CPZsOM5a.mjs.map +1 -0
  212. package/dist/Subscription-BhQbmUD-.mjs +340 -0
  213. package/dist/Subscription-BhQbmUD-.mjs.map +1 -0
  214. package/dist/Subscription-CC--_OnU.d.mts +815 -0
  215. package/dist/SubscriptionInput-BEeB0Cj8.d.mts +42 -0
  216. package/dist/SubscriptionInput-Xcd4JjEs.mjs +53 -0
  217. package/dist/SubscriptionInput-Xcd4JjEs.mjs.map +1 -0
  218. package/dist/SubscriptionTransition-CWt9UVH0.d.mts +23 -0
  219. package/dist/SubscriptionTransition-lrf733c8.mjs +154 -0
  220. package/dist/SubscriptionTransition-lrf733c8.mjs.map +1 -0
  221. package/dist/Subscriptions-4K_qu_2f.mjs +638 -0
  222. package/dist/Subscriptions-4K_qu_2f.mjs.map +1 -0
  223. package/dist/Subscriptions-BF3aSf8X.d.mts +75 -0
  224. package/dist/Thread-B8JApGHa.mjs +283 -0
  225. package/dist/Thread-B8JApGHa.mjs.map +1 -0
  226. package/dist/Thread-BnAtkJl4.d.mts +116 -0
  227. package/dist/ThreadArchiveRange-1PMdjpdJ.mjs +64 -0
  228. package/dist/ThreadArchiveRange-1PMdjpdJ.mjs.map +1 -0
  229. package/dist/ThreadContextHistory-BSStMOLX.mjs +211 -0
  230. package/dist/ThreadContextHistory-BSStMOLX.mjs.map +1 -0
  231. package/dist/ThreadContextHistory-lTZ8Ftq1.d.mts +33 -0
  232. package/dist/ThreadContextHistoryProjection-Cp7_RR6V.d.mts +59 -0
  233. package/dist/ThreadContextHistoryProjection-_8uNz-h1.mjs +149 -0
  234. package/dist/ThreadContextHistoryProjection-_8uNz-h1.mjs.map +1 -0
  235. package/dist/ThreadHistory-BkyGfv5E.d.mts +76 -0
  236. package/dist/ThreadHistory-Blt_W31N.mjs +69 -0
  237. package/dist/ThreadHistory-Blt_W31N.mjs.map +1 -0
  238. package/dist/ThreadImport-C8Tqiezd.mjs +491 -0
  239. package/dist/ThreadImport-C8Tqiezd.mjs.map +1 -0
  240. package/dist/ThreadImport-DaSmrlRi.d.mts +843 -0
  241. package/dist/ThreadInvariants-DyPhMeo-.d.mts +23 -0
  242. package/dist/ThreadInvariants-fniroLRY.mjs +154 -0
  243. package/dist/ThreadInvariants-fniroLRY.mjs.map +1 -0
  244. package/dist/ThreadProjectionMaintenance-D6fBjr1q.mjs +37 -0
  245. package/dist/ThreadProjectionMaintenance-D6fBjr1q.mjs.map +1 -0
  246. package/dist/ThreadProjectionMaintenance-DjUy7kCa.d.mts +51 -0
  247. package/dist/ThreadStore-BMUAp5Ta.mjs +937 -0
  248. package/dist/ThreadStore-BMUAp5Ta.mjs.map +1 -0
  249. package/dist/ThreadTransfer-B3NkyO_y.mjs +154 -0
  250. package/dist/ThreadTransfer-B3NkyO_y.mjs.map +1 -0
  251. package/dist/ThreadTransfer-BM02cbOo.d.mts +63 -0
  252. package/dist/ThreadWork-C-xa2Boi.mjs +484 -0
  253. package/dist/ThreadWork-C-xa2Boi.mjs.map +1 -0
  254. package/dist/ToolBroker-DkoVyx6T.mjs +42 -0
  255. package/dist/ToolBroker-DkoVyx6T.mjs.map +1 -0
  256. package/dist/ToolBroker-Dy2xM6ht.d.mts +134 -0
  257. package/dist/ToolDiscovery-DHySvLQd.mjs +211 -0
  258. package/dist/ToolDiscovery-DHySvLQd.mjs.map +1 -0
  259. package/dist/ToolDiscovery-VjamzX3q.d.mts +119 -0
  260. package/dist/ToolExposure-Cn7xETn5.d.mts +6 -0
  261. package/dist/ToolExposure-D7id9Gt5.d.mts +37 -0
  262. package/dist/ToolExposure-DCvQWFIa.mjs +9 -0
  263. package/dist/ToolExposure-DCvQWFIa.mjs.map +1 -0
  264. package/dist/ToolExposure-DNME8BkG.d.mts +44 -0
  265. package/dist/ToolExposure-DPnq8Won.mjs +30 -0
  266. package/dist/ToolExposure-DPnq8Won.mjs.map +1 -0
  267. package/dist/ToolExposure-DaGaF5tj.mjs +20 -0
  268. package/dist/ToolExposure-DaGaF5tj.mjs.map +1 -0
  269. package/dist/ToolExposure.d.mts +4 -0
  270. package/dist/ToolExposure.mjs +4 -0
  271. package/dist/ToolReconciler-6bb7xlip.d.mts +81 -0
  272. package/dist/ToolReconciler-DJQd3SZA.mjs +87 -0
  273. package/dist/ToolReconciler-DJQd3SZA.mjs.map +1 -0
  274. package/dist/ToolResult-By5KAje4.d.mts +79 -0
  275. package/dist/ToolResult-DwZxjlHw.mjs +160 -0
  276. package/dist/ToolResult-DwZxjlHw.mjs.map +1 -0
  277. package/dist/ToolResultStorage-BmoRewhh.mjs +46 -0
  278. package/dist/ToolResultStorage-BmoRewhh.mjs.map +1 -0
  279. package/dist/ToolResultStorage-Bp5fm0do.d.mts +49 -0
  280. package/dist/ToolResults-C4-HsMCp.d.mts +33 -0
  281. package/dist/ToolResults-nCgBlTp2.mjs +45 -0
  282. package/dist/ToolResults-nCgBlTp2.mjs.map +1 -0
  283. package/dist/Usage-B0xgME5f.mjs +340 -0
  284. package/dist/Usage-B0xgME5f.mjs.map +1 -0
  285. package/dist/Usage-Bc-jXe_9.d.mts +128 -0
  286. package/dist/WakeScheduler-DVYj66C-.mjs +74 -0
  287. package/dist/WakeScheduler-DVYj66C-.mjs.map +1 -0
  288. package/dist/WakeScheduler-SFqj67Sk.d.mts +74 -0
  289. package/dist/WebCapture-CA4ZarW2.mjs +64 -0
  290. package/dist/WebCapture-CA4ZarW2.mjs.map +1 -0
  291. package/dist/WebCapture-pzIeUJ5W.d.mts +49 -0
  292. package/dist/WebSearch-CD0V--qh.d.mts +18 -0
  293. package/dist/WebSearch-DnbOzRL_.mjs +30 -0
  294. package/dist/WebSearch-DnbOzRL_.mjs.map +1 -0
  295. package/dist/Worker-CQu8Qp1j.mjs +267 -0
  296. package/dist/Worker-CQu8Qp1j.mjs.map +1 -0
  297. package/dist/Worker-xxucY_0b.d.mts +468 -0
  298. package/dist/WorkerAdmission-BhFjx86s.mjs +162 -0
  299. package/dist/WorkerAdmission-BhFjx86s.mjs.map +1 -0
  300. package/dist/WorkerAdmission-BnRuXLWF.d.mts +171 -0
  301. package/dist/WorkerHost-DtYzi54D.d.mts +150 -0
  302. package/dist/WorkerHost-DuQug9Bq.mjs +73 -0
  303. package/dist/WorkerHost-DuQug9Bq.mjs.map +1 -0
  304. package/dist/agent-registration-CNs2twrr.mjs +262 -0
  305. package/dist/agent-registration-CNs2twrr.mjs.map +1 -0
  306. package/dist/capabilities/BrowserUse.d.mts +2 -0
  307. package/dist/capabilities/BrowserUse.mjs +1 -0
  308. package/dist/capabilities/Budget.d.mts +2 -0
  309. package/dist/capabilities/Budget.mjs +1 -0
  310. package/dist/capabilities/CodeMode.d.mts +2 -0
  311. package/dist/capabilities/CodeMode.mjs +1 -0
  312. package/dist/capabilities/ContextTools.d.mts +2 -0
  313. package/dist/capabilities/ContextTools.mjs +1 -0
  314. package/dist/capabilities/MemoryNotes.d.mts +2 -0
  315. package/dist/capabilities/MemoryNotes.mjs +1 -0
  316. package/dist/capabilities/Messaging.d.mts +3 -0
  317. package/dist/capabilities/Messaging.mjs +4 -0
  318. package/dist/capabilities/Redaction.d.mts +2 -0
  319. package/dist/capabilities/Redaction.mjs +1 -0
  320. package/dist/capabilities/RunHooks.d.mts +2 -0
  321. package/dist/capabilities/RunHooks.mjs +1 -0
  322. package/dist/capabilities/SemanticMemory.d.mts +2 -0
  323. package/dist/capabilities/SemanticMemory.mjs +1 -0
  324. package/dist/capabilities/Subagent.d.mts +4 -0
  325. package/dist/capabilities/Subagent.mjs +6 -0
  326. package/dist/capabilities/SubagentReservations.d.mts +2 -0
  327. package/dist/capabilities/SubagentReservations.mjs +1 -0
  328. package/dist/capabilities/ToolDiscovery.d.mts +2 -0
  329. package/dist/capabilities/ToolDiscovery.mjs +1 -0
  330. package/dist/capabilities/ToolResults.d.mts +2 -0
  331. package/dist/capabilities/ToolResults.mjs +1 -0
  332. package/dist/capabilities/WebCapture.d.mts +2 -0
  333. package/dist/capabilities/WebCapture.mjs +1 -0
  334. package/dist/capabilities/WebSearch.d.mts +2 -0
  335. package/dist/capabilities/WebSearch.mjs +1 -0
  336. package/dist/compaction-C3hXuO4Z.mjs +539 -0
  337. package/dist/compaction-C3hXuO4Z.mjs.map +1 -0
  338. package/dist/completion-B_WDnSg-.d.mts +11 -0
  339. package/dist/core/Agent.d.mts +2 -0
  340. package/dist/core/Agent.mjs +1 -0
  341. package/dist/core/AgentError.d.mts +2 -0
  342. package/dist/core/AgentError.mjs +1 -0
  343. package/dist/core/AgentPolicy.d.mts +2 -0
  344. package/dist/core/AgentPolicy.mjs +1 -0
  345. package/dist/core/AgentUpdates.d.mts +2 -0
  346. package/dist/core/AgentUpdates.mjs +1 -0
  347. package/dist/core/FailureDiagnostic.d.mts +2 -0
  348. package/dist/core/FailureDiagnostic.mjs +1 -0
  349. package/dist/core/IdGenerator.d.mts +2 -0
  350. package/dist/core/IdGenerator.mjs +1 -0
  351. package/dist/core/Identifiers.d.mts +2 -0
  352. package/dist/core/Identifiers.mjs +1 -0
  353. package/dist/core/Memory.d.mts +2 -0
  354. package/dist/core/Memory.mjs +1 -0
  355. package/dist/core/MemoryNamespace.d.mts +2 -0
  356. package/dist/core/MemoryNamespace.mjs +1 -0
  357. package/dist/core/MemoryReference.d.mts +2 -0
  358. package/dist/core/MemoryReference.mjs +1 -0
  359. package/dist/core/MemoryRevalidation.d.mts +2 -0
  360. package/dist/core/MemoryRevalidation.mjs +1 -0
  361. package/dist/core/MemoryStore.d.mts +2 -0
  362. package/dist/core/MemoryStore.mjs +1 -0
  363. package/dist/core/ProvisionalText.d.mts +2 -0
  364. package/dist/core/ProvisionalText.mjs +1 -0
  365. package/dist/core/Receipt.d.mts +2 -0
  366. package/dist/core/Receipt.mjs +1 -0
  367. package/dist/core/RememberingStore.d.mts +2 -0
  368. package/dist/core/RememberingStore.mjs +1 -0
  369. package/dist/core/RunEvent.d.mts +3 -0
  370. package/dist/core/RunEvent.mjs +1 -0
  371. package/dist/core/RunPolicyUsage.d.mts +2 -0
  372. package/dist/core/RunPolicyUsage.mjs +1 -0
  373. package/dist/core/SemanticMemoryIndex.d.mts +2 -0
  374. package/dist/core/SemanticMemoryIndex.mjs +1 -0
  375. package/dist/core/SemanticMemoryRevalidation.d.mts +2 -0
  376. package/dist/core/SemanticMemoryRevalidation.mjs +1 -0
  377. package/dist/core/SubagentContract.d.mts +2 -0
  378. package/dist/core/SubagentContract.mjs +1 -0
  379. package/dist/core/Thread.d.mts +2 -0
  380. package/dist/core/Thread.mjs +1 -0
  381. package/dist/core/ToolResult.d.mts +2 -0
  382. package/dist/core/ToolResult.mjs +1 -0
  383. package/dist/core/ToolResultStorage.d.mts +2 -0
  384. package/dist/core/ToolResultStorage.mjs +1 -0
  385. package/dist/core/Usage.d.mts +2 -0
  386. package/dist/core/Usage.mjs +1 -0
  387. package/dist/core/Worker.d.mts +3 -0
  388. package/dist/core/Worker.mjs +3 -0
  389. package/dist/durable/ActivityStore.d.mts +2 -0
  390. package/dist/durable/ActivityStore.mjs +1 -0
  391. package/dist/durable/Admin.d.mts +2 -0
  392. package/dist/durable/Admin.mjs +1 -0
  393. package/dist/durable/AgentRegistration.d.mts +3 -0
  394. package/dist/durable/AgentRegistration.mjs +2 -0
  395. package/dist/durable/CommittedActivity.d.mts +2 -0
  396. package/dist/durable/CommittedActivity.mjs +1 -0
  397. package/dist/durable/Digest.d.mts +2 -0
  398. package/dist/durable/Digest.mjs +3 -0
  399. package/dist/durable/DurableAgentRuntime.d.mts +3 -0
  400. package/dist/durable/DurableAgentRuntime.mjs +4 -0
  401. package/dist/durable/DurableFailpoint.d.mts +2 -0
  402. package/dist/durable/DurableFailpoint.mjs +1 -0
  403. package/dist/durable/DurableFailpointTestControl.d.mts +14 -0
  404. package/dist/durable/DurableFailpointTestControl.mjs +21 -0
  405. package/dist/durable/DurableFailpointTestControl.mjs.map +1 -0
  406. package/dist/durable/EventSource.d.mts +2 -0
  407. package/dist/durable/EventSource.mjs +1 -0
  408. package/dist/durable/LifecyclePublication.d.mts +2 -0
  409. package/dist/durable/LifecyclePublication.mjs +1 -0
  410. package/dist/durable/MessageDelivery.d.mts +2 -0
  411. package/dist/durable/MessageDelivery.mjs +1 -0
  412. package/dist/durable/MessageDeliveryStoreConformance.d.mts +401 -0
  413. package/dist/durable/MessageDeliveryStoreConformance.mjs +273 -0
  414. package/dist/durable/MessageDeliveryStoreConformance.mjs.map +1 -0
  415. package/dist/durable/OperationAuthorizer.d.mts +2 -0
  416. package/dist/durable/OperationAuthorizer.mjs +1 -0
  417. package/dist/durable/PersistentHistory.d.mts +2 -0
  418. package/dist/durable/PersistentHistory.mjs +1 -0
  419. package/dist/durable/PreparedInputAdmission.d.mts +2 -0
  420. package/dist/durable/PreparedInputAdmission.mjs +1 -0
  421. package/dist/durable/RecordFormat.d.mts +2 -0
  422. package/dist/durable/RecordFormat.mjs +1 -0
  423. package/dist/durable/Records.d.mts +2 -0
  424. package/dist/durable/Records.mjs +1 -0
  425. package/dist/durable/Recovery.d.mts +2 -0
  426. package/dist/durable/Recovery.mjs +1 -0
  427. package/dist/durable/RunContinuation.d.mts +4 -0
  428. package/dist/durable/RunContinuation.mjs +4 -0
  429. package/dist/durable/RunJournal.d.mts +2 -0
  430. package/dist/durable/RunJournal.mjs +1 -0
  431. package/dist/durable/RunStorage.d.mts +2 -0
  432. package/dist/durable/RunStorage.mjs +1 -0
  433. package/dist/durable/Schedule.d.mts +2 -0
  434. package/dist/durable/Schedule.mjs +1 -0
  435. package/dist/durable/ScheduleStoreConformance.d.mts +16 -0
  436. package/dist/durable/ScheduleStoreConformance.mjs +421 -0
  437. package/dist/durable/ScheduleStoreConformance.mjs.map +1 -0
  438. package/dist/durable/ScheduleTransition.d.mts +2 -0
  439. package/dist/durable/ScheduleTransition.mjs +1 -0
  440. package/dist/durable/Scheduling.d.mts +2 -0
  441. package/dist/durable/Scheduling.mjs +1 -0
  442. package/dist/durable/SettlementPublisher.d.mts +2 -0
  443. package/dist/durable/SettlementPublisher.mjs +99 -0
  444. package/dist/durable/SettlementPublisher.mjs.map +1 -0
  445. package/dist/durable/SqlMemoryStore.d.mts +729 -0
  446. package/dist/durable/SqlMemoryStore.mjs +626 -0
  447. package/dist/durable/SqlMemoryStore.mjs.map +1 -0
  448. package/dist/durable/SqlStorageOwner.d.mts +18 -0
  449. package/dist/durable/SqlStorageOwner.mjs +6 -0
  450. package/dist/durable/SqlStorageOwner.mjs.map +1 -0
  451. package/dist/durable/SubmissionLedger.d.mts +3 -0
  452. package/dist/durable/SubmissionLedger.mjs +3 -0
  453. package/dist/durable/SubmissionLedgerConformance.d.mts +31 -0
  454. package/dist/durable/SubmissionLedgerConformance.mjs +2090 -0
  455. package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -0
  456. package/dist/durable/SubmissionStatus.d.mts +2 -0
  457. package/dist/durable/SubmissionStatus.mjs +1 -0
  458. package/dist/durable/Subscription.d.mts +2 -0
  459. package/dist/durable/Subscription.mjs +1 -0
  460. package/dist/durable/SubscriptionInput.d.mts +2 -0
  461. package/dist/durable/SubscriptionInput.mjs +1 -0
  462. package/dist/durable/SubscriptionStoreConformance.d.mts +15 -0
  463. package/dist/durable/SubscriptionStoreConformance.mjs +816 -0
  464. package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -0
  465. package/dist/durable/SubscriptionTransition.d.mts +2 -0
  466. package/dist/durable/SubscriptionTransition.mjs +1 -0
  467. package/dist/durable/Subscriptions.d.mts +2 -0
  468. package/dist/durable/Subscriptions.mjs +1 -0
  469. package/dist/durable/ThreadArchiveRange.d.mts +2 -0
  470. package/dist/durable/ThreadArchiveRange.mjs +1 -0
  471. package/dist/durable/ThreadContextHistory.d.mts +2 -0
  472. package/dist/durable/ThreadContextHistory.mjs +1 -0
  473. package/dist/durable/ThreadContextHistoryProjection.d.mts +2 -0
  474. package/dist/durable/ThreadContextHistoryProjection.mjs +1 -0
  475. package/dist/durable/ThreadImport.d.mts +2 -0
  476. package/dist/durable/ThreadImport.mjs +1 -0
  477. package/dist/durable/ThreadInvariants.d.mts +2 -0
  478. package/dist/durable/ThreadInvariants.mjs +1 -0
  479. package/dist/durable/ThreadProjectionMaintenance.d.mts +2 -0
  480. package/dist/durable/ThreadProjectionMaintenance.mjs +1 -0
  481. package/dist/durable/ThreadReader.d.mts +2 -0
  482. package/dist/durable/ThreadReader.mjs +1 -0
  483. package/dist/durable/ThreadStore.d.mts +3 -0
  484. package/dist/durable/ThreadStore.mjs +3 -0
  485. package/dist/durable/ThreadStoreConformance.d.mts +53 -0
  486. package/dist/durable/ThreadStoreConformance.mjs +402 -0
  487. package/dist/durable/ThreadStoreConformance.mjs.map +1 -0
  488. package/dist/durable/ThreadTransfer.d.mts +2 -0
  489. package/dist/durable/ThreadTransfer.mjs +1 -0
  490. package/dist/durable/ThreadWork.d.mts +2 -0
  491. package/dist/durable/ThreadWork.mjs +1 -0
  492. package/dist/durable/ToolReconciler.d.mts +2 -0
  493. package/dist/durable/ToolReconciler.mjs +1 -0
  494. package/dist/durable/WakeScheduler.d.mts +2 -0
  495. package/dist/durable/WakeScheduler.mjs +1 -0
  496. package/dist/durable/WorkerAdmission.d.mts +2 -0
  497. package/dist/durable/WorkerAdmission.mjs +1 -0
  498. package/dist/durable/WorkerHost.d.mts +2 -0
  499. package/dist/durable/WorkerHost.mjs +1 -0
  500. package/dist/engine/AgentRuntime.d.mts +2 -0
  501. package/dist/engine/AgentRuntime.mjs +1 -0
  502. package/dist/engine/Compaction.d.mts +4 -0
  503. package/dist/engine/Compaction.mjs +2 -0
  504. package/dist/engine/ContextCompactor.d.mts +2 -0
  505. package/dist/engine/ContextCompactor.mjs +1 -0
  506. package/dist/engine/ContextHistory.d.mts +2 -0
  507. package/dist/engine/ContextHistory.mjs +1 -0
  508. package/dist/engine/ContextWindow.d.mts +2 -0
  509. package/dist/engine/ContextWindow.mjs +1 -0
  510. package/dist/engine/DurableStep.d.mts +2 -0
  511. package/dist/engine/DurableStep.mjs +3 -0
  512. package/dist/engine/MessagingHost.d.mts +2 -0
  513. package/dist/engine/MessagingHost.mjs +1 -0
  514. package/dist/engine/Output.d.mts +3 -0
  515. package/dist/engine/Output.mjs +2 -0
  516. package/dist/engine/RunEventSink.d.mts +2 -0
  517. package/dist/engine/RunEventSink.mjs +1 -0
  518. package/dist/engine/RunOptions.d.mts +2 -0
  519. package/dist/engine/RunOptions.mjs +1 -0
  520. package/dist/engine/SubagentHost.d.mts +2 -0
  521. package/dist/engine/SubagentHost.mjs +1 -0
  522. package/dist/engine/ThreadHistory.d.mts +2 -0
  523. package/dist/engine/ThreadHistory.mjs +1 -0
  524. package/dist/engine/ToolBroker.d.mts +2 -0
  525. package/dist/engine/ToolBroker.mjs +1 -0
  526. package/dist/index.d.mts +90 -0
  527. package/dist/index.mjs +101 -0
  528. package/dist/output-contract-CYA4oBhe.mjs +128 -0
  529. package/dist/output-contract-CYA4oBhe.mjs.map +1 -0
  530. package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
  531. package/dist/run-context-reader-CHox63hg.d.mts +17 -0
  532. package/dist/sandbox/CodeExecutor.d.mts +2 -0
  533. package/dist/sandbox/CodeExecutor.mjs +1 -0
  534. package/dist/sandbox/InteractiveBrowser.d.mts +2 -0
  535. package/dist/sandbox/InteractiveBrowser.mjs +1 -0
  536. package/dist/sandbox/PageCapture.d.mts +2 -0
  537. package/dist/sandbox/PageCapture.mjs +1 -0
  538. package/dist/sandbox/PageScreenshot.d.mts +2 -0
  539. package/dist/sandbox/PageScreenshot.mjs +1 -0
  540. package/dist/sandbox/Sandbox.d.mts +2 -0
  541. package/dist/sandbox/Sandbox.mjs +1 -0
  542. package/dist/subagent-policy-xRJhrc0a.mjs +133 -0
  543. package/dist/subagent-policy-xRJhrc0a.mjs.map +1 -0
  544. package/dist/tool-execution-Cl7v8fXU.mjs +16 -0
  545. package/dist/tool-execution-Cl7v8fXU.mjs.map +1 -0
  546. package/dist/tool-operations-CauPonM8.mjs +84 -0
  547. package/dist/tool-operations-CauPonM8.mjs.map +1 -0
  548. package/dist/utf8-Bl0ZhhGe.mjs +27 -0
  549. package/dist/utf8-Bl0ZhhGe.mjs.map +1 -0
  550. package/package.json +491 -3
  551. package/src/InMemory.ts +79 -0
  552. package/src/ToolExposure.ts +2 -0
  553. package/src/capabilities/BrowserUse.ts +212 -0
  554. package/src/capabilities/Budget.ts +544 -0
  555. package/src/capabilities/CodeMode.ts +1129 -0
  556. package/src/capabilities/ContextTools.ts +131 -0
  557. package/src/capabilities/MemoryNotes.ts +177 -0
  558. package/src/capabilities/Messaging.ts +260 -0
  559. package/src/capabilities/Redaction.ts +163 -0
  560. package/src/capabilities/RunHooks.ts +116 -0
  561. package/src/capabilities/SemanticMemory.ts +402 -0
  562. package/src/capabilities/Subagent.ts +2343 -0
  563. package/src/capabilities/SubagentReservations.ts +807 -0
  564. package/src/capabilities/ToolDiscovery.ts +291 -0
  565. package/src/capabilities/ToolResults.ts +50 -0
  566. package/src/capabilities/WebCapture.ts +64 -0
  567. package/src/capabilities/WebSearch.ts +45 -0
  568. package/src/capabilities/internal/subagent-background.ts +1137 -0
  569. package/src/capabilities/internal/subagent-contract.ts +92 -0
  570. package/src/capabilities/internal/subagent-policy.ts +205 -0
  571. package/src/capabilities/internal/subagent-reporting.ts +152 -0
  572. package/src/core/Agent.ts +528 -0
  573. package/src/core/AgentError.ts +189 -0
  574. package/src/core/AgentPolicy.ts +194 -0
  575. package/src/core/AgentUpdates.ts +104 -0
  576. package/src/core/FailureDiagnostic.ts +392 -0
  577. package/src/core/IdGenerator.ts +42 -0
  578. package/src/core/Identifiers.ts +64 -0
  579. package/src/core/Memory.ts +283 -0
  580. package/src/core/MemoryNamespace.ts +202 -0
  581. package/src/core/MemoryReference.ts +120 -0
  582. package/src/core/MemoryRevalidation.ts +151 -0
  583. package/src/core/MemoryStore.ts +371 -0
  584. package/src/core/Messaging.ts +72 -0
  585. package/src/core/ProvisionalText.ts +53 -0
  586. package/src/core/Receipt.ts +42 -0
  587. package/src/core/RememberingStore.ts +22 -0
  588. package/src/core/RunEvent.ts +345 -0
  589. package/src/core/RunPolicyUsage.ts +19 -0
  590. package/src/core/SemanticMemoryIndex.ts +259 -0
  591. package/src/core/SemanticMemoryRevalidation.ts +220 -0
  592. package/src/core/SubagentContract.ts +263 -0
  593. package/src/core/Thread.ts +447 -0
  594. package/src/core/ToolExposure.ts +75 -0
  595. package/src/core/ToolResult.ts +204 -0
  596. package/src/core/ToolResultStorage.ts +56 -0
  597. package/src/core/Usage.ts +562 -0
  598. package/src/core/Worker.ts +236 -0
  599. package/src/core/internal/agent-updates.ts +42 -0
  600. package/src/core/internal/completion.ts +33 -0
  601. package/src/core/internal/json.ts +17 -0
  602. package/src/core/internal/memory-document.ts +39 -0
  603. package/src/core/internal/message-status.ts +60 -0
  604. package/src/core/internal/strict-schema.ts +14 -0
  605. package/src/core/internal/tool-execution.ts +33 -0
  606. package/src/core/internal/utf8.ts +32 -0
  607. package/src/durable/ActivityStore.ts +131 -0
  608. package/src/durable/Admin.ts +504 -0
  609. package/src/durable/AgentRegistration.ts +16 -0
  610. package/src/durable/CommittedActivity.ts +262 -0
  611. package/src/durable/Digest.ts +57 -0
  612. package/src/durable/DurableAgentRuntime.ts +12758 -0
  613. package/src/durable/DurableFailpoint.ts +108 -0
  614. package/src/durable/DurableFailpointTestControl.ts +39 -0
  615. package/src/durable/EventSource.ts +179 -0
  616. package/src/durable/LifecyclePublication.ts +343 -0
  617. package/src/durable/MessageDelivery.ts +949 -0
  618. package/src/durable/MessageDeliveryStoreConformance.ts +407 -0
  619. package/src/durable/OperationAuthorizer.ts +89 -0
  620. package/src/durable/PersistentHistory.ts +322 -0
  621. package/src/durable/PreparedInputAdmission.ts +128 -0
  622. package/src/durable/RecordFormat.ts +113 -0
  623. package/src/durable/Records.ts +1396 -0
  624. package/src/durable/Recovery.ts +1022 -0
  625. package/src/durable/RunContinuation.ts +1946 -0
  626. package/src/durable/RunJournal.ts +1926 -0
  627. package/src/durable/RunStorage.ts +533 -0
  628. package/src/durable/Schedule.ts +445 -0
  629. package/src/durable/ScheduleStoreConformance.ts +642 -0
  630. package/src/durable/ScheduleTransition.ts +267 -0
  631. package/src/durable/Scheduling.ts +1031 -0
  632. package/src/durable/SettlementPublisher.ts +172 -0
  633. package/src/durable/SqlMemoryStore.ts +1042 -0
  634. package/src/durable/SqlStorageOwner.ts +25 -0
  635. package/src/durable/SubmissionLedger.ts +1247 -0
  636. package/src/durable/SubmissionLedgerConformance.ts +4695 -0
  637. package/src/durable/SubmissionStatus.ts +14 -0
  638. package/src/durable/Subscription.ts +527 -0
  639. package/src/durable/SubscriptionInput.ts +145 -0
  640. package/src/durable/SubscriptionStoreConformance.ts +1275 -0
  641. package/src/durable/SubscriptionTransition.ts +330 -0
  642. package/src/durable/Subscriptions.ts +1245 -0
  643. package/src/durable/ThreadArchiveRange.ts +91 -0
  644. package/src/durable/ThreadContextHistory.ts +338 -0
  645. package/src/durable/ThreadContextHistoryProjection.ts +219 -0
  646. package/src/durable/ThreadImport.ts +1199 -0
  647. package/src/durable/ThreadInvariants.ts +312 -0
  648. package/src/durable/ThreadProjectionMaintenance.ts +72 -0
  649. package/src/durable/ThreadReader.ts +21 -0
  650. package/src/durable/ThreadStore.ts +1258 -0
  651. package/src/durable/ThreadStoreConformance.ts +877 -0
  652. package/src/durable/ThreadTransfer.ts +263 -0
  653. package/src/durable/ThreadWork.ts +713 -0
  654. package/src/durable/ToolReconciler.ts +112 -0
  655. package/src/durable/WakeScheduler.ts +125 -0
  656. package/src/durable/WorkerAdmission.ts +98 -0
  657. package/src/durable/WorkerHost.ts +204 -0
  658. package/src/durable/internal/StorageOwner.ts +181 -0
  659. package/src/durable/internal/agent-registration.ts +713 -0
  660. package/src/durable/internal/agent-updates.ts +338 -0
  661. package/src/durable/internal/canonical-json.ts +110 -0
  662. package/src/durable/internal/evidence.ts +29 -0
  663. package/src/durable/internal/foreign-diagnostic.ts +48 -0
  664. package/src/durable/internal/history-prompt.ts +87 -0
  665. package/src/durable/internal/initial-context.ts +215 -0
  666. package/src/durable/internal/journal-metadata.ts +188 -0
  667. package/src/durable/internal/message-status.ts +18 -0
  668. package/src/durable/internal/messaging-host.ts +615 -0
  669. package/src/durable/internal/prompt-footprint.ts +47 -0
  670. package/src/durable/internal/prompt-history-cache.ts +604 -0
  671. package/src/durable/internal/record-encoding.ts +258 -0
  672. package/src/durable/internal/record-ownership.ts +68 -0
  673. package/src/durable/internal/run-context-reader.ts +51 -0
  674. package/src/durable/internal/run-context.ts +211 -0
  675. package/src/durable/internal/schedule-time.ts +304 -0
  676. package/src/durable/internal/thread-import-reader.ts +85 -0
  677. package/src/durable/internal/thread-initialization.ts +181 -0
  678. package/src/durable/internal/thread-transfer-source.ts +7 -0
  679. package/src/durable/internal/tool-operations.ts +138 -0
  680. package/src/durable/internal/transfer-dependencies.ts +40 -0
  681. package/src/durable/internal/usage-totals.ts +36 -0
  682. package/src/durable/internal/worker-host.ts +4041 -0
  683. package/src/durable/internal/worker-runtime.ts +10 -0
  684. package/src/engine/AgentRuntime.ts +100 -0
  685. package/src/engine/Compaction.ts +11 -0
  686. package/src/engine/ContextCompactor.ts +302 -0
  687. package/src/engine/ContextHistory.ts +75 -0
  688. package/src/engine/ContextWindow.ts +81 -0
  689. package/src/engine/DurableStep.ts +115 -0
  690. package/src/engine/MessagingHost.ts +118 -0
  691. package/src/engine/Output.ts +2 -0
  692. package/src/engine/RunEventSink.ts +124 -0
  693. package/src/engine/RunOptions.ts +664 -0
  694. package/src/engine/SubagentHost.ts +231 -0
  695. package/src/engine/ThreadHistory.ts +125 -0
  696. package/src/engine/ToolBroker.ts +159 -0
  697. package/src/engine/ToolExposure.ts +49 -0
  698. package/src/engine/internal/agent-runtime.ts +11137 -0
  699. package/src/engine/internal/bounded-value.ts +312 -0
  700. package/src/engine/internal/compaction.ts +673 -0
  701. package/src/engine/internal/error-diagnostic.ts +39 -0
  702. package/src/engine/internal/image-tokens.ts +61 -0
  703. package/src/engine/internal/interpreter-options.ts +569 -0
  704. package/src/engine/internal/output-contract.ts +226 -0
  705. package/src/engine/internal/primitive-delta.ts +103 -0
  706. package/src/engine/internal/provider-result-staging.ts +211 -0
  707. package/src/engine/internal/provisional-text.ts +107 -0
  708. package/src/engine/internal/tool-derivative.ts +47 -0
  709. package/src/engine/internal/tool-exposure.ts +228 -0
  710. package/src/engine/internal/tool-telemetry.ts +488 -0
  711. package/src/index.ts +100 -0
  712. package/src/sandbox/CodeExecutor.ts +352 -0
  713. package/src/sandbox/InteractiveBrowser.ts +343 -0
  714. package/src/sandbox/PageCapture.ts +391 -0
  715. package/src/sandbox/PageScreenshot.ts +83 -0
  716. package/src/sandbox/Sandbox.ts +29 -0
  717. package/README.md +0 -3
@@ -0,0 +1,1315 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
2
+ import * as Tool from "effect/ai/Tool";
3
+ import * as Toolkit from "effect/ai/Toolkit";
4
+ import * as Cause from "effect/Cause";
5
+ import * as Clock from "effect/Clock";
6
+ import * as DateTime from "effect/DateTime";
7
+ import * as Duration from "effect/Duration";
8
+ import * as Effect from "effect/Effect";
9
+ import * as Exit from "effect/Exit";
10
+ import * as Layer from "effect/Layer";
11
+ import * as Option from "effect/Option";
12
+ import * as Ref from "effect/Ref";
13
+ import * as Schema from "effect/Schema";
14
+ import * as Scope from "effect/Scope";
15
+ import { u as AgentPolicyError } from "./AgentError-yFdnS9bl.mjs";
16
+ import { c as SettlementId, d as ToolCallId, r as DelegationId, s as RunId, u as ThreadId } from "./Identifiers-LWd4837I.mjs";
17
+ import { t as IdGenerator } from "./IdGenerator-BCzwV0ZI.mjs";
18
+ import { n as utf8ByteLength, r as utf8Bytes } from "./utf8-Bl0ZhhGe.mjs";
19
+ import { c as SubagentExecutionFailureClassification, d as SubagentPolicy, f as SubagentReservationAmounts, i as SubagentBudgetReservation, l as SubagentGrant, m as WorkerOperationTool, r as DelegationTool, s as SubagentExecutionFailure, t as BackgroundSpawnTool, v as narrowSubagentGrant } from "./SubagentContract-C-7AxTm_.mjs";
20
+ import { _ as unknownRunTotals, c as RunUsageReport } from "./Usage-B0xgME5f.mjs";
21
+ import { d as SubagentDurability, f as SubagentDurabilityError, p as ToolCallWaiting, u as AgentSpawner } from "./AgentRuntime-CzP4I4RB.mjs";
22
+ import { t as RunEventSink } from "./RunEventSink-B8uM8bw2.mjs";
23
+ import { a as delegationAllocationFromPolicy, i as SubagentProjectionFailure, n as resolveSubagentPolicy, o as delegationCapsFromPolicy, r as SubagentPrestartDenied, t as residualSubagentCaps } from "./subagent-policy-xRJhrc0a.mjs";
24
+ import { a as SubagentObservedUsage, d as SubagentReservationRequest, h as SubagentReservations, i as SubagentBudgetExhausted, v as makeBudgetReservationId } from "./SubagentReservations-BYNAHPpm.mjs";
25
+ import { C as MessageStatus, S as MessageRef, _ as WorkerStop, c as WorkerError, d as WorkerPage, f as WorkerRef, g as WorkerStarted, o as WorkerCompletion, p as WorkerReport, s as WorkerContext, v as WorkerStopped, y as WorkerSummary } from "./Worker-CQu8Qp1j.mjs";
26
+ import { a as Receipt, n as JoinedToHost, t as IdempotencyKey } from "./Receipt-B-FlCaNH.mjs";
27
+ import { r as WorkerReportPreparationFailure, t as SubagentHost } from "./SubagentHost-BEnICu7g.mjs";
28
+ import * as CryptoDigest from "effect/crypto/Digest";
29
+ import * as Hex from "effect/encoding/Hex";
30
+ import * as Stream from "effect/Stream";
31
+ import { i as Failure } from "./FailureDiagnostic-DdHV2eFs.mjs";
32
+ // src/capabilities/internal/subagent-background.ts
33
+ /** Portable identity checked against this declaration; possession grants no authority. */
34
+ const Worker = (declaration) => WorkerRef.pipe(Schema.refine((worker) => worker.delegationId === declaration.delegationId && worker.targetAgentId === declaration.target.id));
35
+ /** Model-facing projection deliberately excludes operator-private diagnostics. */
36
+ const toolObservation = (success) => Schema.Union([
37
+ Schema.TaggedStruct("Pending", { receipt: Receipt }),
38
+ Schema.TaggedStruct("Settled", {
39
+ receipt: Receipt,
40
+ runId: RunId,
41
+ settlementId: SettlementId,
42
+ outcome: Schema.Literal("completed"),
43
+ result: success
44
+ }),
45
+ Schema.TaggedStruct("Settled", {
46
+ receipt: Receipt,
47
+ runId: Schema.optionalKey(RunId),
48
+ settlementId: SettlementId,
49
+ outcome: Schema.Literals(["failed", "aborted"]),
50
+ failure: SubagentExecutionFailure
51
+ })
52
+ ]);
53
+ /** One exact Receipt, including private canonical failure evidence for programmatic callers. */
54
+ const WorkerObservation = (success) => {
55
+ const projected = toolObservation(success);
56
+ return Schema.Union([
57
+ projected.members[0],
58
+ projected.members[1],
59
+ Schema.Struct({
60
+ ...projected.members[2].fields,
61
+ diagnostic: Schema.optionalKey(Failure)
62
+ })
63
+ ]);
64
+ };
65
+ const host = Effect.serviceOption(SubagentHost).pipe(Effect.flatMap((service) => Option.match(service, {
66
+ onNone: () => WorkerError.make({
67
+ operation: "context",
68
+ reason: "unavailable"
69
+ }),
70
+ onSome: Effect.succeed
71
+ })));
72
+ const receiptEqual = (left, right) => left.threadId === right.threadId && left.submissionId === right.submissionId && left.receiptId === right.receiptId && left.queueSequence === right.queueSequence;
73
+ const operations = (declaration) => {
74
+ const workerSchema = Worker(declaration);
75
+ const projectionFailure = (stage, cause) => SubagentProjectionFailure.make({
76
+ delegationId: declaration.delegationId,
77
+ stage,
78
+ ...cause === void 0 ? {} : { cause },
79
+ message: stage === "input" ? "Worker input did not satisfy the declaration Schema" : "Worker result did not satisfy the declaration Schema"
80
+ });
81
+ const validateWorker = (worker, operation) => Schema.decodeUnknownEffect(workerSchema)(worker).pipe(Effect.mapError((cause) => WorkerError.make({
82
+ operation,
83
+ reason: "worker-mismatch",
84
+ cause
85
+ })));
86
+ const validateReceipt = (worker, receipt, operation) => Schema.decodeEffect(Receipt.check(Schema.makeFilter((value) => value.threadId === worker.threadId)))(receipt).pipe(Effect.mapError((cause) => WorkerError.make({
87
+ operation,
88
+ reason: "receipt-mismatch",
89
+ cause
90
+ })));
91
+ const validateDelivery = Effect.fnUntraced(function* (worker, delivery, operation) {
92
+ const validated = yield* Schema.decodeEffect(MessageStatus)(delivery).pipe(Effect.mapError((cause) => WorkerError.make({
93
+ operation,
94
+ reason: "corrupt",
95
+ cause
96
+ })));
97
+ if (validated.receipt !== null) yield* validateReceipt(worker, validated.receipt, operation);
98
+ return validated;
99
+ });
100
+ const context = host.pipe(Effect.flatMap((service) => service.context), Effect.flatMap(Schema.decodeUnknownEffect(Schema.toType(WorkerContext))), Effect.mapError((error) => Schema.is(WorkerError)(error) ? error : WorkerError.make({
101
+ operation: "context",
102
+ reason: "corrupt",
103
+ cause: error
104
+ })));
105
+ const prepare = Effect.fnUntraced(function* (parameters, caller) {
106
+ const source = caller.source;
107
+ const preparation = source._tag === "tool" ? {
108
+ source: "tool",
109
+ delegationId: declaration.delegationId,
110
+ toolCallId: source.toolCallId,
111
+ parent: {
112
+ agentId: source.agentId,
113
+ threadId: source.threadId,
114
+ runId: source.runId
115
+ }
116
+ } : {
117
+ source: "programmatic",
118
+ delegationId: declaration.delegationId,
119
+ parent: {
120
+ agentId: source.agentId,
121
+ threadId: source.threadId
122
+ }
123
+ };
124
+ const input = yield* declaration.prepareInput(parameters, preparation);
125
+ return yield* Schema.encodeEffect(declaration.target.input)(input).pipe(Effect.mapError((cause) => projectionFailure("input", cause)));
126
+ });
127
+ const validateKey = (key, operation) => Schema.decodeEffect(IdempotencyKey)(key).pipe(Effect.mapError((cause) => WorkerError.make({
128
+ operation,
129
+ reason: "idempotency-conflict",
130
+ cause
131
+ })));
132
+ return {
133
+ start: Effect.fnUntraced(function* (parameters, options) {
134
+ const service = yield* host;
135
+ const caller = yield* context;
136
+ const key = yield* validateKey(options.idempotencyKey, "start");
137
+ const grant = narrowSubagentGrant(declaration.grant, caller.grant);
138
+ if (caller.depth + 1 > grant.maxDepth) return yield* SubagentPrestartDenied.make({
139
+ delegationId: declaration.delegationId,
140
+ targetAgentId: declaration.target.id,
141
+ reason: "nested-delegation",
142
+ message: "Worker start exceeds the inherited depth ceiling"
143
+ });
144
+ if (!(caller.grant?.childLifetimes ?? ["attached", "background"]).includes("background")) return yield* SubagentPrestartDenied.make({
145
+ delegationId: declaration.delegationId,
146
+ targetAgentId: declaration.target.id,
147
+ reason: "grant-violation",
148
+ message: "The inherited grant does not permit background children"
149
+ });
150
+ const encodedParameters = yield* Schema.encodeEffect(declaration.parameters)(parameters).pipe(Effect.mapError((cause) => projectionFailure("input", cause)));
151
+ const encodedGrant = yield* Schema.encodeEffect(SubagentGrant)(grant).pipe(Effect.mapError((cause) => projectionFailure("input", cause)));
152
+ const started = yield* service.start({
153
+ delegationId: declaration.delegationId,
154
+ target: declaration.target,
155
+ idempotencyKey: key,
156
+ encodedParameters,
157
+ encodedGrant,
158
+ ...options.continuationOf === void 0 ? {} : { continuationOf: options.continuationOf },
159
+ ...options.budgetScope === void 0 ? {} : { budgetScope: options.budgetScope },
160
+ ...declaration.policy === void 0 ? {} : { declarationPolicy: declaration.policy },
161
+ prepare: Effect.map(prepare(parameters, caller), (encodedInput) => ({ encodedInput }))
162
+ });
163
+ const validated = yield* Schema.decodeEffect(WorkerStarted)(started).pipe(Effect.mapError((cause) => WorkerError.make({
164
+ operation: "start",
165
+ reason: "corrupt",
166
+ cause
167
+ })));
168
+ if (validated.delivery.message.ownerThreadId !== caller.source.threadId) return yield* WorkerError.make({
169
+ operation: "start",
170
+ reason: "message-mismatch"
171
+ });
172
+ return {
173
+ worker: yield* validateWorker(validated.worker, "start"),
174
+ delivery: validated.delivery
175
+ };
176
+ }),
177
+ followUp: Effect.fnUntraced(function* (worker, parameters, options) {
178
+ const service = yield* host;
179
+ const validated = yield* validateWorker(worker, "followUp");
180
+ const caller = yield* context;
181
+ const key = yield* validateKey(options.idempotencyKey, "followUp");
182
+ const encodedParameters = yield* Schema.encodeEffect(declaration.parameters)(parameters).pipe(Effect.mapError((cause) => projectionFailure("input", cause)));
183
+ const delivery = yield* validateDelivery(validated, yield* service.followUp({
184
+ encodedParameters,
185
+ prepare: prepare(parameters, caller).pipe(Effect.map((encodedInput) => ({ encodedInput }))),
186
+ worker: validated,
187
+ target: declaration.target,
188
+ idempotencyKey: key
189
+ }), "followUp");
190
+ if (delivery.message.ownerThreadId !== caller.source.threadId) return yield* WorkerError.make({
191
+ operation: "followUp",
192
+ reason: "message-mismatch"
193
+ });
194
+ return delivery;
195
+ }),
196
+ inspectMessage: Effect.fnUntraced(function* (worker, message) {
197
+ const service = yield* host;
198
+ const validated = yield* validateWorker(worker, "inspect");
199
+ const requested = yield* Schema.decodeEffect(MessageRef)(message).pipe(Effect.mapError((cause) => WorkerError.make({
200
+ operation: "inspect",
201
+ reason: "message-mismatch",
202
+ cause
203
+ })));
204
+ const observed = yield* service.inspect({
205
+ worker: validated,
206
+ target: declaration.target,
207
+ message: requested
208
+ });
209
+ if (!("message" in observed)) return yield* WorkerError.make({
210
+ operation: "inspect",
211
+ reason: "corrupt"
212
+ });
213
+ const delivery = yield* validateDelivery(validated, observed, "inspect");
214
+ if (!Schema.toEquivalence(MessageRef)(delivery.message, requested)) return yield* WorkerError.make({
215
+ operation: "inspect",
216
+ reason: "message-mismatch"
217
+ });
218
+ return delivery;
219
+ }),
220
+ observe: Effect.fnUntraced(function* (operation, worker, receipt) {
221
+ const service = yield* host;
222
+ const validated = yield* validateWorker(worker, operation);
223
+ const requested = yield* validateReceipt(validated, receipt, operation);
224
+ const observed = yield* service[operation]({
225
+ worker: validated,
226
+ target: declaration.target,
227
+ receipt: requested
228
+ });
229
+ if (!("_tag" in observed)) return yield* WorkerError.make({
230
+ operation,
231
+ reason: "corrupt"
232
+ });
233
+ const returned = yield* validateReceipt(validated, observed.receipt, operation);
234
+ if (!receiptEqual(returned, requested)) return yield* WorkerError.make({
235
+ operation,
236
+ reason: "receipt-mismatch"
237
+ });
238
+ if (observed._tag === "Pending") {
239
+ if (operation === "await") return yield* WorkerError.make({
240
+ operation,
241
+ reason: "corrupt"
242
+ });
243
+ return {
244
+ _tag: "Pending",
245
+ receipt: returned
246
+ };
247
+ }
248
+ const base = {
249
+ _tag: "Settled",
250
+ receipt: returned,
251
+ ...observed.runId === void 0 ? {} : { runId: yield* Schema.decodeEffect(RunId)(observed.runId).pipe(Effect.mapError((cause) => WorkerError.make({
252
+ operation,
253
+ reason: "corrupt",
254
+ cause
255
+ }))) },
256
+ settlementId: yield* Schema.decodeEffect(SettlementId)(observed.settlementId).pipe(Effect.mapError((cause) => WorkerError.make({
257
+ operation,
258
+ reason: "corrupt",
259
+ cause
260
+ })))
261
+ };
262
+ if (observed.outcome === "failed" || observed.outcome === "aborted") return {
263
+ ...base,
264
+ outcome: observed.outcome,
265
+ ...observed.diagnostic === void 0 ? {} : { diagnostic: yield* Schema.decodeEffect(Failure)(observed.diagnostic).pipe(Effect.mapError((cause) => WorkerError.make({
266
+ operation,
267
+ reason: "corrupt",
268
+ cause
269
+ }))) },
270
+ failure: SubagentExecutionFailure.make({
271
+ delegationId: declaration.delegationId,
272
+ targetAgentId: declaration.target.id,
273
+ classification: observed.outcome === "failed" ? "child-failed" : "child-aborted",
274
+ childThreadId: worker.threadId,
275
+ childSubmissionId: returned.submissionId,
276
+ ...base.runId === void 0 ? {} : { childRunId: base.runId },
277
+ errorTag: observed.outcome === "failed" ? "WorkerFailed" : "WorkerAborted",
278
+ message: observed.outcome === "failed" ? "Worker input failed" : "Worker input was aborted"
279
+ })
280
+ };
281
+ if (observed.outcome !== "completed" || base.runId === void 0 || typeof observed.budgetExhausted !== "boolean") return yield* WorkerError.make({
282
+ operation,
283
+ reason: "corrupt"
284
+ });
285
+ const parameters = yield* Schema.decodeUnknownEffect(declaration.parameters)(observed.encodedParameters).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
286
+ const output = yield* Schema.decodeUnknownEffect(declaration.target.output)(observed.encodedResult).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
287
+ const result = yield* declaration.projectResult(output, { budgetExhausted: observed.budgetExhausted }, parameters);
288
+ const encoded = yield* Schema.encodeEffect(declaration.success)(result).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
289
+ const json = yield* Schema.decodeUnknownEffect(Schema.Json)(encoded).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
290
+ const caller = yield* context;
291
+ if (utf8ByteLength(JSON.stringify(json)) > (declaration.policy?.maxResultBytes ?? caller.policy.toolResultBounds.maxBytes)) return yield* projectionFailure("result");
292
+ return yield* Schema.decodeUnknownEffect(Schema.toType(WorkerObservation(declaration.success)))({
293
+ ...base,
294
+ outcome: "completed",
295
+ result
296
+ }).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
297
+ }),
298
+ list: Effect.fnUntraced(function* (options = {}) {
299
+ const service = yield* host;
300
+ const limit = yield* Schema.decodeEffect(Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(100)))(options.limit ?? 20).pipe(Effect.mapError(() => WorkerError.make({
301
+ operation: "list",
302
+ reason: "capacity"
303
+ })));
304
+ const page = yield* service.list({
305
+ delegationId: declaration.delegationId,
306
+ target: declaration.target,
307
+ limit,
308
+ ...options.after === void 0 ? {} : { after: options.after }
309
+ });
310
+ const validated = yield* Schema.decodeEffect(WorkerPage)(page).pipe(Effect.mapError(() => WorkerError.make({
311
+ operation: "list",
312
+ reason: "corrupt"
313
+ })));
314
+ if (validated.items.length > limit) return yield* WorkerError.make({
315
+ operation: "list",
316
+ reason: "corrupt"
317
+ });
318
+ const items = [];
319
+ for (const item of validated.items) {
320
+ const worker = yield* validateWorker(item.worker, "list");
321
+ const latestReceipt = item.latestReceipt === null ? null : yield* validateReceipt(worker, item.latestReceipt, "list");
322
+ items.push({
323
+ ...item,
324
+ worker,
325
+ latestReceipt
326
+ });
327
+ }
328
+ return {
329
+ items,
330
+ next: validated.next
331
+ };
332
+ }),
333
+ cancel: Effect.fnUntraced(function* (worker, receipt) {
334
+ const service = yield* host;
335
+ const validated = yield* validateWorker(worker, "cancel");
336
+ const requested = yield* validateReceipt(validated, receipt, "cancel");
337
+ yield* service.cancel({
338
+ worker: validated,
339
+ target: declaration.target,
340
+ receipt: requested
341
+ });
342
+ })
343
+ };
344
+ };
345
+ /** Retain a first worker input. The same explicit key reuses its durable delivery identity. */
346
+ const start = (declaration, parameters, options) => operations(declaration).start(parameters, options);
347
+ /** Retain typed follow-up parameters for the same worker Thread; inspect its MessageRef for delivery. */
348
+ const followUp = (declaration, worker, parameters, options) => operations(declaration).followUp(worker, parameters, options);
349
+ /** Inspect a continuing worker with the same summary contract returned by list. */
350
+ const summary = Effect.fnUntraced(function* (declaration, worker) {
351
+ const service = yield* host;
352
+ const validated = yield* Schema.decodeEffect(Worker(declaration))(worker).pipe(Effect.mapError(() => WorkerError.make({
353
+ operation: "inspect",
354
+ reason: "worker-mismatch"
355
+ })));
356
+ const result = yield* service.summary({
357
+ worker: validated,
358
+ target: declaration.target
359
+ });
360
+ const value = yield* Schema.decodeEffect(WorkerSummary)(result).pipe(Effect.mapError(() => WorkerError.make({
361
+ operation: "inspect",
362
+ reason: "corrupt"
363
+ })));
364
+ if (value.worker.threadId !== validated.threadId || value.worker.delegationId !== validated.delegationId || value.worker.targetAgentId !== validated.targetAgentId || value.latestReceipt !== null && value.latestReceipt.threadId !== validated.threadId) return yield* WorkerError.make({
365
+ operation: "inspect",
366
+ reason: "worker-mismatch"
367
+ });
368
+ return {
369
+ ...value,
370
+ worker: validated
371
+ };
372
+ });
373
+ function inspect(declaration, worker, reference) {
374
+ return reference === void 0 ? summary(declaration, worker) : "messageId" in reference ? operations(declaration).inspectMessage(worker, reference) : operations(declaration).observe("inspect", worker, reference);
375
+ }
376
+ /** Read an authorized finite history snapshot; pass the last emitted sequence to resume. */
377
+ const observe = (declaration, worker, options = {}) => Stream.unwrap(Effect.gen(function* () {
378
+ const service = yield* host;
379
+ const validated = yield* Schema.decodeEffect(Worker(declaration))(worker).pipe(Effect.mapError(() => WorkerError.make({
380
+ operation: "observe",
381
+ reason: "worker-mismatch"
382
+ })));
383
+ const after = options.after === void 0 ? void 0 : yield* Schema.decodeEffect(Schema.Natural)(options.after).pipe(Effect.mapError(() => WorkerError.make({
384
+ operation: "observe",
385
+ reason: "corrupt"
386
+ })));
387
+ return service.observe({
388
+ worker: validated,
389
+ target: declaration.target,
390
+ ...after === void 0 ? {} : { after }
391
+ });
392
+ }));
393
+ /** Seal a continuing worker, retaining a stable command identity across retries and Runs. */
394
+ const stop = Effect.fnUntraced(function* (declaration, worker, options) {
395
+ const service = yield* host;
396
+ const command = yield* Schema.decodeEffect(WorkerStop)({
397
+ worker,
398
+ ...options
399
+ }).pipe(Effect.mapError((cause) => WorkerError.make({
400
+ operation: "stop",
401
+ reason: "corrupt",
402
+ cause
403
+ })));
404
+ if (worker.delegationId !== declaration.delegationId || worker.targetAgentId !== declaration.target.id) return yield* WorkerError.make({
405
+ operation: "stop",
406
+ reason: "worker-mismatch"
407
+ });
408
+ return yield* service.stop({
409
+ ...command,
410
+ target: declaration.target
411
+ }).pipe(Effect.flatMap(Schema.decodeEffect(WorkerStopped)), Effect.mapError((cause) => Schema.is(WorkerError)(cause) ? cause : WorkerError.make({
412
+ operation: "stop",
413
+ reason: "corrupt",
414
+ cause
415
+ })));
416
+ });
417
+ /** Wait for the exact Receipt. Interrupting this Effect never cancels accepted work. */
418
+ const awaitWorker = (declaration, worker, receipt) => operations(declaration).observe("await", worker, receipt);
419
+ /** List only workers visible through the caller-bound host facet. */
420
+ const list = (declaration, options = {}) => operations(declaration).list(options);
421
+ /** Request cancellation of exactly one Receipt; JoinedToHost remains a typed conflict. */
422
+ const cancel = (declaration, worker, receipt) => operations(declaration).cancel(worker, receipt);
423
+ const ReceiptParameters = (declaration) => Schema.Struct({
424
+ worker: Worker(declaration),
425
+ receipt: Receipt
426
+ });
427
+ const InspectParameters = (declaration) => Schema.Struct({
428
+ worker: Worker(declaration),
429
+ message: Schema.optionalKey(MessageRef),
430
+ receipt: Schema.optionalKey(Receipt)
431
+ }).check(Schema.makeFilter(({ message, receipt }) => message === void 0 !== (receipt === void 0), { message: "Provide exactly one retained message reference or accepted receipt" }));
432
+ const Inspection = (success) => Schema.Union([MessageStatus, toolObservation(success)]);
433
+ const WorkerParameters = (declaration) => Schema.Struct({ worker: Worker(declaration) });
434
+ const Summary = (declaration) => Schema.Struct({
435
+ ...WorkerSummary.fields,
436
+ worker: Worker(declaration)
437
+ });
438
+ const FollowUpParameters = (declaration, parameters) => Schema.Struct({
439
+ worker: Worker(declaration),
440
+ parameters: Schema.Union([parameters])
441
+ });
442
+ const ListParameters = Schema.Struct({
443
+ limit: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(100))),
444
+ after: Schema.optionalKey(ThreadId)
445
+ });
446
+ const Started = (declaration) => Schema.Struct({
447
+ worker: Worker(declaration),
448
+ delivery: MessageStatus
449
+ }).check(Schema.makeFilter(({ worker, delivery }) => delivery.receipt === null || worker.threadId === delivery.receipt.threadId));
450
+ const Page = (declaration) => Schema.Struct({
451
+ items: Schema.Array(Summary(declaration)).check(Schema.isMaxLength(100)),
452
+ next: Schema.NullOr(ThreadId)
453
+ });
454
+ const preparationFailure = (failure) => Schema.Union([
455
+ failure,
456
+ SubagentProjectionFailure,
457
+ WorkerError
458
+ ]);
459
+ const startFailure = (failure) => Schema.Union([
460
+ failure,
461
+ SubagentProjectionFailure,
462
+ SubagentPrestartDenied,
463
+ WorkerError
464
+ ]);
465
+ const cancelFailure = Schema.Union([WorkerError, JoinedToHost]);
466
+ const modelKey = Effect.fnUntraced(function* (operation) {
467
+ const caller = yield* (yield* host).context;
468
+ if (caller.source._tag !== "tool") return yield* WorkerError.make({
469
+ operation,
470
+ reason: "denied"
471
+ });
472
+ const source = caller.source;
473
+ const crypto = yield* CryptoDigest.Digest;
474
+ const bytes = utf8Bytes(JSON.stringify([
475
+ "worker-tool-v1",
476
+ operation,
477
+ source.agentId,
478
+ source.threadId,
479
+ source.runId,
480
+ source.toolCallId
481
+ ]));
482
+ const digest = yield* crypto.digest(CryptoDigest.sha256, bytes).pipe(Effect.mapError(() => WorkerError.make({
483
+ operation,
484
+ reason: "unavailable"
485
+ })));
486
+ return yield* Schema.decodeEffect(IdempotencyKey)(`worker:${Hex.encode(digest)}`).pipe(Effect.mapError(() => WorkerError.make({
487
+ operation,
488
+ reason: "unavailable"
489
+ })));
490
+ });
491
+ /** Pair one native Tool with its checked handler, retaining invocation service requirements. */
492
+ const action = (tool, build) => {
493
+ const layer = Toolkit.make(tool).toLayer(Effect.map(build, (handler) => {
494
+ return { [tool.name]: handler };
495
+ }));
496
+ return Object.freeze({
497
+ tool,
498
+ layer
499
+ });
500
+ };
501
+ /** Retain new worker input under the current Tool Call's stable identity. */
502
+ const startTool = (declaration, options = {}) => {
503
+ const tool = Tool.make(`${declaration.name}_start`, {
504
+ description: `Retain input for a background ${declaration.name} worker and return its delivery state. Pending confirms retention only; inspect the same message instead of starting another worker.`,
505
+ parameters: declaration.parameters,
506
+ success: Started(declaration),
507
+ failure: startFailure(declaration.failure)
508
+ }).annotate(WorkerOperationTool, true).annotate(BackgroundSpawnTool, true).addDependency(SubagentHost).addDependency(CryptoDigest.Digest);
509
+ const ops = operations(declaration);
510
+ return action(tool, Effect.map(Effect.context(), (captured) => (parameters) => Effect.gen(function* () {
511
+ const service = yield* host;
512
+ const idempotencyKey = yield* modelKey("start");
513
+ return yield* ops.start(parameters, {
514
+ ...options,
515
+ idempotencyKey
516
+ }).pipe(Effect.provideService(SubagentHost, service), Effect.provide(captured));
517
+ })));
518
+ };
519
+ /** Retain follow-up input for an existing worker under the current Tool Call's identity. */
520
+ const followUpTool = (declaration) => {
521
+ const tool = Tool.make(`${declaration.name}_follow_up`, {
522
+ description: `Retain typed follow-up input for an existing ${declaration.name} worker. Pending is retained, not executed: inspect the same message instead of sending the command again.`,
523
+ parameters: FollowUpParameters(declaration, declaration.parameters),
524
+ success: MessageStatus,
525
+ failure: preparationFailure(declaration.failure)
526
+ }).annotate(WorkerOperationTool, true).addDependency(SubagentHost).addDependency(CryptoDigest.Digest);
527
+ const ops = operations(declaration);
528
+ return action(tool, Effect.map(Effect.context(), (captured) => (parameters) => Effect.gen(function* () {
529
+ const service = yield* host;
530
+ const idempotencyKey = yield* modelKey("followUp");
531
+ return yield* ops.followUp(parameters.worker, parameters.parameters, { idempotencyKey }).pipe(Effect.provideService(SubagentHost, service), Effect.provide(captured));
532
+ })));
533
+ };
534
+ /** Inspect one delivery or accepted Receipt without resending input. */
535
+ const inspectTool = (declaration) => {
536
+ const tool = Tool.make(`${declaration.name}_inspect`, {
537
+ description: `Inspect one ${declaration.name} delivery by message reference, or its execution result by accepted receipt. Provide exactly one reference; inspection never resends input.`,
538
+ parameters: InspectParameters(declaration),
539
+ success: Inspection(declaration.success),
540
+ failure: preparationFailure(declaration.failure)
541
+ }).annotate(WorkerOperationTool, true).addDependency(SubagentHost);
542
+ const ops = operations(declaration);
543
+ return action(tool, Effect.map(Effect.context(), (captured) => (parameters) => Effect.gen(function* () {
544
+ const service = yield* host;
545
+ if (parameters.message !== void 0) return yield* ops.inspectMessage(parameters.worker, parameters.message);
546
+ if (parameters.receipt === void 0) return yield* WorkerError.make({
547
+ operation: "inspect",
548
+ reason: "message-mismatch"
549
+ });
550
+ return yield* ops.observe("inspect", parameters.worker, parameters.receipt).pipe(Effect.map((observed) => {
551
+ if ("diagnostic" in observed) {
552
+ const { diagnostic: _diagnostic, ...projected } = observed;
553
+ return projected;
554
+ }
555
+ return observed;
556
+ }), Effect.provideService(SubagentHost, service), Effect.provide(captured));
557
+ })));
558
+ };
559
+ /** Inspect a continuing worker's state and latest accepted input. */
560
+ const summaryTool = (declaration) => {
561
+ const tool = Tool.make(`${declaration.name}_summary`, {
562
+ description: `Inspect ${declaration.name}'s continuing worker state and latest accepted input.`,
563
+ parameters: WorkerParameters(declaration),
564
+ success: Summary(declaration),
565
+ failure: WorkerError
566
+ }).annotate(WorkerOperationTool, true).addDependency(SubagentHost);
567
+ return action(tool, Effect.succeed((parameters) => summary(declaration, parameters.worker)));
568
+ };
569
+ /** List workers visible through the current caller's host facet. */
570
+ const listTool = (declaration) => {
571
+ const tool = Tool.make(`${declaration.name}_list`, {
572
+ description: `List visible ${declaration.name} workers.`,
573
+ parameters: ListParameters,
574
+ success: Page(declaration),
575
+ failure: WorkerError
576
+ }).annotate(WorkerOperationTool, true).addDependency(SubagentHost);
577
+ const ops = operations(declaration);
578
+ return action(tool, Effect.succeed((parameters) => ops.list(parameters)));
579
+ };
580
+ /** Request cancellation of one exact worker Receipt. */
581
+ const cancelTool = (declaration) => {
582
+ const tool = Tool.make(`${declaration.name}_cancel`, {
583
+ description: `Request cancellation of one exact ${declaration.name} Receipt.`,
584
+ parameters: ReceiptParameters(declaration),
585
+ success: Schema.Void,
586
+ failure: cancelFailure
587
+ }).annotate(WorkerOperationTool, true).addDependency(SubagentHost);
588
+ const ops = operations(declaration);
589
+ return action(tool, Effect.succeed((parameters) => ops.cancel(parameters.worker, parameters.receipt)));
590
+ };
591
+ // src/capabilities/internal/subagent-reporting.ts
592
+ const projectReport = (declaration) => Effect.fnUntraced(function* (report) {
593
+ const { worker, observation } = report;
594
+ const invalid = () => WorkerReportPreparationFailure.make({ stage: "projection" });
595
+ if (worker.delegationId !== declaration.delegationId || worker.targetAgentId !== declaration.target.id || observation.receipt.threadId !== worker.threadId) return yield* invalid();
596
+ const base = {
597
+ _tag: "Settled",
598
+ worker,
599
+ receipt: yield* Schema.decodeEffect(Receipt)(observation.receipt).pipe(Effect.mapError(invalid)),
600
+ runId: observation.runId,
601
+ settlementId: observation.settlementId
602
+ };
603
+ let projected;
604
+ let encodedResult = null;
605
+ if (observation.outcome === "completed") {
606
+ const parameters = yield* Schema.decodeUnknownEffect(declaration.parameters)(observation.encodedParameters).pipe(Effect.mapError(invalid));
607
+ const output = yield* Schema.decodeUnknownEffect(declaration.target.output)(observation.encodedResult).pipe(Effect.mapError(invalid));
608
+ const result = yield* declaration.projectResult(output, { budgetExhausted: observation.budgetExhausted }, parameters);
609
+ const encoded = yield* Schema.encodeEffect(declaration.success)(result).pipe(Effect.mapError(invalid));
610
+ const json = yield* Schema.decodeUnknownEffect(Schema.Json)(encoded).pipe(Effect.mapError(invalid));
611
+ if (utf8ByteLength(JSON.stringify(json)) > (declaration.policy?.maxResultBytes ?? declaration.target.policy.toolResultBounds.maxBytes)) return yield* invalid();
612
+ projected = {
613
+ ...base,
614
+ outcome: "completed",
615
+ result
616
+ };
617
+ encodedResult = json;
618
+ } else projected = {
619
+ ...base,
620
+ outcome: observation.outcome,
621
+ failure: SubagentExecutionFailure.make({
622
+ delegationId: declaration.delegationId,
623
+ targetAgentId: declaration.target.id,
624
+ classification: observation.outcome === "failed" ? "child-failed" : "child-aborted",
625
+ childThreadId: worker.threadId,
626
+ childSubmissionId: observation.receipt.submissionId,
627
+ childRunId: observation.runId,
628
+ errorTag: observation.outcome === "failed" ? "WorkerFailed" : "WorkerAborted",
629
+ message: observation.outcome === "failed" ? "Worker input failed" : "Worker input was aborted"
630
+ })
631
+ };
632
+ return {
633
+ projected,
634
+ encodedResult
635
+ };
636
+ });
637
+ /** Register this standard completion projection on the parent; registration captures its services. */
638
+ const reporting = (declaration, options = {}) => ({
639
+ delegationId: declaration.delegationId,
640
+ target: declaration.target,
641
+ ...options,
642
+ prepare: Effect.fnUntraced(function* (report) {
643
+ const { projected, encodedResult } = yield* projectReport(declaration)(report);
644
+ const encoded = projected.outcome === "completed" ? {
645
+ ...projected,
646
+ result: encodedResult
647
+ } : {
648
+ ...projected,
649
+ failure: yield* Schema.encodeEffect(SubagentExecutionFailure)(projected.failure).pipe(Effect.mapError(() => WorkerReportPreparationFailure.make({ stage: "projection" })))
650
+ };
651
+ return { message: yield* Schema.decodeEffect(WorkerCompletion)({
652
+ _tag: "WorkerCompletion",
653
+ schemaVersion: 1,
654
+ report: encoded,
655
+ budgetExhausted: report.observation.budgetExhausted
656
+ }).pipe(Effect.mapError(() => WorkerReportPreparationFailure.make({ stage: "projection" }))) };
657
+ })
658
+ });
659
+ // src/capabilities/Subagent.ts
660
+ var Subagent_exports = /* @__PURE__ */ __exportAll({
661
+ SubagentDurableAccounting: () => SubagentDurableAccounting,
662
+ SubagentExecutionFailure: () => SubagentExecutionFailure,
663
+ SubagentExecutionFailureClassification: () => SubagentExecutionFailureClassification,
664
+ SubagentGrant: () => SubagentGrant,
665
+ SubagentPolicy: () => SubagentPolicy,
666
+ SubagentPrestartDenied: () => SubagentPrestartDenied,
667
+ SubagentProjectionFailure: () => SubagentProjectionFailure,
668
+ SubagentResult: () => SubagentResult,
669
+ Worker: () => Worker,
670
+ WorkerCompletion: () => WorkerCompletion,
671
+ WorkerObservation: () => WorkerObservation,
672
+ WorkerReport: () => WorkerReport,
673
+ await: () => awaitWorker,
674
+ cancel: () => cancel,
675
+ cancelTool: () => cancelTool,
676
+ delegationAllocationFromPolicy: () => delegationAllocationFromPolicy,
677
+ delegationCapsFromPolicy: () => delegationCapsFromPolicy,
678
+ followUp: () => followUp,
679
+ followUpTool: () => followUpTool,
680
+ inspect: () => inspect,
681
+ inspectTool: () => inspectTool,
682
+ layer: () => layer,
683
+ list: () => list,
684
+ listTool: () => listTool,
685
+ make: () => make,
686
+ observe: () => observe,
687
+ reporting: () => reporting,
688
+ start: () => start,
689
+ startTool: () => startTool,
690
+ stop: () => stop,
691
+ summaryTool: () => summaryTool
692
+ });
693
+ const decodeDelegationId = Schema.decodeSync(DelegationId);
694
+ /** Default delegation result, preserving partial-output information. */
695
+ const SubagentResult = (output) => Schema.Struct({
696
+ output,
697
+ budgetExhausted: Schema.Boolean
698
+ });
699
+ /**
700
+ * Declare one attached delegation as a pure value.
701
+ *
702
+ * The returned `.tool` is a native Effect AI Tool whose handler dependencies
703
+ * are exactly the engine-owned `AgentSpawner`, `RunEventSink`, and
704
+ * `SubagentDurability` (SUB-003); runtime IDs have an overridable default.
705
+ * The concrete child Binding arrives only through
706
+ * `Subagent.layer`. Throws on an invalid delegation name. Nested declarations remain inert unless the
707
+ * effective inherited grant and reserved subtree budget permit their lifetime and depth.
708
+ */
709
+ const makeExplicit = (name, options) => {
710
+ const delegationId = decodeDelegationId(name);
711
+ const grant = options.grant ?? SubagentGrant.make({
712
+ allowedToolNames: Object.keys(options.target.toolkit.tools),
713
+ maxDepth: 1
714
+ });
715
+ const failureMode = options.failureMode ?? "error";
716
+ const containedFailure = Schema.Union([
717
+ options.failure,
718
+ SubagentPrestartDenied,
719
+ SubagentBudgetExhausted,
720
+ SubagentProjectionFailure,
721
+ SubagentExecutionFailure
722
+ ]);
723
+ const returnModeTool = Tool.make(name, {
724
+ description: options.description,
725
+ parameters: options.parameters,
726
+ success: Schema.Union([options.success, containedFailure]),
727
+ failure: Schema.Union([ToolCallWaiting, SubagentDurabilityError]),
728
+ needsApproval: options.needsApproval
729
+ });
730
+ const errorModeTool = Tool.make(name, {
731
+ description: options.description,
732
+ parameters: options.parameters,
733
+ success: options.success,
734
+ failure: Schema.Union([
735
+ options.failure,
736
+ SubagentPrestartDenied,
737
+ SubagentBudgetExhausted,
738
+ SubagentProjectionFailure,
739
+ SubagentExecutionFailure,
740
+ ToolCallWaiting,
741
+ SubagentDurabilityError
742
+ ]),
743
+ needsApproval: options.needsApproval
744
+ });
745
+ const tool = (failureMode === "return" ? returnModeTool : errorModeTool).annotate(DelegationTool, true).addDependency(AgentSpawner).addDependency(RunEventSink).addDependency(SubagentDurability).addDependency(IdGenerator);
746
+ return Object.freeze({
747
+ ...options,
748
+ name,
749
+ delegationId,
750
+ grant,
751
+ failureMode,
752
+ containedFailure,
753
+ tool
754
+ });
755
+ };
756
+ function make(name, options) {
757
+ const success = options.success ?? SubagentResult(options.target.output);
758
+ const parameters = options.parameters ?? options.target.input;
759
+ const failure = options.failure ?? Schema.Never;
760
+ const inputValue = Schema.decodeUnknownEffect(Schema.toType(options.target.input));
761
+ const resultValue = Schema.decodeUnknownEffect(Schema.toType(success));
762
+ const needsApproval = options.needsApproval;
763
+ const prepareInput = options.prepareInput;
764
+ const projectResult = options.projectResult;
765
+ const projectionFailure = (stage) => SubagentProjectionFailure.make({
766
+ delegationId: decodeDelegationId(name),
767
+ stage,
768
+ message: stage === "input" ? "Delegation parameters did not satisfy the child input Schema" : "Child output did not satisfy the delegation success Schema"
769
+ });
770
+ const resolved = {
771
+ ...options,
772
+ needsApproval: typeof needsApproval === "function" ? (input, context) => needsApproval(input, context) : needsApproval,
773
+ description: options.description ?? options.target.description,
774
+ parameters,
775
+ success,
776
+ failure,
777
+ prepareInput: (input, context) => prepareInput === void 0 ? inputValue(input).pipe(Effect.mapError(() => projectionFailure("input"))) : prepareInput(input, context),
778
+ projectResult: (output, context, input) => projectResult === void 0 ? resultValue({
779
+ output,
780
+ budgetExhausted: context.budgetExhausted
781
+ }).pipe(Effect.mapError(() => projectionFailure("result"))) : projectResult(output, context, input)
782
+ };
783
+ return options.failureMode === "return" ? makeExplicit(name, {
784
+ ...resolved,
785
+ failureMode: "return"
786
+ }) : makeExplicit(name, {
787
+ ...resolved,
788
+ failureMode: "error"
789
+ });
790
+ }
791
+ /**
792
+ * The conservative final accounting summary the durable delegation handler
793
+ * attaches to every settlement join. The handler has no live child usage stream at durable join
794
+ * time, so every dimension conservatively consumes its full reservation and
795
+ * releases nothing — unreported usage never creates budget. The coordinator
796
+ * owns the canonical accounting decision on `SubagentJoined` and may replace
797
+ * structural dimensions from canonical child evidence; this value is opaque
798
+ * encoded policy math to the engine and to storage adapters (D8).
799
+ */
800
+ var SubagentDurableAccounting = class extends Schema.Class("@effect-agent/capabilities/SubagentDurableAccounting")({
801
+ /** The per-invocation allocation reserved at establishment. */
802
+ allocation: SubagentReservationAmounts,
803
+ /** Final consumed decision per dimension. */
804
+ consumed: SubagentReservationAmounts,
805
+ /** Amounts returned to the parent: `allocation - consumed` per dimension. */
806
+ released: SubagentReservationAmounts,
807
+ /** How the decision was computed; the handler only ever reports conservatively. */
808
+ basis: Schema.Literals(["reserved-conservative"])
809
+ }) {};
810
+ const maxEventTextLength = 4096;
811
+ const boundedEventText = (text) => text.length <= maxEventTextLength ? text : `${text.slice(0, 4095)}…`;
812
+ const ErrorMessage = Schema.Struct({ message: Schema.String });
813
+ const ErrorTag = Schema.Struct({ _tag: Schema.NonEmptyString });
814
+ const isDurationPolicyError = (error) => Schema.is(AgentPolicyError)(error) && error.limit === "duration";
815
+ const errorMessageOf = (error) => Option.match(Schema.decodeUnknownOption(ErrorMessage)(error), {
816
+ onNone: () => String(error),
817
+ onSome: ({ message }) => message
818
+ });
819
+ const errorTagOf = (error) => Option.match(Schema.decodeUnknownOption(ErrorTag)(error), {
820
+ onNone: () => "UnknownError",
821
+ onSome: ({ _tag }) => _tag
822
+ });
823
+ const boundedErrorTag = (tag) => {
824
+ const nonEmpty = tag.length === 0 ? "UnknownError" : tag;
825
+ return nonEmpty.length <= 256 ? nonEmpty : nonEmpty.slice(0, 256);
826
+ };
827
+ /**
828
+ * The coordinator's bounded projection of a failed/aborted child Settlement
829
+ * result (S2 plan §1.6, D5): `{errorTag, message}`, never a raw Cause. The
830
+ * fallback tolerates any other bounded shape without ever surfacing the raw
831
+ * value beyond a tag and message.
832
+ */
833
+ const ChildFailureProjection = Schema.Struct({
834
+ errorTag: Schema.NonEmptyString,
835
+ message: Schema.String
836
+ });
837
+ const childFailureProjectionOf = (encodedResult) => Option.match(Schema.decodeUnknownOption(ChildFailureProjection)(encodedResult), {
838
+ onNone: () => ({
839
+ errorTag: errorTagOf(encodedResult),
840
+ message: errorMessageOf(encodedResult)
841
+ }),
842
+ onSome: (projection) => projection
843
+ });
844
+ const zeroReservationAmounts = SubagentReservationAmounts.make({
845
+ turns: 0,
846
+ toolCalls: 0,
847
+ durationMillis: 0,
848
+ inputTokens: 0,
849
+ outputTokens: 0,
850
+ costMicrousd: 0,
851
+ resultBytes: 0
852
+ });
853
+ const encodeDurableAccounting = Schema.encodeEffect(SubagentDurableAccounting);
854
+ const encodeProjectionFailure = Schema.encodeEffect(SubagentProjectionFailure);
855
+ const encodeBudgetFailure = Schema.encodeEffect(SubagentBudgetExhausted);
856
+ const encodeExecutionFailure = Schema.encodeEffect(SubagentExecutionFailure);
857
+ const encodeGrant = Schema.encodeEffect(SubagentGrant);
858
+ const encodeAllocationAmounts = Schema.encodeEffect(SubagentReservationAmounts);
859
+ const toNatural = (value) => Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;
860
+ const observedUsageFromDelta = (delta) => SubagentObservedUsage.make({
861
+ turns: delta.modelCalls,
862
+ toolCalls: toNatural(delta.toolCalls),
863
+ inputTokens: toNatural(delta.inputTokens),
864
+ outputTokens: toNatural(delta.outputTokens),
865
+ costMicrousd: toNatural(delta.costMicrousd)
866
+ });
867
+ /** A child that never started consumed nothing; observing zeros releases everything. */
868
+ const neverStartedUsage = SubagentObservedUsage.make({
869
+ turns: 0,
870
+ toolCalls: 0,
871
+ durationMillis: 0,
872
+ inputTokens: 0,
873
+ outputTokens: 0,
874
+ costMicrousd: 0,
875
+ resultBytes: 0
876
+ });
877
+ /**
878
+ * Finalizer-driven settlement: observe honest final usage, then release the
879
+ * unused allocation exactly once. Runs on every handler exit path — success,
880
+ * declared failure, interruption, and defect — through the reservation's
881
+ * `Effect.acquireRelease`; a missing reservation after a successful reserve
882
+ * is a ledger invariant violation and therefore a defect.
883
+ */
884
+ const settleReservation = (reservations, reservationId, startedAt, conservative) => Effect.gen(function* () {
885
+ const started = yield* Ref.get(startedAt);
886
+ if (started === void 0) yield* reservations.observe(reservationId, neverStartedUsage);
887
+ else {
888
+ const now = yield* Clock.currentTimeMillis;
889
+ yield* reservations.observe(reservationId, SubagentObservedUsage.make({ durationMillis: Math.max(0, Math.floor(now - started)) }));
890
+ }
891
+ if (started !== void 0 && conservative !== void 0) {
892
+ const own = (yield* reservations.parentSnapshot(conservative.parentRunId)).reservations.find((entry) => entry.reservationId === reservationId);
893
+ if (own === void 0) return yield* Effect.die("Missing subtree reservation during finalization");
894
+ const additional = (key) => Math.max(0, conservative.allocation[key] - (own.observedConsumed[key] ?? 0));
895
+ yield* reservations.observe(reservationId, SubagentObservedUsage.make({
896
+ turns: additional("turns"),
897
+ toolCalls: additional("toolCalls"),
898
+ durationMillis: additional("durationMillis"),
899
+ inputTokens: additional("inputTokens"),
900
+ outputTokens: additional("outputTokens"),
901
+ costMicrousd: additional("costMicrousd"),
902
+ resultBytes: additional("resultBytes")
903
+ }));
904
+ }
905
+ yield* reservations.release(reservationId);
906
+ }).pipe(Effect.orDie);
907
+ /**
908
+ * Module-private provenance wrapper (SUB-033 hardening): ONLY the operations
909
+ * that can genuinely produce the engine signals wrap them here, so
910
+ * containment classification never trusts the runtime identity of classes an
911
+ * author could declare in their own failure Schema — a spoofed
912
+ * `ToolCallWaiting` in author data is contained as data, never rethrown as a
913
+ * suspension signal.
914
+ */
915
+ var GenuineEngineSignal = class {
916
+ _tag = "GenuineEngineSignal";
917
+ signal;
918
+ constructor(signal) {
919
+ this.signal = signal;
920
+ }
921
+ };
922
+ const wrapEngineSignal = (signal) => new GenuineEngineSignal(signal);
923
+ function layer(delegation, modelOrBinding, options = {}) {
924
+ const childBinding = modelOrBinding !== void 0 && "definition" in modelOrBinding ? modelOrBinding : {
925
+ definition: delegation.target,
926
+ model: modelOrBinding ?? Layer.effectContext(Effect.context())
927
+ };
928
+ if (childBinding.definition !== delegation.target) throw new Error("Subagent.layer requires the delegation's exact target Definition");
929
+ const resolvePolicy = (spawner) => resolveSubagentPolicy(delegation, spawner.policy, options.parentCaps, spawner.depth === 0 && spawner.budget === void 0 ? "root-attached" : "conserved");
930
+ const toolkit = Toolkit.make(delegation.tool);
931
+ const contained = delegation.failureMode === "return";
932
+ const encodeChildInput = Schema.encodeEffect(delegation.target.input);
933
+ const encodeSuccess = Schema.encodeEffect(delegation.success);
934
+ const decodeChildOutput = Schema.decodeUnknownEffect(delegation.target.output);
935
+ const encodeResultProjectionFailure = Schema.encodeEffect(Schema.Union([delegation.failure, SubagentProjectionFailure]));
936
+ const executionFailure = (classification, errorTag, message, child) => SubagentExecutionFailure.make({
937
+ delegationId: delegation.delegationId,
938
+ targetAgentId: delegation.target.id,
939
+ classification,
940
+ errorTag: boundedErrorTag(errorTag),
941
+ message: boundedEventText(message),
942
+ ...child === void 0 ? {} : {
943
+ childThreadId: child.childThreadId,
944
+ childSubmissionId: child.childSubmissionId,
945
+ childRunId: child.childRunId
946
+ }
947
+ });
948
+ const prestartDenied = (reason, message) => SubagentPrestartDenied.make({
949
+ delegationId: delegation.delegationId,
950
+ targetAgentId: delegation.target.id,
951
+ reason,
952
+ message: boundedEventText(message)
953
+ });
954
+ const validateAttachedCall = Effect.fnUntraced(function* (callId) {
955
+ const spawner = yield* AgentSpawner;
956
+ const toolCallId = yield* Schema.decodeUnknownEffect(ToolCallId)(callId).pipe(Effect.orDie);
957
+ const grant = narrowSubagentGrant(delegation.grant, spawner.grant);
958
+ const depth = spawner.depth + 1;
959
+ if (depth > grant.maxDepth) return yield* prestartDenied("nested-delegation", "Delegation exceeds the inherited depth ceiling");
960
+ if (!(spawner.grant?.childLifetimes ?? ["attached", "background"]).includes("attached")) return yield* prestartDenied("grant-violation", "The inherited grant does not permit attached children");
961
+ return {
962
+ toolCallId,
963
+ grant,
964
+ depth
965
+ };
966
+ });
967
+ const prepareChildInput = Effect.fnUntraced(function* (parameters, toolCallId) {
968
+ const spawner = yield* AgentSpawner;
969
+ const prepared = yield* delegation.prepareInput(parameters, {
970
+ source: "tool",
971
+ delegationId: delegation.delegationId,
972
+ toolCallId,
973
+ parent: spawner.parent
974
+ });
975
+ return yield* encodeChildInput(prepared).pipe(Effect.mapError(() => SubagentProjectionFailure.make({
976
+ delegationId: delegation.delegationId,
977
+ stage: "input",
978
+ message: "Prepared child input did not satisfy the target Agent input Schema"
979
+ })));
980
+ });
981
+ const build = Effect.gen(function* () {
982
+ const captured = yield* Effect.context();
983
+ const invoke = Effect.fnUntraced(function* (parameters, handlerContext) {
984
+ const spawner = yield* AgentSpawner;
985
+ const resolved = resolvePolicy(spawner);
986
+ if (resolved === void 0) return yield* prestartDenied("budget-conflict", "An unbounded parent Run requires an explicit finite delegation policy");
987
+ const { policy, childPolicy, allocation } = resolved;
988
+ const caps = spawner.budget === void 0 ? resolved.caps : residualSubagentCaps(resolved.caps, spawner.policy, spawner.budget, spawner.budgetScope === "worker-run");
989
+ const sink = yield* RunEventSink;
990
+ const reservations = yield* SubagentReservations;
991
+ const { toolCallId, grant, depth } = yield* validateAttachedCall(handlerContext.toolCallId);
992
+ if (spawner.depth > 0 && spawner.budget === void 0) return yield* prestartDenied("budget-conflict", "Nested ephemeral delegation requires an inherited subtree reservation");
993
+ const encodedInput = yield* prepareChildInput(parameters, toolCallId);
994
+ const parentRunId = spawner.parent.runId;
995
+ yield* Effect.acquireRelease(reservations.registerParent(parentRunId, caps).pipe(Effect.catchTag("SubagentParentBudgetConflict", () => Effect.fail(prestartDenied("budget-conflict", "The parent Run is already registered with different delegation caps; supply shared parentCaps explicitly"))), Effect.asVoid), () => reservations.retireParent(parentRunId).pipe(Effect.orDie)).pipe(Scope.provide(spawner.scope));
996
+ const reservationId = makeBudgetReservationId(parentRunId, toolCallId);
997
+ const startedAt = yield* Ref.make(void 0);
998
+ yield* Effect.acquireRelease(reservations.reserve(SubagentReservationRequest.make({
999
+ parentRunId,
1000
+ parentToolCallId: toolCallId,
1001
+ allocation,
1002
+ ...policy.descendantInvocations === void 0 ? {} : { descendantInvocations: policy.descendantInvocations }
1003
+ })).pipe(Effect.catchTags({
1004
+ SubagentReservationConflict: (conflict) => Effect.die(conflict),
1005
+ SubagentParentBudgetUnknown: (unknown) => Effect.die(unknown)
1006
+ })), () => settleReservation(reservations, reservationId, startedAt, (policy.descendantInvocations ?? 0) > 0 ? {
1007
+ parentRunId,
1008
+ allocation
1009
+ } : void 0));
1010
+ yield* reservations.acquireChildSlot(parentRunId, 1 + (policy.descendantInvocations ?? 0)).pipe(Effect.catchTag("SubagentParentBudgetUnknown", (unknown) => Effect.die(unknown)));
1011
+ const seededChild = options.child;
1012
+ const seededBudget = seededChild?.budget;
1013
+ const budget = {
1014
+ guard: seededBudget === void 0 ? (effect) => effect : (effect) => seededBudget.guard(effect),
1015
+ consume: (delta) => reservations.observe(reservationId, observedUsageFromDelta(delta)).pipe(Effect.orDie, Effect.andThen(seededBudget === void 0 ? Effect.void : seededBudget.consume(delta)))
1016
+ };
1017
+ const childStartedAt = yield* Clock.currentTimeMillis;
1018
+ const durationMillis = Math.max(0, Math.min(allocation.durationMillis, Math.floor(DateTime.toEpochMillis(spawner.durationDeadline) - childStartedAt - Duration.toMillis(policy.parentReserveDuration ?? Duration.zero))));
1019
+ if (durationMillis === 0) return yield* SubagentBudgetExhausted.make({
1020
+ parentRunId,
1021
+ dimension: "duration",
1022
+ limitValue: 0,
1023
+ observedValue: 0
1024
+ });
1025
+ const durationDeadlineMillis = childStartedAt + durationMillis;
1026
+ const durationDeadline = DateTime.makeUnsafe(durationDeadlineMillis);
1027
+ const childOptions = {
1028
+ ...seededChild,
1029
+ durationDeadline: seededChild?.durationDeadline === void 0 ? durationDeadline : DateTime.min(durationDeadline, seededChild.durationDeadline),
1030
+ subagentGrant: grant,
1031
+ delegationDepth: depth,
1032
+ subagentBudget: SubagentBudgetReservation.make({
1033
+ caps,
1034
+ allocation,
1035
+ ...policy.descendantInvocations === void 0 ? {} : { descendantInvocations: policy.descendantInvocations }
1036
+ }),
1037
+ budget,
1038
+ toolCallAllowance: childPolicy.maxToolCalls
1039
+ };
1040
+ yield* Ref.set(startedAt, childStartedAt);
1041
+ const childScope = yield* Scope.make();
1042
+ yield* Effect.addFinalizer((exit) => Scope.close(childScope, exit));
1043
+ const child = yield* spawner.spawn({
1044
+ ...childBinding,
1045
+ definition: {
1046
+ ...childBinding.definition,
1047
+ policy: childPolicy
1048
+ }
1049
+ }, encodedInput, {
1050
+ delegationId: delegation.delegationId,
1051
+ parentToolCallId: toolCallId
1052
+ }, childOptions).pipe(Scope.provide(childScope));
1053
+ const payload = {
1054
+ toolCallId,
1055
+ delegationId: delegation.delegationId,
1056
+ childThreadId: child.threadId,
1057
+ childRunId: child.runId,
1058
+ targetAgentId: delegation.target.id,
1059
+ depth: child.parentLink.depth
1060
+ };
1061
+ const emit = (event) => sink.emit(event).pipe(Effect.orDie);
1062
+ yield* emit({
1063
+ _tag: "SubagentRequested",
1064
+ ...payload
1065
+ });
1066
+ yield* emit({
1067
+ _tag: "SubagentStarted",
1068
+ ...payload
1069
+ });
1070
+ return yield* Effect.gen(function* () {
1071
+ const result = yield* child.await.pipe(Effect.catch((childFailure) => Effect.gen(function* () {
1072
+ if (isDurationPolicyError(childFailure) && (yield* Clock.currentTimeMillis) >= durationDeadlineMillis) return;
1073
+ const report = yield* child.usageReport;
1074
+ yield* emit({
1075
+ _tag: "SubagentFailed",
1076
+ ...payload,
1077
+ ...report,
1078
+ errorTag: errorTagOf(childFailure),
1079
+ message: boundedEventText(errorMessageOf(childFailure))
1080
+ });
1081
+ return yield* Effect.fail(options.mapChildFailure === void 0 ? executionFailure("child-failed", errorTagOf(childFailure), "The child Run failed") : options.mapChildFailure(childFailure));
1082
+ })), Effect.timeoutOrElse({
1083
+ duration: Math.max(0, durationDeadlineMillis - (yield* Clock.currentTimeMillis)),
1084
+ orElse: () => Effect.as(Effect.void, void 0)
1085
+ }), Effect.tapCause((cause) => Cause.hasDies(cause) ? child.usageReport.pipe(Effect.flatMap((report) => emit({
1086
+ _tag: "SubagentFailed",
1087
+ ...payload,
1088
+ ...report,
1089
+ errorTag: "Defect",
1090
+ message: "The child Run ended with a defect"
1091
+ })), Effect.ignore) : Effect.void));
1092
+ if (result === void 0) {
1093
+ yield* Scope.close(childScope, Exit.void);
1094
+ const report = yield* child.usageReport;
1095
+ yield* emit({
1096
+ _tag: "SubagentFailed",
1097
+ ...payload,
1098
+ ...report,
1099
+ errorTag: "SubagentBudgetExhausted",
1100
+ message: `Attached child exceeded its ${durationMillis}ms delegation duration budget`
1101
+ });
1102
+ return yield* SubagentBudgetExhausted.make({
1103
+ parentRunId,
1104
+ dimension: "duration",
1105
+ limitValue: durationMillis,
1106
+ observedValue: durationMillis
1107
+ });
1108
+ }
1109
+ const report = yield* child.usageReport;
1110
+ yield* emit({
1111
+ _tag: "SubagentCompleted",
1112
+ ...payload,
1113
+ ...report,
1114
+ turns: result.turns,
1115
+ finishReason: result.finishReason,
1116
+ ...result.exhausted !== void 0 ? { exhausted: result.exhausted } : {}
1117
+ });
1118
+ const projected = yield* delegation.projectResult(result.output, {
1119
+ budgetExhausted: result.finishReason === "budget-exhausted",
1120
+ ...report
1121
+ }, parameters);
1122
+ const encodedResult = yield* encodeSuccess(projected).pipe(Effect.mapError(() => SubagentProjectionFailure.make({
1123
+ delegationId: delegation.delegationId,
1124
+ stage: "result",
1125
+ message: "Projected child result did not satisfy the delegation success Schema"
1126
+ })));
1127
+ const resultBytes = utf8ByteLength(JSON.stringify(encodedResult) ?? "");
1128
+ yield* reservations.observe(reservationId, SubagentObservedUsage.make({ resultBytes })).pipe(Effect.orDie);
1129
+ if (policy.maxResultBytes !== void 0 && resultBytes > policy.maxResultBytes) {
1130
+ yield* emit({
1131
+ _tag: "SubagentFailed",
1132
+ ...payload,
1133
+ ...report,
1134
+ errorTag: "SubagentBudgetExhausted",
1135
+ message: `Projected child result of ${resultBytes} bytes exceeds the ${policy.maxResultBytes}-byte delegation budget`
1136
+ });
1137
+ return yield* SubagentBudgetExhausted.make({
1138
+ parentRunId,
1139
+ dimension: "result-bytes",
1140
+ limitValue: policy.maxResultBytes,
1141
+ observedValue: resultBytes
1142
+ });
1143
+ }
1144
+ yield* emit({
1145
+ _tag: "SubagentJoined",
1146
+ ...payload,
1147
+ ...report
1148
+ });
1149
+ return projected;
1150
+ }).pipe(Effect.onInterrupt(() => Scope.close(childScope, Exit.void).pipe(Effect.andThen(child.usageReport), Effect.flatMap((report) => sink.emit({
1151
+ _tag: "SubagentInterrupted",
1152
+ ...payload,
1153
+ ...report,
1154
+ reason: "Parent Run interrupted the attached child before it settled"
1155
+ })), Effect.ignore)));
1156
+ });
1157
+ /**
1158
+ * Durable branch: establishment through the
1159
+ * coordinator's idempotent protocol instead of an in-process spawn. No
1160
+ * child fiber ever starts here, and the S1 in-memory reservation service
1161
+ * is deliberately not consulted — its Scope-finalizer settlement
1162
+ * contradicts a handler that exits with the waiting signal while the
1163
+ * child keeps running; durable budget lives in the coordinator's fenced
1164
+ * ledger reservation built from `encodedAllocation`.
1165
+ */
1166
+ const invokeDurable = Effect.fnUntraced(function* (parameters, handlerContext, durability) {
1167
+ const spawner = yield* AgentSpawner;
1168
+ const resolved = resolvePolicy(spawner);
1169
+ if (resolved === void 0) return yield* prestartDenied("budget-conflict", "An unbounded parent Run requires an explicit finite delegation policy");
1170
+ const { policy, childPolicy, allocation, caps } = resolved;
1171
+ const encodedAllocation = yield* encodeAllocationAmounts(allocation).pipe(Effect.orDie);
1172
+ const conservativeAccounting = yield* encodeDurableAccounting(SubagentDurableAccounting.make({
1173
+ allocation,
1174
+ consumed: allocation,
1175
+ released: zeroReservationAmounts,
1176
+ basis: "reserved-conservative"
1177
+ })).pipe(Effect.orDie);
1178
+ const sink = yield* RunEventSink;
1179
+ const { toolCallId, grant, depth } = yield* validateAttachedCall(handlerContext.toolCallId);
1180
+ const emit = (event) => sink.emit(event).pipe(Effect.orDie);
1181
+ const encodedGrant = yield* encodeGrant(grant).pipe(Effect.orDie);
1182
+ const encodedInput = yield* prepareChildInput(parameters, toolCallId);
1183
+ const status = yield* Effect.mapError(wrapEngineSignal)(durability.establish({
1184
+ toolCallId,
1185
+ delegationId: delegation.delegationId,
1186
+ target: delegation.target,
1187
+ targetAgentId: delegation.target.id,
1188
+ depth,
1189
+ encodedChildInput: encodedInput,
1190
+ encodedGrant,
1191
+ encodedAllocation,
1192
+ toolCallAllowance: childPolicy.maxToolCalls,
1193
+ policy: childPolicy,
1194
+ budget: {
1195
+ caps,
1196
+ allocation,
1197
+ ...policy.descendantInvocations === void 0 ? {} : { descendantInvocations: policy.descendantInvocations }
1198
+ }
1199
+ }));
1200
+ switch (status._tag) {
1201
+ case "denied": return yield* executionFailure("establishment-denied", status.errorTag, status.message);
1202
+ case "waiting": {
1203
+ const payload = {
1204
+ toolCallId,
1205
+ delegationId: delegation.delegationId,
1206
+ childThreadId: status.childThreadId,
1207
+ childRunId: status.childRunId,
1208
+ targetAgentId: delegation.target.id,
1209
+ depth
1210
+ };
1211
+ yield* emit({
1212
+ _tag: "SubagentRequested",
1213
+ ...payload
1214
+ });
1215
+ yield* emit({
1216
+ _tag: "SubagentStarted",
1217
+ ...payload
1218
+ });
1219
+ return yield* Effect.mapError(wrapEngineSignal)(durability.waiting(toolCallId, status));
1220
+ }
1221
+ case "settled": {
1222
+ const payload = {
1223
+ toolCallId,
1224
+ delegationId: delegation.delegationId,
1225
+ childThreadId: status.childThreadId,
1226
+ childRunId: status.childRunId,
1227
+ targetAgentId: delegation.target.id,
1228
+ depth
1229
+ };
1230
+ const report = RunUsageReport.make({
1231
+ usage: status.usage ?? unknownRunTotals(),
1232
+ delegatedUsage: status.delegatedUsage ?? unknownRunTotals()
1233
+ });
1234
+ const settleFailure = (failure, encodedFailure) => emit({
1235
+ _tag: "SubagentFailed",
1236
+ ...payload,
1237
+ ...report,
1238
+ errorTag: errorTagOf(failure),
1239
+ message: boundedEventText(errorMessageOf(failure))
1240
+ }).pipe(Effect.andThen(Effect.mapError(wrapEngineSignal)(durability.join({
1241
+ toolCallId,
1242
+ encodedResult: encodedFailure,
1243
+ isFailure: !contained,
1244
+ encodedAccounting: conservativeAccounting
1245
+ }))), Effect.andThen(Effect.fail(failure)));
1246
+ if (status.outcome !== "completed") {
1247
+ const projection = childFailureProjectionOf(status.encodedResult);
1248
+ const failure = executionFailure(status.outcome === "aborted" ? "child-aborted" : projection.errorTag === "ChildCompatibilityFailure" ? "child-compatibility" : "child-failed", projection.errorTag, projection.message, status);
1249
+ return yield* settleFailure(failure, yield* encodeExecutionFailure(failure).pipe(Effect.orDie));
1250
+ }
1251
+ const decoded = yield* decodeChildOutput(status.encodedResult).pipe(Effect.catch(() => {
1252
+ const failure = SubagentProjectionFailure.make({
1253
+ delegationId: delegation.delegationId,
1254
+ stage: "result",
1255
+ message: "Settled child output did not satisfy the target Agent output Schema"
1256
+ });
1257
+ return encodeProjectionFailure(failure).pipe(Effect.orDie, Effect.flatMap((encodedFailure) => settleFailure(failure, encodedFailure)));
1258
+ }));
1259
+ const projected = yield* delegation.projectResult(decoded, {
1260
+ budgetExhausted: status.finishReason === "budget-exhausted",
1261
+ ...report
1262
+ }, parameters).pipe(Effect.catch((declared) => encodeResultProjectionFailure(declared).pipe(Effect.orDie, Effect.flatMap((encodedFailure) => settleFailure(declared, encodedFailure)))));
1263
+ const encodedResult = yield* encodeSuccess(projected).pipe(Effect.catch(() => {
1264
+ const failure = SubagentProjectionFailure.make({
1265
+ delegationId: delegation.delegationId,
1266
+ stage: "result",
1267
+ message: "Projected child result did not satisfy the delegation success Schema"
1268
+ });
1269
+ return encodeProjectionFailure(failure).pipe(Effect.orDie, Effect.flatMap((encodedFailure) => settleFailure(failure, encodedFailure)));
1270
+ }));
1271
+ const resultBytes = utf8ByteLength(JSON.stringify(encodedResult) ?? "");
1272
+ if (policy.maxResultBytes !== void 0 && resultBytes > policy.maxResultBytes) {
1273
+ const failure = SubagentBudgetExhausted.make({
1274
+ parentRunId: spawner.parent.runId,
1275
+ dimension: "result-bytes",
1276
+ limitValue: policy.maxResultBytes,
1277
+ observedValue: resultBytes
1278
+ });
1279
+ return yield* settleFailure(failure, yield* encodeBudgetFailure(failure).pipe(Effect.orDie));
1280
+ }
1281
+ yield* Effect.mapError(wrapEngineSignal)(durability.join({
1282
+ toolCallId,
1283
+ encodedResult,
1284
+ isFailure: false,
1285
+ encodedAccounting: conservativeAccounting
1286
+ }));
1287
+ yield* emit({
1288
+ _tag: "SubagentJoined",
1289
+ ...payload,
1290
+ ...report
1291
+ });
1292
+ return projected;
1293
+ }
1294
+ }
1295
+ });
1296
+ const containSignals = (failure) => failure instanceof GenuineEngineSignal ? Effect.fail(failure.signal) : Effect.succeed(failure);
1297
+ const unwrapSignals = (failure) => failure instanceof GenuineEngineSignal ? failure.signal : failure;
1298
+ const handler = Effect.fnUntraced(function* (parameters, handlerContext) {
1299
+ const spawner = yield* AgentSpawner;
1300
+ const sink = yield* RunEventSink;
1301
+ const durability = yield* SubagentDurability;
1302
+ if (durability.mode === "durable") {
1303
+ const durable = invokeDurable(parameters, handlerContext, durability).pipe(Effect.scoped, Effect.provideService(AgentSpawner, spawner), Effect.provideService(RunEventSink, sink), Effect.provideService(SubagentDurability, durability), Effect.provide(captured));
1304
+ return yield* contained ? durable.pipe(Effect.catch(containSignals)) : durable.pipe(Effect.mapError(unwrapSignals));
1305
+ }
1306
+ const ephemeral = invoke(parameters, handlerContext).pipe(Effect.scoped, Effect.provideService(AgentSpawner, spawner), Effect.provideService(RunEventSink, sink), Effect.provideService(SubagentDurability, durability), Effect.provide(captured));
1307
+ return yield* contained ? ephemeral.pipe(Effect.catch(containSignals)) : ephemeral.pipe(Effect.mapError(unwrapSignals));
1308
+ });
1309
+ return { [delegation.name]: handler };
1310
+ });
1311
+ return toolkit.toLayer(build);
1312
+ }
1313
+ export { summaryTool as S, listTool as _, make as a, startTool as b, WorkerObservation as c, cancelTool as d, followUp as f, list as g, inspectTool as h, layer as i, awaitWorker as l, inspect as m, SubagentResult as n, reporting as o, followUpTool as p, Subagent_exports as r, Worker as s, SubagentDurableAccounting as t, cancel as u, observe as v, stop as x, start as y };
1314
+
1315
+ //# sourceMappingURL=Subagent-CSIRUgUo.mjs.map