@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,1107 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
|
|
2
|
+
import * as Prompt from "effect/ai/Prompt";
|
|
3
|
+
import * as Brand from "effect/Brand";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Predicate from "effect/Predicate";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import * as Stream from "effect/Stream";
|
|
8
|
+
import { d as ToolCallId, u as ThreadId } from "./Identifiers-LWd4837I.mjs";
|
|
9
|
+
import { t as RunPolicyUsage } from "./RunPolicyUsage-B-JXRZYO.mjs";
|
|
10
|
+
import { g as summarizeModelUsage } from "./Usage-B0xgME5f.mjs";
|
|
11
|
+
import { f as contextWindowId, n as COMPACTION_SUMMARY_PREFIX, p as contextWindowMessage, t as CLEARED_TOOL_RESULT } from "./compaction-C3hXuO4Z.mjs";
|
|
12
|
+
import { s as digestJson } from "./Digest-CU6IWj-2.mjs";
|
|
13
|
+
import { X as RecordEnvelope, c as CanonicalBatch, f as CanonicalSequence, nt as RunCompleted, wt as ToolCallSettled, z as ModelResponseRecorded } from "./Records-C645aQks.mjs";
|
|
14
|
+
import { t as IdempotencyKey } from "./Receipt-B-FlCaNH.mjs";
|
|
15
|
+
// src/durable/internal/journal-metadata.ts
|
|
16
|
+
const makeRecordId$1 = Brand.nominal();
|
|
17
|
+
/** Deterministic canonical record identity of one Turn's Tool result. */
|
|
18
|
+
const toolCallSettledRecordId = (runId, turn, toolCallId) => makeRecordId$1(`tool-settled:${runId}:${turn}:${toolCallId}`);
|
|
19
|
+
/**
|
|
20
|
+
* Attempt-local metadata collector. Feed every validated record exactly once, in canonical order,
|
|
21
|
+
* including records omitted from the control view. Calling finish transfers its collections;
|
|
22
|
+
* discard the collector afterward. The metadata may only accompany a replay stream bounded at
|
|
23
|
+
* that same captured tail. A later prefix requires a new collector.
|
|
24
|
+
*/
|
|
25
|
+
const makeJournalMetadata = (ownerRunId) => {
|
|
26
|
+
const firstSequenceByRun = /* @__PURE__ */ new Map();
|
|
27
|
+
const responseSequencesByRun = /* @__PURE__ */ new Map();
|
|
28
|
+
const declarationsByRun = /* @__PURE__ */ new Map();
|
|
29
|
+
const terminalSequenceByRun = /* @__PURE__ */ new Map();
|
|
30
|
+
const settledSpans = [];
|
|
31
|
+
const settledSequenceById = /* @__PURE__ */ new Map();
|
|
32
|
+
const settledToolCallRecordIds = /* @__PURE__ */ new Set();
|
|
33
|
+
const settledById = /* @__PURE__ */ new Map();
|
|
34
|
+
const compactions = [];
|
|
35
|
+
return {
|
|
36
|
+
add: (envelope) => {
|
|
37
|
+
const payload = envelope.record.payload;
|
|
38
|
+
if ((payload._tag === "RunCompleted" || payload._tag === "RunFailed" || payload._tag === "SubmissionSettled") && payload.runId !== void 0 && !terminalSequenceByRun.has(payload.runId)) terminalSequenceByRun.set(payload.runId, envelope.sequence);
|
|
39
|
+
if (payload._tag === "CompactionCreated") {
|
|
40
|
+
compactions.push({
|
|
41
|
+
payload,
|
|
42
|
+
sequence: envelope.sequence
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if ("runId" in payload && typeof payload.runId === "string" && !firstSequenceByRun.has(payload.runId)) firstSequenceByRun.set(payload.runId, envelope.sequence);
|
|
47
|
+
if (payload._tag === "ModelResponseRecorded") {
|
|
48
|
+
const sequences = responseSequencesByRun.get(payload.runId) ?? [];
|
|
49
|
+
sequences.push(envelope.sequence);
|
|
50
|
+
responseSequencesByRun.set(payload.runId, sequences);
|
|
51
|
+
const callIds = "toolOperations" in payload ? payload.toolOperations.map((operation) => operation.toolCallId) : payload.messages.content.flatMap((message) => message.role === "assistant" ? message.content.flatMap((part) => part.type === "tool-call" && !part.providerExecuted ? [part.id] : []) : []);
|
|
52
|
+
if (callIds.length > 0) {
|
|
53
|
+
const declarations = declarationsByRun.get(payload.runId) ?? [];
|
|
54
|
+
declarations.push({
|
|
55
|
+
sequence: envelope.sequence,
|
|
56
|
+
turn: payload.turn,
|
|
57
|
+
callIds
|
|
58
|
+
});
|
|
59
|
+
declarationsByRun.set(payload.runId, declarations);
|
|
60
|
+
}
|
|
61
|
+
} else if (payload._tag === "ToolCallSettled") {
|
|
62
|
+
settledToolCallRecordIds.add(envelope.record.recordId);
|
|
63
|
+
settledSequenceById.set(envelope.record.recordId, envelope.sequence);
|
|
64
|
+
if (payload.runId === ownerRunId) settledById.set(envelope.record.recordId, {
|
|
65
|
+
isFailure: payload.isFailure,
|
|
66
|
+
...!("toolSelection" in payload) || payload.toolSelection === void 0 ? {} : { toolSelection: payload.toolSelection },
|
|
67
|
+
...!("budgetRejected" in payload) || payload.budgetRejected === void 0 ? {} : { budgetRejected: payload.budgetRejected }
|
|
68
|
+
});
|
|
69
|
+
const from = declarationsByRun.get(payload.runId)?.findLast((declaration) => declaration.callIds.includes(payload.toolCallId) && toolCallSettledRecordId(payload.runId, declaration.turn, payload.toolCallId) === envelope.record.recordId)?.sequence;
|
|
70
|
+
if (from !== void 0 && from < envelope.sequence) settledSpans.push({
|
|
71
|
+
from,
|
|
72
|
+
to: envelope.sequence,
|
|
73
|
+
runId: payload.runId,
|
|
74
|
+
recordId: envelope.record.recordId
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
finish: () => {
|
|
79
|
+
responseSequencesByRun.forEach((sequences, runId) => {
|
|
80
|
+
responseSequencesByRun.set(runId, sequences.slice());
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
ownerRunId,
|
|
84
|
+
firstSequenceByRun,
|
|
85
|
+
responseSequencesByRun,
|
|
86
|
+
terminalSequenceByRun,
|
|
87
|
+
settledSpans,
|
|
88
|
+
settledSequenceById,
|
|
89
|
+
settledToolCallRecordIds,
|
|
90
|
+
settledById,
|
|
91
|
+
compactions
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
// src/durable/internal/usage-totals.ts
|
|
97
|
+
/** Captured calls are additive and nonnegative; progress does not need attribution groups. */
|
|
98
|
+
const continuationUsage = (calls) => Effect.suspend(() => {
|
|
99
|
+
let inputTokens = 0;
|
|
100
|
+
let outputTokens = 0;
|
|
101
|
+
let costMicrousd = 0;
|
|
102
|
+
let knownWebSearchCalls = 0;
|
|
103
|
+
for (const call of calls) {
|
|
104
|
+
inputTokens += call.inputTokens.total;
|
|
105
|
+
outputTokens += call.outputTokens.total;
|
|
106
|
+
costMicrousd += call.costMicrousd;
|
|
107
|
+
knownWebSearchCalls += call.webSearchCalls ?? 0;
|
|
108
|
+
}
|
|
109
|
+
if (Number.isSafeInteger(inputTokens) && Number.isSafeInteger(outputTokens) && Number.isSafeInteger(costMicrousd) && Number.isSafeInteger(knownWebSearchCalls)) return Effect.succeed({
|
|
110
|
+
modelCalls: calls.length,
|
|
111
|
+
inputTokens,
|
|
112
|
+
outputTokens,
|
|
113
|
+
costMicrousd
|
|
114
|
+
});
|
|
115
|
+
return Effect.map(summarizeModelUsage(calls), (summary) => ({
|
|
116
|
+
modelCalls: summary.modelCalls,
|
|
117
|
+
inputTokens: summary.inputTokens.total,
|
|
118
|
+
outputTokens: summary.outputTokens.total,
|
|
119
|
+
costMicrousd: summary.costMicrousd
|
|
120
|
+
}));
|
|
121
|
+
});
|
|
122
|
+
// src/durable/RunJournal.ts
|
|
123
|
+
var RunJournal_exports = /* @__PURE__ */ __exportAll({
|
|
124
|
+
RunJournalError: () => RunJournalError,
|
|
125
|
+
agentUpdateRecordId: () => agentUpdateRecordId,
|
|
126
|
+
approvalDecisionBatchId: () => approvalDecisionBatchId,
|
|
127
|
+
childIdempotencyKeyFor: () => childIdempotencyKeyFor,
|
|
128
|
+
childThreadIdFor: () => childThreadIdFor,
|
|
129
|
+
compactionBatchId: () => compactionBatchId,
|
|
130
|
+
compactionRecordId: () => compactionRecordId,
|
|
131
|
+
firstWorkerInputRecordId: () => firstWorkerInputRecordId,
|
|
132
|
+
initialRunJournal: () => initialRunJournal,
|
|
133
|
+
markUnknownBatchId: () => markUnknownBatchId,
|
|
134
|
+
modelResponseInterruptedBatchId: () => modelResponseInterruptedBatchId,
|
|
135
|
+
modelResponseInterruptedRecordId: () => modelResponseInterruptedRecordId,
|
|
136
|
+
modelResponseRecordId: () => modelResponseRecordId,
|
|
137
|
+
peerMessageRecordId: () => peerMessageRecordId,
|
|
138
|
+
projectRunJournal: () => projectRunJournal,
|
|
139
|
+
projectRunJournalStream: () => projectRunJournalStream,
|
|
140
|
+
promptFromCanonicalRecords: () => promptFromCanonicalRecords,
|
|
141
|
+
runCompletedRecordId: () => runCompletedRecordId,
|
|
142
|
+
runDurationBatchId: () => runDurationBatchId,
|
|
143
|
+
runDurationRecordId: () => runDurationRecordId,
|
|
144
|
+
runIdForSubmission: () => runIdForSubmission,
|
|
145
|
+
runStartedBatchId: () => runStartedBatchId,
|
|
146
|
+
runStartedRecordId: () => runStartedRecordId,
|
|
147
|
+
subagentJoinBatchId: () => subagentJoinBatchId,
|
|
148
|
+
subagentJoinedRecordId: () => subagentJoinedRecordId,
|
|
149
|
+
subagentLineageBatchId: () => subagentLineageBatchId,
|
|
150
|
+
subagentLineageRecordId: () => subagentLineageRecordId,
|
|
151
|
+
subagentRequestedBatchId: () => subagentRequestedBatchId,
|
|
152
|
+
subagentRequestedRecordId: () => subagentRequestedRecordId,
|
|
153
|
+
subagentStartedBatchId: () => subagentStartedBatchId,
|
|
154
|
+
subagentStartedRecordId: () => subagentStartedRecordId,
|
|
155
|
+
toolApprovalDecisionRecordId: () => toolApprovalDecisionRecordId,
|
|
156
|
+
toolApprovalRequestRecordId: () => toolApprovalRequestRecordId,
|
|
157
|
+
toolCallResolutionBatchId: () => toolCallResolutionBatchId,
|
|
158
|
+
toolCallResolvedRecordId: () => toolCallResolvedRecordId,
|
|
159
|
+
toolCallResultBatchId: () => toolCallResultBatchId,
|
|
160
|
+
toolCallSettledRecordId: () => toolCallSettledRecordId,
|
|
161
|
+
toolCallUnknownRecordId: () => toolCallUnknownRecordId,
|
|
162
|
+
toolStepSettledBatchId: () => toolStepSettledBatchId,
|
|
163
|
+
toolStepSettledRecordId: () => toolStepSettledRecordId,
|
|
164
|
+
turnApprovalsBatchId: () => turnApprovalsBatchId,
|
|
165
|
+
turnBatchId: () => turnBatchId,
|
|
166
|
+
turnCanonicalBatch: () => turnCanonicalBatch,
|
|
167
|
+
turnIdForRun: () => turnIdForRun,
|
|
168
|
+
turnResponseBatch: () => turnResponseBatch,
|
|
169
|
+
turnResponseBatchId: () => turnResponseBatchId,
|
|
170
|
+
turnResultsBatch: () => turnResultsBatch,
|
|
171
|
+
turnResultsBatchId: () => turnResultsBatchId,
|
|
172
|
+
workerInputRecordId: () => workerInputRecordId,
|
|
173
|
+
workerOriginRecordId: () => workerOriginRecordId,
|
|
174
|
+
workerReportRecordId: () => workerReportRecordId
|
|
175
|
+
});
|
|
176
|
+
/** A canonical record could not be projected into Run/Prompt state. */
|
|
177
|
+
var RunJournalError = class extends Schema.TaggedError()("RunJournalError", {
|
|
178
|
+
message: Schema.String,
|
|
179
|
+
cause: Schema.optionalKey(Schema.Defect())
|
|
180
|
+
}) {};
|
|
181
|
+
const journalError = (message, cause) => cause === void 0 ? RunJournalError.make({ message }) : RunJournalError.make({
|
|
182
|
+
message,
|
|
183
|
+
cause
|
|
184
|
+
});
|
|
185
|
+
const makeRunId = Brand.nominal();
|
|
186
|
+
const makeTurnId = Brand.nominal();
|
|
187
|
+
const makeBatchId = Brand.nominal();
|
|
188
|
+
const makeRecordId = Brand.nominal();
|
|
189
|
+
/**
|
|
190
|
+
* Deterministic Run identity pinned per Submission (plan §Coordinator flow). Every Attempt of one
|
|
191
|
+
* Submission shares this Run identity, so canonical per-Turn records from different Attempts
|
|
192
|
+
* belong to one logical Run.
|
|
193
|
+
*/
|
|
194
|
+
const runIdForSubmission = (submissionId) => makeRunId(`run:${submissionId}`);
|
|
195
|
+
/** Stable canonical clock identity shared by every Attempt of one Run. */
|
|
196
|
+
const runStartedRecordId = (runId) => makeRecordId(`run-start:${runId}`);
|
|
197
|
+
const runStartedBatchId = (runId) => makeBatchId(`run-start:${runId}`);
|
|
198
|
+
const runDurationRecordId = (runId) => makeRecordId(`run-duration:${runId}`);
|
|
199
|
+
const runDurationBatchId = (runId) => makeBatchId(`run-duration:${runId}`);
|
|
200
|
+
/** Deterministic Turn identity: Attempt-independent for one (Run, canonical turn) pair. */
|
|
201
|
+
const turnIdForRun = (runId, turn) => makeTurnId(`turn:${runId}:${turn}`);
|
|
202
|
+
/** Deterministic batch identity of a response committed atomically with its closed Turn outcomes. */
|
|
203
|
+
const turnBatchId = (runId, turn) => makeBatchId(`turn:${runId}:${turn}`);
|
|
204
|
+
/**
|
|
205
|
+
* Deterministic batch identity of a tool-declaring Turn's RESPONSE commit (plan §2.1 commit 1):
|
|
206
|
+
* the assistant response plus pending steering becomes canonical before approval preflight and
|
|
207
|
+
* dispatch fencing, or when readonly execution first requires a persisted call-scoped capability.
|
|
208
|
+
* Unsettled declarations conservatively record possible execution.
|
|
209
|
+
*/
|
|
210
|
+
const turnResponseBatchId = (runId, turn) => makeBatchId(`turn-response:${runId}:${turn}`);
|
|
211
|
+
/**
|
|
212
|
+
* Deterministic batch identity of a tool-declaring Turn's RESULTS commit (plan §2.1 commit 5):
|
|
213
|
+
* every `ToolCallSettled` record of the Turn, in declaration order, model-visible atomically.
|
|
214
|
+
*/
|
|
215
|
+
const turnResultsBatchId = (runId, turn) => makeBatchId(`turn-results:${runId}:${turn}`);
|
|
216
|
+
/**
|
|
217
|
+
* Deterministic per-call late-settle batch identity used by the resolution path when one
|
|
218
|
+
* recovered/resolved call settles outside its Turn's results batch. Record identity
|
|
219
|
+
* (`tool-settled:{runId}:{turn}:{toolCallId}`) dedupes double-settles across both paths.
|
|
220
|
+
*/
|
|
221
|
+
const toolCallResultBatchId = (runId, turn, toolCallId) => makeBatchId(`turn-results:${runId}:${turn}:${toolCallId}`);
|
|
222
|
+
/**
|
|
223
|
+
* Deterministic identity of one pre-Turn compaction record (RUN-026,
|
|
224
|
+
* RUN-026). Keyed by Run, Turn, and kind — the engine performs at most one
|
|
225
|
+
* threshold compaction per Turn plus at most one overflow-forced summarize,
|
|
226
|
+
* so a superseding Attempt that re-decides the same compaction replays the
|
|
227
|
+
* batch identity instead of duplicating the record.
|
|
228
|
+
*/
|
|
229
|
+
const compactionRecordId = (runId, turn, kind) => makeRecordId(`compaction:${runId}:${turn}:${kind}`);
|
|
230
|
+
/** Deterministic batch identity of one compaction append (same string as its record id). */
|
|
231
|
+
const compactionBatchId = (runId, turn, kind) => makeBatchId(`compaction:${runId}:${turn}:${kind}`);
|
|
232
|
+
/** Deterministic canonical record identity of one Turn's `ModelResponseRecorded` record. */
|
|
233
|
+
const modelResponseRecordId = (runId, turn) => makeRecordId(`model-response:${runId}:${turn}`);
|
|
234
|
+
/** Terminal Tool completion marker committed atomically with its settled Tool result. */
|
|
235
|
+
const runCompletedRecordId = (runId) => makeRecordId(`run-completed:${runId}`);
|
|
236
|
+
/** Native source reservation locator, including the first admission of a continuing worker. */
|
|
237
|
+
const workerInputRecordId = (messageId) => makeRecordId(`worker-input:${messageId}`);
|
|
238
|
+
/** Source-owned first reservation; native worker identity is minted from its first message. */
|
|
239
|
+
const firstWorkerInputRecordId = (worker) => makeRecordId(`worker-input:${worker.threadId}`);
|
|
240
|
+
const workerOriginRecordId = (threadId) => makeRecordId(`worker-origin:${threadId}`);
|
|
241
|
+
const workerReportRecordId = (messageId) => makeRecordId(`worker-report:${messageId}`);
|
|
242
|
+
const peerMessageRecordId = (messageId) => makeRecordId(messageId);
|
|
243
|
+
/** Same immutable tuple used by native update admission; callers never parse its hash. */
|
|
244
|
+
const agentUpdateRecordId = Effect.fnUntraced(function* (threadId, runId, updateId) {
|
|
245
|
+
return makeRecordId(`agent-update:${yield* digestJson([
|
|
246
|
+
threadId,
|
|
247
|
+
runId,
|
|
248
|
+
updateId
|
|
249
|
+
])}`);
|
|
250
|
+
});
|
|
251
|
+
/** Deterministic batch identity of one Turn's `ToolCallUnknown` marking append. */
|
|
252
|
+
const markUnknownBatchId = (submissionId, turn) => makeBatchId(`mark-unknown:${submissionId}:${turn}`);
|
|
253
|
+
/** Deterministic canonical record identity of one Tool Call's `ToolCallUnknown` record. */
|
|
254
|
+
const toolCallUnknownRecordId = (runId, turn, toolCallId) => makeRecordId(`tool-unknown:${runId}:${turn}:${toolCallId}`);
|
|
255
|
+
/** Deterministic batch identity of one Tool Call's resolution append (DUR-017). */
|
|
256
|
+
const toolCallResolutionBatchId = (submissionId, toolCallId) => makeBatchId(`resolve:${submissionId}:${toolCallId}`);
|
|
257
|
+
/** Deterministic canonical record identity of one Tool Call's `ToolCallResolved` record. */
|
|
258
|
+
const toolCallResolvedRecordId = (runId, turn, toolCallId) => makeRecordId(`tool-resolved:${runId}:${turn}:${toolCallId}`);
|
|
259
|
+
/**
|
|
260
|
+
* Deterministic identity of one accepted Durable Step result. The one-record batch reuses the
|
|
261
|
+
* SAME string, so batch idempotency plus the epoch fence realize the durability §11
|
|
262
|
+
* racing-writers rule: only the fenced winner's record commits; the loser replays it.
|
|
263
|
+
* A versioned JSON tuple keeps separator characters in each identity component distinct.
|
|
264
|
+
* Replay derives this key from the structured payload, including records with legacy IDs.
|
|
265
|
+
*/
|
|
266
|
+
const toolStepSettledRecordId = (runId, toolCallId, stepName) => makeRecordId(JSON.stringify([
|
|
267
|
+
"step@2",
|
|
268
|
+
runId,
|
|
269
|
+
toolCallId,
|
|
270
|
+
stepName
|
|
271
|
+
]));
|
|
272
|
+
/** Deterministic batch identity of one Durable Step commit (same string as its record id). */
|
|
273
|
+
const toolStepSettledBatchId = (runId, toolCallId, stepName) => makeBatchId(toolStepSettledRecordId(runId, toolCallId, stepName));
|
|
274
|
+
/** Deterministic batch identity of one Turn's canonical approval-request append (plan §2.6). */
|
|
275
|
+
const turnApprovalsBatchId = (runId, turn) => makeBatchId(`turn-approvals:${runId}:${turn}`);
|
|
276
|
+
/** Deterministic canonical record identity of one Tool Call's `ToolApprovalRequested` record. */
|
|
277
|
+
const toolApprovalRequestRecordId = (runId, turn, toolCallId) => makeRecordId(`approval-request:${runId}:${turn}:${toolCallId}`);
|
|
278
|
+
/** Deterministic batch identity of one Tool Call's canonical approval-decision append. */
|
|
279
|
+
const approvalDecisionBatchId = (submissionId, toolCallId) => makeBatchId(`approval-decision:${submissionId}:${toolCallId}`);
|
|
280
|
+
/** Deterministic canonical record identity of one Tool Call's `ToolApprovalDecided` record. */
|
|
281
|
+
const toolApprovalDecisionRecordId = (runId, turn, toolCallId) => makeRecordId(`approval-decision:${runId}:${turn}:${toolCallId}`);
|
|
282
|
+
/**
|
|
283
|
+
* One conservative incomplete-usage marker per Run, regardless of how often recovery occurs.
|
|
284
|
+
*/
|
|
285
|
+
const modelResponseInterruptedRecordId = (runId) => makeRecordId(`interrupted:${runId}`);
|
|
286
|
+
/** Deterministic batch identity of one `ModelResponseInterrupted` append (same string). */
|
|
287
|
+
const modelResponseInterruptedBatchId = (runId) => makeBatchId(`interrupted:${runId}`);
|
|
288
|
+
const decodeThreadId = Schema.decodeSync(ThreadId);
|
|
289
|
+
const decodeIdempotencyKey = Schema.decodeSync(IdempotencyKey);
|
|
290
|
+
/**
|
|
291
|
+
* Deterministic canonical record identity of one parent Tool Call's `SubagentRequested` record.
|
|
292
|
+
* The one-record batch reuses the same string, so batch
|
|
293
|
+
* idempotency plus the parent epoch fence make the request append exactly-once-canonical.
|
|
294
|
+
*/
|
|
295
|
+
const subagentRequestedRecordId = (runId, toolCallId) => makeRecordId(`subagent-requested:${runId}:${toolCallId}`);
|
|
296
|
+
/** Deterministic batch identity of one `SubagentRequested` append (same string). */
|
|
297
|
+
const subagentRequestedBatchId = (runId, toolCallId) => makeBatchId(`subagent-requested:${runId}:${toolCallId}`);
|
|
298
|
+
/**
|
|
299
|
+
* Deterministic canonical record identity of one parent Tool Call's `SubagentStarted` record.
|
|
300
|
+
* Recovery's start-link repair appends the EXACT same record
|
|
301
|
+
* under this identity, so a raced repair replays instead of duplicating (SUB-016/SUB-017).
|
|
302
|
+
*/
|
|
303
|
+
const subagentStartedRecordId = (runId, toolCallId) => makeRecordId(`subagent-started:${runId}:${toolCallId}`);
|
|
304
|
+
/** Deterministic batch identity of one `SubagentStarted` append (same string). */
|
|
305
|
+
const subagentStartedBatchId = (runId, toolCallId) => makeBatchId(`subagent-started:${runId}:${toolCallId}`);
|
|
306
|
+
/**
|
|
307
|
+
* Deterministic batch identity of one parent Tool Call's atomic settlement join: the
|
|
308
|
+
* `SubagentJoined` record plus the parent's `ToolCallSettled` record (its existing
|
|
309
|
+
* `tool-settled:{runId}:{turn}:{toolCallId}` identity) commit as ONE canonical batch (SUB-019).
|
|
310
|
+
*/
|
|
311
|
+
const subagentJoinBatchId = (runId, toolCallId) => makeBatchId(`subagent-join:${runId}:${toolCallId}`);
|
|
312
|
+
/** Deterministic canonical record identity of one parent Tool Call's `SubagentJoined` record. */
|
|
313
|
+
const subagentJoinedRecordId = (runId, toolCallId) => makeRecordId(`subagent-joined:${runId}:${toolCallId}`);
|
|
314
|
+
/**
|
|
315
|
+
* Deterministic identity of one child Thread's `SubagentLineageRecorded` record.
|
|
316
|
+
* Its own single-record batch reuses the same string so the generic
|
|
317
|
+
* `thread-created:{cid}` batch identity is never contradicted.
|
|
318
|
+
*/
|
|
319
|
+
const subagentLineageRecordId = (threadId) => makeRecordId(`subagent-lineage:${threadId}`);
|
|
320
|
+
/** Deterministic batch identity of one `SubagentLineageRecorded` append (same string). */
|
|
321
|
+
const subagentLineageBatchId = (threadId) => makeBatchId(`subagent-lineage:${threadId}`);
|
|
322
|
+
/**
|
|
323
|
+
* Deterministic intended child Thread identity: the
|
|
324
|
+
* parent Submission and Tool Call pair addresses exactly one child Thread, so a replayed
|
|
325
|
+
* establishment converges on the one existing child (SUB-016).
|
|
326
|
+
*/
|
|
327
|
+
const childThreadIdFor = (parentSubmissionId, toolCallId) => decodeThreadId(`subagent:${parentSubmissionId}:${toolCallId}`);
|
|
328
|
+
/**
|
|
329
|
+
* Deterministic child admission idempotency key: scoped to
|
|
330
|
+
* the parent Run and Tool Call identity, so duplicate admission attempts resolve through the
|
|
331
|
+
* ledger's idempotency contract to one child Receipt (SUB-016, SUB-031). The ledger key is
|
|
332
|
+
* bounded (256); coordinator-minted Run and Tool Call identities stay far below that bound.
|
|
333
|
+
*/
|
|
334
|
+
const childIdempotencyKeyFor = (parentRunId, toolCallId) => decodeIdempotencyKey(`subagent:${parentRunId}:${toolCallId}`);
|
|
335
|
+
const decodePersistedPrompt = (messages) => Schema.decodeUnknownEffect(Prompt.Prompt)(messages).pipe(Effect.mapError((cause) => journalError("Canonical messages are not Schema-encoded Prompt messages", cause)));
|
|
336
|
+
const decodedMessages = /* @__PURE__ */ new WeakMap();
|
|
337
|
+
const decodePromptMessages = (messages) => Effect.suspend(() => {
|
|
338
|
+
if (Prompt.isPrompt(messages)) return Effect.succeed(messages);
|
|
339
|
+
if (!Predicate.isObject(messages)) return decodePersistedPrompt(messages);
|
|
340
|
+
const cached = decodedMessages.get(messages);
|
|
341
|
+
return cached === void 0 ? decodePersistedPrompt(messages).pipe(Effect.tap((prompt) => Effect.sync(() => {
|
|
342
|
+
decodedMessages.set(messages, prompt);
|
|
343
|
+
}))) : Effect.succeed(cached);
|
|
344
|
+
});
|
|
345
|
+
const toolMessageFromSettled = (settled) => Effect.try({
|
|
346
|
+
try: () => Prompt.makeMessage("tool", { content: settled.map(({ record, cleared }) => Prompt.makePart("tool-result", {
|
|
347
|
+
id: record.toolCallId,
|
|
348
|
+
name: record.toolName,
|
|
349
|
+
result: cleared ? CLEARED_TOOL_RESULT : record.result,
|
|
350
|
+
isFailure: record.isFailure,
|
|
351
|
+
providerExecuted: false
|
|
352
|
+
})) }),
|
|
353
|
+
catch: (cause) => journalError("Unable to rebuild Tool message from ToolCallSettled", cause)
|
|
354
|
+
});
|
|
355
|
+
const initialPolicyUsage = () => ({
|
|
356
|
+
committedTurns: 0,
|
|
357
|
+
toolCalls: 0,
|
|
358
|
+
programmaticToolCalls: 0,
|
|
359
|
+
consecutiveToolFailures: 0,
|
|
360
|
+
finalizationUsed: false,
|
|
361
|
+
modelRestarts: 0
|
|
362
|
+
});
|
|
363
|
+
const initialUsage = (modelUsage) => ({
|
|
364
|
+
modelCalls: 0,
|
|
365
|
+
inputTokens: 0,
|
|
366
|
+
outputTokens: 0,
|
|
367
|
+
lastInputTokens: 0,
|
|
368
|
+
lastOutputTokens: 0,
|
|
369
|
+
costMicrousd: 0,
|
|
370
|
+
modelUsage
|
|
371
|
+
});
|
|
372
|
+
/** Internal first-Run projection after exact input/checkpoint-absence verification. The
|
|
373
|
+
* new UserInputRecorded contributes no model message; the engine evaluates it later. */
|
|
374
|
+
const initialRunJournal = (history) => ({
|
|
375
|
+
policyUsage: RunPolicyUsage.make(initialPolicyUsage()),
|
|
376
|
+
usage: initialUsage([]),
|
|
377
|
+
prompt: history,
|
|
378
|
+
historyBefore: history,
|
|
379
|
+
historyFrom: CanonicalSequence.make(1),
|
|
380
|
+
committedTurns: 0
|
|
381
|
+
});
|
|
382
|
+
const projectedResponseUsage = (response) => Effect.gen(function* () {
|
|
383
|
+
const calls = response.modelUsage;
|
|
384
|
+
if (calls === void 0) return {
|
|
385
|
+
modelCalls: 1,
|
|
386
|
+
inputTokens: response.inputTokens ?? 0,
|
|
387
|
+
outputTokens: response.outputTokens ?? 0,
|
|
388
|
+
costMicrousd: response.costMicrousd ?? 0,
|
|
389
|
+
modelUsage: []
|
|
390
|
+
};
|
|
391
|
+
if (calls.length === 0) return yield* journalError("A canonical modelUsage list must not be empty");
|
|
392
|
+
const summary = yield* summarizeModelUsage(calls).pipe(Effect.mapError((cause) => journalError("Canonical model usage exceeds accounting bounds", cause)));
|
|
393
|
+
if (response.inputTokens !== void 0 && response.inputTokens !== summary.inputTokens.total || response.outputTokens !== void 0 && response.outputTokens !== summary.outputTokens.total || response.costMicrousd !== void 0 && response.costMicrousd !== summary.costMicrousd) return yield* journalError("Canonical detailed and aggregate model usage disagree");
|
|
394
|
+
return {
|
|
395
|
+
modelCalls: summary.modelCalls,
|
|
396
|
+
inputTokens: summary.inputTokens.total,
|
|
397
|
+
outputTokens: summary.outputTokens.total,
|
|
398
|
+
costMicrousd: summary.costMicrousd,
|
|
399
|
+
modelUsage: calls
|
|
400
|
+
};
|
|
401
|
+
});
|
|
402
|
+
const addProjectedUsage = (field, left, right) => Schema.decodeEffect(Schema.Natural)(left + right).pipe(Effect.mapError((cause) => journalError(`Canonical projected usage exceeds safe-integer bounds at ${field}`, cause)));
|
|
403
|
+
const decodeToolCallId = Schema.decodeSync(ToolCallId);
|
|
404
|
+
const decodeToolCallIdEffect = Schema.decodeEffect(ToolCallId);
|
|
405
|
+
const declaredApplicationToolCallIds = (prompt) => {
|
|
406
|
+
const ids = [];
|
|
407
|
+
for (const message of prompt.content) {
|
|
408
|
+
if (message.role !== "assistant") continue;
|
|
409
|
+
for (const part of message.content) if (part.type === "tool-call" && !part.providerExecuted) ids.push(part.id);
|
|
410
|
+
}
|
|
411
|
+
return ids;
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* Phase 5 audit tags that are prompt-transparent: they carry durability evidence (approval,
|
|
415
|
+
* unknown marking, resolution, Step results, approvals, interruption) but contribute nothing to
|
|
416
|
+
* the model-visible Prompt, and — unlike the P4 tags — they do NOT split a contiguous
|
|
417
|
+
* `ToolCallSettled` group into separate Tool messages, so a late-settled call's audit records
|
|
418
|
+
* cannot change the replayed prompt shape.
|
|
419
|
+
*
|
|
420
|
+
* The four S2 Subagent lifecycle tags are prompt-transparent for the same reason (spec §5/§11):
|
|
421
|
+
* the parent prompt never carries child transcript or establishment evidence — the joined child
|
|
422
|
+
* result reaches the model exclusively through the paired `ToolCallSettled` record, and the
|
|
423
|
+
* child-log lineage record is not model input.
|
|
424
|
+
*/
|
|
425
|
+
const PROMPT_TRANSPARENT_TAGS = /* @__PURE__ */ new Set([
|
|
426
|
+
"RunPolicyUsageReserved",
|
|
427
|
+
"RunStarted",
|
|
428
|
+
"RunContextRecorded",
|
|
429
|
+
"RunContinuation",
|
|
430
|
+
"RunDurationExhausted",
|
|
431
|
+
"ToolCallUnknown",
|
|
432
|
+
"ToolCallResolved",
|
|
433
|
+
"ToolStepSettled",
|
|
434
|
+
"ToolApprovalRequested",
|
|
435
|
+
"ToolApprovalDecided",
|
|
436
|
+
"ModelResponseInterrupted",
|
|
437
|
+
"ModelCallAborted",
|
|
438
|
+
"SubagentRequested",
|
|
439
|
+
"SubagentStarted",
|
|
440
|
+
"SubagentJoined",
|
|
441
|
+
"SubagentLineageRecorded",
|
|
442
|
+
"WorkerInputRequested",
|
|
443
|
+
"WorkerOriginRecorded",
|
|
444
|
+
"WorkerInputCompleted",
|
|
445
|
+
"WorkerInputRefused",
|
|
446
|
+
"WorkerReportPrepared",
|
|
447
|
+
"AgentUpdateEmitted",
|
|
448
|
+
"WorkerReportRefused",
|
|
449
|
+
"PeerMessagePrepared",
|
|
450
|
+
"SubtreeBudgetReserved"
|
|
451
|
+
]);
|
|
452
|
+
/**
|
|
453
|
+
* Reconstruct a fixed canonical prefix from a re-readable stream. The caller must keep the same
|
|
454
|
+
* records visible on every traversal. The first collects compaction and settlement metadata;
|
|
455
|
+
* rollovers additionally validate covered Tool batches before rebuilding Prompt and usage. Metadata and the
|
|
456
|
+
* live Prompt remain resident; covered historical message/tool payloads do not. An uncompacted Prompt still grows
|
|
457
|
+
* with its conversation, so hosts must configure an appropriate context compaction policy.
|
|
458
|
+
* Prepared metadata must describe exactly this stream through the same fixed tail;
|
|
459
|
+
* it skips only the metadata scan, never covered-Tool validation or the canonical fold.
|
|
460
|
+
* @internal
|
|
461
|
+
*/
|
|
462
|
+
const projectRunJournalStream = Effect.fnUntraced(function* (records, ownerRunId, onBoundary, savedContext, preparedMetadata, onEvidence) {
|
|
463
|
+
if (savedContext !== void 0 && savedContext.runId !== ownerRunId) return yield* journalError("Saved original context belongs to another Run");
|
|
464
|
+
const initialContext = savedContext?.prompt;
|
|
465
|
+
if (initialContext !== void 0 && savedContext !== void 0 && savedContext.priorHistoryLength > initialContext.content.length) return yield* journalError("Saved original context has an invalid ownership boundary");
|
|
466
|
+
const historical = initialContext?.content.slice(0, savedContext?.priorHistoryLength) ?? [];
|
|
467
|
+
let state = {
|
|
468
|
+
all: [],
|
|
469
|
+
before: [],
|
|
470
|
+
pendingTools: [],
|
|
471
|
+
pendingToolsForRun: false,
|
|
472
|
+
committedTurns: 0
|
|
473
|
+
};
|
|
474
|
+
if (preparedMetadata !== void 0 && preparedMetadata.ownerRunId !== ownerRunId) return yield* journalError("Prepared journal metadata belongs to another replay");
|
|
475
|
+
let metadata = preparedMetadata;
|
|
476
|
+
if (metadata === void 0) {
|
|
477
|
+
const collected = makeJournalMetadata(ownerRunId);
|
|
478
|
+
yield* Stream.runForEach(records, (envelope) => Effect.sync(() => collected.add(envelope)));
|
|
479
|
+
metadata = collected.finish();
|
|
480
|
+
}
|
|
481
|
+
const { firstSequenceByRun, responseSequencesByRun, terminalSequenceByRun, settledSpans, settledSequenceById, settledToolCallRecordIds, settledById } = metadata;
|
|
482
|
+
const declarationByResultSequence = new Map(settledSpans.map(({ from, to }) => [to, from]));
|
|
483
|
+
const spansByDeclaration = /* @__PURE__ */ new Map();
|
|
484
|
+
for (const span of settledSpans) {
|
|
485
|
+
const spans = spansByDeclaration.get(span.from) ?? [];
|
|
486
|
+
spans.push(span);
|
|
487
|
+
spansByDeclaration.set(span.from, spans);
|
|
488
|
+
}
|
|
489
|
+
const isInRunView = (sequence, payload, runId) => {
|
|
490
|
+
if (runId === void 0 || payload.runId === void 0 || payload.runId === runId) return true;
|
|
491
|
+
const first = firstSequenceByRun.get(runId) ?? Number.POSITIVE_INFINITY;
|
|
492
|
+
return sequence < first || payload._tag === "ToolCallSettled" && (declarationByResultSequence.get(sequence) ?? Number.POSITIVE_INFINITY) < first;
|
|
493
|
+
};
|
|
494
|
+
const compactions = metadata.compactions.filter(({ sequence, payload }) => isInRunView(sequence, payload, ownerRunId));
|
|
495
|
+
const recordsForRun = records.pipe(Stream.filter(({ sequence, record: { payload } }) => isInRunView(sequence, payload, ownerRunId)));
|
|
496
|
+
const isCovered = (envelope, compaction) => envelope.sequence <= compaction.coversThrough && isInRunView(envelope.sequence, envelope.record.payload, compaction.runId);
|
|
497
|
+
const settledCoverage = compactions.reduce((through, { payload }) => payload.kind !== "summarize" ? Math.max(through, payload.coversThrough) : through, 0);
|
|
498
|
+
const isTerminalPriorRun = (candidateRunId, compactionRunId, beforeSequence) => {
|
|
499
|
+
const terminal = terminalSequenceByRun.get(candidateRunId);
|
|
500
|
+
return candidateRunId !== compactionRunId && terminal !== void 0 && terminal < beforeSequence && terminal > (responseSequencesByRun.get(candidateRunId)?.findLast((sequence) => sequence < beforeSequence) ?? 0);
|
|
501
|
+
};
|
|
502
|
+
const incompleteResponseSequences = [];
|
|
503
|
+
let ownerPrefixSequence = firstSequenceByRun.get(ownerRunId ?? "") ?? Number.POSITIVE_INFINITY;
|
|
504
|
+
let protectedContext = initialContext === void 0 ? void 0 : Prompt.fromMessages(initialContext.content.slice(savedContext?.priorHistoryLength));
|
|
505
|
+
if (settledCoverage > 0) yield* Stream.runForEach(recordsForRun, (envelope) => Effect.gen(function* () {
|
|
506
|
+
const payload = envelope.record.payload;
|
|
507
|
+
if (payload._tag !== "ModelResponseRecorded" || envelope.sequence > settledCoverage) return;
|
|
508
|
+
const messages = yield* decodePromptMessages(payload.messages);
|
|
509
|
+
const declared = declaredApplicationToolCallIds(messages);
|
|
510
|
+
let lastSettlementSequence = 0;
|
|
511
|
+
for (const id of declared) {
|
|
512
|
+
const callId = yield* decodeToolCallIdEffect(id).pipe(Effect.mapError((cause) => journalError("Failed to decode a declared Tool Call ID", cause)));
|
|
513
|
+
lastSettlementSequence = Math.max(lastSettlementSequence, settledSequenceById.get(toolCallSettledRecordId(payload.runId, payload.turn, callId)) ?? 1e400);
|
|
514
|
+
}
|
|
515
|
+
if (declared.length > 0) incompleteResponseSequences.push({
|
|
516
|
+
sequence: envelope.sequence,
|
|
517
|
+
runId: payload.runId,
|
|
518
|
+
lastSettlementSequence
|
|
519
|
+
});
|
|
520
|
+
if (payload.runId === ownerRunId && payload.turn === 1 && payload.runScopedPrefixLength !== void 0) {
|
|
521
|
+
ownerPrefixSequence = envelope.sequence;
|
|
522
|
+
protectedContext = Prompt.fromMessages(messages.content.slice(0, payload.runScopedPrefixLength));
|
|
523
|
+
}
|
|
524
|
+
}));
|
|
525
|
+
const boundIsValid = (payload, ownSequence, evidence) => {
|
|
526
|
+
const { runId, coversThrough } = payload;
|
|
527
|
+
if (coversThrough <= 0 || coversThrough >= ownSequence) return false;
|
|
528
|
+
const ownerFirst = firstSequenceByRun.get(runId);
|
|
529
|
+
if (payload.kind === "summarize" && ownerFirst !== void 0 && coversThrough >= ownerFirst) return false;
|
|
530
|
+
if (payload.kind !== "summarize" && savedContext?.boundaries.some((boundary) => boundary.sequence <= coversThrough && boundary.incomplete === true && boundary.terminalPriorRun !== true)) return false;
|
|
531
|
+
if (payload.kind !== "summarize") for (const response of incompleteResponseSequences) {
|
|
532
|
+
if (response.sequence > coversThrough || response.lastSettlementSequence < ownSequence || !isInRunView(response.sequence, {
|
|
533
|
+
_tag: "ModelResponseRecorded",
|
|
534
|
+
runId: response.runId
|
|
535
|
+
}, runId)) continue;
|
|
536
|
+
if (evidence !== void 0) {
|
|
537
|
+
evidence.add(response.sequence);
|
|
538
|
+
const terminal = terminalSequenceByRun.get(response.runId);
|
|
539
|
+
const lastResponse = responseSequencesByRun.get(response.runId)?.findLast((sequence) => sequence < ownSequence);
|
|
540
|
+
if (terminal !== void 0) evidence.add(terminal);
|
|
541
|
+
if (lastResponse !== void 0) evidence.add(lastResponse);
|
|
542
|
+
}
|
|
543
|
+
if (!isTerminalPriorRun(response.runId, runId, ownSequence)) return false;
|
|
544
|
+
}
|
|
545
|
+
for (const span of settledSpans) if (span.from <= coversThrough && coversThrough < span.to && span.to < ownSequence && isInRunView(span.from, {
|
|
546
|
+
_tag: "ModelResponseRecorded",
|
|
547
|
+
runId: span.runId
|
|
548
|
+
}, runId)) {
|
|
549
|
+
evidence?.add(span.from);
|
|
550
|
+
evidence?.add(span.to);
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
return true;
|
|
554
|
+
};
|
|
555
|
+
let replacements = [];
|
|
556
|
+
let clearings = [];
|
|
557
|
+
const retainCompaction = (views, next) => {
|
|
558
|
+
if (views.some((prior) => prior.payload.coversThrough > next.payload.coversThrough && isInRunView(next.sequence, next.payload, prior.payload.runId))) return views;
|
|
559
|
+
return [...views.filter((prior) => next.payload.coversThrough < prior.payload.coversThrough || !isInRunView(prior.sequence, prior.payload, next.payload.runId)), next];
|
|
560
|
+
};
|
|
561
|
+
let latestWindowId = savedContext?.contextWindowId;
|
|
562
|
+
let latestWindowSequence = -1;
|
|
563
|
+
let latestWindow;
|
|
564
|
+
let rolloverCoveredThrough = 0;
|
|
565
|
+
for (const { payload, sequence } of compactions) {
|
|
566
|
+
if (!boundIsValid(payload, sequence)) continue;
|
|
567
|
+
if (payload.kind === "rollover" && sequence > latestWindowSequence) {
|
|
568
|
+
latestWindowId = contextWindowId(payload.runId, payload.turn);
|
|
569
|
+
latestWindowSequence = sequence;
|
|
570
|
+
latestWindow = {
|
|
571
|
+
payload,
|
|
572
|
+
sequence
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
if (payload.kind === "rollover") rolloverCoveredThrough = Math.max(rolloverCoveredThrough, payload.coversThrough);
|
|
576
|
+
if (payload.kind === "summarize" || payload.kind === "rollover") {
|
|
577
|
+
if (payload.kind === "summarize" && payload.summary === void 0) continue;
|
|
578
|
+
replacements = retainCompaction(replacements, {
|
|
579
|
+
payload,
|
|
580
|
+
sequence
|
|
581
|
+
});
|
|
582
|
+
} else clearings = retainCompaction(clearings, {
|
|
583
|
+
payload,
|
|
584
|
+
sequence
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
const contextViews = [
|
|
588
|
+
...replacements,
|
|
589
|
+
...clearings,
|
|
590
|
+
...latestWindow === void 0 ? [] : [latestWindow]
|
|
591
|
+
];
|
|
592
|
+
const contextCompactions = new Set(contextViews.map(({ sequence }) => sequence));
|
|
593
|
+
const historyFrom = CanonicalSequence.make(replacements.reduce((from, { payload }) => Math.max(from, payload.coversThrough + 1), savedContext?.historyFrom ?? 1));
|
|
594
|
+
const contextValidationViews = compactions.filter(({ sequence }) => sequence >= historyFrom || contextCompactions.has(sequence));
|
|
595
|
+
const contextEvidence = new Set(contextValidationViews.flatMap(({ payload }) => {
|
|
596
|
+
const sequence = firstSequenceByRun.get(payload.runId);
|
|
597
|
+
return sequence === void 0 ? [] : [sequence];
|
|
598
|
+
}));
|
|
599
|
+
if (onEvidence !== void 0) for (const { payload, sequence } of contextValidationViews) boundIsValid(payload, sequence, contextEvidence);
|
|
600
|
+
const retainEvidence = (envelope) => {
|
|
601
|
+
if (onEvidence === void 0) return;
|
|
602
|
+
onEvidence(envelope);
|
|
603
|
+
if (envelope.sequence < historyFrom && envelope.record.payload._tag === "ModelResponseRecorded") {
|
|
604
|
+
for (const span of spansByDeclaration.get(envelope.sequence) ?? []) if (span.to < historyFrom) contextEvidence.add(span.to);
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
let summaryEmitted = false;
|
|
608
|
+
const retainedPrefix = replacements.some(({ payload }) => payload.kind === "rollover" && payload.runId === ownerRunId && ownerPrefixSequence <= payload.coversThrough) ? protectedContext?.content ?? [] : [];
|
|
609
|
+
const replacementLength = retainedPrefix.length + replacements.length;
|
|
610
|
+
const emitSummary = () => {
|
|
611
|
+
if (summaryEmitted || replacements.length === 0) return;
|
|
612
|
+
summaryEmitted = true;
|
|
613
|
+
state.all.push(...retainedPrefix);
|
|
614
|
+
for (const { payload: replacement } of replacements) {
|
|
615
|
+
const message = replacement.kind === "rollover" ? contextWindowMessage(contextWindowId(replacement.runId, replacement.turn), replacement.handoff) : Prompt.makeMessage("user", { content: [Prompt.makePart("text", { text: `${COMPACTION_SUMMARY_PREFIX}${replacement.summary}` })] });
|
|
616
|
+
state.all.push(message);
|
|
617
|
+
if (replacement.kind !== "rollover" || replacement.runId !== ownerRunId) state.before.push(message);
|
|
618
|
+
onBoundary?.({
|
|
619
|
+
sequence: replacement.coversThrough,
|
|
620
|
+
tag: "CompactionCreated",
|
|
621
|
+
promptLength: state.all.length
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
if (savedContext !== void 0) {
|
|
626
|
+
emitSummary();
|
|
627
|
+
for (const [index, message] of historical.entries()) {
|
|
628
|
+
const boundary = savedContext.boundaries.find((entry) => entry.promptLength > index);
|
|
629
|
+
if (boundary === void 0 && replacements.length > 0) return yield* journalError("Saved context lacks its canonical compaction boundary");
|
|
630
|
+
if (boundary !== void 0 && replacements.some(({ payload }) => boundary.sequence <= payload.coversThrough)) continue;
|
|
631
|
+
const visible = message.role === "tool" && boundary !== void 0 && clearings.some(({ payload }) => boundary.sequence <= payload.coversThrough) ? Prompt.makeMessage("tool", { content: message.content.map((part) => part.type === "tool-result" ? Prompt.makePart("tool-result", {
|
|
632
|
+
...part,
|
|
633
|
+
result: CLEARED_TOOL_RESULT
|
|
634
|
+
}) : part) }) : message;
|
|
635
|
+
state.all.push(visible);
|
|
636
|
+
state.before.push(visible);
|
|
637
|
+
}
|
|
638
|
+
for (const boundary of savedContext.boundaries) {
|
|
639
|
+
const removed = savedContext.boundaries.reduce((length, candidate) => candidate.sequence <= boundary.sequence && replacements.some(({ payload }) => candidate.sequence <= payload.coversThrough) ? Math.max(length, candidate.promptLength) : length, 0);
|
|
640
|
+
onBoundary?.({
|
|
641
|
+
...boundary,
|
|
642
|
+
promptLength: replacementLength + Math.max(0, boundary.promptLength - removed)
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
const modelUsage = [];
|
|
647
|
+
let unobservedModelCalls = 0;
|
|
648
|
+
const usage = initialUsage(modelUsage);
|
|
649
|
+
let toolSelection;
|
|
650
|
+
let usageTurn = 0;
|
|
651
|
+
const incompleteToolTurns = /* @__PURE__ */ new Set();
|
|
652
|
+
const incompleteToolCalls = /* @__PURE__ */ new Set();
|
|
653
|
+
const incompleteContextRuns = /* @__PURE__ */ new Set();
|
|
654
|
+
for (const response of incompleteResponseSequences) if (contextViews.some((view) => view.payload.kind !== "summarize" && response.sequence <= view.payload.coversThrough && response.lastSettlementSequence >= view.sequence)) incompleteContextRuns.add(response.runId);
|
|
655
|
+
let pendingContextToolCallId;
|
|
656
|
+
let ownerTerminated = false;
|
|
657
|
+
const policyUsage = initialPolicyUsage();
|
|
658
|
+
const accountResponse = Effect.fnUntraced(function* (envelope, payload, messages) {
|
|
659
|
+
const record = envelope.record;
|
|
660
|
+
const declared = declaredApplicationToolCallIds(messages);
|
|
661
|
+
const actualResultIds = [];
|
|
662
|
+
let incomplete = false;
|
|
663
|
+
for (const id of declared) {
|
|
664
|
+
const toolCallId = yield* Effect.try({
|
|
665
|
+
try: () => decodeToolCallId(id),
|
|
666
|
+
catch: (cause) => journalError("Failed to decode a declared Tool Call ID", cause)
|
|
667
|
+
});
|
|
668
|
+
const resultId = toolCallSettledRecordId(payload.runId, payload.turn, toolCallId);
|
|
669
|
+
if (settledToolCallRecordIds.has(resultId)) actualResultIds.push(resultId);
|
|
670
|
+
else incomplete = true;
|
|
671
|
+
}
|
|
672
|
+
if (incomplete) {
|
|
673
|
+
incompleteToolTurns.add(envelope.record.recordId);
|
|
674
|
+
incompleteContextRuns.add(payload.runId);
|
|
675
|
+
for (const recordId of actualResultIds) incompleteToolCalls.add(recordId);
|
|
676
|
+
}
|
|
677
|
+
if (payload.runId !== ownerRunId) return;
|
|
678
|
+
if (!("toolOperations" in payload)) return yield* journalError("Owning Run execution requires full canonical evidence");
|
|
679
|
+
if (payload.turn === 1 && payload.runScopedPrefixLength !== void 0) protectedContext = Prompt.fromMessages(messages.content.slice(0, payload.runScopedPrefixLength));
|
|
680
|
+
const responseUsage = yield* projectedResponseUsage(payload);
|
|
681
|
+
unobservedModelCalls = yield* addProjectedUsage("unobservedModelCalls", unobservedModelCalls, payload.unobservedModelCalls ?? 0);
|
|
682
|
+
usage.modelCalls = yield* addProjectedUsage("modelCalls", usage.modelCalls, responseUsage.modelCalls);
|
|
683
|
+
usage.inputTokens = yield* addProjectedUsage("inputTokens", usage.inputTokens, responseUsage.inputTokens);
|
|
684
|
+
usage.outputTokens = yield* addProjectedUsage("outputTokens", usage.outputTokens, responseUsage.outputTokens);
|
|
685
|
+
usage.costMicrousd = yield* addProjectedUsage("costMicrousd", usage.costMicrousd, responseUsage.costMicrousd);
|
|
686
|
+
usage.modelUsage.push(...responseUsage.modelUsage);
|
|
687
|
+
if (payload.turn > usageTurn) {
|
|
688
|
+
usageTurn = payload.turn;
|
|
689
|
+
usage.lastInputTokens = responseUsage.inputTokens;
|
|
690
|
+
usage.lastOutputTokens = responseUsage.outputTokens;
|
|
691
|
+
}
|
|
692
|
+
policyUsage.committedTurns = Math.max(policyUsage.committedTurns, payload.turn);
|
|
693
|
+
const calls = messages.content.flatMap((message) => message.role === "assistant" ? message.content.filter((part) => part.type === "tool-call") : []);
|
|
694
|
+
const candidate = calls.length === 1 ? calls[0] : void 0;
|
|
695
|
+
const candidateResult = candidate === void 0 ? void 0 : settledById.get(`tool-settled:${ownerRunId}:${payload.turn}:${candidate.id}`);
|
|
696
|
+
pendingContextToolCallId = candidate !== void 0 && !candidate.providerExecuted && candidateResult?.isFailure === false && candidateResult.budgetRejected !== true && envelope.sequence > rolloverCoveredThrough ? candidate.id : void 0;
|
|
697
|
+
policyUsage.toolCalls += calls.length;
|
|
698
|
+
if (payload.toolExposure !== void 0) toolSelection = payload.toolExposure.selection;
|
|
699
|
+
if (incompleteToolTurns.has(record.recordId)) return;
|
|
700
|
+
for (const call of calls) {
|
|
701
|
+
const result = call.providerExecuted ? messages.content.flatMap((message) => message.role === "assistant" ? message.content : []).find((part) => part.type === "tool-result" && part.providerExecuted && part.id === call.id) : settledById.get(`tool-settled:${ownerRunId}:${payload.turn}:${call.id}`);
|
|
702
|
+
if (result === void 0 || "budgetRejected" in result && result.budgetRejected === true) continue;
|
|
703
|
+
if (!("isFailure" in result)) continue;
|
|
704
|
+
if (!result.isFailure && "toolSelection" in result && result.toolSelection !== void 0) toolSelection = result.toolSelection;
|
|
705
|
+
policyUsage.consecutiveToolFailures = result.isFailure ? policyUsage.consecutiveToolFailures + 1 : 0;
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
const historicalResults = /* @__PURE__ */ new Map();
|
|
709
|
+
const retiredLateCalls = /* @__PURE__ */ new Map();
|
|
710
|
+
let pendingToolOrder = /* @__PURE__ */ new Map();
|
|
711
|
+
const flushTools = Effect.fnUntraced(function* (current) {
|
|
712
|
+
if (current.pendingTools.length === 0) return current;
|
|
713
|
+
const ordered = current.pendingTools.toSorted((left, right) => (pendingToolOrder.get(left.record.toolCallId) ?? Number.MAX_SAFE_INTEGER) - (pendingToolOrder.get(right.record.toolCallId) ?? Number.MAX_SAFE_INTEGER));
|
|
714
|
+
const toolMessage = yield* toolMessageFromSettled(ordered);
|
|
715
|
+
current.all.push(toolMessage);
|
|
716
|
+
if (!current.pendingToolsForRun) current.before.push(toolMessage);
|
|
717
|
+
return {
|
|
718
|
+
...current,
|
|
719
|
+
pendingTools: [],
|
|
720
|
+
pendingToolsForRun: false
|
|
721
|
+
};
|
|
722
|
+
});
|
|
723
|
+
yield* Stream.runForEach(recordsForRun, (envelope) => Effect.gen(function* () {
|
|
724
|
+
const payload = envelope.record.payload;
|
|
725
|
+
if (contextEvidence.has(envelope.sequence)) retainEvidence(envelope);
|
|
726
|
+
if ((payload._tag === "RunCompleted" || payload._tag === "RunFailed" || payload._tag === "SubmissionSettled") && payload.runId !== void 0 && incompleteContextRuns.has(payload.runId)) retainEvidence(envelope);
|
|
727
|
+
if ((payload._tag === "RunCompleted" || payload._tag === "RunFailed") && payload.runId === ownerRunId || payload._tag === "SubmissionSettled" && runIdForSubmission(payload.submissionId) === ownerRunId) ownerTerminated = true;
|
|
728
|
+
if (payload._tag === "RunPolicyUsageReserved" && payload.runId === ownerRunId) {
|
|
729
|
+
if (payload.programmaticToolCalls < policyUsage.programmaticToolCalls || policyUsage.finalizationUsed && !payload.finalizationUsed) return yield* journalError("Run policy reservations must be monotonic");
|
|
730
|
+
policyUsage.programmaticToolCalls = payload.programmaticToolCalls;
|
|
731
|
+
policyUsage.finalizationUsed = payload.finalizationUsed;
|
|
732
|
+
}
|
|
733
|
+
if (payload._tag === "ModelCallAborted" && payload.runId === ownerRunId) {
|
|
734
|
+
if (payload.restart !== policyUsage.modelRestarts + 1) return yield* journalError("Model restart reservations must advance once");
|
|
735
|
+
policyUsage.modelRestarts = payload.restart;
|
|
736
|
+
const summary = yield* summarizeModelUsage(payload.modelUsage).pipe(Effect.mapError((cause) => journalError("Aborted model usage exceeds accounting bounds", cause)));
|
|
737
|
+
usage.modelCalls = yield* addProjectedUsage("modelCalls", usage.modelCalls, summary.modelCalls);
|
|
738
|
+
usage.inputTokens = yield* addProjectedUsage("inputTokens", usage.inputTokens, summary.inputTokens.total);
|
|
739
|
+
usage.outputTokens = yield* addProjectedUsage("outputTokens", usage.outputTokens, summary.outputTokens.total);
|
|
740
|
+
usage.costMicrousd = yield* addProjectedUsage("costMicrousd", usage.costMicrousd, summary.costMicrousd);
|
|
741
|
+
usage.modelUsage.push(...payload.modelUsage);
|
|
742
|
+
unobservedModelCalls = yield* addProjectedUsage("unobservedModelCalls", unobservedModelCalls, payload.unobservedModelCalls);
|
|
743
|
+
}
|
|
744
|
+
if (PROMPT_TRANSPARENT_TAGS.has(payload._tag)) return;
|
|
745
|
+
if (payload._tag === "CompactionCreated") {
|
|
746
|
+
if (contextCompactions.has(envelope.sequence)) retainEvidence(envelope);
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
if (replacements.some(({ payload }) => isCovered(envelope, payload))) {
|
|
750
|
+
if (payload._tag === "ModelResponseRecorded" && payload.runId !== ownerRunId) {
|
|
751
|
+
const late = (spansByDeclaration.get(envelope.sequence) ?? []).filter((span) => replacements.some((view) => isCovered(envelope, view.payload) && span.to > view.sequence));
|
|
752
|
+
if (late.length > 0) {
|
|
753
|
+
retainEvidence(envelope);
|
|
754
|
+
if (latestWindow !== void 0 && isCovered(envelope, latestWindow.payload)) return;
|
|
755
|
+
const messages = yield* decodePromptMessages(payload.messages);
|
|
756
|
+
for (const message of messages.content) {
|
|
757
|
+
if (message.role !== "assistant") continue;
|
|
758
|
+
for (const call of message.content) {
|
|
759
|
+
if (call.type !== "tool-call" || call.providerExecuted) continue;
|
|
760
|
+
const callId = yield* decodeToolCallIdEffect(call.id).pipe(Effect.mapError((cause) => journalError("Invalid retired Tool Call ID", cause)));
|
|
761
|
+
const id = toolCallSettledRecordId(payload.runId, payload.turn, callId);
|
|
762
|
+
if (late.some((span) => span.recordId === id)) retiredLateCalls.set(id, call);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
if (payload._tag === "ModelResponseRecorded" && payload.runId === ownerRunId) {
|
|
768
|
+
const messages = yield* decodePromptMessages(payload.messages);
|
|
769
|
+
yield* accountResponse(envelope, payload, messages);
|
|
770
|
+
state = {
|
|
771
|
+
...state,
|
|
772
|
+
committedTurns: Math.max(state.committedTurns, payload.turn)
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
emitSummary();
|
|
778
|
+
if (payload._tag === "ToolCallSettled") {
|
|
779
|
+
const declarationFact = {
|
|
780
|
+
sequence: declarationByResultSequence.get(envelope.sequence) ?? 1e400,
|
|
781
|
+
record: { payload: {
|
|
782
|
+
_tag: "ModelResponseRecorded",
|
|
783
|
+
runId: payload.runId
|
|
784
|
+
} }
|
|
785
|
+
};
|
|
786
|
+
const declarationCovered = (compaction) => declarationFact.sequence <= compaction.coversThrough && isInRunView(declarationFact.sequence, declarationFact.record.payload, compaction.runId);
|
|
787
|
+
if (latestWindow !== void 0 && declarationCovered(latestWindow.payload)) return;
|
|
788
|
+
retainEvidence(envelope);
|
|
789
|
+
if (payload.runId !== ownerRunId) {
|
|
790
|
+
const slot = historicalResults.get(envelope.record.recordId);
|
|
791
|
+
if (slot === void 0) {
|
|
792
|
+
const call = retiredLateCalls.get(envelope.record.recordId);
|
|
793
|
+
if (call === void 0 || call.id !== payload.toolCallId || call.name !== payload.toolName) return yield* journalError("Historical Tool result has no matching declaration");
|
|
794
|
+
const pair = [Prompt.makeMessage("assistant", { content: [call] }), Prompt.makeMessage("tool", { content: [Prompt.makePart("tool-result", {
|
|
795
|
+
id: call.id,
|
|
796
|
+
name: call.name,
|
|
797
|
+
result: clearings.some(({ payload }) => declarationCovered(payload)) ? CLEARED_TOOL_RESULT : payload.result,
|
|
798
|
+
isFailure: payload.isFailure,
|
|
799
|
+
providerExecuted: false
|
|
800
|
+
})] })];
|
|
801
|
+
state.all.push(...pair);
|
|
802
|
+
state.before.push(...pair);
|
|
803
|
+
retiredLateCalls.delete(envelope.record.recordId);
|
|
804
|
+
onBoundary?.({
|
|
805
|
+
sequence: envelope.sequence,
|
|
806
|
+
tag: payload._tag,
|
|
807
|
+
promptLength: state.all.length
|
|
808
|
+
});
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
const declared = slot.parts[slot.partIndex];
|
|
812
|
+
if (declared?.id !== payload.toolCallId || declared.name !== payload.toolName) return yield* journalError("Historical Tool result differs from its declaration");
|
|
813
|
+
slot.parts[slot.partIndex] = Prompt.makePart("tool-result", {
|
|
814
|
+
id: payload.toolCallId,
|
|
815
|
+
name: payload.toolName,
|
|
816
|
+
result: clearings.some(({ payload }) => isCovered(envelope, payload) || declarationCovered(payload)) ? CLEARED_TOOL_RESULT : payload.result,
|
|
817
|
+
isFailure: payload.isFailure,
|
|
818
|
+
providerExecuted: false
|
|
819
|
+
});
|
|
820
|
+
const message = Prompt.makeMessage("tool", { content: [...slot.parts] });
|
|
821
|
+
state.all[slot.allIndex] = message;
|
|
822
|
+
state.before[slot.beforeIndex] = message;
|
|
823
|
+
historicalResults.delete(envelope.record.recordId);
|
|
824
|
+
onBoundary?.({
|
|
825
|
+
sequence: envelope.sequence,
|
|
826
|
+
tag: payload._tag,
|
|
827
|
+
promptLength: state.all.length,
|
|
828
|
+
...incompleteToolCalls.has(envelope.record.recordId) ? { incomplete: true } : {},
|
|
829
|
+
...isTerminalPriorRun(payload.runId, ownerRunId, Number.POSITIVE_INFINITY) ? { terminalPriorRun: true } : {}
|
|
830
|
+
});
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
if (state.pendingTools.length > 0 && state.pendingToolsForRun !== (payload.runId === ownerRunId)) state = yield* flushTools(state);
|
|
834
|
+
state.pendingTools.push({
|
|
835
|
+
record: payload,
|
|
836
|
+
cleared: clearings.some(({ payload }) => isCovered(envelope, payload))
|
|
837
|
+
});
|
|
838
|
+
state = {
|
|
839
|
+
...state,
|
|
840
|
+
pendingToolsForRun: payload.runId === ownerRunId
|
|
841
|
+
};
|
|
842
|
+
onBoundary?.({
|
|
843
|
+
sequence: envelope.sequence,
|
|
844
|
+
tag: payload._tag,
|
|
845
|
+
promptLength: state.all.length + 1,
|
|
846
|
+
...isTerminalPriorRun(payload.runId, ownerRunId, Number.POSITIVE_INFINITY) ? { terminalPriorRun: true } : {},
|
|
847
|
+
...incompleteToolCalls.has(envelope.record.recordId) ? { incomplete: true } : {}
|
|
848
|
+
});
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
state = yield* flushTools(state);
|
|
852
|
+
if (payload._tag === "ModelCompleted" && payload.history !== void 0) {
|
|
853
|
+
retainEvidence(envelope);
|
|
854
|
+
const messages = yield* decodePromptMessages(payload.history);
|
|
855
|
+
state.all.length = 0;
|
|
856
|
+
state.before.length = 0;
|
|
857
|
+
historicalResults.clear();
|
|
858
|
+
for (const message of messages.content) {
|
|
859
|
+
state.all.push(message);
|
|
860
|
+
if (payload.runId !== ownerRunId) state.before.push(message);
|
|
861
|
+
}
|
|
862
|
+
onBoundary?.({
|
|
863
|
+
sequence: envelope.sequence,
|
|
864
|
+
tag: payload._tag,
|
|
865
|
+
promptLength: state.all.length
|
|
866
|
+
});
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
if (payload._tag !== "ModelResponseRecorded") return;
|
|
870
|
+
retainEvidence(envelope);
|
|
871
|
+
const messages = yield* decodePromptMessages(payload.messages);
|
|
872
|
+
const forRun = payload.runId === ownerRunId;
|
|
873
|
+
pendingToolOrder = new Map(declaredApplicationToolCallIds(messages).map((id, index) => [id, index]));
|
|
874
|
+
yield* accountResponse(envelope, payload, messages);
|
|
875
|
+
const visibleMessages = forRun ? messages.content : messages.content.filter((message) => message.role !== "system");
|
|
876
|
+
for (const message of visibleMessages) {
|
|
877
|
+
state.all.push(message);
|
|
878
|
+
if (!forRun) state.before.push(message);
|
|
879
|
+
}
|
|
880
|
+
if (!forRun) {
|
|
881
|
+
const calls = messages.content.flatMap((message) => message.role === "assistant" ? message.content.filter((part) => part.type === "tool-call" && !part.providerExecuted) : []);
|
|
882
|
+
if (calls.length > 0) {
|
|
883
|
+
const parts = calls.map((call) => Prompt.makePart("tool-result", {
|
|
884
|
+
id: call.id,
|
|
885
|
+
name: call.name,
|
|
886
|
+
result: {
|
|
887
|
+
_tag: "ToolOutcomeUnknown",
|
|
888
|
+
message: "This earlier operation has no recorded outcome. It may have executed. Do not assume success or retry it; its original operation remains unresolved."
|
|
889
|
+
},
|
|
890
|
+
isFailure: true,
|
|
891
|
+
providerExecuted: false
|
|
892
|
+
}));
|
|
893
|
+
const allIndex = state.all.length;
|
|
894
|
+
const beforeIndex = state.before.length;
|
|
895
|
+
const message = Prompt.makeMessage("tool", { content: parts });
|
|
896
|
+
state.all.push(message);
|
|
897
|
+
state.before.push(message);
|
|
898
|
+
for (const [partIndex, call] of calls.entries()) {
|
|
899
|
+
const callId = yield* decodeToolCallIdEffect(call.id).pipe(Effect.mapError((cause) => journalError("Invalid historical Tool Call ID", cause)));
|
|
900
|
+
const resultId = toolCallSettledRecordId(payload.runId, payload.turn, callId);
|
|
901
|
+
if (!settledToolCallRecordIds.has(resultId)) continue;
|
|
902
|
+
historicalResults.set(resultId, {
|
|
903
|
+
allIndex,
|
|
904
|
+
beforeIndex,
|
|
905
|
+
parts,
|
|
906
|
+
partIndex
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
state = {
|
|
912
|
+
...state,
|
|
913
|
+
committedTurns: forRun ? Math.max(state.committedTurns, payload.turn) : state.committedTurns
|
|
914
|
+
};
|
|
915
|
+
onBoundary?.({
|
|
916
|
+
sequence: envelope.sequence,
|
|
917
|
+
tag: payload._tag,
|
|
918
|
+
promptLength: state.all.length,
|
|
919
|
+
...isTerminalPriorRun(payload.runId, ownerRunId, Number.POSITIVE_INFINITY) ? { terminalPriorRun: true } : {},
|
|
920
|
+
...incompleteToolTurns.has(envelope.record.recordId) ? { incomplete: true } : {}
|
|
921
|
+
});
|
|
922
|
+
}));
|
|
923
|
+
emitSummary();
|
|
924
|
+
state = yield* flushTools(state);
|
|
925
|
+
const validatedPolicyUsage = yield* Schema.decodeEffect(RunPolicyUsage)(policyUsage).pipe(Effect.mapError((cause) => journalError("Run policy accounting exceeds its Schema bounds", cause)));
|
|
926
|
+
return {
|
|
927
|
+
...toolSelection === void 0 ? {} : { toolSelection },
|
|
928
|
+
policyUsage: validatedPolicyUsage,
|
|
929
|
+
prompt: Prompt.fromMessages(state.all),
|
|
930
|
+
historyBefore: Prompt.fromMessages(state.before),
|
|
931
|
+
historyFrom,
|
|
932
|
+
committedTurns: state.committedTurns,
|
|
933
|
+
usage: unobservedModelCalls === 0 ? usage : {
|
|
934
|
+
...usage,
|
|
935
|
+
unobservedModelCalls
|
|
936
|
+
},
|
|
937
|
+
...latestWindowId === void 0 ? {} : { contextWindowId: latestWindowId },
|
|
938
|
+
...protectedContext === void 0 ? {} : { protectedContext },
|
|
939
|
+
...ownerTerminated || pendingContextToolCallId === void 0 ? {} : { pendingContextToolCallId }
|
|
940
|
+
};
|
|
941
|
+
});
|
|
942
|
+
/** Pure projection of one Run's durable recovery state from canonical records. */
|
|
943
|
+
const projectRunJournal = (records, runId) => projectRunJournalStream(Stream.fromIterable(records), runId);
|
|
944
|
+
/**
|
|
945
|
+
* Pure valid-prompt projection from canonical records: `UserInputRecorded` +
|
|
946
|
+
* `ModelResponseRecorded` + complete `ToolCallSettled` batches → the deterministic model-visible
|
|
947
|
+
* Prompt (plan §Coordinator flow step 3).
|
|
948
|
+
*/
|
|
949
|
+
const promptFromCanonicalRecords = (records) => projectRunJournalStream(Stream.fromIterable(records), void 0).pipe(Effect.map((projection) => projection.prompt));
|
|
950
|
+
const decodeModelResponse = Schema.decodeUnknownEffect(ModelResponseRecorded);
|
|
951
|
+
const decodeToolSettled = Schema.decodeUnknownEffect(ToolCallSettled);
|
|
952
|
+
const encodePrompt = Schema.encodeEffect(Prompt.Prompt);
|
|
953
|
+
const requireCanonicalTurn = (turn) => !Number.isInteger(turn) || turn <= 0 ? Effect.fail(journalError(`Canonical turn number must be a positive integer: ${turn}`)) : Effect.void;
|
|
954
|
+
const modelResponseRecord = Effect.fnUntraced(function* (input) {
|
|
955
|
+
const promptMessages = input.responseMessages;
|
|
956
|
+
if (promptMessages.some((message) => message.role === "tool")) return yield* journalError("Application Tool outcomes must be supplied as terminal facts");
|
|
957
|
+
const runScopedPrefixLength = input.runScopedPrefixLength;
|
|
958
|
+
if (runScopedPrefixLength !== void 0 && (input.turn !== 1 || !Number.isSafeInteger(runScopedPrefixLength) || runScopedPrefixLength <= 0 || runScopedPrefixLength > promptMessages.length || promptMessages.slice(0, runScopedPrefixLength).some((message) => message.role !== "system" && message.role !== "user"))) return yield* journalError("Run-scoped Prompt provenance must identify a non-empty system/user prefix of Turn 1 before its assistant response");
|
|
959
|
+
const encodedMessages = yield* encodePrompt(Prompt.fromMessages([...promptMessages])).pipe(Effect.mapErrorEager((cause) => journalError("Turn Prompt messages failed to encode", cause)));
|
|
960
|
+
const modelUsage = input.usage?.modelUsage;
|
|
961
|
+
const payload = yield* decodeModelResponse({
|
|
962
|
+
_tag: "ModelResponseRecorded",
|
|
963
|
+
toolResultMaxBytes: input.toolResultMaxBytes ?? 1048576,
|
|
964
|
+
toolSelectionMaxBytes: input.toolSelectionMaxBytes ?? 0,
|
|
965
|
+
toolOperations: input.toolOperations ?? [],
|
|
966
|
+
...input.toolParameterRejections === void 0 || input.toolParameterRejections.length === 0 ? {} : { toolParameterRejections: input.toolParameterRejections },
|
|
967
|
+
...input.toolExposure === void 0 ? {} : { toolExposure: input.toolExposure },
|
|
968
|
+
runId: input.runId,
|
|
969
|
+
turnId: input.turnId,
|
|
970
|
+
turn: input.turn,
|
|
971
|
+
messages: encodedMessages,
|
|
972
|
+
...runScopedPrefixLength === void 0 ? {} : { runScopedPrefixLength },
|
|
973
|
+
...modelUsage === void 0 ? {} : { modelUsage },
|
|
974
|
+
...input.unobservedModelCalls === void 0 || input.unobservedModelCalls === 0 ? {} : { unobservedModelCalls: input.unobservedModelCalls },
|
|
975
|
+
...input.usage === void 0 ? {} : {
|
|
976
|
+
inputTokens: input.usage.inputTokens,
|
|
977
|
+
outputTokens: input.usage.outputTokens,
|
|
978
|
+
...input.usage.costMicrousd === void 0 || input.usage.costMicrousd === 0 ? {} : { costMicrousd: input.usage.costMicrousd }
|
|
979
|
+
}
|
|
980
|
+
}).pipe(Effect.mapErrorEager((cause) => journalError("Invalid model response operation evidence", cause)));
|
|
981
|
+
if (payload.modelUsage !== void 0) {
|
|
982
|
+
if (payload.modelUsage.length === 0) return yield* journalError("Turn model usage must contain at least one completed call");
|
|
983
|
+
const summary = yield* continuationUsage(payload.modelUsage).pipe(Effect.mapErrorEager((cause) => journalError("Turn model usage exceeds accounting bounds", cause)));
|
|
984
|
+
if (payload.inputTokens !== summary.inputTokens || payload.outputTokens !== summary.outputTokens || (payload.costMicrousd ?? 0) !== summary.costMicrousd) return yield* journalError("Turn detailed and aggregate model usage disagree");
|
|
985
|
+
}
|
|
986
|
+
return RecordEnvelope.make({
|
|
987
|
+
recordId: modelResponseRecordId(input.runId, input.turn),
|
|
988
|
+
family: "thread",
|
|
989
|
+
schemaVersion: 1,
|
|
990
|
+
createdAt: input.createdAt,
|
|
991
|
+
deploymentId: input.deploymentId,
|
|
992
|
+
payload
|
|
993
|
+
});
|
|
994
|
+
});
|
|
995
|
+
const toolSettledRecords = Effect.fnUntraced(function* (input) {
|
|
996
|
+
const toolRecords = [];
|
|
997
|
+
for (const part of input.toolResults) {
|
|
998
|
+
const payload = yield* decodeToolSettled({
|
|
999
|
+
_tag: "ToolCallSettled",
|
|
1000
|
+
...part.toolSelection === void 0 ? {} : { toolSelection: part.toolSelection },
|
|
1001
|
+
runId: input.runId,
|
|
1002
|
+
toolCallId: part.toolCallId,
|
|
1003
|
+
toolName: part.toolName,
|
|
1004
|
+
result: part.result,
|
|
1005
|
+
isFailure: part.isFailure,
|
|
1006
|
+
...part.budgetRejected === true ? { budgetRejected: true } : {}
|
|
1007
|
+
}).pipe(Effect.mapError((cause) => journalError(`Invalid Tool result ${part.toolCallId}`, cause)));
|
|
1008
|
+
toolRecords.push(RecordEnvelope.make({
|
|
1009
|
+
recordId: toolCallSettledRecordId(input.runId, input.turn, payload.toolCallId),
|
|
1010
|
+
family: "thread",
|
|
1011
|
+
schemaVersion: 1,
|
|
1012
|
+
createdAt: input.createdAt,
|
|
1013
|
+
deploymentId: input.deploymentId,
|
|
1014
|
+
payload
|
|
1015
|
+
}));
|
|
1016
|
+
}
|
|
1017
|
+
return toolRecords;
|
|
1018
|
+
});
|
|
1019
|
+
const runCompletionRecord = (input) => {
|
|
1020
|
+
if (input.runCompletion === void 0) return void 0;
|
|
1021
|
+
const completion = {
|
|
1022
|
+
runId: input.runId,
|
|
1023
|
+
...input.runCompletion
|
|
1024
|
+
};
|
|
1025
|
+
return RecordEnvelope.make({
|
|
1026
|
+
recordId: runCompletedRecordId(input.runId),
|
|
1027
|
+
family: "thread",
|
|
1028
|
+
schemaVersion: 1,
|
|
1029
|
+
createdAt: input.createdAt,
|
|
1030
|
+
deploymentId: input.deploymentId,
|
|
1031
|
+
payload: RunCompleted.make({ ...completion })
|
|
1032
|
+
});
|
|
1033
|
+
};
|
|
1034
|
+
/**
|
|
1035
|
+
* Build a canonical batch from interpreter-validated Turn facts: one
|
|
1036
|
+
* `ModelResponseRecorded` record plus one `ToolCallSettled` record per terminal Tool result, all
|
|
1037
|
+
* under the WP0-style deterministic identities, committed as ONE atomic batch. The same input
|
|
1038
|
+
* always yields byte-identical content, so an in-Attempt append retry is an honest batch replay.
|
|
1039
|
+
*
|
|
1040
|
+
* No-tool Turns and eligible readonly Turns use this shape; a terminal `RunCompleted` marker
|
|
1041
|
+
* joins the response in the same atomic batch. Other application Turns split into
|
|
1042
|
+
* `turnResponseBatch` + `turnResultsBatch` before execution.
|
|
1043
|
+
*/
|
|
1044
|
+
const turnCanonicalBatch = Effect.fnUntraced(function* (input) {
|
|
1045
|
+
yield* requireCanonicalTurn(input.turn);
|
|
1046
|
+
const modelResponse = yield* modelResponseRecord(input);
|
|
1047
|
+
const toolRecords = yield* toolSettledRecords(input);
|
|
1048
|
+
const completionRecord = runCompletionRecord(input);
|
|
1049
|
+
return CanonicalBatch.make({
|
|
1050
|
+
batchId: turnBatchId(input.runId, input.turn),
|
|
1051
|
+
producerId: input.producerId,
|
|
1052
|
+
records: completionRecord === void 0 ? [modelResponse, ...toolRecords] : [
|
|
1053
|
+
modelResponse,
|
|
1054
|
+
...toolRecords,
|
|
1055
|
+
completionRecord
|
|
1056
|
+
]
|
|
1057
|
+
});
|
|
1058
|
+
});
|
|
1059
|
+
/**
|
|
1060
|
+
* Commit the normalized response and original operation contracts before application Tools
|
|
1061
|
+
* execute, or promote a deferred readonly response before a persisted call-scoped capability.
|
|
1062
|
+
* An unsettled application declaration is conservative uncertainty after ownership
|
|
1063
|
+
* loss; approvals and the dispatch fence remain separate execution requirements. Provider
|
|
1064
|
+
* results stay in assistant content. Application outcomes belong to the results commit.
|
|
1065
|
+
*/
|
|
1066
|
+
const turnResponseBatch = Effect.fnUntraced(function* (input) {
|
|
1067
|
+
yield* requireCanonicalTurn(input.turn);
|
|
1068
|
+
const modelResponse = yield* modelResponseRecord(input);
|
|
1069
|
+
return CanonicalBatch.make({
|
|
1070
|
+
batchId: turnResponseBatchId(input.runId, input.turn),
|
|
1071
|
+
producerId: input.producerId,
|
|
1072
|
+
records: [modelResponse]
|
|
1073
|
+
});
|
|
1074
|
+
});
|
|
1075
|
+
/**
|
|
1076
|
+
* Commit 5 of a tool-declaring Turn (plan §2.1): the Turn's `ToolCallSettled` records in
|
|
1077
|
+
* declaration order under batch identity `turn-results:{runId}:{turn}` — the batch becomes
|
|
1078
|
+
* model-visible atomically. A completion after already committed Tool results gets its own
|
|
1079
|
+
* terminal batch; it never rewrites or repeats the earlier Tool outcomes.
|
|
1080
|
+
*/
|
|
1081
|
+
const turnResultsBatch = Effect.fnUntraced(function* (input) {
|
|
1082
|
+
yield* requireCanonicalTurn(input.turn);
|
|
1083
|
+
const toolRecords = yield* toolSettledRecords(input);
|
|
1084
|
+
const first = toolRecords[0];
|
|
1085
|
+
const completionRecord = runCompletionRecord(input);
|
|
1086
|
+
if (first === void 0) {
|
|
1087
|
+
if (completionRecord === void 0) return yield* journalError(`Turn ${input.turn} has no terminal Tool results to commit`);
|
|
1088
|
+
return CanonicalBatch.make({
|
|
1089
|
+
batchId: makeBatchId(runCompletedRecordId(input.runId)),
|
|
1090
|
+
producerId: input.producerId,
|
|
1091
|
+
records: [completionRecord]
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
if (input.runCompletion !== void 0 && toolRecords.length !== 1) return yield* journalError("A terminal Tool completion requires exactly one settled result");
|
|
1095
|
+
return CanonicalBatch.make({
|
|
1096
|
+
batchId: turnResultsBatchId(input.runId, input.turn),
|
|
1097
|
+
producerId: input.producerId,
|
|
1098
|
+
records: completionRecord === void 0 ? [first, ...toolRecords.slice(1)] : [
|
|
1099
|
+
first,
|
|
1100
|
+
...toolRecords.slice(1),
|
|
1101
|
+
completionRecord
|
|
1102
|
+
]
|
|
1103
|
+
});
|
|
1104
|
+
});
|
|
1105
|
+
export { makeJournalMetadata as $, subagentRequestedRecordId as A, toolStepSettledRecordId as B, runStartedBatchId as C, subagentLineageBatchId as D, subagentJoinedRecordId as E, toolCallResolutionBatchId as F, turnResponseBatch as G, turnBatchId as H, toolCallResolvedRecordId as I, turnResultsBatchId as J, turnResponseBatchId as K, toolCallResultBatchId as L, subagentStartedRecordId as M, toolApprovalDecisionRecordId as N, subagentLineageRecordId as O, toolApprovalRequestRecordId as P, continuationUsage as Q, toolCallUnknownRecordId as R, runIdForSubmission as S, subagentJoinBatchId as T, turnCanonicalBatch as U, turnApprovalsBatchId as V, turnIdForRun as W, workerOriginRecordId as X, workerInputRecordId as Y, workerReportRecordId as Z, projectRunJournalStream as _, childIdempotencyKeyFor as a, runDurationBatchId as b, compactionRecordId as c, markUnknownBatchId as d, toolCallSettledRecordId as et, modelResponseInterruptedBatchId as f, projectRunJournal as g, peerMessageRecordId as h, approvalDecisionBatchId as i, subagentStartedBatchId as j, subagentRequestedBatchId as k, firstWorkerInputRecordId as l, modelResponseRecordId as m, RunJournal_exports as n, childThreadIdFor as o, modelResponseInterruptedRecordId as p, turnResultsBatch as q, agentUpdateRecordId as r, compactionBatchId as s, RunJournalError as t, initialRunJournal as u, promptFromCanonicalRecords as v, runStartedRecordId as w, runDurationRecordId as x, runCompletedRecordId as y, toolStepSettledBatchId as z };
|
|
1106
|
+
|
|
1107
|
+
//# sourceMappingURL=RunJournal-C_1eqQdr.mjs.map
|