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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (553) hide show
  1. package/dist/Agent-1DMSO_Fl.mjs +86 -0
  2. package/dist/Agent-1DMSO_Fl.mjs.map +1 -0
  3. package/dist/Agent-D9cXqfF3.d.mts +252 -0
  4. package/dist/AgentError-Bn1ytXRD.d.mts +117 -0
  5. package/dist/AgentPolicy-BqDoSXO6.d.mts +96 -0
  6. package/dist/AgentRuntime-BUxDdLpw.d.mts +346 -0
  7. package/dist/AgentRuntime-Cp1hAb-W.mjs +4739 -0
  8. package/dist/AgentRuntime-Cp1hAb-W.mjs.map +1 -0
  9. package/dist/AgentUpdates-DMJ-_xow.d.mts +53 -0
  10. package/dist/ContextCompactor-WwSIG_Z2.d.mts +161 -0
  11. package/dist/ContextWindow-DRQ5Mbm2.d.mts +58 -0
  12. package/dist/DurableAgentRuntime-B-9w7jDt.mjs +7061 -0
  13. package/dist/DurableAgentRuntime-B-9w7jDt.mjs.map +1 -0
  14. package/dist/DurableFailpoint-Cnr3wx1L.d.mts +41 -0
  15. package/dist/DurableStep-Cry_iol4.d.mts +103 -0
  16. package/dist/EventSource-CnlZ3Kma.d.mts +51 -0
  17. package/dist/FailureDiagnostic-BElLOoED.mjs +274 -0
  18. package/dist/FailureDiagnostic-BElLOoED.mjs.map +1 -0
  19. package/dist/FailureDiagnostic-CaAkzGHL.d.mts +223 -0
  20. package/dist/Identifiers-CN2s30fF.d.mts +40 -0
  21. package/dist/InMemory.d.mts +24 -0
  22. package/dist/InMemory.mjs +24 -0
  23. package/dist/InMemory.mjs.map +1 -0
  24. package/dist/MemoryNamespace-BbRW5p71.d.mts +36 -0
  25. package/dist/MemoryReference-B8Q3UJoJ.d.mts +79 -0
  26. package/dist/Messaging-Dkg87ebg.d.mts +221 -0
  27. package/dist/Messaging-JYYN3oYS.d.mts +1067 -0
  28. package/dist/MessagingHost-CqzpxbGz.d.mts +74 -0
  29. package/dist/MessagingHost-DfsbMPvq.mjs +110 -0
  30. package/dist/MessagingHost-DfsbMPvq.mjs.map +1 -0
  31. package/dist/OperationAuthorizer-TzcQtpX5.d.mts +61 -0
  32. package/dist/Output-V-6YL1_Z.d.mts +25 -0
  33. package/dist/PageCapture-Df8Xwskw.d.mts +583 -0
  34. package/dist/PageScreenshot-BpgZKAxl.d.mts +48 -0
  35. package/dist/PreparedInputAdmission-BQLGldl-.d.mts +42 -0
  36. package/dist/Receipt-BAHyigAF.d.mts +33 -0
  37. package/dist/Records-D88mgvyS.d.mts +4214 -0
  38. package/dist/RunEvent-DIrzkjLr.d.mts +460 -0
  39. package/dist/RunEventSink-D5aVhISG.d.mts +108 -0
  40. package/dist/RunJournal-BXrq0VIK.mjs +931 -0
  41. package/dist/RunJournal-BXrq0VIK.mjs.map +1 -0
  42. package/dist/RunOptions-CSBsSj0X.d.mts +935 -0
  43. package/dist/RunPolicyUsage-ClZxyR46.d.mts +21 -0
  44. package/dist/Sandbox-CEsDWBLq.d.mts +173 -0
  45. package/dist/Schedule-BIOHA6RR.d.mts +847 -0
  46. package/dist/Scheduling-DPb2QyAK.mjs +691 -0
  47. package/dist/Scheduling-DPb2QyAK.mjs.map +1 -0
  48. package/dist/Subagent-CNik9RiA.d.mts +1635 -0
  49. package/dist/Subagent-DCrB7an7.mjs +1498 -0
  50. package/dist/Subagent-DCrB7an7.mjs.map +1 -0
  51. package/dist/SubagentContract-DdT7Cqe6.d.mts +116 -0
  52. package/dist/SubagentHost-4WB8Hj0C.d.mts +164 -0
  53. package/dist/Subscription-CRteOKRf.d.mts +948 -0
  54. package/dist/SubscriptionInput-oNcwTPti.d.mts +41 -0
  55. package/dist/Thread-DOBQ0QUY.d.mts +96 -0
  56. package/dist/ThreadHistory-tS1KwxHR.d.mts +60 -0
  57. package/dist/ToolBroker-DWs4tZra.d.mts +133 -0
  58. package/dist/ToolExposure-9uF_Yo0T.mjs +10 -0
  59. package/dist/ToolExposure-9uF_Yo0T.mjs.map +1 -0
  60. package/dist/ToolExposure-C93U1sPu.mjs +30 -0
  61. package/dist/ToolExposure-C93U1sPu.mjs.map +1 -0
  62. package/dist/ToolExposure-UCN12eCd.d.mts +39 -0
  63. package/dist/ToolExposure-r2eOWk4F.d.mts +46 -0
  64. package/dist/ToolExposure.d.mts +8 -0
  65. package/dist/ToolExposure.mjs +21 -0
  66. package/dist/ToolExposure.mjs.map +1 -0
  67. package/dist/ToolReconciler-BmVRAHKs.d.mts +80 -0
  68. package/dist/ToolResult-BKdqWRff.d.mts +78 -0
  69. package/dist/Usage-Dx0aknfk.d.mts +121 -0
  70. package/dist/WakeScheduler-EjUF-GhC.d.mts +56 -0
  71. package/dist/Worker-CfwzMZEK.mjs +271 -0
  72. package/dist/Worker-CfwzMZEK.mjs.map +1 -0
  73. package/dist/Worker-fwWkBg12.d.mts +472 -0
  74. package/dist/agent-registration-CKNsrpwo.mjs +201 -0
  75. package/dist/agent-registration-CKNsrpwo.mjs.map +1 -0
  76. package/dist/capabilities/Approval.d.mts +114 -0
  77. package/dist/capabilities/Approval.mjs +226 -0
  78. package/dist/capabilities/Approval.mjs.map +1 -0
  79. package/dist/capabilities/Budget.d.mts +112 -0
  80. package/dist/capabilities/Budget.mjs +346 -0
  81. package/dist/capabilities/Budget.mjs.map +1 -0
  82. package/dist/capabilities/CodeMode.d.mts +157 -0
  83. package/dist/capabilities/CodeMode.mjs +522 -0
  84. package/dist/capabilities/CodeMode.mjs.map +1 -0
  85. package/dist/capabilities/Commands.d.mts +55 -0
  86. package/dist/capabilities/Commands.mjs +57 -0
  87. package/dist/capabilities/Commands.mjs.map +1 -0
  88. package/dist/capabilities/ContextTools.d.mts +321 -0
  89. package/dist/capabilities/ContextTools.mjs +126 -0
  90. package/dist/capabilities/ContextTools.mjs.map +1 -0
  91. package/dist/capabilities/Mcp.d.mts +108 -0
  92. package/dist/capabilities/Mcp.mjs +259 -0
  93. package/dist/capabilities/Mcp.mjs.map +1 -0
  94. package/dist/capabilities/McpClient.d.mts +115 -0
  95. package/dist/capabilities/McpClient.mjs +506 -0
  96. package/dist/capabilities/McpClient.mjs.map +1 -0
  97. package/dist/capabilities/MemoryNotes.d.mts +424 -0
  98. package/dist/capabilities/MemoryNotes.mjs +128 -0
  99. package/dist/capabilities/MemoryNotes.mjs.map +1 -0
  100. package/dist/capabilities/Messaging.d.mts +3 -0
  101. package/dist/capabilities/Messaging.mjs +152 -0
  102. package/dist/capabilities/Messaging.mjs.map +1 -0
  103. package/dist/capabilities/ModelContext.d.mts +89 -0
  104. package/dist/capabilities/ModelContext.mjs +168 -0
  105. package/dist/capabilities/ModelContext.mjs.map +1 -0
  106. package/dist/capabilities/Redaction.d.mts +37 -0
  107. package/dist/capabilities/Redaction.mjs +104 -0
  108. package/dist/capabilities/Redaction.mjs.map +1 -0
  109. package/dist/capabilities/Remembering.d.mts +434 -0
  110. package/dist/capabilities/Remembering.mjs +290 -0
  111. package/dist/capabilities/Remembering.mjs.map +1 -0
  112. package/dist/capabilities/RunHooks.d.mts +82 -0
  113. package/dist/capabilities/RunHooks.mjs +144 -0
  114. package/dist/capabilities/RunHooks.mjs.map +1 -0
  115. package/dist/capabilities/SemanticMemory.d.mts +431 -0
  116. package/dist/capabilities/SemanticMemory.mjs +315 -0
  117. package/dist/capabilities/SemanticMemory.mjs.map +1 -0
  118. package/dist/capabilities/Subagent.d.mts +4 -0
  119. package/dist/capabilities/Subagent.mjs +5 -0
  120. package/dist/capabilities/SubagentReservations.d.mts +186 -0
  121. package/dist/capabilities/SubagentReservations.mjs +479 -0
  122. package/dist/capabilities/SubagentReservations.mjs.map +1 -0
  123. package/dist/capabilities/ToolDiscovery.d.mts +124 -0
  124. package/dist/capabilities/ToolDiscovery.mjs +230 -0
  125. package/dist/capabilities/ToolDiscovery.mjs.map +1 -0
  126. package/dist/capabilities/WebCapture.d.mts +163 -0
  127. package/dist/capabilities/WebCapture.mjs +335 -0
  128. package/dist/capabilities/WebCapture.mjs.map +1 -0
  129. package/dist/capabilities/WebSearch.d.mts +71 -0
  130. package/dist/capabilities/WebSearch.mjs +115 -0
  131. package/dist/capabilities/WebSearch.mjs.map +1 -0
  132. package/dist/compaction-C2OTceKw.mjs +505 -0
  133. package/dist/compaction-C2OTceKw.mjs.map +1 -0
  134. package/dist/core/Agent.d.mts +2 -0
  135. package/dist/core/Agent.mjs +2 -0
  136. package/dist/core/AgentError.d.mts +2 -0
  137. package/dist/core/AgentError.mjs +134 -0
  138. package/dist/core/AgentError.mjs.map +1 -0
  139. package/dist/core/AgentPolicy.d.mts +2 -0
  140. package/dist/core/AgentPolicy.mjs +94 -0
  141. package/dist/core/AgentPolicy.mjs.map +1 -0
  142. package/dist/core/AgentUpdates.d.mts +2 -0
  143. package/dist/core/AgentUpdates.mjs +63 -0
  144. package/dist/core/AgentUpdates.mjs.map +1 -0
  145. package/dist/core/FailureDiagnostic.d.mts +2 -0
  146. package/dist/core/FailureDiagnostic.mjs +2 -0
  147. package/dist/core/IdGenerator.d.mts +26 -0
  148. package/dist/core/IdGenerator.mjs +27 -0
  149. package/dist/core/IdGenerator.mjs.map +1 -0
  150. package/dist/core/Identifiers.d.mts +2 -0
  151. package/dist/core/Identifiers.mjs +43 -0
  152. package/dist/core/Identifiers.mjs.map +1 -0
  153. package/dist/core/Memory.d.mts +57 -0
  154. package/dist/core/Memory.mjs +203 -0
  155. package/dist/core/Memory.mjs.map +1 -0
  156. package/dist/core/MemoryNamespace.d.mts +2 -0
  157. package/dist/core/MemoryNamespace.mjs +116 -0
  158. package/dist/core/MemoryNamespace.mjs.map +1 -0
  159. package/dist/core/MemoryReference.d.mts +2 -0
  160. package/dist/core/MemoryReference.mjs +109 -0
  161. package/dist/core/MemoryReference.mjs.map +1 -0
  162. package/dist/core/MemoryRevalidation.d.mts +65 -0
  163. package/dist/core/MemoryRevalidation.mjs +126 -0
  164. package/dist/core/MemoryRevalidation.mjs.map +1 -0
  165. package/dist/core/MemoryStore.d.mts +186 -0
  166. package/dist/core/MemoryStore.mjs +243 -0
  167. package/dist/core/MemoryStore.mjs.map +1 -0
  168. package/dist/core/Receipt.d.mts +2 -0
  169. package/dist/core/Receipt.mjs +36 -0
  170. package/dist/core/Receipt.mjs.map +1 -0
  171. package/dist/core/RememberingStore.d.mts +1562 -0
  172. package/dist/core/RememberingStore.mjs +190 -0
  173. package/dist/core/RememberingStore.mjs.map +1 -0
  174. package/dist/core/RunEvent.d.mts +2 -0
  175. package/dist/core/RunEvent.mjs +337 -0
  176. package/dist/core/RunEvent.mjs.map +1 -0
  177. package/dist/core/RunPolicyUsage.d.mts +2 -0
  178. package/dist/core/RunPolicyUsage.mjs +21 -0
  179. package/dist/core/RunPolicyUsage.mjs.map +1 -0
  180. package/dist/core/SemanticMemoryIndex.d.mts +826 -0
  181. package/dist/core/SemanticMemoryIndex.mjs +185 -0
  182. package/dist/core/SemanticMemoryIndex.mjs.map +1 -0
  183. package/dist/core/SemanticMemoryRevalidation.d.mts +45 -0
  184. package/dist/core/SemanticMemoryRevalidation.mjs +191 -0
  185. package/dist/core/SemanticMemoryRevalidation.mjs.map +1 -0
  186. package/dist/core/SubagentContract.d.mts +2 -0
  187. package/dist/core/SubagentContract.mjs +148 -0
  188. package/dist/core/SubagentContract.mjs.map +1 -0
  189. package/dist/core/Thread.d.mts +2 -0
  190. package/dist/core/Thread.mjs +250 -0
  191. package/dist/core/Thread.mjs.map +1 -0
  192. package/dist/core/ToolResult.d.mts +2 -0
  193. package/dist/core/ToolResult.mjs +156 -0
  194. package/dist/core/ToolResult.mjs.map +1 -0
  195. package/dist/core/Usage.d.mts +2 -0
  196. package/dist/core/Usage.mjs +319 -0
  197. package/dist/core/Usage.mjs.map +1 -0
  198. package/dist/core/Worker.d.mts +3 -0
  199. package/dist/core/Worker.mjs +3 -0
  200. package/dist/durable/ActivityStore.d.mts +116 -0
  201. package/dist/durable/ActivityStore.mjs +131 -0
  202. package/dist/durable/ActivityStore.mjs.map +1 -0
  203. package/dist/durable/Admin.d.mts +2 -0
  204. package/dist/durable/Admin.mjs +330 -0
  205. package/dist/durable/Admin.mjs.map +1 -0
  206. package/dist/durable/AgentRegistration.d.mts +2 -0
  207. package/dist/durable/AgentRegistration.mjs +14 -0
  208. package/dist/durable/AgentRegistration.mjs.map +1 -0
  209. package/dist/durable/Certification.d.mts +110 -0
  210. package/dist/durable/Certification.mjs +159 -0
  211. package/dist/durable/Certification.mjs.map +1 -0
  212. package/dist/durable/CommittedActivity.d.mts +62 -0
  213. package/dist/durable/CommittedActivity.mjs +159 -0
  214. package/dist/durable/CommittedActivity.mjs.map +1 -0
  215. package/dist/durable/Digest.d.mts +2 -0
  216. package/dist/durable/Digest.mjs +50 -0
  217. package/dist/durable/Digest.mjs.map +1 -0
  218. package/dist/durable/DurableAgentRuntime.d.mts +3 -0
  219. package/dist/durable/DurableAgentRuntime.mjs +3 -0
  220. package/dist/durable/DurableFailpoint.d.mts +2 -0
  221. package/dist/durable/DurableFailpoint.mjs +102 -0
  222. package/dist/durable/DurableFailpoint.mjs.map +1 -0
  223. package/dist/durable/DurableFailpointTestControl.d.mts +14 -0
  224. package/dist/durable/DurableFailpointTestControl.mjs +19 -0
  225. package/dist/durable/DurableFailpointTestControl.mjs.map +1 -0
  226. package/dist/durable/EventSource.d.mts +2 -0
  227. package/dist/durable/EventSource.mjs +65 -0
  228. package/dist/durable/EventSource.mjs.map +1 -0
  229. package/dist/durable/GitHubWorkflowSource.d.mts +185 -0
  230. package/dist/durable/GitHubWorkflowSource.mjs +209 -0
  231. package/dist/durable/GitHubWorkflowSource.mjs.map +1 -0
  232. package/dist/durable/MessageDelivery.d.mts +893 -0
  233. package/dist/durable/MessageDelivery.mjs +557 -0
  234. package/dist/durable/MessageDelivery.mjs.map +1 -0
  235. package/dist/durable/MessageDeliveryStoreConformance.d.mts +378 -0
  236. package/dist/durable/MessageDeliveryStoreConformance.mjs +270 -0
  237. package/dist/durable/MessageDeliveryStoreConformance.mjs.map +1 -0
  238. package/dist/durable/OperationAuthorizer.d.mts +2 -0
  239. package/dist/durable/OperationAuthorizer.mjs +70 -0
  240. package/dist/durable/OperationAuthorizer.mjs.map +1 -0
  241. package/dist/durable/PersistentHistory.d.mts +16 -0
  242. package/dist/durable/PersistentHistory.mjs +125 -0
  243. package/dist/durable/PersistentHistory.mjs.map +1 -0
  244. package/dist/durable/PreparedInputAdmission.d.mts +2 -0
  245. package/dist/durable/PreparedInputAdmission.mjs +38 -0
  246. package/dist/durable/PreparedInputAdmission.mjs.map +1 -0
  247. package/dist/durable/Records.d.mts +2 -0
  248. package/dist/durable/Records.mjs +848 -0
  249. package/dist/durable/Records.mjs.map +1 -0
  250. package/dist/durable/Recovery.d.mts +2 -0
  251. package/dist/durable/Recovery.mjs +739 -0
  252. package/dist/durable/Recovery.mjs.map +1 -0
  253. package/dist/durable/RunJournal.d.mts +2 -0
  254. package/dist/durable/RunJournal.mjs +2 -0
  255. package/dist/durable/Schedule.d.mts +2 -0
  256. package/dist/durable/Schedule.mjs +391 -0
  257. package/dist/durable/Schedule.mjs.map +1 -0
  258. package/dist/durable/ScheduleStoreConformance.d.mts +17 -0
  259. package/dist/durable/ScheduleStoreConformance.mjs +420 -0
  260. package/dist/durable/ScheduleStoreConformance.mjs.map +1 -0
  261. package/dist/durable/ScheduleTransition.d.mts +24 -0
  262. package/dist/durable/ScheduleTransition.mjs +180 -0
  263. package/dist/durable/ScheduleTransition.mjs.map +1 -0
  264. package/dist/durable/Scheduling.d.mts +54 -0
  265. package/dist/durable/Scheduling.mjs +2 -0
  266. package/dist/durable/SqlMemoryStore.d.mts +29 -0
  267. package/dist/durable/SqlMemoryStore.mjs +436 -0
  268. package/dist/durable/SqlMemoryStore.mjs.map +1 -0
  269. package/dist/durable/SqlMessageDeliveryStore.d.mts +42 -0
  270. package/dist/durable/SqlMessageDeliveryStore.mjs +179 -0
  271. package/dist/durable/SqlMessageDeliveryStore.mjs.map +1 -0
  272. package/dist/durable/SqlStorageV2Upgrade.d.mts +21 -0
  273. package/dist/durable/SqlStorageV2Upgrade.mjs +459 -0
  274. package/dist/durable/SqlStorageV2Upgrade.mjs.map +1 -0
  275. package/dist/durable/SqlSubscriptionStore.d.mts +62 -0
  276. package/dist/durable/SqlSubscriptionStore.mjs +751 -0
  277. package/dist/durable/SqlSubscriptionStore.mjs.map +1 -0
  278. package/dist/durable/SqlThreadNativeReads.d.mts +53 -0
  279. package/dist/durable/SqlThreadNativeReads.mjs +159 -0
  280. package/dist/durable/SqlThreadNativeReads.mjs.map +1 -0
  281. package/dist/durable/SubmissionLedger.d.mts +3 -0
  282. package/dist/durable/SubmissionLedger.mjs +959 -0
  283. package/dist/durable/SubmissionLedger.mjs.map +1 -0
  284. package/dist/durable/SubmissionLedgerConformance.d.mts +29 -0
  285. package/dist/durable/SubmissionLedgerConformance.mjs +2187 -0
  286. package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -0
  287. package/dist/durable/SubmissionStatus.d.mts +2 -0
  288. package/dist/durable/SubmissionStatus.mjs +18 -0
  289. package/dist/durable/SubmissionStatus.mjs.map +1 -0
  290. package/dist/durable/Subscription.d.mts +2 -0
  291. package/dist/durable/Subscription.mjs +360 -0
  292. package/dist/durable/Subscription.mjs.map +1 -0
  293. package/dist/durable/SubscriptionInput.d.mts +2 -0
  294. package/dist/durable/SubscriptionInput.mjs +52 -0
  295. package/dist/durable/SubscriptionInput.mjs.map +1 -0
  296. package/dist/durable/SubscriptionStoreConformance.d.mts +16 -0
  297. package/dist/durable/SubscriptionStoreConformance.mjs +625 -0
  298. package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -0
  299. package/dist/durable/SubscriptionTools.d.mts +273 -0
  300. package/dist/durable/SubscriptionTools.mjs +190 -0
  301. package/dist/durable/SubscriptionTools.mjs.map +1 -0
  302. package/dist/durable/SubscriptionTransition.d.mts +21 -0
  303. package/dist/durable/SubscriptionTransition.mjs +148 -0
  304. package/dist/durable/SubscriptionTransition.mjs.map +1 -0
  305. package/dist/durable/Subscriptions.d.mts +73 -0
  306. package/dist/durable/Subscriptions.mjs +627 -0
  307. package/dist/durable/Subscriptions.mjs.map +1 -0
  308. package/dist/durable/ThreadContextHistory.d.mts +32 -0
  309. package/dist/durable/ThreadContextHistory.mjs +152 -0
  310. package/dist/durable/ThreadContextHistory.mjs.map +1 -0
  311. package/dist/durable/ThreadContextHistoryProjection.d.mts +60 -0
  312. package/dist/durable/ThreadContextHistoryProjection.mjs +149 -0
  313. package/dist/durable/ThreadContextHistoryProjection.mjs.map +1 -0
  314. package/dist/durable/ThreadInvariants.d.mts +76 -0
  315. package/dist/durable/ThreadInvariants.mjs +246 -0
  316. package/dist/durable/ThreadInvariants.mjs.map +1 -0
  317. package/dist/durable/ThreadProjection.d.mts +78 -0
  318. package/dist/durable/ThreadProjection.mjs +158 -0
  319. package/dist/durable/ThreadProjection.mjs.map +1 -0
  320. package/dist/durable/ThreadProjectionMaintenance.d.mts +49 -0
  321. package/dist/durable/ThreadProjectionMaintenance.mjs +33 -0
  322. package/dist/durable/ThreadProjectionMaintenance.mjs.map +1 -0
  323. package/dist/durable/ThreadStore.d.mts +2 -0
  324. package/dist/durable/ThreadStore.mjs +355 -0
  325. package/dist/durable/ThreadStore.mjs.map +1 -0
  326. package/dist/durable/ThreadStoreConformance.d.mts +28 -0
  327. package/dist/durable/ThreadStoreConformance.mjs +503 -0
  328. package/dist/durable/ThreadStoreConformance.mjs.map +1 -0
  329. package/dist/durable/ToolReconciler.d.mts +2 -0
  330. package/dist/durable/ToolReconciler.mjs +85 -0
  331. package/dist/durable/ToolReconciler.mjs.map +1 -0
  332. package/dist/durable/WakeScheduler.d.mts +2 -0
  333. package/dist/durable/WakeScheduler.mjs +85 -0
  334. package/dist/durable/WakeScheduler.mjs.map +1 -0
  335. package/dist/durable/WorkerHost.d.mts +129 -0
  336. package/dist/durable/WorkerHost.mjs +77 -0
  337. package/dist/durable/WorkerHost.mjs.map +1 -0
  338. package/dist/engine/AgentRuntime.d.mts +2 -0
  339. package/dist/engine/AgentRuntime.mjs +2 -0
  340. package/dist/engine/Compaction.d.mts +7 -0
  341. package/dist/engine/Compaction.mjs +16 -0
  342. package/dist/engine/Compaction.mjs.map +1 -0
  343. package/dist/engine/ContextCompactor.d.mts +2 -0
  344. package/dist/engine/ContextCompactor.mjs +119 -0
  345. package/dist/engine/ContextCompactor.mjs.map +1 -0
  346. package/dist/engine/ContextHistory.d.mts +65 -0
  347. package/dist/engine/ContextHistory.mjs +76 -0
  348. package/dist/engine/ContextHistory.mjs.map +1 -0
  349. package/dist/engine/ContextWindow.d.mts +2 -0
  350. package/dist/engine/ContextWindow.mjs +59 -0
  351. package/dist/engine/ContextWindow.mjs.map +1 -0
  352. package/dist/engine/DurableStep.d.mts +2 -0
  353. package/dist/engine/DurableStep.mjs +62 -0
  354. package/dist/engine/DurableStep.mjs.map +1 -0
  355. package/dist/engine/MessagingHost.d.mts +2 -0
  356. package/dist/engine/MessagingHost.mjs +2 -0
  357. package/dist/engine/Output.d.mts +2 -0
  358. package/dist/engine/Output.mjs +8 -0
  359. package/dist/engine/Output.mjs.map +1 -0
  360. package/dist/engine/RunEventSink.d.mts +2 -0
  361. package/dist/engine/RunEventSink.mjs +22 -0
  362. package/dist/engine/RunEventSink.mjs.map +1 -0
  363. package/dist/engine/RunOptions.d.mts +2 -0
  364. package/dist/engine/RunOptions.mjs +124 -0
  365. package/dist/engine/RunOptions.mjs.map +1 -0
  366. package/dist/engine/SubagentHost.d.mts +2 -0
  367. package/dist/engine/SubagentHost.mjs +76 -0
  368. package/dist/engine/SubagentHost.mjs.map +1 -0
  369. package/dist/engine/ThreadHistory.d.mts +2 -0
  370. package/dist/engine/ThreadHistory.mjs +67 -0
  371. package/dist/engine/ThreadHistory.mjs.map +1 -0
  372. package/dist/engine/ToolBroker.d.mts +2 -0
  373. package/dist/engine/ToolBroker.mjs +42 -0
  374. package/dist/engine/ToolBroker.mjs.map +1 -0
  375. package/dist/foreign-diagnostic-DBQ1XHKh.mjs +37 -0
  376. package/dist/foreign-diagnostic-DBQ1XHKh.mjs.map +1 -0
  377. package/dist/index.d.mts +91 -6
  378. package/dist/index.mjs +100 -6
  379. package/dist/output-contract-BC7tjlGw.mjs +84 -0
  380. package/dist/output-contract-BC7tjlGw.mjs.map +1 -0
  381. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  382. package/dist/sandbox/CodeExecutor.d.mts +194 -0
  383. package/dist/sandbox/CodeExecutor.mjs +278 -0
  384. package/dist/sandbox/CodeExecutor.mjs.map +1 -0
  385. package/dist/sandbox/InteractiveBrowser.d.mts +257 -0
  386. package/dist/sandbox/InteractiveBrowser.mjs +236 -0
  387. package/dist/sandbox/InteractiveBrowser.mjs.map +1 -0
  388. package/dist/sandbox/PageCapture.d.mts +2 -0
  389. package/dist/sandbox/PageCapture.mjs +450 -0
  390. package/dist/sandbox/PageCapture.mjs.map +1 -0
  391. package/dist/sandbox/PageCrawl.d.mts +88 -0
  392. package/dist/sandbox/PageCrawl.mjs +124 -0
  393. package/dist/sandbox/PageCrawl.mjs.map +1 -0
  394. package/dist/sandbox/PageScreenshot.d.mts +2 -0
  395. package/dist/sandbox/PageScreenshot.mjs +53 -0
  396. package/dist/sandbox/PageScreenshot.mjs.map +1 -0
  397. package/dist/sandbox/ProtectedBrowser.d.mts +283 -0
  398. package/dist/sandbox/ProtectedBrowser.mjs +298 -0
  399. package/dist/sandbox/ProtectedBrowser.mjs.map +1 -0
  400. package/dist/sandbox/Sandbox.d.mts +2 -0
  401. package/dist/sandbox/Sandbox.mjs +208 -0
  402. package/dist/sandbox/Sandbox.mjs.map +1 -0
  403. package/dist/utf8-BYfhEkcj.mjs +11 -0
  404. package/dist/utf8-BYfhEkcj.mjs.map +1 -0
  405. package/dist/utf8-DchGZRBd.mjs +23 -0
  406. package/dist/utf8-DchGZRBd.mjs.map +1 -0
  407. package/package.json +1 -40
  408. package/src/InMemory.ts +19 -0
  409. package/src/ToolExposure.ts +2 -0
  410. package/src/capabilities/Approval.ts +352 -0
  411. package/src/capabilities/Budget.ts +536 -0
  412. package/src/capabilities/CodeMode.ts +1090 -0
  413. package/src/capabilities/Commands.ts +86 -0
  414. package/src/capabilities/ContextTools.ts +184 -0
  415. package/src/capabilities/Mcp.ts +426 -0
  416. package/src/capabilities/McpClient.ts +967 -0
  417. package/src/capabilities/MemoryNotes.ts +174 -0
  418. package/src/capabilities/Messaging.ts +261 -0
  419. package/src/capabilities/ModelContext.ts +354 -0
  420. package/src/capabilities/Redaction.ts +157 -0
  421. package/src/capabilities/Remembering.ts +550 -0
  422. package/src/capabilities/RunHooks.ts +280 -0
  423. package/src/capabilities/SemanticMemory.ts +447 -0
  424. package/src/capabilities/Subagent.ts +2489 -0
  425. package/src/capabilities/SubagentReservations.ts +850 -0
  426. package/src/capabilities/ToolDiscovery.ts +369 -0
  427. package/src/capabilities/WebCapture.ts +722 -0
  428. package/src/capabilities/WebSearch.ts +190 -0
  429. package/src/capabilities/internal/subagent-background.ts +1273 -0
  430. package/src/capabilities/internal/subagent-contract.ts +146 -0
  431. package/src/capabilities/internal/subagent-policy.ts +235 -0
  432. package/src/capabilities/internal/subagent-reporting.ts +136 -0
  433. package/src/capabilities/internal/utf8.ts +10 -0
  434. package/src/core/Agent.ts +602 -0
  435. package/src/core/AgentError.ts +172 -0
  436. package/src/core/AgentPolicy.ts +153 -0
  437. package/src/core/AgentUpdates.ts +100 -0
  438. package/src/core/FailureDiagnostic.ts +343 -0
  439. package/src/core/IdGenerator.ts +39 -0
  440. package/src/core/Identifiers.ts +48 -0
  441. package/src/core/Memory.ts +290 -0
  442. package/src/core/MemoryNamespace.ts +196 -0
  443. package/src/core/MemoryReference.ts +121 -0
  444. package/src/core/MemoryRevalidation.ts +185 -0
  445. package/src/core/MemoryStore.ts +368 -0
  446. package/src/core/Messaging.ts +72 -0
  447. package/src/core/Receipt.ts +42 -0
  448. package/src/core/RememberingStore.ts +300 -0
  449. package/src/core/RunEvent.ts +366 -0
  450. package/src/core/RunPolicyUsage.ts +17 -0
  451. package/src/core/SemanticMemoryIndex.ts +250 -0
  452. package/src/core/SemanticMemoryRevalidation.ts +254 -0
  453. package/src/core/SubagentContract.ts +196 -0
  454. package/src/core/Thread.ts +371 -0
  455. package/src/core/ToolExposure.ts +74 -0
  456. package/src/core/ToolResult.ts +190 -0
  457. package/src/core/Usage.ts +529 -0
  458. package/src/core/Worker.ts +240 -0
  459. package/src/core/internal/agent-updates.ts +34 -0
  460. package/src/core/internal/message-status.ts +60 -0
  461. package/src/core/internal/strict-schema.ts +14 -0
  462. package/src/core/internal/utf8.ts +23 -0
  463. package/src/durable/ActivityStore.ts +160 -0
  464. package/src/durable/Admin.ts +505 -0
  465. package/src/durable/AgentRegistration.ts +14 -0
  466. package/src/durable/Certification.ts +210 -0
  467. package/src/durable/CommittedActivity.ts +296 -0
  468. package/src/durable/Digest.ts +87 -0
  469. package/src/durable/DurableAgentRuntime.ts +11275 -0
  470. package/src/durable/DurableFailpoint.ts +111 -0
  471. package/src/durable/DurableFailpointTestControl.ts +39 -0
  472. package/src/durable/EventSource.ts +172 -0
  473. package/src/durable/GitHubWorkflowSource.ts +447 -0
  474. package/src/durable/MessageDelivery.ts +832 -0
  475. package/src/durable/MessageDeliveryStoreConformance.ts +410 -0
  476. package/src/durable/OperationAuthorizer.ts +85 -0
  477. package/src/durable/PersistentHistory.ts +260 -0
  478. package/src/durable/PreparedInputAdmission.ts +57 -0
  479. package/src/durable/Records.ts +1075 -0
  480. package/src/durable/Recovery.ts +1018 -0
  481. package/src/durable/RunJournal.ts +1631 -0
  482. package/src/durable/Schedule.ts +513 -0
  483. package/src/durable/ScheduleStoreConformance.ts +638 -0
  484. package/src/durable/ScheduleTransition.ts +265 -0
  485. package/src/durable/Scheduling.ts +1077 -0
  486. package/src/durable/SqlMemoryStore.ts +778 -0
  487. package/src/durable/SqlMessageDeliveryStore.ts +335 -0
  488. package/src/durable/SqlStorageV2Upgrade.ts +500 -0
  489. package/src/durable/SqlSubscriptionStore.ts +1440 -0
  490. package/src/durable/SqlThreadNativeReads.ts +270 -0
  491. package/src/durable/SubmissionLedger.ts +1265 -0
  492. package/src/durable/SubmissionLedgerConformance.ts +4820 -0
  493. package/src/durable/SubmissionStatus.ts +14 -0
  494. package/src/durable/Subscription.ts +544 -0
  495. package/src/durable/SubscriptionInput.ts +144 -0
  496. package/src/durable/SubscriptionStoreConformance.ts +945 -0
  497. package/src/durable/SubscriptionTools.ts +327 -0
  498. package/src/durable/SubscriptionTransition.ts +302 -0
  499. package/src/durable/Subscriptions.ts +1210 -0
  500. package/src/durable/ThreadContextHistory.ts +227 -0
  501. package/src/durable/ThreadContextHistoryProjection.ts +216 -0
  502. package/src/durable/ThreadInvariants.ts +507 -0
  503. package/src/durable/ThreadProjection.ts +269 -0
  504. package/src/durable/ThreadProjectionMaintenance.ts +67 -0
  505. package/src/durable/ThreadStore.ts +573 -0
  506. package/src/durable/ThreadStoreConformance.ts +1156 -0
  507. package/src/durable/ToolReconciler.ts +109 -0
  508. package/src/durable/WakeScheduler.ts +134 -0
  509. package/src/durable/WorkerHost.ts +171 -0
  510. package/src/durable/internal/agent-registration.ts +587 -0
  511. package/src/durable/internal/agent-updates.ts +302 -0
  512. package/src/durable/internal/foreign-diagnostic.ts +47 -0
  513. package/src/durable/internal/journal-checkpoint.ts +104 -0
  514. package/src/durable/internal/journal-metadata.ts +117 -0
  515. package/src/durable/internal/message-status.ts +20 -0
  516. package/src/durable/internal/messaging-host.ts +637 -0
  517. package/src/durable/internal/schedule-time.ts +303 -0
  518. package/src/durable/internal/storage-v2-layout.ts +163 -0
  519. package/src/durable/internal/storage-v2.ts +73 -0
  520. package/src/durable/internal/worker-host.ts +2885 -0
  521. package/src/durable/internal/worker-runtime.ts +9 -0
  522. package/src/engine/AgentRuntime.ts +37 -0
  523. package/src/engine/Compaction.ts +11 -0
  524. package/src/engine/ContextCompactor.ts +277 -0
  525. package/src/engine/ContextHistory.ts +73 -0
  526. package/src/engine/ContextWindow.ts +72 -0
  527. package/src/engine/DurableStep.ts +132 -0
  528. package/src/engine/MessagingHost.ts +110 -0
  529. package/src/engine/Output.ts +2 -0
  530. package/src/engine/RunEventSink.ts +132 -0
  531. package/src/engine/RunOptions.ts +1101 -0
  532. package/src/engine/SubagentHost.ts +230 -0
  533. package/src/engine/ThreadHistory.ts +120 -0
  534. package/src/engine/ToolBroker.ts +157 -0
  535. package/src/engine/ToolExposure.ts +48 -0
  536. package/src/engine/internal/agent-runtime.ts +10500 -0
  537. package/src/engine/internal/bounded-value.ts +315 -0
  538. package/src/engine/internal/compaction.ts +678 -0
  539. package/src/engine/internal/error-diagnostic.ts +39 -0
  540. package/src/engine/internal/output-contract.ts +173 -0
  541. package/src/engine/internal/primitive-delta.ts +80 -0
  542. package/src/engine/internal/provider-result-staging.ts +211 -0
  543. package/src/engine/internal/tool-derivative.ts +106 -0
  544. package/src/engine/internal/tool-exposure.ts +224 -0
  545. package/src/engine/internal/tool-telemetry.ts +484 -0
  546. package/src/index.ts +99 -21
  547. package/src/sandbox/CodeExecutor.ts +352 -0
  548. package/src/sandbox/InteractiveBrowser.ts +339 -0
  549. package/src/sandbox/PageCapture.ts +691 -0
  550. package/src/sandbox/PageCrawl.ts +148 -0
  551. package/src/sandbox/PageScreenshot.ts +81 -0
  552. package/src/sandbox/ProtectedBrowser.ts +452 -0
  553. package/src/sandbox/Sandbox.ts +241 -0
