effect-agent 0.1.0-beta.85 → 0.1.0-beta.87

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 (751) hide show
  1. package/dist/Agent-CN0EWRsR.d.mts +226 -0
  2. package/dist/Agent-RklVROrm.mjs +83 -0
  3. package/dist/Agent-RklVROrm.mjs.map +1 -0
  4. package/dist/AgentError-CggcAQ7V.d.mts +101 -0
  5. package/dist/AgentPolicy-CetmQrf3.d.mts +96 -0
  6. package/dist/AgentRuntime-BLyETCPo.mjs +4562 -0
  7. package/dist/AgentRuntime-BLyETCPo.mjs.map +1 -0
  8. package/dist/AgentRuntime-uxR_a4VM.d.mts +346 -0
  9. package/dist/AgentUpdates-DMJ-_xow.d.mts +53 -0
  10. package/dist/ContextCompactor-Dxu5zhOL.d.mts +161 -0
  11. package/dist/ContextWindow-DRQ5Mbm2.d.mts +58 -0
  12. package/dist/DurableAgentRuntime-uggeJpv3.mjs +6368 -0
  13. package/dist/DurableAgentRuntime-uggeJpv3.mjs.map +1 -0
  14. package/dist/DurableFailpoint-Oinuuedm.d.mts +41 -0
  15. package/dist/DurableStep-Cry_iol4.d.mts +103 -0
  16. package/dist/Ephemeral.d.mts +22 -0
  17. package/dist/Ephemeral.mjs +22 -0
  18. package/dist/Ephemeral.mjs.map +1 -0
  19. package/dist/EventSource-OqS_P9ug.d.mts +51 -0
  20. package/dist/Identifiers-CN2s30fF.d.mts +40 -0
  21. package/dist/MemoryNamespace-BbRW5p71.d.mts +36 -0
  22. package/dist/MemoryReference-B8Q3UJoJ.d.mts +79 -0
  23. package/dist/Messaging-CkcIdt4I.d.mts +490 -0
  24. package/dist/MessagingHost-CRk0kXzT.d.mts +246 -0
  25. package/dist/MessagingHost-CWi_PP3g.mjs +137 -0
  26. package/dist/MessagingHost-CWi_PP3g.mjs.map +1 -0
  27. package/dist/OperationAuthorizer-TzcQtpX5.d.mts +61 -0
  28. package/dist/Output-D6SkedVx.d.mts +25 -0
  29. package/dist/PageCapture-Df8Xwskw.d.mts +583 -0
  30. package/dist/PageScreenshot-BpgZKAxl.d.mts +48 -0
  31. package/dist/PreparedInputAdmission-C4HbjHgl.d.mts +38 -0
  32. package/dist/Receipt-BAHyigAF.d.mts +33 -0
  33. package/dist/Records-BAGkekt8.d.mts +3570 -0
  34. package/dist/RunEvent-DIrzkjLr.d.mts +460 -0
  35. package/dist/RunEventSink-D5aVhISG.d.mts +108 -0
  36. package/dist/RunJournal-Cgg1kNvc.mjs +825 -0
  37. package/dist/RunJournal-Cgg1kNvc.mjs.map +1 -0
  38. package/dist/RunOptions-g1aigcKI.d.mts +915 -0
  39. package/dist/RunPolicyUsage-ClZxyR46.d.mts +21 -0
  40. package/dist/Sandbox-CEsDWBLq.d.mts +173 -0
  41. package/dist/Schedule-H3SEYX9g.d.mts +842 -0
  42. package/dist/Scheduling-C9aIP8zT.mjs +691 -0
  43. package/dist/Scheduling-C9aIP8zT.mjs.map +1 -0
  44. package/dist/Subagent-Cy_hU1tv.mjs +1469 -0
  45. package/dist/Subagent-Cy_hU1tv.mjs.map +1 -0
  46. package/dist/Subagent-DyfzHNdv.d.mts +826 -0
  47. package/dist/SubagentContract-DdT7Cqe6.d.mts +116 -0
  48. package/dist/SubagentHost-CJUBQlcc.d.mts +140 -0
  49. package/dist/Subscription-BEP8oQO5.d.mts +921 -0
  50. package/dist/SubscriptionInput-vAAOBrK7.d.mts +41 -0
  51. package/dist/Thread-DOBQ0QUY.d.mts +96 -0
  52. package/dist/ThreadHistory-tS1KwxHR.d.mts +60 -0
  53. package/dist/ToolBroker-DWs4tZra.d.mts +133 -0
  54. package/dist/ToolExposure-9uF_Yo0T.mjs +10 -0
  55. package/dist/ToolExposure-9uF_Yo0T.mjs.map +1 -0
  56. package/dist/ToolExposure-C93U1sPu.mjs +30 -0
  57. package/dist/ToolExposure-C93U1sPu.mjs.map +1 -0
  58. package/dist/ToolExposure-UCN12eCd.d.mts +39 -0
  59. package/dist/ToolExposure-r2eOWk4F.d.mts +46 -0
  60. package/dist/ToolExposure.d.mts +6 -5
  61. package/dist/ToolExposure.mjs +17 -9
  62. package/dist/ToolExposure.mjs.map +1 -1
  63. package/dist/ToolReconciler-DQVaJfpE.d.mts +76 -0
  64. package/dist/ToolResult-DmmgoChv.d.mts +61 -0
  65. package/dist/Usage-Dx0aknfk.d.mts +121 -0
  66. package/dist/WakeScheduler-EjUF-GhC.d.mts +56 -0
  67. package/dist/Worker-CaPYykpe.d.mts +228 -0
  68. package/dist/agent-registration-CWDMOAZA.mjs +172 -0
  69. package/dist/agent-registration-CWDMOAZA.mjs.map +1 -0
  70. package/dist/capabilities/Approval.d.mts +114 -0
  71. package/dist/capabilities/Approval.mjs +226 -0
  72. package/dist/capabilities/Approval.mjs.map +1 -0
  73. package/dist/capabilities/Budget.d.mts +112 -0
  74. package/dist/capabilities/Budget.mjs +346 -0
  75. package/dist/capabilities/Budget.mjs.map +1 -0
  76. package/dist/capabilities/CodeMode.d.mts +157 -0
  77. package/dist/capabilities/CodeMode.mjs +522 -0
  78. package/dist/capabilities/CodeMode.mjs.map +1 -0
  79. package/dist/capabilities/Commands.d.mts +55 -0
  80. package/dist/capabilities/Commands.mjs +57 -0
  81. package/dist/capabilities/Commands.mjs.map +1 -0
  82. package/dist/capabilities/ContextTools.d.mts +321 -0
  83. package/dist/capabilities/ContextTools.mjs +126 -0
  84. package/dist/capabilities/ContextTools.mjs.map +1 -0
  85. package/dist/capabilities/Mcp.d.mts +108 -0
  86. package/dist/capabilities/Mcp.mjs +260 -0
  87. package/dist/capabilities/Mcp.mjs.map +1 -0
  88. package/dist/capabilities/McpClient.d.mts +115 -0
  89. package/dist/capabilities/McpClient.mjs +506 -0
  90. package/dist/capabilities/McpClient.mjs.map +1 -0
  91. package/dist/capabilities/MemoryNotes.d.mts +424 -0
  92. package/dist/capabilities/MemoryNotes.mjs +128 -0
  93. package/dist/capabilities/MemoryNotes.mjs.map +1 -0
  94. package/dist/capabilities/Messaging.d.mts +3 -0
  95. package/dist/capabilities/Messaging.mjs +151 -0
  96. package/dist/capabilities/Messaging.mjs.map +1 -0
  97. package/dist/capabilities/ModelContext.d.mts +89 -0
  98. package/dist/capabilities/ModelContext.mjs +168 -0
  99. package/dist/capabilities/ModelContext.mjs.map +1 -0
  100. package/dist/capabilities/Redaction.d.mts +37 -0
  101. package/dist/capabilities/Redaction.mjs +104 -0
  102. package/dist/capabilities/Redaction.mjs.map +1 -0
  103. package/dist/capabilities/Remembering.d.mts +434 -0
  104. package/dist/capabilities/Remembering.mjs +290 -0
  105. package/dist/capabilities/Remembering.mjs.map +1 -0
  106. package/dist/capabilities/RunHooks.d.mts +82 -0
  107. package/dist/capabilities/RunHooks.mjs +144 -0
  108. package/dist/capabilities/RunHooks.mjs.map +1 -0
  109. package/dist/capabilities/SemanticMemory.d.mts +431 -0
  110. package/dist/capabilities/SemanticMemory.mjs +315 -0
  111. package/dist/capabilities/SemanticMemory.mjs.map +1 -0
  112. package/dist/capabilities/Subagent.d.mts +4 -0
  113. package/dist/capabilities/Subagent.mjs +5 -0
  114. package/dist/capabilities/SubagentReservations.d.mts +186 -0
  115. package/dist/capabilities/SubagentReservations.mjs +479 -0
  116. package/dist/capabilities/SubagentReservations.mjs.map +1 -0
  117. package/dist/capabilities/ToolDiscovery.d.mts +109 -0
  118. package/dist/capabilities/ToolDiscovery.mjs +211 -0
  119. package/dist/capabilities/ToolDiscovery.mjs.map +1 -0
  120. package/dist/capabilities/WebCapture.d.mts +163 -0
  121. package/dist/capabilities/WebCapture.mjs +335 -0
  122. package/dist/capabilities/WebCapture.mjs.map +1 -0
  123. package/dist/capabilities/WebSearch.d.mts +71 -0
  124. package/dist/capabilities/WebSearch.mjs +112 -0
  125. package/dist/capabilities/WebSearch.mjs.map +1 -0
  126. package/dist/compaction-C2OTceKw.mjs +505 -0
  127. package/dist/compaction-C2OTceKw.mjs.map +1 -0
  128. package/dist/core/Agent.d.mts +2 -0
  129. package/dist/core/Agent.mjs +2 -0
  130. package/dist/core/AgentError.d.mts +2 -0
  131. package/dist/core/AgentError.mjs +117 -0
  132. package/dist/core/AgentError.mjs.map +1 -0
  133. package/dist/core/AgentPolicy.d.mts +2 -0
  134. package/dist/core/AgentPolicy.mjs +94 -0
  135. package/dist/core/AgentPolicy.mjs.map +1 -0
  136. package/dist/core/AgentUpdates.d.mts +2 -0
  137. package/dist/core/AgentUpdates.mjs +63 -0
  138. package/dist/core/AgentUpdates.mjs.map +1 -0
  139. package/dist/core/IdGenerator.d.mts +26 -0
  140. package/dist/core/IdGenerator.mjs +27 -0
  141. package/dist/core/IdGenerator.mjs.map +1 -0
  142. package/dist/core/Identifiers.d.mts +2 -0
  143. package/dist/core/Identifiers.mjs +43 -0
  144. package/dist/core/Identifiers.mjs.map +1 -0
  145. package/dist/core/Memory.d.mts +57 -0
  146. package/dist/core/Memory.mjs +203 -0
  147. package/dist/core/Memory.mjs.map +1 -0
  148. package/dist/core/MemoryNamespace.d.mts +2 -0
  149. package/dist/core/MemoryNamespace.mjs +116 -0
  150. package/dist/core/MemoryNamespace.mjs.map +1 -0
  151. package/dist/core/MemoryReference.d.mts +2 -0
  152. package/dist/core/MemoryReference.mjs +109 -0
  153. package/dist/core/MemoryReference.mjs.map +1 -0
  154. package/dist/core/MemoryRevalidation.d.mts +65 -0
  155. package/dist/core/MemoryRevalidation.mjs +126 -0
  156. package/dist/core/MemoryRevalidation.mjs.map +1 -0
  157. package/dist/core/MemoryStore.d.mts +186 -0
  158. package/dist/core/MemoryStore.mjs +243 -0
  159. package/dist/core/MemoryStore.mjs.map +1 -0
  160. package/dist/core/Receipt.d.mts +2 -0
  161. package/dist/core/Receipt.mjs +36 -0
  162. package/dist/core/Receipt.mjs.map +1 -0
  163. package/dist/core/RememberingStore.d.mts +1562 -0
  164. package/dist/core/RememberingStore.mjs +190 -0
  165. package/dist/core/RememberingStore.mjs.map +1 -0
  166. package/dist/core/RunEvent.d.mts +2 -0
  167. package/dist/core/RunEvent.mjs +337 -0
  168. package/dist/core/RunEvent.mjs.map +1 -0
  169. package/dist/core/RunPolicyUsage.d.mts +2 -0
  170. package/dist/core/RunPolicyUsage.mjs +21 -0
  171. package/dist/core/RunPolicyUsage.mjs.map +1 -0
  172. package/dist/core/SemanticMemoryIndex.d.mts +826 -0
  173. package/dist/core/SemanticMemoryIndex.mjs +185 -0
  174. package/dist/core/SemanticMemoryIndex.mjs.map +1 -0
  175. package/dist/core/SemanticMemoryRevalidation.d.mts +45 -0
  176. package/dist/core/SemanticMemoryRevalidation.mjs +191 -0
  177. package/dist/core/SemanticMemoryRevalidation.mjs.map +1 -0
  178. package/dist/core/SubagentContract.d.mts +2 -0
  179. package/dist/core/SubagentContract.mjs +148 -0
  180. package/dist/core/SubagentContract.mjs.map +1 -0
  181. package/dist/core/Thread.d.mts +2 -0
  182. package/dist/core/Thread.mjs +250 -0
  183. package/dist/core/Thread.mjs.map +1 -0
  184. package/dist/core/ToolResult.d.mts +2 -0
  185. package/dist/core/ToolResult.mjs +140 -0
  186. package/dist/core/ToolResult.mjs.map +1 -0
  187. package/dist/core/Usage.d.mts +2 -0
  188. package/dist/core/Usage.mjs +319 -0
  189. package/dist/core/Usage.mjs.map +1 -0
  190. package/dist/core/Worker.d.mts +3 -0
  191. package/dist/core/Worker.mjs +147 -0
  192. package/dist/core/Worker.mjs.map +1 -0
  193. package/dist/durable/ActivityStore.d.mts +116 -0
  194. package/dist/durable/ActivityStore.mjs +131 -0
  195. package/dist/durable/ActivityStore.mjs.map +1 -0
  196. package/dist/durable/Admin.d.mts +2 -0
  197. package/dist/durable/Admin.mjs +328 -0
  198. package/dist/durable/Admin.mjs.map +1 -0
  199. package/dist/durable/AgentRegistration.d.mts +2 -0
  200. package/dist/durable/AgentRegistration.mjs +14 -0
  201. package/dist/durable/AgentRegistration.mjs.map +1 -0
  202. package/dist/durable/Certification.d.mts +111 -0
  203. package/dist/durable/Certification.mjs +159 -0
  204. package/dist/durable/Certification.mjs.map +1 -0
  205. package/dist/durable/CommittedActivity.d.mts +62 -0
  206. package/dist/durable/CommittedActivity.mjs +159 -0
  207. package/dist/durable/CommittedActivity.mjs.map +1 -0
  208. package/dist/durable/Digest.d.mts +2 -0
  209. package/dist/durable/Digest.mjs +50 -0
  210. package/dist/durable/Digest.mjs.map +1 -0
  211. package/dist/durable/DurableAgentRuntime.d.mts +3 -0
  212. package/dist/durable/DurableAgentRuntime.mjs +3 -0
  213. package/dist/durable/DurableFailpoint.d.mts +2 -0
  214. package/dist/durable/DurableFailpoint.mjs +94 -0
  215. package/dist/durable/DurableFailpoint.mjs.map +1 -0
  216. package/dist/durable/DurableFailpointTestControl.d.mts +15 -0
  217. package/dist/durable/DurableFailpointTestControl.mjs +19 -0
  218. package/dist/durable/DurableFailpointTestControl.mjs.map +1 -0
  219. package/dist/durable/EventSource.d.mts +2 -0
  220. package/dist/durable/EventSource.mjs +65 -0
  221. package/dist/durable/EventSource.mjs.map +1 -0
  222. package/dist/durable/GitHubWorkflowSource.d.mts +144 -0
  223. package/dist/durable/GitHubWorkflowSource.mjs +209 -0
  224. package/dist/durable/GitHubWorkflowSource.mjs.map +1 -0
  225. package/dist/durable/MessageDelivery.d.mts +492 -0
  226. package/dist/durable/MessageDelivery.mjs +495 -0
  227. package/dist/durable/MessageDelivery.mjs.map +1 -0
  228. package/dist/durable/MessageDeliveryStoreConformance.d.mts +358 -0
  229. package/dist/durable/MessageDeliveryStoreConformance.mjs +243 -0
  230. package/dist/durable/MessageDeliveryStoreConformance.mjs.map +1 -0
  231. package/dist/durable/OperationAuthorizer.d.mts +2 -0
  232. package/dist/durable/OperationAuthorizer.mjs +70 -0
  233. package/dist/durable/OperationAuthorizer.mjs.map +1 -0
  234. package/dist/durable/PersistentHistory.d.mts +16 -0
  235. package/dist/durable/PersistentHistory.mjs +125 -0
  236. package/dist/durable/PersistentHistory.mjs.map +1 -0
  237. package/dist/durable/PreparedInputAdmission.d.mts +2 -0
  238. package/dist/durable/PreparedInputAdmission.mjs +34 -0
  239. package/dist/durable/PreparedInputAdmission.mjs.map +1 -0
  240. package/dist/durable/Records.d.mts +2 -0
  241. package/dist/durable/Records.mjs +795 -0
  242. package/dist/durable/Records.mjs.map +1 -0
  243. package/dist/durable/Recovery.d.mts +2 -0
  244. package/dist/durable/Recovery.mjs +739 -0
  245. package/dist/durable/Recovery.mjs.map +1 -0
  246. package/dist/durable/RunJournal.d.mts +2 -0
  247. package/dist/durable/RunJournal.mjs +2 -0
  248. package/dist/durable/Schedule.d.mts +2 -0
  249. package/dist/durable/Schedule.mjs +382 -0
  250. package/dist/durable/Schedule.mjs.map +1 -0
  251. package/dist/durable/ScheduleStoreConformance.d.mts +18 -0
  252. package/dist/durable/ScheduleStoreConformance.mjs +420 -0
  253. package/dist/durable/ScheduleStoreConformance.mjs.map +1 -0
  254. package/dist/durable/ScheduleTransition.d.mts +24 -0
  255. package/dist/durable/ScheduleTransition.mjs +180 -0
  256. package/dist/durable/ScheduleTransition.mjs.map +1 -0
  257. package/dist/durable/Scheduling.d.mts +54 -0
  258. package/dist/durable/Scheduling.mjs +2 -0
  259. package/dist/durable/SqlMemoryStore.d.mts +30 -0
  260. package/dist/durable/SqlMemoryStore.mjs +435 -0
  261. package/dist/durable/SqlMemoryStore.mjs.map +1 -0
  262. package/dist/durable/SqlMessageDeliveryStore.d.mts +40 -0
  263. package/dist/durable/SqlMessageDeliveryStore.mjs +167 -0
  264. package/dist/durable/SqlMessageDeliveryStore.mjs.map +1 -0
  265. package/dist/durable/SqlStorageV2Upgrade.d.mts +22 -0
  266. package/dist/durable/SqlStorageV2Upgrade.mjs +459 -0
  267. package/dist/durable/SqlStorageV2Upgrade.mjs.map +1 -0
  268. package/dist/durable/SqlSubscriptionStore.d.mts +63 -0
  269. package/dist/durable/SqlSubscriptionStore.mjs +751 -0
  270. package/dist/durable/SqlSubscriptionStore.mjs.map +1 -0
  271. package/dist/durable/SubmissionLedger.d.mts +3 -0
  272. package/dist/durable/SubmissionLedger.mjs +914 -0
  273. package/dist/durable/SubmissionLedger.mjs.map +1 -0
  274. package/dist/durable/SubmissionLedgerConformance.d.mts +30 -0
  275. package/dist/durable/SubmissionLedgerConformance.mjs +1986 -0
  276. package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -0
  277. package/dist/durable/SubmissionStatus.d.mts +2 -0
  278. package/dist/durable/SubmissionStatus.mjs +18 -0
  279. package/dist/durable/SubmissionStatus.mjs.map +1 -0
  280. package/dist/durable/Subscription.d.mts +2 -0
  281. package/dist/durable/Subscription.mjs +360 -0
  282. package/dist/durable/Subscription.mjs.map +1 -0
  283. package/dist/durable/SubscriptionInput.d.mts +2 -0
  284. package/dist/durable/SubscriptionInput.mjs +52 -0
  285. package/dist/durable/SubscriptionInput.mjs.map +1 -0
  286. package/dist/durable/SubscriptionStoreConformance.d.mts +17 -0
  287. package/dist/durable/SubscriptionStoreConformance.mjs +625 -0
  288. package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -0
  289. package/dist/durable/SubscriptionTools.d.mts +273 -0
  290. package/dist/durable/SubscriptionTools.mjs +190 -0
  291. package/dist/durable/SubscriptionTools.mjs.map +1 -0
  292. package/dist/durable/SubscriptionTransition.d.mts +21 -0
  293. package/dist/durable/SubscriptionTransition.mjs +148 -0
  294. package/dist/durable/SubscriptionTransition.mjs.map +1 -0
  295. package/dist/durable/Subscriptions.d.mts +73 -0
  296. package/dist/durable/Subscriptions.mjs +627 -0
  297. package/dist/durable/Subscriptions.mjs.map +1 -0
  298. package/dist/durable/ThreadContextHistory.d.mts +32 -0
  299. package/dist/durable/ThreadContextHistory.mjs +152 -0
  300. package/dist/durable/ThreadContextHistory.mjs.map +1 -0
  301. package/dist/durable/ThreadContextHistoryProjection.d.mts +60 -0
  302. package/dist/durable/ThreadContextHistoryProjection.mjs +149 -0
  303. package/dist/durable/ThreadContextHistoryProjection.mjs.map +1 -0
  304. package/dist/durable/ThreadInvariants.d.mts +74 -0
  305. package/dist/durable/ThreadInvariants.mjs +200 -0
  306. package/dist/durable/ThreadInvariants.mjs.map +1 -0
  307. package/dist/durable/ThreadProjection.d.mts +78 -0
  308. package/dist/durable/ThreadProjection.mjs +158 -0
  309. package/dist/durable/ThreadProjection.mjs.map +1 -0
  310. package/dist/durable/ThreadProjectionMaintenance.d.mts +49 -0
  311. package/dist/durable/ThreadProjectionMaintenance.mjs +33 -0
  312. package/dist/durable/ThreadProjectionMaintenance.mjs.map +1 -0
  313. package/dist/durable/ThreadStore.d.mts +2 -0
  314. package/dist/durable/ThreadStore.mjs +147 -0
  315. package/dist/durable/ThreadStore.mjs.map +1 -0
  316. package/dist/durable/ThreadStoreConformance.d.mts +29 -0
  317. package/dist/durable/ThreadStoreConformance.mjs +248 -0
  318. package/dist/durable/ThreadStoreConformance.mjs.map +1 -0
  319. package/dist/durable/ToolReconciler.d.mts +2 -0
  320. package/dist/durable/ToolReconciler.mjs +81 -0
  321. package/dist/durable/ToolReconciler.mjs.map +1 -0
  322. package/dist/durable/WakeScheduler.d.mts +2 -0
  323. package/dist/durable/WakeScheduler.mjs +85 -0
  324. package/dist/durable/WakeScheduler.mjs.map +1 -0
  325. package/dist/durable/WorkerHost.d.mts +129 -0
  326. package/dist/durable/WorkerHost.mjs +77 -0
  327. package/dist/durable/WorkerHost.mjs.map +1 -0
  328. package/dist/engine/AgentRuntime.d.mts +2 -0
  329. package/dist/engine/AgentRuntime.mjs +2 -0
  330. package/dist/engine/Compaction.d.mts +7 -0
  331. package/dist/engine/Compaction.mjs +16 -0
  332. package/dist/engine/Compaction.mjs.map +1 -0
  333. package/dist/engine/ContextCompactor.d.mts +2 -0
  334. package/dist/engine/ContextCompactor.mjs +119 -0
  335. package/dist/engine/ContextCompactor.mjs.map +1 -0
  336. package/dist/engine/ContextHistory.d.mts +65 -0
  337. package/dist/engine/ContextHistory.mjs +76 -0
  338. package/dist/engine/ContextHistory.mjs.map +1 -0
  339. package/dist/engine/ContextWindow.d.mts +2 -0
  340. package/dist/engine/ContextWindow.mjs +59 -0
  341. package/dist/engine/ContextWindow.mjs.map +1 -0
  342. package/dist/engine/DurableStep.d.mts +2 -0
  343. package/dist/engine/DurableStep.mjs +62 -0
  344. package/dist/engine/DurableStep.mjs.map +1 -0
  345. package/dist/engine/MessagingHost.d.mts +2 -0
  346. package/dist/engine/MessagingHost.mjs +2 -0
  347. package/dist/engine/Output.d.mts +2 -0
  348. package/dist/engine/Output.mjs +8 -0
  349. package/dist/engine/Output.mjs.map +1 -0
  350. package/dist/engine/RunEventSink.d.mts +2 -0
  351. package/dist/engine/RunEventSink.mjs +22 -0
  352. package/dist/engine/RunEventSink.mjs.map +1 -0
  353. package/dist/engine/RunOptions.d.mts +2 -0
  354. package/dist/engine/RunOptions.mjs +122 -0
  355. package/dist/engine/RunOptions.mjs.map +1 -0
  356. package/dist/engine/SubagentHost.d.mts +2 -0
  357. package/dist/engine/SubagentHost.mjs +72 -0
  358. package/dist/engine/SubagentHost.mjs.map +1 -0
  359. package/dist/engine/ThreadHistory.d.mts +2 -0
  360. package/dist/engine/ThreadHistory.mjs +67 -0
  361. package/dist/engine/ThreadHistory.mjs.map +1 -0
  362. package/dist/engine/ToolBroker.d.mts +2 -0
  363. package/dist/engine/ToolBroker.mjs +42 -0
  364. package/dist/engine/ToolBroker.mjs.map +1 -0
  365. package/dist/foreign-diagnostic-DBQ1XHKh.mjs +37 -0
  366. package/dist/foreign-diagnostic-DBQ1XHKh.mjs.map +1 -0
  367. package/dist/index.d.mts +88 -54
  368. package/dist/index.mjs +97 -54
  369. package/dist/output-contract-BC7tjlGw.mjs +84 -0
  370. package/dist/output-contract-BC7tjlGw.mjs.map +1 -0
  371. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  372. package/dist/sandbox/CodeExecutor.d.mts +194 -0
  373. package/dist/sandbox/CodeExecutor.mjs +278 -0
  374. package/dist/sandbox/CodeExecutor.mjs.map +1 -0
  375. package/dist/sandbox/InteractiveBrowser.d.mts +142 -0
  376. package/dist/sandbox/InteractiveBrowser.mjs +165 -0
  377. package/dist/sandbox/InteractiveBrowser.mjs.map +1 -0
  378. package/dist/sandbox/PageCapture.d.mts +2 -0
  379. package/dist/sandbox/PageCapture.mjs +450 -0
  380. package/dist/sandbox/PageCapture.mjs.map +1 -0
  381. package/dist/sandbox/PageCrawl.d.mts +88 -0
  382. package/dist/sandbox/PageCrawl.mjs +124 -0
  383. package/dist/sandbox/PageCrawl.mjs.map +1 -0
  384. package/dist/sandbox/PageScreenshot.d.mts +2 -0
  385. package/dist/sandbox/PageScreenshot.mjs +53 -0
  386. package/dist/sandbox/PageScreenshot.mjs.map +1 -0
  387. package/dist/sandbox/ProtectedBrowser.d.mts +252 -0
  388. package/dist/sandbox/ProtectedBrowser.mjs +270 -0
  389. package/dist/sandbox/ProtectedBrowser.mjs.map +1 -0
  390. package/dist/sandbox/Sandbox.d.mts +2 -0
  391. package/dist/sandbox/Sandbox.mjs +208 -0
  392. package/dist/sandbox/Sandbox.mjs.map +1 -0
  393. package/dist/utf8-BYfhEkcj.mjs +11 -0
  394. package/dist/utf8-BYfhEkcj.mjs.map +1 -0
  395. package/dist/utf8-DchGZRBd.mjs +23 -0
  396. package/dist/utf8-DchGZRBd.mjs.map +1 -0
  397. package/package.json +1 -1
  398. package/src/Ephemeral.ts +17 -0
  399. package/src/ToolExposure.ts +2 -2
  400. package/src/capabilities/Approval.ts +352 -0
  401. package/src/capabilities/Budget.ts +536 -0
  402. package/src/capabilities/CodeMode.ts +1090 -0
  403. package/src/capabilities/Commands.ts +86 -0
  404. package/src/capabilities/ContextTools.ts +184 -0
  405. package/src/capabilities/Mcp.ts +427 -0
  406. package/src/capabilities/McpClient.ts +967 -0
  407. package/src/capabilities/MemoryNotes.ts +174 -0
  408. package/src/capabilities/Messaging.ts +261 -0
  409. package/src/capabilities/ModelContext.ts +354 -0
  410. package/src/capabilities/Redaction.ts +157 -0
  411. package/src/capabilities/Remembering.ts +550 -0
  412. package/src/capabilities/RunHooks.ts +280 -0
  413. package/src/capabilities/SemanticMemory.ts +447 -0
  414. package/src/capabilities/Subagent.ts +2277 -0
  415. package/src/capabilities/SubagentReservations.ts +850 -0
  416. package/src/capabilities/ToolDiscovery.ts +339 -0
  417. package/src/capabilities/WebCapture.ts +722 -0
  418. package/src/capabilities/WebSearch.ts +184 -0
  419. package/src/capabilities/internal/subagent-background.ts +1106 -0
  420. package/src/capabilities/internal/subagent-contract.ts +142 -0
  421. package/src/capabilities/internal/subagent-policy.ts +235 -0
  422. package/src/capabilities/internal/subagent-reporting.ts +261 -0
  423. package/src/capabilities/internal/utf8.ts +10 -0
  424. package/src/core/Agent.ts +575 -0
  425. package/src/core/AgentError.ts +152 -0
  426. package/src/core/AgentPolicy.ts +153 -0
  427. package/src/core/AgentUpdates.ts +100 -0
  428. package/src/core/IdGenerator.ts +39 -0
  429. package/src/core/Identifiers.ts +48 -0
  430. package/src/core/Memory.ts +290 -0
  431. package/src/core/MemoryNamespace.ts +196 -0
  432. package/src/core/MemoryReference.ts +121 -0
  433. package/src/core/MemoryRevalidation.ts +185 -0
  434. package/src/core/MemoryStore.ts +368 -0
  435. package/src/core/Messaging.ts +90 -0
  436. package/src/core/Receipt.ts +42 -0
  437. package/src/core/RememberingStore.ts +300 -0
  438. package/src/core/RunEvent.ts +366 -0
  439. package/src/core/RunPolicyUsage.ts +17 -0
  440. package/src/core/SemanticMemoryIndex.ts +250 -0
  441. package/src/core/SemanticMemoryRevalidation.ts +254 -0
  442. package/src/core/SubagentContract.ts +196 -0
  443. package/src/core/Thread.ts +371 -0
  444. package/src/core/ToolExposure.ts +74 -0
  445. package/src/core/ToolResult.ts +170 -0
  446. package/src/core/Usage.ts +529 -0
  447. package/src/core/Worker.ts +173 -0
  448. package/src/core/internal/agent-updates.ts +32 -0
  449. package/src/core/internal/utf8.ts +23 -0
  450. package/src/durable/ActivityStore.ts +160 -0
  451. package/src/durable/Admin.ts +496 -0
  452. package/src/durable/AgentRegistration.ts +13 -0
  453. package/src/durable/Certification.ts +210 -0
  454. package/src/durable/CommittedActivity.ts +296 -0
  455. package/src/durable/Digest.ts +93 -0
  456. package/src/durable/DurableAgentRuntime.ts +10340 -0
  457. package/src/durable/DurableFailpoint.ts +103 -0
  458. package/src/durable/DurableFailpointTestControl.ts +39 -0
  459. package/src/durable/EventSource.ts +172 -0
  460. package/src/durable/GitHubWorkflowSource.ts +453 -0
  461. package/src/durable/MessageDelivery.ts +708 -0
  462. package/src/durable/MessageDeliveryStoreConformance.ts +363 -0
  463. package/src/durable/OperationAuthorizer.ts +85 -0
  464. package/src/durable/PersistentHistory.ts +260 -0
  465. package/src/durable/PreparedInputAdmission.ts +44 -0
  466. package/src/durable/Records.ts +1010 -0
  467. package/src/durable/Recovery.ts +1018 -0
  468. package/src/durable/RunJournal.ts +1479 -0
  469. package/src/durable/Schedule.ts +504 -0
  470. package/src/durable/ScheduleStoreConformance.ts +638 -0
  471. package/src/durable/ScheduleTransition.ts +265 -0
  472. package/src/durable/Scheduling.ts +1077 -0
  473. package/src/durable/SqlMemoryStore.ts +774 -0
  474. package/src/durable/SqlMessageDeliveryStore.ts +302 -0
  475. package/src/durable/SqlStorageV2Upgrade.ts +500 -0
  476. package/src/durable/SqlSubscriptionStore.ts +1440 -0
  477. package/src/durable/SubmissionLedger.ts +1201 -0
  478. package/src/durable/SubmissionLedgerConformance.ts +4579 -0
  479. package/src/durable/SubmissionStatus.ts +14 -0
  480. package/src/durable/Subscription.ts +544 -0
  481. package/src/durable/SubscriptionInput.ts +144 -0
  482. package/src/durable/SubscriptionStoreConformance.ts +945 -0
  483. package/src/durable/SubscriptionTools.ts +327 -0
  484. package/src/durable/SubscriptionTransition.ts +302 -0
  485. package/src/durable/Subscriptions.ts +1210 -0
  486. package/src/durable/ThreadContextHistory.ts +227 -0
  487. package/src/durable/ThreadContextHistoryProjection.ts +216 -0
  488. package/src/durable/ThreadInvariants.ts +442 -0
  489. package/src/durable/ThreadProjection.ts +269 -0
  490. package/src/durable/ThreadProjectionMaintenance.ts +67 -0
  491. package/src/durable/ThreadStore.ts +242 -0
  492. package/src/durable/ThreadStoreConformance.ts +710 -0
  493. package/src/durable/ToolReconciler.ts +105 -0
  494. package/src/durable/WakeScheduler.ts +134 -0
  495. package/src/durable/WorkerHost.ts +171 -0
  496. package/src/durable/internal/agent-registration.ts +525 -0
  497. package/src/durable/internal/agent-updates.ts +302 -0
  498. package/src/durable/internal/foreign-diagnostic.ts +47 -0
  499. package/src/durable/internal/journal-checkpoint.ts +104 -0
  500. package/src/durable/internal/journal-metadata.ts +107 -0
  501. package/src/durable/internal/messaging-host.ts +608 -0
  502. package/src/durable/internal/schedule-time.ts +303 -0
  503. package/src/durable/internal/storage-v2-layout.ts +163 -0
  504. package/src/durable/internal/storage-v2.ts +73 -0
  505. package/src/durable/internal/worker-host.ts +2467 -0
  506. package/src/durable/internal/worker-runtime.ts +9 -0
  507. package/src/engine/AgentRuntime.ts +37 -0
  508. package/src/engine/Compaction.ts +11 -0
  509. package/src/engine/ContextCompactor.ts +277 -0
  510. package/src/engine/ContextHistory.ts +73 -0
  511. package/src/engine/ContextWindow.ts +72 -0
  512. package/src/engine/DurableStep.ts +132 -0
  513. package/src/engine/MessagingHost.ts +110 -0
  514. package/src/engine/Output.ts +2 -0
  515. package/src/engine/RunEventSink.ts +132 -0
  516. package/src/engine/RunOptions.ts +1077 -0
  517. package/src/engine/SubagentHost.ts +181 -0
  518. package/src/engine/ThreadHistory.ts +120 -0
  519. package/src/engine/ToolBroker.ts +157 -0
  520. package/src/engine/ToolExposure.ts +48 -0
  521. package/src/engine/internal/agent-runtime.ts +10117 -0
  522. package/src/engine/internal/bounded-value.ts +315 -0
  523. package/src/engine/internal/compaction.ts +678 -0
  524. package/src/engine/internal/error-diagnostic.ts +39 -0
  525. package/src/engine/internal/output-contract.ts +173 -0
  526. package/src/engine/internal/primitive-delta.ts +80 -0
  527. package/src/engine/internal/provider-result-staging.ts +211 -0
  528. package/src/engine/internal/tool-derivative.ts +106 -0
  529. package/src/engine/internal/tool-exposure.ts +224 -0
  530. package/src/engine/internal/tool-telemetry.ts +484 -0
  531. package/src/index.ts +96 -53
  532. package/src/sandbox/CodeExecutor.ts +352 -0
  533. package/src/sandbox/InteractiveBrowser.ts +257 -0
  534. package/src/sandbox/PageCapture.ts +692 -0
  535. package/src/sandbox/PageCrawl.ts +148 -0
  536. package/src/sandbox/PageScreenshot.ts +81 -0
  537. package/src/sandbox/ProtectedBrowser.ts +413 -0
  538. package/src/sandbox/Sandbox.ts +241 -0
  539. package/dist/Agent.d.mts +0 -5
  540. package/dist/Agent.mjs +0 -10
  541. package/dist/Agent.mjs.map +0 -1
  542. package/dist/AgentError.d.mts +0 -5
  543. package/dist/AgentError.mjs +0 -10
  544. package/dist/AgentError.mjs.map +0 -1
  545. package/dist/AgentPolicy.d.mts +0 -5
  546. package/dist/AgentPolicy.mjs +0 -10
  547. package/dist/AgentPolicy.mjs.map +0 -1
  548. package/dist/AgentRuntime.d.mts +0 -5
  549. package/dist/AgentRuntime.mjs +0 -10
  550. package/dist/AgentRuntime.mjs.map +0 -1
  551. package/dist/AgentUpdates.d.mts +0 -5
  552. package/dist/AgentUpdates.mjs +0 -10
  553. package/dist/AgentUpdates.mjs.map +0 -1
  554. package/dist/Approval.d.mts +0 -5
  555. package/dist/Approval.mjs +0 -10
  556. package/dist/Approval.mjs.map +0 -1
  557. package/dist/Budget.d.mts +0 -5
  558. package/dist/Budget.mjs +0 -10
  559. package/dist/Budget.mjs.map +0 -1
  560. package/dist/CodeMode.d.mts +0 -5
  561. package/dist/CodeMode.mjs +0 -10
  562. package/dist/CodeMode.mjs.map +0 -1
  563. package/dist/Commands.d.mts +0 -5
  564. package/dist/Commands.mjs +0 -10
  565. package/dist/Commands.mjs.map +0 -1
  566. package/dist/Compaction.d.mts +0 -5
  567. package/dist/Compaction.mjs +0 -10
  568. package/dist/Compaction.mjs.map +0 -1
  569. package/dist/ContextCompactor.d.mts +0 -5
  570. package/dist/ContextCompactor.mjs +0 -10
  571. package/dist/ContextCompactor.mjs.map +0 -1
  572. package/dist/ContextHistory.d.mts +0 -5
  573. package/dist/ContextHistory.mjs +0 -10
  574. package/dist/ContextHistory.mjs.map +0 -1
  575. package/dist/ContextTools.d.mts +0 -5
  576. package/dist/ContextTools.mjs +0 -10
  577. package/dist/ContextTools.mjs.map +0 -1
  578. package/dist/ContextWindow.d.mts +0 -5
  579. package/dist/ContextWindow.mjs +0 -10
  580. package/dist/ContextWindow.mjs.map +0 -1
  581. package/dist/DurableStep.d.mts +0 -5
  582. package/dist/DurableStep.mjs +0 -10
  583. package/dist/DurableStep.mjs.map +0 -1
  584. package/dist/EphemeralThreads.d.mts +0 -5
  585. package/dist/EphemeralThreads.mjs +0 -10
  586. package/dist/EphemeralThreads.mjs.map +0 -1
  587. package/dist/IdGenerator.d.mts +0 -5
  588. package/dist/IdGenerator.mjs +0 -10
  589. package/dist/IdGenerator.mjs.map +0 -1
  590. package/dist/Identifiers.d.mts +0 -5
  591. package/dist/Identifiers.mjs +0 -10
  592. package/dist/Identifiers.mjs.map +0 -1
  593. package/dist/Mcp.d.mts +0 -5
  594. package/dist/Mcp.mjs +0 -10
  595. package/dist/Mcp.mjs.map +0 -1
  596. package/dist/McpClient.d.mts +0 -5
  597. package/dist/McpClient.mjs +0 -10
  598. package/dist/McpClient.mjs.map +0 -1
  599. package/dist/Memory.d.mts +0 -5
  600. package/dist/Memory.mjs +0 -10
  601. package/dist/Memory.mjs.map +0 -1
  602. package/dist/MemoryNamespace.d.mts +0 -5
  603. package/dist/MemoryNamespace.mjs +0 -10
  604. package/dist/MemoryNamespace.mjs.map +0 -1
  605. package/dist/MemoryNotes.d.mts +0 -5
  606. package/dist/MemoryNotes.mjs +0 -10
  607. package/dist/MemoryNotes.mjs.map +0 -1
  608. package/dist/MemoryReference.d.mts +0 -5
  609. package/dist/MemoryReference.mjs +0 -10
  610. package/dist/MemoryReference.mjs.map +0 -1
  611. package/dist/MemoryRevalidation.d.mts +0 -5
  612. package/dist/MemoryRevalidation.mjs +0 -10
  613. package/dist/MemoryRevalidation.mjs.map +0 -1
  614. package/dist/MemoryStore.d.mts +0 -5
  615. package/dist/MemoryStore.mjs +0 -10
  616. package/dist/MemoryStore.mjs.map +0 -1
  617. package/dist/Messaging.d.mts +0 -5
  618. package/dist/Messaging.mjs +0 -10
  619. package/dist/Messaging.mjs.map +0 -1
  620. package/dist/MessagingHost.d.mts +0 -5
  621. package/dist/MessagingHost.mjs +0 -10
  622. package/dist/MessagingHost.mjs.map +0 -1
  623. package/dist/ModelContext.d.mts +0 -5
  624. package/dist/ModelContext.mjs +0 -10
  625. package/dist/ModelContext.mjs.map +0 -1
  626. package/dist/Receipt.d.mts +0 -5
  627. package/dist/Receipt.mjs +0 -10
  628. package/dist/Receipt.mjs.map +0 -1
  629. package/dist/Redaction.d.mts +0 -5
  630. package/dist/Redaction.mjs +0 -10
  631. package/dist/Redaction.mjs.map +0 -1
  632. package/dist/Remembering.d.mts +0 -5
  633. package/dist/Remembering.mjs +0 -10
  634. package/dist/Remembering.mjs.map +0 -1
  635. package/dist/RememberingStore.d.mts +0 -5
  636. package/dist/RememberingStore.mjs +0 -10
  637. package/dist/RememberingStore.mjs.map +0 -1
  638. package/dist/RunEvent.d.mts +0 -5
  639. package/dist/RunEvent.mjs +0 -10
  640. package/dist/RunEvent.mjs.map +0 -1
  641. package/dist/RunEventSink.d.mts +0 -5
  642. package/dist/RunEventSink.mjs +0 -10
  643. package/dist/RunEventSink.mjs.map +0 -1
  644. package/dist/RunHooks.d.mts +0 -5
  645. package/dist/RunHooks.mjs +0 -10
  646. package/dist/RunHooks.mjs.map +0 -1
  647. package/dist/RunOptions.d.mts +0 -5
  648. package/dist/RunOptions.mjs +0 -10
  649. package/dist/RunOptions.mjs.map +0 -1
  650. package/dist/RunPolicyUsage.d.mts +0 -5
  651. package/dist/RunPolicyUsage.mjs +0 -10
  652. package/dist/RunPolicyUsage.mjs.map +0 -1
  653. package/dist/SemanticMemory.d.mts +0 -5
  654. package/dist/SemanticMemory.mjs +0 -10
  655. package/dist/SemanticMemory.mjs.map +0 -1
  656. package/dist/SemanticMemoryIndex.d.mts +0 -5
  657. package/dist/SemanticMemoryIndex.mjs +0 -10
  658. package/dist/SemanticMemoryIndex.mjs.map +0 -1
  659. package/dist/SemanticMemoryRevalidation.d.mts +0 -5
  660. package/dist/SemanticMemoryRevalidation.mjs +0 -10
  661. package/dist/SemanticMemoryRevalidation.mjs.map +0 -1
  662. package/dist/Subagent.d.mts +0 -5
  663. package/dist/Subagent.mjs +0 -10
  664. package/dist/Subagent.mjs.map +0 -1
  665. package/dist/SubagentContract.d.mts +0 -5
  666. package/dist/SubagentContract.mjs +0 -10
  667. package/dist/SubagentContract.mjs.map +0 -1
  668. package/dist/SubagentHost.d.mts +0 -5
  669. package/dist/SubagentHost.mjs +0 -10
  670. package/dist/SubagentHost.mjs.map +0 -1
  671. package/dist/SubagentReservations.d.mts +0 -5
  672. package/dist/SubagentReservations.mjs +0 -10
  673. package/dist/SubagentReservations.mjs.map +0 -1
  674. package/dist/ThreadHistory.d.mts +0 -5
  675. package/dist/ThreadHistory.mjs +0 -10
  676. package/dist/ThreadHistory.mjs.map +0 -1
  677. package/dist/ToolBroker.d.mts +0 -5
  678. package/dist/ToolBroker.mjs +0 -10
  679. package/dist/ToolBroker.mjs.map +0 -1
  680. package/dist/ToolDiscovery.d.mts +0 -5
  681. package/dist/ToolDiscovery.mjs +0 -10
  682. package/dist/ToolDiscovery.mjs.map +0 -1
  683. package/dist/ToolResult.d.mts +0 -5
  684. package/dist/ToolResult.mjs +0 -10
  685. package/dist/ToolResult.mjs.map +0 -1
  686. package/dist/Usage.d.mts +0 -5
  687. package/dist/Usage.mjs +0 -10
  688. package/dist/Usage.mjs.map +0 -1
  689. package/dist/WebCapture.d.mts +0 -5
  690. package/dist/WebCapture.mjs +0 -10
  691. package/dist/WebCapture.mjs.map +0 -1
  692. package/dist/WebSearch.d.mts +0 -5
  693. package/dist/WebSearch.mjs +0 -10
  694. package/dist/WebSearch.mjs.map +0 -1
  695. package/dist/Worker.d.mts +0 -5
  696. package/dist/Worker.mjs +0 -10
  697. package/dist/Worker.mjs.map +0 -1
  698. package/dist/rolldown-runtime-BBjsoOtd.mjs +0 -27
  699. package/src/Agent.ts +0 -1
  700. package/src/AgentError.ts +0 -1
  701. package/src/AgentPolicy.ts +0 -1
  702. package/src/AgentRuntime.ts +0 -1
  703. package/src/AgentUpdates.ts +0 -1
  704. package/src/Approval.ts +0 -1
  705. package/src/Budget.ts +0 -1
  706. package/src/CodeMode.ts +0 -1
  707. package/src/Commands.ts +0 -1
  708. package/src/Compaction.ts +0 -1
  709. package/src/ContextCompactor.ts +0 -1
  710. package/src/ContextHistory.ts +0 -1
  711. package/src/ContextTools.ts +0 -1
  712. package/src/ContextWindow.ts +0 -1
  713. package/src/DurableStep.ts +0 -1
  714. package/src/EphemeralThreads.ts +0 -1
  715. package/src/IdGenerator.ts +0 -1
  716. package/src/Identifiers.ts +0 -1
  717. package/src/Mcp.ts +0 -1
  718. package/src/McpClient.ts +0 -1
  719. package/src/Memory.ts +0 -1
  720. package/src/MemoryNamespace.ts +0 -1
  721. package/src/MemoryNotes.ts +0 -1
  722. package/src/MemoryReference.ts +0 -1
  723. package/src/MemoryRevalidation.ts +0 -1
  724. package/src/MemoryStore.ts +0 -1
  725. package/src/Messaging.ts +0 -1
  726. package/src/MessagingHost.ts +0 -1
  727. package/src/ModelContext.ts +0 -1
  728. package/src/Receipt.ts +0 -1
  729. package/src/Redaction.ts +0 -1
  730. package/src/Remembering.ts +0 -1
  731. package/src/RememberingStore.ts +0 -1
  732. package/src/RunEvent.ts +0 -1
  733. package/src/RunEventSink.ts +0 -1
  734. package/src/RunHooks.ts +0 -1
  735. package/src/RunOptions.ts +0 -1
  736. package/src/RunPolicyUsage.ts +0 -1
  737. package/src/SemanticMemory.ts +0 -1
  738. package/src/SemanticMemoryIndex.ts +0 -1
  739. package/src/SemanticMemoryRevalidation.ts +0 -1
  740. package/src/Subagent.ts +0 -1
  741. package/src/SubagentContract.ts +0 -1
  742. package/src/SubagentHost.ts +0 -1
  743. package/src/SubagentReservations.ts +0 -1
  744. package/src/ThreadHistory.ts +0 -1
  745. package/src/ToolBroker.ts +0 -1
  746. package/src/ToolDiscovery.ts +0 -1
  747. package/src/ToolResult.ts +0 -1
  748. package/src/Usage.ts +0 -1
  749. package/src/WebCapture.ts +0 -1
  750. package/src/WebSearch.ts +0 -1
  751. package/src/Worker.ts +0 -1
