effect-agent 0.1.0-beta.85 → 0.1.0-beta.87
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/dist/Agent-CN0EWRsR.d.mts +226 -0
- package/dist/Agent-RklVROrm.mjs +83 -0
- package/dist/Agent-RklVROrm.mjs.map +1 -0
- package/dist/AgentError-CggcAQ7V.d.mts +101 -0
- package/dist/AgentPolicy-CetmQrf3.d.mts +96 -0
- package/dist/AgentRuntime-BLyETCPo.mjs +4562 -0
- package/dist/AgentRuntime-BLyETCPo.mjs.map +1 -0
- package/dist/AgentRuntime-uxR_a4VM.d.mts +346 -0
- package/dist/AgentUpdates-DMJ-_xow.d.mts +53 -0
- package/dist/ContextCompactor-Dxu5zhOL.d.mts +161 -0
- package/dist/ContextWindow-DRQ5Mbm2.d.mts +58 -0
- package/dist/DurableAgentRuntime-uggeJpv3.mjs +6368 -0
- package/dist/DurableAgentRuntime-uggeJpv3.mjs.map +1 -0
- package/dist/DurableFailpoint-Oinuuedm.d.mts +41 -0
- package/dist/DurableStep-Cry_iol4.d.mts +103 -0
- package/dist/Ephemeral.d.mts +22 -0
- package/dist/Ephemeral.mjs +22 -0
- package/dist/Ephemeral.mjs.map +1 -0
- package/dist/EventSource-OqS_P9ug.d.mts +51 -0
- package/dist/Identifiers-CN2s30fF.d.mts +40 -0
- package/dist/MemoryNamespace-BbRW5p71.d.mts +36 -0
- package/dist/MemoryReference-B8Q3UJoJ.d.mts +79 -0
- package/dist/Messaging-CkcIdt4I.d.mts +490 -0
- package/dist/MessagingHost-CRk0kXzT.d.mts +246 -0
- package/dist/MessagingHost-CWi_PP3g.mjs +137 -0
- package/dist/MessagingHost-CWi_PP3g.mjs.map +1 -0
- package/dist/OperationAuthorizer-TzcQtpX5.d.mts +61 -0
- package/dist/Output-D6SkedVx.d.mts +25 -0
- package/dist/PageCapture-Df8Xwskw.d.mts +583 -0
- package/dist/PageScreenshot-BpgZKAxl.d.mts +48 -0
- package/dist/PreparedInputAdmission-C4HbjHgl.d.mts +38 -0
- package/dist/Receipt-BAHyigAF.d.mts +33 -0
- package/dist/Records-BAGkekt8.d.mts +3570 -0
- package/dist/RunEvent-DIrzkjLr.d.mts +460 -0
- package/dist/RunEventSink-D5aVhISG.d.mts +108 -0
- package/dist/RunJournal-Cgg1kNvc.mjs +825 -0
- package/dist/RunJournal-Cgg1kNvc.mjs.map +1 -0
- package/dist/RunOptions-g1aigcKI.d.mts +915 -0
- package/dist/RunPolicyUsage-ClZxyR46.d.mts +21 -0
- package/dist/Sandbox-CEsDWBLq.d.mts +173 -0
- package/dist/Schedule-H3SEYX9g.d.mts +842 -0
- package/dist/Scheduling-C9aIP8zT.mjs +691 -0
- package/dist/Scheduling-C9aIP8zT.mjs.map +1 -0
- package/dist/Subagent-Cy_hU1tv.mjs +1469 -0
- package/dist/Subagent-Cy_hU1tv.mjs.map +1 -0
- package/dist/Subagent-DyfzHNdv.d.mts +826 -0
- package/dist/SubagentContract-DdT7Cqe6.d.mts +116 -0
- package/dist/SubagentHost-CJUBQlcc.d.mts +140 -0
- package/dist/Subscription-BEP8oQO5.d.mts +921 -0
- package/dist/SubscriptionInput-vAAOBrK7.d.mts +41 -0
- package/dist/Thread-DOBQ0QUY.d.mts +96 -0
- package/dist/ThreadHistory-tS1KwxHR.d.mts +60 -0
- package/dist/ToolBroker-DWs4tZra.d.mts +133 -0
- package/dist/ToolExposure-9uF_Yo0T.mjs +10 -0
- package/dist/ToolExposure-9uF_Yo0T.mjs.map +1 -0
- package/dist/ToolExposure-C93U1sPu.mjs +30 -0
- package/dist/ToolExposure-C93U1sPu.mjs.map +1 -0
- package/dist/ToolExposure-UCN12eCd.d.mts +39 -0
- package/dist/ToolExposure-r2eOWk4F.d.mts +46 -0
- package/dist/ToolExposure.d.mts +6 -5
- package/dist/ToolExposure.mjs +17 -9
- package/dist/ToolExposure.mjs.map +1 -1
- package/dist/ToolReconciler-DQVaJfpE.d.mts +76 -0
- package/dist/ToolResult-DmmgoChv.d.mts +61 -0
- package/dist/Usage-Dx0aknfk.d.mts +121 -0
- package/dist/WakeScheduler-EjUF-GhC.d.mts +56 -0
- package/dist/Worker-CaPYykpe.d.mts +228 -0
- package/dist/agent-registration-CWDMOAZA.mjs +172 -0
- package/dist/agent-registration-CWDMOAZA.mjs.map +1 -0
- package/dist/capabilities/Approval.d.mts +114 -0
- package/dist/capabilities/Approval.mjs +226 -0
- package/dist/capabilities/Approval.mjs.map +1 -0
- package/dist/capabilities/Budget.d.mts +112 -0
- package/dist/capabilities/Budget.mjs +346 -0
- package/dist/capabilities/Budget.mjs.map +1 -0
- package/dist/capabilities/CodeMode.d.mts +157 -0
- package/dist/capabilities/CodeMode.mjs +522 -0
- package/dist/capabilities/CodeMode.mjs.map +1 -0
- package/dist/capabilities/Commands.d.mts +55 -0
- package/dist/capabilities/Commands.mjs +57 -0
- package/dist/capabilities/Commands.mjs.map +1 -0
- package/dist/capabilities/ContextTools.d.mts +321 -0
- package/dist/capabilities/ContextTools.mjs +126 -0
- package/dist/capabilities/ContextTools.mjs.map +1 -0
- package/dist/capabilities/Mcp.d.mts +108 -0
- package/dist/capabilities/Mcp.mjs +260 -0
- package/dist/capabilities/Mcp.mjs.map +1 -0
- package/dist/capabilities/McpClient.d.mts +115 -0
- package/dist/capabilities/McpClient.mjs +506 -0
- package/dist/capabilities/McpClient.mjs.map +1 -0
- package/dist/capabilities/MemoryNotes.d.mts +424 -0
- package/dist/capabilities/MemoryNotes.mjs +128 -0
- package/dist/capabilities/MemoryNotes.mjs.map +1 -0
- package/dist/capabilities/Messaging.d.mts +3 -0
- package/dist/capabilities/Messaging.mjs +151 -0
- package/dist/capabilities/Messaging.mjs.map +1 -0
- package/dist/capabilities/ModelContext.d.mts +89 -0
- package/dist/capabilities/ModelContext.mjs +168 -0
- package/dist/capabilities/ModelContext.mjs.map +1 -0
- package/dist/capabilities/Redaction.d.mts +37 -0
- package/dist/capabilities/Redaction.mjs +104 -0
- package/dist/capabilities/Redaction.mjs.map +1 -0
- package/dist/capabilities/Remembering.d.mts +434 -0
- package/dist/capabilities/Remembering.mjs +290 -0
- package/dist/capabilities/Remembering.mjs.map +1 -0
- package/dist/capabilities/RunHooks.d.mts +82 -0
- package/dist/capabilities/RunHooks.mjs +144 -0
- package/dist/capabilities/RunHooks.mjs.map +1 -0
- package/dist/capabilities/SemanticMemory.d.mts +431 -0
- package/dist/capabilities/SemanticMemory.mjs +315 -0
- package/dist/capabilities/SemanticMemory.mjs.map +1 -0
- package/dist/capabilities/Subagent.d.mts +4 -0
- package/dist/capabilities/Subagent.mjs +5 -0
- package/dist/capabilities/SubagentReservations.d.mts +186 -0
- package/dist/capabilities/SubagentReservations.mjs +479 -0
- package/dist/capabilities/SubagentReservations.mjs.map +1 -0
- package/dist/capabilities/ToolDiscovery.d.mts +109 -0
- package/dist/capabilities/ToolDiscovery.mjs +211 -0
- package/dist/capabilities/ToolDiscovery.mjs.map +1 -0
- package/dist/capabilities/WebCapture.d.mts +163 -0
- package/dist/capabilities/WebCapture.mjs +335 -0
- package/dist/capabilities/WebCapture.mjs.map +1 -0
- package/dist/capabilities/WebSearch.d.mts +71 -0
- package/dist/capabilities/WebSearch.mjs +112 -0
- package/dist/capabilities/WebSearch.mjs.map +1 -0
- package/dist/compaction-C2OTceKw.mjs +505 -0
- package/dist/compaction-C2OTceKw.mjs.map +1 -0
- package/dist/core/Agent.d.mts +2 -0
- package/dist/core/Agent.mjs +2 -0
- package/dist/core/AgentError.d.mts +2 -0
- package/dist/core/AgentError.mjs +117 -0
- package/dist/core/AgentError.mjs.map +1 -0
- package/dist/core/AgentPolicy.d.mts +2 -0
- package/dist/core/AgentPolicy.mjs +94 -0
- package/dist/core/AgentPolicy.mjs.map +1 -0
- package/dist/core/AgentUpdates.d.mts +2 -0
- package/dist/core/AgentUpdates.mjs +63 -0
- package/dist/core/AgentUpdates.mjs.map +1 -0
- package/dist/core/IdGenerator.d.mts +26 -0
- package/dist/core/IdGenerator.mjs +27 -0
- package/dist/core/IdGenerator.mjs.map +1 -0
- package/dist/core/Identifiers.d.mts +2 -0
- package/dist/core/Identifiers.mjs +43 -0
- package/dist/core/Identifiers.mjs.map +1 -0
- package/dist/core/Memory.d.mts +57 -0
- package/dist/core/Memory.mjs +203 -0
- package/dist/core/Memory.mjs.map +1 -0
- package/dist/core/MemoryNamespace.d.mts +2 -0
- package/dist/core/MemoryNamespace.mjs +116 -0
- package/dist/core/MemoryNamespace.mjs.map +1 -0
- package/dist/core/MemoryReference.d.mts +2 -0
- package/dist/core/MemoryReference.mjs +109 -0
- package/dist/core/MemoryReference.mjs.map +1 -0
- package/dist/core/MemoryRevalidation.d.mts +65 -0
- package/dist/core/MemoryRevalidation.mjs +126 -0
- package/dist/core/MemoryRevalidation.mjs.map +1 -0
- package/dist/core/MemoryStore.d.mts +186 -0
- package/dist/core/MemoryStore.mjs +243 -0
- package/dist/core/MemoryStore.mjs.map +1 -0
- package/dist/core/Receipt.d.mts +2 -0
- package/dist/core/Receipt.mjs +36 -0
- package/dist/core/Receipt.mjs.map +1 -0
- package/dist/core/RememberingStore.d.mts +1562 -0
- package/dist/core/RememberingStore.mjs +190 -0
- package/dist/core/RememberingStore.mjs.map +1 -0
- package/dist/core/RunEvent.d.mts +2 -0
- package/dist/core/RunEvent.mjs +337 -0
- package/dist/core/RunEvent.mjs.map +1 -0
- package/dist/core/RunPolicyUsage.d.mts +2 -0
- package/dist/core/RunPolicyUsage.mjs +21 -0
- package/dist/core/RunPolicyUsage.mjs.map +1 -0
- package/dist/core/SemanticMemoryIndex.d.mts +826 -0
- package/dist/core/SemanticMemoryIndex.mjs +185 -0
- package/dist/core/SemanticMemoryIndex.mjs.map +1 -0
- package/dist/core/SemanticMemoryRevalidation.d.mts +45 -0
- package/dist/core/SemanticMemoryRevalidation.mjs +191 -0
- package/dist/core/SemanticMemoryRevalidation.mjs.map +1 -0
- package/dist/core/SubagentContract.d.mts +2 -0
- package/dist/core/SubagentContract.mjs +148 -0
- package/dist/core/SubagentContract.mjs.map +1 -0
- package/dist/core/Thread.d.mts +2 -0
- package/dist/core/Thread.mjs +250 -0
- package/dist/core/Thread.mjs.map +1 -0
- package/dist/core/ToolResult.d.mts +2 -0
- package/dist/core/ToolResult.mjs +140 -0
- package/dist/core/ToolResult.mjs.map +1 -0
- package/dist/core/Usage.d.mts +2 -0
- package/dist/core/Usage.mjs +319 -0
- package/dist/core/Usage.mjs.map +1 -0
- package/dist/core/Worker.d.mts +3 -0
- package/dist/core/Worker.mjs +147 -0
- package/dist/core/Worker.mjs.map +1 -0
- package/dist/durable/ActivityStore.d.mts +116 -0
- package/dist/durable/ActivityStore.mjs +131 -0
- package/dist/durable/ActivityStore.mjs.map +1 -0
- package/dist/durable/Admin.d.mts +2 -0
- package/dist/durable/Admin.mjs +328 -0
- package/dist/durable/Admin.mjs.map +1 -0
- package/dist/durable/AgentRegistration.d.mts +2 -0
- package/dist/durable/AgentRegistration.mjs +14 -0
- package/dist/durable/AgentRegistration.mjs.map +1 -0
- package/dist/durable/Certification.d.mts +111 -0
- package/dist/durable/Certification.mjs +159 -0
- package/dist/durable/Certification.mjs.map +1 -0
- package/dist/durable/CommittedActivity.d.mts +62 -0
- package/dist/durable/CommittedActivity.mjs +159 -0
- package/dist/durable/CommittedActivity.mjs.map +1 -0
- package/dist/durable/Digest.d.mts +2 -0
- package/dist/durable/Digest.mjs +50 -0
- package/dist/durable/Digest.mjs.map +1 -0
- package/dist/durable/DurableAgentRuntime.d.mts +3 -0
- package/dist/durable/DurableAgentRuntime.mjs +3 -0
- package/dist/durable/DurableFailpoint.d.mts +2 -0
- package/dist/durable/DurableFailpoint.mjs +94 -0
- package/dist/durable/DurableFailpoint.mjs.map +1 -0
- package/dist/durable/DurableFailpointTestControl.d.mts +15 -0
- package/dist/durable/DurableFailpointTestControl.mjs +19 -0
- package/dist/durable/DurableFailpointTestControl.mjs.map +1 -0
- package/dist/durable/EventSource.d.mts +2 -0
- package/dist/durable/EventSource.mjs +65 -0
- package/dist/durable/EventSource.mjs.map +1 -0
- package/dist/durable/GitHubWorkflowSource.d.mts +144 -0
- package/dist/durable/GitHubWorkflowSource.mjs +209 -0
- package/dist/durable/GitHubWorkflowSource.mjs.map +1 -0
- package/dist/durable/MessageDelivery.d.mts +492 -0
- package/dist/durable/MessageDelivery.mjs +495 -0
- package/dist/durable/MessageDelivery.mjs.map +1 -0
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +358 -0
- package/dist/durable/MessageDeliveryStoreConformance.mjs +243 -0
- package/dist/durable/MessageDeliveryStoreConformance.mjs.map +1 -0
- package/dist/durable/OperationAuthorizer.d.mts +2 -0
- package/dist/durable/OperationAuthorizer.mjs +70 -0
- package/dist/durable/OperationAuthorizer.mjs.map +1 -0
- package/dist/durable/PersistentHistory.d.mts +16 -0
- package/dist/durable/PersistentHistory.mjs +125 -0
- package/dist/durable/PersistentHistory.mjs.map +1 -0
- package/dist/durable/PreparedInputAdmission.d.mts +2 -0
- package/dist/durable/PreparedInputAdmission.mjs +34 -0
- package/dist/durable/PreparedInputAdmission.mjs.map +1 -0
- package/dist/durable/Records.d.mts +2 -0
- package/dist/durable/Records.mjs +795 -0
- package/dist/durable/Records.mjs.map +1 -0
- package/dist/durable/Recovery.d.mts +2 -0
- package/dist/durable/Recovery.mjs +739 -0
- package/dist/durable/Recovery.mjs.map +1 -0
- package/dist/durable/RunJournal.d.mts +2 -0
- package/dist/durable/RunJournal.mjs +2 -0
- package/dist/durable/Schedule.d.mts +2 -0
- package/dist/durable/Schedule.mjs +382 -0
- package/dist/durable/Schedule.mjs.map +1 -0
- package/dist/durable/ScheduleStoreConformance.d.mts +18 -0
- package/dist/durable/ScheduleStoreConformance.mjs +420 -0
- package/dist/durable/ScheduleStoreConformance.mjs.map +1 -0
- package/dist/durable/ScheduleTransition.d.mts +24 -0
- package/dist/durable/ScheduleTransition.mjs +180 -0
- package/dist/durable/ScheduleTransition.mjs.map +1 -0
- package/dist/durable/Scheduling.d.mts +54 -0
- package/dist/durable/Scheduling.mjs +2 -0
- package/dist/durable/SqlMemoryStore.d.mts +30 -0
- package/dist/durable/SqlMemoryStore.mjs +435 -0
- package/dist/durable/SqlMemoryStore.mjs.map +1 -0
- package/dist/durable/SqlMessageDeliveryStore.d.mts +40 -0
- package/dist/durable/SqlMessageDeliveryStore.mjs +167 -0
- package/dist/durable/SqlMessageDeliveryStore.mjs.map +1 -0
- package/dist/durable/SqlStorageV2Upgrade.d.mts +22 -0
- package/dist/durable/SqlStorageV2Upgrade.mjs +459 -0
- package/dist/durable/SqlStorageV2Upgrade.mjs.map +1 -0
- package/dist/durable/SqlSubscriptionStore.d.mts +63 -0
- package/dist/durable/SqlSubscriptionStore.mjs +751 -0
- package/dist/durable/SqlSubscriptionStore.mjs.map +1 -0
- package/dist/durable/SubmissionLedger.d.mts +3 -0
- package/dist/durable/SubmissionLedger.mjs +914 -0
- package/dist/durable/SubmissionLedger.mjs.map +1 -0
- package/dist/durable/SubmissionLedgerConformance.d.mts +30 -0
- package/dist/durable/SubmissionLedgerConformance.mjs +1986 -0
- package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -0
- package/dist/durable/SubmissionStatus.d.mts +2 -0
- package/dist/durable/SubmissionStatus.mjs +18 -0
- package/dist/durable/SubmissionStatus.mjs.map +1 -0
- package/dist/durable/Subscription.d.mts +2 -0
- package/dist/durable/Subscription.mjs +360 -0
- package/dist/durable/Subscription.mjs.map +1 -0
- package/dist/durable/SubscriptionInput.d.mts +2 -0
- package/dist/durable/SubscriptionInput.mjs +52 -0
- package/dist/durable/SubscriptionInput.mjs.map +1 -0
- package/dist/durable/SubscriptionStoreConformance.d.mts +17 -0
- package/dist/durable/SubscriptionStoreConformance.mjs +625 -0
- package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -0
- package/dist/durable/SubscriptionTools.d.mts +273 -0
- package/dist/durable/SubscriptionTools.mjs +190 -0
- package/dist/durable/SubscriptionTools.mjs.map +1 -0
- package/dist/durable/SubscriptionTransition.d.mts +21 -0
- package/dist/durable/SubscriptionTransition.mjs +148 -0
- package/dist/durable/SubscriptionTransition.mjs.map +1 -0
- package/dist/durable/Subscriptions.d.mts +73 -0
- package/dist/durable/Subscriptions.mjs +627 -0
- package/dist/durable/Subscriptions.mjs.map +1 -0
- package/dist/durable/ThreadContextHistory.d.mts +32 -0
- package/dist/durable/ThreadContextHistory.mjs +152 -0
- package/dist/durable/ThreadContextHistory.mjs.map +1 -0
- package/dist/durable/ThreadContextHistoryProjection.d.mts +60 -0
- package/dist/durable/ThreadContextHistoryProjection.mjs +149 -0
- package/dist/durable/ThreadContextHistoryProjection.mjs.map +1 -0
- package/dist/durable/ThreadInvariants.d.mts +74 -0
- package/dist/durable/ThreadInvariants.mjs +200 -0
- package/dist/durable/ThreadInvariants.mjs.map +1 -0
- package/dist/durable/ThreadProjection.d.mts +78 -0
- package/dist/durable/ThreadProjection.mjs +158 -0
- package/dist/durable/ThreadProjection.mjs.map +1 -0
- package/dist/durable/ThreadProjectionMaintenance.d.mts +49 -0
- package/dist/durable/ThreadProjectionMaintenance.mjs +33 -0
- package/dist/durable/ThreadProjectionMaintenance.mjs.map +1 -0
- package/dist/durable/ThreadStore.d.mts +2 -0
- package/dist/durable/ThreadStore.mjs +147 -0
- package/dist/durable/ThreadStore.mjs.map +1 -0
- package/dist/durable/ThreadStoreConformance.d.mts +29 -0
- package/dist/durable/ThreadStoreConformance.mjs +248 -0
- package/dist/durable/ThreadStoreConformance.mjs.map +1 -0
- package/dist/durable/ToolReconciler.d.mts +2 -0
- package/dist/durable/ToolReconciler.mjs +81 -0
- package/dist/durable/ToolReconciler.mjs.map +1 -0
- package/dist/durable/WakeScheduler.d.mts +2 -0
- package/dist/durable/WakeScheduler.mjs +85 -0
- package/dist/durable/WakeScheduler.mjs.map +1 -0
- package/dist/durable/WorkerHost.d.mts +129 -0
- package/dist/durable/WorkerHost.mjs +77 -0
- package/dist/durable/WorkerHost.mjs.map +1 -0
- package/dist/engine/AgentRuntime.d.mts +2 -0
- package/dist/engine/AgentRuntime.mjs +2 -0
- package/dist/engine/Compaction.d.mts +7 -0
- package/dist/engine/Compaction.mjs +16 -0
- package/dist/engine/Compaction.mjs.map +1 -0
- package/dist/engine/ContextCompactor.d.mts +2 -0
- package/dist/engine/ContextCompactor.mjs +119 -0
- package/dist/engine/ContextCompactor.mjs.map +1 -0
- package/dist/engine/ContextHistory.d.mts +65 -0
- package/dist/engine/ContextHistory.mjs +76 -0
- package/dist/engine/ContextHistory.mjs.map +1 -0
- package/dist/engine/ContextWindow.d.mts +2 -0
- package/dist/engine/ContextWindow.mjs +59 -0
- package/dist/engine/ContextWindow.mjs.map +1 -0
- package/dist/engine/DurableStep.d.mts +2 -0
- package/dist/engine/DurableStep.mjs +62 -0
- package/dist/engine/DurableStep.mjs.map +1 -0
- package/dist/engine/MessagingHost.d.mts +2 -0
- package/dist/engine/MessagingHost.mjs +2 -0
- package/dist/engine/Output.d.mts +2 -0
- package/dist/engine/Output.mjs +8 -0
- package/dist/engine/Output.mjs.map +1 -0
- package/dist/engine/RunEventSink.d.mts +2 -0
- package/dist/engine/RunEventSink.mjs +22 -0
- package/dist/engine/RunEventSink.mjs.map +1 -0
- package/dist/engine/RunOptions.d.mts +2 -0
- package/dist/engine/RunOptions.mjs +122 -0
- package/dist/engine/RunOptions.mjs.map +1 -0
- package/dist/engine/SubagentHost.d.mts +2 -0
- package/dist/engine/SubagentHost.mjs +72 -0
- package/dist/engine/SubagentHost.mjs.map +1 -0
- package/dist/engine/ThreadHistory.d.mts +2 -0
- package/dist/engine/ThreadHistory.mjs +67 -0
- package/dist/engine/ThreadHistory.mjs.map +1 -0
- package/dist/engine/ToolBroker.d.mts +2 -0
- package/dist/engine/ToolBroker.mjs +42 -0
- package/dist/engine/ToolBroker.mjs.map +1 -0
- package/dist/foreign-diagnostic-DBQ1XHKh.mjs +37 -0
- package/dist/foreign-diagnostic-DBQ1XHKh.mjs.map +1 -0
- package/dist/index.d.mts +88 -54
- package/dist/index.mjs +97 -54
- package/dist/output-contract-BC7tjlGw.mjs +84 -0
- package/dist/output-contract-BC7tjlGw.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/sandbox/CodeExecutor.d.mts +194 -0
- package/dist/sandbox/CodeExecutor.mjs +278 -0
- package/dist/sandbox/CodeExecutor.mjs.map +1 -0
- package/dist/sandbox/InteractiveBrowser.d.mts +142 -0
- package/dist/sandbox/InteractiveBrowser.mjs +165 -0
- package/dist/sandbox/InteractiveBrowser.mjs.map +1 -0
- package/dist/sandbox/PageCapture.d.mts +2 -0
- package/dist/sandbox/PageCapture.mjs +450 -0
- package/dist/sandbox/PageCapture.mjs.map +1 -0
- package/dist/sandbox/PageCrawl.d.mts +88 -0
- package/dist/sandbox/PageCrawl.mjs +124 -0
- package/dist/sandbox/PageCrawl.mjs.map +1 -0
- package/dist/sandbox/PageScreenshot.d.mts +2 -0
- package/dist/sandbox/PageScreenshot.mjs +53 -0
- package/dist/sandbox/PageScreenshot.mjs.map +1 -0
- package/dist/sandbox/ProtectedBrowser.d.mts +252 -0
- package/dist/sandbox/ProtectedBrowser.mjs +270 -0
- package/dist/sandbox/ProtectedBrowser.mjs.map +1 -0
- package/dist/sandbox/Sandbox.d.mts +2 -0
- package/dist/sandbox/Sandbox.mjs +208 -0
- package/dist/sandbox/Sandbox.mjs.map +1 -0
- package/dist/utf8-BYfhEkcj.mjs +11 -0
- package/dist/utf8-BYfhEkcj.mjs.map +1 -0
- package/dist/utf8-DchGZRBd.mjs +23 -0
- package/dist/utf8-DchGZRBd.mjs.map +1 -0
- package/package.json +1 -1
- package/src/Ephemeral.ts +17 -0
- package/src/ToolExposure.ts +2 -2
- package/src/capabilities/Approval.ts +352 -0
- package/src/capabilities/Budget.ts +536 -0
- package/src/capabilities/CodeMode.ts +1090 -0
- package/src/capabilities/Commands.ts +86 -0
- package/src/capabilities/ContextTools.ts +184 -0
- package/src/capabilities/Mcp.ts +427 -0
- package/src/capabilities/McpClient.ts +967 -0
- package/src/capabilities/MemoryNotes.ts +174 -0
- package/src/capabilities/Messaging.ts +261 -0
- package/src/capabilities/ModelContext.ts +354 -0
- package/src/capabilities/Redaction.ts +157 -0
- package/src/capabilities/Remembering.ts +550 -0
- package/src/capabilities/RunHooks.ts +280 -0
- package/src/capabilities/SemanticMemory.ts +447 -0
- package/src/capabilities/Subagent.ts +2277 -0
- package/src/capabilities/SubagentReservations.ts +850 -0
- package/src/capabilities/ToolDiscovery.ts +339 -0
- package/src/capabilities/WebCapture.ts +722 -0
- package/src/capabilities/WebSearch.ts +184 -0
- package/src/capabilities/internal/subagent-background.ts +1106 -0
- package/src/capabilities/internal/subagent-contract.ts +142 -0
- package/src/capabilities/internal/subagent-policy.ts +235 -0
- package/src/capabilities/internal/subagent-reporting.ts +261 -0
- package/src/capabilities/internal/utf8.ts +10 -0
- package/src/core/Agent.ts +575 -0
- package/src/core/AgentError.ts +152 -0
- package/src/core/AgentPolicy.ts +153 -0
- package/src/core/AgentUpdates.ts +100 -0
- package/src/core/IdGenerator.ts +39 -0
- package/src/core/Identifiers.ts +48 -0
- package/src/core/Memory.ts +290 -0
- package/src/core/MemoryNamespace.ts +196 -0
- package/src/core/MemoryReference.ts +121 -0
- package/src/core/MemoryRevalidation.ts +185 -0
- package/src/core/MemoryStore.ts +368 -0
- package/src/core/Messaging.ts +90 -0
- package/src/core/Receipt.ts +42 -0
- package/src/core/RememberingStore.ts +300 -0
- package/src/core/RunEvent.ts +366 -0
- package/src/core/RunPolicyUsage.ts +17 -0
- package/src/core/SemanticMemoryIndex.ts +250 -0
- package/src/core/SemanticMemoryRevalidation.ts +254 -0
- package/src/core/SubagentContract.ts +196 -0
- package/src/core/Thread.ts +371 -0
- package/src/core/ToolExposure.ts +74 -0
- package/src/core/ToolResult.ts +170 -0
- package/src/core/Usage.ts +529 -0
- package/src/core/Worker.ts +173 -0
- package/src/core/internal/agent-updates.ts +32 -0
- package/src/core/internal/utf8.ts +23 -0
- package/src/durable/ActivityStore.ts +160 -0
- package/src/durable/Admin.ts +496 -0
- package/src/durable/AgentRegistration.ts +13 -0
- package/src/durable/Certification.ts +210 -0
- package/src/durable/CommittedActivity.ts +296 -0
- package/src/durable/Digest.ts +93 -0
- package/src/durable/DurableAgentRuntime.ts +10340 -0
- package/src/durable/DurableFailpoint.ts +103 -0
- package/src/durable/DurableFailpointTestControl.ts +39 -0
- package/src/durable/EventSource.ts +172 -0
- package/src/durable/GitHubWorkflowSource.ts +453 -0
- package/src/durable/MessageDelivery.ts +708 -0
- package/src/durable/MessageDeliveryStoreConformance.ts +363 -0
- package/src/durable/OperationAuthorizer.ts +85 -0
- package/src/durable/PersistentHistory.ts +260 -0
- package/src/durable/PreparedInputAdmission.ts +44 -0
- package/src/durable/Records.ts +1010 -0
- package/src/durable/Recovery.ts +1018 -0
- package/src/durable/RunJournal.ts +1479 -0
- package/src/durable/Schedule.ts +504 -0
- package/src/durable/ScheduleStoreConformance.ts +638 -0
- package/src/durable/ScheduleTransition.ts +265 -0
- package/src/durable/Scheduling.ts +1077 -0
- package/src/durable/SqlMemoryStore.ts +774 -0
- package/src/durable/SqlMessageDeliveryStore.ts +302 -0
- package/src/durable/SqlStorageV2Upgrade.ts +500 -0
- package/src/durable/SqlSubscriptionStore.ts +1440 -0
- package/src/durable/SubmissionLedger.ts +1201 -0
- package/src/durable/SubmissionLedgerConformance.ts +4579 -0
- package/src/durable/SubmissionStatus.ts +14 -0
- package/src/durable/Subscription.ts +544 -0
- package/src/durable/SubscriptionInput.ts +144 -0
- package/src/durable/SubscriptionStoreConformance.ts +945 -0
- package/src/durable/SubscriptionTools.ts +327 -0
- package/src/durable/SubscriptionTransition.ts +302 -0
- package/src/durable/Subscriptions.ts +1210 -0
- package/src/durable/ThreadContextHistory.ts +227 -0
- package/src/durable/ThreadContextHistoryProjection.ts +216 -0
- package/src/durable/ThreadInvariants.ts +442 -0
- package/src/durable/ThreadProjection.ts +269 -0
- package/src/durable/ThreadProjectionMaintenance.ts +67 -0
- package/src/durable/ThreadStore.ts +242 -0
- package/src/durable/ThreadStoreConformance.ts +710 -0
- package/src/durable/ToolReconciler.ts +105 -0
- package/src/durable/WakeScheduler.ts +134 -0
- package/src/durable/WorkerHost.ts +171 -0
- package/src/durable/internal/agent-registration.ts +525 -0
- package/src/durable/internal/agent-updates.ts +302 -0
- package/src/durable/internal/foreign-diagnostic.ts +47 -0
- package/src/durable/internal/journal-checkpoint.ts +104 -0
- package/src/durable/internal/journal-metadata.ts +107 -0
- package/src/durable/internal/messaging-host.ts +608 -0
- package/src/durable/internal/schedule-time.ts +303 -0
- package/src/durable/internal/storage-v2-layout.ts +163 -0
- package/src/durable/internal/storage-v2.ts +73 -0
- package/src/durable/internal/worker-host.ts +2467 -0
- package/src/durable/internal/worker-runtime.ts +9 -0
- package/src/engine/AgentRuntime.ts +37 -0
- package/src/engine/Compaction.ts +11 -0
- package/src/engine/ContextCompactor.ts +277 -0
- package/src/engine/ContextHistory.ts +73 -0
- package/src/engine/ContextWindow.ts +72 -0
- package/src/engine/DurableStep.ts +132 -0
- package/src/engine/MessagingHost.ts +110 -0
- package/src/engine/Output.ts +2 -0
- package/src/engine/RunEventSink.ts +132 -0
- package/src/engine/RunOptions.ts +1077 -0
- package/src/engine/SubagentHost.ts +181 -0
- package/src/engine/ThreadHistory.ts +120 -0
- package/src/engine/ToolBroker.ts +157 -0
- package/src/engine/ToolExposure.ts +48 -0
- package/src/engine/internal/agent-runtime.ts +10117 -0
- package/src/engine/internal/bounded-value.ts +315 -0
- package/src/engine/internal/compaction.ts +678 -0
- package/src/engine/internal/error-diagnostic.ts +39 -0
- package/src/engine/internal/output-contract.ts +173 -0
- package/src/engine/internal/primitive-delta.ts +80 -0
- package/src/engine/internal/provider-result-staging.ts +211 -0
- package/src/engine/internal/tool-derivative.ts +106 -0
- package/src/engine/internal/tool-exposure.ts +224 -0
- package/src/engine/internal/tool-telemetry.ts +484 -0
- package/src/index.ts +96 -53
- package/src/sandbox/CodeExecutor.ts +352 -0
- package/src/sandbox/InteractiveBrowser.ts +257 -0
- package/src/sandbox/PageCapture.ts +692 -0
- package/src/sandbox/PageCrawl.ts +148 -0
- package/src/sandbox/PageScreenshot.ts +81 -0
- package/src/sandbox/ProtectedBrowser.ts +413 -0
- package/src/sandbox/Sandbox.ts +241 -0
- package/dist/Agent.d.mts +0 -5
- package/dist/Agent.mjs +0 -10
- package/dist/Agent.mjs.map +0 -1
- package/dist/AgentError.d.mts +0 -5
- package/dist/AgentError.mjs +0 -10
- package/dist/AgentError.mjs.map +0 -1
- package/dist/AgentPolicy.d.mts +0 -5
- package/dist/AgentPolicy.mjs +0 -10
- package/dist/AgentPolicy.mjs.map +0 -1
- package/dist/AgentRuntime.d.mts +0 -5
- package/dist/AgentRuntime.mjs +0 -10
- package/dist/AgentRuntime.mjs.map +0 -1
- package/dist/AgentUpdates.d.mts +0 -5
- package/dist/AgentUpdates.mjs +0 -10
- package/dist/AgentUpdates.mjs.map +0 -1
- package/dist/Approval.d.mts +0 -5
- package/dist/Approval.mjs +0 -10
- package/dist/Approval.mjs.map +0 -1
- package/dist/Budget.d.mts +0 -5
- package/dist/Budget.mjs +0 -10
- package/dist/Budget.mjs.map +0 -1
- package/dist/CodeMode.d.mts +0 -5
- package/dist/CodeMode.mjs +0 -10
- package/dist/CodeMode.mjs.map +0 -1
- package/dist/Commands.d.mts +0 -5
- package/dist/Commands.mjs +0 -10
- package/dist/Commands.mjs.map +0 -1
- package/dist/Compaction.d.mts +0 -5
- package/dist/Compaction.mjs +0 -10
- package/dist/Compaction.mjs.map +0 -1
- package/dist/ContextCompactor.d.mts +0 -5
- package/dist/ContextCompactor.mjs +0 -10
- package/dist/ContextCompactor.mjs.map +0 -1
- package/dist/ContextHistory.d.mts +0 -5
- package/dist/ContextHistory.mjs +0 -10
- package/dist/ContextHistory.mjs.map +0 -1
- package/dist/ContextTools.d.mts +0 -5
- package/dist/ContextTools.mjs +0 -10
- package/dist/ContextTools.mjs.map +0 -1
- package/dist/ContextWindow.d.mts +0 -5
- package/dist/ContextWindow.mjs +0 -10
- package/dist/ContextWindow.mjs.map +0 -1
- package/dist/DurableStep.d.mts +0 -5
- package/dist/DurableStep.mjs +0 -10
- package/dist/DurableStep.mjs.map +0 -1
- package/dist/EphemeralThreads.d.mts +0 -5
- package/dist/EphemeralThreads.mjs +0 -10
- package/dist/EphemeralThreads.mjs.map +0 -1
- package/dist/IdGenerator.d.mts +0 -5
- package/dist/IdGenerator.mjs +0 -10
- package/dist/IdGenerator.mjs.map +0 -1
- package/dist/Identifiers.d.mts +0 -5
- package/dist/Identifiers.mjs +0 -10
- package/dist/Identifiers.mjs.map +0 -1
- package/dist/Mcp.d.mts +0 -5
- package/dist/Mcp.mjs +0 -10
- package/dist/Mcp.mjs.map +0 -1
- package/dist/McpClient.d.mts +0 -5
- package/dist/McpClient.mjs +0 -10
- package/dist/McpClient.mjs.map +0 -1
- package/dist/Memory.d.mts +0 -5
- package/dist/Memory.mjs +0 -10
- package/dist/Memory.mjs.map +0 -1
- package/dist/MemoryNamespace.d.mts +0 -5
- package/dist/MemoryNamespace.mjs +0 -10
- package/dist/MemoryNamespace.mjs.map +0 -1
- package/dist/MemoryNotes.d.mts +0 -5
- package/dist/MemoryNotes.mjs +0 -10
- package/dist/MemoryNotes.mjs.map +0 -1
- package/dist/MemoryReference.d.mts +0 -5
- package/dist/MemoryReference.mjs +0 -10
- package/dist/MemoryReference.mjs.map +0 -1
- package/dist/MemoryRevalidation.d.mts +0 -5
- package/dist/MemoryRevalidation.mjs +0 -10
- package/dist/MemoryRevalidation.mjs.map +0 -1
- package/dist/MemoryStore.d.mts +0 -5
- package/dist/MemoryStore.mjs +0 -10
- package/dist/MemoryStore.mjs.map +0 -1
- package/dist/Messaging.d.mts +0 -5
- package/dist/Messaging.mjs +0 -10
- package/dist/Messaging.mjs.map +0 -1
- package/dist/MessagingHost.d.mts +0 -5
- package/dist/MessagingHost.mjs +0 -10
- package/dist/MessagingHost.mjs.map +0 -1
- package/dist/ModelContext.d.mts +0 -5
- package/dist/ModelContext.mjs +0 -10
- package/dist/ModelContext.mjs.map +0 -1
- package/dist/Receipt.d.mts +0 -5
- package/dist/Receipt.mjs +0 -10
- package/dist/Receipt.mjs.map +0 -1
- package/dist/Redaction.d.mts +0 -5
- package/dist/Redaction.mjs +0 -10
- package/dist/Redaction.mjs.map +0 -1
- package/dist/Remembering.d.mts +0 -5
- package/dist/Remembering.mjs +0 -10
- package/dist/Remembering.mjs.map +0 -1
- package/dist/RememberingStore.d.mts +0 -5
- package/dist/RememberingStore.mjs +0 -10
- package/dist/RememberingStore.mjs.map +0 -1
- package/dist/RunEvent.d.mts +0 -5
- package/dist/RunEvent.mjs +0 -10
- package/dist/RunEvent.mjs.map +0 -1
- package/dist/RunEventSink.d.mts +0 -5
- package/dist/RunEventSink.mjs +0 -10
- package/dist/RunEventSink.mjs.map +0 -1
- package/dist/RunHooks.d.mts +0 -5
- package/dist/RunHooks.mjs +0 -10
- package/dist/RunHooks.mjs.map +0 -1
- package/dist/RunOptions.d.mts +0 -5
- package/dist/RunOptions.mjs +0 -10
- package/dist/RunOptions.mjs.map +0 -1
- package/dist/RunPolicyUsage.d.mts +0 -5
- package/dist/RunPolicyUsage.mjs +0 -10
- package/dist/RunPolicyUsage.mjs.map +0 -1
- package/dist/SemanticMemory.d.mts +0 -5
- package/dist/SemanticMemory.mjs +0 -10
- package/dist/SemanticMemory.mjs.map +0 -1
- package/dist/SemanticMemoryIndex.d.mts +0 -5
- package/dist/SemanticMemoryIndex.mjs +0 -10
- package/dist/SemanticMemoryIndex.mjs.map +0 -1
- package/dist/SemanticMemoryRevalidation.d.mts +0 -5
- package/dist/SemanticMemoryRevalidation.mjs +0 -10
- package/dist/SemanticMemoryRevalidation.mjs.map +0 -1
- package/dist/Subagent.d.mts +0 -5
- package/dist/Subagent.mjs +0 -10
- package/dist/Subagent.mjs.map +0 -1
- package/dist/SubagentContract.d.mts +0 -5
- package/dist/SubagentContract.mjs +0 -10
- package/dist/SubagentContract.mjs.map +0 -1
- package/dist/SubagentHost.d.mts +0 -5
- package/dist/SubagentHost.mjs +0 -10
- package/dist/SubagentHost.mjs.map +0 -1
- package/dist/SubagentReservations.d.mts +0 -5
- package/dist/SubagentReservations.mjs +0 -10
- package/dist/SubagentReservations.mjs.map +0 -1
- package/dist/ThreadHistory.d.mts +0 -5
- package/dist/ThreadHistory.mjs +0 -10
- package/dist/ThreadHistory.mjs.map +0 -1
- package/dist/ToolBroker.d.mts +0 -5
- package/dist/ToolBroker.mjs +0 -10
- package/dist/ToolBroker.mjs.map +0 -1
- package/dist/ToolDiscovery.d.mts +0 -5
- package/dist/ToolDiscovery.mjs +0 -10
- package/dist/ToolDiscovery.mjs.map +0 -1
- package/dist/ToolResult.d.mts +0 -5
- package/dist/ToolResult.mjs +0 -10
- package/dist/ToolResult.mjs.map +0 -1
- package/dist/Usage.d.mts +0 -5
- package/dist/Usage.mjs +0 -10
- package/dist/Usage.mjs.map +0 -1
- package/dist/WebCapture.d.mts +0 -5
- package/dist/WebCapture.mjs +0 -10
- package/dist/WebCapture.mjs.map +0 -1
- package/dist/WebSearch.d.mts +0 -5
- package/dist/WebSearch.mjs +0 -10
- package/dist/WebSearch.mjs.map +0 -1
- package/dist/Worker.d.mts +0 -5
- package/dist/Worker.mjs +0 -10
- package/dist/Worker.mjs.map +0 -1
- package/dist/rolldown-runtime-BBjsoOtd.mjs +0 -27
- package/src/Agent.ts +0 -1
- package/src/AgentError.ts +0 -1
- package/src/AgentPolicy.ts +0 -1
- package/src/AgentRuntime.ts +0 -1
- package/src/AgentUpdates.ts +0 -1
- package/src/Approval.ts +0 -1
- package/src/Budget.ts +0 -1
- package/src/CodeMode.ts +0 -1
- package/src/Commands.ts +0 -1
- package/src/Compaction.ts +0 -1
- package/src/ContextCompactor.ts +0 -1
- package/src/ContextHistory.ts +0 -1
- package/src/ContextTools.ts +0 -1
- package/src/ContextWindow.ts +0 -1
- package/src/DurableStep.ts +0 -1
- package/src/EphemeralThreads.ts +0 -1
- package/src/IdGenerator.ts +0 -1
- package/src/Identifiers.ts +0 -1
- package/src/Mcp.ts +0 -1
- package/src/McpClient.ts +0 -1
- package/src/Memory.ts +0 -1
- package/src/MemoryNamespace.ts +0 -1
- package/src/MemoryNotes.ts +0 -1
- package/src/MemoryReference.ts +0 -1
- package/src/MemoryRevalidation.ts +0 -1
- package/src/MemoryStore.ts +0 -1
- package/src/Messaging.ts +0 -1
- package/src/MessagingHost.ts +0 -1
- package/src/ModelContext.ts +0 -1
- package/src/Receipt.ts +0 -1
- package/src/Redaction.ts +0 -1
- package/src/Remembering.ts +0 -1
- package/src/RememberingStore.ts +0 -1
- package/src/RunEvent.ts +0 -1
- package/src/RunEventSink.ts +0 -1
- package/src/RunHooks.ts +0 -1
- package/src/RunOptions.ts +0 -1
- package/src/RunPolicyUsage.ts +0 -1
- package/src/SemanticMemory.ts +0 -1
- package/src/SemanticMemoryIndex.ts +0 -1
- package/src/SemanticMemoryRevalidation.ts +0 -1
- package/src/Subagent.ts +0 -1
- package/src/SubagentContract.ts +0 -1
- package/src/SubagentHost.ts +0 -1
- package/src/SubagentReservations.ts +0 -1
- package/src/ThreadHistory.ts +0 -1
- package/src/ToolBroker.ts +0 -1
- package/src/ToolDiscovery.ts +0 -1
- package/src/ToolResult.ts +0 -1
- package/src/Usage.ts +0 -1
- package/src/WebCapture.ts +0 -1
- package/src/WebSearch.ts +0 -1
- package/src/Worker.ts +0 -1
|
@@ -0,0 +1,1018 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
import { ThreadId, SettlementId, SubmissionId, ToolCallId } from "../core/Identifiers.ts";
|
|
4
|
+
import { SettlementOutcome, ToolCallPrepared } from "./Records.ts";
|
|
5
|
+
import {
|
|
6
|
+
ChildReservationId,
|
|
7
|
+
submissionSettlementId,
|
|
8
|
+
WaitingChild,
|
|
9
|
+
type ChildAttachmentSnapshot,
|
|
10
|
+
type ChildBudgetReservationSnapshot,
|
|
11
|
+
type RecoverySnapshot,
|
|
12
|
+
} from "./SubmissionLedger.ts";
|
|
13
|
+
|
|
14
|
+
/** One canonical `ToolCallPrepared` without a settling or resolving canonical record (DUR-009). */
|
|
15
|
+
export class OpenToolCallEvidence extends Schema.Class<OpenToolCallEvidence>(
|
|
16
|
+
"@effect-agent/thread/OpenToolCallEvidence",
|
|
17
|
+
)({
|
|
18
|
+
toolCallId: ToolCallId,
|
|
19
|
+
toolName: ToolCallPrepared.fields.toolName,
|
|
20
|
+
turn: ToolCallPrepared.fields.turn,
|
|
21
|
+
}) {}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A committed tool-declaring response with ZERO prepared and ZERO settled records for its Turn:
|
|
25
|
+
* the provably-safe durability §15 window — no prepared records means no handler ran, so the
|
|
26
|
+
* declared batch resumes without model re-invocation and without Unknown.
|
|
27
|
+
*/
|
|
28
|
+
export class DeclaredPendingBatchEvidence extends Schema.Class<DeclaredPendingBatchEvidence>(
|
|
29
|
+
"@effect-agent/thread/DeclaredPendingBatchEvidence",
|
|
30
|
+
)({
|
|
31
|
+
turn: ToolCallPrepared.fields.turn,
|
|
32
|
+
callCount: Schema.Int.check(Schema.isGreaterThan(0)),
|
|
33
|
+
}) {}
|
|
34
|
+
|
|
35
|
+
/** One canonical `ToolApprovalRequested` without a canonical `ToolApprovalDecided`. */
|
|
36
|
+
export class PendingApprovalEvidence extends Schema.Class<PendingApprovalEvidence>(
|
|
37
|
+
"@effect-agent/thread/PendingApprovalEvidence",
|
|
38
|
+
)({
|
|
39
|
+
toolCallId: ToolCallId,
|
|
40
|
+
turn: ToolCallPrepared.fields.turn,
|
|
41
|
+
}) {}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The authoritative tri-state admission answer recorded as pure classifier evidence (SUB-031):
|
|
45
|
+
* the recovery pass queries `resolveAdmission` with the deterministic child idempotency key for
|
|
46
|
+
* a requested-but-unstarted delegation call and records the result here. Absence of this field
|
|
47
|
+
* means the lookup was not performed — the classifier treats that exactly like `indeterminate`
|
|
48
|
+
* (fail-closed: only a proven `not-admitted` ever permits an admission attempt).
|
|
49
|
+
*/
|
|
50
|
+
export const DelegationAdmissionEvidence = Schema.Literals([
|
|
51
|
+
"not-admitted",
|
|
52
|
+
"admitted",
|
|
53
|
+
"indeterminate",
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
export type DelegationAdmissionEvidence = typeof DelegationAdmissionEvidence.Type;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* One prepared-without-outcome parent Tool Call that IS a delegation (plan §4.1), separated from
|
|
60
|
+
* `openToolCalls` because its establishment protocol is idempotent by construction and must
|
|
61
|
+
* NEVER be marked Unknown (spec §13 vs. DUR-009). Delegation detection is durable and
|
|
62
|
+
* fail-closed: canonical preparation records carry the definition-owned execution kind;
|
|
63
|
+
* child reservations and request records must agree with that classification. Names never
|
|
64
|
+
* authorize replay, including in the pre-reservation window. The
|
|
65
|
+
* `requested`/`started`/`joined` flags come from the parent-log canonical records; the child
|
|
66
|
+
* identity fields are present exactly when those records (or the reservation attachment) carry
|
|
67
|
+
* them.
|
|
68
|
+
*/
|
|
69
|
+
export class OpenDelegationCallEvidence extends Schema.Class<OpenDelegationCallEvidence>(
|
|
70
|
+
"@effect-agent/thread/OpenDelegationCallEvidence",
|
|
71
|
+
)({
|
|
72
|
+
toolCallId: ToolCallId,
|
|
73
|
+
toolName: ToolCallPrepared.fields.toolName,
|
|
74
|
+
turn: ToolCallPrepared.fields.turn,
|
|
75
|
+
/** The canonical `SubagentRequested` record exists for this call. */
|
|
76
|
+
requested: Schema.Boolean,
|
|
77
|
+
/** The canonical `SubagentStarted` record exists for this call. */
|
|
78
|
+
started: Schema.Boolean,
|
|
79
|
+
/** The canonical `SubagentJoined` record exists for this call. */
|
|
80
|
+
joined: Schema.Boolean,
|
|
81
|
+
childThreadId: Schema.optionalKey(ThreadId),
|
|
82
|
+
childSubmissionId: Schema.optionalKey(SubmissionId),
|
|
83
|
+
admission: Schema.optionalKey(DelegationAdmissionEvidence),
|
|
84
|
+
}) {}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Canonical-log facts about one Submission, read strongly consistently alongside the ledger
|
|
88
|
+
* `RecoverySnapshot` (STORE-003). Canonical history wins over every ledger marker (DUR-015), so
|
|
89
|
+
* the classifier consults these facts before trusting ledger state — with one deliberate Phase 5
|
|
90
|
+
* inversion: a RECORDED terminal outcome now beats open tool calls, because a canonical
|
|
91
|
+
* settlement is never revisited (DUR-002/DUR-015); the P4 rule that unknown-beats-settlement is
|
|
92
|
+
* gone.
|
|
93
|
+
*
|
|
94
|
+
* `openToolCalls` is the DUR-009 seam: every `ToolCallPrepared` without a matching
|
|
95
|
+
* `ToolCallSettled` or `ToolCallResolved`. S2 separates `openDelegationCalls` from it (plan
|
|
96
|
+
* §4.1): a delegation's prepared-without-outcome state is provably replay-safe, so those calls
|
|
97
|
+
* route through the Subagent recovery rows and never through `MarkUnknown`. Names and
|
|
98
|
+
* operational reservation rows cannot upgrade ordinary classification. `joinedInputCovered`
|
|
99
|
+
* implements the plan §2.5 prompt-coverage rule for the joined side: a joined input is covered
|
|
100
|
+
* iff a later `ModelResponseRecorded` of the host Run exists after the `input:{sid}` record.
|
|
101
|
+
* `hostSettlementOutcome` is the joined-side view of the host's canonical `SubmissionSettled`
|
|
102
|
+
* record, present exactly when that record exists.
|
|
103
|
+
*/
|
|
104
|
+
export class RecoveryEvidence extends Schema.Class<RecoveryEvidence>(
|
|
105
|
+
"@effect-agent/thread/RecoveryEvidence",
|
|
106
|
+
)({
|
|
107
|
+
/** The Thread exists in the ThreadStore. */
|
|
108
|
+
threadMaterialized: Schema.Boolean,
|
|
109
|
+
/** The deterministic canonical `UserInputRecorded` record (`input:{sid}`) is committed. */
|
|
110
|
+
inputRecorded: Schema.Boolean,
|
|
111
|
+
/**
|
|
112
|
+
* The committed canonical `SubmissionSettled` outcome (`settlement:{sid}`). Present exactly
|
|
113
|
+
* when the canonical settlement record exists, so the flag and the outcome cannot diverge.
|
|
114
|
+
*/
|
|
115
|
+
recordedSettlementOutcome: Schema.optionalKey(SettlementOutcome),
|
|
116
|
+
/** The deterministic canonical `AbortRequested` record (`abort:{sid}`) is committed. */
|
|
117
|
+
abortRecorded: Schema.Boolean,
|
|
118
|
+
/** Prepared ordinary Tool Calls without a canonical settled/resolved outcome (DUR-009). */
|
|
119
|
+
openToolCalls: Schema.Array(OpenToolCallEvidence),
|
|
120
|
+
/**
|
|
121
|
+
* Delegation Tool Calls with an open parent-side obligation (plan §4.1), removed from
|
|
122
|
+
* `openToolCalls`. Wire-required; construction alone defaults it so pre-S2 evidence
|
|
123
|
+
* assemblers stay valid while the classifier's fail-closed detection still protects them.
|
|
124
|
+
*/
|
|
125
|
+
openDelegationCalls: Schema.Array(OpenDelegationCallEvidence).pipe(
|
|
126
|
+
Schema.withConstructorDefault(Effect.succeed([])),
|
|
127
|
+
),
|
|
128
|
+
/** Only persisted orchestration classification authorizes idempotent host-operation replay. */
|
|
129
|
+
openWorkerCalls: Schema.optionalKey(Schema.Array(OpenToolCallEvidence)),
|
|
130
|
+
/** A declared-but-unprepared tool batch: response canonical, zero prepared, zero settled. */
|
|
131
|
+
declaredPendingBatch: Schema.optionalKey(DeclaredPendingBatchEvidence),
|
|
132
|
+
/** Canonically requested approvals without a canonical decision. */
|
|
133
|
+
approvalsPending: Schema.Array(PendingApprovalEvidence),
|
|
134
|
+
/** Joined-side prompt coverage (plan §2.5); `true` whenever the Submission is not joined. */
|
|
135
|
+
joinedInputCovered: Schema.Boolean,
|
|
136
|
+
/** Joined-side view of the host's canonical settlement record, when it exists. */
|
|
137
|
+
hostSettlementOutcome: Schema.optionalKey(SettlementOutcome),
|
|
138
|
+
/**
|
|
139
|
+
* The Thread carries its canonical `SubagentLineageRecorded` record. Only
|
|
140
|
+
* consulted for a parent-linked Submission: a child whose lineage is not yet canonical defers
|
|
141
|
+
* its own materialization/readiness repair to the parent's idempotent establishment
|
|
142
|
+
* (`AwaitParentEstablishment`). Defaults to `false` so an assembler that does not compute it
|
|
143
|
+
* stays fail-closed: deferring is safe because the parent's establishment completes the child;
|
|
144
|
+
* running a Turn before lineage is recorded would violate the child establishment ordering.
|
|
145
|
+
*/
|
|
146
|
+
subagentLineageRecorded: Schema.Boolean.pipe(
|
|
147
|
+
Schema.withConstructorDefault(Effect.succeed(false)),
|
|
148
|
+
),
|
|
149
|
+
}) {}
|
|
150
|
+
|
|
151
|
+
/** Ledger admission committed but the Thread is not durable: finish materialization,
|
|
152
|
+
* append `ThreadCreated`, and mark readiness (crash between admit and materialize). */
|
|
153
|
+
export class CompleteMaterialization extends Schema.TaggedClass<CompleteMaterialization>(
|
|
154
|
+
"@effect-agent/thread/CompleteMaterialization",
|
|
155
|
+
)("CompleteMaterialization", { submissionId: SubmissionId }) {}
|
|
156
|
+
|
|
157
|
+
/** Thread durable but the readiness marker is missing: idempotent `markReady`. */
|
|
158
|
+
export class RepairReadiness extends Schema.TaggedClass<RepairReadiness>(
|
|
159
|
+
"@effect-agent/thread/RepairReadiness",
|
|
160
|
+
)("RepairReadiness", { submissionId: SubmissionId }) {}
|
|
161
|
+
|
|
162
|
+
/** No canonical input yet: append the deterministic `UserInputRecorded` record and mark it. */
|
|
163
|
+
export class ApplyInput extends Schema.TaggedClass<ApplyInput>("@effect-agent/thread/ApplyInput")(
|
|
164
|
+
"ApplyInput",
|
|
165
|
+
{ submissionId: SubmissionId },
|
|
166
|
+
) {}
|
|
167
|
+
|
|
168
|
+
/** Canonical input exists but the ledger marker was lost: repair the marker only (DUR-015). */
|
|
169
|
+
export class RepairInputMarker extends Schema.TaggedClass<RepairInputMarker>(
|
|
170
|
+
"@effect-agent/thread/RepairInputMarker",
|
|
171
|
+
)("RepairInputMarker", { submissionId: SubmissionId }) {}
|
|
172
|
+
|
|
173
|
+
/** Input applied and no terminal work reserved: a worker resumes the Run from the last committed
|
|
174
|
+
* Turn boundary (D6; the model may be re-invoked, duplicate cost is observable — the resuming
|
|
175
|
+
* worker appends `ModelResponseInterrupted` when superseding a prior owner, durability §9). */
|
|
176
|
+
export class ResumeFromTurnBoundary extends Schema.TaggedClass<ResumeFromTurnBoundary>(
|
|
177
|
+
"@effect-agent/thread/ResumeFromTurnBoundary",
|
|
178
|
+
)("ResumeFromTurnBoundary", { submissionId: SubmissionId }) {}
|
|
179
|
+
|
|
180
|
+
/** A settlement is reserved but not canonical: append the EXACT reserved record, then finalize. */
|
|
181
|
+
export class AppendReservedSettlement extends Schema.TaggedClass<AppendReservedSettlement>(
|
|
182
|
+
"@effect-agent/thread/AppendReservedSettlement",
|
|
183
|
+
)("AppendReservedSettlement", {
|
|
184
|
+
submissionId: SubmissionId,
|
|
185
|
+
settlementId: SettlementId,
|
|
186
|
+
outcome: SettlementOutcome,
|
|
187
|
+
}) {}
|
|
188
|
+
|
|
189
|
+
/** The canonical settlement record exists: rebuild/finalize the ledger from history and never
|
|
190
|
+
* rewrite history from the cached ledger status (DUR-011, DUR-015). */
|
|
191
|
+
export class FinalizeLedgerFromHistory extends Schema.TaggedClass<FinalizeLedgerFromHistory>(
|
|
192
|
+
"@effect-agent/thread/FinalizeLedgerFromHistory",
|
|
193
|
+
)("FinalizeLedgerFromHistory", {
|
|
194
|
+
submissionId: SubmissionId,
|
|
195
|
+
settlementId: SettlementId,
|
|
196
|
+
outcome: SettlementOutcome,
|
|
197
|
+
}) {}
|
|
198
|
+
|
|
199
|
+
/** A durable abort intent exists, no terminal outcome is reserved, and no attached-child
|
|
200
|
+
* obligation remains open: settle aborted (DUR-012). The executor first appends
|
|
201
|
+
* `ToolCallUnknown` audit records for any open ordinary calls — abort settles the obligation but
|
|
202
|
+
* never asserts external rollback (durability §13). */
|
|
203
|
+
export class SettleAborted extends Schema.TaggedClass<SettleAborted>(
|
|
204
|
+
"@effect-agent/thread/SettleAborted",
|
|
205
|
+
)("SettleAborted", { submissionId: SubmissionId }) {}
|
|
206
|
+
|
|
207
|
+
/** Prepared ordinary Tool Calls have no canonical outcome: the executor reconciles each open
|
|
208
|
+
* call (recovered result / never-started / safe-retry) and marks the remainder Unknown — never
|
|
209
|
+
* an automatic replay (DUR-009/DUR-017). Delegation calls are excluded: their establishment is
|
|
210
|
+
* idempotent by construction and routes through the Subagent rows instead (plan §4.3). */
|
|
211
|
+
export class MarkUnknown extends Schema.TaggedClass<MarkUnknown>(
|
|
212
|
+
"@effect-agent/thread/MarkUnknown",
|
|
213
|
+
)("MarkUnknown", {
|
|
214
|
+
submissionId: SubmissionId,
|
|
215
|
+
reason: Schema.String,
|
|
216
|
+
openToolCallIds: Schema.Array(ToolCallId),
|
|
217
|
+
}) {}
|
|
218
|
+
|
|
219
|
+
/** A committed tool-declaring response has zero prepared and zero settled records: a worker
|
|
220
|
+
* resumes the declared batch — no model re-invocation, no Unknown (durability §15). S2 also
|
|
221
|
+
* routes an open delegation call WITHOUT establishment evidence here (spec §13 row 1): the
|
|
222
|
+
* declared batch re-executes and the idempotent establishment converges on one child. */
|
|
223
|
+
export class ResumePendingToolBatch extends Schema.TaggedClass<ResumePendingToolBatch>(
|
|
224
|
+
"@effect-agent/thread/ResumePendingToolBatch",
|
|
225
|
+
)("ResumePendingToolBatch", {
|
|
226
|
+
submissionId: SubmissionId,
|
|
227
|
+
turn: DeclaredPendingBatchEvidence.fields.turn,
|
|
228
|
+
}) {}
|
|
229
|
+
|
|
230
|
+
/** Canonically requested approvals lack decisions: the lane waits durably (the executor repairs
|
|
231
|
+
* the ledger suspension from history when the suspend transition itself was lost). */
|
|
232
|
+
export class AwaitApprovalDecision extends Schema.TaggedClass<AwaitApprovalDecision>(
|
|
233
|
+
"@effect-agent/thread/AwaitApprovalDecision",
|
|
234
|
+
)("AwaitApprovalDecision", { submissionId: SubmissionId }) {}
|
|
235
|
+
|
|
236
|
+
/** Every pending approval has a durable decision: a worker resumes the declared batch via the
|
|
237
|
+
* batch-resume seam, appending the canonical `ToolApprovalDecided` records first. */
|
|
238
|
+
export class ResumeSuspended extends Schema.TaggedClass<ResumeSuspended>(
|
|
239
|
+
"@effect-agent/thread/ResumeSuspended",
|
|
240
|
+
)("ResumeSuspended", { submissionId: SubmissionId }) {}
|
|
241
|
+
|
|
242
|
+
/** Unknown Outcomes lack covering resolutions: the lane stays blocked awaiting the authorized
|
|
243
|
+
* DUR-017 resolution path; the obligation stays visible, nothing replays. */
|
|
244
|
+
export class AwaitUnknownResolution extends Schema.TaggedClass<AwaitUnknownResolution>(
|
|
245
|
+
"@effect-agent/thread/AwaitUnknownResolution",
|
|
246
|
+
)("AwaitUnknownResolution", { submissionId: SubmissionId }) {}
|
|
247
|
+
|
|
248
|
+
/** Durable resolution intents cover every open call: apply them canonically
|
|
249
|
+
* (`ToolCallResolved` + `ToolCallSettled` for recovered results) and reopen the lane. */
|
|
250
|
+
export class ApplyUnknownResolutions extends Schema.TaggedClass<ApplyUnknownResolutions>(
|
|
251
|
+
"@effect-agent/thread/ApplyUnknownResolutions",
|
|
252
|
+
)("ApplyUnknownResolutions", { submissionId: SubmissionId }) {}
|
|
253
|
+
|
|
254
|
+
/** `joining` without a canonical `input:{sid}` record: revert to `ready` — the input was never
|
|
255
|
+
* consumed and will be delivered exactly once later (DUR-016). */
|
|
256
|
+
export class RevertJoining extends Schema.TaggedClass<RevertJoining>(
|
|
257
|
+
"@effect-agent/thread/RevertJoining",
|
|
258
|
+
)("RevertJoining", { submissionId: SubmissionId }) {}
|
|
259
|
+
|
|
260
|
+
/** The canonical input exists but the `joined` marker was lost: repair the marker only, exactly
|
|
261
|
+
* like `RepairInputMarker` (DUR-015/DUR-016); the input reattaches, never duplicates. */
|
|
262
|
+
export class RepairJoinMarker extends Schema.TaggedClass<RepairJoinMarker>(
|
|
263
|
+
"@effect-agent/thread/RepairJoinMarker",
|
|
264
|
+
)("RepairJoinMarker", { submissionId: SubmissionId }) {}
|
|
265
|
+
|
|
266
|
+
/** The host Run settled canonically: settle this joined Submission with the host outcome
|
|
267
|
+
* (each joined Submission is owed its own settlement, DUR-002). */
|
|
268
|
+
export class SettleJoinedWithHost extends Schema.TaggedClass<SettleJoinedWithHost>(
|
|
269
|
+
"@effect-agent/thread/SettleJoinedWithHost",
|
|
270
|
+
)("SettleJoinedWithHost", {
|
|
271
|
+
submissionId: SubmissionId,
|
|
272
|
+
outcome: SettlementOutcome,
|
|
273
|
+
}) {}
|
|
274
|
+
|
|
275
|
+
/** The Submission is `joined` and its host Run is still live: nothing to repair — the input
|
|
276
|
+
* reattaches through the host's resume and the Submission settles with the host. */
|
|
277
|
+
export class AwaitHostSettlement extends Schema.TaggedClass<AwaitHostSettlement>(
|
|
278
|
+
"@effect-agent/thread/AwaitHostSettlement",
|
|
279
|
+
)("AwaitHostSettlement", {
|
|
280
|
+
submissionId: SubmissionId,
|
|
281
|
+
hostSubmissionId: Schema.optionalKey(SubmissionId),
|
|
282
|
+
}) {}
|
|
283
|
+
|
|
284
|
+
/** A canonical `SubagentRequested` exists and the authoritative admission lookup proved
|
|
285
|
+
* `notAdmitted`: idempotently admit the intended child from the canonical request payload — it
|
|
286
|
+
* carries the encoded child input (D3), the intended child identity, and every digest — then
|
|
287
|
+
* materialize the child Thread, append its immutable lineage, and mark it ready. No live
|
|
288
|
+
* delegation handler is required (spec §13, SUB-016/SUB-031). */
|
|
289
|
+
export class CompleteChildAdmission extends Schema.TaggedClass<CompleteChildAdmission>(
|
|
290
|
+
"@effect-agent/thread/CompleteChildAdmission",
|
|
291
|
+
)("CompleteChildAdmission", {
|
|
292
|
+
submissionId: SubmissionId,
|
|
293
|
+
toolCallId: ToolCallId,
|
|
294
|
+
}) {}
|
|
295
|
+
|
|
296
|
+
/** A canonical `SubagentRequested` exists but the authoritative admission lookup answered
|
|
297
|
+
* `indeterminate` — or was not (yet) performed: wait and retry the authoritative owner directly.
|
|
298
|
+
* Absence from a projection is never proof of absence and a second admission NEVER occurs
|
|
299
|
+
* (spec §12, SUB-031). */
|
|
300
|
+
export class AwaitChildAdmissionResolution extends Schema.TaggedClass<AwaitChildAdmissionResolution>(
|
|
301
|
+
"@effect-agent/thread/AwaitChildAdmissionResolution",
|
|
302
|
+
)("AwaitChildAdmissionResolution", {
|
|
303
|
+
submissionId: SubmissionId,
|
|
304
|
+
toolCallId: ToolCallId,
|
|
305
|
+
}) {}
|
|
306
|
+
|
|
307
|
+
/** The child Submission is admitted but the parent's `SubagentStarted` link is missing (or its
|
|
308
|
+
* reservation attachment was lost): resolve the SAME child by its deterministic idempotency key
|
|
309
|
+
* and append the exact deterministic start record, then attach the child to its reservation —
|
|
310
|
+
* the same Receipt on every replay (spec §13, SUB-016/SUB-017). */
|
|
311
|
+
export class RepairSubagentStartLink extends Schema.TaggedClass<RepairSubagentStartLink>(
|
|
312
|
+
"@effect-agent/thread/RepairSubagentStartLink",
|
|
313
|
+
)("RepairSubagentStartLink", {
|
|
314
|
+
submissionId: SubmissionId,
|
|
315
|
+
toolCallId: ToolCallId,
|
|
316
|
+
}) {}
|
|
317
|
+
|
|
318
|
+
/** Children are established and at least one is nonterminal while the parent lane is NOT
|
|
319
|
+
* durably suspended: restore the `waitingForChild` suspension so the lane holds no worker
|
|
320
|
+
* permit while each child runs on its own lane. Recovery reattaches the one existing child and
|
|
321
|
+
* NEVER spawns a replacement (spec §13, SUB-018/SUB-030). */
|
|
322
|
+
export class EnsureWaitingForChild extends Schema.TaggedClass<EnsureWaitingForChild>(
|
|
323
|
+
"@effect-agent/thread/EnsureWaitingForChild",
|
|
324
|
+
)("EnsureWaitingForChild", {
|
|
325
|
+
submissionId: SubmissionId,
|
|
326
|
+
children: Schema.NonEmptyArray(WaitingChild),
|
|
327
|
+
}) {}
|
|
328
|
+
|
|
329
|
+
/** The parent is durably suspended `WaitingForChild` and at least one listed child is not yet
|
|
330
|
+
* provably settled: the lane stays dormant and consumes no permit; the child's Settlement wakes
|
|
331
|
+
* it durably (spec §12 step 10). An unresolved ordinary Tool inside a child keeps the parent
|
|
332
|
+
* here honestly — the obligation stays visible and aged, nothing is fabricated (SUB-021). */
|
|
333
|
+
export class AwaitChildSettlement extends Schema.TaggedClass<AwaitChildSettlement>(
|
|
334
|
+
"@effect-agent/thread/AwaitChildSettlement",
|
|
335
|
+
)("AwaitChildSettlement", { submissionId: SubmissionId }) {}
|
|
336
|
+
|
|
337
|
+
/** Every relevant child is provably settled but the parent has not joined (legacy data, or a
|
|
338
|
+
* canonical settlement whose idempotent wake still needs replay): record/replay the durable wake
|
|
339
|
+
* so a claiming worker resumes the declared batch and joins each child's canonical Settlement —
|
|
340
|
+
* the join itself needs the parent Binding and is deferred to that worker (spec §13). */
|
|
341
|
+
export class ResumeWaitingParent extends Schema.TaggedClass<ResumeWaitingParent>(
|
|
342
|
+
"@effect-agent/thread/ResumeWaitingParent",
|
|
343
|
+
)("ResumeWaitingParent", {
|
|
344
|
+
submissionId: SubmissionId,
|
|
345
|
+
children: Schema.NonEmptyArray(WaitingChild),
|
|
346
|
+
}) {}
|
|
347
|
+
|
|
348
|
+
/** The canonical `SubagentJoined` record exists but the reservation release is incomplete:
|
|
349
|
+
* replay `beginChildBudgetRelease` with the accounting decision FROM the canonical record, then
|
|
350
|
+
* apply `releaseChildBudget` — budget stays unavailable until repair, never available twice
|
|
351
|
+
* (spec §12 join step 6, DUR-015). */
|
|
352
|
+
export class ApplyJoinAccounting extends Schema.TaggedClass<ApplyJoinAccounting>(
|
|
353
|
+
"@effect-agent/thread/ApplyJoinAccounting",
|
|
354
|
+
)("ApplyJoinAccounting", {
|
|
355
|
+
submissionId: SubmissionId,
|
|
356
|
+
toolCallId: ToolCallId,
|
|
357
|
+
reservationId: ChildReservationId,
|
|
358
|
+
}) {}
|
|
359
|
+
|
|
360
|
+
/** Parent abort is canonical while attached children are nonterminal: idempotently issue each
|
|
361
|
+
* child's durable abort command and keep the parent waiting for the joins —
|
|
362
|
+
* request-abort-and-join is the ONLY close behavior; the replayed command returns the recorded
|
|
363
|
+
* child intent unchanged, so the intent row IS the propagation marker (spec §13.1, SUB-022,
|
|
364
|
+
* DUR-012). */
|
|
365
|
+
export class PropagateChildAbort extends Schema.TaggedClass<PropagateChildAbort>(
|
|
366
|
+
"@effect-agent/thread/PropagateChildAbort",
|
|
367
|
+
)("PropagateChildAbort", {
|
|
368
|
+
submissionId: SubmissionId,
|
|
369
|
+
children: Schema.NonEmptyArray(WaitingChild),
|
|
370
|
+
}) {}
|
|
371
|
+
|
|
372
|
+
/** A child budget reservation can no longer bind a child — its request is absent with no
|
|
373
|
+
* resumable batch, or the parent is aborting and the child provably never admitted: freeze the
|
|
374
|
+
* deterministic zero-consumed accounting decision and release the unused allocation exactly
|
|
375
|
+
* once (spec §13/§14: "releases the reservation exactly once"). */
|
|
376
|
+
export class ReleaseOrphanChildReservation extends Schema.TaggedClass<ReleaseOrphanChildReservation>(
|
|
377
|
+
"@effect-agent/thread/ReleaseOrphanChildReservation",
|
|
378
|
+
)("ReleaseOrphanChildReservation", {
|
|
379
|
+
submissionId: SubmissionId,
|
|
380
|
+
reservationIds: Schema.NonEmptyArray(ChildReservationId),
|
|
381
|
+
}) {}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* A parent-linked `admitted` Submission whose Thread lacks the canonical
|
|
385
|
+
* `SubagentLineageRecorded` record: the child lane DEFERS its own materialization/readiness
|
|
386
|
+
* repair — the parent's idempotent establishment (admit → materialize → lineage → ready)
|
|
387
|
+
* completes it, so a child never runs a Turn before its lineage record is canonical.
|
|
388
|
+
* This preserves the child establishment ordering. It is ordering/liveness hygiene, not a
|
|
389
|
+
* safety repair — the join already fails closed without lineage (SUB-019).
|
|
390
|
+
*/
|
|
391
|
+
export class AwaitParentEstablishment extends Schema.TaggedClass<AwaitParentEstablishment>(
|
|
392
|
+
"@effect-agent/thread/AwaitParentEstablishment",
|
|
393
|
+
)("AwaitParentEstablishment", {
|
|
394
|
+
submissionId: SubmissionId,
|
|
395
|
+
parentSubmissionId: SubmissionId,
|
|
396
|
+
parentToolCallId: ToolCallId,
|
|
397
|
+
}) {}
|
|
398
|
+
|
|
399
|
+
/** The Submission is settled; nothing is owed. */
|
|
400
|
+
export class NoAction extends Schema.TaggedClass<NoAction>("@effect-agent/thread/NoAction")(
|
|
401
|
+
"NoAction",
|
|
402
|
+
{ submissionId: SubmissionId },
|
|
403
|
+
) {}
|
|
404
|
+
|
|
405
|
+
/** The executable recovery decision table's output alphabet (plan §Recovery classifier). */
|
|
406
|
+
export const RecoveryDecision = Schema.Union([
|
|
407
|
+
CompleteMaterialization,
|
|
408
|
+
RepairReadiness,
|
|
409
|
+
ApplyInput,
|
|
410
|
+
RepairInputMarker,
|
|
411
|
+
ResumeFromTurnBoundary,
|
|
412
|
+
AppendReservedSettlement,
|
|
413
|
+
FinalizeLedgerFromHistory,
|
|
414
|
+
SettleAborted,
|
|
415
|
+
MarkUnknown,
|
|
416
|
+
ResumePendingToolBatch,
|
|
417
|
+
AwaitApprovalDecision,
|
|
418
|
+
ResumeSuspended,
|
|
419
|
+
AwaitUnknownResolution,
|
|
420
|
+
ApplyUnknownResolutions,
|
|
421
|
+
RevertJoining,
|
|
422
|
+
RepairJoinMarker,
|
|
423
|
+
SettleJoinedWithHost,
|
|
424
|
+
AwaitHostSettlement,
|
|
425
|
+
CompleteChildAdmission,
|
|
426
|
+
AwaitChildAdmissionResolution,
|
|
427
|
+
RepairSubagentStartLink,
|
|
428
|
+
EnsureWaitingForChild,
|
|
429
|
+
AwaitChildSettlement,
|
|
430
|
+
ResumeWaitingParent,
|
|
431
|
+
ApplyJoinAccounting,
|
|
432
|
+
PropagateChildAbort,
|
|
433
|
+
ReleaseOrphanChildReservation,
|
|
434
|
+
AwaitParentEstablishment,
|
|
435
|
+
NoAction,
|
|
436
|
+
]);
|
|
437
|
+
|
|
438
|
+
export type RecoveryDecision = typeof RecoveryDecision.Type;
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* The classifier's merged per-call view of one delegation Tool Call: canonical parent-log flags
|
|
442
|
+
* from the evidence, the reservation row, and the child attachment from the ledger snapshot.
|
|
443
|
+
*/
|
|
444
|
+
interface DelegationCallView {
|
|
445
|
+
readonly toolCallId: ToolCallId;
|
|
446
|
+
turn: number | undefined;
|
|
447
|
+
/** A prepared-without-outcome record exists, so the declared batch is worker-resumable. */
|
|
448
|
+
open: boolean;
|
|
449
|
+
requested: boolean;
|
|
450
|
+
started: boolean;
|
|
451
|
+
joined: boolean;
|
|
452
|
+
admission: DelegationAdmissionEvidence | undefined;
|
|
453
|
+
childSubmissionId: SubmissionId | undefined;
|
|
454
|
+
reservation: ChildBudgetReservationSnapshot | undefined;
|
|
455
|
+
attachment: ChildAttachmentSnapshot | undefined;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** The attachment proves the child's canonical Settlement exists. */
|
|
459
|
+
const isTerminalAttachment = (attachment: ChildAttachmentSnapshot): boolean =>
|
|
460
|
+
attachment.childState === "settled" || attachment.childOutcome !== undefined;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Merge every durable delegation-detection source into per-call views (plan §4.1): the
|
|
464
|
+
* explicitly classified `openDelegationCalls`, reservation rows and child attachments.
|
|
465
|
+
* Reservations may need cleanup, but never upgrade an ordinary call into a replayable delegation.
|
|
466
|
+
*/
|
|
467
|
+
const delegationViewsOf = (
|
|
468
|
+
snapshot: RecoverySnapshot,
|
|
469
|
+
evidence: RecoveryEvidence,
|
|
470
|
+
): Array<DelegationCallView> => {
|
|
471
|
+
const views = new Map<ToolCallId, DelegationCallView>();
|
|
472
|
+
|
|
473
|
+
const ensure = (toolCallId: ToolCallId): DelegationCallView => {
|
|
474
|
+
const existing = views.get(toolCallId);
|
|
475
|
+
|
|
476
|
+
if (existing !== undefined) return existing;
|
|
477
|
+
|
|
478
|
+
const created: DelegationCallView = {
|
|
479
|
+
toolCallId,
|
|
480
|
+
turn: undefined,
|
|
481
|
+
open: false,
|
|
482
|
+
requested: false,
|
|
483
|
+
started: false,
|
|
484
|
+
joined: false,
|
|
485
|
+
admission: undefined,
|
|
486
|
+
childSubmissionId: undefined,
|
|
487
|
+
reservation: undefined,
|
|
488
|
+
attachment: undefined,
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
views.set(toolCallId, created);
|
|
492
|
+
|
|
493
|
+
return created;
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
for (const call of evidence.openDelegationCalls) {
|
|
497
|
+
const view = ensure(call.toolCallId);
|
|
498
|
+
|
|
499
|
+
view.turn = call.turn;
|
|
500
|
+
view.open = true;
|
|
501
|
+
view.requested = call.requested;
|
|
502
|
+
view.started = call.started;
|
|
503
|
+
view.joined = call.joined;
|
|
504
|
+
view.admission = call.admission;
|
|
505
|
+
view.childSubmissionId = call.childSubmissionId;
|
|
506
|
+
}
|
|
507
|
+
for (const reservation of snapshot.childReservations) {
|
|
508
|
+
let view = views.get(reservation.parentToolCallId);
|
|
509
|
+
|
|
510
|
+
if (view === undefined) {
|
|
511
|
+
view = ensure(reservation.parentToolCallId);
|
|
512
|
+
}
|
|
513
|
+
view.reservation = reservation;
|
|
514
|
+
if (view.childSubmissionId === undefined && reservation.childSubmissionId !== undefined) {
|
|
515
|
+
view.childSubmissionId = reservation.childSubmissionId;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
for (const attachment of snapshot.childAttachments) {
|
|
519
|
+
const view = ensure(attachment.toolCallId);
|
|
520
|
+
|
|
521
|
+
view.attachment = attachment;
|
|
522
|
+
if (view.childSubmissionId === undefined) {
|
|
523
|
+
view.childSubmissionId = attachment.childSubmissionId;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return [...views.values()];
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
const waitingChildOf = (view: DelegationCallView, childSubmissionId: SubmissionId): WaitingChild =>
|
|
531
|
+
WaitingChild.make({ toolCallId: view.toolCallId, childSubmissionId });
|
|
532
|
+
|
|
533
|
+
const nonEmpty = <A>(values: ReadonlyArray<A>): readonly [A, ...Array<A>] | undefined => {
|
|
534
|
+
const [first, ...rest] = values;
|
|
535
|
+
|
|
536
|
+
return first === undefined ? undefined : [first, ...rest];
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* The reservation's frozen accounting decision has not been applied: whether frozen by a
|
|
541
|
+
* canonical join or by an orphan zero-consumed decision, `releasePending` always finishes
|
|
542
|
+
* through the idempotent `releaseChildBudget` replay — never through a second freeze, whose
|
|
543
|
+
* divergent accounting would conflict (`ChildReservationConflict`).
|
|
544
|
+
*/
|
|
545
|
+
const releasePendingReservation = (
|
|
546
|
+
view: DelegationCallView,
|
|
547
|
+
): ChildBudgetReservationSnapshot | undefined =>
|
|
548
|
+
view.reservation !== undefined && view.reservation.status === "releasePending"
|
|
549
|
+
? view.reservation
|
|
550
|
+
: undefined;
|
|
551
|
+
|
|
552
|
+
/** The reservation still holds unfrozen allocation (`reserved`). */
|
|
553
|
+
const reservedReservation = (
|
|
554
|
+
view: DelegationCallView,
|
|
555
|
+
): ChildBudgetReservationSnapshot | undefined =>
|
|
556
|
+
view.reservation !== undefined && view.reservation.status === "reserved"
|
|
557
|
+
? view.reservation
|
|
558
|
+
: undefined;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* The spec §13 Subagent rows for a live (non-suspended) parent WITHOUT a durable abort intent,
|
|
562
|
+
* in most-repairing-first order. Returns `undefined` when no delegation obligation is open so
|
|
563
|
+
* the ordinary rows apply.
|
|
564
|
+
*/
|
|
565
|
+
const classifyDelegationRepairs = (
|
|
566
|
+
submissionId: SubmissionId,
|
|
567
|
+
views: ReadonlyArray<DelegationCallView>,
|
|
568
|
+
): RecoveryDecision | undefined => {
|
|
569
|
+
const applyJoins: Array<DelegationCallView> = [];
|
|
570
|
+
const completeAdmissions: Array<DelegationCallView> = [];
|
|
571
|
+
const repairStartLinks: Array<DelegationCallView> = [];
|
|
572
|
+
const awaitAdmissions: Array<DelegationCallView> = [];
|
|
573
|
+
const resumeBatches: Array<DelegationCallView> = [];
|
|
574
|
+
const waiting: Array<WaitingChild> = [];
|
|
575
|
+
const terminalUnjoined: Array<WaitingChild> = [];
|
|
576
|
+
const orphanReservations: Array<ChildBudgetReservationSnapshot> = [];
|
|
577
|
+
|
|
578
|
+
for (const view of views) {
|
|
579
|
+
if (view.reservation !== undefined && view.reservation.status === "released") {
|
|
580
|
+
// The reservation lifecycle is complete: release happens only after the canonical join
|
|
581
|
+
// (or a provably-childless orphan decision), so no parent-side budget or waiting
|
|
582
|
+
// obligation remains on this call.
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
if (releasePendingReservation(view) !== undefined) {
|
|
586
|
+
// Row: budget release incomplete with the accounting decision already frozen → finish
|
|
587
|
+
// the idempotent release; a second freeze would conflict.
|
|
588
|
+
applyJoins.push(view);
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
if (view.joined) {
|
|
592
|
+
// Row: parent join canonical, budget release incomplete → apply the canonical accounting.
|
|
593
|
+
if (reservedReservation(view) !== undefined) applyJoins.push(view);
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
if (view.started && view.childSubmissionId !== undefined) {
|
|
597
|
+
// Rows: started + child nonterminal → waiting; child terminal + join missing → wake.
|
|
598
|
+
const child = waitingChildOf(view, view.childSubmissionId);
|
|
599
|
+
|
|
600
|
+
if (view.attachment !== undefined && isTerminalAttachment(view.attachment)) {
|
|
601
|
+
terminalUnjoined.push(child);
|
|
602
|
+
} else {
|
|
603
|
+
waiting.push(child);
|
|
604
|
+
}
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
607
|
+
if (view.started || view.childSubmissionId !== undefined || view.admission === "admitted") {
|
|
608
|
+
// Row: child admitted, parent start record missing (or the start/attachment link is
|
|
609
|
+
// incomplete) → resolve the same child by key and append the exact link.
|
|
610
|
+
repairStartLinks.push(view);
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
if (view.requested) {
|
|
614
|
+
// Rows: requested + notAdmitted → admit exactly one child; indeterminate (or unqueried,
|
|
615
|
+
// fail-closed) → wait/retry the authoritative owner, never a second admission.
|
|
616
|
+
if (view.admission === "not-admitted") completeAdmissions.push(view);
|
|
617
|
+
else awaitAdmissions.push(view);
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
if (view.open) {
|
|
621
|
+
// Row: no reservation and no request (or reservation without a request on a live parent)
|
|
622
|
+
// → the declared batch re-executes; establishment is idempotent by construction.
|
|
623
|
+
resumeBatches.push(view);
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
const reservation = reservedReservation(view);
|
|
627
|
+
|
|
628
|
+
if (reservation !== undefined) {
|
|
629
|
+
// Row: reservation exists, request absent, no resumable batch → release exactly once.
|
|
630
|
+
orphanReservations.push(reservation);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
const applyJoin = applyJoins[0];
|
|
635
|
+
|
|
636
|
+
if (applyJoin?.reservation !== undefined) {
|
|
637
|
+
return ApplyJoinAccounting.make({
|
|
638
|
+
submissionId,
|
|
639
|
+
toolCallId: applyJoin.toolCallId,
|
|
640
|
+
reservationId: applyJoin.reservation.reservationId,
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
const completeAdmission = completeAdmissions[0];
|
|
644
|
+
|
|
645
|
+
if (completeAdmission !== undefined) {
|
|
646
|
+
return CompleteChildAdmission.make({ submissionId, toolCallId: completeAdmission.toolCallId });
|
|
647
|
+
}
|
|
648
|
+
const repairStartLink = repairStartLinks[0];
|
|
649
|
+
|
|
650
|
+
if (repairStartLink !== undefined) {
|
|
651
|
+
return RepairSubagentStartLink.make({ submissionId, toolCallId: repairStartLink.toolCallId });
|
|
652
|
+
}
|
|
653
|
+
const awaitAdmission = awaitAdmissions[0];
|
|
654
|
+
|
|
655
|
+
if (awaitAdmission !== undefined) {
|
|
656
|
+
return AwaitChildAdmissionResolution.make({
|
|
657
|
+
submissionId,
|
|
658
|
+
toolCallId: awaitAdmission.toolCallId,
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
const resumeBatch = resumeBatches[0];
|
|
662
|
+
|
|
663
|
+
if (resumeBatch?.turn !== undefined) {
|
|
664
|
+
return ResumePendingToolBatch.make({ submissionId, turn: resumeBatch.turn });
|
|
665
|
+
}
|
|
666
|
+
const waitingChildren = nonEmpty([...waiting, ...terminalUnjoined]);
|
|
667
|
+
|
|
668
|
+
if (waiting.length > 0 && waitingChildren !== undefined) {
|
|
669
|
+
return EnsureWaitingForChild.make({ submissionId, children: waitingChildren });
|
|
670
|
+
}
|
|
671
|
+
const settledChildren = nonEmpty(terminalUnjoined);
|
|
672
|
+
|
|
673
|
+
if (settledChildren !== undefined) {
|
|
674
|
+
return ResumeWaitingParent.make({ submissionId, children: settledChildren });
|
|
675
|
+
}
|
|
676
|
+
const orphans = nonEmpty(orphanReservations.map((reservation) => reservation.reservationId));
|
|
677
|
+
|
|
678
|
+
if (orphans !== undefined) {
|
|
679
|
+
return ReleaseOrphanChildReservation.make({ submissionId, reservationIds: orphans });
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return undefined;
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* The spec §13/§13.1 Subagent rows under a canonical parent abort intent: request-abort-and-join
|
|
687
|
+
* is the only close behavior, so a nonterminal attached child converts `SettleAborted` into
|
|
688
|
+
* `PropagateChildAbort`, terminal-but-unjoined children are joined first, incomplete releases
|
|
689
|
+
* are applied, provably childless reservations release exactly once, and only a parent with no
|
|
690
|
+
* open child obligation settles aborted. Returns `undefined` for exactly that last case.
|
|
691
|
+
*/
|
|
692
|
+
const classifyDelegationAbort = (
|
|
693
|
+
submissionId: SubmissionId,
|
|
694
|
+
views: ReadonlyArray<DelegationCallView>,
|
|
695
|
+
): RecoveryDecision | undefined => {
|
|
696
|
+
const awaitAdmissions: Array<DelegationCallView> = [];
|
|
697
|
+
const repairStartLinks: Array<DelegationCallView> = [];
|
|
698
|
+
const nonterminal: Array<WaitingChild> = [];
|
|
699
|
+
const terminalUnjoined: Array<WaitingChild> = [];
|
|
700
|
+
const applyJoins: Array<DelegationCallView> = [];
|
|
701
|
+
const orphanReservations: Array<ChildBudgetReservationSnapshot> = [];
|
|
702
|
+
|
|
703
|
+
for (const view of views) {
|
|
704
|
+
if (view.reservation !== undefined && view.reservation.status === "released") {
|
|
705
|
+
// Fully closed (release only follows the canonical join or a provably-childless orphan
|
|
706
|
+
// decision): nothing left to abort, join, or release for this call.
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (releasePendingReservation(view) !== undefined) {
|
|
710
|
+
// The accounting decision is already frozen: finish the idempotent release; a second
|
|
711
|
+
// (zero-consumed) freeze would conflict with the frozen decision.
|
|
712
|
+
applyJoins.push(view);
|
|
713
|
+
continue;
|
|
714
|
+
}
|
|
715
|
+
if (view.joined) {
|
|
716
|
+
if (reservedReservation(view) !== undefined) applyJoins.push(view);
|
|
717
|
+
continue;
|
|
718
|
+
}
|
|
719
|
+
if (view.childSubmissionId !== undefined) {
|
|
720
|
+
if (!view.started) {
|
|
721
|
+
// The child exists but the canonical start link is missing: repair it first so the
|
|
722
|
+
// abort command targets a canonically linked child.
|
|
723
|
+
repairStartLinks.push(view);
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
const child = waitingChildOf(view, view.childSubmissionId);
|
|
727
|
+
|
|
728
|
+
if (view.attachment !== undefined && isTerminalAttachment(view.attachment)) {
|
|
729
|
+
terminalUnjoined.push(child);
|
|
730
|
+
} else {
|
|
731
|
+
nonterminal.push(child);
|
|
732
|
+
}
|
|
733
|
+
continue;
|
|
734
|
+
}
|
|
735
|
+
if (view.started || view.admission === "admitted") {
|
|
736
|
+
repairStartLinks.push(view);
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
if (view.requested) {
|
|
740
|
+
if (view.admission === "not-admitted") {
|
|
741
|
+
// Provably childless request under abort: never admit a child merely to abort it;
|
|
742
|
+
// release the unused reservation exactly once.
|
|
743
|
+
const reservation = reservedReservation(view);
|
|
744
|
+
|
|
745
|
+
if (reservation !== undefined) orphanReservations.push(reservation);
|
|
746
|
+
} else {
|
|
747
|
+
// Indeterminate or unqueried: a child may exist — never release, settle, or re-admit
|
|
748
|
+
// until the authoritative owner answers (SUB-031).
|
|
749
|
+
awaitAdmissions.push(view);
|
|
750
|
+
}
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
const reservation = reservedReservation(view);
|
|
754
|
+
|
|
755
|
+
if (reservation !== undefined) orphanReservations.push(reservation);
|
|
756
|
+
// An open delegation call with no reservation carries no child obligation: establishment
|
|
757
|
+
// never started, so the ordinary aborted settlement (with its unknown-audit for open
|
|
758
|
+
// calls) is honest.
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
const awaitAdmission = awaitAdmissions[0];
|
|
762
|
+
|
|
763
|
+
if (awaitAdmission !== undefined) {
|
|
764
|
+
return AwaitChildAdmissionResolution.make({
|
|
765
|
+
submissionId,
|
|
766
|
+
toolCallId: awaitAdmission.toolCallId,
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
const repairStartLink = repairStartLinks[0];
|
|
770
|
+
|
|
771
|
+
if (repairStartLink !== undefined) {
|
|
772
|
+
return RepairSubagentStartLink.make({ submissionId, toolCallId: repairStartLink.toolCallId });
|
|
773
|
+
}
|
|
774
|
+
const abortChildren = nonEmpty(nonterminal);
|
|
775
|
+
|
|
776
|
+
if (abortChildren !== undefined) {
|
|
777
|
+
return PropagateChildAbort.make({ submissionId, children: abortChildren });
|
|
778
|
+
}
|
|
779
|
+
const settledChildren = nonEmpty(terminalUnjoined);
|
|
780
|
+
|
|
781
|
+
if (settledChildren !== undefined) {
|
|
782
|
+
return ResumeWaitingParent.make({ submissionId, children: settledChildren });
|
|
783
|
+
}
|
|
784
|
+
const applyJoin = applyJoins[0];
|
|
785
|
+
|
|
786
|
+
if (applyJoin?.reservation !== undefined) {
|
|
787
|
+
return ApplyJoinAccounting.make({
|
|
788
|
+
submissionId,
|
|
789
|
+
toolCallId: applyJoin.toolCallId,
|
|
790
|
+
reservationId: applyJoin.reservation.reservationId,
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
const orphans = nonEmpty(orphanReservations.map((reservation) => reservation.reservationId));
|
|
794
|
+
|
|
795
|
+
if (orphans !== undefined) {
|
|
796
|
+
return ReleaseOrphanChildReservation.make({ submissionId, reservationIds: orphans });
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
return undefined;
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Pure recovery classifier (durability §14, DUR-013): a finite persisted snapshot plus canonical
|
|
804
|
+
* evidence deterministically selects exactly one decision. Precedence, most-settled first
|
|
805
|
+
* (plan §4.2/§4.3 — note the deliberate P5 reorder: canonical settlement and reservation beat
|
|
806
|
+
* open tool calls, because a recorded terminal outcome is never revisited, DUR-002/DUR-015; and
|
|
807
|
+
* the three S2 edits: the abort row propagates to nonterminal attached children, delegation
|
|
808
|
+
* calls never mark Unknown, and the suspended row branches on the suspension reason):
|
|
809
|
+
*
|
|
810
|
+
* 1. `settled` → NoAction — terminal outcomes are never revisited (DUR-002).
|
|
811
|
+
* 2. canonical settlement record → FinalizeLedgerFromHistory — history beats every ledger
|
|
812
|
+
* marker (DUR-015), including a missing or divergent reservation AND open tool calls.
|
|
813
|
+
* 3. reservation → FinalizeLedgerFromHistory when finalized, else AppendReservedSettlement —
|
|
814
|
+
* the reserved record is the single exact outcome owed (DUR-011); it also beats a pending
|
|
815
|
+
* abort intent (DUR-012).
|
|
816
|
+
* 4. joined-side states (DUR-016): `joining` without canonical input → RevertJoining; `joining`
|
|
817
|
+
* with canonical input → RepairJoinMarker (marker lost); `joined` + host settled →
|
|
818
|
+
* SettleJoinedWithHost; `joined` + host live → AwaitHostSettlement (deferred).
|
|
819
|
+
* 5. abort intent → the S2 abort rows (spec §13.1 request-abort-and-join): an unproven child
|
|
820
|
+
* admission waits, an admitted-but-unlinked child repairs its start link, a nonterminal
|
|
821
|
+
* attached child gets PropagateChildAbort — the parent does NOT settle — terminal children
|
|
822
|
+
* are joined, incomplete releases applied, provably childless reservations released; ONLY a
|
|
823
|
+
* parent with no open child obligation reaches SettleAborted, where open ordinary calls
|
|
824
|
+
* become `ToolCallUnknown` audit records, never a rollback claim (§13). SettleAborted is
|
|
825
|
+
* position-blind by design (P7 §7(c)): an aborted, never-claimed `ready` Submission earns it
|
|
826
|
+
* ANYWHERE in the queue — the executor settles it immediately without waiting for it to head
|
|
827
|
+
* the lane, because settlement order of never-run work is not execution order (DUR-004
|
|
828
|
+
* bounds execution order; DUR-012 permits settling inactive accepted work without an
|
|
829
|
+
* Attempt).
|
|
830
|
+
* 6. ordinary open tool calls (state not yet `unknown`) → MarkUnknown — reconcile-then-mark,
|
|
831
|
+
* never an automatic replay (DUR-009). Delegation calls are EXCLUDED (plan §4.3's most
|
|
832
|
+
* important edit): their prepared-without-outcome state is provably replay-safe and routes
|
|
833
|
+
* through rows 5/8/9 instead. A lane already `unknown` is in the DUR-017 resolution regime
|
|
834
|
+
* (row 7) and is not re-marked.
|
|
835
|
+
* 7. state `unknown` → ApplyUnknownResolutions when durable intents cover every open ordinary
|
|
836
|
+
* call, else AwaitUnknownResolution.
|
|
837
|
+
* 8. state `suspended` branches on the stored reason: `WaitingForChild` → ResumeWaitingParent
|
|
838
|
+
* when every listed child is provably settled (replay the idempotent wake), else
|
|
839
|
+
* AwaitChildSettlement (SUB-030); `ApprovalPending` keeps the P5 behavior — undecided
|
|
840
|
+
* canonical approval requests → AwaitApprovalDecision (repairing a lost suspend transition
|
|
841
|
+
* from history), every request decided → ResumeSuspended.
|
|
842
|
+
* 9. the S2 establishment/join rows for a live parent (spec §13, most-repairing first):
|
|
843
|
+
* ApplyJoinAccounting → CompleteChildAdmission → RepairSubagentStartLink →
|
|
844
|
+
* AwaitChildAdmissionResolution → ResumePendingToolBatch (idempotent handler re-entry) →
|
|
845
|
+
* EnsureWaitingForChild → ResumeWaitingParent → ReleaseOrphanChildReservation.
|
|
846
|
+
* 10. declared-but-unprepared tool batch → ResumePendingToolBatch — no handler ran (no prepared
|
|
847
|
+
* records), so the batch resumes with no model re-invocation and no Unknown (§15).
|
|
848
|
+
* 11. `admitted` → a parent-linked Submission whose Thread lacks the canonical lineage
|
|
849
|
+
* record defers (AwaitParentEstablishment: the parent's idempotent establishment
|
|
850
|
+
* completes it); otherwise
|
|
851
|
+
* CompleteMaterialization / RepairReadiness by Thread durability.
|
|
852
|
+
* 12. otherwise → ApplyInput / RepairInputMarker / ResumeFromTurnBoundary by canonical input
|
|
853
|
+
* evidence, with the ledger marker repaired from history, never the reverse.
|
|
854
|
+
*
|
|
855
|
+
* A CHILD Submission (one whose snapshot carries `parentLinkage`) classifies through exactly
|
|
856
|
+
* the same rows as any Submission — child recovery proceeds under its own ownership token and
|
|
857
|
+
* epoch (spec §13, SUB-020); nothing here consults the parent's lane.
|
|
858
|
+
*
|
|
859
|
+
* Ownership leases are deliberately ignored here: the executor's fenced claim is the only
|
|
860
|
+
* authority over liveness, and a stale Attempt is fenced by producer epoch regardless (DUR-006).
|
|
861
|
+
*/
|
|
862
|
+
export const classifyRecovery = (
|
|
863
|
+
snapshot: RecoverySnapshot,
|
|
864
|
+
evidence: RecoveryEvidence,
|
|
865
|
+
): RecoveryDecision => {
|
|
866
|
+
const submissionId = snapshot.submission.submissionId;
|
|
867
|
+
const state = snapshot.submission.state;
|
|
868
|
+
|
|
869
|
+
if (state === "settled") {
|
|
870
|
+
return NoAction.make({ submissionId });
|
|
871
|
+
}
|
|
872
|
+
if (evidence.recordedSettlementOutcome !== undefined) {
|
|
873
|
+
return FinalizeLedgerFromHistory.make({
|
|
874
|
+
submissionId,
|
|
875
|
+
settlementId: snapshot.reservation?.settlementId ?? submissionSettlementId(submissionId),
|
|
876
|
+
outcome: evidence.recordedSettlementOutcome,
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
if (snapshot.reservation !== undefined) {
|
|
880
|
+
if (snapshot.reservation.finalized) {
|
|
881
|
+
return FinalizeLedgerFromHistory.make({
|
|
882
|
+
submissionId,
|
|
883
|
+
settlementId: snapshot.reservation.settlementId,
|
|
884
|
+
outcome: snapshot.reservation.outcome,
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
return AppendReservedSettlement.make({
|
|
889
|
+
submissionId,
|
|
890
|
+
settlementId: snapshot.reservation.settlementId,
|
|
891
|
+
outcome: snapshot.reservation.outcome,
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
if (state === "joining") {
|
|
895
|
+
return evidence.inputRecorded
|
|
896
|
+
? RepairJoinMarker.make({ submissionId })
|
|
897
|
+
: RevertJoining.make({ submissionId });
|
|
898
|
+
}
|
|
899
|
+
if (state === "joined") {
|
|
900
|
+
if (evidence.hostSettlementOutcome !== undefined) {
|
|
901
|
+
return SettleJoinedWithHost.make({
|
|
902
|
+
submissionId,
|
|
903
|
+
outcome: evidence.hostSettlementOutcome,
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
return AwaitHostSettlement.make({
|
|
908
|
+
submissionId,
|
|
909
|
+
...(snapshot.hostSubmissionId === undefined
|
|
910
|
+
? {}
|
|
911
|
+
: { hostSubmissionId: snapshot.hostSubmissionId }),
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
const delegationViews = delegationViewsOf(snapshot, evidence);
|
|
915
|
+
|
|
916
|
+
if (snapshot.abortIntent !== undefined) {
|
|
917
|
+
return (
|
|
918
|
+
classifyDelegationAbort(submissionId, delegationViews) ?? SettleAborted.make({ submissionId })
|
|
919
|
+
);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
const delegationCallIds = new Set<string>(
|
|
923
|
+
evidence.openDelegationCalls.map((call) => call.toolCallId),
|
|
924
|
+
);
|
|
925
|
+
|
|
926
|
+
const ordinaryOpenCalls = evidence.openToolCalls.filter(
|
|
927
|
+
(call) => !delegationCallIds.has(call.toolCallId),
|
|
928
|
+
);
|
|
929
|
+
|
|
930
|
+
if (state !== "unknown" && ordinaryOpenCalls.length > 0) {
|
|
931
|
+
return MarkUnknown.make({
|
|
932
|
+
submissionId,
|
|
933
|
+
reason: "An ordinary Tool call may have executed without a canonical outcome",
|
|
934
|
+
openToolCallIds: ordinaryOpenCalls.map((call) => call.toolCallId),
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
if (state === "unknown") {
|
|
938
|
+
const resolved = new Set(
|
|
939
|
+
snapshot.unknownResolutions.map((resolution) => resolution.toolCallId),
|
|
940
|
+
);
|
|
941
|
+
|
|
942
|
+
const covered = ordinaryOpenCalls.every((call) => resolved.has(call.toolCallId));
|
|
943
|
+
|
|
944
|
+
return covered
|
|
945
|
+
? ApplyUnknownResolutions.make({ submissionId })
|
|
946
|
+
: AwaitUnknownResolution.make({ submissionId });
|
|
947
|
+
}
|
|
948
|
+
const decided = new Set(snapshot.approvalDecisions.map((decision) => decision.toolCallId));
|
|
949
|
+
|
|
950
|
+
const undecidedApprovals = evidence.approvalsPending.filter(
|
|
951
|
+
(pending) => !decided.has(pending.toolCallId),
|
|
952
|
+
);
|
|
953
|
+
|
|
954
|
+
if (state === "suspended") {
|
|
955
|
+
const reason = snapshot.suspension?.reason;
|
|
956
|
+
|
|
957
|
+
if (reason !== undefined && reason._tag === "WaitingForChild") {
|
|
958
|
+
const terminalChildIds = new Set(
|
|
959
|
+
snapshot.childAttachments
|
|
960
|
+
.filter(isTerminalAttachment)
|
|
961
|
+
.map((attachment) => attachment.childSubmissionId),
|
|
962
|
+
);
|
|
963
|
+
|
|
964
|
+
return reason.children.every((child) => terminalChildIds.has(child.childSubmissionId))
|
|
965
|
+
? ResumeWaitingParent.make({ submissionId, children: reason.children })
|
|
966
|
+
: AwaitChildSettlement.make({ submissionId });
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
return undecidedApprovals.length === 0
|
|
970
|
+
? ResumeSuspended.make({ submissionId })
|
|
971
|
+
: AwaitApprovalDecision.make({ submissionId });
|
|
972
|
+
}
|
|
973
|
+
if (undecidedApprovals.length > 0) {
|
|
974
|
+
return AwaitApprovalDecision.make({ submissionId });
|
|
975
|
+
}
|
|
976
|
+
const delegationDecision = classifyDelegationRepairs(submissionId, delegationViews);
|
|
977
|
+
|
|
978
|
+
if (delegationDecision !== undefined) {
|
|
979
|
+
return delegationDecision;
|
|
980
|
+
}
|
|
981
|
+
if (evidence.declaredPendingBatch !== undefined) {
|
|
982
|
+
return ResumePendingToolBatch.make({
|
|
983
|
+
submissionId,
|
|
984
|
+
turn: evidence.declaredPendingBatch.turn,
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
const workerCall = evidence.openWorkerCalls?.[0];
|
|
988
|
+
|
|
989
|
+
if (workerCall !== undefined) {
|
|
990
|
+
return ResumePendingToolBatch.make({ submissionId, turn: workerCall.turn });
|
|
991
|
+
}
|
|
992
|
+
if (state === "admitted") {
|
|
993
|
+
// A parent-linked child never self-repairs readiness before its immutable
|
|
994
|
+
// lineage record is canonical — the parent's establishment appends lineage BEFORE
|
|
995
|
+
// markReady, so the parent completes the child idempotently.
|
|
996
|
+
const linkage = snapshot.submission.parentLinkage ?? snapshot.parentLinkage;
|
|
997
|
+
|
|
998
|
+
if (linkage !== undefined && !evidence.subagentLineageRecorded) {
|
|
999
|
+
return AwaitParentEstablishment.make({
|
|
1000
|
+
submissionId,
|
|
1001
|
+
parentSubmissionId: linkage.parentSubmissionId,
|
|
1002
|
+
parentToolCallId: linkage.parentToolCallId,
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
return evidence.threadMaterialized
|
|
1007
|
+
? RepairReadiness.make({ submissionId })
|
|
1008
|
+
: CompleteMaterialization.make({ submissionId });
|
|
1009
|
+
}
|
|
1010
|
+
if (!evidence.inputRecorded) {
|
|
1011
|
+
return ApplyInput.make({ submissionId });
|
|
1012
|
+
}
|
|
1013
|
+
if (snapshot.inputApplied === undefined) {
|
|
1014
|
+
return RepairInputMarker.make({ submissionId });
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
return ResumeFromTurnBoundary.make({ submissionId });
|
|
1018
|
+
};
|