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,159 @@
1
+ import { LedgerCapabilities } from "./SubmissionLedger.mjs";
2
+ import { DurableRuntimeFailpointLocation } from "./DurableFailpoint.mjs";
3
+ import { n as safeUnknownString, t as inspectForeignDiagnostic } from "../foreign-diagnostic-DBQ1XHKh.mjs";
4
+ import { submissionLedgerConformanceCases } from "./SubmissionLedgerConformance.mjs";
5
+ import { threadStoreConformanceCases } from "./ThreadStoreConformance.mjs";
6
+ import { Cause, Effect, Exit, Option, Schema } from "effect";
7
+ //#region src/durable/Certification.ts
8
+ const BoundedCertificationDetail = Schema.String.check(Schema.isMaxLength(4096));
9
+ /**
10
+ * Adapter self-description carried by a certificate. `durability` is read from the candidate
11
+ * ledger's `capabilities` — the adapter's honest claim (persistence.md), never inferred by the
12
+ * certification runner.
13
+ */
14
+ var CertifiedAdapterIdentity = class extends Schema.Class("@effect-agent/thread/CertifiedAdapterIdentity")({
15
+ /** Workspace/package name of the adapter pair under certification. */
16
+ name: Schema.NonEmptyString.check(Schema.isMaxLength(256)),
17
+ version: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),
18
+ durability: LedgerCapabilities.fields.durability
19
+ }) {};
20
+ /** Which shared suite one Tier-1 (or lever-driven Tier-3) case belongs to. */
21
+ const CertificationSuite = Schema.Literals([
22
+ "submission-ledger",
23
+ "thread-store",
24
+ "real-loss"
25
+ ]);
26
+ /** One executed certification case: a conformance contract case or a Tier-3 lever row. */
27
+ var CertificationCaseResult = class extends Schema.Class("@effect-agent/thread/CertificationCaseResult")({
28
+ suite: CertificationSuite,
29
+ name: Schema.NonEmptyString.check(Schema.isMaxLength(512)),
30
+ status: Schema.Literals(["passed", "failed"]),
31
+ detail: Schema.optionalKey(BoundedCertificationDetail)
32
+ }) {};
33
+ /**
34
+ * The six Tier-2 scenario shapes: each reached coordinator fault boundary is armed once
35
+ * per shape. Locations outside a shape's path share its verified clean run.
36
+ */
37
+ const CertificationScenario = Schema.Literals([
38
+ "plain",
39
+ "uncertain-tool",
40
+ "durable-steps",
41
+ "approval",
42
+ "join",
43
+ "delegation"
44
+ ]);
45
+ /**
46
+ * Outcome of one Tier-2 sweep cell:
47
+ *
48
+ * - `converged` — the armed fault fired once, recovery classified the state, and the re-drive
49
+ * converged to verified invariants;
50
+ * - `not-triggered` — the location was not reached with that fault armed, or was absent from
51
+ * the scenario's verified clean path (shared across such locations). Never fault coverage;
52
+ * - `failed` — anything else.
53
+ */
54
+ const CertificationSweepStatus = Schema.Literals([
55
+ "converged",
56
+ "not-triggered",
57
+ "failed"
58
+ ]);
59
+ /** One Tier-2 scenario/location result, including locations outside the verified path. */
60
+ var CertificationSweepResult = class extends Schema.Class("@effect-agent/thread/CertificationSweepResult")({
61
+ scenario: CertificationScenario,
62
+ location: DurableRuntimeFailpointLocation,
63
+ /** The armed fault actually fired (one-shot) somewhere in the cell's drive or re-drive. */
64
+ failpointFired: Schema.Boolean,
65
+ status: CertificationSweepStatus,
66
+ /**
67
+ * Every lane's digest chain recomputed from `EMPTY_TAIL_DIGEST` and matched the exported
68
+ * tail — fully discharged here because the runner captures per-batch producer identity at
69
+ * append time (the port-only admin `verify` reports this check `skipped` instead).
70
+ * Unreached locations may share the scenario's clean-run verification.
71
+ */
72
+ digestChainVerified: Schema.Boolean,
73
+ detail: Schema.optionalKey(BoundedCertificationDetail)
74
+ }) {};
75
+ /**
76
+ * How the real-loss tier was discharged. Tier 3 is never silently claimed: an adapter either
77
+ * exercised a real loss lever in this run (`exercised`), cites committed real-loss evidence
78
+ * (`recorded-evidence`), honestly records that nothing exercised it (`not-exercised`), or is a
79
+ * non-durable reference adapter with no real loss to exercise (`not-applicable`).
80
+ */
81
+ const CertificationTierThreeStatus = Schema.Literals([
82
+ "exercised",
83
+ "recorded-evidence",
84
+ "not-exercised",
85
+ "not-applicable"
86
+ ]);
87
+ /** The Tier-3 (real loss lever) section of a certificate. */
88
+ var CertificationTierThreeReport = class extends Schema.Class("@effect-agent/thread/CertificationTierThreeReport")({
89
+ status: CertificationTierThreeStatus,
90
+ /** Cited real-loss suites. The runner does not execute or verify these references. */
91
+ evidence: Schema.Array(BoundedCertificationDetail),
92
+ /** Rows executed by a supplied crash lever in THIS run (`suite: "real-loss"`). */
93
+ cases: Schema.Array(CertificationCaseResult),
94
+ detail: Schema.optionalKey(BoundedCertificationDetail)
95
+ }) {};
96
+ /**
97
+ * The Schema-encoded certification report (plan §1): Tier 1 = the two shared port contract
98
+ * suites verbatim; Tier 2 = the coordinator failpoint convergence sweep; Tier 3 = the real
99
+ * loss lever record. `ok` is true exactly when every EXECUTED check passed — honest scope
100
+ * statements (`not-triggered`, `recorded-evidence`, `not-exercised`, `not-applicable`) never
101
+ * count as failures and never count as silent coverage. `fullyCertified` additionally requires
102
+ * a durable adapter and passing real-loss cases executed in this run. Citations alone do not
103
+ * certify recovery. A non-durable adapter can pass conformance but is never fully certified.
104
+ * The semantic assertions live in the runner tests.
105
+ */
106
+ var CertificationReport = class extends Schema.Class("@effect-agent/thread/CertificationReport")({
107
+ format: Schema.Literal("effect-agent/certification@2"),
108
+ adapter: CertifiedAdapterIdentity,
109
+ generatedAt: Schema.DateTimeUtcFromString,
110
+ tier1: Schema.Array(CertificationCaseResult),
111
+ tier2: Schema.Array(CertificationSweepResult),
112
+ tier3: CertificationTierThreeReport,
113
+ ok: Schema.Boolean,
114
+ fullyCertified: Schema.Boolean
115
+ }) {};
116
+ /** Bounded operator-readable rendering of one failure Cause for a certification detail. */
117
+ const causeDetail = (cause) => {
118
+ const failure = Cause.findErrorOption(cause);
119
+ if (Option.isSome(failure)) {
120
+ const diagnostic = inspectForeignDiagnostic(failure.value);
121
+ if (diagnostic.tag !== void 0 || diagnostic.message !== void 0) return `${diagnostic.tag ?? "Error"}${diagnostic.message === void 0 ? "" : `: ${diagnostic.message}`}`.slice(0, 4096);
122
+ return safeUnknownString(failure.value, "Unknown foreign failure").slice(0, 4096);
123
+ }
124
+ return `defect: ${safeUnknownString(cause, "Unknown defect")}`.slice(0, 4096);
125
+ };
126
+ const caseResult = (suite, name, exit) => Exit.isSuccess(exit) ? CertificationCaseResult.make({
127
+ suite,
128
+ name,
129
+ status: "passed"
130
+ }) : CertificationCaseResult.make({
131
+ suite,
132
+ name,
133
+ status: "failed",
134
+ detail: causeDetail(exit.cause)
135
+ });
136
+ /**
137
+ * Tier 1 — port contract (plan §1): run BOTH shared conformance case arrays verbatim against
138
+ * the provided candidate adapters and fold every case into a typed result. Case failures are
139
+ * captured per-case (never short-circuiting the sweep), so a certificate always reports the
140
+ * complete contract surface. Requires the candidate `SubmissionLedger` and `ThreadStore`
141
+ * plus `Crypto.Crypto`, and must run under a TestClock (the ledger cases drive lease expiry
142
+ * through virtual time).
143
+ */
144
+ const certifyPorts = Effect.fn("Thread.certifyPorts")(function* () {
145
+ const results = [];
146
+ for (const contractCase of submissionLedgerConformanceCases) {
147
+ const exit = yield* Effect.exit(contractCase.run);
148
+ results.push(caseResult("submission-ledger", contractCase.name, exit));
149
+ }
150
+ for (const contractCase of threadStoreConformanceCases) {
151
+ const exit = yield* Effect.exit(contractCase.run);
152
+ results.push(caseResult("thread-store", contractCase.name, exit));
153
+ }
154
+ return results;
155
+ });
156
+ //#endregion
157
+ export { CertificationCaseResult, CertificationReport, CertificationScenario, CertificationSuite, CertificationSweepResult, CertificationSweepStatus, CertificationTierThreeReport, CertificationTierThreeStatus, CertifiedAdapterIdentity, certifyPorts };
158
+
159
+ //# sourceMappingURL=Certification.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Certification.mjs","names":[],"sources":["../../src/durable/Certification.ts"],"sourcesContent":["import type { Crypto } from \"effect\";\nimport { Cause, Effect, Exit, Option, Schema } from \"effect\";\n\nimport { DurableRuntimeFailpointLocation } from \"./DurableFailpoint.ts\";\nimport { inspectForeignDiagnostic, safeUnknownString } from \"./internal/foreign-diagnostic.ts\";\nimport type { SubmissionLedger } from \"./SubmissionLedger.ts\";\nimport { LedgerCapabilities } from \"./SubmissionLedger.ts\";\nimport { submissionLedgerConformanceCases } from \"./SubmissionLedgerConformance.ts\";\nimport type { ThreadStore } from \"./ThreadStore.ts\";\nimport { threadStoreConformanceCases } from \"./ThreadStoreConformance.ts\";\n\n// ---------------------------------------------------------------------------\n// Certification report vocabulary (WP2, plan §1)\n// ---------------------------------------------------------------------------\n\nconst BoundedCertificationDetail = Schema.String.check(Schema.isMaxLength(4_096));\n\n/**\n * Adapter self-description carried by a certificate. `durability` is read from the candidate\n * ledger's `capabilities` — the adapter's honest claim (persistence.md), never inferred by the\n * certification runner.\n */\nexport class CertifiedAdapterIdentity extends Schema.Class<CertifiedAdapterIdentity>(\n \"@effect-agent/thread/CertifiedAdapterIdentity\",\n)({\n /** Workspace/package name of the adapter pair under certification. */\n name: Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n version: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),\n durability: LedgerCapabilities.fields.durability,\n}) {}\n\n/** Which shared suite one Tier-1 (or lever-driven Tier-3) case belongs to. */\nexport const CertificationSuite = Schema.Literals([\n \"submission-ledger\",\n \"thread-store\",\n \"real-loss\",\n]);\n\nexport type CertificationSuite = typeof CertificationSuite.Type;\n\n/** One executed certification case: a conformance contract case or a Tier-3 lever row. */\nexport class CertificationCaseResult extends Schema.Class<CertificationCaseResult>(\n \"@effect-agent/thread/CertificationCaseResult\",\n)({\n suite: CertificationSuite,\n name: Schema.NonEmptyString.check(Schema.isMaxLength(512)),\n status: Schema.Literals([\"passed\", \"failed\"]),\n detail: Schema.optionalKey(BoundedCertificationDetail),\n}) {}\n\n/**\n * The six Tier-2 scenario shapes: each reached coordinator fault boundary is armed once\n * per shape. Locations outside a shape's path share its verified clean run.\n */\nexport const CertificationScenario = Schema.Literals([\n \"plain\",\n \"uncertain-tool\",\n \"durable-steps\",\n \"approval\",\n \"join\",\n \"delegation\",\n]);\n\nexport type CertificationScenario = typeof CertificationScenario.Type;\n\n/**\n * Outcome of one Tier-2 sweep cell:\n *\n * - `converged` — the armed fault fired once, recovery classified the state, and the re-drive\n * converged to verified invariants;\n * - `not-triggered` — the location was not reached with that fault armed, or was absent from\n * the scenario's verified clean path (shared across such locations). Never fault coverage;\n * - `failed` — anything else.\n */\nexport const CertificationSweepStatus = Schema.Literals([\"converged\", \"not-triggered\", \"failed\"]);\nexport type CertificationSweepStatus = typeof CertificationSweepStatus.Type;\n\n/** One Tier-2 scenario/location result, including locations outside the verified path. */\nexport class CertificationSweepResult extends Schema.Class<CertificationSweepResult>(\n \"@effect-agent/thread/CertificationSweepResult\",\n)({\n scenario: CertificationScenario,\n location: DurableRuntimeFailpointLocation,\n /** The armed fault actually fired (one-shot) somewhere in the cell's drive or re-drive. */\n failpointFired: Schema.Boolean,\n status: CertificationSweepStatus,\n /**\n * Every lane's digest chain recomputed from `EMPTY_TAIL_DIGEST` and matched the exported\n * tail — fully discharged here because the runner captures per-batch producer identity at\n * append time (the port-only admin `verify` reports this check `skipped` instead).\n * Unreached locations may share the scenario's clean-run verification.\n */\n digestChainVerified: Schema.Boolean,\n detail: Schema.optionalKey(BoundedCertificationDetail),\n}) {}\n\n/**\n * How the real-loss tier was discharged. Tier 3 is never silently claimed: an adapter either\n * exercised a real loss lever in this run (`exercised`), cites committed real-loss evidence\n * (`recorded-evidence`), honestly records that nothing exercised it (`not-exercised`), or is a\n * non-durable reference adapter with no real loss to exercise (`not-applicable`).\n */\nexport const CertificationTierThreeStatus = Schema.Literals([\n \"exercised\",\n \"recorded-evidence\",\n \"not-exercised\",\n \"not-applicable\",\n]);\n\nexport type CertificationTierThreeStatus = typeof CertificationTierThreeStatus.Type;\n\n/** The Tier-3 (real loss lever) section of a certificate. */\nexport class CertificationTierThreeReport extends Schema.Class<CertificationTierThreeReport>(\n \"@effect-agent/thread/CertificationTierThreeReport\",\n)({\n status: CertificationTierThreeStatus,\n /** Cited real-loss suites. The runner does not execute or verify these references. */\n evidence: Schema.Array(BoundedCertificationDetail),\n /** Rows executed by a supplied crash lever in THIS run (`suite: \"real-loss\"`). */\n cases: Schema.Array(CertificationCaseResult),\n detail: Schema.optionalKey(BoundedCertificationDetail),\n}) {}\n\n/**\n * The Schema-encoded certification report (plan §1): Tier 1 = the two shared port contract\n * suites verbatim; Tier 2 = the coordinator failpoint convergence sweep; Tier 3 = the real\n * loss lever record. `ok` is true exactly when every EXECUTED check passed — honest scope\n * statements (`not-triggered`, `recorded-evidence`, `not-exercised`, `not-applicable`) never\n * count as failures and never count as silent coverage. `fullyCertified` additionally requires\n * a durable adapter and passing real-loss cases executed in this run. Citations alone do not\n * certify recovery. A non-durable adapter can pass conformance but is never fully certified.\n * The semantic assertions live in the runner tests.\n */\nexport class CertificationReport extends Schema.Class<CertificationReport>(\n \"@effect-agent/thread/CertificationReport\",\n)({\n format: Schema.Literal(\"effect-agent/certification@2\"),\n adapter: CertifiedAdapterIdentity,\n generatedAt: Schema.DateTimeUtcFromString,\n tier1: Schema.Array(CertificationCaseResult),\n tier2: Schema.Array(CertificationSweepResult),\n tier3: CertificationTierThreeReport,\n ok: Schema.Boolean,\n fullyCertified: Schema.Boolean,\n}) {}\n\n/** Bounded operator-readable rendering of one failure Cause for a certification detail. */\nconst causeDetail = (cause: Cause.Cause<unknown>): string => {\n const failure = Cause.findErrorOption(cause);\n\n if (Option.isSome(failure)) {\n const diagnostic = inspectForeignDiagnostic(failure.value);\n\n if (diagnostic.tag !== undefined || diagnostic.message !== undefined) {\n const tag = diagnostic.tag ?? \"Error\";\n\n return `${tag}${diagnostic.message === undefined ? \"\" : `: ${diagnostic.message}`}`.slice(\n 0,\n 4_096,\n );\n }\n\n return safeUnknownString(failure.value, \"Unknown foreign failure\").slice(0, 4_096);\n }\n\n return `defect: ${safeUnknownString(cause, \"Unknown defect\")}`.slice(0, 4_096);\n};\n\nconst caseResult = <A, E>(\n suite: CertificationSuite,\n name: string,\n exit: Exit.Exit<A, E>,\n): CertificationCaseResult =>\n Exit.isSuccess(exit)\n ? CertificationCaseResult.make({ suite, name, status: \"passed\" })\n : CertificationCaseResult.make({\n suite,\n name,\n status: \"failed\",\n detail: causeDetail(exit.cause),\n });\n\n/**\n * Tier 1 — port contract (plan §1): run BOTH shared conformance case arrays verbatim against\n * the provided candidate adapters and fold every case into a typed result. Case failures are\n * captured per-case (never short-circuiting the sweep), so a certificate always reports the\n * complete contract surface. Requires the candidate `SubmissionLedger` and `ThreadStore`\n * plus `Crypto.Crypto`, and must run under a TestClock (the ledger cases drive lease expiry\n * through virtual time).\n */\nexport const certifyPorts = Effect.fn(\"Thread.certifyPorts\")(function* (): Effect.fn.Return<\n ReadonlyArray<CertificationCaseResult>,\n never,\n SubmissionLedger | ThreadStore | Crypto.Crypto\n> {\n const results: Array<CertificationCaseResult> = [];\n\n for (const contractCase of submissionLedgerConformanceCases) {\n const exit = yield* Effect.exit(contractCase.run);\n\n results.push(caseResult(\"submission-ledger\", contractCase.name, exit));\n }\n for (const contractCase of threadStoreConformanceCases) {\n const exit = yield* Effect.exit(contractCase.run);\n\n results.push(caseResult(\"thread-store\", contractCase.name, exit));\n }\n\n return results;\n});\n"],"mappings":";;;;;;;AAeA,MAAM,6BAA6B,OAAO,OAAO,MAAM,OAAO,YAAY,IAAK,CAAC;;;;;;AAOhF,IAAa,2BAAb,cAA8C,OAAO,MACnD,+CACF,CAAC,CAAC;;CAEA,MAAM,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;CACzD,SAAS,OAAO,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,GAAG,CAAC,CAAC;CACxE,YAAY,mBAAmB,OAAO;AACxC,CAAC,CAAC,CAAC,CAAC;;AAGJ,MAAa,qBAAqB,OAAO,SAAS;CAChD;CACA;CACA;AACF,CAAC;;AAKD,IAAa,0BAAb,cAA6C,OAAO,MAClD,8CACF,CAAC,CAAC;CACA,OAAO;CACP,MAAM,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;CACzD,QAAQ,OAAO,SAAS,CAAC,UAAU,QAAQ,CAAC;CAC5C,QAAQ,OAAO,YAAY,0BAA0B;AACvD,CAAC,CAAC,CAAC,CAAC;;;;;AAMJ,MAAa,wBAAwB,OAAO,SAAS;CACnD;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;;AAaD,MAAa,2BAA2B,OAAO,SAAS;CAAC;CAAa;CAAiB;AAAQ,CAAC;;AAIhG,IAAa,2BAAb,cAA8C,OAAO,MACnD,+CACF,CAAC,CAAC;CACA,UAAU;CACV,UAAU;;CAEV,gBAAgB,OAAO;CACvB,QAAQ;;;;;;;CAOR,qBAAqB,OAAO;CAC5B,QAAQ,OAAO,YAAY,0BAA0B;AACvD,CAAC,CAAC,CAAC,CAAC;;;;;;;AAQJ,MAAa,+BAA+B,OAAO,SAAS;C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A,MAAM,UAA0C,CAAC;CAEjD,KAAK,MAAM,gBAAgB,kCAAkC;EAC3D,MAAM,OAAO,OAAO,OAAO,KAAK,aAAa,GAAG;EAEhD,QAAQ,KAAK,WAAW,qBAAqB,aAAa,MAAM,IAAI,CAAC;CACvE;CACA,KAAK,MAAM,gBAAgB,6BAA6B;EACtD,MAAM,OAAO,OAAO,OAAO,KAAK,aAAa,GAAG;EAEhD,QAAQ,KAAK,WAAW,gBAAgB,aAAa,MAAM,IAAI,CAAC;CAClE;CAEA,OAAO;AACT,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { Ci as DigestError, O as PersistedJson, Sn as ThreadStore, dn as ThreadNotMaterialized, l as CanonicalRecordEnvelope, wn as ThreadStoreError } from "../Records-D88mgvyS.mjs";
2
+ import { ActivityProcessorKey, ActivityProcessorStore, ActivityStoreFailure, PreparedActivity } from "./ActivityStore.mjs";
3
+ import { Crypto, Effect, Schema, Scope } from "effect";
4
+ declare namespace CommittedActivity_d_exports {
5
+ export { ActivityPassLimits, ActivityPassResult, ActivityProcessingError, CommittedActivityProcessor, activityWorkId, processCommittedActivity };
6
+ }
7
+ declare const ActivityPassLimits_base: Schema.Class<ActivityPassLimits, Schema.Struct<{
8
+ readonly maxRecords: Schema.Int;
9
+ readonly pageSize: Schema.Int;
10
+ readonly timeoutMillis: Schema.Int;
11
+ readonly leaseMillis: Schema.Int;
12
+ }>, {}>;
13
+ export declare class ActivityPassLimits extends ActivityPassLimits_base {}
14
+ declare const ActivityProcessingError_base: Schema.Class<ActivityProcessingError, Schema.TaggedStruct<"ActivityProcessingError", {
15
+ readonly reason: Schema.Literals<readonly ["invalid-input", "noncontiguous", "timeout"]>;
16
+ readonly message: Schema.String;
17
+ }>, import("effect/Cause").YieldableError>;
18
+ export declare class ActivityProcessingError extends ActivityProcessingError_base {}
19
+ declare const ActivityPassResult_base: Schema.Class<ActivityPassResult, Schema.Struct<{
20
+ readonly key: typeof ActivityProcessorKey;
21
+ readonly capturedTail: Schema.brand<Schema.Natural, "@effect-agent/thread/CanonicalSequence">;
22
+ readonly throughSequence: Schema.brand<Schema.Natural, "@effect-agent/thread/CanonicalSequence">;
23
+ readonly processed: Schema.Natural;
24
+ readonly pendingRecords: Schema.Natural;
25
+ readonly startedAt: Schema.Finite;
26
+ readonly finishedAt: Schema.Finite;
27
+ }>, {}>;
28
+ export declare class ActivityPassResult extends ActivityPassResult_base {}
29
+ export interface CommittedActivityProcessor<E = never, R = never, EApply = never, RApply = never> {
30
+ readonly key: ActivityProcessorKey;
31
+ /** Unique to this worker lifetime; it is not canonical Thread ownership. */
32
+ readonly owner: string;
33
+ readonly limits: ActivityPassLimits;
34
+ /** Select eligibility and encode an application Schema; null can represent no output. */
35
+ readonly extract: (record: CanonicalRecordEnvelope) => Effect.Effect<PersistedJson, E, R>;
36
+ /**
37
+ * Must durably reconcile workId before returning, using atomic idempotency and conditional
38
+ * writes. This may run again after any lost acknowledgement. A stale invocation can finish
39
+ * only the already pinned output; it must not overwrite a later correction or withdrawal.
40
+ * Retain reconciliation evidence for the lifetime of pending work, including any supported
41
+ * backup/restore window. Returning before durable application would permit skipped output.
42
+ */
43
+ readonly apply: (work: PreparedActivity) => Effect.Effect<void, EApply, RApply>;
44
+ }
45
+ /** Stable work identity independent of worker claims, retry count, extraction, and clocks. */
46
+ export declare const activityWorkId: (key: ActivityProcessorKey, sequence: number & import("effect/Brand").Brand<"@effect-agent/thread/CanonicalSequence">) => Effect.Effect<string & import("effect/Brand").Brand<"@effect-agent/thread/Digest">, DigestError, Crypto.Crypto>;
47
+ /**
48
+ * Process one bounded committed prefix of one application-selected Thread. Nothing runs until
49
+ * invoked, and no daemon, global Thread directory, admission ledger, or engine checkpoint is
50
+ * involved. PersistentHistory makes a successful Run's batch visible together; durable Runs
51
+ * expose incremental committed records. The application decides what each record means.
52
+ *
53
+ * A durable pending output wins over a new extraction after restart. Apply finishes before
54
+ * progress advances, so separate output stores require durable idempotency. This does not
55
+ * promise exactly-once external side effects. Each callback owns a Scope; the finite pass has
56
+ * a timeout and a longer lease. Claim release has a separate 500ms deadline; failure leaves
57
+ * the bounded lease to expire.
58
+ */
59
+ export declare const processCommittedActivity: <E = never, R = never, EApply = never, RApply = never>(processor: CommittedActivityProcessor<E, R, EApply, RApply>) => Effect.Effect<ActivityPassResult, E | EApply | ActivityProcessingError | DigestError | ThreadNotMaterialized | ThreadStoreError | ActivityStoreFailure, ActivityProcessorStore | Crypto.Crypto | ThreadStore | Exclude<R, Scope.Scope> | Exclude<RApply, Scope.Scope>>;
60
+ //#endregion
61
+ export { CommittedActivity_d_exports as t };
62
+ //# sourceMappingURL=CommittedActivity.d.mts.map
@@ -0,0 +1,159 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ import { CanonicalRecordEnvelope, CanonicalSequence, PersistedJson, RecordEnvelope } from "./Records.mjs";
3
+ import { ActivityClaim, ActivityClaimRequest, ActivityProcessorKey, ActivityProcessorStore, PreparedActivity } from "./ActivityStore.mjs";
4
+ import { digestJson } from "./Digest.mjs";
5
+ import { ThreadRead, ThreadStore, ThreadTail, ThreadTailRequest } from "./ThreadStore.mjs";
6
+ import { Clock, Effect, Schema, Stream } from "effect";
7
+ //#region src/durable/CommittedActivity.ts
8
+ var CommittedActivity_exports = /* @__PURE__ */ __exportAll({
9
+ ActivityPassLimits: () => ActivityPassLimits,
10
+ ActivityPassResult: () => ActivityPassResult,
11
+ ActivityProcessingError: () => ActivityProcessingError,
12
+ activityWorkId: () => activityWorkId,
13
+ processCommittedActivity: () => processCommittedActivity
14
+ });
15
+ var ActivityPassLimits = class extends Schema.Class("@effect-agent/thread/ActivityPassLimits")({
16
+ maxRecords: Schema.Int.check(Schema.isBetween({
17
+ minimum: 1,
18
+ maximum: 4096
19
+ })),
20
+ pageSize: Schema.Int.check(Schema.isBetween({
21
+ minimum: 1,
22
+ maximum: 128
23
+ })),
24
+ timeoutMillis: Schema.Int.check(Schema.isBetween({
25
+ minimum: 1,
26
+ maximum: 3e5
27
+ })),
28
+ leaseMillis: ActivityClaimRequest.fields.leaseMillis
29
+ }) {};
30
+ var ActivityProcessingError = class extends Schema.TaggedError()("ActivityProcessingError", {
31
+ reason: Schema.Literals([
32
+ "invalid-input",
33
+ "noncontiguous",
34
+ "timeout"
35
+ ]),
36
+ message: Schema.String.check(Schema.isMaxLength(1024))
37
+ }) {};
38
+ var ActivityPassResult = class extends Schema.Class("@effect-agent/thread/ActivityPassResult")({
39
+ key: ActivityProcessorKey,
40
+ capturedTail: CanonicalSequence,
41
+ throughSequence: CanonicalSequence,
42
+ processed: Schema.Natural,
43
+ pendingRecords: Schema.Natural,
44
+ startedAt: Schema.Finite,
45
+ finishedAt: Schema.Finite
46
+ }) {};
47
+ const invalid = (message) => ActivityProcessingError.make({
48
+ reason: "invalid-input",
49
+ message
50
+ });
51
+ const contiguous = () => ActivityProcessingError.make({
52
+ reason: "noncontiguous",
53
+ message: "Committed activity does not match its captured Thread prefix or pinned record"
54
+ });
55
+ /** Stable work identity independent of worker claims, retry count, extraction, and clocks. */
56
+ const activityWorkId = Effect.fn("activityWorkId")(function* (key, sequence) {
57
+ return yield* digestJson([
58
+ "effect-agent/activity@1",
59
+ key.processorId,
60
+ key.processorVersion,
61
+ key.threadId,
62
+ sequence
63
+ ]);
64
+ });
65
+ /**
66
+ * Process one bounded committed prefix of one application-selected Thread. Nothing runs until
67
+ * invoked, and no daemon, global Thread directory, admission ledger, or engine checkpoint is
68
+ * involved. PersistentHistory makes a successful Run's batch visible together; durable Runs
69
+ * expose incremental committed records. The application decides what each record means.
70
+ *
71
+ * A durable pending output wins over a new extraction after restart. Apply finishes before
72
+ * progress advances, so separate output stores require durable idempotency. This does not
73
+ * promise exactly-once external side effects. Each callback owns a Scope; the finite pass has
74
+ * a timeout and a longer lease. Claim release has a separate 500ms deadline; failure leaves
75
+ * the bounded lease to expire.
76
+ */
77
+ const processCommittedActivity = Effect.fn("processCommittedActivity")(function* (processor) {
78
+ const key = yield* Schema.decodeEffect(ActivityProcessorKey)(processor.key).pipe(Effect.mapError(() => invalid("Invalid activity processor key")));
79
+ const limits = yield* Schema.decodeEffect(ActivityPassLimits)(processor.limits).pipe(Effect.mapError(() => invalid("Invalid activity pass limits")));
80
+ if (limits.leaseMillis < limits.timeoutMillis + 1e3) return yield* invalid("The activity lease must exceed the pass timeout by at least 1000ms");
81
+ const request = yield* ActivityClaimRequest.makeEffect({
82
+ key,
83
+ owner: processor.owner,
84
+ leaseMillis: limits.leaseMillis
85
+ }).pipe(Effect.mapError(() => invalid("Invalid activity worker identity")));
86
+ const progress = yield* ActivityProcessorStore;
87
+ const threads = yield* ThreadStore;
88
+ return yield* Effect.scoped(Effect.gen(function* () {
89
+ const acquired = yield* Effect.acquireRelease(progress.claim(request).pipe(Effect.interruptible), (claim) => progress.release(claim).pipe(Effect.interruptible, Effect.timeoutOption(500), Effect.ignore));
90
+ let claim = yield* Schema.decodeEffect(ActivityClaim)(acquired).pipe(Effect.mapError(() => invalid("Malformed activity claim")));
91
+ if (!Schema.toEquivalence(ActivityProcessorKey)(claim.key, key) || claim.owner !== request.owner) return yield* invalid("Activity claim identity does not match its request");
92
+ const startedAt = yield* Clock.currentTimeMillis;
93
+ const tail = yield* threads.inspectTail(ThreadTailRequest.make({ threadId: key.threadId })).pipe(Effect.flatMap((value) => Schema.decodeEffect(ThreadTail)(value).pipe(Effect.mapError(contiguous))));
94
+ if (tail.threadId !== key.threadId || tail.tailSequence < claim.throughSequence || claim.pending !== null && tail.tailSequence < claim.pending.sequence) return yield* contiguous();
95
+ const through = Math.min(tail.tailSequence, claim.throughSequence + limits.maxRecords);
96
+ let processed = 0;
97
+ while (claim.throughSequence < through) {
98
+ const limit = Math.min(limits.pageSize, through - claim.throughSequence);
99
+ const page = yield* threads.read(ThreadRead.make({
100
+ threadId: key.threadId,
101
+ afterSequence: claim.throughSequence,
102
+ limit
103
+ })).pipe(Stream.take(limit + 1), Stream.runCollect);
104
+ if (page.length !== limit) return yield* contiguous();
105
+ for (const rawRecord of page) {
106
+ const record = yield* Schema.decodeEffect(Schema.toType(CanonicalRecordEnvelope))(rawRecord).pipe(Effect.mapError(contiguous));
107
+ if (record.threadId !== key.threadId || record.sequence !== claim.throughSequence + 1) return yield* contiguous();
108
+ const workId = yield* activityWorkId(key, record.sequence);
109
+ const encodedRecord = yield* Schema.encodeEffect(RecordEnvelope)(record.record).pipe(Effect.mapError(contiguous));
110
+ const recordDigest = yield* digestJson(encodedRecord);
111
+ let work = claim.pending;
112
+ if (work === null) {
113
+ const output = yield* Effect.scoped(processor.extract(record)).pipe(Effect.flatMap((value) => Schema.decodeEffect(PersistedJson)(value).pipe(Effect.mapError(() => invalid("Malformed activity output")))));
114
+ work = yield* progress.prepare({
115
+ claim,
116
+ work: PreparedActivity.make({
117
+ version: 1,
118
+ key,
119
+ sequence: record.sequence,
120
+ workId,
121
+ recordId: record.record.recordId,
122
+ recordDigest,
123
+ output
124
+ })
125
+ });
126
+ }
127
+ const prepared = yield* Schema.decodeEffect(PreparedActivity)(work).pipe(Effect.mapError(() => invalid("Malformed prepared activity")));
128
+ if (!Schema.toEquivalence(ActivityProcessorKey)(prepared.key, key) || prepared.sequence !== record.sequence || prepared.workId !== workId || prepared.recordId !== record.record.recordId || prepared.recordDigest !== recordDigest) return yield* contiguous();
129
+ yield* Effect.scoped(processor.apply(prepared));
130
+ const next = yield* progress.advance({
131
+ claim,
132
+ workId
133
+ }).pipe(Effect.flatMap((value) => Schema.decodeEffect(ActivityClaim)(value).pipe(Effect.mapError(() => invalid("Malformed activity progress")))));
134
+ if (!Schema.toEquivalence(ActivityProcessorKey)(next.key, key) || next.owner !== claim.owner || next.epoch !== claim.epoch || next.throughSequence !== record.sequence || next.pending !== null) return yield* invalid("Activity progress advanced outside the claimed record");
135
+ claim = next;
136
+ processed += 1;
137
+ }
138
+ }
139
+ return ActivityPassResult.make({
140
+ key,
141
+ capturedTail: tail.tailSequence,
142
+ throughSequence: claim.throughSequence,
143
+ processed,
144
+ pendingRecords: tail.tailSequence - claim.throughSequence,
145
+ startedAt,
146
+ finishedAt: yield* Clock.currentTimeMillis
147
+ });
148
+ })).pipe(Effect.timeoutOrElse({
149
+ duration: limits.timeoutMillis,
150
+ orElse: () => Effect.fail(ActivityProcessingError.make({
151
+ reason: "timeout",
152
+ message: "Activity pass timed out"
153
+ }))
154
+ }));
155
+ });
156
+ //#endregion
157
+ export { ActivityPassLimits, ActivityPassResult, ActivityProcessingError, activityWorkId, processCommittedActivity, CommittedActivity_exports as t };
158
+
159
+ //# sourceMappingURL=CommittedActivity.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommittedActivity.mjs","names":[],"sources":["../../src/durable/CommittedActivity.ts"],"sourcesContent":["import { Clock, Effect, Schema, Stream, type Crypto, type Scope } from \"effect\";\n\nimport {\n ActivityClaim,\n ActivityClaimRequest,\n ActivityProcessorKey,\n ActivityProcessorStore,\n PreparedActivity,\n type ActivityStoreFailure,\n} from \"./ActivityStore.ts\";\nimport { digestJson, type DigestError } from \"./Digest.ts\";\nimport {\n CanonicalRecordEnvelope,\n CanonicalSequence,\n PersistedJson,\n RecordEnvelope,\n} from \"./Records.ts\";\nimport {\n ThreadRead,\n ThreadStore,\n ThreadTail,\n ThreadTailRequest,\n type ThreadNotMaterialized,\n type ThreadStoreError,\n} from \"./ThreadStore.ts\";\n\nexport class ActivityPassLimits extends Schema.Class<ActivityPassLimits>(\n \"@effect-agent/thread/ActivityPassLimits\",\n)({\n maxRecords: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 4_096 })),\n pageSize: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 128 })),\n timeoutMillis: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 300_000 })),\n leaseMillis: ActivityClaimRequest.fields.leaseMillis,\n}) {}\n\nexport class ActivityProcessingError extends Schema.TaggedError<ActivityProcessingError>()(\n \"ActivityProcessingError\",\n {\n reason: Schema.Literals([\"invalid-input\", \"noncontiguous\", \"timeout\"]),\n message: Schema.String.check(Schema.isMaxLength(1_024)),\n },\n) {}\n\nexport class ActivityPassResult extends Schema.Class<ActivityPassResult>(\n \"@effect-agent/thread/ActivityPassResult\",\n)({\n key: ActivityProcessorKey,\n capturedTail: CanonicalSequence,\n throughSequence: CanonicalSequence,\n processed: Schema.Natural,\n pendingRecords: Schema.Natural,\n startedAt: Schema.Finite,\n finishedAt: Schema.Finite,\n}) {}\n\nexport interface CommittedActivityProcessor<E = never, R = never, EApply = never, RApply = never> {\n readonly key: ActivityProcessorKey;\n /** Unique to this worker lifetime; it is not canonical Thread ownership. */\n readonly owner: string;\n readonly limits: ActivityPassLimits;\n /** Select eligibility and encode an application Schema; null can represent no output. */\n readonly extract: (record: CanonicalRecordEnvelope) => Effect.Effect<PersistedJson, E, R>;\n /**\n * Must durably reconcile workId before returning, using atomic idempotency and conditional\n * writes. This may run again after any lost acknowledgement. A stale invocation can finish\n * only the already pinned output; it must not overwrite a later correction or withdrawal.\n * Retain reconciliation evidence for the lifetime of pending work, including any supported\n * backup/restore window. Returning before durable application would permit skipped output.\n */\n readonly apply: (work: PreparedActivity) => Effect.Effect<void, EApply, RApply>;\n}\n\nconst invalid = (message: string) =>\n ActivityProcessingError.make({ reason: \"invalid-input\", message });\n\nconst contiguous = () =>\n ActivityProcessingError.make({\n reason: \"noncontiguous\",\n message: \"Committed activity does not match its captured Thread prefix or pinned record\",\n });\n\n/** Stable work identity independent of worker claims, retry count, extraction, and clocks. */\nexport const activityWorkId = Effect.fn(\"activityWorkId\")(function* (\n key: ActivityProcessorKey,\n sequence: CanonicalSequence,\n) {\n return yield* digestJson([\n \"effect-agent/activity@1\",\n key.processorId,\n key.processorVersion,\n key.threadId,\n sequence,\n ]);\n});\n\n/**\n * Process one bounded committed prefix of one application-selected Thread. Nothing runs until\n * invoked, and no daemon, global Thread directory, admission ledger, or engine checkpoint is\n * involved. PersistentHistory makes a successful Run's batch visible together; durable Runs\n * expose incremental committed records. The application decides what each record means.\n *\n * A durable pending output wins over a new extraction after restart. Apply finishes before\n * progress advances, so separate output stores require durable idempotency. This does not\n * promise exactly-once external side effects. Each callback owns a Scope; the finite pass has\n * a timeout and a longer lease. Claim release has a separate 500ms deadline; failure leaves\n * the bounded lease to expire.\n */\nexport const processCommittedActivity = Effect.fn(\"processCommittedActivity\")(function* <\n E = never,\n R = never,\n EApply = never,\n RApply = never,\n>(\n processor: CommittedActivityProcessor<E, R, EApply, RApply>,\n): Effect.fn.Return<\n ActivityPassResult,\n | E\n | EApply\n | ActivityStoreFailure\n | ActivityProcessingError\n | DigestError\n | ThreadStoreError\n | ThreadNotMaterialized,\n ActivityProcessorStore | ThreadStore | Crypto.Crypto | Exclude<R | RApply, Scope.Scope>\n> {\n const key = yield* Schema.decodeEffect(ActivityProcessorKey)(processor.key).pipe(\n Effect.mapError(() => invalid(\"Invalid activity processor key\")),\n );\n\n const limits = yield* Schema.decodeEffect(ActivityPassLimits)(processor.limits).pipe(\n Effect.mapError(() => invalid(\"Invalid activity pass limits\")),\n );\n\n if (limits.leaseMillis < limits.timeoutMillis + 1_000) {\n return yield* invalid(\"The activity lease must exceed the pass timeout by at least 1000ms\");\n }\n\n const request = yield* ActivityClaimRequest.makeEffect({\n key,\n owner: processor.owner,\n leaseMillis: limits.leaseMillis,\n }).pipe(Effect.mapError(() => invalid(\"Invalid activity worker identity\")));\n\n const progress = yield* ActivityProcessorStore;\n const threads = yield* ThreadStore;\n\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const acquired = yield* Effect.acquireRelease(\n progress.claim(request).pipe(Effect.interruptible),\n (claim) =>\n progress\n .release(claim)\n .pipe(Effect.interruptible, Effect.timeoutOption(500), Effect.ignore),\n );\n\n let claim = yield* Schema.decodeEffect(ActivityClaim)(acquired).pipe(\n Effect.mapError(() => invalid(\"Malformed activity claim\")),\n );\n\n if (\n !Schema.toEquivalence(ActivityProcessorKey)(claim.key, key) ||\n claim.owner !== request.owner\n )\n return yield* invalid(\"Activity claim identity does not match its request\");\n const startedAt = yield* Clock.currentTimeMillis;\n\n const tail = yield* threads\n .inspectTail(ThreadTailRequest.make({ threadId: key.threadId }))\n .pipe(\n Effect.flatMap((value) =>\n Schema.decodeEffect(ThreadTail)(value).pipe(Effect.mapError(contiguous)),\n ),\n );\n\n if (\n tail.threadId !== key.threadId ||\n tail.tailSequence < claim.throughSequence ||\n (claim.pending !== null && tail.tailSequence < claim.pending.sequence)\n ) {\n return yield* contiguous();\n }\n const through = Math.min(tail.tailSequence, claim.throughSequence + limits.maxRecords);\n let processed = 0;\n\n while (claim.throughSequence < through) {\n const limit = Math.min(limits.pageSize, through - claim.throughSequence);\n\n const page = yield* threads\n .read(\n ThreadRead.make({\n threadId: key.threadId,\n afterSequence: claim.throughSequence,\n limit,\n }),\n )\n .pipe(Stream.take(limit + 1), Stream.runCollect);\n\n if (page.length !== limit) return yield* contiguous();\n for (const rawRecord of page) {\n const record = yield* Schema.decodeEffect(Schema.toType(CanonicalRecordEnvelope))(\n rawRecord,\n ).pipe(Effect.mapError(contiguous));\n\n if (record.threadId !== key.threadId || record.sequence !== claim.throughSequence + 1) {\n return yield* contiguous();\n }\n const workId = yield* activityWorkId(key, record.sequence);\n\n const encodedRecord = yield* Schema.encodeEffect(RecordEnvelope)(record.record).pipe(\n Effect.mapError(contiguous),\n );\n\n const recordDigest = yield* digestJson(encodedRecord);\n let work = claim.pending;\n\n if (work === null) {\n const output = yield* Effect.scoped(processor.extract(record)).pipe(\n Effect.flatMap((value) =>\n Schema.decodeEffect(PersistedJson)(value).pipe(\n Effect.mapError(() => invalid(\"Malformed activity output\")),\n ),\n ),\n );\n\n work = yield* progress.prepare({\n claim,\n work: PreparedActivity.make({\n version: 1,\n key,\n sequence: record.sequence,\n workId,\n recordId: record.record.recordId,\n recordDigest,\n output,\n }),\n });\n }\n\n const prepared = yield* Schema.decodeEffect(PreparedActivity)(work).pipe(\n Effect.mapError(() => invalid(\"Malformed prepared activity\")),\n );\n\n if (\n !Schema.toEquivalence(ActivityProcessorKey)(prepared.key, key) ||\n prepared.sequence !== record.sequence ||\n prepared.workId !== workId ||\n prepared.recordId !== record.record.recordId ||\n prepared.recordDigest !== recordDigest\n )\n return yield* contiguous();\n yield* Effect.scoped(processor.apply(prepared));\n\n const next = yield* progress\n .advance({ claim, workId })\n .pipe(\n Effect.flatMap((value) =>\n Schema.decodeEffect(ActivityClaim)(value).pipe(\n Effect.mapError(() => invalid(\"Malformed activity progress\")),\n ),\n ),\n );\n\n if (\n !Schema.toEquivalence(ActivityProcessorKey)(next.key, key) ||\n next.owner !== claim.owner ||\n next.epoch !== claim.epoch ||\n next.throughSequence !== record.sequence ||\n next.pending !== null\n )\n return yield* invalid(\"Activity progress advanced outside the claimed record\");\n claim = next;\n processed += 1;\n }\n }\n\n return ActivityPassResult.make({\n key,\n capturedTail: tail.tailSequence,\n throughSequence: claim.throughSequence,\n processed,\n pendingRecords: tail.tailSequence - claim.throughSequence,\n startedAt,\n finishedAt: yield* Clock.currentTimeMillis,\n });\n }),\n ).pipe(\n Effect.timeoutOrElse({\n duration: limits.timeoutMillis,\n orElse: () =>\n Effect.fail(\n ActivityProcessingError.make({ reason: \"timeout\", message: \"Activity pass timed out\" }),\n ),\n }),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;AA0BA,IAAa,qBAAb,cAAwC,OAAO,MAC7C,yCACF,CAAC,CAAC;CACA,YAAY,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAM,CAAC,CAAC;CAC7E,UAAU,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAI,CAAC,CAAC;CACzE,eAAe,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAQ,CAAC,CAAC;CAClF,aAAa,qBAAqB,OAAO;AAC3C,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,0BAAb,cAA6C,OAAO,YAAqC,CAAC,CACxF,2BACA;CACE,QAAQ,OAAO,SAAS;EAAC;EAAiB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AAM,OAAO,OAAO,SACjB,QAAQ;KAAE;KAAO;IAAO,CAAC,CAAC,CAC1B,KACC,OAAO,SAAS,UACd,OAAO,aAAa,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,KACxC,OAAO,eAAe,QAAQ,6BAA6B,CAAC,CAC9D,CACF,CACF;IAEF,IACE,CAAC,OAAO,cAAc,oBAAoB,CAAC,CAAC,KAAK,KAAK,GAAG,KACzD,KAAK,UAAU,MAAM,SACrB,KAAK,UAAU,MAAM,SACrB,KAAK,oBAAoB,OAAO,YAChC,KAAK,YAAY,MAEjB,OAAO,OAAO,QAAQ,uDAAuD;IAC/E,QAAQ;IACR,aAAa;GACf;EACF;EAEA,OAAO,mBAAmB,KAAK;GAC7B;GACA,cAAc,KAAK;GACnB,iBAAiB,MAAM;GACvB;GACA,gBAAgB,KAAK,eAAe,MAAM;GAC1C;GACA,YAAY,OAAO,MAAM;EAC3B,CAAC;CACH,CAAC,CACH,CAAC,CAAC,KACA,OAAO,cAAc;EACnB,UAAU,OAAO;EACjB,cACE,OAAO,KACL,wBAAwB,KAAK;GAAE,QAAQ;GAAW,SAAS;EAA0B,CAAC,CACxF;CACJ,CAAC,CACH;AACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Ci as DigestError, Di as digestDefinition, Ei as digestCanonicalBatch, Oi as digestDefinitions, Ti as EMPTY_TAIL_DIGEST, ki as digestJson } from "../Records-D88mgvyS.mjs";
2
+ export { DigestError, EMPTY_TAIL_DIGEST, digestCanonicalBatch, digestDefinition, digestDefinitions, digestJson };
@@ -0,0 +1,50 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ import { CanonicalBatch, DefinitionDigests, Digest } from "./Records.mjs";
3
+ import { Array, Crypto, Effect, Encoding, Schema } from "effect";
4
+ //#region src/durable/Digest.ts
5
+ var Digest_exports = /* @__PURE__ */ __exportAll({
6
+ DigestError: () => DigestError,
7
+ EMPTY_TAIL_DIGEST: () => EMPTY_TAIL_DIGEST,
8
+ digestCanonicalBatch: () => digestCanonicalBatch,
9
+ digestDefinition: () => digestDefinition,
10
+ digestDefinitions: () => digestDefinitions,
11
+ digestJson: () => digestJson
12
+ });
13
+ var DigestError = class extends Schema.TaggedError()("DigestError", {
14
+ message: Schema.String,
15
+ cause: Schema.optionalKey(Schema.Defect())
16
+ }) {};
17
+ const utf8 = new TextEncoder();
18
+ const canonicalJson = (value) => {
19
+ if (value === null || typeof value === "boolean" || typeof value === "number" || typeof value === "string") return JSON.stringify(value);
20
+ if (Array.isArray(value)) return `[${globalThis.Array.from(value, canonicalJson).join(",")}]`;
21
+ return `{${Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`).join(",")}}`;
22
+ };
23
+ /** Digest a JSON value using a stable, locale-independent object-key ordering (UTF-16 code units, RFC 8785 style). */
24
+ const digestJson = Effect.fnUntraced(function* (value) {
25
+ const crypto = yield* Crypto.Crypto;
26
+ const bytes = utf8.encode(canonicalJson(value));
27
+ const digest = yield* crypto.digest("SHA-256", bytes).pipe(Effect.mapError((error) => DigestError.make({
28
+ message: `SHA-256 failed: ${error.message}`,
29
+ cause: error
30
+ })));
31
+ return yield* Schema.decodeEffect(Digest)(Encoding.encodeHex(digest)).pipe(Effect.mapError(() => DigestError.make({ message: "SHA-256 returned an invalid digest" })));
32
+ });
33
+ /** Digest a canonical batch together with the prior tail to form an append-only hash chain. */
34
+ const digestCanonicalBatch = (previousTailDigest, batch) => Schema.encodeEffect(CanonicalBatch)(batch).pipe(Effect.mapError(() => DigestError.make({ message: "Canonical batch encoding failed" })), Effect.flatMap((encoded) => digestJson({
35
+ previousTailDigest,
36
+ batch: encoded
37
+ })));
38
+ /** Digest one schema-encoded Agent, Model, or Toolkit definition. */
39
+ const digestDefinition = (definition) => digestJson(definition);
40
+ /** Digest all replay-relevant definitions without hiding which authority changed. */
41
+ const digestDefinitions = (definitions) => Effect.all({
42
+ agent: digestDefinition(definitions.agent),
43
+ model: digestDefinition(definitions.model),
44
+ tools: digestDefinition(definitions.tools)
45
+ }).pipe(Effect.map((digests) => DefinitionDigests.make(digests)));
46
+ const EMPTY_TAIL_DIGEST = Schema.decodeSync(Digest)("0000000000000000000000000000000000000000000000000000000000000000");
47
+ //#endregion
48
+ export { DigestError, EMPTY_TAIL_DIGEST, digestCanonicalBatch, digestDefinition, digestDefinitions, digestJson, Digest_exports as t };
49
+
50
+ //# sourceMappingURL=Digest.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Digest.mjs","names":[],"sources":["../../src/durable/Digest.ts"],"sourcesContent":["import type { PlatformError } from \"effect\";\nimport { Array, Crypto, Effect, Encoding, Schema } from \"effect\";\n\nimport type { DefinitionDigestInput } from \"./Records.ts\";\nimport { CanonicalBatch, DefinitionDigests, Digest } from \"./Records.ts\";\n\nexport class DigestError extends Schema.TaggedError<DigestError>()(\"DigestError\", {\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n}) {}\n\nconst utf8 = new TextEncoder();\n\nconst canonicalJson = (value: Schema.Json): string => {\n if (\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"number\" ||\n typeof value === \"string\"\n ) {\n return JSON.stringify(value);\n }\n if (Array.isArray<Schema.Json>(value)) {\n return `[${globalThis.Array.from(value, canonicalJson).join(\",\")}]`;\n }\n\n const entries = Object.entries(value).sort(([left], [right]) =>\n left < right ? -1 : left > right ? 1 : 0,\n );\n\n return `{${entries\n .map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`)\n .join(\",\")}}`;\n};\n\n/** Digest a JSON value using a stable, locale-independent object-key ordering (UTF-16 code units, RFC 8785 style). */\nexport const digestJson = Effect.fnUntraced(function* (\n value: Schema.Json,\n): Effect.fn.Return<Digest, DigestError, Crypto.Crypto> {\n const crypto = yield* Crypto.Crypto;\n\n const bytes = utf8.encode(canonicalJson(value));\n\n const digest = yield* crypto\n .digest(\"SHA-256\", bytes)\n .pipe(\n Effect.mapError((error: PlatformError.PlatformError) =>\n DigestError.make({ message: `SHA-256 failed: ${error.message}`, cause: error }),\n ),\n );\n\n return yield* Schema.decodeEffect(Digest)(Encoding.encodeHex(digest)).pipe(\n Effect.mapError(() => DigestError.make({ message: \"SHA-256 returned an invalid digest\" })),\n );\n});\n\n/** Digest a canonical batch together with the prior tail to form an append-only hash chain. */\nexport const digestCanonicalBatch = (\n previousTailDigest: Digest,\n batch: CanonicalBatch,\n): Effect.Effect<Digest, DigestError, Crypto.Crypto> =>\n Schema.encodeEffect(CanonicalBatch)(batch).pipe(\n Effect.mapError(() => DigestError.make({ message: \"Canonical batch encoding failed\" })),\n Effect.flatMap((encoded) =>\n digestJson({\n previousTailDigest,\n batch: encoded,\n }),\n ),\n );\n\n/** Digest one schema-encoded Agent, Model, or Toolkit definition. */\nexport const digestDefinition = (definition: Schema.Json) => digestJson(definition);\n\n/** Digest all replay-relevant definitions without hiding which authority changed. */\nexport const digestDefinitions = (\n definitions: DefinitionDigestInput,\n): Effect.Effect<DefinitionDigests, DigestError, Crypto.Crypto> =>\n Effect.all({\n agent: digestDefinition(definitions.agent),\n model: digestDefinition(definitions.model),\n tools: digestDefinition(definitions.tools),\n }).pipe(Effect.map((digests) => DefinitionDigests.make(digests)));\n\nexport const EMPTY_TAIL_DIGEST = Schema.decodeSync(Digest)(\n \"0000000000000000000000000000000000000000000000000000000000000000\",\n);\n"],"mappings":";;;;;;;;;;;;AAMA,IAAa,cAAb,cAAiC,OAAO,YAAyB,CAAC,CAAC,eAAe;CAChF,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,OAAO,IAAI,YAAY;AAE7B,MAAM,iBAAiB,UAA+B;CACpD,IACE,UAAU,QACV,OAAO,UAAU,aACjB,OAAO,UAAU,YACjB,OAAO,UAAU,UAEjB,OAAO,KAAK,UAAU,KAAK;CAE7B,IAAI,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kB,KAAK,OAAO,CAAC,CAAC;AAElE,MAAa,oBAAoB,OAAO,WAAW,MAAM,CAAC,CACxD,kEACF"}
@@ -0,0 +1,3 @@
1
+ import { a as Receipt } from "../Receipt-BAHyigAF.mjs";
2
+ import { At as DurableRetryFailure, Bt as RecoveryFailure, Ct as DurableApprovalSuspension, Dt as DurableObserveOptions, Et as DurableObligationFailure, Ft as DurableSubmitOptions, Gt as isolateRecovery, Ht as RecoverySweepOptions, It as DurableVerifyFailure, Jt as threadCreatedBatchId, Kt as recoveryRepairBatchId, Lt as DurableWorkerFailure, Mt as DurableRuntimeConfigOptions, Nt as DurableSubmitAgent, Ot as DurableProgressFailure, Pt as DurableSubmitFailure, Rt as DurableWorkerRequirements, St as DurableApprovalResolver, Tt as DurableExplainFailure, Ut as RecoverySweepResult, Vt as RecoveryReport, Wt as childReservationIdFor, Yt as threadCreatedRecordId, _t as ApprovalSuspensionError, jt as DurableRuntimeConfig, kt as DurableResolveFailure, qt as recoveryRepairRecordId, vt as DurableAbortFailure, wt as DurableAwaitFailure, xt as DurableApprovalFailure, yt as DurableAgentRuntime, zt as RecoveryBlocked } from "../Records-D88mgvyS.mjs";
3
+ export { ApprovalSuspensionError, DurableAbortFailure, DurableAgentRuntime, DurableApprovalFailure, DurableApprovalResolver, DurableApprovalSuspension, DurableAwaitFailure, DurableExplainFailure, DurableObligationFailure, DurableObserveOptions, DurableProgressFailure, DurableResolveFailure, DurableRetryFailure, DurableRuntimeConfig, DurableRuntimeConfigOptions, DurableSubmitAgent, DurableSubmitFailure, DurableSubmitOptions, DurableVerifyFailure, DurableWorkerFailure, DurableWorkerRequirements, Receipt, RecoveryBlocked, RecoveryFailure, RecoveryReport, RecoverySweepOptions, RecoverySweepResult, childReservationIdFor, isolateRecovery, recoveryRepairBatchId, recoveryRepairRecordId, threadCreatedBatchId, threadCreatedRecordId };
@@ -0,0 +1,3 @@
1
+ import { Receipt } from "../core/Receipt.mjs";
2
+ import { a as DurableApprovalSuspension, c as RecoveryFailure, d as childReservationIdFor, f as isolateRecovery, g as threadCreatedRecordId, h as threadCreatedBatchId, i as DurableApprovalResolver, l as RecoveryReport, m as recoveryRepairRecordId, n as DurableAgentRuntime, o as DurableRuntimeConfig, p as recoveryRepairBatchId, s as RecoveryBlocked, t as ApprovalSuspensionError, u as RecoverySweepResult } from "../DurableAgentRuntime-B-9w7jDt.mjs";
3
+ export { ApprovalSuspensionError, DurableAgentRuntime, DurableApprovalResolver, DurableApprovalSuspension, DurableRuntimeConfig, Receipt, RecoveryBlocked, RecoveryFailure, RecoveryReport, RecoverySweepResult, childReservationIdFor, isolateRecovery, recoveryRepairBatchId, recoveryRepairRecordId, threadCreatedBatchId, threadCreatedRecordId };
@@ -0,0 +1,2 @@
1
+ import { a as DurableRuntimeFailpointLocation, i as DurableRuntimeFailpointHandler, n as DurableRuntimeFailpoint, r as DurableRuntimeFailpointError } from "../DurableFailpoint-Cnr3wx1L.mjs";
2
+ export { DurableRuntimeFailpoint, DurableRuntimeFailpointError, DurableRuntimeFailpointHandler, DurableRuntimeFailpointLocation };
@@ -0,0 +1,102 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ import { Context, Effect, Layer, Schema } from "effect";
3
+ //#region src/durable/DurableFailpoint.ts
4
+ var DurableFailpoint_exports = /* @__PURE__ */ __exportAll({
5
+ DurableRuntimeFailpoint: () => DurableRuntimeFailpoint,
6
+ DurableRuntimeFailpointError: () => DurableRuntimeFailpointError,
7
+ DurableRuntimeFailpointLocation: () => DurableRuntimeFailpointLocation
8
+ });
9
+ /**
10
+ * Coordinator-owned failpoint locations (plan §Failpoints). Locations normally sit immediately
11
+ * AFTER one durable mutation of the six-step coordinator flow, so a fault injected there
12
+ * simulates a crash between two durable steps; the matching BEFORE boundary of each mutation is
13
+ * owned by the storage adapters (`ledger:*:before`, `append:before`, ...), giving every durable
14
+ * mutation a failpoint on both sides (change discipline). Run-start append also exposes its
15
+ * BEFORE boundary here to distinguish a fresh clock from a committed clock in crash tests.
16
+ *
17
+ * The `subagent:*` family covers every durable mutation of the S2 establishment/join protocol
18
+ * including reservation, request append, child admission, child readiness,
19
+ * start-link append, sibling per-call settles at the suspension seam, the `waitingForChild`
20
+ * suspension, child abort propagation, the atomic join batch, and both reservation-release
21
+ * transitions.
22
+ */
23
+ const DurableRuntimeFailpointLocation = Schema.Literals([
24
+ "submit:after-admit",
25
+ "submit:after-materialize",
26
+ "claim:after-claim",
27
+ "input:after-canonical-append",
28
+ "run:before-start-append",
29
+ "run:after-start-append",
30
+ "run:before-duration-append",
31
+ "run:after-duration-append",
32
+ "turn:after-canonical-append",
33
+ "turn:after-response-append",
34
+ "turn:after-results-append",
35
+ "compaction:before-canonical-append",
36
+ "compaction:after-canonical-append",
37
+ "checkpoint:before-save",
38
+ "checkpoint:after-save",
39
+ "tools:after-prepared-append",
40
+ "tools:before-prepared-append",
41
+ "tools:before-unavailable-append",
42
+ "tools:after-unavailable-append",
43
+ "policy:before-reservation-append",
44
+ "policy:after-reservation-append",
45
+ "step:after-step-append",
46
+ "approval:after-request-append",
47
+ "approval:after-suspend",
48
+ "join:after-claim",
49
+ "join:after-canonical-append",
50
+ "resolve:after-intent",
51
+ "terminalize:after-reserve",
52
+ "terminalize:after-canonical-append",
53
+ "abort:after-intent",
54
+ "subagent:after-reserve",
55
+ "subagent:after-request-append",
56
+ "subagent:after-admit",
57
+ "subagent:after-child-ready",
58
+ "subagent:after-start-append",
59
+ "subagent:after-sibling-settle",
60
+ "subagent:after-suspend",
61
+ "subagent:after-child-abort-intent",
62
+ "subagent:before-join-append",
63
+ "subagent:after-join-append",
64
+ "subagent:after-release-pending",
65
+ "subagent:after-release",
66
+ "worker:before-stop-append",
67
+ "worker:after-stop-append",
68
+ "worker:before-stop-seal",
69
+ "worker:after-stop-seal",
70
+ "worker:before-source-append",
71
+ "worker:after-source-append",
72
+ "worker:before-origin-append",
73
+ "worker:after-origin-append",
74
+ "worker:before-completion-append",
75
+ "worker:after-completion-append",
76
+ "worker:before-subtree-append",
77
+ "worker:after-subtree-append",
78
+ "worker:before-report-append",
79
+ "worker:after-report-append",
80
+ "worker:before-report-delivery",
81
+ "worker:after-report-delivery",
82
+ "update:before-canonical-append",
83
+ "update:after-canonical-append",
84
+ "update:before-delivery-insert",
85
+ "update:after-delivery-insert"
86
+ ]);
87
+ /** Injected coordinator fault. Reaching the caller means the preceding durable step committed. */
88
+ var DurableRuntimeFailpointError = class extends Schema.TaggedError()("DurableRuntimeFailpointError", { location: DurableRuntimeFailpointLocation }) {};
89
+ const noFailpoint = () => Effect.void;
90
+ /**
91
+ * Explicit fault-injection authority used at durable coordinator step boundaries. The process
92
+ * crash harness (WP5) maps a hit to `process.exit`; in-process tests fail the step with the
93
+ * typed `DurableRuntimeFailpointError` instead.
94
+ */
95
+ var DurableRuntimeFailpoint = class extends Context.Service()("@effect-agent/thread/DurableRuntimeFailpoint") {
96
+ /** Production default: no fault injection. */
97
+ static layer = Layer.succeed(this)({ hit: noFailpoint });
98
+ };
99
+ //#endregion
100
+ export { DurableRuntimeFailpoint, DurableRuntimeFailpointError, DurableRuntimeFailpointLocation, DurableFailpoint_exports as t };
101
+
102
+ //# sourceMappingURL=DurableFailpoint.mjs.map