effect-agent 0.1.0-beta.164 → 0.1.0-beta.165

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 (285) hide show
  1. package/dist/{Admin-Vhz6NdaH.d.mts → Admin-CbwoQEm8.d.mts} +24 -24
  2. package/dist/{Agent-BMATXYsI.mjs → Agent-B0WrUcHy.mjs} +9 -9
  3. package/dist/Agent-B0WrUcHy.mjs.map +1 -0
  4. package/dist/{Agent-ZfnNCQXs.d.mts → Agent-D0fbFT2d.d.mts} +27 -24
  5. package/dist/{AgentError-Bn1ytXRD.d.mts → AgentError-BMqPzIVt.d.mts} +3 -3
  6. package/dist/{AgentPolicy-B4oH8TbG.d.mts → AgentPolicy-CclAEpHn.d.mts} +2 -2
  7. package/dist/{AgentRuntime-D1MmB_0z.d.mts → AgentRuntime-BM36roNi.d.mts} +44 -30
  8. package/dist/{AgentRuntime-Q50HloUc.mjs → AgentRuntime-BTfPyMXN.mjs} +91 -30
  9. package/dist/AgentRuntime-BTfPyMXN.mjs.map +1 -0
  10. package/dist/{AgentUpdates-DMJ-_xow.d.mts → AgentUpdates-DksV4D0A.d.mts} +6 -3
  11. package/dist/{ContextCompactor-BoKQOjr5.d.mts → ContextCompactor-DLpX-HUG.d.mts} +18 -12
  12. package/dist/{ContextWindow-DRQ5Mbm2.d.mts → ContextWindow-aGZOPIPq.d.mts} +24 -22
  13. package/dist/{Digest-COAt3Orl.d.mts → Digest-3l_02jaM.d.mts} +2 -2
  14. package/dist/{DurableAgentRuntime-BTMOgDl_.mjs → DurableAgentRuntime-CWmWREPj.mjs} +11 -11
  15. package/dist/{DurableAgentRuntime-BTMOgDl_.mjs.map → DurableAgentRuntime-CWmWREPj.mjs.map} +1 -1
  16. package/dist/{DurableStep-Cry_iol4.d.mts → DurableStep-CTqx6DOV.d.mts} +13 -11
  17. package/dist/{EventSource-CtS0RBM7.d.mts → EventSource-D29Jsj5U.d.mts} +3 -3
  18. package/dist/{FailureDiagnostic-BElLOoED.mjs → FailureDiagnostic-D9oW23Cn.mjs} +16 -10
  19. package/dist/FailureDiagnostic-D9oW23Cn.mjs.map +1 -0
  20. package/dist/{FailureDiagnostic-CaAkzGHL.d.mts → FailureDiagnostic-DvHruCSJ.d.mts} +10 -9
  21. package/dist/InMemory.d.mts +28 -5
  22. package/dist/InMemory.mjs +37 -4
  23. package/dist/InMemory.mjs.map +1 -1
  24. package/dist/{Messaging-CICd_CSi.d.mts → Messaging-BbuaphiQ.d.mts} +6 -6
  25. package/dist/{Messaging-7VXQnWI3.d.mts → Messaging-DF_IWnxV.d.mts} +5 -5
  26. package/dist/{MessagingHost-DXwWnrMh.d.mts → MessagingHost-Bfbfkx6f.d.mts} +13 -12
  27. package/dist/{MessagingHost-DfsbMPvq.mjs → MessagingHost-DJZJZILu.mjs} +4 -3
  28. package/dist/MessagingHost-DJZJZILu.mjs.map +1 -0
  29. package/dist/{Output-CY7NZByV.d.mts → Output-UsQKiPhz.d.mts} +4 -4
  30. package/dist/{PreparedInputAdmission-CS_zlCvD.d.mts → PreparedInputAdmission-DXvjTe4U.d.mts} +6 -6
  31. package/dist/{Receipt-BAHyigAF.d.mts → Receipt-BkM21Qiu.d.mts} +2 -2
  32. package/dist/{Records-Bm4Qt70a.d.mts → Records-CAQktL0z.d.mts} +8 -8
  33. package/dist/{RunEvent-D0aepYwN.d.mts → RunEvent-B3CRIqIC.d.mts} +5 -5
  34. package/dist/{RunEventSink-9CUdI9Ar.d.mts → RunEventSink-sDXDkrAl.d.mts} +9 -7
  35. package/dist/{RunJournal-D8Vvf_io.mjs → RunJournal-NRgq1PNe.mjs} +3 -3
  36. package/dist/{RunJournal-D8Vvf_io.mjs.map → RunJournal-NRgq1PNe.mjs.map} +1 -1
  37. package/dist/{RunOptions-BHmBa05n.d.mts → RunOptions-CkSZSuIh.d.mts} +87 -83
  38. package/dist/{RunPolicyUsage-CUudVtg_.d.mts → RunPolicyUsage-QmYVw9z8.d.mts} +2 -2
  39. package/dist/{Schedule-Bi_XVKLF.d.mts → Schedule-rEIiYnRq.d.mts} +4 -4
  40. package/dist/{Subagent-Cxvuaius.mjs → Subagent-C-fyHbcp.mjs} +5 -5
  41. package/dist/{Subagent-Cxvuaius.mjs.map → Subagent-C-fyHbcp.mjs.map} +1 -1
  42. package/dist/{Subagent-D59om8SR.d.mts → Subagent-t3pJDZMN.d.mts} +15 -15
  43. package/dist/{SubagentContract-tyN9v-Jv.d.mts → SubagentContract-DdPzxYQj.d.mts} +3 -2
  44. package/dist/{SubagentHost-VTyf_wEF.d.mts → SubagentHost-CXFlEpj0.d.mts} +19 -16
  45. package/dist/{Subscription-nbSNY6Hs.d.mts → Subscription-BJj-R-6V.d.mts} +8 -8
  46. package/dist/{SubscriptionInput-DbXnOMS2.d.mts → SubscriptionInput-DyQtODg2.d.mts} +3 -3
  47. package/dist/Thread-DT8RTLIQ.d.mts +117 -0
  48. package/dist/{ThreadHistory-FD-o4TsR.d.mts → ThreadHistory-DQ-IC1hU.d.mts} +12 -9
  49. package/dist/{ToolBroker-DWs4tZra.d.mts → ToolBroker-DXwv2aUT.d.mts} +14 -12
  50. package/dist/{ToolExposure-UCN12eCd.d.mts → ToolExposure-BsaSH15e.d.mts} +5 -4
  51. package/dist/{ToolExposure-r2eOWk4F.d.mts → ToolExposure-Ckg3-sTf.d.mts} +3 -2
  52. package/dist/{ToolExposure-9uF_Yo0T.mjs → ToolExposure-DBATXxmL.mjs} +2 -2
  53. package/dist/ToolExposure-DBATXxmL.mjs.map +1 -0
  54. package/dist/{ToolExposure-C93U1sPu.mjs → ToolExposure-hTJT2ekj.mjs} +3 -2
  55. package/dist/ToolExposure-hTJT2ekj.mjs.map +1 -0
  56. package/dist/ToolExposure.d.mts +2 -2
  57. package/dist/ToolExposure.mjs +2 -2
  58. package/dist/{ToolResult-BKdqWRff.d.mts → ToolResult-DqyEhJLF.d.mts} +2 -2
  59. package/dist/{Usage-BNjPR7Zr.d.mts → Usage-CzZJ6A2n.d.mts} +3 -2
  60. package/dist/{Worker-XEBYxRQv.d.mts → Worker-DH5SAVIK.d.mts} +7 -7
  61. package/dist/{Worker-CfwzMZEK.mjs → Worker-DZjdMjZn.mjs} +3 -3
  62. package/dist/Worker-DZjdMjZn.mjs.map +1 -0
  63. package/dist/{WorkerAdmission-BVbSB8_A.mjs → WorkerAdmission-DJ76C2b-.mjs} +4 -4
  64. package/dist/{WorkerAdmission-BVbSB8_A.mjs.map → WorkerAdmission-DJ76C2b-.mjs.map} +1 -1
  65. package/dist/{agent-registration-BIOzAej4.mjs → agent-registration-D1dWV7KK.mjs} +3 -3
  66. package/dist/{agent-registration-BIOzAej4.mjs.map → agent-registration-D1dWV7KK.mjs.map} +1 -1
  67. package/dist/capabilities/BrowserUse.d.mts +1 -1
  68. package/dist/capabilities/BrowserUse.mjs +1 -1
  69. package/dist/capabilities/CodeMode.d.mts +2 -2
  70. package/dist/capabilities/CodeMode.mjs +3 -3
  71. package/dist/capabilities/Commands.d.mts +1 -1
  72. package/dist/capabilities/ContextTools.d.mts +2 -2
  73. package/dist/capabilities/ContextTools.mjs +1 -1
  74. package/dist/capabilities/Mcp.d.mts +1 -1
  75. package/dist/capabilities/Mcp.mjs +1 -1
  76. package/dist/capabilities/McpClient.d.mts +1 -1
  77. package/dist/capabilities/McpClient.mjs +1 -1
  78. package/dist/capabilities/MemoryNotes.d.mts +2 -2
  79. package/dist/capabilities/MemoryNotes.mjs +1 -1
  80. package/dist/capabilities/Messaging.d.mts +2 -2
  81. package/dist/capabilities/Messaging.mjs +3 -3
  82. package/dist/capabilities/ModelContext.d.mts +1 -1
  83. package/dist/capabilities/Redaction.d.mts +1 -1
  84. package/dist/capabilities/RunHooks.d.mts +7 -6
  85. package/dist/capabilities/RunHooks.mjs +2 -1
  86. package/dist/capabilities/RunHooks.mjs.map +1 -1
  87. package/dist/capabilities/SemanticMemory.d.mts +1 -1
  88. package/dist/capabilities/SemanticMemory.mjs +1 -1
  89. package/dist/capabilities/Subagent.d.mts +3 -3
  90. package/dist/capabilities/Subagent.mjs +2 -2
  91. package/dist/capabilities/SubagentReservations.d.mts +64 -60
  92. package/dist/capabilities/SubagentReservations.mjs +6 -1
  93. package/dist/capabilities/SubagentReservations.mjs.map +1 -1
  94. package/dist/capabilities/ToolDiscovery.d.mts +2 -2
  95. package/dist/capabilities/ToolDiscovery.mjs +3 -3
  96. package/dist/capabilities/WebCapture.d.mts +1 -1
  97. package/dist/capabilities/WebCapture.mjs +1 -1
  98. package/dist/capabilities/WebSearch.d.mts +1 -1
  99. package/dist/capabilities/WebSearch.mjs +1 -1
  100. package/dist/{compaction-BQK4MUg3.mjs → compaction-FDJhjbzH.mjs} +4 -3
  101. package/dist/compaction-FDJhjbzH.mjs.map +1 -0
  102. package/dist/core/Agent.d.mts +1 -1
  103. package/dist/core/Agent.mjs +1 -1
  104. package/dist/core/AgentError.d.mts +1 -1
  105. package/dist/core/AgentError.mjs +4 -4
  106. package/dist/core/AgentError.mjs.map +1 -1
  107. package/dist/core/AgentPolicy.d.mts +1 -1
  108. package/dist/core/AgentUpdates.d.mts +1 -1
  109. package/dist/core/AgentUpdates.mjs +5 -1
  110. package/dist/core/AgentUpdates.mjs.map +1 -1
  111. package/dist/core/FailureDiagnostic.d.mts +1 -1
  112. package/dist/core/FailureDiagnostic.mjs +1 -1
  113. package/dist/core/IdGenerator.d.mts +3 -1
  114. package/dist/core/IdGenerator.mjs +8 -5
  115. package/dist/core/IdGenerator.mjs.map +1 -1
  116. package/dist/core/Receipt.d.mts +1 -1
  117. package/dist/core/Receipt.mjs +1 -1
  118. package/dist/core/Receipt.mjs.map +1 -1
  119. package/dist/core/RunEvent.d.mts +1 -1
  120. package/dist/core/RunEvent.mjs +2 -2
  121. package/dist/core/RunEvent.mjs.map +1 -1
  122. package/dist/core/RunPolicyUsage.d.mts +1 -1
  123. package/dist/core/RunPolicyUsage.mjs +1 -1
  124. package/dist/core/RunPolicyUsage.mjs.map +1 -1
  125. package/dist/core/SubagentContract.d.mts +1 -1
  126. package/dist/core/SubagentContract.mjs +2 -1
  127. package/dist/core/SubagentContract.mjs.map +1 -1
  128. package/dist/core/Thread.d.mts +2 -2
  129. package/dist/core/Thread.mjs +82 -33
  130. package/dist/core/Thread.mjs.map +1 -1
  131. package/dist/core/ToolResult.d.mts +1 -1
  132. package/dist/core/ToolResult.mjs +1 -1
  133. package/dist/core/ToolResult.mjs.map +1 -1
  134. package/dist/core/Usage.d.mts +1 -1
  135. package/dist/core/Usage.mjs +2 -1
  136. package/dist/core/Usage.mjs.map +1 -1
  137. package/dist/core/Worker.d.mts +2 -2
  138. package/dist/core/Worker.mjs +1 -1
  139. package/dist/durable/ActivityStore.d.mts +1 -1
  140. package/dist/durable/Admin.d.mts +1 -1
  141. package/dist/durable/AgentRegistration.d.mts +1 -1
  142. package/dist/durable/AgentRegistration.mjs +1 -1
  143. package/dist/durable/Certification.d.mts +1 -1
  144. package/dist/durable/CommittedActivity.d.mts +3 -3
  145. package/dist/durable/Digest.d.mts +1 -1
  146. package/dist/durable/DurableAgentRuntime.d.mts +2 -2
  147. package/dist/durable/DurableAgentRuntime.mjs +2 -2
  148. package/dist/durable/EventSource.d.mts +1 -1
  149. package/dist/durable/GitHubWorkflowSource.d.mts +4 -4
  150. package/dist/durable/GitHubWorkflowSource.mjs +1 -1
  151. package/dist/durable/LifecyclePublication.d.mts +1 -1
  152. package/dist/durable/LifecyclePublication.mjs +1 -1
  153. package/dist/durable/MessageDelivery.d.mts +9 -9
  154. package/dist/durable/MessageDelivery.mjs +2 -2
  155. package/dist/durable/MessageDeliveryStoreConformance.d.mts +28 -28
  156. package/dist/durable/MessageDeliveryStoreConformance.mjs +1 -1
  157. package/dist/durable/PersistentHistory.d.mts +2 -2
  158. package/dist/durable/PersistentHistory.mjs +2 -2
  159. package/dist/durable/PreparedInputAdmission.d.mts +1 -1
  160. package/dist/durable/PreparedInputAdmission.mjs +1 -1
  161. package/dist/durable/Records.d.mts +1 -1
  162. package/dist/durable/Records.mjs +5 -5
  163. package/dist/durable/Recovery.d.mts +1 -1
  164. package/dist/durable/RunJournal.d.mts +1 -1
  165. package/dist/durable/RunJournal.mjs +1 -1
  166. package/dist/durable/Schedule.d.mts +1 -1
  167. package/dist/durable/Schedule.mjs +1 -1
  168. package/dist/durable/ScheduleStoreConformance.d.mts +1 -1
  169. package/dist/durable/ScheduleTransition.d.mts +1 -1
  170. package/dist/durable/Scheduling.d.mts +4 -4
  171. package/dist/durable/SubmissionLedger.d.mts +2 -2
  172. package/dist/durable/SubmissionLedger.mjs +3 -3
  173. package/dist/durable/SubmissionLedgerConformance.d.mts +2 -2
  174. package/dist/durable/SubmissionLedgerConformance.mjs +3 -3
  175. package/dist/durable/SubmissionStatus.d.mts +1 -1
  176. package/dist/durable/Subscription.d.mts +1 -1
  177. package/dist/durable/Subscription.mjs +1 -1
  178. package/dist/durable/SubscriptionInput.d.mts +1 -1
  179. package/dist/durable/SubscriptionInput.mjs +1 -1
  180. package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
  181. package/dist/durable/SubscriptionTools.d.mts +7 -7
  182. package/dist/durable/SubscriptionTools.mjs +1 -1
  183. package/dist/durable/SubscriptionTransition.d.mts +1 -1
  184. package/dist/durable/Subscriptions.d.mts +7 -7
  185. package/dist/durable/ThreadContextHistory.d.mts +1 -1
  186. package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
  187. package/dist/durable/ThreadContextHistoryProjection.mjs +2 -2
  188. package/dist/durable/ThreadInvariants.d.mts +2 -2
  189. package/dist/durable/ThreadInvariants.mjs +1 -1
  190. package/dist/durable/ThreadProjection.d.mts +1 -1
  191. package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
  192. package/dist/durable/ThreadStore.d.mts +1 -1
  193. package/dist/durable/ThreadStore.mjs +1 -1
  194. package/dist/durable/ThreadStoreConformance.d.mts +1 -1
  195. package/dist/durable/ThreadStoreConformance.mjs +1 -1
  196. package/dist/durable/WorkerAdmission.d.mts +6 -6
  197. package/dist/durable/WorkerAdmission.mjs +1 -1
  198. package/dist/durable/WorkerHost.d.mts +7 -7
  199. package/dist/durable/WorkerHost.mjs +1 -1
  200. package/dist/engine/AgentRuntime.d.mts +1 -1
  201. package/dist/engine/AgentRuntime.mjs +1 -1
  202. package/dist/engine/Compaction.d.mts +1 -1
  203. package/dist/engine/Compaction.mjs +1 -1
  204. package/dist/engine/ContextCompactor.d.mts +1 -1
  205. package/dist/engine/ContextCompactor.mjs +8 -3
  206. package/dist/engine/ContextCompactor.mjs.map +1 -1
  207. package/dist/engine/ContextWindow.d.mts +1 -1
  208. package/dist/engine/ContextWindow.mjs +3 -1
  209. package/dist/engine/ContextWindow.mjs.map +1 -1
  210. package/dist/engine/DurableStep.d.mts +1 -1
  211. package/dist/engine/DurableStep.mjs +2 -1
  212. package/dist/engine/DurableStep.mjs.map +1 -1
  213. package/dist/engine/MessagingHost.d.mts +1 -1
  214. package/dist/engine/MessagingHost.mjs +1 -1
  215. package/dist/engine/Output.d.mts +1 -1
  216. package/dist/engine/Output.mjs +1 -1
  217. package/dist/engine/RunEventSink.d.mts +1 -1
  218. package/dist/engine/RunEventSink.mjs +2 -1
  219. package/dist/engine/RunEventSink.mjs.map +1 -1
  220. package/dist/engine/RunOptions.d.mts +1 -1
  221. package/dist/engine/RunOptions.mjs +5 -2
  222. package/dist/engine/RunOptions.mjs.map +1 -1
  223. package/dist/engine/SubagentHost.d.mts +1 -1
  224. package/dist/engine/SubagentHost.mjs +4 -2
  225. package/dist/engine/SubagentHost.mjs.map +1 -1
  226. package/dist/engine/ThreadHistory.d.mts +1 -1
  227. package/dist/engine/ThreadHistory.mjs +12 -10
  228. package/dist/engine/ThreadHistory.mjs.map +1 -1
  229. package/dist/engine/ToolBroker.d.mts +1 -1
  230. package/dist/engine/ToolBroker.mjs +2 -1
  231. package/dist/engine/ToolBroker.mjs.map +1 -1
  232. package/dist/index.d.mts +34 -34
  233. package/dist/index.mjs +9 -9
  234. package/dist/{output-contract-DS-S8mTv.mjs → output-contract-DUNIO6as.mjs} +4 -3
  235. package/dist/output-contract-DUNIO6as.mjs.map +1 -0
  236. package/package.json +1 -1
  237. package/src/InMemory.ts +61 -2
  238. package/src/capabilities/RunHooks.ts +6 -3
  239. package/src/capabilities/SubagentReservations.ts +7 -1
  240. package/src/core/Agent.ts +3 -8
  241. package/src/core/AgentError.ts +1 -1
  242. package/src/core/AgentUpdates.ts +5 -1
  243. package/src/core/FailureDiagnostic.ts +6 -8
  244. package/src/core/IdGenerator.ts +5 -2
  245. package/src/core/Messaging.ts +1 -1
  246. package/src/core/Receipt.ts +1 -1
  247. package/src/core/RunEvent.ts +1 -1
  248. package/src/core/RunPolicyUsage.ts +1 -1
  249. package/src/core/SubagentContract.ts +2 -1
  250. package/src/core/Thread.ts +163 -61
  251. package/src/core/ToolExposure.ts +2 -1
  252. package/src/core/ToolResult.ts +1 -1
  253. package/src/core/Usage.ts +2 -1
  254. package/src/core/Worker.ts +1 -1
  255. package/src/core/internal/agent-updates.ts +3 -2
  256. package/src/core/internal/message-status.ts +1 -1
  257. package/src/core/internal/strict-schema.ts +3 -1
  258. package/src/engine/ContextCompactor.ts +8 -2
  259. package/src/engine/ContextWindow.ts +4 -1
  260. package/src/engine/DurableStep.ts +2 -1
  261. package/src/engine/MessagingHost.ts +2 -1
  262. package/src/engine/RunEventSink.ts +2 -1
  263. package/src/engine/RunOptions.ts +5 -1
  264. package/src/engine/SubagentHost.ts +3 -1
  265. package/src/engine/ThreadHistory.ts +20 -10
  266. package/src/engine/ToolBroker.ts +2 -1
  267. package/src/engine/ToolExposure.ts +2 -1
  268. package/src/engine/internal/agent-runtime.ts +41 -49
  269. package/src/engine/internal/bounded-value.ts +2 -1
  270. package/src/engine/internal/compaction.ts +3 -2
  271. package/src/engine/internal/output-contract.ts +3 -2
  272. package/src/engine/internal/primitive-delta.ts +51 -10
  273. package/src/engine/internal/tool-derivative.ts +5 -1
  274. package/src/engine/internal/tool-exposure.ts +5 -2
  275. package/src/engine/internal/tool-telemetry.ts +12 -13
  276. package/dist/Agent-BMATXYsI.mjs.map +0 -1
  277. package/dist/AgentRuntime-Q50HloUc.mjs.map +0 -1
  278. package/dist/FailureDiagnostic-BElLOoED.mjs.map +0 -1
  279. package/dist/MessagingHost-DfsbMPvq.mjs.map +0 -1
  280. package/dist/Thread-DOBQ0QUY.d.mts +0 -96
  281. package/dist/ToolExposure-9uF_Yo0T.mjs.map +0 -1
  282. package/dist/ToolExposure-C93U1sPu.mjs.map +0 -1
  283. package/dist/Worker-CfwzMZEK.mjs.map +0 -1
  284. package/dist/compaction-BQK4MUg3.mjs.map +0 -1
  285. package/dist/output-contract-DS-S8mTv.mjs.map +0 -1
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
3
- import { a as PinnedTool, n as DiscoveryTool } from "../ToolExposure-C93U1sPu.mjs";
4
- import { t as CurrentToolCatalog } from "../ToolExposure-9uF_Yo0T.mjs";
3
+ import { a as PinnedTool, n as DiscoveryTool } from "../ToolExposure-hTJT2ekj.mjs";
4
+ import { t as CurrentToolCatalog } from "../ToolExposure-DBATXxmL.mjs";
5
5
  import { ToolExecutionClass } from "../engine/DurableStep.mjs";
