effect-agent 0.1.0-beta.12 → 0.1.0-beta.121

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 (553) hide show
  1. package/dist/Agent-1DMSO_Fl.mjs +86 -0
  2. package/dist/Agent-1DMSO_Fl.mjs.map +1 -0
  3. package/dist/Agent-D9cXqfF3.d.mts +252 -0
  4. package/dist/AgentError-Bn1ytXRD.d.mts +117 -0
  5. package/dist/AgentPolicy-BqDoSXO6.d.mts +96 -0
  6. package/dist/AgentRuntime-BUxDdLpw.d.mts +346 -0
  7. package/dist/AgentRuntime-Cp1hAb-W.mjs +4739 -0
  8. package/dist/AgentRuntime-Cp1hAb-W.mjs.map +1 -0
  9. package/dist/AgentUpdates-DMJ-_xow.d.mts +53 -0
  10. package/dist/ContextCompactor-WwSIG_Z2.d.mts +161 -0
  11. package/dist/ContextWindow-DRQ5Mbm2.d.mts +58 -0
  12. package/dist/DurableAgentRuntime-B-9w7jDt.mjs +7061 -0
  13. package/dist/DurableAgentRuntime-B-9w7jDt.mjs.map +1 -0
  14. package/dist/DurableFailpoint-Cnr3wx1L.d.mts +41 -0
  15. package/dist/DurableStep-Cry_iol4.d.mts +103 -0
  16. package/dist/EventSource-CnlZ3Kma.d.mts +51 -0
  17. package/dist/FailureDiagnostic-BElLOoED.mjs +274 -0
  18. package/dist/FailureDiagnostic-BElLOoED.mjs.map +1 -0
  19. package/dist/FailureDiagnostic-CaAkzGHL.d.mts +223 -0
  20. package/dist/Identifiers-CN2s30fF.d.mts +40 -0
  21. package/dist/InMemory.d.mts +24 -0
  22. package/dist/InMemory.mjs +24 -0
  23. package/dist/InMemory.mjs.map +1 -0
  24. package/dist/MemoryNamespace-BbRW5p71.d.mts +36 -0
  25. package/dist/MemoryReference-B8Q3UJoJ.d.mts +79 -0
  26. package/dist/Messaging-Dkg87ebg.d.mts +221 -0
  27. package/dist/Messaging-JYYN3oYS.d.mts +1067 -0
  28. package/dist/MessagingHost-CqzpxbGz.d.mts +74 -0
  29. package/dist/MessagingHost-DfsbMPvq.mjs +110 -0
  30. package/dist/MessagingHost-DfsbMPvq.mjs.map +1 -0
  31. package/dist/OperationAuthorizer-TzcQtpX5.d.mts +61 -0
  32. package/dist/Output-V-6YL1_Z.d.mts +25 -0
  33. package/dist/PageCapture-Df8Xwskw.d.mts +583 -0
  34. package/dist/PageScreenshot-BpgZKAxl.d.mts +48 -0
  35. package/dist/PreparedInputAdmission-BQLGldl-.d.mts +42 -0
  36. package/dist/Receipt-BAHyigAF.d.mts +33 -0
  37. package/dist/Records-D88mgvyS.d.mts +4214 -0
  38. package/dist/RunEvent-DIrzkjLr.d.mts +460 -0
  39. package/dist/RunEventSink-D5aVhISG.d.mts +108 -0
  40. package/dist/RunJournal-BXrq0VIK.mjs +931 -0
  41. package/dist/RunJournal-BXrq0VIK.mjs.map +1 -0
  42. package/dist/RunOptions-CSBsSj0X.d.mts +935 -0
  43. package/dist/RunPolicyUsage-ClZxyR46.d.mts +21 -0
  44. package/dist/Sandbox-CEsDWBLq.d.mts +173 -0
  45. package/dist/Schedule-BIOHA6RR.d.mts +847 -0
  46. package/dist/Scheduling-DPb2QyAK.mjs +691 -0
  47. package/dist/Scheduling-DPb2QyAK.mjs.map +1 -0
  48. package/dist/Subagent-CNik9RiA.d.mts +1635 -0
  49. package/dist/Subagent-DCrB7an7.mjs +1498 -0
  50. package/dist/Subagent-DCrB7an7.mjs.map +1 -0
  51. package/dist/SubagentContract-DdT7Cqe6.d.mts +116 -0
  52. package/dist/SubagentHost-4WB8Hj0C.d.mts +164 -0
  53. package/dist/Subscription-CRteOKRf.d.mts +948 -0
  54. package/dist/SubscriptionInput-oNcwTPti.d.mts +41 -0
  55. package/dist/Thread-DOBQ0QUY.d.mts +96 -0
  56. package/dist/ThreadHistory-tS1KwxHR.d.mts +60 -0
  57. package/dist/ToolBroker-DWs4tZra.d.mts +133 -0
  58. package/dist/ToolExposure-9uF_Yo0T.mjs +10 -0
  59. package/dist/ToolExposure-9uF_Yo0T.mjs.map +1 -0
  60. package/dist/ToolExposure-C93U1sPu.mjs +30 -0
  61. package/dist/ToolExposure-C93U1sPu.mjs.map +1 -0
  62. package/dist/ToolExposure-UCN12eCd.d.mts +39 -0
  63. package/dist/ToolExposure-r2eOWk4F.d.mts +46 -0
  64. package/dist/ToolExposure.d.mts +8 -0
  65. package/dist/ToolExposure.mjs +21 -0
  66. package/dist/ToolExposure.mjs.map +1 -0
  67. package/dist/ToolReconciler-BmVRAHKs.d.mts +80 -0
  68. package/dist/ToolResult-BKdqWRff.d.mts +78 -0
  69. package/dist/Usage-Dx0aknfk.d.mts +121 -0
  70. package/dist/WakeScheduler-EjUF-GhC.d.mts +56 -0
  71. package/dist/Worker-CfwzMZEK.mjs +271 -0
  72. package/dist/Worker-CfwzMZEK.mjs.map +1 -0
  73. package/dist/Worker-fwWkBg12.d.mts +472 -0
  74. package/dist/agent-registration-CKNsrpwo.mjs +201 -0
  75. package/dist/agent-registration-CKNsrpwo.mjs.map +1 -0
  76. package/dist/capabilities/Approval.d.mts +114 -0
  77. package/dist/capabilities/Approval.mjs +226 -0
  78. package/dist/capabilities/Approval.mjs.map +1 -0
  79. package/dist/capabilities/Budget.d.mts +112 -0
  80. package/dist/capabilities/Budget.mjs +346 -0
  81. package/dist/capabilities/Budget.mjs.map +1 -0
  82. package/dist/capabilities/CodeMode.d.mts +157 -0
  83. package/dist/capabilities/CodeMode.mjs +522 -0
  84. package/dist/capabilities/CodeMode.mjs.map +1 -0
  85. package/dist/capabilities/Commands.d.mts +55 -0
  86. package/dist/capabilities/Commands.mjs +57 -0
  87. package/dist/capabilities/Commands.mjs.map +1 -0
  88. package/dist/capabilities/ContextTools.d.mts +321 -0
  89. package/dist/capabilities/ContextTools.mjs +126 -0
  90. package/dist/capabilities/ContextTools.mjs.map +1 -0
  91. package/dist/capabilities/Mcp.d.mts +108 -0
  92. package/dist/capabilities/Mcp.mjs +259 -0
  93. package/dist/capabilities/Mcp.mjs.map +1 -0
  94. package/dist/capabilities/McpClient.d.mts +115 -0
  95. package/dist/capabilities/McpClient.mjs +506 -0
  96. package/dist/capabilities/McpClient.mjs.map +1 -0
  97. package/dist/capabilities/MemoryNotes.d.mts +424 -0
  98. package/dist/capabilities/MemoryNotes.mjs +128 -0
  99. package/dist/capabilities/MemoryNotes.mjs.map +1 -0
  100. package/dist/capabilities/Messaging.d.mts +3 -0
  101. package/dist/capabilities/Messaging.mjs +152 -0
  102. package/dist/capabilities/Messaging.mjs.map +1 -0
  103. package/dist/capabilities/ModelContext.d.mts +89 -0
  104. package/dist/capabilities/ModelContext.mjs +168 -0
  105. package/dist/capabilities/ModelContext.mjs.map +1 -0
  106. package/dist/capabilities/Redaction.d.mts +37 -0
  107. package/dist/capabilities/Redaction.mjs +104 -0
  108. package/dist/capabilities/Redaction.mjs.map +1 -0
  109. package/dist/capabilities/Remembering.d.mts +434 -0
  110. package/dist/capabilities/Remembering.mjs +290 -0
  111. package/dist/capabilities/Remembering.mjs.map +1 -0
  112. package/dist/capabilities/RunHooks.d.mts +82 -0
  113. package/dist/capabilities/RunHooks.mjs +144 -0
  114. package/dist/capabilities/RunHooks.mjs.map +1 -0
  115. package/dist/capabilities/SemanticMemory.d.mts +431 -0
  116. package/dist/capabilities/SemanticMemory.mjs +315 -0
  117. package/dist/capabilities/SemanticMemory.mjs.map +1 -0
  118. package/dist/capabilities/Subagent.d.mts +4 -0
  119. package/dist/capabilities/Subagent.mjs +5 -0
  120. package/dist/capabilities/SubagentReservations.d.mts +186 -0
  121. package/dist/capabilities/SubagentReservations.mjs +479 -0
  122. package/dist/capabilities/SubagentReservations.mjs.map +1 -0
  123. package/dist/capabilities/ToolDiscovery.d.mts +124 -0
  124. package/dist/capabilities/ToolDiscovery.mjs +230 -0
  125. package/dist/capabilities/ToolDiscovery.mjs.map +1 -0
  126. package/dist/capabilities/WebCapture.d.mts +163 -0
  127. package/dist/capabilities/WebCapture.mjs +335 -0
  128. package/dist/capabilities/WebCapture.mjs.map +1 -0
  129. package/dist/capabilities/WebSearch.d.mts +71 -0
  130. package/dist/capabilities/WebSearch.mjs +115 -0
  131. package/dist/capabilities/WebSearch.mjs.map +1 -0
  132. package/dist/compaction-C2OTceKw.mjs +505 -0
  133. package/dist/compaction-C2OTceKw.mjs.map +1 -0
  134. package/dist/core/Agent.d.mts +2 -0
  135. package/dist/core/Agent.mjs +2 -0
  136. package/dist/core/AgentError.d.mts +2 -0
  137. package/dist/core/AgentError.mjs +134 -0
  138. package/dist/core/AgentError.mjs.map +1 -0
  139. package/dist/core/AgentPolicy.d.mts +2 -0
  140. package/dist/core/AgentPolicy.mjs +94 -0
  141. package/dist/core/AgentPolicy.mjs.map +1 -0
  142. package/dist/core/AgentUpdates.d.mts +2 -0
  143. package/dist/core/AgentUpdates.mjs +63 -0
  144. package/dist/core/AgentUpdates.mjs.map +1 -0
  145. package/dist/core/FailureDiagnostic.d.mts +2 -0
  146. package/dist/core/FailureDiagnostic.mjs +2 -0
  147. package/dist/core/IdGenerator.d.mts +26 -0
  148. package/dist/core/IdGenerator.mjs +27 -0
  149. package/dist/core/IdGenerator.mjs.map +1 -0
  150. package/dist/core/Identifiers.d.mts +2 -0
  151. package/dist/core/Identifiers.mjs +43 -0
  152. package/dist/core/Identifiers.mjs.map +1 -0
  153. package/dist/core/Memory.d.mts +57 -0
  154. package/dist/core/Memory.mjs +203 -0
  155. package/dist/core/Memory.mjs.map +1 -0
  156. package/dist/core/MemoryNamespace.d.mts +2 -0
  157. package/dist/core/MemoryNamespace.mjs +116 -0
  158. package/dist/core/MemoryNamespace.mjs.map +1 -0
  159. package/dist/core/MemoryReference.d.mts +2 -0
  160. package/dist/core/MemoryReference.mjs +109 -0
  161. package/dist/core/MemoryReference.mjs.map +1 -0
  162. package/dist/core/MemoryRevalidation.d.mts +65 -0
  163. package/dist/core/MemoryRevalidation.mjs +126 -0
  164. package/dist/core/MemoryRevalidation.mjs.map +1 -0
  165. package/dist/core/MemoryStore.d.mts +186 -0
  166. package/dist/core/MemoryStore.mjs +243 -0
  167. package/dist/core/MemoryStore.mjs.map +1 -0
  168. package/dist/core/Receipt.d.mts +2 -0
  169. package/dist/core/Receipt.mjs +36 -0
  170. package/dist/core/Receipt.mjs.map +1 -0
  171. package/dist/core/RememberingStore.d.mts +1562 -0
  172. package/dist/core/RememberingStore.mjs +190 -0
  173. package/dist/core/RememberingStore.mjs.map +1 -0
  174. package/dist/core/RunEvent.d.mts +2 -0
  175. package/dist/core/RunEvent.mjs +337 -0
  176. package/dist/core/RunEvent.mjs.map +1 -0
  177. package/dist/core/RunPolicyUsage.d.mts +2 -0
  178. package/dist/core/RunPolicyUsage.mjs +21 -0
  179. package/dist/core/RunPolicyUsage.mjs.map +1 -0
  180. package/dist/core/SemanticMemoryIndex.d.mts +826 -0
  181. package/dist/core/SemanticMemoryIndex.mjs +185 -0
  182. package/dist/core/SemanticMemoryIndex.mjs.map +1 -0
  183. package/dist/core/SemanticMemoryRevalidation.d.mts +45 -0
  184. package/dist/core/SemanticMemoryRevalidation.mjs +191 -0
  185. package/dist/core/SemanticMemoryRevalidation.mjs.map +1 -0
  186. package/dist/core/SubagentContract.d.mts +2 -0
  187. package/dist/core/SubagentContract.mjs +148 -0
  188. package/dist/core/SubagentContract.mjs.map +1 -0
  189. package/dist/core/Thread.d.mts +2 -0
  190. package/dist/core/Thread.mjs +250 -0
  191. package/dist/core/Thread.mjs.map +1 -0
  192. package/dist/core/ToolResult.d.mts +2 -0
  193. package/dist/core/ToolResult.mjs +156 -0
  194. package/dist/core/ToolResult.mjs.map +1 -0
  195. package/dist/core/Usage.d.mts +2 -0
  196. package/dist/core/Usage.mjs +319 -0
  197. package/dist/core/Usage.mjs.map +1 -0
  198. package/dist/core/Worker.d.mts +3 -0
  199. package/dist/core/Worker.mjs +3 -0
  200. package/dist/durable/ActivityStore.d.mts +116 -0
  201. package/dist/durable/ActivityStore.mjs +131 -0
  202. package/dist/durable/ActivityStore.mjs.map +1 -0
  203. package/dist/durable/Admin.d.mts +2 -0
  204. package/dist/durable/Admin.mjs +330 -0
  205. package/dist/durable/Admin.mjs.map +1 -0
  206. package/dist/durable/AgentRegistration.d.mts +2 -0
  207. package/dist/durable/AgentRegistration.mjs +14 -0
  208. package/dist/durable/AgentRegistration.mjs.map +1 -0
  209. package/dist/durable/Certification.d.mts +110 -0
  210. package/dist/durable/Certification.mjs +159 -0
  211. package/dist/durable/Certification.mjs.map +1 -0
  212. package/dist/durable/CommittedActivity.d.mts +62 -0
  213. package/dist/durable/CommittedActivity.mjs +159 -0
  214. package/dist/durable/CommittedActivity.mjs.map +1 -0
  215. package/dist/durable/Digest.d.mts +2 -0
  216. package/dist/durable/Digest.mjs +50 -0
  217. package/dist/durable/Digest.mjs.map +1 -0
  218. package/dist/durable/DurableAgentRuntime.d.mts +3 -0
  219. package/dist/durable/DurableAgentRuntime.mjs +3 -0
  220. package/dist/durable/DurableFailpoint.d.mts +2 -0
  221. package/dist/durable/DurableFailpoint.mjs +102 -0
  222. package/dist/durable/DurableFailpoint.mjs.map +1 -0
  223. package/dist/durable/DurableFailpointTestControl.d.mts +14 -0
  224. package/dist/durable/DurableFailpointTestControl.mjs +19 -0
  225. package/dist/durable/DurableFailpointTestControl.mjs.map +1 -0
  226. package/dist/durable/EventSource.d.mts +2 -0
  227. package/dist/durable/EventSource.mjs +65 -0
  228. package/dist/durable/EventSource.mjs.map +1 -0
  229. package/dist/durable/GitHubWorkflowSource.d.mts +185 -0
  230. package/dist/durable/GitHubWorkflowSource.mjs +209 -0
  231. package/dist/durable/GitHubWorkflowSource.mjs.map +1 -0
  232. package/dist/durable/MessageDelivery.d.mts +893 -0
  233. package/dist/durable/MessageDelivery.mjs +557 -0
  234. package/dist/durable/MessageDelivery.mjs.map +1 -0
  235. package/dist/durable/MessageDeliveryStoreConformance.d.mts +378 -0
  236. package/dist/durable/MessageDeliveryStoreConformance.mjs +270 -0
  237. package/dist/durable/MessageDeliveryStoreConformance.mjs.map +1 -0
  238. package/dist/durable/OperationAuthorizer.d.mts +2 -0
  239. package/dist/durable/OperationAuthorizer.mjs +70 -0
  240. package/dist/durable/OperationAuthorizer.mjs.map +1 -0
  241. package/dist/durable/PersistentHistory.d.mts +16 -0
  242. package/dist/durable/PersistentHistory.mjs +125 -0
  243. package/dist/durable/PersistentHistory.mjs.map +1 -0
  244. package/dist/durable/PreparedInputAdmission.d.mts +2 -0
  245. package/dist/durable/PreparedInputAdmission.mjs +38 -0
  246. package/dist/durable/PreparedInputAdmission.mjs.map +1 -0
  247. package/dist/durable/Records.d.mts +2 -0
  248. package/dist/durable/Records.mjs +848 -0
  249. package/dist/durable/Records.mjs.map +1 -0
  250. package/dist/durable/Recovery.d.mts +2 -0
  251. package/dist/durable/Recovery.mjs +739 -0
  252. package/dist/durable/Recovery.mjs.map +1 -0
  253. package/dist/durable/RunJournal.d.mts +2 -0
  254. package/dist/durable/RunJournal.mjs +2 -0
  255. package/dist/durable/Schedule.d.mts +2 -0
  256. package/dist/durable/Schedule.mjs +391 -0
  257. package/dist/durable/Schedule.mjs.map +1 -0
  258. package/dist/durable/ScheduleStoreConformance.d.mts +17 -0
  259. package/dist/durable/ScheduleStoreConformance.mjs +420 -0
  260. package/dist/durable/ScheduleStoreConformance.mjs.map +1 -0
  261. package/dist/durable/ScheduleTransition.d.mts +24 -0
  262. package/dist/durable/ScheduleTransition.mjs +180 -0
  263. package/dist/durable/ScheduleTransition.mjs.map +1 -0
  264. package/dist/durable/Scheduling.d.mts +54 -0
  265. package/dist/durable/Scheduling.mjs +2 -0
  266. package/dist/durable/SqlMemoryStore.d.mts +29 -0
  267. package/dist/durable/SqlMemoryStore.mjs +436 -0
  268. package/dist/durable/SqlMemoryStore.mjs.map +1 -0
  269. package/dist/durable/SqlMessageDeliveryStore.d.mts +42 -0
  270. package/dist/durable/SqlMessageDeliveryStore.mjs +179 -0
  271. package/dist/durable/SqlMessageDeliveryStore.mjs.map +1 -0
  272. package/dist/durable/SqlStorageV2Upgrade.d.mts +21 -0
  273. package/dist/durable/SqlStorageV2Upgrade.mjs +459 -0
  274. package/dist/durable/SqlStorageV2Upgrade.mjs.map +1 -0
  275. package/dist/durable/SqlSubscriptionStore.d.mts +62 -0
  276. package/dist/durable/SqlSubscriptionStore.mjs +751 -0
  277. package/dist/durable/SqlSubscriptionStore.mjs.map +1 -0
  278. package/dist/durable/SqlThreadNativeReads.d.mts +53 -0
  279. package/dist/durable/SqlThreadNativeReads.mjs +159 -0
  280. package/dist/durable/SqlThreadNativeReads.mjs.map +1 -0
  281. package/dist/durable/SubmissionLedger.d.mts +3 -0
  282. package/dist/durable/SubmissionLedger.mjs +959 -0
  283. package/dist/durable/SubmissionLedger.mjs.map +1 -0
  284. package/dist/durable/SubmissionLedgerConformance.d.mts +29 -0
  285. package/dist/durable/SubmissionLedgerConformance.mjs +2187 -0
  286. package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -0
  287. package/dist/durable/SubmissionStatus.d.mts +2 -0
  288. package/dist/durable/SubmissionStatus.mjs +18 -0
  289. package/dist/durable/SubmissionStatus.mjs.map +1 -0
  290. package/dist/durable/Subscription.d.mts +2 -0
  291. package/dist/durable/Subscription.mjs +360 -0
  292. package/dist/durable/Subscription.mjs.map +1 -0
  293. package/dist/durable/SubscriptionInput.d.mts +2 -0
  294. package/dist/durable/SubscriptionInput.mjs +52 -0
  295. package/dist/durable/SubscriptionInput.mjs.map +1 -0
  296. package/dist/durable/SubscriptionStoreConformance.d.mts +16 -0
  297. package/dist/durable/SubscriptionStoreConformance.mjs +625 -0
  298. package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -0
  299. package/dist/durable/SubscriptionTools.d.mts +273 -0
  300. package/dist/durable/SubscriptionTools.mjs +190 -0
  301. package/dist/durable/SubscriptionTools.mjs.map +1 -0
  302. package/dist/durable/SubscriptionTransition.d.mts +21 -0
  303. package/dist/durable/SubscriptionTransition.mjs +148 -0
  304. package/dist/durable/SubscriptionTransition.mjs.map +1 -0
  305. package/dist/durable/Subscriptions.d.mts +73 -0
  306. package/dist/durable/Subscriptions.mjs +627 -0
  307. package/dist/durable/Subscriptions.mjs.map +1 -0
  308. package/dist/durable/ThreadContextHistory.d.mts +32 -0
  309. package/dist/durable/ThreadContextHistory.mjs +152 -0
  310. package/dist/durable/ThreadContextHistory.mjs.map +1 -0
  311. package/dist/durable/ThreadContextHistoryProjection.d.mts +60 -0
  312. package/dist/durable/ThreadContextHistoryProjection.mjs +149 -0
  313. package/dist/durable/ThreadContextHistoryProjection.mjs.map +1 -0
  314. package/dist/durable/ThreadInvariants.d.mts +76 -0
  315. package/dist/durable/ThreadInvariants.mjs +246 -0
  316. package/dist/durable/ThreadInvariants.mjs.map +1 -0
  317. package/dist/durable/ThreadProjection.d.mts +78 -0
  318. package/dist/durable/ThreadProjection.mjs +158 -0
  319. package/dist/durable/ThreadProjection.mjs.map +1 -0
  320. package/dist/durable/ThreadProjectionMaintenance.d.mts +49 -0
  321. package/dist/durable/ThreadProjectionMaintenance.mjs +33 -0
  322. package/dist/durable/ThreadProjectionMaintenance.mjs.map +1 -0
  323. package/dist/durable/ThreadStore.d.mts +2 -0
  324. package/dist/durable/ThreadStore.mjs +355 -0
  325. package/dist/durable/ThreadStore.mjs.map +1 -0
  326. package/dist/durable/ThreadStoreConformance.d.mts +28 -0
  327. package/dist/durable/ThreadStoreConformance.mjs +503 -0
  328. package/dist/durable/ThreadStoreConformance.mjs.map +1 -0
  329. package/dist/durable/ToolReconciler.d.mts +2 -0
  330. package/dist/durable/ToolReconciler.mjs +85 -0
  331. package/dist/durable/ToolReconciler.mjs.map +1 -0
  332. package/dist/durable/WakeScheduler.d.mts +2 -0
  333. package/dist/durable/WakeScheduler.mjs +85 -0
  334. package/dist/durable/WakeScheduler.mjs.map +1 -0
  335. package/dist/durable/WorkerHost.d.mts +129 -0
  336. package/dist/durable/WorkerHost.mjs +77 -0
  337. package/dist/durable/WorkerHost.mjs.map +1 -0
  338. package/dist/engine/AgentRuntime.d.mts +2 -0
  339. package/dist/engine/AgentRuntime.mjs +2 -0
  340. package/dist/engine/Compaction.d.mts +7 -0
  341. package/dist/engine/Compaction.mjs +16 -0
  342. package/dist/engine/Compaction.mjs.map +1 -0
  343. package/dist/engine/ContextCompactor.d.mts +2 -0
  344. package/dist/engine/ContextCompactor.mjs +119 -0
  345. package/dist/engine/ContextCompactor.mjs.map +1 -0
  346. package/dist/engine/ContextHistory.d.mts +65 -0
  347. package/dist/engine/ContextHistory.mjs +76 -0
  348. package/dist/engine/ContextHistory.mjs.map +1 -0
  349. package/dist/engine/ContextWindow.d.mts +2 -0
  350. package/dist/engine/ContextWindow.mjs +59 -0
  351. package/dist/engine/ContextWindow.mjs.map +1 -0
  352. package/dist/engine/DurableStep.d.mts +2 -0
  353. package/dist/engine/DurableStep.mjs +62 -0
  354. package/dist/engine/DurableStep.mjs.map +1 -0
  355. package/dist/engine/MessagingHost.d.mts +2 -0
  356. package/dist/engine/MessagingHost.mjs +2 -0
  357. package/dist/engine/Output.d.mts +2 -0
  358. package/dist/engine/Output.mjs +8 -0
  359. package/dist/engine/Output.mjs.map +1 -0
  360. package/dist/engine/RunEventSink.d.mts +2 -0
  361. package/dist/engine/RunEventSink.mjs +22 -0
  362. package/dist/engine/RunEventSink.mjs.map +1 -0
  363. package/dist/engine/RunOptions.d.mts +2 -0
  364. package/dist/engine/RunOptions.mjs +124 -0
  365. package/dist/engine/RunOptions.mjs.map +1 -0
  366. package/dist/engine/SubagentHost.d.mts +2 -0
  367. package/dist/engine/SubagentHost.mjs +76 -0
  368. package/dist/engine/SubagentHost.mjs.map +1 -0
  369. package/dist/engine/ThreadHistory.d.mts +2 -0
  370. package/dist/engine/ThreadHistory.mjs +67 -0
  371. package/dist/engine/ThreadHistory.mjs.map +1 -0
  372. package/dist/engine/ToolBroker.d.mts +2 -0
  373. package/dist/engine/ToolBroker.mjs +42 -0
  374. package/dist/engine/ToolBroker.mjs.map +1 -0
  375. package/dist/foreign-diagnostic-DBQ1XHKh.mjs +37 -0
  376. package/dist/foreign-diagnostic-DBQ1XHKh.mjs.map +1 -0
  377. package/dist/index.d.mts +91 -6
  378. package/dist/index.mjs +100 -6
  379. package/dist/output-contract-BC7tjlGw.mjs +84 -0
  380. package/dist/output-contract-BC7tjlGw.mjs.map +1 -0
  381. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  382. package/dist/sandbox/CodeExecutor.d.mts +194 -0
  383. package/dist/sandbox/CodeExecutor.mjs +278 -0
  384. package/dist/sandbox/CodeExecutor.mjs.map +1 -0
  385. package/dist/sandbox/InteractiveBrowser.d.mts +257 -0
  386. package/dist/sandbox/InteractiveBrowser.mjs +236 -0
  387. package/dist/sandbox/InteractiveBrowser.mjs.map +1 -0
  388. package/dist/sandbox/PageCapture.d.mts +2 -0
  389. package/dist/sandbox/PageCapture.mjs +450 -0
  390. package/dist/sandbox/PageCapture.mjs.map +1 -0
  391. package/dist/sandbox/PageCrawl.d.mts +88 -0
  392. package/dist/sandbox/PageCrawl.mjs +124 -0
  393. package/dist/sandbox/PageCrawl.mjs.map +1 -0
  394. package/dist/sandbox/PageScreenshot.d.mts +2 -0
  395. package/dist/sandbox/PageScreenshot.mjs +53 -0
  396. package/dist/sandbox/PageScreenshot.mjs.map +1 -0
  397. package/dist/sandbox/ProtectedBrowser.d.mts +283 -0
  398. package/dist/sandbox/ProtectedBrowser.mjs +298 -0
  399. package/dist/sandbox/ProtectedBrowser.mjs.map +1 -0
  400. package/dist/sandbox/Sandbox.d.mts +2 -0
  401. package/dist/sandbox/Sandbox.mjs +208 -0
  402. package/dist/sandbox/Sandbox.mjs.map +1 -0
  403. package/dist/utf8-BYfhEkcj.mjs +11 -0
  404. package/dist/utf8-BYfhEkcj.mjs.map +1 -0
  405. package/dist/utf8-DchGZRBd.mjs +23 -0
  406. package/dist/utf8-DchGZRBd.mjs.map +1 -0
  407. package/package.json +1 -40
  408. package/src/InMemory.ts +19 -0
  409. package/src/ToolExposure.ts +2 -0
  410. package/src/capabilities/Approval.ts +352 -0
  411. package/src/capabilities/Budget.ts +536 -0
  412. package/src/capabilities/CodeMode.ts +1090 -0
  413. package/src/capabilities/Commands.ts +86 -0
  414. package/src/capabilities/ContextTools.ts +184 -0
  415. package/src/capabilities/Mcp.ts +426 -0
  416. package/src/capabilities/McpClient.ts +967 -0
  417. package/src/capabilities/MemoryNotes.ts +174 -0
  418. package/src/capabilities/Messaging.ts +261 -0
  419. package/src/capabilities/ModelContext.ts +354 -0
  420. package/src/capabilities/Redaction.ts +157 -0
  421. package/src/capabilities/Remembering.ts +550 -0
  422. package/src/capabilities/RunHooks.ts +280 -0
  423. package/src/capabilities/SemanticMemory.ts +447 -0
  424. package/src/capabilities/Subagent.ts +2489 -0
  425. package/src/capabilities/SubagentReservations.ts +850 -0
  426. package/src/capabilities/ToolDiscovery.ts +369 -0
  427. package/src/capabilities/WebCapture.ts +722 -0
  428. package/src/capabilities/WebSearch.ts +190 -0
  429. package/src/capabilities/internal/subagent-background.ts +1273 -0
  430. package/src/capabilities/internal/subagent-contract.ts +146 -0
  431. package/src/capabilities/internal/subagent-policy.ts +235 -0
  432. package/src/capabilities/internal/subagent-reporting.ts +136 -0
  433. package/src/capabilities/internal/utf8.ts +10 -0
  434. package/src/core/Agent.ts +602 -0
  435. package/src/core/AgentError.ts +172 -0
  436. package/src/core/AgentPolicy.ts +153 -0
  437. package/src/core/AgentUpdates.ts +100 -0
  438. package/src/core/FailureDiagnostic.ts +343 -0
  439. package/src/core/IdGenerator.ts +39 -0
  440. package/src/core/Identifiers.ts +48 -0
  441. package/src/core/Memory.ts +290 -0
  442. package/src/core/MemoryNamespace.ts +196 -0
  443. package/src/core/MemoryReference.ts +121 -0
  444. package/src/core/MemoryRevalidation.ts +185 -0
  445. package/src/core/MemoryStore.ts +368 -0
  446. package/src/core/Messaging.ts +72 -0
  447. package/src/core/Receipt.ts +42 -0
  448. package/src/core/RememberingStore.ts +300 -0
  449. package/src/core/RunEvent.ts +366 -0
  450. package/src/core/RunPolicyUsage.ts +17 -0
  451. package/src/core/SemanticMemoryIndex.ts +250 -0
  452. package/src/core/SemanticMemoryRevalidation.ts +254 -0
  453. package/src/core/SubagentContract.ts +196 -0
  454. package/src/core/Thread.ts +371 -0
  455. package/src/core/ToolExposure.ts +74 -0
  456. package/src/core/ToolResult.ts +190 -0
  457. package/src/core/Usage.ts +529 -0
  458. package/src/core/Worker.ts +240 -0
  459. package/src/core/internal/agent-updates.ts +34 -0
  460. package/src/core/internal/message-status.ts +60 -0
  461. package/src/core/internal/strict-schema.ts +14 -0
  462. package/src/core/internal/utf8.ts +23 -0
  463. package/src/durable/ActivityStore.ts +160 -0
  464. package/src/durable/Admin.ts +505 -0
  465. package/src/durable/AgentRegistration.ts +14 -0
  466. package/src/durable/Certification.ts +210 -0
  467. package/src/durable/CommittedActivity.ts +296 -0
  468. package/src/durable/Digest.ts +87 -0
  469. package/src/durable/DurableAgentRuntime.ts +11275 -0
  470. package/src/durable/DurableFailpoint.ts +111 -0
  471. package/src/durable/DurableFailpointTestControl.ts +39 -0
  472. package/src/durable/EventSource.ts +172 -0
  473. package/src/durable/GitHubWorkflowSource.ts +447 -0
  474. package/src/durable/MessageDelivery.ts +832 -0
  475. package/src/durable/MessageDeliveryStoreConformance.ts +410 -0
  476. package/src/durable/OperationAuthorizer.ts +85 -0
  477. package/src/durable/PersistentHistory.ts +260 -0
  478. package/src/durable/PreparedInputAdmission.ts +57 -0
  479. package/src/durable/Records.ts +1075 -0
  480. package/src/durable/Recovery.ts +1018 -0
  481. package/src/durable/RunJournal.ts +1631 -0
  482. package/src/durable/Schedule.ts +513 -0
  483. package/src/durable/ScheduleStoreConformance.ts +638 -0
  484. package/src/durable/ScheduleTransition.ts +265 -0
  485. package/src/durable/Scheduling.ts +1077 -0
  486. package/src/durable/SqlMemoryStore.ts +778 -0
  487. package/src/durable/SqlMessageDeliveryStore.ts +335 -0
  488. package/src/durable/SqlStorageV2Upgrade.ts +500 -0
  489. package/src/durable/SqlSubscriptionStore.ts +1440 -0
  490. package/src/durable/SqlThreadNativeReads.ts +270 -0
  491. package/src/durable/SubmissionLedger.ts +1265 -0
  492. package/src/durable/SubmissionLedgerConformance.ts +4820 -0
  493. package/src/durable/SubmissionStatus.ts +14 -0
  494. package/src/durable/Subscription.ts +544 -0
  495. package/src/durable/SubscriptionInput.ts +144 -0
  496. package/src/durable/SubscriptionStoreConformance.ts +945 -0
  497. package/src/durable/SubscriptionTools.ts +327 -0
  498. package/src/durable/SubscriptionTransition.ts +302 -0
  499. package/src/durable/Subscriptions.ts +1210 -0
  500. package/src/durable/ThreadContextHistory.ts +227 -0
  501. package/src/durable/ThreadContextHistoryProjection.ts +216 -0
  502. package/src/durable/ThreadInvariants.ts +507 -0
  503. package/src/durable/ThreadProjection.ts +269 -0
  504. package/src/durable/ThreadProjectionMaintenance.ts +67 -0
  505. package/src/durable/ThreadStore.ts +573 -0
  506. package/src/durable/ThreadStoreConformance.ts +1156 -0
  507. package/src/durable/ToolReconciler.ts +109 -0
  508. package/src/durable/WakeScheduler.ts +134 -0
  509. package/src/durable/WorkerHost.ts +171 -0
  510. package/src/durable/internal/agent-registration.ts +587 -0
  511. package/src/durable/internal/agent-updates.ts +302 -0
  512. package/src/durable/internal/foreign-diagnostic.ts +47 -0
  513. package/src/durable/internal/journal-checkpoint.ts +104 -0
  514. package/src/durable/internal/journal-metadata.ts +117 -0
  515. package/src/durable/internal/message-status.ts +20 -0
  516. package/src/durable/internal/messaging-host.ts +637 -0
  517. package/src/durable/internal/schedule-time.ts +303 -0
  518. package/src/durable/internal/storage-v2-layout.ts +163 -0
  519. package/src/durable/internal/storage-v2.ts +73 -0
  520. package/src/durable/internal/worker-host.ts +2885 -0
  521. package/src/durable/internal/worker-runtime.ts +9 -0
  522. package/src/engine/AgentRuntime.ts +37 -0
  523. package/src/engine/Compaction.ts +11 -0
  524. package/src/engine/ContextCompactor.ts +277 -0
  525. package/src/engine/ContextHistory.ts +73 -0
  526. package/src/engine/ContextWindow.ts +72 -0
  527. package/src/engine/DurableStep.ts +132 -0
  528. package/src/engine/MessagingHost.ts +110 -0
  529. package/src/engine/Output.ts +2 -0
  530. package/src/engine/RunEventSink.ts +132 -0
  531. package/src/engine/RunOptions.ts +1101 -0
  532. package/src/engine/SubagentHost.ts +230 -0
  533. package/src/engine/ThreadHistory.ts +120 -0
  534. package/src/engine/ToolBroker.ts +157 -0
  535. package/src/engine/ToolExposure.ts +48 -0
  536. package/src/engine/internal/agent-runtime.ts +10500 -0
  537. package/src/engine/internal/bounded-value.ts +315 -0
  538. package/src/engine/internal/compaction.ts +678 -0
  539. package/src/engine/internal/error-diagnostic.ts +39 -0
  540. package/src/engine/internal/output-contract.ts +173 -0
  541. package/src/engine/internal/primitive-delta.ts +80 -0
  542. package/src/engine/internal/provider-result-staging.ts +211 -0
  543. package/src/engine/internal/tool-derivative.ts +106 -0
  544. package/src/engine/internal/tool-exposure.ts +224 -0
  545. package/src/engine/internal/tool-telemetry.ts +484 -0
  546. package/src/index.ts +99 -21
  547. package/src/sandbox/CodeExecutor.ts +352 -0
  548. package/src/sandbox/InteractiveBrowser.ts +339 -0
  549. package/src/sandbox/PageCapture.ts +691 -0
  550. package/src/sandbox/PageCrawl.ts +148 -0
  551. package/src/sandbox/PageScreenshot.ts +81 -0
  552. package/src/sandbox/ProtectedBrowser.ts +452 -0
  553. package/src/sandbox/Sandbox.ts +241 -0