@@ -0,0 +1,522 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
3
+ import { r as IncludesCatalogDocumentation, t as AdditionalToolCatalog } from "../ToolExposure-C93U1sPu.mjs";
4
+ import { t as CurrentToolCatalog } from "../ToolExposure-9uF_Yo0T.mjs";
5
+ import { ToolExecutionClass } from "../engine/DurableStep.mjs";
6
+ import { ProgrammaticCallRecord, ToolBroker } from "../engine/ToolBroker.mjs";
7
+ import { NetworkDisabled } from "../sandbox/Sandbox.mjs";
8
+ import { CodeExecutionHost, CodeExecutionLimits, CodeExecutionNamespace, CodeExecutionRequest, CodeExecutor, JsIdentifier } from "../sandbox/CodeExecutor.mjs";
9
+ import { Tool, Toolkit } from "effect/unstable/ai";
10
+ import { Cause, Context, Duration, Effect, Exit, Option, Schema } from "effect";
11
+ //#region src/capabilities/CodeMode.ts
12
+ var CodeMode_exports = /* @__PURE__ */ __exportAll({
13
+ CodeModeDescriptionError: () => CodeModeDescriptionError,
14
+ CodeModeFailure: () => CodeModeFailure,
15
+ CodeModeParameters: () => CodeModeParameters,
16
+ CodeModePassReport: () => CodeModePassReport,
17
+ CodeModeSuccess: () => CodeModeSuccess,
18
+ make: () => make
19
+ });
20
+ /**
21
+ * Code Mode (D-035, ADR-0017; capability spec §9.1): one native Effect AI
22
+ * Tool whose input is bounded JavaScript source, executed in one isolated
23
+ * `CodeExecutor` pass that may call an explicit construction-time allowlist
24
+ * of existing Tools through typed sandbox globals and the engine-owned
25
+ * `ToolBroker`. The builder follows the Delegation pattern: an explicit
26
+ * record of selected Tools plus namespace mapping fixed at construction,
27
+ * returning an ordinary Tool and a handler Layer, with no ambient registry
28
+ * (CAP-014). Deployment class `E` only.
29
+ */
30
+ const maxFailureTextLength = 4096;
31
+ const BoundedFailureText = Schema.String.check(Schema.isMaxLength(maxFailureTextLength));
32
+ const BoundedErrorTag = Schema.NonEmptyString.check(Schema.isMaxLength(256));
33
+ const BoundedLogLine = Schema.String.check(Schema.isMaxLength(16384));
34
+ const BoundedLogs = Schema.Array(BoundedLogLine).check(Schema.isMaxLength(4096));
35
+ const BoundedCode = Schema.NonEmptyString.check(Schema.isMaxLength(524288));
36
+ /** A pass-local report, available to the host even when the caller interrupts execution. */
37
+ const CodeModePassReport = Schema.Struct({
38
+ status: Schema.Literals([
39
+ "completed",
40
+ "failed",
41
+ "interrupted",
42
+ "defect"
43
+ ]),
44
+ calls: Schema.Array(ProgrammaticCallRecord)
45
+ });
46
+ const encodedJsonByteLength = (value) => {
47
+ try {
48
+ const encoded = JSON.stringify(value);
49
+ return encoded === void 0 ? void 0 : utf8ByteLength(encoded);
50
+ } catch {
51
+ return;
52
+ }
53
+ };
54
+ /** Model-decoded Code Mode parameters: one async function expression. */
55
+ const CodeModeParameters = Schema.Struct({ code: BoundedCode });
56
+ /**
57
+ * The bounded model-visible success: the program's JSON result plus captured
58
+ * logs, both already passed through the aggregate egress budget (CAP-016).
59
+ */
60
+ var CodeModeSuccess = class extends Schema.Class("@effect-agent/capabilities/CodeModeSuccess")({
61
+ result: Schema.Json,
62
+ logs: BoundedLogs
63
+ }) {};
64
+ /**
65
+ * The bounded model-visible failure envelope. `failureMode: "return"` turns
66
+ * it into a failed Tool result, so a model can correct a failing program
67
+ * without a blind retry; it carries the same bounded log capture as success
68
+ * plus the bounded thrown value where one exists, all inside the same
69
+ * aggregate egress budget (CAP-016).
70
+ */
71
+ var CodeModeFailure = class extends Schema.TaggedError()("CodeModeFailure", {
72
+ errorTag: BoundedErrorTag,
73
+ message: BoundedFailureText,
74
+ logs: BoundedLogs,
75
+ thrown: Schema.optionalKey(Schema.Json),
76
+ /** Invocation-ordered evidence that fits the egress budget. This is not a replay plan. */
77
+ calls: Schema.optionalKey(Schema.Array(ProgrammaticCallRecord)),
78
+ omittedCalls: Schema.optionalKey(Schema.Natural)
79
+ }) {};
80
+ /** A selective documentation request is invalid or cannot fit its declared byte budget. */
81
+ var CodeModeDescriptionError = class extends Schema.TaggedError()("CodeModeDescriptionError", {
82
+ reason: Schema.Literals([
83
+ "invalid-selection",
84
+ "unknown-method",
85
+ "invalid-bound",
86
+ "limit-exceeded"
87
+ ]),
88
+ message: BoundedFailureText
89
+ }) {};
90
+ const DescriptionMethods = Schema.Array(Schema.NonEmptyString.check(Schema.isMaxLength(257))).check(Schema.isMinLength(1), Schema.isMaxLength(64), Schema.isUnique());
91
+ const DescriptionByteLimit = Schema.Int.check(Schema.isBetween({
92
+ minimum: 1,
93
+ maximum: 262144
94
+ }));
95
+ const defaultLimits = CodeExecutionLimits.make({
96
+ maxSourceBytes: 262144,
97
+ maxWallTime: Duration.seconds(30),
98
+ maxLogBytes: 262144,
99
+ maxResultBytes: 1048576,
100
+ maxHostCalls: 64,
101
+ maxHostCallArgumentBytes: 262144,
102
+ maxHostCallResultBytes: 1048576
103
+ });
104
+ const defaultMaxEgressBytes = 65536;
105
+ const MAX_RENDER_DEPTH = 24;
106
+ const isJsonSchemaRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
107
+ const renderJsonSchemaType = (schema, defs, depth, indent) => {
108
+ if (depth > MAX_RENDER_DEPTH) throw new Error("Code Mode declaration rendering exceeded its depth bound");
109
+ if (!isJsonSchemaRecord(schema)) throw new Error(`Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema)}`);
110
+ const reference = schema.$ref;
111
+ if (typeof reference === "string") {
112
+ const match = /^#\/\$defs\/(.+)$/.exec(reference);
113
+ const key = match === null ? void 0 : match[1].replaceAll("~1", "/").replaceAll("~0", "~");
114
+ const resolved = key === void 0 ? void 0 : defs[key];
115
+ if (resolved === void 0) throw new Error(`Code Mode cannot resolve the JSON schema reference ${reference}`);
116
+ return renderJsonSchemaType(resolved, defs, depth + 1, indent);
117
+ }
118
+ if (Array.isArray(schema.enum)) return schema.enum.map((value) => JSON.stringify(value)).join(" | ");
119
+ if ("const" in schema) return JSON.stringify(schema.const);
120
+ const union = schema.anyOf ?? schema.oneOf;
121
+ if (Array.isArray(union)) return union.map((member) => renderJsonSchemaType(member, defs, depth + 1, indent)).join(" | ");
122
+ const type = schema.type;
123
+ if (Array.isArray(type)) return type.map((member) => renderJsonSchemaType({
124
+ ...schema,
125
+ type: member
126
+ }, defs, depth + 1, indent)).join(" | ");
127
+ switch (type) {
128
+ case "string": return "string";
129
+ case "number":
130
+ case "integer": return "number";
131
+ case "boolean": return "boolean";
132
+ case "null": return "null";
133
+ case "array":
134
+ if (!("items" in schema)) throw new Error("Code Mode cannot render an array schema without items");
135
+ return `ReadonlyArray<${renderJsonSchemaType(schema.items, defs, depth + 1, indent)}>`;
136
+ case "object":
137
+ case void 0:
138
+ if (isJsonSchemaRecord(schema.properties)) {
139
+ const required = Array.isArray(schema.required) ? schema.required : [];
140
+ const inner = `${indent} `;
141
+ const fields = Object.entries(schema.properties).map(([key, property]) => {
142
+ const optional = required.includes(key) ? "" : "?";
143
+ const rendered = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
144
+ return `${inner}readonly ${rendered}${optional}: ${renderJsonSchemaType(property, defs, depth + 1, inner)};`;
145
+ });
146
+ return fields.length === 0 ? "{}" : `{\n${fields.join("\n")}\n${indent}}`;
147
+ }
148
+ if (isJsonSchemaRecord(schema.additionalProperties)) return `Record<string, ${renderJsonSchemaType(schema.additionalProperties, defs, depth + 1, indent)}>`;
149
+ if (type === "object" && !("properties" in schema) && !("additionalProperties" in schema)) return "Record<string, unknown>";
150
+ }
151
+ throw new Error(`Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema).slice(0, 200)}; fix or simplify the Tool's Schema`);
152
+ };
153
+ const renderTopLevel = (jsonSchema, indent) => {
154
+ const defs = isJsonSchemaRecord(jsonSchema) && isJsonSchemaRecord(jsonSchema.$defs) ? jsonSchema.$defs : {};
155
+ return renderJsonSchemaType(jsonSchema, defs, 0, indent);
156
+ };
157
+ const decodeIdentifier = Schema.decodeUnknownOption(JsIdentifier);
158
+ const renderDeclarations = (methods) => {
159
+ const namespaces = /* @__PURE__ */ new Map();
160
+ for (const method of methods) {
161
+ const existing = namespaces.get(method.namespace) ?? [];
162
+ existing.push(method);
163
+ namespaces.set(method.namespace, existing);
164
+ }
165
+ return [...namespaces.entries()].map(([namespace, members]) => {
166
+ return `declare const ${namespace}: {\n${members.map((member) => {
167
+ const parameters = renderTopLevel(Tool.getJsonSchema(member.tool), " ");
168
+ const success = renderTopLevel(Tool.getJsonSchemaFromSchema(member.tool.successSchema), " ");
169
+ const safeDescription = member.tool.description?.replaceAll("*/", "*\\/").replaceAll(/\s*\n\s*/g, " ");
170
+ return `${safeDescription === void 0 ? "" : ` /** ${safeDescription} */\n`} ${member.method}(input: ${parameters}): Promise<${success}>;`;
171
+ }).join("\n")}\n};`;
172
+ }).join("\n\n");
173
+ };
174
+ const truncationMarker = "… logs truncated by the egress budget";
175
+ const MAX_EGRESS_LOG_LINE_CHARACTERS = 16e3;
176
+ /**
177
+ * Budget charge of one log line as it actually crosses to the model: the
178
+ * JSON-encoded string (quotes, escapes) plus one array separator. Charging
179
+ * raw UTF-8 would undercount model-visible bytes for escape-heavy content.
180
+ */
181
+ const encodedLogLineBytes = (line) => {
182
+ try {
183
+ return utf8ByteLength(JSON.stringify(line)) + 1;
184
+ } catch {
185
+ return Number.MAX_SAFE_INTEGER;
186
+ }
187
+ };
188
+ const budgetedLogs = (logs, remainingBytes) => {
189
+ const kept = [];
190
+ let used = 0;
191
+ let truncated = false;
192
+ for (const raw of logs) {
193
+ const line = raw.length > MAX_EGRESS_LOG_LINE_CHARACTERS ? `${raw.slice(0, 15999)}…` : raw;
194
+ const bytes = encodedLogLineBytes(line);
195
+ if (kept.length >= 4096 || used + bytes > remainingBytes) {
196
+ truncated = true;
197
+ break;
198
+ }
199
+ kept.push(line);
200
+ used += bytes;
201
+ }
202
+ if (truncated) {
203
+ const markerBytes = encodedLogLineBytes(truncationMarker);
204
+ while (kept.length > 0 && used + markerBytes > remainingBytes) used -= encodedLogLineBytes(kept.pop() ?? "");
205
+ if (markerBytes <= remainingBytes) kept.push(truncationMarker);
206
+ }
207
+ return kept;
208
+ };
209
+ const boundedMessage = (message) => message.slice(0, maxFailureTextLength);
210
+ const executionFailureMessage = (error) => {
211
+ switch (error._tag) {
212
+ case "CodeExecutionTimeoutError": return `The program exceeded its ${Duration.format(error.maxWallTime)} ${error.kind} budget`;
213
+ case "CodeOutputLimitError": return `The ${error.surface} limit of ${error.limit} bytes was exceeded (${error.observed} bytes observed)`;
214
+ case "CodeHostCallLimitError": return `The pass exceeded its executor cap of ${error.limit} host calls`;
215
+ default: return error.message;
216
+ }
217
+ };
218
+ /** UTF-8-aware truncation so a message can never exceed the aggregate budget. */
219
+ const truncateToUtf8Bytes = (value, maxBytes) => {
220
+ if (utf8ByteLength(value) <= maxBytes) return value;
221
+ let output = "";
222
+ let used = 0;
223
+ for (const character of value) {
224
+ const bytes = utf8ByteLength(character);
225
+ if (used + bytes + 3 > maxBytes) break;
226
+ output += character;
227
+ used += bytes;
228
+ }
229
+ return `${output}…`;
230
+ };
231
+ const make = (name, options) => {
232
+ const limits = options.limits ?? defaultLimits;
233
+ const maxEgressBytes = options.maxEgressBytes ?? defaultMaxEgressBytes;
234
+ if (!Number.isSafeInteger(maxEgressBytes) || maxEgressBytes < 256 || maxEgressBytes > 4194304) throw new Error(`Code Mode maxEgressBytes must be an integer between 256 and 4194304; received ${String(maxEgressBytes)}`);
235
+ const methods = [];
236
+ const toolsByName = /* @__PURE__ */ new Map();
237
+ const methodToTool = /* @__PURE__ */ new Map();
238
+ for (const [namespace, namespaceMethods] of Object.entries(options.tools)) {
239
+ if (Option.isNone(decodeIdentifier(namespace))) throw new Error(`Code Mode namespace ${namespace} is not a valid JavaScript identifier`);
240
+ const entries = Object.entries(namespaceMethods);
241
+ if (entries.length === 0) throw new Error(`Code Mode namespace ${namespace} declares no methods`);
242
+ for (const [method, tool] of entries) {
243
+ if (Option.isNone(decodeIdentifier(method))) throw new Error(`Code Mode method ${namespace}.${method} is not a valid JavaScript identifier`);
244
+ const approval = tool.needsApproval;
245
+ if (approval !== void 0 && approval !== false) throw new Error(`Code Mode rejects Tool ${tool.name} (${namespace}.${method}): approval-requiring Tools cannot be invoked programmatically in the ephemeral slice`);
246
+ const existing = toolsByName.get(tool.name);
247
+ if (existing !== void 0 && existing !== tool) throw new Error(`Code Mode selected two different Tools named ${tool.name}; Tool names must identify one Tool`);
248
+ toolsByName.set(tool.name, tool);
249
+ methodToTool.set(`${namespace}.${method}`, tool.name);
250
+ methods.push({
251
+ namespace,
252
+ method,
253
+ tool
254
+ });
255
+ }
256
+ }
257
+ if (methods.length === 0) throw new Error("Code Mode requires at least one allowlisted Tool");
258
+ const declarations = renderDeclarations(methods);
259
+ const methodsByPath = new Map(methods.map((method) => [`${method.namespace}.${method.method}`, method]));
260
+ const describe = Effect.fn("CodeMode.describe")(function* (selected, options) {
261
+ const paths = yield* Schema.decodeEffect(DescriptionMethods)(selected).pipe(Effect.mapError(() => CodeModeDescriptionError.make({
262
+ reason: "invalid-selection",
263
+ message: "Select between 1 and 64 unique namespace.method names, each at most 257 characters"
264
+ })));
265
+ const maxBytes = yield* Schema.decodeEffect(DescriptionByteLimit)(options?.maxBytes ?? 16384).pipe(Effect.mapError(() => CodeModeDescriptionError.make({
266
+ reason: "invalid-bound",
267
+ message: "The documentation byte limit must be an integer between 1 and 262144"
268
+ })));
269
+ const selectedMethods = [];
270
+ for (const path of paths) {
271
+ const method = methodsByPath.get(path);
272
+ if (method === void 0) return yield* CodeModeDescriptionError.make({
273
+ reason: "unknown-method",
274
+ message: "The selection contains a method outside this Code Mode allowlist"
275
+ });
276
+ selectedMethods.push(method);
277
+ }
278
+ const documentation = renderDeclarations(selectedMethods);
279
+ if (utf8ByteLength(documentation) > maxBytes) return yield* CodeModeDescriptionError.make({
280
+ reason: "limit-exceeded",
281
+ message: `The selected declarations exceed the ${maxBytes}-byte documentation limit; select fewer methods or raise the limit`
282
+ });
283
+ return documentation;
284
+ });
285
+ const namespaces = [...new Set(methods.map((method) => method.namespace))].map((namespace) => CodeExecutionNamespace.make({
286
+ name: namespace,
287
+ methods: methods.filter((method) => method.namespace === namespace).map((method) => method.method)
288
+ }));
289
+ const description = [
290
+ options.description,
291
+ "",
292
+ "The `code` argument must be one JavaScript async function expression; the sandbox invokes it exactly once with no arguments. It runs isolated with no ambient network, filesystem, environment, or secrets. Return one JSON value. `console.log` output is captured within a bounded budget and returned alongside the result.",
293
+ "Namespace methods return Promises. An expected Tool failure rejects with a JSON envelope carrying a stable `_tag`; catch it to branch. Use Promise.all for independent calls; the host bounds concurrency. Await every call you need. Writes may complete before a failure: inspect call outcomes and never blindly retry a program.",
294
+ ...options.includeDeclarations === false ? [] : [
295
+ "",
296
+ "Sandbox globals:",
297
+ "```ts",
298
+ declarations,
299
+ "```"
300
+ ]
301
+ ].join("\n");
302
+ const tool = Tool.make(name, {
303
+ description,
304
+ parameters: CodeModeParameters,
305
+ success: CodeModeSuccess,
306
+ failure: CodeModeFailure,
307
+ failureMode: "return"
308
+ }).annotate(Tool.Readonly, false).annotate(ToolExecutionClass, "uncertain").annotate(IncludesCatalogDocumentation, options.includeDeclarations !== false).annotate(AdditionalToolCatalog, Object.freeze(methods.map((method) => Object.freeze({ ...method })))).addDependency(ToolBroker);
309
+ const outerToolkit = Toolkit.make(tool);
310
+ /**
311
+ * The nested namespace record collapses into one Toolkit keyed by exact
312
+ * Tool names. The assertion restores the name-keyed record type TypeScript
313
+ * cannot compute from `Map` iteration; construction above guarantees the
314
+ * name uniqueness the type states.
315
+ */
316
+ const selectedToolkit = Toolkit.make(...toolsByName.values());
317
+ const executionRequest = (code, visibleNamespaces) => CodeExecutionRequest.make({
318
+ language: "javascript",
319
+ source: code,
320
+ namespaces: visibleNamespaces,
321
+ network: NetworkDisabled.make({}),
322
+ limits
323
+ });
324
+ const routeHostCall = (pass, hostCall, visiblePaths) => Effect.gen(function* () {
325
+ const path = `${hostCall.namespace}.${hostCall.method}`;
326
+ const toolName = visiblePaths === void 0 || visiblePaths.has(path) ? methodToTool.get(path) : void 0;
327
+ if (toolName === void 0) return {
328
+ _tag: "CodeHostCallFailure",
329
+ error: {
330
+ _tag: "UnknownCodeModeMethod",
331
+ message: "The requested method is not available in this pass"
332
+ }
333
+ };
334
+ const outcome = yield* pass.invoke({
335
+ toolName,
336
+ encodedArguments: hostCall.argument
337
+ });
338
+ switch (outcome._tag) {
339
+ case "ProgrammaticCallSuccess": {
340
+ const value = decodeBrokerJson(outcome.encodedResult);
341
+ return Option.isSome(value) ? {
342
+ _tag: "CodeHostCallSuccess",
343
+ value: value.value
344
+ } : {
345
+ _tag: "CodeHostCallFailure",
346
+ error: brokerProtocolEnvelope
347
+ };
348
+ }
349
+ case "ProgrammaticCallFailure": {
350
+ const value = decodeBrokerJson(outcome.encodedResult);
351
+ return {
352
+ _tag: "CodeHostCallFailure",
353
+ error: Option.isSome(value) ? value.value : brokerProtocolEnvelope
354
+ };
355
+ }
356
+ case "ProgrammaticCallError": return {
357
+ _tag: "CodeHostCallFailure",
358
+ error: {
359
+ _tag: outcome.errorTag,
360
+ message: outcome.message
361
+ }
362
+ };
363
+ }
364
+ });
365
+ const build = Effect.gen(function* () {
366
+ const captured = yield* Effect.context();
367
+ const redactionServices = yield* Effect.context();
368
+ const configuredRedactor = options.redactEgress;
369
+ const redact = configuredRedactor === void 0 ? void 0 : (egress) => Effect.scoped(configuredRedactor(egress)).pipe(Effect.updateContext((current) => Context.merge(current, redactionServices)));
370
+ const withHandler = yield* selectedToolkit;
371
+ const executor = yield* CodeExecutor;
372
+ const successEgress = (execution) => Effect.gen(function* () {
373
+ let egress = {
374
+ result: execution.value,
375
+ logs: execution.logs
376
+ };
377
+ if (redact !== void 0) egress = yield* redact(egress);
378
+ const resultBytes = encodedJsonByteLength(egress.result);
379
+ if (resultBytes === void 0 || resultBytes > maxEgressBytes) return yield* CodeModeFailure.make({
380
+ errorTag: "CodeModeEgressExceeded",
381
+ message: `The program result of ${resultBytes ?? "unencodable"} bytes exceeds the ${maxEgressBytes}-byte model-visible egress budget; return a smaller value`,
382
+ logs: budgetedLogs(egress.logs, Math.max(0, maxEgressBytes - 256))
383
+ });
384
+ return CodeModeSuccess.make({
385
+ result: egress.result,
386
+ logs: budgetedLogs(egress.logs, maxEgressBytes - resultBytes)
387
+ });
388
+ });
389
+ /**
390
+ * The failure half of the aggregate egress policy (CAP-016): the configured
391
+ * redaction pass covers failure logs and thrown values exactly like success
392
+ * egress — a program cannot leak by logging and then throwing — and the
393
+ * message itself is bounded by the budget, not only by its own schema cap.
394
+ */
395
+ const failureEgress = (error) => Effect.gen(function* () {
396
+ if (error._tag === "ToolBrokerUnavailableError" || error._tag === "ToolBrokerConfigurationError") return CodeModeFailure.make({
397
+ errorTag: error._tag,
398
+ message: truncateToUtf8Bytes(boundedMessage(error.message), maxEgressBytes),
399
+ logs: []
400
+ });
401
+ let logs = "logs" in error ? error.logs : [];
402
+ let candidateThrown = error._tag === "CodeProgramFailedError" ? error.thrown : void 0;
403
+ if (redact !== void 0) {
404
+ const redacted = yield* redact({
405
+ result: candidateThrown ?? null,
406
+ logs
407
+ });
408
+ logs = redacted.logs;
409
+ candidateThrown = candidateThrown === void 0 ? void 0 : redacted.result;
410
+ }
411
+ const message = truncateToUtf8Bytes(boundedMessage(executionFailureMessage(error)), maxEgressBytes);
412
+ const messageBytes = utf8ByteLength(message);
413
+ const candidateBytes = candidateThrown === void 0 ? void 0 : encodedJsonByteLength(candidateThrown);
414
+ const includeThrown = candidateThrown !== void 0 && candidateBytes !== void 0 && messageBytes + candidateBytes <= maxEgressBytes;
415
+ const remaining = Math.max(0, maxEgressBytes - messageBytes - (includeThrown ? candidateBytes ?? 0 : 0));
416
+ return CodeModeFailure.make({
417
+ errorTag: error._tag,
418
+ message,
419
+ logs: budgetedLogs(logs, remaining),
420
+ ...includeThrown ? { thrown: candidateThrown } : {}
421
+ });
422
+ });
423
+ const invoke = Effect.fn(`CodeMode.${name}`)(function* (parameters) {
424
+ const broker = yield* ToolBroker;
425
+ const catalogue = yield* Effect.serviceOption(CurrentToolCatalog);
426
+ const visiblePaths = Option.isNone(catalogue) ? void 0 : new Set(catalogue.value.entries.flatMap((entry) => entry.kind === "code-mode" && entry.nativeToolName === name && methodsByPath.get(`${entry.namespace}.${entry.method}`)?.tool.name === entry.tool.name ? [`${entry.namespace}.${entry.method}`] : []));
427
+ const visibleNamespaces = visiblePaths === void 0 ? namespaces : namespaces.flatMap((namespace) => {
428
+ const allowed = namespace.methods.filter((method) => visiblePaths.has(`${namespace.name}.${method}`));
429
+ return allowed.length === 0 ? [] : [CodeExecutionNamespace.make({
430
+ name: namespace.name,
431
+ methods: allowed
432
+ })];
433
+ });
434
+ let calls = [];
435
+ return yield* Effect.gen(function* () {
436
+ const pass = yield* broker.openPass(withHandler, {
437
+ maxResultBytes: limits.maxHostCallResultBytes,
438
+ concurrency: limits.maxHostCallConcurrency ?? 4
439
+ });
440
+ const host = CodeExecutionHost.of({ call: (hostCall) => routeHostCall(pass, hostCall, visiblePaths) });
441
+ return yield* executor.execute(executionRequest(parameters.code, visibleNamespaces)).pipe(Effect.provideService(CodeExecutionHost, host), Effect.scoped, Effect.onExit((exit) => Effect.gen(function* () {
442
+ calls = yield* pass.snapshot;
443
+ if (options.onPassExit !== void 0) yield* Effect.scoped(options.onPassExit({
444
+ status: Exit.isSuccess(exit) ? "completed" : Cause.hasInterrupts(exit.cause) ? "interrupted" : Cause.hasDies(exit.cause) ? "defect" : "failed",
445
+ calls
446
+ })).pipe(Effect.provideContext(redactionServices));
447
+ })));
448
+ }).pipe(Effect.scoped, Effect.provideService(ToolBroker, broker), Effect.provideContext(captured)).pipe(Effect.catch((error) => failureEgress(error).pipe(Effect.flatMap(Effect.fail))), Effect.flatMap(successEgress), Effect.mapError((failure) => {
449
+ if (calls.length === 0) return failure;
450
+ const complete = CodeModeFailure.make({
451
+ errorTag: failure.errorTag,
452
+ message: failure.message,
453
+ logs: failure.logs,
454
+ ...failure.thrown === void 0 ? {} : { thrown: failure.thrown },
455
+ calls,
456
+ omittedCalls: 0
457
+ });
458
+ if ((encodedJsonByteLength(complete) ?? Infinity) <= maxEgressBytes) return complete;
459
+ const base = {
460
+ errorTag: failure.errorTag,
461
+ message: truncateToUtf8Bytes(failure.message, Math.min(256, maxEgressBytes / 4)),
462
+ logs: []
463
+ };
464
+ const kept = [];
465
+ for (const call of calls) {
466
+ const candidate = CodeModeFailure.make({
467
+ ...base,
468
+ calls: [...kept, call],
469
+ omittedCalls: calls.length - kept.length - 1
470
+ });
471
+ if ((encodedJsonByteLength(candidate) ?? Infinity) > maxEgressBytes) break;
472
+ kept.push(call);
473
+ }
474
+ return CodeModeFailure.make({
475
+ ...base,
476
+ calls: kept,
477
+ omittedCalls: calls.length - kept.length
478
+ });
479
+ }));
480
+ });
481
+ return { [name]: invoke };
482
+ });
483
+ /**
484
+ * TypeScript cannot unify the two spellings of the singleton Tool record
485
+ * (`CodeModeTools<Name>` versus the toolkit's name-remapped form) over a
486
+ * generic `Name`, nor reduce the deferred `Exclude` when `toLayer`
487
+ * subtracts what `build` consumed; the assertions pin the layer to its
488
+ * documented requirement surface and never bypass validation.
489
+ */
490
+ const handlers = outerToolkit.toLayer(build);
491
+ return Object.freeze({
492
+ name,
493
+ description,
494
+ declarations,
495
+ describe,
496
+ namespaces,
497
+ limits,
498
+ maxEgressBytes,
499
+ tool,
500
+ handlers
501
+ });
502
+ };
503
+ /**
504
+ * Fail-closed JSON boundary for broker outcomes: hostile values can throw
505
+ * from trap getters during decode, and a value outside the JSON surface must
506
+ * become a typed failure envelope — never a fabricated success.
507
+ */
508
+ const decodeBrokerJson = (value) => {
509
+ try {
510
+ return Schema.decodeUnknownOption(Schema.Json)(value);
511
+ } catch {
512
+ return Option.none();
513
+ }
514
+ };
515
+ const brokerProtocolEnvelope = {
516
+ _tag: "CodeModeProtocolError",
517
+ message: "The broker returned a value outside the JSON surface"
518
+ };
519
+ //#endregion
520
+ export { CodeModeDescriptionError, CodeModeFailure, CodeModeParameters, CodeModePassReport, CodeModeSuccess, make, CodeMode_exports as t };
521
+
522
+ //# sourceMappingURL=CodeMode.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeMode.mjs","names":["ToolExecutionClassAnnotation"],"sources":["../../src/capabilities/CodeMode.ts"],"sourcesContent":["import {\n type Layer,\n Cause,\n Context,\n Duration,\n Effect,\n Exit,\n Option,\n Schema,\n type Scope,\n} from \"effect\";\nimport { Tool, Toolkit } from \"effect/unstable/ai\";\n\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { AdditionalToolCatalog, IncludesCatalogDocumentation } from \"../core/ToolExposure.ts\";\nimport {\n type ToolBrokerConfigurationError,\n type ToolBrokerUnavailableError,\n ToolBroker,\n type ProgrammaticCallOutcome,\n type ToolBrokerPass,\n ProgrammaticCallRecord,\n} from \"../engine/ToolBroker.ts\";\nimport { CurrentToolCatalog } from \"../engine/ToolExposure.ts\";\nimport {\n type CodeExecutionError,\n CodeExecutionHost,\n CodeExecutionLimits,\n CodeExecutionNamespace,\n CodeExecutionRequest,\n CodeExecutor,\n JsIdentifier,\n type CodeExecutionResult,\n type CodeHostCall,\n type CodeHostCallResult,\n} from \"../sandbox/CodeExecutor.ts\";\nimport { NetworkDisabled } from \"../sandbox/Sandbox.ts\";\n\n/**\n * Code Mode (D-035, ADR-0017; capability spec §9.1): one native Effect AI\n * Tool whose input is bounded JavaScript source, executed in one isolated\n * `CodeExecutor` pass that may call an explicit construction-time allowlist\n * of existing Tools through typed sandbox globals and the engine-owned\n * `ToolBroker`. The builder follows the Delegation pattern: an explicit\n * record of selected Tools plus namespace mapping fixed at construction,\n * returning an ordinary Tool and a handler Layer, with no ambient registry\n * (CAP-014). Deployment class `E` only.\n */\n\nconst maxFailureTextLength = 4 * 1024;\nconst BoundedFailureText = Schema.String.check(Schema.isMaxLength(maxFailureTextLength));\nconst BoundedErrorTag = Schema.NonEmptyString.check(Schema.isMaxLength(256));\nconst BoundedLogLine = Schema.String.check(Schema.isMaxLength(16 * 1024));\nconst BoundedLogs = Schema.Array(BoundedLogLine).check(Schema.isMaxLength(4_096));\nconst BoundedCode = Schema.NonEmptyString.check(Schema.isMaxLength(512 * 1024));\n\n/** A pass-local report, available to the host even when the caller interrupts execution. */\nexport const CodeModePassReport = Schema.Struct({\n status: Schema.Literals([\"completed\", \"failed\", \"interrupted\", \"defect\"]),\n calls: Schema.Array(ProgrammaticCallRecord),\n});\n\nexport type CodeModePassReport = typeof CodeModePassReport.Type;\n\nconst encodedJsonByteLength = (value: unknown): number | undefined => {\n try {\n const encoded = JSON.stringify(value);\n\n return encoded === undefined ? undefined : utf8ByteLength(encoded);\n } catch {\n return undefined;\n }\n};\n\n/** Model-decoded Code Mode parameters: one async function expression. */\nexport const CodeModeParameters = Schema.Struct({\n code: BoundedCode,\n});\n\n/**\n * The bounded model-visible success: the program's JSON result plus captured\n * logs, both already passed through the aggregate egress budget (CAP-016).\n */\nexport class CodeModeSuccess extends Schema.Class<CodeModeSuccess>(\n \"@effect-agent/capabilities/CodeModeSuccess\",\n)({\n result: Schema.Json,\n logs: BoundedLogs,\n}) {}\n\n/**\n * The bounded model-visible failure envelope. `failureMode: \"return\"` turns\n * it into a failed Tool result, so a model can correct a failing program\n * without a blind retry; it carries the same bounded log capture as success\n * plus the bounded thrown value where one exists, all inside the same\n * aggregate egress budget (CAP-016).\n */\nexport class CodeModeFailure extends Schema.TaggedError<CodeModeFailure>()(\"CodeModeFailure\", {\n errorTag: BoundedErrorTag,\n message: BoundedFailureText,\n logs: BoundedLogs,\n thrown: Schema.optionalKey(Schema.Json),\n /** Invocation-ordered evidence that fits the egress budget. This is not a replay plan. */\n calls: Schema.optionalKey(Schema.Array(ProgrammaticCallRecord)),\n omittedCalls: Schema.optionalKey(Schema.Natural),\n}) {}\n\n/** A selective documentation request is invalid or cannot fit its declared byte budget. */\nexport class CodeModeDescriptionError extends Schema.TaggedError<CodeModeDescriptionError>()(\n \"CodeModeDescriptionError\",\n {\n reason: Schema.Literals([\n \"invalid-selection\",\n \"unknown-method\",\n \"invalid-bound\",\n \"limit-exceeded\",\n ]),\n message: BoundedFailureText,\n },\n) {}\n\nconst DescriptionMethods = Schema.Array(Schema.NonEmptyString.check(Schema.isMaxLength(257))).check(\n Schema.isMinLength(1),\n Schema.isMaxLength(64),\n Schema.isUnique(),\n);\n\nconst DescriptionByteLimit = Schema.Int.check(\n Schema.isBetween({ minimum: 1, maximum: 256 * 1024 }),\n);\n\n/** The namespace-record shape accepted by `CodeMode.make`. */\nexport type CodeModeNamespaces = Record<string, Record<string, Tool.Any>>;\n\n/**\n * Union of every Tool selected across all namespaces, computed distributively\n * per namespace: indexing the namespace union with the INTERSECTION of method\n * keys would erase every Tool once two namespaces have disjoint methods.\n */\nexport type CodeModeSelectedTool<Namespaces extends CodeModeNamespaces> = {\n [Namespace in keyof Namespaces]: Namespaces[Namespace][keyof Namespaces[Namespace]];\n}[keyof Namespaces];\n\n/** The selected Tools re-keyed by their own Tool names. */\nexport type CodeModeSelectedRecord<Namespaces extends CodeModeNamespaces> = {\n readonly [T in CodeModeSelectedTool<Namespaces> as T[\"name\"]]: T;\n};\n\n/**\n * The native Effect AI Tool created by `CodeMode.make` (CAP-014). Its only\n * per-call dependency is the engine-provided `ToolBroker`; the `CodeExecutor`\n * and every selected handler and redaction service are construction requirements of the handler\n * Layer instead, so they stay visible in the composed `R`.\n */\nexport type CodeModeTool<Name extends string> = Tool.Tool<\n Name,\n {\n readonly parameters: typeof CodeModeParameters;\n readonly success: typeof CodeModeSuccess;\n readonly failure: typeof CodeModeFailure;\n readonly failureMode: \"return\";\n },\n ToolBroker\n>;\n\n/** Singleton Tool record provided by one Code Mode handler Layer. */\nexport type CodeModeTools<Name extends string> = {\n readonly [Key in Name]: CodeModeTool<Name>;\n};\n\n/** Construction requirements of the Code Mode handler Layer. */\nexport type CodeModeLayerRequirements<\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n> =\n | CodeExecutor\n | Exclude<RedactionRequirements, Scope.Scope>\n | Tool.HandlersFor<CodeModeSelectedRecord<Namespaces>>\n | Tool.HandlerServices<CodeModeSelectedTool<Namespaces>>;\n\nexport interface CodeModeOptions<\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n> {\n /** Model-visible description; the builder appends the sandbox contract. */\n readonly description: string;\n /** Include all sandbox declarations in the model-facing description. Defaults to true. */\n readonly includeDeclarations?: boolean | undefined;\n /**\n * Explicit allowlist: namespace name → method name → native Effect AI\n * Tool. Reads and mutations are allowed; calls requiring additional approval fail closed.\n */\n readonly tools: Namespaces;\n /** Executor limits for one pass; a bounded default applies when omitted. */\n readonly limits?: CodeExecutionLimits | undefined;\n /**\n * Aggregate model-visible egress budget in UTF-8 bytes across the final\n * result, captured logs, and any thrown value (CAP-016). Default 65536.\n */\n readonly maxEgressBytes?: number | undefined;\n /**\n * Host-only ephemeral report after executor resources and invocation fibers close, including\n * failure, defect, and interruption. It contains no arguments/results and is never a checkpoint.\n * Keep this total callback bounded; its services are captured with the handler Layer.\n */\n readonly onPassExit?:\n | ((report: CodeModePassReport) => Effect.Effect<void, never, RedactionRequirements>)\n | undefined;\n /**\n * Optional aggregate redaction pass applied to the model-visible egress\n * before the byte budget. Its services are acquired with the handler Layer;\n * temporary resources close with each redaction invocation.\n * It must be total; a defect stays a defect.\n */\n readonly redactEgress?:\n | ((egress: {\n readonly result: Schema.Json;\n readonly logs: ReadonlyArray<string>;\n }) => Effect.Effect<\n {\n readonly result: Schema.Json;\n readonly logs: ReadonlyArray<string>;\n },\n never,\n RedactionRequirements\n >)\n | undefined;\n}\n\n/**\n * An immutable Code Mode definition: one model-facing Tool over an explicit\n * allowlist, plus the handler Layer that runs generated programs through the\n * `CodeExecutor` port and the engine-owned broker. It owns no acquired\n * resources.\n */\nexport interface CodeModeDefinition<\n Name extends string,\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n> {\n readonly name: Name;\n /** The assembled model-facing description, optionally including all declarations. */\n readonly description: string;\n /** Rendered TypeScript declarations of the sandbox globals (documentation only). */\n readonly declarations: string;\n /**\n * Render complete encoded-schema declarations for 1–64 unique, exact namespace.method names.\n * The UTF-8 byte limit defaults to 16384 and must be an integer from 1 through 262144.\n * Oversized documentation fails rather than truncating a declaration. This host operation\n * does not authorize a model to see the selected methods; filter selections by current\n * visibility and inherited grants before returning its output to a model.\n */\n readonly describe: (\n methods: ReadonlyArray<string>,\n options?: { readonly maxBytes?: number | undefined },\n ) => Effect.Effect<string, CodeModeDescriptionError>;\n /** The executor-facing namespace catalog derived from the allowlist. */\n readonly namespaces: ReadonlyArray<CodeExecutionNamespace>;\n readonly limits: CodeExecutionLimits;\n readonly maxEgressBytes: number;\n /** The ordinary Effect AI Tool to include in the model-facing Toolkit. */\n readonly tool: CodeModeTool<Name>;\n /** Handler Layer; selected handler requirements stay visible in `R`. */\n readonly handlers: Layer.Layer<\n Tool.HandlersFor<CodeModeTools<Name>>,\n never,\n CodeModeLayerRequirements<Namespaces, RedactionRequirements>\n >;\n}\n\nconst defaultLimits = CodeExecutionLimits.make({\n maxSourceBytes: 256 * 1024,\n maxWallTime: Duration.seconds(30),\n maxLogBytes: 256 * 1024,\n maxResultBytes: 1024 * 1024,\n maxHostCalls: 64,\n maxHostCallArgumentBytes: 256 * 1024,\n maxHostCallResultBytes: 1024 * 1024,\n});\n\nconst defaultMaxEgressBytes = 64 * 1024;\n\n// ---------------------------------------------------------------------------\n// Declaration rendering (capability spec §9.1): the encoded side of each\n// Schema — the JSON that actually crosses the sandbox boundary — rendered as\n// TypeScript documentation via the same JSON-schema derivation Effect AI\n// applies to Tool parameters. A schema the renderer cannot express fails Tool\n// construction closed rather than degrading to `unknown`.\n// ---------------------------------------------------------------------------\n\nconst MAX_RENDER_DEPTH = 24;\n\nconst isJsonSchemaRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst renderJsonSchemaType = (\n schema: unknown,\n defs: Record<string, unknown>,\n depth: number,\n indent: string,\n): string => {\n if (depth > MAX_RENDER_DEPTH) {\n throw new Error(\"Code Mode declaration rendering exceeded its depth bound\");\n }\n if (!isJsonSchemaRecord(schema)) {\n throw new Error(`Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema)}`);\n }\n const reference = schema.$ref;\n\n if (typeof reference === \"string\") {\n const match = /^#\\/\\$defs\\/(.+)$/.exec(reference);\n // JSON-pointer tokens escape `/` as `~1` and `~` as `~0`.\n const key = match === null ? undefined : match[1].replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\");\n const resolved = key === undefined ? undefined : defs[key];\n\n if (resolved === undefined) {\n throw new Error(`Code Mode cannot resolve the JSON schema reference ${reference}`);\n }\n\n return renderJsonSchemaType(resolved, defs, depth + 1, indent);\n }\n if (Array.isArray(schema.enum)) {\n return schema.enum.map((value) => JSON.stringify(value)).join(\" | \");\n }\n if (\"const\" in schema) {\n return JSON.stringify(schema.const);\n }\n const union = schema.anyOf ?? schema.oneOf;\n\n if (Array.isArray(union)) {\n return union.map((member) => renderJsonSchemaType(member, defs, depth + 1, indent)).join(\" | \");\n }\n const type = schema.type;\n\n if (Array.isArray(type)) {\n return type\n .map((member) => renderJsonSchemaType({ ...schema, type: member }, defs, depth + 1, indent))\n .join(\" | \");\n }\n switch (type) {\n case \"string\": {\n return \"string\";\n }\n case \"number\":\n case \"integer\": {\n return \"number\";\n }\n case \"boolean\": {\n return \"boolean\";\n }\n case \"null\": {\n return \"null\";\n }\n case \"array\": {\n if (!(\"items\" in schema)) {\n throw new Error(\"Code Mode cannot render an array schema without items\");\n }\n\n return `ReadonlyArray<${renderJsonSchemaType(schema.items, defs, depth + 1, indent)}>`;\n }\n case \"object\":\n case undefined: {\n if (isJsonSchemaRecord(schema.properties)) {\n const required = Array.isArray(schema.required) ? schema.required : [];\n const inner = `${indent} `;\n\n const fields = Object.entries(schema.properties).map(([key, property]) => {\n const optional = required.includes(key) ? \"\" : \"?\";\n // A JSON property name need not be a TypeScript identifier.\n const rendered = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);\n\n return `${inner}readonly ${rendered}${optional}: ${renderJsonSchemaType(property, defs, depth + 1, inner)};`;\n });\n\n return fields.length === 0 ? \"{}\" : `{\\n${fields.join(\"\\n\")}\\n${indent}}`;\n }\n if (isJsonSchemaRecord(schema.additionalProperties)) {\n return `Record<string, ${renderJsonSchemaType(schema.additionalProperties, defs, depth + 1, indent)}>`;\n }\n // A bare `{ \"type\": \"object\" }` states \"any JSON object\" (Schema.Json's\n // object member derives to exactly this); rendering it as an\n // unconstrained record is faithful, not a deriver degradation.\n if (type === \"object\" && !(\"properties\" in schema) && !(\"additionalProperties\" in schema)) {\n return \"Record<string, unknown>\";\n }\n break;\n }\n default: {\n break;\n }\n }\n throw new Error(\n `Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema).slice(0, 200)}; fix or simplify the Tool's Schema`,\n );\n};\n\nconst renderTopLevel = (jsonSchema: unknown, indent: string): string => {\n const defs =\n isJsonSchemaRecord(jsonSchema) && isJsonSchemaRecord(jsonSchema.$defs)\n ? jsonSchema.$defs\n : ({} as Record<string, unknown>);\n\n return renderJsonSchemaType(jsonSchema, defs, 0, indent);\n};\n\nconst decodeIdentifier = Schema.decodeUnknownOption(JsIdentifier);\n\ninterface ResolvedMethod {\n readonly namespace: string;\n readonly method: string;\n readonly tool: Tool.Any;\n}\n\nconst renderDeclarations = (methods: ReadonlyArray<ResolvedMethod>): string => {\n const namespaces = new Map<string, Array<ResolvedMethod>>();\n\n for (const method of methods) {\n const existing = namespaces.get(method.namespace) ?? [];\n\n existing.push(method);\n namespaces.set(method.namespace, existing);\n }\n\n const blocks = [...namespaces.entries()].map(([namespace, members]) => {\n const lines = members.map((member) => {\n const parameters = renderTopLevel(Tool.getJsonSchema(member.tool), \" \");\n const success = renderTopLevel(Tool.getJsonSchemaFromSchema(member.tool.successSchema), \" \");\n\n // A description is arbitrary text: newlines and comment terminators\n // must not be able to break out of the documentation comment.\n const safeDescription = member.tool.description\n ?.replaceAll(\"*/\", \"*\\\\/\")\n .replaceAll(/\\s*\\n\\s*/g, \" \");\n\n const description = safeDescription === undefined ? \"\" : ` /** ${safeDescription} */\\n`;\n\n return `${description} ${member.method}(input: ${parameters}): Promise<${success}>;`;\n });\n\n return `declare const ${namespace}: {\\n${lines.join(\"\\n\")}\\n};`;\n });\n\n return blocks.join(\"\\n\\n\");\n};\n\n// ---------------------------------------------------------------------------\n// Aggregate model-visible egress (CAP-016): the final result, captured logs,\n// and any thrown value share one byte budget. Logs are truncated line-by-line\n// with an explicit marker; a result that alone exceeds the budget is a typed\n// failure rather than silent truncation.\n// ---------------------------------------------------------------------------\n\nconst truncationMarker = \"… logs truncated by the egress budget\";\nconst MAX_EGRESS_LOG_LINE_CHARACTERS = 16_000;\n\n/**\n * Budget charge of one log line as it actually crosses to the model: the\n * JSON-encoded string (quotes, escapes) plus one array separator. Charging\n * raw UTF-8 would undercount model-visible bytes for escape-heavy content.\n */\nconst encodedLogLineBytes = (line: string): number => {\n try {\n return utf8ByteLength(JSON.stringify(line)) + 1;\n } catch {\n return Number.MAX_SAFE_INTEGER;\n }\n};\n\nconst budgetedLogs = (\n logs: ReadonlyArray<string>,\n remainingBytes: number,\n): ReadonlyArray<string> => {\n const kept: Array<string> = [];\n let used = 0;\n let truncated = false;\n\n for (const raw of logs) {\n // Per-line cap keeps every kept line inside the BoundedLogLine schema.\n const line =\n raw.length > MAX_EGRESS_LOG_LINE_CHARACTERS\n ? `${raw.slice(0, MAX_EGRESS_LOG_LINE_CHARACTERS - 1)}…`\n : raw;\n\n const bytes = encodedLogLineBytes(line);\n\n if (kept.length >= 4_096 || used + bytes > remainingBytes) {\n truncated = true;\n break;\n }\n kept.push(line);\n used += bytes;\n }\n if (truncated) {\n // Truncation is never silent: drop kept lines from the end until the\n // marker itself fits inside the budget.\n const markerBytes = encodedLogLineBytes(truncationMarker);\n\n while (kept.length > 0 && used + markerBytes > remainingBytes) {\n used -= encodedLogLineBytes(kept.pop() ?? \"\");\n }\n if (markerBytes <= remainingBytes) {\n kept.push(truncationMarker);\n }\n }\n\n return kept;\n};\n\nconst boundedMessage = (message: string): string => message.slice(0, maxFailureTextLength);\n\nconst executionFailureMessage = (error: CodeExecutionError): string => {\n switch (error._tag) {\n case \"CodeExecutionTimeoutError\": {\n return `The program exceeded its ${Duration.format(error.maxWallTime)} ${error.kind} budget`;\n }\n case \"CodeOutputLimitError\": {\n return `The ${error.surface} limit of ${error.limit} bytes was exceeded (${error.observed} bytes observed)`;\n }\n case \"CodeHostCallLimitError\": {\n return `The pass exceeded its executor cap of ${error.limit} host calls`;\n }\n default: {\n return error.message;\n }\n }\n};\n\n/** UTF-8-aware truncation so a message can never exceed the aggregate budget. */\nconst truncateToUtf8Bytes = (value: string, maxBytes: number): string => {\n if (utf8ByteLength(value) <= maxBytes) {\n return value;\n }\n let output = \"\";\n let used = 0;\n\n for (const character of value) {\n const bytes = utf8ByteLength(character);\n\n if (used + bytes + 3 > maxBytes) {\n break;\n }\n output += character;\n used += bytes;\n }\n\n return `${output}…`;\n};\n\ntype EgressRedactor<Requirements = never> = NonNullable<\n CodeModeOptions<CodeModeNamespaces, Requirements>[\"redactEgress\"]\n>;\n\n// ---------------------------------------------------------------------------\n// Builder\n// ---------------------------------------------------------------------------\n\nconst make = <\n const Name extends string,\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n>(\n name: Name,\n options: CodeModeOptions<Namespaces, RedactionRequirements>,\n): CodeModeDefinition<Name, Namespaces, RedactionRequirements> => {\n const limits = options.limits ?? defaultLimits;\n const maxEgressBytes = options.maxEgressBytes ?? defaultMaxEgressBytes;\n\n // Fail closed on an invalid egress bound: NaN would make every size\n // comparison false and Infinity would remove the bound entirely.\n if (\n !Number.isSafeInteger(maxEgressBytes) ||\n maxEgressBytes < 256 ||\n maxEgressBytes > 4 * 1024 * 1024\n ) {\n throw new Error(\n `Code Mode maxEgressBytes must be an integer between 256 and ${4 * 1024 * 1024}; received ${String(maxEgressBytes)}`,\n );\n }\n\n // Construction-time fail-closed validation (CAP-014).\n const methods: Array<ResolvedMethod> = [];\n const toolsByName = new Map<string, Tool.Any>();\n const methodToTool = new Map<string, string>();\n\n for (const [namespace, namespaceMethods] of Object.entries(options.tools)) {\n if (Option.isNone(decodeIdentifier(namespace))) {\n throw new Error(`Code Mode namespace ${namespace} is not a valid JavaScript identifier`);\n }\n const entries = Object.entries(namespaceMethods);\n\n if (entries.length === 0) {\n throw new Error(`Code Mode namespace ${namespace} declares no methods`);\n }\n for (const [method, tool] of entries) {\n if (Option.isNone(decodeIdentifier(method))) {\n throw new Error(\n `Code Mode method ${namespace}.${method} is not a valid JavaScript identifier`,\n );\n }\n const approval = tool.needsApproval;\n\n if (approval !== undefined && approval !== false) {\n throw new Error(\n `Code Mode rejects Tool ${tool.name} (${namespace}.${method}): approval-requiring Tools cannot be invoked programmatically in the ephemeral slice`,\n );\n }\n const existing = toolsByName.get(tool.name);\n\n if (existing !== undefined && existing !== tool) {\n throw new Error(\n `Code Mode selected two different Tools named ${tool.name}; Tool names must identify one Tool`,\n );\n }\n toolsByName.set(tool.name, tool);\n methodToTool.set(`${namespace}.${method}`, tool.name);\n methods.push({ namespace, method, tool });\n }\n }\n if (methods.length === 0) {\n throw new Error(\"Code Mode requires at least one allowlisted Tool\");\n }\n\n // Declarations derive from the encoded Schemas and fail construction closed\n // on anything the renderer cannot express.\n const declarations = renderDeclarations(methods);\n\n const methodsByPath = new Map(\n methods.map((method) => [`${method.namespace}.${method.method}`, method]),\n );\n\n const describe = Effect.fn(\"CodeMode.describe\")(function* (\n selected: ReadonlyArray<string>,\n options?: { readonly maxBytes?: number | undefined },\n ) {\n const paths = yield* Schema.decodeEffect(DescriptionMethods)(selected).pipe(\n Effect.mapError(() =>\n CodeModeDescriptionError.make({\n reason: \"invalid-selection\",\n message:\n \"Select between 1 and 64 unique namespace.method names, each at most 257 characters\",\n }),\n ),\n );\n\n const maxBytes = yield* Schema.decodeEffect(DescriptionByteLimit)(\n options?.maxBytes ?? 16 * 1024,\n ).pipe(\n Effect.mapError(() =>\n CodeModeDescriptionError.make({\n reason: \"invalid-bound\",\n message: \"The documentation byte limit must be an integer between 1 and 262144\",\n }),\n ),\n );\n\n const selectedMethods: Array<ResolvedMethod> = [];\n\n for (const path of paths) {\n const method = methodsByPath.get(path);\n\n if (method === undefined) {\n return yield* CodeModeDescriptionError.make({\n reason: \"unknown-method\",\n message: \"The selection contains a method outside this Code Mode allowlist\",\n });\n }\n selectedMethods.push(method);\n }\n\n const documentation = renderDeclarations(selectedMethods);\n\n if (utf8ByteLength(documentation) > maxBytes) {\n return yield* CodeModeDescriptionError.make({\n reason: \"limit-exceeded\",\n message: `The selected declarations exceed the ${maxBytes}-byte documentation limit; select fewer methods or raise the limit`,\n });\n }\n\n return documentation;\n });\n\n const namespaces = [...new Set(methods.map((method) => method.namespace))].map((namespace) =>\n CodeExecutionNamespace.make({\n name: namespace,\n methods: methods\n .filter((method) => method.namespace === namespace)\n .map((method) => method.method),\n }),\n );\n\n const description = [\n options.description,\n \"\",\n \"The `code` argument must be one JavaScript async function expression; the sandbox invokes it exactly once with no arguments. It runs isolated with no ambient network, filesystem, environment, or secrets. Return one JSON value. `console.log` output is captured within a bounded budget and returned alongside the result.\",\n \"Namespace methods return Promises. An expected Tool failure rejects with a JSON envelope carrying a stable `_tag`; catch it to branch. Use Promise.all for independent calls; the host bounds concurrency. Await every call you need. Writes may complete before a failure: inspect call outcomes and never blindly retry a program.\",\n ...(options.includeDeclarations === false\n ? []\n : [\"\", \"Sandbox globals:\", \"```ts\", declarations, \"```\"]),\n ].join(\"\\n\");\n\n const tool = Tool.make(name, {\n description,\n parameters: CodeModeParameters,\n success: CodeModeSuccess,\n failure: CodeModeFailure,\n failureMode: \"return\",\n })\n .annotate(Tool.Readonly, false)\n .annotate(ToolExecutionClassAnnotation, \"uncertain\")\n .annotate(IncludesCatalogDocumentation, options.includeDeclarations !== false)\n .annotate(\n AdditionalToolCatalog,\n Object.freeze(methods.map((method) => Object.freeze({ ...method }))),\n )\n .addDependency(ToolBroker) as CodeModeTool<Name>;\n\n const outerToolkit = Toolkit.make(tool);\n\n /**\n * The nested namespace record collapses into one Toolkit keyed by exact\n * Tool names. The assertion restores the name-keyed record type TypeScript\n * cannot compute from `Map` iteration; construction above guarantees the\n * name uniqueness the type states.\n */\n const selectedToolkit = Toolkit.make(...toolsByName.values()) as unknown as Toolkit.Toolkit<\n CodeModeSelectedRecord<Namespaces>\n >;\n\n const executionRequest = (\n code: string,\n visibleNamespaces: ReadonlyArray<CodeExecutionNamespace>,\n ): CodeExecutionRequest =>\n CodeExecutionRequest.make({\n language: \"javascript\",\n source: code,\n namespaces: visibleNamespaces,\n network: NetworkDisabled.make({}),\n limits,\n });\n\n const routeHostCall = (\n pass: ToolBrokerPass,\n hostCall: CodeHostCall,\n visiblePaths: ReadonlySet<string> | undefined,\n ): Effect.Effect<CodeHostCallResult> =>\n Effect.gen(function* () {\n const path = `${hostCall.namespace}.${hostCall.method}`;\n\n const toolName =\n visiblePaths === undefined || visiblePaths.has(path) ? methodToTool.get(path) : undefined;\n\n if (toolName === undefined) {\n return {\n _tag: \"CodeHostCallFailure\",\n error: {\n _tag: \"UnknownCodeModeMethod\",\n message: \"The requested method is not available in this pass\",\n },\n } as const;\n }\n\n const outcome: ProgrammaticCallOutcome = yield* pass.invoke({\n toolName,\n encodedArguments: hostCall.argument,\n });\n\n switch (outcome._tag) {\n case \"ProgrammaticCallSuccess\": {\n const value = decodeBrokerJson(outcome.encodedResult);\n\n return Option.isSome(value)\n ? ({ _tag: \"CodeHostCallSuccess\", value: value.value } as const)\n : ({ _tag: \"CodeHostCallFailure\", error: brokerProtocolEnvelope } as const);\n }\n case \"ProgrammaticCallFailure\": {\n const value = decodeBrokerJson(outcome.encodedResult);\n\n return {\n _tag: \"CodeHostCallFailure\",\n error: Option.isSome(value) ? value.value : brokerProtocolEnvelope,\n } as const;\n }\n case \"ProgrammaticCallError\": {\n return {\n _tag: \"CodeHostCallFailure\",\n error: { _tag: outcome.errorTag, message: outcome.message },\n } as const;\n }\n }\n });\n\n const build = Effect.gen(function* () {\n const captured = yield* Effect.context<never>();\n const redactionServices = yield* Effect.context<Exclude<RedactionRequirements, Scope.Scope>>();\n const configuredRedactor = options.redactEgress;\n\n const redact: EgressRedactor | undefined =\n configuredRedactor === undefined\n ? undefined\n : (egress) =>\n Effect.scoped(configuredRedactor(egress)).pipe(\n // Merge invocation-local services before opening the redaction Scope.\n // The inner Scope shadows any Scope retained in the construction context.\n Effect.updateContext((current: Context.Context<never>) =>\n Context.merge(current, redactionServices),\n ),\n );\n\n const withHandler = yield* selectedToolkit;\n const executor = yield* CodeExecutor;\n\n const successEgress = (\n execution: CodeExecutionResult,\n ): Effect.Effect<CodeModeSuccess, CodeModeFailure> =>\n Effect.gen(function* () {\n let egress: { readonly result: Schema.Json; readonly logs: ReadonlyArray<string> } = {\n result: execution.value,\n logs: execution.logs,\n };\n\n if (redact !== undefined) {\n egress = yield* redact(egress);\n }\n const resultBytes = encodedJsonByteLength(egress.result);\n\n if (resultBytes === undefined || resultBytes > maxEgressBytes) {\n return yield* CodeModeFailure.make({\n errorTag: \"CodeModeEgressExceeded\",\n message: `The program result of ${resultBytes ?? \"unencodable\"} bytes exceeds the ${maxEgressBytes}-byte model-visible egress budget; return a smaller value`,\n logs: budgetedLogs(egress.logs, Math.max(0, maxEgressBytes - 256)),\n });\n }\n\n return CodeModeSuccess.make({\n result: egress.result,\n logs: budgetedLogs(egress.logs, maxEgressBytes - resultBytes),\n });\n });\n\n /**\n * The failure half of the aggregate egress policy (CAP-016): the configured\n * redaction pass covers failure logs and thrown values exactly like success\n * egress — a program cannot leak by logging and then throwing — and the\n * message itself is bounded by the budget, not only by its own schema cap.\n */\n const failureEgress = (\n error: CodeExecutionError | ToolBrokerUnavailableError | ToolBrokerConfigurationError,\n ): Effect.Effect<CodeModeFailure> =>\n Effect.gen(function* () {\n if (\n error._tag === \"ToolBrokerUnavailableError\" ||\n error._tag === \"ToolBrokerConfigurationError\"\n ) {\n return CodeModeFailure.make({\n errorTag: error._tag,\n message: truncateToUtf8Bytes(boundedMessage(error.message), maxEgressBytes),\n logs: [],\n });\n }\n let logs: ReadonlyArray<string> = \"logs\" in error ? error.logs : [];\n let candidateThrown = error._tag === \"CodeProgramFailedError\" ? error.thrown : undefined;\n\n if (redact !== undefined) {\n const redacted = yield* redact({ result: candidateThrown ?? null, logs });\n\n logs = redacted.logs;\n candidateThrown = candidateThrown === undefined ? undefined : redacted.result;\n }\n\n const message = truncateToUtf8Bytes(\n boundedMessage(executionFailureMessage(error)),\n maxEgressBytes,\n );\n\n const messageBytes = utf8ByteLength(message);\n\n // `thrown` is included only when it fits TOGETHER with the message inside\n // the aggregate budget, and it reduces the log allowance only when it is\n // actually included.\n const candidateBytes =\n candidateThrown === undefined ? undefined : encodedJsonByteLength(candidateThrown);\n\n const includeThrown =\n candidateThrown !== undefined &&\n candidateBytes !== undefined &&\n messageBytes + candidateBytes <= maxEgressBytes;\n\n const remaining = Math.max(\n 0,\n maxEgressBytes - messageBytes - (includeThrown ? (candidateBytes ?? 0) : 0),\n );\n\n return CodeModeFailure.make({\n errorTag: error._tag,\n message,\n logs: budgetedLogs(logs, remaining),\n ...(includeThrown ? { thrown: candidateThrown } : {}),\n });\n });\n\n const invoke = Effect.fn(`CodeMode.${name}`)(function* (parameters: { readonly code: string }) {\n const broker = yield* ToolBroker;\n // Resolve invocation authority before restoring captured construction services. A Layer\n // built under an older Run must not restore that Run's catalogue or hidden method names.\n const catalogue = yield* Effect.serviceOption(CurrentToolCatalog);\n\n const visiblePaths = Option.isNone(catalogue)\n ? undefined\n : new Set(\n catalogue.value.entries.flatMap((entry) =>\n entry.kind === \"code-mode\" &&\n entry.nativeToolName === name &&\n methodsByPath.get(`${entry.namespace}.${entry.method}`)?.tool.name === entry.tool.name\n ? [`${entry.namespace}.${entry.method}`]\n : [],\n ),\n );\n\n const visibleNamespaces =\n visiblePaths === undefined\n ? namespaces\n : namespaces.flatMap((namespace) => {\n const allowed = namespace.methods.filter((method) =>\n visiblePaths.has(`${namespace.name}.${method}`),\n );\n\n return allowed.length === 0\n ? []\n : [CodeExecutionNamespace.make({ name: namespace.name, methods: allowed })];\n });\n\n let calls: ReadonlyArray<ProgrammaticCallRecord> = [];\n\n const execution = Effect.gen(function* () {\n const pass = yield* broker.openPass(withHandler, {\n maxResultBytes: limits.maxHostCallResultBytes,\n concurrency: limits.maxHostCallConcurrency ?? 4,\n });\n\n const host = CodeExecutionHost.of({\n call: (hostCall) => routeHostCall(pass, hostCall, visiblePaths),\n });\n\n return yield* executor.execute(executionRequest(parameters.code, visibleNamespaces)).pipe(\n Effect.provideService(CodeExecutionHost, host),\n Effect.scoped,\n Effect.onExit((exit) =>\n Effect.gen(function* () {\n calls = yield* pass.snapshot;\n if (options.onPassExit !== undefined) {\n yield* Effect.scoped(\n options.onPassExit({\n status: Exit.isSuccess(exit)\n ? \"completed\"\n : Cause.hasInterrupts(exit.cause)\n ? \"interrupted\"\n : Cause.hasDies(exit.cause)\n ? \"defect\"\n : \"failed\",\n calls,\n }),\n ).pipe(Effect.provideContext(redactionServices));\n }\n }),\n ),\n );\n }).pipe(\n Effect.scoped,\n // The live engine broker is re-provided innermost so a Layer built\n // inside another Run can never shadow it; the captured construction\n // context supplies the selected handlers' services (same idiom as\n // Subagent.layer). TypeScript cannot reduce the deferred Exclude\n // over the generic namespace record, so the same private-assertion\n // contract as the engine's provideHookServices pins the identity\n // that providing the captured Context leaves no requirements; it\n // never bypasses validation.\n Effect.provideService(ToolBroker, broker),\n Effect.provideContext(captured),\n ) as Effect.Effect<\n CodeExecutionResult,\n CodeExecutionError | ToolBrokerUnavailableError | ToolBrokerConfigurationError\n >;\n\n return yield* execution.pipe(\n Effect.catch((error) => failureEgress(error).pipe(Effect.flatMap(Effect.fail))),\n Effect.flatMap(successEgress),\n Effect.mapError((failure) => {\n if (calls.length === 0) return failure;\n\n const complete = CodeModeFailure.make({\n errorTag: failure.errorTag,\n message: failure.message,\n logs: failure.logs,\n ...(failure.thrown === undefined ? {} : { thrown: failure.thrown }),\n calls,\n omittedCalls: 0,\n });\n\n if ((encodedJsonByteLength(complete) ?? Infinity) <= maxEgressBytes) return complete;\n\n // Evidence takes priority over logs and thrown values. Never silently omit calls.\n const base = {\n errorTag: failure.errorTag,\n message: truncateToUtf8Bytes(failure.message, Math.min(256, maxEgressBytes / 4)),\n logs: [],\n };\n\n const kept: Array<ProgrammaticCallRecord> = [];\n\n for (const call of calls) {\n const candidate = CodeModeFailure.make({\n ...base,\n calls: [...kept, call],\n omittedCalls: calls.length - kept.length - 1,\n });\n\n if ((encodedJsonByteLength(candidate) ?? Infinity) > maxEgressBytes) break;\n kept.push(call);\n }\n\n return CodeModeFailure.make({\n ...base,\n calls: kept,\n omittedCalls: calls.length - kept.length,\n });\n }),\n );\n });\n\n return { [name]: invoke } as unknown as Toolkit.HandlersFrom<CodeModeTools<Name>>;\n });\n\n /**\n * TypeScript cannot unify the two spellings of the singleton Tool record\n * (`CodeModeTools<Name>` versus the toolkit's name-remapped form) over a\n * generic `Name`, nor reduce the deferred `Exclude` when `toLayer`\n * subtracts what `build` consumed; the assertions pin the layer to its\n * documented requirement surface and never bypass validation.\n */\n const handlers = outerToolkit.toLayer(\n build as unknown as Effect.Effect<\n Toolkit.HandlersFrom<Toolkit.ToolsByName<readonly [CodeModeTool<Name>]>>,\n never,\n | CodeExecutor\n | Tool.HandlersFor<CodeModeSelectedRecord<Namespaces>>\n | Exclude<RedactionRequirements, Scope.Scope>\n >,\n ) as unknown as Layer.Layer<\n Tool.HandlersFor<CodeModeTools<Name>>,\n never,\n CodeModeLayerRequirements<Namespaces, RedactionRequirements>\n >;\n\n return Object.freeze({\n name,\n description,\n declarations,\n describe,\n namespaces,\n limits,\n maxEgressBytes,\n tool,\n handlers,\n });\n};\n\n/**\n * Fail-closed JSON boundary for broker outcomes: hostile values can throw\n * from trap getters during decode, and a value outside the JSON surface must\n * become a typed failure envelope — never a fabricated success.\n */\nconst decodeBrokerJson = (value: unknown): Option.Option<Schema.Json> => {\n try {\n return Schema.decodeUnknownOption(Schema.Json)(value);\n } catch {\n return Option.none();\n }\n};\n\nconst brokerProtocolEnvelope: Schema.Json = {\n _tag: \"CodeModeProtocolError\",\n message: \"The broker returned a value outside the JSON surface\",\n};\n\n// The engine annotation is imported under a local alias to keep the builder\n// readable next to Effect AI's own `Tool.Readonly` annotation.\nimport { ToolExecutionClass as ToolExecutionClassAnnotation } from \"../engine/DurableStep.ts\";\n\n/** Code Mode builder namespace (capability spec §9.1). */\nexport { make };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB,OAAO,OAAO,MAAM,OAAO,YAAY,oBAAoB,CAAC;AACvF,MAAM,kBAAkB,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;AAC3E,MAAM,iBAAiB,OAAO,OAAO,MAAM,OAAO,YAAY,KAAS,CAAC;AACxE,MAAM,cAAc,OAAO,MAAM,cAAc,CAAC,CAAC,MAAM,OAAO,YAAY,IAAK,CAAC;AAChF,MAAM,cAAc,OAAO,eAAe,MAAM,OAAO,YAAY,MAAU,CAAC;;AAG9E,MAAa,qBAAqB,OAAO,OAAO;CAC9C,QAAQ,OAAO,SAAS;EAAC;EAAa;EAAU;EAAe;CAAQ,CAAC;CACxE,OAAO,OAAO,MAAM,sBAAsB;AAC5C,CAAC;AAID,MAAM,yBAAyB,UAAuC;CACpE,IAAI;EACF,MAAM,UAAU,KAAK,UAAU,KAAK;EAE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