effect-agent 0.1.0-beta.15 → 0.1.0-beta.151

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 (542) hide show
  1. package/dist/Admin-CKIdJoP8.d.mts +4236 -0
  2. package/dist/Agent-1DMSO_Fl.mjs +86 -0
  3. package/dist/Agent-1DMSO_Fl.mjs.map +1 -0
  4. package/dist/Agent-Cjd_ZveM.d.mts +259 -0
  5. package/dist/AgentError-Bn1ytXRD.d.mts +117 -0
  6. package/dist/AgentPolicy-BqDoSXO6.d.mts +96 -0
  7. package/dist/AgentRuntime-D8U9gl9Q.mjs +4745 -0
  8. package/dist/AgentRuntime-D8U9gl9Q.mjs.map +1 -0
  9. package/dist/AgentRuntime-sXpKcyxu.d.mts +346 -0
  10. package/dist/AgentUpdates-DMJ-_xow.d.mts +53 -0
  11. package/dist/ContextCompactor-WwSIG_Z2.d.mts +161 -0
  12. package/dist/ContextWindow-DRQ5Mbm2.d.mts +58 -0
  13. package/dist/Digest-U69rDHuO.d.mts +22 -0
  14. package/dist/DurableAgentRuntime-R2LUYnRl.mjs +7207 -0
  15. package/dist/DurableAgentRuntime-R2LUYnRl.mjs.map +1 -0
  16. package/dist/DurableFailpoint-Cnr3wx1L.d.mts +41 -0
  17. package/dist/DurableStep-Cry_iol4.d.mts +103 -0
  18. package/dist/EventSource-CMbXXmwe.d.mts +51 -0
  19. package/dist/FailureDiagnostic-BElLOoED.mjs +274 -0
  20. package/dist/FailureDiagnostic-BElLOoED.mjs.map +1 -0
  21. package/dist/FailureDiagnostic-CaAkzGHL.d.mts +223 -0
  22. package/dist/Identifiers-CN2s30fF.d.mts +40 -0
  23. package/dist/InMemory.d.mts +24 -0
  24. package/dist/InMemory.mjs +24 -0
  25. package/dist/InMemory.mjs.map +1 -0
  26. package/dist/MemoryNamespace-BbRW5p71.d.mts +36 -0
  27. package/dist/MemoryReference-B8Q3UJoJ.d.mts +79 -0
  28. package/dist/Messaging-Dkg87ebg.d.mts +221 -0
  29. package/dist/Messaging-ccQURKCf.d.mts +1067 -0
  30. package/dist/MessagingHost-D04wE-7W.d.mts +74 -0
  31. package/dist/MessagingHost-DfsbMPvq.mjs +110 -0
  32. package/dist/MessagingHost-DfsbMPvq.mjs.map +1 -0
  33. package/dist/OperationAuthorizer-TzcQtpX5.d.mts +61 -0
  34. package/dist/Output-CFD1CPfU.d.mts +25 -0
  35. package/dist/PageCapture-Df8Xwskw.d.mts +583 -0
  36. package/dist/PreparedInputAdmission-Bt6rgtVu.d.mts +42 -0
  37. package/dist/Receipt-BAHyigAF.d.mts +33 -0
  38. package/dist/Records-B5GFWCpn.d.mts +1104 -0
  39. package/dist/RunEvent-DIrzkjLr.d.mts +460 -0
  40. package/dist/RunEventSink-D5aVhISG.d.mts +108 -0
  41. package/dist/RunJournal-Gd83HYqG.mjs +954 -0
  42. package/dist/RunJournal-Gd83HYqG.mjs.map +1 -0
  43. package/dist/RunOptions-Bv9NpkPZ.d.mts +943 -0
  44. package/dist/RunPolicyUsage-ClZxyR46.d.mts +21 -0
  45. package/dist/Sandbox-CEsDWBLq.d.mts +173 -0
  46. package/dist/Schedule-CtYREFnz.d.mts +847 -0
  47. package/dist/Scheduling-DPb2QyAK.mjs +691 -0
  48. package/dist/Scheduling-DPb2QyAK.mjs.map +1 -0
  49. package/dist/Subagent-VHrANXFy.d.mts +1652 -0
  50. package/dist/Subagent-hG9lJ7tJ.mjs +1502 -0
  51. package/dist/Subagent-hG9lJ7tJ.mjs.map +1 -0
  52. package/dist/SubagentContract-DdT7Cqe6.d.mts +116 -0
  53. package/dist/SubagentHost-C-4A7tA2.d.mts +172 -0
  54. package/dist/Subscription-BJAzYNw1.d.mts +979 -0
  55. package/dist/SubscriptionInput-CkBJt0AS.d.mts +41 -0
  56. package/dist/Thread-DOBQ0QUY.d.mts +96 -0
  57. package/dist/ThreadHistory-tS1KwxHR.d.mts +60 -0
  58. package/dist/ToolBroker-DWs4tZra.d.mts +133 -0
  59. package/dist/ToolExposure-9uF_Yo0T.mjs +10 -0
  60. package/dist/ToolExposure-9uF_Yo0T.mjs.map +1 -0
  61. package/dist/ToolExposure-C93U1sPu.mjs +30 -0
  62. package/dist/ToolExposure-C93U1sPu.mjs.map +1 -0
  63. package/dist/ToolExposure-UCN12eCd.d.mts +39 -0
  64. package/dist/ToolExposure-r2eOWk4F.d.mts +46 -0
  65. package/dist/ToolExposure.d.mts +8 -0
  66. package/dist/ToolExposure.mjs +21 -0
  67. package/dist/ToolExposure.mjs.map +1 -0
  68. package/dist/ToolReconciler-BmVRAHKs.d.mts +80 -0
  69. package/dist/ToolResult-BKdqWRff.d.mts +78 -0
  70. package/dist/Usage-Dx0aknfk.d.mts +121 -0
  71. package/dist/WakeScheduler-EjUF-GhC.d.mts +56 -0
  72. package/dist/Worker-CfwzMZEK.mjs +271 -0
  73. package/dist/Worker-CfwzMZEK.mjs.map +1 -0
  74. package/dist/Worker-fwWkBg12.d.mts +472 -0
  75. package/dist/WorkerAdmission-CJ_oWRuS.mjs +171 -0
  76. package/dist/WorkerAdmission-CJ_oWRuS.mjs.map +1 -0
  77. package/dist/agent-registration-CKNsrpwo.mjs +201 -0
  78. package/dist/agent-registration-CKNsrpwo.mjs.map +1 -0
  79. package/dist/capabilities/Approval.d.mts +114 -0
  80. package/dist/capabilities/Approval.mjs +226 -0
  81. package/dist/capabilities/Approval.mjs.map +1 -0
  82. package/dist/capabilities/Budget.d.mts +112 -0
  83. package/dist/capabilities/Budget.mjs +346 -0
  84. package/dist/capabilities/Budget.mjs.map +1 -0
  85. package/dist/capabilities/CodeMode.d.mts +157 -0
  86. package/dist/capabilities/CodeMode.mjs +523 -0
  87. package/dist/capabilities/CodeMode.mjs.map +1 -0
  88. package/dist/capabilities/Commands.d.mts +55 -0
  89. package/dist/capabilities/Commands.mjs +57 -0
  90. package/dist/capabilities/Commands.mjs.map +1 -0
  91. package/dist/capabilities/ContextTools.d.mts +321 -0
  92. package/dist/capabilities/ContextTools.mjs +126 -0
  93. package/dist/capabilities/ContextTools.mjs.map +1 -0
  94. package/dist/capabilities/Mcp.d.mts +108 -0
  95. package/dist/capabilities/Mcp.mjs +259 -0
  96. package/dist/capabilities/Mcp.mjs.map +1 -0
  97. package/dist/capabilities/McpClient.d.mts +115 -0
  98. package/dist/capabilities/McpClient.mjs +519 -0
  99. package/dist/capabilities/McpClient.mjs.map +1 -0
  100. package/dist/capabilities/MemoryNotes.d.mts +424 -0
  101. package/dist/capabilities/MemoryNotes.mjs +128 -0
  102. package/dist/capabilities/MemoryNotes.mjs.map +1 -0
  103. package/dist/capabilities/Messaging.d.mts +3 -0
  104. package/dist/capabilities/Messaging.mjs +152 -0
  105. package/dist/capabilities/Messaging.mjs.map +1 -0
  106. package/dist/capabilities/ModelContext.d.mts +89 -0
  107. package/dist/capabilities/ModelContext.mjs +168 -0
  108. package/dist/capabilities/ModelContext.mjs.map +1 -0
  109. package/dist/capabilities/Redaction.d.mts +37 -0
  110. package/dist/capabilities/Redaction.mjs +104 -0
  111. package/dist/capabilities/Redaction.mjs.map +1 -0
  112. package/dist/capabilities/Remembering.d.mts +434 -0
  113. package/dist/capabilities/Remembering.mjs +290 -0
  114. package/dist/capabilities/Remembering.mjs.map +1 -0
  115. package/dist/capabilities/RunHooks.d.mts +82 -0
  116. package/dist/capabilities/RunHooks.mjs +144 -0
  117. package/dist/capabilities/RunHooks.mjs.map +1 -0
  118. package/dist/capabilities/SemanticMemory.d.mts +431 -0
  119. package/dist/capabilities/SemanticMemory.mjs +315 -0
  120. package/dist/capabilities/SemanticMemory.mjs.map +1 -0
  121. package/dist/capabilities/Subagent.d.mts +4 -0
  122. package/dist/capabilities/Subagent.mjs +5 -0
  123. package/dist/capabilities/SubagentReservations.d.mts +186 -0
  124. package/dist/capabilities/SubagentReservations.mjs +479 -0
  125. package/dist/capabilities/SubagentReservations.mjs.map +1 -0
  126. package/dist/capabilities/ToolDiscovery.d.mts +124 -0
  127. package/dist/capabilities/ToolDiscovery.mjs +230 -0
  128. package/dist/capabilities/ToolDiscovery.mjs.map +1 -0
  129. package/dist/capabilities/WebCapture.d.mts +163 -0
  130. package/dist/capabilities/WebCapture.mjs +335 -0
  131. package/dist/capabilities/WebCapture.mjs.map +1 -0
  132. package/dist/capabilities/WebSearch.d.mts +71 -0
  133. package/dist/capabilities/WebSearch.mjs +115 -0
  134. package/dist/capabilities/WebSearch.mjs.map +1 -0
  135. package/dist/compaction-C2OTceKw.mjs +505 -0
  136. package/dist/compaction-C2OTceKw.mjs.map +1 -0
  137. package/dist/core/Agent.d.mts +2 -0
  138. package/dist/core/Agent.mjs +2 -0
  139. package/dist/core/AgentError.d.mts +2 -0
  140. package/dist/core/AgentError.mjs +134 -0
  141. package/dist/core/AgentError.mjs.map +1 -0
  142. package/dist/core/AgentPolicy.d.mts +2 -0
  143. package/dist/core/AgentPolicy.mjs +94 -0
  144. package/dist/core/AgentPolicy.mjs.map +1 -0
  145. package/dist/core/AgentUpdates.d.mts +2 -0
  146. package/dist/core/AgentUpdates.mjs +63 -0
  147. package/dist/core/AgentUpdates.mjs.map +1 -0
  148. package/dist/core/FailureDiagnostic.d.mts +2 -0
  149. package/dist/core/FailureDiagnostic.mjs +2 -0
  150. package/dist/core/IdGenerator.d.mts +26 -0
  151. package/dist/core/IdGenerator.mjs +27 -0
  152. package/dist/core/IdGenerator.mjs.map +1 -0
  153. package/dist/core/Identifiers.d.mts +2 -0
  154. package/dist/core/Identifiers.mjs +43 -0
  155. package/dist/core/Identifiers.mjs.map +1 -0
  156. package/dist/core/Memory.d.mts +57 -0
  157. package/dist/core/Memory.mjs +203 -0
  158. package/dist/core/Memory.mjs.map +1 -0
  159. package/dist/core/MemoryNamespace.d.mts +2 -0
  160. package/dist/core/MemoryNamespace.mjs +116 -0
  161. package/dist/core/MemoryNamespace.mjs.map +1 -0
  162. package/dist/core/MemoryReference.d.mts +2 -0
  163. package/dist/core/MemoryReference.mjs +109 -0
  164. package/dist/core/MemoryReference.mjs.map +1 -0
  165. package/dist/core/MemoryRevalidation.d.mts +65 -0
  166. package/dist/core/MemoryRevalidation.mjs +126 -0
  167. package/dist/core/MemoryRevalidation.mjs.map +1 -0
  168. package/dist/core/MemoryStore.d.mts +186 -0
  169. package/dist/core/MemoryStore.mjs +243 -0
  170. package/dist/core/MemoryStore.mjs.map +1 -0
  171. package/dist/core/Receipt.d.mts +2 -0
  172. package/dist/core/Receipt.mjs +36 -0
  173. package/dist/core/Receipt.mjs.map +1 -0
  174. package/dist/core/RememberingStore.d.mts +1562 -0
  175. package/dist/core/RememberingStore.mjs +190 -0
  176. package/dist/core/RememberingStore.mjs.map +1 -0
  177. package/dist/core/RunEvent.d.mts +2 -0
  178. package/dist/core/RunEvent.mjs +337 -0
  179. package/dist/core/RunEvent.mjs.map +1 -0
  180. package/dist/core/RunPolicyUsage.d.mts +2 -0
  181. package/dist/core/RunPolicyUsage.mjs +21 -0
  182. package/dist/core/RunPolicyUsage.mjs.map +1 -0
  183. package/dist/core/SemanticMemoryIndex.d.mts +826 -0
  184. package/dist/core/SemanticMemoryIndex.mjs +185 -0
  185. package/dist/core/SemanticMemoryIndex.mjs.map +1 -0
  186. package/dist/core/SemanticMemoryRevalidation.d.mts +45 -0
  187. package/dist/core/SemanticMemoryRevalidation.mjs +191 -0
  188. package/dist/core/SemanticMemoryRevalidation.mjs.map +1 -0
  189. package/dist/core/SubagentContract.d.mts +2 -0
  190. package/dist/core/SubagentContract.mjs +148 -0
  191. package/dist/core/SubagentContract.mjs.map +1 -0
  192. package/dist/core/Thread.d.mts +2 -0
  193. package/dist/core/Thread.mjs +250 -0
  194. package/dist/core/Thread.mjs.map +1 -0
  195. package/dist/core/ToolResult.d.mts +2 -0
  196. package/dist/core/ToolResult.mjs +156 -0
  197. package/dist/core/ToolResult.mjs.map +1 -0
  198. package/dist/core/Usage.d.mts +2 -0
  199. package/dist/core/Usage.mjs +319 -0
  200. package/dist/core/Usage.mjs.map +1 -0
  201. package/dist/core/Worker.d.mts +3 -0
  202. package/dist/core/Worker.mjs +3 -0
  203. package/dist/durable/ActivityStore.d.mts +116 -0
  204. package/dist/durable/ActivityStore.mjs +131 -0
  205. package/dist/durable/ActivityStore.mjs.map +1 -0
  206. package/dist/durable/Admin.d.mts +2 -0
  207. package/dist/durable/Admin.mjs +330 -0
  208. package/dist/durable/Admin.mjs.map +1 -0
  209. package/dist/durable/AgentRegistration.d.mts +2 -0
  210. package/dist/durable/AgentRegistration.mjs +14 -0
  211. package/dist/durable/AgentRegistration.mjs.map +1 -0
  212. package/dist/durable/Certification.d.mts +110 -0
  213. package/dist/durable/Certification.mjs +159 -0
  214. package/dist/durable/Certification.mjs.map +1 -0
  215. package/dist/durable/CommittedActivity.d.mts +64 -0
  216. package/dist/durable/CommittedActivity.mjs +159 -0
  217. package/dist/durable/CommittedActivity.mjs.map +1 -0
  218. package/dist/durable/Digest.d.mts +2 -0
  219. package/dist/durable/Digest.mjs +50 -0
  220. package/dist/durable/Digest.mjs.map +1 -0
  221. package/dist/durable/DurableAgentRuntime.d.mts +3 -0
  222. package/dist/durable/DurableAgentRuntime.mjs +4 -0
  223. package/dist/durable/DurableFailpoint.d.mts +2 -0
  224. package/dist/durable/DurableFailpoint.mjs +102 -0
  225. package/dist/durable/DurableFailpoint.mjs.map +1 -0
  226. package/dist/durable/DurableFailpointTestControl.d.mts +14 -0
  227. package/dist/durable/DurableFailpointTestControl.mjs +19 -0
  228. package/dist/durable/DurableFailpointTestControl.mjs.map +1 -0
  229. package/dist/durable/EventSource.d.mts +2 -0
  230. package/dist/durable/EventSource.mjs +65 -0
  231. package/dist/durable/EventSource.mjs.map +1 -0
  232. package/dist/durable/GitHubWorkflowSource.d.mts +185 -0
  233. package/dist/durable/GitHubWorkflowSource.mjs +209 -0
  234. package/dist/durable/GitHubWorkflowSource.mjs.map +1 -0
  235. package/dist/durable/LifecyclePublication.d.mts +2 -0
  236. package/dist/durable/LifecyclePublication.mjs +189 -0
  237. package/dist/durable/LifecyclePublication.mjs.map +1 -0
  238. package/dist/durable/MessageDelivery.d.mts +935 -0
  239. package/dist/durable/MessageDelivery.mjs +557 -0
  240. package/dist/durable/MessageDelivery.mjs.map +1 -0
  241. package/dist/durable/MessageDeliveryStoreConformance.d.mts +400 -0
  242. package/dist/durable/MessageDeliveryStoreConformance.mjs +270 -0
  243. package/dist/durable/MessageDeliveryStoreConformance.mjs.map +1 -0
  244. package/dist/durable/OperationAuthorizer.d.mts +2 -0
  245. package/dist/durable/OperationAuthorizer.mjs +70 -0
  246. package/dist/durable/OperationAuthorizer.mjs.map +1 -0
  247. package/dist/durable/PersistentHistory.d.mts +16 -0
  248. package/dist/durable/PersistentHistory.mjs +125 -0
  249. package/dist/durable/PersistentHistory.mjs.map +1 -0
  250. package/dist/durable/PreparedInputAdmission.d.mts +2 -0
  251. package/dist/durable/PreparedInputAdmission.mjs +38 -0
  252. package/dist/durable/PreparedInputAdmission.mjs.map +1 -0
  253. package/dist/durable/Records.d.mts +2 -0
  254. package/dist/durable/Records.mjs +858 -0
  255. package/dist/durable/Records.mjs.map +1 -0
  256. package/dist/durable/Recovery.d.mts +2 -0
  257. package/dist/durable/Recovery.mjs +739 -0
  258. package/dist/durable/Recovery.mjs.map +1 -0
  259. package/dist/durable/RunJournal.d.mts +2 -0
  260. package/dist/durable/RunJournal.mjs +2 -0
  261. package/dist/durable/Schedule.d.mts +2 -0
  262. package/dist/durable/Schedule.mjs +391 -0
  263. package/dist/durable/Schedule.mjs.map +1 -0
  264. package/dist/durable/ScheduleStoreConformance.d.mts +17 -0
  265. package/dist/durable/ScheduleStoreConformance.mjs +420 -0
  266. package/dist/durable/ScheduleStoreConformance.mjs.map +1 -0
  267. package/dist/durable/ScheduleTransition.d.mts +24 -0
  268. package/dist/durable/ScheduleTransition.mjs +180 -0
  269. package/dist/durable/ScheduleTransition.mjs.map +1 -0
  270. package/dist/durable/Scheduling.d.mts +55 -0
  271. package/dist/durable/Scheduling.mjs +2 -0
  272. package/dist/durable/SqlMemoryStore.d.mts +29 -0
  273. package/dist/durable/SqlMemoryStore.mjs +436 -0
  274. package/dist/durable/SqlMemoryStore.mjs.map +1 -0
  275. package/dist/durable/SubmissionLedger.d.mts +3 -0
  276. package/dist/durable/SubmissionLedger.mjs +986 -0
  277. package/dist/durable/SubmissionLedger.mjs.map +1 -0
  278. package/dist/durable/SubmissionLedgerConformance.d.mts +30 -0
  279. package/dist/durable/SubmissionLedgerConformance.mjs +2254 -0
  280. package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -0
  281. package/dist/durable/SubmissionStatus.d.mts +2 -0
  282. package/dist/durable/SubmissionStatus.mjs +18 -0
  283. package/dist/durable/SubmissionStatus.mjs.map +1 -0
  284. package/dist/durable/Subscription.d.mts +2 -0
  285. package/dist/durable/Subscription.mjs +360 -0
  286. package/dist/durable/Subscription.mjs.map +1 -0
  287. package/dist/durable/SubscriptionInput.d.mts +2 -0
  288. package/dist/durable/SubscriptionInput.mjs +52 -0
  289. package/dist/durable/SubscriptionInput.mjs.map +1 -0
  290. package/dist/durable/SubscriptionStoreConformance.d.mts +16 -0
  291. package/dist/durable/SubscriptionStoreConformance.mjs +625 -0
  292. package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -0
  293. package/dist/durable/SubscriptionTools.d.mts +274 -0
  294. package/dist/durable/SubscriptionTools.mjs +190 -0
  295. package/dist/durable/SubscriptionTools.mjs.map +1 -0
  296. package/dist/durable/SubscriptionTransition.d.mts +21 -0
  297. package/dist/durable/SubscriptionTransition.mjs +148 -0
  298. package/dist/durable/SubscriptionTransition.mjs.map +1 -0
  299. package/dist/durable/Subscriptions.d.mts +74 -0
  300. package/dist/durable/Subscriptions.mjs +627 -0
  301. package/dist/durable/Subscriptions.mjs.map +1 -0
  302. package/dist/durable/ThreadContextHistory.d.mts +32 -0
  303. package/dist/durable/ThreadContextHistory.mjs +152 -0
  304. package/dist/durable/ThreadContextHistory.mjs.map +1 -0
  305. package/dist/durable/ThreadContextHistoryProjection.d.mts +60 -0
  306. package/dist/durable/ThreadContextHistoryProjection.mjs +149 -0
  307. package/dist/durable/ThreadContextHistoryProjection.mjs.map +1 -0
  308. package/dist/durable/ThreadInvariants.d.mts +77 -0
  309. package/dist/durable/ThreadInvariants.mjs +246 -0
  310. package/dist/durable/ThreadInvariants.mjs.map +1 -0
  311. package/dist/durable/ThreadProjection.d.mts +78 -0
  312. package/dist/durable/ThreadProjection.mjs +158 -0
  313. package/dist/durable/ThreadProjection.mjs.map +1 -0
  314. package/dist/durable/ThreadProjectionMaintenance.d.mts +49 -0
  315. package/dist/durable/ThreadProjectionMaintenance.mjs +33 -0
  316. package/dist/durable/ThreadProjectionMaintenance.mjs.map +1 -0
  317. package/dist/durable/ThreadStore.d.mts +2 -0
  318. package/dist/durable/ThreadStore.mjs +383 -0
  319. package/dist/durable/ThreadStore.mjs.map +1 -0
  320. package/dist/durable/ThreadStoreConformance.d.mts +28 -0
  321. package/dist/durable/ThreadStoreConformance.mjs +543 -0
  322. package/dist/durable/ThreadStoreConformance.mjs.map +1 -0
  323. package/dist/durable/ToolReconciler.d.mts +2 -0
  324. package/dist/durable/ToolReconciler.mjs +85 -0
  325. package/dist/durable/ToolReconciler.mjs.map +1 -0
  326. package/dist/durable/WakeScheduler.d.mts +2 -0
  327. package/dist/durable/WakeScheduler.mjs +85 -0
  328. package/dist/durable/WakeScheduler.mjs.map +1 -0
  329. package/dist/durable/WorkerAdmission.d.mts +172 -0
  330. package/dist/durable/WorkerAdmission.mjs +2 -0
  331. package/dist/durable/WorkerHost.d.mts +156 -0
  332. package/dist/durable/WorkerHost.mjs +77 -0
  333. package/dist/durable/WorkerHost.mjs.map +1 -0
  334. package/dist/engine/AgentRuntime.d.mts +2 -0
  335. package/dist/engine/AgentRuntime.mjs +2 -0
  336. package/dist/engine/Compaction.d.mts +7 -0
  337. package/dist/engine/Compaction.mjs +16 -0
  338. package/dist/engine/Compaction.mjs.map +1 -0
  339. package/dist/engine/ContextCompactor.d.mts +2 -0
  340. package/dist/engine/ContextCompactor.mjs +119 -0
  341. package/dist/engine/ContextCompactor.mjs.map +1 -0
  342. package/dist/engine/ContextHistory.d.mts +65 -0
  343. package/dist/engine/ContextHistory.mjs +76 -0
  344. package/dist/engine/ContextHistory.mjs.map +1 -0
  345. package/dist/engine/ContextWindow.d.mts +2 -0
  346. package/dist/engine/ContextWindow.mjs +59 -0
  347. package/dist/engine/ContextWindow.mjs.map +1 -0
  348. package/dist/engine/DurableStep.d.mts +2 -0
  349. package/dist/engine/DurableStep.mjs +62 -0
  350. package/dist/engine/DurableStep.mjs.map +1 -0
  351. package/dist/engine/MessagingHost.d.mts +2 -0
  352. package/dist/engine/MessagingHost.mjs +2 -0
  353. package/dist/engine/Output.d.mts +2 -0
  354. package/dist/engine/Output.mjs +8 -0
  355. package/dist/engine/Output.mjs.map +1 -0
  356. package/dist/engine/RunEventSink.d.mts +2 -0
  357. package/dist/engine/RunEventSink.mjs +22 -0
  358. package/dist/engine/RunEventSink.mjs.map +1 -0
  359. package/dist/engine/RunOptions.d.mts +2 -0
  360. package/dist/engine/RunOptions.mjs +124 -0
  361. package/dist/engine/RunOptions.mjs.map +1 -0
  362. package/dist/engine/SubagentHost.d.mts +2 -0
  363. package/dist/engine/SubagentHost.mjs +76 -0
  364. package/dist/engine/SubagentHost.mjs.map +1 -0
  365. package/dist/engine/ThreadHistory.d.mts +2 -0
  366. package/dist/engine/ThreadHistory.mjs +67 -0
  367. package/dist/engine/ThreadHistory.mjs.map +1 -0
  368. package/dist/engine/ToolBroker.d.mts +2 -0
  369. package/dist/engine/ToolBroker.mjs +42 -0
  370. package/dist/engine/ToolBroker.mjs.map +1 -0
  371. package/dist/foreign-diagnostic-DBQ1XHKh.mjs +37 -0
  372. package/dist/foreign-diagnostic-DBQ1XHKh.mjs.map +1 -0
  373. package/dist/index.d.mts +92 -6
  374. package/dist/index.mjs +100 -6
  375. package/dist/output-contract-DS-S8mTv.mjs +135 -0
  376. package/dist/output-contract-DS-S8mTv.mjs.map +1 -0
  377. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  378. package/dist/sandbox/CodeExecutor.d.mts +194 -0
  379. package/dist/sandbox/CodeExecutor.mjs +278 -0
  380. package/dist/sandbox/CodeExecutor.mjs.map +1 -0
  381. package/dist/sandbox/InteractiveBrowser.d.mts +257 -0
  382. package/dist/sandbox/InteractiveBrowser.mjs +236 -0
  383. package/dist/sandbox/InteractiveBrowser.mjs.map +1 -0
  384. package/dist/sandbox/PageCapture.d.mts +2 -0
  385. package/dist/sandbox/PageCapture.mjs +450 -0
  386. package/dist/sandbox/PageCapture.mjs.map +1 -0
  387. package/dist/sandbox/PageCrawl.d.mts +88 -0
  388. package/dist/sandbox/PageCrawl.mjs +124 -0
  389. package/dist/sandbox/PageCrawl.mjs.map +1 -0
  390. package/dist/sandbox/PageScreenshot.d.mts +48 -0
  391. package/dist/sandbox/PageScreenshot.mjs +53 -0
  392. package/dist/sandbox/PageScreenshot.mjs.map +1 -0
  393. package/dist/sandbox/Sandbox.d.mts +2 -0
  394. package/dist/sandbox/Sandbox.mjs +208 -0
  395. package/dist/sandbox/Sandbox.mjs.map +1 -0
  396. package/dist/utf8-BYfhEkcj.mjs +11 -0
  397. package/dist/utf8-BYfhEkcj.mjs.map +1 -0
  398. package/dist/utf8-DchGZRBd.mjs +23 -0
  399. package/dist/utf8-DchGZRBd.mjs.map +1 -0
  400. package/package.json +1 -40
  401. package/src/InMemory.ts +19 -0
  402. package/src/ToolExposure.ts +2 -0
  403. package/src/capabilities/Approval.ts +352 -0
  404. package/src/capabilities/Budget.ts +536 -0
  405. package/src/capabilities/CodeMode.ts +1099 -0
  406. package/src/capabilities/Commands.ts +86 -0
  407. package/src/capabilities/ContextTools.ts +184 -0
  408. package/src/capabilities/Mcp.ts +426 -0
  409. package/src/capabilities/McpClient.ts +983 -0
  410. package/src/capabilities/MemoryNotes.ts +174 -0
  411. package/src/capabilities/Messaging.ts +261 -0
  412. package/src/capabilities/ModelContext.ts +354 -0
  413. package/src/capabilities/Redaction.ts +157 -0
  414. package/src/capabilities/Remembering.ts +550 -0
  415. package/src/capabilities/RunHooks.ts +280 -0
  416. package/src/capabilities/SemanticMemory.ts +447 -0
  417. package/src/capabilities/Subagent.ts +2489 -0
  418. package/src/capabilities/SubagentReservations.ts +850 -0
  419. package/src/capabilities/ToolDiscovery.ts +369 -0
  420. package/src/capabilities/WebCapture.ts +722 -0
  421. package/src/capabilities/WebSearch.ts +190 -0
  422. package/src/capabilities/internal/subagent-background.ts +1307 -0
  423. package/src/capabilities/internal/subagent-contract.ts +146 -0
  424. package/src/capabilities/internal/subagent-policy.ts +235 -0
  425. package/src/capabilities/internal/subagent-reporting.ts +136 -0
  426. package/src/capabilities/internal/utf8.ts +10 -0
  427. package/src/core/Agent.ts +609 -0
  428. package/src/core/AgentError.ts +172 -0
  429. package/src/core/AgentPolicy.ts +153 -0
  430. package/src/core/AgentUpdates.ts +100 -0
  431. package/src/core/FailureDiagnostic.ts +343 -0
  432. package/src/core/IdGenerator.ts +39 -0
  433. package/src/core/Identifiers.ts +48 -0
  434. package/src/core/Memory.ts +290 -0
  435. package/src/core/MemoryNamespace.ts +196 -0
  436. package/src/core/MemoryReference.ts +121 -0
  437. package/src/core/MemoryRevalidation.ts +185 -0
  438. package/src/core/MemoryStore.ts +368 -0
  439. package/src/core/Messaging.ts +72 -0
  440. package/src/core/Receipt.ts +42 -0
  441. package/src/core/RememberingStore.ts +300 -0
  442. package/src/core/RunEvent.ts +366 -0
  443. package/src/core/RunPolicyUsage.ts +17 -0
  444. package/src/core/SemanticMemoryIndex.ts +250 -0
  445. package/src/core/SemanticMemoryRevalidation.ts +254 -0
  446. package/src/core/SubagentContract.ts +196 -0
  447. package/src/core/Thread.ts +371 -0
  448. package/src/core/ToolExposure.ts +74 -0
  449. package/src/core/ToolResult.ts +190 -0
  450. package/src/core/Usage.ts +529 -0
  451. package/src/core/Worker.ts +240 -0
  452. package/src/core/internal/agent-updates.ts +34 -0
  453. package/src/core/internal/message-status.ts +60 -0
  454. package/src/core/internal/strict-schema.ts +14 -0
  455. package/src/core/internal/utf8.ts +23 -0
  456. package/src/durable/ActivityStore.ts +160 -0
  457. package/src/durable/Admin.ts +505 -0
  458. package/src/durable/AgentRegistration.ts +14 -0
  459. package/src/durable/Certification.ts +210 -0
  460. package/src/durable/CommittedActivity.ts +296 -0
  461. package/src/durable/Digest.ts +87 -0
  462. package/src/durable/DurableAgentRuntime.ts +11367 -0
  463. package/src/durable/DurableFailpoint.ts +111 -0
  464. package/src/durable/DurableFailpointTestControl.ts +39 -0
  465. package/src/durable/EventSource.ts +172 -0
  466. package/src/durable/GitHubWorkflowSource.ts +447 -0
  467. package/src/durable/LifecyclePublication.ts +298 -0
  468. package/src/durable/MessageDelivery.ts +834 -0
  469. package/src/durable/MessageDeliveryStoreConformance.ts +410 -0
  470. package/src/durable/OperationAuthorizer.ts +85 -0
  471. package/src/durable/PersistentHistory.ts +260 -0
  472. package/src/durable/PreparedInputAdmission.ts +57 -0
  473. package/src/durable/Records.ts +1087 -0
  474. package/src/durable/Recovery.ts +1018 -0
  475. package/src/durable/RunJournal.ts +1695 -0
  476. package/src/durable/Schedule.ts +513 -0
  477. package/src/durable/ScheduleStoreConformance.ts +638 -0
  478. package/src/durable/ScheduleTransition.ts +265 -0
  479. package/src/durable/Scheduling.ts +1077 -0
  480. package/src/durable/SqlMemoryStore.ts +778 -0
  481. package/src/durable/SubmissionLedger.ts +1297 -0
  482. package/src/durable/SubmissionLedgerConformance.ts +4940 -0
  483. package/src/durable/SubmissionStatus.ts +14 -0
  484. package/src/durable/Subscription.ts +544 -0
  485. package/src/durable/SubscriptionInput.ts +144 -0
  486. package/src/durable/SubscriptionStoreConformance.ts +945 -0
  487. package/src/durable/SubscriptionTools.ts +327 -0
  488. package/src/durable/SubscriptionTransition.ts +302 -0
  489. package/src/durable/Subscriptions.ts +1210 -0
  490. package/src/durable/ThreadContextHistory.ts +227 -0
  491. package/src/durable/ThreadContextHistoryProjection.ts +216 -0
  492. package/src/durable/ThreadInvariants.ts +507 -0
  493. package/src/durable/ThreadProjection.ts +269 -0
  494. package/src/durable/ThreadProjectionMaintenance.ts +67 -0
  495. package/src/durable/ThreadStore.ts +637 -0
  496. package/src/durable/ThreadStoreConformance.ts +1296 -0
  497. package/src/durable/ToolReconciler.ts +109 -0
  498. package/src/durable/WakeScheduler.ts +134 -0
  499. package/src/durable/WorkerAdmission.ts +104 -0
  500. package/src/durable/WorkerHost.ts +205 -0
  501. package/src/durable/internal/agent-registration.ts +587 -0
  502. package/src/durable/internal/agent-updates.ts +306 -0
  503. package/src/durable/internal/foreign-diagnostic.ts +47 -0
  504. package/src/durable/internal/journal-checkpoint.ts +104 -0
  505. package/src/durable/internal/journal-metadata.ts +124 -0
  506. package/src/durable/internal/message-status.ts +20 -0
  507. package/src/durable/internal/messaging-host.ts +637 -0
  508. package/src/durable/internal/schedule-time.ts +303 -0
  509. package/src/durable/internal/thread-initialization.ts +195 -0
  510. package/src/durable/internal/worker-host.ts +3309 -0
  511. package/src/durable/internal/worker-runtime.ts +9 -0
  512. package/src/engine/AgentRuntime.ts +37 -0
  513. package/src/engine/Compaction.ts +11 -0
  514. package/src/engine/ContextCompactor.ts +277 -0
  515. package/src/engine/ContextHistory.ts +73 -0
  516. package/src/engine/ContextWindow.ts +72 -0
  517. package/src/engine/DurableStep.ts +132 -0
  518. package/src/engine/MessagingHost.ts +110 -0
  519. package/src/engine/Output.ts +2 -0
  520. package/src/engine/RunEventSink.ts +132 -0
  521. package/src/engine/RunOptions.ts +1109 -0
  522. package/src/engine/SubagentHost.ts +239 -0
  523. package/src/engine/ThreadHistory.ts +120 -0
  524. package/src/engine/ToolBroker.ts +157 -0
  525. package/src/engine/ToolExposure.ts +48 -0
  526. package/src/engine/internal/agent-runtime.ts +10596 -0
  527. package/src/engine/internal/bounded-value.ts +315 -0
  528. package/src/engine/internal/compaction.ts +678 -0
  529. package/src/engine/internal/error-diagnostic.ts +39 -0
  530. package/src/engine/internal/output-contract.ts +250 -0
  531. package/src/engine/internal/primitive-delta.ts +80 -0
  532. package/src/engine/internal/provider-result-staging.ts +211 -0
  533. package/src/engine/internal/tool-derivative.ts +106 -0
  534. package/src/engine/internal/tool-exposure.ts +224 -0
  535. package/src/engine/internal/tool-telemetry.ts +484 -0
  536. package/src/index.ts +99 -22
  537. package/src/sandbox/CodeExecutor.ts +352 -0
  538. package/src/sandbox/InteractiveBrowser.ts +339 -0
  539. package/src/sandbox/PageCapture.ts +691 -0
  540. package/src/sandbox/PageCrawl.ts +148 -0
  541. package/src/sandbox/PageScreenshot.ts +81 -0
  542. package/src/sandbox/Sandbox.ts +241 -0
