@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,1258 @@
|
|
|
1
|
+
import * as Context from 'effect/Context'
|
|
2
|
+
import * as Effect from 'effect/Effect'
|
|
3
|
+
import * as Layer from 'effect/Layer'
|
|
4
|
+
import * as Option from 'effect/Option'
|
|
5
|
+
import * as Result from 'effect/Result'
|
|
6
|
+
import * as Schema from 'effect/Schema'
|
|
7
|
+
import * as Stream from 'effect/Stream'
|
|
8
|
+
import * as Struct from 'effect/Struct'
|
|
9
|
+
|
|
10
|
+
import { ReceiptId, RunId, SubmissionId, ThreadId, ToolCallId } from '../core/Identifiers'
|
|
11
|
+
import { utf8ByteLength } from '../core/internal/utf8'
|
|
12
|
+
import { QueueSequence } from '../core/Receipt'
|
|
13
|
+
import { AssignmentTerminal } from '../core/Worker'
|
|
14
|
+
import type { IntegrityReport } from './Admin'
|
|
15
|
+
import { captureRecord, type ProgressAppendRecord, recordEncoding } from './internal/record-encoding'
|
|
16
|
+
import { transferRecordDependencies } from './internal/transfer-dependencies'
|
|
17
|
+
import type { LifecyclePublicationStorage } from './LifecyclePublication'
|
|
18
|
+
import { MessageDeliveryError, MessageDeliveryRecord } from './MessageDelivery'
|
|
19
|
+
import { ExportRecord } from './RecordFormat'
|
|
20
|
+
import {
|
|
21
|
+
BatchId,
|
|
22
|
+
type CanonicalBatch,
|
|
23
|
+
CanonicalRecordEnvelope,
|
|
24
|
+
CanonicalSequence,
|
|
25
|
+
CURRENT_RECORD_FORMAT,
|
|
26
|
+
Digest,
|
|
27
|
+
MAX_RUN_TOOL_CALL_IDENTITIES,
|
|
28
|
+
ObservationOffset,
|
|
29
|
+
ProducerId,
|
|
30
|
+
type PromptRecordEnvelope,
|
|
31
|
+
RecordEnvelope,
|
|
32
|
+
RecordId,
|
|
33
|
+
type RecordJson,
|
|
34
|
+
type RunContinuation,
|
|
35
|
+
} from './Records'
|
|
36
|
+
import { subagentLineageRecordId, workerOriginRecordId } from './RunJournal'
|
|
37
|
+
import { ScheduleInstant } from './Schedule'
|
|
38
|
+
import type { OwnershipLost } from './SubmissionLedger'
|
|
39
|
+
import { AbortIntent, AdmissionRequest, ApprovalDecisionIntent, UnknownResolutionIntent } from './SubmissionLedger'
|
|
40
|
+
import { MAX_CANONICAL_BATCH_BYTES, type ThreadArchiveStorage } from './ThreadArchiveRange'
|
|
41
|
+
import type { ThreadWorkStorage } from './ThreadWork'
|
|
42
|
+
|
|
43
|
+
export const MAX_THREAD_EXPORT_PAGE_RECORDS = 256
|
|
44
|
+
export const MAX_THREAD_EXPORT_PAGE_BYTES = 32 * 1024 * 1024
|
|
45
|
+
export const MAX_THREAD_EXPORT_CURSOR_CHARS = 16_384
|
|
46
|
+
/** Includes a maximally JSON-escaped cursor, snapshot, seal, digests and page structure. */
|
|
47
|
+
const THREAD_EXPORT_METADATA_BYTES = 128 * 1024
|
|
48
|
+
|
|
49
|
+
/** Reserve the manifest identity even when no canonical record or admission exists yet. */
|
|
50
|
+
export const transferPageFits = (threadId: ThreadId, factBytes = 0): boolean =>
|
|
51
|
+
utf8ByteLength(JSON.stringify(threadId)) + factBytes + THREAD_EXPORT_METADATA_BYTES <=
|
|
52
|
+
MAX_THREAD_EXPORT_PAGE_BYTES
|
|
53
|
+
|
|
54
|
+
/** Check a complete retained fact before fresh acceptance; existing replays keep their identity. */
|
|
55
|
+
export const makeTransferFactCheck = <A, I>(schema: Schema.Codec<A, I>) => {
|
|
56
|
+
const encode = Schema.encodeResult(Schema.fromJsonString(schema))
|
|
57
|
+
|
|
58
|
+
return (threadId: ThreadId, fact: A): boolean => {
|
|
59
|
+
const encoded = encode(fact)
|
|
60
|
+
|
|
61
|
+
return Result.isSuccess(encoded) && transferPageFits(threadId, utf8ByteLength(encoded.success))
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { PROMPT_EVIDENCE_TAGS } from './Records'
|
|
66
|
+
|
|
67
|
+
/** Counts of closed owner facts, computed only when an idle export begins. */
|
|
68
|
+
export const ThreadExportSnapshot = Schema.Struct({
|
|
69
|
+
admissions: Schema.Natural,
|
|
70
|
+
aborts: Schema.Natural,
|
|
71
|
+
approvals: Schema.Natural,
|
|
72
|
+
resolutions: Schema.Natural,
|
|
73
|
+
deliveries: Schema.Natural,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
export type ThreadExportSnapshot = typeof ThreadExportSnapshot.Type
|
|
77
|
+
|
|
78
|
+
/** Irreversible Thread-local admission restriction, independent of claims and worker completion. */
|
|
79
|
+
export const ThreadWorkerSeal = Schema.Struct({ terminal: Schema.optionalKey(AssignmentTerminal) })
|
|
80
|
+
export type ThreadWorkerSeal = typeof ThreadWorkerSeal.Type
|
|
81
|
+
|
|
82
|
+
/** Opaque, snapshot-bound transfer position. Only the exporting adapter constructs it. */
|
|
83
|
+
export const ThreadExportCursor = Schema.NonEmptyString.check(
|
|
84
|
+
Schema.isMaxLength(MAX_THREAD_EXPORT_CURSOR_CHARS),
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
export type ThreadExportCursor = typeof ThreadExportCursor.Type
|
|
88
|
+
|
|
89
|
+
/** Exact canonical identity; absence is not proof that an admission was never accepted. */
|
|
90
|
+
export const ThreadRecordRequest = Schema.Struct({ threadId: ThreadId, recordId: RecordId })
|
|
91
|
+
export type ThreadRecordRequest = typeof ThreadRecordRequest.Type
|
|
92
|
+
|
|
93
|
+
/** The original user input for a Run, excluding later joined inputs. */
|
|
94
|
+
export const ThreadRunInputRequest = Schema.Struct({ threadId: ThreadId, runId: RunId })
|
|
95
|
+
export type ThreadRunInputRequest = typeof ThreadRunInputRequest.Type
|
|
96
|
+
|
|
97
|
+
/** Native accounting for one funding Run; settled Thread history is never included. */
|
|
98
|
+
export const ThreadWorkerStateRequest = Schema.Struct({
|
|
99
|
+
threadId: ThreadId,
|
|
100
|
+
sourceSubmissionId: Schema.optionalKey(SubmissionId),
|
|
101
|
+
limit: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(16_384)),
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
export type ThreadWorkerStateRequest = typeof ThreadWorkerStateRequest.Type
|
|
105
|
+
|
|
106
|
+
/** Saturating count of outstanding peer deliveries and terminal rows inside their retention window. */
|
|
107
|
+
export const ThreadPeerCountRequest = Schema.Struct({
|
|
108
|
+
threadId: ThreadId,
|
|
109
|
+
nowMillis: ScheduleInstant,
|
|
110
|
+
limit: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(1000)),
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
export type ThreadPeerCountRequest = typeof ThreadPeerCountRequest.Type
|
|
114
|
+
|
|
115
|
+
/** Capacity is derived from unresolved canonical obligations at this exact tail. */
|
|
116
|
+
export const ThreadWorkerCapacityRequest = Schema.Struct({
|
|
117
|
+
threadId: ThreadId,
|
|
118
|
+
workerThreadId: ThreadId,
|
|
119
|
+
expectedTailSequence: CanonicalSequence,
|
|
120
|
+
update: Schema.Boolean,
|
|
121
|
+
activeLimit: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(100)),
|
|
122
|
+
pendingLimit: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(100)),
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
export type ThreadWorkerCapacityRequest = typeof ThreadWorkerCapacityRequest.Type
|
|
126
|
+
|
|
127
|
+
export const ThreadWorkerCapacity = Schema.Struct({
|
|
128
|
+
threadId: ThreadId,
|
|
129
|
+
tailSequence: CanonicalSequence,
|
|
130
|
+
/** min(actual distinct workers, activeLimit + 1); equality remains distinguishable. */
|
|
131
|
+
activeWorkers: Schema.Natural.check(Schema.isLessThanOrEqualTo(101)),
|
|
132
|
+
workerActive: Schema.Boolean,
|
|
133
|
+
/** min(actual inputs in the requested partition, pendingLimit + 1). */
|
|
134
|
+
pendingInputs: Schema.Natural.check(Schema.isLessThanOrEqualTo(101)),
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
export type ThreadWorkerCapacity = typeof ThreadWorkerCapacity.Type
|
|
138
|
+
|
|
139
|
+
/** Explicit maintenance may traverse all pages while retaining only one bounded page or Run. */
|
|
140
|
+
export const ThreadVerificationRequest = Schema.Struct({
|
|
141
|
+
threadId: ThreadId,
|
|
142
|
+
requireAllSettled: Schema.optionalKey(Schema.Boolean),
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
export type ThreadVerificationRequest = typeof ThreadVerificationRequest.Type
|
|
146
|
+
|
|
147
|
+
export interface ThreadVerificationStorage {
|
|
148
|
+
readonly verify: (
|
|
149
|
+
request: ThreadVerificationRequest,
|
|
150
|
+
) => Effect.Effect<IntegrityReport, ThreadStoreError | ThreadNotMaterialized>
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const incomplete = (operation: string) =>
|
|
154
|
+
ThreadStoreError.make({
|
|
155
|
+
operation,
|
|
156
|
+
message: 'Native canonical read is incomplete or corrupt',
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
/** Collect a complete bounded selection, using canonical sequence as a sparse cursor. */
|
|
160
|
+
const selectedRecords = Effect.fnUntraced(function*(
|
|
161
|
+
threadId: ThreadId,
|
|
162
|
+
selection: ThreadSelection,
|
|
163
|
+
limit: number,
|
|
164
|
+
) {
|
|
165
|
+
const store = yield* ThreadReader
|
|
166
|
+
const records: Array<CanonicalRecordEnvelope> = []
|
|
167
|
+
let bytes = 0
|
|
168
|
+
let afterSequence: CanonicalSequence | undefined
|
|
169
|
+
|
|
170
|
+
while (true) {
|
|
171
|
+
const pageLimit = Math.min(8, limit + 1 - records.length)
|
|
172
|
+
|
|
173
|
+
const page = yield* Stream.runCollect(
|
|
174
|
+
store.read({
|
|
175
|
+
threadId,
|
|
176
|
+
selection,
|
|
177
|
+
page: { limit: pageLimit, ...(afterSequence === undefined ? {} : { afterSequence }) },
|
|
178
|
+
}),
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
for (const entry of page) {
|
|
182
|
+
if (
|
|
183
|
+
entry.threadId !== threadId ||
|
|
184
|
+
entry.sequence <= (afterSequence ?? 0) ||
|
|
185
|
+
('expectedTailSequence' in selection && entry.sequence > selection.expectedTailSequence)
|
|
186
|
+
) {
|
|
187
|
+
return yield* incomplete('read selection identity')
|
|
188
|
+
}
|
|
189
|
+
afterSequence = entry.sequence
|
|
190
|
+
bytes += yield* Effect.fromResult(recordEncoding(entry.record)).pipe(
|
|
191
|
+
Effect.map((record) => record.bytes),
|
|
192
|
+
Effect.mapError(() => incomplete('read selection bytes')),
|
|
193
|
+
)
|
|
194
|
+
if (bytes > MAX_THREAD_EXPORT_PAGE_BYTES) {
|
|
195
|
+
return yield* incomplete('read selection byte limit')
|
|
196
|
+
}
|
|
197
|
+
records.push(entry)
|
|
198
|
+
}
|
|
199
|
+
if (page.length > pageLimit || records.length > limit) {
|
|
200
|
+
return yield* incomplete('read selection limit')
|
|
201
|
+
}
|
|
202
|
+
if (page.length < pageLimit) return records
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
/** Host-owned read: authenticate the Thread and exact locator before calling. */
|
|
207
|
+
export const getRecord = Effect.fnUntraced(function*(request: ThreadRecordRequest) {
|
|
208
|
+
yield* Schema.decodeEffect(ThreadRecordRequest)(request).pipe(
|
|
209
|
+
Effect.mapError(() => incomplete('getRecord request')),
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
const records = yield* selectedRecords(
|
|
213
|
+
request.threadId,
|
|
214
|
+
{ _tag: 'RecordId', recordId: request.recordId },
|
|
215
|
+
1,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
if (records.some((entry) => entry.record.recordId !== request.recordId)) {
|
|
219
|
+
return yield* incomplete('getRecord identity')
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return Option.fromUndefinedOr(records[0])
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
export const getRunInput = Effect.fnUntraced(function*(request: ThreadRunInputRequest) {
|
|
226
|
+
yield* Schema.decodeEffect(ThreadRunInputRequest)(request).pipe(
|
|
227
|
+
Effect.mapError(() => incomplete('getRunInput request')),
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
const records = yield* selectedRecords(
|
|
231
|
+
request.threadId,
|
|
232
|
+
{ _tag: 'RunInput', runId: request.runId },
|
|
233
|
+
1,
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
if (
|
|
237
|
+
records.some(
|
|
238
|
+
({ record: { payload } }) =>
|
|
239
|
+
payload._tag !== 'UserInputRecorded' ||
|
|
240
|
+
payload.kind !== 'user' ||
|
|
241
|
+
payload.runId !== request.runId,
|
|
242
|
+
)
|
|
243
|
+
) {
|
|
244
|
+
return yield* incomplete('getRunInput identity')
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return Option.fromUndefinedOr(records[0])
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
/** A bounded snapshot of source identity and the selected funding Run's accounting. */
|
|
251
|
+
export const readWorkerState = Effect.fnUntraced(function*(request: ThreadWorkerStateRequest) {
|
|
252
|
+
yield* Schema.decodeEffect(ThreadWorkerStateRequest)(request).pipe(
|
|
253
|
+
Effect.mapError(() => incomplete('readWorkerState request')),
|
|
254
|
+
)
|
|
255
|
+
const store = yield* ThreadReader
|
|
256
|
+
const tail = yield* store.inspectTail(ThreadTailRequest.make({ threadId: request.threadId }))
|
|
257
|
+
|
|
258
|
+
const records = yield* selectedRecords(
|
|
259
|
+
request.threadId,
|
|
260
|
+
{
|
|
261
|
+
_tag: 'WorkerState',
|
|
262
|
+
expectedTailSequence: tail.tailSequence,
|
|
263
|
+
...(request.sourceSubmissionId === undefined
|
|
264
|
+
? {}
|
|
265
|
+
: { sourceSubmissionId: request.sourceSubmissionId }),
|
|
266
|
+
},
|
|
267
|
+
request.limit,
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
threadId: request.threadId,
|
|
272
|
+
tailSequence: tail.tailSequence,
|
|
273
|
+
records,
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
export class ThreadMaterialization extends Schema.Class<ThreadMaterialization>(
|
|
278
|
+
'@effect-agent/thread/ThreadMaterialization',
|
|
279
|
+
)({
|
|
280
|
+
threadId: ThreadId,
|
|
281
|
+
}) {}
|
|
282
|
+
|
|
283
|
+
const isExecutionProgressRecord = (
|
|
284
|
+
record: RecordEnvelope,
|
|
285
|
+
): record is RecordEnvelope & { readonly payload: RunContinuation } => record.payload._tag === 'RunContinuation'
|
|
286
|
+
|
|
287
|
+
const ExecutionProgressRecord = RecordEnvelope.pipe(
|
|
288
|
+
Schema.refine(isExecutionProgressRecord, { message: 'Expected a Run continuation record' }),
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
/** Current interpreter state. Wire version 2 retains one copy of its continuation. */
|
|
292
|
+
export class ExecutionCheckpoint extends Schema.Class<ExecutionCheckpoint>(
|
|
293
|
+
'@effect-agent/thread/ExecutionCheckpoint',
|
|
294
|
+
)({
|
|
295
|
+
version: Schema.Literal(2),
|
|
296
|
+
/** Logical progress encoding is charged while active; previous revisions are discarded. */
|
|
297
|
+
progressRecord: ExecutionProgressRecord,
|
|
298
|
+
/** Original start, evaluated context and validated completion intent while the Run is active. */
|
|
299
|
+
operational: Schema.Array(RecordEnvelope).check(Schema.isMaxLength(8)),
|
|
300
|
+
canonicalRecords: Schema.Natural,
|
|
301
|
+
/** Stable admitted-input position also supplies a bounded transfer cursor. */
|
|
302
|
+
originalSequence: CanonicalSequence.check(Schema.isGreaterThan(0)),
|
|
303
|
+
throughSequence: CanonicalSequence,
|
|
304
|
+
batchId: BatchId,
|
|
305
|
+
}) {
|
|
306
|
+
/** View of the retained payload, not a second encoded field. */
|
|
307
|
+
get progress(): RunContinuation {
|
|
308
|
+
return this.progressRecord.payload
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** A revision-checked transition committed by the same owner as the retained history facts. */
|
|
313
|
+
export class ExecutionUpdate extends Schema.Class<ExecutionUpdate>(
|
|
314
|
+
'@effect-agent/thread/ExecutionUpdate',
|
|
315
|
+
)({
|
|
316
|
+
previousRevision: Schema.Natural,
|
|
317
|
+
checkpoint: ExecutionCheckpoint,
|
|
318
|
+
/** Newly durable operational facts; capture and validate these before entering the writer. */
|
|
319
|
+
facts: Schema.Array(RecordEnvelope).check(Schema.isMaxLength(8)),
|
|
320
|
+
/** Delete current Run state in the same transaction as its authorized terminal publication. */
|
|
321
|
+
retire: Schema.Boolean,
|
|
322
|
+
}) {}
|
|
323
|
+
|
|
324
|
+
/** A progress-only commit has no canonical records and does not advance the history tail. */
|
|
325
|
+
export class CommitBatch extends Schema.Class<CommitBatch>('@effect-agent/thread/CommitBatch')({
|
|
326
|
+
batchId: BatchId,
|
|
327
|
+
producerId: ProducerId,
|
|
328
|
+
records: Schema.Array(RecordEnvelope).check(Schema.isMaxLength(256)),
|
|
329
|
+
}) {}
|
|
330
|
+
|
|
331
|
+
export class ExecutionRead extends Schema.Class<ExecutionRead>(
|
|
332
|
+
'@effect-agent/thread/ExecutionRead',
|
|
333
|
+
)({
|
|
334
|
+
threadId: ThreadId,
|
|
335
|
+
runId: RunId,
|
|
336
|
+
}) {}
|
|
337
|
+
|
|
338
|
+
export class AppendRequest extends Schema.Class<AppendRequest>(
|
|
339
|
+
'@effect-agent/thread/AppendRequest',
|
|
340
|
+
)({
|
|
341
|
+
threadId: ThreadId,
|
|
342
|
+
batch: CommitBatch,
|
|
343
|
+
executions: Schema.optionalKey(Schema.Array(ExecutionUpdate).check(Schema.isMaxLength(256))),
|
|
344
|
+
expectedTailSequence: CanonicalSequence,
|
|
345
|
+
}) {}
|
|
346
|
+
|
|
347
|
+
const RecordCount = Schema.Array(Schema.Unknown).check(Schema.isMaxLength(256))
|
|
348
|
+
const ExecutionRecordCount = Schema.Array(Schema.Unknown).check(Schema.isMaxLength(8))
|
|
349
|
+
|
|
350
|
+
const AppendHeader = Schema.Struct({
|
|
351
|
+
threadId: ThreadId,
|
|
352
|
+
expectedTailSequence: CanonicalSequence,
|
|
353
|
+
batchId: BatchId,
|
|
354
|
+
producerId: ProducerId,
|
|
355
|
+
records: RecordCount,
|
|
356
|
+
executions: RecordCount,
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
const validateHeader = Schema.decodeUnknownSync(AppendHeader)
|
|
360
|
+
|
|
361
|
+
const validateExecutionHeader = Schema.decodeUnknownSync(
|
|
362
|
+
Schema.Struct({
|
|
363
|
+
previousRevision: ExecutionUpdate.fields.previousRevision,
|
|
364
|
+
retire: ExecutionUpdate.fields.retire,
|
|
365
|
+
checkpoint: Schema.Struct({
|
|
366
|
+
version: ExecutionCheckpoint.fields.version,
|
|
367
|
+
canonicalRecords: ExecutionCheckpoint.fields.canonicalRecords,
|
|
368
|
+
originalSequence: ExecutionCheckpoint.fields.originalSequence,
|
|
369
|
+
throughSequence: ExecutionCheckpoint.fields.throughSequence,
|
|
370
|
+
batchId: ExecutionCheckpoint.fields.batchId,
|
|
371
|
+
operational: ExecutionRecordCount,
|
|
372
|
+
}),
|
|
373
|
+
facts: ExecutionRecordCount,
|
|
374
|
+
}),
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
/** Capture records once; wrapper fields retain their owning Schema's constraints. */
|
|
378
|
+
const captureExecution = (input: ExecutionUpdate) => {
|
|
379
|
+
const checkpointInput = input.checkpoint
|
|
380
|
+
const operationalInput = checkpointInput.operational
|
|
381
|
+
const factsInput = input.facts
|
|
382
|
+
|
|
383
|
+
const header = validateExecutionHeader({
|
|
384
|
+
previousRevision: input.previousRevision,
|
|
385
|
+
retire: input.retire,
|
|
386
|
+
checkpoint: {
|
|
387
|
+
version: checkpointInput.version,
|
|
388
|
+
canonicalRecords: checkpointInput.canonicalRecords,
|
|
389
|
+
originalSequence: checkpointInput.originalSequence,
|
|
390
|
+
throughSequence: checkpointInput.throughSequence,
|
|
391
|
+
batchId: checkpointInput.batchId,
|
|
392
|
+
operational: operationalInput,
|
|
393
|
+
},
|
|
394
|
+
facts: factsInput,
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
const operationalLength = header.checkpoint.operational.length
|
|
398
|
+
const factsLength = header.facts.length
|
|
399
|
+
|
|
400
|
+
const progress = captureRecord(checkpointInput.progressRecord)
|
|
401
|
+
|
|
402
|
+
if (Result.isFailure(progress)) return Result.fail(progress.failure)
|
|
403
|
+
const progressRecord = progress.success.canonical
|
|
404
|
+
|
|
405
|
+
if (!isExecutionProgressRecord(progressRecord)) {
|
|
406
|
+
return Result.fail(
|
|
407
|
+
ThreadStoreError.make({
|
|
408
|
+
operation: 'prepare durable commit',
|
|
409
|
+
message: 'Expected a Run continuation record',
|
|
410
|
+
}),
|
|
411
|
+
)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Use the Schema-validated indexed lengths, never a caller's iterator. Sparse slots
|
|
415
|
+
// still visit the record boundary, where undefined is refused.
|
|
416
|
+
const operational = []
|
|
417
|
+
|
|
418
|
+
for (let index = 0; index < operationalLength; index++) {
|
|
419
|
+
const record = captureRecord(operationalInput[index]!)
|
|
420
|
+
|
|
421
|
+
if (Result.isFailure(record)) return Result.fail(record.failure)
|
|
422
|
+
operational.push(record.success)
|
|
423
|
+
}
|
|
424
|
+
const facts = []
|
|
425
|
+
|
|
426
|
+
for (let index = 0; index < factsLength; index++) {
|
|
427
|
+
const record = captureRecord(factsInput[index]!)
|
|
428
|
+
|
|
429
|
+
if (Result.isFailure(record)) return Result.fail(record.failure)
|
|
430
|
+
facts.push(record.success)
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const checkpoint = Object.freeze(
|
|
434
|
+
ExecutionCheckpoint.make(
|
|
435
|
+
{
|
|
436
|
+
...header.checkpoint,
|
|
437
|
+
progressRecord,
|
|
438
|
+
operational: Object.freeze(operational.map(({ canonical }) => canonical)),
|
|
439
|
+
},
|
|
440
|
+
{ disableChecks: true },
|
|
441
|
+
),
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
const update = Object.freeze(
|
|
445
|
+
ExecutionUpdate.make(
|
|
446
|
+
{
|
|
447
|
+
previousRevision: header.previousRevision,
|
|
448
|
+
retire: header.retire,
|
|
449
|
+
checkpoint,
|
|
450
|
+
facts: Object.freeze(facts.map(({ canonical }) => canonical)),
|
|
451
|
+
},
|
|
452
|
+
{ disableChecks: true },
|
|
453
|
+
),
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
const checkpointJson = `{"version":${checkpoint.version},"progressRecord":${progress.success.json},"operational":[${
|
|
457
|
+
operational.map(({ json }) => json).join(',')
|
|
458
|
+
}],"canonicalRecords":${checkpoint.canonicalRecords},"originalSequence":${checkpoint.originalSequence},"throughSequence":${checkpoint.throughSequence},"batchId":${
|
|
459
|
+
JSON.stringify(checkpoint.batchId)
|
|
460
|
+
}}`
|
|
461
|
+
const json = `{"previousRevision":${update.previousRevision},"checkpoint":${checkpointJson},"facts":[${
|
|
462
|
+
facts.map(({ json }) => json).join(',')
|
|
463
|
+
}],"retire":${update.retire}}`
|
|
464
|
+
|
|
465
|
+
return Result.succeed(
|
|
466
|
+
Object.freeze({
|
|
467
|
+
update,
|
|
468
|
+
json,
|
|
469
|
+
checkpointJson,
|
|
470
|
+
factsJson: JSON.stringify(facts.map(({ wire }) => wire)),
|
|
471
|
+
bytes: utf8ByteLength(json),
|
|
472
|
+
}),
|
|
473
|
+
)
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
const capturedAppends = new WeakMap<AppendRequest, CapturedAppend>()
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Admission reserves one complete batch's envelope, references, snapshot and continuation cursor.
|
|
480
|
+
* Adapters supply their native offset byte bound. Dependency literals already occur in record
|
|
481
|
+
* wire, so ordinary batches need only arithmetic; near the page limit, charge the exact references.
|
|
482
|
+
*/
|
|
483
|
+
export const canonicalBatchFitsTransfer = (
|
|
484
|
+
threadId: ThreadId,
|
|
485
|
+
batch: Pick<CommitBatch, 'batchId' | 'records'>,
|
|
486
|
+
batchBytes: number,
|
|
487
|
+
maxOffsetBytes: number,
|
|
488
|
+
): boolean => {
|
|
489
|
+
const threadJson = JSON.stringify(threadId)
|
|
490
|
+
const threadBytes = utf8ByteLength(threadJson)
|
|
491
|
+
const batchIdBytes = utf8ByteLength(JSON.stringify(batch.batchId))
|
|
492
|
+
|
|
493
|
+
// 128 bytes per envelope covers keys, sequence and punctuation. 128 KiB reserves the
|
|
494
|
+
// maximum JSON-escaped cursor plus bounded snapshot, seal, digest and page metadata.
|
|
495
|
+
const overhead = batch.records.length * (batchIdBytes + threadBytes + maxOffsetBytes + 128) +
|
|
496
|
+
threadBytes +
|
|
497
|
+
THREAD_EXPORT_METADATA_BYTES
|
|
498
|
+
|
|
499
|
+
if (2 * batchBytes + overhead + 2 <= MAX_THREAD_EXPORT_PAGE_BYTES) return true
|
|
500
|
+
|
|
501
|
+
const dependencyBytes = utf8ByteLength(JSON.stringify(transferRecordDependencies(batch.records)))
|
|
502
|
+
|
|
503
|
+
return batchBytes + overhead + dependencyBytes <= MAX_THREAD_EXPORT_PAGE_BYTES
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Adapter-owned append captured before writer acquisition can suspend. Record JSON
|
|
508
|
+
* is shared by the batch and record rows. Privately owned facts and wire metadata
|
|
509
|
+
* keep payloads, identities and validation stable across suspension; adapters persist the
|
|
510
|
+
* captured strings rather than reconstructing bytes from caller-owned values.
|
|
511
|
+
* Transport decoding intentionally returns an ordinary AppendRequest for fresh capture.
|
|
512
|
+
*/
|
|
513
|
+
export interface PreparedAppend extends AppendRequest {
|
|
514
|
+
readonly batchJson: string
|
|
515
|
+
readonly batchBytes: number
|
|
516
|
+
readonly progress: ReadonlyArray<ProgressAppendRecord>
|
|
517
|
+
readonly executionWrites: ReadonlyArray<{
|
|
518
|
+
readonly update: ExecutionUpdate
|
|
519
|
+
readonly json: string
|
|
520
|
+
/** Checkpoint wire from the same detached, validated execution capture. */
|
|
521
|
+
readonly checkpointJson: string
|
|
522
|
+
/** Schema-encoded fact array from this same capture, for the stable retry digest. */
|
|
523
|
+
readonly factsJson: string
|
|
524
|
+
readonly bytes: number
|
|
525
|
+
}>
|
|
526
|
+
readonly records: ReadonlyArray<{
|
|
527
|
+
readonly recordId: RecordId
|
|
528
|
+
readonly recordJson: string
|
|
529
|
+
readonly recordBytes: number
|
|
530
|
+
readonly wire: RecordJson
|
|
531
|
+
readonly canonical: CanonicalBatch['records'][number]
|
|
532
|
+
}>
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
interface CapturedAppend extends PreparedAppend {
|
|
536
|
+
readonly records: ReadonlyArray<
|
|
537
|
+
Omit<PreparedAppend['records'][number], 'wire'> & {
|
|
538
|
+
readonly wire: typeof RecordEnvelope.Encoded
|
|
539
|
+
}
|
|
540
|
+
>
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export const PreparedAppend = {
|
|
544
|
+
capture: (input: AppendRequest): Effect.Effect<CapturedAppend, ThreadStoreError> =>
|
|
545
|
+
Effect.suspend(() => {
|
|
546
|
+
const existing = capturedAppends.get(input)
|
|
547
|
+
|
|
548
|
+
if (existing !== undefined) return Effect.succeed(existing)
|
|
549
|
+
|
|
550
|
+
return Effect.try({
|
|
551
|
+
try: () =>
|
|
552
|
+
Result.gen(function*() {
|
|
553
|
+
const executions = input.executions ?? []
|
|
554
|
+
const recordInputs = input.batch.records
|
|
555
|
+
|
|
556
|
+
const header = validateHeader({
|
|
557
|
+
...input,
|
|
558
|
+
batchId: input.batch.batchId,
|
|
559
|
+
producerId: input.batch.producerId,
|
|
560
|
+
records: recordInputs,
|
|
561
|
+
executions,
|
|
562
|
+
})
|
|
563
|
+
|
|
564
|
+
const recordLength = header.records.length
|
|
565
|
+
const executionLength = header.executions.length
|
|
566
|
+
|
|
567
|
+
const executionWrites: Array<PreparedAppend['executionWrites'][number]> = []
|
|
568
|
+
|
|
569
|
+
for (let index = 0; index < executionLength; index++) {
|
|
570
|
+
executionWrites.push(yield* captureExecution(executions[index]!))
|
|
571
|
+
}
|
|
572
|
+
Object.freeze(executionWrites)
|
|
573
|
+
|
|
574
|
+
if (recordLength === 0 && executionWrites.length === 0) {
|
|
575
|
+
return yield* Result.fail(
|
|
576
|
+
ThreadStoreError.make({
|
|
577
|
+
operation: 'prepare durable commit',
|
|
578
|
+
message: 'A commit must contain history facts or an active execution transition',
|
|
579
|
+
}),
|
|
580
|
+
)
|
|
581
|
+
}
|
|
582
|
+
if (executionWrites.some(({ bytes }) => !transferPageFits(header.threadId, bytes))) {
|
|
583
|
+
return yield* Result.fail(
|
|
584
|
+
ThreadStoreError.make({
|
|
585
|
+
operation: 'prepare durable commit',
|
|
586
|
+
message: 'Active state exceeds its bounded transfer representation',
|
|
587
|
+
}),
|
|
588
|
+
)
|
|
589
|
+
}
|
|
590
|
+
// Visit Schema-validated indexed slots, including sparse ones, never a caller's iterator.
|
|
591
|
+
const encodings = []
|
|
592
|
+
|
|
593
|
+
for (let index = 0; index < recordLength; index++) {
|
|
594
|
+
encodings.push(yield* captureRecord(recordInputs[index]!))
|
|
595
|
+
}
|
|
596
|
+
const prefix = `{"batchId":${JSON.stringify(header.batchId)},"producerId":${
|
|
597
|
+
JSON.stringify(header.producerId)
|
|
598
|
+
},"records":[`
|
|
599
|
+
const batchJson = `${prefix}${encodings.map(({ json }) => json).join(',')}]}`
|
|
600
|
+
|
|
601
|
+
const batchBytes = encodings.reduce(
|
|
602
|
+
(total, record) => total + record.bytes,
|
|
603
|
+
utf8ByteLength(prefix) + (encodings.length === 0 ? 2 : encodings.length + 1),
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
if (batchBytes > MAX_CANONICAL_BATCH_BYTES) {
|
|
607
|
+
return yield* Result.fail(
|
|
608
|
+
ThreadStoreError.make({
|
|
609
|
+
operation: 'prepare canonical append',
|
|
610
|
+
message: `Canonical batch exceeds ${MAX_CANONICAL_BATCH_BYTES} bytes`,
|
|
611
|
+
}),
|
|
612
|
+
)
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const batch = Object.freeze(
|
|
616
|
+
CommitBatch.make(
|
|
617
|
+
{
|
|
618
|
+
batchId: header.batchId,
|
|
619
|
+
producerId: header.producerId,
|
|
620
|
+
records: Object.freeze(encodings.map(({ canonical }) => canonical)),
|
|
621
|
+
},
|
|
622
|
+
{ disableChecks: true },
|
|
623
|
+
),
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
const request = AppendRequest.make(
|
|
627
|
+
{
|
|
628
|
+
threadId: header.threadId,
|
|
629
|
+
expectedTailSequence: header.expectedTailSequence,
|
|
630
|
+
batch,
|
|
631
|
+
...(executionWrites.length === 0
|
|
632
|
+
? {}
|
|
633
|
+
: { executions: Object.freeze(executionWrites.map(({ update }) => update)) }),
|
|
634
|
+
},
|
|
635
|
+
{ disableChecks: true },
|
|
636
|
+
)
|
|
637
|
+
|
|
638
|
+
const records = Object.freeze(
|
|
639
|
+
encodings.map(({ canonical, json, wire, bytes }) =>
|
|
640
|
+
Object.freeze({
|
|
641
|
+
recordId: canonical.recordId,
|
|
642
|
+
recordJson: json,
|
|
643
|
+
recordBytes: bytes,
|
|
644
|
+
wire,
|
|
645
|
+
canonical,
|
|
646
|
+
})
|
|
647
|
+
),
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
const progress = Object.freeze(encodings.map(({ progress }) => progress))
|
|
651
|
+
|
|
652
|
+
const captured = Object.freeze(
|
|
653
|
+
Object.assign(request, {
|
|
654
|
+
batchJson,
|
|
655
|
+
batchBytes,
|
|
656
|
+
records,
|
|
657
|
+
progress,
|
|
658
|
+
executionWrites,
|
|
659
|
+
}),
|
|
660
|
+
)
|
|
661
|
+
|
|
662
|
+
capturedAppends.set(captured, captured)
|
|
663
|
+
|
|
664
|
+
return captured
|
|
665
|
+
}),
|
|
666
|
+
catch: (cause) =>
|
|
667
|
+
Schema.is(ThreadStoreError)(cause)
|
|
668
|
+
? cause
|
|
669
|
+
: ThreadStoreError.make({
|
|
670
|
+
operation: 'prepare canonical append',
|
|
671
|
+
message: Schema.isSchemaError(cause)
|
|
672
|
+
? cause.message
|
|
673
|
+
: 'Canonical append capture failed',
|
|
674
|
+
cause,
|
|
675
|
+
}),
|
|
676
|
+
}).pipe(
|
|
677
|
+
Effect.flatMap(Effect.fromResult),
|
|
678
|
+
Effect.mapError((cause) =>
|
|
679
|
+
Schema.is(ThreadStoreError)(cause)
|
|
680
|
+
? cause
|
|
681
|
+
: ThreadStoreError.make({
|
|
682
|
+
operation: 'prepare canonical append',
|
|
683
|
+
message: cause.message,
|
|
684
|
+
cause,
|
|
685
|
+
})
|
|
686
|
+
),
|
|
687
|
+
)
|
|
688
|
+
}),
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export class AppendResult extends Schema.Class<AppendResult>('@effect-agent/thread/AppendResult')({
|
|
692
|
+
firstSequence: CanonicalSequence,
|
|
693
|
+
lastSequence: CanonicalSequence,
|
|
694
|
+
replayed: Schema.Boolean,
|
|
695
|
+
}) {}
|
|
696
|
+
|
|
697
|
+
export class ThreadRead extends Schema.Class<ThreadRead>('@effect-agent/thread/ThreadRead')({
|
|
698
|
+
threadId: ThreadId,
|
|
699
|
+
afterSequence: Schema.optionalKey(CanonicalSequence),
|
|
700
|
+
limit: Schema.Natural.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(1_024)),
|
|
701
|
+
}) {}
|
|
702
|
+
|
|
703
|
+
/** Sparse ordered history page at a fixed tail; no record-count limit on the whole range. */
|
|
704
|
+
export const ThreadPromptRead = Schema.Struct({
|
|
705
|
+
...ThreadRead.fields,
|
|
706
|
+
throughSequence: CanonicalSequence,
|
|
707
|
+
})
|
|
708
|
+
|
|
709
|
+
export type ThreadPromptRead = typeof ThreadPromptRead.Type
|
|
710
|
+
|
|
711
|
+
/** Closed native selections; mutable metadata is read at this exact canonical tail. */
|
|
712
|
+
export const ThreadSelection = Schema.Union([
|
|
713
|
+
Schema.TaggedStruct('RecordId', { recordId: RecordId }),
|
|
714
|
+
Schema.TaggedStruct('RunInput', { runId: RunId }),
|
|
715
|
+
/** Exact original declaration indexed by its deterministic settlement identity. */
|
|
716
|
+
Schema.TaggedStruct('ToolDeclaration', {
|
|
717
|
+
settlementRecordId: RecordId,
|
|
718
|
+
throughSequence: CanonicalSequence,
|
|
719
|
+
}),
|
|
720
|
+
/** Only the selected Run's facts; unrelated Thread traffic cannot enlarge its suffix. */
|
|
721
|
+
Schema.TaggedStruct('RunEvidence', {
|
|
722
|
+
runId: RunId,
|
|
723
|
+
submissionId: SubmissionId,
|
|
724
|
+
throughSequence: CanonicalSequence,
|
|
725
|
+
}),
|
|
726
|
+
/** Exact declaration, this call's facts, and shared approval proof from its original batch. */
|
|
727
|
+
Schema.TaggedStruct('OperationEvidence', {
|
|
728
|
+
runId: RunId,
|
|
729
|
+
toolCallId: ToolCallId,
|
|
730
|
+
originRecordId: RecordId,
|
|
731
|
+
approvalToolCallIds: Schema.Array(ToolCallId).check(
|
|
732
|
+
Schema.isMinLength(1),
|
|
733
|
+
Schema.isMaxLength(MAX_RUN_TOOL_CALL_IDENTITIES),
|
|
734
|
+
Schema.makeFilter((ids) => new Set(ids).size === ids.length),
|
|
735
|
+
),
|
|
736
|
+
throughSequence: CanonicalSequence,
|
|
737
|
+
}).check(
|
|
738
|
+
Schema.makeFilter((selection) => selection.approvalToolCallIds.includes(selection.toolCallId)),
|
|
739
|
+
),
|
|
740
|
+
Schema.TaggedStruct('LastAgentUpdate', {
|
|
741
|
+
throughSequence: CanonicalSequence,
|
|
742
|
+
}),
|
|
743
|
+
/** Sparse canonical pages; callers bound total evidence before building model metadata. */
|
|
744
|
+
Schema.TaggedStruct('PromptEvidence', {
|
|
745
|
+
throughSequence: CanonicalSequence,
|
|
746
|
+
}),
|
|
747
|
+
Schema.TaggedStruct('LatestModelCompleted', {
|
|
748
|
+
throughSequence: CanonicalSequence,
|
|
749
|
+
}),
|
|
750
|
+
/** Latest application input; framework worker completion/update messages are excluded. */
|
|
751
|
+
Schema.TaggedStruct('LatestApplicationInput', {
|
|
752
|
+
throughSequence: CanonicalSequence,
|
|
753
|
+
}),
|
|
754
|
+
/** Presence of durable ownership forbids an immediate-history writer on this Thread. */
|
|
755
|
+
Schema.TaggedStruct('DurableHistoryOwner', {
|
|
756
|
+
throughSequence: CanonicalSequence,
|
|
757
|
+
}),
|
|
758
|
+
/** Latest rollover covering positions strictly before the addressed evidence. */
|
|
759
|
+
Schema.TaggedStruct('ContextWindowBoundary', {
|
|
760
|
+
atSequence: CanonicalSequence,
|
|
761
|
+
throughSequence: CanonicalSequence,
|
|
762
|
+
}),
|
|
763
|
+
Schema.TaggedStruct('DeliveryPredecessor', {
|
|
764
|
+
throughSequence: CanonicalSequence,
|
|
765
|
+
}),
|
|
766
|
+
/** Canonical creation/handoff intents retained independently of Run settlement. */
|
|
767
|
+
Schema.TaggedStruct('WorkHandoffs', {
|
|
768
|
+
throughSequence: CanonicalSequence,
|
|
769
|
+
}),
|
|
770
|
+
/** Unresolved inputs only, selected through disposable work membership. */
|
|
771
|
+
Schema.TaggedStruct('LiveWorkerInputs', {
|
|
772
|
+
throughSequence: CanonicalSequence,
|
|
773
|
+
workerThreadId: Schema.optionalKey(ThreadId),
|
|
774
|
+
}),
|
|
775
|
+
/** A retained stop for the exact worker, independent of historical inputs. */
|
|
776
|
+
Schema.TaggedStruct('WorkerStop', {
|
|
777
|
+
workerThreadId: ThreadId,
|
|
778
|
+
throughSequence: CanonicalSequence,
|
|
779
|
+
}),
|
|
780
|
+
Schema.TaggedStruct('WorkerExecution', {
|
|
781
|
+
expectedTailSequence: CanonicalSequence,
|
|
782
|
+
}),
|
|
783
|
+
Schema.TaggedStruct('WorkerState', {
|
|
784
|
+
expectedTailSequence: CanonicalSequence,
|
|
785
|
+
sourceSubmissionId: Schema.optionalKey(SubmissionId),
|
|
786
|
+
}),
|
|
787
|
+
])
|
|
788
|
+
|
|
789
|
+
export type ThreadSelection = typeof ThreadSelection.Type
|
|
790
|
+
|
|
791
|
+
/** Nested page makes an old ThreadRead decoder reject, never strip a selection into history. */
|
|
792
|
+
export const SelectedThreadRead = Schema.Struct({
|
|
793
|
+
threadId: ThreadId,
|
|
794
|
+
selection: ThreadSelection,
|
|
795
|
+
page: Schema.Struct({
|
|
796
|
+
afterSequence: Schema.optionalKey(CanonicalSequence),
|
|
797
|
+
limit: ThreadRead.fields.limit,
|
|
798
|
+
}),
|
|
799
|
+
})
|
|
800
|
+
|
|
801
|
+
export type SelectedThreadRead = typeof SelectedThreadRead.Type
|
|
802
|
+
export const ThreadReadRequest = Schema.Union([SelectedThreadRead, ThreadRead])
|
|
803
|
+
export type ThreadReadRequest = typeof ThreadReadRequest.Type
|
|
804
|
+
|
|
805
|
+
export class ThreadObservation extends Schema.Class<ThreadObservation>(
|
|
806
|
+
'@effect-agent/thread/ThreadObservation',
|
|
807
|
+
)({
|
|
808
|
+
threadId: ThreadId,
|
|
809
|
+
afterOffset: Schema.optionalKey(ObservationOffset),
|
|
810
|
+
}) {}
|
|
811
|
+
|
|
812
|
+
export class ThreadExportRequest extends Schema.Class<ThreadExportRequest>(
|
|
813
|
+
'@effect-agent/thread/ThreadExportRequest',
|
|
814
|
+
)({
|
|
815
|
+
threadId: ThreadId,
|
|
816
|
+
cursor: Schema.optionalKey(ThreadExportCursor),
|
|
817
|
+
}) {}
|
|
818
|
+
|
|
819
|
+
export class ThreadTailRequest extends Schema.Class<ThreadTailRequest>(
|
|
820
|
+
'@effect-agent/thread/ThreadTailRequest',
|
|
821
|
+
)({
|
|
822
|
+
threadId: ThreadId,
|
|
823
|
+
}) {}
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* The committed tail of one Thread Log. A resuming producer composes its next
|
|
827
|
+
* AppendRequest from this value instead of exporting the whole log.
|
|
828
|
+
*/
|
|
829
|
+
export class ThreadTail extends Schema.Class<ThreadTail>('@effect-agent/thread/ThreadTail')({
|
|
830
|
+
threadId: ThreadId,
|
|
831
|
+
tailSequence: CanonicalSequence,
|
|
832
|
+
}) {}
|
|
833
|
+
|
|
834
|
+
export class ThreadIdentityRequest extends Schema.Class<ThreadIdentityRequest>(
|
|
835
|
+
'@effect-agent/thread/ThreadIdentityRequest',
|
|
836
|
+
)({ threadId: ThreadId }) {}
|
|
837
|
+
|
|
838
|
+
export class FreshRunRead extends Schema.Class<FreshRunRead>('@effect-agent/thread/FreshRunRead')({
|
|
839
|
+
threadId: ThreadId,
|
|
840
|
+
submissionId: SubmissionId,
|
|
841
|
+
}) {}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* One consistent snapshot: Thread ID, canonical tail, admission presence, first record,
|
|
845
|
+
* exact worker origin, then exact subagent lineage. A row selected twice appears only
|
|
846
|
+
* once. Missing identity records remain absent; the snapshot grants no execution authority.
|
|
847
|
+
*/
|
|
848
|
+
export class ThreadIdentity extends Schema.Class<ThreadIdentity>(
|
|
849
|
+
'@effect-agent/thread/ThreadIdentity',
|
|
850
|
+
)(
|
|
851
|
+
Schema.Struct({
|
|
852
|
+
...ThreadTail.fields,
|
|
853
|
+
/** Whether any admission is retained, including settled inputs and inputs not yet canonical. */
|
|
854
|
+
hasAdmissions: Schema.Boolean,
|
|
855
|
+
records: Schema.Array(CanonicalRecordEnvelope).check(Schema.isMaxLength(3)),
|
|
856
|
+
}).check(
|
|
857
|
+
Schema.makeFilter((snapshot) => {
|
|
858
|
+
if (snapshot.tailSequence === 0) return snapshot.records.length === 0
|
|
859
|
+
if (snapshot.records[0]?.sequence !== 1) return false
|
|
860
|
+
const origin = workerOriginRecordId(snapshot.threadId)
|
|
861
|
+
const lineage = subagentLineageRecordId(snapshot.threadId)
|
|
862
|
+
const ids = new Set<RecordId>()
|
|
863
|
+
const sequences = new Set<CanonicalSequence>()
|
|
864
|
+
let previous = -1
|
|
865
|
+
|
|
866
|
+
for (const entry of snapshot.records) {
|
|
867
|
+
const rank = entry.sequence === 1
|
|
868
|
+
? 0
|
|
869
|
+
: entry.record.recordId === origin
|
|
870
|
+
? 1
|
|
871
|
+
: entry.record.recordId === lineage
|
|
872
|
+
? 2
|
|
873
|
+
: -1
|
|
874
|
+
|
|
875
|
+
if (
|
|
876
|
+
entry.threadId !== snapshot.threadId ||
|
|
877
|
+
entry.sequence < 1 ||
|
|
878
|
+
entry.sequence > snapshot.tailSequence ||
|
|
879
|
+
rank <= previous ||
|
|
880
|
+
ids.has(entry.record.recordId) ||
|
|
881
|
+
sequences.has(entry.sequence)
|
|
882
|
+
) {
|
|
883
|
+
return false
|
|
884
|
+
}
|
|
885
|
+
ids.add(entry.record.recordId)
|
|
886
|
+
sequences.add(entry.sequence)
|
|
887
|
+
previous = rank
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
return true
|
|
891
|
+
}),
|
|
892
|
+
),
|
|
893
|
+
) {}
|
|
894
|
+
|
|
895
|
+
/** Immutable accepted input, distinct from all regenerable ledger execution state. */
|
|
896
|
+
export class ThreadAdmission extends Schema.Class<ThreadAdmission>(
|
|
897
|
+
'@effect-agent/thread/ThreadAdmission',
|
|
898
|
+
)({
|
|
899
|
+
...AdmissionRequest.fields,
|
|
900
|
+
submissionId: SubmissionId,
|
|
901
|
+
receiptId: ReceiptId,
|
|
902
|
+
queueSequence: QueueSequence,
|
|
903
|
+
createdAt: Schema.DateTimeUtcFromString,
|
|
904
|
+
/** Stable closed Receipt timestamp; required for idle transfer, absent on active verification facts. */
|
|
905
|
+
settledAt: Schema.optionalKey(Schema.DateTimeUtcFromString),
|
|
906
|
+
}) {}
|
|
907
|
+
|
|
908
|
+
/** Accepted operator commands are facts; their application markers are deliberately omitted. */
|
|
909
|
+
export const ThreadAbortFact = AbortIntent.mapFields(Struct.omit(['canonicalRecordId']))
|
|
910
|
+
|
|
911
|
+
export const ThreadApprovalFact = ApprovalDecisionIntent.mapFields(
|
|
912
|
+
Struct.omit(['canonicalRecordId']),
|
|
913
|
+
)
|
|
914
|
+
|
|
915
|
+
export const ThreadResolutionFact = UnknownResolutionIntent.mapFields(
|
|
916
|
+
Struct.omit(['canonicalRecordId']),
|
|
917
|
+
)
|
|
918
|
+
|
|
919
|
+
export const ThreadCommands = Schema.Struct({
|
|
920
|
+
aborts: Schema.Array(ThreadAbortFact).check(Schema.isMaxLength(MAX_THREAD_EXPORT_PAGE_RECORDS)),
|
|
921
|
+
approvals: Schema.Array(ThreadApprovalFact).check(
|
|
922
|
+
Schema.isMaxLength(MAX_THREAD_EXPORT_PAGE_RECORDS),
|
|
923
|
+
),
|
|
924
|
+
resolutions: Schema.Array(ThreadResolutionFact).check(
|
|
925
|
+
Schema.isMaxLength(MAX_THREAD_EXPORT_PAGE_RECORDS),
|
|
926
|
+
),
|
|
927
|
+
})
|
|
928
|
+
|
|
929
|
+
export const ThreadExportBatch = Schema.Struct({ batchId: BatchId, producerId: ProducerId })
|
|
930
|
+
|
|
931
|
+
/** The wire is part of the export type: ordinary read envelopes are not lossless archives. */
|
|
932
|
+
export class ThreadExportRecord extends CanonicalRecordEnvelope.extend<ThreadExportRecord>(
|
|
933
|
+
'@effect-agent/thread/ThreadExportRecord',
|
|
934
|
+
)({
|
|
935
|
+
record: ExportRecord,
|
|
936
|
+
}) {}
|
|
937
|
+
|
|
938
|
+
/** One bounded, batch-aligned page. An absent cursor alone marks a complete transfer. */
|
|
939
|
+
export class ThreadExport extends Schema.Class<ThreadExport>('@effect-agent/thread/ThreadExport')({
|
|
940
|
+
transferFormat: Schema.Literal('effect-agent/thread-transfer@4'),
|
|
941
|
+
format: Schema.NonEmptyString,
|
|
942
|
+
threadId: ThreadId,
|
|
943
|
+
tailSequence: CanonicalSequence,
|
|
944
|
+
snapshot: ThreadExportSnapshot,
|
|
945
|
+
/** Presence seals the restored inbox; a terminal reason also requires exact settled worker evidence. */
|
|
946
|
+
workerSeal: Schema.optionalKey(ThreadWorkerSeal),
|
|
947
|
+
/** Inclusive first canonical position, even on a page containing only other owner facts. */
|
|
948
|
+
fromSequence: CanonicalSequence.check(Schema.isGreaterThan(0)),
|
|
949
|
+
records: Schema.Array(ThreadExportRecord).check(
|
|
950
|
+
Schema.isMaxLength(MAX_THREAD_EXPORT_PAGE_RECORDS),
|
|
951
|
+
),
|
|
952
|
+
batches: Schema.Array(ThreadExportBatch).check(
|
|
953
|
+
Schema.isMaxLength(MAX_THREAD_EXPORT_PAGE_RECORDS),
|
|
954
|
+
),
|
|
955
|
+
admissions: Schema.Array(ThreadAdmission).check(
|
|
956
|
+
Schema.isMaxLength(MAX_THREAD_EXPORT_PAGE_RECORDS),
|
|
957
|
+
),
|
|
958
|
+
commands: ThreadCommands,
|
|
959
|
+
/** Frozen delivery facts and outcomes; claims and leases are never transfer authority. */
|
|
960
|
+
deliveries: Schema.Array(MessageDeliveryRecord).check(
|
|
961
|
+
Schema.isMaxLength(MAX_THREAD_EXPORT_PAGE_RECORDS),
|
|
962
|
+
),
|
|
963
|
+
cursor: Schema.optionalKey(ThreadExportCursor),
|
|
964
|
+
/** Exact reference-bearing records identify cross-range recovery dependencies. */
|
|
965
|
+
dependencies: Schema.Array(RecordId).check(Schema.isMaxLength(256 * 4_096)),
|
|
966
|
+
}) {}
|
|
967
|
+
|
|
968
|
+
/** Idle export authority. Applications quiesce external producers for the complete export. */
|
|
969
|
+
export class ThreadExportSource extends Context.Service<
|
|
970
|
+
ThreadExportSource,
|
|
971
|
+
Pick<ThreadStore['Service'], 'export'>
|
|
972
|
+
>()('@effect-agent/thread/ThreadExportSource') {
|
|
973
|
+
static layer() {
|
|
974
|
+
return Layer.effect(
|
|
975
|
+
ThreadExportSource,
|
|
976
|
+
Effect.map(ThreadStore, (store) => ThreadExportSource.of({ export: store.export })),
|
|
977
|
+
)
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/** Pull bounded idle pages. The caller keeps this Thread quiescent until the stream ends. */
|
|
982
|
+
export const streamExport = (request: ThreadExportRequest) =>
|
|
983
|
+
Stream.unwrap(
|
|
984
|
+
Effect.gen(function*() {
|
|
985
|
+
const source = yield* ThreadExportSource
|
|
986
|
+
let previous: ThreadExport | undefined
|
|
987
|
+
|
|
988
|
+
return Stream.paginate(request, (current) =>
|
|
989
|
+
source.export(current).pipe(
|
|
990
|
+
Effect.flatMap((page) => {
|
|
991
|
+
if (
|
|
992
|
+
page.threadId !== request.threadId ||
|
|
993
|
+
(previous !== undefined &&
|
|
994
|
+
(!Schema.toEquivalence(ThreadExportSnapshot)(page.snapshot, previous.snapshot) ||
|
|
995
|
+
!Schema.toEquivalence(Schema.UndefinedOr(ThreadWorkerSeal))(
|
|
996
|
+
page.workerSeal,
|
|
997
|
+
previous.workerSeal,
|
|
998
|
+
) ||
|
|
999
|
+
page.tailSequence !== previous.tailSequence ||
|
|
1000
|
+
page.fromSequence !==
|
|
1001
|
+
(previous.records.at(-1)?.sequence ?? previous.fromSequence - 1) + 1 ||
|
|
1002
|
+
(page.cursor !== undefined && page.cursor === current.cursor)))
|
|
1003
|
+
) {
|
|
1004
|
+
return Effect.fail(
|
|
1005
|
+
ThreadStoreError.make({
|
|
1006
|
+
operation: 'stream Thread export',
|
|
1007
|
+
message: 'Transfer snapshot or cursor is inconsistent',
|
|
1008
|
+
}),
|
|
1009
|
+
)
|
|
1010
|
+
}
|
|
1011
|
+
previous = page
|
|
1012
|
+
|
|
1013
|
+
return Effect.succeed(
|
|
1014
|
+
[
|
|
1015
|
+
[page],
|
|
1016
|
+
page.cursor === undefined
|
|
1017
|
+
? Option.none()
|
|
1018
|
+
: Option.some(
|
|
1019
|
+
ThreadExportRequest.make({ threadId: request.threadId, cursor: page.cursor }),
|
|
1020
|
+
),
|
|
1021
|
+
] as const,
|
|
1022
|
+
)
|
|
1023
|
+
}),
|
|
1024
|
+
))
|
|
1025
|
+
}),
|
|
1026
|
+
)
|
|
1027
|
+
|
|
1028
|
+
/** A bounded, disposable prior Prompt, checked against its captured historyDigest. */
|
|
1029
|
+
export const MAX_PROMPT_CHECKPOINT_BYTES = 16 * 1024 * 1024
|
|
1030
|
+
|
|
1031
|
+
/** Maximum ordinary Runs between full prompt replacements and in a cold catch-up suffix. */
|
|
1032
|
+
export const MAX_PROMPT_CHECKPOINT_RUNS = 16
|
|
1033
|
+
|
|
1034
|
+
export const PromptCheckpointHead = Schema.Struct({
|
|
1035
|
+
version: Schema.Literal(2),
|
|
1036
|
+
recordFormat: Schema.Literal(CURRENT_RECORD_FORMAT),
|
|
1037
|
+
threadId: ThreadId,
|
|
1038
|
+
runId: RunId,
|
|
1039
|
+
throughSequence: CanonicalSequence,
|
|
1040
|
+
historyThrough: CanonicalSequence,
|
|
1041
|
+
priorHistoryLength: Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 16_384 })),
|
|
1042
|
+
historyDigest: Digest,
|
|
1043
|
+
})
|
|
1044
|
+
|
|
1045
|
+
export const PromptCheckpoint = Schema.Struct({
|
|
1046
|
+
...PromptCheckpointHead.fields,
|
|
1047
|
+
/** Canonical JSON from Effect's Prompt codec; integrity is checked before decoding it. */
|
|
1048
|
+
promptJson: Schema.String.check(Schema.isMaxLength(MAX_PROMPT_CHECKPOINT_BYTES)),
|
|
1049
|
+
})
|
|
1050
|
+
|
|
1051
|
+
export type PromptCheckpoint = typeof PromptCheckpoint.Type
|
|
1052
|
+
|
|
1053
|
+
export const PromptCheckpointRead = Schema.Struct({
|
|
1054
|
+
threadId: ThreadId,
|
|
1055
|
+
throughSequence: CanonicalSequence,
|
|
1056
|
+
})
|
|
1057
|
+
|
|
1058
|
+
export type PromptCheckpointRead = typeof PromptCheckpointRead.Type
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Optional cold-context acceleration. Save only after canonical settlement.
|
|
1062
|
+
* Replace the prior value atomically at the exact supplied sequence.
|
|
1063
|
+
* One process owns the Thread; import only targets empty Threads and atomically deletes these
|
|
1064
|
+
* derivatives. The runtime validates the content digest and a bounded suffix of completed Runs.
|
|
1065
|
+
* Any incompatible head, content digest or suffix is a cache miss.
|
|
1066
|
+
* Never export these bytes or use them as execution/compaction evidence.
|
|
1067
|
+
*/
|
|
1068
|
+
export interface PromptCheckpoints {
|
|
1069
|
+
readonly save: (checkpoint: PromptCheckpoint) => Effect.Effect<void, ThreadStoreError>
|
|
1070
|
+
readonly load: (
|
|
1071
|
+
request: PromptCheckpointRead,
|
|
1072
|
+
) => Effect.Effect<Option.Option<PromptCheckpoint>, ThreadStoreError>
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* Content-free storage provenance constructed by adapters from source-authored labels.
|
|
1077
|
+
* Raw foreign lookalikes are not trusted diagnostics. Never include rejected values, SQL,
|
|
1078
|
+
* or schema messages.
|
|
1079
|
+
*/
|
|
1080
|
+
export class ThreadStoreDiagnostic extends Schema.Class<ThreadStoreDiagnostic>(
|
|
1081
|
+
'@effect-agent/thread/ThreadStoreDiagnostic',
|
|
1082
|
+
)({
|
|
1083
|
+
causeTag: Schema.String.check(Schema.isMaxLength(128)),
|
|
1084
|
+
operation: Schema.String.check(Schema.isMaxLength(256)),
|
|
1085
|
+
decoder: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(128))),
|
|
1086
|
+
issueTag: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(128))),
|
|
1087
|
+
sequence: Schema.optionalKey(CanonicalSequence),
|
|
1088
|
+
}) {}
|
|
1089
|
+
|
|
1090
|
+
export class ThreadStoreError extends Schema.TaggedError<ThreadStoreError>()('ThreadStoreError', {
|
|
1091
|
+
operation: Schema.String,
|
|
1092
|
+
message: Schema.String,
|
|
1093
|
+
cause: Schema.optionalKey(Schema.Defect()),
|
|
1094
|
+
diagnostic: Schema.optionalKey(ThreadStoreDiagnostic),
|
|
1095
|
+
/** Atomic outbox rejection; unlike diagnostic causes, this survives routed storage codecs. */
|
|
1096
|
+
deliveryReason: Schema.optionalKey(MessageDeliveryError.fields.reason),
|
|
1097
|
+
}) {}
|
|
1098
|
+
|
|
1099
|
+
export class ThreadNotMaterialized extends Schema.TaggedError<ThreadNotMaterialized>()(
|
|
1100
|
+
'ThreadNotMaterialized',
|
|
1101
|
+
{ threadId: ThreadId },
|
|
1102
|
+
) {}
|
|
1103
|
+
|
|
1104
|
+
/** Export is Thread-local: external schedules, subscriptions and ingress are application-owned. */
|
|
1105
|
+
export class ThreadExportRejected extends Schema.TaggedError<ThreadExportRejected>()(
|
|
1106
|
+
'ThreadExportRejected',
|
|
1107
|
+
{
|
|
1108
|
+
threadId: ThreadId,
|
|
1109
|
+
reason: Schema.Literals(['non-idle', 'source-changed', 'live-import-source']),
|
|
1110
|
+
},
|
|
1111
|
+
) {
|
|
1112
|
+
override get message(): string {
|
|
1113
|
+
switch (this.reason) {
|
|
1114
|
+
case 'non-idle':
|
|
1115
|
+
return `Thread ${this.threadId} is not idle; close its active owner and finish pending work before export.`
|
|
1116
|
+
case 'source-changed':
|
|
1117
|
+
return `Thread ${this.threadId} changed during export; keep the source quiescent and restart from the first page.`
|
|
1118
|
+
case 'live-import-source':
|
|
1119
|
+
return `Import requires a detached archive; finish exporting Thread ${this.threadId} before opening the destination transaction.`
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* A canonical append that cannot commit: `batch-content` replays a batch ID with different
|
|
1126
|
+
* content, `record-identity` reuses a canonical record ID, and `tail` declares a stale expected
|
|
1127
|
+
* tail. `stale-command` rejects a superseded operational request and must not be reprepared.
|
|
1128
|
+
* Tail conflicts carry the actual committed tail as a diagnostic resume hint.
|
|
1129
|
+
*/
|
|
1130
|
+
export class AppendConflict extends Schema.TaggedError<AppendConflict>()('AppendConflict', {
|
|
1131
|
+
threadId: ThreadId,
|
|
1132
|
+
batchId: BatchId,
|
|
1133
|
+
reason: Schema.Literals(['batch-content', 'record-identity', 'tail', 'stale-command']),
|
|
1134
|
+
actualTailSequence: Schema.optionalKey(CanonicalSequence),
|
|
1135
|
+
}) {}
|
|
1136
|
+
|
|
1137
|
+
export type ThreadStoreFailure =
|
|
1138
|
+
| ThreadStoreError
|
|
1139
|
+
| ThreadNotMaterialized
|
|
1140
|
+
| AppendConflict
|
|
1141
|
+
| OwnershipLost
|
|
1142
|
+
|
|
1143
|
+
export class ThreadStore extends Context.Service<
|
|
1144
|
+
ThreadStore,
|
|
1145
|
+
{
|
|
1146
|
+
readonly lifecyclePublications?: LifecyclePublicationStorage
|
|
1147
|
+
/** Native owner inventory and explicit canonical-index reconstruction. Absence fails closed. */
|
|
1148
|
+
readonly work?: ThreadWorkStorage
|
|
1149
|
+
/** Bounded physical log ranges, independent of compaction and execution ownership. */
|
|
1150
|
+
readonly archives?: ThreadArchiveStorage
|
|
1151
|
+
readonly verification?: ThreadVerificationStorage
|
|
1152
|
+
readonly materialize: (request: ThreadMaterialization) => Effect.Effect<void, ThreadStoreError>
|
|
1153
|
+
/**
|
|
1154
|
+
* Commit history, current execution and frozen peer/report/update deliveries atomically
|
|
1155
|
+
* under the storage owner's mutation gate. Delivery-bearing appends require the native
|
|
1156
|
+
* MessageDeliveryStore paired to this physical owner; limits apply before publication.
|
|
1157
|
+
* Only the latest active operational intent replays. Historical batches compare exact
|
|
1158
|
+
* canonical content; their prior operational intent is no longer retained.
|
|
1159
|
+
*/
|
|
1160
|
+
readonly append: (
|
|
1161
|
+
request: AppendRequest,
|
|
1162
|
+
) => Effect.Effect<
|
|
1163
|
+
AppendResult,
|
|
1164
|
+
ThreadStoreError | ThreadNotMaterialized | AppendConflict | OwnershipLost
|
|
1165
|
+
>
|
|
1166
|
+
/** Authoritative current state only. Absence after settlement is normal; loss while active is corruption. */
|
|
1167
|
+
readonly readExecution: (
|
|
1168
|
+
request: ExecutionRead,
|
|
1169
|
+
) => Effect.Effect<
|
|
1170
|
+
Option.Option<ExecutionCheckpoint>,
|
|
1171
|
+
ThreadStoreError | ThreadNotMaterialized
|
|
1172
|
+
>
|
|
1173
|
+
/** Return immutable values decoded from privately owned canonical JSON. Unknown/Json
|
|
1174
|
+
* subgraphs must not retain caller/provider objects, accessors or oversized backing views.
|
|
1175
|
+
* Schema validation without canonical capture does not establish this ownership. */
|
|
1176
|
+
readonly read: (
|
|
1177
|
+
request: ThreadReadRequest,
|
|
1178
|
+
) => Stream.Stream<CanonicalRecordEnvelope, ThreadStoreError | ThreadNotMaterialized>
|
|
1179
|
+
/** Decode only PromptRecord fields of PROMPT_EVIDENCE_TAGS, including archived ranges.
|
|
1180
|
+
* Bound raw hydration without shortening a page before its limit or captured range end.
|
|
1181
|
+
* Preserve read's canonical ownership contract, including nested Unknown/Json values.
|
|
1182
|
+
* The immutable source was validated on write; use read for integrity or execution evidence. */
|
|
1183
|
+
readonly readPrompt: (
|
|
1184
|
+
request: ThreadPromptRead,
|
|
1185
|
+
) => Stream.Stream<PromptRecordEnvelope, ThreadStoreError | ThreadNotMaterialized>
|
|
1186
|
+
readonly observe: (
|
|
1187
|
+
request: ThreadObservation,
|
|
1188
|
+
) => Stream.Stream<CanonicalRecordEnvelope, ThreadStoreError | ThreadNotMaterialized>
|
|
1189
|
+
readonly export: (
|
|
1190
|
+
request: ThreadExportRequest,
|
|
1191
|
+
) => Effect.Effect<
|
|
1192
|
+
ThreadExport,
|
|
1193
|
+
ThreadStoreError | ThreadNotMaterialized | ThreadExportRejected
|
|
1194
|
+
>
|
|
1195
|
+
readonly inspectTail: (
|
|
1196
|
+
request: ThreadTailRequest,
|
|
1197
|
+
) => Effect.Effect<ThreadTail, ThreadStoreError | ThreadNotMaterialized>
|
|
1198
|
+
readonly readIdentity: (
|
|
1199
|
+
request: ThreadIdentityRequest,
|
|
1200
|
+
) => Effect.Effect<ThreadIdentity, ThreadStoreError | ThreadNotMaterialized>
|
|
1201
|
+
/** Owner-held preparation for an admitted root Run. Some proves an initialized root
|
|
1202
|
+
* identity and no checkpoint, Run membership or exact input/abort/settlement record.
|
|
1203
|
+
* None requires ordinary recovery; it never authorizes overwriting existing evidence. */
|
|
1204
|
+
readonly readFreshRun?: (
|
|
1205
|
+
request: FreshRunRead,
|
|
1206
|
+
) => Effect.Effect<Option.Option<ThreadIdentity>, ThreadStoreError | ThreadNotMaterialized>
|
|
1207
|
+
readonly readWorkerCapacity?: (
|
|
1208
|
+
request: ThreadWorkerCapacityRequest,
|
|
1209
|
+
) => Effect.Effect<ThreadWorkerCapacity, ThreadStoreError | ThreadNotMaterialized>
|
|
1210
|
+
readonly promptCheckpoints?: PromptCheckpoints | undefined
|
|
1211
|
+
/** Indexed scalar count; required when assembling a durable runtime. */
|
|
1212
|
+
readonly countPeerMessages?:
|
|
1213
|
+
| ((
|
|
1214
|
+
request: ThreadPeerCountRequest,
|
|
1215
|
+
) => Effect.Effect<number, ThreadStoreError | ThreadNotMaterialized>)
|
|
1216
|
+
| undefined
|
|
1217
|
+
}
|
|
1218
|
+
>()('@effect-agent/thread/ThreadStore') {}
|
|
1219
|
+
|
|
1220
|
+
/** Canonical observation without append or materialization authority. */
|
|
1221
|
+
export class ThreadReader extends Context.Service<
|
|
1222
|
+
ThreadReader,
|
|
1223
|
+
Pick<
|
|
1224
|
+
ThreadStore['Service'],
|
|
1225
|
+
| 'read'
|
|
1226
|
+
| 'readExecution'
|
|
1227
|
+
| 'readPrompt'
|
|
1228
|
+
| 'observe'
|
|
1229
|
+
| 'export'
|
|
1230
|
+
| 'inspectTail'
|
|
1231
|
+
| 'readIdentity'
|
|
1232
|
+
| 'countPeerMessages'
|
|
1233
|
+
| 'readWorkerCapacity'
|
|
1234
|
+
>
|
|
1235
|
+
>()('@effect-agent/thread/ThreadReader') {
|
|
1236
|
+
static fromStore(store: ThreadStore['Service']): ThreadReader['Service'] {
|
|
1237
|
+
return {
|
|
1238
|
+
read: store.read,
|
|
1239
|
+
readExecution: store.readExecution,
|
|
1240
|
+
readPrompt: store.readPrompt,
|
|
1241
|
+
observe: store.observe,
|
|
1242
|
+
export: store.export,
|
|
1243
|
+
inspectTail: store.inspectTail,
|
|
1244
|
+
readIdentity: store.readIdentity,
|
|
1245
|
+
...(store.readWorkerCapacity === undefined
|
|
1246
|
+
? {}
|
|
1247
|
+
: { readWorkerCapacity: store.readWorkerCapacity }),
|
|
1248
|
+
...(store.countPeerMessages === undefined
|
|
1249
|
+
? {}
|
|
1250
|
+
: { countPeerMessages: store.countPeerMessages }),
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/** Capture this assembly's store, independently of other local or routed stores. */
|
|
1255
|
+
static layer() {
|
|
1256
|
+
return Layer.effect(ThreadReader, Effect.map(ThreadStore, ThreadReader.fromStore))
|
|
1257
|
+
}
|
|
1258
|
+
}
|