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,691 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { n as utf8ByteLength } from "./utf8-DchGZRBd.mjs";
|
|
3
|
+
import { ThreadId } from "./core/Identifiers.mjs";
|
|
4
|
+
import { IdempotencyKey } from "./core/Receipt.mjs";
|
|
5
|
+
import { DefinitionDigests, PersistedJson } from "./durable/Records.mjs";
|
|
6
|
+
import { digestJson } from "./durable/Digest.mjs";
|
|
7
|
+
import { ScheduleAuthorizer, ScheduleConflict, ScheduleDestination, ScheduleFailpoint, ScheduleInstant, ScheduleNotFound, ScheduleStorageError, ScheduleStore, ScheduleTimingRequest, ScheduleValidationError, ScheduleWake, ScheduledInputAdmission, SchedulingLimits, defaultSchedulingLimits } from "./durable/Schedule.mjs";
|
|
8
|
+
import { admitPreparedInput } from "./durable/PreparedInputAdmission.mjs";
|
|
9
|
+
import { Cause, Context, Cron, Crypto, DateTime, Effect, Layer, Option, Result, Schema, Semaphore } from "effect";
|
|
10
|
+
//#region src/durable/internal/schedule-time.ts
|
|
11
|
+
const invalid = (message) => Result.fail(ScheduleValidationError.make({ message }));
|
|
12
|
+
const checkedInstant = (millis, label) => Schema.decodeResult(ScheduleInstant)(millis).pipe(Result.mapError(() => ScheduleValidationError.make({ message: `${label} is outside the supported ScheduleInstant range` })));
|
|
13
|
+
const values = (set, size) => set.size === 0 ? Array.from({ length: size }, (_, index) => index) : [...set];
|
|
14
|
+
/**
|
|
15
|
+
* Cron frequency proof without calendar enumeration. It checks the minimum circular spacing of
|
|
16
|
+
* the allowed hour/minute pairs. Day restrictions may make a rule sparser, so this deliberately
|
|
17
|
+
* rejects some safe rules when a configured minimum exceeds one minute.
|
|
18
|
+
*/
|
|
19
|
+
const validateCronFrequency = (cron, minimumMillis) => {
|
|
20
|
+
if (cron.seconds.size !== 1) return invalid("Cron must select exactly one seconds value");
|
|
21
|
+
if (minimumMillis <= 6e4) return Result.succeed(void 0);
|
|
22
|
+
if (Option.isSome(cron.tz) && DateTime.isTimeZoneNamed(cron.tz.value) && cron.tz.value.id !== "UTC") return invalid("Cron minimums above one minute require UTC or a fixed-offset time zone");
|
|
23
|
+
const minuteOfDay = values(cron.hours, 24).flatMap((hour) => values(cron.minutes, 60).map((minute) => hour * 60 + minute));
|
|
24
|
+
minuteOfDay.sort((left, right) => left - right);
|
|
25
|
+
let minimumGap = 1440;
|
|
26
|
+
for (let index = 0; index < minuteOfDay.length; index += 1) {
|
|
27
|
+
const current = minuteOfDay[index];
|
|
28
|
+
const next = minuteOfDay[(index + 1) % minuteOfDay.length];
|
|
29
|
+
if (current === void 0 || next === void 0) continue;
|
|
30
|
+
const gap = next > current ? next - current : 1440 - current + next;
|
|
31
|
+
minimumGap = Math.min(minimumGap, gap);
|
|
32
|
+
}
|
|
33
|
+
return minimumGap * 6e4 >= minimumMillis ? Result.succeed(void 0) : invalid(`Cron may fire more often than the configured ${minimumMillis}ms minimum`);
|
|
34
|
+
};
|
|
35
|
+
const parseScheduleCron = (expression, timeZone, minimumMillis) => {
|
|
36
|
+
const parsed = Cron.parse(expression, timeZone);
|
|
37
|
+
if (Result.isFailure(parsed)) return invalid(parsed.failure.message);
|
|
38
|
+
const frequency = validateCronFrequency(parsed.success, minimumMillis);
|
|
39
|
+
return Result.isFailure(frequency) ? Result.fail(frequency.failure) : Result.succeed(parsed.success);
|
|
40
|
+
};
|
|
41
|
+
const normalizeScheduleTiming = (request, nowMillis, minimumMillis) => {
|
|
42
|
+
switch (request._tag) {
|
|
43
|
+
case "At": return Result.succeed(request);
|
|
44
|
+
case "After": {
|
|
45
|
+
const at = checkedInstant(nowMillis + request.delayMillis, "Relative deadline");
|
|
46
|
+
return Result.map(at, (atMillis) => ({
|
|
47
|
+
_tag: "At",
|
|
48
|
+
atMillis
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
case "Interval": {
|
|
52
|
+
if (request.everyMillis < minimumMillis) return invalid(`Interval must be at least ${minimumMillis}ms`);
|
|
53
|
+
const anchor = checkedInstant(request.anchorMillis ?? nowMillis + request.everyMillis, "Interval anchor");
|
|
54
|
+
return Result.map(anchor, (anchorMillis) => ({
|
|
55
|
+
_tag: "Interval",
|
|
56
|
+
everyMillis: request.everyMillis,
|
|
57
|
+
anchorMillis
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
case "Cron": {
|
|
61
|
+
const timeZone = request.timeZone ?? "UTC";
|
|
62
|
+
const cron = parseScheduleCron(request.expression, timeZone, minimumMillis);
|
|
63
|
+
if (Result.isFailure(cron)) return Result.fail(cron.failure);
|
|
64
|
+
return Result.succeed({
|
|
65
|
+
_tag: "Cron",
|
|
66
|
+
expression: request.expression,
|
|
67
|
+
timeZone
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const parsedStoredCron = (timing) => {
|
|
73
|
+
const parsed = Cron.parse(timing.expression, timing.timeZone);
|
|
74
|
+
return Result.isFailure(parsed) ? invalid(`Stored cron is invalid: ${parsed.failure.message}`) : Result.succeed(parsed.success);
|
|
75
|
+
};
|
|
76
|
+
/** Strictly selects the first occurrence after an instant. */
|
|
77
|
+
const scheduleNextAfter = (timing, afterMillis) => {
|
|
78
|
+
switch (timing._tag) {
|
|
79
|
+
case "At": return Result.succeed(timing.atMillis > afterMillis ? timing.atMillis : null);
|
|
80
|
+
case "Interval": {
|
|
81
|
+
if (afterMillis < timing.anchorMillis) return Result.succeed(timing.anchorMillis);
|
|
82
|
+
const steps = Math.floor((afterMillis - timing.anchorMillis) / timing.everyMillis) + 1;
|
|
83
|
+
const next = timing.anchorMillis + steps * timing.everyMillis;
|
|
84
|
+
return checkedInstant(next, "Next interval occurrence");
|
|
85
|
+
}
|
|
86
|
+
case "Cron": {
|
|
87
|
+
const cron = parsedStoredCron(timing);
|
|
88
|
+
if (Result.isFailure(cron)) return Result.fail(cron.failure);
|
|
89
|
+
return Result.try({
|
|
90
|
+
try: () => {
|
|
91
|
+
let next = Cron.next(cron.success, afterMillis).getTime();
|
|
92
|
+
while (next <= afterMillis) {
|
|
93
|
+
const following = Cron.next(cron.success, next).getTime();
|
|
94
|
+
if (following <= next) throw new Error("Cron did not advance");
|
|
95
|
+
next = following;
|
|
96
|
+
}
|
|
97
|
+
return next;
|
|
98
|
+
},
|
|
99
|
+
catch: () => ScheduleValidationError.make({ message: "Cron has no supported next firing" })
|
|
100
|
+
}).pipe(Result.flatMap((next) => checkedInstant(next, "Next cron occurrence")));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/** Initial cursor. Past one-shots remain due; recurring rules start strictly after registration. */
|
|
105
|
+
const scheduleInitialCursor = (timing, nowMillis) => timing._tag === "At" ? Result.succeed(timing.atMillis) : scheduleNextAfter(timing, nowMillis);
|
|
106
|
+
/** Coalesces recurring occurrences using the same forward sequence as registration. */
|
|
107
|
+
const scheduleDueOccurrence = (timing, cursorMillis, nowMillis) => {
|
|
108
|
+
if (cursorMillis > nowMillis) return Result.succeed(null);
|
|
109
|
+
if (timing._tag === "At") return Result.succeed({
|
|
110
|
+
intendedAtMillis: cursorMillis,
|
|
111
|
+
nextAtMillis: null,
|
|
112
|
+
skippedRange: null
|
|
113
|
+
});
|
|
114
|
+
let intendedAtMillis;
|
|
115
|
+
if (timing._tag === "Interval") {
|
|
116
|
+
const steps = Math.floor((nowMillis - timing.anchorMillis) / timing.everyMillis);
|
|
117
|
+
intendedAtMillis = Math.max(cursorMillis, timing.anchorMillis + steps * timing.everyMillis);
|
|
118
|
+
} else {
|
|
119
|
+
const cron = parsedStoredCron(timing);
|
|
120
|
+
if (Result.isFailure(cron)) return Result.fail(cron.failure);
|
|
121
|
+
const due = Result.try({
|
|
122
|
+
try: () => {
|
|
123
|
+
let intended = cursorMillis;
|
|
124
|
+
const zone = Option.getOrUndefined(cron.success.tz);
|
|
125
|
+
if (zone !== void 0 && (DateTime.isTimeZoneOffset(zone) || zone.id === "UTC")) intended = Math.max(cursorMillis, Cron.prev(cron.success, nowMillis + 1e3).getTime());
|
|
126
|
+
else {
|
|
127
|
+
const calendar = Cron.make({
|
|
128
|
+
...cron.success,
|
|
129
|
+
seconds: [0],
|
|
130
|
+
minutes: [0],
|
|
131
|
+
hours: [0],
|
|
132
|
+
tz: DateTime.zoneMakeNamedUnsafe("UTC")
|
|
133
|
+
});
|
|
134
|
+
const localDay = DateTime.makeUnsafe(DateTime.toDate(DateTime.makeZonedUnsafe(nowMillis, { timeZone: zone }))).pipe(DateTime.startOf("day"), DateTime.subtract({ days: 2 }));
|
|
135
|
+
const seedDay = Cron.prev(calendar, DateTime.toEpochMillis(localDay) + 1e3);
|
|
136
|
+
const seed = DateTime.makeZonedUnsafe(seedDay, {
|
|
137
|
+
timeZone: zone,
|
|
138
|
+
adjustForTimeZone: true
|
|
139
|
+
}).pipe(DateTime.toEpochMillis) - 1e3;
|
|
140
|
+
if (seed > cursorMillis) {
|
|
141
|
+
const first = Cron.next(cron.success, seed).getTime();
|
|
142
|
+
if (first <= nowMillis) intended = Math.max(intended, first);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
let next = Cron.next(cron.success, intended).getTime();
|
|
146
|
+
while (next <= nowMillis) {
|
|
147
|
+
if (next <= intended) throw new Error("Cron did not advance");
|
|
148
|
+
intended = next;
|
|
149
|
+
next = Cron.next(cron.success, intended).getTime();
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
intended,
|
|
153
|
+
next
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
catch: () => ScheduleValidationError.make({ message: "Cron has no supported due firing" })
|
|
157
|
+
});
|
|
158
|
+
if (Result.isFailure(due)) return Result.fail(due.failure);
|
|
159
|
+
const next = checkedInstant(due.success.next, "Next cron occurrence");
|
|
160
|
+
if (Result.isFailure(next)) return Result.fail(next.failure);
|
|
161
|
+
return Result.succeed({
|
|
162
|
+
intendedAtMillis: due.success.intended,
|
|
163
|
+
nextAtMillis: next.success,
|
|
164
|
+
skippedRange: due.success.intended === cursorMillis ? null : {
|
|
165
|
+
fromMillis: cursorMillis,
|
|
166
|
+
toMillis: due.success.intended
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const next = scheduleNextAfter(timing, nowMillis);
|
|
171
|
+
if (Result.isFailure(next)) return Result.fail(next.failure);
|
|
172
|
+
return Result.succeed({
|
|
173
|
+
intendedAtMillis,
|
|
174
|
+
nextAtMillis: next.success,
|
|
175
|
+
skippedRange: intendedAtMillis === cursorMillis ? null : {
|
|
176
|
+
fromMillis: cursorMillis,
|
|
177
|
+
toMillis: intendedAtMillis
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
const scheduleResumeCursor = (timing, existingCursor, nowMillis) => {
|
|
182
|
+
if (timing._tag === "At") return Result.succeed(existingCursor);
|
|
183
|
+
return scheduleNextAfter(timing, nowMillis);
|
|
184
|
+
};
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/durable/Scheduling.ts
|
|
187
|
+
var Scheduling_exports = /* @__PURE__ */ __exportAll({
|
|
188
|
+
ScheduleDriver: () => ScheduleDriver,
|
|
189
|
+
ScheduleWakeNoop: () => ScheduleWakeNoop,
|
|
190
|
+
Scheduling: () => Scheduling
|
|
191
|
+
});
|
|
192
|
+
const equivalentDefinitions = Schema.toEquivalence(DefinitionDigests);
|
|
193
|
+
const equivalentInput = Schema.toEquivalence(PersistedJson);
|
|
194
|
+
const keyOf = (scope, scheduleId) => ({
|
|
195
|
+
owner: scope.owner,
|
|
196
|
+
scheduleId
|
|
197
|
+
});
|
|
198
|
+
const notFound = (key) => ScheduleNotFound.make({ key });
|
|
199
|
+
const asSnapshot = (record, observedAtMillis) => {
|
|
200
|
+
const intendedAtMillis = record.pending?.envelope.intendedAtMillis ?? record.nextAtMillis;
|
|
201
|
+
return {
|
|
202
|
+
owner: record.owner,
|
|
203
|
+
scheduleId: record.scheduleId,
|
|
204
|
+
createdAtMillis: record.createdAtMillis,
|
|
205
|
+
updatedAtMillis: record.updatedAtMillis,
|
|
206
|
+
configurationRevision: record.configurationRevision,
|
|
207
|
+
configuration: {
|
|
208
|
+
timing: record.configuration.timing,
|
|
209
|
+
destination: record.configuration.destination,
|
|
210
|
+
deliveryPrincipal: record.configuration.deliveryPrincipal,
|
|
211
|
+
...record.configuration.admissionGroup === void 0 ? {} : { admissionGroup: record.configuration.admissionGroup },
|
|
212
|
+
...record.configuration.admissionFence === void 0 ? {} : { admissionFence: record.configuration.admissionFence },
|
|
213
|
+
agentId: record.configuration.agentId
|
|
214
|
+
},
|
|
215
|
+
state: record.state,
|
|
216
|
+
nextAtMillis: record.nextAtMillis,
|
|
217
|
+
pending: record.pending === null ? null : {
|
|
218
|
+
intendedAtMillis: record.pending.envelope.intendedAtMillis,
|
|
219
|
+
preparedAtMillis: record.pending.envelope.preparedAtMillis,
|
|
220
|
+
configurationRevision: record.pending.envelope.configurationRevision,
|
|
221
|
+
occurrenceId: record.pending.envelope.occurrenceId,
|
|
222
|
+
retry: record.pending.retry
|
|
223
|
+
},
|
|
224
|
+
lastReceipt: record.lastReceipt,
|
|
225
|
+
lastRefusal: record.lastRefusal,
|
|
226
|
+
lastSkippedRange: record.lastSkippedRange,
|
|
227
|
+
observedAtMillis,
|
|
228
|
+
pendingAgeMillis: record.pending === null ? null : Math.max(0, observedAtMillis - record.pending.envelope.preparedAtMillis),
|
|
229
|
+
latenessMillis: intendedAtMillis === null ? 0 : Math.max(0, observedAtMillis - intendedAtMillis)
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
const inputByteLength = (input) => utf8ByteLength(JSON.stringify(input));
|
|
233
|
+
const currentMillis = DateTime.now.pipe(Effect.map(DateTime.toEpochMillis));
|
|
234
|
+
const validateRequestedFields = Effect.fn("Scheduling.validateRequestedFields")(function* (options) {
|
|
235
|
+
yield* Schema.encodeEffect(ScheduleTimingRequest)(options.timing).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Invalid timing request" })));
|
|
236
|
+
yield* Schema.encodeEffect(ScheduleDestination)(options.destination).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Invalid destination" })));
|
|
237
|
+
yield* Schema.encodeEffect(DefinitionDigests)(options.definitions).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Invalid definition digests" })));
|
|
238
|
+
});
|
|
239
|
+
const resolveInput = Effect.fn("Scheduling.resolveInput")(function* (agent, input, maximumBytes) {
|
|
240
|
+
const encoded = yield* Schema.encodeEffect(agent.definition.input)(input).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Unable to encode Agent input" })));
|
|
241
|
+
const payload = yield* Schema.decodeUnknownEffect(PersistedJson)(encoded).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Agent input does not satisfy the canonical persistence bounds" })));
|
|
242
|
+
if (inputByteLength(payload) > maximumBytes) return yield* ScheduleValidationError.make({ message: `Encoded Agent input exceeds the configured ${maximumBytes} byte limit` });
|
|
243
|
+
return {
|
|
244
|
+
payload,
|
|
245
|
+
digest: yield* digestJson(payload).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Unable to digest encoded Agent input" })))
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
const makeManagement = (limits) => Effect.gen(function* () {
|
|
249
|
+
const nowMillis = yield* currentMillis;
|
|
250
|
+
yield* Schema.decodeEffect(ScheduleInstant)(nowMillis + limits.recoveryPollMillis).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Scheduling recovery deadline exceeds the supported instant range" })));
|
|
251
|
+
const store = yield* ScheduleStore;
|
|
252
|
+
const authorizer = yield* ScheduleAuthorizer;
|
|
253
|
+
const wake = yield* ScheduleWake;
|
|
254
|
+
const crypto = yield* Crypto.Crypto;
|
|
255
|
+
const withCrypto = (effect) => Effect.provideService(effect, Crypto.Crypto, crypto);
|
|
256
|
+
const fingerprint = Effect.fn("Scheduling.fingerprint")(function* (agentId, inputDigest, options) {
|
|
257
|
+
const timing = yield* Schema.encodeEffect(ScheduleTimingRequest)(options.timing).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Invalid timing request" })));
|
|
258
|
+
const destination = yield* Schema.encodeEffect(ScheduleDestination)(options.destination).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Invalid destination" })));
|
|
259
|
+
const definitions = yield* Schema.encodeEffect(DefinitionDigests)(options.definitions).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Invalid definition digests" })));
|
|
260
|
+
return yield* withCrypto(digestJson({
|
|
261
|
+
schemaVersion: 1,
|
|
262
|
+
owner: options.scope.owner,
|
|
263
|
+
scheduleId: options.scheduleId,
|
|
264
|
+
registeringPrincipal: options.scope.principal,
|
|
265
|
+
deliveryPrincipal: options.deliveryPrincipal,
|
|
266
|
+
...options.admissionGroup === void 0 ? {} : { admissionGroup: options.admissionGroup },
|
|
267
|
+
...options.admissionFence === void 0 ? {} : { admissionFence: options.admissionFence },
|
|
268
|
+
agentId,
|
|
269
|
+
definitions,
|
|
270
|
+
destination,
|
|
271
|
+
timing,
|
|
272
|
+
inputDigest
|
|
273
|
+
})).pipe(Effect.mapError(() => ScheduleValidationError.make({ message: "Unable to digest Schedule registration" })));
|
|
274
|
+
});
|
|
275
|
+
const configuration = (agentId, payload, inputDigest, options, timing) => ({
|
|
276
|
+
timing,
|
|
277
|
+
destination: options.destination,
|
|
278
|
+
deliveryPrincipal: options.deliveryPrincipal,
|
|
279
|
+
...options.admissionGroup === void 0 ? {} : { admissionGroup: options.admissionGroup },
|
|
280
|
+
...options.admissionFence === void 0 ? {} : { admissionFence: options.admissionFence },
|
|
281
|
+
agentId,
|
|
282
|
+
definitions: options.definitions,
|
|
283
|
+
input: payload,
|
|
284
|
+
inputDigest
|
|
285
|
+
});
|
|
286
|
+
const create = Effect.fn("Scheduling.create")(function* (agent, input, options) {
|
|
287
|
+
const nowMillis = yield* currentMillis;
|
|
288
|
+
const resolvedInput = yield* resolveInput(agent, input, limits.maxInputBytes).pipe(Effect.provideService(Crypto.Crypto, crypto));
|
|
289
|
+
const creationFingerprint = yield* fingerprint(agent.definition.id, resolvedInput.digest, options);
|
|
290
|
+
const key = keyOf(options.scope, options.scheduleId);
|
|
291
|
+
yield* authorizer.manage({
|
|
292
|
+
operation: "create",
|
|
293
|
+
scope: options.scope,
|
|
294
|
+
scheduleId: options.scheduleId
|
|
295
|
+
});
|
|
296
|
+
const existing = yield* store.get(key);
|
|
297
|
+
if (existing !== null) {
|
|
298
|
+
if (existing.creationFingerprint !== creationFingerprint) return yield* ScheduleConflict.make({
|
|
299
|
+
reason: "creation",
|
|
300
|
+
key
|
|
301
|
+
});
|
|
302
|
+
yield* authorizer.manage({
|
|
303
|
+
operation: "create",
|
|
304
|
+
scope: options.scope,
|
|
305
|
+
scheduleId: options.scheduleId,
|
|
306
|
+
configuration: existing.configuration
|
|
307
|
+
});
|
|
308
|
+
return asSnapshot(existing, nowMillis);
|
|
309
|
+
}
|
|
310
|
+
const timing = yield* Effect.fromResult(normalizeScheduleTiming(options.timing, nowMillis, limits.minIntervalMillis));
|
|
311
|
+
const nextAtMillis = yield* Effect.fromResult(scheduleInitialCursor(timing, nowMillis));
|
|
312
|
+
if (nextAtMillis === null) return yield* ScheduleValidationError.make({ message: "Timing has no next occurrence" });
|
|
313
|
+
const nextConfiguration = configuration(agent.definition.id, resolvedInput.payload, resolvedInput.digest, options, timing);
|
|
314
|
+
yield* authorizer.manage({
|
|
315
|
+
operation: "create",
|
|
316
|
+
scope: options.scope,
|
|
317
|
+
scheduleId: options.scheduleId,
|
|
318
|
+
configuration: nextConfiguration
|
|
319
|
+
});
|
|
320
|
+
const record = {
|
|
321
|
+
schemaVersion: 1,
|
|
322
|
+
owner: options.scope.owner,
|
|
323
|
+
scheduleId: options.scheduleId,
|
|
324
|
+
creationFingerprint,
|
|
325
|
+
createdBy: options.scope.principal,
|
|
326
|
+
createdAtMillis: nowMillis,
|
|
327
|
+
updatedAtMillis: nowMillis,
|
|
328
|
+
configurationRevision: 1,
|
|
329
|
+
version: 1,
|
|
330
|
+
configuration: nextConfiguration,
|
|
331
|
+
state: "active",
|
|
332
|
+
nextAtMillis,
|
|
333
|
+
pending: null,
|
|
334
|
+
lastReceipt: null,
|
|
335
|
+
lastRefusal: null,
|
|
336
|
+
lastSkippedRange: null
|
|
337
|
+
};
|
|
338
|
+
const inserted = yield* store.insert(record, limits.maxSchedulesPerOwner);
|
|
339
|
+
yield* wake.notify;
|
|
340
|
+
return asSnapshot(inserted, nowMillis);
|
|
341
|
+
});
|
|
342
|
+
const update = Effect.fn("Scheduling.update")(function* (agent, input, options) {
|
|
343
|
+
const nowMillis = yield* currentMillis;
|
|
344
|
+
const key = keyOf(options.scope, options.scheduleId);
|
|
345
|
+
yield* authorizer.manage({
|
|
346
|
+
operation: "update",
|
|
347
|
+
scope: options.scope,
|
|
348
|
+
scheduleId: options.scheduleId
|
|
349
|
+
});
|
|
350
|
+
yield* validateRequestedFields(options);
|
|
351
|
+
const existing = yield* store.get(key);
|
|
352
|
+
if (existing === null) return yield* notFound(key);
|
|
353
|
+
if (existing.configurationRevision !== options.expectedRevision) return yield* ScheduleConflict.make({
|
|
354
|
+
reason: "revision",
|
|
355
|
+
key
|
|
356
|
+
});
|
|
357
|
+
const resolvedInput = yield* resolveInput(agent, input, limits.maxInputBytes).pipe(Effect.provideService(Crypto.Crypto, crypto));
|
|
358
|
+
const timingRequest = options.timing._tag === "Interval" && options.timing.anchorMillis === void 0 && existing.configuration.timing._tag === "Interval" && existing.configuration.timing.everyMillis === options.timing.everyMillis ? {
|
|
359
|
+
...options.timing,
|
|
360
|
+
anchorMillis: existing.configuration.timing.anchorMillis
|
|
361
|
+
} : options.timing;
|
|
362
|
+
const timing = yield* Effect.fromResult(normalizeScheduleTiming(timingRequest, nowMillis, limits.minIntervalMillis));
|
|
363
|
+
const nextAtMillis = timing._tag === "At" ? timing.atMillis : yield* Effect.fromResult(scheduleNextAfter(timing, nowMillis));
|
|
364
|
+
if (nextAtMillis === null) return yield* ScheduleValidationError.make({ message: "Timing has no next occurrence" });
|
|
365
|
+
const nextConfiguration = configuration(agent.definition.id, resolvedInput.payload, resolvedInput.digest, options, timing);
|
|
366
|
+
yield* authorizer.manage({
|
|
367
|
+
operation: "update",
|
|
368
|
+
scope: options.scope,
|
|
369
|
+
scheduleId: options.scheduleId,
|
|
370
|
+
configuration: nextConfiguration
|
|
371
|
+
});
|
|
372
|
+
const changed = yield* store.change(key, {
|
|
373
|
+
_tag: "Update",
|
|
374
|
+
expectedRevision: options.expectedRevision,
|
|
375
|
+
configuration: nextConfiguration,
|
|
376
|
+
nextAtMillis,
|
|
377
|
+
nowMillis
|
|
378
|
+
}, limits.maxSchedulesPerOwner);
|
|
379
|
+
yield* wake.notify;
|
|
380
|
+
return asSnapshot(changed, nowMillis);
|
|
381
|
+
});
|
|
382
|
+
const get = Effect.fn("Scheduling.get")(function* (scope, scheduleId) {
|
|
383
|
+
yield* authorizer.manage({
|
|
384
|
+
operation: "get",
|
|
385
|
+
scope,
|
|
386
|
+
scheduleId
|
|
387
|
+
});
|
|
388
|
+
const key = keyOf(scope, scheduleId);
|
|
389
|
+
const record = yield* store.get(key);
|
|
390
|
+
if (record === null) return yield* notFound(key);
|
|
391
|
+
return asSnapshot(record, yield* currentMillis);
|
|
392
|
+
});
|
|
393
|
+
const list = Effect.fn("Scheduling.list")(function* (scope, options = {}) {
|
|
394
|
+
yield* authorizer.manage({
|
|
395
|
+
operation: "list",
|
|
396
|
+
scope
|
|
397
|
+
});
|
|
398
|
+
const limit = options.limit ?? 50;
|
|
399
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 100) return yield* ScheduleValidationError.make({ message: "Schedule page limit must be an integer from 1 through 100" });
|
|
400
|
+
const page = yield* store.list({
|
|
401
|
+
owner: scope.owner,
|
|
402
|
+
...options.after === void 0 ? {} : { after: options.after },
|
|
403
|
+
limit
|
|
404
|
+
});
|
|
405
|
+
const nowMillis = yield* currentMillis;
|
|
406
|
+
return {
|
|
407
|
+
items: page.items.map((record) => asSnapshot(record, nowMillis)),
|
|
408
|
+
next: page.next
|
|
409
|
+
};
|
|
410
|
+
});
|
|
411
|
+
const control = Effect.fn("Scheduling.control")(function* (operation, scope, scheduleId, expectedRevision) {
|
|
412
|
+
yield* authorizer.manage({
|
|
413
|
+
operation,
|
|
414
|
+
scope,
|
|
415
|
+
scheduleId
|
|
416
|
+
});
|
|
417
|
+
const key = keyOf(scope, scheduleId);
|
|
418
|
+
const attempt = () => Effect.suspend(() => Effect.gen(function* () {
|
|
419
|
+
const record = yield* store.get(key);
|
|
420
|
+
if (record === null) return yield* notFound(key);
|
|
421
|
+
if (record.configurationRevision !== expectedRevision) return yield* ScheduleConflict.make({
|
|
422
|
+
reason: "revision",
|
|
423
|
+
key
|
|
424
|
+
});
|
|
425
|
+
if (operation === "resume" && record.state === "active") return record;
|
|
426
|
+
const nowMillis = yield* currentMillis;
|
|
427
|
+
const nextAtMillis = operation === "resume" ? yield* Effect.fromResult(scheduleResumeCursor(record.configuration.timing, record.nextAtMillis, nowMillis)) : operation === "cancel" ? null : record.nextAtMillis;
|
|
428
|
+
const skippedRange = operation === "resume" && record.configuration.timing._tag !== "At" && record.nextAtMillis !== null && nextAtMillis !== null && nextAtMillis > record.nextAtMillis ? {
|
|
429
|
+
fromMillis: record.nextAtMillis,
|
|
430
|
+
toMillis: nextAtMillis
|
|
431
|
+
} : null;
|
|
432
|
+
return yield* store.change(key, {
|
|
433
|
+
_tag: "Control",
|
|
434
|
+
expectedRevision,
|
|
435
|
+
expectedVersion: record.version,
|
|
436
|
+
action: operation,
|
|
437
|
+
nextAtMillis,
|
|
438
|
+
nowMillis,
|
|
439
|
+
skippedRange
|
|
440
|
+
}, limits.maxSchedulesPerOwner).pipe(Effect.catchTag("ScheduleConflict", (error) => error.reason === "revision" ? attempt() : Effect.fail(error)));
|
|
441
|
+
}));
|
|
442
|
+
const changed = yield* attempt();
|
|
443
|
+
yield* wake.notify;
|
|
444
|
+
return asSnapshot(changed, yield* currentMillis);
|
|
445
|
+
});
|
|
446
|
+
const recover = Effect.fn("Scheduling.recover")(function* (scope, scheduleId, expectedRevision, expectedGeneration) {
|
|
447
|
+
yield* authorizer.manage({
|
|
448
|
+
operation: "recover",
|
|
449
|
+
scope,
|
|
450
|
+
scheduleId
|
|
451
|
+
});
|
|
452
|
+
const key = keyOf(scope, scheduleId);
|
|
453
|
+
const record = yield* store.get(key);
|
|
454
|
+
if (record === null) return yield* notFound(key);
|
|
455
|
+
if (record.configurationRevision !== expectedRevision) return yield* ScheduleConflict.make({
|
|
456
|
+
reason: "revision",
|
|
457
|
+
key
|
|
458
|
+
});
|
|
459
|
+
const time = yield* currentMillis;
|
|
460
|
+
if (record.pending === null) return asSnapshot(record, time);
|
|
461
|
+
const recovered = yield* store.change(key, {
|
|
462
|
+
_tag: "Recover",
|
|
463
|
+
expectedGeneration,
|
|
464
|
+
expectedRevision,
|
|
465
|
+
occurrenceId: record.pending.envelope.occurrenceId,
|
|
466
|
+
nowMillis: time
|
|
467
|
+
});
|
|
468
|
+
yield* wake.notify;
|
|
469
|
+
return asSnapshot(recovered, time);
|
|
470
|
+
});
|
|
471
|
+
return Scheduling.of({
|
|
472
|
+
recover,
|
|
473
|
+
create,
|
|
474
|
+
update,
|
|
475
|
+
get,
|
|
476
|
+
list,
|
|
477
|
+
pause: (scope, id, revision) => control("pause", scope, id, revision),
|
|
478
|
+
resume: (scope, id, revision) => control("resume", scope, id, revision),
|
|
479
|
+
cancel: (scope, id, revision) => control("cancel", scope, id, revision)
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
const makeDriver = (limits) => Effect.gen(function* () {
|
|
483
|
+
const store = yield* ScheduleStore;
|
|
484
|
+
const authorizer = yield* ScheduleAuthorizer;
|
|
485
|
+
const admission = yield* ScheduledInputAdmission;
|
|
486
|
+
const failpoint = yield* ScheduleFailpoint;
|
|
487
|
+
const crypto = yield* Crypto.Crypto;
|
|
488
|
+
const admissionSemaphore = yield* Semaphore.make(limits.admissionConcurrency);
|
|
489
|
+
const withCrypto = (effect) => Effect.provideService(effect, Crypto.Crypto, crypto);
|
|
490
|
+
const retry = Effect.fn("Scheduling.retry")(function* (key, record, reason, nowMillis) {
|
|
491
|
+
if (record.pending === null) return record;
|
|
492
|
+
const current = record.pending.retry;
|
|
493
|
+
const delay = Math.min(limits.retryBaseMillis * 2 ** Math.min(current.attempts, 52), limits.retryMaxMillis);
|
|
494
|
+
return yield* store.change(key, {
|
|
495
|
+
_tag: "Retry",
|
|
496
|
+
occurrenceId: record.pending.envelope.occurrenceId,
|
|
497
|
+
retry: {
|
|
498
|
+
generation: current.generation,
|
|
499
|
+
attempts: current.attempts + 1,
|
|
500
|
+
automaticAttempts: current.automaticAttempts + 1,
|
|
501
|
+
parked: current.automaticAttempts + 1 >= (limits.maxAutomaticAttempts ?? 8),
|
|
502
|
+
nextAttemptAtMillis: Math.min(nowMillis + delay, 864e13),
|
|
503
|
+
lastAttemptAtMillis: nowMillis,
|
|
504
|
+
lastFailure: reason
|
|
505
|
+
},
|
|
506
|
+
nowMillis
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
const verifyPending = Effect.fn("Scheduling.verifyPending")(function* (key, record) {
|
|
510
|
+
const pending = record.pending;
|
|
511
|
+
if (pending === null) return;
|
|
512
|
+
const envelope = pending.envelope;
|
|
513
|
+
const occurrenceId = yield* withCrypto(digestJson({
|
|
514
|
+
schemaVersion: 1,
|
|
515
|
+
owner: envelope.owner,
|
|
516
|
+
scheduleId: envelope.scheduleId,
|
|
517
|
+
configurationRevision: envelope.configurationRevision,
|
|
518
|
+
intendedAtMillis: envelope.intendedAtMillis
|
|
519
|
+
})).pipe(Effect.mapError(() => corrupt("process")));
|
|
520
|
+
const usesCurrentConfiguration = envelope.configurationRevision === record.configurationRevision;
|
|
521
|
+
const expectedThreadId = usesCurrentConfiguration ? record.configuration.destination._tag === "ExistingThread" ? record.configuration.destination.threadId : Schema.decodeSync(ThreadId)(`schedule-thread:${envelope.occurrenceId}`) : null;
|
|
522
|
+
const expectedAdmissionKey = Schema.decodeSync(IdempotencyKey)(`schedule-occurrence:${envelope.occurrenceId}`);
|
|
523
|
+
const digest = yield* withCrypto(digestJson(envelope.input)).pipe(Effect.mapError(() => corrupt("process")));
|
|
524
|
+
if (envelope.schemaVersion !== 1 || envelope.owner.tenantId !== key.owner.tenantId || envelope.owner.ownerId !== key.owner.ownerId || envelope.scheduleId !== key.scheduleId || envelope.configurationRevision > record.configurationRevision || envelope.occurrenceId !== occurrenceId || usesCurrentConfiguration && (envelope.deliveryPrincipal !== record.configuration.deliveryPrincipal || envelope.agentId !== record.configuration.agentId || !equivalentDefinitions(envelope.definitions, record.configuration.definitions) || !equivalentInput(envelope.input, record.configuration.input) || envelope.inputDigest !== record.configuration.inputDigest) || envelope.inputDigest !== digest || expectedThreadId !== null && envelope.threadId !== expectedThreadId || envelope.admissionKey !== expectedAdmissionKey) return yield* corrupt("process");
|
|
525
|
+
});
|
|
526
|
+
const deliverPending = Effect.fn("Scheduling.deliverPending")(function* (key, record, nowMillis) {
|
|
527
|
+
if (record.pending === null || record.pending.retry.parked === true || record.pending.retry.nextAttemptAtMillis > nowMillis) return record;
|
|
528
|
+
yield* verifyPending(key, record);
|
|
529
|
+
const envelope = record.pending.envelope;
|
|
530
|
+
const outcome = yield* admissionSemaphore.withPermit(admitPreparedInput(admission.submit(envelope), limits.admissionTimeoutMillis).pipe(Effect.tap((outcome) => outcome._tag === "Receipt" ? failpoint.hit("schedule:admission:after") : Effect.void)));
|
|
531
|
+
const completedAtMillis = yield* currentMillis;
|
|
532
|
+
if (outcome._tag === "Receipt") {
|
|
533
|
+
if (outcome.receipt.threadId !== envelope.threadId) return yield* corrupt("admission");
|
|
534
|
+
return yield* store.change(key, {
|
|
535
|
+
_tag: "Complete",
|
|
536
|
+
occurrenceId: envelope.occurrenceId,
|
|
537
|
+
receipt: outcome.receipt,
|
|
538
|
+
nowMillis: completedAtMillis
|
|
539
|
+
}).pipe(Effect.catchTag("ScheduleStorageError", (error) => error.reason === "unavailable" ? retry(key, record, "storage", completedAtMillis) : Effect.fail(error)));
|
|
540
|
+
}
|
|
541
|
+
if (outcome._tag === "Refused") {
|
|
542
|
+
const refusal = {
|
|
543
|
+
atMillis: completedAtMillis,
|
|
544
|
+
intendedAtMillis: envelope.intendedAtMillis,
|
|
545
|
+
occurrenceId: envelope.occurrenceId,
|
|
546
|
+
phase: "admission",
|
|
547
|
+
code: outcome.error.code
|
|
548
|
+
};
|
|
549
|
+
return yield* store.change(key, {
|
|
550
|
+
_tag: "Refuse",
|
|
551
|
+
occurrenceId: envelope.occurrenceId,
|
|
552
|
+
refusal,
|
|
553
|
+
nowMillis: completedAtMillis
|
|
554
|
+
}).pipe(Effect.catchTag("ScheduleStorageError", (error) => error.reason === "unavailable" ? retry(key, record, "storage", completedAtMillis) : Effect.fail(error)));
|
|
555
|
+
}
|
|
556
|
+
return yield* retry(key, record, outcome.reason, completedAtMillis);
|
|
557
|
+
});
|
|
558
|
+
const processRecord = Effect.fn("Scheduling.processRecord")(function* (key, initial, nowMillis) {
|
|
559
|
+
if (initial.pending !== null) return yield* deliverPending(key, initial, nowMillis);
|
|
560
|
+
if (initial.state !== "active" || initial.nextAtMillis === null || initial.nextAtMillis > nowMillis) return initial;
|
|
561
|
+
if ((yield* withCrypto(digestJson(initial.configuration.input)).pipe(Effect.mapError(() => ScheduleStorageError.make({
|
|
562
|
+
operation: "prepare",
|
|
563
|
+
reason: "unavailable"
|
|
564
|
+
})))) !== initial.configuration.inputDigest) return yield* corrupt("prepare");
|
|
565
|
+
const due = yield* Effect.fromResult(scheduleDueOccurrence(initial.configuration.timing, initial.nextAtMillis, nowMillis));
|
|
566
|
+
if (due === null) return initial;
|
|
567
|
+
const occurrenceId = yield* withCrypto(digestJson({
|
|
568
|
+
schemaVersion: 1,
|
|
569
|
+
owner: initial.owner,
|
|
570
|
+
scheduleId: initial.scheduleId,
|
|
571
|
+
configurationRevision: initial.configurationRevision,
|
|
572
|
+
intendedAtMillis: due.intendedAtMillis
|
|
573
|
+
})).pipe(Effect.mapError(() => corrupt("prepare")));
|
|
574
|
+
const occurrence = {
|
|
575
|
+
key,
|
|
576
|
+
configurationRevision: initial.configurationRevision,
|
|
577
|
+
configuration: initial.configuration,
|
|
578
|
+
intendedAtMillis: due.intendedAtMillis,
|
|
579
|
+
occurrenceId
|
|
580
|
+
};
|
|
581
|
+
const authorization = yield* authorizer.prepare(occurrence).pipe(Effect.result);
|
|
582
|
+
if (Result.isFailure(authorization)) {
|
|
583
|
+
if (authorization.failure._tag === "ScheduleStorageError") return yield* authorization.failure;
|
|
584
|
+
return yield* store.change(key, {
|
|
585
|
+
_tag: "DenyPreparation",
|
|
586
|
+
expectedRevision: initial.configurationRevision,
|
|
587
|
+
expectedCursor: initial.nextAtMillis,
|
|
588
|
+
refusal: {
|
|
589
|
+
atMillis: nowMillis,
|
|
590
|
+
intendedAtMillis: due.intendedAtMillis,
|
|
591
|
+
occurrenceId,
|
|
592
|
+
phase: "preparation",
|
|
593
|
+
code: authorization.failure.code
|
|
594
|
+
},
|
|
595
|
+
nowMillis
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
const threadId = initial.configuration.destination._tag === "ExistingThread" ? initial.configuration.destination.threadId : Schema.decodeSync(ThreadId)(`schedule-thread:${occurrenceId}`);
|
|
599
|
+
const admissionKey = Schema.decodeSync(IdempotencyKey)(`schedule-occurrence:${occurrenceId}`);
|
|
600
|
+
const prepared = yield* store.change(key, {
|
|
601
|
+
_tag: "Prepare",
|
|
602
|
+
expectedRevision: initial.configurationRevision,
|
|
603
|
+
expectedCursor: initial.nextAtMillis,
|
|
604
|
+
envelope: {
|
|
605
|
+
schemaVersion: 1,
|
|
606
|
+
owner: initial.owner,
|
|
607
|
+
scheduleId: initial.scheduleId,
|
|
608
|
+
configurationRevision: initial.configurationRevision,
|
|
609
|
+
intendedAtMillis: due.intendedAtMillis,
|
|
610
|
+
preparedAtMillis: nowMillis,
|
|
611
|
+
occurrenceId,
|
|
612
|
+
threadId,
|
|
613
|
+
deliveryPrincipal: initial.configuration.deliveryPrincipal,
|
|
614
|
+
...initial.configuration.admissionGroup === void 0 ? {} : { admissionGroup: initial.configuration.admissionGroup },
|
|
615
|
+
...initial.configuration.admissionFence === void 0 ? {} : { admissionFence: initial.configuration.admissionFence },
|
|
616
|
+
agentId: initial.configuration.agentId,
|
|
617
|
+
definitions: initial.configuration.definitions,
|
|
618
|
+
input: initial.configuration.input,
|
|
619
|
+
inputDigest: initial.configuration.inputDigest,
|
|
620
|
+
admissionKey,
|
|
621
|
+
authorization: authorization.success
|
|
622
|
+
},
|
|
623
|
+
nextAtMillis: due.nextAtMillis,
|
|
624
|
+
skippedRange: due.skippedRange,
|
|
625
|
+
nowMillis
|
|
626
|
+
});
|
|
627
|
+
return yield* deliverPending(key, prepared, nowMillis);
|
|
628
|
+
});
|
|
629
|
+
const process = Effect.fn("Scheduling.process")(function* (key) {
|
|
630
|
+
const nowMillis = yield* currentMillis;
|
|
631
|
+
const record = yield* store.get(key);
|
|
632
|
+
if (record === null) return yield* notFound(key);
|
|
633
|
+
return yield* processRecord(key, record, nowMillis).pipe(Effect.catchTag("ScheduleConflict", () => store.get(key).pipe(Effect.flatMap((current) => current === null ? Effect.fail(notFound(key)) : processRecord(key, current, nowMillis)))));
|
|
634
|
+
});
|
|
635
|
+
const runDue = Effect.fn("ScheduleDriver.runDue")(function* (owner) {
|
|
636
|
+
const nowMillis = yield* currentMillis;
|
|
637
|
+
let after;
|
|
638
|
+
let processed = 0;
|
|
639
|
+
let failed = 0;
|
|
640
|
+
while (true) {
|
|
641
|
+
const due = yield* store.due(nowMillis, limits.dueBatchSize, owner, after);
|
|
642
|
+
if (due.length === 0) break;
|
|
643
|
+
yield* Effect.forEach(due, (key) => process(key).pipe(Effect.matchCauseEffect({
|
|
644
|
+
onSuccess: () => Effect.sync(() => {
|
|
645
|
+
processed += 1;
|
|
646
|
+
}),
|
|
647
|
+
onFailure: (cause) => Cause.hasInterrupts(cause) ? Effect.interrupt : Effect.gen(function* () {
|
|
648
|
+
failed += 1;
|
|
649
|
+
yield* Effect.logWarning("Schedule processing failed").pipe(Effect.annotateLogs({ failureTag: Option.match(Cause.findErrorOption(cause), {
|
|
650
|
+
onNone: () => "Defect",
|
|
651
|
+
onSome: (error) => error._tag
|
|
652
|
+
}) }));
|
|
653
|
+
})
|
|
654
|
+
})), { concurrency: limits.admissionConcurrency });
|
|
655
|
+
after = due.at(-1);
|
|
656
|
+
if (due.length < limits.dueBatchSize) break;
|
|
657
|
+
}
|
|
658
|
+
return {
|
|
659
|
+
processed,
|
|
660
|
+
failed
|
|
661
|
+
};
|
|
662
|
+
});
|
|
663
|
+
return ScheduleDriver.of({
|
|
664
|
+
process,
|
|
665
|
+
runDue
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
const corrupt = (operation) => ScheduleStorageError.make({
|
|
669
|
+
operation,
|
|
670
|
+
reason: "corrupt"
|
|
671
|
+
});
|
|
672
|
+
const validateLimits = (limits) => Schema.decodeEffect(SchedulingLimits)(limits).pipe(Effect.mapError((error) => ScheduleValidationError.make({ message: `Invalid Scheduling limits: ${error.message}` })), Effect.filterOrFail((validated) => validated.retryBaseMillis <= validated.retryMaxMillis, () => ScheduleValidationError.make({ message: "Scheduling retryBaseMillis must not exceed retryMaxMillis" })));
|
|
673
|
+
var Scheduling = class Scheduling extends Context.Service()("@effect-agent/thread/Scheduling") {
|
|
674
|
+
static layer(limits = defaultSchedulingLimits) {
|
|
675
|
+
return Layer.effect(Scheduling, validateLimits(limits).pipe(Effect.flatMap(makeManagement)));
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
const ScheduleWakeNoop = Layer.succeed(ScheduleWake, {
|
|
679
|
+
notify: Effect.void,
|
|
680
|
+
await: Effect.never
|
|
681
|
+
});
|
|
682
|
+
/** Privileged host capability. Never provide this service to management callers or model tools. */
|
|
683
|
+
var ScheduleDriver = class ScheduleDriver extends Context.Service()("@effect-agent/thread/ScheduleDriver") {
|
|
684
|
+
static layer(limits = defaultSchedulingLimits) {
|
|
685
|
+
return Layer.effect(ScheduleDriver, validateLimits(limits).pipe(Effect.flatMap(makeDriver)));
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
//#endregion
|
|
689
|
+
export { Scheduling_exports as i, ScheduleWakeNoop as n, Scheduling as r, ScheduleDriver as t };
|
|
690
|
+
|
|
691
|
+
//# sourceMappingURL=Scheduling-C9aIP8zT.mjs.map
|