@systemfsoftware/agent 0.0.0-stage → 0.1.0
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-26pelcl9.d.mts +5678 -0
- package/dist/Admin-BcQDrWKY.mjs +329 -0
- package/dist/Admin-BcQDrWKY.mjs.map +1 -0
- package/dist/Agent-BH_R6LOI.d.mts +219 -0
- package/dist/Agent-Bn3zMhDH.mjs +60 -0
- package/dist/Agent-Bn3zMhDH.mjs.map +1 -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-h07X1mZM.mjs +14 -0
- package/dist/AgentRegistration-h07X1mZM.mjs.map +1 -0
- package/dist/AgentRuntime-C3GQPdrv.d.mts +751 -0
- package/dist/AgentRuntime-CrYYV9RF.mjs +5224 -0
- package/dist/AgentRuntime-CrYYV9RF.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-DgCEbTwW.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-DMfj2beT.d.mts +62 -0
- package/dist/CommittedActivity-DXyCKCtX.mjs +146 -0
- package/dist/CommittedActivity-DXyCKCtX.mjs.map +1 -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-D5jrWNNH.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-D3UTrNQg.mjs +8432 -0
- package/dist/DurableAgentRuntime-D3UTrNQg.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-BWY08cyT.d.mts +52 -0
- package/dist/EventSource-BwZVkEQi.mjs +66 -0
- package/dist/EventSource-BwZVkEQi.mjs.map +1 -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-CPvcb5OX.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-C0S-Cakt.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-DnnpWe-H.d.mts +1074 -0
- package/dist/MessagingHost-Bm5e-kAX.mjs +117 -0
- package/dist/MessagingHost-Bm5e-kAX.mjs.map +1 -0
- package/dist/MessagingHost-DPPHTLdT.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-CafxF31F.d.mts +22 -0
- package/dist/Output-DQ8mWcgf.mjs +7 -0
- package/dist/Output-DQ8mWcgf.mjs.map +1 -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-CTAVhHKH.mjs +147 -0
- package/dist/PersistentHistory-CTAVhHKH.mjs.map +1 -0
- package/dist/PersistentHistory-h-C7avqL.d.mts +14 -0
- package/dist/PreparedInputAdmission-DYugcCHR.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-Bpfp087i.mjs +1060 -0
- package/dist/RunContinuation-Bpfp087i.mjs.map +1 -0
- package/dist/RunContinuation-Cy2W8ASl.d.mts +127 -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-DcqokgFt.d.mts +22 -0
- package/dist/ScheduleTransition-DtNzlN9k.mjs +180 -0
- package/dist/ScheduleTransition-DtNzlN9k.mjs.map +1 -0
- package/dist/Scheduling-BaJXJIVt.d.mts +57 -0
- package/dist/Scheduling-BpJN9E1j.mjs +699 -0
- package/dist/Scheduling-BpJN9E1j.mjs.map +1 -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-BJJN6n0E.mjs +1315 -0
- package/dist/Subagent-BJJN6n0E.mjs.map +1 -0
- package/dist/Subagent-GXU32fQt.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-BC9B9dNT.d.mts +167 -0
- package/dist/SubagentHost-BEnICu7g.mjs +70 -0
- package/dist/SubagentHost-BEnICu7g.mjs.map +1 -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-BJ0TtZwM.d.mts +815 -0
- package/dist/Subscription-BhQbmUD-.mjs +340 -0
- package/dist/Subscription-BhQbmUD-.mjs.map +1 -0
- package/dist/SubscriptionInput-BbV69oX_.mjs +53 -0
- package/dist/SubscriptionInput-BbV69oX_.mjs.map +1 -0
- package/dist/SubscriptionInput-D6Okd6-z.d.mts +42 -0
- package/dist/SubscriptionTransition-Da9DmAr_.d.mts +23 -0
- package/dist/SubscriptionTransition-lrf733c8.mjs +154 -0
- package/dist/SubscriptionTransition-lrf733c8.mjs.map +1 -0
- package/dist/Subscriptions-BS3AXmQ0.mjs +638 -0
- package/dist/Subscriptions-BS3AXmQ0.mjs.map +1 -0
- package/dist/Subscriptions-DgjahL6V.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-BVTD96Pe.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-BQDW9E_Y.d.mts +843 -0
- package/dist/ThreadImport-C8Tqiezd.mjs +491 -0
- package/dist/ThreadImport-C8Tqiezd.mjs.map +1 -0
- package/dist/ThreadInvariants-fniroLRY.mjs +154 -0
- package/dist/ThreadInvariants-fniroLRY.mjs.map +1 -0
- package/dist/ThreadInvariants-w53c67YS.d.mts +23 -0
- package/dist/ThreadProjectionMaintenance-4ccU1auU.d.mts +51 -0
- package/dist/ThreadProjectionMaintenance-D6fBjr1q.mjs +37 -0
- package/dist/ThreadProjectionMaintenance-D6fBjr1q.mjs.map +1 -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-D0KsqkSR.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-DvcfbTBk.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-NUk_x837.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-DnbOzRL_.mjs +30 -0
- package/dist/WebSearch-DnbOzRL_.mjs.map +1 -0
- package/dist/WebSearch-RBUUOfT8.d.mts +18 -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-CubQgpsl.d.mts +171 -0
- package/dist/WorkerAdmission-D8tw_OmT.mjs +162 -0
- package/dist/WorkerAdmission-D8tw_OmT.mjs.map +1 -0
- package/dist/WorkerHost-BciHCzHq.d.mts +150 -0
- package/dist/WorkerHost-DuQug9Bq.mjs +73 -0
- package/dist/WorkerHost-DuQug9Bq.mjs.map +1 -0
- package/dist/agent-registration-D9ofkoBa.mjs +262 -0
- package/dist/agent-registration-D9ofkoBa.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-D1Tx1G6V.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 +11083 -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,1315 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
|
|
2
|
+
import * as Tool from "effect/ai/Tool";
|
|
3
|
+
import * as Toolkit from "effect/ai/Toolkit";
|
|
4
|
+
import * as Cause from "effect/Cause";
|
|
5
|
+
import * as Clock from "effect/Clock";
|
|
6
|
+
import * as DateTime from "effect/DateTime";
|
|
7
|
+
import * as Duration from "effect/Duration";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Exit from "effect/Exit";
|
|
10
|
+
import * as Layer from "effect/Layer";
|
|
11
|
+
import * as Option from "effect/Option";
|
|
12
|
+
import * as Ref from "effect/Ref";
|
|
13
|
+
import * as Schema from "effect/Schema";
|
|
14
|
+
import * as Scope from "effect/Scope";
|
|
15
|
+
import { u as AgentPolicyError } from "./AgentError-yFdnS9bl.mjs";
|
|
16
|
+
import { c as SettlementId, d as ToolCallId, r as DelegationId, s as RunId, u as ThreadId } from "./Identifiers-LWd4837I.mjs";
|
|
17
|
+
import { t as IdGenerator } from "./IdGenerator-BCzwV0ZI.mjs";
|
|
18
|
+
import { n as utf8ByteLength, r as utf8Bytes } from "./utf8-Bl0ZhhGe.mjs";
|
|
19
|
+
import { c as SubagentExecutionFailureClassification, d as SubagentPolicy, f as SubagentReservationAmounts, i as SubagentBudgetReservation, l as SubagentGrant, m as WorkerOperationTool, r as DelegationTool, s as SubagentExecutionFailure, t as BackgroundSpawnTool, v as narrowSubagentGrant } from "./SubagentContract-C-7AxTm_.mjs";
|
|
20
|
+
import { _ as unknownRunTotals, c as RunUsageReport } from "./Usage-B0xgME5f.mjs";
|
|
21
|
+
import { d as SubagentDurability, f as SubagentDurabilityError, p as ToolCallWaiting, u as AgentSpawner } from "./AgentRuntime-CrYYV9RF.mjs";
|
|
22
|
+
import { t as RunEventSink } from "./RunEventSink-B8uM8bw2.mjs";
|
|
23
|
+
import { a as delegationAllocationFromPolicy, i as SubagentProjectionFailure, n as resolveSubagentPolicy, o as delegationCapsFromPolicy, r as SubagentPrestartDenied, t as residualSubagentCaps } from "./subagent-policy-xRJhrc0a.mjs";
|
|
24
|
+
import { a as SubagentObservedUsage, d as SubagentReservationRequest, h as SubagentReservations, i as SubagentBudgetExhausted, v as makeBudgetReservationId } from "./SubagentReservations-BYNAHPpm.mjs";
|
|
25
|
+
import { C as MessageStatus, S as MessageRef, _ as WorkerStop, c as WorkerError, d as WorkerPage, f as WorkerRef, g as WorkerStarted, o as WorkerCompletion, p as WorkerReport, s as WorkerContext, v as WorkerStopped, y as WorkerSummary } from "./Worker-CQu8Qp1j.mjs";
|
|
26
|
+
import { a as Receipt, n as JoinedToHost, t as IdempotencyKey } from "./Receipt-B-FlCaNH.mjs";
|
|
27
|
+
import { r as WorkerReportPreparationFailure, t as SubagentHost } from "./SubagentHost-BEnICu7g.mjs";
|
|
28
|
+
import * as CryptoDigest from "effect/crypto/Digest";
|
|
29
|
+
import * as Hex from "effect/encoding/Hex";
|
|
30
|
+
import * as Stream from "effect/Stream";
|
|
31
|
+
import { i as Failure } from "./FailureDiagnostic-DdHV2eFs.mjs";
|
|
32
|
+
// src/capabilities/internal/subagent-background.ts
|
|
33
|
+
/** Portable identity checked against this declaration; possession grants no authority. */
|
|
34
|
+
const Worker = (declaration) => WorkerRef.pipe(Schema.refine((worker) => worker.delegationId === declaration.delegationId && worker.targetAgentId === declaration.target.id));
|
|
35
|
+
/** Model-facing projection deliberately excludes operator-private diagnostics. */
|
|
36
|
+
const toolObservation = (success) => Schema.Union([
|
|
37
|
+
Schema.TaggedStruct("Pending", { receipt: Receipt }),
|
|
38
|
+
Schema.TaggedStruct("Settled", {
|
|
39
|
+
receipt: Receipt,
|
|
40
|
+
runId: RunId,
|
|
41
|
+
settlementId: SettlementId,
|
|
42
|
+
outcome: Schema.Literal("completed"),
|
|
43
|
+
result: success
|
|
44
|
+
}),
|
|
45
|
+
Schema.TaggedStruct("Settled", {
|
|
46
|
+
receipt: Receipt,
|
|
47
|
+
runId: Schema.optionalKey(RunId),
|
|
48
|
+
settlementId: SettlementId,
|
|
49
|
+
outcome: Schema.Literals(["failed", "aborted"]),
|
|
50
|
+
failure: SubagentExecutionFailure
|
|
51
|
+
})
|
|
52
|
+
]);
|
|
53
|
+
/** One exact Receipt, including private canonical failure evidence for programmatic callers. */
|
|
54
|
+
const WorkerObservation = (success) => {
|
|
55
|
+
const projected = toolObservation(success);
|
|
56
|
+
return Schema.Union([
|
|
57
|
+
projected.members[0],
|
|
58
|
+
projected.members[1],
|
|
59
|
+
Schema.Struct({
|
|
60
|
+
...projected.members[2].fields,
|
|
61
|
+
diagnostic: Schema.optionalKey(Failure)
|
|
62
|
+
})
|
|
63
|
+
]);
|
|
64
|
+
};
|
|
65
|
+
const host = Effect.serviceOption(SubagentHost).pipe(Effect.flatMap((service) => Option.match(service, {
|
|
66
|
+
onNone: () => WorkerError.make({
|
|
67
|
+
operation: "context",
|
|
68
|
+
reason: "unavailable"
|
|
69
|
+
}),
|
|
70
|
+
onSome: Effect.succeed
|
|
71
|
+
})));
|
|
72
|
+
const receiptEqual = (left, right) => left.threadId === right.threadId && left.submissionId === right.submissionId && left.receiptId === right.receiptId && left.queueSequence === right.queueSequence;
|
|
73
|
+
const operations = (declaration) => {
|
|
74
|
+
const workerSchema = Worker(declaration);
|
|
75
|
+
const projectionFailure = (stage, cause) => SubagentProjectionFailure.make({
|
|
76
|
+
delegationId: declaration.delegationId,
|
|
77
|
+
stage,
|
|
78
|
+
...cause === void 0 ? {} : { cause },
|
|
79
|
+
message: stage === "input" ? "Worker input did not satisfy the declaration Schema" : "Worker result did not satisfy the declaration Schema"
|
|
80
|
+
});
|
|
81
|
+
const validateWorker = (worker, operation) => Schema.decodeUnknownEffect(workerSchema)(worker).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
82
|
+
operation,
|
|
83
|
+
reason: "worker-mismatch",
|
|
84
|
+
cause
|
|
85
|
+
})));
|
|
86
|
+
const validateReceipt = (worker, receipt, operation) => Schema.decodeEffect(Receipt.check(Schema.makeFilter((value) => value.threadId === worker.threadId)))(receipt).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
87
|
+
operation,
|
|
88
|
+
reason: "receipt-mismatch",
|
|
89
|
+
cause
|
|
90
|
+
})));
|
|
91
|
+
const validateDelivery = Effect.fnUntraced(function* (worker, delivery, operation) {
|
|
92
|
+
const validated = yield* Schema.decodeEffect(MessageStatus)(delivery).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
93
|
+
operation,
|
|
94
|
+
reason: "corrupt",
|
|
95
|
+
cause
|
|
96
|
+
})));
|
|
97
|
+
if (validated.receipt !== null) yield* validateReceipt(worker, validated.receipt, operation);
|
|
98
|
+
return validated;
|
|
99
|
+
});
|
|
100
|
+
const context = host.pipe(Effect.flatMap((service) => service.context), Effect.flatMap(Schema.decodeUnknownEffect(Schema.toType(WorkerContext))), Effect.mapError((error) => Schema.is(WorkerError)(error) ? error : WorkerError.make({
|
|
101
|
+
operation: "context",
|
|
102
|
+
reason: "corrupt",
|
|
103
|
+
cause: error
|
|
104
|
+
})));
|
|
105
|
+
const prepare = Effect.fnUntraced(function* (parameters, caller) {
|
|
106
|
+
const source = caller.source;
|
|
107
|
+
const preparation = source._tag === "tool" ? {
|
|
108
|
+
source: "tool",
|
|
109
|
+
delegationId: declaration.delegationId,
|
|
110
|
+
toolCallId: source.toolCallId,
|
|
111
|
+
parent: {
|
|
112
|
+
agentId: source.agentId,
|
|
113
|
+
threadId: source.threadId,
|
|
114
|
+
runId: source.runId
|
|
115
|
+
}
|
|
116
|
+
} : {
|
|
117
|
+
source: "programmatic",
|
|
118
|
+
delegationId: declaration.delegationId,
|
|
119
|
+
parent: {
|
|
120
|
+
agentId: source.agentId,
|
|
121
|
+
threadId: source.threadId
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const input = yield* declaration.prepareInput(parameters, preparation);
|
|
125
|
+
return yield* Schema.encodeEffect(declaration.target.input)(input).pipe(Effect.mapError((cause) => projectionFailure("input", cause)));
|
|
126
|
+
});
|
|
127
|
+
const validateKey = (key, operation) => Schema.decodeEffect(IdempotencyKey)(key).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
128
|
+
operation,
|
|
129
|
+
reason: "idempotency-conflict",
|
|
130
|
+
cause
|
|
131
|
+
})));
|
|
132
|
+
return {
|
|
133
|
+
start: Effect.fnUntraced(function* (parameters, options) {
|
|
134
|
+
const service = yield* host;
|
|
135
|
+
const caller = yield* context;
|
|
136
|
+
const key = yield* validateKey(options.idempotencyKey, "start");
|
|
137
|
+
const grant = narrowSubagentGrant(declaration.grant, caller.grant);
|
|
138
|
+
if (caller.depth + 1 > grant.maxDepth) return yield* SubagentPrestartDenied.make({
|
|
139
|
+
delegationId: declaration.delegationId,
|
|
140
|
+
targetAgentId: declaration.target.id,
|
|
141
|
+
reason: "nested-delegation",
|
|
142
|
+
message: "Worker start exceeds the inherited depth ceiling"
|
|
143
|
+
});
|
|
144
|
+
if (!(caller.grant?.childLifetimes ?? ["attached", "background"]).includes("background")) return yield* SubagentPrestartDenied.make({
|
|
145
|
+
delegationId: declaration.delegationId,
|
|
146
|
+
targetAgentId: declaration.target.id,
|
|
147
|
+
reason: "grant-violation",
|
|
148
|
+
message: "The inherited grant does not permit background children"
|
|
149
|
+
});
|
|
150
|
+
const encodedParameters = yield* Schema.encodeEffect(declaration.parameters)(parameters).pipe(Effect.mapError((cause) => projectionFailure("input", cause)));
|
|
151
|
+
const encodedGrant = yield* Schema.encodeEffect(SubagentGrant)(grant).pipe(Effect.mapError((cause) => projectionFailure("input", cause)));
|
|
152
|
+
const started = yield* service.start({
|
|
153
|
+
delegationId: declaration.delegationId,
|
|
154
|
+
target: declaration.target,
|
|
155
|
+
idempotencyKey: key,
|
|
156
|
+
encodedParameters,
|
|
157
|
+
encodedGrant,
|
|
158
|
+
...options.continuationOf === void 0 ? {} : { continuationOf: options.continuationOf },
|
|
159
|
+
...options.budgetScope === void 0 ? {} : { budgetScope: options.budgetScope },
|
|
160
|
+
...declaration.policy === void 0 ? {} : { declarationPolicy: declaration.policy },
|
|
161
|
+
prepare: Effect.map(prepare(parameters, caller), (encodedInput) => ({ encodedInput }))
|
|
162
|
+
});
|
|
163
|
+
const validated = yield* Schema.decodeEffect(WorkerStarted)(started).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
164
|
+
operation: "start",
|
|
165
|
+
reason: "corrupt",
|
|
166
|
+
cause
|
|
167
|
+
})));
|
|
168
|
+
if (validated.delivery.message.ownerThreadId !== caller.source.threadId) return yield* WorkerError.make({
|
|
169
|
+
operation: "start",
|
|
170
|
+
reason: "message-mismatch"
|
|
171
|
+
});
|
|
172
|
+
return {
|
|
173
|
+
worker: yield* validateWorker(validated.worker, "start"),
|
|
174
|
+
delivery: validated.delivery
|
|
175
|
+
};
|
|
176
|
+
}),
|
|
177
|
+
followUp: Effect.fnUntraced(function* (worker, parameters, options) {
|
|
178
|
+
const service = yield* host;
|
|
179
|
+
const validated = yield* validateWorker(worker, "followUp");
|
|
180
|
+
const caller = yield* context;
|
|
181
|
+
const key = yield* validateKey(options.idempotencyKey, "followUp");
|
|
182
|
+
const encodedParameters = yield* Schema.encodeEffect(declaration.parameters)(parameters).pipe(Effect.mapError((cause) => projectionFailure("input", cause)));
|
|
183
|
+
const delivery = yield* validateDelivery(validated, yield* service.followUp({
|
|
184
|
+
encodedParameters,
|
|
185
|
+
prepare: prepare(parameters, caller).pipe(Effect.map((encodedInput) => ({ encodedInput }))),
|
|
186
|
+
worker: validated,
|
|
187
|
+
target: declaration.target,
|
|
188
|
+
idempotencyKey: key
|
|
189
|
+
}), "followUp");
|
|
190
|
+
if (delivery.message.ownerThreadId !== caller.source.threadId) return yield* WorkerError.make({
|
|
191
|
+
operation: "followUp",
|
|
192
|
+
reason: "message-mismatch"
|
|
193
|
+
});
|
|
194
|
+
return delivery;
|
|
195
|
+
}),
|
|
196
|
+
inspectMessage: Effect.fnUntraced(function* (worker, message) {
|
|
197
|
+
const service = yield* host;
|
|
198
|
+
const validated = yield* validateWorker(worker, "inspect");
|
|
199
|
+
const requested = yield* Schema.decodeEffect(MessageRef)(message).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
200
|
+
operation: "inspect",
|
|
201
|
+
reason: "message-mismatch",
|
|
202
|
+
cause
|
|
203
|
+
})));
|
|
204
|
+
const observed = yield* service.inspect({
|
|
205
|
+
worker: validated,
|
|
206
|
+
target: declaration.target,
|
|
207
|
+
message: requested
|
|
208
|
+
});
|
|
209
|
+
if (!("message" in observed)) return yield* WorkerError.make({
|
|
210
|
+
operation: "inspect",
|
|
211
|
+
reason: "corrupt"
|
|
212
|
+
});
|
|
213
|
+
const delivery = yield* validateDelivery(validated, observed, "inspect");
|
|
214
|
+
if (!Schema.toEquivalence(MessageRef)(delivery.message, requested)) return yield* WorkerError.make({
|
|
215
|
+
operation: "inspect",
|
|
216
|
+
reason: "message-mismatch"
|
|
217
|
+
});
|
|
218
|
+
return delivery;
|
|
219
|
+
}),
|
|
220
|
+
observe: Effect.fnUntraced(function* (operation, worker, receipt) {
|
|
221
|
+
const service = yield* host;
|
|
222
|
+
const validated = yield* validateWorker(worker, operation);
|
|
223
|
+
const requested = yield* validateReceipt(validated, receipt, operation);
|
|
224
|
+
const observed = yield* service[operation]({
|
|
225
|
+
worker: validated,
|
|
226
|
+
target: declaration.target,
|
|
227
|
+
receipt: requested
|
|
228
|
+
});
|
|
229
|
+
if (!("_tag" in observed)) return yield* WorkerError.make({
|
|
230
|
+
operation,
|
|
231
|
+
reason: "corrupt"
|
|
232
|
+
});
|
|
233
|
+
const returned = yield* validateReceipt(validated, observed.receipt, operation);
|
|
234
|
+
if (!receiptEqual(returned, requested)) return yield* WorkerError.make({
|
|
235
|
+
operation,
|
|
236
|
+
reason: "receipt-mismatch"
|
|
237
|
+
});
|
|
238
|
+
if (observed._tag === "Pending") {
|
|
239
|
+
if (operation === "await") return yield* WorkerError.make({
|
|
240
|
+
operation,
|
|
241
|
+
reason: "corrupt"
|
|
242
|
+
});
|
|
243
|
+
return {
|
|
244
|
+
_tag: "Pending",
|
|
245
|
+
receipt: returned
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const base = {
|
|
249
|
+
_tag: "Settled",
|
|
250
|
+
receipt: returned,
|
|
251
|
+
...observed.runId === void 0 ? {} : { runId: yield* Schema.decodeEffect(RunId)(observed.runId).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
252
|
+
operation,
|
|
253
|
+
reason: "corrupt",
|
|
254
|
+
cause
|
|
255
|
+
}))) },
|
|
256
|
+
settlementId: yield* Schema.decodeEffect(SettlementId)(observed.settlementId).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
257
|
+
operation,
|
|
258
|
+
reason: "corrupt",
|
|
259
|
+
cause
|
|
260
|
+
})))
|
|
261
|
+
};
|
|
262
|
+
if (observed.outcome === "failed" || observed.outcome === "aborted") return {
|
|
263
|
+
...base,
|
|
264
|
+
outcome: observed.outcome,
|
|
265
|
+
...observed.diagnostic === void 0 ? {} : { diagnostic: yield* Schema.decodeEffect(Failure)(observed.diagnostic).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
266
|
+
operation,
|
|
267
|
+
reason: "corrupt",
|
|
268
|
+
cause
|
|
269
|
+
}))) },
|
|
270
|
+
failure: SubagentExecutionFailure.make({
|
|
271
|
+
delegationId: declaration.delegationId,
|
|
272
|
+
targetAgentId: declaration.target.id,
|
|
273
|
+
classification: observed.outcome === "failed" ? "child-failed" : "child-aborted",
|
|
274
|
+
childThreadId: worker.threadId,
|
|
275
|
+
childSubmissionId: returned.submissionId,
|
|
276
|
+
...base.runId === void 0 ? {} : { childRunId: base.runId },
|
|
277
|
+
errorTag: observed.outcome === "failed" ? "WorkerFailed" : "WorkerAborted",
|
|
278
|
+
message: observed.outcome === "failed" ? "Worker input failed" : "Worker input was aborted"
|
|
279
|
+
})
|
|
280
|
+
};
|
|
281
|
+
if (observed.outcome !== "completed" || base.runId === void 0 || typeof observed.budgetExhausted !== "boolean") return yield* WorkerError.make({
|
|
282
|
+
operation,
|
|
283
|
+
reason: "corrupt"
|
|
284
|
+
});
|
|
285
|
+
const parameters = yield* Schema.decodeUnknownEffect(declaration.parameters)(observed.encodedParameters).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
|
|
286
|
+
const output = yield* Schema.decodeUnknownEffect(declaration.target.output)(observed.encodedResult).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
|
|
287
|
+
const result = yield* declaration.projectResult(output, { budgetExhausted: observed.budgetExhausted }, parameters);
|
|
288
|
+
const encoded = yield* Schema.encodeEffect(declaration.success)(result).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
|
|
289
|
+
const json = yield* Schema.decodeUnknownEffect(Schema.Json)(encoded).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
|
|
290
|
+
const caller = yield* context;
|
|
291
|
+
if (utf8ByteLength(JSON.stringify(json)) > (declaration.policy?.maxResultBytes ?? caller.policy.toolResultBounds.maxBytes)) return yield* projectionFailure("result");
|
|
292
|
+
return yield* Schema.decodeUnknownEffect(Schema.toType(WorkerObservation(declaration.success)))({
|
|
293
|
+
...base,
|
|
294
|
+
outcome: "completed",
|
|
295
|
+
result
|
|
296
|
+
}).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
|
|
297
|
+
}),
|
|
298
|
+
list: Effect.fnUntraced(function* (options = {}) {
|
|
299
|
+
const service = yield* host;
|
|
300
|
+
const limit = yield* Schema.decodeEffect(Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(100)))(options.limit ?? 20).pipe(Effect.mapError(() => WorkerError.make({
|
|
301
|
+
operation: "list",
|
|
302
|
+
reason: "capacity"
|
|
303
|
+
})));
|
|
304
|
+
const page = yield* service.list({
|
|
305
|
+
delegationId: declaration.delegationId,
|
|
306
|
+
target: declaration.target,
|
|
307
|
+
limit,
|
|
308
|
+
...options.after === void 0 ? {} : { after: options.after }
|
|
309
|
+
});
|
|
310
|
+
const validated = yield* Schema.decodeEffect(WorkerPage)(page).pipe(Effect.mapError(() => WorkerError.make({
|
|
311
|
+
operation: "list",
|
|
312
|
+
reason: "corrupt"
|
|
313
|
+
})));
|
|
314
|
+
if (validated.items.length > limit) return yield* WorkerError.make({
|
|
315
|
+
operation: "list",
|
|
316
|
+
reason: "corrupt"
|
|
317
|
+
});
|
|
318
|
+
const items = [];
|
|
319
|
+
for (const item of validated.items) {
|
|
320
|
+
const worker = yield* validateWorker(item.worker, "list");
|
|
321
|
+
const latestReceipt = item.latestReceipt === null ? null : yield* validateReceipt(worker, item.latestReceipt, "list");
|
|
322
|
+
items.push({
|
|
323
|
+
...item,
|
|
324
|
+
worker,
|
|
325
|
+
latestReceipt
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
items,
|
|
330
|
+
next: validated.next
|
|
331
|
+
};
|
|
332
|
+
}),
|
|
333
|
+
cancel: Effect.fnUntraced(function* (worker, receipt) {
|
|
334
|
+
const service = yield* host;
|
|
335
|
+
const validated = yield* validateWorker(worker, "cancel");
|
|
336
|
+
const requested = yield* validateReceipt(validated, receipt, "cancel");
|
|
337
|
+
yield* service.cancel({
|
|
338
|
+
worker: validated,
|
|
339
|
+
target: declaration.target,
|
|
340
|
+
receipt: requested
|
|
341
|
+
});
|
|
342
|
+
})
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
/** Retain a first worker input. The same explicit key reuses its durable delivery identity. */
|
|
346
|
+
const start = (declaration, parameters, options) => operations(declaration).start(parameters, options);
|
|
347
|
+
/** Retain typed follow-up parameters for the same worker Thread; inspect its MessageRef for delivery. */
|
|
348
|
+
const followUp = (declaration, worker, parameters, options) => operations(declaration).followUp(worker, parameters, options);
|
|
349
|
+
/** Inspect a continuing worker with the same summary contract returned by list. */
|
|
350
|
+
const summary = Effect.fnUntraced(function* (declaration, worker) {
|
|
351
|
+
const service = yield* host;
|
|
352
|
+
const validated = yield* Schema.decodeEffect(Worker(declaration))(worker).pipe(Effect.mapError(() => WorkerError.make({
|
|
353
|
+
operation: "inspect",
|
|
354
|
+
reason: "worker-mismatch"
|
|
355
|
+
})));
|
|
356
|
+
const result = yield* service.summary({
|
|
357
|
+
worker: validated,
|
|
358
|
+
target: declaration.target
|
|
359
|
+
});
|
|
360
|
+
const value = yield* Schema.decodeEffect(WorkerSummary)(result).pipe(Effect.mapError(() => WorkerError.make({
|
|
361
|
+
operation: "inspect",
|
|
362
|
+
reason: "corrupt"
|
|
363
|
+
})));
|
|
364
|
+
if (value.worker.threadId !== validated.threadId || value.worker.delegationId !== validated.delegationId || value.worker.targetAgentId !== validated.targetAgentId || value.latestReceipt !== null && value.latestReceipt.threadId !== validated.threadId) return yield* WorkerError.make({
|
|
365
|
+
operation: "inspect",
|
|
366
|
+
reason: "worker-mismatch"
|
|
367
|
+
});
|
|
368
|
+
return {
|
|
369
|
+
...value,
|
|
370
|
+
worker: validated
|
|
371
|
+
};
|
|
372
|
+
});
|
|
373
|
+
function inspect(declaration, worker, reference) {
|
|
374
|
+
return reference === void 0 ? summary(declaration, worker) : "messageId" in reference ? operations(declaration).inspectMessage(worker, reference) : operations(declaration).observe("inspect", worker, reference);
|
|
375
|
+
}
|
|
376
|
+
/** Read an authorized finite history snapshot; pass the last emitted sequence to resume. */
|
|
377
|
+
const observe = (declaration, worker, options = {}) => Stream.unwrap(Effect.gen(function* () {
|
|
378
|
+
const service = yield* host;
|
|
379
|
+
const validated = yield* Schema.decodeEffect(Worker(declaration))(worker).pipe(Effect.mapError(() => WorkerError.make({
|
|
380
|
+
operation: "observe",
|
|
381
|
+
reason: "worker-mismatch"
|
|
382
|
+
})));
|
|
383
|
+
const after = options.after === void 0 ? void 0 : yield* Schema.decodeEffect(Schema.Natural)(options.after).pipe(Effect.mapError(() => WorkerError.make({
|
|
384
|
+
operation: "observe",
|
|
385
|
+
reason: "corrupt"
|
|
386
|
+
})));
|
|
387
|
+
return service.observe({
|
|
388
|
+
worker: validated,
|
|
389
|
+
target: declaration.target,
|
|
390
|
+
...after === void 0 ? {} : { after }
|
|
391
|
+
});
|
|
392
|
+
}));
|
|
393
|
+
/** Seal a continuing worker, retaining a stable command identity across retries and Runs. */
|
|
394
|
+
const stop = Effect.fnUntraced(function* (declaration, worker, options) {
|
|
395
|
+
const service = yield* host;
|
|
396
|
+
const command = yield* Schema.decodeEffect(WorkerStop)({
|
|
397
|
+
worker,
|
|
398
|
+
...options
|
|
399
|
+
}).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
400
|
+
operation: "stop",
|
|
401
|
+
reason: "corrupt",
|
|
402
|
+
cause
|
|
403
|
+
})));
|
|
404
|
+
if (worker.delegationId !== declaration.delegationId || worker.targetAgentId !== declaration.target.id) return yield* WorkerError.make({
|
|
405
|
+
operation: "stop",
|
|
406
|
+
reason: "worker-mismatch"
|
|
407
|
+
});
|
|
408
|
+
return yield* service.stop({
|
|
409
|
+
...command,
|
|
410
|
+
target: declaration.target
|
|
411
|
+
}).pipe(Effect.flatMap(Schema.decodeEffect(WorkerStopped)), Effect.mapError((cause) => Schema.is(WorkerError)(cause) ? cause : WorkerError.make({
|
|
412
|
+
operation: "stop",
|
|
413
|
+
reason: "corrupt",
|
|
414
|
+
cause
|
|
415
|
+
})));
|
|
416
|
+
});
|
|
417
|
+
/** Wait for the exact Receipt. Interrupting this Effect never cancels accepted work. */
|
|
418
|
+
const awaitWorker = (declaration, worker, receipt) => operations(declaration).observe("await", worker, receipt);
|
|
419
|
+
/** List only workers visible through the caller-bound host facet. */
|
|
420
|
+
const list = (declaration, options = {}) => operations(declaration).list(options);
|
|
421
|
+
/** Request cancellation of exactly one Receipt; JoinedToHost remains a typed conflict. */
|
|
422
|
+
const cancel = (declaration, worker, receipt) => operations(declaration).cancel(worker, receipt);
|
|
423
|
+
const ReceiptParameters = (declaration) => Schema.Struct({
|
|
424
|
+
worker: Worker(declaration),
|
|
425
|
+
receipt: Receipt
|
|
426
|
+
});
|
|
427
|
+
const InspectParameters = (declaration) => Schema.Struct({
|
|
428
|
+
worker: Worker(declaration),
|
|
429
|
+
message: Schema.optionalKey(MessageRef),
|
|
430
|
+
receipt: Schema.optionalKey(Receipt)
|
|
431
|
+
}).check(Schema.makeFilter(({ message, receipt }) => message === void 0 !== (receipt === void 0), { message: "Provide exactly one retained message reference or accepted receipt" }));
|
|
432
|
+
const Inspection = (success) => Schema.Union([MessageStatus, toolObservation(success)]);
|
|
433
|
+
const WorkerParameters = (declaration) => Schema.Struct({ worker: Worker(declaration) });
|
|
434
|
+
const Summary = (declaration) => Schema.Struct({
|
|
435
|
+
...WorkerSummary.fields,
|
|
436
|
+
worker: Worker(declaration)
|
|
437
|
+
});
|
|
438
|
+
const FollowUpParameters = (declaration, parameters) => Schema.Struct({
|
|
439
|
+
worker: Worker(declaration),
|
|
440
|
+
parameters: Schema.Union([parameters])
|
|
441
|
+
});
|
|
442
|
+
const ListParameters = Schema.Struct({
|
|
443
|
+
limit: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(100))),
|
|
444
|
+
after: Schema.optionalKey(ThreadId)
|
|
445
|
+
});
|
|
446
|
+
const Started = (declaration) => Schema.Struct({
|
|
447
|
+
worker: Worker(declaration),
|
|
448
|
+
delivery: MessageStatus
|
|
449
|
+
}).check(Schema.makeFilter(({ worker, delivery }) => delivery.receipt === null || worker.threadId === delivery.receipt.threadId));
|
|
450
|
+
const Page = (declaration) => Schema.Struct({
|
|
451
|
+
items: Schema.Array(Summary(declaration)).check(Schema.isMaxLength(100)),
|
|
452
|
+
next: Schema.NullOr(ThreadId)
|
|
453
|
+
});
|
|
454
|
+
const preparationFailure = (failure) => Schema.Union([
|
|
455
|
+
failure,
|
|
456
|
+
SubagentProjectionFailure,
|
|
457
|
+
WorkerError
|
|
458
|
+
]);
|
|
459
|
+
const startFailure = (failure) => Schema.Union([
|
|
460
|
+
failure,
|
|
461
|
+
SubagentProjectionFailure,
|
|
462
|
+
SubagentPrestartDenied,
|
|
463
|
+
WorkerError
|
|
464
|
+
]);
|
|
465
|
+
const cancelFailure = Schema.Union([WorkerError, JoinedToHost]);
|
|
466
|
+
const modelKey = Effect.fnUntraced(function* (operation) {
|
|
467
|
+
const caller = yield* (yield* host).context;
|
|
468
|
+
if (caller.source._tag !== "tool") return yield* WorkerError.make({
|
|
469
|
+
operation,
|
|
470
|
+
reason: "denied"
|
|
471
|
+
});
|
|
472
|
+
const source = caller.source;
|
|
473
|
+
const crypto = yield* CryptoDigest.Digest;
|
|
474
|
+
const bytes = utf8Bytes(JSON.stringify([
|
|
475
|
+
"worker-tool-v1",
|
|
476
|
+
operation,
|
|
477
|
+
source.agentId,
|
|
478
|
+
source.threadId,
|
|
479
|
+
source.runId,
|
|
480
|
+
source.toolCallId
|
|
481
|
+
]));
|
|
482
|
+
const digest = yield* crypto.digest(CryptoDigest.sha256, bytes).pipe(Effect.mapError(() => WorkerError.make({
|
|
483
|
+
operation,
|
|
484
|
+
reason: "unavailable"
|
|
485
|
+
})));
|
|
486
|
+
return yield* Schema.decodeEffect(IdempotencyKey)(`worker:${Hex.encode(digest)}`).pipe(Effect.mapError(() => WorkerError.make({
|
|
487
|
+
operation,
|
|
488
|
+
reason: "unavailable"
|
|
489
|
+
})));
|
|
490
|
+
});
|
|
491
|
+
/** Pair one native Tool with its checked handler, retaining invocation service requirements. */
|
|
492
|
+
const action = (tool, build) => {
|
|
493
|
+
const layer = Toolkit.make(tool).toLayer(Effect.map(build, (handler) => {
|
|
494
|
+
return { [tool.name]: handler };
|
|
495
|
+
}));
|
|
496
|
+
return Object.freeze({
|
|
497
|
+
tool,
|
|
498
|
+
layer
|
|
499
|
+
});
|
|
500
|
+
};
|
|
501
|
+
/** Retain new worker input under the current Tool Call's stable identity. */
|
|
502
|
+
const startTool = (declaration, options = {}) => {
|
|
503
|
+
const tool = Tool.make(`${declaration.name}_start`, {
|
|
504
|
+
description: `Retain input for a background ${declaration.name} worker and return its delivery state. Pending confirms retention only; inspect the same message instead of starting another worker.`,
|
|
505
|
+
parameters: declaration.parameters,
|
|
506
|
+
success: Started(declaration),
|
|
507
|
+
failure: startFailure(declaration.failure)
|
|
508
|
+
}).annotate(WorkerOperationTool, true).annotate(BackgroundSpawnTool, true).addDependency(SubagentHost).addDependency(CryptoDigest.Digest);
|
|
509
|
+
const ops = operations(declaration);
|
|
510
|
+
return action(tool, Effect.map(Effect.context(), (captured) => (parameters) => Effect.gen(function* () {
|
|
511
|
+
const service = yield* host;
|
|
512
|
+
const idempotencyKey = yield* modelKey("start");
|
|
513
|
+
return yield* ops.start(parameters, {
|
|
514
|
+
...options,
|
|
515
|
+
idempotencyKey
|
|
516
|
+
}).pipe(Effect.provideService(SubagentHost, service), Effect.provide(captured));
|
|
517
|
+
})));
|
|
518
|
+
};
|
|
519
|
+
/** Retain follow-up input for an existing worker under the current Tool Call's identity. */
|
|
520
|
+
const followUpTool = (declaration) => {
|
|
521
|
+
const tool = Tool.make(`${declaration.name}_follow_up`, {
|
|
522
|
+
description: `Retain typed follow-up input for an existing ${declaration.name} worker. Pending is retained, not executed: inspect the same message instead of sending the command again.`,
|
|
523
|
+
parameters: FollowUpParameters(declaration, declaration.parameters),
|
|
524
|
+
success: MessageStatus,
|
|
525
|
+
failure: preparationFailure(declaration.failure)
|
|
526
|
+
}).annotate(WorkerOperationTool, true).addDependency(SubagentHost).addDependency(CryptoDigest.Digest);
|
|
527
|
+
const ops = operations(declaration);
|
|
528
|
+
return action(tool, Effect.map(Effect.context(), (captured) => (parameters) => Effect.gen(function* () {
|
|
529
|
+
const service = yield* host;
|
|
530
|
+
const idempotencyKey = yield* modelKey("followUp");
|
|
531
|
+
return yield* ops.followUp(parameters.worker, parameters.parameters, { idempotencyKey }).pipe(Effect.provideService(SubagentHost, service), Effect.provide(captured));
|
|
532
|
+
})));
|
|
533
|
+
};
|
|
534
|
+
/** Inspect one delivery or accepted Receipt without resending input. */
|
|
535
|
+
const inspectTool = (declaration) => {
|
|
536
|
+
const tool = Tool.make(`${declaration.name}_inspect`, {
|
|
537
|
+
description: `Inspect one ${declaration.name} delivery by message reference, or its execution result by accepted receipt. Provide exactly one reference; inspection never resends input.`,
|
|
538
|
+
parameters: InspectParameters(declaration),
|
|
539
|
+
success: Inspection(declaration.success),
|
|
540
|
+
failure: preparationFailure(declaration.failure)
|
|
541
|
+
}).annotate(WorkerOperationTool, true).addDependency(SubagentHost);
|
|
542
|
+
const ops = operations(declaration);
|
|
543
|
+
return action(tool, Effect.map(Effect.context(), (captured) => (parameters) => Effect.gen(function* () {
|
|
544
|
+
const service = yield* host;
|
|
545
|
+
if (parameters.message !== void 0) return yield* ops.inspectMessage(parameters.worker, parameters.message);
|
|
546
|
+
if (parameters.receipt === void 0) return yield* WorkerError.make({
|
|
547
|
+
operation: "inspect",
|
|
548
|
+
reason: "message-mismatch"
|
|
549
|
+
});
|
|
550
|
+
return yield* ops.observe("inspect", parameters.worker, parameters.receipt).pipe(Effect.map((observed) => {
|
|
551
|
+
if ("diagnostic" in observed) {
|
|
552
|
+
const { diagnostic: _diagnostic, ...projected } = observed;
|
|
553
|
+
return projected;
|
|
554
|
+
}
|
|
555
|
+
return observed;
|
|
556
|
+
}), Effect.provideService(SubagentHost, service), Effect.provide(captured));
|
|
557
|
+
})));
|
|
558
|
+
};
|
|
559
|
+
/** Inspect a continuing worker's state and latest accepted input. */
|
|
560
|
+
const summaryTool = (declaration) => {
|
|
561
|
+
const tool = Tool.make(`${declaration.name}_summary`, {
|
|
562
|
+
description: `Inspect ${declaration.name}'s continuing worker state and latest accepted input.`,
|
|
563
|
+
parameters: WorkerParameters(declaration),
|
|
564
|
+
success: Summary(declaration),
|
|
565
|
+
failure: WorkerError
|
|
566
|
+
}).annotate(WorkerOperationTool, true).addDependency(SubagentHost);
|
|
567
|
+
return action(tool, Effect.succeed((parameters) => summary(declaration, parameters.worker)));
|
|
568
|
+
};
|
|
569
|
+
/** List workers visible through the current caller's host facet. */
|
|
570
|
+
const listTool = (declaration) => {
|
|
571
|
+
const tool = Tool.make(`${declaration.name}_list`, {
|
|
572
|
+
description: `List visible ${declaration.name} workers.`,
|
|
573
|
+
parameters: ListParameters,
|
|
574
|
+
success: Page(declaration),
|
|
575
|
+
failure: WorkerError
|
|
576
|
+
}).annotate(WorkerOperationTool, true).addDependency(SubagentHost);
|
|
577
|
+
const ops = operations(declaration);
|
|
578
|
+
return action(tool, Effect.succeed((parameters) => ops.list(parameters)));
|
|
579
|
+
};
|
|
580
|
+
/** Request cancellation of one exact worker Receipt. */
|
|
581
|
+
const cancelTool = (declaration) => {
|
|
582
|
+
const tool = Tool.make(`${declaration.name}_cancel`, {
|
|
583
|
+
description: `Request cancellation of one exact ${declaration.name} Receipt.`,
|
|
584
|
+
parameters: ReceiptParameters(declaration),
|
|
585
|
+
success: Schema.Void,
|
|
586
|
+
failure: cancelFailure
|
|
587
|
+
}).annotate(WorkerOperationTool, true).addDependency(SubagentHost);
|
|
588
|
+
const ops = operations(declaration);
|
|
589
|
+
return action(tool, Effect.succeed((parameters) => ops.cancel(parameters.worker, parameters.receipt)));
|
|
590
|
+
};
|
|
591
|
+
// src/capabilities/internal/subagent-reporting.ts
|
|
592
|
+
const projectReport = (declaration) => Effect.fnUntraced(function* (report) {
|
|
593
|
+
const { worker, observation } = report;
|
|
594
|
+
const invalid = () => WorkerReportPreparationFailure.make({ stage: "projection" });
|
|
595
|
+
if (worker.delegationId !== declaration.delegationId || worker.targetAgentId !== declaration.target.id || observation.receipt.threadId !== worker.threadId) return yield* invalid();
|
|
596
|
+
const base = {
|
|
597
|
+
_tag: "Settled",
|
|
598
|
+
worker,
|
|
599
|
+
receipt: yield* Schema.decodeEffect(Receipt)(observation.receipt).pipe(Effect.mapError(invalid)),
|
|
600
|
+
runId: observation.runId,
|
|
601
|
+
settlementId: observation.settlementId
|
|
602
|
+
};
|
|
603
|
+
let projected;
|
|
604
|
+
let encodedResult = null;
|
|
605
|
+
if (observation.outcome === "completed") {
|
|
606
|
+
const parameters = yield* Schema.decodeUnknownEffect(declaration.parameters)(observation.encodedParameters).pipe(Effect.mapError(invalid));
|
|
607
|
+
const output = yield* Schema.decodeUnknownEffect(declaration.target.output)(observation.encodedResult).pipe(Effect.mapError(invalid));
|
|
608
|
+
const result = yield* declaration.projectResult(output, { budgetExhausted: observation.budgetExhausted }, parameters);
|
|
609
|
+
const encoded = yield* Schema.encodeEffect(declaration.success)(result).pipe(Effect.mapError(invalid));
|
|
610
|
+
const json = yield* Schema.decodeUnknownEffect(Schema.Json)(encoded).pipe(Effect.mapError(invalid));
|
|
611
|
+
if (utf8ByteLength(JSON.stringify(json)) > (declaration.policy?.maxResultBytes ?? declaration.target.policy.toolResultBounds.maxBytes)) return yield* invalid();
|
|
612
|
+
projected = {
|
|
613
|
+
...base,
|
|
614
|
+
outcome: "completed",
|
|
615
|
+
result
|
|
616
|
+
};
|
|
617
|
+
encodedResult = json;
|
|
618
|
+
} else projected = {
|
|
619
|
+
...base,
|
|
620
|
+
outcome: observation.outcome,
|
|
621
|
+
failure: SubagentExecutionFailure.make({
|
|
622
|
+
delegationId: declaration.delegationId,
|
|
623
|
+
targetAgentId: declaration.target.id,
|
|
624
|
+
classification: observation.outcome === "failed" ? "child-failed" : "child-aborted",
|
|
625
|
+
childThreadId: worker.threadId,
|
|
626
|
+
childSubmissionId: observation.receipt.submissionId,
|
|
627
|
+
childRunId: observation.runId,
|
|
628
|
+
errorTag: observation.outcome === "failed" ? "WorkerFailed" : "WorkerAborted",
|
|
629
|
+
message: observation.outcome === "failed" ? "Worker input failed" : "Worker input was aborted"
|
|
630
|
+
})
|
|
631
|
+
};
|
|
632
|
+
return {
|
|
633
|
+
projected,
|
|
634
|
+
encodedResult
|
|
635
|
+
};
|
|
636
|
+
});
|
|
637
|
+
/** Register this standard completion projection on the parent; registration captures its services. */
|
|
638
|
+
const reporting = (declaration, options = {}) => ({
|
|
639
|
+
delegationId: declaration.delegationId,
|
|
640
|
+
target: declaration.target,
|
|
641
|
+
...options,
|
|
642
|
+
prepare: Effect.fnUntraced(function* (report) {
|
|
643
|
+
const { projected, encodedResult } = yield* projectReport(declaration)(report);
|
|
644
|
+
const encoded = projected.outcome === "completed" ? {
|
|
645
|
+
...projected,
|
|
646
|
+
result: encodedResult
|
|
647
|
+
} : {
|
|
648
|
+
...projected,
|
|
649
|
+
failure: yield* Schema.encodeEffect(SubagentExecutionFailure)(projected.failure).pipe(Effect.mapError(() => WorkerReportPreparationFailure.make({ stage: "projection" })))
|
|
650
|
+
};
|
|
651
|
+
return { message: yield* Schema.decodeEffect(WorkerCompletion)({
|
|
652
|
+
_tag: "WorkerCompletion",
|
|
653
|
+
schemaVersion: 1,
|
|
654
|
+
report: encoded,
|
|
655
|
+
budgetExhausted: report.observation.budgetExhausted
|
|
656
|
+
}).pipe(Effect.mapError(() => WorkerReportPreparationFailure.make({ stage: "projection" }))) };
|
|
657
|
+
})
|
|
658
|
+
});
|
|
659
|
+
// src/capabilities/Subagent.ts
|
|
660
|
+
var Subagent_exports = /* @__PURE__ */ __exportAll({
|
|
661
|
+
SubagentDurableAccounting: () => SubagentDurableAccounting,
|
|
662
|
+
SubagentExecutionFailure: () => SubagentExecutionFailure,
|
|
663
|
+
SubagentExecutionFailureClassification: () => SubagentExecutionFailureClassification,
|
|
664
|
+
SubagentGrant: () => SubagentGrant,
|
|
665
|
+
SubagentPolicy: () => SubagentPolicy,
|
|
666
|
+
SubagentPrestartDenied: () => SubagentPrestartDenied,
|
|
667
|
+
SubagentProjectionFailure: () => SubagentProjectionFailure,
|
|
668
|
+
SubagentResult: () => SubagentResult,
|
|
669
|
+
Worker: () => Worker,
|
|
670
|
+
WorkerCompletion: () => WorkerCompletion,
|
|
671
|
+
WorkerObservation: () => WorkerObservation,
|
|
672
|
+
WorkerReport: () => WorkerReport,
|
|
673
|
+
await: () => awaitWorker,
|
|
674
|
+
cancel: () => cancel,
|
|
675
|
+
cancelTool: () => cancelTool,
|
|
676
|
+
delegationAllocationFromPolicy: () => delegationAllocationFromPolicy,
|
|
677
|
+
delegationCapsFromPolicy: () => delegationCapsFromPolicy,
|
|
678
|
+
followUp: () => followUp,
|
|
679
|
+
followUpTool: () => followUpTool,
|
|
680
|
+
inspect: () => inspect,
|
|
681
|
+
inspectTool: () => inspectTool,
|
|
682
|
+
layer: () => layer,
|
|
683
|
+
list: () => list,
|
|
684
|
+
listTool: () => listTool,
|
|
685
|
+
make: () => make,
|
|
686
|
+
observe: () => observe,
|
|
687
|
+
reporting: () => reporting,
|
|
688
|
+
start: () => start,
|
|
689
|
+
startTool: () => startTool,
|
|
690
|
+
stop: () => stop,
|
|
691
|
+
summaryTool: () => summaryTool
|
|
692
|
+
});
|
|
693
|
+
const decodeDelegationId = Schema.decodeSync(DelegationId);
|
|
694
|
+
/** Default delegation result, preserving partial-output information. */
|
|
695
|
+
const SubagentResult = (output) => Schema.Struct({
|
|
696
|
+
output,
|
|
697
|
+
budgetExhausted: Schema.Boolean
|
|
698
|
+
});
|
|
699
|
+
/**
|
|
700
|
+
* Declare one attached delegation as a pure value.
|
|
701
|
+
*
|
|
702
|
+
* The returned `.tool` is a native Effect AI Tool whose handler dependencies
|
|
703
|
+
* are exactly the engine-owned `AgentSpawner`, `RunEventSink`, and
|
|
704
|
+
* `SubagentDurability` (SUB-003); runtime IDs have an overridable default.
|
|
705
|
+
* The concrete child Binding arrives only through
|
|
706
|
+
* `Subagent.layer`. Throws on an invalid delegation name. Nested declarations remain inert unless the
|
|
707
|
+
* effective inherited grant and reserved subtree budget permit their lifetime and depth.
|
|
708
|
+
*/
|
|
709
|
+
const makeExplicit = (name, options) => {
|
|
710
|
+
const delegationId = decodeDelegationId(name);
|
|
711
|
+
const grant = options.grant ?? SubagentGrant.make({
|
|
712
|
+
allowedToolNames: Object.keys(options.target.toolkit.tools),
|
|
713
|
+
maxDepth: 1
|
|
714
|
+
});
|
|
715
|
+
const failureMode = options.failureMode ?? "error";
|
|
716
|
+
const containedFailure = Schema.Union([
|
|
717
|
+
options.failure,
|
|
718
|
+
SubagentPrestartDenied,
|
|
719
|
+
SubagentBudgetExhausted,
|
|
720
|
+
SubagentProjectionFailure,
|
|
721
|
+
SubagentExecutionFailure
|
|
722
|
+
]);
|
|
723
|
+
const returnModeTool = Tool.make(name, {
|
|
724
|
+
description: options.description,
|
|
725
|
+
parameters: options.parameters,
|
|
726
|
+
success: Schema.Union([options.success, containedFailure]),
|
|
727
|
+
failure: Schema.Union([ToolCallWaiting, SubagentDurabilityError]),
|
|
728
|
+
needsApproval: options.needsApproval
|
|
729
|
+
});
|
|
730
|
+
const errorModeTool = Tool.make(name, {
|
|
731
|
+
description: options.description,
|
|
732
|
+
parameters: options.parameters,
|
|
733
|
+
success: options.success,
|
|
734
|
+
failure: Schema.Union([
|
|
735
|
+
options.failure,
|
|
736
|
+
SubagentPrestartDenied,
|
|
737
|
+
SubagentBudgetExhausted,
|
|
738
|
+
SubagentProjectionFailure,
|
|
739
|
+
SubagentExecutionFailure,
|
|
740
|
+
ToolCallWaiting,
|
|
741
|
+
SubagentDurabilityError
|
|
742
|
+
]),
|
|
743
|
+
needsApproval: options.needsApproval
|
|
744
|
+
});
|
|
745
|
+
const tool = (failureMode === "return" ? returnModeTool : errorModeTool).annotate(DelegationTool, true).addDependency(AgentSpawner).addDependency(RunEventSink).addDependency(SubagentDurability).addDependency(IdGenerator);
|
|
746
|
+
return Object.freeze({
|
|
747
|
+
...options,
|
|
748
|
+
name,
|
|
749
|
+
delegationId,
|
|
750
|
+
grant,
|
|
751
|
+
failureMode,
|
|
752
|
+
containedFailure,
|
|
753
|
+
tool
|
|
754
|
+
});
|
|
755
|
+
};
|
|
756
|
+
function make(name, options) {
|
|
757
|
+
const success = options.success ?? SubagentResult(options.target.output);
|
|
758
|
+
const parameters = options.parameters ?? options.target.input;
|
|
759
|
+
const failure = options.failure ?? Schema.Never;
|
|
760
|
+
const inputValue = Schema.decodeUnknownEffect(Schema.toType(options.target.input));
|
|
761
|
+
const resultValue = Schema.decodeUnknownEffect(Schema.toType(success));
|
|
762
|
+
const needsApproval = options.needsApproval;
|
|
763
|
+
const prepareInput = options.prepareInput;
|
|
764
|
+
const projectResult = options.projectResult;
|
|
765
|
+
const projectionFailure = (stage) => SubagentProjectionFailure.make({
|
|
766
|
+
delegationId: decodeDelegationId(name),
|
|
767
|
+
stage,
|
|
768
|
+
message: stage === "input" ? "Delegation parameters did not satisfy the child input Schema" : "Child output did not satisfy the delegation success Schema"
|
|
769
|
+
});
|
|
770
|
+
const resolved = {
|
|
771
|
+
...options,
|
|
772
|
+
needsApproval: typeof needsApproval === "function" ? (input, context) => needsApproval(input, context) : needsApproval,
|
|
773
|
+
description: options.description ?? options.target.description,
|
|
774
|
+
parameters,
|
|
775
|
+
success,
|
|
776
|
+
failure,
|
|
777
|
+
prepareInput: (input, context) => prepareInput === void 0 ? inputValue(input).pipe(Effect.mapError(() => projectionFailure("input"))) : prepareInput(input, context),
|
|
778
|
+
projectResult: (output, context, input) => projectResult === void 0 ? resultValue({
|
|
779
|
+
output,
|
|
780
|
+
budgetExhausted: context.budgetExhausted
|
|
781
|
+
}).pipe(Effect.mapError(() => projectionFailure("result"))) : projectResult(output, context, input)
|
|
782
|
+
};
|
|
783
|
+
return options.failureMode === "return" ? makeExplicit(name, {
|
|
784
|
+
...resolved,
|
|
785
|
+
failureMode: "return"
|
|
786
|
+
}) : makeExplicit(name, {
|
|
787
|
+
...resolved,
|
|
788
|
+
failureMode: "error"
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* The conservative final accounting summary the durable delegation handler
|
|
793
|
+
* attaches to every settlement join. The handler has no live child usage stream at durable join
|
|
794
|
+
* time, so every dimension conservatively consumes its full reservation and
|
|
795
|
+
* releases nothing — unreported usage never creates budget. The coordinator
|
|
796
|
+
* owns the canonical accounting decision on `SubagentJoined` and may replace
|
|
797
|
+
* structural dimensions from canonical child evidence; this value is opaque
|
|
798
|
+
* encoded policy math to the engine and to storage adapters (D8).
|
|
799
|
+
*/
|
|
800
|
+
var SubagentDurableAccounting = class extends Schema.Class("@effect-agent/capabilities/SubagentDurableAccounting")({
|
|
801
|
+
/** The per-invocation allocation reserved at establishment. */
|
|
802
|
+
allocation: SubagentReservationAmounts,
|
|
803
|
+
/** Final consumed decision per dimension. */
|
|
804
|
+
consumed: SubagentReservationAmounts,
|
|
805
|
+
/** Amounts returned to the parent: `allocation - consumed` per dimension. */
|
|
806
|
+
released: SubagentReservationAmounts,
|
|
807
|
+
/** How the decision was computed; the handler only ever reports conservatively. */
|
|
808
|
+
basis: Schema.Literals(["reserved-conservative"])
|
|
809
|
+
}) {};
|
|
810
|
+
const maxEventTextLength = 4096;
|
|
811
|
+
const boundedEventText = (text) => text.length <= maxEventTextLength ? text : `${text.slice(0, 4095)}…`;
|
|
812
|
+
const ErrorMessage = Schema.Struct({ message: Schema.String });
|
|
813
|
+
const ErrorTag = Schema.Struct({ _tag: Schema.NonEmptyString });
|
|
814
|
+
const isDurationPolicyError = (error) => Schema.is(AgentPolicyError)(error) && error.limit === "duration";
|
|
815
|
+
const errorMessageOf = (error) => Option.match(Schema.decodeUnknownOption(ErrorMessage)(error), {
|
|
816
|
+
onNone: () => String(error),
|
|
817
|
+
onSome: ({ message }) => message
|
|
818
|
+
});
|
|
819
|
+
const errorTagOf = (error) => Option.match(Schema.decodeUnknownOption(ErrorTag)(error), {
|
|
820
|
+
onNone: () => "UnknownError",
|
|
821
|
+
onSome: ({ _tag }) => _tag
|
|
822
|
+
});
|
|
823
|
+
const boundedErrorTag = (tag) => {
|
|
824
|
+
const nonEmpty = tag.length === 0 ? "UnknownError" : tag;
|
|
825
|
+
return nonEmpty.length <= 256 ? nonEmpty : nonEmpty.slice(0, 256);
|
|
826
|
+
};
|
|
827
|
+
/**
|
|
828
|
+
* The coordinator's bounded projection of a failed/aborted child Settlement
|
|
829
|
+
* result (S2 plan §1.6, D5): `{errorTag, message}`, never a raw Cause. The
|
|
830
|
+
* fallback tolerates any other bounded shape without ever surfacing the raw
|
|
831
|
+
* value beyond a tag and message.
|
|
832
|
+
*/
|
|
833
|
+
const ChildFailureProjection = Schema.Struct({
|
|
834
|
+
errorTag: Schema.NonEmptyString,
|
|
835
|
+
message: Schema.String
|
|
836
|
+
});
|
|
837
|
+
const childFailureProjectionOf = (encodedResult) => Option.match(Schema.decodeUnknownOption(ChildFailureProjection)(encodedResult), {
|
|
838
|
+
onNone: () => ({
|
|
839
|
+
errorTag: errorTagOf(encodedResult),
|
|
840
|
+
message: errorMessageOf(encodedResult)
|
|
841
|
+
}),
|
|
842
|
+
onSome: (projection) => projection
|
|
843
|
+
});
|
|
844
|
+
const zeroReservationAmounts = SubagentReservationAmounts.make({
|
|
845
|
+
turns: 0,
|
|
846
|
+
toolCalls: 0,
|
|
847
|
+
durationMillis: 0,
|
|
848
|
+
inputTokens: 0,
|
|
849
|
+
outputTokens: 0,
|
|
850
|
+
costMicrousd: 0,
|
|
851
|
+
resultBytes: 0
|
|
852
|
+
});
|
|
853
|
+
const encodeDurableAccounting = Schema.encodeEffect(SubagentDurableAccounting);
|
|
854
|
+
const encodeProjectionFailure = Schema.encodeEffect(SubagentProjectionFailure);
|
|
855
|
+
const encodeBudgetFailure = Schema.encodeEffect(SubagentBudgetExhausted);
|
|
856
|
+
const encodeExecutionFailure = Schema.encodeEffect(SubagentExecutionFailure);
|
|
857
|
+
const encodeGrant = Schema.encodeEffect(SubagentGrant);
|
|
858
|
+
const encodeAllocationAmounts = Schema.encodeEffect(SubagentReservationAmounts);
|
|
859
|
+
const toNatural = (value) => Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;
|
|
860
|
+
const observedUsageFromDelta = (delta) => SubagentObservedUsage.make({
|
|
861
|
+
turns: delta.modelCalls,
|
|
862
|
+
toolCalls: toNatural(delta.toolCalls),
|
|
863
|
+
inputTokens: toNatural(delta.inputTokens),
|
|
864
|
+
outputTokens: toNatural(delta.outputTokens),
|
|
865
|
+
costMicrousd: toNatural(delta.costMicrousd)
|
|
866
|
+
});
|
|
867
|
+
/** A child that never started consumed nothing; observing zeros releases everything. */
|
|
868
|
+
const neverStartedUsage = SubagentObservedUsage.make({
|
|
869
|
+
turns: 0,
|
|
870
|
+
toolCalls: 0,
|
|
871
|
+
durationMillis: 0,
|
|
872
|
+
inputTokens: 0,
|
|
873
|
+
outputTokens: 0,
|
|
874
|
+
costMicrousd: 0,
|
|
875
|
+
resultBytes: 0
|
|
876
|
+
});
|
|
877
|
+
/**
|
|
878
|
+
* Finalizer-driven settlement: observe honest final usage, then release the
|
|
879
|
+
* unused allocation exactly once. Runs on every handler exit path — success,
|
|
880
|
+
* declared failure, interruption, and defect — through the reservation's
|
|
881
|
+
* `Effect.acquireRelease`; a missing reservation after a successful reserve
|
|
882
|
+
* is a ledger invariant violation and therefore a defect.
|
|
883
|
+
*/
|
|
884
|
+
const settleReservation = (reservations, reservationId, startedAt, conservative) => Effect.gen(function* () {
|
|
885
|
+
const started = yield* Ref.get(startedAt);
|
|
886
|
+
if (started === void 0) yield* reservations.observe(reservationId, neverStartedUsage);
|
|
887
|
+
else {
|
|
888
|
+
const now = yield* Clock.currentTimeMillis;
|
|
889
|
+
yield* reservations.observe(reservationId, SubagentObservedUsage.make({ durationMillis: Math.max(0, Math.floor(now - started)) }));
|
|
890
|
+
}
|
|
891
|
+
if (started !== void 0 && conservative !== void 0) {
|
|
892
|
+
const own = (yield* reservations.parentSnapshot(conservative.parentRunId)).reservations.find((entry) => entry.reservationId === reservationId);
|
|
893
|
+
if (own === void 0) return yield* Effect.die("Missing subtree reservation during finalization");
|
|
894
|
+
const additional = (key) => Math.max(0, conservative.allocation[key] - (own.observedConsumed[key] ?? 0));
|
|
895
|
+
yield* reservations.observe(reservationId, SubagentObservedUsage.make({
|
|
896
|
+
turns: additional("turns"),
|
|
897
|
+
toolCalls: additional("toolCalls"),
|
|
898
|
+
durationMillis: additional("durationMillis"),
|
|
899
|
+
inputTokens: additional("inputTokens"),
|
|
900
|
+
outputTokens: additional("outputTokens"),
|
|
901
|
+
costMicrousd: additional("costMicrousd"),
|
|
902
|
+
resultBytes: additional("resultBytes")
|
|
903
|
+
}));
|
|
904
|
+
}
|
|
905
|
+
yield* reservations.release(reservationId);
|
|
906
|
+
}).pipe(Effect.orDie);
|
|
907
|
+
/**
|
|
908
|
+
* Module-private provenance wrapper (SUB-033 hardening): ONLY the operations
|
|
909
|
+
* that can genuinely produce the engine signals wrap them here, so
|
|
910
|
+
* containment classification never trusts the runtime identity of classes an
|
|
911
|
+
* author could declare in their own failure Schema — a spoofed
|
|
912
|
+
* `ToolCallWaiting` in author data is contained as data, never rethrown as a
|
|
913
|
+
* suspension signal.
|
|
914
|
+
*/
|
|
915
|
+
var GenuineEngineSignal = class {
|
|
916
|
+
_tag = "GenuineEngineSignal";
|
|
917
|
+
signal;
|
|
918
|
+
constructor(signal) {
|
|
919
|
+
this.signal = signal;
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
const wrapEngineSignal = (signal) => new GenuineEngineSignal(signal);
|
|
923
|
+
function layer(delegation, modelOrBinding, options = {}) {
|
|
924
|
+
const childBinding = modelOrBinding !== void 0 && "definition" in modelOrBinding ? modelOrBinding : {
|
|
925
|
+
definition: delegation.target,
|
|
926
|
+
model: modelOrBinding ?? Layer.effectContext(Effect.context())
|
|
927
|
+
};
|
|
928
|
+
if (childBinding.definition !== delegation.target) throw new Error("Subagent.layer requires the delegation's exact target Definition");
|
|
929
|
+
const resolvePolicy = (spawner) => resolveSubagentPolicy(delegation, spawner.policy, options.parentCaps, spawner.depth === 0 && spawner.budget === void 0 ? "root-attached" : "conserved");
|
|
930
|
+
const toolkit = Toolkit.make(delegation.tool);
|
|
931
|
+
const contained = delegation.failureMode === "return";
|
|
932
|
+
const encodeChildInput = Schema.encodeEffect(delegation.target.input);
|
|
933
|
+
const encodeSuccess = Schema.encodeEffect(delegation.success);
|
|
934
|
+
const decodeChildOutput = Schema.decodeUnknownEffect(delegation.target.output);
|
|
935
|
+
const encodeResultProjectionFailure = Schema.encodeEffect(Schema.Union([delegation.failure, SubagentProjectionFailure]));
|
|
936
|
+
const executionFailure = (classification, errorTag, message, child) => SubagentExecutionFailure.make({
|
|
937
|
+
delegationId: delegation.delegationId,
|
|
938
|
+
targetAgentId: delegation.target.id,
|
|
939
|
+
classification,
|
|
940
|
+
errorTag: boundedErrorTag(errorTag),
|
|
941
|
+
message: boundedEventText(message),
|
|
942
|
+
...child === void 0 ? {} : {
|
|
943
|
+
childThreadId: child.childThreadId,
|
|
944
|
+
childSubmissionId: child.childSubmissionId,
|
|
945
|
+
childRunId: child.childRunId
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
const prestartDenied = (reason, message) => SubagentPrestartDenied.make({
|
|
949
|
+
delegationId: delegation.delegationId,
|
|
950
|
+
targetAgentId: delegation.target.id,
|
|
951
|
+
reason,
|
|
952
|
+
message: boundedEventText(message)
|
|
953
|
+
});
|
|
954
|
+
const validateAttachedCall = Effect.fnUntraced(function* (callId) {
|
|
955
|
+
const spawner = yield* AgentSpawner;
|
|
956
|
+
const toolCallId = yield* Schema.decodeUnknownEffect(ToolCallId)(callId).pipe(Effect.orDie);
|
|
957
|
+
const grant = narrowSubagentGrant(delegation.grant, spawner.grant);
|
|
958
|
+
const depth = spawner.depth + 1;
|
|
959
|
+
if (depth > grant.maxDepth) return yield* prestartDenied("nested-delegation", "Delegation exceeds the inherited depth ceiling");
|
|
960
|
+
if (!(spawner.grant?.childLifetimes ?? ["attached", "background"]).includes("attached")) return yield* prestartDenied("grant-violation", "The inherited grant does not permit attached children");
|
|
961
|
+
return {
|
|
962
|
+
toolCallId,
|
|
963
|
+
grant,
|
|
964
|
+
depth
|
|
965
|
+
};
|
|
966
|
+
});
|
|
967
|
+
const prepareChildInput = Effect.fnUntraced(function* (parameters, toolCallId) {
|
|
968
|
+
const spawner = yield* AgentSpawner;
|
|
969
|
+
const prepared = yield* delegation.prepareInput(parameters, {
|
|
970
|
+
source: "tool",
|
|
971
|
+
delegationId: delegation.delegationId,
|
|
972
|
+
toolCallId,
|
|
973
|
+
parent: spawner.parent
|
|
974
|
+
});
|
|
975
|
+
return yield* encodeChildInput(prepared).pipe(Effect.mapError(() => SubagentProjectionFailure.make({
|
|
976
|
+
delegationId: delegation.delegationId,
|
|
977
|
+
stage: "input",
|
|
978
|
+
message: "Prepared child input did not satisfy the target Agent input Schema"
|
|
979
|
+
})));
|
|
980
|
+
});
|
|
981
|
+
const build = Effect.gen(function* () {
|
|
982
|
+
const captured = yield* Effect.context();
|
|
983
|
+
const invoke = Effect.fnUntraced(function* (parameters, handlerContext) {
|
|
984
|
+
const spawner = yield* AgentSpawner;
|
|
985
|
+
const resolved = resolvePolicy(spawner);
|
|
986
|
+
if (resolved === void 0) return yield* prestartDenied("budget-conflict", "An unbounded parent Run requires an explicit finite delegation policy");
|
|
987
|
+
const { policy, childPolicy, allocation } = resolved;
|
|
988
|
+
const caps = spawner.budget === void 0 ? resolved.caps : residualSubagentCaps(resolved.caps, spawner.policy, spawner.budget, spawner.budgetScope === "worker-run");
|
|
989
|
+
const sink = yield* RunEventSink;
|
|
990
|
+
const reservations = yield* SubagentReservations;
|
|
991
|
+
const { toolCallId, grant, depth } = yield* validateAttachedCall(handlerContext.toolCallId);
|
|
992
|
+
if (spawner.depth > 0 && spawner.budget === void 0) return yield* prestartDenied("budget-conflict", "Nested ephemeral delegation requires an inherited subtree reservation");
|
|
993
|
+
const encodedInput = yield* prepareChildInput(parameters, toolCallId);
|
|
994
|
+
const parentRunId = spawner.parent.runId;
|
|
995
|
+
yield* Effect.acquireRelease(reservations.registerParent(parentRunId, caps).pipe(Effect.catchTag("SubagentParentBudgetConflict", () => Effect.fail(prestartDenied("budget-conflict", "The parent Run is already registered with different delegation caps; supply shared parentCaps explicitly"))), Effect.asVoid), () => reservations.retireParent(parentRunId).pipe(Effect.orDie)).pipe(Scope.provide(spawner.scope));
|
|
996
|
+
const reservationId = makeBudgetReservationId(parentRunId, toolCallId);
|
|
997
|
+
const startedAt = yield* Ref.make(void 0);
|
|
998
|
+
yield* Effect.acquireRelease(reservations.reserve(SubagentReservationRequest.make({
|
|
999
|
+
parentRunId,
|
|
1000
|
+
parentToolCallId: toolCallId,
|
|
1001
|
+
allocation,
|
|
1002
|
+
...policy.descendantInvocations === void 0 ? {} : { descendantInvocations: policy.descendantInvocations }
|
|
1003
|
+
})).pipe(Effect.catchTags({
|
|
1004
|
+
SubagentReservationConflict: (conflict) => Effect.die(conflict),
|
|
1005
|
+
SubagentParentBudgetUnknown: (unknown) => Effect.die(unknown)
|
|
1006
|
+
})), () => settleReservation(reservations, reservationId, startedAt, (policy.descendantInvocations ?? 0) > 0 ? {
|
|
1007
|
+
parentRunId,
|
|
1008
|
+
allocation
|
|
1009
|
+
} : void 0));
|
|
1010
|
+
yield* reservations.acquireChildSlot(parentRunId, 1 + (policy.descendantInvocations ?? 0)).pipe(Effect.catchTag("SubagentParentBudgetUnknown", (unknown) => Effect.die(unknown)));
|
|
1011
|
+
const seededChild = options.child;
|
|
1012
|
+
const seededBudget = seededChild?.budget;
|
|
1013
|
+
const budget = {
|
|
1014
|
+
guard: seededBudget === void 0 ? (effect) => effect : (effect) => seededBudget.guard(effect),
|
|
1015
|
+
consume: (delta) => reservations.observe(reservationId, observedUsageFromDelta(delta)).pipe(Effect.orDie, Effect.andThen(seededBudget === void 0 ? Effect.void : seededBudget.consume(delta)))
|
|
1016
|
+
};
|
|
1017
|
+
const childStartedAt = yield* Clock.currentTimeMillis;
|
|
1018
|
+
const durationMillis = Math.max(0, Math.min(allocation.durationMillis, Math.floor(DateTime.toEpochMillis(spawner.durationDeadline) - childStartedAt - Duration.toMillis(policy.parentReserveDuration ?? Duration.zero))));
|
|
1019
|
+
if (durationMillis === 0) return yield* SubagentBudgetExhausted.make({
|
|
1020
|
+
parentRunId,
|
|
1021
|
+
dimension: "duration",
|
|
1022
|
+
limitValue: 0,
|
|
1023
|
+
observedValue: 0
|
|
1024
|
+
});
|
|
1025
|
+
const durationDeadlineMillis = childStartedAt + durationMillis;
|
|
1026
|
+
const durationDeadline = DateTime.makeUnsafe(durationDeadlineMillis);
|
|
1027
|
+
const childOptions = {
|
|
1028
|
+
...seededChild,
|
|
1029
|
+
durationDeadline: seededChild?.durationDeadline === void 0 ? durationDeadline : DateTime.min(durationDeadline, seededChild.durationDeadline),
|
|
1030
|
+
subagentGrant: grant,
|
|
1031
|
+
delegationDepth: depth,
|
|
1032
|
+
subagentBudget: SubagentBudgetReservation.make({
|
|
1033
|
+
caps,
|
|
1034
|
+
allocation,
|
|
1035
|
+
...policy.descendantInvocations === void 0 ? {} : { descendantInvocations: policy.descendantInvocations }
|
|
1036
|
+
}),
|
|
1037
|
+
budget,
|
|
1038
|
+
toolCallAllowance: childPolicy.maxToolCalls
|
|
1039
|
+
};
|
|
1040
|
+
yield* Ref.set(startedAt, childStartedAt);
|
|
1041
|
+
const childScope = yield* Scope.make();
|
|
1042
|
+
yield* Effect.addFinalizer((exit) => Scope.close(childScope, exit));
|
|
1043
|
+
const child = yield* spawner.spawn({
|
|
1044
|
+
...childBinding,
|
|
1045
|
+
definition: {
|
|
1046
|
+
...childBinding.definition,
|
|
1047
|
+
policy: childPolicy
|
|
1048
|
+
}
|
|
1049
|
+
}, encodedInput, {
|
|
1050
|
+
delegationId: delegation.delegationId,
|
|
1051
|
+
parentToolCallId: toolCallId
|
|
1052
|
+
}, childOptions).pipe(Scope.provide(childScope));
|
|
1053
|
+
const payload = {
|
|
1054
|
+
toolCallId,
|
|
1055
|
+
delegationId: delegation.delegationId,
|
|
1056
|
+
childThreadId: child.threadId,
|
|
1057
|
+
childRunId: child.runId,
|
|
1058
|
+
targetAgentId: delegation.target.id,
|
|
1059
|
+
depth: child.parentLink.depth
|
|
1060
|
+
};
|
|
1061
|
+
const emit = (event) => sink.emit(event).pipe(Effect.orDie);
|
|
1062
|
+
yield* emit({
|
|
1063
|
+
_tag: "SubagentRequested",
|
|
1064
|
+
...payload
|
|
1065
|
+
});
|
|
1066
|
+
yield* emit({
|
|
1067
|
+
_tag: "SubagentStarted",
|
|
1068
|
+
...payload
|
|
1069
|
+
});
|
|
1070
|
+
return yield* Effect.gen(function* () {
|
|
1071
|
+
const result = yield* child.await.pipe(Effect.catch((childFailure) => Effect.gen(function* () {
|
|
1072
|
+
if (isDurationPolicyError(childFailure) && (yield* Clock.currentTimeMillis) >= durationDeadlineMillis) return;
|
|
1073
|
+
const report = yield* child.usageReport;
|
|
1074
|
+
yield* emit({
|
|
1075
|
+
_tag: "SubagentFailed",
|
|
1076
|
+
...payload,
|
|
1077
|
+
...report,
|
|
1078
|
+
errorTag: errorTagOf(childFailure),
|
|
1079
|
+
message: boundedEventText(errorMessageOf(childFailure))
|
|
1080
|
+
});
|
|
1081
|
+
return yield* Effect.fail(options.mapChildFailure === void 0 ? executionFailure("child-failed", errorTagOf(childFailure), "The child Run failed") : options.mapChildFailure(childFailure));
|
|
1082
|
+
})), Effect.timeoutOrElse({
|
|
1083
|
+
duration: Math.max(0, durationDeadlineMillis - (yield* Clock.currentTimeMillis)),
|
|
1084
|
+
orElse: () => Effect.as(Effect.void, void 0)
|
|
1085
|
+
}), Effect.tapCause((cause) => Cause.hasDies(cause) ? child.usageReport.pipe(Effect.flatMap((report) => emit({
|
|
1086
|
+
_tag: "SubagentFailed",
|
|
1087
|
+
...payload,
|
|
1088
|
+
...report,
|
|
1089
|
+
errorTag: "Defect",
|
|
1090
|
+
message: "The child Run ended with a defect"
|
|
1091
|
+
})), Effect.ignore) : Effect.void));
|
|
1092
|
+
if (result === void 0) {
|
|
1093
|
+
yield* Scope.close(childScope, Exit.void);
|
|
1094
|
+
const report = yield* child.usageReport;
|
|
1095
|
+
yield* emit({
|
|
1096
|
+
_tag: "SubagentFailed",
|
|
1097
|
+
...payload,
|
|
1098
|
+
...report,
|
|
1099
|
+
errorTag: "SubagentBudgetExhausted",
|
|
1100
|
+
message: `Attached child exceeded its ${durationMillis}ms delegation duration budget`
|
|
1101
|
+
});
|
|
1102
|
+
return yield* SubagentBudgetExhausted.make({
|
|
1103
|
+
parentRunId,
|
|
1104
|
+
dimension: "duration",
|
|
1105
|
+
limitValue: durationMillis,
|
|
1106
|
+
observedValue: durationMillis
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
const report = yield* child.usageReport;
|
|
1110
|
+
yield* emit({
|
|
1111
|
+
_tag: "SubagentCompleted",
|
|
1112
|
+
...payload,
|
|
1113
|
+
...report,
|
|
1114
|
+
turns: result.turns,
|
|
1115
|
+
finishReason: result.finishReason,
|
|
1116
|
+
...result.exhausted !== void 0 ? { exhausted: result.exhausted } : {}
|
|
1117
|
+
});
|
|
1118
|
+
const projected = yield* delegation.projectResult(result.output, {
|
|
1119
|
+
budgetExhausted: result.finishReason === "budget-exhausted",
|
|
1120
|
+
...report
|
|
1121
|
+
}, parameters);
|
|
1122
|
+
const encodedResult = yield* encodeSuccess(projected).pipe(Effect.mapError(() => SubagentProjectionFailure.make({
|
|
1123
|
+
delegationId: delegation.delegationId,
|
|
1124
|
+
stage: "result",
|
|
1125
|
+
message: "Projected child result did not satisfy the delegation success Schema"
|
|
1126
|
+
})));
|
|
1127
|
+
const resultBytes = utf8ByteLength(JSON.stringify(encodedResult) ?? "");
|
|
1128
|
+
yield* reservations.observe(reservationId, SubagentObservedUsage.make({ resultBytes })).pipe(Effect.orDie);
|
|
1129
|
+
if (policy.maxResultBytes !== void 0 && resultBytes > policy.maxResultBytes) {
|
|
1130
|
+
yield* emit({
|
|
1131
|
+
_tag: "SubagentFailed",
|
|
1132
|
+
...payload,
|
|
1133
|
+
...report,
|
|
1134
|
+
errorTag: "SubagentBudgetExhausted",
|
|
1135
|
+
message: `Projected child result of ${resultBytes} bytes exceeds the ${policy.maxResultBytes}-byte delegation budget`
|
|
1136
|
+
});
|
|
1137
|
+
return yield* SubagentBudgetExhausted.make({
|
|
1138
|
+
parentRunId,
|
|
1139
|
+
dimension: "result-bytes",
|
|
1140
|
+
limitValue: policy.maxResultBytes,
|
|
1141
|
+
observedValue: resultBytes
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
yield* emit({
|
|
1145
|
+
_tag: "SubagentJoined",
|
|
1146
|
+
...payload,
|
|
1147
|
+
...report
|
|
1148
|
+
});
|
|
1149
|
+
return projected;
|
|
1150
|
+
}).pipe(Effect.onInterrupt(() => Scope.close(childScope, Exit.void).pipe(Effect.andThen(child.usageReport), Effect.flatMap((report) => sink.emit({
|
|
1151
|
+
_tag: "SubagentInterrupted",
|
|
1152
|
+
...payload,
|
|
1153
|
+
...report,
|
|
1154
|
+
reason: "Parent Run interrupted the attached child before it settled"
|
|
1155
|
+
})), Effect.ignore)));
|
|
1156
|
+
});
|
|
1157
|
+
/**
|
|
1158
|
+
* Durable branch: establishment through the
|
|
1159
|
+
* coordinator's idempotent protocol instead of an in-process spawn. No
|
|
1160
|
+
* child fiber ever starts here, and the S1 in-memory reservation service
|
|
1161
|
+
* is deliberately not consulted — its Scope-finalizer settlement
|
|
1162
|
+
* contradicts a handler that exits with the waiting signal while the
|
|
1163
|
+
* child keeps running; durable budget lives in the coordinator's fenced
|
|
1164
|
+
* ledger reservation built from `encodedAllocation`.
|
|
1165
|
+
*/
|
|
1166
|
+
const invokeDurable = Effect.fnUntraced(function* (parameters, handlerContext, durability) {
|
|
1167
|
+
const spawner = yield* AgentSpawner;
|
|
1168
|
+
const resolved = resolvePolicy(spawner);
|
|
1169
|
+
if (resolved === void 0) return yield* prestartDenied("budget-conflict", "An unbounded parent Run requires an explicit finite delegation policy");
|
|
1170
|
+
const { policy, childPolicy, allocation, caps } = resolved;
|
|
1171
|
+
const encodedAllocation = yield* encodeAllocationAmounts(allocation).pipe(Effect.orDie);
|
|
1172
|
+
const conservativeAccounting = yield* encodeDurableAccounting(SubagentDurableAccounting.make({
|
|
1173
|
+
allocation,
|
|
1174
|
+
consumed: allocation,
|
|
1175
|
+
released: zeroReservationAmounts,
|
|
1176
|
+
basis: "reserved-conservative"
|
|
1177
|
+
})).pipe(Effect.orDie);
|
|
1178
|
+
const sink = yield* RunEventSink;
|
|
1179
|
+
const { toolCallId, grant, depth } = yield* validateAttachedCall(handlerContext.toolCallId);
|
|
1180
|
+
const emit = (event) => sink.emit(event).pipe(Effect.orDie);
|
|
1181
|
+
const encodedGrant = yield* encodeGrant(grant).pipe(Effect.orDie);
|
|
1182
|
+
const encodedInput = yield* prepareChildInput(parameters, toolCallId);
|
|
1183
|
+
const status = yield* Effect.mapError(wrapEngineSignal)(durability.establish({
|
|
1184
|
+
toolCallId,
|
|
1185
|
+
delegationId: delegation.delegationId,
|
|
1186
|
+
target: delegation.target,
|
|
1187
|
+
targetAgentId: delegation.target.id,
|
|
1188
|
+
depth,
|
|
1189
|
+
encodedChildInput: encodedInput,
|
|
1190
|
+
encodedGrant,
|
|
1191
|
+
encodedAllocation,
|
|
1192
|
+
toolCallAllowance: childPolicy.maxToolCalls,
|
|
1193
|
+
policy: childPolicy,
|
|
1194
|
+
budget: {
|
|
1195
|
+
caps,
|
|
1196
|
+
allocation,
|
|
1197
|
+
...policy.descendantInvocations === void 0 ? {} : { descendantInvocations: policy.descendantInvocations }
|
|
1198
|
+
}
|
|
1199
|
+
}));
|
|
1200
|
+
switch (status._tag) {
|
|
1201
|
+
case "denied": return yield* executionFailure("establishment-denied", status.errorTag, status.message);
|
|
1202
|
+
case "waiting": {
|
|
1203
|
+
const payload = {
|
|
1204
|
+
toolCallId,
|
|
1205
|
+
delegationId: delegation.delegationId,
|
|
1206
|
+
childThreadId: status.childThreadId,
|
|
1207
|
+
childRunId: status.childRunId,
|
|
1208
|
+
targetAgentId: delegation.target.id,
|
|
1209
|
+
depth
|
|
1210
|
+
};
|
|
1211
|
+
yield* emit({
|
|
1212
|
+
_tag: "SubagentRequested",
|
|
1213
|
+
...payload
|
|
1214
|
+
});
|
|
1215
|
+
yield* emit({
|
|
1216
|
+
_tag: "SubagentStarted",
|
|
1217
|
+
...payload
|
|
1218
|
+
});
|
|
1219
|
+
return yield* Effect.mapError(wrapEngineSignal)(durability.waiting(toolCallId, status));
|
|
1220
|
+
}
|
|
1221
|
+
case "settled": {
|
|
1222
|
+
const payload = {
|
|
1223
|
+
toolCallId,
|
|
1224
|
+
delegationId: delegation.delegationId,
|
|
1225
|
+
childThreadId: status.childThreadId,
|
|
1226
|
+
childRunId: status.childRunId,
|
|
1227
|
+
targetAgentId: delegation.target.id,
|
|
1228
|
+
depth
|
|
1229
|
+
};
|
|
1230
|
+
const report = RunUsageReport.make({
|
|
1231
|
+
usage: status.usage ?? unknownRunTotals(),
|
|
1232
|
+
delegatedUsage: status.delegatedUsage ?? unknownRunTotals()
|
|
1233
|
+
});
|
|
1234
|
+
const settleFailure = (failure, encodedFailure) => emit({
|
|
1235
|
+
_tag: "SubagentFailed",
|
|
1236
|
+
...payload,
|
|
1237
|
+
...report,
|
|
1238
|
+
errorTag: errorTagOf(failure),
|
|
1239
|
+
message: boundedEventText(errorMessageOf(failure))
|
|
1240
|
+
}).pipe(Effect.andThen(Effect.mapError(wrapEngineSignal)(durability.join({
|
|
1241
|
+
toolCallId,
|
|
1242
|
+
encodedResult: encodedFailure,
|
|
1243
|
+
isFailure: !contained,
|
|
1244
|
+
encodedAccounting: conservativeAccounting
|
|
1245
|
+
}))), Effect.andThen(Effect.fail(failure)));
|
|
1246
|
+
if (status.outcome !== "completed") {
|
|
1247
|
+
const projection = childFailureProjectionOf(status.encodedResult);
|
|
1248
|
+
const failure = executionFailure(status.outcome === "aborted" ? "child-aborted" : projection.errorTag === "ChildCompatibilityFailure" ? "child-compatibility" : "child-failed", projection.errorTag, projection.message, status);
|
|
1249
|
+
return yield* settleFailure(failure, yield* encodeExecutionFailure(failure).pipe(Effect.orDie));
|
|
1250
|
+
}
|
|
1251
|
+
const decoded = yield* decodeChildOutput(status.encodedResult).pipe(Effect.catch(() => {
|
|
1252
|
+
const failure = SubagentProjectionFailure.make({
|
|
1253
|
+
delegationId: delegation.delegationId,
|
|
1254
|
+
stage: "result",
|
|
1255
|
+
message: "Settled child output did not satisfy the target Agent output Schema"
|
|
1256
|
+
});
|
|
1257
|
+
return encodeProjectionFailure(failure).pipe(Effect.orDie, Effect.flatMap((encodedFailure) => settleFailure(failure, encodedFailure)));
|
|
1258
|
+
}));
|
|
1259
|
+
const projected = yield* delegation.projectResult(decoded, {
|
|
1260
|
+
budgetExhausted: status.finishReason === "budget-exhausted",
|
|
1261
|
+
...report
|
|
1262
|
+
}, parameters).pipe(Effect.catch((declared) => encodeResultProjectionFailure(declared).pipe(Effect.orDie, Effect.flatMap((encodedFailure) => settleFailure(declared, encodedFailure)))));
|
|
1263
|
+
const encodedResult = yield* encodeSuccess(projected).pipe(Effect.catch(() => {
|
|
1264
|
+
const failure = SubagentProjectionFailure.make({
|
|
1265
|
+
delegationId: delegation.delegationId,
|
|
1266
|
+
stage: "result",
|
|
1267
|
+
message: "Projected child result did not satisfy the delegation success Schema"
|
|
1268
|
+
});
|
|
1269
|
+
return encodeProjectionFailure(failure).pipe(Effect.orDie, Effect.flatMap((encodedFailure) => settleFailure(failure, encodedFailure)));
|
|
1270
|
+
}));
|
|
1271
|
+
const resultBytes = utf8ByteLength(JSON.stringify(encodedResult) ?? "");
|
|
1272
|
+
if (policy.maxResultBytes !== void 0 && resultBytes > policy.maxResultBytes) {
|
|
1273
|
+
const failure = SubagentBudgetExhausted.make({
|
|
1274
|
+
parentRunId: spawner.parent.runId,
|
|
1275
|
+
dimension: "result-bytes",
|
|
1276
|
+
limitValue: policy.maxResultBytes,
|
|
1277
|
+
observedValue: resultBytes
|
|
1278
|
+
});
|
|
1279
|
+
return yield* settleFailure(failure, yield* encodeBudgetFailure(failure).pipe(Effect.orDie));
|
|
1280
|
+
}
|
|
1281
|
+
yield* Effect.mapError(wrapEngineSignal)(durability.join({
|
|
1282
|
+
toolCallId,
|
|
1283
|
+
encodedResult,
|
|
1284
|
+
isFailure: false,
|
|
1285
|
+
encodedAccounting: conservativeAccounting
|
|
1286
|
+
}));
|
|
1287
|
+
yield* emit({
|
|
1288
|
+
_tag: "SubagentJoined",
|
|
1289
|
+
...payload,
|
|
1290
|
+
...report
|
|
1291
|
+
});
|
|
1292
|
+
return projected;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
const containSignals = (failure) => failure instanceof GenuineEngineSignal ? Effect.fail(failure.signal) : Effect.succeed(failure);
|
|
1297
|
+
const unwrapSignals = (failure) => failure instanceof GenuineEngineSignal ? failure.signal : failure;
|
|
1298
|
+
const handler = Effect.fnUntraced(function* (parameters, handlerContext) {
|
|
1299
|
+
const spawner = yield* AgentSpawner;
|
|
1300
|
+
const sink = yield* RunEventSink;
|
|
1301
|
+
const durability = yield* SubagentDurability;
|
|
1302
|
+
if (durability.mode === "durable") {
|
|
1303
|
+
const durable = invokeDurable(parameters, handlerContext, durability).pipe(Effect.scoped, Effect.provideService(AgentSpawner, spawner), Effect.provideService(RunEventSink, sink), Effect.provideService(SubagentDurability, durability), Effect.provide(captured));
|
|
1304
|
+
return yield* contained ? durable.pipe(Effect.catch(containSignals)) : durable.pipe(Effect.mapError(unwrapSignals));
|
|
1305
|
+
}
|
|
1306
|
+
const ephemeral = invoke(parameters, handlerContext).pipe(Effect.scoped, Effect.provideService(AgentSpawner, spawner), Effect.provideService(RunEventSink, sink), Effect.provideService(SubagentDurability, durability), Effect.provide(captured));
|
|
1307
|
+
return yield* contained ? ephemeral.pipe(Effect.catch(containSignals)) : ephemeral.pipe(Effect.mapError(unwrapSignals));
|
|
1308
|
+
});
|
|
1309
|
+
return { [delegation.name]: handler };
|
|
1310
|
+
});
|
|
1311
|
+
return toolkit.toLayer(build);
|
|
1312
|
+
}
|
|
1313
|
+
export { summaryTool as S, listTool as _, make as a, startTool as b, WorkerObservation as c, cancelTool as d, followUp as f, list as g, inspectTool as h, layer as i, awaitWorker as l, inspect as m, SubagentResult as n, reporting as o, followUpTool as p, Subagent_exports as r, Worker as s, SubagentDurableAccounting as t, cancel as u, observe as v, stop as x, start as y };
|
|
1314
|
+
|
|
1315
|
+
//# sourceMappingURL=Subagent-BJJN6n0E.mjs.map
|