@@ -0,0 +1,157 @@
1
+ import { s as ToolBroker } from "../ToolBroker-DWs4tZra.mjs";
2
+ import { CodeExecutionLimits, CodeExecutionNamespace, CodeExecutor } from "../sandbox/CodeExecutor.mjs";
3
+ import { Tool } from "effect/unstable/ai";
4
+ import { Cause, Effect, Layer, Schema, Scope } from "effect";
5
+ declare namespace CodeMode_d_exports {
6
+ export { CodeModeDefinition, CodeModeDescriptionError, CodeModeFailure, CodeModeLayerRequirements, CodeModeNamespaces, CodeModeOptions, CodeModeParameters, CodeModePassReport, CodeModeSelectedRecord, CodeModeSelectedTool, CodeModeSuccess, CodeModeTool, CodeModeTools, make };
7
+ }
8
+ /** A pass-local report, available to the host even when the caller interrupts execution. */
9
+ export declare const CodeModePassReport: Schema.Struct<{
10
+ readonly status: Schema.Literals<readonly ["completed", "failed", "interrupted", "defect"]>;
11
+ readonly calls: Schema.$Array<Schema.Struct<{
12
+ readonly sequenceIndex: Schema.Natural;
13
+ readonly toolName: Schema.String;
14
+ readonly status: Schema.Literals<readonly ["not-started", "succeeded", "failed", "uncertain"]>;
15
+ readonly errorTag: Schema.optionalKey<Schema.String>;
16
+ }>>;
17
+ }>;
18
+ export type CodeModePassReport = typeof CodeModePassReport.Type;
19
+ /** Model-decoded Code Mode parameters: one async function expression. */
20
+ export declare const CodeModeParameters: Schema.Struct<{
21
+ readonly code: Schema.NonEmptyString;
22
+ }>;
23
+ declare const CodeModeSuccess_base: Schema.Class<CodeModeSuccess, Schema.Struct<{
24
+ readonly result: Schema.Codec<Schema.Json, Schema.Json, never, never>;
25
+ readonly logs: Schema.$Array<Schema.String>;
26
+ }>, {}>;
27
+ /**
28
+ * The bounded model-visible success: the program's JSON result plus captured
29
+ * logs, both already passed through the aggregate egress budget (CAP-016).
30
+ */
31
+ export declare class CodeModeSuccess extends CodeModeSuccess_base {}
32
+ declare const CodeModeFailure_base: Schema.Class<CodeModeFailure, Schema.TaggedStruct<"CodeModeFailure", {
33
+ readonly errorTag: Schema.NonEmptyString;
34
+ readonly message: Schema.String;
35
+ readonly logs: Schema.$Array<Schema.String>;
36
+ readonly thrown: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
37
+ /** Invocation-ordered evidence that fits the egress budget. This is not a replay plan. */
38
+ readonly calls: Schema.optionalKey<Schema.$Array<Schema.Struct<{
39
+ readonly sequenceIndex: Schema.Natural;
40
+ readonly toolName: Schema.String;
41
+ readonly status: Schema.Literals<readonly ["not-started", "succeeded", "failed", "uncertain"]>;
42
+ readonly errorTag: Schema.optionalKey<Schema.String>;
43
+ }>>>;
44
+ readonly omittedCalls: Schema.optionalKey<Schema.Natural>;
45
+ }>, Cause.YieldableError>;
46
+ /**
47
+ * The bounded model-visible failure envelope. `failureMode: "return"` turns
48
+ * it into a failed Tool result, so a model can correct a failing program
49
+ * without a blind retry; it carries the same bounded log capture as success
50
+ * plus the bounded thrown value where one exists, all inside the same
51
+ * aggregate egress budget (CAP-016).
52
+ */
53
+ export declare class CodeModeFailure extends CodeModeFailure_base {}
54
+ declare const CodeModeDescriptionError_base: Schema.Class<CodeModeDescriptionError, Schema.TaggedStruct<"CodeModeDescriptionError", {
55
+ readonly reason: Schema.Literals<readonly ["invalid-selection", "unknown-method", "invalid-bound", "limit-exceeded"]>;
56
+ readonly message: Schema.String;
57
+ }>, Cause.YieldableError>;
58
+ /** A selective documentation request is invalid or cannot fit its declared byte budget. */
59
+ export declare class CodeModeDescriptionError extends CodeModeDescriptionError_base {}
60
+ /** The namespace-record shape accepted by `CodeMode.make`. */
61
+ export type CodeModeNamespaces = Record<string, Record<string, Tool.Any>>;
62
+ /**
63
+ * Union of every Tool selected across all namespaces, computed distributively
64
+ * per namespace: indexing the namespace union with the INTERSECTION of method
65
+ * keys would erase every Tool once two namespaces have disjoint methods.
66
+ */
67
+ export type CodeModeSelectedTool<Namespaces extends CodeModeNamespaces> = { [Namespace in keyof Namespaces]: Namespaces[Namespace][keyof Namespaces[Namespace]]; }[keyof Namespaces];
68
+ /** The selected Tools re-keyed by their own Tool names. */
69
+ export type CodeModeSelectedRecord<Namespaces extends CodeModeNamespaces> = { readonly [T in CodeModeSelectedTool<Namespaces> as T["name"]]: T; };
70
+ /**
71
+ * The native Effect AI Tool created by `CodeMode.make` (CAP-014). Its only
72
+ * per-call dependency is the engine-provided `ToolBroker`; the `CodeExecutor`
73
+ * and every selected handler and redaction service are construction requirements of the handler
74
+ * Layer instead, so they stay visible in the composed `R`.
75
+ */
76
+ export type CodeModeTool<Name extends string> = Tool.Tool<Name, {
77
+ readonly parameters: typeof CodeModeParameters;
78
+ readonly success: typeof CodeModeSuccess;
79
+ readonly failure: typeof CodeModeFailure;
80
+ readonly failureMode: "return";
81
+ }, ToolBroker>;
82
+ /** Singleton Tool record provided by one Code Mode handler Layer. */
83
+ export type CodeModeTools<Name extends string> = { readonly [Key in Name]: CodeModeTool<Name>; };
84
+ /** Construction requirements of the Code Mode handler Layer. */
85
+ export type CodeModeLayerRequirements<Namespaces extends CodeModeNamespaces, RedactionRequirements = never> = CodeExecutor | Exclude<RedactionRequirements, Scope.Scope> | Tool.HandlersFor<CodeModeSelectedRecord<Namespaces>> | Tool.HandlerServices<CodeModeSelectedTool<Namespaces>>;
86
+ export interface CodeModeOptions<Namespaces extends CodeModeNamespaces, RedactionRequirements = never> {
87
+ /** Model-visible description; the builder appends the sandbox contract. */
88
+ readonly description: string;
89
+ /** Include all sandbox declarations in the model-facing description. Defaults to true. */
90
+ readonly includeDeclarations?: boolean | undefined;
91
+ /**
92
+ * Explicit allowlist: namespace name → method name → native Effect AI
93
+ * Tool. Reads and mutations are allowed; calls requiring additional approval fail closed.
94
+ */
95
+ readonly tools: Namespaces;
96
+ /** Executor limits for one pass; a bounded default applies when omitted. */
97
+ readonly limits?: CodeExecutionLimits | undefined;
98
+ /**
99
+ * Aggregate model-visible egress budget in UTF-8 bytes across the final
100
+ * result, captured logs, and any thrown value (CAP-016). Default 65536.
101
+ */
102
+ readonly maxEgressBytes?: number | undefined;
103
+ /**
104
+ * Host-only ephemeral report after executor resources and invocation fibers close, including
105
+ * failure, defect, and interruption. It contains no arguments/results and is never a checkpoint.
106
+ * Keep this total callback bounded; its services are captured with the handler Layer.
107
+ */
108
+ readonly onPassExit?: ((report: CodeModePassReport) => Effect.Effect<void, never, RedactionRequirements>) | undefined;
109
+ /**
110
+ * Optional aggregate redaction pass applied to the model-visible egress
111
+ * before the byte budget. Its services are acquired with the handler Layer;
112
+ * temporary resources close with each redaction invocation.
113
+ * It must be total; a defect stays a defect.
114
+ */
115
+ readonly redactEgress?: ((egress: {
116
+ readonly result: Schema.Json;
117
+ readonly logs: ReadonlyArray<string>;
118
+ }) => Effect.Effect<{
119
+ readonly result: Schema.Json;
120
+ readonly logs: ReadonlyArray<string>;
121
+ }, never, RedactionRequirements>) | undefined;
122
+ }
123
+ /**
124
+ * An immutable Code Mode definition: one model-facing Tool over an explicit
125
+ * allowlist, plus the handler Layer that runs generated programs through the
126
+ * `CodeExecutor` port and the engine-owned broker. It owns no acquired
127
+ * resources.
128
+ */
129
+ export interface CodeModeDefinition<Name extends string, Namespaces extends CodeModeNamespaces, RedactionRequirements = never> {
130
+ readonly name: Name;
131
+ /** The assembled model-facing description, optionally including all declarations. */
132
+ readonly description: string;
133
+ /** Rendered TypeScript declarations of the sandbox globals (documentation only). */
134
+ readonly declarations: string;
135
+ /**
136
+ * Render complete encoded-schema declarations for 1–64 unique, exact namespace.method names.
137
+ * The UTF-8 byte limit defaults to 16384 and must be an integer from 1 through 262144.
138
+ * Oversized documentation fails rather than truncating a declaration. This host operation
139
+ * does not authorize a model to see the selected methods; filter selections by current
140
+ * visibility and inherited grants before returning its output to a model.
141
+ */
142
+ readonly describe: (methods: ReadonlyArray<string>, options?: {
143
+ readonly maxBytes?: number | undefined;
144
+ }) => Effect.Effect<string, CodeModeDescriptionError>;
145
+ /** The executor-facing namespace catalog derived from the allowlist. */
146
+ readonly namespaces: ReadonlyArray<CodeExecutionNamespace>;
147
+ readonly limits: CodeExecutionLimits;
148
+ readonly maxEgressBytes: number;
149
+ /** The ordinary Effect AI Tool to include in the model-facing Toolkit. */
150
+ readonly tool: CodeModeTool<Name>;
151
+ /** Handler Layer; selected handler requirements stay visible in `R`. */
152
+ readonly handlers: Layer.Layer<Tool.HandlersFor<CodeModeTools<Name>>, never, CodeModeLayerRequirements<Namespaces, RedactionRequirements>>;
153
+ }
154
+ declare const make: <const Name extends string, Namespaces extends CodeModeNamespaces, RedactionRequirements = never>(name: Name, options: CodeModeOptions<Namespaces, RedactionRequirements>) => CodeModeDefinition<Name, Namespaces, RedactionRequirements>;
155
+ //#endregion
156
+ export { make, CodeMode_d_exports as t };
157
+ //# sourceMappingURL=CodeMode.d.mts.map
@@ -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