@systemfsoftware/agent 0.0.0-stage → 0.1.0-beta.192
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.
- package/LICENSE +21 -0
- package/dist/ActivityStore-CEy3oY41.mjs +90 -0
- package/dist/ActivityStore-CEy3oY41.mjs.map +1 -0
- package/dist/ActivityStore-CPXWRHGz.d.mts +91 -0
- package/dist/Admin-BcQDrWKY.mjs +329 -0
- package/dist/Admin-BcQDrWKY.mjs.map +1 -0
- package/dist/Admin-BfolLkHj.d.mts +5678 -0
- package/dist/Agent-Bn3zMhDH.mjs +60 -0
- package/dist/Agent-Bn3zMhDH.mjs.map +1 -0
- package/dist/Agent-DSVEpq4e.d.mts +219 -0
- package/dist/AgentError-RkUaetX8.d.mts +128 -0
- package/dist/AgentError-yFdnS9bl.mjs +141 -0
- package/dist/AgentError-yFdnS9bl.mjs.map +1 -0
- package/dist/AgentPolicy-CI7LRBQa.mjs +116 -0
- package/dist/AgentPolicy-CI7LRBQa.mjs.map +1 -0
- package/dist/AgentPolicy-D-GmZQex.d.mts +128 -0
- package/dist/AgentRegistration-Dg53p6du.mjs +14 -0
- package/dist/AgentRegistration-Dg53p6du.mjs.map +1 -0
- package/dist/AgentRuntime-CoGy_5dm.d.mts +751 -0
- package/dist/AgentRuntime-CzP4I4RB.mjs +5249 -0
- package/dist/AgentRuntime-CzP4I4RB.mjs.map +1 -0
- package/dist/AgentUpdates-7xT0It_R.d.mts +54 -0
- package/dist/AgentUpdates-BS_6gR5K.mjs +66 -0
- package/dist/AgentUpdates-BS_6gR5K.mjs.map +1 -0
- package/dist/BrowserUse-C9vict2M.d.mts +196 -0
- package/dist/BrowserUse-DjEyFDLZ.mjs +156 -0
- package/dist/BrowserUse-DjEyFDLZ.mjs.map +1 -0
- package/dist/Budget-CXh_ChFJ.d.mts +112 -0
- package/dist/Budget-j1UkthgY.mjs +351 -0
- package/dist/Budget-j1UkthgY.mjs.map +1 -0
- package/dist/CodeExecutor-B_Vt1Ghy.mjs +281 -0
- package/dist/CodeExecutor-B_Vt1Ghy.mjs.map +1 -0
- package/dist/CodeExecutor-D5-Rda75.d.mts +198 -0
- package/dist/CodeMode-B7JvfKAD.d.mts +159 -0
- package/dist/CodeMode-BI7WhUkr.mjs +555 -0
- package/dist/CodeMode-BI7WhUkr.mjs.map +1 -0
- package/dist/CommittedActivity-DXyCKCtX.mjs +146 -0
- package/dist/CommittedActivity-DXyCKCtX.mjs.map +1 -0
- package/dist/CommittedActivity-LWOKXqdi.d.mts +62 -0
- package/dist/Compaction-C0hWAmOG.mjs +15 -0
- package/dist/Compaction-C0hWAmOG.mjs.map +1 -0
- package/dist/Compaction-e5cNeFmY.d.mts +5 -0
- package/dist/ContextCompactor-Chm9BLrD.d.mts +165 -0
- package/dist/ContextCompactor-DV4NOQvg.mjs +134 -0
- package/dist/ContextCompactor-DV4NOQvg.mjs.map +1 -0
- package/dist/ContextHistory-C80rW5M7.mjs +76 -0
- package/dist/ContextHistory-C80rW5M7.mjs.map +1 -0
- package/dist/ContextHistory-akQ1Td7a.d.mts +65 -0
- package/dist/ContextTools-917r7gpv.d.mts +186 -0
- package/dist/ContextTools-p8JDPo-W.mjs +88 -0
- package/dist/ContextTools-p8JDPo-W.mjs.map +1 -0
- package/dist/ContextWindow-BJZI4MMt.d.mts +61 -0
- package/dist/ContextWindow-kbFcs1IF.mjs +63 -0
- package/dist/ContextWindow-kbFcs1IF.mjs.map +1 -0
- package/dist/Digest-BDToAbaX.d.mts +25 -0
- package/dist/Digest-CU6IWj-2.mjs +106 -0
- package/dist/Digest-CU6IWj-2.mjs.map +1 -0
- package/dist/DurableAgentRuntime-BHXo8GPJ.mjs +8432 -0
- package/dist/DurableAgentRuntime-BHXo8GPJ.mjs.map +1 -0
- package/dist/DurableFailpoint-BD5nowNl.mjs +98 -0
- package/dist/DurableFailpoint-BD5nowNl.mjs.map +1 -0
- package/dist/DurableFailpoint-Cqi5tyof.d.mts +42 -0
- package/dist/DurableStep-CzVIho7y.mjs +54 -0
- package/dist/DurableStep-CzVIho7y.mjs.map +1 -0
- package/dist/DurableStep-cI_Ho_rU.d.mts +109 -0
- package/dist/EventSource-BwZVkEQi.mjs +66 -0
- package/dist/EventSource-BwZVkEQi.mjs.map +1 -0
- package/dist/EventSource-C0TCBeIf.d.mts +52 -0
- package/dist/FailureDiagnostic-DdHV2eFs.mjs +304 -0
- package/dist/FailureDiagnostic-DdHV2eFs.mjs.map +1 -0
- package/dist/FailureDiagnostic-DpzYNI8f.d.mts +232 -0
- package/dist/IdGenerator-BCzwV0ZI.mjs +29 -0
- package/dist/IdGenerator-BCzwV0ZI.mjs.map +1 -0
- package/dist/IdGenerator-BY8NH74o.d.mts +26 -0
- package/dist/Identifiers-LWd4837I.mjs +41 -0
- package/dist/Identifiers-LWd4837I.mjs.map +1 -0
- package/dist/Identifiers-qafW4EP0.d.mts +38 -0
- package/dist/InMemory-BrTm6XEO.mjs +57 -0
- package/dist/InMemory-BrTm6XEO.mjs.map +1 -0
- package/dist/InMemory-C3qXFT5k.d.mts +46 -0
- package/dist/InMemory.d.mts +2 -0
- package/dist/InMemory.mjs +1 -0
- package/dist/InteractiveBrowser-B-hlNJy5.mjs +237 -0
- package/dist/InteractiveBrowser-B-hlNJy5.mjs.map +1 -0
- package/dist/InteractiveBrowser-nnML0r7w.d.mts +258 -0
- package/dist/LifecyclePublication-BDc_ug5v.mjs +204 -0
- package/dist/LifecyclePublication-BDc_ug5v.mjs.map +1 -0
- package/dist/Memory-CT5bDZqi.d.mts +57 -0
- package/dist/Memory-Dl9ecPpm.mjs +204 -0
- package/dist/Memory-Dl9ecPpm.mjs.map +1 -0
- package/dist/MemoryNamespace-BtnlH_E6.d.mts +35 -0
- package/dist/MemoryNamespace-DZSpjLj9.mjs +116 -0
- package/dist/MemoryNamespace-DZSpjLj9.mjs.map +1 -0
- package/dist/MemoryNotes-4CRzkPBD.d.mts +425 -0
- package/dist/MemoryNotes-i41TsH11.mjs +132 -0
- package/dist/MemoryNotes-i41TsH11.mjs.map +1 -0
- package/dist/MemoryReference-Dd3KSMa7.d.mts +77 -0
- package/dist/MemoryReference-RFU0HQJG.mjs +108 -0
- package/dist/MemoryReference-RFU0HQJG.mjs.map +1 -0
- package/dist/MemoryRevalidation--aAh_Pfq.mjs +136 -0
- package/dist/MemoryRevalidation--aAh_Pfq.mjs.map +1 -0
- package/dist/MemoryRevalidation-FsJ8E61W.d.mts +64 -0
- package/dist/MemoryStore-Bg5RunTk.d.mts +187 -0
- package/dist/MemoryStore-E0J99hb2.mjs +245 -0
- package/dist/MemoryStore-E0J99hb2.mjs.map +1 -0
- package/dist/MessageDelivery-BE2Yf3FC.mjs +615 -0
- package/dist/MessageDelivery-BE2Yf3FC.mjs.map +1 -0
- package/dist/MessageDelivery-Dh6GZBt_.d.mts +1129 -0
- package/dist/Messaging-BqWHYf93.d.mts +216 -0
- package/dist/Messaging-DgSiv4f4.mjs +154 -0
- package/dist/Messaging-DgSiv4f4.mjs.map +1 -0
- package/dist/Messaging-DhM-APnP.d.mts +1074 -0
- package/dist/MessagingHost-Bm5e-kAX.mjs +117 -0
- package/dist/MessagingHost-Bm5e-kAX.mjs.map +1 -0
- package/dist/MessagingHost-CubWeYKN.d.mts +80 -0
- package/dist/OperationAuthorizer-VSiHCC2S.mjs +72 -0
- package/dist/OperationAuthorizer-VSiHCC2S.mjs.map +1 -0
- package/dist/OperationAuthorizer-y-F-Ox_Q.d.mts +62 -0
- package/dist/Output-DQ8mWcgf.mjs +7 -0
- package/dist/Output-DQ8mWcgf.mjs.map +1 -0
- package/dist/Output-SbOdlBFL.d.mts +22 -0
- package/dist/PageCapture-BfRURUOA.mjs +275 -0
- package/dist/PageCapture-BfRURUOA.mjs.map +1 -0
- package/dist/PageCapture-C_mE72Sd.d.mts +216 -0
- package/dist/PageScreenshot-BJTASs4o.mjs +53 -0
- package/dist/PageScreenshot-BJTASs4o.mjs.map +1 -0
- package/dist/PageScreenshot-CaoaH7mc.d.mts +48 -0
- package/dist/PersistentHistory-BrtZ0g2j.d.mts +14 -0
- package/dist/PersistentHistory-CTAVhHKH.mjs +147 -0
- package/dist/PersistentHistory-CTAVhHKH.mjs.map +1 -0
- package/dist/PreparedInputAdmission-Ci18uY4s.d.mts +973 -0
- package/dist/PreparedInputAdmission-adqVJJa6.mjs +95 -0
- package/dist/PreparedInputAdmission-adqVJJa6.mjs.map +1 -0
- package/dist/ProvisionalText-BcKpPYKQ.d.mts +70 -0
- package/dist/ProvisionalText-DXddTK4c.mjs +47 -0
- package/dist/ProvisionalText-DXddTK4c.mjs.map +1 -0
- package/dist/Receipt-B-FlCaNH.mjs +35 -0
- package/dist/Receipt-B-FlCaNH.mjs.map +1 -0
- package/dist/Receipt-B4feBxMY.d.mts +31 -0
- package/dist/RecordFormat-DoNh-AFe.mjs +79 -0
- package/dist/RecordFormat-DoNh-AFe.mjs.map +1 -0
- package/dist/RecordFormat-ZMus8Dx8.d.mts +52 -0
- package/dist/Records-C645aQks.mjs +1145 -0
- package/dist/Records-C645aQks.mjs.map +1 -0
- package/dist/Records-C9I1nCL9.d.mts +1423 -0
- package/dist/Recovery-zWy_kmZq.mjs +736 -0
- package/dist/Recovery-zWy_kmZq.mjs.map +1 -0
- package/dist/Redaction-C0zLBAn6.d.mts +28 -0
- package/dist/Redaction-CtyCBMEj.mjs +116 -0
- package/dist/Redaction-CtyCBMEj.mjs.map +1 -0
- package/dist/RememberingStore-BO-OnCgP.mjs +23 -0
- package/dist/RememberingStore-BO-OnCgP.mjs.map +1 -0
- package/dist/RememberingStore-DgqXmILx.d.mts +14 -0
- package/dist/RunContinuation-BVAHoYlN.d.mts +127 -0
- package/dist/RunContinuation-Bpfp087i.mjs +1060 -0
- package/dist/RunContinuation-Bpfp087i.mjs.map +1 -0
- package/dist/RunEvent-CwgDzXcH.d.mts +465 -0
- package/dist/RunEvent-DJxENnJi.mjs +345 -0
- package/dist/RunEvent-DJxENnJi.mjs.map +1 -0
- package/dist/RunEventSink-B8uM8bw2.mjs +22 -0
- package/dist/RunEventSink-B8uM8bw2.mjs.map +1 -0
- package/dist/RunEventSink-f-T4jbNB.d.mts +105 -0
- package/dist/RunHooks-Bob22Bcj.d.mts +40 -0
- package/dist/RunHooks-DWuLBVdU.mjs +60 -0
- package/dist/RunHooks-DWuLBVdU.mjs.map +1 -0
- package/dist/RunJournal-C_1eqQdr.mjs +1107 -0
- package/dist/RunJournal-C_1eqQdr.mjs.map +1 -0
- package/dist/RunOptions-BVSa3BO2.d.mts +560 -0
- package/dist/RunOptions-COEUCrx4.mjs +61 -0
- package/dist/RunOptions-COEUCrx4.mjs.map +1 -0
- package/dist/RunPolicyUsage-B-JXRZYO.mjs +25 -0
- package/dist/RunPolicyUsage-B-JXRZYO.mjs.map +1 -0
- package/dist/RunPolicyUsage-jvJo0vJp.d.mts +21 -0
- package/dist/RunStorage-CsQQ0Y5u.mjs +304 -0
- package/dist/RunStorage-CsQQ0Y5u.mjs.map +1 -0
- package/dist/Sandbox-37vXP0BV.d.mts +24 -0
- package/dist/Sandbox-Bze6pHYc.mjs +30 -0
- package/dist/Sandbox-Bze6pHYc.mjs.map +1 -0
- package/dist/Schedule-BY0lzbij.mjs +336 -0
- package/dist/Schedule-BY0lzbij.mjs.map +1 -0
- package/dist/ScheduleTransition-CjVP48I8.d.mts +22 -0
- package/dist/ScheduleTransition-DtNzlN9k.mjs +180 -0
- package/dist/ScheduleTransition-DtNzlN9k.mjs.map +1 -0
- package/dist/Scheduling-BpJN9E1j.mjs +699 -0
- package/dist/Scheduling-BpJN9E1j.mjs.map +1 -0
- package/dist/Scheduling-DYTM29s9.d.mts +57 -0
- package/dist/SemanticMemory-BRV0cuWg.mjs +300 -0
- package/dist/SemanticMemory-BRV0cuWg.mjs.map +1 -0
- package/dist/SemanticMemory-rgWlhW87.d.mts +431 -0
- package/dist/SemanticMemoryIndex-D7yNEWpt.d.mts +826 -0
- package/dist/SemanticMemoryIndex-godQDjNx.mjs +186 -0
- package/dist/SemanticMemoryIndex-godQDjNx.mjs.map +1 -0
- package/dist/SemanticMemoryRevalidation-Bm3_pfsI.d.mts +44 -0
- package/dist/SemanticMemoryRevalidation-D8VV-eU6.mjs +179 -0
- package/dist/SemanticMemoryRevalidation-D8VV-eU6.mjs.map +1 -0
- package/dist/Subagent-CSIRUgUo.mjs +1315 -0
- package/dist/Subagent-CSIRUgUo.mjs.map +1 -0
- package/dist/Subagent-CXEI5YZ8.d.mts +2368 -0
- package/dist/SubagentContract-B7vQPueI.d.mts +176 -0
- package/dist/SubagentContract-C-7AxTm_.mjs +187 -0
- package/dist/SubagentContract-C-7AxTm_.mjs.map +1 -0
- package/dist/SubagentHost-BEnICu7g.mjs +70 -0
- package/dist/SubagentHost-BEnICu7g.mjs.map +1 -0
- package/dist/SubagentHost-CKhz1vbH.d.mts +167 -0
- package/dist/SubagentReservations-BYNAHPpm.mjs +465 -0
- package/dist/SubagentReservations-BYNAHPpm.mjs.map +1 -0
- package/dist/SubagentReservations-WrmIVzO5.d.mts +185 -0
- package/dist/SubmissionLedger-WG0beEyt.mjs +921 -0
- package/dist/SubmissionLedger-WG0beEyt.mjs.map +1 -0
- package/dist/SubmissionStatus-CPZsOM5a.mjs +17 -0
- package/dist/SubmissionStatus-CPZsOM5a.mjs.map +1 -0
- package/dist/Subscription-BhQbmUD-.mjs +340 -0
- package/dist/Subscription-BhQbmUD-.mjs.map +1 -0
- package/dist/Subscription-CC--_OnU.d.mts +815 -0
- package/dist/SubscriptionInput-BEeB0Cj8.d.mts +42 -0
- package/dist/SubscriptionInput-Xcd4JjEs.mjs +53 -0
- package/dist/SubscriptionInput-Xcd4JjEs.mjs.map +1 -0
- package/dist/SubscriptionTransition-CWt9UVH0.d.mts +23 -0
- package/dist/SubscriptionTransition-lrf733c8.mjs +154 -0
- package/dist/SubscriptionTransition-lrf733c8.mjs.map +1 -0
- package/dist/Subscriptions-4K_qu_2f.mjs +638 -0
- package/dist/Subscriptions-4K_qu_2f.mjs.map +1 -0
- package/dist/Subscriptions-BF3aSf8X.d.mts +75 -0
- package/dist/Thread-B8JApGHa.mjs +283 -0
- package/dist/Thread-B8JApGHa.mjs.map +1 -0
- package/dist/Thread-BnAtkJl4.d.mts +116 -0
- package/dist/ThreadArchiveRange-1PMdjpdJ.mjs +64 -0
- package/dist/ThreadArchiveRange-1PMdjpdJ.mjs.map +1 -0
- package/dist/ThreadContextHistory-BSStMOLX.mjs +211 -0
- package/dist/ThreadContextHistory-BSStMOLX.mjs.map +1 -0
- package/dist/ThreadContextHistory-lTZ8Ftq1.d.mts +33 -0
- package/dist/ThreadContextHistoryProjection-Cp7_RR6V.d.mts +59 -0
- package/dist/ThreadContextHistoryProjection-_8uNz-h1.mjs +149 -0
- package/dist/ThreadContextHistoryProjection-_8uNz-h1.mjs.map +1 -0
- package/dist/ThreadHistory-BkyGfv5E.d.mts +76 -0
- package/dist/ThreadHistory-Blt_W31N.mjs +69 -0
- package/dist/ThreadHistory-Blt_W31N.mjs.map +1 -0
- package/dist/ThreadImport-C8Tqiezd.mjs +491 -0
- package/dist/ThreadImport-C8Tqiezd.mjs.map +1 -0
- package/dist/ThreadImport-DaSmrlRi.d.mts +843 -0
- package/dist/ThreadInvariants-DyPhMeo-.d.mts +23 -0
- package/dist/ThreadInvariants-fniroLRY.mjs +154 -0
- package/dist/ThreadInvariants-fniroLRY.mjs.map +1 -0
- package/dist/ThreadProjectionMaintenance-D6fBjr1q.mjs +37 -0
- package/dist/ThreadProjectionMaintenance-D6fBjr1q.mjs.map +1 -0
- package/dist/ThreadProjectionMaintenance-DjUy7kCa.d.mts +51 -0
- package/dist/ThreadStore-BMUAp5Ta.mjs +937 -0
- package/dist/ThreadStore-BMUAp5Ta.mjs.map +1 -0
- package/dist/ThreadTransfer-B3NkyO_y.mjs +154 -0
- package/dist/ThreadTransfer-B3NkyO_y.mjs.map +1 -0
- package/dist/ThreadTransfer-BM02cbOo.d.mts +63 -0
- package/dist/ThreadWork-C-xa2Boi.mjs +484 -0
- package/dist/ThreadWork-C-xa2Boi.mjs.map +1 -0
- package/dist/ToolBroker-DkoVyx6T.mjs +42 -0
- package/dist/ToolBroker-DkoVyx6T.mjs.map +1 -0
- package/dist/ToolBroker-Dy2xM6ht.d.mts +134 -0
- package/dist/ToolDiscovery-DHySvLQd.mjs +211 -0
- package/dist/ToolDiscovery-DHySvLQd.mjs.map +1 -0
- package/dist/ToolDiscovery-VjamzX3q.d.mts +119 -0
- package/dist/ToolExposure-Cn7xETn5.d.mts +6 -0
- package/dist/ToolExposure-D7id9Gt5.d.mts +37 -0
- package/dist/ToolExposure-DCvQWFIa.mjs +9 -0
- package/dist/ToolExposure-DCvQWFIa.mjs.map +1 -0
- package/dist/ToolExposure-DNME8BkG.d.mts +44 -0
- package/dist/ToolExposure-DPnq8Won.mjs +30 -0
- package/dist/ToolExposure-DPnq8Won.mjs.map +1 -0
- package/dist/ToolExposure-DaGaF5tj.mjs +20 -0
- package/dist/ToolExposure-DaGaF5tj.mjs.map +1 -0
- package/dist/ToolExposure.d.mts +4 -0
- package/dist/ToolExposure.mjs +4 -0
- package/dist/ToolReconciler-6bb7xlip.d.mts +81 -0
- package/dist/ToolReconciler-DJQd3SZA.mjs +87 -0
- package/dist/ToolReconciler-DJQd3SZA.mjs.map +1 -0
- package/dist/ToolResult-By5KAje4.d.mts +79 -0
- package/dist/ToolResult-DwZxjlHw.mjs +160 -0
- package/dist/ToolResult-DwZxjlHw.mjs.map +1 -0
- package/dist/ToolResultStorage-BmoRewhh.mjs +46 -0
- package/dist/ToolResultStorage-BmoRewhh.mjs.map +1 -0
- package/dist/ToolResultStorage-Bp5fm0do.d.mts +49 -0
- package/dist/ToolResults-C4-HsMCp.d.mts +33 -0
- package/dist/ToolResults-nCgBlTp2.mjs +45 -0
- package/dist/ToolResults-nCgBlTp2.mjs.map +1 -0
- package/dist/Usage-B0xgME5f.mjs +340 -0
- package/dist/Usage-B0xgME5f.mjs.map +1 -0
- package/dist/Usage-Bc-jXe_9.d.mts +128 -0
- package/dist/WakeScheduler-DVYj66C-.mjs +74 -0
- package/dist/WakeScheduler-DVYj66C-.mjs.map +1 -0
- package/dist/WakeScheduler-SFqj67Sk.d.mts +74 -0
- package/dist/WebCapture-CA4ZarW2.mjs +64 -0
- package/dist/WebCapture-CA4ZarW2.mjs.map +1 -0
- package/dist/WebCapture-pzIeUJ5W.d.mts +49 -0
- package/dist/WebSearch-CD0V--qh.d.mts +18 -0
- package/dist/WebSearch-DnbOzRL_.mjs +30 -0
- package/dist/WebSearch-DnbOzRL_.mjs.map +1 -0
- package/dist/Worker-CQu8Qp1j.mjs +267 -0
- package/dist/Worker-CQu8Qp1j.mjs.map +1 -0
- package/dist/Worker-xxucY_0b.d.mts +468 -0
- package/dist/WorkerAdmission-BhFjx86s.mjs +162 -0
- package/dist/WorkerAdmission-BhFjx86s.mjs.map +1 -0
- package/dist/WorkerAdmission-BnRuXLWF.d.mts +171 -0
- package/dist/WorkerHost-DtYzi54D.d.mts +150 -0
- package/dist/WorkerHost-DuQug9Bq.mjs +73 -0
- package/dist/WorkerHost-DuQug9Bq.mjs.map +1 -0
- package/dist/agent-registration-CNs2twrr.mjs +262 -0
- package/dist/agent-registration-CNs2twrr.mjs.map +1 -0
- package/dist/capabilities/BrowserUse.d.mts +2 -0
- package/dist/capabilities/BrowserUse.mjs +1 -0
- package/dist/capabilities/Budget.d.mts +2 -0
- package/dist/capabilities/Budget.mjs +1 -0
- package/dist/capabilities/CodeMode.d.mts +2 -0
- package/dist/capabilities/CodeMode.mjs +1 -0
- package/dist/capabilities/ContextTools.d.mts +2 -0
- package/dist/capabilities/ContextTools.mjs +1 -0
- package/dist/capabilities/MemoryNotes.d.mts +2 -0
- package/dist/capabilities/MemoryNotes.mjs +1 -0
- package/dist/capabilities/Messaging.d.mts +3 -0
- package/dist/capabilities/Messaging.mjs +4 -0
- package/dist/capabilities/Redaction.d.mts +2 -0
- package/dist/capabilities/Redaction.mjs +1 -0
- package/dist/capabilities/RunHooks.d.mts +2 -0
- package/dist/capabilities/RunHooks.mjs +1 -0
- package/dist/capabilities/SemanticMemory.d.mts +2 -0
- package/dist/capabilities/SemanticMemory.mjs +1 -0
- package/dist/capabilities/Subagent.d.mts +4 -0
- package/dist/capabilities/Subagent.mjs +6 -0
- package/dist/capabilities/SubagentReservations.d.mts +2 -0
- package/dist/capabilities/SubagentReservations.mjs +1 -0
- package/dist/capabilities/ToolDiscovery.d.mts +2 -0
- package/dist/capabilities/ToolDiscovery.mjs +1 -0
- package/dist/capabilities/ToolResults.d.mts +2 -0
- package/dist/capabilities/ToolResults.mjs +1 -0
- package/dist/capabilities/WebCapture.d.mts +2 -0
- package/dist/capabilities/WebCapture.mjs +1 -0
- package/dist/capabilities/WebSearch.d.mts +2 -0
- package/dist/capabilities/WebSearch.mjs +1 -0
- package/dist/compaction-C3hXuO4Z.mjs +539 -0
- package/dist/compaction-C3hXuO4Z.mjs.map +1 -0
- package/dist/completion-B_WDnSg-.d.mts +11 -0
- package/dist/core/Agent.d.mts +2 -0
- package/dist/core/Agent.mjs +1 -0
- package/dist/core/AgentError.d.mts +2 -0
- package/dist/core/AgentError.mjs +1 -0
- package/dist/core/AgentPolicy.d.mts +2 -0
- package/dist/core/AgentPolicy.mjs +1 -0
- package/dist/core/AgentUpdates.d.mts +2 -0
- package/dist/core/AgentUpdates.mjs +1 -0
- package/dist/core/FailureDiagnostic.d.mts +2 -0
- package/dist/core/FailureDiagnostic.mjs +1 -0
- package/dist/core/IdGenerator.d.mts +2 -0
- package/dist/core/IdGenerator.mjs +1 -0
- package/dist/core/Identifiers.d.mts +2 -0
- package/dist/core/Identifiers.mjs +1 -0
- package/dist/core/Memory.d.mts +2 -0
- package/dist/core/Memory.mjs +1 -0
- package/dist/core/MemoryNamespace.d.mts +2 -0
- package/dist/core/MemoryNamespace.mjs +1 -0
- package/dist/core/MemoryReference.d.mts +2 -0
- package/dist/core/MemoryReference.mjs +1 -0
- package/dist/core/MemoryRevalidation.d.mts +2 -0
- package/dist/core/MemoryRevalidation.mjs +1 -0
- package/dist/core/MemoryStore.d.mts +2 -0
- package/dist/core/MemoryStore.mjs +1 -0
- package/dist/core/ProvisionalText.d.mts +2 -0
- package/dist/core/ProvisionalText.mjs +1 -0
- package/dist/core/Receipt.d.mts +2 -0
- package/dist/core/Receipt.mjs +1 -0
- package/dist/core/RememberingStore.d.mts +2 -0
- package/dist/core/RememberingStore.mjs +1 -0
- package/dist/core/RunEvent.d.mts +3 -0
- package/dist/core/RunEvent.mjs +1 -0
- package/dist/core/RunPolicyUsage.d.mts +2 -0
- package/dist/core/RunPolicyUsage.mjs +1 -0
- package/dist/core/SemanticMemoryIndex.d.mts +2 -0
- package/dist/core/SemanticMemoryIndex.mjs +1 -0
- package/dist/core/SemanticMemoryRevalidation.d.mts +2 -0
- package/dist/core/SemanticMemoryRevalidation.mjs +1 -0
- package/dist/core/SubagentContract.d.mts +2 -0
- package/dist/core/SubagentContract.mjs +1 -0
- package/dist/core/Thread.d.mts +2 -0
- package/dist/core/Thread.mjs +1 -0
- package/dist/core/ToolResult.d.mts +2 -0
- package/dist/core/ToolResult.mjs +1 -0
- package/dist/core/ToolResultStorage.d.mts +2 -0
- package/dist/core/ToolResultStorage.mjs +1 -0
- package/dist/core/Usage.d.mts +2 -0
- package/dist/core/Usage.mjs +1 -0
- package/dist/core/Worker.d.mts +3 -0
- package/dist/core/Worker.mjs +3 -0
- package/dist/durable/ActivityStore.d.mts +2 -0
- package/dist/durable/ActivityStore.mjs +1 -0
- package/dist/durable/Admin.d.mts +2 -0
- package/dist/durable/Admin.mjs +1 -0
- package/dist/durable/AgentRegistration.d.mts +3 -0
- package/dist/durable/AgentRegistration.mjs +2 -0
- package/dist/durable/CommittedActivity.d.mts +2 -0
- package/dist/durable/CommittedActivity.mjs +1 -0
- package/dist/durable/Digest.d.mts +2 -0
- package/dist/durable/Digest.mjs +3 -0
- package/dist/durable/DurableAgentRuntime.d.mts +3 -0
- package/dist/durable/DurableAgentRuntime.mjs +4 -0
- package/dist/durable/DurableFailpoint.d.mts +2 -0
- package/dist/durable/DurableFailpoint.mjs +1 -0
- package/dist/durable/DurableFailpointTestControl.d.mts +14 -0
- package/dist/durable/DurableFailpointTestControl.mjs +21 -0
- package/dist/durable/DurableFailpointTestControl.mjs.map +1 -0
- package/dist/durable/EventSource.d.mts +2 -0
- package/dist/durable/EventSource.mjs +1 -0
- package/dist/durable/LifecyclePublication.d.mts +2 -0
- package/dist/durable/LifecyclePublication.mjs +1 -0
- package/dist/durable/MessageDelivery.d.mts +2 -0
- package/dist/durable/MessageDelivery.mjs +1 -0
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +401 -0
- package/dist/durable/MessageDeliveryStoreConformance.mjs +273 -0
- package/dist/durable/MessageDeliveryStoreConformance.mjs.map +1 -0
- package/dist/durable/OperationAuthorizer.d.mts +2 -0
- package/dist/durable/OperationAuthorizer.mjs +1 -0
- package/dist/durable/PersistentHistory.d.mts +2 -0
- package/dist/durable/PersistentHistory.mjs +1 -0
- package/dist/durable/PreparedInputAdmission.d.mts +2 -0
- package/dist/durable/PreparedInputAdmission.mjs +1 -0
- package/dist/durable/RecordFormat.d.mts +2 -0
- package/dist/durable/RecordFormat.mjs +1 -0
- package/dist/durable/Records.d.mts +2 -0
- package/dist/durable/Records.mjs +1 -0
- package/dist/durable/Recovery.d.mts +2 -0
- package/dist/durable/Recovery.mjs +1 -0
- package/dist/durable/RunContinuation.d.mts +4 -0
- package/dist/durable/RunContinuation.mjs +4 -0
- package/dist/durable/RunJournal.d.mts +2 -0
- package/dist/durable/RunJournal.mjs +1 -0
- package/dist/durable/RunStorage.d.mts +2 -0
- package/dist/durable/RunStorage.mjs +1 -0
- package/dist/durable/Schedule.d.mts +2 -0
- package/dist/durable/Schedule.mjs +1 -0
- package/dist/durable/ScheduleStoreConformance.d.mts +16 -0
- package/dist/durable/ScheduleStoreConformance.mjs +421 -0
- package/dist/durable/ScheduleStoreConformance.mjs.map +1 -0
- package/dist/durable/ScheduleTransition.d.mts +2 -0
- package/dist/durable/ScheduleTransition.mjs +1 -0
- package/dist/durable/Scheduling.d.mts +2 -0
- package/dist/durable/Scheduling.mjs +1 -0
- package/dist/durable/SettlementPublisher.d.mts +2 -0
- package/dist/durable/SettlementPublisher.mjs +99 -0
- package/dist/durable/SettlementPublisher.mjs.map +1 -0
- package/dist/durable/SqlMemoryStore.d.mts +729 -0
- package/dist/durable/SqlMemoryStore.mjs +626 -0
- package/dist/durable/SqlMemoryStore.mjs.map +1 -0
- package/dist/durable/SqlStorageOwner.d.mts +18 -0
- package/dist/durable/SqlStorageOwner.mjs +6 -0
- package/dist/durable/SqlStorageOwner.mjs.map +1 -0
- package/dist/durable/SubmissionLedger.d.mts +3 -0
- package/dist/durable/SubmissionLedger.mjs +3 -0
- package/dist/durable/SubmissionLedgerConformance.d.mts +31 -0
- package/dist/durable/SubmissionLedgerConformance.mjs +2090 -0
- package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -0
- package/dist/durable/SubmissionStatus.d.mts +2 -0
- package/dist/durable/SubmissionStatus.mjs +1 -0
- package/dist/durable/Subscription.d.mts +2 -0
- package/dist/durable/Subscription.mjs +1 -0
- package/dist/durable/SubscriptionInput.d.mts +2 -0
- package/dist/durable/SubscriptionInput.mjs +1 -0
- package/dist/durable/SubscriptionStoreConformance.d.mts +15 -0
- package/dist/durable/SubscriptionStoreConformance.mjs +816 -0
- package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -0
- package/dist/durable/SubscriptionTransition.d.mts +2 -0
- package/dist/durable/SubscriptionTransition.mjs +1 -0
- package/dist/durable/Subscriptions.d.mts +2 -0
- package/dist/durable/Subscriptions.mjs +1 -0
- package/dist/durable/ThreadArchiveRange.d.mts +2 -0
- package/dist/durable/ThreadArchiveRange.mjs +1 -0
- package/dist/durable/ThreadContextHistory.d.mts +2 -0
- package/dist/durable/ThreadContextHistory.mjs +1 -0
- package/dist/durable/ThreadContextHistoryProjection.d.mts +2 -0
- package/dist/durable/ThreadContextHistoryProjection.mjs +1 -0
- package/dist/durable/ThreadImport.d.mts +2 -0
- package/dist/durable/ThreadImport.mjs +1 -0
- package/dist/durable/ThreadInvariants.d.mts +2 -0
- package/dist/durable/ThreadInvariants.mjs +1 -0
- package/dist/durable/ThreadProjectionMaintenance.d.mts +2 -0
- package/dist/durable/ThreadProjectionMaintenance.mjs +1 -0
- package/dist/durable/ThreadReader.d.mts +2 -0
- package/dist/durable/ThreadReader.mjs +1 -0
- package/dist/durable/ThreadStore.d.mts +3 -0
- package/dist/durable/ThreadStore.mjs +3 -0
- package/dist/durable/ThreadStoreConformance.d.mts +53 -0
- package/dist/durable/ThreadStoreConformance.mjs +402 -0
- package/dist/durable/ThreadStoreConformance.mjs.map +1 -0
- package/dist/durable/ThreadTransfer.d.mts +2 -0
- package/dist/durable/ThreadTransfer.mjs +1 -0
- package/dist/durable/ThreadWork.d.mts +2 -0
- package/dist/durable/ThreadWork.mjs +1 -0
- package/dist/durable/ToolReconciler.d.mts +2 -0
- package/dist/durable/ToolReconciler.mjs +1 -0
- package/dist/durable/WakeScheduler.d.mts +2 -0
- package/dist/durable/WakeScheduler.mjs +1 -0
- package/dist/durable/WorkerAdmission.d.mts +2 -0
- package/dist/durable/WorkerAdmission.mjs +1 -0
- package/dist/durable/WorkerHost.d.mts +2 -0
- package/dist/durable/WorkerHost.mjs +1 -0
- package/dist/engine/AgentRuntime.d.mts +2 -0
- package/dist/engine/AgentRuntime.mjs +1 -0
- package/dist/engine/Compaction.d.mts +4 -0
- package/dist/engine/Compaction.mjs +2 -0
- package/dist/engine/ContextCompactor.d.mts +2 -0
- package/dist/engine/ContextCompactor.mjs +1 -0
- package/dist/engine/ContextHistory.d.mts +2 -0
- package/dist/engine/ContextHistory.mjs +1 -0
- package/dist/engine/ContextWindow.d.mts +2 -0
- package/dist/engine/ContextWindow.mjs +1 -0
- package/dist/engine/DurableStep.d.mts +2 -0
- package/dist/engine/DurableStep.mjs +3 -0
- package/dist/engine/MessagingHost.d.mts +2 -0
- package/dist/engine/MessagingHost.mjs +1 -0
- package/dist/engine/Output.d.mts +3 -0
- package/dist/engine/Output.mjs +2 -0
- package/dist/engine/RunEventSink.d.mts +2 -0
- package/dist/engine/RunEventSink.mjs +1 -0
- package/dist/engine/RunOptions.d.mts +2 -0
- package/dist/engine/RunOptions.mjs +1 -0
- package/dist/engine/SubagentHost.d.mts +2 -0
- package/dist/engine/SubagentHost.mjs +1 -0
- package/dist/engine/ThreadHistory.d.mts +2 -0
- package/dist/engine/ThreadHistory.mjs +1 -0
- package/dist/engine/ToolBroker.d.mts +2 -0
- package/dist/engine/ToolBroker.mjs +1 -0
- package/dist/index.d.mts +90 -0
- package/dist/index.mjs +101 -0
- package/dist/output-contract-CYA4oBhe.mjs +128 -0
- package/dist/output-contract-CYA4oBhe.mjs.map +1 -0
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/dist/run-context-reader-CHox63hg.d.mts +17 -0
- package/dist/sandbox/CodeExecutor.d.mts +2 -0
- package/dist/sandbox/CodeExecutor.mjs +1 -0
- package/dist/sandbox/InteractiveBrowser.d.mts +2 -0
- package/dist/sandbox/InteractiveBrowser.mjs +1 -0
- package/dist/sandbox/PageCapture.d.mts +2 -0
- package/dist/sandbox/PageCapture.mjs +1 -0
- package/dist/sandbox/PageScreenshot.d.mts +2 -0
- package/dist/sandbox/PageScreenshot.mjs +1 -0
- package/dist/sandbox/Sandbox.d.mts +2 -0
- package/dist/sandbox/Sandbox.mjs +1 -0
- package/dist/subagent-policy-xRJhrc0a.mjs +133 -0
- package/dist/subagent-policy-xRJhrc0a.mjs.map +1 -0
- package/dist/tool-execution-Cl7v8fXU.mjs +16 -0
- package/dist/tool-execution-Cl7v8fXU.mjs.map +1 -0
- package/dist/tool-operations-CauPonM8.mjs +84 -0
- package/dist/tool-operations-CauPonM8.mjs.map +1 -0
- package/dist/utf8-Bl0ZhhGe.mjs +27 -0
- package/dist/utf8-Bl0ZhhGe.mjs.map +1 -0
- package/package.json +491 -3
- package/src/InMemory.ts +79 -0
- package/src/ToolExposure.ts +2 -0
- package/src/capabilities/BrowserUse.ts +212 -0
- package/src/capabilities/Budget.ts +544 -0
- package/src/capabilities/CodeMode.ts +1129 -0
- package/src/capabilities/ContextTools.ts +131 -0
- package/src/capabilities/MemoryNotes.ts +177 -0
- package/src/capabilities/Messaging.ts +260 -0
- package/src/capabilities/Redaction.ts +163 -0
- package/src/capabilities/RunHooks.ts +116 -0
- package/src/capabilities/SemanticMemory.ts +402 -0
- package/src/capabilities/Subagent.ts +2343 -0
- package/src/capabilities/SubagentReservations.ts +807 -0
- package/src/capabilities/ToolDiscovery.ts +291 -0
- package/src/capabilities/ToolResults.ts +50 -0
- package/src/capabilities/WebCapture.ts +64 -0
- package/src/capabilities/WebSearch.ts +45 -0
- package/src/capabilities/internal/subagent-background.ts +1137 -0
- package/src/capabilities/internal/subagent-contract.ts +92 -0
- package/src/capabilities/internal/subagent-policy.ts +205 -0
- package/src/capabilities/internal/subagent-reporting.ts +152 -0
- package/src/core/Agent.ts +528 -0
- package/src/core/AgentError.ts +189 -0
- package/src/core/AgentPolicy.ts +194 -0
- package/src/core/AgentUpdates.ts +104 -0
- package/src/core/FailureDiagnostic.ts +392 -0
- package/src/core/IdGenerator.ts +42 -0
- package/src/core/Identifiers.ts +64 -0
- package/src/core/Memory.ts +283 -0
- package/src/core/MemoryNamespace.ts +202 -0
- package/src/core/MemoryReference.ts +120 -0
- package/src/core/MemoryRevalidation.ts +151 -0
- package/src/core/MemoryStore.ts +371 -0
- package/src/core/Messaging.ts +72 -0
- package/src/core/ProvisionalText.ts +53 -0
- package/src/core/Receipt.ts +42 -0
- package/src/core/RememberingStore.ts +22 -0
- package/src/core/RunEvent.ts +345 -0
- package/src/core/RunPolicyUsage.ts +19 -0
- package/src/core/SemanticMemoryIndex.ts +259 -0
- package/src/core/SemanticMemoryRevalidation.ts +220 -0
- package/src/core/SubagentContract.ts +263 -0
- package/src/core/Thread.ts +447 -0
- package/src/core/ToolExposure.ts +75 -0
- package/src/core/ToolResult.ts +204 -0
- package/src/core/ToolResultStorage.ts +56 -0
- package/src/core/Usage.ts +562 -0
- package/src/core/Worker.ts +236 -0
- package/src/core/internal/agent-updates.ts +42 -0
- package/src/core/internal/completion.ts +33 -0
- package/src/core/internal/json.ts +17 -0
- package/src/core/internal/memory-document.ts +39 -0
- package/src/core/internal/message-status.ts +60 -0
- package/src/core/internal/strict-schema.ts +14 -0
- package/src/core/internal/tool-execution.ts +33 -0
- package/src/core/internal/utf8.ts +32 -0
- package/src/durable/ActivityStore.ts +131 -0
- package/src/durable/Admin.ts +504 -0
- package/src/durable/AgentRegistration.ts +16 -0
- package/src/durable/CommittedActivity.ts +262 -0
- package/src/durable/Digest.ts +57 -0
- package/src/durable/DurableAgentRuntime.ts +12758 -0
- package/src/durable/DurableFailpoint.ts +108 -0
- package/src/durable/DurableFailpointTestControl.ts +39 -0
- package/src/durable/EventSource.ts +179 -0
- package/src/durable/LifecyclePublication.ts +343 -0
- package/src/durable/MessageDelivery.ts +949 -0
- package/src/durable/MessageDeliveryStoreConformance.ts +407 -0
- package/src/durable/OperationAuthorizer.ts +89 -0
- package/src/durable/PersistentHistory.ts +322 -0
- package/src/durable/PreparedInputAdmission.ts +128 -0
- package/src/durable/RecordFormat.ts +113 -0
- package/src/durable/Records.ts +1396 -0
- package/src/durable/Recovery.ts +1022 -0
- package/src/durable/RunContinuation.ts +1946 -0
- package/src/durable/RunJournal.ts +1926 -0
- package/src/durable/RunStorage.ts +533 -0
- package/src/durable/Schedule.ts +445 -0
- package/src/durable/ScheduleStoreConformance.ts +642 -0
- package/src/durable/ScheduleTransition.ts +267 -0
- package/src/durable/Scheduling.ts +1031 -0
- package/src/durable/SettlementPublisher.ts +172 -0
- package/src/durable/SqlMemoryStore.ts +1042 -0
- package/src/durable/SqlStorageOwner.ts +25 -0
- package/src/durable/SubmissionLedger.ts +1247 -0
- package/src/durable/SubmissionLedgerConformance.ts +4695 -0
- package/src/durable/SubmissionStatus.ts +14 -0
- package/src/durable/Subscription.ts +527 -0
- package/src/durable/SubscriptionInput.ts +145 -0
- package/src/durable/SubscriptionStoreConformance.ts +1275 -0
- package/src/durable/SubscriptionTransition.ts +330 -0
- package/src/durable/Subscriptions.ts +1245 -0
- package/src/durable/ThreadArchiveRange.ts +91 -0
- package/src/durable/ThreadContextHistory.ts +338 -0
- package/src/durable/ThreadContextHistoryProjection.ts +219 -0
- package/src/durable/ThreadImport.ts +1199 -0
- package/src/durable/ThreadInvariants.ts +312 -0
- package/src/durable/ThreadProjectionMaintenance.ts +72 -0
- package/src/durable/ThreadReader.ts +21 -0
- package/src/durable/ThreadStore.ts +1258 -0
- package/src/durable/ThreadStoreConformance.ts +877 -0
- package/src/durable/ThreadTransfer.ts +263 -0
- package/src/durable/ThreadWork.ts +713 -0
- package/src/durable/ToolReconciler.ts +112 -0
- package/src/durable/WakeScheduler.ts +125 -0
- package/src/durable/WorkerAdmission.ts +98 -0
- package/src/durable/WorkerHost.ts +204 -0
- package/src/durable/internal/StorageOwner.ts +181 -0
- package/src/durable/internal/agent-registration.ts +713 -0
- package/src/durable/internal/agent-updates.ts +338 -0
- package/src/durable/internal/canonical-json.ts +110 -0
- package/src/durable/internal/evidence.ts +29 -0
- package/src/durable/internal/foreign-diagnostic.ts +48 -0
- package/src/durable/internal/history-prompt.ts +87 -0
- package/src/durable/internal/initial-context.ts +215 -0
- package/src/durable/internal/journal-metadata.ts +188 -0
- package/src/durable/internal/message-status.ts +18 -0
- package/src/durable/internal/messaging-host.ts +615 -0
- package/src/durable/internal/prompt-footprint.ts +47 -0
- package/src/durable/internal/prompt-history-cache.ts +604 -0
- package/src/durable/internal/record-encoding.ts +258 -0
- package/src/durable/internal/record-ownership.ts +68 -0
- package/src/durable/internal/run-context-reader.ts +51 -0
- package/src/durable/internal/run-context.ts +211 -0
- package/src/durable/internal/schedule-time.ts +304 -0
- package/src/durable/internal/thread-import-reader.ts +85 -0
- package/src/durable/internal/thread-initialization.ts +181 -0
- package/src/durable/internal/thread-transfer-source.ts +7 -0
- package/src/durable/internal/tool-operations.ts +138 -0
- package/src/durable/internal/transfer-dependencies.ts +40 -0
- package/src/durable/internal/usage-totals.ts +36 -0
- package/src/durable/internal/worker-host.ts +4041 -0
- package/src/durable/internal/worker-runtime.ts +10 -0
- package/src/engine/AgentRuntime.ts +100 -0
- package/src/engine/Compaction.ts +11 -0
- package/src/engine/ContextCompactor.ts +302 -0
- package/src/engine/ContextHistory.ts +75 -0
- package/src/engine/ContextWindow.ts +81 -0
- package/src/engine/DurableStep.ts +115 -0
- package/src/engine/MessagingHost.ts +118 -0
- package/src/engine/Output.ts +2 -0
- package/src/engine/RunEventSink.ts +124 -0
- package/src/engine/RunOptions.ts +664 -0
- package/src/engine/SubagentHost.ts +231 -0
- package/src/engine/ThreadHistory.ts +125 -0
- package/src/engine/ToolBroker.ts +159 -0
- package/src/engine/ToolExposure.ts +49 -0
- package/src/engine/internal/agent-runtime.ts +11137 -0
- package/src/engine/internal/bounded-value.ts +312 -0
- package/src/engine/internal/compaction.ts +673 -0
- package/src/engine/internal/error-diagnostic.ts +39 -0
- package/src/engine/internal/image-tokens.ts +61 -0
- package/src/engine/internal/interpreter-options.ts +569 -0
- package/src/engine/internal/output-contract.ts +226 -0
- package/src/engine/internal/primitive-delta.ts +103 -0
- package/src/engine/internal/provider-result-staging.ts +211 -0
- package/src/engine/internal/provisional-text.ts +107 -0
- package/src/engine/internal/tool-derivative.ts +47 -0
- package/src/engine/internal/tool-exposure.ts +228 -0
- package/src/engine/internal/tool-telemetry.ts +488 -0
- package/src/index.ts +100 -0
- package/src/sandbox/CodeExecutor.ts +352 -0
- package/src/sandbox/InteractiveBrowser.ts +343 -0
- package/src/sandbox/PageCapture.ts +391 -0
- package/src/sandbox/PageScreenshot.ts +83 -0
- package/src/sandbox/Sandbox.ts +29 -0
- package/README.md +0 -3
|
@@ -0,0 +1,1060 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as DateTime from "effect/DateTime";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Option from "effect/Option";
|
|
6
|
+
import * as Result from "effect/Result";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as Semaphore from "effect/Semaphore";
|
|
9
|
+
import * as Stream from "effect/Stream";
|
|
10
|
+
import { l as AgentPersistenceCapacityError } from "./AgentError-yFdnS9bl.mjs";
|
|
11
|
+
import { d as ToolCallId } from "./Identifiers-LWd4837I.mjs";
|
|
12
|
+
import { n as utf8ByteLength } from "./utf8-Bl0ZhhGe.mjs";
|
|
13
|
+
import { G as PromptRecord, J as RUN_TERMINAL_RESERVE_BYTES, O as MAX_RUN_CONTINUATION_BYTES, V as PROMPT_EVIDENCE_TAGS, X as RecordEnvelope, Z as RecordId, c as CanonicalBatch, f as CanonicalSequence, it as RunContinuation, rt as RunContextRecorded, w as MAX_PERSISTED_JSON_BYTES, x as EvidenceReference } from "./Records-C645aQks.mjs";
|
|
14
|
+
import { B as ThreadReader, _t as terminalUsageCharge, a as ExecutionCheckpoint, dt as recordEncoding, ft as canonicalRunIds, gt as isWorkHandoff, ht as isTerminalBudgetFact, i as CommitBatch, it as getRunInput, mt as isPreContinuationFact, pt as executionRunIds, q as ThreadStoreError, rt as getRecord, s as ExecutionUpdate, ut as captureRecord } from "./ThreadStore-BMUAp5Ta.mjs";
|
|
15
|
+
import { A as subagentRequestedRecordId, L as toolCallResultBatchId, M as subagentStartedRecordId, Q as continuationUsage, S as runIdForSubmission, _ as projectRunJournalStream, et as toolCallSettledRecordId, t as RunJournalError, y as runCompletedRecordId } from "./RunJournal-C_1eqQdr.mjs";
|
|
16
|
+
import * as Prompt from "effect/ai/Prompt";
|
|
17
|
+
import { i as digestCanonicalJson, r as canonicalJson } from "./Digest-CU6IWj-2.mjs";
|
|
18
|
+
import * as Layer from "effect/Layer";
|
|
19
|
+
import { Mt as submissionSettlementBatchId, Pt as submissionSettlementRecordId, jt as submissionInputRecordId, kt as submissionAbortRecordId } from "./SubmissionLedger-WG0beEyt.mjs";
|
|
20
|
+
// src/durable/internal/evidence.ts
|
|
21
|
+
const failure$1 = (message, cause) => ThreadStoreError.make({
|
|
22
|
+
operation: "RunContinuation",
|
|
23
|
+
message,
|
|
24
|
+
...cause === void 0 ? {} : { cause }
|
|
25
|
+
});
|
|
26
|
+
/** References identify immutable facts; schema and owning readers validate their meaning. */
|
|
27
|
+
const reference = (record) => Effect.succeed(EvidenceReference.make({ recordId: record.recordId }));
|
|
28
|
+
/** Resolve an immutable fact by Thread and record identity. A failed reference leaves the original work owed. */
|
|
29
|
+
const resolveEvidence = Effect.fnUntraced(function* (threadId, ref) {
|
|
30
|
+
const found = yield* getRecord({
|
|
31
|
+
threadId,
|
|
32
|
+
recordId: ref.recordId
|
|
33
|
+
});
|
|
34
|
+
if (Option.isNone(found)) return yield* failure$1("Required canonical evidence is unavailable");
|
|
35
|
+
return found.value;
|
|
36
|
+
});
|
|
37
|
+
// src/durable/internal/run-context-reader.ts
|
|
38
|
+
/** Canonical history access bound by the recovery or verification-snapshot owner. */
|
|
39
|
+
var RunContextReader = class RunContextReader extends Context.Service()("@effect-agent/thread/RunContextReader") {
|
|
40
|
+
static layer(threadId) {
|
|
41
|
+
return Layer.effect(RunContextReader, Effect.gen(function* () {
|
|
42
|
+
const reader = yield* ThreadReader;
|
|
43
|
+
return RunContextReader.of({
|
|
44
|
+
read: reader.readPrompt,
|
|
45
|
+
record: (recordId) => getRecord({
|
|
46
|
+
threadId,
|
|
47
|
+
recordId
|
|
48
|
+
}).pipe(Effect.provideService(ThreadReader, reader), Effect.map(Option.getOrUndefined))
|
|
49
|
+
});
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
// src/durable/internal/run-context.ts
|
|
54
|
+
const invalid = (message) => RunJournalError.make({ message });
|
|
55
|
+
const encodePrompt = Schema.encodeEffect(Schema.toCodecJson(Prompt.Prompt));
|
|
56
|
+
const decodePromptRecord = Schema.decodeUnknownEffect(PromptRecord);
|
|
57
|
+
const promptTags = new Set(PROMPT_EVIDENCE_TAGS);
|
|
58
|
+
const projectHistoryRecord = (entry, ownerRunId) => {
|
|
59
|
+
if (!("batchId" in entry)) return Effect.succeed(entry);
|
|
60
|
+
const payload = entry.record.payload;
|
|
61
|
+
if ("runId" in payload && payload.runId === ownerRunId || !promptTags.has(payload._tag)) return Effect.succeed(entry);
|
|
62
|
+
return decodePromptRecord({
|
|
63
|
+
recordId: entry.record.recordId,
|
|
64
|
+
payload
|
|
65
|
+
}).pipe(Effect.map((record) => ({
|
|
66
|
+
threadId: entry.threadId,
|
|
67
|
+
sequence: entry.sequence,
|
|
68
|
+
record
|
|
69
|
+
})), Effect.catchTag("SchemaError", () => Effect.succeed(entry)));
|
|
70
|
+
};
|
|
71
|
+
const encodeRunHistory = (prompt) => encodePrompt(prompt).pipe(Effect.map(canonicalJson), Effect.mapError((cause) => RunJournalError.make({
|
|
72
|
+
message: "Original model history integrity is unavailable",
|
|
73
|
+
cause
|
|
74
|
+
})));
|
|
75
|
+
const digestRunHistory = (prompt) => encodeRunHistory(prompt).pipe(Effect.flatMap(digestCanonicalJson), Effect.mapError((cause) => RunJournalError.make({
|
|
76
|
+
message: "Original model history integrity is unavailable",
|
|
77
|
+
cause
|
|
78
|
+
})));
|
|
79
|
+
const validateContextBoundary = (context, original) => original.record.payload._tag !== "UserInputRecorded" || original.record.payload.kind !== "user" || original.record.payload.runId !== context.runId || context.historyThrough + 1 !== original.sequence || context.historyFrom < 1 || context.historyFrom > original.sequence || context.retained.some((ref, index) => ref.sequence <= (context.retained[index - 1]?.sequence ?? 0) || ref.sequence >= context.historyFrom) ? Effect.fail(invalid("Saved context has an invalid original admission boundary")) : Effect.void;
|
|
80
|
+
/** Reconstruct the exact saved range using the owner's history validation boundary. */
|
|
81
|
+
const readProjectedHistory = Effect.fnUntraced(function* (context, original) {
|
|
82
|
+
yield* validateContextBoundary(context, original);
|
|
83
|
+
const reader = yield* RunContextReader;
|
|
84
|
+
const records = [];
|
|
85
|
+
for (const ref of context.retained) {
|
|
86
|
+
const entry = yield* reader.record(ref.recordId);
|
|
87
|
+
if (entry === void 0 || entry.threadId !== original.threadId || entry.record.recordId !== ref.recordId || entry.sequence !== ref.sequence) return yield* invalid("Saved context has missing or corrupt retained evidence");
|
|
88
|
+
records.push(yield* projectHistoryRecord(entry, context.runId));
|
|
89
|
+
}
|
|
90
|
+
let after = CanonicalSequence.make(context.historyFrom - 1);
|
|
91
|
+
while (after < context.historyThrough) {
|
|
92
|
+
const page = yield* reader.read({
|
|
93
|
+
threadId: original.threadId,
|
|
94
|
+
throughSequence: context.historyThrough,
|
|
95
|
+
afterSequence: after,
|
|
96
|
+
limit: 8
|
|
97
|
+
}).pipe(Stream.take(9), Stream.runCollect);
|
|
98
|
+
if (page.length > 8) return yield* invalid("Saved context page exceeds its record bound");
|
|
99
|
+
for (const entry of page) {
|
|
100
|
+
if (entry.threadId !== original.threadId || entry.sequence <= after || entry.sequence > context.historyThrough) return yield* invalid("Saved context range has invalid canonical ordering");
|
|
101
|
+
after = entry.sequence;
|
|
102
|
+
records.push(yield* projectHistoryRecord(entry, context.runId));
|
|
103
|
+
}
|
|
104
|
+
if (page.length < 8) break;
|
|
105
|
+
}
|
|
106
|
+
let through = 0;
|
|
107
|
+
const retained = new Map(context.retained.map((ref) => [ref.sequence, ref.recordId]));
|
|
108
|
+
for (const entry of records) {
|
|
109
|
+
if (entry.threadId !== original.threadId || entry.sequence <= through || entry.sequence > context.historyThrough || entry.sequence < context.historyFrom && retained.get(entry.sequence) !== entry.record.recordId) return yield* invalid("Saved context has invalid canonical range evidence");
|
|
110
|
+
through = entry.sequence;
|
|
111
|
+
retained.delete(entry.sequence);
|
|
112
|
+
}
|
|
113
|
+
if (retained.size !== 0) return yield* invalid("Saved context is missing retained evidence");
|
|
114
|
+
const boundaries = [];
|
|
115
|
+
records.push(original);
|
|
116
|
+
const history = yield* projectRunJournalStream(Stream.fromIterable(records), context.runId, (boundary) => boundaries.push(boundary));
|
|
117
|
+
return {
|
|
118
|
+
prompt: history.prompt,
|
|
119
|
+
historyFrom: history.historyFrom,
|
|
120
|
+
boundaries,
|
|
121
|
+
...history.contextWindowId === void 0 ? {} : { contextWindowId: history.contextWindowId }
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
/** Both readers preserve the exact saved context and historyDigest. */
|
|
125
|
+
const readRunContext = Effect.fnUntraced(function* (context, original, recordId) {
|
|
126
|
+
const history = yield* readProjectedHistory(context, original);
|
|
127
|
+
if ((yield* digestRunHistory(history.prompt)) !== context.historyDigest || history.historyFrom !== context.historyFrom || history.prompt.content.length !== context.priorHistoryLength || history.contextWindowId !== context.contextWindowId) return yield* invalid("Saved context differs from its original model history");
|
|
128
|
+
const prefix = yield* Schema.decodeUnknownEffect(Prompt.Prompt)(context.runScopedInput).pipe(Effect.mapError(() => invalid("Saved Run instructions and input are malformed")));
|
|
129
|
+
return {
|
|
130
|
+
runId: context.runId,
|
|
131
|
+
prompt: Prompt.fromMessages([...history.prompt.content, ...prefix.content]),
|
|
132
|
+
priorHistoryLength: context.priorHistoryLength,
|
|
133
|
+
historyFrom: context.historyFrom,
|
|
134
|
+
boundaries: history.boundaries.filter((boundary) => boundary.promptLength <= context.priorHistoryLength),
|
|
135
|
+
recordId,
|
|
136
|
+
...context.contextWindowId === void 0 ? {} : { contextWindowId: context.contextWindowId }
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
// src/durable/RunContinuation.ts
|
|
140
|
+
var RunContinuation_exports = /* @__PURE__ */ __exportAll({
|
|
141
|
+
CurrentRunSettlement: () => CurrentRunSettlement,
|
|
142
|
+
CurrentRunWriter: () => CurrentRunWriter,
|
|
143
|
+
EvidenceReference: () => EvidenceReference,
|
|
144
|
+
ProgressAppendReader: () => ProgressAppendReader,
|
|
145
|
+
RunContextRecorded: () => RunContextRecorded,
|
|
146
|
+
RunContinuation: () => RunContinuation,
|
|
147
|
+
canonicalRecordBytes: () => canonicalRecordBytes,
|
|
148
|
+
canonicalRunIds: () => canonicalRunIds,
|
|
149
|
+
executionRunIds: () => executionRunIds,
|
|
150
|
+
isOperationalRecord: () => isOperationalRecord,
|
|
151
|
+
isPreContinuationFact: () => isPreContinuationFact,
|
|
152
|
+
isWorkHandoff: () => isWorkHandoff,
|
|
153
|
+
makeProgressWriter: () => makeProgressWriter,
|
|
154
|
+
prepareProgressAppend: () => prepareProgressAppend,
|
|
155
|
+
readContinuation: () => readContinuation,
|
|
156
|
+
readRunEvidenceSnapshot: () => readRunEvidenceSnapshot,
|
|
157
|
+
reference: () => reference,
|
|
158
|
+
resolveEvidence: () => resolveEvidence,
|
|
159
|
+
resolveExecutionEvidence: () => resolveExecutionEvidence,
|
|
160
|
+
runEvidence: () => runEvidence,
|
|
161
|
+
terminalUsageCharge: () => terminalUsageCharge,
|
|
162
|
+
validateProgressAppend: () => validateProgressAppend,
|
|
163
|
+
validateSuffix: () => validateSuffix,
|
|
164
|
+
verifyRunContinuations: () => verifyRunContinuations
|
|
165
|
+
});
|
|
166
|
+
/** Writer and progress sequencer selected at the local owner's resource boundary. */
|
|
167
|
+
var CurrentRunWriter = class extends Context.Service()("@effect-agent/thread/CurrentRunWriter") {};
|
|
168
|
+
/** Settlement publication keeps its original atomic authority and claim-scoped implementation. */
|
|
169
|
+
var CurrentRunSettlement = class extends Context.Service()("@effect-agent/thread/CurrentRunSettlement") {};
|
|
170
|
+
/** Canonical reads pinned to the append owner's current transaction or mutation gate. */
|
|
171
|
+
var ProgressAppendReader = class extends Context.Service()("@effect-agent/thread/ProgressAppendReader") {};
|
|
172
|
+
const failure = (message, cause) => ThreadStoreError.make({
|
|
173
|
+
operation: "RunContinuation",
|
|
174
|
+
message,
|
|
175
|
+
...cause === void 0 ? {} : { cause }
|
|
176
|
+
});
|
|
177
|
+
const capacityFailure = (message) => failure(message, AgentPersistenceCapacityError.make({ message }));
|
|
178
|
+
const isExecutionProgressRecord = (record) => record.payload._tag === "RunContinuation";
|
|
179
|
+
const validateBatchShape = Schema.decodeUnknownSync(Schema.Struct({
|
|
180
|
+
batchId: CanonicalBatch.fields.batchId,
|
|
181
|
+
producerId: CanonicalBatch.fields.producerId,
|
|
182
|
+
records: Schema.NonEmptyArray(Schema.Unknown).check(Schema.isMaxLength(256))
|
|
183
|
+
}));
|
|
184
|
+
const decodeExecutionFrontier = Schema.decodeUnknownEffect(Schema.Struct({
|
|
185
|
+
canonicalRecords: ExecutionCheckpoint.fields.canonicalRecords,
|
|
186
|
+
throughSequence: ExecutionCheckpoint.fields.throughSequence
|
|
187
|
+
}));
|
|
188
|
+
/** One private snapshot for every retry; callers cannot change facts while awaiting the gate. */
|
|
189
|
+
const captureFacts = (batch) => Effect.try({
|
|
190
|
+
try: () => Result.gen(function* () {
|
|
191
|
+
const inputs = batch.records;
|
|
192
|
+
const { batchId, producerId, records: slots } = validateBatchShape({
|
|
193
|
+
batchId: batch.batchId,
|
|
194
|
+
producerId: batch.producerId,
|
|
195
|
+
records: inputs
|
|
196
|
+
});
|
|
197
|
+
const records = [(yield* captureRecord(inputs[0])).canonical];
|
|
198
|
+
for (let index = 1; index < slots.length; index++) records.push((yield* captureRecord(inputs[index])).canonical);
|
|
199
|
+
return Object.freeze(CanonicalBatch.make({
|
|
200
|
+
batchId,
|
|
201
|
+
producerId,
|
|
202
|
+
records: Object.freeze(records)
|
|
203
|
+
}, { disableChecks: true }));
|
|
204
|
+
}),
|
|
205
|
+
catch: (cause) => failure("Cannot capture canonical progress facts", cause)
|
|
206
|
+
}).pipe(Effect.flatMap(Effect.fromResult), Effect.mapError((cause) => Schema.is(ThreadStoreError)(cause) ? cause : failure("Cannot capture canonical progress facts", cause)));
|
|
207
|
+
/** Exact UTF-8 wire accounting reuses the append's privately captured Schema encoding. */
|
|
208
|
+
const canonicalRecordBytes = (record) => {
|
|
209
|
+
const encoded = recordEncoding(record);
|
|
210
|
+
if (Result.isFailure(encoded)) throw encoded.failure.cause ?? new RangeError(encoded.failure.message);
|
|
211
|
+
return encoded.success.bytes;
|
|
212
|
+
};
|
|
213
|
+
/** Capture before acquiring the mutation owner; summaries never cross a wire boundary. */
|
|
214
|
+
const prepareProgressAppend = (records) => {
|
|
215
|
+
const encodings = Result.all(records.map(captureRecord));
|
|
216
|
+
if (Result.isFailure(encodings)) throw encodings.failure.cause ?? new RangeError(encodings.failure.message);
|
|
217
|
+
return Object.freeze(encodings.success.map((record) => record.progress));
|
|
218
|
+
};
|
|
219
|
+
/** These values belong to the active Run, not its permanent conversation history. */
|
|
220
|
+
const isOperationalRecord = ({ payload }) => payload._tag === "RunStarted" || payload._tag === "RunContextRecorded" || payload._tag === "RunCompleted";
|
|
221
|
+
const readContinuation = Effect.fnUntraced(function* (threadId, runId, throughSequence) {
|
|
222
|
+
const loaded = yield* (yield* ThreadReader).readExecution({
|
|
223
|
+
threadId,
|
|
224
|
+
runId
|
|
225
|
+
}).pipe(Effect.catchTag("ThreadNotMaterialized", (cause) => throughSequence === 0 ? Effect.succeedNone : failure("Active Run history is not materialized", cause)));
|
|
226
|
+
if (Option.isNone(loaded)) return Option.none();
|
|
227
|
+
const value = loaded.value;
|
|
228
|
+
if (value.progress.runId !== runId || value.throughSequence > throughSequence || canonicalRecordBytes(value.progressRecord) > 8192 || value.operational.some((record) => !isOperationalRecord(record) || !executionRunIds(record).includes(runId)) || new Set(value.operational.map((record) => record.recordId)).size !== value.operational.length) return yield* failure("Invalid active Run checkpoint");
|
|
229
|
+
return Option.some({
|
|
230
|
+
...value,
|
|
231
|
+
checkpoint: value,
|
|
232
|
+
get progress() {
|
|
233
|
+
return value.progress;
|
|
234
|
+
},
|
|
235
|
+
record: value.progressRecord,
|
|
236
|
+
continuation: value.progress
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
/** Resolve an active-only fact without presenting it as a canonical envelope or sequence. */
|
|
240
|
+
const resolveExecutionEvidence = Effect.fnUntraced(function* (threadId, checkpoint, ref) {
|
|
241
|
+
return checkpoint.operational.find((record) => record.recordId === ref.recordId) ?? (yield* resolveEvidence(threadId, ref)).record;
|
|
242
|
+
});
|
|
243
|
+
/** Each selected page is at most eight records; total resident encoded evidence is bounded. */
|
|
244
|
+
const runEvidence = (threadId, submissionId, throughSequence, afterSequence = CanonicalSequence.make(0)) => Stream.unwrap(Effect.map(ThreadReader, (reader) => Stream.suspend(() => {
|
|
245
|
+
let after = afterSequence;
|
|
246
|
+
let count = 0;
|
|
247
|
+
let bytes = 0;
|
|
248
|
+
const runId = runIdForSubmission(submissionId);
|
|
249
|
+
const controls = /* @__PURE__ */ new Set([
|
|
250
|
+
submissionInputRecordId(submissionId),
|
|
251
|
+
submissionAbortRecordId(submissionId),
|
|
252
|
+
submissionSettlementRecordId(submissionId)
|
|
253
|
+
]);
|
|
254
|
+
const next = () => Stream.unwrap(Stream.runCollect(reader.read({
|
|
255
|
+
threadId,
|
|
256
|
+
selection: {
|
|
257
|
+
_tag: "RunEvidence",
|
|
258
|
+
runId,
|
|
259
|
+
submissionId,
|
|
260
|
+
throughSequence
|
|
261
|
+
},
|
|
262
|
+
page: {
|
|
263
|
+
limit: 8,
|
|
264
|
+
...after === 0 ? {} : { afterSequence: after }
|
|
265
|
+
}
|
|
266
|
+
})).pipe(Effect.mapError((cause) => cause._tag === "ThreadStoreError" ? cause : failure("Selected Run disappeared", cause)), Effect.flatMap((page) => Effect.gen(function* () {
|
|
267
|
+
if (page.length > 8) return yield* failure("Run evidence page exceeds its record bound");
|
|
268
|
+
for (const entry of page) {
|
|
269
|
+
if (entry.threadId !== threadId || entry.sequence <= after || entry.sequence > throughSequence || entry.record.payload._tag === "RunContinuation" || !canonicalRunIds(entry.record).includes(runId) && !controls.has(entry.record.recordId)) return yield* failure("Run evidence page has invalid identity or ordering");
|
|
270
|
+
after = entry.sequence;
|
|
271
|
+
count += 1;
|
|
272
|
+
bytes += yield* Effect.try({
|
|
273
|
+
try: () => canonicalRecordBytes(entry.record),
|
|
274
|
+
catch: (cause) => failure("Selected Run evidence is malformed", cause)
|
|
275
|
+
});
|
|
276
|
+
if (count > 16388 || bytes > 42205184) return yield* failure("Selected Run evidence exceeds its recovery bound");
|
|
277
|
+
}
|
|
278
|
+
return page.length < 8 ? Stream.fromIterable(page) : Stream.concat(Stream.fromIterable(page), Stream.suspend(next));
|
|
279
|
+
}))));
|
|
280
|
+
return next();
|
|
281
|
+
})));
|
|
282
|
+
/** A bounded selected-Run suffix, never a Thread-wide tail or an implicit replay fallback. */
|
|
283
|
+
const validateSuffix = (records, through) => {
|
|
284
|
+
const suffix = records.filter((record) => record.sequence > through);
|
|
285
|
+
return suffix.length <= 64 && suffix.reduce((bytes, record) => bytes + canonicalRecordBytes(record.record), 0) <= 2097152;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Selected semantic evidence without expanding model context. Worker acknowledgements and
|
|
289
|
+
* delivery repair must validate locator completeness before treating missing effects as closed.
|
|
290
|
+
*/
|
|
291
|
+
const readRunEvidenceSnapshot = Effect.fnUntraced(function* (threadId, submissionId, throughSequence) {
|
|
292
|
+
const records = yield* Stream.runCollect(runEvidence(threadId, submissionId, throughSequence));
|
|
293
|
+
const runId = runIdForSubmission(submissionId);
|
|
294
|
+
const own = records.filter((entry) => executionRunIds(entry.record).includes(runId));
|
|
295
|
+
const progress = yield* readContinuation(threadId, runId, throughSequence);
|
|
296
|
+
if (Option.isNone(progress)) {
|
|
297
|
+
const terminal = own.findLast(({ record }) => record.payload._tag === "SubmissionSettled" && record.payload.runId === runId);
|
|
298
|
+
if (terminal?.record.payload._tag === "SubmissionSettled") {
|
|
299
|
+
if (terminal.record.payload.historyRecordCount === void 0 || own.filter((entry) => entry.sequence <= terminal.sequence).length !== terminal.record.payload.historyRecordCount) return yield* failure("Settled Run history is incomplete");
|
|
300
|
+
return records;
|
|
301
|
+
}
|
|
302
|
+
if (own.some(({ record }) => !isPreContinuationFact(record))) return yield* failure("Active execution has no durable checkpoint");
|
|
303
|
+
return records;
|
|
304
|
+
}
|
|
305
|
+
const checkpoint = progress.value;
|
|
306
|
+
const cursor = checkpoint.continuation;
|
|
307
|
+
if (cursor.submissionId !== submissionId) return yield* failure("Active checkpoint has another admitted owner");
|
|
308
|
+
if (own.filter((entry) => entry.sequence <= checkpoint.throughSequence).length !== checkpoint.canonicalRecords || !validateSuffix(own, checkpoint.throughSequence)) return yield* failure("Selected execution history is incomplete or exceeds its suffix bound");
|
|
309
|
+
const resolve = (ref) => resolveExecutionEvidence(threadId, checkpoint.checkpoint, ref);
|
|
310
|
+
const input = yield* resolve(cursor.originalInput);
|
|
311
|
+
if (input.payload._tag !== "UserInputRecorded" || input.payload.submissionId !== submissionId || input.payload.kind !== "user" || input.payload.runId !== runId) return yield* failure("Active checkpoint has no original accepted input");
|
|
312
|
+
yield* resolve(cursor.lastFact);
|
|
313
|
+
if (cursor.savedContext !== void 0) {
|
|
314
|
+
const context = yield* resolve(cursor.savedContext);
|
|
315
|
+
if (context.payload._tag !== "RunContextRecorded" || context.payload.runId !== runId) return yield* failure("Active checkpoint has invalid saved context");
|
|
316
|
+
}
|
|
317
|
+
if (cursor.latestResponse !== void 0) {
|
|
318
|
+
const response = yield* resolve(cursor.latestResponse);
|
|
319
|
+
if (response.payload._tag !== "ModelResponseRecorded" || response.payload.runId !== runId || response.payload.turn !== cursor.accounting.committedTurns) return yield* failure("Active checkpoint has invalid operation evidence");
|
|
320
|
+
}
|
|
321
|
+
if (cursor.terminal !== void 0) {
|
|
322
|
+
const terminal = yield* resolve(cursor.terminal);
|
|
323
|
+
if (terminal.payload._tag !== "RunCompleted" && terminal.payload._tag !== "RunFailed" && terminal.payload._tag !== "SubmissionSettled") return yield* failure("Active checkpoint has invalid terminal evidence");
|
|
324
|
+
}
|
|
325
|
+
return records;
|
|
326
|
+
});
|
|
327
|
+
/** Called inside the adapter's existing mutation, before publishing any fact or index. */
|
|
328
|
+
const validateProgressAppend = Effect.fnUntraced(function* (records, updates = []) {
|
|
329
|
+
const reader = yield* ProgressAppendReader;
|
|
330
|
+
if (records.some((record) => record.continuation !== void 0)) return yield* failure("Interpreter progress must be committed as active execution state");
|
|
331
|
+
const operational = new Map(updates.flatMap((update) => update.facts.map((fact) => [fact.recordId, fact])));
|
|
332
|
+
const factsAndProgress = [
|
|
333
|
+
...records,
|
|
334
|
+
...prepareProgressAppend([...operational.values()]),
|
|
335
|
+
...prepareProgressAppend(updates.map((update) => update.checkpoint.progressRecord))
|
|
336
|
+
];
|
|
337
|
+
const seen = /* @__PURE__ */ new Set();
|
|
338
|
+
let progressStarted = false;
|
|
339
|
+
for (const record of factsAndProgress) {
|
|
340
|
+
const next = record.continuation;
|
|
341
|
+
if (next === void 0) {
|
|
342
|
+
if (progressStarted) return yield* failure("Execution facts cannot follow their continuation");
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
progressStarted = true;
|
|
346
|
+
if (record.recordBytes > 8192) return yield* failure("Encoded continuation exceeds its record byte bound");
|
|
347
|
+
if (seen.has(next.runId)) return yield* failure("One atomic batch cannot publish conflicting Run progress");
|
|
348
|
+
seen.add(next.runId);
|
|
349
|
+
const update = updates.find((value) => value.checkpoint.progress.runId === next.runId);
|
|
350
|
+
if (update === void 0 || update.previousRevision + 1 !== next.revision || update.facts.some((fact) => !isOperationalRecord(fact)) || update.retire && (next.position !== "settled" || next.terminal === void 0)) return yield* failure("Invalid active execution transition");
|
|
351
|
+
const facts = factsAndProgress.filter((fact) => fact.continuation === void 0 && fact.runIds.includes(next.runId));
|
|
352
|
+
const frontier = facts.find((fact) => fact.recordId === next.lastFact.recordId);
|
|
353
|
+
const prior = yield* reader.previous(next.runId);
|
|
354
|
+
const retained = prior === void 0 ? (yield* reader.initial(next)).filter((fact) => executionRunIds(fact).includes(next.runId)) : [];
|
|
355
|
+
const retainedBytes = retained.reduce((bytes, fact) => bytes + canonicalRecordBytes(fact), 0);
|
|
356
|
+
const factBytes = facts.reduce((bytes, fact) => bytes + fact.recordBytes, 0);
|
|
357
|
+
const turnBase = prior?.turn === next.turn ? prior.turnBytes : retainedBytes;
|
|
358
|
+
const closing = facts.filter((fact) => fact.terminal);
|
|
359
|
+
if (frontier === void 0 || retained.length > 64 || retainedBytes > 2097152 || retained.some((fact) => !isPreContinuationFact(fact) || !executionRunIds(fact).includes(next.runId)) || frontier.recordId !== next.lastFact.recordId || next.revision !== (prior?.revision ?? 0) + 1 || next.recordBytes < (prior?.recordBytes ?? 0) || next.turn < (prior?.turn ?? 0) || prior !== void 0 && next.turn === prior.turn && next.turnBytes <= prior.turnBytes || next.recordBytes !== (prior?.recordBytes ?? retainedBytes) + factBytes || next.terminalUsageBytes !== (prior?.terminalUsageBytes ?? 0) + facts.reduce((bytes, fact) => bytes + fact.terminalUsageBytes, 0) || next.turnBytes !== turnBase + factBytes + record.recordBytes || next.recordCount !== (prior?.recordCount ?? retained.length) + facts.length || next.terminalRecords !== (prior?.terminalRecords ?? 0) + closing.length || next.terminalBytes !== (prior?.terminalBytes ?? 0) + closing.reduce((bytes, fact) => bytes + fact.recordBytes, 0) + (closing.length > 0 ? record.recordBytes : 0) || prior !== void 0 && (prior.submissionId !== next.submissionId || !Schema.toEquivalence(EvidenceReference)(prior.originalInput, next.originalInput) || prior.savedContext !== void 0 && (next.savedContext === void 0 || !Schema.toEquivalence(EvidenceReference)(prior.savedContext, next.savedContext))) || prior !== void 0 && [
|
|
360
|
+
"committedTurns",
|
|
361
|
+
"toolCalls",
|
|
362
|
+
"programmaticToolCalls",
|
|
363
|
+
"modelRestarts",
|
|
364
|
+
"modelCalls",
|
|
365
|
+
"inputTokens",
|
|
366
|
+
"outputTokens",
|
|
367
|
+
"costMicrousd",
|
|
368
|
+
"unobservedModelCalls",
|
|
369
|
+
"accountedToolTurn"
|
|
370
|
+
].some((field) => next.accounting[field] < prior.accounting[field]) || prior?.accounting.finalizationUsed === true && !next.accounting.finalizationUsed) return yield* failure("Run continuation conflicts with its canonical frontier or revision");
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
/** Headers/identities must themselves fit a continuation. Leave room for a result's cursor too. */
|
|
374
|
+
const resultCapacity = (state) => {
|
|
375
|
+
const response = state.response;
|
|
376
|
+
if (response === void 0 || state.continuation.position === "settling" || state.continuation.position === "settled" || state.continuation.accounting.accountedToolTurn >= response.turn) return {
|
|
377
|
+
bytes: 0,
|
|
378
|
+
records: 0
|
|
379
|
+
};
|
|
380
|
+
let bytes = 0;
|
|
381
|
+
let records = 0;
|
|
382
|
+
for (const operation of response.toolOperations) {
|
|
383
|
+
if (state.results.has(operation.toolCallId)) continue;
|
|
384
|
+
const identity = JSON.stringify({
|
|
385
|
+
recordId: toolCallSettledRecordId(response.runId, response.turn, operation.toolCallId),
|
|
386
|
+
payload: {
|
|
387
|
+
_tag: "ToolCallSettled",
|
|
388
|
+
runId: response.runId,
|
|
389
|
+
toolCallId: operation.toolCallId,
|
|
390
|
+
toolName: operation.toolName,
|
|
391
|
+
result: null,
|
|
392
|
+
isFailure: false
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
const resultBytes = operation.executionKind === "ordinary" && operation.executionClass !== "readonly" ? MAX_PERSISTED_JSON_BYTES : Math.max(response.toolResultMaxBytes, state.childResults.get(operation.toolCallId)?.resultBytes ?? 0);
|
|
396
|
+
const joining = state.childResults.get(operation.toolCallId);
|
|
397
|
+
bytes += utf8ByteLength(identity) + resultBytes + (joining?.remainingBytes ?? 0) + response.toolSelectionMaxBytes + 2 * MAX_RUN_CONTINUATION_BYTES + 256;
|
|
398
|
+
records += joining?.remainingRecords ?? 1;
|
|
399
|
+
}
|
|
400
|
+
return {
|
|
401
|
+
bytes,
|
|
402
|
+
records
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
const emptyAccounting = () => ({
|
|
406
|
+
committedTurns: 0,
|
|
407
|
+
toolCalls: 0,
|
|
408
|
+
programmaticToolCalls: 0,
|
|
409
|
+
consecutiveToolFailures: 0,
|
|
410
|
+
finalizationUsed: false,
|
|
411
|
+
modelRestarts: 0,
|
|
412
|
+
modelCalls: 0,
|
|
413
|
+
unobservedModelCalls: 0,
|
|
414
|
+
inputTokens: 0,
|
|
415
|
+
outputTokens: 0,
|
|
416
|
+
lastInputTokens: 0,
|
|
417
|
+
lastOutputTokens: 0,
|
|
418
|
+
costMicrousd: 0,
|
|
419
|
+
accountedToolTurn: 0
|
|
420
|
+
});
|
|
421
|
+
/** Recompute semantic progress solely from immutable owning facts. No port grants authority. */
|
|
422
|
+
const advanceFacts = Effect.fnUntraced(function* (previous, facts, submissionId, initialBytes) {
|
|
423
|
+
const accounting = { ...previous?.continuation.accounting ?? emptyAccounting() };
|
|
424
|
+
let savedContext = previous?.continuation.savedContext;
|
|
425
|
+
let latestResponse = previous?.continuation.latestResponse;
|
|
426
|
+
let terminal = previous?.continuation.terminal;
|
|
427
|
+
let position = previous?.continuation.position ?? "starting";
|
|
428
|
+
let response = previous?.response;
|
|
429
|
+
let results = new Map(previous?.results);
|
|
430
|
+
let childResults = new Map(previous?.childResults);
|
|
431
|
+
let completionBytes = previous?.completionBytes;
|
|
432
|
+
let factBytes = 0;
|
|
433
|
+
let turn = previous?.continuation.turn ?? 1;
|
|
434
|
+
let usageCharge = 0;
|
|
435
|
+
let closingBytes = 0;
|
|
436
|
+
let closingCount = 0;
|
|
437
|
+
for (const fact of facts) {
|
|
438
|
+
const payload = fact.payload;
|
|
439
|
+
const captured = recordEncoding(fact);
|
|
440
|
+
if (Result.isFailure(captured)) return yield* failure("Cannot account canonical progress facts", captured.failure);
|
|
441
|
+
const encoded = captured.success;
|
|
442
|
+
factBytes += encoded.bytes;
|
|
443
|
+
if ("turn" in payload) turn = Math.max(turn, payload.turn);
|
|
444
|
+
usageCharge += encoded.progress.terminalUsageBytes;
|
|
445
|
+
if (encoded.progress.terminal) {
|
|
446
|
+
closingBytes += encoded.bytes;
|
|
447
|
+
closingCount++;
|
|
448
|
+
}
|
|
449
|
+
switch (payload._tag) {
|
|
450
|
+
case "RunStarted":
|
|
451
|
+
position = "awaiting-model";
|
|
452
|
+
break;
|
|
453
|
+
case "RunContextRecorded":
|
|
454
|
+
if (savedContext !== void 0) return yield* failure("A Run's original context cannot be replaced");
|
|
455
|
+
savedContext = EvidenceReference.make({ recordId: fact.recordId });
|
|
456
|
+
position = "awaiting-model";
|
|
457
|
+
break;
|
|
458
|
+
case "ModelResponseRecorded": {
|
|
459
|
+
if (savedContext === void 0) return yield* failure("A model response has no saved original Run context");
|
|
460
|
+
if (payload.turn !== accounting.committedTurns + 1) return yield* failure("Canonical Turn progress must advance once");
|
|
461
|
+
const calls = payload.messages.content.flatMap((message) => message.role === "assistant" && typeof message.content !== "string" ? message.content.filter((part) => part.type === "tool-call") : []);
|
|
462
|
+
const summary = payload.modelUsage === void 0 ? void 0 : yield* continuationUsage(payload.modelUsage).pipe(Effect.mapError((cause) => failure("Invalid usage evidence", cause)));
|
|
463
|
+
accounting.committedTurns = payload.turn;
|
|
464
|
+
accounting.toolCalls += calls.length;
|
|
465
|
+
accounting.modelCalls += summary?.modelCalls ?? 1;
|
|
466
|
+
accounting.inputTokens += summary?.inputTokens ?? payload.inputTokens ?? 0;
|
|
467
|
+
accounting.outputTokens += summary?.outputTokens ?? payload.outputTokens ?? 0;
|
|
468
|
+
accounting.costMicrousd += summary?.costMicrousd ?? payload.costMicrousd ?? 0;
|
|
469
|
+
accounting.lastInputTokens = summary?.inputTokens ?? payload.inputTokens ?? 0;
|
|
470
|
+
accounting.lastOutputTokens = summary?.outputTokens ?? payload.outputTokens ?? 0;
|
|
471
|
+
accounting.unobservedModelCalls += payload.unobservedModelCalls ?? 0;
|
|
472
|
+
latestResponse = EvidenceReference.make({ recordId: fact.recordId });
|
|
473
|
+
response = payload;
|
|
474
|
+
results = /* @__PURE__ */ new Map();
|
|
475
|
+
childResults = /* @__PURE__ */ new Map();
|
|
476
|
+
position = payload.toolOperations.length === 0 ? "awaiting-model" : "processing-operations";
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
479
|
+
case "ToolCallSettled":
|
|
480
|
+
results.set(payload.toolCallId, payload);
|
|
481
|
+
childResults.delete(payload.toolCallId);
|
|
482
|
+
break;
|
|
483
|
+
case "ToolCallUnknown":
|
|
484
|
+
position = "unknown";
|
|
485
|
+
break;
|
|
486
|
+
case "ToolCallResolved":
|
|
487
|
+
position = "processing-operations";
|
|
488
|
+
break;
|
|
489
|
+
case "ToolApprovalRequested":
|
|
490
|
+
position = "waiting-approval";
|
|
491
|
+
break;
|
|
492
|
+
case "ToolApprovalDecided":
|
|
493
|
+
position = "processing-operations";
|
|
494
|
+
break;
|
|
495
|
+
case "SubagentRequested":
|
|
496
|
+
childResults.set(payload.toolCallId, {
|
|
497
|
+
resultBytes: Math.min(MAX_PERSISTED_JSON_BYTES, payload.budget?.allocation.resultBytes ?? 1048576),
|
|
498
|
+
remainingBytes: RUN_TERMINAL_RESERVE_BYTES,
|
|
499
|
+
remainingRecords: 4
|
|
500
|
+
});
|
|
501
|
+
position = "waiting-dependency";
|
|
502
|
+
break;
|
|
503
|
+
case "SubagentStarted":
|
|
504
|
+
{
|
|
505
|
+
const reserved = childResults.get(payload.toolCallId);
|
|
506
|
+
if (reserved !== void 0) childResults.set(payload.toolCallId, {
|
|
507
|
+
...reserved,
|
|
508
|
+
remainingBytes: Math.max(0, reserved.remainingBytes - canonicalRecordBytes(fact) - MAX_RUN_CONTINUATION_BYTES),
|
|
509
|
+
remainingRecords: reserved.remainingRecords - 1
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
position = "waiting-dependency";
|
|
513
|
+
break;
|
|
514
|
+
case "RunPolicyUsageReserved":
|
|
515
|
+
if (payload.programmaticToolCalls < accounting.programmaticToolCalls || accounting.finalizationUsed && !payload.finalizationUsed) return yield* failure("Run reservations cannot be refunded");
|
|
516
|
+
accounting.programmaticToolCalls = payload.programmaticToolCalls;
|
|
517
|
+
accounting.finalizationUsed = payload.finalizationUsed;
|
|
518
|
+
break;
|
|
519
|
+
case "ModelCallAborted": {
|
|
520
|
+
if (payload.restart !== (accounting.modelRestarts ?? 0) + 1) return yield* failure("Model restart progress must advance once");
|
|
521
|
+
const summary = yield* continuationUsage(payload.modelUsage).pipe(Effect.mapError((cause) => failure("Invalid cancelled model usage", cause)));
|
|
522
|
+
accounting.modelRestarts = payload.restart;
|
|
523
|
+
accounting.modelCalls += summary.modelCalls;
|
|
524
|
+
accounting.inputTokens += summary.inputTokens;
|
|
525
|
+
accounting.outputTokens += summary.outputTokens;
|
|
526
|
+
accounting.costMicrousd += summary.costMicrousd;
|
|
527
|
+
accounting.unobservedModelCalls += payload.unobservedModelCalls;
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
case "RunCompleted":
|
|
531
|
+
case "RunFailed":
|
|
532
|
+
completionBytes = payload._tag === "RunCompleted" ? utf8ByteLength(JSON.stringify(payload.output)) + (payload.runDisposition === void 0 ? 0 : utf8ByteLength(JSON.stringify(payload.runDisposition))) : void 0;
|
|
533
|
+
terminal = EvidenceReference.make({ recordId: fact.recordId });
|
|
534
|
+
position = "settling";
|
|
535
|
+
break;
|
|
536
|
+
case "SubmissionSettled":
|
|
537
|
+
if (payload.submissionId !== submissionId) break;
|
|
538
|
+
terminal = EvidenceReference.make({ recordId: fact.recordId });
|
|
539
|
+
position = "settled";
|
|
540
|
+
if (payload.usageSummary !== void 0) {
|
|
541
|
+
accounting.modelCalls = payload.usageSummary.modelCalls;
|
|
542
|
+
accounting.inputTokens = payload.usageSummary.inputTokens.total;
|
|
543
|
+
accounting.outputTokens = payload.usageSummary.outputTokens.total;
|
|
544
|
+
accounting.costMicrousd = payload.usageSummary.costMicrousd;
|
|
545
|
+
accounting.unobservedModelCalls = payload.usageSummary.unobservedModelCalls ?? accounting.unobservedModelCalls;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
if (response !== void 0 && response.turn > accounting.accountedToolTurn && response.toolOperations.every((operation) => results.has(operation.toolCallId))) {
|
|
550
|
+
const parts = response.messages.content.flatMap((message) => message.role === "assistant" && typeof message.content !== "string" ? message.content : []);
|
|
551
|
+
for (const call of parts) {
|
|
552
|
+
if (call.type !== "tool-call") continue;
|
|
553
|
+
const result = call.providerExecuted ? parts.find((part) => part.type === "tool-result" && part.id === call.id) : results.get(ToolCallId.make(call.id));
|
|
554
|
+
if (result === void 0 || !("isFailure" in result) || !call.providerExecuted && "budgetRejected" in result && result.budgetRejected === true) continue;
|
|
555
|
+
accounting.consecutiveToolFailures = result.isFailure ? accounting.consecutiveToolFailures + 1 : 0;
|
|
556
|
+
}
|
|
557
|
+
accounting.accountedToolTurn = response.turn;
|
|
558
|
+
results.clear();
|
|
559
|
+
if (position !== "settling" && position !== "settled") position = "awaiting-model";
|
|
560
|
+
}
|
|
561
|
+
const last = facts.at(-1);
|
|
562
|
+
if (last === void 0) return yield* failure("Progress has no owning fact");
|
|
563
|
+
if (previous?.continuation.position === "settled") position = "settled";
|
|
564
|
+
else if (previous?.continuation.position === "settling" && position !== "settled") position = "settling";
|
|
565
|
+
const turnBase = (previous?.continuation.turn === turn ? previous.continuation.turnBytes : initialBytes) + factBytes;
|
|
566
|
+
const terminalUsageBytes = (previous?.continuation.terminalUsageBytes ?? 0) + usageCharge;
|
|
567
|
+
return {
|
|
568
|
+
accounting,
|
|
569
|
+
savedContext,
|
|
570
|
+
latestResponse,
|
|
571
|
+
terminal,
|
|
572
|
+
position,
|
|
573
|
+
response,
|
|
574
|
+
results,
|
|
575
|
+
childResults,
|
|
576
|
+
completionBytes,
|
|
577
|
+
last,
|
|
578
|
+
factBytes,
|
|
579
|
+
turn,
|
|
580
|
+
turnBase,
|
|
581
|
+
usageCharge,
|
|
582
|
+
terminalUsageBytes,
|
|
583
|
+
terminalBytes: (previous?.continuation.terminalBytes ?? 0) + closingBytes,
|
|
584
|
+
terminalRecords: (previous?.continuation.terminalRecords ?? 0) + closingCount,
|
|
585
|
+
closing: closingCount > 0
|
|
586
|
+
};
|
|
587
|
+
});
|
|
588
|
+
/**
|
|
589
|
+
* Verify retained history. Mutable checkpoint revisions are deliberately not historical proof.
|
|
590
|
+
* Active original context is still checked against its exact retained historyDigest.
|
|
591
|
+
*/
|
|
592
|
+
const verifyRunContinuations = Effect.fnUntraced(function* (records, options) {
|
|
593
|
+
const inputs = records.filter(({ record }) => record.payload._tag === "UserInputRecorded" && record.payload.kind === "user" && record.payload.submissionId !== void 0);
|
|
594
|
+
if (records.some(({ record }) => record.payload._tag === "RunContinuation")) return yield* failure("Mutable interpreter progress is not canonical history");
|
|
595
|
+
for (const input of inputs) {
|
|
596
|
+
const payload = input.record.payload;
|
|
597
|
+
if (payload._tag !== "UserInputRecorded" || payload.submissionId === void 0) continue;
|
|
598
|
+
const runId = runIdForSubmission(payload.submissionId);
|
|
599
|
+
const own = records.filter((entry) => executionRunIds(entry.record).includes(runId));
|
|
600
|
+
const terminal = own.findLast(({ record }) => record.payload._tag === "SubmissionSettled" && record.payload.runId === runId);
|
|
601
|
+
if (terminal?.record.payload._tag === "SubmissionSettled") {
|
|
602
|
+
if (terminal.record.payload.historyRecordCount === void 0 || own.filter((entry) => entry.sequence <= terminal.sequence).length !== terminal.record.payload.historyRecordCount) return yield* failure("Terminal history differs from its retained fact count");
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
if (options?.verifyContext === false) continue;
|
|
606
|
+
const checkpoint = options?.executions?.find((value) => value.progress.runId === runId);
|
|
607
|
+
if (checkpoint === void 0) {
|
|
608
|
+
if (own.some(({ record }) => !isPreContinuationFact(record))) return yield* failure("Active execution is missing its authoritative checkpoint");
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
const saved = checkpoint.operational.find(({ payload }) => payload._tag === "RunContextRecorded");
|
|
612
|
+
if (saved?.payload._tag === "RunContextRecorded") {
|
|
613
|
+
yield* validateContextBoundary(saved.payload, input).pipe(Effect.mapError((cause) => failure("Context has an invalid admission boundary", cause)));
|
|
614
|
+
yield* readRunContext(saved.payload, input, saved.recordId).pipe(Effect.mapError((cause) => failure("Context differs from its original history", cause)));
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
/**
|
|
619
|
+
* Prepare progress for the existing atomic append/publication. Accept the returned state only
|
|
620
|
+
* after that append commits; a failed or stale producer cannot publish speculative progress.
|
|
621
|
+
* One writer retains bounded metadata for its active Run, not its historical results or IDs.
|
|
622
|
+
*/
|
|
623
|
+
const makeProgressWriter = Effect.fnUntraced(function* (threadId, deploymentId) {
|
|
624
|
+
const reader = yield* ThreadReader;
|
|
625
|
+
const gate = yield* Semaphore.make(1);
|
|
626
|
+
const cached = /* @__PURE__ */ new Map();
|
|
627
|
+
let verifiedEmpty;
|
|
628
|
+
const reservations = /* @__PURE__ */ new Map();
|
|
629
|
+
const stagedUsage = /* @__PURE__ */ new Map();
|
|
630
|
+
const provide = (effect) => Effect.provideService(effect, ThreadReader, reader);
|
|
631
|
+
const loadUncachedState = Effect.fnUntraced(function* (runId, after) {
|
|
632
|
+
const loaded = yield* provide(readContinuation(threadId, runId, after));
|
|
633
|
+
if (Option.isNone(loaded)) return void 0;
|
|
634
|
+
const continuation = loaded.value.continuation;
|
|
635
|
+
let response;
|
|
636
|
+
let completionBytes;
|
|
637
|
+
const results = /* @__PURE__ */ new Map();
|
|
638
|
+
const childResults = /* @__PURE__ */ new Map();
|
|
639
|
+
if (continuation.latestResponse !== void 0) {
|
|
640
|
+
const evidence = yield* provide(resolveEvidence(threadId, continuation.latestResponse));
|
|
641
|
+
if (evidence.record.payload._tag !== "ModelResponseRecorded" || evidence.record.payload.runId !== runId) return yield* failure("Continuation operation reference is invalid");
|
|
642
|
+
response = evidence.record.payload;
|
|
643
|
+
if (continuation.accounting.accountedToolTurn < response.turn) for (const operation of response.toolOperations) {
|
|
644
|
+
const found = yield* provide(getRecord({
|
|
645
|
+
threadId,
|
|
646
|
+
recordId: toolCallSettledRecordId(runId, response.turn, operation.toolCallId)
|
|
647
|
+
}));
|
|
648
|
+
if (Option.isSome(found)) {
|
|
649
|
+
const result = found.value.record.payload;
|
|
650
|
+
if (result._tag !== "ToolCallSettled" || result.runId !== runId || result.toolCallId !== operation.toolCallId || result.toolName !== operation.toolName) return yield* failure("Continuation result identity is invalid");
|
|
651
|
+
results.set(operation.toolCallId, result);
|
|
652
|
+
} else if (operation.executionKind === "delegation") {
|
|
653
|
+
const requested = yield* provide(getRecord({
|
|
654
|
+
threadId,
|
|
655
|
+
recordId: subagentRequestedRecordId(runId, operation.toolCallId)
|
|
656
|
+
}));
|
|
657
|
+
if (Option.isSome(requested) && requested.value.record.payload._tag === "SubagentRequested") {
|
|
658
|
+
if (requested.value.record.payload.runId !== runId || requested.value.record.payload.toolCallId !== operation.toolCallId) return yield* failure("Continuation child request identity is invalid");
|
|
659
|
+
const started = yield* provide(getRecord({
|
|
660
|
+
threadId,
|
|
661
|
+
recordId: subagentStartedRecordId(runId, operation.toolCallId)
|
|
662
|
+
}));
|
|
663
|
+
if (Option.isSome(started) && (started.value.record.payload._tag !== "SubagentStarted" || started.value.record.payload.runId !== runId || started.value.record.payload.toolCallId !== operation.toolCallId || started.value.record.payload.childThreadId !== requested.value.record.payload.childThreadId)) return yield* failure("Continuation child start identity is invalid");
|
|
664
|
+
const startedBytes = Option.isSome(started) ? canonicalRecordBytes(started.value.record) + MAX_RUN_CONTINUATION_BYTES : 0;
|
|
665
|
+
childResults.set(operation.toolCallId, {
|
|
666
|
+
resultBytes: Math.min(MAX_PERSISTED_JSON_BYTES, requested.value.record.payload.budget?.allocation.resultBytes ?? 1048576),
|
|
667
|
+
remainingBytes: Math.max(0, RUN_TERMINAL_RESERVE_BYTES - startedBytes),
|
|
668
|
+
remainingRecords: Option.isSome(started) ? 3 : 4
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
if (continuation.position === "settling" && continuation.terminal !== void 0) {
|
|
675
|
+
const payload = (yield* provide(resolveExecutionEvidence(threadId, loaded.value.checkpoint, continuation.terminal))).payload;
|
|
676
|
+
if (payload._tag === "RunCompleted") completionBytes = utf8ByteLength(JSON.stringify(payload.output)) + (payload.runDisposition === void 0 ? 0 : utf8ByteLength(JSON.stringify(payload.runDisposition)));
|
|
677
|
+
}
|
|
678
|
+
return {
|
|
679
|
+
continuation,
|
|
680
|
+
record: loaded.value.record,
|
|
681
|
+
checkpoint: loaded.value.checkpoint,
|
|
682
|
+
...response === void 0 ? {} : { response },
|
|
683
|
+
results,
|
|
684
|
+
childResults,
|
|
685
|
+
...completionBytes === void 0 ? {} : { completionBytes }
|
|
686
|
+
};
|
|
687
|
+
});
|
|
688
|
+
const checkFutureShapes = (state, cursorBytes) => {
|
|
689
|
+
const progress = state.continuation;
|
|
690
|
+
if (progress.position === "settled") return Effect.void;
|
|
691
|
+
const size = cursorBytes ?? canonicalRecordBytes(state.record);
|
|
692
|
+
const textBytes = (value) => utf8ByteLength(JSON.stringify(value));
|
|
693
|
+
const refBytes = (value) => utf8ByteLength(JSON.stringify(value));
|
|
694
|
+
const ref = (recordId) => EvidenceReference.make({ recordId });
|
|
695
|
+
const fits = (batchId, lastFact, terminal) => size + textBytes(JSON.stringify([
|
|
696
|
+
"continuation@1",
|
|
697
|
+
progress.runId,
|
|
698
|
+
batchId
|
|
699
|
+
])) - textBytes(state.record.recordId) + textBytes(deploymentId) - textBytes(state.record.deploymentId) + refBytes(lastFact) - refBytes(progress.lastFact) + (terminal === void 0 ? 0 : refBytes(terminal) - (progress.terminal === void 0 ? 0 : refBytes(progress.terminal)) + 12) + 1024 <= MAX_RUN_CONTINUATION_BYTES;
|
|
700
|
+
if (!fits(submissionSettlementBatchId(progress.submissionId), ref(submissionSettlementRecordId(progress.submissionId)), ref(runCompletedRecordId(progress.runId)))) return Effect.fail(capacityFailure("Run has no room for a terminal continuation envelope"));
|
|
701
|
+
if (state.response !== void 0 && progress.accounting.accountedToolTurn < state.response.turn) for (const operation of state.response.toolOperations) {
|
|
702
|
+
if (state.results.has(operation.toolCallId)) continue;
|
|
703
|
+
if (!fits(toolCallResultBatchId(progress.runId, state.response.turn, operation.toolCallId), ref(toolCallSettledRecordId(progress.runId, state.response.turn, operation.toolCallId)))) return Effect.fail(capacityFailure("Tool dispatch has no room for its result continuation envelope"));
|
|
704
|
+
}
|
|
705
|
+
return Effect.void;
|
|
706
|
+
};
|
|
707
|
+
const checkCapacity = (state, consumed = /* @__PURE__ */ new Set(), extra, committedUsageBytes = 0) => {
|
|
708
|
+
const progress = state.continuation;
|
|
709
|
+
const pending = resultCapacity(state);
|
|
710
|
+
const terminal = progress.position === "settled" ? 0 : Math.max(0, RUN_TERMINAL_RESERVE_BYTES + 2 * (state.completionBytes ?? 0) + 2 * (progress.terminalUsageBytes + Math.max(0, (stagedUsage.get(progress.runId) ?? 0) - committedUsageBytes)) - progress.terminalBytes);
|
|
711
|
+
let turnBytes = (extra !== void 0 && extra.turn !== progress.turn ? 0 : progress.turnBytes) + pending.bytes + terminal + (extra?.bytes ?? 0);
|
|
712
|
+
let recordBytes = progress.recordBytes + pending.bytes + terminal + (extra?.bytes ?? 0);
|
|
713
|
+
let recordCount = progress.recordCount + pending.records + (progress.position === "settled" ? 0 : Math.max(0, 4 - progress.terminalRecords)) + (extra?.records ?? 0);
|
|
714
|
+
for (const [recordId, reservation] of reservations) {
|
|
715
|
+
if (reservation.runId !== progress.runId || consumed.has(recordId)) continue;
|
|
716
|
+
if (reservation.turn === (extra?.turn ?? progress.turn)) turnBytes += reservation.bytes;
|
|
717
|
+
recordBytes += reservation.bytes;
|
|
718
|
+
recordCount += reservation.records;
|
|
719
|
+
}
|
|
720
|
+
if (turnBytes > 4194304 || recordBytes > 33554432 || recordCount > 16384) return Effect.fail(failure("Run has no remaining canonical dispatch capacity", AgentPersistenceCapacityError.make({ message: "Run has no room for the next result and a bounded terminal settlement" })));
|
|
721
|
+
return Effect.void;
|
|
722
|
+
};
|
|
723
|
+
const prepare = Effect.fnUntraced(function* (batch, after, mode = "commit") {
|
|
724
|
+
if (batch.records.some((record) => record.payload._tag === "RunContinuation")) return yield* failure("A caller cannot supply interpreter progress to the progress writer");
|
|
725
|
+
const ownedRecords = [...batch.records];
|
|
726
|
+
const groups = /* @__PURE__ */ new Map();
|
|
727
|
+
for (const record of ownedRecords) for (const runId of executionRunIds(record)) {
|
|
728
|
+
const facts = groups.get(runId) ?? [];
|
|
729
|
+
facts.push(record);
|
|
730
|
+
groups.set(runId, facts);
|
|
731
|
+
}
|
|
732
|
+
const executions = [];
|
|
733
|
+
const accepted = /* @__PURE__ */ new Map();
|
|
734
|
+
let executionCount = 0;
|
|
735
|
+
for (const [runId, facts] of groups) {
|
|
736
|
+
const empty = verifiedEmpty?.runId === runId && verifiedEmpty.through === after && verifiedEmpty.writer === Option.getOrUndefined(yield* Effect.serviceOption(CurrentRunWriter));
|
|
737
|
+
const previous = empty ? void 0 : cached.get(runId) ?? (yield* loadUncachedState(runId, after));
|
|
738
|
+
let original = facts.find((record) => record.payload._tag === "UserInputRecorded" && record.payload.kind === "user" && record.payload.runId === runId && record.payload.submissionId !== void 0);
|
|
739
|
+
let originalCount = 0;
|
|
740
|
+
let initialBytes = 0;
|
|
741
|
+
let originalSequence = previous?.checkpoint?.originalSequence;
|
|
742
|
+
if (previous === void 0 && original === void 0) {
|
|
743
|
+
const input = yield* provide(getRunInput({
|
|
744
|
+
threadId,
|
|
745
|
+
runId
|
|
746
|
+
}));
|
|
747
|
+
if (Option.isNone(input) || input.value.record.payload._tag !== "UserInputRecorded" || input.value.record.payload.submissionId === void 0) continue;
|
|
748
|
+
original = input.value.record;
|
|
749
|
+
originalSequence = input.value.sequence;
|
|
750
|
+
}
|
|
751
|
+
const submissionId = previous?.continuation.submissionId ?? (original?.payload._tag === "UserInputRecorded" ? original.payload.submissionId : void 0);
|
|
752
|
+
if (submissionId === void 0) return yield* failure("Run progress has no original admission identity");
|
|
753
|
+
if (runId !== runIdForSubmission(submissionId)) return yield* failure("Run progress conflicts with its original admission");
|
|
754
|
+
if (previous === void 0 && original === void 0) return yield* failure("Run has no accepted original input");
|
|
755
|
+
if (previous === void 0 && !empty) {
|
|
756
|
+
const settled = yield* provide(getRecord({
|
|
757
|
+
threadId,
|
|
758
|
+
recordId: submissionSettlementRecordId(submissionId)
|
|
759
|
+
}));
|
|
760
|
+
if (Option.isSome(settled) && settled.value.sequence <= after && settled.value.record.payload._tag === "SubmissionSettled" && settled.value.record.payload.runId === runId && settled.value.record.payload.historyRecordCount !== void 0 && facts.every(({ payload }) => payload._tag === "WorkerReportPrepared" || payload._tag === "SubmissionSettled" || payload._tag === "ToolCallSettled" || payload._tag === "ToolCallResolved" || payload._tag === "SubagentJoined")) continue;
|
|
761
|
+
const existing = (yield* provide(Stream.runCollect(runEvidence(threadId, submissionId, after).pipe(Stream.take(65))))).filter(({ record }) => executionRunIds(record).includes(runId));
|
|
762
|
+
if (!validateSuffix(existing, CanonicalSequence.make(0)) || existing.some(({ record }) => !isPreContinuationFact(record))) return yield* failure(`Run execution has no active checkpoint or exceeds its preparation bound (${facts.map((fact) => fact.payload._tag).join(", ")})`);
|
|
763
|
+
originalCount = existing.length;
|
|
764
|
+
initialBytes = existing.reduce((bytes, entry) => bytes + canonicalRecordBytes(entry.record), 0);
|
|
765
|
+
}
|
|
766
|
+
const canonicalRecords = (previous?.checkpoint?.canonicalRecords ?? originalCount) + facts.filter((fact) => !isOperationalRecord(fact)).length;
|
|
767
|
+
for (let index = 0; index < facts.length; index++) {
|
|
768
|
+
const fact = facts[index];
|
|
769
|
+
const payload = fact.payload;
|
|
770
|
+
if (payload._tag !== "SubmissionSettled" || payload.runId !== runId) continue;
|
|
771
|
+
const retained = yield* Effect.fromResult(captureRecord(RecordEnvelope.make({
|
|
772
|
+
...fact,
|
|
773
|
+
payload: {
|
|
774
|
+
...payload,
|
|
775
|
+
historyRecordCount: canonicalRecords
|
|
776
|
+
}
|
|
777
|
+
}))).pipe(Effect.map((record) => record.canonical), Effect.mapError((cause) => failure("Cannot capture canonical progress facts", cause)));
|
|
778
|
+
facts[index] = retained;
|
|
779
|
+
ownedRecords[ownedRecords.indexOf(fact)] = retained;
|
|
780
|
+
}
|
|
781
|
+
const originalInput = previous !== void 0 ? previous.continuation.originalInput : original === void 0 ? yield* failure("Run progress has no original input") : EvidenceReference.make({ recordId: original.recordId });
|
|
782
|
+
const next = yield* advanceFacts(previous, facts, submissionId, initialBytes);
|
|
783
|
+
const { accounting, savedContext, latestResponse, terminal, position, response, results, childResults, completionBytes, last, factBytes, turn, turnBase, usageCharge, terminalUsageBytes } = next;
|
|
784
|
+
let continuation = RunContinuation.make({
|
|
785
|
+
version: 1,
|
|
786
|
+
runId,
|
|
787
|
+
submissionId,
|
|
788
|
+
revision: (previous?.continuation.revision ?? 0) + 1,
|
|
789
|
+
recordCount: (previous?.continuation.recordCount ?? originalCount) + facts.length,
|
|
790
|
+
recordBytes: (previous?.continuation.recordBytes ?? initialBytes) + factBytes,
|
|
791
|
+
turn,
|
|
792
|
+
turnBytes: turnBase,
|
|
793
|
+
terminalUsageBytes,
|
|
794
|
+
terminalBytes: next.terminalBytes,
|
|
795
|
+
terminalRecords: next.terminalRecords,
|
|
796
|
+
originalInput,
|
|
797
|
+
...savedContext === void 0 ? {} : { savedContext },
|
|
798
|
+
...latestResponse === void 0 ? {} : { latestResponse },
|
|
799
|
+
...terminal === void 0 ? {} : { terminal },
|
|
800
|
+
lastFact: EvidenceReference.make({ recordId: last.recordId }),
|
|
801
|
+
position,
|
|
802
|
+
accounting
|
|
803
|
+
}, { disableChecks: true });
|
|
804
|
+
const header = {
|
|
805
|
+
recordId: RecordId.make(JSON.stringify([
|
|
806
|
+
"continuation@1",
|
|
807
|
+
runId,
|
|
808
|
+
batch.batchId
|
|
809
|
+
])),
|
|
810
|
+
family: "thread",
|
|
811
|
+
schemaVersion: 1,
|
|
812
|
+
createdAt: last.createdAt,
|
|
813
|
+
deploymentId: last.deploymentId
|
|
814
|
+
};
|
|
815
|
+
const provisional = {
|
|
816
|
+
...header,
|
|
817
|
+
createdAt: DateTime.formatIso(header.createdAt),
|
|
818
|
+
payload: continuation
|
|
819
|
+
};
|
|
820
|
+
const initialCursorBytes = utf8ByteLength(JSON.stringify(provisional));
|
|
821
|
+
const initialWidth = String(continuation.turnBytes).length + String(continuation.terminalBytes).length;
|
|
822
|
+
let turnBytes = continuation.turnBytes;
|
|
823
|
+
let terminalBytes = continuation.terminalBytes;
|
|
824
|
+
for (let attempts = 0;; attempts++) {
|
|
825
|
+
const cursorBytes = initialCursorBytes + String(turnBytes).length + String(terminalBytes).length - initialWidth;
|
|
826
|
+
const nextTurnBytes = turnBase + cursorBytes;
|
|
827
|
+
const nextTerminalBytes = next.terminalBytes + (next.closing ? cursorBytes : 0);
|
|
828
|
+
if (nextTurnBytes === turnBytes && nextTerminalBytes === terminalBytes) break;
|
|
829
|
+
if (attempts >= 4) return yield* failure("Continuation byte accounting did not converge");
|
|
830
|
+
turnBytes = nextTurnBytes;
|
|
831
|
+
terminalBytes = nextTerminalBytes;
|
|
832
|
+
}
|
|
833
|
+
continuation = RunContinuation.make({
|
|
834
|
+
...continuation,
|
|
835
|
+
turnBytes,
|
|
836
|
+
terminalBytes
|
|
837
|
+
}, { disableChecks: true });
|
|
838
|
+
const proposedRecord = RecordEnvelope.make({
|
|
839
|
+
...header,
|
|
840
|
+
payload: continuation
|
|
841
|
+
}, { disableChecks: true });
|
|
842
|
+
const cursorBytes = turnBytes - turnBase;
|
|
843
|
+
if (cursorBytes > 8192) return yield* capacityFailure("Encoded continuation exceeds 8192 bytes including its envelope");
|
|
844
|
+
executionCount++;
|
|
845
|
+
if (mode === "preflight" && previous?.checkpoint !== void 0 && facts.every(({ payload }) => payload._tag === "ModelResponseRecorded")) {
|
|
846
|
+
continuation = yield* RunContinuation.makeEffect({ ...continuation }).pipe(Effect.mapError(() => capacityFailure("Canonical continuation exceeds its protocol bounds")));
|
|
847
|
+
yield* decodeExecutionFrontier({
|
|
848
|
+
canonicalRecords,
|
|
849
|
+
throughSequence: after + ownedRecords.filter((fact) => !isOperationalRecord(fact)).length
|
|
850
|
+
}).pipe(Effect.mapError((cause) => failure("Active execution exceeds its bounds", cause)));
|
|
851
|
+
const state = {
|
|
852
|
+
continuation,
|
|
853
|
+
record: proposedRecord,
|
|
854
|
+
...response === void 0 ? {} : { response },
|
|
855
|
+
results,
|
|
856
|
+
childResults,
|
|
857
|
+
...completionBytes === void 0 ? {} : { completionBytes }
|
|
858
|
+
};
|
|
859
|
+
yield* checkCapacity(state, new Set(batch.records.map(({ recordId }) => recordId)), void 0, usageCharge);
|
|
860
|
+
yield* checkFutureShapes(state, cursorBytes);
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
const record = yield* Effect.fromResult(captureRecord(proposedRecord)).pipe(Effect.map((record) => record.canonical), Effect.mapError((cause) => Schema.isSchemaError(cause.cause) ? capacityFailure("Canonical continuation exceeds its protocol bounds") : failure("Cannot capture canonical progress facts", cause)));
|
|
864
|
+
if (!isExecutionProgressRecord(record)) return yield* failure("Captured execution has no Run continuation");
|
|
865
|
+
if (canonicalRecordBytes(record) !== cursorBytes) return yield* failure("Continuation byte accounting differs from its Schema encoding");
|
|
866
|
+
const operational = new Map((previous?.checkpoint?.operational ?? []).map((fact) => [fact.recordId, fact]));
|
|
867
|
+
const changed = facts.filter(isOperationalRecord);
|
|
868
|
+
for (const fact of changed) {
|
|
869
|
+
const prior = operational.get(fact.recordId);
|
|
870
|
+
if (prior !== void 0 && (yield* Effect.fromResult(recordEncoding(prior)).pipe(Effect.mapError((cause) => failure("Cannot encode active Run fact", cause)))).json !== (yield* Effect.fromResult(recordEncoding(fact)).pipe(Effect.mapError((cause) => failure("Cannot encode active Run fact", cause)))).json) return yield* failure("An active Run fact cannot change after becoming durable");
|
|
871
|
+
operational.set(fact.recordId, fact);
|
|
872
|
+
}
|
|
873
|
+
const checkpoint = ExecutionCheckpoint.make({
|
|
874
|
+
version: 2,
|
|
875
|
+
progressRecord: record,
|
|
876
|
+
operational: [...operational.values()],
|
|
877
|
+
canonicalRecords,
|
|
878
|
+
originalSequence: originalSequence ?? CanonicalSequence.make(after + ownedRecords.filter((fact) => !isOperationalRecord(fact)).findIndex((fact) => fact.recordId === originalInput.recordId) + 1),
|
|
879
|
+
throughSequence: CanonicalSequence.make(after + ownedRecords.filter((fact) => !isOperationalRecord(fact)).length),
|
|
880
|
+
batchId: batch.batchId
|
|
881
|
+
}, { disableChecks: true });
|
|
882
|
+
const state = {
|
|
883
|
+
continuation: record.payload,
|
|
884
|
+
record,
|
|
885
|
+
checkpoint,
|
|
886
|
+
...response === void 0 ? {} : { response },
|
|
887
|
+
results,
|
|
888
|
+
childResults,
|
|
889
|
+
...completionBytes === void 0 ? {} : { completionBytes }
|
|
890
|
+
};
|
|
891
|
+
if (!facts.every((fact) => isTerminalBudgetFact(fact) && fact.payload._tag !== "RunCompleted")) yield* checkCapacity(state, new Set(batch.records.map(({ recordId }) => recordId)), void 0, usageCharge);
|
|
892
|
+
yield* checkFutureShapes(state);
|
|
893
|
+
executions.push(ExecutionUpdate.make({
|
|
894
|
+
previousRevision: previous?.continuation.revision ?? 0,
|
|
895
|
+
checkpoint,
|
|
896
|
+
facts: changed,
|
|
897
|
+
retire: position === "settled"
|
|
898
|
+
}, { disableChecks: true }));
|
|
899
|
+
accepted.set(runId, state);
|
|
900
|
+
}
|
|
901
|
+
if (ownedRecords.length + executionCount > 256) return yield* failure("Progress and facts exceed the atomic batch bound");
|
|
902
|
+
return {
|
|
903
|
+
batch: CommitBatch.make({
|
|
904
|
+
...batch,
|
|
905
|
+
records: ownedRecords.filter((fact) => !isOperationalRecord(fact))
|
|
906
|
+
}, { disableChecks: true }),
|
|
907
|
+
executions,
|
|
908
|
+
accept: () => {
|
|
909
|
+
for (const record of batch.records) reservations.delete(record.recordId);
|
|
910
|
+
for (const [runId, state] of accepted) if (executions.find((update) => update.checkpoint.progress.runId === runId)?.retire) cached.delete(runId);
|
|
911
|
+
else cached.set(runId, state);
|
|
912
|
+
while (cached.size > 8) {
|
|
913
|
+
const first = cached.keys().next().value;
|
|
914
|
+
if (first !== void 0) cached.delete(first);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
});
|
|
919
|
+
const tail = Effect.flatMap(CurrentRunWriter, (writer) => writer.threadId !== threadId ? Effect.fail(failure("Progress writer belongs to another Thread")) : Effect.map(writer.tail, (position) => position.sequence));
|
|
920
|
+
const commitCaptured = Effect.fnUntraced(function* (batch) {
|
|
921
|
+
const writer = yield* CurrentRunWriter;
|
|
922
|
+
for (let retries = 0;; retries++) {
|
|
923
|
+
const prepared = yield* prepare(batch, yield* tail).pipe(Effect.catchTag("ThreadNotMaterialized", (cause) => failure("Selected Run disappeared during progress publication", cause)));
|
|
924
|
+
const result = yield* writer.append(prepared.batch, prepared.executions).pipe(Effect.catchTag("AppendConflict", (conflict) => {
|
|
925
|
+
if (conflict.reason !== "tail" || retries >= 8) return Effect.fail(conflict);
|
|
926
|
+
cached.clear();
|
|
927
|
+
return Effect.as(Effect.void, void 0);
|
|
928
|
+
}));
|
|
929
|
+
if (result === void 0) continue;
|
|
930
|
+
if (result.replayed) cached.clear();
|
|
931
|
+
else prepared.accept();
|
|
932
|
+
return result;
|
|
933
|
+
}
|
|
934
|
+
}, (effect) => Effect.flatMap(CurrentRunWriter, (writer) => writer.withProgress(gate.withPermits(1)(effect))));
|
|
935
|
+
const publishCaptured = Effect.fnUntraced(function* (batch) {
|
|
936
|
+
const publisher = yield* CurrentRunSettlement;
|
|
937
|
+
if (publisher.threadId !== threadId) return yield* failure("Settlement publisher belongs to another Thread");
|
|
938
|
+
for (let retries = 0;; retries++) {
|
|
939
|
+
const prepared = yield* prepare(batch, (yield* publisher.tail).sequence).pipe(Effect.catchTag("ThreadNotMaterialized", (cause) => failure("Selected Run disappeared during progress publication", cause)));
|
|
940
|
+
const first = prepared.batch.records[0];
|
|
941
|
+
if (first === void 0) return yield* failure("Settlement must publish a retained terminal fact");
|
|
942
|
+
const terminalBatch = CanonicalBatch.make({
|
|
943
|
+
...prepared.batch,
|
|
944
|
+
records: [first, ...prepared.batch.records.slice(1)]
|
|
945
|
+
}, { disableChecks: true });
|
|
946
|
+
const result = yield* publisher.publishSettlement(terminalBatch, prepared.executions).pipe(Effect.catchTag("AppendConflict", (conflict) => {
|
|
947
|
+
if (conflict.reason !== "tail" || retries >= 8) return Effect.fail(conflict);
|
|
948
|
+
cached.clear();
|
|
949
|
+
return Effect.as(Effect.void, void 0);
|
|
950
|
+
}));
|
|
951
|
+
if (result === void 0) continue;
|
|
952
|
+
if (result.replayed) cached.clear();
|
|
953
|
+
else prepared.accept();
|
|
954
|
+
return result;
|
|
955
|
+
}
|
|
956
|
+
}, (effect) => Effect.flatMap(CurrentRunSettlement, (writer) => writer.withProgress(gate.withPermits(1)(effect))));
|
|
957
|
+
const commit = (batch) => captureFacts(batch).pipe(Effect.flatMap(commitCaptured));
|
|
958
|
+
const publish = (batch) => captureFacts(batch).pipe(Effect.flatMap(publishCaptured));
|
|
959
|
+
const preflight = (batch) => gate.withPermits(1)(Effect.gen(function* () {
|
|
960
|
+
const owned = yield* captureFacts(batch);
|
|
961
|
+
yield* prepare(owned, yield* tail, "preflight");
|
|
962
|
+
}));
|
|
963
|
+
const reserve = (runId, probe, bytes) => gate.withPermits(1)(Effect.gen(function* () {
|
|
964
|
+
const after = yield* tail;
|
|
965
|
+
yield* prepare(yield* captureFacts(probe), after);
|
|
966
|
+
const recordId = probe.records[0].recordId;
|
|
967
|
+
const state = cached.get(runId) ?? (yield* loadUncachedState(runId, after));
|
|
968
|
+
if (state === void 0) return yield* failure("Dispatch has no canonical Run progress");
|
|
969
|
+
if (reservations.has(recordId)) return yield* failure("Dispatch capacity is already reserved");
|
|
970
|
+
yield* checkCapacity(state, /* @__PURE__ */ new Set(), {
|
|
971
|
+
turn: state.continuation.turn,
|
|
972
|
+
bytes,
|
|
973
|
+
records: 1
|
|
974
|
+
});
|
|
975
|
+
reservations.set(recordId, {
|
|
976
|
+
runId,
|
|
977
|
+
turn: state.continuation.turn,
|
|
978
|
+
bytes,
|
|
979
|
+
records: 1
|
|
980
|
+
});
|
|
981
|
+
return yield* Effect.succeed(gate.withPermits(1)(Effect.sync(() => {
|
|
982
|
+
reservations.delete(recordId);
|
|
983
|
+
})));
|
|
984
|
+
}));
|
|
985
|
+
const defer = (batch) => gate.withPermits(1)(Effect.gen(function* () {
|
|
986
|
+
const after = yield* tail;
|
|
987
|
+
const owned = yield* captureFacts(batch);
|
|
988
|
+
yield* prepare(owned, after, "preflight");
|
|
989
|
+
const response = owned.records.find((record) => record.payload._tag === "ModelResponseRecorded");
|
|
990
|
+
if (response === void 0 || response.payload._tag !== "ModelResponseRecorded") return yield* failure("Deferred dispatch has no response");
|
|
991
|
+
const progress = cached.get(response.payload.runId) ?? (yield* loadUncachedState(response.payload.runId, after));
|
|
992
|
+
if (progress === void 0) return yield* failure("Deferred dispatch has no Run progress");
|
|
993
|
+
const pending = resultCapacity({
|
|
994
|
+
...progress,
|
|
995
|
+
continuation: {
|
|
996
|
+
...progress.continuation,
|
|
997
|
+
accounting: {
|
|
998
|
+
...progress.continuation.accounting,
|
|
999
|
+
accountedToolTurn: 0
|
|
1000
|
+
}
|
|
1001
|
+
},
|
|
1002
|
+
response: response.payload,
|
|
1003
|
+
results: /* @__PURE__ */ new Map(),
|
|
1004
|
+
childResults: /* @__PURE__ */ new Map()
|
|
1005
|
+
});
|
|
1006
|
+
const bytes = owned.records.reduce((total, record) => total + canonicalRecordBytes(record), 0) + MAX_RUN_CONTINUATION_BYTES + pending.bytes;
|
|
1007
|
+
const records = owned.records.length + pending.records;
|
|
1008
|
+
yield* checkCapacity(progress, /* @__PURE__ */ new Set(), {
|
|
1009
|
+
turn: response.payload.turn,
|
|
1010
|
+
bytes,
|
|
1011
|
+
records
|
|
1012
|
+
});
|
|
1013
|
+
reservations.set(response.recordId, {
|
|
1014
|
+
runId: response.payload.runId,
|
|
1015
|
+
turn: response.payload.turn,
|
|
1016
|
+
bytes,
|
|
1017
|
+
records
|
|
1018
|
+
});
|
|
1019
|
+
return owned;
|
|
1020
|
+
}));
|
|
1021
|
+
const checkState = (state, recovered) => {
|
|
1022
|
+
if (state === void 0) return Effect.fail(failure("Execution has no canonical Run progress"));
|
|
1023
|
+
const capacity = () => state.continuation.position === "settling" || state.continuation.position === "settled" ? Effect.void : checkCapacity(state);
|
|
1024
|
+
return recovered ? Effect.andThen(checkFutureShapes(state), capacity) : capacity();
|
|
1025
|
+
};
|
|
1026
|
+
const check = (runId) => gate.withPermits(1)(Effect.flatMap(CurrentRunWriter, (writer) => {
|
|
1027
|
+
if (writer.threadId !== threadId) return Effect.fail(failure("Progress writer belongs to another Thread"));
|
|
1028
|
+
const retained = cached.get(runId);
|
|
1029
|
+
if (retained !== void 0) return checkState(retained, false);
|
|
1030
|
+
return Effect.flatMap(writer.tail, (position) => Effect.flatMap(loadUncachedState(runId, position.sequence), (state) => checkState(state, true)));
|
|
1031
|
+
}));
|
|
1032
|
+
return {
|
|
1033
|
+
commit,
|
|
1034
|
+
publish,
|
|
1035
|
+
preflight,
|
|
1036
|
+
reserve,
|
|
1037
|
+
defer,
|
|
1038
|
+
check,
|
|
1039
|
+
/** Scope a verified empty execution/evidence view to one owned initialization body.
|
|
1040
|
+
* The caller holds progress+mutation gates; a changed writer or tail never reuses it. */
|
|
1041
|
+
withVerifiedEmptyRun: (runId, through, body) => Effect.flatMap(CurrentRunWriter, (writer) => {
|
|
1042
|
+
const view = {
|
|
1043
|
+
runId,
|
|
1044
|
+
through,
|
|
1045
|
+
writer
|
|
1046
|
+
};
|
|
1047
|
+
verifiedEmpty = view;
|
|
1048
|
+
return body.pipe(Effect.ensuring(Effect.sync(() => {
|
|
1049
|
+
if (verifiedEmpty === view) verifiedEmpty = void 0;
|
|
1050
|
+
})));
|
|
1051
|
+
}),
|
|
1052
|
+
stageUsage: (runId, bytes) => {
|
|
1053
|
+
if (bytes === 0) stagedUsage.delete(runId);
|
|
1054
|
+
else stagedUsage.set(runId, bytes);
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
});
|
|
1058
|
+
export { readRunContext as _, canonicalRecordBytes as a, reference as b, prepareProgressAppend as c, resolveExecutionEvidence as d, runEvidence as f, digestRunHistory as g, verifyRunContinuations as h, RunContinuation_exports as i, readContinuation as l, validateSuffix as m, CurrentRunWriter as n, isOperationalRecord as o, validateProgressAppend as p, ProgressAppendReader as r, makeProgressWriter as s, CurrentRunSettlement as t, readRunEvidenceSnapshot as u, validateContextBoundary as v, resolveEvidence as x, RunContextReader as y };
|
|
1059
|
+
|
|
1060
|
+
//# sourceMappingURL=RunContinuation-Bpfp087i.mjs.map
|