effect-agent 0.1.0-beta.12 → 0.1.0-beta.121
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-1DMSO_Fl.mjs +86 -0
- package/dist/Agent-1DMSO_Fl.mjs.map +1 -0
- package/dist/Agent-D9cXqfF3.d.mts +252 -0
- package/dist/AgentError-Bn1ytXRD.d.mts +117 -0
- package/dist/AgentPolicy-BqDoSXO6.d.mts +96 -0
- package/dist/AgentRuntime-BUxDdLpw.d.mts +346 -0
- package/dist/AgentRuntime-Cp1hAb-W.mjs +4739 -0
- package/dist/AgentRuntime-Cp1hAb-W.mjs.map +1 -0
- package/dist/AgentUpdates-DMJ-_xow.d.mts +53 -0
- package/dist/ContextCompactor-WwSIG_Z2.d.mts +161 -0
- package/dist/ContextWindow-DRQ5Mbm2.d.mts +58 -0
- package/dist/DurableAgentRuntime-B-9w7jDt.mjs +7061 -0
- package/dist/DurableAgentRuntime-B-9w7jDt.mjs.map +1 -0
- package/dist/DurableFailpoint-Cnr3wx1L.d.mts +41 -0
- package/dist/DurableStep-Cry_iol4.d.mts +103 -0
- package/dist/EventSource-CnlZ3Kma.d.mts +51 -0
- package/dist/FailureDiagnostic-BElLOoED.mjs +274 -0
- package/dist/FailureDiagnostic-BElLOoED.mjs.map +1 -0
- package/dist/FailureDiagnostic-CaAkzGHL.d.mts +223 -0
- package/dist/Identifiers-CN2s30fF.d.mts +40 -0
- package/dist/InMemory.d.mts +24 -0
- package/dist/InMemory.mjs +24 -0
- package/dist/InMemory.mjs.map +1 -0
- package/dist/MemoryNamespace-BbRW5p71.d.mts +36 -0
- package/dist/MemoryReference-B8Q3UJoJ.d.mts +79 -0
- package/dist/Messaging-Dkg87ebg.d.mts +221 -0
- package/dist/Messaging-JYYN3oYS.d.mts +1067 -0
- package/dist/MessagingHost-CqzpxbGz.d.mts +74 -0
- package/dist/MessagingHost-DfsbMPvq.mjs +110 -0
- package/dist/MessagingHost-DfsbMPvq.mjs.map +1 -0
- package/dist/OperationAuthorizer-TzcQtpX5.d.mts +61 -0
- package/dist/Output-V-6YL1_Z.d.mts +25 -0
- package/dist/PageCapture-Df8Xwskw.d.mts +583 -0
- package/dist/PageScreenshot-BpgZKAxl.d.mts +48 -0
- package/dist/PreparedInputAdmission-BQLGldl-.d.mts +42 -0
- package/dist/Receipt-BAHyigAF.d.mts +33 -0
- package/dist/Records-D88mgvyS.d.mts +4214 -0
- package/dist/RunEvent-DIrzkjLr.d.mts +460 -0
- package/dist/RunEventSink-D5aVhISG.d.mts +108 -0
- package/dist/RunJournal-BXrq0VIK.mjs +931 -0
- package/dist/RunJournal-BXrq0VIK.mjs.map +1 -0
- package/dist/RunOptions-CSBsSj0X.d.mts +935 -0
- package/dist/RunPolicyUsage-ClZxyR46.d.mts +21 -0
- package/dist/Sandbox-CEsDWBLq.d.mts +173 -0
- package/dist/Schedule-BIOHA6RR.d.mts +847 -0
- package/dist/Scheduling-DPb2QyAK.mjs +691 -0
- package/dist/Scheduling-DPb2QyAK.mjs.map +1 -0
- package/dist/Subagent-CNik9RiA.d.mts +1635 -0
- package/dist/Subagent-DCrB7an7.mjs +1498 -0
- package/dist/Subagent-DCrB7an7.mjs.map +1 -0
- package/dist/SubagentContract-DdT7Cqe6.d.mts +116 -0
- package/dist/SubagentHost-4WB8Hj0C.d.mts +164 -0
- package/dist/Subscription-CRteOKRf.d.mts +948 -0
- package/dist/SubscriptionInput-oNcwTPti.d.mts +41 -0
- package/dist/Thread-DOBQ0QUY.d.mts +96 -0
- package/dist/ThreadHistory-tS1KwxHR.d.mts +60 -0
- package/dist/ToolBroker-DWs4tZra.d.mts +133 -0
- package/dist/ToolExposure-9uF_Yo0T.mjs +10 -0
- package/dist/ToolExposure-9uF_Yo0T.mjs.map +1 -0
- package/dist/ToolExposure-C93U1sPu.mjs +30 -0
- package/dist/ToolExposure-C93U1sPu.mjs.map +1 -0
- package/dist/ToolExposure-UCN12eCd.d.mts +39 -0
- package/dist/ToolExposure-r2eOWk4F.d.mts +46 -0
- package/dist/ToolExposure.d.mts +8 -0
- package/dist/ToolExposure.mjs +21 -0
- package/dist/ToolExposure.mjs.map +1 -0
- package/dist/ToolReconciler-BmVRAHKs.d.mts +80 -0
- package/dist/ToolResult-BKdqWRff.d.mts +78 -0
- package/dist/Usage-Dx0aknfk.d.mts +121 -0
- package/dist/WakeScheduler-EjUF-GhC.d.mts +56 -0
- package/dist/Worker-CfwzMZEK.mjs +271 -0
- package/dist/Worker-CfwzMZEK.mjs.map +1 -0
- package/dist/Worker-fwWkBg12.d.mts +472 -0
- package/dist/agent-registration-CKNsrpwo.mjs +201 -0
- package/dist/agent-registration-CKNsrpwo.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 +259 -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 +152 -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 +124 -0
- package/dist/capabilities/ToolDiscovery.mjs +230 -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 +115 -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 +134 -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/FailureDiagnostic.d.mts +2 -0
- package/dist/core/FailureDiagnostic.mjs +2 -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 +156 -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 +3 -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 +330 -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 +110 -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 +102 -0
- package/dist/durable/DurableFailpoint.mjs.map +1 -0
- package/dist/durable/DurableFailpointTestControl.d.mts +14 -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 +185 -0
- package/dist/durable/GitHubWorkflowSource.mjs +209 -0
- package/dist/durable/GitHubWorkflowSource.mjs.map +1 -0
- package/dist/durable/MessageDelivery.d.mts +893 -0
- package/dist/durable/MessageDelivery.mjs +557 -0
- package/dist/durable/MessageDelivery.mjs.map +1 -0
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +378 -0
- package/dist/durable/MessageDeliveryStoreConformance.mjs +270 -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 +38 -0
- package/dist/durable/PreparedInputAdmission.mjs.map +1 -0
- package/dist/durable/Records.d.mts +2 -0
- package/dist/durable/Records.mjs +848 -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 +391 -0
- package/dist/durable/Schedule.mjs.map +1 -0
- package/dist/durable/ScheduleStoreConformance.d.mts +17 -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 +29 -0
- package/dist/durable/SqlMemoryStore.mjs +436 -0
- package/dist/durable/SqlMemoryStore.mjs.map +1 -0
- package/dist/durable/SqlMessageDeliveryStore.d.mts +42 -0
- package/dist/durable/SqlMessageDeliveryStore.mjs +179 -0
- package/dist/durable/SqlMessageDeliveryStore.mjs.map +1 -0
- package/dist/durable/SqlStorageV2Upgrade.d.mts +21 -0
- package/dist/durable/SqlStorageV2Upgrade.mjs +459 -0
- package/dist/durable/SqlStorageV2Upgrade.mjs.map +1 -0
- package/dist/durable/SqlSubscriptionStore.d.mts +62 -0
- package/dist/durable/SqlSubscriptionStore.mjs +751 -0
- package/dist/durable/SqlSubscriptionStore.mjs.map +1 -0
- package/dist/durable/SqlThreadNativeReads.d.mts +53 -0
- package/dist/durable/SqlThreadNativeReads.mjs +159 -0
- package/dist/durable/SqlThreadNativeReads.mjs.map +1 -0
- package/dist/durable/SubmissionLedger.d.mts +3 -0
- package/dist/durable/SubmissionLedger.mjs +959 -0
- package/dist/durable/SubmissionLedger.mjs.map +1 -0
- package/dist/durable/SubmissionLedgerConformance.d.mts +29 -0
- package/dist/durable/SubmissionLedgerConformance.mjs +2187 -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 +16 -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 +76 -0
- package/dist/durable/ThreadInvariants.mjs +246 -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 +355 -0
- package/dist/durable/ThreadStore.mjs.map +1 -0
- package/dist/durable/ThreadStoreConformance.d.mts +28 -0
- package/dist/durable/ThreadStoreConformance.mjs +503 -0
- package/dist/durable/ThreadStoreConformance.mjs.map +1 -0
- package/dist/durable/ToolReconciler.d.mts +2 -0
- package/dist/durable/ToolReconciler.mjs +85 -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 +124 -0
- package/dist/engine/RunOptions.mjs.map +1 -0
- package/dist/engine/SubagentHost.d.mts +2 -0
- package/dist/engine/SubagentHost.mjs +76 -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 +91 -6
- package/dist/index.mjs +100 -6
- package/dist/output-contract-BC7tjlGw.mjs +84 -0
- package/dist/output-contract-BC7tjlGw.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/sandbox/CodeExecutor.d.mts +194 -0
- package/dist/sandbox/CodeExecutor.mjs +278 -0
- package/dist/sandbox/CodeExecutor.mjs.map +1 -0
- package/dist/sandbox/InteractiveBrowser.d.mts +257 -0
- package/dist/sandbox/InteractiveBrowser.mjs +236 -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 +283 -0
- package/dist/sandbox/ProtectedBrowser.mjs +298 -0
- package/dist/sandbox/ProtectedBrowser.mjs.map +1 -0
- package/dist/sandbox/Sandbox.d.mts +2 -0
- package/dist/sandbox/Sandbox.mjs +208 -0
- package/dist/sandbox/Sandbox.mjs.map +1 -0
- package/dist/utf8-BYfhEkcj.mjs +11 -0
- package/dist/utf8-BYfhEkcj.mjs.map +1 -0
- package/dist/utf8-DchGZRBd.mjs +23 -0
- package/dist/utf8-DchGZRBd.mjs.map +1 -0
- package/package.json +1 -40
- package/src/InMemory.ts +19 -0
- package/src/ToolExposure.ts +2 -0
- package/src/capabilities/Approval.ts +352 -0
- package/src/capabilities/Budget.ts +536 -0
- package/src/capabilities/CodeMode.ts +1090 -0
- package/src/capabilities/Commands.ts +86 -0
- package/src/capabilities/ContextTools.ts +184 -0
- package/src/capabilities/Mcp.ts +426 -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 +2489 -0
- package/src/capabilities/SubagentReservations.ts +850 -0
- package/src/capabilities/ToolDiscovery.ts +369 -0
- package/src/capabilities/WebCapture.ts +722 -0
- package/src/capabilities/WebSearch.ts +190 -0
- package/src/capabilities/internal/subagent-background.ts +1273 -0
- package/src/capabilities/internal/subagent-contract.ts +146 -0
- package/src/capabilities/internal/subagent-policy.ts +235 -0
- package/src/capabilities/internal/subagent-reporting.ts +136 -0
- package/src/capabilities/internal/utf8.ts +10 -0
- package/src/core/Agent.ts +602 -0
- package/src/core/AgentError.ts +172 -0
- package/src/core/AgentPolicy.ts +153 -0
- package/src/core/AgentUpdates.ts +100 -0
- package/src/core/FailureDiagnostic.ts +343 -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 +72 -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 +190 -0
- package/src/core/Usage.ts +529 -0
- package/src/core/Worker.ts +240 -0
- package/src/core/internal/agent-updates.ts +34 -0
- package/src/core/internal/message-status.ts +60 -0
- package/src/core/internal/strict-schema.ts +14 -0
- package/src/core/internal/utf8.ts +23 -0
- package/src/durable/ActivityStore.ts +160 -0
- package/src/durable/Admin.ts +505 -0
- package/src/durable/AgentRegistration.ts +14 -0
- package/src/durable/Certification.ts +210 -0
- package/src/durable/CommittedActivity.ts +296 -0
- package/src/durable/Digest.ts +87 -0
- package/src/durable/DurableAgentRuntime.ts +11275 -0
- package/src/durable/DurableFailpoint.ts +111 -0
- package/src/durable/DurableFailpointTestControl.ts +39 -0
- package/src/durable/EventSource.ts +172 -0
- package/src/durable/GitHubWorkflowSource.ts +447 -0
- package/src/durable/MessageDelivery.ts +832 -0
- package/src/durable/MessageDeliveryStoreConformance.ts +410 -0
- package/src/durable/OperationAuthorizer.ts +85 -0
- package/src/durable/PersistentHistory.ts +260 -0
- package/src/durable/PreparedInputAdmission.ts +57 -0
- package/src/durable/Records.ts +1075 -0
- package/src/durable/Recovery.ts +1018 -0
- package/src/durable/RunJournal.ts +1631 -0
- package/src/durable/Schedule.ts +513 -0
- package/src/durable/ScheduleStoreConformance.ts +638 -0
- package/src/durable/ScheduleTransition.ts +265 -0
- package/src/durable/Scheduling.ts +1077 -0
- package/src/durable/SqlMemoryStore.ts +778 -0
- package/src/durable/SqlMessageDeliveryStore.ts +335 -0
- package/src/durable/SqlStorageV2Upgrade.ts +500 -0
- package/src/durable/SqlSubscriptionStore.ts +1440 -0
- package/src/durable/SqlThreadNativeReads.ts +270 -0
- package/src/durable/SubmissionLedger.ts +1265 -0
- package/src/durable/SubmissionLedgerConformance.ts +4820 -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 +507 -0
- package/src/durable/ThreadProjection.ts +269 -0
- package/src/durable/ThreadProjectionMaintenance.ts +67 -0
- package/src/durable/ThreadStore.ts +573 -0
- package/src/durable/ThreadStoreConformance.ts +1156 -0
- package/src/durable/ToolReconciler.ts +109 -0
- package/src/durable/WakeScheduler.ts +134 -0
- package/src/durable/WorkerHost.ts +171 -0
- package/src/durable/internal/agent-registration.ts +587 -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 +117 -0
- package/src/durable/internal/message-status.ts +20 -0
- package/src/durable/internal/messaging-host.ts +637 -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 +2885 -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 +1101 -0
- package/src/engine/SubagentHost.ts +230 -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 +10500 -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 +99 -21
- package/src/sandbox/CodeExecutor.ts +352 -0
- package/src/sandbox/InteractiveBrowser.ts +339 -0
- package/src/sandbox/PageCapture.ts +691 -0
- package/src/sandbox/PageCrawl.ts +148 -0
- package/src/sandbox/PageScreenshot.ts +81 -0
- package/src/sandbox/ProtectedBrowser.ts +452 -0
- package/src/sandbox/Sandbox.ts +241 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as ReconciliationSafeToRetry, c as ToolReconcilerError, i as ReconciliationNeverStarted, n as ReconciliationCompleted, o as ReconciliationUncertain, r as ReconciliationDecision, s as ToolReconciler, t as PreparedToolCallEvidence } from "../ToolReconciler-BmVRAHKs.mjs";
|
|
2
|
+
export { PreparedToolCallEvidence, ReconciliationCompleted, ReconciliationDecision, ReconciliationNeverStarted, ReconciliationSafeToRetry, ReconciliationUncertain, ToolReconciler, ToolReconcilerError };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { RunId, SubmissionId, ThreadId, ToolCallId } from "../core/Identifiers.mjs";
|
|
3
|
+
import { Digest, PersistedJson, ToolCallPrepared } from "./Records.mjs";
|
|
4
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
5
|
+
//#region src/durable/ToolReconciler.ts
|
|
6
|
+
var ToolReconciler_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
PreparedToolCallEvidence: () => PreparedToolCallEvidence,
|
|
8
|
+
ReconciliationCompleted: () => ReconciliationCompleted,
|
|
9
|
+
ReconciliationDecision: () => ReconciliationDecision,
|
|
10
|
+
ReconciliationNeverStarted: () => ReconciliationNeverStarted,
|
|
11
|
+
ReconciliationSafeToRetry: () => ReconciliationSafeToRetry,
|
|
12
|
+
ReconciliationUncertain: () => ReconciliationUncertain,
|
|
13
|
+
ToolReconciler: () => ToolReconciler,
|
|
14
|
+
ToolReconcilerError: () => ToolReconcilerError
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Everything a reconciliation policy can consult about one prepared-but-unsettled ordinary Tool
|
|
18
|
+
* Call (durability §10): deterministic identities for supplier-side lookup plus the exact
|
|
19
|
+
* Schema-encoded parameters and their digest. Built from the canonical `ToolCallPrepared` record
|
|
20
|
+
* and the owning Submission's identities — never from in-memory Attempt state.
|
|
21
|
+
*/
|
|
22
|
+
var PreparedToolCallEvidence = class extends Schema.Class("@effect-agent/thread/PreparedToolCallEvidence")({
|
|
23
|
+
threadId: ThreadId,
|
|
24
|
+
submissionId: SubmissionId,
|
|
25
|
+
runId: RunId,
|
|
26
|
+
turn: ToolCallPrepared.fields.turn,
|
|
27
|
+
toolCallId: ToolCallId,
|
|
28
|
+
toolName: ToolCallPrepared.fields.toolName,
|
|
29
|
+
parameters: PersistedJson,
|
|
30
|
+
parametersDigest: Digest,
|
|
31
|
+
executionKind: ToolCallPrepared.fields.executionKind,
|
|
32
|
+
executionClass: ToolCallPrepared.fields.executionClass,
|
|
33
|
+
replay: ToolCallPrepared.fields.replay
|
|
34
|
+
}) {};
|
|
35
|
+
/** Proof of nonexecution: resume the original operation or report it unavailable. */
|
|
36
|
+
var ReconciliationNeverStarted = class extends Schema.TaggedClass("@effect-agent/thread/ReconciliationNeverStarted")("NeverStarted", {}) {};
|
|
37
|
+
/**
|
|
38
|
+
* Proof that the external execution completed: `result` is the recovered supplier truth, which
|
|
39
|
+
* becomes canonical (`ToolCallSettled` + `ToolCallResolved`) WITHOUT executing anything.
|
|
40
|
+
*/
|
|
41
|
+
var ReconciliationCompleted = class extends Schema.TaggedClass("@effect-agent/thread/ReconciliationCompleted")("CompletedWithResult", {
|
|
42
|
+
result: PersistedJson,
|
|
43
|
+
isFailure: Schema.Boolean
|
|
44
|
+
}) {};
|
|
45
|
+
/** Only the original operation, identity and parameters may repeat under supported semantics. */
|
|
46
|
+
var ReconciliationSafeToRetry = class extends Schema.TaggedClass("@effect-agent/thread/ReconciliationSafeToRetry")("SafeToRetry", {}) {};
|
|
47
|
+
/** No proof either way: the outcome is Unknown and requires authorized resolution (DUR-017). */
|
|
48
|
+
var ReconciliationUncertain = class extends Schema.TaggedClass("@effect-agent/thread/ReconciliationUncertain")("Uncertain", { reason: Schema.String }) {};
|
|
49
|
+
/**
|
|
50
|
+
* What a reconciliation policy can prove about one prepared-but-unsettled ordinary Tool Call
|
|
51
|
+
* (durability §10): execution never started, execution completed with a recoverable result,
|
|
52
|
+
* execution is safe to repeat, or nothing — in which case the Run enters Unknown. The engine
|
|
53
|
+
* never invents an external result. Proven nonexecution can close a retired operation with
|
|
54
|
+
* an explicit not-executed result; uncertainty stays parked.
|
|
55
|
+
*/
|
|
56
|
+
const ReconciliationDecision = Schema.Union([
|
|
57
|
+
ReconciliationNeverStarted,
|
|
58
|
+
ReconciliationCompleted,
|
|
59
|
+
ReconciliationSafeToRetry,
|
|
60
|
+
ReconciliationUncertain
|
|
61
|
+
]);
|
|
62
|
+
/** The reconciliation policy itself failed (supplier unreachable, corrupt lookup, ...). The
|
|
63
|
+
* caller treats this as no proof: the call stays open and the pass may retry. */
|
|
64
|
+
var ToolReconcilerError = class extends Schema.TaggedError()("ToolReconcilerError", {
|
|
65
|
+
toolCallId: ToolCallId,
|
|
66
|
+
message: Schema.String,
|
|
67
|
+
cause: Schema.optionalKey(Schema.Defect())
|
|
68
|
+
}) {};
|
|
69
|
+
/**
|
|
70
|
+
* Application-registered reconciliation policy consulted by recovery for every open ordinary
|
|
71
|
+
* Tool Call before an Unknown Outcome is recorded (durability §10, DUR-009). A decision is a
|
|
72
|
+
* claim about EXTERNAL truth — typically an idempotency-keyed supplier lookup — never a guess
|
|
73
|
+
* from canonical state alone.
|
|
74
|
+
*
|
|
75
|
+
* `ToolReconciler.uncertain` is the fail-closed default (AGENTS rule 11): with no registered
|
|
76
|
+
* policy, every open call stays Unknown and routes to the authorized DUR-017 resolution path.
|
|
77
|
+
*/
|
|
78
|
+
var ToolReconciler = class extends Context.Service()("@effect-agent/thread/ToolReconciler") {
|
|
79
|
+
/** Fail-closed default: no proof is ever asserted, every open call stays Unknown. */
|
|
80
|
+
static uncertain = Layer.succeed(this)({ reconcile: () => Effect.succeed(ReconciliationUncertain.make({ reason: "No reconciliation policy is registered; the outcome stays unknown" })) });
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { PreparedToolCallEvidence, ReconciliationCompleted, ReconciliationDecision, ReconciliationNeverStarted, ReconciliationSafeToRetry, ReconciliationUncertain, ToolReconciler, ToolReconcilerError, ToolReconciler_exports as t };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=ToolReconciler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolReconciler.mjs","names":[],"sources":["../../src/durable/ToolReconciler.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport { ThreadId, RunId, SubmissionId, ToolCallId } from \"../core/Identifiers.ts\";\nimport { Digest, PersistedJson, ToolCallPrepared } from \"./Records.ts\";\n\n/**\n * Everything a reconciliation policy can consult about one prepared-but-unsettled ordinary Tool\n * Call (durability §10): deterministic identities for supplier-side lookup plus the exact\n * Schema-encoded parameters and their digest. Built from the canonical `ToolCallPrepared` record\n * and the owning Submission's identities — never from in-memory Attempt state.\n */\nexport class PreparedToolCallEvidence extends Schema.Class<PreparedToolCallEvidence>(\n \"@effect-agent/thread/PreparedToolCallEvidence\",\n)({\n threadId: ThreadId,\n submissionId: SubmissionId,\n runId: RunId,\n turn: ToolCallPrepared.fields.turn,\n toolCallId: ToolCallId,\n toolName: ToolCallPrepared.fields.toolName,\n parameters: PersistedJson,\n parametersDigest: Digest,\n executionKind: ToolCallPrepared.fields.executionKind,\n executionClass: ToolCallPrepared.fields.executionClass,\n replay: ToolCallPrepared.fields.replay,\n}) {}\n\n/** Proof of nonexecution: resume the original operation or report it unavailable. */\nexport class ReconciliationNeverStarted extends Schema.TaggedClass<ReconciliationNeverStarted>(\n \"@effect-agent/thread/ReconciliationNeverStarted\",\n)(\"NeverStarted\", {}) {}\n\n/**\n * Proof that the external execution completed: `result` is the recovered supplier truth, which\n * becomes canonical (`ToolCallSettled` + `ToolCallResolved`) WITHOUT executing anything.\n */\nexport class ReconciliationCompleted extends Schema.TaggedClass<ReconciliationCompleted>(\n \"@effect-agent/thread/ReconciliationCompleted\",\n)(\"CompletedWithResult\", {\n result: PersistedJson,\n isFailure: Schema.Boolean,\n}) {}\n\n/** Only the original operation, identity and parameters may repeat under supported semantics. */\nexport class ReconciliationSafeToRetry extends Schema.TaggedClass<ReconciliationSafeToRetry>(\n \"@effect-agent/thread/ReconciliationSafeToRetry\",\n)(\"SafeToRetry\", {}) {}\n\n/** No proof either way: the outcome is Unknown and requires authorized resolution (DUR-017). */\nexport class ReconciliationUncertain extends Schema.TaggedClass<ReconciliationUncertain>(\n \"@effect-agent/thread/ReconciliationUncertain\",\n)(\"Uncertain\", {\n reason: Schema.String,\n}) {}\n\n/**\n * What a reconciliation policy can prove about one prepared-but-unsettled ordinary Tool Call\n * (durability §10): execution never started, execution completed with a recoverable result,\n * execution is safe to repeat, or nothing — in which case the Run enters Unknown. The engine\n * never invents an external result. Proven nonexecution can close a retired operation with\n * an explicit not-executed result; uncertainty stays parked.\n */\nexport const ReconciliationDecision = Schema.Union([\n ReconciliationNeverStarted,\n ReconciliationCompleted,\n ReconciliationSafeToRetry,\n ReconciliationUncertain,\n]);\n\nexport type ReconciliationDecision = typeof ReconciliationDecision.Type;\n\n/** The reconciliation policy itself failed (supplier unreachable, corrupt lookup, ...). The\n * caller treats this as no proof: the call stays open and the pass may retry. */\nexport class ToolReconcilerError extends Schema.TaggedError<ToolReconcilerError>()(\n \"ToolReconcilerError\",\n {\n toolCallId: ToolCallId,\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * Application-registered reconciliation policy consulted by recovery for every open ordinary\n * Tool Call before an Unknown Outcome is recorded (durability §10, DUR-009). A decision is a\n * claim about EXTERNAL truth — typically an idempotency-keyed supplier lookup — never a guess\n * from canonical state alone.\n *\n * `ToolReconciler.uncertain` is the fail-closed default (AGENTS rule 11): with no registered\n * policy, every open call stays Unknown and routes to the authorized DUR-017 resolution path.\n */\nexport class ToolReconciler extends Context.Service<\n ToolReconciler,\n {\n readonly reconcile: (\n evidence: PreparedToolCallEvidence,\n ) => Effect.Effect<ReconciliationDecision, ToolReconcilerError>;\n }\n>()(\"@effect-agent/thread/ToolReconciler\") {\n /** Fail-closed default: no proof is ever asserted, every open call stays Unknown. */\n static readonly uncertain: Layer.Layer<ToolReconciler> = Layer.succeed(this)({\n reconcile: () =>\n Effect.succeed(\n ReconciliationUncertain.make({\n reason: \"No reconciliation policy is registered; the outcome stays unknown\",\n }),\n ),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAWA,IAAa,2BAAb,cAA8C,OAAO,MACnD,+CACF,CAAC,CAAC;CACA,UAAU;CACV,cAAc;CACd,OAAO;CACP,MAAM,iBAAiB,OAAO;CAC9B,YAAY;CACZ,UAAU,iBAAiB,OAAO;CAClC,YAAY;CACZ,kBAAkB;CAClB,eAAe,iBAAiB,OAAO;CACvC,gBAAgB,iBAAiB,OAAO;CACxC,QAAQ,iBAAiB,OAAO;AAClC,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,6BAAb,cAAgD,OAAO,YACrD,iDACF,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;AAMvB,IAAa,0BAAb,cAA6C,OAAO,YAClD,8CACF,CAAC,CAAC,uBAAuB;CACvB,QAAQ;CACR,WAAW,OAAO;AACpB,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,4BAAb,cAA+C,OAAO,YACpD,gDACF,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;;AAGtB,IAAa,0BAAb,cAA6C,OAAO,YAClD,8CACF,CAAC,CAAC,aAAa,EACb,QAAQ,OAAO,OACjB,CAAC,CAAC,CAAC,CAAC;;;;;;;;AASJ,MAAa,yBAAyB,OAAO,MAAM;CACjD;CACA;CACA;CACA;AACF,CAAC;;;AAMD,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,YAAY;CACZ,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC;;;;;;;;;;AAWH,IAAa,iBAAb,cAAoC,QAAQ,QAO1C,CAAC,CAAC,qCAAqC,CAAC,CAAC;;CAEzC,OAAgB,YAAyC,MAAM,QAAQ,IAAI,CAAC,CAAC,EAC3E,iBACE,OAAO,QACL,wBAAwB,KAAK,EAC3B,QAAQ,oEACV,CAAC,CACH,EACJ,CAAC;AACH"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Context, Deferred, Effect, Layer, Ref, Stream } from "effect";
|
|
3
|
+
//#region src/durable/WakeScheduler.ts
|
|
4
|
+
var WakeScheduler_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
WakeScheduler: () => WakeScheduler,
|
|
6
|
+
makeWakeSubscriptionHub: () => makeWakeSubscriptionHub
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Build the shared per-incarnation registration primitive used by host WakeSchedulers. The hub
|
|
10
|
+
* contains hints only: eviction may discard it, while a reconnecting caller re-subscribes and
|
|
11
|
+
* rechecks canonical storage. Scope finalizers remove cancelled waiters, and notify broadcasts
|
|
12
|
+
* instead of consuming a signal that belongs to another waiter.
|
|
13
|
+
*/
|
|
14
|
+
const makeWakeSubscriptionHub = Effect.gen(function* () {
|
|
15
|
+
const registrations = yield* Ref.make(/* @__PURE__ */ new Map());
|
|
16
|
+
const nextId = yield* Ref.make(0);
|
|
17
|
+
const remove = (threadId, id) => Ref.update(registrations, (current) => {
|
|
18
|
+
const existing = current.get(threadId);
|
|
19
|
+
if (existing === void 0 || !existing.has(id)) return current;
|
|
20
|
+
const next = new Map(current);
|
|
21
|
+
const thread = new Map(existing);
|
|
22
|
+
thread.delete(id);
|
|
23
|
+
if (thread.size === 0) next.delete(threadId);
|
|
24
|
+
else next.set(threadId, thread);
|
|
25
|
+
return next;
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
subscribe: Effect.fn("WakeSubscriptionHub.subscribe")((threadId) => Effect.gen(function* () {
|
|
29
|
+
const deferred = yield* Deferred.make();
|
|
30
|
+
const registration = {
|
|
31
|
+
id: yield* Ref.getAndUpdate(nextId, (current) => current + 1),
|
|
32
|
+
deferred
|
|
33
|
+
};
|
|
34
|
+
yield* Effect.addFinalizer(() => remove(threadId, registration.id));
|
|
35
|
+
yield* Ref.update(registrations, (current) => {
|
|
36
|
+
const next = new Map(current);
|
|
37
|
+
const thread = new Map(current.get(threadId) ?? []);
|
|
38
|
+
thread.set(registration.id, registration.deferred);
|
|
39
|
+
next.set(threadId, thread);
|
|
40
|
+
return next;
|
|
41
|
+
});
|
|
42
|
+
return registration.deferred;
|
|
43
|
+
}).pipe(Effect.map((deferred) => Deferred.await(deferred)))),
|
|
44
|
+
notify: Effect.fn("WakeSubscriptionHub.notify")(function* (threadId) {
|
|
45
|
+
const waiters = yield* Ref.modify(registrations, (current) => {
|
|
46
|
+
const thread = current.get(threadId);
|
|
47
|
+
if (thread === void 0) return [[], current];
|
|
48
|
+
const next = new Map(current);
|
|
49
|
+
next.delete(threadId);
|
|
50
|
+
return [[...thread.values()], next];
|
|
51
|
+
});
|
|
52
|
+
yield* Effect.forEach(waiters, (waiter) => Deferred.succeed(waiter, void 0), { discard: true });
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Liveness hint channel for durable schedulers. `notify` announces that a Thread lane may
|
|
58
|
+
* have claimable, canonical, or settled work; `wakes` is the all-lanes subscription surface for
|
|
59
|
+
* workers, while `subscribe` installs an efficient one-Thread wait registration.
|
|
60
|
+
*
|
|
61
|
+
* Correctness must NEVER depend on delivery: notifications may be dropped, coalesced, duplicated,
|
|
62
|
+
* or observed by no subscriber (a notify before any subscription is simply lost). Every consumer
|
|
63
|
+
* must pair a wake with durable authority: workers use periodic SubmissionLedger scans, while a
|
|
64
|
+
* public progress waiter subscribes before its canonical read and reconnects/rechecks after an
|
|
65
|
+
* incarnation loss (persistence §14).
|
|
66
|
+
*
|
|
67
|
+
* Each run of `wakes` creates its own subscription whose resources live in that run's Scope and
|
|
68
|
+
* are released when the consuming stream ends or is interrupted. Implementations must not spawn
|
|
69
|
+
* daemon fibers.
|
|
70
|
+
*/
|
|
71
|
+
var WakeScheduler = class WakeScheduler extends Context.Service()("@effect-agent/thread/WakeScheduler") {
|
|
72
|
+
/**
|
|
73
|
+
* Discards every notification and never wakes anyone. Valid because WakeScheduler is only a
|
|
74
|
+
* liveness hint: consumers relying on ledger scans stay correct, merely slower.
|
|
75
|
+
*/
|
|
76
|
+
static layerNoop = Layer.succeed(WakeScheduler, {
|
|
77
|
+
notify: () => Effect.void,
|
|
78
|
+
subscribe: () => Effect.succeed(Effect.never),
|
|
79
|
+
wakes: Stream.never
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { WakeScheduler, makeWakeSubscriptionHub, WakeScheduler_exports as t };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=WakeScheduler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WakeScheduler.mjs","names":[],"sources":["../../src/durable/WakeScheduler.ts"],"sourcesContent":["import type { Scope } from \"effect\";\nimport { Context, Deferred, Effect, Layer, Ref, Stream } from \"effect\";\n\nimport { type ThreadId } from \"../core/Identifiers.ts\";\n\n/**\n * Incarnation-local, thread-keyed wake registrations. A registration is installed before\n * its returned Effect can be awaited, which lets a caller subscribe, check durable authority,\n * and then park without a lost-wakeup window.\n */\nexport interface WakeSubscriptionHub {\n /** Register one Scope-owned waiter and return its one-shot wake Effect. */\n readonly subscribe: (\n threadId: ThreadId,\n ) => Effect.Effect<Effect.Effect<void>, never, Scope.Scope>;\n /** Wake every currently registered waiter for exactly this Thread. */\n readonly notify: (threadId: ThreadId) => Effect.Effect<void>;\n}\n\ninterface WakeRegistration {\n readonly id: number;\n readonly deferred: Deferred.Deferred<void>;\n}\n\ntype WakeRegistrations = ReadonlyMap<ThreadId, ReadonlyMap<number, Deferred.Deferred<void>>>;\n\n/**\n * Build the shared per-incarnation registration primitive used by host WakeSchedulers. The hub\n * contains hints only: eviction may discard it, while a reconnecting caller re-subscribes and\n * rechecks canonical storage. Scope finalizers remove cancelled waiters, and notify broadcasts\n * instead of consuming a signal that belongs to another waiter.\n */\nexport const makeWakeSubscriptionHub: Effect.Effect<WakeSubscriptionHub> = Effect.gen(function* () {\n const registrations = yield* Ref.make<WakeRegistrations>(new Map());\n const nextId = yield* Ref.make(0);\n\n const remove = (threadId: ThreadId, id: number) =>\n Ref.update(registrations, (current) => {\n const existing = current.get(threadId);\n\n if (existing === undefined || !existing.has(id)) return current;\n const next = new Map(current);\n const thread = new Map(existing);\n\n thread.delete(id);\n if (thread.size === 0) {\n next.delete(threadId);\n } else {\n next.set(threadId, thread);\n }\n\n return next;\n });\n\n const subscribe = Effect.fn(\"WakeSubscriptionHub.subscribe\")(\n (threadId: ThreadId): Effect.Effect<Effect.Effect<void>, never, Scope.Scope> =>\n Effect.gen(function* () {\n const deferred = yield* Deferred.make<void>();\n const id = yield* Ref.getAndUpdate(nextId, (current) => current + 1);\n const registration: WakeRegistration = { id, deferred };\n\n yield* Effect.addFinalizer(() => remove(threadId, registration.id));\n yield* Ref.update(registrations, (current) => {\n const next = new Map(current);\n const thread = new Map(current.get(threadId) ?? []);\n\n thread.set(registration.id, registration.deferred);\n next.set(threadId, thread);\n\n return next;\n });\n\n return registration.deferred;\n }).pipe(Effect.map((deferred) => Deferred.await(deferred))),\n );\n\n const notify = Effect.fn(\"WakeSubscriptionHub.notify\")(function* (threadId: ThreadId) {\n const waiters = yield* Ref.modify(registrations, (current) => {\n const thread = current.get(threadId);\n\n if (thread === undefined) return [[], current] as const;\n const next = new Map(current);\n\n next.delete(threadId);\n\n return [[...thread.values()], next] as const;\n });\n\n yield* Effect.forEach(waiters, (waiter) => Deferred.succeed(waiter, undefined), {\n discard: true,\n });\n });\n\n return { subscribe, notify };\n});\n\n/**\n * Liveness hint channel for durable schedulers. `notify` announces that a Thread lane may\n * have claimable, canonical, or settled work; `wakes` is the all-lanes subscription surface for\n * workers, while `subscribe` installs an efficient one-Thread wait registration.\n *\n * Correctness must NEVER depend on delivery: notifications may be dropped, coalesced, duplicated,\n * or observed by no subscriber (a notify before any subscription is simply lost). Every consumer\n * must pair a wake with durable authority: workers use periodic SubmissionLedger scans, while a\n * public progress waiter subscribes before its canonical read and reconnects/rechecks after an\n * incarnation loss (persistence §14).\n *\n * Each run of `wakes` creates its own subscription whose resources live in that run's Scope and\n * are released when the consuming stream ends or is interrupted. Implementations must not spawn\n * daemon fibers.\n */\nexport class WakeScheduler extends Context.Service<\n WakeScheduler,\n {\n /** Best-effort hint that `threadId` may have claimable or settled work. Never fails. */\n readonly notify: (threadId: ThreadId) => Effect.Effect<void>;\n /** Scope-owned one-shot registration for exactly one Thread. */\n readonly subscribe: (\n threadId: ThreadId,\n ) => Effect.Effect<Effect.Effect<void>, never, Scope.Scope>;\n /** Scope-owned subscription to wake hints, starting at subscription time. */\n readonly wakes: Stream.Stream<ThreadId>;\n }\n>()(\"@effect-agent/thread/WakeScheduler\") {\n /**\n * Discards every notification and never wakes anyone. Valid because WakeScheduler is only a\n * liveness hint: consumers relying on ledger scans stay correct, merely slower.\n */\n static readonly layerNoop: Layer.Layer<WakeScheduler> = Layer.succeed(WakeScheduler, {\n notify: () => Effect.void,\n subscribe: () => Effect.succeed(Effect.never),\n wakes: Stream.never,\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,MAAa,0BAA8D,OAAO,IAAI,aAAa;CACjG,MAAM,gBAAgB,OAAO,IAAI,qBAAwB,IAAI,IAAI,CAAC;CAClE,MAAM,SAAS,OAAO,IAAI,KAAK,CAAC;CAEhC,MAAM,UAAU,UAAoB,OAClC,IAAI,OAAO,gBAAgB,YAAY;EACrC,MAAM,WAAW,QAAQ,IAAI,QAAQ;EAErC,IAAI,aAAa,KAAA,KAAa,CAAC,SAAS,IAAI,EAAE,GAAG,OAAO;EACxD,MAAM,OAAO,IAAI,IAAI,OAAO;EAC5B,MAAM,SAAS,IAAI,IAAI,QAAQ;EAE/B,OAAO,OAAO,EAAE;EAChB,IAAI,OAAO,SAAS,GAClB,KAAK,OAAO,QAAQ;OAEpB,KAAK,IAAI,UAAU,MAAM;EAG3B,OAAO;CACT,CAAC;CAyCH,OAAO;EAAE,WAvCS,OAAO,GAAG,+BAA+B,CAAC,EACzD,aACC,OAAO,IAAI,aAAa;GACtB,MAAM,WAAW,OAAO,SAAS,KAAW;GAE5C,MAAM,eAAiC;IAAE,IAAA,OADvB,IAAI,aAAa,SAAS,YAAY,UAAU,CAAC;IACtB;GAAS;GAEtD,OAAO,OAAO,mBAAmB,OAAO,UAAU,aAAa,EAAE,CAAC;GAClE,OAAO,IAAI,OAAO,gBAAgB,YAAY;IAC5C,MAAM,OAAO,IAAI,IAAI,OAAO;IAC5B,MAAM,SAAS,IAAI,IAAI,QAAQ,IAAI,QAAQ,KAAK,CAAC,CAAC;IAElD,OAAO,IAAI,aAAa,IAAI,aAAa,QAAQ;IACjD,KAAK,IAAI,UAAU,MAAM;IAEzB,OAAO;GACT,CAAC;GAED,OAAO,aAAa;EACtB,CAAC,CAAC,CAAC,KAAK,OAAO,KAAK,aAAa,SAAS,MAAM,QAAQ,CAAC,CAAC,CAoB7C;EAAG,QAjBL,OAAO,GAAG,4BAA4B,CAAC,CAAC,WAAW,UAAoB;GACpF,MAAM,UAAU,OAAO,IAAI,OAAO,gBAAgB,YAAY;IAC5D,MAAM,SAAS,QAAQ,IAAI,QAAQ;IAEnC,IAAI,WAAW,KAAA,GAAW,OAAO,CAAC,CAAC,GAAG,OAAO;IAC7C,MAAM,OAAO,IAAI,IAAI,OAAO;IAE5B,KAAK,OAAO,QAAQ;IAEpB,OAAO,CAAC,CAAC,GAAG,OAAO,OAAO,CAAC,GAAG,IAAI;GACpC,CAAC;GAED,OAAO,OAAO,QAAQ,UAAU,WAAW,SAAS,QAAQ,QAAQ,KAAA,CAAS,GAAG,EAC9E,SAAS,KACX,CAAC;EACH,CAEyB;CAAE;AAC7B,CAAC;;;;;;;;;;;;;;;;AAiBD,IAAa,gBAAb,MAAa,sBAAsB,QAAQ,QAYzC,CAAC,CAAC,oCAAoC,CAAC,CAAC;;;;;CAKxC,OAAgB,YAAwC,MAAM,QAAQ,eAAe;EACnF,cAAc,OAAO;EACrB,iBAAiB,OAAO,QAAQ,OAAO,KAAK;EAC5C,OAAO,OAAO;CAChB,CAAC;AACH"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { l as SubmissionId, u as ThreadId } from "../Identifiers-CN2s30fF.mjs";
|
|
2
|
+
import { i as SubagentBudgetReservation } from "../SubagentContract-DdT7Cqe6.mjs";
|
|
3
|
+
import { r as Principal } from "../Receipt-BAHyigAF.mjs";
|
|
4
|
+
import { t as AgentPolicy } from "../AgentPolicy-BqDoSXO6.mjs";
|
|
5
|
+
import { r as AnyDefinition, t as Agent_d_exports } from "../Agent-D9cXqfF3.mjs";
|
|
6
|
+
import { c as WorkerError, f as WorkerRef, h as WorkerSource } from "../Worker-fwWkBg12.mjs";
|
|
7
|
+
import { O as PersistedJson, _ as Digest, dt as WorkerOrigin, h as DefinitionDigests, ko as SubmissionSnapshot } from "../Records-D88mgvyS.mjs";
|
|
8
|
+
import { Context, Effect, Option, Schema } from "effect";
|
|
9
|
+
declare namespace WorkerHost_d_exports {
|
|
10
|
+
export { WorkerBudgetAuthorizer, WorkerConcurrencyLimit, WorkerConcurrencyResolver, WorkerHostAuthorizationRequest, WorkerHostAuthorizer, WorkerHostConfig, WorkerHostLimits, WorkerPolicyResolver, WorkerPolicySource, WorkerPolicyTarget };
|
|
11
|
+
}
|
|
12
|
+
/** Host-verified source input; absence never means the latest input in the Thread. */
|
|
13
|
+
export interface WorkerPolicySource {
|
|
14
|
+
readonly threadId: ThreadId;
|
|
15
|
+
readonly definition: AnyDefinition;
|
|
16
|
+
readonly definitions: DefinitionDigests;
|
|
17
|
+
readonly submission?: SubmissionSnapshot;
|
|
18
|
+
}
|
|
19
|
+
/** Initial input is validated again at destination admission, including idempotent replay. */
|
|
20
|
+
export type WorkerPolicyTarget = {
|
|
21
|
+
readonly definition: AnyDefinition;
|
|
22
|
+
readonly definitions: DefinitionDigests;
|
|
23
|
+
readonly source: WorkerSource;
|
|
24
|
+
} & ({
|
|
25
|
+
readonly _tag: "InitialInput";
|
|
26
|
+
readonly sourceSubmission?: SubmissionSnapshot;
|
|
27
|
+
readonly input: PersistedJson;
|
|
28
|
+
readonly inputDigest: Digest;
|
|
29
|
+
} | {
|
|
30
|
+
readonly _tag: "RetainedWorker";
|
|
31
|
+
/** Verified against canonical source history before this request reaches the resolver. */
|
|
32
|
+
readonly origin: WorkerOrigin;
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Opt-in host authority for policies captured in immutable application input. None preserves
|
|
36
|
+
* the registered Definition's existing policy/override semantics. Some is a complete policy,
|
|
37
|
+
* never merged with static overrides. Decode and authorize the exact captured revision; do not
|
|
38
|
+
* read mutable settings or substitute a current capture for missing historical authority.
|
|
39
|
+
* RetainedWorker may affirm only origin.policy, never replace a continuing worker's allowance.
|
|
40
|
+
* Return WorkerError(unavailable) for temporarily unavailable authority so delivery can retry.
|
|
41
|
+
* Implementations are acquired through Effect Layers; capture their dependencies in Layer R.
|
|
42
|
+
*/
|
|
43
|
+
export declare const WorkerPolicyResolver: Context.Reference<{
|
|
44
|
+
readonly resolveSource: (request: WorkerPolicySource) => Effect.Effect<Option.Option<AgentPolicy>, WorkerError>;
|
|
45
|
+
readonly resolveTarget: (request: WorkerPolicyTarget) => Effect.Effect<Option.Option<AgentPolicy>, WorkerError>;
|
|
46
|
+
}>;
|
|
47
|
+
/** A host-authorized ceiling on active background workers, not retained workers or Run usage. */
|
|
48
|
+
export declare const WorkerConcurrencyLimit: Schema.Struct<{
|
|
49
|
+
readonly maxActiveWorkersPerSource: Schema.Int;
|
|
50
|
+
}>;
|
|
51
|
+
export type WorkerConcurrencyLimit = typeof WorkerConcurrencyLimit.Type;
|
|
52
|
+
/**
|
|
53
|
+
* Optional source-aware operational authority. Resolution occurs inside every new source
|
|
54
|
+
* reservation attempt, against the same canonical history used for the append CAS. None
|
|
55
|
+
* preserves WorkerHostConfig; Some can only narrow it. The selected submission is exact,
|
|
56
|
+
* never the latest input. Implementations must authorize that immutable capture and retain
|
|
57
|
+
* construction dependencies in Layer R. Unavailable authority must return WorkerError(unavailable).
|
|
58
|
+
*
|
|
59
|
+
* One worker occupies a slot while any of its inputs remain unacknowledged. Steering an active
|
|
60
|
+
* worker does not acquire another slot. Decreases (including zero) do not cancel incumbents;
|
|
61
|
+
* an idle worker needs a slot again. Idempotent retained reservations do not reacquire slots.
|
|
62
|
+
*/
|
|
63
|
+
export declare const WorkerConcurrencyResolver: Context.Reference<{
|
|
64
|
+
readonly resolve: (request: {
|
|
65
|
+
readonly source: WorkerSource;
|
|
66
|
+
readonly sourceSubmission?: SubmissionSnapshot;
|
|
67
|
+
readonly worker: WorkerRef;
|
|
68
|
+
readonly principal: Principal;
|
|
69
|
+
}) => Effect.Effect<Option.Option<WorkerConcurrencyLimit>, WorkerError>;
|
|
70
|
+
}>;
|
|
71
|
+
/** Host ceilings apply across all declarations owned by one source Thread. */
|
|
72
|
+
export declare const WorkerHostLimits: Schema.Struct<{
|
|
73
|
+
readonly maxWorkersPerSource: Schema.Int;
|
|
74
|
+
/** Active background workers across declarations; omission retains source Tool concurrency. */
|
|
75
|
+
readonly maxActiveWorkersPerSource: Schema.optionalKey<Schema.Int>;
|
|
76
|
+
readonly maxInputsPerWorker: Schema.Int;
|
|
77
|
+
readonly maxPendingInputsPerWorker: Schema.Int;
|
|
78
|
+
readonly maxUpdateInputsPerWorker: Schema.optionalKey<Schema.Int>;
|
|
79
|
+
readonly maxPendingUpdateInputsPerWorker: Schema.optionalKey<Schema.Int>;
|
|
80
|
+
readonly lifetimeMillis: Schema.Int;
|
|
81
|
+
/** Preparation may repeat after loss before its decision commits; keep callbacks side-effect free. */
|
|
82
|
+
readonly reportPreparationTimeoutMillis: Schema.optionalKey<Schema.Int>;
|
|
83
|
+
}>;
|
|
84
|
+
export type WorkerHostLimits = typeof WorkerHostLimits.Type;
|
|
85
|
+
export declare const WorkerHostConfig: Context.Reference<{
|
|
86
|
+
readonly maxWorkersPerSource: number;
|
|
87
|
+
readonly maxActiveWorkersPerSource?: number | undefined;
|
|
88
|
+
readonly maxInputsPerWorker: number;
|
|
89
|
+
readonly maxPendingInputsPerWorker: number;
|
|
90
|
+
readonly maxUpdateInputsPerWorker?: number | undefined;
|
|
91
|
+
readonly maxPendingUpdateInputsPerWorker?: number | undefined;
|
|
92
|
+
readonly lifetimeMillis: number;
|
|
93
|
+
readonly reportPreparationTimeoutMillis?: number | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Authenticate every acquisition/operation and authorize its exact source Thread. A returned
|
|
97
|
+
* Principal is host-owned admission identity. Context access authenticates source metadata;
|
|
98
|
+
* read, send and control remain separate grants. WorkerRefs and caller-supplied Thread
|
|
99
|
+
* identifiers alone never confer any of them.
|
|
100
|
+
*/
|
|
101
|
+
export interface WorkerHostAuthorizationRequest {
|
|
102
|
+
readonly sourceThreadId: ThreadId;
|
|
103
|
+
/** An explicitly selected owner input; authorize this locator as well as the Thread. */
|
|
104
|
+
readonly sourceSubmissionId?: SubmissionId;
|
|
105
|
+
readonly principal: Principal;
|
|
106
|
+
readonly operation: WorkerError["operation"];
|
|
107
|
+
readonly access: "context" | "read" | "send" | "control";
|
|
108
|
+
readonly worker?: WorkerRef;
|
|
109
|
+
}
|
|
110
|
+
export declare const WorkerHostAuthorizer: Context.Reference<{
|
|
111
|
+
readonly authorize: (request: WorkerHostAuthorizationRequest) => Effect.Effect<Principal, WorkerError>;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Deployment-owned permission to fund a root's background worker independently. The decision
|
|
115
|
+
* covers the exact immutable origin and is checked again before each input admission. It never
|
|
116
|
+
* changes delegation depth or Tool authority. Omission denies independent funding.
|
|
117
|
+
*/
|
|
118
|
+
export declare const WorkerBudgetAuthorizer: Context.Reference<{
|
|
119
|
+
readonly authorize: (request: {
|
|
120
|
+
readonly source: WorkerSource;
|
|
121
|
+
readonly principal: Principal;
|
|
122
|
+
readonly worker: WorkerRef;
|
|
123
|
+
readonly policy: AgentPolicy;
|
|
124
|
+
readonly budget: SubagentBudgetReservation;
|
|
125
|
+
}) => Effect.Effect<void, WorkerError>;
|
|
126
|
+
}>;
|
|
127
|
+
//#endregion
|
|
128
|
+
export { WorkerHost_d_exports as t };
|
|
129
|
+
//# sourceMappingURL=WorkerHost.d.mts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { c as WorkerError } from "../Worker-CfwzMZEK.mjs";
|
|
3
|
+
import { Context, Effect, Option, Schema } from "effect";
|
|
4
|
+
//#region src/durable/WorkerHost.ts
|
|
5
|
+
var WorkerHost_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
WorkerBudgetAuthorizer: () => WorkerBudgetAuthorizer,
|
|
7
|
+
WorkerConcurrencyLimit: () => WorkerConcurrencyLimit,
|
|
8
|
+
WorkerConcurrencyResolver: () => WorkerConcurrencyResolver,
|
|
9
|
+
WorkerHostAuthorizer: () => WorkerHostAuthorizer,
|
|
10
|
+
WorkerHostConfig: () => WorkerHostConfig,
|
|
11
|
+
WorkerHostLimits: () => WorkerHostLimits,
|
|
12
|
+
WorkerPolicyResolver: () => WorkerPolicyResolver
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Opt-in host authority for policies captured in immutable application input. None preserves
|
|
16
|
+
* the registered Definition's existing policy/override semantics. Some is a complete policy,
|
|
17
|
+
* never merged with static overrides. Decode and authorize the exact captured revision; do not
|
|
18
|
+
* read mutable settings or substitute a current capture for missing historical authority.
|
|
19
|
+
* RetainedWorker may affirm only origin.policy, never replace a continuing worker's allowance.
|
|
20
|
+
* Return WorkerError(unavailable) for temporarily unavailable authority so delivery can retry.
|
|
21
|
+
* Implementations are acquired through Effect Layers; capture their dependencies in Layer R.
|
|
22
|
+
*/
|
|
23
|
+
const WorkerPolicyResolver = Context.Reference("@effect-agent/thread/WorkerPolicyResolver", { defaultValue: () => ({
|
|
24
|
+
resolveSource: () => Effect.succeed(Option.none()),
|
|
25
|
+
resolveTarget: () => Effect.succeed(Option.none())
|
|
26
|
+
}) });
|
|
27
|
+
const Positive = Schema.Int.check(Schema.isGreaterThan(0));
|
|
28
|
+
/** A host-authorized ceiling on active background workers, not retained workers or Run usage. */
|
|
29
|
+
const WorkerConcurrencyLimit = Schema.Struct({ maxActiveWorkersPerSource: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)) });
|
|
30
|
+
/**
|
|
31
|
+
* Optional source-aware operational authority. Resolution occurs inside every new source
|
|
32
|
+
* reservation attempt, against the same canonical history used for the append CAS. None
|
|
33
|
+
* preserves WorkerHostConfig; Some can only narrow it. The selected submission is exact,
|
|
34
|
+
* never the latest input. Implementations must authorize that immutable capture and retain
|
|
35
|
+
* construction dependencies in Layer R. Unavailable authority must return WorkerError(unavailable).
|
|
36
|
+
*
|
|
37
|
+
* One worker occupies a slot while any of its inputs remain unacknowledged. Steering an active
|
|
38
|
+
* worker does not acquire another slot. Decreases (including zero) do not cancel incumbents;
|
|
39
|
+
* an idle worker needs a slot again. Idempotent retained reservations do not reacquire slots.
|
|
40
|
+
*/
|
|
41
|
+
const WorkerConcurrencyResolver = Context.Reference("@effect-agent/thread/WorkerConcurrencyResolver", { defaultValue: () => ({ resolve: () => Effect.succeed(Option.none()) }) });
|
|
42
|
+
/** Host ceilings apply across all declarations owned by one source Thread. */
|
|
43
|
+
const WorkerHostLimits = Schema.Struct({
|
|
44
|
+
maxWorkersPerSource: Positive.check(Schema.isLessThanOrEqualTo(100)),
|
|
45
|
+
/** Active background workers across declarations; omission retains source Tool concurrency. */
|
|
46
|
+
maxActiveWorkersPerSource: Schema.optionalKey(Positive.check(Schema.isLessThanOrEqualTo(100))),
|
|
47
|
+
maxInputsPerWorker: Positive.check(Schema.isLessThanOrEqualTo(1e3)),
|
|
48
|
+
maxPendingInputsPerWorker: Positive.check(Schema.isLessThanOrEqualTo(100)),
|
|
49
|
+
maxUpdateInputsPerWorker: Schema.optionalKey(Positive.check(Schema.isLessThanOrEqualTo(1e3))),
|
|
50
|
+
maxPendingUpdateInputsPerWorker: Schema.optionalKey(Positive.check(Schema.isLessThanOrEqualTo(100))),
|
|
51
|
+
lifetimeMillis: Positive.check(Schema.isLessThanOrEqualTo(6048e5)),
|
|
52
|
+
/** Preparation may repeat after loss before its decision commits; keep callbacks side-effect free. */
|
|
53
|
+
reportPreparationTimeoutMillis: Schema.optionalKey(Positive.check(Schema.isLessThanOrEqualTo(3e4)))
|
|
54
|
+
});
|
|
55
|
+
const WorkerHostConfig = Context.Reference("@effect-agent/thread/WorkerHostConfig", { defaultValue: () => ({
|
|
56
|
+
maxWorkersPerSource: 32,
|
|
57
|
+
maxInputsPerWorker: 64,
|
|
58
|
+
maxPendingInputsPerWorker: 8,
|
|
59
|
+
lifetimeMillis: 864e5
|
|
60
|
+
}) });
|
|
61
|
+
const WorkerHostAuthorizer = Context.Reference("@effect-agent/thread/WorkerHostAuthorizer", { defaultValue: () => ({ authorize: (request) => WorkerError.make({
|
|
62
|
+
operation: request.operation,
|
|
63
|
+
reason: "denied"
|
|
64
|
+
}) }) });
|
|
65
|
+
/**
|
|
66
|
+
* Deployment-owned permission to fund a root's background worker independently. The decision
|
|
67
|
+
* covers the exact immutable origin and is checked again before each input admission. It never
|
|
68
|
+
* changes delegation depth or Tool authority. Omission denies independent funding.
|
|
69
|
+
*/
|
|
70
|
+
const WorkerBudgetAuthorizer = Context.Reference("@effect-agent/thread/WorkerBudgetAuthorizer", { defaultValue: () => ({ authorize: () => WorkerError.make({
|
|
71
|
+
operation: "start",
|
|
72
|
+
reason: "denied"
|
|
73
|
+
}) }) });
|
|
74
|
+
//#endregion
|
|
75
|
+
export { WorkerBudgetAuthorizer, WorkerConcurrencyLimit, WorkerConcurrencyResolver, WorkerHostAuthorizer, WorkerHostConfig, WorkerHostLimits, WorkerPolicyResolver, WorkerHost_exports as t };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=WorkerHost.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerHost.mjs","names":[],"sources":["../../src/durable/WorkerHost.ts"],"sourcesContent":["import { Context, Effect, Option, Schema } from \"effect\";\n\nimport type * as Agent from \"../core/Agent.ts\";\nimport type { AgentPolicy } from \"../core/AgentPolicy.ts\";\nimport type { SubmissionId, ThreadId } from \"../core/Identifiers.ts\";\nimport type { SubagentBudgetReservation } from \"../core/SubagentContract.ts\";\nimport { WorkerError, type WorkerRef, type WorkerSource } from \"../core/Worker.ts\";\nimport type { DefinitionDigests, Digest, PersistedJson, WorkerOrigin } from \"./Records.ts\";\nimport type { Principal, SubmissionSnapshot } from \"./SubmissionLedger.ts\";\n\n/** Host-verified source input; absence never means the latest input in the Thread. */\nexport interface WorkerPolicySource {\n readonly threadId: ThreadId;\n readonly definition: Agent.AnyDefinition;\n readonly definitions: DefinitionDigests;\n readonly submission?: SubmissionSnapshot;\n}\n\n/** Initial input is validated again at destination admission, including idempotent replay. */\nexport type WorkerPolicyTarget = {\n readonly definition: Agent.AnyDefinition;\n readonly definitions: DefinitionDigests;\n readonly source: WorkerSource;\n} & (\n | {\n readonly _tag: \"InitialInput\";\n readonly sourceSubmission?: SubmissionSnapshot;\n readonly input: PersistedJson;\n readonly inputDigest: Digest;\n }\n | {\n readonly _tag: \"RetainedWorker\";\n /** Verified against canonical source history before this request reaches the resolver. */\n readonly origin: WorkerOrigin;\n }\n);\n\n/**\n * Opt-in host authority for policies captured in immutable application input. None preserves\n * the registered Definition's existing policy/override semantics. Some is a complete policy,\n * never merged with static overrides. Decode and authorize the exact captured revision; do not\n * read mutable settings or substitute a current capture for missing historical authority.\n * RetainedWorker may affirm only origin.policy, never replace a continuing worker's allowance.\n * Return WorkerError(unavailable) for temporarily unavailable authority so delivery can retry.\n * Implementations are acquired through Effect Layers; capture their dependencies in Layer R.\n */\nexport const WorkerPolicyResolver = Context.Reference<{\n readonly resolveSource: (\n request: WorkerPolicySource,\n ) => Effect.Effect<Option.Option<AgentPolicy>, WorkerError>;\n readonly resolveTarget: (\n request: WorkerPolicyTarget,\n ) => Effect.Effect<Option.Option<AgentPolicy>, WorkerError>;\n}>(\"@effect-agent/thread/WorkerPolicyResolver\", {\n defaultValue: () => ({\n resolveSource: () => Effect.succeed(Option.none()),\n resolveTarget: () => Effect.succeed(Option.none()),\n }),\n});\n\nconst Positive = Schema.Int.check(Schema.isGreaterThan(0));\n\n/** A host-authorized ceiling on active background workers, not retained workers or Run usage. */\nexport const WorkerConcurrencyLimit = Schema.Struct({\n maxActiveWorkersPerSource: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n});\n\nexport type WorkerConcurrencyLimit = typeof WorkerConcurrencyLimit.Type;\n\n/**\n * Optional source-aware operational authority. Resolution occurs inside every new source\n * reservation attempt, against the same canonical history used for the append CAS. None\n * preserves WorkerHostConfig; Some can only narrow it. The selected submission is exact,\n * never the latest input. Implementations must authorize that immutable capture and retain\n * construction dependencies in Layer R. Unavailable authority must return WorkerError(unavailable).\n *\n * One worker occupies a slot while any of its inputs remain unacknowledged. Steering an active\n * worker does not acquire another slot. Decreases (including zero) do not cancel incumbents;\n * an idle worker needs a slot again. Idempotent retained reservations do not reacquire slots.\n */\nexport const WorkerConcurrencyResolver = Context.Reference<{\n readonly resolve: (request: {\n readonly source: WorkerSource;\n readonly sourceSubmission?: SubmissionSnapshot;\n readonly worker: WorkerRef;\n readonly principal: Principal;\n }) => Effect.Effect<Option.Option<WorkerConcurrencyLimit>, WorkerError>;\n}>(\"@effect-agent/thread/WorkerConcurrencyResolver\", {\n defaultValue: () => ({ resolve: () => Effect.succeed(Option.none()) }),\n});\n\n/** Host ceilings apply across all declarations owned by one source Thread. */\nexport const WorkerHostLimits = Schema.Struct({\n maxWorkersPerSource: Positive.check(Schema.isLessThanOrEqualTo(100)),\n /** Active background workers across declarations; omission retains source Tool concurrency. */\n maxActiveWorkersPerSource: Schema.optionalKey(Positive.check(Schema.isLessThanOrEqualTo(100))),\n maxInputsPerWorker: Positive.check(Schema.isLessThanOrEqualTo(1_000)),\n maxPendingInputsPerWorker: Positive.check(Schema.isLessThanOrEqualTo(100)),\n maxUpdateInputsPerWorker: Schema.optionalKey(Positive.check(Schema.isLessThanOrEqualTo(1_000))),\n maxPendingUpdateInputsPerWorker: Schema.optionalKey(\n Positive.check(Schema.isLessThanOrEqualTo(100)),\n ),\n lifetimeMillis: Positive.check(Schema.isLessThanOrEqualTo(604_800_000)),\n /** Preparation may repeat after loss before its decision commits; keep callbacks side-effect free. */\n reportPreparationTimeoutMillis: Schema.optionalKey(\n Positive.check(Schema.isLessThanOrEqualTo(30_000)),\n ),\n});\n\nexport type WorkerHostLimits = typeof WorkerHostLimits.Type;\n\nexport const WorkerHostConfig = Context.Reference<WorkerHostLimits>(\n \"@effect-agent/thread/WorkerHostConfig\",\n {\n defaultValue: () => ({\n maxWorkersPerSource: 32,\n maxInputsPerWorker: 64,\n maxPendingInputsPerWorker: 8,\n lifetimeMillis: 86_400_000,\n }),\n },\n);\n\n/**\n * Authenticate every acquisition/operation and authorize its exact source Thread. A returned\n * Principal is host-owned admission identity. Context access authenticates source metadata;\n * read, send and control remain separate grants. WorkerRefs and caller-supplied Thread\n * identifiers alone never confer any of them.\n */\nexport interface WorkerHostAuthorizationRequest {\n readonly sourceThreadId: ThreadId;\n /** An explicitly selected owner input; authorize this locator as well as the Thread. */\n readonly sourceSubmissionId?: SubmissionId;\n readonly principal: Principal;\n readonly operation: WorkerError[\"operation\"];\n readonly access: \"context\" | \"read\" | \"send\" | \"control\";\n readonly worker?: WorkerRef;\n}\n\nexport const WorkerHostAuthorizer = Context.Reference<{\n readonly authorize: (\n request: WorkerHostAuthorizationRequest,\n ) => Effect.Effect<Principal, WorkerError>;\n}>(\"@effect-agent/thread/WorkerHostAuthorizer\", {\n defaultValue: () => ({\n authorize: (request) =>\n WorkerError.make({\n operation: request.operation,\n reason: \"denied\",\n }),\n }),\n});\n\n/**\n * Deployment-owned permission to fund a root's background worker independently. The decision\n * covers the exact immutable origin and is checked again before each input admission. It never\n * changes delegation depth or Tool authority. Omission denies independent funding.\n */\nexport const WorkerBudgetAuthorizer = Context.Reference<{\n readonly authorize: (request: {\n readonly source: WorkerSource;\n readonly principal: Principal;\n readonly worker: WorkerRef;\n readonly policy: AgentPolicy;\n readonly budget: SubagentBudgetReservation;\n }) => Effect.Effect<void, WorkerError>;\n}>(\"@effect-agent/thread/WorkerBudgetAuthorizer\", {\n defaultValue: () => ({\n authorize: () => WorkerError.make({ operation: \"start\", reason: \"denied\" }),\n }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAa,uBAAuB,QAAQ,UAOzC,6CAA6C,EAC9C,qBAAqB;CACnB,qBAAqB,OAAO,QAAQ,OAAO,KAAK,CAAC;CACjD,qBAAqB,OAAO,QAAQ,OAAO,KAAK,CAAC;AACnD,GACF,CAAC;AAED,MAAM,WAAW,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;;AAGzD,MAAa,yBAAyB,OAAO,OAAO,EAClD,2BAA2B,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC,EAC9E,CAAC;;;;;;;;;;;;AAeD,MAAa,4BAA4B,QAAQ,UAO9C,kDAAkD,EACnD,qBAAqB,EAAE,eAAe,OAAO,QAAQ,OAAO,KAAK,CAAC,EAAE,GACtE,CAAC;;AAGD,MAAa,mBAAmB,OAAO,OAAO;CAC5C,qBAAqB,SAAS,MAAM,OAAO,oBAAoB,GAAG,CAAC;;CAEnE,2BAA2B,OAAO,YAAY,SAAS,MAAM,OAAO,oBAAoB,GAAG,CAAC,CAAC;CAC7F,oBAAoB,SAAS,MAAM,OAAO,oBAAoB,GAAK,CAAC;CACpE,2BAA2B,SAAS,MAAM,OAAO,oBAAoB,GAAG,CAAC;CACzE,0BAA0B,OAAO,YAAY,SAAS,MAAM,OAAO,oBAAoB,GAAK,CAAC,CAAC;CAC9F,iCAAiC,OAAO,YACtC,SAAS,MAAM,OAAO,oBAAoB,GAAG,CAAC,CAChD;CACA,gBAAgB,SAAS,MAAM,OAAO,oBAAoB,MAAW,CAAC;;CAEtE,gCAAgC,OAAO,YACrC,SAAS,MAAM,OAAO,oBAAoB,GAAM,CAAC,CACnD;AACF,CAAC;AAID,MAAa,mBAAmB,QAAQ,UACtC,yCACA,EACE,qBAAqB;CACnB,qBAAqB;CACrB,oBAAoB;CACpB,2BAA2B;CAC3B,gBAAgB;AAClB,GACF,CACF;AAkBA,MAAa,uBAAuB,QAAQ,UAIzC,6CAA6C,EAC9C,qBAAqB,EACnB,YAAY,YACV,YAAY,KAAK;CACf,WAAW,QAAQ;CACnB,QAAQ;AACV,CAAC,EACL,GACF,CAAC;;;;;;AAOD,MAAa,yBAAyB,QAAQ,UAQ3C,+CAA+C,EAChD,qBAAqB,EACnB,iBAAiB,YAAY,KAAK;CAAE,WAAW;CAAS,QAAQ;AAAS,CAAC,EAC5E,GACF,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as start, C as decodeFinalOutput, D as renderInputPrompt, E as projectCompletionOutput, F as withTerminalDefectEvent, M as stream, N as streamUnknown, O as run, P as streamWithUsageAccountingUnknown, S as ToolCallWaiting, T as projectCompletionFromToolOutput, _ as SubagentDurability, a as AgentResultSchema, b as SubagentDurabilityError, c as AgentSpawner, d as DetachedRun, f as EngineProvidedToolServices, g as SpawnedChildRun, h as SpawnRunOptions, i as AgentResult, j as startUnknown, k as runUnknown, l as AgentSpawnerParent, m as SpawnDelegation, n as AgentChildPending, o as AgentRuntimeFailure, p as RuntimeBinding, r as AgentCompletionProjectionRequirements, s as AgentRuntimeRequirements, u as AgentSpawnerService, v as SubagentDurabilityDurable, w as encodeRunDisposition, x as SubagentDurabilityService, y as SubagentDurabilityEphemeral } from "../AgentRuntime-BUxDdLpw.mjs";
|
|
2
|
+
export { AgentChildPending, type AgentCompletionProjectionRequirements, type AgentResult, AgentResultSchema, type AgentRuntimeFailure, type AgentRuntimeRequirements, AgentSpawner, type AgentSpawnerParent, type AgentSpawnerService, type DetachedRun, type EngineProvidedToolServices, type RuntimeBinding, type SpawnDelegation, type SpawnRunOptions, type SpawnedChildRun, SubagentDurability, type SubagentDurabilityDurable, type SubagentDurabilityEphemeral, SubagentDurabilityError, type SubagentDurabilityService, ToolCallWaiting, decodeFinalOutput, encodeRunDisposition, projectCompletionFromToolOutput, projectCompletionOutput, renderInputPrompt, run, runUnknown, start, startUnknown, stream, streamUnknown, streamWithUsageAccountingUnknown, withTerminalDefectEvent };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as stream, a as SubagentDurability, b as withTerminalDefectEvent, c as decodeFinalOutput, d as projectCompletionOutput, f as renderInputPrompt, g as startUnknown, h as start, i as AgentSpawner, l as encodeRunDisposition, m as runUnknown, n as AgentChildPending, o as SubagentDurabilityError, p as run, r as AgentResultSchema, s as ToolCallWaiting, u as projectCompletionFromToolOutput, v as streamUnknown, y as streamWithUsageAccountingUnknown } from "../AgentRuntime-Cp1hAb-W.mjs";
|
|
2
|
+
export { AgentChildPending, AgentResultSchema, AgentSpawner, SubagentDurability, SubagentDurabilityError, ToolCallWaiting, decodeFinalOutput, encodeRunDisposition, projectCompletionFromToolOutput, projectCompletionOutput, renderInputPrompt, run, runUnknown, start, startUnknown, stream, streamUnknown, streamWithUsageAccountingUnknown, withTerminalDefectEvent };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { d as CONTEXT_ROLLOVER_PREFIX, f as ContextCompactionState, g as estimatePromptTokens, h as estimateMessageTokens, l as CLEARED_TOOL_RESULT, m as contextWindowMessage, p as contextWindowId, u as COMPACTION_SUMMARY_PREFIX } from "../ContextCompactor-WwSIG_Z2.mjs";
|
|
2
|
+
declare namespace Compaction_d_exports {
|
|
3
|
+
export { CLEARED_TOOL_RESULT, COMPACTION_SUMMARY_PREFIX, CONTEXT_ROLLOVER_PREFIX, ContextCompactionState, contextWindowId, contextWindowMessage, estimateMessageTokens, estimatePromptTokens };
|
|
4
|
+
}
|
|
5
|
+
//#endregion
|
|
6
|
+
export { CLEARED_TOOL_RESULT, COMPACTION_SUMMARY_PREFIX, CONTEXT_ROLLOVER_PREFIX, type ContextCompactionState, contextWindowId, contextWindowMessage, estimateMessageTokens, estimatePromptTokens, Compaction_d_exports as t };
|
|
7
|
+
//# sourceMappingURL=Compaction.d.mts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { f as contextWindowId, h as estimatePromptTokens, m as estimateMessageTokens, n as COMPACTION_SUMMARY_PREFIX, p as contextWindowMessage, r as CONTEXT_ROLLOVER_PREFIX, t as CLEARED_TOOL_RESULT } from "../compaction-C2OTceKw.mjs";
|
|
3
|
+
//#region src/engine/Compaction.ts
|
|
4
|
+
var Compaction_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
CLEARED_TOOL_RESULT: () => CLEARED_TOOL_RESULT,
|
|
6
|
+
COMPACTION_SUMMARY_PREFIX: () => COMPACTION_SUMMARY_PREFIX,
|
|
7
|
+
CONTEXT_ROLLOVER_PREFIX: () => CONTEXT_ROLLOVER_PREFIX,
|
|
8
|
+
contextWindowId: () => contextWindowId,
|
|
9
|
+
contextWindowMessage: () => contextWindowMessage,
|
|
10
|
+
estimateMessageTokens: () => estimateMessageTokens,
|
|
11
|
+
estimatePromptTokens: () => estimatePromptTokens
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { CLEARED_TOOL_RESULT, COMPACTION_SUMMARY_PREFIX, CONTEXT_ROLLOVER_PREFIX, contextWindowId, contextWindowMessage, estimateMessageTokens, estimatePromptTokens, Compaction_exports as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=Compaction.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Compaction.mjs","names":[],"sources":["../../src/engine/Compaction.ts"],"sourcesContent":["/** Public Compaction API. Implementation helpers remain private. */\nexport {\n CLEARED_TOOL_RESULT,\n COMPACTION_SUMMARY_PREFIX,\n CONTEXT_ROLLOVER_PREFIX,\n contextWindowId,\n contextWindowMessage,\n estimateMessageTokens,\n estimatePromptTokens,\n type ContextCompactionState,\n} from \"./internal/compaction.ts\";\n"],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as ContextCompaction, c as ContextMessageTokenEstimator, i as CompactionRequest, n as CompactionError, o as ContextCompactor, r as CompactionModelLayer, t as CompactionDecision } from "../ContextCompactor-WwSIG_Z2.mjs";
|
|
2
|
+
export { CompactionDecision, CompactionError, CompactionModelLayer, CompactionRequest, ContextCompaction, ContextCompactor, ContextMessageTokenEstimator };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { a as SUMMARY_REQUEST_PREFIX, c as buildRolloverHandoff, d as collectCoveredMessages, g as evaluateMessageTokenEstimates, h as estimatePromptTokens, i as SUMMARY_MAX_LENGTH, l as choosePruneBound, o as SUMMARY_REQUEST_SUFFIX, s as buildCompactedView, u as chooseSummarizeCut, y as renderForSummary } from "../compaction-C2OTceKw.mjs";
|
|
3
|
+
import { ContextHandoff } from "./ContextWindow.mjs";
|
|
4
|
+
import { Prompt } from "effect/unstable/ai";
|
|
5
|
+
import { Context, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
6
|
+
//#region src/engine/ContextCompactor.ts
|
|
7
|
+
var ContextCompactor_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
CompactionDecision: () => CompactionDecision,
|
|
9
|
+
CompactionError: () => CompactionError,
|
|
10
|
+
ContextCompactor: () => ContextCompactor
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* A proposed view change. Source indices are exclusive prefix bounds, never record sequences.
|
|
14
|
+
* Summaries contain at most 65,536 characters; the interpreter rejects oversized decisions
|
|
15
|
+
* before committing or changing coverage.
|
|
16
|
+
*/
|
|
17
|
+
const CompactionDecision = Schema.Union([
|
|
18
|
+
Schema.Struct({
|
|
19
|
+
kind: Schema.Literal("rollover"),
|
|
20
|
+
through: Schema.Natural,
|
|
21
|
+
handoff: Schema.optionalKey(ContextHandoff)
|
|
22
|
+
}),
|
|
23
|
+
Schema.Struct({
|
|
24
|
+
kind: Schema.Literal("clear-tool-results"),
|
|
25
|
+
through: Schema.Natural
|
|
26
|
+
}),
|
|
27
|
+
Schema.Struct({
|
|
28
|
+
kind: Schema.Literal("summarize"),
|
|
29
|
+
through: Schema.Natural,
|
|
30
|
+
summary: Schema.NonEmptyString.check(Schema.isMaxLength(SUMMARY_MAX_LENGTH), Schema.isPattern(/\S/))
|
|
31
|
+
})
|
|
32
|
+
]);
|
|
33
|
+
/** Expected strategy or decision-validation failure. Causes stay in the live Effect only. */
|
|
34
|
+
var CompactionError = class extends Schema.TaggedError()("CompactionError", {
|
|
35
|
+
message: Schema.String.check(Schema.isMaxLength(4096)),
|
|
36
|
+
cause: Schema.optionalKey(Schema.Defect())
|
|
37
|
+
}) {};
|
|
38
|
+
const evaluateEstimates = (override, operation) => Effect.suspend(() => {
|
|
39
|
+
const result = evaluateMessageTokenEstimates(override, operation);
|
|
40
|
+
return Option.isSome(result) ? Effect.succeed(result.value) : CompactionError.make({ message: "Message token estimator returned an invalid token count" });
|
|
41
|
+
});
|
|
42
|
+
const defaultCompactor = (model) => ({
|
|
43
|
+
estimate: estimatePromptTokens,
|
|
44
|
+
compact: (request) => Stream.unwrap(Effect.gen(function* () {
|
|
45
|
+
const { source, policy, targetTokens, trigger, modelCallAllowed } = request;
|
|
46
|
+
if (request.requested !== void 0) return Stream.succeed({
|
|
47
|
+
kind: "rollover",
|
|
48
|
+
...request.requested
|
|
49
|
+
});
|
|
50
|
+
const forceSummarize = trigger === "overflow";
|
|
51
|
+
const state = { ...request.state };
|
|
52
|
+
const keepRecentTokens = targetTokens === void 0 ? policy.keepRecentTokens : Math.max(1, Math.min(policy.keepRecentTokens, targetTokens));
|
|
53
|
+
const decisions = [];
|
|
54
|
+
if (!forceSummarize && policy.mode !== "summarize") {
|
|
55
|
+
const through = yield* evaluateEstimates(request.estimateMessageTokens, (estimate) => choosePruneBound(source.content, state, keepRecentTokens, targetTokens, estimate));
|
|
56
|
+
if (through > state.clearedThrough) {
|
|
57
|
+
state.clearedThrough = through;
|
|
58
|
+
decisions.push({
|
|
59
|
+
kind: "clear-tool-results",
|
|
60
|
+
through
|
|
61
|
+
});
|
|
62
|
+
if (targetTokens !== void 0 && (yield* evaluateEstimates(request.estimateMessageTokens, (estimate) => estimatePromptTokens(buildCompactedView(source.content, state), estimate))) <= targetTokens) return Stream.fromIterable(decisions);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const prune = Stream.fromIterable(decisions);
|
|
66
|
+
if ((!modelCallAllowed || policy.mode === "prune") && !forceSummarize) return prune;
|
|
67
|
+
return prune.pipe(Stream.concat(Stream.unwrap(Effect.gen(function* () {
|
|
68
|
+
const through = yield* evaluateEstimates(request.estimateMessageTokens, (estimate) => chooseSummarizeCut(source.content, state, keepRecentTokens, estimate));
|
|
69
|
+
const covered = collectCoveredMessages(source.content, state, through);
|
|
70
|
+
if (covered.length === 0) return Stream.empty;
|
|
71
|
+
const transcript = renderForSummary(covered, state.replacement?.kind === "summarize" ? state.replacement.summary : state.replacement?.handoff);
|
|
72
|
+
if (transcript === void 0) return yield* CompactionError.make({ message: `Previous compaction summary exceeds ${SUMMARY_MAX_LENGTH} characters` });
|
|
73
|
+
const prompt = Prompt.fromMessages([Prompt.userMessage({ content: [Prompt.textPart({ text: `${SUMMARY_REQUEST_PREFIX}${transcript}${SUMMARY_REQUEST_SUFFIX}` })] })]);
|
|
74
|
+
const text = yield* request.summarize(prompt, model);
|
|
75
|
+
return Stream.succeed({
|
|
76
|
+
kind: "summarize",
|
|
77
|
+
through,
|
|
78
|
+
summary: text.trim()
|
|
79
|
+
});
|
|
80
|
+
}))));
|
|
81
|
+
}))
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* The sole interpreter compaction port. Runs without an installed service provide layer at their
|
|
85
|
+
* composition boundary. Decorators yield this service during construction and receive their
|
|
86
|
+
* underlying implementation through Layer.provide. Direct harnesses use the same Layer contract.
|
|
87
|
+
*/
|
|
88
|
+
var ContextCompactor = class ContextCompactor extends Context.Service()("@effect-agent/engine/ContextCompactor") {
|
|
89
|
+
static layer = Layer.succeed(ContextCompactor, defaultCompactor());
|
|
90
|
+
/**
|
|
91
|
+
* Start fresh windows without a summarizer call. The engine retains instructions/input and
|
|
92
|
+
* commits each boundary; a bounded emergency handoff preserves user inputs and unseen results.
|
|
93
|
+
* Applications provide notes/history tools alongside this strategy.
|
|
94
|
+
*/
|
|
95
|
+
static layerRollover = Layer.succeed(ContextCompactor, {
|
|
96
|
+
estimate: estimatePromptTokens,
|
|
97
|
+
compact: (request) => Stream.unwrap(Effect.gen(function* () {
|
|
98
|
+
if (request.requested !== void 0) return Stream.succeed({
|
|
99
|
+
kind: "rollover",
|
|
100
|
+
...request.requested
|
|
101
|
+
});
|
|
102
|
+
const through = request.source.content.findLastIndex((message) => message.role === "assistant" || message.role === "tool") + 1;
|
|
103
|
+
if (collectCoveredMessages(request.source.content, request.state, through).length === 0) return Stream.empty;
|
|
104
|
+
const handoff = yield* evaluateEstimates(request.estimateMessageTokens, (estimate) => buildRolloverHandoff(request.source.content, request.state, request.targetTokens, through, estimate));
|
|
105
|
+
if (handoff === void 0) return Stream.fail(CompactionError.make({ message: "Insufficient context capacity for an automatic rollover handoff" }));
|
|
106
|
+
return Stream.succeed({
|
|
107
|
+
kind: "rollover",
|
|
108
|
+
through,
|
|
109
|
+
handoff
|
|
110
|
+
});
|
|
111
|
+
}))
|
|
112
|
+
});
|
|
113
|
+
/** Use the bounded default algorithm with a separate upstream Effect AI Model. */
|
|
114
|
+
static layerWithModel = (model) => Layer.effect(ContextCompactor, Effect.map(model.captureRequirements, (captured) => defaultCompactor(captured)));
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
export { CompactionDecision, CompactionError, ContextCompactor, ContextCompactor_exports as t };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=ContextCompactor.mjs.map
|