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 @@
|
|
|
1
|
+
{"version":3,"file":"Subscriptions.mjs","names":[],"sources":["../../src/durable/Subscriptions.ts"],"sourcesContent":["import { Cause, Context, Crypto, DateTime, Effect, Layer, Option, Schema, Semaphore } from \"effect\";\n\nimport { ThreadId } from \"../core/Identifiers.ts\";\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { digestJson } from \"./Digest.ts\";\nimport { EventSources, type NormalizedEvent } from \"./EventSource.ts\";\nimport { admitPreparedInput, PreparedInputAdmission } from \"./PreparedInputAdmission.ts\";\nimport { DefinitionDigests, type PersistedJson } from \"./Records.ts\";\nimport { type ScheduleRetryReason } from \"./Schedule.ts\";\nimport { type AdmissionFence, IdempotencyKey, type Principal } from \"./SubmissionLedger.ts\";\nimport {\n AcceptedEvent,\n type EventAcknowledgement,\n type EventSourceVersion,\n PreparedInput,\n SubscriptionAuthorizer,\n SubscriptionConfiguration,\n SubscriptionDelivery,\n type SubscriptionDeliveryKey,\n type SubscriptionDeliverySnapshot,\n SubscriptionError,\n SubscriptionFailpoint,\n SubscriptionKey,\n SubscriptionLimits,\n type SubscriptionRecord,\n type SubscriptionChange,\n SubscriptionScope,\n type SubscriptionSnapshot,\n SubscriptionSourceError,\n SubscriptionStore,\n type SubscriptionStoreFailure,\n defaultSubscriptionLimits,\n subscriptionDeliveryKeyString,\n} from \"./Subscription.ts\";\nimport { resolveSubscriptionInput, SubscriptionInputBindings } from \"./SubscriptionInput.ts\";\n\nconst now = DateTime.now.pipe(Effect.map(DateTime.toEpochMillis));\n\nconst failure = (reason: SubscriptionError[\"reason\"], code: string) =>\n SubscriptionError.make({ reason, code });\n\nconst bytes = (value: PersistedJson) => utf8ByteLength(JSON.stringify(value));\n\nconst sameSource = (a: EventSourceVersion, b: EventSourceVersion) =>\n a.name === b.name && a.version === b.version;\n\nconst samePartition = Schema.toEquivalence(SubscriptionScope.fields.partition);\n\nconst validate = <S extends Schema.Top>(schema: S, value: unknown) =>\n Schema.decodeUnknownEffect(schema)(value).pipe(\n Effect.mapError(() => failure(\"validation\", \"schema\")),\n );\n\nconst snapshot = (record: SubscriptionRecord, time: number): SubscriptionSnapshot => ({\n key: record.key,\n configurationRevision: record.configurationRevision,\n configurationFingerprint: record.configurationFingerprint,\n ...(record.configuration.admissionGroup === undefined\n ? {}\n : { admissionGroup: record.configuration.admissionGroup }),\n ...(record.configuration.admissionFence === undefined\n ? {}\n : { admissionFence: record.configuration.admissionFence }),\n source: record.configuration.source,\n mode: record.configuration.mode,\n state:\n record.state === \"active\" &&\n record.configuration.expiresAtMillis !== null &&\n record.configuration.expiresAtMillis <= time\n ? \"expired\"\n : record.state,\n createdAtMillis: record.createdAtMillis,\n expiresAtMillis: record.configuration.expiresAtMillis,\n recovery: record.recovery,\n});\n\nconst deliverySnapshot = (\n record: SubscriptionDelivery,\n): typeof SubscriptionDeliverySnapshot.Type => ({\n key: record.key,\n state: record.state,\n configurationRevision: record.configurationRevision,\n ...(record.observeSettlement === undefined\n ? {}\n : { observeSettlement: record.observeSettlement }),\n ...(record.settledAtMillis === undefined ? {} : { settledAtMillis: record.settledAtMillis }),\n retry: record.retry,\n receipt: record.receipt,\n refusal: record.refusal,\n});\n\nexport interface SubscribeOptions {\n readonly subscriptionId: string;\n readonly source: EventSourceVersion;\n readonly parameters: PersistedJson;\n readonly context: PersistedJson;\n readonly mode: \"once\" | \"continuous\";\n readonly expiresAtMillis: number | null;\n readonly destination: SubscriptionConfiguration[\"destination\"];\n readonly deliveryPrincipal: Principal;\n readonly admissionGroup?: string;\n readonly admissionFence?: AdmissionFence;\n readonly agentId: SubscriptionConfiguration[\"agentId\"];\n readonly definitions: SubscriptionConfiguration[\"definitions\"];\n}\n\nexport type SubscriptionFailure = SubscriptionStoreFailure | SubscriptionSourceError;\n\n/** Only management and redacted status. Do not provide intake or drivers to Agent Tools. */\nexport class Subscriptions extends Context.Service<\n Subscriptions,\n {\n readonly recoverSubscription: (\n scope: SubscriptionScope,\n key: SubscriptionKey,\n expectedRevision: number,\n ) => Effect.Effect<SubscriptionSnapshot, SubscriptionStoreFailure>;\n readonly getSubscription: (\n scope: SubscriptionScope,\n key: SubscriptionKey,\n ) => Effect.Effect<SubscriptionSnapshot, SubscriptionError>;\n readonly subscribe: (\n scope: SubscriptionScope,\n options: SubscribeOptions,\n ) => Effect.Effect<SubscriptionSnapshot, SubscriptionFailure>;\n readonly updateSubscription: (\n scope: SubscriptionScope,\n key: SubscriptionKey,\n expectedRevision: number,\n options: Omit<SubscribeOptions, \"subscriptionId\">,\n ) => Effect.Effect<SubscriptionSnapshot, SubscriptionFailure>;\n readonly pauseSubscription: (\n scope: SubscriptionScope,\n key: SubscriptionKey,\n expectedRevision: number,\n ) => Effect.Effect<SubscriptionSnapshot, SubscriptionStoreFailure>;\n readonly resumeSubscription: (\n scope: SubscriptionScope,\n key: SubscriptionKey,\n expectedRevision: number,\n ) => Effect.Effect<SubscriptionSnapshot, SubscriptionStoreFailure>;\n readonly listSubscriptions: (\n scope: SubscriptionScope,\n after?: number,\n limit?: number,\n ) => Effect.Effect<\n { readonly items: ReadonlyArray<SubscriptionSnapshot>; readonly next: number | null },\n SubscriptionError\n >;\n readonly recoverDelivery: (\n scope: SubscriptionScope,\n key: SubscriptionDeliveryKey,\n expectedGeneration: number,\n ) => Effect.Effect<typeof SubscriptionDeliverySnapshot.Type, SubscriptionStoreFailure>;\n readonly cancelSubscription: (\n scope: SubscriptionScope,\n key: SubscriptionKey,\n expectedRevision?: number,\n ) => Effect.Effect<SubscriptionSnapshot, SubscriptionStoreFailure>;\n readonly listDeliveries: (\n scope: SubscriptionScope,\n key: SubscriptionKey,\n after?: string,\n limit?: number,\n ) => Effect.Effect<\n {\n readonly items: ReadonlyArray<typeof SubscriptionDeliverySnapshot.Type>;\n readonly next: string | null;\n },\n SubscriptionError\n >;\n }\n>()(\"@effect-agent/thread/Subscriptions\") {\n static layer(limits: SubscriptionLimits = defaultSubscriptionLimits) {\n return Layer.effect(Subscriptions, makeManagement(limits));\n }\n}\n\n/** Trusted intake acknowledges retained routing work, never a Thread Submission Receipt. */\nexport class SubscriptionIntake extends Context.Service<\n SubscriptionIntake,\n {\n readonly accept: (\n principal: Principal,\n source: EventSourceVersion,\n payload: unknown,\n ) => Effect.Effect<EventAcknowledgement, SubscriptionFailure>;\n readonly status: (\n principal: Principal,\n source: EventSourceVersion,\n eventId: string,\n ) => Effect.Effect<\n EventAcknowledgement & {\n readonly routingComplete: boolean;\n readonly routingFailure: string | null;\n readonly nextAttemptAtMillis: number;\n },\n SubscriptionError\n >;\n }\n>()(\"@effect-agent/thread/SubscriptionIntake\") {\n static layer(limits: SubscriptionLimits = defaultSubscriptionLimits) {\n return Layer.effect(SubscriptionIntake, makeIntake(limits));\n }\n}\n\n/** One bounded sweep. The platform owns polling/alarm recovery; no subscription retains a Run. */\nexport class SubscriptionDriver extends Context.Service<\n SubscriptionDriver,\n {\n readonly runDue: Effect.Effect<\n { readonly processed: number; readonly failed: number },\n SubscriptionStoreFailure\n >;\n readonly processDelivery: (\n key: SubscriptionDeliveryKey,\n ) => Effect.Effect<void, SubscriptionFailure>;\n }\n>()(\"@effect-agent/thread/SubscriptionDriver\") {\n static layer(limits: SubscriptionLimits = defaultSubscriptionLimits) {\n return Layer.effect(SubscriptionDriver, makeDriver(limits));\n }\n}\n\nconst dependencies = Effect.gen(function* () {\n const store = yield* SubscriptionStore;\n const authorizer = yield* SubscriptionAuthorizer;\n const sources = (yield* EventSources).sources;\n const crypto = yield* Crypto.Crypto;\n\n const digest = (value: PersistedJson) =>\n digestJson(value).pipe(\n Effect.provideService(Crypto.Crypto, crypto),\n Effect.mapError(() => failure(\"storage\", \"digest\")),\n );\n\n const source = (version: EventSourceVersion) => {\n const found = sources.filter((s) => sameSource(s.source, version));\n const item = found[0];\n\n return found.length === 1 && item !== undefined\n ? Effect.succeed(item)\n : Effect.fail(failure(\"unsupported-source\", \"source-version\"));\n };\n\n const scope = Effect.fn(\"Subscriptions.scope\")(function* (value: SubscriptionScope) {\n const decoded = yield* validate(SubscriptionScope, value);\n\n if (!samePartition(decoded.partition, store.partition))\n return yield* failure(\"unauthorized\", \"partition\");\n\n return decoded;\n });\n\n const acceptNormalized = Effect.fn(\"Subscriptions.acceptNormalized\")(function* (\n version: EventSourceVersion,\n event: NormalizedEvent,\n limits: SubscriptionLimits,\n ) {\n const time = yield* now;\n\n const record = yield* validate(AcceptedEvent, {\n schemaVersion: 1,\n partition: store.partition,\n eventId: event.eventId,\n source: version,\n matchingKey: event.matchingKey,\n payload: event.payload,\n payloadDigest: yield* digest(event.payload),\n acceptedAtMillis: time,\n ...(event.occurredAtMillis === undefined ? {} : { occurredAtMillis: event.occurredAtMillis }),\n cutoff: 0,\n cursor: 0,\n routingComplete: false,\n routingFailure: null,\n nextAttemptAtMillis: time,\n });\n\n const retained = yield* store.accept(record, limits);\n\n if (retained.tombstone !== true && (yield* digest(retained.payload)) !== retained.payloadDigest)\n return yield* failure(\"corrupt\", \"event-digest\");\n\n return retained;\n });\n\n return { store, authorizer, source, digest, scope, acceptNormalized };\n});\n\nconst pageLimit = (value: number) =>\n validate(Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(100)), value);\n\nconst makeManagement = Effect.fn(\"Subscriptions.make\")(function* (requested: SubscriptionLimits) {\n const limits = yield* validate(SubscriptionLimits, requested);\n const { bindings } = yield* SubscriptionInputBindings;\n const { store, authorizer, source, digest, scope } = yield* dependencies;\n\n const subscribe: Subscriptions[\"Service\"][\"subscribe\"] = Effect.fn(\"Subscriptions.subscribe\")(\n function* (scopeValue, options) {\n const owner = yield* scope(scopeValue);\n\n yield* authorizer.manage(\"subscribe\", owner);\n const behavior = yield* source(options.source);\n const params = yield* behavior.parameters(options.parameters);\n const binding = yield* resolveSubscriptionInput(bindings, options);\n const context = yield* binding.context(options.context);\n\n const configuration = yield* validate(SubscriptionConfiguration, {\n ...options,\n parameters: params.parameters,\n context,\n matchingKey: params.matchingKey,\n });\n\n yield* authorizer.manage(\"subscribe\", owner, configuration);\n\n const key = yield* validate(SubscriptionKey, {\n partition: owner.partition,\n ownerId: owner.ownerId,\n subscriptionId: options.subscriptionId,\n });\n\n const encodedConfiguration = yield* Schema.encodeEffect(SubscriptionConfiguration)(\n configuration,\n ).pipe(Effect.mapError(() => failure(\"validation\", \"configuration\")));\n\n const creationFingerprint = yield* digest({\n key,\n createdBy: owner.principal,\n configuration: encodedConfiguration,\n });\n\n const existing = yield* store.get(key);\n\n if (existing !== null) {\n const retainedConfiguration = yield* Schema.encodeEffect(SubscriptionConfiguration)(\n existing.creationConfiguration,\n ).pipe(Effect.mapError(() => failure(\"corrupt\", \"creation-configuration\")));\n\n const retainedFingerprint = yield* digest({\n key: existing.key,\n createdBy: existing.createdBy,\n configuration: retainedConfiguration,\n });\n\n if (retainedFingerprint !== existing.creationFingerprint)\n return yield* failure(\"corrupt\", \"creation-fingerprint\");\n\n const currentConfiguration = yield* Schema.encodeEffect(SubscriptionConfiguration)(\n existing.configuration,\n ).pipe(Effect.mapError(() => failure(\"corrupt\", \"configuration\")));\n\n if (\n (yield* digest({\n key: existing.key,\n createdBy: existing.createdBy,\n configuration: currentConfiguration,\n })) !== existing.configurationFingerprint\n )\n return yield* failure(\"corrupt\", \"creation-fingerprint\");\n if (existing.creationFingerprint !== creationFingerprint)\n return yield* failure(\"conflict\", \"creation\");\n\n return snapshot(existing, yield* now);\n }\n if (\n bytes(params.parameters) > limits.maxPayloadBytes ||\n bytes(context) > limits.maxContextBytes\n )\n return yield* failure(\"validation\", \"registration-bounds\");\n const time = yield* now;\n\n if (\n configuration.expiresAtMillis !== null &&\n (configuration.expiresAtMillis <= time ||\n configuration.expiresAtMillis - time > limits.maxLifetimeMillis)\n )\n return yield* failure(\"validation\", \"lifetime\");\n if (behavior.reconcile !== undefined && configuration.mode !== \"once\")\n return yield* failure(\"validation\", \"reconciliation-requires-once\");\n\n const record = yield* store.register(\n {\n schemaVersion: 1,\n key,\n creationFingerprint,\n configurationRevision: 1,\n configurationFingerprint: creationFingerprint,\n creationConfiguration: configuration,\n createdBy: owner.principal,\n createdAtMillis: time,\n ordinal: 0,\n configuration,\n state: \"active\",\n recovery:\n behavior.reconcile === undefined\n ? null\n : { attempts: 0, nextAttemptAtMillis: time, lastFailure: null },\n },\n limits,\n );\n\n return snapshot(record, time);\n },\n );\n\n const listSubscriptions: Subscriptions[\"Service\"][\"listSubscriptions\"] = Effect.fn(\n \"Subscriptions.listSubscriptions\",\n )(function* (scopeValue, after = 0, requestedLimit = 50) {\n const owner = yield* scope(scopeValue);\n\n yield* authorizer.manage(\"list\", owner);\n const limit = yield* pageLimit(requestedLimit);\n\n yield* validate(Schema.Natural, after);\n const records = yield* store.list(owner.ownerId, after, limit);\n const time = yield* now;\n\n return {\n items: records.map((record) => snapshot(record, time)),\n next: records.length === limit ? (records.at(-1)?.ordinal ?? null) : null,\n };\n });\n\n const ownedKey = Effect.fn(\"Subscriptions.ownedKey\")(function* (\n owner: SubscriptionScope,\n key: SubscriptionKey,\n ) {\n yield* validate(SubscriptionKey, key);\n if (!samePartition(owner.partition, key.partition) || owner.ownerId !== key.ownerId)\n return yield* failure(\"unauthorized\", \"owner\");\n\n return key;\n });\n\n const updateSubscription: Subscriptions[\"Service\"][\"updateSubscription\"] = Effect.fn(\n \"Subscriptions.updateSubscription\",\n )(function* (scopeValue, key, expectedRevision, options) {\n const owner = yield* scope(scopeValue);\n\n yield* authorizer.manage(\"update\", owner);\n yield* ownedKey(owner, key);\n const behavior = yield* source(options.source);\n const parameters = yield* behavior.parameters(options.parameters);\n const binding = yield* resolveSubscriptionInput(bindings, options);\n const context = yield* binding.context(options.context);\n\n const configuration = yield* validate(SubscriptionConfiguration, {\n ...options,\n ...parameters,\n context,\n });\n\n yield* authorizer.manage(\"update\", owner, configuration);\n const time = yield* now;\n\n if (\n bytes(parameters.parameters) > limits.maxPayloadBytes ||\n bytes(context) > limits.maxContextBytes\n )\n return yield* failure(\"validation\", \"registration-bounds\");\n if (\n configuration.expiresAtMillis !== null &&\n (configuration.expiresAtMillis <= time ||\n configuration.expiresAtMillis - time > limits.maxLifetimeMillis)\n )\n return yield* failure(\"validation\", \"lifetime\");\n if (behavior.reconcile !== undefined && configuration.mode !== \"once\")\n return yield* failure(\"validation\", \"reconciliation-requires-once\");\n const existing = yield* store.get(key);\n\n if (existing === null) return yield* failure(\"not-found\", \"subscription\");\n\n const encoded = yield* Schema.encodeEffect(SubscriptionConfiguration)(configuration).pipe(\n Effect.mapError(() => failure(\"validation\", \"configuration\")),\n );\n\n const configurationFingerprint = yield* digest({\n key,\n createdBy: existing.createdBy,\n configuration: encoded,\n });\n\n const updated = yield* store.change(key, expectedRevision, {\n _tag: \"Update\",\n configuration,\n configurationFingerprint,\n recovery:\n behavior.reconcile === undefined\n ? null\n : { attempts: 0, nextAttemptAtMillis: time, lastFailure: null },\n });\n\n return snapshot(updated, time);\n });\n\n const changeState = Effect.fn(\"Subscriptions.changeState\")(function* (\n scopeValue: SubscriptionScope,\n key: SubscriptionKey,\n expectedRevision: number,\n change: Extract<SubscriptionChange, { readonly _tag: \"Pause\" | \"Resume\" }>,\n ) {\n const owner = yield* scope(scopeValue);\n\n yield* authorizer.manage(change._tag === \"Pause\" ? \"pause\" : \"resume\", owner);\n const updated = yield* store.change(yield* ownedKey(owner, key), expectedRevision, change);\n\n return snapshot(updated, yield* now);\n });\n\n const cancelSubscription: Subscriptions[\"Service\"][\"cancelSubscription\"] = Effect.fn(\n \"Subscriptions.cancelSubscription\",\n )(function* (scopeValue, key, expectedRevision) {\n const owner = yield* scope(scopeValue);\n\n yield* authorizer.manage(\"cancel\", owner);\n const record = yield* store.cancel(yield* ownedKey(owner, key), expectedRevision);\n\n return snapshot(record, yield* now);\n });\n\n const listDeliveries: Subscriptions[\"Service\"][\"listDeliveries\"] = Effect.fn(\n \"Subscriptions.listDeliveries\",\n )(function* (scopeValue, key, after = \"\", requestedLimit = 50) {\n const owner = yield* scope(scopeValue);\n\n yield* authorizer.manage(\"deliveries\", owner);\n const limit = yield* pageLimit(requestedLimit);\n const records = yield* store.listDeliveries(yield* ownedKey(owner, key), after, limit);\n const last = records.at(-1);\n\n return {\n items: records.map(deliverySnapshot),\n next:\n records.length === limit && last !== undefined\n ? subscriptionDeliveryKeyString(last.key)\n : null,\n };\n });\n\n const recoverDelivery: Subscriptions[\"Service\"][\"recoverDelivery\"] = Effect.fn(\n \"Subscriptions.recoverDelivery\",\n )(function* (scopeValue, key, expectedGeneration) {\n const owner = yield* scope(scopeValue);\n\n yield* authorizer.manage(\"recover\", owner);\n yield* ownedKey(owner, key.subscription);\n const existing = yield* store.delivery(key);\n\n if (existing === null) return yield* failure(\"not-found\", \"delivery\");\n\n const recovered = yield* store.changeDelivery(key, existing.deliveryId, {\n _tag: \"Recover\",\n expectedGeneration,\n nowMillis: yield* now,\n });\n\n return deliverySnapshot(recovered);\n });\n\n const getSubscription: Subscriptions[\"Service\"][\"getSubscription\"] = Effect.fn(\n \"Subscriptions.getSubscription\",\n )(function* (scopeValue, key) {\n const owner = yield* scope(scopeValue);\n\n yield* authorizer.manage(\"get\", owner);\n const record = yield* store.get(yield* ownedKey(owner, key));\n\n if (record === null) return yield* failure(\"not-found\", \"subscription\");\n\n return snapshot(record, yield* now);\n });\n\n return Subscriptions.of({\n getSubscription,\n recoverSubscription: (scopeValue, key, expectedRevision) =>\n Effect.gen(function* () {\n const owner = yield* scope(scopeValue);\n\n yield* authorizer.manage(\"recover\", owner);\n\n return snapshot(\n yield* store.change(yield* ownedKey(owner, key), expectedRevision, {\n _tag: \"Recover\",\n nowMillis: yield* now,\n }),\n yield* now,\n );\n }),\n recoverDelivery,\n subscribe,\n updateSubscription,\n pauseSubscription: (scope, key, revision) =>\n changeState(scope, key, revision, { _tag: \"Pause\" }),\n resumeSubscription: (scope, key, revision) =>\n changeState(scope, key, revision, { _tag: \"Resume\" }),\n listSubscriptions,\n cancelSubscription,\n listDeliveries,\n });\n});\n\nconst makeIntake = Effect.fn(\"SubscriptionIntake.make\")(function* (requested: SubscriptionLimits) {\n const limits = yield* validate(SubscriptionLimits, requested);\n const { store, authorizer, source, acceptNormalized } = yield* dependencies;\n\n const accept: SubscriptionIntake[\"Service\"][\"accept\"] = Effect.fn(\"SubscriptionIntake.accept\")(\n function* (principal, version, payload) {\n yield* authorizer.intake(store.partition, version, principal);\n const behavior = yield* source(version);\n const event = yield* behavior.normalize(payload);\n const accepted = yield* acceptNormalized(version, event, limits);\n\n return {\n partition: accepted.partition,\n eventId: accepted.eventId,\n acceptedAtMillis: accepted.acceptedAtMillis,\n };\n },\n );\n\n const status: SubscriptionIntake[\"Service\"][\"status\"] = Effect.fn(\"SubscriptionIntake.status\")(\n function* (principal, version, eventId) {\n yield* authorizer.intake(store.partition, version, principal);\n const event = yield* store.event(eventId);\n\n if (event === null) return yield* failure(\"not-found\", \"event\");\n if (!sameSource(event.source, version)) return yield* failure(\"conflict\", \"event-source\");\n\n return {\n partition: event.partition,\n eventId: event.eventId,\n acceptedAtMillis: event.acceptedAtMillis,\n routingComplete: event.routingComplete,\n routingFailure: event.routingFailure,\n nextAttemptAtMillis: event.nextAttemptAtMillis,\n };\n },\n );\n\n return SubscriptionIntake.of({ accept, status });\n});\n\nconst makeDriver = Effect.fn(\"SubscriptionDriver.make\")(function* (requested: SubscriptionLimits) {\n const limits = yield* validate(SubscriptionLimits, requested);\n const { bindings } = yield* SubscriptionInputBindings;\n const { store, authorizer, source, digest, acceptNormalized } = yield* dependencies;\n const admission = yield* PreparedInputAdmission;\n\n if (limits.retention !== undefined && admission.submissionStatus === undefined)\n return yield* failure(\"validation\", \"retention-requires-submission-status\");\n const failpoint = yield* SubscriptionFailpoint;\n const semaphore = yield* Semaphore.make(limits.concurrency);\n const sweepSemaphore = yield* Semaphore.make(1);\n const definitionEquals = Schema.toEquivalence(DefinitionDigests);\n const nextAttempt = (time: number) => Math.min(time + limits.retryMillis, 8_640_000_000_000_000);\n\n const selected = Effect.fn(\"Subscriptions.selected\")(function* (\n event: AcceptedEvent,\n subscription: SubscriptionRecord,\n ) {\n const deliveryId = yield* digest({\n schemaVersion: 1,\n subscription: subscription.key,\n eventId: event.eventId,\n });\n\n const time = yield* now;\n\n return yield* validate(SubscriptionDelivery, {\n schemaVersion: 1,\n key: { subscription: subscription.key, eventId: event.eventId },\n deliveryId,\n subscriptionFingerprint: subscription.configurationFingerprint,\n configurationRevision: subscription.configurationRevision,\n configuration: subscription.configuration,\n eventDigest: event.payloadDigest,\n source: event.source,\n threadId:\n subscription.configuration.destination._tag === \"ExistingThread\"\n ? subscription.configuration.destination.threadId\n : Schema.decodeSync(ThreadId)(`subscription:${deliveryId}`),\n admissionKey: Schema.decodeSync(IdempotencyKey)(`subscription:${deliveryId}`),\n selectedAtMillis: time,\n ...(limits.retention === undefined ? {} : { observeSettlement: true }),\n state: \"selected\",\n envelope: null,\n envelopeDigest: null,\n retry: {\n generation: 0,\n attempts: 0,\n automaticAttempts: 0,\n parked: false,\n nextAttemptAtMillis: time,\n lastAttemptAtMillis: null,\n lastFailure: null,\n },\n receipt: null,\n refusal: null,\n });\n });\n\n const route = Effect.fn(\"Subscriptions.route\")(function* (event: AcceptedEvent) {\n const behavior = yield* source(event.source);\n const normalized = yield* behavior.normalize(event.payload);\n\n if (\n normalized.eventId !== event.eventId ||\n normalized.occurredAtMillis !== event.occurredAtMillis ||\n normalized.matchingKey !== event.matchingKey ||\n (yield* digest(normalized.payload)) !== event.payloadDigest ||\n (yield* digest(event.payload)) !== event.payloadDigest\n )\n return yield* failure(\"corrupt\", \"event-source-bindings\");\n const candidates = yield* store.candidates(event, limits.batchSize);\n const deliveries: Array<SubscriptionDelivery> = [];\n const time = yield* now;\n\n for (const candidate of candidates) {\n if (\n candidate.state !== \"active\" ||\n (candidate.configuration.expiresAtMillis !== null &&\n candidate.configuration.expiresAtMillis <= time)\n )\n continue;\n\n const config = yield* Schema.encodeEffect(SubscriptionConfiguration)(\n candidate.configuration,\n ).pipe(Effect.mapError(() => failure(\"corrupt\", \"configuration\")));\n\n const fingerprint = yield* digest({\n key: candidate.key,\n createdBy: candidate.createdBy,\n configuration: config,\n });\n\n const parameters = yield* behavior.parameters(candidate.configuration.parameters);\n\n if (\n fingerprint !== candidate.configurationFingerprint ||\n parameters.matchingKey !== candidate.configuration.matchingKey\n )\n return yield* failure(\"corrupt\", \"registration-source-bindings\");\n if (yield* behavior.matches(event, candidate))\n deliveries.push(yield* selected(event, candidate));\n }\n const cursor = candidates.at(-1)?.ordinal ?? event.cursor;\n\n yield* store.select(\n event,\n deliveries,\n cursor,\n candidates.length < limits.batchSize,\n yield* now,\n limits,\n );\n });\n\n const retry = (delivery: SubscriptionDelivery, reason: ScheduleRetryReason) =>\n now.pipe(\n Effect.flatMap((time) =>\n store.changeDelivery(delivery.key, delivery.deliveryId, {\n _tag: \"Retry\",\n nowMillis: time,\n retry: {\n generation: delivery.retry.generation,\n attempts: delivery.retry.attempts + 1,\n automaticAttempts: delivery.retry.automaticAttempts + 1,\n parked: delivery.retry.automaticAttempts + 1 >= (limits.maxAutomaticAttempts ?? 8),\n lastAttemptAtMillis: time,\n nextAttemptAtMillis: nextAttempt(time),\n lastFailure: reason,\n },\n }),\n ),\n Effect.asVoid,\n );\n\n const refuse = (\n delivery: SubscriptionDelivery,\n phase: \"preparation\" | \"admission\",\n code: string,\n ) =>\n now.pipe(\n Effect.flatMap((time) =>\n store.changeDelivery(delivery.key, delivery.deliveryId, {\n _tag: \"Refuse\",\n refusal: { phase, code },\n nowMillis: time,\n }),\n ),\n Effect.asVoid,\n );\n\n const verifySelected = Effect.fn(\"Subscriptions.verifySelected\")(function* (\n delivery: SubscriptionDelivery,\n ) {\n const current = yield* store.get(delivery.key.subscription);\n\n const subscription =\n current === null\n ? null\n : {\n ...current,\n configuration: delivery.configuration,\n configurationRevision: delivery.configurationRevision,\n configurationFingerprint: delivery.subscriptionFingerprint,\n };\n\n const event = yield* store.event(delivery.key.eventId);\n\n if (\n subscription === null ||\n event === null ||\n !sameSource(delivery.source, event.source) ||\n !sameSource(delivery.source, subscription.configuration.source)\n )\n return yield* failure(\"corrupt\", \"selected-reference\");\n\n const expectedId = yield* digest({\n schemaVersion: 1,\n subscription: subscription.key,\n eventId: event.eventId,\n });\n\n const configuration = yield* Schema.encodeEffect(SubscriptionConfiguration)(\n subscription.configuration,\n ).pipe(Effect.mapError(() => failure(\"corrupt\", \"configuration\")));\n\n const fingerprint = yield* digest({\n key: subscription.key,\n createdBy: subscription.createdBy,\n configuration,\n });\n\n const destination = subscription.configuration.destination;\n\n if (\n delivery.subscriptionFingerprint !== fingerprint ||\n delivery.eventDigest !== event.payloadDigest ||\n (yield* digest(event.payload)) !== event.payloadDigest ||\n delivery.deliveryId !== expectedId ||\n delivery.admissionKey !== `subscription:${expectedId}` ||\n delivery.threadId !==\n (destination._tag === \"ExistingThread\"\n ? destination.threadId\n : `subscription:${expectedId}`)\n )\n return yield* failure(\"corrupt\", \"selected-bindings\");\n\n return { subscription, event };\n });\n\n const envelopeDigest = Effect.fn(\"Subscriptions.envelopeDigest\")(function* (\n delivery: SubscriptionDelivery,\n envelope: PreparedInput,\n ) {\n const encoded = yield* Schema.encodeEffect(PreparedInput)(envelope).pipe(\n Effect.mapError(() => failure(\"corrupt\", \"prepared-envelope\")),\n );\n\n return yield* digest({\n deliveryId: delivery.deliveryId,\n subscriptionFingerprint: delivery.subscriptionFingerprint,\n eventDigest: delivery.eventDigest,\n envelope: encoded,\n });\n });\n\n const prepare = Effect.fn(\"Subscriptions.prepare\")(function* (delivery: SubscriptionDelivery) {\n const { subscription, event } = yield* verifySelected(delivery);\n const time = yield* now;\n\n if (\n subscription.state === \"cancelled\" ||\n (subscription.configuration.expiresAtMillis !== null &&\n subscription.configuration.expiresAtMillis <= time)\n ) {\n yield* refuse(\n delivery,\n \"preparation\",\n subscription.state === \"cancelled\" ? \"cancelled\" : \"expired\",\n );\n\n return null;\n }\n const binding = yield* resolveSubscriptionInput(bindings, subscription.configuration);\n\n if ((yield* digest(event.payload)) !== event.payloadDigest)\n return yield* failure(\"corrupt\", \"event-digest\");\n const authorization = yield* authorizer.prepare(subscription, event);\n const input = yield* binding.prepare(event, subscription);\n\n if (bytes(input) > limits.maxPayloadBytes)\n return yield* SubscriptionSourceError.make({ code: \"input-bounds\", retryable: false });\n\n const envelope = yield* validate(PreparedInput, {\n schemaVersion: 1,\n threadId: delivery.threadId,\n admissionKey: delivery.admissionKey,\n deliveryPrincipal: subscription.configuration.deliveryPrincipal,\n ...(subscription.configuration.admissionGroup === undefined\n ? {}\n : { admissionGroup: subscription.configuration.admissionGroup }),\n ...(subscription.configuration.admissionFence === undefined\n ? {}\n : { admissionFence: subscription.configuration.admissionFence }),\n agentId: subscription.configuration.agentId,\n definitions: subscription.configuration.definitions,\n input,\n inputDigest: yield* digest(input),\n authorization,\n });\n\n return yield* store.changeDelivery(delivery.key, delivery.deliveryId, {\n _tag: \"Prepare\",\n envelope,\n envelopeDigest: yield* envelopeDigest(delivery, envelope),\n nowMillis: yield* now,\n });\n });\n\n const process = Effect.fn(\"Subscriptions.processDelivery\")(function* (\n key: SubscriptionDeliveryKey,\n ) {\n let delivery = yield* store.delivery(key);\n\n if (delivery === null) return yield* failure(\"not-found\", \"delivery\");\n if (\n delivery.state === \"delivered\" &&\n delivery.observeSettlement === true &&\n delivery.receipt !== null\n ) {\n const settled =\n admission.submissionStatus === undefined\n ? false\n : yield* admission.submissionStatus(delivery.receipt).pipe(\n Effect.timeout(limits.operationTimeoutMillis),\n Effect.map((status) => status._tag === \"settled\"),\n Effect.catch((error) =>\n Effect.logWarning(\"Subscription settlement observation unavailable\", {\n tag: error._tag,\n }).pipe(Effect.as(false)),\n ),\n );\n\n const time = yield* now;\n\n yield* store.changeDelivery(delivery.key, delivery.deliveryId, {\n _tag: \"ObserveSettlement\",\n receipt: delivery.receipt,\n settled,\n nowMillis: time,\n nextAttemptAtMillis: nextAttempt(time),\n });\n\n return;\n }\n if (\n delivery.retry.parked === true ||\n delivery.retry.nextAttemptAtMillis > (yield* now) ||\n delivery.state === \"delivered\" ||\n delivery.state === \"refused\"\n )\n return;\n if (delivery.state === \"selected\") {\n const original = delivery;\n\n delivery = yield* prepare(original).pipe(\n Effect.timeout(limits.operationTimeoutMillis),\n Effect.catchTag(\"SubscriptionSourceError\", (error) =>\n (error.retryable\n ? retry(original, \"transport\")\n : refuse(original, \"preparation\", error.code)\n ).pipe(Effect.as(null)),\n ),\n Effect.catchTag(\"SubscriptionError\", (error) =>\n error.reason === \"unauthorized\"\n ? refuse(original, \"preparation\", error.code).pipe(Effect.as(null))\n : Effect.fail(error),\n ),\n Effect.catchTag(\"TimeoutError\", () => retry(original, \"timeout\").pipe(Effect.as(null))),\n );\n }\n if (delivery === null || delivery.state === \"refused\" || delivery.state === \"delivered\") return;\n if (\n delivery.state !== \"prepared\" ||\n delivery.envelope === null ||\n delivery.envelopeDigest === null\n )\n return yield* failure(\"corrupt\", \"prepared-state\");\n const { subscription } = yield* verifySelected(delivery);\n const envelope = delivery.envelope;\n\n if (\n (yield* digest(envelope.input)) !== envelope.inputDigest ||\n envelope.threadId !== delivery.threadId ||\n envelope.admissionKey !== delivery.admissionKey ||\n envelope.deliveryPrincipal !== subscription.configuration.deliveryPrincipal ||\n envelope.agentId !== subscription.configuration.agentId ||\n !definitionEquals(envelope.definitions, subscription.configuration.definitions) ||\n delivery.envelopeDigest !== (yield* envelopeDigest(delivery, envelope))\n )\n return yield* failure(\"corrupt\", \"prepared-envelope\");\n\n const outcome = yield* admitPreparedInput(\n admission.submit(envelope),\n limits.operationTimeoutMillis,\n ).pipe(Effect.mapError(() => failure(\"corrupt\", \"admission\")));\n\n if (outcome._tag === \"Receipt\") {\n yield* failpoint.hit(\"subscription:admission:after\");\n if (outcome.receipt.threadId !== envelope.threadId)\n return yield* failure(\"corrupt\", \"receipt-destination\");\n yield* store.changeDelivery(delivery.key, delivery.deliveryId, {\n _tag: \"Complete\",\n receipt: outcome.receipt,\n nowMillis: yield* now,\n });\n } else if (outcome._tag === \"Refused\") yield* refuse(delivery, \"admission\", outcome.error.code);\n else yield* retry(delivery, outcome.reason);\n });\n\n const processDelivery: SubscriptionDriver[\"Service\"][\"processDelivery\"] = (key) =>\n semaphore.withPermit(process(key));\n\n const reconcile = Effect.fn(\"Subscriptions.reconcile\")(function* (\n subscription: SubscriptionRecord,\n ) {\n const time = yield* now;\n\n if (\n subscription.state !== \"active\" ||\n (subscription.configuration.expiresAtMillis !== null &&\n subscription.configuration.expiresAtMillis <= time)\n )\n return yield* store.deferRecovery(subscription.key, subscription.configurationRevision, null);\n const behavior = yield* source(subscription.configuration.source);\n\n if (behavior.reconcile === undefined)\n return yield* failure(\"unsupported-source\", \"source-reconciliation\");\n yield* authorizer.reconcile(subscription);\n\n const observation = yield* behavior.reconcile(subscription).pipe(\n Effect.timeout(limits.operationTimeoutMillis),\n Effect.map((event) => ({ _tag: \"Observed\" as const, event })),\n Effect.catchTag(\"SubscriptionSourceError\", (error) =>\n Effect.succeed({ _tag: \"Failed\" as const, error }),\n ),\n );\n\n if (observation._tag === \"Failed\")\n return yield* store.deferRecovery(subscription.key, subscription.configurationRevision, {\n attempts: (subscription.recovery?.attempts ?? 0) + 1,\n nextAttemptAtMillis: observation.error.retryable ? nextAttempt(time) : null,\n lastFailure: observation.error.code,\n });\n const observed = observation.event;\n\n if (observed !== null) {\n const event = yield* acceptNormalized(behavior.source, observed, limits);\n\n if (event.tombstone === true)\n return yield* store.deferRecovery(subscription.key, subscription.configurationRevision, {\n attempts: (subscription.recovery?.attempts ?? 0) + 1,\n nextAttemptAtMillis: null,\n lastFailure: \"event-reclaimed\",\n });\n\n if (\n event.matchingKey !== subscription.configuration.matchingKey ||\n !(yield* behavior.matches(event, subscription))\n )\n return yield* failure(\"conflict\", \"reconciliation-match\");\n yield* store.catchUp(event, yield* selected(event, subscription), yield* now, limits);\n\n return;\n }\n yield* store.deferRecovery(subscription.key, subscription.configurationRevision, {\n attempts: (subscription.recovery?.attempts ?? 0) + 1,\n nextAttemptAtMillis: nextAttempt(time),\n lastFailure: null,\n });\n });\n\n const runDue = Effect.gen(function* () {\n const time = yield* now;\n let processed = 0;\n let failed = 0;\n\n const failureCode = <E>(cause: Cause.Cause<E>) =>\n Option.match(Cause.findErrorOption(cause), {\n onNone: () => \"defect\",\n onSome: (error) =>\n Schema.is(SubscriptionError)(error)\n ? error.reason\n : Schema.is(SubscriptionSourceError)(error)\n ? error.code\n : Schema.is(Schema.Struct({ _tag: Schema.Literal(\"TimeoutError\") }))(error)\n ? \"timeout\"\n : \"interrupted-work\",\n });\n\n const attempt = <E>(\n work: Effect.Effect<void, E>,\n recover: (code: string) => Effect.Effect<void, SubscriptionStoreFailure>,\n ) =>\n work.pipe(\n Effect.matchCauseEffect({\n onSuccess: () =>\n Effect.sync(() => {\n processed += 1;\n }),\n onFailure: (cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.interrupt\n : Effect.gen(function* () {\n failed += 1;\n const code = failureCode(cause);\n\n yield* recover(code).pipe(\n Effect.catchCause((c) =>\n Cause.hasInterruptsOnly(c) ? Effect.interrupt : Effect.void,\n ),\n );\n yield* Effect.logWarning(\"Subscription work remains pending\").pipe(\n Effect.annotateLogs({ failureCode: code }),\n );\n }),\n }),\n );\n\n // Persist progress even when one record cannot be decoded or deferred. An eviction cannot\n // send every sweep back to a corrupt first page. Each category receives one bounded page.\n const cursors = yield* store.readScanCursors;\n const records = yield* store.recovering(time, cursors.recovery, limits.batchSize);\n const events = yield* store.pendingEvents(time, cursors.events, limits.batchSize);\n const deliveries = yield* store.pendingDeliveries(time, cursors.deliveries, limits.batchSize);\n const lastDelivery = deliveries.at(-1);\n\n yield* store.advanceScanCursors({\n recovery: records.length < limits.batchSize ? 0 : (records.at(-1)?.ordinal ?? 0),\n events: events.length < limits.batchSize ? \"\" : (events.at(-1) ?? \"\"),\n deliveries:\n deliveries.length < limits.batchSize || lastDelivery === undefined\n ? \"\"\n : subscriptionDeliveryKeyString(lastDelivery),\n });\n yield* Effect.forEach(\n records,\n (cursor) =>\n Effect.gen(function* () {\n let record: SubscriptionRecord | null = null;\n\n yield* attempt(\n Effect.gen(function* () {\n record = yield* store.get(cursor.key);\n\n if (record !== null) yield* reconcile(record);\n }).pipe(Effect.timeout(limits.operationTimeoutMillis)),\n (code) =>\n // A failed read supplies no revision that can safely authorize a mutation.\n record === null\n ? Effect.void\n : store.deferRecovery(record.key, record.configurationRevision, {\n attempts: (record.recovery?.attempts ?? 0) + 1,\n nextAttemptAtMillis: code === \"unauthorized\" ? null : nextAttempt(time),\n lastFailure: code,\n }),\n );\n }),\n { concurrency: limits.concurrency },\n );\n yield* Effect.forEach(\n events,\n (eventId) =>\n attempt(\n store.event(eventId).pipe(\n Effect.flatMap((event) =>\n event === null ? failure(\"not-found\", \"event\") : route(event),\n ),\n Effect.timeout(limits.operationTimeoutMillis),\n ),\n (code) => store.deferEvent(eventId, nextAttempt(time), code),\n ),\n { concurrency: limits.concurrency },\n );\n yield* Effect.forEach(\n deliveries,\n (key) =>\n attempt(processDelivery(key), () =>\n store\n .delivery(key)\n .pipe(\n Effect.flatMap((delivery) =>\n delivery === null ? Effect.void : retry(delivery, \"ambiguous\"),\n ),\n ),\n ),\n { concurrency: limits.concurrency },\n );\n\n if (limits.retention !== undefined)\n yield* store.compact(yield* now, limits.retention, limits.batchSize);\n\n return { processed, failed };\n });\n\n return SubscriptionDriver.of({ runDue: sweepSemaphore.withPermit(runDue), processDelivery });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAM,MAAM,SAAS,IAAI,KAAK,OAAO,IAAI,SAAS,aAAa,CAAC;AAEhE,MAAM,WAAW,QAAqC,SACpD,kBAAkB,KAAK;CAAE;CAAQ;AAAK,CAAC;AAEzC,MAAM,SAAS,UAAyB,eAAe,KAAK,UAAU,KAAK,CAAC;AAE5E,MAAM,cAAc,GAAuB,MACzC,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE;AAEvC,MAAM,gBAAgB,OAAO,cAAc,kBAAkB,OAAO,SAAS;AAE7E,MAAM,YAAkC,QAAW,UACjD,OAAO,oBAAoB,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KACxC,OAAO,eAAe,QAAQ,cAAc,QAAQ,CAAC,CACvD;AAEF,MAAM,YAAY,QAA4B,UAAwC;CACpF,KAAK,OAAO;CACZ,uBAAuB,OAAO;CAC9B,0BAA0B,OAAO;CACjC,GAAI,OAAO,cAAc,mBAAmB,KAAA,IACxC,CAAC,IACD,EAAE,gBAAgB,OAAO,cAAc,eAAe;CAC1D,GAAI,OAAO,cAAc,mBAAmB,KAAA,IACxC,CAAC,IACD,EAAE,gBAAgB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,OAAO,OAAO,OAAO,MAAM,UAAU,WAAW,CAC/D,CACF,CACJ,GACF,EAAE,aAAa,OAAO,YAAY,CACpC;EAEA,IAAI,OAAO,cAAc,KAAA,GACvB,OAAO,MAAM,QAAQ,OAAO,KAAK,OAAO,WAAW,OAAO,SAAS;EAErE,OAAO;GAAE;GAAW;EAAO;CAC7B,CAAC;CAED,OAAO,mBAAmB,GAAG;EAAE,QAAQ,eAAe,WAAW,MAAM;EAAG;CAAgB,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ContextHistory, ContextHistoryError } from "../engine/ContextHistory.mjs";
|
|
2
|
+
import { nn as ThreadStore } from "../Records-BAGkekt8.mjs";
|
|
3
|
+
import { Layer, Schema } from "effect";
|
|
4
|
+
declare namespace ThreadContextHistory_d_exports {
|
|
5
|
+
export { ThreadContextHistoryOptions, layer };
|
|
6
|
+
}
|
|
7
|
+
/** Bounds each lookup; a larger archive needs an explicitly configured or indexed adapter. */
|
|
8
|
+
declare const ThreadContextHistoryOptions: Schema.Struct<{
|
|
9
|
+
readonly maxRecords: Schema.optionalKey<Schema.Int>;
|
|
10
|
+
readonly timeoutMillis: Schema.optionalKey<Schema.Int>;
|
|
11
|
+
}>;
|
|
12
|
+
type ThreadContextHistoryOptions = typeof ThreadContextHistoryOptions.Type;
|
|
13
|
+
/**
|
|
14
|
+
* Provides bounded lexical search and paged reads over retained canonical transcript evidence.
|
|
15
|
+
* Each operation captures one tail and scans at most `maxRecords` (default 16,384), in pages of
|
|
16
|
+
* 64, with a `timeoutMillis` deadline (default 10 seconds). An oversized history fails explicitly
|
|
17
|
+
* instead of returning an incomplete search. No index, mutable archive, or background work is created.
|
|
18
|
+
* Search resolves `beforeRecordId` against eligible canonical evidence in that same scan and
|
|
19
|
+
* returns only older matches. It still verifies the entire captured tail and its boundaries.
|
|
20
|
+
*
|
|
21
|
+
* Rollover coverage boundaries assign subsequent records to the new window, including later Runs.
|
|
22
|
+
* Before the first rollover, each Run uses its initial `context:<runId>:0` identity. Pruning and
|
|
23
|
+
* summarization never remove searchable source records. Tool results remain exactly as retained,
|
|
24
|
+
* including any truncation envelope; discarded output bytes and transient recall are unavailable.
|
|
25
|
+
*
|
|
26
|
+
* The host must supply an authorized ThreadStore. This adapter does not grant access based on a
|
|
27
|
+
* Thread ID. Context Tools select the current Run's Thread, never a model-selected Thread.
|
|
28
|
+
*/
|
|
29
|
+
declare const layer: (options?: ThreadContextHistoryOptions) => Layer.Layer<ContextHistory, ContextHistoryError, ThreadStore>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { ThreadContextHistoryOptions, layer, ThreadContextHistory_d_exports as t };
|
|
32
|
+
//# sourceMappingURL=ThreadContextHistory.d.mts.map
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { ContextHistory, ContextHistoryError, ContextHistoryHit, ContextHistoryPage, ContextHistoryRead, ContextHistorySearch } from "../engine/ContextHistory.mjs";
|
|
3
|
+
import { CanonicalRecordEnvelope, CanonicalSequence } from "./Records.mjs";
|
|
4
|
+
import { ThreadRead, ThreadStore, ThreadTail, ThreadTailRequest } from "./ThreadStore.mjs";
|
|
5
|
+
import { ContextHistoryEvidence, matchText, normalizeQuery, project, windowIdFor } from "./ThreadContextHistoryProjection.mjs";
|
|
6
|
+
import { Effect, Layer, Schema, Stream } from "effect";
|
|
7
|
+
//#region src/durable/ThreadContextHistory.ts
|
|
8
|
+
var ThreadContextHistory_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
ThreadContextHistoryOptions: () => ThreadContextHistoryOptions,
|
|
10
|
+
layer: () => layer
|
|
11
|
+
});
|
|
12
|
+
/** Bounds each lookup; a larger archive needs an explicitly configured or indexed adapter. */
|
|
13
|
+
const ThreadContextHistoryOptions = Schema.Struct({
|
|
14
|
+
maxRecords: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
15
|
+
minimum: 1,
|
|
16
|
+
maximum: 65536
|
|
17
|
+
}))),
|
|
18
|
+
timeoutMillis: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
19
|
+
minimum: 1,
|
|
20
|
+
maximum: 3e5
|
|
21
|
+
})))
|
|
22
|
+
});
|
|
23
|
+
const unavailable = () => ContextHistoryError.make({
|
|
24
|
+
reason: "unavailable",
|
|
25
|
+
message: "Canonical context history is unavailable"
|
|
26
|
+
});
|
|
27
|
+
const invalid = (message) => ContextHistoryError.make({
|
|
28
|
+
reason: "invalid-input",
|
|
29
|
+
message
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Provides bounded lexical search and paged reads over retained canonical transcript evidence.
|
|
33
|
+
* Each operation captures one tail and scans at most `maxRecords` (default 16,384), in pages of
|
|
34
|
+
* 64, with a `timeoutMillis` deadline (default 10 seconds). An oversized history fails explicitly
|
|
35
|
+
* instead of returning an incomplete search. No index, mutable archive, or background work is created.
|
|
36
|
+
* Search resolves `beforeRecordId` against eligible canonical evidence in that same scan and
|
|
37
|
+
* returns only older matches. It still verifies the entire captured tail and its boundaries.
|
|
38
|
+
*
|
|
39
|
+
* Rollover coverage boundaries assign subsequent records to the new window, including later Runs.
|
|
40
|
+
* Before the first rollover, each Run uses its initial `context:<runId>:0` identity. Pruning and
|
|
41
|
+
* summarization never remove searchable source records. Tool results remain exactly as retained,
|
|
42
|
+
* including any truncation envelope; discarded output bytes and transient recall are unavailable.
|
|
43
|
+
*
|
|
44
|
+
* The host must supply an authorized ThreadStore. This adapter does not grant access based on a
|
|
45
|
+
* Thread ID. Context Tools select the current Run's Thread, never a model-selected Thread.
|
|
46
|
+
*/
|
|
47
|
+
const layer = (options = {}) => Layer.effect(ContextHistory, Effect.gen(function* () {
|
|
48
|
+
const decoded = yield* Schema.decodeEffect(ThreadContextHistoryOptions)(options).pipe(Effect.mapError(() => invalid("Invalid context history limits")));
|
|
49
|
+
const maxRecords = decoded.maxRecords ?? 16384;
|
|
50
|
+
const timeoutMillis = decoded.timeoutMillis ?? 1e4;
|
|
51
|
+
const store = yield* ThreadStore;
|
|
52
|
+
const scan = Effect.fn("ThreadContextHistory.scan")(function* (threadId, visit) {
|
|
53
|
+
const tail = yield* store.inspectTail(ThreadTailRequest.make({ threadId })).pipe(Effect.mapError(unavailable), Effect.flatMap((value) => Schema.decodeEffect(Schema.toType(ThreadTail))(value).pipe(Effect.mapError(unavailable))));
|
|
54
|
+
if (tail.threadId !== threadId) return yield* unavailable();
|
|
55
|
+
if (tail.tailSequence > maxRecords) return yield* ContextHistoryError.make({
|
|
56
|
+
reason: "limit",
|
|
57
|
+
message: `Context history exceeds the configured ${maxRecords} record scan limit`
|
|
58
|
+
});
|
|
59
|
+
const boundaries = [];
|
|
60
|
+
let cursor = Schema.decodeSync(CanonicalSequence)(0);
|
|
61
|
+
while (cursor < tail.tailSequence) {
|
|
62
|
+
const limit = Math.min(64, tail.tailSequence - cursor);
|
|
63
|
+
const page = yield* store.read(ThreadRead.make({
|
|
64
|
+
threadId,
|
|
65
|
+
afterSequence: cursor,
|
|
66
|
+
limit
|
|
67
|
+
})).pipe(Stream.take(limit + 1), Stream.runCollect, Effect.mapError(unavailable));
|
|
68
|
+
if (page.length !== limit) return yield* unavailable();
|
|
69
|
+
for (const raw of page) {
|
|
70
|
+
const record = yield* Schema.decodeEffect(Schema.toType(CanonicalRecordEnvelope))(raw).pipe(Effect.mapError(unavailable));
|
|
71
|
+
if (record.threadId !== threadId || record.sequence !== cursor + 1) return yield* unavailable();
|
|
72
|
+
if (record.record.payload._tag === "CompactionCreated") {
|
|
73
|
+
const { boundary } = yield* project(record);
|
|
74
|
+
if (boundary !== void 0) {
|
|
75
|
+
if (boundary.coversThrough < (boundaries.at(-1)?.coversThrough ?? 0)) return yield* unavailable();
|
|
76
|
+
boundaries.push(boundary);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
yield* visit(record);
|
|
80
|
+
cursor = record.sequence;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return boundaries;
|
|
84
|
+
});
|
|
85
|
+
const search = Effect.fn("ThreadContextHistory.search")(function* (input) {
|
|
86
|
+
const request = yield* Schema.decodeEffect(Schema.toType(ContextHistorySearch))(input).pipe(Effect.mapError(() => invalid("Invalid context history search")));
|
|
87
|
+
const query = yield* normalizeQuery(request.query);
|
|
88
|
+
const matches = [];
|
|
89
|
+
let anchorFound = false;
|
|
90
|
+
const boundaries = yield* scan(request.threadId, Effect.fn(function* (record) {
|
|
91
|
+
const item = (yield* project(record)).evidence;
|
|
92
|
+
if (item === void 0) return;
|
|
93
|
+
if (item.recordId === request.beforeRecordId) anchorFound = true;
|
|
94
|
+
if (anchorFound) return;
|
|
95
|
+
const text = matchText(item.text, query);
|
|
96
|
+
if (text === void 0) return;
|
|
97
|
+
matches.push(ContextHistoryEvidence.make({
|
|
98
|
+
...item,
|
|
99
|
+
text
|
|
100
|
+
}));
|
|
101
|
+
if (matches.length > request.limit) matches.shift();
|
|
102
|
+
}));
|
|
103
|
+
if (request.beforeRecordId !== void 0 && !anchorFound) return yield* ContextHistoryError.make({
|
|
104
|
+
reason: "not-found",
|
|
105
|
+
message: "Retained context record was not found in this Thread"
|
|
106
|
+
});
|
|
107
|
+
return matches.reverse().map((item) => ContextHistoryHit.make({
|
|
108
|
+
recordId: item.recordId,
|
|
109
|
+
windowId: windowIdFor(item, boundaries),
|
|
110
|
+
text: item.text
|
|
111
|
+
}));
|
|
112
|
+
}, Effect.timeoutOrElse({
|
|
113
|
+
duration: timeoutMillis,
|
|
114
|
+
orElse: () => Effect.fail(ContextHistoryError.make({
|
|
115
|
+
reason: "limit",
|
|
116
|
+
message: "Context history search exceeded its time limit"
|
|
117
|
+
}))
|
|
118
|
+
}));
|
|
119
|
+
const read = Effect.fn("ThreadContextHistory.read")(function* (input) {
|
|
120
|
+
const request = yield* Schema.decodeEffect(Schema.toType(ContextHistoryRead))(input).pipe(Effect.mapError(() => invalid("Invalid context history read")));
|
|
121
|
+
let selected;
|
|
122
|
+
const boundaries = yield* scan(request.threadId, Effect.fn(function* (record) {
|
|
123
|
+
if (record.record.recordId === request.recordId) selected = (yield* project(record)).evidence;
|
|
124
|
+
}));
|
|
125
|
+
if (selected === void 0) return yield* ContextHistoryError.make({
|
|
126
|
+
reason: "not-found",
|
|
127
|
+
message: "Retained context record was not found in this Thread"
|
|
128
|
+
});
|
|
129
|
+
if (request.offset > selected.text.length) return yield* invalid("Context history offset is beyond the retained record");
|
|
130
|
+
const end = Math.min(selected.text.length, request.offset + request.maxChars);
|
|
131
|
+
return ContextHistoryPage.make({
|
|
132
|
+
recordId: selected.recordId,
|
|
133
|
+
windowId: windowIdFor(selected, boundaries),
|
|
134
|
+
text: selected.text.slice(request.offset, end),
|
|
135
|
+
nextOffset: end < selected.text.length ? end : null
|
|
136
|
+
});
|
|
137
|
+
}, Effect.timeoutOrElse({
|
|
138
|
+
duration: timeoutMillis,
|
|
139
|
+
orElse: () => Effect.fail(ContextHistoryError.make({
|
|
140
|
+
reason: "limit",
|
|
141
|
+
message: "Context history read exceeded its time limit"
|
|
142
|
+
}))
|
|
143
|
+
}));
|
|
144
|
+
return ContextHistory.of({
|
|
145
|
+
search,
|
|
146
|
+
read
|
|
147
|
+
});
|
|
148
|
+
}));
|
|
149
|
+
//#endregion
|
|
150
|
+
export { ThreadContextHistoryOptions, layer, ThreadContextHistory_exports as t };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=ThreadContextHistory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThreadContextHistory.mjs","names":[],"sources":["../../src/durable/ThreadContextHistory.ts"],"sourcesContent":["import { Effect, Layer, Schema, Stream } from \"effect\";\n\nimport type { ThreadId } from \"../core/Identifiers.ts\";\nimport {\n ContextHistory,\n ContextHistoryError,\n ContextHistoryHit,\n ContextHistoryPage,\n ContextHistoryRead,\n ContextHistorySearch,\n} from \"../engine/ContextHistory.ts\";\nimport { CanonicalRecordEnvelope, CanonicalSequence } from \"./Records.ts\";\nimport type { ContextHistoryBoundary } from \"./ThreadContextHistoryProjection.ts\";\nimport {\n ContextHistoryEvidence,\n project,\n normalizeQuery,\n matchText,\n windowIdFor,\n} from \"./ThreadContextHistoryProjection.ts\";\nimport { ThreadRead, ThreadStore, ThreadTail, ThreadTailRequest } from \"./ThreadStore.ts\";\n\n/** Bounds each lookup; a larger archive needs an explicitly configured or indexed adapter. */\nexport const ThreadContextHistoryOptions = Schema.Struct({\n maxRecords: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65_536 })),\n ),\n timeoutMillis: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 300_000 })),\n ),\n});\n\nexport type ThreadContextHistoryOptions = typeof ThreadContextHistoryOptions.Type;\n\nconst unavailable = () =>\n ContextHistoryError.make({\n reason: \"unavailable\",\n message: \"Canonical context history is unavailable\",\n });\n\nconst invalid = (message: string) => ContextHistoryError.make({ reason: \"invalid-input\", message });\n\n/**\n * Provides bounded lexical search and paged reads over retained canonical transcript evidence.\n * Each operation captures one tail and scans at most `maxRecords` (default 16,384), in pages of\n * 64, with a `timeoutMillis` deadline (default 10 seconds). An oversized history fails explicitly\n * instead of returning an incomplete search. No index, mutable archive, or background work is created.\n * Search resolves `beforeRecordId` against eligible canonical evidence in that same scan and\n * returns only older matches. It still verifies the entire captured tail and its boundaries.\n *\n * Rollover coverage boundaries assign subsequent records to the new window, including later Runs.\n * Before the first rollover, each Run uses its initial `context:<runId>:0` identity. Pruning and\n * summarization never remove searchable source records. Tool results remain exactly as retained,\n * including any truncation envelope; discarded output bytes and transient recall are unavailable.\n *\n * The host must supply an authorized ThreadStore. This adapter does not grant access based on a\n * Thread ID. Context Tools select the current Run's Thread, never a model-selected Thread.\n */\nexport const layer = (\n options: ThreadContextHistoryOptions = {},\n): Layer.Layer<ContextHistory, ContextHistoryError, ThreadStore> =>\n Layer.effect(\n ContextHistory,\n Effect.gen(function* () {\n const decoded = yield* Schema.decodeEffect(ThreadContextHistoryOptions)(options).pipe(\n Effect.mapError(() => invalid(\"Invalid context history limits\")),\n );\n\n const maxRecords = decoded.maxRecords ?? 16_384;\n const timeoutMillis = decoded.timeoutMillis ?? 10_000;\n const store = yield* ThreadStore;\n\n const scan = Effect.fn(\"ThreadContextHistory.scan\")(function* (\n threadId: ThreadId,\n visit: (record: CanonicalRecordEnvelope) => Effect.Effect<void, ContextHistoryError>,\n ) {\n const tail = yield* store.inspectTail(ThreadTailRequest.make({ threadId })).pipe(\n Effect.mapError(unavailable),\n Effect.flatMap((value) =>\n Schema.decodeEffect(Schema.toType(ThreadTail))(value).pipe(\n Effect.mapError(unavailable),\n ),\n ),\n );\n\n if (tail.threadId !== threadId) return yield* unavailable();\n if (tail.tailSequence > maxRecords)\n return yield* ContextHistoryError.make({\n reason: \"limit\",\n message: `Context history exceeds the configured ${maxRecords} record scan limit`,\n });\n const boundaries: Array<ContextHistoryBoundary> = [];\n let cursor = Schema.decodeSync(CanonicalSequence)(0);\n\n while (cursor < tail.tailSequence) {\n const limit = Math.min(64, tail.tailSequence - cursor);\n\n const page = yield* store\n .read(ThreadRead.make({ threadId, afterSequence: cursor, limit }))\n .pipe(Stream.take(limit + 1), Stream.runCollect, Effect.mapError(unavailable));\n\n if (page.length !== limit) return yield* unavailable();\n for (const raw of page) {\n const record = yield* Schema.decodeEffect(Schema.toType(CanonicalRecordEnvelope))(\n raw,\n ).pipe(Effect.mapError(unavailable));\n\n if (record.threadId !== threadId || record.sequence !== cursor + 1)\n return yield* unavailable();\n if (record.record.payload._tag === \"CompactionCreated\") {\n const { boundary } = yield* project(record);\n\n if (boundary !== undefined) {\n if (boundary.coversThrough < (boundaries.at(-1)?.coversThrough ?? 0))\n return yield* unavailable();\n boundaries.push(boundary);\n }\n }\n yield* visit(record);\n cursor = record.sequence;\n }\n }\n\n return boundaries;\n });\n\n const search = Effect.fn(\"ThreadContextHistory.search\")(\n function* (input: ContextHistorySearch) {\n const request = yield* Schema.decodeEffect(Schema.toType(ContextHistorySearch))(\n input,\n ).pipe(Effect.mapError(() => invalid(\"Invalid context history search\")));\n\n const query = yield* normalizeQuery(request.query);\n const matches: Array<ContextHistoryEvidence> = [];\n let anchorFound = false;\n\n const boundaries = yield* scan(\n request.threadId,\n Effect.fn(function* (record) {\n const item = (yield* project(record)).evidence;\n\n if (item === undefined) return;\n if (item.recordId === request.beforeRecordId) anchorFound = true;\n // The scan is ascending: retain older candidates until the exclusive anchor.\n // Continue scanning to verify the captured tail and all window boundaries.\n if (anchorFound) return;\n const text = matchText(item.text, query);\n\n if (text === undefined) return;\n matches.push(ContextHistoryEvidence.make({ ...item, text }));\n if (matches.length > request.limit) matches.shift();\n }),\n );\n\n if (request.beforeRecordId !== undefined && !anchorFound)\n return yield* ContextHistoryError.make({\n reason: \"not-found\",\n message: \"Retained context record was not found in this Thread\",\n });\n\n return matches.reverse().map((item) =>\n ContextHistoryHit.make({\n recordId: item.recordId,\n windowId: windowIdFor(item, boundaries),\n text: item.text,\n }),\n );\n },\n Effect.timeoutOrElse({\n duration: timeoutMillis,\n orElse: () =>\n Effect.fail(\n ContextHistoryError.make({\n reason: \"limit\",\n message: \"Context history search exceeded its time limit\",\n }),\n ),\n }),\n );\n\n const read = Effect.fn(\"ThreadContextHistory.read\")(\n function* (input: ContextHistoryRead) {\n const request = yield* Schema.decodeEffect(Schema.toType(ContextHistoryRead))(input).pipe(\n Effect.mapError(() => invalid(\"Invalid context history read\")),\n );\n\n let selected: ContextHistoryEvidence | undefined;\n\n const boundaries = yield* scan(\n request.threadId,\n Effect.fn(function* (record) {\n if (record.record.recordId === request.recordId)\n selected = (yield* project(record)).evidence;\n }),\n );\n\n if (selected === undefined)\n return yield* ContextHistoryError.make({\n reason: \"not-found\",\n message: \"Retained context record was not found in this Thread\",\n });\n if (request.offset > selected.text.length)\n return yield* invalid(\"Context history offset is beyond the retained record\");\n const end = Math.min(selected.text.length, request.offset + request.maxChars);\n\n return ContextHistoryPage.make({\n recordId: selected.recordId,\n windowId: windowIdFor(selected, boundaries),\n text: selected.text.slice(request.offset, end),\n nextOffset: end < selected.text.length ? end : null,\n });\n },\n Effect.timeoutOrElse({\n duration: timeoutMillis,\n orElse: () =>\n Effect.fail(\n ContextHistoryError.make({\n reason: \"limit\",\n message: \"Context history read exceeded its time limit\",\n }),\n ),\n }),\n );\n\n return ContextHistory.of({ search, read });\n }),\n );\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAa,8BAA8B,OAAO,OAAO;CACvD,YAAY,OAAO,YACjB,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAO,CAAC,CAAC,CACpE;CACA,eAAe,OAAO,YACpB,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAQ,CAAC,CAAC,CACrE;AACF,CAAC;AAID,MAAM,oBACJ,oBAAoB,KAAK;CACvB,QAAQ;CACR,SAAS;AACX,CAAC;AAEH,MAAM,WAAW,YAAoB,oBAAoB,KAAK;CAAE,QAAQ;CAAiB;AAAQ,CAAC;;;;;;;;;;;;;;;;;AAkBlG,MAAa,SACX,UAAuC,CAAC,MAExC,MAAM,OACJ,gBACA,OAAO,IAAI,aAAa;CACtB,MAAM,UAAU,OAAO,OAAO,aAAa,2BAA2B,CAAC,CAAC,OAAO,CAAC,CAAC,KAC/E,OAAO,eAAe,QAAQ,gCAAgC,CAAC,CACjE;CAEA,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,gBAAgB,QAAQ,iBAAiB;CAC/C,MAAM,QAAQ,OAAO;CAErB,MAAM,OAAO,OAAO,GAAG,2BAA2B,CAAC,CAAC,WAClD,UACA,OACA;EACA,MAAM,OAAO,OAAO,MAAM,YAAY,kBAAkB,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,KAC1E,OAAO,SAAS,WAAW,GAC3B,OAAO,SAAS,UACd,OAAO,aAAa,OAAO,OAAO,UAAU,CAAC,CAAC,CAAC,KAAK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EAEA,IAAI;EAEJ,MAAM,aAAa,OAAO,KACxB,QAAQ,UACR,OAAO,GAAG,WAAW,QAAQ;GAC3B,IAAI,OAAO,OAAO,aAAa,QAAQ,UACrC,YAAY,OAAO,QAAQ,MAAM,EAAA,CAAG;EACxC,CAAC,CACH;EAEA,IAAI,aAAa,KAAA,GACf,OAAO,OAAO,oBAAoB,KAAK;GACrC,QAAQ;GACR,SAAS;EACX,CAAC;EACH,IAAI,QAAQ,SAAS,SAAS,KAAK,QACjC,OAAO,OAAO,QAAQ,sDAAsD;EAC9E,MAAM,MAAM,KAAK,IAAI,SAAS,KAAK,QAAQ,QAAQ,SAAS,QAAQ,QAAQ;EAE5E,OAAO,mBAAmB,KAAK;GAC7B,UAAU,SAAS;GACnB,UAAU,YAAY,UAAU,UAAU;GAC1C,MAAM,SAAS,KAAK,MAAM,QAAQ,QAAQ,GAAG;GAC7C,YAAY,MAAM,SAAS,KAAK,SAAS,MAAM;EACjD,CAAC;CACH,GACA,OAAO,cAAc;EACnB,UAAU;EACV,cACE,OAAO,KACL,oBAAoB,KAAK;GACvB,QAAQ;GACR,SAAS;EACX,CAAC,CACH;CACJ,CAAC,CACH;CAEA,OAAO,eAAe,GAAG;EAAE;EAAQ;CAAK,CAAC;AAC3C,CAAC,CACH"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ContextHistoryError } from "../engine/ContextHistory.mjs";
|
|
2
|
+
import { l as CanonicalRecordEnvelope } from "../Records-BAGkekt8.mjs";
|
|
3
|
+
import { Effect, Schema } from "effect";
|
|
4
|
+
declare namespace ThreadContextHistoryProjection_d_exports {
|
|
5
|
+
export { ContextHistoryBoundary, ContextHistoryEvidence, ContextHistoryProjection, matchText, normalizeQuery, normalizeText, project, windowIdFor };
|
|
6
|
+
}
|
|
7
|
+
declare const ContextHistoryEvidence_base: Schema.Class<ContextHistoryEvidence, Schema.Struct<{
|
|
8
|
+
readonly recordId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/RecordId">;
|
|
9
|
+
readonly sequence: Schema.brand<Schema.Natural, "@effect-agent/thread/CanonicalSequence">;
|
|
10
|
+
readonly runId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/RunId">;
|
|
11
|
+
readonly text: Schema.NonEmptyString;
|
|
12
|
+
}>, {}>;
|
|
13
|
+
/** Full retained recall text from one canonical record; never raw discarded Tool output. */
|
|
14
|
+
declare class ContextHistoryEvidence extends ContextHistoryEvidence_base {}
|
|
15
|
+
declare const ContextHistoryBoundary_base: Schema.Class<ContextHistoryBoundary, Schema.Struct<{
|
|
16
|
+
readonly sequence: Schema.brand<Schema.Natural, "@effect-agent/thread/CanonicalSequence">;
|
|
17
|
+
readonly coversThrough: Schema.brand<Schema.Natural, "@effect-agent/thread/CanonicalSequence">;
|
|
18
|
+
readonly windowId: Schema.NonEmptyString;
|
|
19
|
+
}>, {}>;
|
|
20
|
+
/** The committing position and covered position are distinct; membership uses coversThrough. */
|
|
21
|
+
declare class ContextHistoryBoundary extends ContextHistoryBoundary_base {}
|
|
22
|
+
declare const ContextHistoryProjection_base: Schema.Class<ContextHistoryProjection, Schema.Struct<{
|
|
23
|
+
readonly evidence: Schema.optionalKey<typeof ContextHistoryEvidence>;
|
|
24
|
+
readonly boundary: Schema.optionalKey<typeof ContextHistoryBoundary>;
|
|
25
|
+
}>, {}>;
|
|
26
|
+
/** An empty projection still consumes its canonical position in an index watermark. */
|
|
27
|
+
declare class ContextHistoryProjection extends ContextHistoryProjection_base {}
|
|
28
|
+
/**
|
|
29
|
+
* Project one decoded canonical record without reading storage or retaining mutable state.
|
|
30
|
+
* Only model transcript text and settled Tool results are evidence. Instructions, reasoning,
|
|
31
|
+
* attachment bytes, raw submissions, Steps, approvals, and diagnostics remain private. Tool
|
|
32
|
+
* truncation envelopes are rendered as retained; discarded bytes cannot be reconstructed.
|
|
33
|
+
*
|
|
34
|
+
* An index must process contiguous records, including empty projections, and commit its rows
|
|
35
|
+
* and watermark atomically. Validate nondecreasing coversThrough across rollover boundaries.
|
|
36
|
+
* Filter both evidence and committing boundary sequences to the operation's captured tail.
|
|
37
|
+
* Authorization and canonical verification of index candidates remain the host's responsibility.
|
|
38
|
+
* For search pagination, resolve and canonically verify `beforeRecordId` as eligible evidence
|
|
39
|
+
* in the same Thread and captured tail, then select matching evidence with sequence strictly
|
|
40
|
+
* below that anchor, in descending sequence order. The anchor need not match the new query.
|
|
41
|
+
* Do not restrict rollover boundaries to the anchor: later commits may assign older evidence
|
|
42
|
+
* to a window. An ID or an index row alone does not establish existence, eligibility, or access.
|
|
43
|
+
*/
|
|
44
|
+
declare const project: (envelope: CanonicalRecordEnvelope) => Effect.Effect<ContextHistoryProjection, ContextHistoryError, never>;
|
|
45
|
+
/** JavaScript case folding for literal substring lookup; do not substitute SQL lower or FTS. */
|
|
46
|
+
declare const normalizeText: (text: string) => string;
|
|
47
|
+
/** Validate, trim, and case-fold a search query using the native history contract. */
|
|
48
|
+
declare const normalizeQuery: (query: string) => Effect.Effect<string, ContextHistoryError, never>;
|
|
49
|
+
/** Match a normalized query and retain the native 200-character lead and 2,000-character page. */
|
|
50
|
+
declare const matchText: (text: string, normalizedQuery: string) => string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Boundaries must be in canonical order with nondecreasing coversThrough and belong to the
|
|
53
|
+
* same captured Thread tail as the evidence. An index may supply only its last boundary whose
|
|
54
|
+
* coversThrough is strictly less than evidence.sequence. Later Runs inherit that window;
|
|
55
|
+
* evidence before the first rollover keeps its own Run's initial identity.
|
|
56
|
+
*/
|
|
57
|
+
declare const windowIdFor: (evidence: ContextHistoryEvidence, boundaries: ReadonlyArray<ContextHistoryBoundary>) => string;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { ContextHistoryBoundary, ContextHistoryEvidence, ContextHistoryProjection, matchText, normalizeQuery, normalizeText, project, ThreadContextHistoryProjection_d_exports as t, windowIdFor };
|
|
60
|
+
//# sourceMappingURL=ThreadContextHistoryProjection.d.mts.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { RunId } from "../core/Identifiers.mjs";
|
|
3
|
+
import { f as contextWindowId } from "../compaction-C2OTceKw.mjs";
|
|
4
|
+
import { ContextHistoryError, ContextHistorySearch } from "../engine/ContextHistory.mjs";
|
|
5
|
+
import { CanonicalSequence, PersistedJson, RecordId } from "./Records.mjs";
|
|
6
|
+
import { Prompt } from "effect/unstable/ai";
|
|
7
|
+
import { Effect, Schema } from "effect";
|
|
8
|
+
//#region src/durable/ThreadContextHistoryProjection.ts
|
|
9
|
+
var ThreadContextHistoryProjection_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
ContextHistoryBoundary: () => ContextHistoryBoundary,
|
|
11
|
+
ContextHistoryEvidence: () => ContextHistoryEvidence,
|
|
12
|
+
ContextHistoryProjection: () => ContextHistoryProjection,
|
|
13
|
+
matchText: () => matchText,
|
|
14
|
+
normalizeQuery: () => normalizeQuery,
|
|
15
|
+
normalizeText: () => normalizeText,
|
|
16
|
+
project: () => project,
|
|
17
|
+
windowIdFor: () => windowIdFor
|
|
18
|
+
});
|
|
19
|
+
/** Full retained recall text from one canonical record; never raw discarded Tool output. */
|
|
20
|
+
var ContextHistoryEvidence = class extends Schema.Class("@effect-agent/thread/ContextHistoryEvidence")({
|
|
21
|
+
recordId: RecordId,
|
|
22
|
+
sequence: CanonicalSequence,
|
|
23
|
+
runId: RunId,
|
|
24
|
+
text: Schema.NonEmptyString
|
|
25
|
+
}) {};
|
|
26
|
+
/** The committing position and covered position are distinct; membership uses coversThrough. */
|
|
27
|
+
var ContextHistoryBoundary = class extends Schema.Class("@effect-agent/thread/ContextHistoryBoundary")({
|
|
28
|
+
sequence: CanonicalSequence,
|
|
29
|
+
coversThrough: CanonicalSequence,
|
|
30
|
+
windowId: Schema.NonEmptyString
|
|
31
|
+
}) {};
|
|
32
|
+
/** An empty projection still consumes its canonical position in an index watermark. */
|
|
33
|
+
var ContextHistoryProjection = class extends Schema.Class("@effect-agent/thread/ContextHistoryProjection")({
|
|
34
|
+
evidence: Schema.optionalKey(ContextHistoryEvidence),
|
|
35
|
+
boundary: Schema.optionalKey(ContextHistoryBoundary)
|
|
36
|
+
}) {};
|
|
37
|
+
const unavailable = () => ContextHistoryError.make({
|
|
38
|
+
reason: "unavailable",
|
|
39
|
+
message: "Canonical context history is unavailable"
|
|
40
|
+
});
|
|
41
|
+
const jsonText = Effect.fn("ThreadContextHistoryProjection.jsonText")(function* (value) {
|
|
42
|
+
const json = yield* Schema.decodeUnknownEffect(PersistedJson)(value).pipe(Effect.mapError(unavailable));
|
|
43
|
+
return JSON.stringify(json);
|
|
44
|
+
});
|
|
45
|
+
const promptText = Effect.fn("ThreadContextHistoryProjection.promptText")(function* (value) {
|
|
46
|
+
const prompt = yield* Schema.decodeUnknownEffect(Prompt.Prompt)(value).pipe(Effect.mapError(unavailable));
|
|
47
|
+
const messages = [];
|
|
48
|
+
for (const message of prompt.content) {
|
|
49
|
+
if (message.role === "system") continue;
|
|
50
|
+
const parts = [];
|
|
51
|
+
for (const part of message.content) switch (part.type) {
|
|
52
|
+
case "text":
|
|
53
|
+
parts.push(part.text);
|
|
54
|
+
break;
|
|
55
|
+
case "tool-call":
|
|
56
|
+
parts.push(`tool call ${part.name} (${part.id}):\n${yield* jsonText(part.params)}`);
|
|
57
|
+
break;
|
|
58
|
+
case "tool-result":
|
|
59
|
+
parts.push(`tool result ${part.name} (${part.id}; ${part.isFailure ? "failure" : "success"}):\n${yield* jsonText(part.result)}`);
|
|
60
|
+
break;
|
|
61
|
+
case "file": parts.push("[attachment omitted]");
|
|
62
|
+
}
|
|
63
|
+
if (parts.length > 0) messages.push(`${message.role}:\n${parts.join("\n")}`);
|
|
64
|
+
}
|
|
65
|
+
return messages.join("\n\n");
|
|
66
|
+
});
|
|
67
|
+
const retainedEvidence = Effect.fn("ThreadContextHistoryProjection.evidence")(function* (envelope) {
|
|
68
|
+
const payload = envelope.record.payload;
|
|
69
|
+
let text;
|
|
70
|
+
if (payload._tag === "ModelResponseRecorded") text = yield* promptText(payload.messages);
|
|
71
|
+
else if (payload._tag === "ModelCompleted") text = payload.messages === void 0 ? `assistant output:\n${yield* jsonText(payload.output)}` : yield* promptText(payload.messages);
|
|
72
|
+
else if (payload._tag === "ToolCallSettled") text = `tool result ${payload.toolName} (${payload.toolCallId}; ${payload.isFailure ? "failure" : "success"}):\n${yield* jsonText(payload.result)}`;
|
|
73
|
+
else return;
|
|
74
|
+
return text.length === 0 ? void 0 : ContextHistoryEvidence.make({
|
|
75
|
+
recordId: envelope.record.recordId,
|
|
76
|
+
sequence: envelope.sequence,
|
|
77
|
+
runId: payload.runId,
|
|
78
|
+
text
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Project one decoded canonical record without reading storage or retaining mutable state.
|
|
83
|
+
* Only model transcript text and settled Tool results are evidence. Instructions, reasoning,
|
|
84
|
+
* attachment bytes, raw submissions, Steps, approvals, and diagnostics remain private. Tool
|
|
85
|
+
* truncation envelopes are rendered as retained; discarded bytes cannot be reconstructed.
|
|
86
|
+
*
|
|
87
|
+
* An index must process contiguous records, including empty projections, and commit its rows
|
|
88
|
+
* and watermark atomically. Validate nondecreasing coversThrough across rollover boundaries.
|
|
89
|
+
* Filter both evidence and committing boundary sequences to the operation's captured tail.
|
|
90
|
+
* Authorization and canonical verification of index candidates remain the host's responsibility.
|
|
91
|
+
* For search pagination, resolve and canonically verify `beforeRecordId` as eligible evidence
|
|
92
|
+
* in the same Thread and captured tail, then select matching evidence with sequence strictly
|
|
93
|
+
* below that anchor, in descending sequence order. The anchor need not match the new query.
|
|
94
|
+
* Do not restrict rollover boundaries to the anchor: later commits may assign older evidence
|
|
95
|
+
* to a window. An ID or an index row alone does not establish existence, eligibility, or access.
|
|
96
|
+
*/
|
|
97
|
+
const project = Effect.fn("ThreadContextHistoryProjection.project")(function* (envelope) {
|
|
98
|
+
const payload = envelope.record.payload;
|
|
99
|
+
if (payload._tag === "CompactionCreated" && payload.kind === "rollover") {
|
|
100
|
+
if (payload.coversThrough >= envelope.sequence) return yield* unavailable();
|
|
101
|
+
return ContextHistoryProjection.make({ boundary: ContextHistoryBoundary.make({
|
|
102
|
+
sequence: envelope.sequence,
|
|
103
|
+
coversThrough: payload.coversThrough,
|
|
104
|
+
windowId: contextWindowId(payload.runId, payload.turn)
|
|
105
|
+
}) });
|
|
106
|
+
}
|
|
107
|
+
const evidence = yield* retainedEvidence(envelope);
|
|
108
|
+
return ContextHistoryProjection.make(evidence === void 0 ? {} : { evidence });
|
|
109
|
+
});
|
|
110
|
+
/** JavaScript case folding for literal substring lookup; do not substitute SQL lower or FTS. */
|
|
111
|
+
const normalizeText = (text) => text.toLowerCase();
|
|
112
|
+
/** Validate, trim, and case-fold a search query using the native history contract. */
|
|
113
|
+
const normalizeQuery = Effect.fn("ThreadContextHistoryProjection.normalizeQuery")(function* (query) {
|
|
114
|
+
const decoded = yield* Schema.decodeEffect(ContextHistorySearch.fields.query)(query).pipe(Effect.mapError(() => ContextHistoryError.make({
|
|
115
|
+
reason: "invalid-input",
|
|
116
|
+
message: "Invalid context history search"
|
|
117
|
+
})));
|
|
118
|
+
const normalized = normalizeText(decoded.trim());
|
|
119
|
+
if (normalized.length === 0) return yield* ContextHistoryError.make({
|
|
120
|
+
reason: "invalid-input",
|
|
121
|
+
message: "Context history search requires non-whitespace text"
|
|
122
|
+
});
|
|
123
|
+
return normalized;
|
|
124
|
+
});
|
|
125
|
+
/** Match a normalized query and retain the native 200-character lead and 2,000-character page. */
|
|
126
|
+
const matchText = (text, normalizedQuery) => {
|
|
127
|
+
const index = normalizeText(text).indexOf(normalizedQuery);
|
|
128
|
+
if (index < 0) return void 0;
|
|
129
|
+
const start = Math.max(0, index - 200);
|
|
130
|
+
return text.slice(start, start + 2e3);
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Boundaries must be in canonical order with nondecreasing coversThrough and belong to the
|
|
134
|
+
* same captured Thread tail as the evidence. An index may supply only its last boundary whose
|
|
135
|
+
* coversThrough is strictly less than evidence.sequence. Later Runs inherit that window;
|
|
136
|
+
* evidence before the first rollover keeps its own Run's initial identity.
|
|
137
|
+
*/
|
|
138
|
+
const windowIdFor = (evidence, boundaries) => {
|
|
139
|
+
let windowId = contextWindowId(evidence.runId, 0);
|
|
140
|
+
for (const boundary of boundaries) {
|
|
141
|
+
if (evidence.sequence <= boundary.coversThrough) break;
|
|
142
|
+
windowId = boundary.windowId;
|
|
143
|
+
}
|
|
144
|
+
return windowId;
|
|
145
|
+
};
|
|
146
|
+
//#endregion
|
|
147
|
+
export { ContextHistoryBoundary, ContextHistoryEvidence, ContextHistoryProjection, matchText, normalizeQuery, normalizeText, project, ThreadContextHistoryProjection_exports as t, windowIdFor };
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=ThreadContextHistoryProjection.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThreadContextHistoryProjection.mjs","names":[],"sources":["../../src/durable/ThreadContextHistoryProjection.ts"],"sourcesContent":["import { Effect, Schema } from \"effect\";\nimport { Prompt } from \"effect/unstable/ai\";\n\nimport { RunId } from \"../core/Identifiers.ts\";\nimport { contextWindowId } from \"../engine/Compaction.ts\";\nimport { ContextHistoryError, ContextHistorySearch } from \"../engine/ContextHistory.ts\";\nimport type { CanonicalRecordEnvelope } from \"./Records.ts\";\nimport { CanonicalSequence, PersistedJson, RecordId } from \"./Records.ts\";\n\n/** Full retained recall text from one canonical record; never raw discarded Tool output. */\nexport class ContextHistoryEvidence extends Schema.Class<ContextHistoryEvidence>(\n \"@effect-agent/thread/ContextHistoryEvidence\",\n)({\n recordId: RecordId,\n sequence: CanonicalSequence,\n runId: RunId,\n text: Schema.NonEmptyString,\n}) {}\n\n/** The committing position and covered position are distinct; membership uses coversThrough. */\nexport class ContextHistoryBoundary extends Schema.Class<ContextHistoryBoundary>(\n \"@effect-agent/thread/ContextHistoryBoundary\",\n)({\n sequence: CanonicalSequence,\n coversThrough: CanonicalSequence,\n windowId: Schema.NonEmptyString,\n}) {}\n\n/** An empty projection still consumes its canonical position in an index watermark. */\nexport class ContextHistoryProjection extends Schema.Class<ContextHistoryProjection>(\n \"@effect-agent/thread/ContextHistoryProjection\",\n)({\n evidence: Schema.optionalKey(ContextHistoryEvidence),\n boundary: Schema.optionalKey(ContextHistoryBoundary),\n}) {}\n\nconst unavailable = () =>\n ContextHistoryError.make({\n reason: \"unavailable\",\n message: \"Canonical context history is unavailable\",\n });\n\nconst jsonText = Effect.fn(\"ThreadContextHistoryProjection.jsonText\")(function* (value: unknown) {\n const json = yield* Schema.decodeUnknownEffect(PersistedJson)(value).pipe(\n Effect.mapError(unavailable),\n );\n\n return JSON.stringify(json);\n});\n\nconst promptText = Effect.fn(\"ThreadContextHistoryProjection.promptText\")(function* (\n value: PersistedJson,\n) {\n const prompt = yield* Schema.decodeUnknownEffect(Prompt.Prompt)(value).pipe(\n Effect.mapError(unavailable),\n );\n\n const messages: Array<string> = [];\n\n for (const message of prompt.content) {\n // Provider options, system instructions, reasoning, and attachment bytes are not recall data.\n if (message.role === \"system\") continue;\n const parts: Array<string> = [];\n\n for (const part of message.content) {\n switch (part.type) {\n case \"text\":\n parts.push(part.text);\n break;\n case \"tool-call\":\n parts.push(`tool call ${part.name} (${part.id}):\\n${yield* jsonText(part.params)}`);\n break;\n case \"tool-result\":\n parts.push(\n `tool result ${part.name} (${part.id}; ${part.isFailure ? \"failure\" : \"success\"}):\\n${yield* jsonText(part.result)}`,\n );\n break;\n case \"file\":\n parts.push(\"[attachment omitted]\");\n break;\n case \"reasoning\":\n case \"tool-approval-request\":\n case \"tool-approval-response\":\n break;\n }\n }\n if (parts.length > 0) messages.push(`${message.role}:\\n${parts.join(\"\\n\")}`);\n }\n\n return messages.join(\"\\n\\n\");\n});\n\nconst retainedEvidence = Effect.fn(\"ThreadContextHistoryProjection.evidence\")(function* (\n envelope: CanonicalRecordEnvelope,\n): Effect.fn.Return<ContextHistoryEvidence | undefined, ContextHistoryError> {\n const payload = envelope.record.payload;\n let text: string;\n\n if (payload._tag === \"ModelResponseRecorded\") {\n text = yield* promptText(payload.messages);\n } else if (payload._tag === \"ModelCompleted\") {\n text =\n payload.messages === undefined\n ? `assistant output:\\n${yield* jsonText(payload.output)}`\n : yield* promptText(payload.messages);\n } else if (payload._tag === \"ToolCallSettled\") {\n text = `tool result ${payload.toolName} (${payload.toolCallId}; ${payload.isFailure ? \"failure\" : \"success\"}):\\n${yield* jsonText(payload.result)}`;\n } else {\n // Raw submission input can contain fields excluded by the Agent's input projection.\n // Step outputs, approvals, failure diagnostics, and operational records stay private.\n return undefined;\n }\n\n return text.length === 0\n ? undefined\n : ContextHistoryEvidence.make({\n recordId: envelope.record.recordId,\n sequence: envelope.sequence,\n runId: payload.runId,\n text,\n });\n});\n\n/**\n * Project one decoded canonical record without reading storage or retaining mutable state.\n * Only model transcript text and settled Tool results are evidence. Instructions, reasoning,\n * attachment bytes, raw submissions, Steps, approvals, and diagnostics remain private. Tool\n * truncation envelopes are rendered as retained; discarded bytes cannot be reconstructed.\n *\n * An index must process contiguous records, including empty projections, and commit its rows\n * and watermark atomically. Validate nondecreasing coversThrough across rollover boundaries.\n * Filter both evidence and committing boundary sequences to the operation's captured tail.\n * Authorization and canonical verification of index candidates remain the host's responsibility.\n * For search pagination, resolve and canonically verify `beforeRecordId` as eligible evidence\n * in the same Thread and captured tail, then select matching evidence with sequence strictly\n * below that anchor, in descending sequence order. The anchor need not match the new query.\n * Do not restrict rollover boundaries to the anchor: later commits may assign older evidence\n * to a window. An ID or an index row alone does not establish existence, eligibility, or access.\n */\nexport const project = Effect.fn(\"ThreadContextHistoryProjection.project\")(function* (\n envelope: CanonicalRecordEnvelope,\n): Effect.fn.Return<ContextHistoryProjection, ContextHistoryError> {\n const payload = envelope.record.payload;\n\n if (payload._tag === \"CompactionCreated\" && payload.kind === \"rollover\") {\n if (payload.coversThrough >= envelope.sequence) return yield* unavailable();\n\n return ContextHistoryProjection.make({\n boundary: ContextHistoryBoundary.make({\n sequence: envelope.sequence,\n coversThrough: payload.coversThrough,\n windowId: contextWindowId(payload.runId, payload.turn),\n }),\n });\n }\n const evidence = yield* retainedEvidence(envelope);\n\n return ContextHistoryProjection.make(evidence === undefined ? {} : { evidence });\n});\n\n/** JavaScript case folding for literal substring lookup; do not substitute SQL lower or FTS. */\nexport const normalizeText = (text: string): string => text.toLowerCase();\n\n/** Validate, trim, and case-fold a search query using the native history contract. */\nexport const normalizeQuery = Effect.fn(\"ThreadContextHistoryProjection.normalizeQuery\")(function* (\n query: string,\n): Effect.fn.Return<string, ContextHistoryError> {\n const decoded = yield* Schema.decodeEffect(ContextHistorySearch.fields.query)(query).pipe(\n Effect.mapError(() =>\n ContextHistoryError.make({\n reason: \"invalid-input\",\n message: \"Invalid context history search\",\n }),\n ),\n );\n\n const normalized = normalizeText(decoded.trim());\n\n if (normalized.length === 0)\n return yield* ContextHistoryError.make({\n reason: \"invalid-input\",\n message: \"Context history search requires non-whitespace text\",\n });\n\n return normalized;\n});\n\n/** Match a normalized query and retain the native 200-character lead and 2,000-character page. */\nexport const matchText = (text: string, normalizedQuery: string): string | undefined => {\n const index = normalizeText(text).indexOf(normalizedQuery);\n\n if (index < 0) return undefined;\n const start = Math.max(0, index - 200);\n\n return text.slice(start, start + 2_000);\n};\n\n/**\n * Boundaries must be in canonical order with nondecreasing coversThrough and belong to the\n * same captured Thread tail as the evidence. An index may supply only its last boundary whose\n * coversThrough is strictly less than evidence.sequence. Later Runs inherit that window;\n * evidence before the first rollover keeps its own Run's initial identity.\n */\nexport const windowIdFor = (\n evidence: ContextHistoryEvidence,\n boundaries: ReadonlyArray<ContextHistoryBoundary>,\n): string => {\n let windowId = contextWindowId(evidence.runId, 0);\n\n for (const boundary of boundaries) {\n if (evidence.sequence <= boundary.coversThrough) break;\n windowId = boundary.windowId;\n }\n\n return windowId;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA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