@@ -0,0 +1,2 @@
1
+ import { a as layer, n as ThreadHistoryError, r as ThreadHistoryRun, t as ThreadHistory } from "../ThreadHistory-tS1KwxHR.mjs";
2
+ export { ThreadHistory, ThreadHistoryError, ThreadHistoryRun, layer };
@@ -0,0 +1,67 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ import { ThreadId } from "../core/Identifiers.mjs";
3
+ import { Store, layerMemory, toPrompt } from "../core/Thread.mjs";
4
+ import { Context, Effect, Layer, Schema } from "effect";
5
+ //#region src/engine/ThreadHistory.ts
6
+ var ThreadHistory_exports = /* @__PURE__ */ __exportAll({
7
+ ThreadHistory: () => ThreadHistory,
8
+ ThreadHistoryError: () => ThreadHistoryError,
9
+ layer: () => layer
10
+ });
11
+ /** A history adapter rejected a read, staged value, or completed Run commit. */
12
+ var ThreadHistoryError = class extends Schema.TaggedError()("ThreadHistoryError", {
13
+ threadId: ThreadId,
14
+ reason: Schema.Literals([
15
+ "not-found",
16
+ "conflict",
17
+ "fenced",
18
+ "incompatible",
19
+ "limit",
20
+ "encoding",
21
+ "storage"
22
+ ]),
23
+ message: Schema.String,
24
+ cause: Schema.optionalKey(Schema.Defect())
25
+ }) {};
26
+ /**
27
+ * History shared by Runs with the same Thread ID. The default layer retains native messages
28
+ * incrementally in memory for its application Scope, including completed updates before a failure.
29
+ * PersistentHistory.layer from effect-agent/persistent-history instead commits successful
30
+ * Runs to an explicit ThreadStore. Durable hosts retain history through their journal hooks.
31
+ * No implementation may retry model or Tool execution or claim interrupted-work recovery.
32
+ */
33
+ var ThreadHistory = class ThreadHistory extends Context.Service()("@effect-agent/engine/ThreadHistory") {
34
+ /**
35
+ * Retain bounded in-memory history across Runs. Provide once around the application so
36
+ * all Runs share the same store. The underlying Thread.Store service is exposed for
37
+ * snapshots and interactive hooks; separate Layer builds own separate stores.
38
+ */
39
+ static layer = Layer.effect(ThreadHistory, Effect.gen(function* () {
40
+ const threads = yield* Store;
41
+ const historyError = (cause) => ThreadHistoryError.make({
42
+ threadId: cause.threadId,
43
+ reason: cause._tag === "ThreadNotFound" ? "not-found" : cause._tag === "ThreadLimitExceeded" ? "limit" : cause._tag === "ThreadHistoryDiverged" ? "conflict" : "encoding",
44
+ message: cause._tag === "ThreadNotFound" ? "Thread history is not present in this application Scope" : cause._tag === "ThreadLimitExceeded" ? `In-memory history exceeds the ${cause.limit} limit of ${cause.limitValue}` : cause.message,
45
+ cause
46
+ });
47
+ return ThreadHistory.of({
48
+ retention: "incremental",
49
+ load: (threadId) => threads.snapshot(threadId).pipe(Effect.map(toPrompt), Effect.mapError(historyError)),
50
+ open: Effect.fn("ThreadHistory.open")(function* ({ threadId, runId }) {
51
+ const snapshot = yield* threads.create(threadId).pipe(Effect.mapError(historyError));
52
+ return {
53
+ prompt: toPrompt(snapshot),
54
+ stageInput: () => Effect.void,
55
+ stageHistory: (history) => threads.recordHistory(threadId, runId, history).pipe(Effect.asVoid, Effect.mapError(historyError)),
56
+ commit: () => Effect.void
57
+ };
58
+ })
59
+ });
60
+ })).pipe(Layer.provideMerge(layerMemory));
61
+ };
62
+ /** Retain in-memory conversation history for the application Scope. */
63
+ const layer = ThreadHistory.layer;
64
+ //#endregion
65
+ export { ThreadHistory, ThreadHistoryError, layer, ThreadHistory_exports as t };
66
+
67
+ //# sourceMappingURL=ThreadHistory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreadHistory.mjs","names":["ConversationStore"],"sources":["../../src/engine/ThreadHistory.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema } from \"effect\";\nimport type { Prompt } from \"effect/unstable/ai\";\n\nimport { ThreadId, type RunId } from \"../core/Identifiers.ts\";\nimport { type RunCompleted } from \"../core/RunEvent.ts\";\nimport {\n Store as ConversationStore,\n layerMemory,\n toPrompt,\n type ThreadError,\n} from \"../core/Thread.ts\";\n\n/** A history adapter rejected a read, staged value, or completed Run commit. */\nexport class ThreadHistoryError extends Schema.TaggedError<ThreadHistoryError>()(\n \"ThreadHistoryError\",\n {\n threadId: ThreadId,\n reason: Schema.Literals([\n \"not-found\",\n \"conflict\",\n \"fenced\",\n \"incompatible\",\n \"limit\",\n \"encoding\",\n \"storage\",\n ]),\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * One Run's history owner. Incremental adapters retain each stageHistory update; on-success\n * adapters stage privately until commit. Before commit, the interpreter\n * finishes run-owned work and closes resources acquired for that Run, then validates the result\n * for run/start.await. Shared model, provider, and client services supplied by an enclosing\n * application Layer remain owned by that application's Scope and may outlive multiple Runs.\n * Commit must succeed before RunCompleted becomes observable. Schema-encoded input is opaque\n * here; the adapter owns its persistence boundary. A failed commit may have reached storage;\n * callers must inspect history before retrying external execution.\n */\nexport interface ThreadHistoryRun {\n readonly prompt: Prompt.Prompt;\n readonly stageInput: (input: unknown) => Effect.Effect<void, ThreadHistoryError>;\n readonly stageHistory: (history: Prompt.Prompt) => Effect.Effect<void, ThreadHistoryError>;\n readonly commit: (completed: RunCompleted) => Effect.Effect<void, ThreadHistoryError>;\n}\n\n/**\n * History shared by Runs with the same Thread ID. The default layer retains native messages\n * incrementally in memory for its application Scope, including completed updates before a failure.\n * PersistentHistory.layer from effect-agent/persistent-history instead commits successful\n * Runs to an explicit ThreadStore. Durable hosts retain history through their journal hooks.\n * No implementation may retry model or Tool execution or claim interrupted-work recovery.\n */\nexport class ThreadHistory extends Context.Service<\n ThreadHistory,\n {\n readonly retention: \"incremental\" | \"on-success\";\n readonly open: (request: {\n readonly threadId: ThreadId;\n readonly runId: RunId;\n }) => Effect.Effect<ThreadHistoryRun, ThreadHistoryError>;\n readonly load: (threadId: ThreadId) => Effect.Effect<Prompt.Prompt, ThreadHistoryError>;\n }\n>()(\"@effect-agent/engine/ThreadHistory\") {\n /**\n * Retain bounded in-memory history across Runs. Provide once around the application so\n * all Runs share the same store. The underlying Thread.Store service is exposed for\n * snapshots and interactive hooks; separate Layer builds own separate stores.\n */\n static readonly layer = Layer.effect(\n ThreadHistory,\n Effect.gen(function* () {\n const threads = yield* ConversationStore;\n\n const historyError = (cause: ThreadError): ThreadHistoryError =>\n ThreadHistoryError.make({\n threadId: cause.threadId,\n reason:\n cause._tag === \"ThreadNotFound\"\n ? \"not-found\"\n : cause._tag === \"ThreadLimitExceeded\"\n ? \"limit\"\n : cause._tag === \"ThreadHistoryDiverged\"\n ? \"conflict\"\n : \"encoding\",\n message:\n cause._tag === \"ThreadNotFound\"\n ? \"Thread history is not present in this application Scope\"\n : cause._tag === \"ThreadLimitExceeded\"\n ? `In-memory history exceeds the ${cause.limit} limit of ${cause.limitValue}`\n : cause.message,\n cause,\n });\n\n return ThreadHistory.of({\n retention: \"incremental\",\n load: (threadId) =>\n threads.snapshot(threadId).pipe(Effect.map(toPrompt), Effect.mapError(historyError)),\n open: Effect.fn(\"ThreadHistory.open\")(function* ({ threadId, runId }) {\n const snapshot = yield* threads.create(threadId).pipe(Effect.mapError(historyError));\n\n return {\n prompt: toPrompt(snapshot),\n stageInput: () => Effect.void,\n stageHistory: (history: Prompt.Prompt) =>\n threads\n .recordHistory(threadId, runId, history)\n .pipe(Effect.asVoid, Effect.mapError(historyError)),\n commit: () => Effect.void,\n };\n }),\n });\n }),\n ).pipe(Layer.provideMerge(layerMemory));\n}\n\n/** Retain in-memory conversation history for the application Scope. */\nexport const layer = ThreadHistory.layer;\n"],"mappings":";;;;;;;;;;;AAaA,IAAa,qBAAb,cAAwC,OAAO,YAAgC,CAAC,CAC9E,sBACA;CACE,UAAU;CACV,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC;;;;;;;;AA0BH,IAAa,gBAAb,MAAa,sBAAsB,QAAQ,QAUzC,CAAC,CAAC,oCAAoC,CAAC,CAAC;;;;;;CAMxC,OAAgB,QAAQ,MAAM,OAC5B,eACA,OAAO,IAAI,aAAa;EACtB,MAAM,UAAU,OAAOA;EAEvB,MAAM,gBAAgB,UACpB,mBAAmB,KAAK;GACtB,UAAU,MAAM;GAChB,QACE,MAAM,SAAS,mBACX,cACA,MAAM,SAAS,wBACb,UACA,MAAM,SAAS,0BACb,aACA;GACV,SACE,MAAM,SAAS,mBACX,4DACA,MAAM,SAAS,wBACb,iCAAiC,MAAM,MAAM,YAAY,MAAM,eAC/D,MAAM;GACd;EACF,CAAC;EAEH,OAAO,cAAc,GAAG;GACtB,WAAW;GACX,OAAO,aACL,QAAQ,SAAS,QAAQ,CAAC,CAAC,KAAK,OAAO,IAAI,QAAQ,GAAG,OAAO,SAAS,YAAY,CAAC;GACrF,MAAM,OAAO,GAAG,oBAAoB,CAAC,CAAC,WAAW,EAAE,UAAU,SAAS;IACpE,MAAM,WAAW,OAAO,QAAQ,OAAO,QAAQ,CAAC,CAAC,KAAK,OAAO,SAAS,YAAY,CAAC;IAEnF,OAAO;KACL,QAAQ,SAAS,QAAQ;KACzB,kBAAkB,OAAO;KACzB,eAAe,YACb,QACG,cAAc,UAAU,OAAO,OAAO,CAAC,CACvC,KAAK,OAAO,QAAQ,OAAO,SAAS,YAAY,CAAC;KACtD,cAAc,OAAO;IACvB;GACF,CAAC;EACH,CAAC;CACH,CAAC,CACH,CAAC,CAAC,KAAK,MAAM,aAAa,WAAW,CAAC;AACxC;;AAGA,MAAa,QAAQ,cAAc"}
@@ -0,0 +1,2 @@
1
+ import { a as ProgrammaticCallSuccess, c as ToolBrokerConfigurationError, d as ToolBrokerService, f as ToolBrokerUnavailableError, i as ProgrammaticCallRecord, l as ToolBrokerPass, n as ProgrammaticCallFailure, o as ProgrammaticToolInput, r as ProgrammaticCallOutcome, s as ToolBroker, t as ProgrammaticCallError, u as ToolBrokerPassOptions } from "../ToolBroker-DWs4tZra.mjs";
2
+ export { ProgrammaticCallError, ProgrammaticCallFailure, ProgrammaticCallOutcome, ProgrammaticCallRecord, ProgrammaticCallSuccess, ProgrammaticToolInput, ToolBroker, ToolBrokerConfigurationError, ToolBrokerPass, ToolBrokerPassOptions, ToolBrokerService, ToolBrokerUnavailableError };
@@ -0,0 +1,42 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ import { Context, Schema } from "effect";
3
+ //#region src/engine/ToolBroker.ts
4
+ var ToolBroker_exports = /* @__PURE__ */ __exportAll({
5
+ ProgrammaticCallRecord: () => ProgrammaticCallRecord,
6
+ ToolBroker: () => ToolBroker,
7
+ ToolBrokerConfigurationError: () => ToolBrokerConfigurationError,
8
+ ToolBrokerUnavailableError: () => ToolBrokerUnavailableError
9
+ });
10
+ /**
11
+ * Ephemeral execution evidence, ordered by invocation rather than completion. No arguments or
12
+ * results are copied into this diagnostic. A started call without a confirmed result is uncertain;
13
+ * a failed call is a confirmed failure, not a promise that external effects were rolled back.
14
+ */
15
+ const ProgrammaticCallRecord = Schema.Struct({
16
+ sequenceIndex: Schema.Natural,
17
+ toolName: Schema.String,
18
+ status: Schema.Literals([
19
+ "not-started",
20
+ "succeeded",
21
+ "failed",
22
+ "uncertain"
23
+ ]),
24
+ errorTag: Schema.optionalKey(Schema.String)
25
+ });
26
+ /** The broker was used outside a live Tool batch; there is nothing to bind to. */
27
+ var ToolBrokerUnavailableError = class extends Schema.TaggedError()("ToolBrokerUnavailableError", { message: Schema.String }) {};
28
+ /**
29
+ * The pass options are invalid — for example a `maxResultBytes` that is not
30
+ * a positive safe integer, which would make the size comparison fail open.
31
+ */
32
+ var ToolBrokerConfigurationError = class extends Schema.TaggedError()("ToolBrokerConfigurationError", { message: Schema.String }) {};
33
+ /**
34
+ * Engine-provided programmatic Tool broker (RUN-016, RUN-017). Declare it
35
+ * with `.addDependency(ToolBroker)` on a Tool that performs programmatic
36
+ * invocation; the interpreter supplies it, and an application Layer must not.
37
+ */
38
+ var ToolBroker = class extends Context.Service()("@effect-agent/engine/ToolBroker") {};
39
+ //#endregion
40
+ export { ProgrammaticCallRecord, ToolBroker, ToolBrokerConfigurationError, ToolBrokerUnavailableError, ToolBroker_exports as t };
41
+
42
+ //# sourceMappingURL=ToolBroker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolBroker.mjs","names":[],"sources":["../../src/engine/ToolBroker.ts"],"sourcesContent":["import type { Effect } from \"effect\";\nimport { Context, Schema } from \"effect\";\nimport type { Tool, Toolkit } from \"effect/unstable/ai\";\n\n/**\n * Programmatic Tool invocation seam for Code Mode (runtime spec §12.1,\n * ADR-0017 decision 3). The interpreter provides `ToolBroker` locally in the\n * same pattern as `AgentSpawner` and `DurableStep`: a fail-closed Run-level\n * default shadowed by a live per-outer-Tool-Call service, excluded from\n * `AgentRuntimeRequirements`. The live service is bound to the outer Tool\n * Call's identity, the Run's policy context, and the already-held scheduling\n * permit; per-call input from generated code is data only, and the broker\n * allocates every sequence index from its own monotonic per-pass state.\n */\n\n/** One programmatic invocation request. Data only: the broker owns identity. */\nexport interface ProgrammaticToolInput {\n /** The exact Effect AI Tool name resolved by the capability's namespace map. */\n readonly toolName: string;\n /** Schema-encoded (wire-form) parameters, exactly as they cross the sandbox. */\n readonly encodedArguments: unknown;\n}\n\n/** The handler ran and settled with an owned JSON snapshot of its encoded success value. */\nexport interface ProgrammaticCallSuccess {\n readonly _tag: \"ProgrammaticCallSuccess\";\n /** Broker-owned invocation index within the pass; rejected calls leave gaps. */\n readonly index: number;\n readonly encodedResult: unknown;\n}\n\n/**\n * The handler settled with the Tool's declared, Schema-encoded typed failure\n * (an Effect AI `failureMode: \"return\"` result). The program may catch and\n * branch on it.\n */\nexport interface ProgrammaticCallFailure {\n readonly _tag: \"ProgrammaticCallFailure\";\n readonly index: number;\n readonly encodedResult: unknown;\n}\n\n/**\n * The call never produced a settled handler result: a broker preflight\n * rejected it (authorization, budget, unknown Tool, approval-requiring Tool,\n * invalid parameters), the handler failed in its typed error channel, or the\n * result failed encoding or the broker-owned size bound. `errorTag` and\n * `message` are the same bounded projection the direct path uses for\n * `ToolCallFailed` events; `index` is present only when the handler was\n * actually started (preflight rejections consume no identity and no budget).\n */\nexport interface ProgrammaticCallError {\n readonly _tag: \"ProgrammaticCallError\";\n readonly index: number | undefined;\n readonly errorTag: string;\n readonly message: string;\n}\n\n/**\n * Total outcome of one programmatic invocation; defects stay defects. Trusted applications may\n * install `CurrentToolFailureObserver` to receive non-propagating failures before the outcome\n * returns, with the live Cause retained before projection. Neither Causes nor observation values\n * cross the broker boundary.\n */\nexport type ProgrammaticCallOutcome =\n | ProgrammaticCallSuccess\n | ProgrammaticCallFailure\n | ProgrammaticCallError;\n\n/**\n * Ephemeral execution evidence, ordered by invocation rather than completion. No arguments or\n * results are copied into this diagnostic. A started call without a confirmed result is uncertain;\n * a failed call is a confirmed failure, not a promise that external effects were rolled back.\n */\nexport const ProgrammaticCallRecord = Schema.Struct({\n sequenceIndex: Schema.Natural,\n toolName: Schema.String,\n status: Schema.Literals([\"not-started\", \"succeeded\", \"failed\", \"uncertain\"]),\n errorTag: Schema.optionalKey(Schema.String),\n});\n\nexport type ProgrammaticCallRecord = typeof ProgrammaticCallRecord.Type;\n\n/** Broker-owned per-pass policy for results crossing back into the sandbox. */\nexport interface ToolBrokerPassOptions {\n /** Maximum active invocations in this pass, from one through 64. Defaults to four. */\n readonly concurrency?: number | undefined;\n /**\n * Maximum UTF-8 byte size of one encoded success result at the sandbox\n * boundary. The returned value is decoded from the exact JSON representation\n * admitted by this bound, after redaction. Later handler or redactor mutations\n * cannot change it. The executor enforces its own transport bound independently.\n */\n readonly maxResultBytes: number;\n /**\n * Optional broker-owned redaction pass applied to every encoded success\n * result before the size bound. It must be total; a defect stays a defect.\n */\n readonly redactResult?: ((encodedResult: unknown) => Effect.Effect<unknown>) | undefined;\n}\n\n/**\n * One open programmatic pass, bound to one outer Tool Call. A finite Effect Semaphore bounds\n * execution. The caller owns invocation fibers and must join or interrupt them before leaving\n * its Scope. Results return as soon as they settle, without waiting for unrelated earlier calls.\n */\nexport interface ToolBrokerPass {\n readonly invoke: (input: ProgrammaticToolInput) => Effect.Effect<ProgrammaticCallOutcome>;\n /** Owned snapshot in invocation order, including interrupted and rejected calls. Never replay it. */\n readonly snapshot: Effect.Effect<ReadonlyArray<ProgrammaticCallRecord>>;\n}\n\n/** The broker was used outside a live Tool batch; there is nothing to bind to. */\nexport class ToolBrokerUnavailableError extends Schema.TaggedError<ToolBrokerUnavailableError>()(\n \"ToolBrokerUnavailableError\",\n {\n message: Schema.String,\n },\n) {}\n\n/**\n * The pass options are invalid — for example a `maxResultBytes` that is not\n * a positive safe integer, which would make the size comparison fail open.\n */\nexport class ToolBrokerConfigurationError extends Schema.TaggedError<ToolBrokerConfigurationError>()(\n \"ToolBrokerConfigurationError\",\n {\n message: Schema.String,\n },\n) {}\n\n/**\n * The engine-owned broker service. `openPass` fixes the capability-supplied\n * Toolkit and per-pass result policy once for the whole pass and captures the\n * handler services present at the call site, so nothing inside business\n * execution — least of all generated code — can substitute handlers, policy,\n * or identity afterwards.\n */\nexport interface ToolBrokerService {\n readonly openPass: <Tools extends Record<string, Tool.Any>>(\n toolkit: Toolkit.WithHandler<Tools>,\n options: ToolBrokerPassOptions,\n ) => Effect.Effect<\n ToolBrokerPass,\n ToolBrokerUnavailableError | ToolBrokerConfigurationError,\n Tool.HandlerServices<Tools[keyof Tools]>\n >;\n}\n\n/**\n * Engine-provided programmatic Tool broker (RUN-016, RUN-017). Declare it\n * with `.addDependency(ToolBroker)` on a Tool that performs programmatic\n * invocation; the interpreter supplies it, and an application Layer must not.\n */\nexport class ToolBroker extends Context.Service<ToolBroker, ToolBrokerService>()(\n \"@effect-agent/engine/ToolBroker\",\n) {}\n"],"mappings":";;;;;;;;;;;;;;AA0EA,MAAa,yBAAyB,OAAO,OAAO;CAClD,eAAe,OAAO;CACtB,UAAU,OAAO;CACjB,QAAQ,OAAO,SAAS;EAAC;EAAe;EAAa;EAAU;CAAW,CAAC;CAC3E,UAAU,OAAO,YAAY,OAAO,MAAM;AAC5C,CAAC;;AAkCD,IAAa,6BAAb,cAAgD,OAAO,YAAwC,CAAC,CAC9F,8BACA,EACE,SAAS,OAAO,OAClB,CACF,CAAC,CAAC,CAAC;;;;;AAMH,IAAa,+BAAb,cAAkD,OAAO,YAA0C,CAAC,CAClG,gCACA,EACE,SAAS,OAAO,OAClB,CACF,CAAC,CAAC,CAAC;;;;;;AAyBH,IAAa,aAAb,cAAgC,QAAQ,QAAuC,CAAC,CAC9E,iCACF,CAAC,CAAC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { Option, Schema } from "effect";
2
+ //#region src/durable/internal/foreign-diagnostic.ts
3
+ const ErrorMessage = Schema.Struct({ message: Schema.String });
4
+ const ErrorTag = Schema.Struct({ _tag: Schema.NonEmptyString });
5
+ const decodeErrorMessage = Schema.decodeUnknownOption(ErrorMessage);
6
+ const decodeErrorTag = Schema.decodeUnknownOption(ErrorTag);
7
+ /**
8
+ * Inspect a foreign failure without trusting its property accessors. Schema owns the accepted
9
+ * fields, while the guards around each decode keep hostile proxies and getters from escaping as
10
+ * defects during diagnostic projection.
11
+ */
12
+ const inspectForeignDiagnostic = (value) => {
13
+ let tag;
14
+ let message;
15
+ try {
16
+ tag = Option.getOrUndefined(decodeErrorTag(value))?._tag;
17
+ } catch {}
18
+ try {
19
+ message = Option.getOrUndefined(decodeErrorMessage(value))?.message;
20
+ } catch {}
21
+ return {
22
+ ...tag === void 0 ? {} : { tag },
23
+ ...message === void 0 ? {} : { message }
24
+ };
25
+ };
26
+ /** Render an opaque foreign value without allowing its coercion hooks to escape. */
27
+ const safeUnknownString = (value, fallback) => {
28
+ try {
29
+ return String(value);
30
+ } catch {
31
+ return fallback;
32
+ }
33
+ };
34
+ //#endregion
35
+ export { safeUnknownString as n, inspectForeignDiagnostic as t };
36
+
37
+ //# sourceMappingURL=foreign-diagnostic-DBQ1XHKh.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foreign-diagnostic-DBQ1XHKh.mjs","names":[],"sources":["../src/durable/internal/foreign-diagnostic.ts"],"sourcesContent":["import { Option, Schema } from \"effect\";\n\nconst ErrorMessage = Schema.Struct({ message: Schema.String });\nconst ErrorTag = Schema.Struct({ _tag: Schema.NonEmptyString });\nconst decodeErrorMessage = Schema.decodeUnknownOption(ErrorMessage);\nconst decodeErrorTag = Schema.decodeUnknownOption(ErrorTag);\n\ninterface ForeignDiagnostic {\n readonly tag?: string | undefined;\n readonly message?: string | undefined;\n}\n\n/**\n * Inspect a foreign failure without trusting its property accessors. Schema owns the accepted\n * fields, while the guards around each decode keep hostile proxies and getters from escaping as\n * defects during diagnostic projection.\n */\nexport const inspectForeignDiagnostic = (value: unknown): ForeignDiagnostic => {\n let tag: string | undefined;\n let message: string | undefined;\n\n try {\n tag = Option.getOrUndefined(decodeErrorTag(value))?._tag;\n } catch {\n // A diagnostic is best effort. The caller supplies the stable fallback classification.\n }\n\n try {\n message = Option.getOrUndefined(decodeErrorMessage(value))?.message;\n } catch {\n // A hostile message accessor must not replace the original failure with a defect.\n }\n\n return {\n ...(tag === undefined ? {} : { tag }),\n ...(message === undefined ? {} : { message }),\n };\n};\n\n/** Render an opaque foreign value without allowing its coercion hooks to escape. */\nexport const safeUnknownString = (value: unknown, fallback: string): string => {\n try {\n return String(value);\n } catch {\n return fallback;\n }\n};\n"],"mappings":";;AAEA,MAAM,eAAe,OAAO,OAAO,EAAE,SAAS,OAAO,OAAO,CAAC;AAC7D,MAAM,WAAW,OAAO,OAAO,EAAE,MAAM,OAAO,eAAe,CAAC;AAC9D,MAAM,qBAAqB,OAAO,oBAAoB,YAAY;AAClE,MAAM,iBAAiB,OAAO,oBAAoB,QAAQ;;;;;;AAY1D,MAAa,4BAA4B,UAAsC;CAC7E,IAAI;CACJ,IAAI;CAEJ,IAAI;EACF,MAAM,OAAO,eAAe,eAAe,KAAK,CAAC,CAAC,EAAE;CACtD,QAAQ,CAER;CAEA,IAAI;EACF,UAAU,OAAO,eAAe,mBAAmB,KAAK,CAAC,CAAC,EAAE;CAC9D,QAAQ,CAER;CAEA,OAAO;EACL,GAAI,QAAQ,KAAA,IAAY,CAAC,IAAI,EAAE,IAAI;EACnC,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ;CAC7C;AACF;;AAGA,MAAa,qBAAqB,OAAgB,aAA6B;CAC7E,IAAI;EACF,OAAO,OAAO,KAAK;CACrB,QAAQ;EACN,OAAO;CACT;AACF"}
package/dist/index.d.mts CHANGED
@@ -1,6 +1,92 @@
1
- import { CommandDrainPolicy, RunSchedulingOverride } from "@effect-agent/capabilities";
2
- import { delegationToolPrefix, isDelegationToolName } from "@effect-agent/core";
3
- export * from "@effect-agent/capabilities";
4
- export * from "@effect-agent/core";
5
- export * from "@effect-agent/engine";
6
- export { CommandDrainPolicy, RunSchedulingOverride, delegationToolPrefix, isDelegationToolName };
1
+ import { a as Identifiers_d_exports } from "./Identifiers-CN2s30fF.mjs";
2
+ import { f as Thread_d_exports } from "./Thread-DOBQ0QUY.mjs";
3
+ import { a as SubagentContract_d_exports } from "./SubagentContract-DdT7Cqe6.mjs";
4
+ import { t as SubagentReservations_d_exports } from "./capabilities/SubagentReservations.mjs";
5
+ import { o as Receipt_d_exports } from "./Receipt-BAHyigAF.mjs";
6
+ import { t as AgentUpdates_d_exports } from "./AgentUpdates-DMJ-_xow.mjs";
7
+ import { f as Usage_d_exports } from "./Usage-Dx0aknfk.mjs";
8
+ import { u as RunEvent_d_exports } from "./RunEvent-DIrzkjLr.mjs";
9
+ import { i as ThreadHistory_d_exports } from "./ThreadHistory-tS1KwxHR.mjs";
10
+ import { t as InMemory_d_exports } from "./InMemory.mjs";
11
+ import { t as ToolExposure_d_exports } from "./ToolExposure.mjs";
12
+ import { t as Redaction_d_exports } from "./capabilities/Redaction.mjs";
13
+ import { t as Approval_d_exports } from "./capabilities/Approval.mjs";
14
+ import { t as Budget_d_exports } from "./capabilities/Budget.mjs";
15
+ import { p as ToolBroker_d_exports } from "./ToolBroker-DWs4tZra.mjs";
16
+ import { D as Sandbox_d_exports } from "./Sandbox-CEsDWBLq.mjs";
17
+ import { t as CodeExecutor_d_exports } from "./sandbox/CodeExecutor.mjs";
18
+ import { t as CodeMode_d_exports } from "./capabilities/CodeMode.mjs";
19
+ import { a as FailureDiagnostic_d_exports } from "./FailureDiagnostic-CaAkzGHL.mjs";
20
+ import { i as AgentError_d_exports } from "./AgentError-Bn1ytXRD.mjs";
21
+ import { r as ToolResult_d_exports } from "./ToolResult-BKdqWRff.mjs";
22
+ import { r as AgentPolicy_d_exports } from "./AgentPolicy-BqDoSXO6.mjs";
23
+ import { t as Agent_d_exports } from "./Agent-Cjd_ZveM.mjs";
24
+ import { c as MemoryReference_d_exports } from "./MemoryReference-B8Q3UJoJ.mjs";
25
+ import { n as RunPolicyUsage_d_exports } from "./RunPolicyUsage-ClZxyR46.mjs";
26
+ import { x as Worker_d_exports } from "./Worker-fwWkBg12.mjs";
27
+ import { s as ContextWindow_d_exports } from "./ContextWindow-DRQ5Mbm2.mjs";
28
+ import { s as ContextCompactor_d_exports } from "./ContextCompactor-WwSIG_Z2.mjs";
29
+ import { i as DurableStep_d_exports } from "./DurableStep-Cry_iol4.mjs";
30
+ import { F as RunOptions_d_exports } from "./RunOptions-Bv9NpkPZ.mjs";
31
+ import { t as Commands_d_exports } from "./capabilities/Commands.mjs";
32
+ import { t as ContextHistory_d_exports } from "./engine/ContextHistory.mjs";
33
+ import { t as ContextTools_d_exports } from "./capabilities/ContextTools.mjs";
34
+ import { t as Mcp_d_exports } from "./capabilities/Mcp.mjs";
35
+ import { t as McpClient_d_exports } from "./capabilities/McpClient.mjs";
36
+ import { i as MemoryNamespace_d_exports } from "./MemoryNamespace-BbRW5p71.mjs";
37
+ import { t as MemoryStore_d_exports } from "./core/MemoryStore.mjs";
38
+ import { t as MemoryNotes_d_exports } from "./capabilities/MemoryNotes.mjs";
39
+ import { n as MessagingHost_d_exports } from "./MessagingHost-D04wE-7W.mjs";
40
+ import { t as Messaging_d_exports } from "./Messaging-ccQURKCf.mjs";
41
+ import { t as ModelContext_d_exports } from "./capabilities/ModelContext.mjs";
42
+ import { t as RememberingStore_d_exports } from "./core/RememberingStore.mjs";
43
+ import { t as Remembering_d_exports } from "./capabilities/Remembering.mjs";
44
+ import { t as RunHooks_d_exports } from "./capabilities/RunHooks.mjs";
45
+ import { t as MemoryRevalidation_d_exports } from "./core/MemoryRevalidation.mjs";
46
+ import { t as SemanticMemoryIndex_d_exports } from "./core/SemanticMemoryIndex.mjs";
47
+ import { t as SemanticMemoryRevalidation_d_exports } from "./core/SemanticMemoryRevalidation.mjs";
48
+ import { t as SemanticMemory_d_exports } from "./capabilities/SemanticMemory.mjs";
49
+ import { s as SubagentHost_d_exports } from "./SubagentHost-C-4A7tA2.mjs";
50
+ import { t as AgentRuntime_d_exports } from "./AgentRuntime-sXpKcyxu.mjs";
51
+ import { i as RunEventSink_d_exports } from "./RunEventSink-D5aVhISG.mjs";
52
+ import { v as Subagent_d_exports } from "./Subagent-VHrANXFy.mjs";
53
+ import { t as ToolDiscovery_d_exports } from "./capabilities/ToolDiscovery.mjs";
54
+ import { D as PageCapture_d_exports } from "./PageCapture-Df8Xwskw.mjs";
55
+ import { t as WebCapture_d_exports } from "./capabilities/WebCapture.mjs";
56
+ import { t as WebSearch_d_exports } from "./capabilities/WebSearch.mjs";
57
+ import { t as IdGenerator_d_exports } from "./core/IdGenerator.mjs";
58
+ import { t as Memory_d_exports } from "./core/Memory.mjs";
59
+ import { N as Records_d_exports } from "./Records-B5GFWCpn.mjs";
60
+ import { t as ActivityStore_d_exports } from "./durable/ActivityStore.mjs";
61
+ import { n as Digest_d_exports } from "./Digest-U69rDHuO.mjs";
62
+ import { J as Recovery_d_exports, Pa as AgentRegistration_d_exports, Pi as RunJournal_d_exports, Qn as DurableAgentRuntime_d_exports, Si as LifecyclePublication_d_exports, bn as SubmissionLedger_d_exports, ki as SubmissionStatus_d_exports, oi as ThreadStore_d_exports, t as Admin_d_exports } from "./Admin-CKIdJoP8.mjs";
63
+ import { t as DurableFailpoint_d_exports } from "./DurableFailpoint-Cnr3wx1L.mjs";
64
+ import { a as OperationAuthorizer_d_exports } from "./OperationAuthorizer-TzcQtpX5.mjs";
65
+ import { l as ToolReconciler_d_exports } from "./ToolReconciler-BmVRAHKs.mjs";
66
+ import { n as WakeScheduler_d_exports } from "./WakeScheduler-EjUF-GhC.mjs";
67
+ import { t as CommittedActivity_d_exports } from "./durable/CommittedActivity.mjs";
68
+ import { R as Schedule_d_exports } from "./Schedule-CtYREFnz.mjs";
69
+ import { k as Subscription_d_exports } from "./Subscription-BJAzYNw1.mjs";
70
+ import { n as EventSource_d_exports } from "./EventSource-CMbXXmwe.mjs";
71
+ import { n as PreparedInputAdmission_d_exports } from "./PreparedInputAdmission-Bt6rgtVu.mjs";
72
+ import { r as SubscriptionInput_d_exports } from "./SubscriptionInput-CkBJt0AS.mjs";
73
+ import { t as Subscriptions_d_exports } from "./durable/Subscriptions.mjs";
74
+ import { t as MessageDelivery_d_exports } from "./durable/MessageDelivery.mjs";
75
+ import { t as PersistentHistory_d_exports } from "./durable/PersistentHistory.mjs";
76
+ import { t as ScheduleTransition_d_exports } from "./durable/ScheduleTransition.mjs";
77
+ import { t as Scheduling_d_exports } from "./durable/Scheduling.mjs";
78
+ import { t as SubscriptionTools_d_exports } from "./durable/SubscriptionTools.mjs";
79
+ import { t as SubscriptionTransition_d_exports } from "./durable/SubscriptionTransition.mjs";
80
+ import { t as ThreadContextHistory_d_exports } from "./durable/ThreadContextHistory.mjs";
81
+ import { t as ThreadContextHistoryProjection_d_exports } from "./durable/ThreadContextHistoryProjection.mjs";
82
+ import { t as ThreadInvariants_d_exports } from "./durable/ThreadInvariants.mjs";
83
+ import { t as ThreadProjection_d_exports } from "./durable/ThreadProjection.mjs";
84
+ import { t as ThreadProjectionMaintenance_d_exports } from "./durable/ThreadProjectionMaintenance.mjs";
85
+ import { t as WorkerAdmission_d_exports } from "./durable/WorkerAdmission.mjs";
86
+ import { t as WorkerHost_d_exports } from "./durable/WorkerHost.mjs";
87
+ import { t as Compaction_d_exports } from "./engine/Compaction.mjs";
88
+ import { t as Output_d_exports } from "./Output-CFD1CPfU.mjs";
89
+ import { t as PageScreenshot_d_exports } from "./sandbox/PageScreenshot.mjs";
90
+ import { t as InteractiveBrowser_d_exports } from "./sandbox/InteractiveBrowser.mjs";
91
+ import { t as PageCrawl_d_exports } from "./sandbox/PageCrawl.mjs";
92
+ export { ActivityStore_d_exports as ActivityStore, Admin_d_exports as Admin, Agent_d_exports as Agent, AgentError_d_exports as AgentError, AgentPolicy_d_exports as AgentPolicy, AgentRegistration_d_exports as AgentRegistration, AgentRuntime_d_exports as AgentRuntime, AgentUpdates_d_exports as AgentUpdates, Approval_d_exports as Approval, Budget_d_exports as Budget, CodeExecutor_d_exports as CodeExecutor, CodeMode_d_exports as CodeMode, Commands_d_exports as Commands, CommittedActivity_d_exports as CommittedActivity, Compaction_d_exports as Compaction, ContextCompactor_d_exports as ContextCompactor, ContextHistory_d_exports as ContextHistory, ContextTools_d_exports as ContextTools, ContextWindow_d_exports as ContextWindow, Digest_d_exports as Digest, DurableAgentRuntime_d_exports as DurableAgentRuntime, DurableFailpoint_d_exports as DurableFailpoint, DurableStep_d_exports as DurableStep, EventSource_d_exports as EventSource, FailureDiagnostic_d_exports as FailureDiagnostic, IdGenerator_d_exports as IdGenerator, Identifiers_d_exports as Identifiers, InMemory_d_exports as InMemory, InteractiveBrowser_d_exports as InteractiveBrowser, LifecyclePublication_d_exports as LifecyclePublication, Mcp_d_exports as Mcp, McpClient_d_exports as McpClient, Memory_d_exports as Memory, MemoryNamespace_d_exports as MemoryNamespace, MemoryNotes_d_exports as MemoryNotes, MemoryReference_d_exports as MemoryReference, MemoryRevalidation_d_exports as MemoryRevalidation, MemoryStore_d_exports as MemoryStore, MessageDelivery_d_exports as MessageDelivery, Messaging_d_exports as Messaging, MessagingHost_d_exports as MessagingHost, ModelContext_d_exports as ModelContext, OperationAuthorizer_d_exports as OperationAuthorizer, Output_d_exports as Output, PageCapture_d_exports as PageCapture, PageCrawl_d_exports as PageCrawl, PageScreenshot_d_exports as PageScreenshot, PersistentHistory_d_exports as PersistentHistory, PreparedInputAdmission_d_exports as PreparedInputAdmission, Receipt_d_exports as Receipt, Records_d_exports as Records, Recovery_d_exports as Recovery, Redaction_d_exports as Redaction, Remembering_d_exports as Remembering, RememberingStore_d_exports as RememberingStore, RunEvent_d_exports as RunEvent, RunEventSink_d_exports as RunEventSink, RunHooks_d_exports as RunHooks, RunJournal_d_exports as RunJournal, RunOptions_d_exports as RunOptions, RunPolicyUsage_d_exports as RunPolicyUsage, Sandbox_d_exports as Sandbox, Schedule_d_exports as Schedule, ScheduleTransition_d_exports as ScheduleTransition, Scheduling_d_exports as Scheduling, SemanticMemory_d_exports as SemanticMemory, SemanticMemoryIndex_d_exports as SemanticMemoryIndex, SemanticMemoryRevalidation_d_exports as SemanticMemoryRevalidation, Subagent_d_exports as Subagent, SubagentContract_d_exports as SubagentContract, SubagentHost_d_exports as SubagentHost, SubagentReservations_d_exports as SubagentReservations, SubmissionLedger_d_exports as SubmissionLedger, SubmissionStatus_d_exports as SubmissionStatus, Subscription_d_exports as Subscription, SubscriptionInput_d_exports as SubscriptionInput, SubscriptionTools_d_exports as SubscriptionTools, SubscriptionTransition_d_exports as SubscriptionTransition, Subscriptions_d_exports as Subscriptions, Thread_d_exports as Thread, ThreadContextHistory_d_exports as ThreadContextHistory, ThreadContextHistoryProjection_d_exports as ThreadContextHistoryProjection, ThreadHistory_d_exports as ThreadHistory, ThreadInvariants_d_exports as ThreadInvariants, ThreadProjection_d_exports as ThreadProjection, ThreadProjectionMaintenance_d_exports as ThreadProjectionMaintenance, ThreadStore_d_exports as ThreadStore, ToolBroker_d_exports as ToolBroker, ToolDiscovery_d_exports as ToolDiscovery, ToolExposure_d_exports as ToolExposure, ToolReconciler_d_exports as ToolReconciler, ToolResult_d_exports as ToolResult, Usage_d_exports as Usage, WakeScheduler_d_exports as WakeScheduler, WebCapture_d_exports as WebCapture, WebSearch_d_exports as WebSearch, Worker_d_exports as Worker, WorkerAdmission_d_exports as WorkerAdmission, WorkerHost_d_exports as WorkerHost };
package/dist/index.mjs CHANGED
@@ -1,6 +1,100 @@
1
- import { CommandDrainPolicy, RunSchedulingOverride } from "@effect-agent/capabilities";
2
- import { delegationToolPrefix, isDelegationToolName } from "@effect-agent/core";
3
- export * from "@effect-agent/capabilities";
4
- export * from "@effect-agent/core";
5
- export * from "@effect-agent/engine";
6
- export { CommandDrainPolicy, RunSchedulingOverride, delegationToolPrefix, isDelegationToolName };
1
+ import { t as Identifiers_exports } from "./core/Identifiers.mjs";
2
+ import { t as ToolResult_exports } from "./core/ToolResult.mjs";
3
+ import { t as AgentPolicy_exports } from "./core/AgentPolicy.mjs";
4
+ import { t as Receipt_exports } from "./core/Receipt.mjs";
5
+ import { t as AgentUpdates_exports } from "./core/AgentUpdates.mjs";
6
+ import { t as Agent_exports } from "./Agent-1DMSO_Fl.mjs";
7
+ import { a as FailureDiagnostic_exports } from "./FailureDiagnostic-BElLOoED.mjs";
8
+ import { t as AgentError_exports } from "./core/AgentError.mjs";
9
+ import { t as IdGenerator_exports } from "./core/IdGenerator.mjs";
10
+ import { t as SubagentContract_exports } from "./core/SubagentContract.mjs";
11
+ import { t as Usage_exports } from "./core/Usage.mjs";
12
+ import { t as RunEvent_exports } from "./core/RunEvent.mjs";
13
+ import { x as Worker_exports } from "./Worker-CfwzMZEK.mjs";
14
+ import { n as MessagingHost_exports } from "./MessagingHost-DfsbMPvq.mjs";
15
+ import { t as SubagentHost_exports } from "./engine/SubagentHost.mjs";
16
+ import { t as Thread_exports } from "./core/Thread.mjs";
17
+ import { t as ThreadHistory_exports } from "./engine/ThreadHistory.mjs";
18
+ import { t as AgentRuntime_exports } from "./AgentRuntime-D8U9gl9Q.mjs";
19
+ import { t as ContextWindow_exports } from "./engine/ContextWindow.mjs";
20
+ import { t as DurableStep_exports } from "./engine/DurableStep.mjs";
21
+ import { t as ContextCompactor_exports } from "./engine/ContextCompactor.mjs";
22
+ import { t as RunEventSink_exports } from "./engine/RunEventSink.mjs";
23
+ import { t as MemoryReference_exports } from "./core/MemoryReference.mjs";
24
+ import { t as RunPolicyUsage_exports } from "./core/RunPolicyUsage.mjs";
25
+ import { t as RunOptions_exports } from "./engine/RunOptions.mjs";
26
+ import { t as ToolBroker_exports } from "./engine/ToolBroker.mjs";
27
+ import { t as Redaction_exports } from "./capabilities/Redaction.mjs";
28
+ import { t as Approval_exports } from "./capabilities/Approval.mjs";
29
+ import { t as Budget_exports } from "./capabilities/Budget.mjs";
30
+ import { t as Sandbox_exports } from "./sandbox/Sandbox.mjs";
31
+ import { t as CodeExecutor_exports } from "./sandbox/CodeExecutor.mjs";
32
+ import { t as CodeMode_exports } from "./capabilities/CodeMode.mjs";
33
+ import { t as Commands_exports } from "./capabilities/Commands.mjs";
34
+ import { t as Compaction_exports } from "./engine/Compaction.mjs";
35
+ import { t as ContextHistory_exports } from "./engine/ContextHistory.mjs";
36
+ import { t as ContextTools_exports } from "./capabilities/ContextTools.mjs";
37
+ import { t as SubagentReservations_exports } from "./capabilities/SubagentReservations.mjs";
38
+ import { t as InMemory_exports } from "./InMemory.mjs";
39
+ import { t as InteractiveBrowser_exports } from "./sandbox/InteractiveBrowser.mjs";
40
+ import { t as Mcp_exports } from "./capabilities/Mcp.mjs";
41
+ import { t as McpClient_exports } from "./capabilities/McpClient.mjs";
42
+ import { t as Memory_exports } from "./core/Memory.mjs";
43
+ import { t as MemoryNamespace_exports } from "./core/MemoryNamespace.mjs";
44
+ import { t as MemoryStore_exports } from "./core/MemoryStore.mjs";
45
+ import { t as MemoryNotes_exports } from "./capabilities/MemoryNotes.mjs";
46
+ import { t as MemoryRevalidation_exports } from "./core/MemoryRevalidation.mjs";
47
+ import { t as Messaging_exports } from "./capabilities/Messaging.mjs";
48
+ import { t as ModelContext_exports } from "./capabilities/ModelContext.mjs";
49
+ import { t as Output_exports } from "./engine/Output.mjs";
50
+ import { t as PageCapture_exports } from "./sandbox/PageCapture.mjs";
51
+ import { t as PageCrawl_exports } from "./sandbox/PageCrawl.mjs";
52
+ import { t as PageScreenshot_exports } from "./sandbox/PageScreenshot.mjs";
53
+ import { t as RememberingStore_exports } from "./core/RememberingStore.mjs";
54
+ import { t as Remembering_exports } from "./capabilities/Remembering.mjs";
55
+ import { t as RunHooks_exports } from "./capabilities/RunHooks.mjs";
56
+ import { t as SemanticMemoryIndex_exports } from "./core/SemanticMemoryIndex.mjs";
57
+ import { t as SemanticMemoryRevalidation_exports } from "./core/SemanticMemoryRevalidation.mjs";
58
+ import { t as SemanticMemory_exports } from "./capabilities/SemanticMemory.mjs";
59
+ import { r as Subagent_exports } from "./Subagent-hG9lJ7tJ.mjs";
60
+ import { t as ToolDiscovery_exports } from "./capabilities/ToolDiscovery.mjs";
61
+ import { t as ToolExposure_exports } from "./ToolExposure.mjs";
62
+ import { t as WebCapture_exports } from "./capabilities/WebCapture.mjs";
63
+ import { t as WebSearch_exports } from "./capabilities/WebSearch.mjs";
64
+ import { t as Records_exports } from "./durable/Records.mjs";
65
+ import { t as ActivityStore_exports } from "./durable/ActivityStore.mjs";
66
+ import { t as SubmissionLedger_exports } from "./durable/SubmissionLedger.mjs";
67
+ import { t as Recovery_exports } from "./durable/Recovery.mjs";
68
+ import { t as Admin_exports } from "./durable/Admin.mjs";
69
+ import { t as Digest_exports } from "./durable/Digest.mjs";
70
+ import { t as AgentRegistration_exports } from "./durable/AgentRegistration.mjs";
71
+ import { r as DurableAgentRuntime_exports } from "./DurableAgentRuntime-R2LUYnRl.mjs";
72
+ import { n as RunJournal_exports } from "./RunJournal-Gd83HYqG.mjs";
73
+ import { t as ThreadStore_exports } from "./durable/ThreadStore.mjs";
74
+ import { t as CommittedActivity_exports } from "./durable/CommittedActivity.mjs";
75
+ import { t as DurableFailpoint_exports } from "./durable/DurableFailpoint.mjs";
76
+ import { t as Schedule_exports } from "./durable/Schedule.mjs";
77
+ import { t as PreparedInputAdmission_exports } from "./durable/PreparedInputAdmission.mjs";
78
+ import { t as Subscription_exports } from "./durable/Subscription.mjs";
79
+ import { t as MessageDelivery_exports } from "./durable/MessageDelivery.mjs";
80
+ import { t as WakeScheduler_exports } from "./durable/WakeScheduler.mjs";
81
+ import { i as WorkerAdmission_exports } from "./WorkerAdmission-CJ_oWRuS.mjs";
82
+ import { t as WorkerHost_exports } from "./durable/WorkerHost.mjs";
83
+ import { t as OperationAuthorizer_exports } from "./durable/OperationAuthorizer.mjs";
84
+ import { t as SubmissionStatus_exports } from "./durable/SubmissionStatus.mjs";
85
+ import { t as ThreadInvariants_exports } from "./durable/ThreadInvariants.mjs";
86
+ import { t as ToolReconciler_exports } from "./durable/ToolReconciler.mjs";
87
+ import { t as EventSource_exports } from "./durable/EventSource.mjs";
88
+ import { t as PersistentHistory_exports } from "./durable/PersistentHistory.mjs";
89
+ import { t as ScheduleTransition_exports } from "./durable/ScheduleTransition.mjs";
90
+ import { i as Scheduling_exports } from "./Scheduling-DPb2QyAK.mjs";
91
+ import { t as SubscriptionInput_exports } from "./durable/SubscriptionInput.mjs";
92
+ import { t as Subscriptions_exports } from "./durable/Subscriptions.mjs";
93
+ import { t as SubscriptionTools_exports } from "./durable/SubscriptionTools.mjs";
94
+ import { t as SubscriptionTransition_exports } from "./durable/SubscriptionTransition.mjs";
95
+ import { t as ThreadProjection_exports } from "./durable/ThreadProjection.mjs";
96
+ import { t as ThreadProjectionMaintenance_exports } from "./durable/ThreadProjectionMaintenance.mjs";
97
+ import { t as ThreadContextHistoryProjection_exports } from "./durable/ThreadContextHistoryProjection.mjs";
98
+ import { t as ThreadContextHistory_exports } from "./durable/ThreadContextHistory.mjs";
99
+ import { t as LifecyclePublication_exports } from "./durable/LifecyclePublication.mjs";
100
+ export { ActivityStore_exports as ActivityStore, Admin_exports as Admin, Agent_exports as Agent, AgentError_exports as AgentError, AgentPolicy_exports as AgentPolicy, AgentRegistration_exports as AgentRegistration, AgentRuntime_exports as AgentRuntime, AgentUpdates_exports as AgentUpdates, Approval_exports as Approval, Budget_exports as Budget, CodeExecutor_exports as CodeExecutor, CodeMode_exports as CodeMode, Commands_exports as Commands, CommittedActivity_exports as CommittedActivity, Compaction_exports as Compaction, ContextCompactor_exports as ContextCompactor, ContextHistory_exports as ContextHistory, ContextTools_exports as ContextTools, ContextWindow_exports as ContextWindow, Digest_exports as Digest, DurableAgentRuntime_exports as DurableAgentRuntime, DurableFailpoint_exports as DurableFailpoint, DurableStep_exports as DurableStep, EventSource_exports as EventSource, FailureDiagnostic_exports as FailureDiagnostic, IdGenerator_exports as IdGenerator, Identifiers_exports as Identifiers, InMemory_exports as InMemory, InteractiveBrowser_exports as InteractiveBrowser, LifecyclePublication_exports as LifecyclePublication, Mcp_exports as Mcp, McpClient_exports as McpClient, Memory_exports as Memory, MemoryNamespace_exports as MemoryNamespace, MemoryNotes_exports as MemoryNotes, MemoryReference_exports as MemoryReference, MemoryRevalidation_exports as MemoryRevalidation, MemoryStore_exports as MemoryStore, MessageDelivery_exports as MessageDelivery, Messaging_exports as Messaging, MessagingHost_exports as MessagingHost, ModelContext_exports as ModelContext, OperationAuthorizer_exports as OperationAuthorizer, Output_exports as Output, PageCapture_exports as PageCapture, PageCrawl_exports as PageCrawl, PageScreenshot_exports as PageScreenshot, PersistentHistory_exports as PersistentHistory, PreparedInputAdmission_exports as PreparedInputAdmission, Receipt_exports as Receipt, Records_exports as Records, Recovery_exports as Recovery, Redaction_exports as Redaction, Remembering_exports as Remembering, RememberingStore_exports as RememberingStore, RunEvent_exports as RunEvent, RunEventSink_exports as RunEventSink, RunHooks_exports as RunHooks, RunJournal_exports as RunJournal, RunOptions_exports as RunOptions, RunPolicyUsage_exports as RunPolicyUsage, Sandbox_exports as Sandbox, Schedule_exports as Schedule, ScheduleTransition_exports as ScheduleTransition, Scheduling_exports as Scheduling, SemanticMemory_exports as SemanticMemory, SemanticMemoryIndex_exports as SemanticMemoryIndex, SemanticMemoryRevalidation_exports as SemanticMemoryRevalidation, Subagent_exports as Subagent, SubagentContract_exports as SubagentContract, SubagentHost_exports as SubagentHost, SubagentReservations_exports as SubagentReservations, SubmissionLedger_exports as SubmissionLedger, SubmissionStatus_exports as SubmissionStatus, Subscription_exports as Subscription, SubscriptionInput_exports as SubscriptionInput, SubscriptionTools_exports as SubscriptionTools, SubscriptionTransition_exports as SubscriptionTransition, Subscriptions_exports as Subscriptions, Thread_exports as Thread, ThreadContextHistory_exports as ThreadContextHistory, ThreadContextHistoryProjection_exports as ThreadContextHistoryProjection, ThreadHistory_exports as ThreadHistory, ThreadInvariants_exports as ThreadInvariants, ThreadProjection_exports as ThreadProjection, ThreadProjectionMaintenance_exports as ThreadProjectionMaintenance, ThreadStore_exports as ThreadStore, ToolBroker_exports as ToolBroker, ToolDiscovery_exports as ToolDiscovery, ToolExposure_exports as ToolExposure, ToolReconciler_exports as ToolReconciler, ToolResult_exports as ToolResult, Usage_exports as Usage, WakeScheduler_exports as WakeScheduler, WebCapture_exports as WebCapture, WebSearch_exports as WebSearch, Worker_exports as Worker, WorkerAdmission_exports as WorkerAdmission, WorkerHost_exports as WorkerHost };
@@ -0,0 +1,135 @@
1
+ import { Prompt, Tool } from "effect/unstable/ai";
2
+ import { Schema } from "effect";
3
+ //#region src/engine/internal/output-contract.ts
4
+ const outputFormatAnnotation = "@effect-agent/engine/Output/format";
5
+ /**
6
+ * Declare ordinary assistant text as an Agent's final-output wire format. Apply this to the
7
+ * complete output Schema after composing transformations. Its encoded type must be string;
8
+ * decoding, checks, transformations, and service requirements remain owned by that Schema.
9
+ * Text is preserved verbatim, including whitespace, quotes, and an empty reply when allowed.
10
+ * Required completion Tools still take precedence. Unmarked Schemas use JSON final output.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * output: Output.text(Schema.String.check(Schema.isMaxLength(20_000)))
15
+ * ```
16
+ */
17
+ const textOutput = (schema) => schema.annotate({ [outputFormatAnnotation]: "text" });
18
+ const isTextOutput = (schema) => Schema.resolveAnnotations(schema)?.[outputFormatAnnotation] === "text";
19
+ const contractDirective = (definition) => definition.completion === void 0 ? "Final output contract: when the task is complete, the final assistant message must be only JSON that is valid against this JSON Schema — no prose, no Markdown code fences, nothing before or after the JSON." : `Final output contract: when the task is complete without calling the "${definition.completion.tool}" completion Tool, the final assistant message must be only JSON that is valid against this JSON Schema — no prose, no Markdown code fences, nothing before or after the JSON. When calling the "${definition.completion.tool}" completion Tool, never place this private Agent output JSON in any Tool argument; follow the Tool's parameter schema instead. Call it as the sole application Tool Call, after receiving any other needed application Tool results. Completed provider Tool results may accompany it. The engine projects the successful completion Tool result into the Agent output.`;
20
+ const requiredCompletionDirective = (tool, hasAlternatives) => `Final output contract: ${hasAlternatives ? "otherwise complete" : "complete only"} by calling the required completion Tool ${JSON.stringify(tool)} as the sole application Tool Call in its batch. Completed provider Tool results may accompany it. Do not emit an ordinary final assistant text answer. The Tool's canonical parameters and successful result are projected and validated as the Agent output.`;
21
+ /**
22
+ * Render the model-visible final-output contract for one definition. The
23
+ * derivation and message identity are stable for an immutable definition.
24
+ * An output Schema the Effect AI derivation cannot represent is reported as
25
+ * `unrenderable`; the caller falls back to the prior behavior — the contract
26
+ * is guidance, and a Schema that decodes but does not render must not become
27
+ * a new failure mode.
28
+ */
29
+ const rendered = (message) => ({
30
+ _tag: "rendered",
31
+ message,
32
+ part: Prompt.makeMessage("system", { content: message })
33
+ });
34
+ const renderOutputSchemaContract = (definition) => {
35
+ if (definition.completion?.required === true) return rendered(requiredCompletionDirective(definition.completion.tool, (definition.completionFromTools?.length ?? 0) > 0));
36
+ if (isTextOutput(definition.output)) return rendered("Final output contract: write the final reply as ordinary assistant text, without JSON wrapping. An empty reply is valid only when allowed by the output Schema and the task instructions." + (definition.completion === void 0 ? "" : ` When calling the "${definition.completion.tool}" completion Tool, follow its parameter schema instead and call it as the sole application Tool Call, after receiving any other needed application Tool results; completed provider Tool results may accompany it; the engine projects its successful result into the Agent output.`));
37
+ try {
38
+ const jsonSchema = Tool.getJsonSchemaFromSchema(definition.output);
39
+ return rendered(`${contractDirective(definition)}\n\n${JSON.stringify(jsonSchema, void 0, 2)}`);
40
+ } catch (cause) {
41
+ return {
42
+ _tag: "unrenderable",
43
+ reason: cause instanceof Error ? cause.message : String(cause)
44
+ };
45
+ }
46
+ };
47
+ const outputContracts = /* @__PURE__ */ new WeakMap();
48
+ const outputSchemaContract = (definition) => {
49
+ const cached = outputContracts.get(definition);
50
+ if (cached !== void 0) return cached;
51
+ const base = renderOutputSchemaContract(definition);
52
+ const alternatives = definition.completionFromTools ?? [];
53
+ const contract = base._tag === "rendered" && alternatives.length > 0 ? rendered(`The following action Tools may complete the Run from their successful canonical result: ${alternatives.map((declaration) => JSON.stringify(declaration.tool)).join(", ")}. Call such a Tool as the sole application Tool Call, following its parameter schema. Completed provider Tool results may accompany it. It may complete the Run only when it satisfies the whole request. An incomplete or pending result continues the Run. These actions are unavailable during finalization after budget exhaustion.
54
+
55
+ ` + base.message) : base;
56
+ outputContracts.set(definition, contract);
57
+ return contract;
58
+ };
59
+ const sameSystemMessage = Schema.toEquivalence(Prompt.SystemMessage);
60
+ /**
61
+ * Keep supported system instructions in conversation order so changing late guidance
62
+ * cannot invalidate the preceding user/tool cache prefix. Omit an exact repeat
63
+ * only when no distinct system instruction intervened; returning to an earlier
64
+ * instruction after a different one must preserve the new directive's precedence.
65
+ * Anchor the immutable output contract after the initial system block.
66
+ * Restore leading static instructions for caller-supplied conversation-only history.
67
+ *
68
+ * This runs after preparation and compaction. Canonical messages, protected
69
+ * instruction/input spans and compaction coverage retain their original positions.
70
+ * Adapters without this capability retain the grouped-system projection: keep the
71
+ * last equivalent instruction with its native options, then the contract and
72
+ * conversation. This prevents older Anthropic adapters from discarding system groups.
73
+ */
74
+ const prepareModelPrompt = (prompt, contract, systemMessagesInHistory, staticInstructions) => {
75
+ if (systemMessagesInHistory) {
76
+ const content = [];
77
+ let lastSystem;
78
+ let ordered = prompt.content;
79
+ if (staticInstructions !== void 0) {
80
+ const firstConversation = prompt.content.findIndex((message) => message.role !== "system");
81
+ const leading = prompt.content.slice(0, firstConversation === -1 ? prompt.content.length : firstConversation);
82
+ const restored = [];
83
+ const instructions = typeof staticInstructions === "string" ? [Prompt.systemMessage({ content: staticInstructions })] : Prompt.make(staticInstructions).content;
84
+ for (const message of instructions) {
85
+ if (message.role !== "system") break;
86
+ if (leading.some((candidate) => candidate.role === "system" && sameSystemMessage(candidate, message))) break;
87
+ const original = prompt.content.find((candidate) => candidate.role === "system" && sameSystemMessage(candidate, message));
88
+ if (original === void 0) break;
89
+ restored.push(original);
90
+ }
91
+ if (restored.length > 0) ordered = [
92
+ ...leading,
93
+ ...restored,
94
+ ...prompt.content.slice(leading.length)
95
+ ];
96
+ }
97
+ for (const message of ordered) {
98
+ if (message.role === "system") {
99
+ if (lastSystem !== void 0 && sameSystemMessage(lastSystem, message)) continue;
100
+ lastSystem = message;
101
+ }
102
+ content.push(message);
103
+ }
104
+ if (contract !== void 0) {
105
+ const firstConversation = content.findIndex((message) => message.role !== "system");
106
+ content.splice(firstConversation === -1 ? content.length : firstConversation, 0, contract);
107
+ }
108
+ return Prompt.fromMessages(content);
109
+ }
110
+ const systems = [];
111
+ const conversation = [];
112
+ const seen = /* @__PURE__ */ new Map();
113
+ for (let index = prompt.content.length - 1; index >= 0; index -= 1) {
114
+ const message = prompt.content[index];
115
+ if (message === void 0) continue;
116
+ if (message.role !== "system") {
117
+ conversation.push(message);
118
+ continue;
119
+ }
120
+ const variants = seen.get(message.content);
121
+ if (variants?.some((previous) => sameSystemMessage(previous, message))) continue;
122
+ if (variants === void 0) seen.set(message.content, [message]);
123
+ else variants.push(message);
124
+ systems.push(message);
125
+ }
126
+ return Prompt.fromMessages([
127
+ ...systems.reverse(),
128
+ ...contract === void 0 ? [] : [contract],
129
+ ...conversation.reverse()
130
+ ]);
131
+ };
132
+ //#endregion
133
+ export { textOutput as i, outputSchemaContract as n, prepareModelPrompt as r, isTextOutput as t };
134
+
135
+ //# sourceMappingURL=output-contract-DS-S8mTv.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-contract-DS-S8mTv.mjs","names":[],"sources":["../src/engine/internal/output-contract.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { Prompt, Tool } from \"effect/unstable/ai\";\n\nimport type * as Agent from \"../../core/Agent.ts\";\n\nconst outputFormatAnnotation = \"@effect-agent/engine/Output/format\";\n\n/**\n * Declare ordinary assistant text as an Agent's final-output wire format. Apply this to the\n * complete output Schema after composing transformations. Its encoded type must be string;\n * decoding, checks, transformations, and service requirements remain owned by that Schema.\n * Text is preserved verbatim, including whitespace, quotes, and an empty reply when allowed.\n * Required completion Tools still take precedence. Unmarked Schemas use JSON final output.\n *\n * @example\n * ```ts\n * output: Output.text(Schema.String.check(Schema.isMaxLength(20_000)))\n * ```\n */\nexport const textOutput = <S extends Schema.Top & { readonly Encoded: string }>(\n schema: S,\n): S[\"Rebuild\"] => schema.annotate({ [outputFormatAnnotation]: \"text\" });\n\nexport const isTextOutput = (schema: Schema.Top): boolean =>\n Schema.resolveAnnotations(schema)?.[outputFormatAnnotation] === \"text\";\n\n/**\n * Model-visible final-output contract (RUN-028).\n *\n * For ordinary text completion, the interpreter's only output-conformance\n * point is `decodeFinalOutput`, which validates the final text after the\n * model has already finished. This module renders that Schema's wire contract\n * with the same Effect AI derivation the providers use for Tool parameters\n * and states it as one framework-owned system message on every model request.\n * A required completion Tool instead gets a native-tool directive: its Tool\n * parameter Schema is already carried by the provider request, and ordinary\n * final text is not an allowed completion path.\n *\n * The contract is a per-request projection of the immutable definition —\n * exactly like the Tool schemas the request already carries. It is inserted\n * at model-request materialization (after context preparation) and never\n * into official history, so canonical records, run events, and the committed\n * DN/DC golden are unchanged.\n *\n */\n\n/** Rendering outcome for one definition's output Schema. */\ntype OutputContract =\n | {\n readonly _tag: \"rendered\";\n /** The complete system-message text: directive plus the derived JSON Schema. */\n readonly message: string;\n readonly part: Prompt.SystemMessage;\n }\n | {\n readonly _tag: \"unrenderable\";\n /** Why Effect AI's JSON-Schema derivation rejected the output Schema. */\n readonly reason: string;\n };\n\nconst contractDirective = (definition: Agent.AnyDefinition): string =>\n definition.completion === undefined\n ? \"Final output contract: when the task is complete, the final assistant message must be only \" +\n \"JSON that is valid against this JSON Schema — no prose, no Markdown code fences, nothing \" +\n \"before or after the JSON.\"\n : `Final output contract: when the task is complete without calling the \"${definition.completion.tool}\" completion Tool, the final assistant message must be only ` +\n \"JSON that is valid against this JSON Schema — no prose, no Markdown code fences, nothing \" +\n `before or after the JSON. When calling the \"${definition.completion.tool}\" completion Tool, never place this private Agent output JSON in any Tool argument; follow the Tool's parameter schema instead. Call it as the sole application Tool Call, after receiving any other needed application Tool results. Completed provider Tool results may accompany it. The engine projects the successful completion Tool result into the Agent output.`;\n\nconst requiredCompletionDirective = (tool: string, hasAlternatives: boolean): string =>\n `Final output contract: ${hasAlternatives ? \"otherwise complete\" : \"complete only\"} by calling the required completion Tool ${JSON.stringify(tool)} ` +\n \"as the sole application Tool Call in its batch. Completed provider Tool results may accompany it. Do not emit an ordinary final assistant text answer. \" +\n \"The Tool's canonical parameters and successful result are projected and validated as the Agent output.\";\n\n/**\n * Render the model-visible final-output contract for one definition. The\n * derivation and message identity are stable for an immutable definition.\n * An output Schema the Effect AI derivation cannot represent is reported as\n * `unrenderable`; the caller falls back to the prior behavior — the contract\n * is guidance, and a Schema that decodes but does not render must not become\n * a new failure mode.\n */\nconst rendered = (message: string): OutputContract => ({\n _tag: \"rendered\",\n message,\n part: Prompt.makeMessage(\"system\", { content: message }),\n});\n\nconst renderOutputSchemaContract = (definition: Agent.AnyDefinition): OutputContract => {\n if (definition.completion?.required === true) {\n return rendered(\n requiredCompletionDirective(\n definition.completion.tool,\n (definition.completionFromTools?.length ?? 0) > 0,\n ),\n );\n }\n if (isTextOutput(definition.output)) {\n return rendered(\n \"Final output contract: write the final reply as ordinary assistant text, without JSON wrapping. \" +\n \"An empty reply is valid only when allowed by the output Schema and the task instructions.\" +\n (definition.completion === undefined\n ? \"\"\n : ` When calling the \"${definition.completion.tool}\" completion Tool, follow its parameter schema instead and call it as the sole application Tool Call, after receiving any other needed application Tool results; completed provider Tool results may accompany it; the engine projects its successful result into the Agent output.`),\n );\n }\n try {\n const jsonSchema = Tool.getJsonSchemaFromSchema(definition.output);\n\n return rendered(\n `${contractDirective(definition)}\\n\\n${JSON.stringify(jsonSchema, undefined, 2)}`,\n );\n } catch (cause) {\n return {\n _tag: \"unrenderable\",\n reason: cause instanceof Error ? cause.message : String(cause),\n };\n }\n};\n\n// Native incremental-response tracking recognizes message objects, not rendered text.\n// Weak keys retain neither discarded definitions nor their Schema graphs.\nconst outputContracts = new WeakMap<Agent.AnyDefinition, OutputContract>();\n\nexport const outputSchemaContract = (definition: Agent.AnyDefinition): OutputContract => {\n const cached = outputContracts.get(definition);\n\n if (cached !== undefined) return cached;\n const base = renderOutputSchemaContract(definition);\n const alternatives = definition.completionFromTools ?? [];\n\n const contract =\n base._tag === \"rendered\" && alternatives.length > 0\n ? rendered(\n `The following action Tools may complete the Run from their successful canonical result: ${alternatives.map((declaration) => JSON.stringify(declaration.tool)).join(\", \")}. ` +\n \"Call such a Tool as the sole application Tool Call, following its parameter schema. Completed provider Tool results may accompany it. It may complete the Run only when it satisfies the whole request. \" +\n \"An incomplete or pending result continues the Run. These actions are unavailable during finalization after budget exhaustion.\\n\\n\" +\n base.message,\n )\n : base;\n\n outputContracts.set(definition, contract);\n\n return contract;\n};\n\nconst sameSystemMessage = Schema.toEquivalence(Prompt.SystemMessage);\n\n/**\n * Keep supported system instructions in conversation order so changing late guidance\n * cannot invalidate the preceding user/tool cache prefix. Omit an exact repeat\n * only when no distinct system instruction intervened; returning to an earlier\n * instruction after a different one must preserve the new directive's precedence.\n * Anchor the immutable output contract after the initial system block.\n * Restore leading static instructions for caller-supplied conversation-only history.\n *\n * This runs after preparation and compaction. Canonical messages, protected\n * instruction/input spans and compaction coverage retain their original positions.\n * Adapters without this capability retain the grouped-system projection: keep the\n * last equivalent instruction with its native options, then the contract and\n * conversation. This prevents older Anthropic adapters from discarding system groups.\n */\nexport const prepareModelPrompt = (\n prompt: Prompt.Prompt,\n contract: Prompt.SystemMessage | undefined,\n systemMessagesInHistory: boolean,\n staticInstructions: Prompt.RawInput | undefined,\n): Prompt.Prompt => {\n if (systemMessagesInHistory) {\n const content: Array<Prompt.Message> = [];\n let lastSystem: Prompt.SystemMessage | undefined;\n let ordered = prompt.content;\n\n if (staticInstructions !== undefined) {\n const firstConversation = prompt.content.findIndex((message) => message.role !== \"system\");\n\n const leading = prompt.content.slice(\n 0,\n firstConversation === -1 ? prompt.content.length : firstConversation,\n );\n\n const restored: Array<Prompt.Message> = [];\n\n const instructions =\n typeof staticInstructions === \"string\"\n ? [Prompt.systemMessage({ content: staticInstructions })]\n : Prompt.make(staticInstructions).content;\n\n for (const message of instructions) {\n if (message.role !== \"system\") break;\n if (\n leading.some(\n (candidate) => candidate.role === \"system\" && sameSystemMessage(candidate, message),\n )\n )\n break;\n\n const original = prompt.content.find(\n (candidate) => candidate.role === \"system\" && sameSystemMessage(candidate, message),\n );\n\n if (original === undefined) break;\n restored.push(original);\n }\n if (restored.length > 0)\n ordered = [...leading, ...restored, ...prompt.content.slice(leading.length)];\n }\n\n for (const message of ordered) {\n if (message.role === \"system\") {\n if (lastSystem !== undefined && sameSystemMessage(lastSystem, message)) continue;\n lastSystem = message;\n }\n content.push(message);\n }\n if (contract !== undefined) {\n const firstConversation = content.findIndex((message) => message.role !== \"system\");\n\n content.splice(firstConversation === -1 ? content.length : firstConversation, 0, contract);\n }\n\n return Prompt.fromMessages(content);\n }\n\n const systems: Array<Prompt.SystemMessage> = [];\n const conversation: Array<Prompt.Message> = [];\n const seen = new Map<string, Array<Prompt.SystemMessage>>();\n\n for (let index = prompt.content.length - 1; index >= 0; index -= 1) {\n const message = prompt.content[index];\n\n if (message === undefined) continue;\n if (message.role !== \"system\") {\n conversation.push(message);\n continue;\n }\n const variants = seen.get(message.content);\n\n if (variants?.some((previous) => sameSystemMessage(previous, message))) continue;\n if (variants === undefined) seen.set(message.content, [message]);\n else variants.push(message);\n systems.push(message);\n }\n\n return Prompt.fromMessages([\n ...systems.reverse(),\n ...(contract === undefined ? [] : [contract]),\n ...conversation.reverse(),\n ]);\n};\n"],"mappings":";;;AAKA,MAAM,yBAAyB;;;;;;;;;;;;;AAc/B,MAAa,cACX,WACiB,OAAO,SAAS,GAAG,yBAAyB,OAAO,CAAC;AAEvE,MAAa,gBAAgB,WAC3B,OAAO,mBAAmB,MAAM,CAAC,GAAG,4BAA4B;AAoClE,MAAM,qBAAqB,eACzB,WAAW,eAAe,KAAA,IACtB,kNAGA,yEAAyE,WAAW,WAAW,KAAK,mMAErD,WAAW,WAAW,KAAK;AAEhF,MAAM,+BAA+B,MAAc,oBACjD,0BAA0B,kBAAkB,uBAAuB,gBAAgB,2CAA2C,KAAK,UAAU,IAAI,EAAE;;;;;;;;;AAYrJ,MAAM,YAAY,aAAqC;CACrD,MAAM;CACN;CACA,MAAM,OAAO,YAAY,UAAU,EAAE,SAAS,QAAQ,CAAC;AACzD;AAEA,MAAM,8BAA8B,eAAoD;CACtF,IAAI,WAAW,YAAY,aAAa,MACtC,OAAO,SACL,4BACE,WAAW,WAAW,OACrB,WAAW,qBAAqB,UAAU,KAAK,CAClD,CACF;CAEF,IAAI,aAAa,WAAW,MAAM,GAChC,OAAO,SACL,+LAEG,WAAW,eAAe,KAAA,IACvB,KACA,sBAAsB,WAAW,WAAW,KAAK,qRACzD;CAEF,IAAI;EACF,MAAM,aAAa,KAAK,wBAAwB,WAAW,MAAM;EAEjE,OAAO,SACL,GAAG,kBAAkB,UAAU,EAAE,MAAM,KAAK,UAAU,YAAY,KAAA,GAAW,CAAC,GAChF;CACF,SAAS,OAAO;EACd,OAAO;GACL,MAAM;GACN,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC/D;CACF;AACF;AAIA,MAAM,kCAAkB,IAAI,QAA6C;AAEzE,MAAa,wBAAwB,eAAoD;CACvF,MAAM,SAAS,gBAAgB,IAAI,UAAU;CAE7C,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,OAAO,2BAA2B,UAAU;CAClD,MAAM,eAAe,WAAW,uBAAuB,CAAC;CAExD,MAAM,WACJ,KAAK,SAAS,cAAc,aAAa,SAAS,IAC9C,SACE,2FAA2F,aAAa,KAAK,gBAAgB,KAAK,UAAU,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;;IAGxK,KAAK,OACT,IACA;CAEN,gBAAgB,IAAI,YAAY,QAAQ;CAExC,OAAO;AACT;AAEA,MAAM,oBAAoB,OAAO,cAAc,OAAO,aAAa;;;;;;;;;;;;;;;AAgBnE,MAAa,sBACX,QACA,UACA,yBACA,uBACkB;CAClB,IAAI,yBAAyB;EAC3B,MAAM,UAAiC,CAAC;EACxC,IAAI;EACJ,IAAI,UAAU,OAAO;EAErB,IAAI,uBAAuB,KAAA,GAAW;GACpC,MAAM,oBAAoB,OAAO,QAAQ,WAAW,YAAY,QAAQ,SAAS,QAAQ;GAEzF,MAAM,UAAU,OAAO,QAAQ,MAC7B,GACA,sBAAsB,KAAK,OAAO,QAAQ,SAAS,iBACrD;GAEA,MAAM,WAAkC,CAAC;GAEzC,MAAM,eACJ,OAAO,uBAAuB,WAC1B,CAAC,OAAO,cAAc,EAAE,SAAS,mBAAmB,CAAC,CAAC,IACtD,OAAO,KAAK,kBAAkB,CAAC,CAAC;GAEtC,KAAK,MAAM,WAAW,cAAc;IAClC,IAAI,QAAQ,SAAS,UAAU;IAC/B,IACE,QAAQ,MACL,cAAc,UAAU,SAAS,YAAY,kBAAkB,WAAW,OAAO,CACpF,GAEA;IAEF,MAAM,WAAW,OAAO,QAAQ,MAC7B,cAAc,UAAU,SAAS,YAAY,kBAAkB,WAAW,OAAO,CACpF;IAEA,IAAI,aAAa,KAAA,GAAW;IAC5B,SAAS,KAAK,QAAQ;GACxB;GACA,IAAI,SAAS,SAAS,GACpB,UAAU;IAAC,GAAG;IAAS,GAAG;IAAU,GAAG,OAAO,QAAQ,MAAM,QAAQ,MAAM;GAAC;EAC/E;EAEA,KAAK,MAAM,WAAW,SAAS;GAC7B,IAAI,QAAQ,SAAS,UAAU;IAC7B,IAAI,eAAe,KAAA,KAAa,kBAAkB,YAAY,OAAO,GAAG;IACxE,aAAa;GACf;GACA,QAAQ,KAAK,OAAO;EACtB;EACA,IAAI,aAAa,KAAA,GAAW;GAC1B,MAAM,oBAAoB,QAAQ,WAAW,YAAY,QAAQ,SAAS,QAAQ;GAElF,QAAQ,OAAO,sBAAsB,KAAK,QAAQ,SAAS,mBAAmB,GAAG,QAAQ;EAC3F;EAEA,OAAO,OAAO,aAAa,OAAO;CACpC;CAEA,MAAM,UAAuC,CAAC;CAC9C,MAAM,eAAsC,CAAC;CAC7C,MAAM,uBAAO,IAAI,IAAyC;CAE1D,KAAK,IAAI,QAAQ,OAAO,QAAQ,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG;EAClE,MAAM,UAAU,OAAO,QAAQ;EAE/B,IAAI,YAAY,KAAA,GAAW;EAC3B,IAAI,QAAQ,SAAS,UAAU;GAC7B,aAAa,KAAK,OAAO;GACzB;EACF;EACA,MAAM,WAAW,KAAK,IAAI,QAAQ,OAAO;EAEzC,IAAI,UAAU,MAAM,aAAa,kBAAkB,UAAU,OAAO,CAAC,GAAG;EACxE,IAAI,aAAa,KAAA,GAAW,KAAK,IAAI,QAAQ,SAAS,CAAC,OAAO,CAAC;OAC1D,SAAS,KAAK,OAAO;EAC1B,QAAQ,KAAK,OAAO;CACtB;CAEA,OAAO,OAAO,aAAa;EACzB,GAAG,QAAQ,QAAQ;EACnB,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,CAAC,QAAQ;EAC3C,GAAG,aAAa,QAAQ;CAC1B,CAAC;AACH"}
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };