effect-agent 0.1.0-beta.9 → 0.1.0-beta.91
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-CHipL2jG.mjs +4598 -0
- package/dist/AgentRuntime-CHipL2jG.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-D7gDKGjH.mjs +6368 -0
- package/dist/DurableAgentRuntime-D7gDKGjH.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-DyfzHNdv.d.mts +826 -0
- package/dist/Subagent-U5qXOFE8.mjs +1469 -0
- package/dist/Subagent-U5qXOFE8.mjs.map +1 -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 +8 -0
- package/dist/ToolExposure.mjs +21 -0
- package/dist/ToolExposure.mjs.map +1 -0
- 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 +436 -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 +89 -6
- package/dist/index.mjs +98 -6
- 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 +273 -0
- package/dist/sandbox/ProtectedBrowser.mjs +287 -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 -40
- package/src/Ephemeral.ts +17 -0
- package/src/ToolExposure.ts +2 -0
- 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 +778 -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 +10162 -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 +97 -22
- 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 +436 -0
- package/src/sandbox/Sandbox.ts +241 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import type { Layer } from "effect";
|
|
2
|
+
import { Crypto, Effect, Schema } from "effect";
|
|
3
|
+
import { Tool, Toolkit } from "effect/unstable/ai";
|
|
4
|
+
|
|
5
|
+
import { type AgentId, type ThreadId } from "../core/Identifiers.ts";
|
|
6
|
+
import { DurableStep, ToolExecutionClass } from "../engine/DurableStep.ts";
|
|
7
|
+
import type { DefinitionDigests, PersistedJson } from "./Records.ts";
|
|
8
|
+
import type { ScheduleDestination } from "./Schedule.ts";
|
|
9
|
+
import type { Principal } from "./SubmissionLedger.ts";
|
|
10
|
+
import {
|
|
11
|
+
type EventSourceVersion,
|
|
12
|
+
SubscriptionError,
|
|
13
|
+
SubscriptionFailpointError,
|
|
14
|
+
SubscriptionName,
|
|
15
|
+
SubscriptionSnapshot,
|
|
16
|
+
SubscriptionSourceError,
|
|
17
|
+
type SubscriptionScope,
|
|
18
|
+
} from "./Subscription.ts";
|
|
19
|
+
import { Subscriptions } from "./Subscriptions.ts";
|
|
20
|
+
|
|
21
|
+
export const SubscriptionToolRegistration = Schema.Struct({
|
|
22
|
+
subscriptionId: SubscriptionName,
|
|
23
|
+
source: Schema.Struct({ name: SubscriptionName, version: SubscriptionName }),
|
|
24
|
+
mode: Schema.Literals(["once", "continuous"]),
|
|
25
|
+
state: Schema.Literals(["active", "paused", "consumed", "cancelled", "expired"]),
|
|
26
|
+
createdAtMillis: Schema.Int,
|
|
27
|
+
expiresAtMillis: Schema.NullOr(Schema.Int),
|
|
28
|
+
recovery: SubscriptionSnapshot.fields.recovery,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export type SubscriptionToolRegistration = typeof SubscriptionToolRegistration.Type;
|
|
32
|
+
|
|
33
|
+
export const SubscribeToEventParameters = Schema.Struct({
|
|
34
|
+
source: Schema.Struct({ name: SubscriptionName, version: SubscriptionName }),
|
|
35
|
+
parameters: Schema.Json,
|
|
36
|
+
mode: Schema.Literals(["once", "continuous"]),
|
|
37
|
+
expiresAtMillis: Schema.NullOr(Schema.Int).annotate({
|
|
38
|
+
description:
|
|
39
|
+
"Absolute Unix epoch milliseconds, or null to remain active until cancelled; retain the same value on retries",
|
|
40
|
+
}),
|
|
41
|
+
context: Schema.Json,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const ListEventSubscriptionsParameters = Schema.Struct({
|
|
45
|
+
after: Schema.optionalKey(Schema.Natural),
|
|
46
|
+
limit: Schema.optionalKey(
|
|
47
|
+
Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(100)),
|
|
48
|
+
),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const CancelEventSubscriptionParameters = Schema.Struct({
|
|
52
|
+
subscriptionId: SubscriptionName,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const SubscriptionToolSourceCatalogEntry = Schema.Struct({
|
|
56
|
+
source: Schema.Struct({ name: SubscriptionName, version: SubscriptionName }),
|
|
57
|
+
description: Schema.NonEmptyString.check(Schema.isMaxLength(2_048)),
|
|
58
|
+
parametersJsonSchema: Schema.Json,
|
|
59
|
+
contextJsonSchema: Schema.Json,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export type SubscriptionToolSourceCatalogEntry = typeof SubscriptionToolSourceCatalogEntry.Type;
|
|
63
|
+
|
|
64
|
+
const SubscriptionToolFailure = Schema.Union([
|
|
65
|
+
SubscriptionError,
|
|
66
|
+
SubscriptionSourceError,
|
|
67
|
+
SubscriptionFailpointError,
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
export const ListEventSources = Tool.make("list_event_sources", {
|
|
71
|
+
description:
|
|
72
|
+
"List the exact event source versions this host permits, with their parameter and continuation-context JSON Schemas. Inspect this catalog before subscribing.",
|
|
73
|
+
parameters: Schema.Struct({}),
|
|
74
|
+
success: Schema.Array(SubscriptionToolSourceCatalogEntry),
|
|
75
|
+
failure: SubscriptionError,
|
|
76
|
+
failureMode: "return",
|
|
77
|
+
})
|
|
78
|
+
.annotate(Tool.Readonly, true)
|
|
79
|
+
.annotate(ToolExecutionClass, "readonly");
|
|
80
|
+
|
|
81
|
+
export const SubscribeToEvent = Tool.make("subscribe_to_event", {
|
|
82
|
+
description:
|
|
83
|
+
"Register a durable event subscription from the host-permitted source catalog. The destination, Agent, authority, and delivery principal are fixed by the host.",
|
|
84
|
+
parameters: SubscribeToEventParameters,
|
|
85
|
+
success: SubscriptionToolRegistration,
|
|
86
|
+
failure: SubscriptionToolFailure,
|
|
87
|
+
failureMode: "return",
|
|
88
|
+
dependencies: [DurableStep],
|
|
89
|
+
})
|
|
90
|
+
.annotate(Tool.Readonly, false)
|
|
91
|
+
.annotate(ToolExecutionClass, "idempotent");
|
|
92
|
+
|
|
93
|
+
export const ListEventSubscriptions = Tool.make("list_event_subscriptions", {
|
|
94
|
+
description: "List redacted durable event subscriptions in the current host-bound owner scope.",
|
|
95
|
+
parameters: ListEventSubscriptionsParameters,
|
|
96
|
+
success: Schema.Struct({
|
|
97
|
+
items: Schema.Array(SubscriptionToolRegistration),
|
|
98
|
+
next: Schema.NullOr(Schema.Natural),
|
|
99
|
+
}),
|
|
100
|
+
failure: SubscriptionError,
|
|
101
|
+
failureMode: "return",
|
|
102
|
+
})
|
|
103
|
+
.annotate(Tool.Readonly, true)
|
|
104
|
+
.annotate(ToolExecutionClass, "readonly");
|
|
105
|
+
|
|
106
|
+
export const CancelEventSubscription = Tool.make("cancel_event_subscription", {
|
|
107
|
+
description: "Cancel one durable event subscription in the current host-bound owner scope.",
|
|
108
|
+
parameters: CancelEventSubscriptionParameters,
|
|
109
|
+
success: SubscriptionToolRegistration,
|
|
110
|
+
failure: Schema.Union([SubscriptionError, SubscriptionFailpointError]),
|
|
111
|
+
failureMode: "return",
|
|
112
|
+
dependencies: [DurableStep],
|
|
113
|
+
})
|
|
114
|
+
.annotate(Tool.Readonly, false)
|
|
115
|
+
.annotate(ToolExecutionClass, "idempotent");
|
|
116
|
+
|
|
117
|
+
export const SubscriptionTools = Toolkit.make(
|
|
118
|
+
ListEventSources,
|
|
119
|
+
SubscribeToEvent,
|
|
120
|
+
ListEventSubscriptions,
|
|
121
|
+
CancelEventSubscription,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
export interface PermittedSubscriptionToolSource {
|
|
125
|
+
readonly source: EventSourceVersion;
|
|
126
|
+
/** The source's input Schema must be the input Schema of this exact host Agent identity. */
|
|
127
|
+
readonly agentId: AgentId;
|
|
128
|
+
readonly description: string;
|
|
129
|
+
readonly parameters: Schema.Top;
|
|
130
|
+
readonly context: Schema.Top;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface SubscriptionToolsOptions {
|
|
134
|
+
readonly scope: SubscriptionScope;
|
|
135
|
+
readonly currentThreadId: ThreadId;
|
|
136
|
+
readonly deliveryPrincipal: Principal;
|
|
137
|
+
readonly agentId: AgentId;
|
|
138
|
+
readonly definitions: DefinitionDigests;
|
|
139
|
+
readonly permittedSources: ReadonlyArray<PermittedSubscriptionToolSource>;
|
|
140
|
+
/** Defaults to the current Thread; a host may instead bind deterministic fresh delivery. */
|
|
141
|
+
readonly destination?: ScheduleDestination | undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const sameSource = (left: EventSourceVersion, right: EventSourceVersion): boolean =>
|
|
145
|
+
left.name === right.name && left.version === right.version;
|
|
146
|
+
|
|
147
|
+
const registration = (
|
|
148
|
+
snapshot: typeof SubscriptionSnapshot.Type,
|
|
149
|
+
): SubscriptionToolRegistration => ({
|
|
150
|
+
subscriptionId: snapshot.key.subscriptionId,
|
|
151
|
+
source: snapshot.source,
|
|
152
|
+
mode: snapshot.mode,
|
|
153
|
+
state: snapshot.state,
|
|
154
|
+
createdAtMillis: snapshot.createdAtMillis,
|
|
155
|
+
expiresAtMillis: snapshot.expiresAtMillis,
|
|
156
|
+
recovery: snapshot.recovery,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const toolFailure = (reason: SubscriptionError["reason"], code: string): SubscriptionError =>
|
|
160
|
+
SubscriptionError.make({ reason, code });
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Bind management authority before exposing Tools to a model. The model can select only an exact
|
|
164
|
+
* source/version and source-defined parameters; it cannot choose another tenant, owner,
|
|
165
|
+
* Thread, Agent, definition digest, principal, destination policy, or credential.
|
|
166
|
+
*/
|
|
167
|
+
export const subscriptionToolsLayer = (
|
|
168
|
+
options: SubscriptionToolsOptions,
|
|
169
|
+
): Layer.Layer<
|
|
170
|
+
Tool.HandlersFor<Toolkit.Tools<typeof SubscriptionTools>>,
|
|
171
|
+
SubscriptionError,
|
|
172
|
+
Subscriptions | Crypto.Crypto
|
|
173
|
+
> => {
|
|
174
|
+
const destination: ScheduleDestination = options.destination ?? {
|
|
175
|
+
_tag: "ExistingThread",
|
|
176
|
+
threadId: options.currentThreadId,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const build = Effect.gen(function* () {
|
|
180
|
+
const duplicate = options.permittedSources.find(
|
|
181
|
+
(candidate, index, all) =>
|
|
182
|
+
all.findIndex((item) => sameSource(item.source, candidate.source)) !== index,
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
if (duplicate !== undefined) {
|
|
186
|
+
return yield* toolFailure("validation", "duplicate-source-catalog-entry");
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const mismatched = options.permittedSources.find(
|
|
190
|
+
(candidate) => candidate.agentId !== options.agentId,
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
if (mismatched !== undefined) {
|
|
194
|
+
return yield* toolFailure("validation", "source-agent-mismatch");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const catalog = yield* Effect.forEach(options.permittedSources, (candidate) =>
|
|
198
|
+
Effect.gen(function* () {
|
|
199
|
+
const description = yield* Schema.decodeEffect(
|
|
200
|
+
SubscriptionToolSourceCatalogEntry.fields.description,
|
|
201
|
+
)(candidate.description).pipe(
|
|
202
|
+
Effect.mapError(() => toolFailure("validation", "source-catalog-description")),
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
return SubscriptionToolSourceCatalogEntry.make({
|
|
206
|
+
source: candidate.source,
|
|
207
|
+
description,
|
|
208
|
+
parametersJsonSchema: yield* Effect.try({
|
|
209
|
+
try: () => Tool.getJsonSchemaFromSchema(candidate.parameters),
|
|
210
|
+
catch: () => toolFailure("validation", "source-parameters-schema"),
|
|
211
|
+
}),
|
|
212
|
+
contextJsonSchema: yield* Effect.try({
|
|
213
|
+
try: () => Tool.getJsonSchemaFromSchema(candidate.context),
|
|
214
|
+
catch: () => toolFailure("validation", "source-context-schema"),
|
|
215
|
+
}),
|
|
216
|
+
});
|
|
217
|
+
}),
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
const subscriptions = yield* Subscriptions;
|
|
221
|
+
const crypto = yield* Crypto.Crypto;
|
|
222
|
+
|
|
223
|
+
const permitted = (source: EventSourceVersion) =>
|
|
224
|
+
options.permittedSources.some((candidate) => sameSource(candidate.source, source));
|
|
225
|
+
|
|
226
|
+
const subscribe = Effect.fn("SubscriptionTools.subscribe")(function* (parameters: {
|
|
227
|
+
readonly source: EventSourceVersion;
|
|
228
|
+
readonly parameters: PersistedJson;
|
|
229
|
+
readonly mode: "once" | "continuous";
|
|
230
|
+
readonly expiresAtMillis: number | null;
|
|
231
|
+
readonly context: PersistedJson;
|
|
232
|
+
}) {
|
|
233
|
+
if (!permitted(parameters.source)) {
|
|
234
|
+
return yield* toolFailure("unauthorized", "source-catalog");
|
|
235
|
+
}
|
|
236
|
+
const step = yield* DurableStep;
|
|
237
|
+
|
|
238
|
+
// The first committed Step creates one identity per Tool Call. Re-entry observes the same
|
|
239
|
+
// value, while a separate identical call receives a distinct identity.
|
|
240
|
+
const subscriptionId = yield* step
|
|
241
|
+
.do(
|
|
242
|
+
"subscription-identity",
|
|
243
|
+
SubscriptionName,
|
|
244
|
+
crypto.randomUUIDv7.pipe(
|
|
245
|
+
Effect.map((id) => `tool:${id}`),
|
|
246
|
+
Effect.mapError(() => toolFailure("storage", "creation-identity")),
|
|
247
|
+
),
|
|
248
|
+
)
|
|
249
|
+
.pipe(
|
|
250
|
+
Effect.catchTag("DurableStepError", (error) =>
|
|
251
|
+
Effect.fail(toolFailure("storage", `durable-step-${error.reason}`)),
|
|
252
|
+
),
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
return yield* step
|
|
256
|
+
.do(
|
|
257
|
+
"register-subscription",
|
|
258
|
+
SubscriptionToolRegistration,
|
|
259
|
+
subscriptions
|
|
260
|
+
.subscribe(options.scope, {
|
|
261
|
+
subscriptionId,
|
|
262
|
+
source: parameters.source,
|
|
263
|
+
parameters: parameters.parameters,
|
|
264
|
+
context: parameters.context,
|
|
265
|
+
mode: parameters.mode,
|
|
266
|
+
expiresAtMillis: parameters.expiresAtMillis,
|
|
267
|
+
destination,
|
|
268
|
+
deliveryPrincipal: options.deliveryPrincipal,
|
|
269
|
+
agentId: options.agentId,
|
|
270
|
+
definitions: options.definitions,
|
|
271
|
+
})
|
|
272
|
+
.pipe(Effect.map(registration)),
|
|
273
|
+
)
|
|
274
|
+
.pipe(
|
|
275
|
+
Effect.catchTag("DurableStepError", (error) =>
|
|
276
|
+
Effect.fail(toolFailure("storage", `durable-step-${error.reason}`)),
|
|
277
|
+
),
|
|
278
|
+
);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
const list = Effect.fn("SubscriptionTools.list")(function* (parameters: {
|
|
282
|
+
readonly after?: number | undefined;
|
|
283
|
+
readonly limit?: number | undefined;
|
|
284
|
+
}) {
|
|
285
|
+
const page = yield* subscriptions.listSubscriptions(
|
|
286
|
+
options.scope,
|
|
287
|
+
parameters.after,
|
|
288
|
+
parameters.limit,
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
return { items: page.items.map(registration), next: page.next };
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
const cancel = Effect.fn("SubscriptionTools.cancel")(function* (parameters: {
|
|
295
|
+
readonly subscriptionId: string;
|
|
296
|
+
}) {
|
|
297
|
+
const step = yield* DurableStep;
|
|
298
|
+
|
|
299
|
+
return yield* step
|
|
300
|
+
.do(
|
|
301
|
+
"cancel-subscription",
|
|
302
|
+
SubscriptionToolRegistration,
|
|
303
|
+
subscriptions
|
|
304
|
+
.cancelSubscription(options.scope, {
|
|
305
|
+
partition: options.scope.partition,
|
|
306
|
+
ownerId: options.scope.ownerId,
|
|
307
|
+
subscriptionId: parameters.subscriptionId,
|
|
308
|
+
})
|
|
309
|
+
.pipe(Effect.map(registration)),
|
|
310
|
+
)
|
|
311
|
+
.pipe(
|
|
312
|
+
Effect.catchTag("DurableStepError", (error) =>
|
|
313
|
+
Effect.fail(toolFailure("storage", `durable-step-${error.reason}`)),
|
|
314
|
+
),
|
|
315
|
+
);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
return SubscriptionTools.of({
|
|
319
|
+
list_event_sources: () => Effect.succeed(catalog),
|
|
320
|
+
subscribe_to_event: subscribe,
|
|
321
|
+
list_event_subscriptions: list,
|
|
322
|
+
cancel_event_subscription: cancel,
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
return SubscriptionTools.toLayer(build);
|
|
327
|
+
};
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { Result, Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
import { Receipt } from "./DurableAgentRuntime.ts";
|
|
4
|
+
import { DefinitionDigests } from "./Records.ts";
|
|
5
|
+
import { AdmissionFence } from "./SubmissionLedger.ts";
|
|
6
|
+
import {
|
|
7
|
+
type AcceptedEvent,
|
|
8
|
+
type DeliveryChange,
|
|
9
|
+
type SubscriptionChange,
|
|
10
|
+
type SubscriptionLimits,
|
|
11
|
+
type SourcePartition,
|
|
12
|
+
SubscriptionDelivery,
|
|
13
|
+
SubscriptionConfiguration,
|
|
14
|
+
type SubscriptionDelivery as SubscriptionDeliveryType,
|
|
15
|
+
type SubscriptionRecord,
|
|
16
|
+
SubscriptionError,
|
|
17
|
+
} from "./Subscription.ts";
|
|
18
|
+
|
|
19
|
+
const conflict = (code: string) => SubscriptionError.make({ reason: "conflict", code });
|
|
20
|
+
const sameDefinitions = Schema.toEquivalence(DefinitionDigests);
|
|
21
|
+
const sameReceipt = Schema.toEquivalence(Receipt);
|
|
22
|
+
|
|
23
|
+
export const sameSourcePartition = (left: SourcePartition, right: SourcePartition): boolean =>
|
|
24
|
+
left.tenantId === right.tenantId && left.address === right.address;
|
|
25
|
+
|
|
26
|
+
/** The retained event is authoritative. An absent historical occurrence stays unknown on replay. */
|
|
27
|
+
export const sameAcceptedEventIdentity = (left: AcceptedEvent, right: AcceptedEvent): boolean =>
|
|
28
|
+
sameSourcePartition(left.partition, right.partition) &&
|
|
29
|
+
left.eventId === right.eventId &&
|
|
30
|
+
left.source.name === right.source.name &&
|
|
31
|
+
left.source.version === right.source.version &&
|
|
32
|
+
left.matchingKey === right.matchingKey &&
|
|
33
|
+
left.payloadDigest === right.payloadDigest &&
|
|
34
|
+
(left.occurredAtMillis === undefined || left.occurredAtMillis === right.occurredAtMillis);
|
|
35
|
+
|
|
36
|
+
export const subscriptionMatchesEvent = (
|
|
37
|
+
subscription: SubscriptionRecord,
|
|
38
|
+
event: AcceptedEvent,
|
|
39
|
+
): boolean =>
|
|
40
|
+
subscription.configuration.source.name === event.source.name &&
|
|
41
|
+
subscription.configuration.source.version === event.source.version &&
|
|
42
|
+
subscription.configuration.matchingKey === event.matchingKey;
|
|
43
|
+
|
|
44
|
+
export const subscriptionCanSelect = (
|
|
45
|
+
subscription: SubscriptionRecord,
|
|
46
|
+
event: AcceptedEvent,
|
|
47
|
+
nowMillis: number,
|
|
48
|
+
bypassCutoff: boolean,
|
|
49
|
+
): boolean =>
|
|
50
|
+
subscriptionMatchesEvent(subscription, event) &&
|
|
51
|
+
subscription.state === "active" &&
|
|
52
|
+
(subscription.configuration.expiresAtMillis === null ||
|
|
53
|
+
subscription.configuration.expiresAtMillis > nowMillis) &&
|
|
54
|
+
(bypassCutoff || subscription.ordinal <= event.cutoff);
|
|
55
|
+
|
|
56
|
+
export const subscriptionDeliveryCanSelect = (
|
|
57
|
+
delivery: SubscriptionDeliveryType,
|
|
58
|
+
subscription: SubscriptionRecord,
|
|
59
|
+
event: AcceptedEvent,
|
|
60
|
+
): boolean => {
|
|
61
|
+
const expectedThread =
|
|
62
|
+
subscription.configuration.destination._tag === "ExistingThread"
|
|
63
|
+
? subscription.configuration.destination.threadId
|
|
64
|
+
: `subscription:${delivery.deliveryId}`;
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
event.tombstone !== true &&
|
|
68
|
+
delivery.key.eventId === event.eventId &&
|
|
69
|
+
delivery.key.subscription.partition.tenantId === subscription.key.partition.tenantId &&
|
|
70
|
+
delivery.key.subscription.partition.address === subscription.key.partition.address &&
|
|
71
|
+
delivery.key.subscription.ownerId === subscription.key.ownerId &&
|
|
72
|
+
delivery.key.subscription.subscriptionId === subscription.key.subscriptionId &&
|
|
73
|
+
delivery.source.name === event.source.name &&
|
|
74
|
+
delivery.source.version === event.source.version &&
|
|
75
|
+
delivery.subscriptionFingerprint === subscription.configurationFingerprint &&
|
|
76
|
+
delivery.configurationRevision === subscription.configurationRevision &&
|
|
77
|
+
Schema.toEquivalence(SubscriptionConfiguration)(
|
|
78
|
+
delivery.configuration,
|
|
79
|
+
subscription.configuration,
|
|
80
|
+
) &&
|
|
81
|
+
delivery.eventDigest === event.payloadDigest &&
|
|
82
|
+
delivery.threadId === expectedThread &&
|
|
83
|
+
delivery.admissionKey === `subscription:${delivery.deliveryId}` &&
|
|
84
|
+
delivery.state === "selected" &&
|
|
85
|
+
delivery.envelope === null &&
|
|
86
|
+
delivery.envelopeDigest === null &&
|
|
87
|
+
delivery.receipt === null &&
|
|
88
|
+
delivery.refusal === null
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const sameSubscriptionDelivery = (
|
|
93
|
+
left: SubscriptionDeliveryType,
|
|
94
|
+
right: SubscriptionDeliveryType,
|
|
95
|
+
): boolean =>
|
|
96
|
+
Schema.encodeSync(Schema.fromJsonString(SubscriptionDelivery))(left) ===
|
|
97
|
+
Schema.encodeSync(Schema.fromJsonString(SubscriptionDelivery))(right);
|
|
98
|
+
|
|
99
|
+
/** Pure lifecycle transition used inside each adapter's local atomic mutation. */
|
|
100
|
+
export const applySubscriptionDeliveryChange = (
|
|
101
|
+
existing: SubscriptionDeliveryType,
|
|
102
|
+
subscription: SubscriptionRecord,
|
|
103
|
+
deliveryId: string,
|
|
104
|
+
change: DeliveryChange,
|
|
105
|
+
): Result.Result<SubscriptionDeliveryType, SubscriptionError> => {
|
|
106
|
+
if (existing.deliveryId !== deliveryId) return Result.fail(conflict("stale-delivery"));
|
|
107
|
+
|
|
108
|
+
const configuration = existing.configuration;
|
|
109
|
+
|
|
110
|
+
switch (change._tag) {
|
|
111
|
+
case "ObserveSettlement":
|
|
112
|
+
if (
|
|
113
|
+
existing.state !== "delivered" ||
|
|
114
|
+
existing.receipt === null ||
|
|
115
|
+
!sameReceipt(existing.receipt, change.receipt)
|
|
116
|
+
)
|
|
117
|
+
return Result.fail(conflict("settlement-receipt"));
|
|
118
|
+
if (existing.settledAtMillis !== undefined) return Result.succeed(existing);
|
|
119
|
+
|
|
120
|
+
return Result.succeed({
|
|
121
|
+
...existing,
|
|
122
|
+
observeSettlement: !change.settled,
|
|
123
|
+
...(change.settled ? { settledAtMillis: change.nowMillis } : {}),
|
|
124
|
+
retry: { ...existing.retry, nextAttemptAtMillis: change.nextAttemptAtMillis },
|
|
125
|
+
});
|
|
126
|
+
case "Recover":
|
|
127
|
+
if (existing.retry.generation !== change.expectedGeneration) return Result.succeed(existing);
|
|
128
|
+
if (existing.state === "delivered" || existing.state === "refused")
|
|
129
|
+
return Result.succeed(existing);
|
|
130
|
+
|
|
131
|
+
return Result.succeed({
|
|
132
|
+
...existing,
|
|
133
|
+
retry: {
|
|
134
|
+
...existing.retry,
|
|
135
|
+
generation: existing.retry.generation + 1,
|
|
136
|
+
automaticAttempts: 0,
|
|
137
|
+
parked: false,
|
|
138
|
+
nextAttemptAtMillis: change.nowMillis,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
case "Prepare": {
|
|
142
|
+
if (existing.state === "prepared") {
|
|
143
|
+
return existing.envelope !== null &&
|
|
144
|
+
existing.envelopeDigest === change.envelopeDigest &&
|
|
145
|
+
Schema.encodeSync(Schema.fromJsonString(SubscriptionDelivery.fields.envelope))(
|
|
146
|
+
existing.envelope,
|
|
147
|
+
) ===
|
|
148
|
+
Schema.encodeSync(Schema.fromJsonString(SubscriptionDelivery.fields.envelope))(
|
|
149
|
+
change.envelope,
|
|
150
|
+
)
|
|
151
|
+
? Result.succeed(existing)
|
|
152
|
+
: Result.fail(conflict("prepared-envelope"));
|
|
153
|
+
}
|
|
154
|
+
if (existing.state !== "selected") return Result.fail(conflict("delivery-state"));
|
|
155
|
+
if (
|
|
156
|
+
subscription.state === "cancelled" ||
|
|
157
|
+
(configuration.expiresAtMillis !== null &&
|
|
158
|
+
configuration.expiresAtMillis <= change.nowMillis)
|
|
159
|
+
) {
|
|
160
|
+
return Result.succeed({
|
|
161
|
+
...existing,
|
|
162
|
+
state: "refused",
|
|
163
|
+
refusal: {
|
|
164
|
+
phase: "preparation",
|
|
165
|
+
code: subscription.state === "cancelled" ? "cancelled" : "expired",
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (
|
|
170
|
+
change.envelope.threadId !== existing.threadId ||
|
|
171
|
+
change.envelope.admissionKey !== existing.admissionKey ||
|
|
172
|
+
change.envelope.deliveryPrincipal !== configuration.deliveryPrincipal ||
|
|
173
|
+
change.envelope.agentId !== configuration.agentId ||
|
|
174
|
+
change.envelope.admissionGroup !== configuration.admissionGroup ||
|
|
175
|
+
!Schema.toEquivalence(Schema.optional(AdmissionFence))(
|
|
176
|
+
change.envelope.admissionFence,
|
|
177
|
+
configuration.admissionFence,
|
|
178
|
+
) ||
|
|
179
|
+
!sameDefinitions(change.envelope.definitions, configuration.definitions)
|
|
180
|
+
)
|
|
181
|
+
return Result.fail(conflict("prepared-identity"));
|
|
182
|
+
|
|
183
|
+
return Result.succeed({
|
|
184
|
+
...existing,
|
|
185
|
+
state: "prepared",
|
|
186
|
+
envelope: change.envelope,
|
|
187
|
+
envelopeDigest: change.envelopeDigest,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
case "Complete":
|
|
191
|
+
if (change.receipt.threadId !== existing.threadId)
|
|
192
|
+
return Result.fail(conflict("receipt-thread"));
|
|
193
|
+
if (existing.state === "delivered")
|
|
194
|
+
return existing.receipt !== null && sameReceipt(existing.receipt, change.receipt)
|
|
195
|
+
? Result.succeed(existing)
|
|
196
|
+
: Result.fail(conflict("receipt"));
|
|
197
|
+
|
|
198
|
+
return existing.state === "prepared"
|
|
199
|
+
? Result.succeed({
|
|
200
|
+
...existing,
|
|
201
|
+
state: "delivered",
|
|
202
|
+
receipt: change.receipt,
|
|
203
|
+
completedAtMillis: change.nowMillis,
|
|
204
|
+
})
|
|
205
|
+
: Result.fail(conflict("delivery-state"));
|
|
206
|
+
case "Refuse":
|
|
207
|
+
if (existing.state === "refused")
|
|
208
|
+
return existing.refusal?.phase === change.refusal.phase &&
|
|
209
|
+
existing.refusal.code === change.refusal.code
|
|
210
|
+
? Result.succeed(existing)
|
|
211
|
+
: Result.fail(conflict("refusal"));
|
|
212
|
+
if (
|
|
213
|
+
(change.refusal.phase === "preparation" && existing.state !== "selected") ||
|
|
214
|
+
(change.refusal.phase === "admission" && existing.state !== "prepared")
|
|
215
|
+
)
|
|
216
|
+
return Result.fail(conflict("refusal-phase"));
|
|
217
|
+
|
|
218
|
+
return existing.state === "delivered"
|
|
219
|
+
? Result.fail(conflict("delivery-state"))
|
|
220
|
+
: Result.succeed({
|
|
221
|
+
...existing,
|
|
222
|
+
state: "refused",
|
|
223
|
+
refusal: change.refusal,
|
|
224
|
+
completedAtMillis: change.nowMillis,
|
|
225
|
+
});
|
|
226
|
+
case "Retry":
|
|
227
|
+
if (existing.state === "delivered" || existing.state === "refused")
|
|
228
|
+
return Result.fail(conflict("delivery-state"));
|
|
229
|
+
if (
|
|
230
|
+
change.retry.generation !== existing.retry.generation ||
|
|
231
|
+
change.retry.attempts <= existing.retry.attempts ||
|
|
232
|
+
change.retry.nextAttemptAtMillis < existing.retry.nextAttemptAtMillis
|
|
233
|
+
)
|
|
234
|
+
return Result.succeed(existing);
|
|
235
|
+
|
|
236
|
+
return Result.succeed({ ...existing, retry: change.retry });
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/** CAS management never mutates a selected or prepared delivery. */
|
|
241
|
+
export const applySubscriptionChange = (
|
|
242
|
+
existing: SubscriptionRecord,
|
|
243
|
+
expectedRevision: number,
|
|
244
|
+
change: SubscriptionChange,
|
|
245
|
+
): Result.Result<SubscriptionRecord, SubscriptionError> => {
|
|
246
|
+
const revision = existing.configurationRevision;
|
|
247
|
+
|
|
248
|
+
if (revision !== expectedRevision)
|
|
249
|
+
return Result.fail(
|
|
250
|
+
SubscriptionError.make({
|
|
251
|
+
reason: "conflict",
|
|
252
|
+
code: "configuration-revision",
|
|
253
|
+
currentRevision: revision,
|
|
254
|
+
currentState: existing.state,
|
|
255
|
+
}),
|
|
256
|
+
);
|
|
257
|
+
if (existing.state === "cancelled" || existing.state === "consumed")
|
|
258
|
+
return Result.fail(conflict("subscription-state"));
|
|
259
|
+
if (change._tag === "Pause" && existing.state !== "active")
|
|
260
|
+
return Result.fail(conflict("subscription-state"));
|
|
261
|
+
if (change._tag === "Resume" && existing.state !== "paused")
|
|
262
|
+
return Result.fail(conflict("subscription-state"));
|
|
263
|
+
|
|
264
|
+
return Result.succeed({
|
|
265
|
+
...existing,
|
|
266
|
+
creationConfiguration: existing.creationConfiguration,
|
|
267
|
+
configurationRevision: revision + 1,
|
|
268
|
+
...(change._tag === "Update"
|
|
269
|
+
? {
|
|
270
|
+
configuration: change.configuration,
|
|
271
|
+
configurationFingerprint: change.configurationFingerprint,
|
|
272
|
+
recovery: change.recovery,
|
|
273
|
+
}
|
|
274
|
+
: change._tag === "Recover"
|
|
275
|
+
? {
|
|
276
|
+
recovery:
|
|
277
|
+
existing.recovery === null
|
|
278
|
+
? null
|
|
279
|
+
: { ...existing.recovery, nextAttemptAtMillis: change.nowMillis },
|
|
280
|
+
}
|
|
281
|
+
: { state: change._tag === "Pause" ? ("paused" as const) : ("active" as const) }),
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/** Called only after retained identity lookup: unfinished work remains replayable past the horizon. */
|
|
286
|
+
export const validateEventRetention = (
|
|
287
|
+
event: AcceptedEvent,
|
|
288
|
+
limits: SubscriptionLimits,
|
|
289
|
+
nowMillis: number,
|
|
290
|
+
): Result.Result<void, SubscriptionError> => {
|
|
291
|
+
if (limits.retention === undefined) return Result.void;
|
|
292
|
+
if (
|
|
293
|
+
event.occurredAtMillis === undefined ||
|
|
294
|
+
event.occurredAtMillis > nowMillis ||
|
|
295
|
+
event.occurredAtMillis <= nowMillis - limits.retention.replayHorizonMillis
|
|
296
|
+
)
|
|
297
|
+
return Result.fail(
|
|
298
|
+
SubscriptionError.make({ reason: "validation", code: "event-replay-horizon" }),
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
return Result.void;
|
|
302
|
+
};
|