@@ -0,0 +1,128 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
3
+ import { DurableStep, DurableStepError, ToolExecutionClass } from "../engine/DurableStep.mjs";
4
+ import { MemoryContent, MemorySourceReference } from "../core/MemoryReference.mjs";
5
+ import { ActiveMemoryDocument, MemoryConflict, MemoryDocument, MemoryKey, MemoryMutationFailure, MemoryOperationConflict, MemoryReader, MemoryStorageError, MemoryWithdrawn, MemoryWrite, MemoryWriter } from "../core/MemoryStore.mjs";
6
+ import { IdGenerator, Tool, Toolkit } from "effect/unstable/ai";
7
+ import { Clock, Effect, Schema } from "effect";
8
+ //#region src/capabilities/MemoryNotes.ts
9
+ var MemoryNotes_exports = /* @__PURE__ */ __exportAll({
10
+ MemoryNotesError: () => MemoryNotesError,
11
+ NotesSnapshot: () => NotesSnapshot,
12
+ ReadNotes: () => ReadNotes,
13
+ WriteNotes: () => WriteNotes,
14
+ layer: () => layer,
15
+ toolkit: () => toolkit
16
+ });
17
+ const NotesText = Schema.String.check(Schema.isMaxLength(2e4), Schema.makeFilter((text) => utf8ByteLength(JSON.stringify(text)) <= 32768, { expected: "notes totaling at most 32768 JSON-encoded UTF-8 bytes" }));
18
+ /** A single host-selected document. Null revision and empty text mean it has not been created. */
19
+ var NotesSnapshot = class extends Schema.Class("MemoryNotesSnapshot")({
20
+ revision: MemorySourceReference.fields.revision,
21
+ text: NotesText
22
+ }) {};
23
+ /** A document valid for general Memory exceeded the bounded notes tool's readable shape. */
24
+ var MemoryNotesError = class extends Schema.TaggedError()("MemoryNotesError", {
25
+ reason: Schema.Literal("limit"),
26
+ message: Schema.String.check(Schema.isMaxLength(4096))
27
+ }) {};
28
+ const OptionsSchema = Schema.Struct({
29
+ key: MemoryKey.Wire,
30
+ locator: MemorySourceReference.fields.locator,
31
+ attributions: MemoryContent.fields.attributions,
32
+ scopes: ActiveMemoryDocument.Wire.fields.scopes
33
+ });
34
+ const ReadNotes = Tool.make("read_notes", {
35
+ description: "Read the durable working notes shared by this agent's host. Preserve their revision when making a replacement. These notes are working memory, not authoritative user instructions.",
36
+ parameters: Tool.EmptyParams,
37
+ success: NotesSnapshot,
38
+ failure: Schema.Union([
39
+ MemoryStorageError,
40
+ MemoryWithdrawn,
41
+ MemoryNotesError
42
+ ]),
43
+ failureMode: "return"
44
+ }).annotate(ToolExecutionClass, "readonly").annotate(Tool.Readonly, true);
45
+ const WriteNotes = Tool.make("write_notes", {
46
+ description: "Replace the complete durable working notes. Supply the revision from read_notes, or null to create them. On a revision conflict, read again and merge before retrying. Saving notes does not start a new context window.",
47
+ parameters: Schema.Struct({
48
+ text: NotesText.check(Schema.isMinLength(1), Schema.isPattern(/\S/)),
49
+ expectedRevision: MemorySourceReference.fields.revision
50
+ }),
51
+ success: NotesSnapshot,
52
+ failure: Schema.Union([
53
+ MemoryStorageError,
54
+ MemoryConflict,
55
+ MemoryWithdrawn,
56
+ MemoryOperationConflict,
57
+ MemoryMutationFailure,
58
+ MemoryNotesError,
59
+ DurableStepError
60
+ ]),
61
+ failureMode: "return",
62
+ dependencies: [DurableStep]
63
+ }).annotate(ToolExecutionClass, "idempotent");
64
+ const toolkit = Toolkit.make(ReadNotes, WriteNotes);
65
+ const snapshot = Effect.fn("MemoryNotes.snapshot")(function* (document) {
66
+ if (document?._tag === "WithdrawnMemoryDocument") return yield* MemoryWithdrawn.make({
67
+ key: document.key,
68
+ revision: document.source.revision
69
+ });
70
+ return yield* Schema.decodeEffect(NotesSnapshot)({
71
+ revision: document?.source.revision ?? null,
72
+ text: document?.content.text ?? ""
73
+ }).pipe(Effect.mapError(() => MemoryNotesError.make({
74
+ reason: "limit",
75
+ message: "Notes exceed 20000 characters or 32768 JSON-encoded UTF-8 bytes"
76
+ })));
77
+ });
78
+ /**
79
+ * Bind the tools to one authorized Memory document. The host supplies a durable MemoryWriter
80
+ * when notes must survive process loss. Revision conflicts never trigger an automatic overwrite.
81
+ * A Durable Step saves the exact command, including operation identity and timestamp, before
82
+ * dispatch; retries reuse it and the writer's existing idempotency receipt. Ephemeral Runs
83
+ * retain the Memory store's semantics but do not acquire durable Tool recovery.
84
+ * Supply Effect AI's IdGenerator service to select operation identities.
85
+ */
86
+ const layer = (options) => {
87
+ const config = Schema.decodeSync(OptionsSchema)(options);
88
+ return toolkit.toLayer(Effect.gen(function* () {
89
+ const reader = yield* MemoryReader;
90
+ const writer = yield* MemoryWriter;
91
+ const ids = yield* IdGenerator.IdGenerator;
92
+ return toolkit.of({
93
+ read_notes: () => reader.get(config.key).pipe(Effect.flatMap(snapshot)),
94
+ write_notes: Effect.fn("MemoryNotes.write_notes")(function* (request) {
95
+ const step = yield* DurableStep;
96
+ const command = yield* step.do("prepare-notes", MemoryWrite.Wire, Effect.gen(function* () {
97
+ const operationId = yield* ids.generateId();
98
+ const recordedAt = yield* Clock.currentTimeMillis;
99
+ return MemoryWrite.make({
100
+ _tag: "Put",
101
+ key: config.key,
102
+ operationId,
103
+ expectedRevision: request.expectedRevision,
104
+ locator: config.locator,
105
+ scopes: config.scopes,
106
+ content: MemoryContent.make({
107
+ text: request.text,
108
+ attributions: config.attributions,
109
+ metadata: {},
110
+ recordedAt
111
+ })
112
+ });
113
+ }));
114
+ const document = yield* step.do("write-notes", MemoryDocument.Wire, writer.change(command));
115
+ return yield* snapshot(document);
116
+ }, Effect.catchTag("DurableStepError", (error) => Effect.fail(DurableStepError.make({
117
+ stepName: error.stepName,
118
+ reason: error.reason,
119
+ message: "Could not persist the notes operation",
120
+ ...error.toolCallId === void 0 ? {} : { toolCallId: error.toolCallId }
121
+ }))))
122
+ });
123
+ }));
124
+ };
125
+ //#endregion
126
+ export { MemoryNotesError, NotesSnapshot, ReadNotes, WriteNotes, layer, MemoryNotes_exports as t, toolkit };
127
+
128
+ //# sourceMappingURL=MemoryNotes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryNotes.mjs","names":[],"sources":["../../src/capabilities/MemoryNotes.ts"],"sourcesContent":["import { Clock, Effect, Schema } from \"effect\";\nimport { IdGenerator, Tool, Toolkit } from \"effect/unstable/ai\";\n\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { MemoryContent, MemorySourceReference } from \"../core/MemoryReference.ts\";\nimport {\n ActiveMemoryDocument,\n MemoryConflict,\n MemoryDocument,\n MemoryKey,\n MemoryMutationFailure,\n MemoryOperationConflict,\n MemoryReader,\n MemoryStorageError,\n MemoryWithdrawn,\n MemoryWrite,\n MemoryWriter,\n} from \"../core/MemoryStore.ts\";\nimport { DurableStep, DurableStepError, ToolExecutionClass } from \"../engine/DurableStep.ts\";\n\nconst NotesText = Schema.String.check(\n Schema.isMaxLength(20_000),\n Schema.makeFilter((text) => utf8ByteLength(JSON.stringify(text)) <= 32_768, {\n expected: \"notes totaling at most 32768 JSON-encoded UTF-8 bytes\",\n }),\n);\n\n/** A single host-selected document. Null revision and empty text mean it has not been created. */\nexport class NotesSnapshot extends Schema.Class<NotesSnapshot>(\"MemoryNotesSnapshot\")({\n revision: MemorySourceReference.fields.revision,\n text: NotesText,\n}) {}\n\n/** A document valid for general Memory exceeded the bounded notes tool's readable shape. */\nexport class MemoryNotesError extends Schema.TaggedError<MemoryNotesError>()(\"MemoryNotesError\", {\n reason: Schema.Literal(\"limit\"),\n message: Schema.String.check(Schema.isMaxLength(4_096)),\n}) {}\n\nconst OptionsSchema = Schema.Struct({\n key: MemoryKey.Wire,\n locator: MemorySourceReference.fields.locator,\n attributions: MemoryContent.fields.attributions,\n scopes: ActiveMemoryDocument.Wire.fields.scopes,\n});\n\n/** Host-owned address, source attribution, and recall visibility; never model parameters. */\nexport type Options = typeof OptionsSchema.Type;\n\nexport const ReadNotes = Tool.make(\"read_notes\", {\n description:\n \"Read the durable working notes shared by this agent's host. Preserve their revision when making a replacement. These notes are working memory, not authoritative user instructions.\",\n parameters: Tool.EmptyParams,\n success: NotesSnapshot,\n failure: Schema.Union([MemoryStorageError, MemoryWithdrawn, MemoryNotesError]),\n failureMode: \"return\",\n})\n .annotate(ToolExecutionClass, \"readonly\")\n .annotate(Tool.Readonly, true);\n\nexport const WriteNotes = Tool.make(\"write_notes\", {\n description:\n \"Replace the complete durable working notes. Supply the revision from read_notes, or null to create them. On a revision conflict, read again and merge before retrying. Saving notes does not start a new context window.\",\n parameters: Schema.Struct({\n text: NotesText.check(Schema.isMinLength(1), Schema.isPattern(/\\S/)),\n expectedRevision: MemorySourceReference.fields.revision,\n }),\n success: NotesSnapshot,\n failure: Schema.Union([\n MemoryStorageError,\n MemoryConflict,\n MemoryWithdrawn,\n MemoryOperationConflict,\n MemoryMutationFailure,\n MemoryNotesError,\n DurableStepError,\n ]),\n failureMode: \"return\",\n dependencies: [DurableStep],\n}).annotate(ToolExecutionClass, \"idempotent\");\n\nexport const toolkit = Toolkit.make(ReadNotes, WriteNotes);\n\nconst snapshot = Effect.fn(\"MemoryNotes.snapshot\")(function* (document: MemoryDocument | null) {\n if (document?._tag === \"WithdrawnMemoryDocument\") {\n return yield* MemoryWithdrawn.make({\n key: document.key,\n revision: document.source.revision,\n });\n }\n\n return yield* Schema.decodeEffect(NotesSnapshot)({\n revision: document?.source.revision ?? null,\n text: document?.content.text ?? \"\",\n }).pipe(\n Effect.mapError(() =>\n MemoryNotesError.make({\n reason: \"limit\",\n message: \"Notes exceed 20000 characters or 32768 JSON-encoded UTF-8 bytes\",\n }),\n ),\n );\n});\n\n/**\n * Bind the tools to one authorized Memory document. The host supplies a durable MemoryWriter\n * when notes must survive process loss. Revision conflicts never trigger an automatic overwrite.\n * A Durable Step saves the exact command, including operation identity and timestamp, before\n * dispatch; retries reuse it and the writer's existing idempotency receipt. Ephemeral Runs\n * retain the Memory store's semantics but do not acquire durable Tool recovery.\n * Supply Effect AI's IdGenerator service to select operation identities.\n */\nexport const layer = (options: Options) => {\n const config = Schema.decodeSync(OptionsSchema)(options);\n\n return toolkit.toLayer(\n Effect.gen(function* () {\n const reader = yield* MemoryReader;\n const writer = yield* MemoryWriter;\n const ids = yield* IdGenerator.IdGenerator;\n\n return toolkit.of({\n read_notes: () => reader.get(config.key).pipe(Effect.flatMap(snapshot)),\n write_notes: Effect.fn(\"MemoryNotes.write_notes\")(\n function* (request) {\n const step = yield* DurableStep;\n\n const command = yield* step.do(\n \"prepare-notes\",\n MemoryWrite.Wire,\n Effect.gen(function* () {\n const operationId = yield* ids.generateId();\n const recordedAt = yield* Clock.currentTimeMillis;\n\n return MemoryWrite.make({\n _tag: \"Put\",\n key: config.key,\n operationId,\n expectedRevision: request.expectedRevision,\n locator: config.locator,\n scopes: config.scopes,\n content: MemoryContent.make({\n text: request.text,\n attributions: config.attributions,\n metadata: {},\n recordedAt,\n }),\n });\n }),\n );\n\n const document = yield* step.do(\n \"write-notes\",\n MemoryDocument.Wire,\n writer.change(command),\n );\n\n return yield* snapshot(document);\n },\n Effect.catchTag(\"DurableStepError\", (error) =>\n Effect.fail(\n DurableStepError.make({\n stepName: error.stepName,\n reason: error.reason,\n message: \"Could not persist the notes operation\",\n ...(error.toolCallId === undefined ? {} : { toolCallId: error.toolCallId }),\n }),\n ),\n ),\n ),\n });\n }),\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,MAAM,YAAY,OAAO,OAAO,MAC9B,OAAO,YAAY,GAAM,GACzB,OAAO,YAAY,SAAS,eAAe,KAAK,UAAU,IAAI,CAAC,KAAK,OAAQ,EAC1E,UAAU,wDACZ,CAAC,CACH;;AAGA,IAAa,gBAAb,cAAmC,OAAO,MAAqB,qBAAqB,CAAC,CAAC;CACpF,UAAU,sBAAsB,OAAO;CACvC,MAAM;AACR,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,mBAAb,cAAsC,OAAO,YAA8B,CAAC,CAAC,oBAAoB;CAC/F,QAAQ,OAAO,QAAQ,OAAO;CAC9B,SAAS,OAAO,OAAO,MAAM,OAAO,YAAY,IAAK,CAAC;AACxD,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,gBAAgB,OAAO,OAAO;CAClC,KAAK,UAAU;CACf,SAAS,sBAAsB,OAAO;CACtC,cAAc,cAAc,OAAO;CACnC,QAAQ,qBAAqB,KAAK,OAAO;AAC3C,CAAC;AAKD,MAAa,YAAY,KAAK,KAAK,cAAc;CAC/C,aACE;CACF,YAAY,KAAK;CACjB,SAAS;CACT,SAAS,OAAO,MAAM;EAAC;EAAoB;EAAiB;CAAgB,CAAC;CAC7E,aAAa;AACf,CAAC,CAAC,CACC,SAAS,oBAAoB,UAAU,CAAC,CACxC,SAAS,KAAK,UAAU,IAAI;AAE/B,MAAa,aAAa,KAAK,KAAK,eAAe;CACjD,aACE;CACF,YAAY,OAAO,OAA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AC1C,MAAM,aAAa,OAAO,MAAM;KAEhC,OAAO,YAAY,KAAK;MACtB,MAAM;MACN,KAAK,OAAO;MACZ;MACA,kBAAkB,QAAQ;MAC1B,SAAS,OAAO;MAChB,QAAQ,OAAO;MACf,SAAS,cAAc,KAAK;OAC1B,MAAM,QAAQ;OACd,cAAc,OAAO;OACrB,UAAU,CAAC;OACX;MACF,CAAC;KACH,CAAC;IACH,CAAC,CACH;IAEA,MAAM,WAAW,OAAO,KAAK,GAC3B,eACA,eAAe,MACf,OAAO,OAAO,OAAO,CACvB;IAEA,OAAO,OAAO,SAAS,QAAQ;GACjC,GACA,OAAO,SAAS,qBAAqB,UACnC,OAAO,KACL,iBAAiB,KAAK;IACpB,UAAU,MAAM;IAChB,QAAQ,MAAM;IACd,SAAS;IACT,GAAI,MAAM,eAAe,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,MAAM,WAAW;GAC3E,CAAC,CACH,CACF,CACF;EACF,CAAC;CACH,CAAC,CACH;AACF"}
@@ -0,0 +1,3 @@
1
+ import { a as MessageAdmission, c as MessageRef, i as MessageAddress, l as MessageStatus, n as InboxPage, o as MessagingError, r as InputMessage, s as PeerName, t as InboxEntry } from "../Messaging-Dkg87ebg.mjs";
2
+ import { a as inspect, c as reply, d as retryTool, f as send, i as inboxTool, l as replyTool, n as Peer, o as inspectTool, p as sendTool, r as inbox, s as peer, u as retry } from "../Messaging-JYYN3oYS.mjs";
3
+ export { InboxEntry, InboxPage, InputMessage, MessageAddress, MessageAdmission, MessageRef, MessageStatus, MessagingError, Peer, PeerName, inbox, inboxTool, inspect, inspectTool, peer, reply, replyTool, retry, retryTool, send, sendTool };
@@ -0,0 +1,152 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ import { IdempotencyKey } from "../core/Receipt.mjs";
3
+ import { WorkerOperationTool } from "../core/SubagentContract.mjs";
4
+ import { C as MessageStatus, S as MessageRef } from "../Worker-CfwzMZEK.mjs";
5
+ import { c as InboxPage, d as MessageAdmission, f as MessagingError, l as InputMessage, p as PeerName, s as InboxEntry, t as MessagingHost, u as MessageAddress } from "../MessagingHost-DfsbMPvq.mjs";
6
+ import { t as utf8Bytes } from "../utf8-BYfhEkcj.mjs";
7
+ import { Tool, Toolkit } from "effect/unstable/ai";
8
+ import { Crypto, Effect, Encoding, Option, Schema } from "effect";
9
+ //#region src/capabilities/Messaging.ts
10
+ var Messaging_exports = /* @__PURE__ */ __exportAll({
11
+ InboxEntry: () => InboxEntry,
12
+ InboxPage: () => InboxPage,
13
+ InputMessage: () => InputMessage,
14
+ MessageAddress: () => MessageAddress,
15
+ MessageAdmission: () => MessageAdmission,
16
+ MessageRef: () => MessageRef,
17
+ MessageStatus: () => MessageStatus,
18
+ MessagingError: () => MessagingError,
19
+ PeerName: () => PeerName,
20
+ inbox: () => inbox,
21
+ inboxTool: () => inboxTool,
22
+ inspect: () => inspect,
23
+ inspectTool: () => inspectTool,
24
+ peer: () => peer,
25
+ reply: () => reply,
26
+ replyTool: () => replyTool,
27
+ retry: () => retry,
28
+ retryTool: () => retryTool,
29
+ send: () => send,
30
+ sendTool: () => sendTool
31
+ });
32
+ const peer = (name, options) => {
33
+ Schema.decodeSync(PeerName)(name);
34
+ return Object.freeze({
35
+ name,
36
+ target: options.target
37
+ });
38
+ };
39
+ const host = Effect.serviceOption(MessagingHost).pipe(Effect.flatMap((value) => Option.isSome(value) ? Effect.succeed(value.value) : MessagingError.make({
40
+ operation: "context",
41
+ reason: "unavailable"
42
+ })));
43
+ const dispatch = (declaration, input, options, operation) => Effect.gen(function* () {
44
+ const service = yield* host;
45
+ const invalid = () => MessagingError.make({
46
+ operation,
47
+ reason: "invalid-input"
48
+ });
49
+ const idempotencyKey = yield* Schema.decodeEffect(IdempotencyKey)(options.idempotencyKey).pipe(Effect.mapError(invalid));
50
+ const encodedInput = yield* Schema.encodeEffect(declaration.target.input)(input).pipe(Effect.mapError(invalid));
51
+ const inReplyTo = options.inReplyTo === void 0 ? void 0 : yield* Schema.decodeEffect(MessageRef)(options.inReplyTo).pipe(Effect.mapError(invalid));
52
+ const request = {
53
+ ...declaration,
54
+ encodedInput,
55
+ idempotencyKey,
56
+ ...inReplyTo === void 0 ? {} : { inReplyTo }
57
+ };
58
+ const result = operation === "reply" ? inReplyTo === void 0 ? yield* invalid() : yield* service.reply({
59
+ ...request,
60
+ inReplyTo
61
+ }) : yield* service.send(request);
62
+ return yield* Schema.decodeEffect(MessageStatus)(result).pipe(Effect.mapError(() => MessagingError.make({
63
+ operation,
64
+ reason: "corrupt"
65
+ })));
66
+ });
67
+ /** Retain a durable message. Its status distinguishes outbound retention from destination acceptance. */
68
+ const send = (declaration, input, options) => dispatch(declaration, input, options, "send");
69
+ /** Reply to an authenticated inbound message; return routing still requires independent send authority. */
70
+ const reply = (declaration, inReplyTo, input, options) => dispatch(declaration, input, {
71
+ ...options,
72
+ inReplyTo
73
+ }, "reply");
74
+ /** Return bounded provenance for messages from this peer, without granting permission to reply. */
75
+ const inbox = (declaration, options = {}) => Effect.gen(function* () {
76
+ return yield* (yield* host).inbox({
77
+ ...declaration,
78
+ ...options,
79
+ limit: options.limit ?? 20
80
+ });
81
+ });
82
+ const inspect = (declaration, message) => Effect.gen(function* () {
83
+ return yield* (yield* host).inspect({
84
+ ...declaration,
85
+ message
86
+ });
87
+ });
88
+ /** Explicitly renew a parked delivery's bounded retry budget, retaining its complete frozen envelope. */
89
+ const retry = (declaration, message) => Effect.gen(function* () {
90
+ return yield* (yield* host).retry({
91
+ ...declaration,
92
+ message
93
+ });
94
+ });
95
+ const modelKey = Effect.fn("Messaging.modelKey")(function* () {
96
+ const source = yield* (yield* host).context;
97
+ if (source._tag !== "tool") return yield* MessagingError.make({
98
+ operation: "send",
99
+ reason: "denied"
100
+ });
101
+ const digest = yield* (yield* Crypto.Crypto).digest("SHA-256", utf8Bytes(JSON.stringify(source))).pipe(Effect.mapError(() => MessagingError.make({
102
+ operation: "send",
103
+ reason: "unavailable"
104
+ })));
105
+ return Schema.decodeSync(IdempotencyKey)(`peer-tool:${Encoding.encodeHex(digest)}`);
106
+ });
107
+ const native = (name, parameters, success, description, handler) => {
108
+ const tool = Tool.make(name, {
109
+ parameters,
110
+ success,
111
+ failure: MessagingError,
112
+ description
113
+ }).annotate(WorkerOperationTool, true).addDependency(MessagingHost).addDependency(Crypto.Crypto);
114
+ const toolkit = Toolkit.make(tool);
115
+ const build = Effect.gen(function* () {
116
+ const captured = yield* Effect.context();
117
+ const invoke = Effect.fn("Messaging.tool")(function* (value) {
118
+ const service = yield* host;
119
+ const crypto = yield* Crypto.Crypto;
120
+ return yield* handler(value).pipe(Effect.provideService(MessagingHost, service), Effect.provideService(Crypto.Crypto, crypto), Effect.provide(captured));
121
+ });
122
+ return { [name]: invoke };
123
+ });
124
+ return {
125
+ tool,
126
+ toolkit,
127
+ layer: toolkit.toLayer(build)
128
+ };
129
+ };
130
+ /** Install only the native operations chosen by the host; schemas come from the Peer declaration. */
131
+ const sendTool = (declaration) => native(`${declaration.name}_send`, declaration.target.input, MessageStatus, `Send input to ${declaration.name} through its authorized durable route.`, (input) => Effect.gen(function* () {
132
+ return yield* send(declaration, input, { idempotencyKey: yield* modelKey() });
133
+ }));
134
+ const replyTool = (declaration) => {
135
+ const inputSchema = declaration.target.input;
136
+ return native(`${declaration.name}_reply`, Schema.Struct({
137
+ inReplyTo: MessageRef,
138
+ input: inputSchema
139
+ }), MessageStatus, `Reply to a recorded inbound message from ${declaration.name}.`, ({ inReplyTo, input }) => Effect.gen(function* () {
140
+ return yield* reply(declaration, inReplyTo, input, { idempotencyKey: yield* modelKey() });
141
+ }));
142
+ };
143
+ const inboxTool = (declaration) => native(`${declaration.name}_inbox`, Schema.Struct({
144
+ after: Schema.optionalKey(Schema.Natural),
145
+ limit: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(100)))
146
+ }), InboxPage, `Read a bounded page of message provenance from ${declaration.name}.`, (options) => inbox(declaration, options));
147
+ const inspectTool = (declaration) => native(`${declaration.name}_message_status`, Schema.Struct({ message: MessageRef }), MessageStatus, `Inspect delivery status of a message sent to ${declaration.name}.`, ({ message }) => inspect(declaration, message));
148
+ const retryTool = (declaration) => native(`${declaration.name}_retry_message`, Schema.Struct({ message: MessageRef }), MessageStatus, `Renew bounded automatic retries for a parked message to ${declaration.name}.`, ({ message }) => retry(declaration, message));
149
+ //#endregion
150
+ export { InboxEntry, InboxPage, InputMessage, MessageAddress, MessageAdmission, MessageRef, MessageStatus, MessagingError, PeerName, inbox, inboxTool, inspect, inspectTool, peer, reply, replyTool, retry, retryTool, send, sendTool, Messaging_exports as t };
151
+
152
+ //# sourceMappingURL=Messaging.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Messaging.mjs","names":[],"sources":["../../src/capabilities/Messaging.ts"],"sourcesContent":["import { Crypto, Effect, Encoding, Option, Schema } from \"effect\";\nimport { Tool, Toolkit } from \"effect/unstable/ai\";\n\nimport type { AnyDefinition } from \"../core/Agent.ts\";\nimport {\n InboxPage,\n MessageRef,\n MessageStatus,\n MessagingError,\n PeerName,\n} from \"../core/Messaging.ts\";\nimport { IdempotencyKey } from \"../core/Receipt.ts\";\nimport { WorkerOperationTool } from \"../core/SubagentContract.ts\";\nimport { MessagingHost } from \"../engine/MessagingHost.ts\";\nimport { utf8Bytes } from \"./internal/utf8.ts\";\n\nexport * from \"../core/Messaging.ts\";\n\n/** A fixed host route and its destination-owned input Schema. Construction acquires no resources. */\nexport interface Peer<Name extends string, Input extends Schema.Top> {\n readonly name: Name;\n readonly target: AnyDefinition & { readonly input: Input };\n}\n\nexport const peer = <const Name extends string, Input extends Schema.Top>(\n name: Name,\n options: { readonly target: AnyDefinition & { readonly input: Input } },\n): Peer<Name, Input> => {\n Schema.decodeSync(PeerName)(name);\n\n return Object.freeze({ name, target: options.target });\n};\n\nconst host: Effect.Effect<MessagingHost[\"Service\"], MessagingError, MessagingHost> =\n Effect.serviceOption(MessagingHost).pipe(\n Effect.flatMap((value) =>\n Option.isSome(value)\n ? Effect.succeed(value.value)\n : MessagingError.make({ operation: \"context\", reason: \"unavailable\" }),\n ),\n );\n\nconst dispatch = <Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n input: Input[\"Type\"],\n options: { readonly idempotencyKey: IdempotencyKey; readonly inReplyTo?: MessageRef },\n operation: \"send\" | \"reply\",\n) =>\n Effect.gen(function* () {\n const service = yield* host;\n const invalid = () => MessagingError.make({ operation, reason: \"invalid-input\" });\n\n const idempotencyKey = yield* Schema.decodeEffect(IdempotencyKey)(options.idempotencyKey).pipe(\n Effect.mapError(invalid),\n );\n\n const encodedInput = yield* Schema.encodeEffect(declaration.target.input)(input).pipe(\n Effect.mapError(invalid),\n );\n\n const inReplyTo =\n options.inReplyTo === undefined\n ? undefined\n : yield* Schema.decodeEffect(MessageRef)(options.inReplyTo).pipe(Effect.mapError(invalid));\n\n const request = {\n ...declaration,\n encodedInput,\n idempotencyKey,\n ...(inReplyTo === undefined ? {} : { inReplyTo }),\n };\n\n const result =\n operation === \"reply\"\n ? inReplyTo === undefined\n ? yield* invalid()\n : yield* service.reply({ ...request, inReplyTo })\n : yield* service.send(request);\n\n return yield* Schema.decodeEffect(MessageStatus)(result).pipe(\n Effect.mapError(() => MessagingError.make({ operation, reason: \"corrupt\" })),\n );\n });\n\n/** Retain a durable message. Its status distinguishes outbound retention from destination acceptance. */\nexport const send = <Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n input: Input[\"Type\"],\n options: { readonly idempotencyKey: IdempotencyKey; readonly inReplyTo?: MessageRef },\n) => dispatch(declaration, input, options, \"send\");\n\n/** Reply to an authenticated inbound message; return routing still requires independent send authority. */\nexport const reply = <Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n inReplyTo: MessageRef,\n input: Input[\"Type\"],\n options: { readonly idempotencyKey: IdempotencyKey },\n) => dispatch(declaration, input, { ...options, inReplyTo }, \"reply\");\n\n/** Return bounded provenance for messages from this peer, without granting permission to reply. */\nexport const inbox = <Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n options: { readonly after?: number; readonly limit?: number } = {},\n) =>\n Effect.gen(function* () {\n const service = yield* host;\n\n return yield* service.inbox({ ...declaration, ...options, limit: options.limit ?? 20 });\n });\n\nexport const inspect = <Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n message: MessageRef,\n) =>\n Effect.gen(function* () {\n const service = yield* host;\n\n return yield* service.inspect({ ...declaration, message });\n });\n\n/** Explicitly renew a parked delivery's bounded retry budget, retaining its complete frozen envelope. */\nexport const retry = <Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n message: MessageRef,\n) =>\n Effect.gen(function* () {\n const service = yield* host;\n\n return yield* service.retry({ ...declaration, message });\n });\n\nconst modelKey = Effect.fn(\"Messaging.modelKey\")(function* () {\n const source = yield* (yield* host).context;\n\n if (source._tag !== \"tool\")\n return yield* MessagingError.make({ operation: \"send\", reason: \"denied\" });\n const crypto = yield* Crypto.Crypto;\n\n const digest = yield* crypto\n .digest(\"SHA-256\", utf8Bytes(JSON.stringify(source)))\n .pipe(Effect.mapError(() => MessagingError.make({ operation: \"send\", reason: \"unavailable\" })));\n\n return Schema.decodeSync(IdempotencyKey)(`peer-tool:${Encoding.encodeHex(digest)}`);\n});\n\nconst native = <\n const Name extends string,\n Parameters extends Schema.Top,\n Success extends Schema.Top,\n R,\n>(\n name: Name,\n parameters: Parameters,\n success: Success,\n description: string,\n handler: (\n parameters: Parameters[\"Type\"],\n ) => Effect.Effect<Success[\"Type\"], MessagingError, R | MessagingHost | Crypto.Crypto>,\n) => {\n const tool = Tool.make(name, { parameters, success, failure: MessagingError, description })\n .annotate(WorkerOperationTool, true)\n .addDependency(MessagingHost)\n .addDependency(Crypto.Crypto);\n\n const toolkit = Toolkit.make(tool);\n\n const build = Effect.gen(function* () {\n const captured = yield* Effect.context<Exclude<R, MessagingHost | Crypto.Crypto>>();\n\n const invoke = Effect.fn(\"Messaging.tool\")(function* (value: Parameters[\"Type\"]) {\n const service = yield* host;\n const crypto = yield* Crypto.Crypto;\n\n return yield* handler(value).pipe(\n Effect.provideService(MessagingHost, service),\n Effect.provideService(Crypto.Crypto, crypto),\n Effect.provide(captured),\n );\n });\n\n // The computed single key is precisely the native Tool's literal name.\n return { [name]: invoke } as unknown as Toolkit.HandlersFrom<typeof toolkit.tools>;\n });\n\n return { tool, toolkit, layer: toolkit.toLayer(build) };\n};\n\n/** Install only the native operations chosen by the host; schemas come from the Peer declaration. */\nexport const sendTool = <const Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n) =>\n native(\n `${declaration.name}_send` as const,\n declaration.target.input,\n MessageStatus,\n `Send input to ${declaration.name} through its authorized durable route.`,\n (input) =>\n Effect.gen(function* () {\n return yield* send(declaration, input, { idempotencyKey: yield* modelKey() });\n }),\n );\n\nexport const replyTool = <const Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n) => {\n const inputSchema: Schema.Codec<\n Input[\"Type\"],\n Input[\"Encoded\"],\n Input[\"DecodingServices\"],\n Input[\"EncodingServices\"]\n > = declaration.target.input;\n\n return native(\n `${declaration.name}_reply` as const,\n Schema.Struct({ inReplyTo: MessageRef, input: inputSchema }),\n MessageStatus,\n `Reply to a recorded inbound message from ${declaration.name}.`,\n ({ inReplyTo, input }) =>\n Effect.gen(function* () {\n return yield* reply(declaration, inReplyTo, input, { idempotencyKey: yield* modelKey() });\n }),\n );\n};\n\nexport const inboxTool = <const Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n) =>\n native(\n `${declaration.name}_inbox` as const,\n Schema.Struct({\n after: Schema.optionalKey(Schema.Natural),\n limit: Schema.optionalKey(\n Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(100)),\n ),\n }),\n InboxPage,\n `Read a bounded page of message provenance from ${declaration.name}.`,\n (options) => inbox(declaration, options),\n );\n\nexport const inspectTool = <const Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n) =>\n native(\n `${declaration.name}_message_status` as const,\n Schema.Struct({ message: MessageRef }),\n MessageStatus,\n `Inspect delivery status of a message sent to ${declaration.name}.`,\n ({ message }) => inspect(declaration, message),\n );\n\nexport const retryTool = <const Name extends string, Input extends Schema.Top>(\n declaration: Peer<Name, Input>,\n) =>\n native(\n `${declaration.name}_retry_message` as const,\n Schema.Struct({ message: MessageRef }),\n MessageStatus,\n `Renew bounded automatic retries for a parked message to ${declaration.name}.`,\n ({ message }) => retry(declaration, message),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,QACX,MACA,YACsB;CACtB,OAAO,WAAW,QAAQ,CAAC,CAAC,IAAI;CAEhC,OAAO,OAAO,OAAO;EAAE;EAAM,QAAQ,QAAQ;CAAO,CAAC;AACvD;AAEA,MAAM,OACJ,OAAO,cAAc,aAAa,CAAC,CAAC,KAClC,OAAO,SAAS,UACd,OAAO,OAAO,KAAK,IACf,OAAO,QAAQ,MAAM,KAAK,IAC1B,eAAe,KAAK;CAAE,WAAW;CAAW,QAAQ;AAAc,CAAC,CACzE,CACF;AAEF,MAAM,YACJ,aACA,OACA,SACA,cAEA,OAAO,IAAI,aAAa;CACtB,MAAM,UAAU,OAAO;CACvB,MAAM,gBAAgB,eAAe,KAAK;EAAE;EAAW,QAAQ;CAAgB,CAAC;CAEhF,MAAM,iBAAiB,OAAO,OAAO,aAAa,cAAc,CAAC,CAAC,QAAQ,cAAc,CAAC,CAAC,KACxF,OAAO,SAAS,OAAO,CACzB;CAEA,MAAM,eAAe,OAAO,OAAO,aAAa,YAAY,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAC/E,OAAO,SAAS,OAAO,CACzB;CAEA,MAAM,YACJ,QAAQ,cAAc,KAAA,IAClB,KAAA,IACA,OAAO,OAAO,aAAa,UAAU,CAAC,CAAC,QAAQ,SAAS,CAAC,CAAC,KAAK,OAAO,S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AAO;CAEvB,OAAO,OACL,GAAG,YAAY,KAAK,SACpB,OAAO,OAAO;EAAE,WAAW;EAAY,OAAO;CAAY,CAAC,GAC3D,eACA,4CAA4C,YAAY,KAAK,KAC5D,EAAE,WAAW,YACZ,OAAO,IAAI,aAAa;EACtB,OAAO,OAAO,MAAM,aAAa,WAAW,OAAO,EAAE,gBAAgB,OAAO,SAAS,EAAE,CAAC;CAC1F,CAAC,CACL;AACF;AAEA,MAAa,aACX,gBAEA,OACE,GAAG,YAAY,KAAK,SACpB,OAAO,OAAO;CACZ,OAAO,OAAO,YAAY,OAAO,OAAO;CACxC,OAAO,OAAO,YACZ,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,GAAG,OAAO,oBAAoB,GAAG,CAAC,CAC3E;AACF,CAAC,GACD,WACA,kDAAkD,YAAY,KAAK,KAClE,YAAY,MAAM,aAAa,OAAO,CACzC;AAEF,MAAa,eACX,gBAEA,OACE,GAAG,YAAY,KAAK,kBACpB,OAAO,OAAO,EAAE,SAAS,WAAW,CAAC,GACrC,eACA,gDAAgD,YAAY,KAAK,KAChE,EAAE,cAAc,QAAQ,aAAa,OAAO,CAC/C;AAEF,MAAa,aACX,gBAEA,OACE,GAAG,YAAY,KAAK,iBACpB,OAAO,OAAO,EAAE,SAAS,WAAW,CAAC,GACrC,eACA,2DAA2D,YAAY,KAAK,KAC3E,EAAE,cAAc,MAAM,aAAa,OAAO,CAC7C"}
@@ -0,0 +1,89 @@
1
+ import { n as Thread } from "../Thread-DOBQ0QUY.mjs";
2
+ import { Crypto, Effect, Schema } from "effect";
3
+ declare namespace ModelContext_d_exports {
4
+ export { CompactionArtifact, CompactionDigestError, ContextLimitExceeded, ContextTransform, ContextTransformError, InvalidCompactionArtifact, ModelContextMessage, PreparedModelContext, RetainedFact, applyCompaction, digestCompactionSource, prepareModelContext };
5
+ }
6
+ declare const ModelContextMessage_base: Schema.Class<ModelContextMessage, Schema.Struct<{
7
+ readonly role: Schema.Literals<readonly ["system", "user", "assistant", "tool"]>;
8
+ readonly content: Schema.String;
9
+ readonly sourceSequences: Schema.$Array<Schema.Natural>;
10
+ }>, {}>;
11
+ /** A model-context message derived from, but never replacing, source history. */
12
+ export declare class ModelContextMessage extends ModelContextMessage_base {}
13
+ declare const RetainedFact_base: Schema.Class<RetainedFact, Schema.Struct<{
14
+ readonly fact: Schema.String;
15
+ readonly sourceSequences: Schema.$Array<Schema.Natural>;
16
+ }>, {}>;
17
+ /** A fact retained explicitly by compaction, independent of the generated prose summary. */
18
+ export declare class RetainedFact extends RetainedFact_base {}
19
+ declare const CompactionArtifact_base: Schema.Class<CompactionArtifact, Schema.Struct<{
20
+ readonly version: Schema.Literal<1>;
21
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
22
+ readonly coversFrom: Schema.Natural;
23
+ readonly coversThrough: Schema.Natural;
24
+ readonly summary: typeof ModelContextMessage;
25
+ readonly retainedFacts: Schema.refine<readonly RetainedFact[], Schema.$Array<typeof RetainedFact>>;
26
+ readonly tokenEstimate: Schema.Natural;
27
+ readonly sourceDigest: Schema.String;
28
+ readonly compactorVersion: Schema.NonEmptyString;
29
+ }>, {}>;
30
+ /** Versioned, replayable artifact that covers a prefix or middle range without deleting source. */
31
+ export declare class CompactionArtifact extends CompactionArtifact_base {}
32
+ declare const PreparedModelContext_base: Schema.Class<PreparedModelContext, Schema.Struct<{
33
+ readonly source: typeof Thread;
34
+ readonly messages: Schema.refine<readonly ModelContextMessage[], Schema.$Array<typeof ModelContextMessage>>;
35
+ readonly compactions: Schema.$Array<typeof CompactionArtifact>;
36
+ }>, {}>;
37
+ /** Context exposed to a model, with source history kept intact for audit and reconstruction. */
38
+ export declare class PreparedModelContext extends PreparedModelContext_base {}
39
+ declare const ContextTransformError_base: Schema.Class<ContextTransformError, Schema.TaggedStruct<"ContextTransformError", {
40
+ readonly transformId: Schema.NonEmptyString;
41
+ readonly message: Schema.String;
42
+ }>, import("effect/Cause").YieldableError>;
43
+ /** Transform failure is named and bounded so model context preparation has a closed error channel. */
44
+ export declare class ContextTransformError extends ContextTransformError_base {}
45
+ declare const CompactionDigestError_base: Schema.Class<CompactionDigestError, Schema.TaggedStruct<"CompactionDigestError", {
46
+ readonly message: Schema.String;
47
+ }>, import("effect/Cause").YieldableError>;
48
+ /** Source encoding or hashing failed before an artifact could be trusted. */
49
+ export declare class CompactionDigestError extends CompactionDigestError_base {}
50
+ declare const InvalidCompactionArtifact_base: Schema.Class<InvalidCompactionArtifact, Schema.TaggedStruct<"InvalidCompactionArtifact", {
51
+ readonly message: Schema.String;
52
+ }>, import("effect/Cause").YieldableError>;
53
+ /** Compaction artifacts that do not bind to the exact source range are rejected before use. */
54
+ export declare class InvalidCompactionArtifact extends InvalidCompactionArtifact_base {}
55
+ declare const ContextLimitExceeded_base: Schema.Class<ContextLimitExceeded, Schema.TaggedStruct<"ContextLimitExceeded", {
56
+ readonly limit: Schema.Literals<readonly ["messages", "message-bytes", "compactions"]>;
57
+ readonly limitValue: Schema.Natural;
58
+ readonly observedValue: Schema.Natural;
59
+ }>, import("effect/Cause").YieldableError>;
60
+ /** A transform or compaction exceeded the finite model-view collection bounds. */
61
+ export declare class ContextLimitExceeded extends ContextLimitExceeded_base {}
62
+ /**
63
+ * Ordered context transform. It receives and returns only the model-visible
64
+ * message view, making replacement of the authoritative source impossible.
65
+ * Required services remain visible in prepareModelContext; expected failures
66
+ * are translated by the transform into ContextTransformError.
67
+ */
68
+ export interface ContextTransform<Requirements = never> {
69
+ readonly id: string;
70
+ readonly version: string;
71
+ readonly apply: (messages: ReadonlyArray<ModelContextMessage>) => Effect.Effect<ReadonlyArray<ModelContextMessage>, ContextTransformError, Requirements>;
72
+ }
73
+ /** Apply transforms in declaration order, always restoring the original source snapshot. */
74
+ export declare const prepareModelContext: <const Requirements extends ReadonlyArray<unknown> = readonly []>(snapshot: Thread, transforms?: { readonly [Index in keyof Requirements]: ContextTransform<Requirements[Index]>; }) => Effect.Effect<PreparedModelContext, ContextTransformError, Requirements[number]>;
75
+ /** Compute a cryptographic digest over the canonical encoded exact source range. */
76
+ export declare const digestCompactionSource: (snapshot: Thread, coversFrom: number, coversThrough: number) => Effect.Effect<string, CompactionDigestError | InvalidCompactionArtifact, Crypto.Crypto>;
77
+ /**
78
+ * Replace only the model-view messages fully covered by the artifact range
79
+ * with its summary. The digest is recomputed against the exact source slice
80
+ * before the artifact can influence context. Messages that are not fully
81
+ * covered — including transform-synthesized messages without provenance and
82
+ * messages whose provenance only partially overlaps the range — remain
83
+ * visible, and the summary is inserted before the first message derived
84
+ * entirely from later source.
85
+ */
86
+ export declare const applyCompaction: (context: PreparedModelContext, artifact: CompactionArtifact) => Effect.Effect<PreparedModelContext, CompactionDigestError | ContextLimitExceeded | ContextTransformError | InvalidCompactionArtifact, Crypto.Crypto>;
87
+ //#endregion
88
+ export { ModelContext_d_exports as t };
89
+ //# sourceMappingURL=ModelContext.d.mts.map
@@ -0,0 +1,168 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ import { ThreadId } from "../core/Identifiers.mjs";
3
+ import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
4
+ import { Thread, ThreadMessage, ThreadText } from "../core/Thread.mjs";
5
+ import { Crypto, Effect, Encoding, Schema } from "effect";
6
+ //#region src/capabilities/ModelContext.ts
7
+ var ModelContext_exports = /* @__PURE__ */ __exportAll({
8
+ CompactionArtifact: () => CompactionArtifact,
9
+ CompactionDigestError: () => CompactionDigestError,
10
+ ContextLimitExceeded: () => ContextLimitExceeded,
11
+ ContextTransformError: () => ContextTransformError,
12
+ InvalidCompactionArtifact: () => InvalidCompactionArtifact,
13
+ ModelContextMessage: () => ModelContextMessage,
14
+ PreparedModelContext: () => PreparedModelContext,
15
+ RetainedFact: () => RetainedFact,
16
+ applyCompaction: () => applyCompaction,
17
+ digestCompactionSource: () => digestCompactionSource,
18
+ prepareModelContext: () => prepareModelContext
19
+ });
20
+ const MAX_CONTEXT_MESSAGES = 1024;
21
+ const MAX_CONTEXT_MESSAGE_BYTES = 4194304;
22
+ const MAX_SOURCE_SEQUENCES = 1024;
23
+ const MAX_RETAINED_FACTS = 256;
24
+ const MAX_RETAINED_FACT_BYTES = 1048576;
25
+ const MAX_COMPACTIONS = 16;
26
+ const SourceSequences = Schema.Array(Schema.Natural).check(Schema.isMaxLength(MAX_SOURCE_SEQUENCES));
27
+ /** A model-context message derived from, but never replacing, source history. */
28
+ var ModelContextMessage = class extends Schema.Class("@effect-agent/capabilities/ModelContextMessage")({
29
+ role: Schema.Literals([
30
+ "system",
31
+ "user",
32
+ "assistant",
33
+ "tool"
34
+ ]),
35
+ content: ThreadText,
36
+ sourceSequences: SourceSequences
37
+ }) {};
38
+ /** A fact retained explicitly by compaction, independent of the generated prose summary. */
39
+ var RetainedFact = class extends Schema.Class("@effect-agent/capabilities/RetainedFact")({
40
+ fact: Schema.String.check(Schema.isMaxLength(4096)),
41
+ sourceSequences: SourceSequences
42
+ }) {};
43
+ const ModelContextMessages = Schema.Array(ModelContextMessage).check(Schema.isMaxLength(MAX_CONTEXT_MESSAGES)).pipe(Schema.refine((messages) => messages.reduce((total, message) => total + utf8ByteLength(message.content), 0) <= MAX_CONTEXT_MESSAGE_BYTES, { expected: `model context totaling at most ${MAX_CONTEXT_MESSAGE_BYTES} UTF-8 bytes` }));
44
+ const RetainedFacts = Schema.Array(RetainedFact).check(Schema.isMaxLength(MAX_RETAINED_FACTS)).pipe(Schema.refine((facts) => facts.reduce((total, retained) => total + utf8ByteLength(retained.fact), 0) <= MAX_RETAINED_FACT_BYTES, { expected: `retained facts totaling at most ${MAX_RETAINED_FACT_BYTES} UTF-8 bytes` }));
45
+ const SourceDigest = Schema.String.check(Schema.isPattern(/^sha256:[a-f0-9]{64}$/));
46
+ /** Versioned, replayable artifact that covers a prefix or middle range without deleting source. */
47
+ var CompactionArtifact = class extends Schema.Class("@effect-agent/capabilities/CompactionArtifact")({
48
+ version: Schema.Literal(1),
49
+ threadId: ThreadId,
50
+ coversFrom: Schema.Natural,
51
+ coversThrough: Schema.Natural,
52
+ summary: ModelContextMessage,
53
+ retainedFacts: RetainedFacts,
54
+ tokenEstimate: Schema.Natural,
55
+ sourceDigest: SourceDigest,
56
+ compactorVersion: Schema.NonEmptyString
57
+ }) {};
58
+ /** Context exposed to a model, with source history kept intact for audit and reconstruction. */
59
+ var PreparedModelContext = class extends Schema.Class("@effect-agent/capabilities/PreparedModelContext")({
60
+ source: Thread,
61
+ messages: ModelContextMessages,
62
+ compactions: Schema.Array(CompactionArtifact).check(Schema.isMaxLength(MAX_COMPACTIONS))
63
+ }) {};
64
+ /** Transform failure is named and bounded so model context preparation has a closed error channel. */
65
+ var ContextTransformError = class extends Schema.TaggedError()("ContextTransformError", {
66
+ transformId: Schema.NonEmptyString,
67
+ message: Schema.String
68
+ }) {};
69
+ /** Source encoding or hashing failed before an artifact could be trusted. */
70
+ var CompactionDigestError = class extends Schema.TaggedError()("CompactionDigestError", { message: Schema.String }) {};
71
+ /** Compaction artifacts that do not bind to the exact source range are rejected before use. */
72
+ var InvalidCompactionArtifact = class extends Schema.TaggedError()("InvalidCompactionArtifact", { message: Schema.String }) {};
73
+ /** A transform or compaction exceeded the finite model-view collection bounds. */
74
+ var ContextLimitExceeded = class extends Schema.TaggedError()("ContextLimitExceeded", {
75
+ limit: Schema.Literals([
76
+ "messages",
77
+ "message-bytes",
78
+ "compactions"
79
+ ]),
80
+ limitValue: Schema.Natural,
81
+ observedValue: Schema.Natural
82
+ }) {};
83
+ const messageText = (message) => {
84
+ if (message.role === "system") return message.content;
85
+ return message.content.map((part) => {
86
+ if (part.type === "text" || part.type === "reasoning") return part.text;
87
+ return `[${part.type}]`;
88
+ }).join("\n").slice(0, 65536);
89
+ };
90
+ const asModelMessages = (snapshot) => snapshot.messages.map((entry) => ModelContextMessage.make({
91
+ role: entry.message.role,
92
+ content: messageText(entry.message),
93
+ sourceSequences: [entry.sequence]
94
+ }));
95
+ const validateModelView = (messages, transformId) => {
96
+ if (messages.length > MAX_CONTEXT_MESSAGES) return Effect.fail(ContextTransformError.make({
97
+ transformId,
98
+ message: `Transform produced ${messages.length} messages; maximum is ${MAX_CONTEXT_MESSAGES}`
99
+ }));
100
+ const bytes = messages.reduce((total, message) => total + utf8ByteLength(message.content), 0);
101
+ return bytes > MAX_CONTEXT_MESSAGE_BYTES ? Effect.fail(ContextTransformError.make({
102
+ transformId,
103
+ message: `Transform produced ${bytes} UTF-8 bytes; maximum is ${MAX_CONTEXT_MESSAGE_BYTES}`
104
+ })) : Effect.succeed(messages);
105
+ };
106
+ /** Apply transforms in declaration order, always restoring the original source snapshot. */
107
+ const prepareModelContext = (snapshot, transforms) => (transforms ?? []).reduce((messages, transform) => messages.pipe(Effect.flatMap(transform.apply), Effect.flatMap((transformed) => validateModelView(transformed, transform.id))), Effect.succeed(asModelMessages(snapshot))).pipe(Effect.map((messages) => PreparedModelContext.make({
108
+ source: snapshot,
109
+ messages,
110
+ compactions: []
111
+ })));
112
+ const exactSourceRange = (snapshot, coversFrom, coversThrough) => {
113
+ if (coversFrom > coversThrough || coversThrough >= snapshot.nextSequence) return Effect.fail(InvalidCompactionArtifact.make({ message: "Compaction artifact covers an invalid source range" }));
114
+ const selected = snapshot.messages.filter((message) => message.sequence >= coversFrom && message.sequence <= coversThrough);
115
+ const expectedCount = coversThrough - coversFrom + 1;
116
+ if (selected.length !== expectedCount || selected[0]?.sequence !== coversFrom || selected[selected.length - 1]?.sequence !== coversThrough) return Effect.fail(InvalidCompactionArtifact.make({ message: "Compaction source range is not contiguous in authoritative history" }));
117
+ return Effect.succeed(selected);
118
+ };
119
+ const utf8Bytes = (value) => {
120
+ const hex = Encoding.encodeHex(value);
121
+ const bytes = new Uint8Array(hex.length / 2);
122
+ for (let index = 0; index < bytes.length; index += 1) bytes[index] = Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16);
123
+ return bytes;
124
+ };
125
+ /** Compute a cryptographic digest over the canonical encoded exact source range. */
126
+ const digestCompactionSource = Effect.fn("digestCompactionSource")(function* (snapshot, coversFrom, coversThrough) {
127
+ const selected = yield* exactSourceRange(snapshot, coversFrom, coversThrough);
128
+ const encoded = yield* Schema.encodeEffect(Schema.Array(ThreadMessage))(selected).pipe(Effect.mapError((error) => CompactionDigestError.make({ message: `Could not encode compaction source: ${error.message}` })));
129
+ const digest = yield* (yield* Crypto.Crypto).digest("SHA-256", utf8Bytes(JSON.stringify(encoded))).pipe(Effect.mapError((error) => CompactionDigestError.make({ message: `Could not digest compaction source: ${error.message}` })));
130
+ return `sha256:${Encoding.encodeHex(digest)}`;
131
+ });
132
+ /**
133
+ * Replace only the model-view messages fully covered by the artifact range
134
+ * with its summary. The digest is recomputed against the exact source slice
135
+ * before the artifact can influence context. Messages that are not fully
136
+ * covered — including transform-synthesized messages without provenance and
137
+ * messages whose provenance only partially overlaps the range — remain
138
+ * visible, and the summary is inserted before the first message derived
139
+ * entirely from later source.
140
+ */
141
+ const applyCompaction = Effect.fn("applyCompaction")(function* (context, artifact) {
142
+ if (artifact.threadId !== context.source.threadId) return yield* InvalidCompactionArtifact.make({ message: "Compaction artifact belongs to another Thread" });
143
+ if ((yield* digestCompactionSource(context.source, artifact.coversFrom, artifact.coversThrough)) !== artifact.sourceDigest) return yield* InvalidCompactionArtifact.make({ message: "Compaction source digest does not match authoritative history" });
144
+ const provenanceInRange = (sequences) => sequences.length > 0 && sequences.every((sequence) => sequence >= artifact.coversFrom && sequence <= artifact.coversThrough);
145
+ if (!provenanceInRange(artifact.summary.sourceSequences) || artifact.retainedFacts.some((fact) => !provenanceInRange(fact.sourceSequences))) return yield* InvalidCompactionArtifact.make({ message: "Compaction summary or retained-fact provenance falls outside its covered range" });
146
+ if (context.compactions.length >= MAX_COMPACTIONS) return yield* ContextLimitExceeded.make({
147
+ limit: "compactions",
148
+ limitValue: MAX_COMPACTIONS,
149
+ observedValue: context.compactions.length + 1
150
+ });
151
+ const fullyCovered = (message) => message.sourceSequences.length > 0 && message.sourceSequences.every((sequence) => sequence >= artifact.coversFrom && sequence <= artifact.coversThrough);
152
+ const kept = context.messages.filter((message) => !fullyCovered(message));
153
+ const summaryAt = kept.findIndex((message) => message.sourceSequences.length > 0 && message.sourceSequences.every((sequence) => sequence > artifact.coversThrough));
154
+ const messages = yield* validateModelView(summaryAt === -1 ? [...kept, artifact.summary] : [
155
+ ...kept.slice(0, summaryAt),
156
+ artifact.summary,
157
+ ...kept.slice(summaryAt)
158
+ ], `compaction:${artifact.compactorVersion}`);
159
+ return PreparedModelContext.make({
160
+ source: context.source,
161
+ messages,
162
+ compactions: [...context.compactions, artifact]
163
+ });
164
+ });
165
+ //#endregion
166
+ export { CompactionArtifact, CompactionDigestError, ContextLimitExceeded, ContextTransformError, InvalidCompactionArtifact, ModelContextMessage, PreparedModelContext, RetainedFact, applyCompaction, digestCompactionSource, prepareModelContext, ModelContext_exports as t };
167
+
168
+ //# sourceMappingURL=ModelContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelContext.mjs","names":["ThreadSnapshot"],"sources":["../../src/capabilities/ModelContext.ts"],"sourcesContent":["import { Crypto, Effect, Encoding, Schema } from \"effect\";\nimport type { Prompt } from \"effect/unstable/ai\";\n\nimport { ThreadId } from \"../core/Identifiers.ts\";\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { ThreadMessage, Thread as ThreadSnapshot, ThreadText } from \"../core/Thread.ts\";\n\nconst MAX_CONTEXT_MESSAGES = 1_024;\nconst MAX_CONTEXT_MESSAGE_BYTES = 4 * 1024 * 1024;\nconst MAX_SOURCE_SEQUENCES = 1_024;\nconst MAX_RETAINED_FACTS = 256;\nconst MAX_RETAINED_FACT_BYTES = 1024 * 1024;\nconst MAX_COMPACTIONS = 16;\n\nconst SourceSequences = Schema.Array(Schema.Natural).check(\n Schema.isMaxLength(MAX_SOURCE_SEQUENCES),\n);\n\n/** A model-context message derived from, but never replacing, source history. */\nexport class ModelContextMessage extends Schema.Class<ModelContextMessage>(\n \"@effect-agent/capabilities/ModelContextMessage\",\n)({\n role: Schema.Literals([\"system\", \"user\", \"assistant\", \"tool\"]),\n content: ThreadText,\n sourceSequences: SourceSequences,\n}) {}\n\n/** A fact retained explicitly by compaction, independent of the generated prose summary. */\nexport class RetainedFact extends Schema.Class<RetainedFact>(\n \"@effect-agent/capabilities/RetainedFact\",\n)({\n fact: Schema.String.check(Schema.isMaxLength(4 * 1024)),\n sourceSequences: SourceSequences,\n}) {}\n\nconst ModelContextMessages = Schema.Array(ModelContextMessage)\n .check(Schema.isMaxLength(MAX_CONTEXT_MESSAGES))\n .pipe(\n Schema.refine(\n (messages): messages is ReadonlyArray<ModelContextMessage> =>\n messages.reduce((total, message) => total + utf8ByteLength(message.content), 0) <=\n MAX_CONTEXT_MESSAGE_BYTES,\n { expected: `model context totaling at most ${MAX_CONTEXT_MESSAGE_BYTES} UTF-8 bytes` },\n ),\n );\n\nconst RetainedFacts = Schema.Array(RetainedFact)\n .check(Schema.isMaxLength(MAX_RETAINED_FACTS))\n .pipe(\n Schema.refine(\n (facts): facts is ReadonlyArray<RetainedFact> =>\n facts.reduce((total, retained) => total + utf8ByteLength(retained.fact), 0) <=\n MAX_RETAINED_FACT_BYTES,\n { expected: `retained facts totaling at most ${MAX_RETAINED_FACT_BYTES} UTF-8 bytes` },\n ),\n );\n\nconst SourceDigest = Schema.String.check(Schema.isPattern(/^sha256:[a-f0-9]{64}$/));\n\n/** Versioned, replayable artifact that covers a prefix or middle range without deleting source. */\nexport class CompactionArtifact extends Schema.Class<CompactionArtifact>(\n \"@effect-agent/capabilities/CompactionArtifact\",\n)({\n version: Schema.Literal(1),\n threadId: ThreadId,\n coversFrom: Schema.Natural,\n coversThrough: Schema.Natural,\n summary: ModelContextMessage,\n retainedFacts: RetainedFacts,\n tokenEstimate: Schema.Natural,\n sourceDigest: SourceDigest,\n compactorVersion: Schema.NonEmptyString,\n}) {}\n\n/** Context exposed to a model, with source history kept intact for audit and reconstruction. */\nexport class PreparedModelContext extends Schema.Class<PreparedModelContext>(\n \"@effect-agent/capabilities/PreparedModelContext\",\n)({\n source: ThreadSnapshot,\n messages: ModelContextMessages,\n compactions: Schema.Array(CompactionArtifact).check(Schema.isMaxLength(MAX_COMPACTIONS)),\n}) {}\n\n/** Transform failure is named and bounded so model context preparation has a closed error channel. */\nexport class ContextTransformError extends Schema.TaggedError<ContextTransformError>()(\n \"ContextTransformError\",\n { transformId: Schema.NonEmptyString, message: Schema.String },\n) {}\n\n/** Source encoding or hashing failed before an artifact could be trusted. */\nexport class CompactionDigestError extends Schema.TaggedError<CompactionDigestError>()(\n \"CompactionDigestError\",\n { message: Schema.String },\n) {}\n\n/** Compaction artifacts that do not bind to the exact source range are rejected before use. */\nexport class InvalidCompactionArtifact extends Schema.TaggedError<InvalidCompactionArtifact>()(\n \"InvalidCompactionArtifact\",\n { message: Schema.String },\n) {}\n\n/** A transform or compaction exceeded the finite model-view collection bounds. */\nexport class ContextLimitExceeded extends Schema.TaggedError<ContextLimitExceeded>()(\n \"ContextLimitExceeded\",\n {\n limit: Schema.Literals([\"messages\", \"message-bytes\", \"compactions\"]),\n limitValue: Schema.Natural,\n observedValue: Schema.Natural,\n },\n) {}\n\n/**\n * Ordered context transform. It receives and returns only the model-visible\n * message view, making replacement of the authoritative source impossible.\n * Required services remain visible in prepareModelContext; expected failures\n * are translated by the transform into ContextTransformError.\n */\nexport interface ContextTransform<Requirements = never> {\n readonly id: string;\n readonly version: string;\n readonly apply: (\n messages: ReadonlyArray<ModelContextMessage>,\n ) => Effect.Effect<ReadonlyArray<ModelContextMessage>, ContextTransformError, Requirements>;\n}\n\nconst messageText = (message: Prompt.Message): string => {\n if (message.role === \"system\") return message.content;\n\n const content = message.content\n .map((part) => {\n if (part.type === \"text\" || part.type === \"reasoning\") return part.text;\n\n return `[${part.type}]`;\n })\n .join(\"\\n\");\n\n return content.slice(0, 64 * 1024);\n};\n\nconst asModelMessages = (snapshot: ThreadSnapshot): ReadonlyArray<ModelContextMessage> =>\n snapshot.messages.map((entry) =>\n ModelContextMessage.make({\n role: entry.message.role,\n content: messageText(entry.message),\n sourceSequences: [entry.sequence],\n }),\n );\n\nconst validateModelView = (\n messages: ReadonlyArray<ModelContextMessage>,\n transformId: string,\n): Effect.Effect<ReadonlyArray<ModelContextMessage>, ContextTransformError> => {\n if (messages.length > MAX_CONTEXT_MESSAGES) {\n return Effect.fail(\n ContextTransformError.make({\n transformId,\n message: `Transform produced ${messages.length} messages; maximum is ${MAX_CONTEXT_MESSAGES}`,\n }),\n );\n }\n const bytes = messages.reduce((total, message) => total + utf8ByteLength(message.content), 0);\n\n return bytes > MAX_CONTEXT_MESSAGE_BYTES\n ? Effect.fail(\n ContextTransformError.make({\n transformId,\n message: `Transform produced ${bytes} UTF-8 bytes; maximum is ${MAX_CONTEXT_MESSAGE_BYTES}`,\n }),\n )\n : Effect.succeed(messages);\n};\n\n/** Apply transforms in declaration order, always restoring the original source snapshot. */\nexport const prepareModelContext = <\n const Requirements extends ReadonlyArray<unknown> = readonly [],\n>(\n snapshot: ThreadSnapshot,\n transforms?: { readonly [Index in keyof Requirements]: ContextTransform<Requirements[Index]> },\n): Effect.Effect<PreparedModelContext, ContextTransformError, Requirements[number]> =>\n (transforms ?? [])\n .reduce<\n Effect.Effect<ReadonlyArray<ModelContextMessage>, ContextTransformError, Requirements[number]>\n >(\n (messages, transform) =>\n messages.pipe(\n Effect.flatMap(transform.apply),\n Effect.flatMap((transformed) => validateModelView(transformed, transform.id)),\n ),\n Effect.succeed(asModelMessages(snapshot)),\n )\n .pipe(\n Effect.map((messages) =>\n PreparedModelContext.make({\n source: snapshot,\n messages,\n compactions: [],\n }),\n ),\n );\n\nconst exactSourceRange = (\n snapshot: ThreadSnapshot,\n coversFrom: number,\n coversThrough: number,\n): Effect.Effect<ReadonlyArray<ThreadMessage>, InvalidCompactionArtifact> => {\n if (coversFrom > coversThrough || coversThrough >= snapshot.nextSequence) {\n return Effect.fail(\n InvalidCompactionArtifact.make({\n message: \"Compaction artifact covers an invalid source range\",\n }),\n );\n }\n\n const selected = snapshot.messages.filter(\n (message) => message.sequence >= coversFrom && message.sequence <= coversThrough,\n );\n\n const expectedCount = coversThrough - coversFrom + 1;\n\n if (\n selected.length !== expectedCount ||\n selected[0]?.sequence !== coversFrom ||\n selected[selected.length - 1]?.sequence !== coversThrough\n ) {\n return Effect.fail(\n InvalidCompactionArtifact.make({\n message: \"Compaction source range is not contiguous in authoritative history\",\n }),\n );\n }\n\n return Effect.succeed(selected);\n};\n\nconst utf8Bytes = (value: string): Uint8Array => {\n const hex = Encoding.encodeHex(value);\n const bytes = new Uint8Array(hex.length / 2);\n\n for (let index = 0; index < bytes.length; index += 1) {\n bytes[index] = Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16);\n }\n\n return bytes;\n};\n\n/** Compute a cryptographic digest over the canonical encoded exact source range. */\nexport const digestCompactionSource = Effect.fn(\"digestCompactionSource\")(function* (\n snapshot: ThreadSnapshot,\n coversFrom: number,\n coversThrough: number,\n) {\n const selected = yield* exactSourceRange(snapshot, coversFrom, coversThrough);\n\n const encoded = yield* Schema.encodeEffect(Schema.Array(ThreadMessage))(selected).pipe(\n Effect.mapError((error) =>\n CompactionDigestError.make({\n message: `Could not encode compaction source: ${error.message}`,\n }),\n ),\n );\n\n const crypto = yield* Crypto.Crypto;\n\n const digest = yield* crypto.digest(\"SHA-256\", utf8Bytes(JSON.stringify(encoded))).pipe(\n Effect.mapError((error) =>\n CompactionDigestError.make({\n message: `Could not digest compaction source: ${error.message}`,\n }),\n ),\n );\n\n return `sha256:${Encoding.encodeHex(digest)}`;\n});\n\n/**\n * Replace only the model-view messages fully covered by the artifact range\n * with its summary. The digest is recomputed against the exact source slice\n * before the artifact can influence context. Messages that are not fully\n * covered — including transform-synthesized messages without provenance and\n * messages whose provenance only partially overlaps the range — remain\n * visible, and the summary is inserted before the first message derived\n * entirely from later source.\n */\nexport const applyCompaction = Effect.fn(\"applyCompaction\")(function* (\n context: PreparedModelContext,\n artifact: CompactionArtifact,\n) {\n if (artifact.threadId !== context.source.threadId) {\n return yield* InvalidCompactionArtifact.make({\n message: \"Compaction artifact belongs to another Thread\",\n });\n }\n\n const actualDigest = yield* digestCompactionSource(\n context.source,\n artifact.coversFrom,\n artifact.coversThrough,\n );\n\n if (actualDigest !== artifact.sourceDigest) {\n return yield* InvalidCompactionArtifact.make({\n message: \"Compaction source digest does not match authoritative history\",\n });\n }\n\n const provenanceInRange = (sequences: ReadonlyArray<number>): boolean =>\n sequences.length > 0 &&\n sequences.every(\n (sequence) => sequence >= artifact.coversFrom && sequence <= artifact.coversThrough,\n );\n\n if (\n !provenanceInRange(artifact.summary.sourceSequences) ||\n artifact.retainedFacts.some((fact) => !provenanceInRange(fact.sourceSequences))\n ) {\n return yield* InvalidCompactionArtifact.make({\n message: \"Compaction summary or retained-fact provenance falls outside its covered range\",\n });\n }\n if (context.compactions.length >= MAX_COMPACTIONS) {\n return yield* ContextLimitExceeded.make({\n limit: \"compactions\",\n limitValue: MAX_COMPACTIONS,\n observedValue: context.compactions.length + 1,\n });\n }\n\n const fullyCovered = (message: ModelContextMessage): boolean =>\n message.sourceSequences.length > 0 &&\n message.sourceSequences.every(\n (sequence) => sequence >= artifact.coversFrom && sequence <= artifact.coversThrough,\n );\n\n const kept = context.messages.filter((message) => !fullyCovered(message));\n\n const summaryAt = kept.findIndex(\n (message) =>\n message.sourceSequences.length > 0 &&\n message.sourceSequences.every((sequence) => sequence > artifact.coversThrough),\n );\n\n const messages = yield* validateModelView(\n summaryAt === -1\n ? [...kept, artifact.summary]\n : [...kept.slice(0, summaryAt), artifact.summary, ...kept.slice(summaryAt)],\n `compaction:${artifact.compactorVersion}`,\n );\n\n return PreparedModelContext.make({\n source: context.source,\n messages,\n compactions: [...context.compactions, artifact],\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAOA,MAAM,uBAAuB;AAC7B,MAAM,4BAA4B;AAClC,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AAC3B,MAAM,0BAA0B;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