6
- import { Tool, Toolkit } from "effect/unstable/ai";
7
6
  import { Effect, Schema } from "effect";
7
+ import { Tool, Toolkit } from "effect/unstable/ai";
8
8
  //#region src/capabilities/ToolDiscovery.ts
9
9
  var ToolDiscovery_exports = /* @__PURE__ */ __exportAll({
10
10
  Descriptor: () => Descriptor,
@@ -1,6 +1,6 @@
1
1
  import { L as PageScrapeGroup, S as PageCaptureResponseFormat, l as PageCaptureEngine, o as PageCapture } from "../PageCapture-Df8Xwskw.mjs";
2
- import { Tool } from "effect/unstable/ai";
3
2
  import { Layer, Schema } from "effect";
3
+ import { Tool } from "effect/unstable/ai";
4
4
  declare namespace WebCapture_d_exports {
5
5
  export { WebCaptureAction, WebCaptureDefinition, WebCaptureExtractDefinition, WebCaptureExtractLayerRequirements, WebCaptureExtractOptions, WebCaptureExtractParameters, WebCaptureExtractTool, WebCaptureExtractTools, WebCaptureFailure, WebCaptureOptions, WebCaptureParameters, WebCaptureScrapeDefinition, WebCaptureScrapeOptions, WebCaptureScrapeParameters, WebCaptureScrapeSuccess, WebCaptureScrapeTool, WebCaptureScrapeTools, WebCaptureSuccess, WebCaptureTool, WebCaptureTools, make, makeExtract, makeScrape };
6
6
  }
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { ToolExecutionClass } from "../engine/DurableStep.mjs";
3
3
  import { CapturePageContent, CapturePageLinks, CapturePageMarkdown, CapturePageScrape, CapturePageStructured, PageCapture, PageCaptureLimits, PageCaptureRequest, PageCaptureResponseFormat, PageResourcePolicy, PageScrapeCaptured, PageUrlTarget } from "../sandbox/PageCapture.mjs";
4
- import { Tool, Toolkit } from "effect/unstable/ai";
5
4
  import { Effect, Option, Schema } from "effect";
5
+ import { Tool, Toolkit } from "effect/unstable/ai";
6
6
  //#region src/capabilities/WebCapture.ts
7
7
  var WebCapture_exports = /* @__PURE__ */ __exportAll({
8
8
  WebCaptureAction: () => WebCaptureAction,
@@ -1,5 +1,5 @@
1
- import { LanguageModel, Tool, Toolkit } from "effect/unstable/ai";
2
1
  import { Schema } from "effect";
2
+ import { LanguageModel, Tool, Toolkit } from "effect/unstable/ai";
3
3
  declare namespace WebSearch_d_exports {
4
4
  export { Failure, Options, Parameters, Result, Source, layer, native, tool, toolkit };
5
5
  }
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
3
3
  import { ToolExecutionClass } from "../engine/DurableStep.mjs";
4
- import { LanguageModel, Tool, Toolkit } from "effect/unstable/ai";
5
4
  import { Effect, Option, Schema } from "effect";
5
+ import { LanguageModel, Tool, Toolkit } from "effect/unstable/ai";
6
6
  //#region src/capabilities/WebSearch.ts
7
7
  var WebSearch_exports = /* @__PURE__ */ __exportAll({
8
8
  Failure: () => Failure,
@@ -1,5 +1,6 @@
1
- import { Prompt } from "effect/unstable/ai";
2
- import { Option, Schema } from "effect";
1
+ import * as Schema from "effect/Schema";
2
+ import * as Option from "effect/Option";
3
+ import * as Prompt from "effect/unstable/ai/Prompt";
3
4
  //#region src/engine/internal/provider-result-staging.ts
4
5
  const MAX_JSON_DEPTH = 128;
5
6
  const FailedSnapshot = Symbol("@effect-agent/engine/FailedProviderResultSnapshot");
@@ -502,4 +503,4 @@ const renderForSummary = (covered, previousSummary) => {
502
503
  //#endregion
503
504
  export { initialCompactionState as _, SUMMARY_REQUEST_PREFIX as a, boundedCanonicalJsonSnapshot as b, buildRolloverHandoff as c, collectCoveredMessages as d, contextWindowId as f, evaluateMessageTokenEstimates as g, estimatePromptTokens as h, SUMMARY_MAX_LENGTH as i, choosePruneBound as l, estimateMessageTokens as m, COMPACTION_SUMMARY_PREFIX as n, SUMMARY_REQUEST_SUFFIX as o, contextWindowMessage as p, CONTEXT_ROLLOVER_PREFIX as r, buildCompactedView as s, CLEARED_TOOL_RESULT as t, chooseSummarizeCut as u, isContextOverflowMessage as v, boundedJsonSnapshot as x, renderForSummary as y };
504
505
 
505
- //# sourceMappingURL=compaction-BQK4MUg3.mjs.map
506
+ //# sourceMappingURL=compaction-FDJhjbzH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction-FDJhjbzH.mjs","names":[],"sources":["../src/engine/internal/provider-result-staging.ts","../src/engine/internal/compaction.ts"],"sourcesContent":["import type { Schema } from \"effect\";\n\nconst MAX_JSON_DEPTH = 128;\n\nexport interface BoundedJsonSnapshot {\n readonly value: Schema.Json;\n readonly bytes: number;\n}\n\nconst FailedSnapshot = Symbol(\"@effect-agent/engine/FailedProviderResultSnapshot\");\n\n/**\n * @internal Normalize one untrusted JSON value into an owned, frozen snapshot while counting the\n * exact UTF-8 bytes of that same snapshot. The traversal never invokes `toJSON` or accessors,\n * rejects non-plain objects and excessive nesting, and stops as soon as the byte budget is spent.\n */\nconst snapshotJson = (\n root: unknown,\n maxBytes: number,\n maxDepth: number,\n rejectNonFiniteNumbers: boolean,\n): BoundedJsonSnapshot | undefined => {\n if (\n !Number.isSafeInteger(maxBytes) ||\n maxBytes < 0 ||\n !Number.isSafeInteger(maxDepth) ||\n maxDepth < 0\n ) {\n return undefined;\n }\n let total = 0;\n const ancestors = new WeakSet<object>();\n\n const add = (bytes: number): boolean => {\n if (bytes > maxBytes - total) return false;\n total += bytes;\n\n return true;\n };\n\n const addString = (value: string): boolean => {\n if (!add(2)) return false;\n for (let index = 0; index < value.length; index += 1) {\n const code = value.charCodeAt(index);\n\n if (code === 0x22 || code === 0x5c) {\n if (!add(2)) return false;\n } else if (code <= 0x1f) {\n // Backspace, tab, newline, form-feed, and carriage-return use two-byte escapes; all other\n // control characters use a six-byte `\\\\u00xx` escape.\n if (!add(code >= 0x08 && code <= 0x0d && code !== 0x0b ? 2 : 6)) return false;\n } else if (code <= 0x7f) {\n if (!add(1)) return false;\n } else if (code <= 0x7ff) {\n if (!add(2)) return false;\n } else if (code >= 0xd800 && code <= 0xdbff) {\n const low = value.charCodeAt(index + 1);\n\n if (low >= 0xdc00 && low <= 0xdfff) {\n if (!add(4)) return false;\n index += 1;\n } else if (!add(6)) {\n return false;\n }\n } else if (code >= 0xdc00 && code <= 0xdfff) {\n if (!add(6)) return false;\n } else if (!add(3)) {\n return false;\n }\n }\n\n return true;\n };\n\n const visit = (value: unknown, depth: number): Schema.Json | typeof FailedSnapshot => {\n if (depth > maxDepth) return FailedSnapshot;\n if (value === null) return add(4) ? null : FailedSnapshot;\n switch (typeof value) {\n case \"string\":\n return addString(value) ? value : FailedSnapshot;\n case \"boolean\":\n return add(value ? 4 : 5) ? value : FailedSnapshot;\n case \"number\": {\n // JSON's numeric representation is inherently bounded for one IEEE-754 value. Retain the\n // wire-equivalent null for non-finite values so counting and later serialization agree.\n if (!Number.isFinite(value)) {\n return rejectNonFiniteNumbers ? FailedSnapshot : add(4) ? null : FailedSnapshot;\n }\n const encoded = JSON.stringify(value);\n\n return encoded !== undefined && add(encoded.length) ? value : FailedSnapshot;\n }\n case \"object\": {\n if (ancestors.has(value)) return FailedSnapshot;\n const isArray = Array.isArray(value);\n const prototype = Object.getPrototypeOf(value);\n\n if (prototype !== (isArray ? Array.prototype : Object.prototype) && prototype !== null) {\n return FailedSnapshot;\n }\n if (\n Object.getOwnPropertyDescriptor(value, \"toJSON\") !== undefined ||\n (prototype !== null && Object.getOwnPropertyDescriptor(prototype, \"toJSON\") !== undefined)\n ) {\n return FailedSnapshot;\n }\n ancestors.add(value);\n try {\n if (isArray) {\n const lengthDescriptor = Object.getOwnPropertyDescriptor(value, \"length\");\n\n if (\n lengthDescriptor === undefined ||\n !(\"value\" in lengthDescriptor) ||\n typeof lengthDescriptor.value !== \"number\" ||\n !Number.isSafeInteger(lengthDescriptor.value) ||\n lengthDescriptor.value < 0\n ) {\n return FailedSnapshot;\n }\n if (!add(1)) return FailedSnapshot;\n const snapshot: Array<Schema.Json> = [];\n\n for (let index = 0; index < lengthDescriptor.value; index += 1) {\n if (index > 0 && !add(1)) return FailedSnapshot;\n const descriptor = Object.getOwnPropertyDescriptor(value, index);\n\n if (descriptor === undefined) {\n if (!add(4)) return FailedSnapshot;\n snapshot.push(null);\n continue;\n }\n if (!(\"value\" in descriptor)) return FailedSnapshot;\n const item = visit(descriptor.value, depth + 1);\n\n if (item === FailedSnapshot) return FailedSnapshot;\n snapshot.push(item);\n }\n if (!add(1)) return FailedSnapshot;\n Object.setPrototypeOf(snapshot, null);\n\n return Object.freeze(snapshot);\n }\n if (!add(1)) return FailedSnapshot;\n const entries: Array<readonly [string, Schema.Json]> = [];\n let first = true;\n\n for (const key in value) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n\n if (descriptor === undefined || !descriptor.enumerable) continue;\n if (!(\"value\" in descriptor)) return FailedSnapshot;\n if (!first && !add(1)) return FailedSnapshot;\n first = false;\n if (!addString(key) || !add(1)) return FailedSnapshot;\n const item = visit(descriptor.value, depth + 1);\n\n if (item === FailedSnapshot) return FailedSnapshot;\n entries.push([key, item]);\n }\n if (!add(1)) return FailedSnapshot;\n const snapshot: Record<string, Schema.Json> = Object.fromEntries(entries);\n\n Object.setPrototypeOf(snapshot, null);\n\n return Object.freeze(snapshot);\n } finally {\n ancestors.delete(value);\n }\n }\n case \"bigint\":\n case \"function\":\n case \"symbol\":\n case \"undefined\":\n return FailedSnapshot;\n }\n\n return FailedSnapshot;\n };\n\n try {\n const value = visit(root, 0);\n\n return value === FailedSnapshot ? undefined : { value, bytes: total };\n } catch {\n // Revoked or adversarial proxies and reflection failures are protocol-invalid, never trusted.\n return undefined;\n }\n};\n\n/**\n * Normalize provider-owned JSON using JSON serialization's `NaN`/infinity to\n * `null` behavior. Provider events use this form so byte accounting matches\n * their eventual JSON representation.\n */\nexport const boundedJsonSnapshot = (\n root: unknown,\n maxBytes: number,\n maxDepth = MAX_JSON_DEPTH,\n): BoundedJsonSnapshot | undefined => snapshotJson(root, maxBytes, maxDepth, false);\n\n/**\n * Validate canonical JSON without repairing non-finite numbers. Recovery\n * inputs use this form because changing a recorded value would fabricate\n * history.\n */\nexport const boundedCanonicalJsonSnapshot = (\n root: unknown,\n maxBytes: number,\n maxDepth = MAX_JSON_DEPTH,\n): BoundedJsonSnapshot | undefined => snapshotJson(root, maxBytes, maxDepth, true);\n","import * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport * as Prompt from \"effect/unstable/ai/Prompt\";\n\nimport type { ContextMessageTokenEstimator } from \"../ContextCompactor.ts\";\nimport { boundedCanonicalJsonSnapshot } from \"./provider-result-staging.ts\";\n\n/**\n * Pure helpers for engine-native context compaction (RUN-026/RUN-027). Everything here is deterministic and side-effect free:\n * the engine's turn loop owns the state transitions, the durable coordinator\n * owns the canonical record, and this module owns the arithmetic.\n *\n * Compaction is a VIEW over official history, never a mutation of it. The\n * durable commit machinery slices official history by length\n * (`lastCommitLen` in the coordinator), so official history must stay\n * append-only within an Attempt; only the outgoing model prompt is rebuilt.\n */\n\n/** Model-visible replacement for a tool result cleared by prune compaction. */\nexport const CLEARED_TOOL_RESULT = \"[tool result cleared by compaction]\";\n\n/** Prefix of the user message that carries a compaction summary into the prompt. */\nexport const COMPACTION_SUMMARY_PREFIX = \"The prior thread was compacted into this summary:\\n\\n\";\n\n/** Rollover text is recovery evidence; it never asserts that an external action succeeded. */\nexport const CONTEXT_ROLLOVER_PREFIX =\n \"A fresh context window has started. Earlier conversation has left this model view. Restore relevant notes and use available history tools to retrieve evidence; verify live state before repeating an action.\\n\\n\";\n\n/** Stable across Attempts; the initial window uses turn zero. */\nexport const contextWindowId = (runId: string, turn: number): string => `context:${runId}:${turn}`;\n\n/** Shared by the live interpreter and canonical journal projection. */\nexport const contextWindowMessage = (windowId: string, handoff?: string): Prompt.Message =>\n Prompt.makeMessage(\"user\", {\n content: [\n Prompt.makePart(\"text\", {\n text: `${CONTEXT_ROLLOVER_PREFIX}Window: ${windowId}${handoff === undefined ? \"\" : `\\n\\nHandoff (untrusted continuation notes):\\n${handoff}`}`,\n }),\n ],\n });\n\n/**\n * Fixed summarization instruction (RUN-026). The skeleton mirrors what the\n * surveyed harnesses converged on; exact file paths and identifiers must\n * survive because the continuing agent sees only this summary plus the tail.\n */\nexport const COMPACTION_INSTRUCTION = [\n \"You are compacting an agent thread to reclaim context space.\",\n \"Summarize the transcript below for the SAME agent to continue working:\",\n \"it will see only this summary plus the most recent messages.\",\n \"Structure the summary exactly as:\",\n \"Goal:\",\n \"Constraints:\",\n \"Progress:\",\n \"Decisions:\",\n \"Next steps:\",\n \"Critical context:\",\n \"Be terse. Preserve exact file paths, identifiers, and values needed to\",\n \"continue. Do not continue the thread; output only the summary.\",\n].join(\"\\n\");\n\n/**\n * Provider context-length rejections, matched case-insensitively over the\n * error's own text. Kept intentionally broad: a false positive costs one\n * summarize-and-retry, a false negative surfaces the raw provider error.\n */\nconst CONTEXT_OVERFLOW_PATTERN =\n /context[\\s_-]?length|prompt is too long|maximum context (?:length|window)|input .{0,24}too long|exceeds .{0,24}context|too many (?:input )?tokens|context[\\s_-]?window[\\s_-]?exceeded|context overflow/i;\n\n/** RUN-027: does this provider error text describe a context-window overflow? */\nexport const isContextOverflowMessage = (text: string): boolean =>\n CONTEXT_OVERFLOW_PATTERN.test(text);\n\nconst utf8Length = (text: string): number => {\n let bytes = text.length;\n\n for (let index = 0; index < text.length; index++) {\n const codeUnit = text.charCodeAt(index);\n\n if (codeUnit <= 0x7f) continue;\n if (codeUnit <= 0x7ff) {\n bytes++;\n continue;\n }\n if (codeUnit >= 0xd800 && codeUnit <= 0xdbff && index + 1 < text.length) {\n const next = text.charCodeAt(index + 1);\n\n if (next >= 0xdc00 && next <= 0xdfff) {\n // The two UTF-16 code units already contributed two of the four UTF-8 bytes.\n bytes += 2;\n index++;\n continue;\n }\n }\n bytes += 2;\n }\n\n return bytes;\n};\n\n/**\n * Deterministic UTF-8 bytes/4 token estimate over one message's structural JSON.\n * Conservative for prose, slightly generous for dense JSON — the estimate\n * only gates WHEN to compact, never what is preserved.\n */\nexport const estimateMessageTokens = (message: Prompt.Message): number => {\n let text: string | undefined;\n\n try {\n text = JSON.stringify(message);\n } catch {\n text = undefined;\n }\n\n return text === undefined ? 0 : Math.ceil(utf8Length(text) / 4);\n};\n\n/** Sum of `estimateMessageTokens` over a message array. */\nexport const estimatePromptTokens = (\n messages: ReadonlyArray<Prompt.Message>,\n estimate: (message: Prompt.Message) => number = estimateMessageTokens,\n): number => {\n let total = 0;\n\n for (const message of messages) {\n total += estimate(message);\n }\n\n return total;\n};\n\nconst isTokenEstimate = Schema.is(Schema.Natural);\n\n/** Validate each replacement at the Effect caller's boundary without throwing from arithmetic. */\nexport const evaluateMessageTokenEstimates = <A>(\n override: ContextMessageTokenEstimator | undefined,\n operation: (estimate: (message: Prompt.Message) => number) => A,\n): Option.Option<A> => {\n let valid = true;\n\n const value = operation((message) => {\n const replacement = override?.(message);\n const estimate = replacement === undefined ? estimateMessageTokens(message) : replacement;\n\n if (!isTokenEstimate(estimate)) valid = false;\n\n return estimate;\n });\n\n return valid ? Option.some(value) : Option.none();\n};\n\n/**\n * Mutable per-Run compaction state held on the engine's RunContext. Indices\n * are positions in the SOURCE prompt (the official-history basis handed to\n * each Turn). Ordinary history grows append-only. Prepared history must retain\n * content-equivalent covered prefixes or the engine rejects the next Turn.\n */\nexport interface ContextCompactionState {\n /**\n * Source-index bounds `[start, end)` of the protected instruction/input\n * block, mapped to prepared indices when necessary. `-1` before mapping;\n * an unmappable protected block fails before any compaction decision.\n */\n protectedStart: number;\n protectedEnd: number;\n /** Prepared prompts also retain application-added system instructions. */\n protectSystemMessages?: boolean;\n /** Tool messages at source index below this bound render as cleared. */\n clearedThrough: number;\n /**\n * Source messages below this bound (outside the protected block) are\n * replaced by a summary or a fresh-window marker. Absent before the first replacement.\n */\n replacement:\n | { readonly kind: \"summarize\"; readonly through: number; readonly summary: string }\n | {\n readonly kind: \"rollover\";\n readonly through: number;\n readonly windowId: string;\n readonly handoff?: string;\n }\n | undefined;\n /** Loop guard: at most one threshold compaction per Turn. */\n lastCompactionTurn: number;\n /** RUN-027 guard: at most one overflow compact-and-retry per Turn. */\n overflowRetryTurn: number;\n /**\n * View length at the last model call, the base of the provider-anchored\n * estimate. `-1` invalidates it (fresh Run or just compacted), forcing a\n * full-view estimate.\n */\n lastViewLength: number;\n}\n\n/** Fresh compaction state for a new Run. */\nexport const initialCompactionState = (): ContextCompactionState => ({\n protectedStart: -1,\n protectedEnd: -1,\n clearedThrough: 0,\n replacement: undefined,\n lastCompactionTurn: 0,\n overflowRetryTurn: 0,\n lastViewLength: -1,\n});\n\nconst isProtected = (\n state: ContextCompactionState,\n source: ReadonlyArray<Prompt.Message>,\n index: number,\n): boolean => {\n if (state.protectSystemMessages && source[index]?.role === \"system\") return true;\n if (state.protectedStart >= 0) {\n return index >= state.protectedStart && index < state.protectedEnd;\n }\n\n return source[index]?.role === \"system\";\n};\n\nconst clearedToolMessage = (message: Prompt.Message): Prompt.Message => {\n if (message.role !== \"tool\" || typeof message.content === \"string\") {\n return message;\n }\n\n // Structural rebuild keeps the message's pairing identity (same part ids\n // and names) while replacing only the result payloads the model would see.\n return Prompt.makeMessage(\"tool\", {\n content: message.content.map((part) =>\n part.type === \"tool-result\"\n ? Prompt.makePart(\"tool-result\", {\n id: part.id,\n name: part.name,\n result: CLEARED_TOOL_RESULT,\n isFailure: part.isFailure,\n providerExecuted: part.providerExecuted,\n })\n : part,\n ),\n });\n};\n\nconst renderMessage = (\n state: ContextCompactionState,\n message: Prompt.Message,\n index: number,\n): Prompt.Message =>\n index < state.clearedThrough && message.role === \"tool\" ? clearedToolMessage(message) : message;\n\nconst summaryMessage = (summary: string): Prompt.Message =>\n Prompt.makeMessage(\"user\", {\n content: [Prompt.makePart(\"text\", { text: `${COMPACTION_SUMMARY_PREFIX}${summary}` })],\n });\n\n/**\n * Build the model-visible view of the source prompt under the current\n * compaction state: protected block in place, covered span replaced by the\n * summary message, old tool results cleared. Identity when no compaction has\n * happened.\n */\nexport const buildCompactedView = (\n source: ReadonlyArray<Prompt.Message>,\n state: ContextCompactionState,\n): ReadonlyArray<Prompt.Message> => {\n if (state.replacement === undefined && state.clearedThrough === 0) {\n return source;\n }\n const view: Array<Prompt.Message> = [];\n\n if (state.replacement !== undefined && state.replacement.through > 0) {\n const protectedStart =\n state.protectedStart >= 0 && !state.protectSystemMessages ? state.protectedStart : 0;\n\n const protectedEnd =\n state.protectedStart >= 0 && !state.protectSystemMessages\n ? state.protectedEnd\n : (state.replacement?.through ?? 0);\n\n for (\n let index = protectedStart;\n index < Math.min(protectedEnd, state.replacement?.through ?? 0, source.length);\n index += 1\n ) {\n const message = source[index];\n\n if (message !== undefined && isProtected(state, source, index)) {\n view.push(renderMessage(state, message, index));\n }\n }\n view.push(\n state.replacement.kind === \"summarize\"\n ? summaryMessage(state.replacement.summary)\n : contextWindowMessage(state.replacement.windowId, state.replacement.handoff),\n );\n for (let index = state.replacement?.through ?? 0; index < source.length; index += 1) {\n const message = source[index];\n\n if (message !== undefined) {\n view.push(renderMessage(state, message, index));\n }\n }\n\n return view;\n }\n for (let index = 0; index < source.length; index += 1) {\n const message = source[index];\n\n if (message !== undefined) {\n view.push(renderMessage(state, message, index));\n }\n }\n\n return view;\n};\n\n/**\n * Prune selection: the new `clearedThrough` bound. Walks tool messages\n * newest→oldest, always protecting the most recent tool message (the model\n * has not reacted to it yet), then protecting older ones while their\n * estimates fit inside `keepRecentTokens`. If the whole view exceeds `targetTokens`,\n * clear more older results until it fits or only the newest result remains.\n * Replaced messages consume no retention budget. Never decreases the bound.\n */\nexport const choosePruneBound = (\n source: ReadonlyArray<Prompt.Message>,\n state: ContextCompactionState,\n keepRecentTokens: number,\n targetTokens?: number,\n estimate: (message: Prompt.Message) => number = estimateMessageTokens,\n): number => {\n const toolIndices: Array<number> = [];\n\n for (let index = 0; index < source.length; index += 1) {\n if (\n index >= (state.replacement?.through ?? 0) &&\n source[index]?.role === \"tool\" &&\n !isProtected(state, source, index)\n ) {\n toolIndices.push(index);\n }\n }\n if (toolIndices.length <= 1) {\n return state.clearedThrough;\n }\n let budget = keepRecentTokens;\n let newestCleared = -1;\n\n for (let position = toolIndices.length - 1; position >= 0; position -= 1) {\n const index = toolIndices[position];\n\n if (index === undefined) continue;\n const message = source[index];\n\n if (message === undefined) continue;\n if (position === toolIndices.length - 1) {\n budget -= estimate(message);\n continue;\n }\n const cost = estimate(message);\n\n if (budget - cost >= 0 && index >= state.clearedThrough) {\n budget -= cost;\n continue;\n }\n newestCleared = index;\n break;\n }\n\n let through =\n newestCleared === -1 ? state.clearedThrough : Math.max(state.clearedThrough, newestCleared + 1);\n\n if (targetTokens === undefined) return through;\n\n let estimated = estimatePromptTokens(\n buildCompactedView(source, { ...state, clearedThrough: through }),\n estimate,\n );\n\n for (\n let position = 0;\n position < toolIndices.length - 1 && estimated > targetTokens;\n position += 1\n ) {\n const index = toolIndices[position];\n\n if (index === undefined || index < through) continue;\n const message = source[index];\n\n if (message === undefined) continue;\n through = index + 1;\n estimated -= estimate(message) - estimate(clearedToolMessage(message));\n }\n\n return through;\n};\n\n/**\n * Summarize selection: the source cut index `C` — messages `[0, C)` outside\n * the protected block fold into the summary; `[C, …)` is the kept tail.\n * Walks newest→oldest accumulating view estimates until `keepRecentTokens`\n * is retained, then moves the cut down to keep leading user/system messages\n * with their assistant response and tool results with their declaring assistant.\n */\nexport const chooseSummarizeCut = (\n source: ReadonlyArray<Prompt.Message>,\n state: ContextCompactionState,\n keepRecentTokens: number,\n estimate: (message: Prompt.Message) => number = estimateMessageTokens,\n): number => {\n let kept = 0;\n let cut = 0;\n\n for (let index = source.length - 1; index >= 0; index -= 1) {\n const message = source[index];\n\n if (message === undefined) continue;\n kept += estimate(renderMessage(state, message, index));\n if (kept >= keepRecentTokens) {\n cut = index;\n break;\n }\n }\n // Durable responses commit pending input and the assistant reply together.\n while (\n cut > 0 &&\n (source[cut]?.role === \"tool\" ||\n source[cut - 1]?.role === \"user\" ||\n source[cut - 1]?.role === \"system\")\n ) {\n cut -= 1;\n }\n\n return Math.max(cut, state.replacement?.through ?? 0);\n};\n\n/**\n * The messages a cut NEWLY covers — from the prior replacement boundary to the\n * cut, protected block excluded, in order. Starting at the replacement boundary\n * keeps repeated compactions incremental: the previously covered span lives\n * on only through the previous summary, never as resubmitted raw history.\n */\nexport const collectCoveredMessages = (\n source: ReadonlyArray<Prompt.Message>,\n state: ContextCompactionState,\n cut: number,\n): ReadonlyArray<Prompt.Message> => {\n const covered: Array<Prompt.Message> = [];\n\n for (\n let index = Math.max(0, state.replacement?.through ?? 0);\n index < cut && index < source.length;\n index += 1\n ) {\n const message = source[index];\n\n if (message !== undefined && !isProtected(state, source, index)) {\n covered.push(message);\n }\n }\n\n return covered;\n};\n\nconst SUMMARY_TOOL_RESULT_CLIP = 2_000;\n\nconst jsonPreview = (value: unknown, limit: number): string => {\n if (typeof value === \"string\") return JSON.stringify(value.slice(0, limit)).slice(0, limit);\n const snapshot = boundedCanonicalJsonSnapshot(value, limit);\n\n return snapshot === undefined\n ? \"[omitted oversized or unsupported JSON]\"\n : JSON.stringify(snapshot.value);\n};\n\nconst partText = (part: Prompt.Message[\"content\"][number] | string): string => {\n if (typeof part === \"string\") return part;\n switch (part.type) {\n case \"text\": {\n return part.text;\n }\n case \"reasoning\": {\n return \"\";\n }\n case \"tool-call\": {\n return `[tool call ${part.name.slice(0, 500)} ${jsonPreview(part.params, 500)}]`;\n }\n case \"tool-result\": {\n return `[tool result ${part.name.slice(0, 500)}: ${jsonPreview(part.result, SUMMARY_TOOL_RESULT_CLIP)}]`;\n }\n default: {\n return `[${part.type}]`;\n }\n }\n};\n\n/**\n * Character budget for the complete default summarizer request, including\n * its instruction, transcript delimiters, previous summary, and elision marker.\n */\nexport const SUMMARY_INPUT_BUDGET = 80_000;\nexport const SUMMARY_MAX_LENGTH = 65_536;\nexport const SUMMARY_REQUEST_PREFIX = `${COMPACTION_INSTRUCTION}\\n\\n<transcript>\\n`;\nexport const SUMMARY_REQUEST_SUFFIX = \"\\n</transcript>\";\n\nconst SUMMARY_MESSAGE_CLIP = 2_000;\nconst SUMMARY_ELISION_RESERVE = 128;\n\nconst summaryBlock = (message: Prompt.Message): string => {\n let text = \"\";\n\n if (typeof message.content === \"string\") {\n text = message.content.slice(0, SUMMARY_MESSAGE_CLIP + 1);\n } else {\n for (const part of message.content) {\n const piece = partText(part);\n\n if (piece.length === 0) continue;\n if (text.length > 0) text += \"\\n\";\n text += piece.slice(0, SUMMARY_MESSAGE_CLIP + 1 - text.length);\n if (text.length > SUMMARY_MESSAGE_CLIP) break;\n }\n }\n if (text.length === 0) return \"\";\n\n return `[${message.role}]\\n${text.length > SUMMARY_MESSAGE_CLIP ? `${text.slice(0, SUMMARY_MESSAGE_CLIP)}…` : text}`;\n};\n\n/**\n * Deterministic emergency input record, not a progress summary. Keep recent user inputs and\n * the last, as-yet-unconsumed Tool batch. Clip before rendering large payloads, identify Tool\n * calls for archive lookup, and never recursively copy earlier recovery records.\n */\nexport const buildRolloverHandoff = (\n source: ReadonlyArray<Prompt.Message>,\n state: ContextCompactionState,\n targetTokens: number | undefined,\n through = source.length,\n estimate: (message: Prompt.Message) => number = estimateMessageTokens,\n): string | undefined => {\n const protectedTokens = estimatePromptTokens(\n source.filter((_, index) => index >= through || isProtected(state, source, index)),\n estimate,\n );\n\n const maxChars = Math.min(\n 5_000,\n Math.max(0, Math.floor(((targetTokens ?? 10_000) - protectedTokens - 200) * 2)),\n );\n\n if (maxChars < 160) return undefined;\n const blocks: Array<string> = [];\n let length = 0;\n const start = state.replacement?.through ?? 0;\n\n const lastTool = source.findLastIndex(\n (message, index) => index < through && message.role === \"tool\",\n );\n\n const unconsumed =\n lastTool >= start &&\n !source.slice(lastTool + 1, through).some((message) => message.role === \"assistant\");\n\n let lastAssistant = lastTool;\n\n while (lastAssistant >= start && source[lastAssistant]?.role !== \"assistant\") lastAssistant -= 1;\n for (let index = through - 1; index >= start; index -= 1) {\n const message = source[index];\n\n if (message === undefined || isProtected(state, source, index)) continue;\n const isUnconsumedBatch = unconsumed && index >= lastAssistant && index <= lastTool;\n\n if (message.role !== \"user\" && !isUnconsumedBatch) continue;\n // A projected boundary from a previous Attempt is already a derived handoff.\n if (\n message.role === \"user\" &&\n message.content.some(\n (part) => part.type === \"text\" && part.text.startsWith(CONTEXT_ROLLOVER_PREFIX),\n )\n )\n continue;\n let block = summaryBlock(message);\n\n if (isUnconsumedBatch && typeof message.content !== \"string\") {\n const ids = message.content\n .flatMap((part) =>\n part.type === \"tool-call\" || part.type === \"tool-result\" ? [part.id.slice(0, 256)] : [],\n )\n .slice(0, 16);\n\n block = `[Unconsumed batch; history search call IDs: ${ids.join(\", \")}]\\n${block}`;\n }\n const remaining = maxChars - length - 120;\n\n if (remaining <= 0) break;\n const selected = block.slice(0, Math.min(2_500, remaining));\n\n blocks.unshift(selected);\n length += selected.length + 2;\n if (selected.length < block.length) break;\n }\n\n return `Recovery excerpts, not verified progress. Content may be omitted; use notes and history.\\n\\n${blocks.join(\"\\n\\n\")}`.slice(\n 0,\n maxChars,\n );\n};\n\n/**\n * Render the covered span as plain text for the summarizer call, bounded\n * twice: every message's rendered text is clipped to a fixed length (tool\n * results additionally clip their JSON payloads), and the whole render obeys\n * `SUMMARY_INPUT_BUDGET` with middle-out retention — oldest and newest\n * blocks survive, the middle collapses into one deterministic elision\n * marker. A previous summary is folded in first so nothing silently drops\n * out of coverage across repeated compactions. An oversized previous summary\n * returns undefined before rendering: callers must reject it, never truncate it.\n */\nexport const renderForSummary = (\n covered: ReadonlyArray<Prompt.Message>,\n previousSummary: string | undefined,\n): string | undefined => {\n if (previousSummary !== undefined && previousSummary.length > SUMMARY_MAX_LENGTH)\n return undefined;\n const joiner = \"\\n\\n\";\n\n const previousBlock =\n previousSummary === undefined ? undefined : `[Previous summary]\\n${previousSummary}`;\n\n const fixed =\n (previousBlock === undefined ? 0 : previousBlock.length + joiner.length) +\n SUMMARY_REQUEST_PREFIX.length +\n SUMMARY_REQUEST_SUFFIX.length;\n\n const budget = SUMMARY_INPUT_BUDGET - fixed - SUMMARY_ELISION_RESERVE;\n const head: Array<string> = [];\n const tail: Array<string> = [];\n let length = 0;\n let start = 0;\n let end = covered.length - 1;\n let boundaryBlock: string | undefined;\n\n while (start <= end) {\n const message = covered[start];\n const block = message === undefined ? \"\" : summaryBlock(message);\n\n if (block.length > 0 && length + block.length + joiner.length > Math.floor(budget / 2)) {\n boundaryBlock = block;\n break;\n }\n if (block.length > 0) {\n head.push(block);\n length += block.length + joiner.length;\n }\n start += 1;\n }\n while (end >= start) {\n const message = covered[end];\n\n const block =\n end === start && boundaryBlock !== undefined\n ? boundaryBlock\n : message === undefined\n ? \"\"\n : summaryBlock(message);\n\n if (block.length > 0 && length + block.length + joiner.length > budget) break;\n if (block.length > 0) {\n tail.push(block);\n length += block.length + joiner.length;\n }\n end -= 1;\n }\n const omitted = end - start + 1;\n const lines: Array<string> = [];\n\n if (previousBlock !== undefined) {\n lines.push(previousBlock);\n }\n lines.push(...head);\n if (omitted > 0) lines.push(`[… ${omitted} messages omitted from summary input …]`);\n lines.push(...tail.reverse());\n\n return lines.join(joiner);\n};\n"],"mappings":";;;;AAEA,MAAM,iBAAiB;AAOvB,MAAM,iBAAiB,OAAO,mDAAmD;;;;;;AAOjF,MAAM,gBACJ,MACA,UACA,UACA,2BACoC;CACpC,IACE,CAAC,OAAO,cAAc,QAAQ,KAC9B,WAAW,KACX,CAAC,OAAO,cAAc,QAAQ,KAC9B,WAAW,GAEX;CAEF,IAAI,QAAQ;CACZ,MAAM,4BAAY,IAAI,QAAgB;CAEtC,MAAM,OAAO,UAA2B;EACtC,IAAI,QAAQ,WAAW,OAAO,OAAO;EACrC,SAAS;EAET,OAAO;CACT;CAEA,MAAM,aAAa,UAA2B;EAC5C,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO;EACpB,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAAG;GACpD,MAAM,OAAO,MAAM,WAAW,KAAK;GAEnC,IAAI,SAAS,MAAQ,SAAS,IACxB;QAAA,CAAC,IAAI,CAAC,GAAG,OAAO;GAAA,OACf,IAAI,QAAQ,IAGb;QAAA,CAAC,IAAI,QAAQ,KAAQ,QAAQ,MAAQ,SAAS,KAAO,IAAI,CAAC,GAAG,OAAO;GAAA,OACnE,IAAI,QAAQ,KACb;QAAA,CAAC,IAAI,CAAC,GAAG,OAAO;GAAA,OACf,IAAI,QAAQ,MACb;QAAA,CAAC,IAAI,CAAC,GAAG,OAAO;GAAA,OACf,IAAI,QAAQ,SAAU,QAAQ,OAAQ;IAC3C,MAAM,MAAM,MAAM,WAAW,QAAQ,CAAC;IAEtC,IAAI,OAAO,SAAU,OAAO,OAAQ;KAClC,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO;KACpB,SAAS;IACX,OAAO,I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AAkB,KAAA,IAC/B,gBACA,YAAY,KAAA,IACV,KACA,aAAa,OAAO;EAE5B,IAAI,MAAM,SAAS,KAAK,SAAS,MAAM,SAAS,IAAgB,QAAQ;EACxE,IAAI,MAAM,SAAS,GAAG;GACpB,KAAK,KAAK,KAAK;GACf,UAAU,MAAM,SAAS;EAC3B;EACA,OAAO;CACT;CACA,MAAM,UAAU,MAAM,QAAQ;CAC9B,MAAM,QAAuB,CAAC;CAE9B,IAAI,kBAAkB,KAAA,GACpB,MAAM,KAAK,aAAa;CAE1B,MAAM,KAAK,GAAG,IAAI;CAClB,IAAI,UAAU,GAAG,MAAM,KAAK,MAAM,QAAQ,wCAAwC;CAClF,MAAM,KAAK,GAAG,KAAK,QAAQ,CAAC;CAE5B,OAAO,MAAM,KAAK,MAAM;AAC1B"}
@@ -1,2 +1,2 @@
1
- import { A as ToolUnion, C as OutputSchema, D as RunDispositionFailure, E as RunDispositionDeclaration, F as isModelResolver, I as make, L as withModel, M as Update, N as UpdatesSchema, O as RunDispositionSchema, P as inspectTools, S as Output, T as RunDisposition, _ as InstructionSource, a as CompletionFromToolDeclaration, b as Name, c as Definition, d as EncodedInput, f as Failure, g as InstructionResult, h as InputSchema, i as Binding, j as Tools, k as ToolInspection, l as DefinitionOptions, m as InputPromptSource, n as Any, o as CompletionProjectionInput, p as Input, r as AnyDefinition, s as CompletionToolDeclaration, u as DefinitionRequirements, v as ModelResolver, w as Requirements, x as NativeModel, y as ModelServices } from "../Agent-ZfnNCQXs.mjs";
1
+ import { A as ToolUnion, C as OutputSchema, D as RunDispositionFailure, E as RunDispositionDeclaration, F as isModelResolver, I as make, L as withModel, M as Update, N as UpdatesSchema, O as RunDispositionSchema, P as inspectTools, S as Output, T as RunDisposition, _ as InstructionSource, a as CompletionFromToolDeclaration, b as Name, c as Definition, d as EncodedInput, f as Failure, g as InstructionResult, h as InputSchema, i as Binding, j as Tools, k as ToolInspection, l as DefinitionOptions, m as InputPromptSource, n as Any, o as CompletionProjectionInput, p as Input, r as AnyDefinition, s as CompletionToolDeclaration, u as DefinitionRequirements, v as ModelResolver, w as Requirements, x as NativeModel, y as ModelServices } from "../Agent-D0fbFT2d.mjs";
2
2
  export { Any, AnyDefinition, Binding, CompletionFromToolDeclaration, CompletionProjectionInput, CompletionToolDeclaration, Definition, DefinitionOptions, DefinitionRequirements, EncodedInput, Failure, Input, InputPromptSource, InputSchema, InstructionResult, InstructionSource, ModelResolver, ModelServices, Name, NativeModel, Output, OutputSchema, Requirements, RunDisposition, RunDispositionDeclaration, RunDispositionFailure, RunDispositionSchema, ToolInspection, ToolUnion, Tools, Update, UpdatesSchema, inspectTools, isModelResolver, make, withModel };
@@ -1,2 +1,2 @@
1
- import { a as make, i as isModelResolver, n as ToolInspection, o as withModel, r as inspectTools } from "../Agent-BMATXYsI.mjs";
1
+ import { a as make, i as isModelResolver, n as ToolInspection, o as withModel, r as inspectTools } from "../Agent-B0WrUcHy.mjs";
2
2
  export { ToolInspection, inspectTools, isModelResolver, make, withModel };
@@ -1,2 +1,2 @@
1
- import { a as AgentInputError, c as AgentPolicyError, d as AgentToolAuthorizationDenied, f as ContextBudgetError, h as PolicyLimit, l as AgentRunDispositionError, m as ModelProtocolError, n as AgentApprovalPending, o as AgentInterrupted, p as ContextOverflowError, r as AgentError, s as AgentOutputError, t as AgentApprovalDenied, u as AgentToolAuthorizationCheckError } from "../AgentError-Bn1ytXRD.mjs";
1
+ import { a as AgentInputError, c as AgentPolicyError, d as AgentToolAuthorizationDenied, f as ContextBudgetError, h as PolicyLimit, l as AgentRunDispositionError, m as ModelProtocolError, n as AgentApprovalPending, o as AgentInterrupted, p as ContextOverflowError, r as AgentError, s as AgentOutputError, t as AgentApprovalDenied, u as AgentToolAuthorizationCheckError } from "../AgentError-BMqPzIVt.mjs";
2
2
  export { AgentApprovalDenied, AgentApprovalPending, AgentError, AgentInputError, AgentInterrupted, AgentOutputError, AgentPolicyError, AgentRunDispositionError, AgentToolAuthorizationCheckError, AgentToolAuthorizationDenied, ContextBudgetError, ContextOverflowError, ModelProtocolError, PolicyLimit };
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { ToolCallId } from "./Identifiers.mjs";
3
- import { t as Cause$1 } from "../FailureDiagnostic-BElLOoED.mjs";
4
- import { Schema } from "effect";
3
+ import { t as Cause } from "../FailureDiagnostic-D9oW23Cn.mjs";
4
+ import * as Schema from "effect/Schema";
5
5
  //#region src/core/AgentError.ts
6
6
  var AgentError_exports = /* @__PURE__ */ __exportAll({
7
7
  AgentApprovalDenied: () => AgentApprovalDenied,
@@ -63,7 +63,7 @@ var AgentToolAuthorizationDenied = class extends Schema.TaggedError()("AgentTool
63
63
  toolName: Schema.NonEmptyString,
64
64
  message: Schema.String,
65
65
  /** Optional original policy evidence, excluded from model-facing ToolCallFailed data. */
66
- cause: Schema.optionalKey(Cause$1),
66
+ cause: Schema.optionalKey(Cause),
67
67
  stack: Schema.optionalKey(Schema.String)
68
68
  }) {};
69
69
  /** The host could not complete its authority check; this is not a policy denial. */
@@ -74,7 +74,7 @@ var AgentToolAuthorizationCheckError = class extends Schema.TaggedError()("Agent
74
74
  message: Schema.String,
75
75
  check: Schema.optionalKey(Schema.String),
76
76
  callId: Schema.optionalKey(Schema.String),
77
- cause: Cause$1,
77
+ cause: Cause,
78
78
  stack: Schema.optionalKey(Schema.String)
79
79
  }) {};
80
80
  /** A native Effect AI Tool approval has no decision and the ephemeral Run cannot proceed. */
@@ -1 +1 @@
1
- {"version":3,"file":"AgentError.mjs","names":["FailureDiagnostic.Cause"],"sources":["../../src/core/AgentError.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport * as FailureDiagnostic from \"./FailureDiagnostic.ts\";\nimport { ToolCallId } from \"./Identifiers.ts\";\n\n/** Run input failed to decode through the agent definition's input Schema. */\nexport class AgentInputError extends Schema.TaggedError<AgentInputError>()(\"AgentInputError\", {\n message: Schema.String,\n}) {}\n\n/** Final model output failed to decode through the agent definition's output Schema. */\nexport class AgentOutputError extends Schema.TaggedError<AgentOutputError>()(\"AgentOutputError\", {\n message: Schema.String,\n}) {}\n\n/** An application-selected run disposition failed its definition-owned Schema boundary. */\nexport class AgentRunDispositionError extends Schema.TaggedError<AgentRunDispositionError>()(\n \"AgentRunDispositionError\",\n {\n cause: Schema.Defect(),\n message: Schema.String,\n },\n) {}\n\n/** The finite policy dimension a run exhausted; shared with durable settlement metadata. */\nexport const PolicyLimit = Schema.Literals([\n \"turns\",\n \"tool-calls\",\n \"duration\",\n \"usage\",\n \"tokens\",\n \"cost\",\n \"repeated-failures\",\n]);\n\nexport type PolicyLimit = typeof PolicyLimit.Type;\n\n/** A run exhausted one of its finite policy limits. */\nexport class AgentPolicyError extends Schema.TaggedError<AgentPolicyError>()(\"AgentPolicyError\", {\n limit: PolicyLimit,\n message: Schema.String,\n}) {}\n\n/** A native Effect AI Tool approval was explicitly denied before its Handler started. */\nexport class AgentApprovalDenied extends Schema.TaggedError<AgentApprovalDenied>()(\n \"AgentApprovalDenied\",\n {\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n message: Schema.String,\n },\n) {\n /** Decode the native Effect AI Tool Call ID at the core error boundary. */\n static override make(input: {\n readonly toolCallId: string;\n readonly toolName: string;\n readonly message: string;\n }): AgentApprovalDenied {\n return super.make({\n ...input,\n toolCallId: Schema.decodeSync(ToolCallId)(input.toolCallId),\n });\n }\n}\n\n/** A host denied current execution authority for a Tool Call before its Handler started. */\nexport class AgentToolAuthorizationDenied extends Schema.TaggedError<AgentToolAuthorizationDenied>()(\n \"AgentToolAuthorizationDenied\",\n {\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n message: Schema.String,\n /** Optional original policy evidence, excluded from model-facing ToolCallFailed data. */\n cause: Schema.optionalKey(FailureDiagnostic.Cause),\n stack: Schema.optionalKey(Schema.String),\n },\n) {}\n\n/** The host could not complete its authority check; this is not a policy denial. */\nexport class AgentToolAuthorizationCheckError extends Schema.TaggedError<AgentToolAuthorizationCheckError>()(\n \"AgentToolAuthorizationCheckError\",\n {\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n /** Safe summary. The original cause is private diagnostic evidence. */\n message: Schema.String,\n check: Schema.optionalKey(Schema.String),\n callId: Schema.optionalKey(Schema.String),\n cause: FailureDiagnostic.Cause,\n stack: Schema.optionalKey(Schema.String),\n },\n) {}\n\n/** A native Effect AI Tool approval has no decision and the ephemeral Run cannot proceed. */\nexport class AgentApprovalPending extends Schema.TaggedError<AgentApprovalPending>()(\n \"AgentApprovalPending\",\n {\n approvalId: Schema.NonEmptyString,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n message: Schema.String,\n },\n) {\n /** Decode the native Effect AI Tool Call ID at the core error boundary. */\n static override make(input: {\n readonly approvalId: string;\n readonly toolCallId: string;\n readonly toolName: string;\n readonly message: string;\n }): AgentApprovalPending {\n return super.make({\n ...input,\n toolCallId: Schema.decodeSync(ToolCallId)(input.toolCallId),\n });\n }\n}\n\n/** A model response sequence violated an agent-loop protocol invariant. */\nexport class ModelProtocolError extends Schema.TaggedError<ModelProtocolError>()(\n \"ModelProtocolError\",\n {\n message: Schema.String,\n },\n) {}\n\n/** A run was interrupted without manufacturing a successful result. */\nexport class AgentInterrupted extends Schema.TaggedError<AgentInterrupted>()(\"AgentInterrupted\", {\n message: Schema.String,\n}) {}\n\n/**\n * The provider rejected a prompt that exceeds the model context window and\n * compaction recovery is unavailable or was already attempted once. This is\n * an expected failure: the engine classifies the provider error rather than\n * surfacing an opaque transport failure.\n */\nexport class ContextOverflowError extends Schema.TaggedError<ContextOverflowError>()(\n \"ContextOverflowError\",\n {\n message: Schema.String,\n retried: Schema.Boolean,\n },\n) {}\n\n/** Local context preparation could not fit a legal prompt inside its target before provider I/O. */\nexport class ContextBudgetError extends Schema.TaggedError<ContextBudgetError>()(\n \"ContextBudgetError\",\n {\n message: Schema.String,\n estimatedTokens: Schema.Natural,\n targetTokens: Schema.Natural,\n completionReserveTokens: Schema.Natural,\n },\n) {}\n\n/** Schema for framework-owned agent errors; application and Effect AI failures remain separate. */\nexport const AgentError = Schema.Union([\n AgentInputError,\n AgentOutputError,\n AgentRunDispositionError,\n AgentPolicyError,\n AgentApprovalDenied,\n AgentToolAuthorizationDenied,\n AgentToolAuthorizationCheckError,\n AgentApprovalPending,\n ModelProtocolError,\n AgentInterrupted,\n ContextOverflowError,\n ContextBudgetError,\n]);\n\nexport type AgentError = typeof AgentError.Type;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAMA,IAAa,kBAAb,cAAqC,OAAO,YAA6B,CAAC,CAAC,mBAAmB,EAC5F,SAAS,OAAO,OAClB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,mBAAb,cAAsC,OAAO,YAA8B,CAAC,CAAC,oBAAoB,EAC/F,SAAS,OAAO,OAClB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,4BACA;CACE,OAAO,OAAO,OAAO;CACrB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;;AAGH,MAAa,cAAc,OAAO,SAAS;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAKD,IAAa,mBAAb,cAAsC,OAAO,YAA8B,CAAC,CAAC,oBAAoB;CAC/F,OAAO;CACP,SAAS,OAAO;AAClB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,YAAY;CACZ,UAAU,OAAO;CACjB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC;;CAEA,OAAgB,KAAK,OAIG;EACtB,OAAO,MAAM,KAAK;GAChB,GAAG;GACH,YAAY,OAAO,WAAW,UAAU,CAAC,CAAC,MAAM,UAAU;EAC5D,CAAC;CACH;AACF;;AAGA,IAAa,+BAAb,cAAkD,OAAO,YAA0C,CAAC,CAClG,gCACA;CACE,YAAY;CACZ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ACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"AgentError.mjs","names":["FailureDiagnostic.Cause"],"sources":["../../src/core/AgentError.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport * as FailureDiagnostic from \"./FailureDiagnostic.ts\";\nimport { ToolCallId } from \"./Identifiers.ts\";\n\n/** Run input failed to decode through the agent definition's input Schema. */\nexport class AgentInputError extends Schema.TaggedError<AgentInputError>()(\"AgentInputError\", {\n message: Schema.String,\n}) {}\n\n/** Final model output failed to decode through the agent definition's output Schema. */\nexport class AgentOutputError extends Schema.TaggedError<AgentOutputError>()(\"AgentOutputError\", {\n message: Schema.String,\n}) {}\n\n/** An application-selected run disposition failed its definition-owned Schema boundary. */\nexport class AgentRunDispositionError extends Schema.TaggedError<AgentRunDispositionError>()(\n \"AgentRunDispositionError\",\n {\n cause: Schema.Defect(),\n message: Schema.String,\n },\n) {}\n\n/** The finite policy dimension a run exhausted; shared with durable settlement metadata. */\nexport const PolicyLimit = Schema.Literals([\n \"turns\",\n \"tool-calls\",\n \"duration\",\n \"usage\",\n \"tokens\",\n \"cost\",\n \"repeated-failures\",\n]);\n\nexport type PolicyLimit = typeof PolicyLimit.Type;\n\n/** A run exhausted one of its finite policy limits. */\nexport class AgentPolicyError extends Schema.TaggedError<AgentPolicyError>()(\"AgentPolicyError\", {\n limit: PolicyLimit,\n message: Schema.String,\n}) {}\n\n/** A native Effect AI Tool approval was explicitly denied before its Handler started. */\nexport class AgentApprovalDenied extends Schema.TaggedError<AgentApprovalDenied>()(\n \"AgentApprovalDenied\",\n {\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n message: Schema.String,\n },\n) {\n /** Decode the native Effect AI Tool Call ID at the core error boundary. */\n static override make(input: {\n readonly toolCallId: string;\n readonly toolName: string;\n readonly message: string;\n }): AgentApprovalDenied {\n return super.make({\n ...input,\n toolCallId: Schema.decodeSync(ToolCallId)(input.toolCallId),\n });\n }\n}\n\n/** A host denied current execution authority for a Tool Call before its Handler started. */\nexport class AgentToolAuthorizationDenied extends Schema.TaggedError<AgentToolAuthorizationDenied>()(\n \"AgentToolAuthorizationDenied\",\n {\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n message: Schema.String,\n /** Optional original policy evidence, excluded from model-facing ToolCallFailed data. */\n cause: Schema.optionalKey(FailureDiagnostic.Cause),\n stack: Schema.optionalKey(Schema.String),\n },\n) {}\n\n/** The host could not complete its authority check; this is not a policy denial. */\nexport class AgentToolAuthorizationCheckError extends Schema.TaggedError<AgentToolAuthorizationCheckError>()(\n \"AgentToolAuthorizationCheckError\",\n {\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n /** Safe summary. The original cause is private diagnostic evidence. */\n message: Schema.String,\n check: Schema.optionalKey(Schema.String),\n callId: Schema.optionalKey(Schema.String),\n cause: FailureDiagnostic.Cause,\n stack: Schema.optionalKey(Schema.String),\n },\n) {}\n\n/** A native Effect AI Tool approval has no decision and the ephemeral Run cannot proceed. */\nexport class AgentApprovalPending extends Schema.TaggedError<AgentApprovalPending>()(\n \"AgentApprovalPending\",\n {\n approvalId: Schema.NonEmptyString,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n message: Schema.String,\n },\n) {\n /** Decode the native Effect AI Tool Call ID at the core error boundary. */\n static override make(input: {\n readonly approvalId: string;\n readonly toolCallId: string;\n readonly toolName: string;\n readonly message: string;\n }): AgentApprovalPending {\n return super.make({\n ...input,\n toolCallId: Schema.decodeSync(ToolCallId)(input.toolCallId),\n });\n }\n}\n\n/** A model response sequence violated an agent-loop protocol invariant. */\nexport class ModelProtocolError extends Schema.TaggedError<ModelProtocolError>()(\n \"ModelProtocolError\",\n {\n message: Schema.String,\n },\n) {}\n\n/** A run was interrupted without manufacturing a successful result. */\nexport class AgentInterrupted extends Schema.TaggedError<AgentInterrupted>()(\"AgentInterrupted\", {\n message: Schema.String,\n}) {}\n\n/**\n * The provider rejected a prompt that exceeds the model context window and\n * compaction recovery is unavailable or was already attempted once. This is\n * an expected failure: the engine classifies the provider error rather than\n * surfacing an opaque transport failure.\n */\nexport class ContextOverflowError extends Schema.TaggedError<ContextOverflowError>()(\n \"ContextOverflowError\",\n {\n message: Schema.String,\n retried: Schema.Boolean,\n },\n) {}\n\n/** Local context preparation could not fit a legal prompt inside its target before provider I/O. */\nexport class ContextBudgetError extends Schema.TaggedError<ContextBudgetError>()(\n \"ContextBudgetError\",\n {\n message: Schema.String,\n estimatedTokens: Schema.Natural,\n targetTokens: Schema.Natural,\n completionReserveTokens: Schema.Natural,\n },\n) {}\n\n/** Schema for framework-owned agent errors; application and Effect AI failures remain separate. */\nexport const AgentError = Schema.Union([\n AgentInputError,\n AgentOutputError,\n AgentRunDispositionError,\n AgentPolicyError,\n AgentApprovalDenied,\n AgentToolAuthorizationDenied,\n AgentToolAuthorizationCheckError,\n AgentApprovalPending,\n ModelProtocolError,\n AgentInterrupted,\n ContextOverflowError,\n ContextBudgetError,\n]);\n\nexport type AgentError = typeof AgentError.Type;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAMA,IAAa,kBAAb,cAAqC,OAAO,YAA6B,CAAC,CAAC,mBAAmB,EAC5F,SAAS,OAAO,OAClB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,mBAAb,cAAsC,OAAO,YAA8B,CAAC,CAAC,oBAAoB,EAC/F,SAAS,OAAO,OAClB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,4BACA;CACE,OAAO,OAAO,OAAO;CACrB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;;AAGH,MAAa,cAAc,OAAO,SAAS;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAKD,IAAa,mBAAb,cAAsC,OAAO,YAA8B,CAAC,CAAC,oBAAoB;CAC/F,OAAO;CACP,SAAS,OAAO;AAClB,CAAC,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AC,CAAC,CAAC,CAAC;;;;;;;AAQJ,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,SAAS,OAAO;CAChB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;;AAGH,IAAa,qBAAb,cAAwC,OAAO,YAAgC,CAAC,CAC9E,sBACA;CACE,SAAS,OAAO;CAChB,iBAAiB,OAAO;CACxB,cAAc,OAAO;CACrB,yBAAyB,OAAO;AAClC,CACF,CAAC,CAAC,CAAC;;AAGH,MAAa,aAAa,OAAO,MAAM;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
@@ -1,2 +1,2 @@
1
- import { a as CompactionPolicyInput, i as CompactionPolicy, n as AgentPolicyInput, t as AgentPolicy } from "../AgentPolicy-B4oH8TbG.mjs";
1
+ import { a as CompactionPolicyInput, i as CompactionPolicy, n as AgentPolicyInput, t as AgentPolicy } from "../AgentPolicy-CclAEpHn.mjs";
2
2
  export { AgentPolicy, AgentPolicyInput, CompactionPolicy, CompactionPolicyInput };
@@ -1,2 +1,2 @@
1
- import { a as decode, i as UpdateError, n as Emitter, o as emit, r as Update, s as observe } from "../AgentUpdates-DMJ-_xow.mjs";
1
+ import { a as decode, i as UpdateError, n as Emitter, o as emit, r as Update, s as observe } from "../AgentUpdates-DksV4D0A.mjs";
2
2
  export { Emitter, Update, UpdateError, decode, emit, observe };
@@ -1,7 +1,11 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { AgentId, RunId, ThreadId } from "./Identifiers.mjs";
3
3
  import { IdempotencyKey } from "./Receipt.mjs";
4
- import { Context, Effect, Option, Schema, Stream } from "effect";
4
+ import * as Schema from "effect/Schema";
5
+ import * as Context from "effect/Context";
6
+ import * as Effect from "effect/Effect";
7
+ import * as Option from "effect/Option";
8
+ import * as Stream from "effect/Stream";
5
9
  //#region src/core/AgentUpdates.ts
6
10
  var AgentUpdates_exports = /* @__PURE__ */ __exportAll({
7
11
  Emitter: () => Emitter,
@@ -1 +1 @@
1
- {"version":3,"file":"AgentUpdates.mjs","names":[],"sources":["../../src/core/AgentUpdates.ts"],"sourcesContent":["import { Context, Effect, Option, Schema, Stream } from \"effect\";\n\nimport { AgentId, ThreadId, RunId } from \"./Identifiers.ts\";\nimport { IdempotencyKey } from \"./Receipt.ts\";\n\n/** Canonical schema-encoded intermediate output, scoped to one logical Run. */\nexport class Update extends Schema.Class<Update>(\"@effect-agent/core/AgentUpdates/Update\")({\n schemaVersion: Schema.Literal(1),\n agentId: AgentId,\n threadId: ThreadId,\n runId: RunId,\n updateId: IdempotencyKey,\n sequence: Schema.Int.check(Schema.isGreaterThan(0)),\n value: Schema.Json,\n}) {}\n\n/** Fail-closed update acceptance and decoding errors; payloads are never included. */\nexport class UpdateError extends Schema.TaggedError<UpdateError>()(\"AgentUpdateError\", {\n reason: Schema.Literals([\n \"validation\",\n \"unavailable\",\n \"conflict\",\n \"capacity\",\n \"storage\",\n \"identity\",\n \"denied\",\n ]),\n}) {}\n\n/** Engine-owned invocation port. The Agent ID and exact update Schema must match the executing definition. */\nexport class Emitter extends Context.Service<\n Emitter,\n {\n readonly emit: (request: {\n readonly target: { readonly id: AgentId; readonly updates?: Schema.Top | undefined };\n readonly updateId: IdempotencyKey;\n readonly value: Schema.Json;\n }) => Effect.Effect<Update, UpdateError>;\n }\n>()(\"@effect-agent/core/AgentUpdates/Emitter\") {}\n\n/** Structural schema boundary accepted by definitions and their model bindings. */\ntype Source<S extends Schema.Top> = {\n readonly id: AgentId;\n readonly updates?: S | undefined;\n};\n\ntype BoundSource<S extends Schema.Top> = Source<S> | { readonly definition: Source<S> };\n\n/** Emit a decoded update under an explicit stable key. Retries cannot replace accepted values. */\nexport const emit = Effect.fn(\"AgentUpdates.emit\")(function* <S extends Schema.Top>(\n agent: BoundSource<S>,\n value: NoInfer<S[\"Type\"]>,\n options: { readonly idempotencyKey: IdempotencyKey },\n): Effect.fn.Return<Update, UpdateError, Emitter | S[\"EncodingServices\"]> {\n const target = \"definition\" in agent ? agent.definition : agent;\n\n if (target.updates === undefined) return yield* new UpdateError({ reason: \"unavailable\" });\n\n const updateId = yield* Schema.decodeEffect(IdempotencyKey)(options.idempotencyKey).pipe(\n Effect.mapError(() => new UpdateError({ reason: \"validation\" })),\n );\n\n const encoded = yield* Schema.encodeEffect(target.updates)(value).pipe(\n Effect.flatMap(Schema.decodeUnknownEffect(Schema.Json)),\n Effect.mapError(() => new UpdateError({ reason: \"validation\" })),\n );\n\n const emitter = yield* Effect.serviceOption(Emitter);\n\n if (Option.isNone(emitter)) return yield* new UpdateError({ reason: \"unavailable\" });\n\n return yield* emitter.value.emit({ target, updateId, value: encoded });\n});\n\n/** Decode canonical update data through its declaring Agent Schema. */\nexport const decode = Effect.fn(\"AgentUpdates.decode\")(function* <S extends Schema.Top>(\n agent: BoundSource<S>,\n update: Update,\n): Effect.fn.Return<S[\"Type\"], UpdateError, S[\"DecodingServices\"]> {\n const definition = \"definition\" in agent ? agent.definition : agent;\n\n if (definition.updates === undefined) return yield* new UpdateError({ reason: \"unavailable\" });\n\n const decoded = yield* Schema.decodeEffect(Update)(update).pipe(\n Effect.mapError(() => new UpdateError({ reason: \"validation\" })),\n );\n\n if (decoded.agentId !== definition.id) return yield* new UpdateError({ reason: \"identity\" });\n\n return yield* Schema.decodeEffect(definition.updates)(decoded.value).pipe(\n Effect.mapError(() => new UpdateError({ reason: \"validation\" })),\n );\n});\n\n/** Decode an encoded update stream without hiding its failures or requirements. */\nexport const observe = <S extends Schema.Top, E, R>(\n agent: BoundSource<S>,\n updates: Stream.Stream<Update, E, R>,\n) => updates.pipe(Stream.mapEffect((update) => decode(agent, update)));\n"],"mappings":";;;;;;;;;;;;;;AAMA,IAAa,SAAb,cAA4B,OAAO,MAAc,wCAAwC,CAAC,CAAC;CACzF,eAAe,OAAO,QAAQ,CAAC;CAC/B,SAAS;CACT,UAAU;CACV,OAAO;CACP,UAAU;C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IAAI,WAAW,YAAY,KAAA,GAAW,OAAO,OAAO,IAAI,YAAY,EAAE,QAAQ,cAAc,CAAC;CAE7F,MAAM,UAAU,OAAO,OAAO,aAAa,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KACzD,OAAO,eAAe,IAAI,YAAY,EAAE,QAAQ,aAAa,CAAC,CAAC,CACjE;CAEA,IAAI,QAAQ,YAAY,WAAW,IAAI,OAAO,OAAO,IAAI,YAAY,EAAE,QAAQ,WAAW,CAAC;CAE3F,OAAO,OAAO,OAAO,aAAa,WAAW,OAAO,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,KACnE,OAAO,eAAe,IAAI,YAAY,EAAE,QAAQ,aAAa,CAAC,CAAC,CACjE;AACF,CAAC;;AAGD,MAAa,WACX,OACA,YACG,QAAQ,KAAK,OAAO,WAAW,WAAW,OAAO,OAAO,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"AgentUpdates.mjs","names":[],"sources":["../../src/core/AgentUpdates.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nimport { AgentId, ThreadId, RunId } from \"./Identifiers.ts\";\nimport { IdempotencyKey } from \"./Receipt.ts\";\n\n/** Canonical schema-encoded intermediate output, scoped to one logical Run. */\nexport class Update extends Schema.Class<Update>(\"@effect-agent/core/AgentUpdates/Update\")({\n schemaVersion: Schema.Literal(1),\n agentId: AgentId,\n threadId: ThreadId,\n runId: RunId,\n updateId: IdempotencyKey,\n sequence: Schema.Int.check(Schema.isGreaterThan(0)),\n value: Schema.Json,\n}) {}\n\n/** Fail-closed update acceptance and decoding errors; payloads are never included. */\nexport class UpdateError extends Schema.TaggedError<UpdateError>()(\"AgentUpdateError\", {\n reason: Schema.Literals([\n \"validation\",\n \"unavailable\",\n \"conflict\",\n \"capacity\",\n \"storage\",\n \"identity\",\n \"denied\",\n ]),\n}) {}\n\n/** Engine-owned invocation port. The Agent ID and exact update Schema must match the executing definition. */\nexport class Emitter extends Context.Service<\n Emitter,\n {\n readonly emit: (request: {\n readonly target: { readonly id: AgentId; readonly updates?: Schema.Top | undefined };\n readonly updateId: IdempotencyKey;\n readonly value: Schema.Json;\n }) => Effect.Effect<Update, UpdateError>;\n }\n>()(\"@effect-agent/core/AgentUpdates/Emitter\") {}\n\n/** Structural schema boundary accepted by definitions and their model bindings. */\ntype Source<S extends Schema.Top> = {\n readonly id: AgentId;\n readonly updates?: S | undefined;\n};\n\ntype BoundSource<S extends Schema.Top> = Source<S> | { readonly definition: Source<S> };\n\n/** Emit a decoded update under an explicit stable key. Retries cannot replace accepted values. */\nexport const emit = Effect.fn(\"AgentUpdates.emit\")(function* <S extends Schema.Top>(\n agent: BoundSource<S>,\n value: NoInfer<S[\"Type\"]>,\n options: { readonly idempotencyKey: IdempotencyKey },\n): Effect.fn.Return<Update, UpdateError, Emitter | S[\"EncodingServices\"]> {\n const target = \"definition\" in agent ? agent.definition : agent;\n\n if (target.updates === undefined) return yield* new UpdateError({ reason: \"unavailable\" });\n\n const updateId = yield* Schema.decodeEffect(IdempotencyKey)(options.idempotencyKey).pipe(\n Effect.mapError(() => new UpdateError({ reason: \"validation\" })),\n );\n\n const encoded = yield* Schema.encodeEffect(target.updates)(value).pipe(\n Effect.flatMap(Schema.decodeUnknownEffect(Schema.Json)),\n Effect.mapError(() => new UpdateError({ reason: \"validation\" })),\n );\n\n const emitter = yield* Effect.serviceOption(Emitter);\n\n if (Option.isNone(emitter)) return yield* new UpdateError({ reason: \"unavailable\" });\n\n return yield* emitter.value.emit({ target, updateId, value: encoded });\n});\n\n/** Decode canonical update data through its declaring Agent Schema. */\nexport const decode = Effect.fn(\"AgentUpdates.decode\")(function* <S extends Schema.Top>(\n agent: BoundSource<S>,\n update: Update,\n): Effect.fn.Return<S[\"Type\"], UpdateError, S[\"DecodingServices\"]> {\n const definition = \"definition\" in agent ? agent.definition : agent;\n\n if (definition.updates === undefined) return yield* new UpdateError({ reason: \"unavailable\" });\n\n const decoded = yield* Schema.decodeEffect(Update)(update).pipe(\n Effect.mapError(() => new UpdateError({ reason: \"validation\" })),\n );\n\n if (decoded.agentId !== definition.id) return yield* new UpdateError({ reason: \"identity\" });\n\n return yield* Schema.decodeEffect(definition.updates)(decoded.value).pipe(\n Effect.mapError(() => new UpdateError({ reason: \"validation\" })),\n );\n});\n\n/** Decode an encoded update stream without hiding its failures or requirements. */\nexport const observe = <S extends Schema.Top, E, R>(\n agent: BoundSource<S>,\n updates: Stream.Stream<Update, E, R>,\n) => updates.pipe(Stream.mapEffect((update) => decode(agent, update)));\n"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,IAAa,SAAb,cAA4B,OAAO,MAAc,wCAAwC,CAAC,CAAC;CACzF,eAAe,OAAO,QAAQ,CAAC;CAC/B,SAAS;CACT,UAAU;CACV,OAAO;CACP,UAAU;CACV,UAAU,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;CAClD,OAAO,OAAO;AAChB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,cAAb,cAAiC,OAAO,YAAyB,CAAC,CAAC,oBAAoB,EACrF,QAAQ,OAAO,SAAS;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,EACH,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,UAAb,cAA6B,QAAQ,QASnC,CAAC,CAAC,yCAAyC,CAAC,CAAC,CAAC;;AAWhD,MAAa,OAAO,OAAO,GAAG,mBAAmB,CAAC,CAAC,WACjD,OACA,OACA,SACwE;CACxE,MAAM,SAAS,gBAAgB,QAAQ,MAAM,aAAa;CAE1D,IAAI,OAAO,YAAY,KAAA,GAAW,OAAO,OAAO,IAAI,YAAY,EAAE,QAAQ,cAAc,CAAC;CAEzF,MAAM,WAAW,OAAO,OAAO,aAAa,cAAc,CAAC,CAAC,QAAQ,cAAc,CAAC,CAAC,KAClF,OAAO,eAAe,IAAI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agnostic-CaAkzGHL.mjs";
1
+ import { c as captureContext, i as Failure, l as redactText, n as Context, o as Value, r as Diagnostic, s as capture, t as Cause } from "../FailureDiagnostic-DvHruCSJ.mjs";
2
2
  export { Cause, Context, Diagnostic, Failure, Value, capture, captureContext, redactText };
@@ -1,2 +1,2 @@
1
- import { c as captureContext, i as Failure, l as redactText, n as Context, o as Value, r as Diagnostic, s as capture, t as Cause } from "../FailureDiagnostic-BElLOoED.mjs";
1
+ import { c as captureContext, i as Failure, l as redactText, n as Context, o as Value, r as Diagnostic, s as capture, t as Cause } from "../FailureDiagnostic-D9oW23Cn.mjs";
2
2
  export { Cause, Context, Diagnostic, Failure, Value, capture, captureContext, redactText };
@@ -1,5 +1,7 @@
1
1
  import { f as TurnId, s as RunId, u as ThreadId } from "../Identifiers-CN2s30fF.mjs";
2
- import { Context, Effect, Layer } from "effect";
2
+ import * as Context from "effect/Context";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Layer from "effect/Layer";
3
5
  declare namespace IdGenerator_d_exports {
4
6
  export { IdGenerator, Service, layer };
5
7
  }
@@ -1,16 +1,19 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { RunId, ThreadId, TurnId } from "./Identifiers.mjs";
3
- import { IdGenerator as IdGenerator$1 } from "effect/unstable/ai";
4
- import { Context, Effect, Layer, Schema } from "effect";
3
+ import * as Schema from "effect/Schema";
4
+ import * as Context from "effect/Context";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Layer from "effect/Layer";
7
+ import * as EffectAiIdGenerator from "effect/unstable/ai/IdGenerator";
5
8
  //#region src/core/IdGenerator.ts
6
9
  var IdGenerator_exports = /* @__PURE__ */ __exportAll({
7
10
  IdGenerator: () => IdGenerator,
8
11
  layer: () => layer
9
12
  });
10
13
  const defaultGenerator = {
11
- nextThreadId: IdGenerator$1.defaultIdGenerator.generateId().pipe(Effect.map((id) => Schema.decodeSync(ThreadId)(`thread-${id}`))),
12
- nextRunId: IdGenerator$1.defaultIdGenerator.generateId().pipe(Effect.map((id) => Schema.decodeSync(RunId)(`run-${id}`))),
13
- nextTurnId: IdGenerator$1.defaultIdGenerator.generateId().pipe(Effect.map((id) => Schema.decodeSync(TurnId)(`turn-${id}`)))
14
+ nextThreadId: EffectAiIdGenerator.defaultIdGenerator.generateId().pipe(Effect.map((id) => Schema.decodeSync(ThreadId)(`thread-${id}`))),
15
+ nextRunId: EffectAiIdGenerator.defaultIdGenerator.generateId().pipe(Effect.map((id) => Schema.decodeSync(RunId)(`run-${id}`))),
16
+ nextTurnId: EffectAiIdGenerator.defaultIdGenerator.generateId().pipe(Effect.map((id) => Schema.decodeSync(TurnId)(`turn-${id}`)))
14
17
  };
15
18
  /**
16
19
  * Runtime identities default to Effect AI's generator without requiring a Layer.
@@ -1 +1 @@
1
- {"version":3,"file":"IdGenerator.mjs","names":["EffectAiIdGenerator"],"sources":["../../src/core/IdGenerator.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema } from \"effect\";\nimport { IdGenerator as EffectAiIdGenerator } from \"effect/unstable/ai\";\n\nimport { ThreadId, RunId, TurnId } from \"./Identifiers.ts\";\n\n/** Replaceable authority for creating runtime identities, including deterministic test IDs. */\nexport interface Service {\n /** Create the identity for a new thread. */\n readonly nextThreadId: Effect.Effect<ThreadId>;\n /** Create the identity for a new run. */\n readonly nextRunId: Effect.Effect<RunId>;\n /** Create the identity for a new model turn. */\n readonly nextTurnId: Effect.Effect<TurnId>;\n}\n\nconst defaultGenerator: Service = {\n nextThreadId: EffectAiIdGenerator.defaultIdGenerator\n .generateId()\n .pipe(Effect.map((id) => Schema.decodeSync(ThreadId)(`thread-${id}`))),\n nextRunId: EffectAiIdGenerator.defaultIdGenerator\n .generateId()\n .pipe(Effect.map((id) => Schema.decodeSync(RunId)(`run-${id}`))),\n nextTurnId: EffectAiIdGenerator.defaultIdGenerator\n .generateId()\n .pipe(Effect.map((id) => Schema.decodeSync(TurnId)(`turn-${id}`))),\n};\n\n/**\n * Runtime identities default to Effect AI's generator without requiring a Layer.\n * Randomness is fiber-local and can be seeded in tests. Override this reference\n * with Layer.succeed/Layer.effect or Effect.provideService for custom identities.\n * The default holds only Effects: it allocates no mutable state or resources.\n */\nexport const IdGenerator = Context.Reference<Service>(\"@effect-agent/core/IdGenerator\", {\n defaultValue: () => defaultGenerator,\n});\n\n/** Explicitly select the default generator, replacing any enclosing override. */\nexport const layer: Layer.Layer<never> = Layer.succeed(IdGenerator, defaultGenerator);\n"],"mappings":";;;;;;;;;AAeA,MAAM,mBAA4B;CAChC,cAAcA,cAAoB,mBAC/B,WAAW,CAAC,CACZ,KAAK,OAAO,KAAK,OAAO,OAAO,WAAW,QAAQ,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC;CACvE,WAAWA,cAAoB,mBAC5B,WAAW,CAAC,CACZ,KAAK,OAAO,KAAK,OAAO,OAAO,WAAW,KAAK,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC;CACjE,YAAYA,cAAoB,mBAC7B,WAAW,CAAC,CACZ,KAAK,OAAO,KAAK,OAAO,OAAO,WAAW,MAAM,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC;AACrE;;;;;;;AAQA,MAAa,cAAc,QAAQ,UAAmB,kCAAkC,EACtF,oBAAoB,iBACtB,CAAC;;AAGD,MAAa,QAA4B,MAAM,QAAQ,aAAa,gBAAgB"}
1
+ {"version":3,"file":"IdGenerator.mjs","names":[],"sources":["../../src/core/IdGenerator.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as EffectAiIdGenerator from \"effect/unstable/ai/IdGenerator\";\n\nimport { ThreadId, RunId, TurnId } from \"./Identifiers.ts\";\n\n/** Replaceable authority for creating runtime identities, including deterministic test IDs. */\nexport interface Service {\n /** Create the identity for a new thread. */\n readonly nextThreadId: Effect.Effect<ThreadId>;\n /** Create the identity for a new run. */\n readonly nextRunId: Effect.Effect<RunId>;\n /** Create the identity for a new model turn. */\n readonly nextTurnId: Effect.Effect<TurnId>;\n}\n\nconst defaultGenerator: Service = {\n nextThreadId: EffectAiIdGenerator.defaultIdGenerator\n .generateId()\n .pipe(Effect.map((id) => Schema.decodeSync(ThreadId)(`thread-${id}`))),\n nextRunId: EffectAiIdGenerator.defaultIdGenerator\n .generateId()\n .pipe(Effect.map((id) => Schema.decodeSync(RunId)(`run-${id}`))),\n nextTurnId: EffectAiIdGenerator.defaultIdGenerator\n .generateId()\n .pipe(Effect.map((id) => Schema.decodeSync(TurnId)(`turn-${id}`))),\n};\n\n/**\n * Runtime identities default to Effect AI's generator without requiring a Layer.\n * Randomness is fiber-local and can be seeded in tests. Override this reference\n * with Layer.succeed/Layer.effect or Effect.provideService for custom identities.\n * The default holds only Effects: it allocates no mutable state or resources.\n */\nexport const IdGenerator = Context.Reference<Service>(\"@effect-agent/core/IdGenerator\", {\n defaultValue: () => defaultGenerator,\n});\n\n/** Explicitly select the default generator, replacing any enclosing override. */\nexport const layer: Layer.Layer<never> = Layer.succeed(IdGenerator, defaultGenerator);\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAM,mBAA4B;CAChC,cAAc,oBAAoB,mBAC/B,WAAW,CAAC,CACZ,KAAK,OAAO,KAAK,OAAO,OAAO,WAAW,QAAQ,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC;CACvE,WAAW,oBAAoB,mBAC5B,WAAW,CAAC,CACZ,KAAK,OAAO,KAAK,OAAO,OAAO,WAAW,KAAK,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC;CACjE,YAAY,oBAAoB,mBAC7B,WAAW,CAAC,CACZ,KAAK,OAAO,KAAK,OAAO,OAAO,WAAW,MAAM,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC;AACrE;;;;;;;AAQA,MAAa,cAAc,QAAQ,UAAmB,kCAAkC,EACtF,oBAAoB,iBACtB,CAAC;;AAGD,MAAa,QAA4B,MAAM,QAAQ,aAAa,gBAAgB"}
@@ -1,2 +1,2 @@
1
- import { a as Receipt, i as QueueSequence, n as JoinedToHost, r as Principal, t as IdempotencyKey } from "../Receipt-BAHyigAF.mjs";
1
+ import { a as Receipt, i as QueueSequence, n as JoinedToHost, r as Principal, t as IdempotencyKey } from "../Receipt-BkM21Qiu.mjs";
2
2
  export { IdempotencyKey, JoinedToHost, Principal, QueueSequence, Receipt };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { ReceiptId, SubmissionId, ThreadId } from "./Identifiers.mjs";
3
- import { Schema } from "effect";
3
+ import * as Schema from "effect/Schema";
4
4
  //#region src/core/Receipt.ts
5
5
  var Receipt_exports = /* @__PURE__ */ __exportAll({
6
6
  IdempotencyKey: () => IdempotencyKey,
@@ -1 +1 @@
1
- {"version":3,"file":"Receipt.mjs","names":[],"sources":["../../src/core/Receipt.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport { ReceiptId, SubmissionId, ThreadId } from \"./Identifiers.ts\";\n\n// Keep the established brand and Schema identities when sharing these values inward.\n/** Caller-supplied deduplication key, scoped to one Thread and authenticated principal. */\nexport const IdempotencyKey = Schema.NonEmptyString.check(Schema.isMaxLength(256)).pipe(\n Schema.brand(\"@effect-agent/thread/IdempotencyKey\"),\n);\n\nexport type IdempotencyKey = typeof IdempotencyKey.Type;\n\n/** Stable host-authenticated admission principal; the established durable brand is preserved. */\nexport const Principal = Schema.NonEmptyString.check(Schema.isMaxLength(256)).pipe(\n Schema.brand(\"@effect-agent/thread/Principal\"),\n);\n\nexport type Principal = typeof Principal.Type;\n\n/** Thread-local FIFO position allocated once at admission. */\nexport const QueueSequence = Schema.Natural.pipe(\n Schema.brand(\"@effect-agent/thread/QueueSequence\"),\n);\n\nexport type QueueSequence = typeof QueueSequence.Type;\n\n/**\n * One accepted input whose admission, Thread materialization and readiness are committed.\n * A Receipt identifies an observation target; possession grants no authorization.\n */\nexport class Receipt extends Schema.Class<Receipt>(\"@effect-agent/thread/Receipt\")({\n receiptId: ReceiptId,\n submissionId: SubmissionId,\n threadId: ThreadId,\n queueSequence: QueueSequence,\n}) {}\n\n/** The input joined this host Submission; cancelling it must never silently cancel the host. */\nexport class JoinedToHost extends Schema.TaggedError<JoinedToHost>()(\"JoinedToHost\", {\n submissionId: SubmissionId,\n hostSubmissionId: SubmissionId,\n}) {}\n"],"mappings":";;;;;;;;;;;;AAMA,MAAa,iBAAiB,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC,CAAC,CAAC,KACjF,OAAO,MAAM,qCAAqC,CACpD;;AAKA,MAAa,YAAY,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC,CAAC,CAAC,KAC5E,OAAO,MAAM,gCAAgC,CAC/C;;AAKA,MAAa,gBAAgB,OAAO,QAAQ,KAC1C,OAAO,MAAM,oCAAoC,CACnD;;;;;AAQA,IAAa,UAAb,cAA6B,OAAO,MAAe,8BAA8B,CAAC,CAAC;CACjF,WAAW;CACX,cAAc;CACd,UAAU;CACV,eAAe;AACjB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAAC,gBAAgB;CACnF,cAAc;CACd,kBAAkB;AACpB,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"Receipt.mjs","names":[],"sources":["../../src/core/Receipt.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport { ReceiptId, SubmissionId, ThreadId } from \"./Identifiers.ts\";\n\n// Keep the established brand and Schema identities when sharing these values inward.\n/** Caller-supplied deduplication key, scoped to one Thread and authenticated principal. */\nexport const IdempotencyKey = Schema.NonEmptyString.check(Schema.isMaxLength(256)).pipe(\n Schema.brand(\"@effect-agent/thread/IdempotencyKey\"),\n);\n\nexport type IdempotencyKey = typeof IdempotencyKey.Type;\n\n/** Stable host-authenticated admission principal; the established durable brand is preserved. */\nexport const Principal = Schema.NonEmptyString.check(Schema.isMaxLength(256)).pipe(\n Schema.brand(\"@effect-agent/thread/Principal\"),\n);\n\nexport type Principal = typeof Principal.Type;\n\n/** Thread-local FIFO position allocated once at admission. */\nexport const QueueSequence = Schema.Natural.pipe(\n Schema.brand(\"@effect-agent/thread/QueueSequence\"),\n);\n\nexport type QueueSequence = typeof QueueSequence.Type;\n\n/**\n * One accepted input whose admission, Thread materialization and readiness are committed.\n * A Receipt identifies an observation target; possession grants no authorization.\n */\nexport class Receipt extends Schema.Class<Receipt>(\"@effect-agent/thread/Receipt\")({\n receiptId: ReceiptId,\n submissionId: SubmissionId,\n threadId: ThreadId,\n queueSequence: QueueSequence,\n}) {}\n\n/** The input joined this host Submission; cancelling it must never silently cancel the host. */\nexport class JoinedToHost extends Schema.TaggedError<JoinedToHost>()(\"JoinedToHost\", {\n submissionId: SubmissionId,\n hostSubmissionId: SubmissionId,\n}) {}\n"],"mappings":";;;;;;;;;;;;AAMA,MAAa,iBAAiB,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC,CAAC,CAAC,KACjF,OAAO,MAAM,qCAAqC,CACpD;;AAKA,MAAa,YAAY,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC,CAAC,CAAC,KAC5E,OAAO,MAAM,gCAAgC,CAC/C;;AAKA,MAAa,gBAAgB,OAAO,QAAQ,KAC1C,OAAO,MAAM,oCAAoC,CACnD;;;;;AAQA,IAAa,UAAb,cAA6B,OAAO,MAAe,8BAA8B,CAAC,CAAC;CACjF,WAAW;CACX,cAAc;CACd,UAAU;CACV,eAAe;AACjB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAAC,gBAAgB;CACnF,cAAc;CACd,kBAAkB;AACpB,CAAC,CAAC,CAAC,CAAC"}
@@ -1,2 +1,2 @@
1
- import { A as TurnCompleted, C as TextDelta, D as ToolCallSucceeded, E as ToolCallStarted, O as ToolFailureHandling, S as SubagentStarted, T as ToolCallFailed, _ as SubagentFailed, a as ExhaustedLimit, b as SubagentProgress, c as ReasoningDelta, f as RunFailed, g as SubagentCompleted, h as RunSuspended, i as CompactionPerformed, j as TurnStarted, k as ToolProgress, l as RunCompleted, m as RunStarted, n as ApprovalRequested, o as ModelRestarted, p as RunInterrupted, r as BudgetWarning, s as ModelStarted, t as AgentUpdateEmitted, u as RunEvent, v as SubagentInterrupted, w as ToolCallDeclared, x as SubagentRequested, y as SubagentJoined } from "../RunEvent-D0aepYwN.mjs";
1
+ import { A as TurnCompleted, C as TextDelta, D as ToolCallSucceeded, E as ToolCallStarted, O as ToolFailureHandling, S as SubagentStarted, T as ToolCallFailed, _ as SubagentFailed, a as ExhaustedLimit, b as SubagentProgress, c as ReasoningDelta, f as RunFailed, g as SubagentCompleted, h as RunSuspended, i as CompactionPerformed, j as TurnStarted, k as ToolProgress, l as RunCompleted, m as RunStarted, n as ApprovalRequested, o as ModelRestarted, p as RunInterrupted, r as BudgetWarning, s as ModelStarted, t as AgentUpdateEmitted, u as RunEvent, v as SubagentInterrupted, w as ToolCallDeclared, x as SubagentRequested, y as SubagentJoined } from "../RunEvent-B3CRIqIC.mjs";
2
2
  export { AgentUpdateEmitted, ApprovalRequested, BudgetWarning, CompactionPerformed, ExhaustedLimit, ModelRestarted, ModelStarted, ReasoningDelta, RunCompleted, RunEvent, RunFailed, RunInterrupted, RunStarted, RunSuspended, SubagentCompleted, SubagentFailed, SubagentInterrupted, SubagentJoined, SubagentProgress, SubagentRequested, SubagentStarted, TextDelta, ToolCallDeclared, ToolCallFailed, ToolCallStarted, ToolCallSucceeded, ToolFailureHandling, ToolProgress, TurnCompleted, TurnStarted };
@@ -2,9 +2,9 @@ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { AgentId, DelegationId, RunId, ThreadId, ToolCallId, TurnId } from "./Identifiers.mjs";
3
3
  import { Update } from "./AgentUpdates.mjs";
4
4
  import { DelegationDepth } from "./SubagentContract.mjs";
5
- import { o as Selection } from "../ToolExposure-C93U1sPu.mjs";
5
+ import { o as Selection } from "../ToolExposure-hTJT2ekj.mjs";
6
6
  import { RunTotals } from "./Usage.mjs";
7
- import { Schema } from "effect";
7
+ import * as Schema from "effect/Schema";
8
8
  //#region src/core/RunEvent.ts
9
9
  var RunEvent_exports = /* @__PURE__ */ __exportAll({
10
10
  AgentUpdateEmitted: () => AgentUpdateEmitted,
@@ -1 +1 @@
1
- {"version":3,"file":"RunEvent.mjs","names":[],"sources":["../../src/core/RunEvent.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport { Update } from \"./AgentUpdates.ts\";\nimport { AgentId, ThreadId, DelegationId, RunId, ToolCallId, TurnId } from \"./Identifiers.ts\";\nimport { DelegationDepth } from \"./SubagentContract.ts\";\nimport { Selection } from \"./ToolExposure.ts\";\nimport { RunTotals } from \"./Usage.ts\";\n\nconst RunEventBase = {\n eventVersion: Schema.Literal(1),\n runId: RunId,\n threadId: ThreadId,\n agentId: AgentId,\n sequence: Schema.Natural,\n timestamp: Schema.DateTimeUtcFromString,\n turnId: Schema.optionalKey(TurnId),\n toolCallId: Schema.optionalKey(ToolCallId),\n};\n\n/** A schema-encoded Agent update accepted by the owning Run. */\nexport class AgentUpdateEmitted extends Schema.TaggedClass<AgentUpdateEmitted>()(\n \"AgentUpdateEmitted\",\n { ...RunEventBase, update: Update },\n) {}\n\n/** Signals that the runtime has created a run and assigned its identities. */\nexport class RunStarted extends Schema.TaggedClass<RunStarted>()(\"RunStarted\", RunEventBase) {}\n\n/** Signals the start of a positive-numbered model turn. */\nexport class TurnStarted extends Schema.TaggedClass<TurnStarted>()(\"TurnStarted\", {\n ...RunEventBase,\n turn: Schema.Int.check(Schema.isGreaterThan(0)),\n}) {}\n\n/** Signals that the model request for a turn is starting. */\nexport class ModelStarted extends Schema.TaggedClass<ModelStarted>()(\"ModelStarted\", {\n ...RunEventBase,\n turn: Schema.Int.check(Schema.isGreaterThan(0)),\n}) {}\n\n/** Discard all drafts for this turnId; a new model request will include joined input. */\nexport class ModelRestarted extends Schema.TaggedClass<ModelRestarted>()(\"ModelRestarted\", {\n ...RunEventBase,\n turnId: TurnId,\n turn: Schema.Int.check(Schema.isGreaterThan(0)),\n reason: Schema.Literal(\"joined-input\"),\n}) {}\n\n/** Carries one live assistant text delta. */\nexport class TextDelta extends Schema.TaggedClass<TextDelta>()(\"TextDelta\", {\n ...RunEventBase,\n text: Schema.String,\n}) {}\n\n/** Carries reasoning content explicitly exposed by the provider. */\nexport class ReasoningDelta extends Schema.TaggedClass<ReasoningDelta>()(\"ReasoningDelta\", {\n ...RunEventBase,\n text: Schema.String,\n}) {}\n\n/** Reports a complete model-declared Tool Call and its execution boundary. */\nexport class ToolCallDeclared extends Schema.TaggedClass<ToolCallDeclared>()(\"ToolCallDeclared\", {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n parameters: Schema.Json,\n providerExecuted: Schema.Boolean,\n}) {}\n\n/** Signals that a validated Tool Call handler has started. */\nexport class ToolCallStarted extends Schema.TaggedClass<ToolCallStarted>()(\"ToolCallStarted\", {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n}) {}\n\n/** Carries a preliminary Tool result that is not the call's terminal outcome. */\nexport class ToolProgress extends Schema.TaggedClass<ToolProgress>()(\"ToolProgress\", {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n result: Schema.Json,\n providerExecuted: Schema.Boolean,\n}) {}\n\n/** Records the successful terminal result of a Tool Call. */\nexport class ToolCallSucceeded extends Schema.TaggedClass<ToolCallSucceeded>()(\n \"ToolCallSucceeded\",\n {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n toolSelection: Schema.optionalKey(Selection),\n result: Schema.Json,\n providerExecuted: Schema.Boolean,\n },\n) {}\n\n/**\n * How this boundary handled a failed invocation, independently of its native failure mode.\n * `returned-to-model` records the result path; delivery still requires the complete batch to\n * commit and a later model call. A sibling, policy or later operation can still fail the Run.\n * This classification never implies that side effects were rolled back.\n */\nexport const ToolFailureHandling = Schema.Literals([\n \"propagated\",\n \"returned-to-model\",\n \"returned-to-caller\",\n]);\n\nexport type ToolFailureHandling = typeof ToolFailureHandling.Type;\n\n/** Records a terminal Tool Call failure using safe, serializable diagnostics. */\nexport class ToolCallFailed extends Schema.TaggedClass<ToolCallFailed>()(\"ToolCallFailed\", {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n errorTag: Schema.NonEmptyString,\n message: Schema.String,\n providerExecuted: Schema.Boolean,\n /** Native configuration when a local Tool is known; absent on provider results and old events. */\n failureMode: Schema.optionalKey(Schema.Literals([\"error\", \"return\"])),\n /** Actual route at this boundary. Absence on older events means unknown, never recoverable. */\n failureHandling: Schema.optionalKey(ToolFailureHandling),\n /** Synthetic policy rejection; no handler ran and the failure streak is unchanged. */\n budgetRejected: Schema.optionalKey(Schema.Literal(true)),\n}) {}\n\n/** Signals that a decoded Tool Call requires approval before execution. */\nexport class ApprovalRequested extends Schema.TaggedClass<ApprovalRequested>()(\n \"ApprovalRequested\",\n {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n },\n) {}\n\n/** Records the normalized finish reason for a completed assistant turn. */\nexport class TurnCompleted extends Schema.TaggedClass<TurnCompleted>()(\"TurnCompleted\", {\n ...RunEventBase,\n turn: Schema.Int.check(Schema.isGreaterThan(0)),\n finishReason: Schema.Literals([\n \"stop\",\n \"length\",\n \"content-filter\",\n \"tool-calls\",\n \"error\",\n \"pause\",\n \"other\",\n \"unknown\",\n ]),\n}) {}\n\n/** Advisory that one policy limit crossed its warning fraction; emitted once per limit per run. */\nexport class BudgetWarning extends Schema.TaggedClass<BudgetWarning>()(\"BudgetWarning\", {\n ...RunEventBase,\n limit: Schema.Literals([\"tokens\", \"tool-calls\", \"turns\", \"duration\", \"context\"]),\n consumed: Schema.Natural,\n limitValue: Schema.Natural,\n}) {}\n\n/** Records that the engine reduced model context at a Turn seam without erasing source history. */\nexport class CompactionPerformed extends Schema.TaggedClass<CompactionPerformed>()(\n \"CompactionPerformed\",\n {\n ...RunEventBase,\n turn: Schema.Int.check(Schema.isGreaterThan(0)),\n kind: Schema.Literals([\"clear-tool-results\", \"summarize\", \"rollover\"]),\n tokensBeforeEstimate: Schema.Natural,\n tokensAfterEstimate: Schema.Natural,\n },\n) {}\n\n/**\n * Dimension that bound when a Run settled through the final-answer resolution\n * (RUN-018; the token dimension per RUN-025). This is the exhausted marker\n * the re-delegation grant flow (RUN-021) consumes and the durable\n * `SubmissionSettled` record persists (RUN-011).\n */\nexport const ExhaustedLimit = Schema.Literals([\"tokens\", \"tool-calls\", \"turns\"]);\nexport type ExhaustedLimit = typeof ExhaustedLimit.Type;\n\nconst CompletionFinishReason = Schema.Literals([\"completed\", \"model-stop\", \"budget-exhausted\"]);\n\ntype CompletionMetadata = Readonly<{\n finishReason: typeof CompletionFinishReason.Type;\n exhausted?: ExhaustedLimit | undefined;\n}>;\n\nconst validateCompletionMetadata = ({\n exhausted,\n finishReason,\n}: CompletionMetadata): string | undefined => {\n const isBudgetExhausted = finishReason === \"budget-exhausted\";\n\n return isBudgetExhausted === (exhausted !== undefined)\n ? undefined\n : '`exhausted` must be present exactly when `finishReason` is \"budget-exhausted\"';\n};\n\nconst RunCompletedFields = Schema.Struct({\n ...RunEventBase,\n output: Schema.Json,\n /** Schema-encoded application disposition, present only for an ordinary completed Run. */\n runDisposition: Schema.optionalKey(Schema.Json),\n turns: Schema.Int.check(Schema.isGreaterThan(0)),\n finishReason: CompletionFinishReason,\n exhausted: Schema.optionalKey(ExhaustedLimit),\n /** Own Run usage, excluding attached descendants. Missing legacy reports are unknown. */\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n}).check(\n Schema.makeFilter((event) => validateCompletionMetadata(event)),\n Schema.makeFilter((event) =>\n event.finishReason === \"budget-exhausted\" && event.runDisposition !== undefined\n ? {\n path: [\"runDisposition\"],\n issue: '`runDisposition` is not allowed when `finishReason` is \"budget-exhausted\"',\n }\n : undefined,\n ),\n);\n\n/**\n * Successful terminal event carrying Schema-compatible output and the completed turn count.\n * `\"budget-exhausted\"` marks a Run that settled through the policy's final-answer resolution\n * after Turn, Tool Call, or token exhaustion — never a plain `\"model-stop\"` (RUN-011); its\n * `turns` count may exceed `maxTurns` by the single grace Turn, and `exhausted` names the\n * dimension that bound.\n *\n * Invariant: `exhausted` is present exactly when `finishReason` is\n * `\"budget-exhausted\"`, and a budget-exhausted completion has no application\n * run disposition. The checked Struct enforces both rules during construction,\n * decoding, and encoding without replacing the class in `RunEvent`.\n */\nexport class RunCompleted extends Schema.TaggedClass<RunCompleted>()(\n \"RunCompleted\",\n RunCompletedFields,\n) {}\n\n/** Terminal event for a run that failed with an expected error. */\nexport class RunFailed extends Schema.TaggedClass<RunFailed>()(\"RunFailed\", {\n ...RunEventBase,\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n errorTag: Schema.NonEmptyString,\n message: Schema.String,\n}) {}\n\n/** Terminal event for a run stopped by interruption. */\nexport class RunInterrupted extends Schema.TaggedClass<RunInterrupted>()(\"RunInterrupted\", {\n ...RunEventBase,\n message: Schema.String,\n}) {}\n\n/** Terminal event for a run awaiting resumable external input. */\nexport class RunSuspended extends Schema.TaggedClass<RunSuspended>()(\"RunSuspended\", {\n ...RunEventBase,\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n reason: Schema.String,\n}) {}\n\nconst SubagentText = Schema.String.check(Schema.isMaxLength(4 * 1024));\n\nconst SubagentEventBase = {\n ...RunEventBase,\n turnId: TurnId,\n toolCallId: ToolCallId,\n delegationId: DelegationId,\n childThreadId: ThreadId,\n childRunId: RunId,\n targetAgentId: AgentId,\n depth: DelegationDepth,\n};\n\n/** Signals that a delegation Tool Call passed preflight with preallocated child identity. */\nexport class SubagentRequested extends Schema.TaggedClass<SubagentRequested>()(\n \"SubagentRequested\",\n SubagentEventBase,\n) {}\n\n/** Signals that the child run has started inside its parent-owned scoped region. */\nexport class SubagentStarted extends Schema.TaggedClass<SubagentStarted>()(\n \"SubagentStarted\",\n SubagentEventBase,\n) {}\n\n/** Carries a bounded child progress summary without duplicating the child event stream. */\nexport class SubagentProgress extends Schema.TaggedClass<SubagentProgress>()(\"SubagentProgress\", {\n ...SubagentEventBase,\n summary: SubagentText,\n}) {}\n\n/**\n * Records the child run's successful terminal outcome before the parent join.\n * Same invariant as `RunCompleted`: `exhausted` is present exactly when\n * `finishReason` is `\"budget-exhausted\"` (the pair travels verbatim from the\n * child's terminal event); consumers treat a divergent pair fail-safe.\n */\nexport class SubagentCompleted extends Schema.TaggedClass<SubagentCompleted>()(\n \"SubagentCompleted\",\n Schema.Struct({\n ...SubagentEventBase,\n turns: Schema.Int.check(Schema.isGreaterThan(0)),\n finishReason: CompletionFinishReason,\n exhausted: Schema.optionalKey(ExhaustedLimit),\n /**\n * The child's own observed usage. Delegated usage covers its attached descendants separately.\n */\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n }).check(Schema.makeFilter((event) => validateCompletionMetadata(event))),\n) {}\n\n/** Records the child run's expected terminal failure using safe, serializable diagnostics. */\nexport class SubagentFailed extends Schema.TaggedClass<SubagentFailed>()(\"SubagentFailed\", {\n ...SubagentEventBase,\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n errorTag: Schema.NonEmptyString,\n message: SubagentText,\n}) {}\n\n/** Records that the child run was stopped by interruption before a terminal outcome. */\nexport class SubagentInterrupted extends Schema.TaggedClass<SubagentInterrupted>()(\n \"SubagentInterrupted\",\n {\n ...SubagentEventBase,\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n reason: SubagentText,\n },\n) {}\n\n/** Records that the child's terminal outcome was joined into its parent delegation Tool Call. */\nexport class SubagentJoined extends Schema.TaggedClass<SubagentJoined>()(\"SubagentJoined\", {\n ...SubagentEventBase,\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n}) {}\n\n/** Versioned union of stable semantic run events, excluding raw provider chunks. */\nexport const RunEvent = Schema.Union([\n AgentUpdateEmitted,\n RunStarted,\n TurnStarted,\n ModelStarted,\n ModelRestarted,\n TextDelta,\n ReasoningDelta,\n ToolCallDeclared,\n ToolCallStarted,\n ToolProgress,\n ToolCallSucceeded,\n ToolCallFailed,\n ApprovalRequested,\n TurnCompleted,\n BudgetWarning,\n CompactionPerformed,\n RunCompleted,\n RunFailed,\n RunInterrupted,\n RunSuspended,\n SubagentRequested,\n SubagentStarted,\n SubagentProgress,\n SubagentCompleted,\n SubagentFailed,\n SubagentInterrupted,\n SubagentJoined,\n]);\n\nexport type RunEvent = typeof RunEvent.Type;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,eAAe;CACnB,cAAc,OAAO,QAAQ,CAAC;CAC9B,OAAO;CACP,UAAU;CACV,SAAS;CACT,UAAU,OAAO;CACjB,WAAW,OAAO;CAClB,QAAQ,OAAO,YAAY,MAAM;CACjC,YAAY,OAAO,YAAY,UAAU;AAC3C;;AAGA,IAAa,qBAAb,cAAwC,OAAO,YAAgC,CAAC,CAC9E,sBACA;CAAE,GAAG;CAAc,QAAQ;AAAO,CACpC,CAAC,CAAC,CAAC;;AAGH,IAAa,aAAb,cAAgC,OAAO,YAAwB,CAAC,CAAC,cAAc,YAAY,CAAC,CAAC,CAAC;;AAG9F,IAAa,cAAb,cAAiC,OAAO,YAAyB,CAAC,CAAC,eAAe;CAChF,GAAG;CACH,MAAM,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAAC,gBAAgB;CACnF,GAAG;CACH,MAAM,OAAO,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GH,IAAa,iBAAb,cAAoC,OAAO,YAA4B,CAAC,CAAC,kBAAkB;CACzF,GAAG;CACH,OAAO,OAAO,YAAY,SAAS;CACnC,gBAAgB,OAAO,YAAY,SAAS;AAC9C,CAAC,CAAC,CAAC,CAAC;;AAGJ,MAAa,WAAW,OAAO,MAAM;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"RunEvent.mjs","names":[],"sources":["../../src/core/RunEvent.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport { Update } from \"./AgentUpdates.ts\";\nimport { AgentId, ThreadId, DelegationId, RunId, ToolCallId, TurnId } from \"./Identifiers.ts\";\nimport { DelegationDepth } from \"./SubagentContract.ts\";\nimport { Selection } from \"./ToolExposure.ts\";\nimport { RunTotals } from \"./Usage.ts\";\n\nconst RunEventBase = {\n eventVersion: Schema.Literal(1),\n runId: RunId,\n threadId: ThreadId,\n agentId: AgentId,\n sequence: Schema.Natural,\n timestamp: Schema.DateTimeUtcFromString,\n turnId: Schema.optionalKey(TurnId),\n toolCallId: Schema.optionalKey(ToolCallId),\n};\n\n/** A schema-encoded Agent update accepted by the owning Run. */\nexport class AgentUpdateEmitted extends Schema.TaggedClass<AgentUpdateEmitted>()(\n \"AgentUpdateEmitted\",\n { ...RunEventBase, update: Update },\n) {}\n\n/** Signals that the runtime has created a run and assigned its identities. */\nexport class RunStarted extends Schema.TaggedClass<RunStarted>()(\"RunStarted\", RunEventBase) {}\n\n/** Signals the start of a positive-numbered model turn. */\nexport class TurnStarted extends Schema.TaggedClass<TurnStarted>()(\"TurnStarted\", {\n ...RunEventBase,\n turn: Schema.Int.check(Schema.isGreaterThan(0)),\n}) {}\n\n/** Signals that the model request for a turn is starting. */\nexport class ModelStarted extends Schema.TaggedClass<ModelStarted>()(\"ModelStarted\", {\n ...RunEventBase,\n turn: Schema.Int.check(Schema.isGreaterThan(0)),\n}) {}\n\n/** Discard all drafts for this turnId; a new model request will include joined input. */\nexport class ModelRestarted extends Schema.TaggedClass<ModelRestarted>()(\"ModelRestarted\", {\n ...RunEventBase,\n turnId: TurnId,\n turn: Schema.Int.check(Schema.isGreaterThan(0)),\n reason: Schema.Literal(\"joined-input\"),\n}) {}\n\n/** Carries one live assistant text delta. */\nexport class TextDelta extends Schema.TaggedClass<TextDelta>()(\"TextDelta\", {\n ...RunEventBase,\n text: Schema.String,\n}) {}\n\n/** Carries reasoning content explicitly exposed by the provider. */\nexport class ReasoningDelta extends Schema.TaggedClass<ReasoningDelta>()(\"ReasoningDelta\", {\n ...RunEventBase,\n text: Schema.String,\n}) {}\n\n/** Reports a complete model-declared Tool Call and its execution boundary. */\nexport class ToolCallDeclared extends Schema.TaggedClass<ToolCallDeclared>()(\"ToolCallDeclared\", {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n parameters: Schema.Json,\n providerExecuted: Schema.Boolean,\n}) {}\n\n/** Signals that a validated Tool Call handler has started. */\nexport class ToolCallStarted extends Schema.TaggedClass<ToolCallStarted>()(\"ToolCallStarted\", {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n}) {}\n\n/** Carries a preliminary Tool result that is not the call's terminal outcome. */\nexport class ToolProgress extends Schema.TaggedClass<ToolProgress>()(\"ToolProgress\", {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n result: Schema.Json,\n providerExecuted: Schema.Boolean,\n}) {}\n\n/** Records the successful terminal result of a Tool Call. */\nexport class ToolCallSucceeded extends Schema.TaggedClass<ToolCallSucceeded>()(\n \"ToolCallSucceeded\",\n {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n toolSelection: Schema.optionalKey(Selection),\n result: Schema.Json,\n providerExecuted: Schema.Boolean,\n },\n) {}\n\n/**\n * How this boundary handled a failed invocation, independently of its native failure mode.\n * `returned-to-model` records the result path; delivery still requires the complete batch to\n * commit and a later model call. A sibling, policy or later operation can still fail the Run.\n * This classification never implies that side effects were rolled back.\n */\nexport const ToolFailureHandling = Schema.Literals([\n \"propagated\",\n \"returned-to-model\",\n \"returned-to-caller\",\n]);\n\nexport type ToolFailureHandling = typeof ToolFailureHandling.Type;\n\n/** Records a terminal Tool Call failure using safe, serializable diagnostics. */\nexport class ToolCallFailed extends Schema.TaggedClass<ToolCallFailed>()(\"ToolCallFailed\", {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n errorTag: Schema.NonEmptyString,\n message: Schema.String,\n providerExecuted: Schema.Boolean,\n /** Native configuration when a local Tool is known; absent on provider results and old events. */\n failureMode: Schema.optionalKey(Schema.Literals([\"error\", \"return\"])),\n /** Actual route at this boundary. Absence on older events means unknown, never recoverable. */\n failureHandling: Schema.optionalKey(ToolFailureHandling),\n /** Synthetic policy rejection; no handler ran and the failure streak is unchanged. */\n budgetRejected: Schema.optionalKey(Schema.Literal(true)),\n}) {}\n\n/** Signals that a decoded Tool Call requires approval before execution. */\nexport class ApprovalRequested extends Schema.TaggedClass<ApprovalRequested>()(\n \"ApprovalRequested\",\n {\n ...RunEventBase,\n toolCallId: ToolCallId,\n toolName: Schema.NonEmptyString,\n },\n) {}\n\n/** Records the normalized finish reason for a completed assistant turn. */\nexport class TurnCompleted extends Schema.TaggedClass<TurnCompleted>()(\"TurnCompleted\", {\n ...RunEventBase,\n turn: Schema.Int.check(Schema.isGreaterThan(0)),\n finishReason: Schema.Literals([\n \"stop\",\n \"length\",\n \"content-filter\",\n \"tool-calls\",\n \"error\",\n \"pause\",\n \"other\",\n \"unknown\",\n ]),\n}) {}\n\n/** Advisory that one policy limit crossed its warning fraction; emitted once per limit per run. */\nexport class BudgetWarning extends Schema.TaggedClass<BudgetWarning>()(\"BudgetWarning\", {\n ...RunEventBase,\n limit: Schema.Literals([\"tokens\", \"tool-calls\", \"turns\", \"duration\", \"context\"]),\n consumed: Schema.Natural,\n limitValue: Schema.Natural,\n}) {}\n\n/** Records that the engine reduced model context at a Turn seam without erasing source history. */\nexport class CompactionPerformed extends Schema.TaggedClass<CompactionPerformed>()(\n \"CompactionPerformed\",\n {\n ...RunEventBase,\n turn: Schema.Int.check(Schema.isGreaterThan(0)),\n kind: Schema.Literals([\"clear-tool-results\", \"summarize\", \"rollover\"]),\n tokensBeforeEstimate: Schema.Natural,\n tokensAfterEstimate: Schema.Natural,\n },\n) {}\n\n/**\n * Dimension that bound when a Run settled through the final-answer resolution\n * (RUN-018; the token dimension per RUN-025). This is the exhausted marker\n * the re-delegation grant flow (RUN-021) consumes and the durable\n * `SubmissionSettled` record persists (RUN-011).\n */\nexport const ExhaustedLimit = Schema.Literals([\"tokens\", \"tool-calls\", \"turns\"]);\nexport type ExhaustedLimit = typeof ExhaustedLimit.Type;\n\nconst CompletionFinishReason = Schema.Literals([\"completed\", \"model-stop\", \"budget-exhausted\"]);\n\ntype CompletionMetadata = Readonly<{\n finishReason: typeof CompletionFinishReason.Type;\n exhausted?: ExhaustedLimit | undefined;\n}>;\n\nconst validateCompletionMetadata = ({\n exhausted,\n finishReason,\n}: CompletionMetadata): string | undefined => {\n const isBudgetExhausted = finishReason === \"budget-exhausted\";\n\n return isBudgetExhausted === (exhausted !== undefined)\n ? undefined\n : '`exhausted` must be present exactly when `finishReason` is \"budget-exhausted\"';\n};\n\nconst RunCompletedFields = Schema.Struct({\n ...RunEventBase,\n output: Schema.Json,\n /** Schema-encoded application disposition, present only for an ordinary completed Run. */\n runDisposition: Schema.optionalKey(Schema.Json),\n turns: Schema.Int.check(Schema.isGreaterThan(0)),\n finishReason: CompletionFinishReason,\n exhausted: Schema.optionalKey(ExhaustedLimit),\n /** Own Run usage, excluding attached descendants. Missing legacy reports are unknown. */\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n}).check(\n Schema.makeFilter((event) => validateCompletionMetadata(event)),\n Schema.makeFilter((event) =>\n event.finishReason === \"budget-exhausted\" && event.runDisposition !== undefined\n ? {\n path: [\"runDisposition\"],\n issue: '`runDisposition` is not allowed when `finishReason` is \"budget-exhausted\"',\n }\n : undefined,\n ),\n);\n\n/**\n * Successful terminal event carrying Schema-compatible output and the completed turn count.\n * `\"budget-exhausted\"` marks a Run that settled through the policy's final-answer resolution\n * after Turn, Tool Call, or token exhaustion — never a plain `\"model-stop\"` (RUN-011); its\n * `turns` count may exceed `maxTurns` by the single grace Turn, and `exhausted` names the\n * dimension that bound.\n *\n * Invariant: `exhausted` is present exactly when `finishReason` is\n * `\"budget-exhausted\"`, and a budget-exhausted completion has no application\n * run disposition. The checked Struct enforces both rules during construction,\n * decoding, and encoding without replacing the class in `RunEvent`.\n */\nexport class RunCompleted extends Schema.TaggedClass<RunCompleted>()(\n \"RunCompleted\",\n RunCompletedFields,\n) {}\n\n/** Terminal event for a run that failed with an expected error. */\nexport class RunFailed extends Schema.TaggedClass<RunFailed>()(\"RunFailed\", {\n ...RunEventBase,\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n errorTag: Schema.NonEmptyString,\n message: Schema.String,\n}) {}\n\n/** Terminal event for a run stopped by interruption. */\nexport class RunInterrupted extends Schema.TaggedClass<RunInterrupted>()(\"RunInterrupted\", {\n ...RunEventBase,\n message: Schema.String,\n}) {}\n\n/** Terminal event for a run awaiting resumable external input. */\nexport class RunSuspended extends Schema.TaggedClass<RunSuspended>()(\"RunSuspended\", {\n ...RunEventBase,\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n reason: Schema.String,\n}) {}\n\nconst SubagentText = Schema.String.check(Schema.isMaxLength(4 * 1024));\n\nconst SubagentEventBase = {\n ...RunEventBase,\n turnId: TurnId,\n toolCallId: ToolCallId,\n delegationId: DelegationId,\n childThreadId: ThreadId,\n childRunId: RunId,\n targetAgentId: AgentId,\n depth: DelegationDepth,\n};\n\n/** Signals that a delegation Tool Call passed preflight with preallocated child identity. */\nexport class SubagentRequested extends Schema.TaggedClass<SubagentRequested>()(\n \"SubagentRequested\",\n SubagentEventBase,\n) {}\n\n/** Signals that the child run has started inside its parent-owned scoped region. */\nexport class SubagentStarted extends Schema.TaggedClass<SubagentStarted>()(\n \"SubagentStarted\",\n SubagentEventBase,\n) {}\n\n/** Carries a bounded child progress summary without duplicating the child event stream. */\nexport class SubagentProgress extends Schema.TaggedClass<SubagentProgress>()(\"SubagentProgress\", {\n ...SubagentEventBase,\n summary: SubagentText,\n}) {}\n\n/**\n * Records the child run's successful terminal outcome before the parent join.\n * Same invariant as `RunCompleted`: `exhausted` is present exactly when\n * `finishReason` is `\"budget-exhausted\"` (the pair travels verbatim from the\n * child's terminal event); consumers treat a divergent pair fail-safe.\n */\nexport class SubagentCompleted extends Schema.TaggedClass<SubagentCompleted>()(\n \"SubagentCompleted\",\n Schema.Struct({\n ...SubagentEventBase,\n turns: Schema.Int.check(Schema.isGreaterThan(0)),\n finishReason: CompletionFinishReason,\n exhausted: Schema.optionalKey(ExhaustedLimit),\n /**\n * The child's own observed usage. Delegated usage covers its attached descendants separately.\n */\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n }).check(Schema.makeFilter((event) => validateCompletionMetadata(event))),\n) {}\n\n/** Records the child run's expected terminal failure using safe, serializable diagnostics. */\nexport class SubagentFailed extends Schema.TaggedClass<SubagentFailed>()(\"SubagentFailed\", {\n ...SubagentEventBase,\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n errorTag: Schema.NonEmptyString,\n message: SubagentText,\n}) {}\n\n/** Records that the child run was stopped by interruption before a terminal outcome. */\nexport class SubagentInterrupted extends Schema.TaggedClass<SubagentInterrupted>()(\n \"SubagentInterrupted\",\n {\n ...SubagentEventBase,\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n reason: SubagentText,\n },\n) {}\n\n/** Records that the child's terminal outcome was joined into its parent delegation Tool Call. */\nexport class SubagentJoined extends Schema.TaggedClass<SubagentJoined>()(\"SubagentJoined\", {\n ...SubagentEventBase,\n usage: Schema.optionalKey(RunTotals),\n delegatedUsage: Schema.optionalKey(RunTotals),\n}) {}\n\n/** Versioned union of stable semantic run events, excluding raw provider chunks. */\nexport const RunEvent = Schema.Union([\n AgentUpdateEmitted,\n RunStarted,\n TurnStarted,\n ModelStarted,\n ModelRestarted,\n TextDelta,\n ReasoningDelta,\n ToolCallDeclared,\n ToolCallStarted,\n ToolProgress,\n ToolCallSucceeded,\n ToolCallFailed,\n ApprovalRequested,\n TurnCompleted,\n BudgetWarning,\n CompactionPerformed,\n RunCompleted,\n RunFailed,\n RunInterrupted,\n RunSuspended,\n SubagentRequested,\n SubagentStarted,\n SubagentProgress,\n SubagentCompleted,\n SubagentFailed,\n SubagentInterrupted,\n SubagentJoined,\n]);\n\nexport type RunEvent = typeof RunEvent.Type;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,eAAe;CACnB,cAAc,OAAO,QAAQ,CAAC;CAC9B,OAAO;CACP,UAAU;CACV,SAAS;CACT,UAAU,OAAO;CACjB,WAAW,OAAO;CAClB,QAAQ,OAAO,YAAY,MAAM;CACjC,YAAY,OAAO,YAAY,UAAU;AAC3C;;AAGA,IAAa,qBAAb,cAAwC,OAAO,YAAgC,CAAC,CAC9E,sBACA;CAAE,GAAG;CAAc,QAAQ;AAAO,CACpC,CAAC,CAAC,CAAC;;AAGH,IAAa,aAAb,cAAgC,OAAO,YAAwB,CAAC,CAAC,cAAc,YAAY,CAAC,CAAC,CAAC;;AAG9F,IAAa,cAAb,cAAiC,OAAO,YAAyB,CAAC,CAAC,eAAe;CAChF,GAAG;CACH,MAAM,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC,CAAC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,YAAY,SAAS;CACnC,gBAAgB,OAAO,YAAY,SAAS;CAC5C,QAAQ;AACV,CACF,CAAC,CAAC,CAAC;;AAGH,IAAa,iBAAb,cAAoC,OAAO,YAA4B,CAAC,CAAC,kBAAkB;CACzF,GAAG;CACH,OAAO,OAAO,YAAY,SAAS;CACnC,gBAAgB,OAAO,YAAY,SAAS;AAC9C,CAAC,CAAC,CAAC,CAAC;;AAGJ,MAAa,WAAW,OAAO,MAAM;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
@@ -1,2 +1,2 @@
1
- import { t as RunPolicyUsage } from "../RunPolicyUsage-CUudVtg_.mjs";
1
+ import { t as RunPolicyUsage } from "../RunPolicyUsage-QmYVw9z8.mjs";
2
2
  export { RunPolicyUsage };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
- import { Schema } from "effect";
2
+ import * as Schema from "effect/Schema";
3
3
  //#region src/core/RunPolicyUsage.ts
4
4
  var RunPolicyUsage_exports = /* @__PURE__ */ __exportAll({ RunPolicyUsage: () => RunPolicyUsage });
5
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"RunPolicyUsage.mjs","names":[],"sources":["../../src/core/RunPolicyUsage.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\n/**\n * Cumulative policy accounting for one logical Run across replacement Attempts.\n * Turns and model-declared calls include a pending batch. The failure streak excludes that\n * entire batch until its declaration-ordered outcomes are folded once during continuation.\n * Programmatic calls are reserved before execution; finalization is reserved before its model call.\n */\nexport const RunPolicyUsage = Schema.Struct({\n committedTurns: Schema.Natural,\n toolCalls: Schema.Natural,\n programmaticToolCalls: Schema.Natural,\n consecutiveToolFailures: Schema.Natural,\n finalizationUsed: Schema.Boolean,\n /** Joined-input replacements already reserved; absent before this feature. */\n modelRestarts: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 2 }))),\n});\n\nexport type RunPolicyUsage = typeof RunPolicyUsage.Type;\n"],"mappings":";;;;;;;;;;AAQA,MAAa,iBAAiB,OAAO,OAAO;CAC1C,gBAAgB,OAAO;CACvB,WAAW,OAAO;CAClB,uBAAuB,OAAO;CAC9B,yBAAyB,OAAO;CAChC,kBAAkB,OAAO;;CAEzB,eAAe,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAE,CAAC,CAAC,CAAC;AAClG,CAAC"}
1
+ {"version":3,"file":"RunPolicyUsage.mjs","names":[],"sources":["../../src/core/RunPolicyUsage.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\n/**\n * Cumulative policy accounting for one logical Run across replacement Attempts.\n * Turns and model-declared calls include a pending batch. The failure streak excludes that\n * entire batch until its declaration-ordered outcomes are folded once during continuation.\n * Programmatic calls are reserved before execution; finalization is reserved before its model call.\n */\nexport const RunPolicyUsage = Schema.Struct({\n committedTurns: Schema.Natural,\n toolCalls: Schema.Natural,\n programmaticToolCalls: Schema.Natural,\n consecutiveToolFailures: Schema.Natural,\n finalizationUsed: Schema.Boolean,\n /** Joined-input replacements already reserved; absent before this feature. */\n modelRestarts: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 2 }))),\n});\n\nexport type RunPolicyUsage = typeof RunPolicyUsage.Type;\n"],"mappings":";;;;;;;;;;AAQA,MAAa,iBAAiB,OAAO,OAAO;CAC1C,gBAAgB,OAAO;CACvB,WAAW,OAAO;CAClB,uBAAuB,OAAO;CAC9B,yBAAyB,OAAO;CAChC,kBAAkB,OAAO;;CAEzB,eAAe,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAE,CAAC,CAAC,CAAC;AAClG,CAAC"}
@@ -1,2 +1,2 @@
1
- import { _ as narrowSubagentGrant, c as SubagentExecutionFailureClassification, d as SubagentReservationAmounts, f as ToolExecutionKind, g as maxErrorTagLength, h as isSubagentToolAllowed, i as SubagentBudgetReservation, l as SubagentGrant, m as getToolExecutionKind, n as DelegationDepth, o as SubagentDelegationCaps, p as WorkerOperationTool, r as DelegationTool, s as SubagentExecutionFailure, t as BackgroundSpawnTool, u as SubagentParentLink } from "../SubagentContract-tyN9v-Jv.mjs";
1
+ import { _ as narrowSubagentGrant, c as SubagentExecutionFailureClassification, d as SubagentReservationAmounts, f as ToolExecutionKind, g as maxErrorTagLength, h as isSubagentToolAllowed, i as SubagentBudgetReservation, l as SubagentGrant, m as getToolExecutionKind, n as DelegationDepth, o as SubagentDelegationCaps, p as WorkerOperationTool, r as DelegationTool, s as SubagentExecutionFailure, t as BackgroundSpawnTool, u as SubagentParentLink } from "../SubagentContract-DdPzxYQj.mjs";
2
2
  export { BackgroundSpawnTool, DelegationDepth, DelegationTool, SubagentBudgetReservation, SubagentDelegationCaps, SubagentExecutionFailure, SubagentExecutionFailureClassification, SubagentGrant, SubagentParentLink, SubagentReservationAmounts, ToolExecutionKind, WorkerOperationTool, getToolExecutionKind, isSubagentToolAllowed, maxErrorTagLength, narrowSubagentGrant };
@@ -1,6 +1,7 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { AgentId, DelegationId, RunId, SubmissionId, ThreadId, ToolCallId } from "./Identifiers.mjs";
3
- import { Context, Schema } from "effect";
3
+ import * as Schema from "effect/Schema";
4
+ import * as Context from "effect/Context";
4
5
  //#region src/core/SubagentContract.ts
5
6
  var SubagentContract_exports = /* @__PURE__ */ __exportAll({
6
7
  BackgroundSpawnTool: () => BackgroundSpawnTool,