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,506 @@
|
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
|
|
3
|
+
import { ToolExecutionClass } from "../engine/DurableStep.mjs";
|
|
4
|
+
import { McpConnectionError, McpConnector, McpServerIdentity, McpToolOutputSchema } from "./Mcp.mjs";
|
|
5
|
+
import { Tool, Toolkit } from "effect/unstable/ai";
|
|
6
|
+
import { Cause, Context, Effect, Layer, Option, Predicate, Queue, Schema, Scope, Stream } from "effect";
|
|
7
|
+
import * as McpSchema from "effect/unstable/ai/McpSchema";
|
|
8
|
+
import * as McpProtocol from "effect/unstable/ai/McpProtocol";
|
|
9
|
+
import { Headers, HttpClient, HttpClientRequest } from "effect/unstable/http";
|
|
10
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
|
11
|
+
import { RpcClient, RpcClientError, RpcSerialization } from "effect/unstable/rpc";
|
|
12
|
+
//#region src/capabilities/McpClient.ts
|
|
13
|
+
var McpClient_exports = /* @__PURE__ */ __exportAll({
|
|
14
|
+
McpClientProtocolVersion: () => McpClientProtocolVersion,
|
|
15
|
+
McpHttpTransport: () => McpHttpTransport,
|
|
16
|
+
McpStdioTransport: () => McpStdioTransport,
|
|
17
|
+
McpToolCallFailed: () => McpToolCallFailed,
|
|
18
|
+
McpToolResult: () => McpToolResult,
|
|
19
|
+
defaultMcpClientInfo: () => defaultMcpClientInfo,
|
|
20
|
+
layer: () => layer
|
|
21
|
+
});
|
|
22
|
+
/** Largest single JSON-RPC message a transport accepts from a server by default. */
|
|
23
|
+
const DEFAULT_MAX_MESSAGE_BYTES = 4194304;
|
|
24
|
+
/** Bounded `tools/list` pagination: a server cannot keep a client walking cursors forever. */
|
|
25
|
+
const MAX_TOOL_LIST_PAGES = 64;
|
|
26
|
+
const MCP_SESSION_ID_HEADER = "mcp-session-id";
|
|
27
|
+
const MCP_PROTOCOL_VERSION_HEADER = "mcp-protocol-version";
|
|
28
|
+
const JSON_RPC_METHOD_NOT_FOUND = -32601;
|
|
29
|
+
/**
|
|
30
|
+
* The protocol revisions this client negotiates, as implemented by Effect AI's
|
|
31
|
+
* native MCP protocol adapters. The newest revision is offered first; a server
|
|
32
|
+
* answering with any other listed revision is accepted, anything else fails.
|
|
33
|
+
*/
|
|
34
|
+
const McpClientProtocolVersion = Schema.Literals([
|
|
35
|
+
McpProtocol.v2025_11_25.protocolVersion,
|
|
36
|
+
McpProtocol.v2025_06_18.protocolVersion,
|
|
37
|
+
McpProtocol.v2025_03_26.protocolVersion,
|
|
38
|
+
McpProtocol.v2024_11_05.protocolVersion
|
|
39
|
+
]);
|
|
40
|
+
const OFFERED_PROTOCOL_VERSION = McpProtocol.v2025_11_25.protocolVersion;
|
|
41
|
+
/** Identity this client presents to servers during `initialize`. */
|
|
42
|
+
const defaultMcpClientInfo = McpSchema.Implementation.make({
|
|
43
|
+
name: "effect-agent",
|
|
44
|
+
version: "1.0.0"
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* The model-visible result of a remote MCP tool call: the server's content
|
|
48
|
+
* blocks and, when the tool declares an `outputSchema`, its structured result.
|
|
49
|
+
* A result with `isError` never becomes this value; it fails the Tool Call.
|
|
50
|
+
*/
|
|
51
|
+
var McpToolResult = class extends Schema.Class("@effect-agent/capabilities/McpToolResult")({
|
|
52
|
+
content: Schema.Array(McpSchema.ContentBlock),
|
|
53
|
+
structuredContent: Schema.optionalKey(Schema.Json)
|
|
54
|
+
}) {};
|
|
55
|
+
/**
|
|
56
|
+
* Typed failure of one remote MCP tool call. `tool-error` carries the server's
|
|
57
|
+
* error content; the other reasons describe why no trustworthy result exists.
|
|
58
|
+
* None of them claims the remote effect did not happen.
|
|
59
|
+
*/
|
|
60
|
+
var McpToolCallFailed = class extends Schema.TaggedError()("McpToolCallFailed", {
|
|
61
|
+
serverId: Schema.NonEmptyString,
|
|
62
|
+
tool: Schema.NonEmptyString,
|
|
63
|
+
reason: Schema.Literals([
|
|
64
|
+
"tool-error",
|
|
65
|
+
"invalid-arguments",
|
|
66
|
+
"protocol-error",
|
|
67
|
+
"transport"
|
|
68
|
+
]),
|
|
69
|
+
message: Schema.String,
|
|
70
|
+
content: Schema.optionalKey(Schema.Array(McpSchema.ContentBlock))
|
|
71
|
+
}) {};
|
|
72
|
+
const isNotificationTag = (tag) => tag.startsWith("notifications/");
|
|
73
|
+
const isRpcClientError = Schema.is(RpcClientError.RpcClientError);
|
|
74
|
+
const protocolDefect = (message, cause) => new RpcClientError.RpcClientError({ reason: new RpcClientError.RpcClientDefect({
|
|
75
|
+
message,
|
|
76
|
+
cause
|
|
77
|
+
}) });
|
|
78
|
+
const InitializeProtocolVersion = Schema.Struct({ protocolVersion: Schema.String });
|
|
79
|
+
const decodeInitializeProtocolVersion = Schema.decodeUnknownOption(InitializeProtocolVersion);
|
|
80
|
+
const ServerRequest = Schema.Struct({
|
|
81
|
+
_tag: Schema.Literal("Request"),
|
|
82
|
+
tag: Schema.String
|
|
83
|
+
});
|
|
84
|
+
const isServerRequest = Schema.is(ServerRequest);
|
|
85
|
+
const isJsonRpcRequest = (message) => isServerRequest(message);
|
|
86
|
+
/** JSON-RPC error a client returns for a server-initiated request it does not serve. */
|
|
87
|
+
const declineServerRequest = (request) => ({
|
|
88
|
+
_tag: "Exit",
|
|
89
|
+
requestId: request.id,
|
|
90
|
+
exit: {
|
|
91
|
+
_tag: "Failure",
|
|
92
|
+
cause: [{
|
|
93
|
+
_tag: "Fail",
|
|
94
|
+
error: {
|
|
95
|
+
code: JSON_RPC_METHOD_NOT_FOUND,
|
|
96
|
+
message: `Client does not serve ${request.tag}`
|
|
97
|
+
}
|
|
98
|
+
}]
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* Routes one decoded JSON-RPC message. Responses reach the RPC client; server
|
|
103
|
+
* notifications are logged; server requests (sampling, elicitation, roots)
|
|
104
|
+
* are declined fail-closed through `respond` because this client serves none.
|
|
105
|
+
*/
|
|
106
|
+
const routeMessage = (message, options) => {
|
|
107
|
+
if (isJsonRpcRequest(message)) {
|
|
108
|
+
if (message.isNotification === true) return Effect.logDebug("Ignoring MCP server notification").pipe(Effect.annotateLogs({ method: message.tag }));
|
|
109
|
+
return options.respond(declineServerRequest(message));
|
|
110
|
+
}
|
|
111
|
+
if (Predicate.hasProperty(message, "_tag") && message._tag === "Exit") options.onExit(message);
|
|
112
|
+
return options.writeResponse(options.clientId, message);
|
|
113
|
+
};
|
|
114
|
+
/** Reads a response body as text while refusing bodies above `maxBytes`. */
|
|
115
|
+
const readBoundedText = Effect.fn("McpHttpTransport.readBoundedText")(function* (response, maxBytes) {
|
|
116
|
+
const declared = Number(response.headers["content-length"]);
|
|
117
|
+
if (Number.isFinite(declared) && declared > maxBytes) return yield* protocolDefect(`MCP response of ${declared} bytes exceeds the ${maxBytes} byte message bound`);
|
|
118
|
+
const chunks = [];
|
|
119
|
+
let received = 0;
|
|
120
|
+
yield* response.stream.pipe(Stream.decodeText(), Stream.runForEach((chunk) => {
|
|
121
|
+
received += utf8ByteLength(chunk);
|
|
122
|
+
if (received > maxBytes) return Effect.fail(protocolDefect(`MCP response exceeds the ${maxBytes} byte message bound`));
|
|
123
|
+
chunks.push(chunk);
|
|
124
|
+
return Effect.void;
|
|
125
|
+
}), Effect.mapError((error) => isRpcClientError(error) ? error : protocolDefect("Could not read the MCP HTTP response", error)));
|
|
126
|
+
return chunks.join("");
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Delivers the `data` of each `text/event-stream` event as it arrives. Only
|
|
130
|
+
* `data` fields carry JSON-RPC messages; `event`, `id`, `retry`, and comment
|
|
131
|
+
* lines are ignored because this client never resumes a stream, so a server
|
|
132
|
+
* retry directive neither ends the stream nor fails the request. At most
|
|
133
|
+
* `maxBytes` of an unterminated event stays buffered.
|
|
134
|
+
*/
|
|
135
|
+
const consumeEventStream = Effect.fn("McpHttpTransport.consumeEventStream")(function* (response, maxBytes, deliver) {
|
|
136
|
+
let buffer = "";
|
|
137
|
+
let pendingBytes = 0;
|
|
138
|
+
const dispatchEvent = (block) => {
|
|
139
|
+
const data = block.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).replace(/^ /, "")).join("\n");
|
|
140
|
+
return data.length === 0 ? Effect.void : deliver(data);
|
|
141
|
+
};
|
|
142
|
+
const drain = (final) => Effect.suspend(() => {
|
|
143
|
+
const blocks = [];
|
|
144
|
+
while (true) {
|
|
145
|
+
const match = /\r?\n\r?\n/.exec(buffer);
|
|
146
|
+
if (match === null) break;
|
|
147
|
+
blocks.push(buffer.slice(0, match.index));
|
|
148
|
+
buffer = buffer.slice(match.index + match[0].length);
|
|
149
|
+
}
|
|
150
|
+
if (final && buffer.length > 0) {
|
|
151
|
+
blocks.push(buffer);
|
|
152
|
+
buffer = "";
|
|
153
|
+
}
|
|
154
|
+
pendingBytes = utf8ByteLength(buffer);
|
|
155
|
+
return Effect.forEach(blocks, dispatchEvent, { discard: true });
|
|
156
|
+
});
|
|
157
|
+
yield* response.stream.pipe(Stream.decodeText(), Stream.runForEach((chunk) => {
|
|
158
|
+
buffer += chunk;
|
|
159
|
+
pendingBytes += utf8ByteLength(chunk);
|
|
160
|
+
if (pendingBytes > maxBytes) return Effect.fail(protocolDefect(`MCP event stream buffered more than ${maxBytes} bytes`));
|
|
161
|
+
return drain(false);
|
|
162
|
+
}), Effect.mapError((error) => isRpcClientError(error) ? error : protocolDefect("Could not read the MCP event stream", error)));
|
|
163
|
+
yield* drain(true);
|
|
164
|
+
});
|
|
165
|
+
const makeHttpProtocol = Effect.fn("McpHttpTransport.protocol")(function* (options) {
|
|
166
|
+
const client = yield* HttpClient.HttpClient;
|
|
167
|
+
const serialization = RpcSerialization.jsonRpc();
|
|
168
|
+
const parser = serialization.makeUnsafe();
|
|
169
|
+
const maxMessageBytes = options.maxMessageBytes ?? DEFAULT_MAX_MESSAGE_BYTES;
|
|
170
|
+
const configuredHeaders = Headers.fromInput(options.headers);
|
|
171
|
+
const url = options.url;
|
|
172
|
+
let sessionId;
|
|
173
|
+
let protocolVersion;
|
|
174
|
+
let initializeRequestId;
|
|
175
|
+
/** Request ids whose JSON-RPC response has been delivered. */
|
|
176
|
+
const answered = /* @__PURE__ */ new Set();
|
|
177
|
+
const transportHeaders = () => Headers.merge(configuredHeaders, Headers.fromInput({
|
|
178
|
+
accept: "application/json, text/event-stream",
|
|
179
|
+
...sessionId === void 0 ? {} : { [MCP_SESSION_ID_HEADER]: sessionId },
|
|
180
|
+
...protocolVersion === void 0 ? {} : { [MCP_PROTOCOL_VERSION_HEADER]: protocolVersion }
|
|
181
|
+
}));
|
|
182
|
+
const post = (body) => client.execute(HttpClientRequest.post(url).pipe(HttpClientRequest.setHeaders(transportHeaders()), HttpClientRequest.bodyText(body, "application/json"))).pipe(Effect.mapError((error) => protocolDefect(`MCP HTTP request to ${options.serverId} failed`, error)));
|
|
183
|
+
yield* Effect.addFinalizer(() => sessionId === void 0 ? Effect.void : client.execute(HttpClientRequest.delete(url).pipe(HttpClientRequest.setHeaders(transportHeaders()))).pipe(Effect.ignore));
|
|
184
|
+
return yield* RpcClient.Protocol.make((writeResponse) => Effect.sync(() => {
|
|
185
|
+
const encode = (message) => Effect.suspend(() => {
|
|
186
|
+
const encoded = parser.encode(message);
|
|
187
|
+
return typeof encoded === "string" ? Effect.succeed(encoded) : Effect.fail(protocolDefect("Could not encode an MCP JSON-RPC message"));
|
|
188
|
+
});
|
|
189
|
+
const deliver = (clientId, data) => Effect.suspend(() => {
|
|
190
|
+
let messages;
|
|
191
|
+
try {
|
|
192
|
+
messages = parser.decode(data);
|
|
193
|
+
} catch (cause) {
|
|
194
|
+
return writeResponse(clientId, {
|
|
195
|
+
_tag: "ClientProtocolError",
|
|
196
|
+
error: protocolDefect("Could not decode an MCP JSON-RPC message", cause)
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return Effect.forEach(messages, (message) => routeMessage(message, {
|
|
200
|
+
clientId,
|
|
201
|
+
writeResponse,
|
|
202
|
+
respond: (response) => encode(response).pipe(Effect.flatMap(post), Effect.ignore),
|
|
203
|
+
onExit: (exit) => {
|
|
204
|
+
answered.add(exit.requestId);
|
|
205
|
+
if (exit.requestId !== initializeRequestId || exit.exit._tag !== "Success") return;
|
|
206
|
+
const decoded = decodeInitializeProtocolVersion(exit.exit.value);
|
|
207
|
+
if (Option.isSome(decoded)) protocolVersion = decoded.value.protocolVersion;
|
|
208
|
+
}
|
|
209
|
+
}), { discard: true });
|
|
210
|
+
});
|
|
211
|
+
/**
|
|
212
|
+
* Posts one message and delivers whatever the server answers. A request
|
|
213
|
+
* whose HTTP exchange completes without a JSON-RPC response for its id
|
|
214
|
+
* (for example a `202`, an `id: null` error, or a stream that ends
|
|
215
|
+
* early) fails that request instead of leaving its caller waiting.
|
|
216
|
+
*/
|
|
217
|
+
const dispatch = Effect.fn("McpHttpTransport.dispatch")(function* (clientId, message, requestId) {
|
|
218
|
+
const response = yield* post(yield* encode(message));
|
|
219
|
+
const responseSession = response.headers[MCP_SESSION_ID_HEADER];
|
|
220
|
+
if (responseSession !== void 0) sessionId = responseSession;
|
|
221
|
+
if (response.status < 200 || response.status >= 300) return yield* protocolDefect(`MCP server ${options.serverId} answered HTTP ${response.status}`);
|
|
222
|
+
const contentType = response.headers["content-type"] ?? "";
|
|
223
|
+
if (response.status !== 202 && response.status !== 204) {
|
|
224
|
+
if (contentType.startsWith("text/event-stream")) yield* consumeEventStream(response, maxMessageBytes, (data) => deliver(clientId, data));
|
|
225
|
+
else {
|
|
226
|
+
const text = yield* readBoundedText(response, maxMessageBytes);
|
|
227
|
+
if (text.length > 0) yield* deliver(clientId, text);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (requestId !== void 0 && !answered.has(requestId)) yield* writeResponse(clientId, {
|
|
231
|
+
_tag: "Exit",
|
|
232
|
+
requestId,
|
|
233
|
+
exit: {
|
|
234
|
+
_tag: "Failure",
|
|
235
|
+
cause: [{
|
|
236
|
+
_tag: "Die",
|
|
237
|
+
defect: `MCP server ${options.serverId} closed the HTTP exchange without answering request ${String(requestId)}`
|
|
238
|
+
}]
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
answered.delete(requestId ?? "");
|
|
242
|
+
});
|
|
243
|
+
const send = (clientId, request) => {
|
|
244
|
+
switch (request._tag) {
|
|
245
|
+
case "Request":
|
|
246
|
+
if (isNotificationTag(request.tag)) return dispatch(clientId, {
|
|
247
|
+
...request,
|
|
248
|
+
isNotification: true
|
|
249
|
+
});
|
|
250
|
+
if (request.tag === "initialize") initializeRequestId = request.id;
|
|
251
|
+
return dispatch(clientId, request, request.id);
|
|
252
|
+
case "Interrupt": return dispatch(clientId, {
|
|
253
|
+
_tag: "Request",
|
|
254
|
+
id: request.requestId,
|
|
255
|
+
tag: "notifications/cancelled",
|
|
256
|
+
payload: { requestId: request.requestId },
|
|
257
|
+
headers: [],
|
|
258
|
+
isNotification: true
|
|
259
|
+
});
|
|
260
|
+
case "Ack":
|
|
261
|
+
case "Ping":
|
|
262
|
+
case "Eof": return Effect.void;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
return {
|
|
266
|
+
send,
|
|
267
|
+
supportsAck: false,
|
|
268
|
+
supportsTransferables: false,
|
|
269
|
+
codecFor: serialization.codecFor
|
|
270
|
+
};
|
|
271
|
+
}));
|
|
272
|
+
});
|
|
273
|
+
const makeStdioProtocol = Effect.fn("McpStdioTransport.protocol")(function* (options) {
|
|
274
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
275
|
+
const maxMessageBytes = options.maxMessageBytes ?? DEFAULT_MAX_MESSAGE_BYTES;
|
|
276
|
+
const serialization = RpcSerialization.ndJsonRpc({ maxBufferSize: maxMessageBytes });
|
|
277
|
+
const parser = serialization.makeUnsafe();
|
|
278
|
+
const handle = yield* spawner.spawn(ChildProcess.make(options.command, [...options.args ?? []], {
|
|
279
|
+
...options.cwd === void 0 ? {} : { cwd: options.cwd },
|
|
280
|
+
...options.env === void 0 ? {} : {
|
|
281
|
+
env: options.env,
|
|
282
|
+
extendEnv: true
|
|
283
|
+
}
|
|
284
|
+
})).pipe(Effect.mapError((cause) => McpConnectionError.make({
|
|
285
|
+
serverId: options.serverId,
|
|
286
|
+
message: `Could not start the MCP server process for ${options.serverId}`,
|
|
287
|
+
cause
|
|
288
|
+
})));
|
|
289
|
+
const outbound = yield* Queue.unbounded();
|
|
290
|
+
let closed;
|
|
291
|
+
const closedWith = (message, cause) => closed ??= protocolDefect(message, cause);
|
|
292
|
+
yield* Stream.fromQueue(outbound).pipe(Stream.encodeText, Stream.run(handle.stdin), Effect.matchCauseEffect({
|
|
293
|
+
onSuccess: () => Effect.sync(() => closedWith(`MCP server process ${options.serverId} closed stdin`)),
|
|
294
|
+
onFailure: (cause) => Cause.hasInterruptsOnly(cause) ? Effect.void : Effect.sync(() => closedWith(`Writing to MCP server process ${options.serverId} failed`, Cause.squash(cause)))
|
|
295
|
+
}), Effect.forkScoped);
|
|
296
|
+
yield* handle.stderr.pipe(Stream.decodeText(), Stream.splitLines, Stream.runForEach((line) => Effect.logDebug(line)), Effect.ignore, Effect.annotateLogs({
|
|
297
|
+
mcpServerId: options.serverId,
|
|
298
|
+
stream: "stderr"
|
|
299
|
+
}), Effect.forkScoped);
|
|
300
|
+
return yield* RpcClient.Protocol.make(Effect.fnUntraced(function* (writeResponse, clientIds) {
|
|
301
|
+
const broadcast = (error) => Effect.forEach(clientIds, (clientId) => writeResponse(clientId, {
|
|
302
|
+
_tag: "ClientProtocolError",
|
|
303
|
+
error
|
|
304
|
+
}), { discard: true });
|
|
305
|
+
const deliver = (chunk) => Effect.suspend(() => {
|
|
306
|
+
let messages;
|
|
307
|
+
try {
|
|
308
|
+
messages = parser.decode(chunk);
|
|
309
|
+
} catch (cause) {
|
|
310
|
+
return broadcast(protocolDefect("Could not decode an MCP stdio frame", cause));
|
|
311
|
+
}
|
|
312
|
+
return Effect.forEach(messages, (message) => Effect.forEach(clientIds, (clientId) => routeMessage(message, {
|
|
313
|
+
clientId,
|
|
314
|
+
writeResponse,
|
|
315
|
+
respond: (response) => enqueue(response).pipe(Effect.ignore),
|
|
316
|
+
onExit: () => {}
|
|
317
|
+
}), { discard: true }), { discard: true });
|
|
318
|
+
});
|
|
319
|
+
const enqueue = (message) => Effect.suspend(() => {
|
|
320
|
+
if (closed !== void 0) return Effect.fail(closed);
|
|
321
|
+
const encoded = parser.encode(message);
|
|
322
|
+
if (typeof encoded !== "string") return Effect.fail(protocolDefect("Could not encode an MCP JSON-RPC message"));
|
|
323
|
+
return Queue.offer(outbound, encoded).pipe(Effect.asVoid);
|
|
324
|
+
});
|
|
325
|
+
yield* handle.stdout.pipe(Stream.runForEach(deliver), Effect.matchCauseEffect({
|
|
326
|
+
onSuccess: () => broadcast(closedWith(`MCP server process ${options.serverId} closed stdout`)),
|
|
327
|
+
onFailure: (cause) => Cause.hasInterruptsOnly(cause) ? Effect.void : broadcast(closedWith(`Reading MCP server process ${options.serverId} failed`, Cause.squash(cause)))
|
|
328
|
+
}), Effect.forkScoped);
|
|
329
|
+
const send = (_clientId, request) => {
|
|
330
|
+
switch (request._tag) {
|
|
331
|
+
case "Request": return enqueue(isNotificationTag(request.tag) ? {
|
|
332
|
+
...request,
|
|
333
|
+
isNotification: true
|
|
334
|
+
} : request);
|
|
335
|
+
case "Interrupt": return enqueue({
|
|
336
|
+
_tag: "Request",
|
|
337
|
+
id: request.requestId,
|
|
338
|
+
tag: "notifications/cancelled",
|
|
339
|
+
payload: { requestId: request.requestId },
|
|
340
|
+
headers: [],
|
|
341
|
+
isNotification: true
|
|
342
|
+
});
|
|
343
|
+
case "Ack":
|
|
344
|
+
case "Ping":
|
|
345
|
+
case "Eof": return Effect.void;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
return {
|
|
349
|
+
send,
|
|
350
|
+
supportsAck: false,
|
|
351
|
+
supportsTransferables: false,
|
|
352
|
+
codecFor: serialization.codecFor
|
|
353
|
+
};
|
|
354
|
+
}));
|
|
355
|
+
});
|
|
356
|
+
/** Streamable HTTP transport for one remote MCP server; requires `HttpClient`. */
|
|
357
|
+
const McpHttpTransport = { make: (options) => ({
|
|
358
|
+
serverId: options.serverId,
|
|
359
|
+
trustToolAnnotations: options.trustToolAnnotations ?? false,
|
|
360
|
+
protocol: makeHttpProtocol(options)
|
|
361
|
+
}) };
|
|
362
|
+
/** stdio transport for one local MCP server process; requires `ChildProcessSpawner`. */
|
|
363
|
+
const McpStdioTransport = { make: (options) => ({
|
|
364
|
+
serverId: options.serverId,
|
|
365
|
+
trustToolAnnotations: options.trustToolAnnotations ?? false,
|
|
366
|
+
protocol: makeStdioProtocol(options)
|
|
367
|
+
}) };
|
|
368
|
+
const executionClassFor = (annotations) => {
|
|
369
|
+
if (annotations === void 0) return "uncertain";
|
|
370
|
+
if (annotations.readOnlyHint) return "readonly";
|
|
371
|
+
if (annotations.idempotentHint && !annotations.destructiveHint) return "idempotent";
|
|
372
|
+
return "uncertain";
|
|
373
|
+
};
|
|
374
|
+
const makeMcpTool = (tool, trustToolAnnotations) => {
|
|
375
|
+
let dynamic = Tool.dynamic(tool.name, {
|
|
376
|
+
...tool.description === void 0 ? {} : { description: tool.description },
|
|
377
|
+
parameters: tool.inputSchema,
|
|
378
|
+
success: McpToolResult,
|
|
379
|
+
failure: McpToolCallFailed,
|
|
380
|
+
failureMode: "return"
|
|
381
|
+
});
|
|
382
|
+
const title = tool.title ?? tool.annotations?.title;
|
|
383
|
+
if (title !== void 0) dynamic = dynamic.annotate(Tool.Title, title);
|
|
384
|
+
dynamic = dynamic.annotate(McpToolOutputSchema, Option.fromNullishOr(tool.outputSchema));
|
|
385
|
+
if (tool.annotations !== void 0) dynamic = dynamic.annotate(Tool.Readonly, tool.annotations.readOnlyHint).annotate(Tool.Destructive, tool.annotations.destructiveHint).annotate(Tool.Idempotent, tool.annotations.idempotentHint).annotate(Tool.OpenWorld, tool.annotations.openWorldHint);
|
|
386
|
+
if (trustToolAnnotations) dynamic = dynamic.annotate(ToolExecutionClass, executionClassFor(tool.annotations));
|
|
387
|
+
return dynamic;
|
|
388
|
+
};
|
|
389
|
+
const ToolArguments = Schema.Record(Schema.String, Schema.Json);
|
|
390
|
+
const decodeToolArguments = Schema.decodeUnknownEffect(ToolArguments);
|
|
391
|
+
const errorText = (content) => content.flatMap((block) => block.type === "text" ? [block.text] : []).join("\n").slice(0, 4096);
|
|
392
|
+
const describeDefect = (defect) => (Predicate.hasProperty(defect, "message") && Predicate.isString(defect.message) ? defect.message : String(defect)).slice(0, 4096);
|
|
393
|
+
const connectionError = (serverId, message) => (cause) => McpConnectionError.make({
|
|
394
|
+
serverId,
|
|
395
|
+
message,
|
|
396
|
+
cause
|
|
397
|
+
});
|
|
398
|
+
/**
|
|
399
|
+
* Keeps every non-interrupt outcome of one protocol step typed: expected
|
|
400
|
+
* failures and defects (such as an undecodable server reply) both become the
|
|
401
|
+
* connection error, so a misbehaving server cannot crash the connector.
|
|
402
|
+
*/
|
|
403
|
+
const failClosed = (serverId, message) => (self) => self.pipe(Effect.mapError(connectionError(serverId, message)), Effect.catchDefect((defect) => Effect.fail(connectionError(serverId, message)(defect))));
|
|
404
|
+
const connectServer = Effect.fn("McpClient.connect")(function* (transport, request, clientInfo) {
|
|
405
|
+
const serverId = transport.serverId;
|
|
406
|
+
const protocol = yield* transport.protocol;
|
|
407
|
+
const client = yield* RpcClient.make(McpSchema.ClientRpcs, {
|
|
408
|
+
spanPrefix: "McpClient",
|
|
409
|
+
spanAttributes: { "mcp.server_id": serverId }
|
|
410
|
+
}).pipe(Effect.provideService(RpcClient.Protocol, protocol));
|
|
411
|
+
const initialized = yield* client.initialize({
|
|
412
|
+
protocolVersion: OFFERED_PROTOCOL_VERSION,
|
|
413
|
+
capabilities: McpSchema.ClientCapabilities.make({}),
|
|
414
|
+
clientInfo
|
|
415
|
+
}).pipe(failClosed(serverId, `MCP initialize with ${serverId} failed`));
|
|
416
|
+
const negotiated = yield* Schema.decodeUnknownEffect(McpClientProtocolVersion)(initialized.protocolVersion).pipe(Effect.mapError(connectionError(serverId, `MCP server ${serverId} negotiated unsupported protocol version '${initialized.protocolVersion}'`)));
|
|
417
|
+
yield* Effect.annotateCurrentSpan({ "mcp.protocol_version": negotiated });
|
|
418
|
+
yield* client["notifications/initialized"](void 0, { discard: true }).pipe(failClosed(serverId, `Could not acknowledge MCP initialization with ${serverId}`));
|
|
419
|
+
const tools = [];
|
|
420
|
+
let cursor;
|
|
421
|
+
let pages = 0;
|
|
422
|
+
do {
|
|
423
|
+
const page = yield* client["tools/list"](cursor === void 0 ? void 0 : McpSchema.PaginatedRequestMeta.make({ cursor })).pipe(failClosed(serverId, `MCP tools/list with ${serverId} failed`));
|
|
424
|
+
tools.push(...page.tools);
|
|
425
|
+
cursor = page.nextCursor;
|
|
426
|
+
pages += 1;
|
|
427
|
+
if (tools.length > request.maxToolCount) break;
|
|
428
|
+
if (cursor !== void 0 && pages >= MAX_TOOL_LIST_PAGES) return yield* McpConnectionError.make({
|
|
429
|
+
serverId,
|
|
430
|
+
message: `MCP server ${serverId} paginated tools/list beyond ${MAX_TOOL_LIST_PAGES} pages`
|
|
431
|
+
});
|
|
432
|
+
} while (cursor !== void 0);
|
|
433
|
+
const callTool = Effect.fn("McpClient.callTool")(function* (name, params) {
|
|
434
|
+
const args = yield* decodeToolArguments(params ?? {}).pipe(Effect.mapError((cause) => McpToolCallFailed.make({
|
|
435
|
+
serverId,
|
|
436
|
+
tool: name,
|
|
437
|
+
reason: "invalid-arguments",
|
|
438
|
+
message: `MCP tool arguments must be a JSON object: ${cause.message}`
|
|
439
|
+
})));
|
|
440
|
+
const result = yield* client["tools/call"]({
|
|
441
|
+
name,
|
|
442
|
+
arguments: args
|
|
443
|
+
}).pipe(Effect.mapError((error) => McpToolCallFailed.make({
|
|
444
|
+
serverId,
|
|
445
|
+
tool: name,
|
|
446
|
+
reason: isRpcClientError(error) ? "transport" : "protocol-error",
|
|
447
|
+
message: error.message
|
|
448
|
+
})), Effect.catchDefect((defect) => Effect.fail(McpToolCallFailed.make({
|
|
449
|
+
serverId,
|
|
450
|
+
tool: name,
|
|
451
|
+
reason: "protocol-error",
|
|
452
|
+
message: describeDefect(defect)
|
|
453
|
+
}))));
|
|
454
|
+
if (result.isError === true) return yield* McpToolCallFailed.make({
|
|
455
|
+
serverId,
|
|
456
|
+
tool: name,
|
|
457
|
+
reason: "tool-error",
|
|
458
|
+
message: errorText(result.content),
|
|
459
|
+
content: result.content
|
|
460
|
+
});
|
|
461
|
+
return McpToolResult.make({
|
|
462
|
+
content: result.content,
|
|
463
|
+
...result.structuredContent === void 0 ? {} : { structuredContent: result.structuredContent }
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
const toolkit = yield* Effect.try({
|
|
467
|
+
try: () => Toolkit.make(...tools.map((tool) => makeMcpTool(tool, transport.trustToolAnnotations))),
|
|
468
|
+
catch: connectionError(serverId, `MCP server ${serverId} advertised tools that cannot form a Toolkit`)
|
|
469
|
+
});
|
|
470
|
+
const handlers = toolkit.toLayer(Object.fromEntries(tools.map((tool) => [tool.name, (params) => callTool(tool.name, params)])));
|
|
471
|
+
return {
|
|
472
|
+
identity: McpServerIdentity.make({
|
|
473
|
+
serverId,
|
|
474
|
+
implementation: initialized.serverInfo
|
|
475
|
+
}),
|
|
476
|
+
capabilities: initialized.capabilities,
|
|
477
|
+
tools,
|
|
478
|
+
toolkit,
|
|
479
|
+
handlers
|
|
480
|
+
};
|
|
481
|
+
});
|
|
482
|
+
const makeConnectorLayer = (transports, options) => Layer.effect(McpConnector)(Effect.gen(function* () {
|
|
483
|
+
const services = yield* Effect.context();
|
|
484
|
+
const byServerId = new Map(transports.map((transport) => [transport.serverId, transport]));
|
|
485
|
+
const clientInfo = options?.clientInfo ?? defaultMcpClientInfo;
|
|
486
|
+
return McpConnector.of({ connect: (request) => {
|
|
487
|
+
const transport = byServerId.get(request.serverId);
|
|
488
|
+
if (transport === void 0) return Effect.fail(McpConnectionError.make({
|
|
489
|
+
serverId: request.serverId,
|
|
490
|
+
message: `No MCP transport is configured for server '${request.serverId}'`
|
|
491
|
+
}));
|
|
492
|
+
return connectServer(transport, request, clientInfo).pipe(Effect.updateContext((caller) => Context.merge(Context.merge(caller, services), Context.pick(Scope.Scope)(caller))));
|
|
493
|
+
} });
|
|
494
|
+
}));
|
|
495
|
+
/**
|
|
496
|
+
* `McpConnector` over real transports. Each `connect` acquires the transport
|
|
497
|
+
* in the caller's Scope, negotiates a protocol revision, lists tools within the
|
|
498
|
+
* request bounds, and returns dynamic Effect AI Tools plus the handler Layer
|
|
499
|
+
* that forwards their calls. The Layer requires the union of every
|
|
500
|
+
* transport's platform services.
|
|
501
|
+
*/
|
|
502
|
+
const layer = (transports, options) => makeConnectorLayer(transports, options);
|
|
503
|
+
//#endregion
|
|
504
|
+
export { McpClientProtocolVersion, McpHttpTransport, McpStdioTransport, McpToolCallFailed, McpToolResult, defaultMcpClientInfo, layer, McpClient_exports as t };
|
|
505
|
+
|
|
506
|
+
//# sourceMappingURL=McpClient.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpClient.mjs","names":[],"sources":["../../src/capabilities/McpClient.ts"],"sourcesContent":["import {\n Cause,\n Context,\n Effect,\n Layer,\n Option,\n Predicate,\n Queue,\n Schema,\n Scope,\n Stream,\n} from \"effect\";\nimport { Tool, Toolkit } from \"effect/unstable/ai\";\nimport * as McpProtocol from \"effect/unstable/ai/McpProtocol\";\nimport * as McpSchema from \"effect/unstable/ai/McpSchema\";\nimport {\n Headers,\n HttpClient,\n HttpClientRequest,\n type HttpClientResponse,\n} from \"effect/unstable/http\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/unstable/process\";\nimport { RpcClient, RpcClientError, type RpcMessage, RpcSerialization } from \"effect/unstable/rpc\";\n\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { ToolExecutionClass, type ToolExecutionClassValue } from \"../engine/DurableStep.ts\";\nimport {\n McpConnectionError,\n McpConnector,\n type McpConnectedServer,\n type McpConnectionRequest,\n McpServerIdentity,\n McpToolOutputSchema,\n} from \"./Mcp.ts\";\n\n// ---------------------------------------------------------------------------\n// MCP client: native Effect AI MCP schemas and protocol adapters, the Effect\n// RPC client, and Effect HTTP / child-process services connect an Agent to a\n// remote MCP server. Discovered tools become dynamic Effect AI Tools whose\n// handlers forward `tools/call`; `connectMcp` still applies every discovery\n// bound before the Toolkit reaches Agent context.\n// ---------------------------------------------------------------------------\n\n/** Largest single JSON-RPC message a transport accepts from a server by default. */\nconst DEFAULT_MAX_MESSAGE_BYTES = 4 * 1024 * 1024;\n/** Bounded `tools/list` pagination: a server cannot keep a client walking cursors forever. */\nconst MAX_TOOL_LIST_PAGES = 64;\nconst MCP_SESSION_ID_HEADER = \"mcp-session-id\";\nconst MCP_PROTOCOL_VERSION_HEADER = \"mcp-protocol-version\";\nconst JSON_RPC_METHOD_NOT_FOUND = -32601;\n\n/**\n * The protocol revisions this client negotiates, as implemented by Effect AI's\n * native MCP protocol adapters. The newest revision is offered first; a server\n * answering with any other listed revision is accepted, anything else fails.\n */\nexport const McpClientProtocolVersion = Schema.Literals([\n McpProtocol.v2025_11_25.protocolVersion,\n McpProtocol.v2025_06_18.protocolVersion,\n McpProtocol.v2025_03_26.protocolVersion,\n McpProtocol.v2024_11_05.protocolVersion,\n]);\n\nexport type McpClientProtocolVersion = typeof McpClientProtocolVersion.Type;\n\nconst OFFERED_PROTOCOL_VERSION: McpClientProtocolVersion = McpProtocol.v2025_11_25.protocolVersion;\n\n/** Identity this client presents to servers during `initialize`. */\nexport const defaultMcpClientInfo = McpSchema.Implementation.make({\n name: \"effect-agent\",\n version: \"1.0.0\",\n});\n\n/**\n * The model-visible result of a remote MCP tool call: the server's content\n * blocks and, when the tool declares an `outputSchema`, its structured result.\n * A result with `isError` never becomes this value; it fails the Tool Call.\n */\nexport class McpToolResult extends Schema.Class<McpToolResult>(\n \"@effect-agent/capabilities/McpToolResult\",\n)({\n content: Schema.Array(McpSchema.ContentBlock),\n structuredContent: Schema.optionalKey(Schema.Json),\n}) {}\n\n/**\n * Typed failure of one remote MCP tool call. `tool-error` carries the server's\n * error content; the other reasons describe why no trustworthy result exists.\n * None of them claims the remote effect did not happen.\n */\nexport class McpToolCallFailed extends Schema.TaggedError<McpToolCallFailed>()(\n \"McpToolCallFailed\",\n {\n serverId: Schema.NonEmptyString,\n tool: Schema.NonEmptyString,\n reason: Schema.Literals([\"tool-error\", \"invalid-arguments\", \"protocol-error\", \"transport\"]),\n message: Schema.String,\n content: Schema.optionalKey(Schema.Array(McpSchema.ContentBlock)),\n },\n) {}\n\n/**\n * One reachable MCP server. `protocol` acquires a JSON-RPC transport in the\n * caller's Scope; `R` names the platform services that transport needs so the\n * connector Layer keeps them in its requirements.\n */\nexport interface McpServerTransport<R = never> {\n readonly serverId: string;\n /**\n * Whether the server's `readOnlyHint`, `idempotentHint`, and\n * `destructiveHint` may set the framework execution class of its tools.\n * Hints are server-declared and untrusted, so the default leaves every\n * remote tool `uncertain`.\n */\n readonly trustToolAnnotations: boolean;\n readonly protocol: Effect.Effect<\n RpcClient.Protocol[\"Service\"],\n McpConnectionError,\n Scope.Scope | R\n >;\n}\n\n/** Streamable HTTP server address. Header values may carry credentials the application owns. */\nexport interface McpHttpTransportOptions {\n readonly serverId: string;\n readonly url: string;\n readonly headers?: Headers.Input | undefined;\n /** Largest accepted response message. Defaults to 4 MiB. */\n readonly maxMessageBytes?: number | undefined;\n readonly trustToolAnnotations?: boolean | undefined;\n}\n\n/** A local MCP server process speaking newline-delimited JSON-RPC on stdio. */\nexport interface McpStdioTransportOptions {\n readonly serverId: string;\n readonly command: string;\n readonly args?: ReadonlyArray<string> | undefined;\n readonly cwd?: string | undefined;\n readonly env?: Readonly<Record<string, string>> | undefined;\n /** Largest accepted stdout frame. Defaults to 4 MiB. */\n readonly maxMessageBytes?: number | undefined;\n readonly trustToolAnnotations?: boolean | undefined;\n}\n\nconst isNotificationTag = (tag: string): boolean => tag.startsWith(\"notifications/\");\nconst isRpcClientError = Schema.is(RpcClientError.RpcClientError);\n\nconst protocolDefect = (message: string, cause?: unknown): RpcClientError.RpcClientError =>\n new RpcClientError.RpcClientError({\n reason: new RpcClientError.RpcClientDefect({ message, cause }),\n });\n\nconst InitializeProtocolVersion = Schema.Struct({ protocolVersion: Schema.String });\nconst decodeInitializeProtocolVersion = Schema.decodeUnknownOption(InitializeProtocolVersion);\n\nconst ServerRequest = Schema.Struct({ _tag: Schema.Literal(\"Request\"), tag: Schema.String });\nconst isServerRequest = Schema.is(ServerRequest);\n\nconst isJsonRpcRequest = (message: unknown): message is RpcMessage.RequestEncoded =>\n isServerRequest(message);\n\n/** JSON-RPC error a client returns for a server-initiated request it does not serve. */\nconst declineServerRequest = (\n request: RpcMessage.RequestEncoded,\n): RpcMessage.ResponseExitEncoded => ({\n _tag: \"Exit\",\n requestId: request.id,\n exit: {\n _tag: \"Failure\",\n cause: [\n {\n _tag: \"Fail\",\n error: {\n code: JSON_RPC_METHOD_NOT_FOUND,\n message: `Client does not serve ${request.tag}`,\n },\n },\n ],\n },\n});\n\n/**\n * Routes one decoded JSON-RPC message. Responses reach the RPC client; server\n * notifications are logged; server requests (sampling, elicitation, roots)\n * are declined fail-closed through `respond` because this client serves none.\n */\nconst routeMessage = (\n message: unknown,\n options: {\n readonly clientId: number;\n readonly writeResponse: (\n clientId: number,\n response: RpcMessage.FromServerEncoded,\n ) => Effect.Effect<void>;\n readonly respond: (response: RpcMessage.ResponseExitEncoded) => Effect.Effect<void>;\n readonly onExit: (exit: RpcMessage.ResponseExitEncoded) => void;\n },\n): Effect.Effect<void> => {\n if (isJsonRpcRequest(message)) {\n if (message.isNotification === true) {\n return Effect.logDebug(\"Ignoring MCP server notification\").pipe(\n Effect.annotateLogs({ method: message.tag }),\n );\n }\n\n return options.respond(declineServerRequest(message));\n }\n if (Predicate.hasProperty(message, \"_tag\") && message._tag === \"Exit\") {\n options.onExit(message as RpcMessage.ResponseExitEncoded);\n }\n\n return options.writeResponse(options.clientId, message as RpcMessage.FromServerEncoded);\n};\n\n/** Reads a response body as text while refusing bodies above `maxBytes`. */\nconst readBoundedText = Effect.fn(\"McpHttpTransport.readBoundedText\")(function* (\n response: HttpClientResponse.HttpClientResponse,\n maxBytes: number,\n) {\n const declared = Number(response.headers[\"content-length\"]);\n\n if (Number.isFinite(declared) && declared > maxBytes) {\n return yield* protocolDefect(\n `MCP response of ${declared} bytes exceeds the ${maxBytes} byte message bound`,\n );\n }\n const chunks: Array<string> = [];\n let received = 0;\n\n yield* response.stream.pipe(\n Stream.decodeText(),\n Stream.runForEach((chunk) => {\n received += utf8ByteLength(chunk);\n if (received > maxBytes) {\n return Effect.fail(\n protocolDefect(`MCP response exceeds the ${maxBytes} byte message bound`),\n );\n }\n chunks.push(chunk);\n\n return Effect.void;\n }),\n Effect.mapError((error) =>\n isRpcClientError(error)\n ? error\n : protocolDefect(\"Could not read the MCP HTTP response\", error),\n ),\n );\n\n return chunks.join(\"\");\n});\n\n/**\n * Delivers the `data` of each `text/event-stream` event as it arrives. Only\n * `data` fields carry JSON-RPC messages; `event`, `id`, `retry`, and comment\n * lines are ignored because this client never resumes a stream, so a server\n * retry directive neither ends the stream nor fails the request. At most\n * `maxBytes` of an unterminated event stays buffered.\n */\nconst consumeEventStream = Effect.fn(\"McpHttpTransport.consumeEventStream\")(function* (\n response: HttpClientResponse.HttpClientResponse,\n maxBytes: number,\n deliver: (data: string) => Effect.Effect<void>,\n) {\n let buffer = \"\";\n let pendingBytes = 0;\n\n const dispatchEvent = (block: string): Effect.Effect<void> => {\n const data = block\n .split(/\\r?\\n/)\n .filter((line) => line.startsWith(\"data:\"))\n .map((line) => line.slice(\"data:\".length).replace(/^ /, \"\"))\n .join(\"\\n\");\n\n return data.length === 0 ? Effect.void : deliver(data);\n };\n\n const drain = (final: boolean): Effect.Effect<void> =>\n Effect.suspend(() => {\n const blocks: Array<string> = [];\n\n while (true) {\n const match = /\\r?\\n\\r?\\n/.exec(buffer);\n\n if (match === null) break;\n blocks.push(buffer.slice(0, match.index));\n buffer = buffer.slice(match.index + match[0].length);\n }\n if (final && buffer.length > 0) {\n blocks.push(buffer);\n buffer = \"\";\n }\n pendingBytes = utf8ByteLength(buffer);\n\n return Effect.forEach(blocks, dispatchEvent, { discard: true });\n });\n\n yield* response.stream.pipe(\n Stream.decodeText(),\n Stream.runForEach((chunk) => {\n buffer += chunk;\n pendingBytes += utf8ByteLength(chunk);\n if (pendingBytes > maxBytes) {\n return Effect.fail(protocolDefect(`MCP event stream buffered more than ${maxBytes} bytes`));\n }\n\n return drain(false);\n }),\n Effect.mapError((error) =>\n isRpcClientError(error)\n ? error\n : protocolDefect(\"Could not read the MCP event stream\", error),\n ),\n );\n yield* drain(true);\n});\n\nconst makeHttpProtocol = Effect.fn(\"McpHttpTransport.protocol\")(function* (\n options: McpHttpTransportOptions,\n) {\n const client = yield* HttpClient.HttpClient;\n const serialization = RpcSerialization.jsonRpc();\n const parser = serialization.makeUnsafe();\n const maxMessageBytes = options.maxMessageBytes ?? DEFAULT_MAX_MESSAGE_BYTES;\n const configuredHeaders = Headers.fromInput(options.headers);\n const url = options.url;\n let sessionId: string | undefined;\n let protocolVersion: string | undefined;\n let initializeRequestId: string | number | undefined;\n /** Request ids whose JSON-RPC response has been delivered. */\n const answered = new Set<string | number>();\n\n const transportHeaders = (): Headers.Headers =>\n Headers.merge(\n configuredHeaders,\n Headers.fromInput({\n accept: \"application/json, text/event-stream\",\n ...(sessionId === undefined ? {} : { [MCP_SESSION_ID_HEADER]: sessionId }),\n ...(protocolVersion === undefined\n ? {}\n : { [MCP_PROTOCOL_VERSION_HEADER]: protocolVersion }),\n }),\n );\n\n const post = (body: string) =>\n client\n .execute(\n HttpClientRequest.post(url).pipe(\n HttpClientRequest.setHeaders(transportHeaders()),\n HttpClientRequest.bodyText(body, \"application/json\"),\n ),\n )\n .pipe(\n Effect.mapError((error) =>\n protocolDefect(`MCP HTTP request to ${options.serverId} failed`, error),\n ),\n );\n\n // Ending the session is a courtesy to the server; the Scope owns the client.\n yield* Effect.addFinalizer(() =>\n sessionId === undefined\n ? Effect.void\n : client\n .execute(\n HttpClientRequest.delete(url).pipe(HttpClientRequest.setHeaders(transportHeaders())),\n )\n .pipe(Effect.ignore),\n );\n\n return yield* RpcClient.Protocol.make((writeResponse) =>\n Effect.sync(() => {\n const encode = (message: unknown): Effect.Effect<string, RpcClientError.RpcClientError> =>\n Effect.suspend(() => {\n const encoded = parser.encode(message);\n\n return typeof encoded === \"string\"\n ? Effect.succeed(encoded)\n : Effect.fail(protocolDefect(\"Could not encode an MCP JSON-RPC message\"));\n });\n\n const deliver = (clientId: number, data: string): Effect.Effect<void> =>\n Effect.suspend(() => {\n let messages: ReadonlyArray<unknown>;\n\n try {\n messages = parser.decode(data);\n } catch (cause) {\n return writeResponse(clientId, {\n _tag: \"ClientProtocolError\",\n error: protocolDefect(\"Could not decode an MCP JSON-RPC message\", cause),\n });\n }\n\n return Effect.forEach(\n messages,\n (message) =>\n routeMessage(message, {\n clientId,\n writeResponse,\n respond: (response) => encode(response).pipe(Effect.flatMap(post), Effect.ignore),\n onExit: (exit) => {\n answered.add(exit.requestId);\n if (exit.requestId !== initializeRequestId || exit.exit._tag !== \"Success\") {\n return;\n }\n const decoded = decodeInitializeProtocolVersion(exit.exit.value);\n\n if (Option.isSome(decoded)) protocolVersion = decoded.value.protocolVersion;\n },\n }),\n { discard: true },\n );\n });\n\n /**\n * Posts one message and delivers whatever the server answers. A request\n * whose HTTP exchange completes without a JSON-RPC response for its id\n * (for example a `202`, an `id: null` error, or a stream that ends\n * early) fails that request instead of leaving its caller waiting.\n */\n const dispatch = Effect.fn(\"McpHttpTransport.dispatch\")(function* (\n clientId: number,\n message: unknown,\n requestId?: string | number,\n ) {\n const response = yield* post(yield* encode(message));\n const responseSession = response.headers[MCP_SESSION_ID_HEADER];\n\n if (responseSession !== undefined) sessionId = responseSession;\n if (response.status < 200 || response.status >= 300) {\n return yield* protocolDefect(\n `MCP server ${options.serverId} answered HTTP ${response.status}`,\n );\n }\n const contentType = response.headers[\"content-type\"] ?? \"\";\n\n if (response.status !== 202 && response.status !== 204) {\n if (contentType.startsWith(\"text/event-stream\")) {\n yield* consumeEventStream(response, maxMessageBytes, (data) => deliver(clientId, data));\n } else {\n const text = yield* readBoundedText(response, maxMessageBytes);\n\n if (text.length > 0) yield* deliver(clientId, text);\n }\n }\n if (requestId !== undefined && !answered.has(requestId)) {\n yield* writeResponse(clientId, {\n _tag: \"Exit\",\n requestId,\n exit: {\n _tag: \"Failure\",\n cause: [\n {\n _tag: \"Die\",\n defect: `MCP server ${options.serverId} closed the HTTP exchange without answering request ${String(requestId)}`,\n },\n ],\n },\n });\n }\n answered.delete(requestId ?? \"\");\n });\n\n const send: RpcClient.Protocol[\"Service\"][\"send\"] = (clientId, request) => {\n switch (request._tag) {\n case \"Request\": {\n if (isNotificationTag(request.tag)) {\n return dispatch(clientId, { ...request, isNotification: true });\n }\n if (request.tag === \"initialize\") initializeRequestId = request.id;\n\n return dispatch(clientId, request, request.id);\n }\n case \"Interrupt\": {\n return dispatch(clientId, {\n _tag: \"Request\",\n id: request.requestId,\n tag: \"notifications/cancelled\",\n payload: { requestId: request.requestId },\n headers: [],\n isNotification: true,\n } satisfies RpcMessage.RequestEncoded);\n }\n case \"Ack\":\n case \"Ping\":\n case \"Eof\": {\n return Effect.void;\n }\n }\n };\n\n return {\n send,\n supportsAck: false,\n supportsTransferables: false,\n codecFor: serialization.codecFor,\n };\n }),\n );\n});\n\nconst makeStdioProtocol = Effect.fn(\"McpStdioTransport.protocol\")(function* (\n options: McpStdioTransportOptions,\n) {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const maxMessageBytes = options.maxMessageBytes ?? DEFAULT_MAX_MESSAGE_BYTES;\n const serialization = RpcSerialization.ndJsonRpc({ maxBufferSize: maxMessageBytes });\n const parser = serialization.makeUnsafe();\n\n const handle = yield* spawner\n .spawn(\n ChildProcess.make(options.command, [...(options.args ?? [])], {\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n ...(options.env === undefined ? {} : { env: options.env, extendEnv: true }),\n }),\n )\n .pipe(\n Effect.mapError((cause) =>\n McpConnectionError.make({\n serverId: options.serverId,\n message: `Could not start the MCP server process for ${options.serverId}`,\n cause,\n }),\n ),\n );\n\n const outbound = yield* Queue.unbounded<string>();\n // Once the process is gone every later send fails immediately instead of\n // queueing behind a writer that no longer exists.\n let closed: RpcClientError.RpcClientError | undefined;\n\n const closedWith = (message: string, cause?: unknown): RpcClientError.RpcClientError =>\n (closed ??= protocolDefect(message, cause));\n\n yield* Stream.fromQueue(outbound).pipe(\n Stream.encodeText,\n Stream.run(handle.stdin),\n Effect.matchCauseEffect({\n onSuccess: () =>\n Effect.sync(() => closedWith(`MCP server process ${options.serverId} closed stdin`)),\n onFailure: (cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.void\n : Effect.sync(() =>\n closedWith(\n `Writing to MCP server process ${options.serverId} failed`,\n Cause.squash(cause),\n ),\n ),\n }),\n Effect.forkScoped,\n );\n yield* handle.stderr.pipe(\n Stream.decodeText(),\n Stream.splitLines,\n Stream.runForEach((line) => Effect.logDebug(line)),\n Effect.ignore,\n Effect.annotateLogs({ mcpServerId: options.serverId, stream: \"stderr\" }),\n Effect.forkScoped,\n );\n\n return yield* RpcClient.Protocol.make(\n Effect.fnUntraced(function* (writeResponse, clientIds) {\n const broadcast = (error: RpcClientError.RpcClientError) =>\n Effect.forEach(\n clientIds,\n (clientId) => writeResponse(clientId, { _tag: \"ClientProtocolError\", error }),\n { discard: true },\n );\n\n const deliver = (chunk: Uint8Array): Effect.Effect<void> =>\n Effect.suspend(() => {\n let messages: ReadonlyArray<unknown>;\n\n try {\n messages = parser.decode(chunk);\n } catch (cause) {\n return broadcast(protocolDefect(\"Could not decode an MCP stdio frame\", cause));\n }\n\n return Effect.forEach(\n messages,\n (message) =>\n Effect.forEach(\n clientIds,\n (clientId) =>\n routeMessage(message, {\n clientId,\n writeResponse,\n respond: (response) => enqueue(response).pipe(Effect.ignore),\n onExit: () => {},\n }),\n { discard: true },\n ),\n { discard: true },\n );\n });\n\n const enqueue = (message: unknown): Effect.Effect<void, RpcClientError.RpcClientError> =>\n Effect.suspend(() => {\n if (closed !== undefined) return Effect.fail(closed);\n const encoded = parser.encode(message);\n\n if (typeof encoded !== \"string\") {\n return Effect.fail(protocolDefect(\"Could not encode an MCP JSON-RPC message\"));\n }\n\n return Queue.offer(outbound, encoded).pipe(Effect.asVoid);\n });\n\n yield* handle.stdout.pipe(\n Stream.runForEach(deliver),\n Effect.matchCauseEffect({\n onSuccess: () =>\n broadcast(closedWith(`MCP server process ${options.serverId} closed stdout`)),\n onFailure: (cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.void\n : broadcast(\n closedWith(\n `Reading MCP server process ${options.serverId} failed`,\n Cause.squash(cause),\n ),\n ),\n }),\n Effect.forkScoped,\n );\n\n const send: RpcClient.Protocol[\"Service\"][\"send\"] = (_clientId, request) => {\n switch (request._tag) {\n case \"Request\": {\n return enqueue(\n isNotificationTag(request.tag) ? { ...request, isNotification: true } : request,\n );\n }\n case \"Interrupt\": {\n return enqueue({\n _tag: \"Request\",\n id: request.requestId,\n tag: \"notifications/cancelled\",\n payload: { requestId: request.requestId },\n headers: [],\n isNotification: true,\n } satisfies RpcMessage.RequestEncoded);\n }\n case \"Ack\":\n case \"Ping\":\n case \"Eof\": {\n return Effect.void;\n }\n }\n };\n\n return {\n send,\n supportsAck: false,\n supportsTransferables: false,\n codecFor: serialization.codecFor,\n };\n }),\n );\n});\n\n/** Streamable HTTP transport for one remote MCP server; requires `HttpClient`. */\nexport const McpHttpTransport = {\n make: (options: McpHttpTransportOptions): McpServerTransport<HttpClient.HttpClient> => ({\n serverId: options.serverId,\n trustToolAnnotations: options.trustToolAnnotations ?? false,\n protocol: makeHttpProtocol(options),\n }),\n} as const;\n\n/** stdio transport for one local MCP server process; requires `ChildProcessSpawner`. */\nexport const McpStdioTransport = {\n make: (\n options: McpStdioTransportOptions,\n ): McpServerTransport<ChildProcessSpawner.ChildProcessSpawner> => ({\n serverId: options.serverId,\n trustToolAnnotations: options.trustToolAnnotations ?? false,\n protocol: makeStdioProtocol(options),\n }),\n} as const;\n\n/**\n * Effect AI Tool derived from one discovered MCP tool. Its parameters are the\n * server's JSON Schema, so handlers receive `unknown` and the server validates\n * arguments; `Tool.getJsonSchema` still advertises the discovered schema. A\n * failed call returns `McpToolCallFailed` to the model as a failed tool result.\n */\nexport type McpTool = Tool.Tool<\n string,\n {\n readonly parameters: typeof Schema.Unknown;\n readonly success: typeof McpToolResult;\n readonly failure: typeof McpToolCallFailed;\n readonly failureMode: \"return\";\n }\n>;\n\n/** Toolkit of discovered MCP tools; every member forwards `tools/call` to its server. */\nexport type McpToolkit = Toolkit.Toolkit<Record<string, McpTool>>;\n\nconst executionClassFor = (\n annotations: McpSchema.ToolAnnotations | undefined,\n): ToolExecutionClassValue => {\n if (annotations === undefined) return \"uncertain\";\n if (annotations.readOnlyHint) return \"readonly\";\n if (annotations.idempotentHint && !annotations.destructiveHint) return \"idempotent\";\n\n return \"uncertain\";\n};\n\nconst makeMcpTool = (tool: McpSchema.Tool, trustToolAnnotations: boolean): McpTool => {\n let dynamic: McpTool = Tool.dynamic(tool.name, {\n ...(tool.description === undefined ? {} : { description: tool.description }),\n parameters: tool.inputSchema,\n success: McpToolResult,\n failure: McpToolCallFailed,\n // MCP reports tool errors inside results so the model can self-correct;\n // `return` hands the typed failure to the model the same way.\n failureMode: \"return\",\n });\n\n const title = tool.title ?? tool.annotations?.title;\n\n if (title !== undefined) dynamic = dynamic.annotate(Tool.Title, title);\n dynamic = dynamic.annotate(McpToolOutputSchema, Option.fromNullishOr(tool.outputSchema));\n if (tool.annotations !== undefined) {\n dynamic = dynamic\n .annotate(Tool.Readonly, tool.annotations.readOnlyHint)\n .annotate(Tool.Destructive, tool.annotations.destructiveHint)\n .annotate(Tool.Idempotent, tool.annotations.idempotentHint)\n .annotate(Tool.OpenWorld, tool.annotations.openWorldHint);\n }\n if (trustToolAnnotations) {\n dynamic = dynamic.annotate(ToolExecutionClass, executionClassFor(tool.annotations));\n }\n\n return dynamic;\n};\n\nconst ToolArguments = Schema.Record(Schema.String, Schema.Json);\nconst decodeToolArguments = Schema.decodeUnknownEffect(ToolArguments);\n\nconst errorText = (content: ReadonlyArray<typeof McpSchema.ContentBlock.Type>): string =>\n content\n .flatMap((block) => (block.type === \"text\" ? [block.text] : []))\n .join(\"\\n\")\n .slice(0, 4 * 1024);\n\nconst describeDefect = (defect: unknown): string =>\n (Predicate.hasProperty(defect, \"message\") && Predicate.isString(defect.message)\n ? defect.message\n : String(defect)\n ).slice(0, 4 * 1024);\n\nconst connectionError = (serverId: string, message: string) => (cause: unknown) =>\n McpConnectionError.make({ serverId, message, cause });\n\n/**\n * Keeps every non-interrupt outcome of one protocol step typed: expected\n * failures and defects (such as an undecodable server reply) both become the\n * connection error, so a misbehaving server cannot crash the connector.\n */\nconst failClosed =\n (serverId: string, message: string) =>\n <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, McpConnectionError, R> =>\n self.pipe(\n Effect.mapError(connectionError(serverId, message)),\n Effect.catchDefect((defect) => Effect.fail(connectionError(serverId, message)(defect))),\n );\n\nconst connectServer = Effect.fn(\"McpClient.connect\")(function* <R>(\n transport: McpServerTransport<R>,\n request: McpConnectionRequest,\n clientInfo: McpSchema.Implementation,\n): Effect.fn.Return<McpConnectedServer, McpConnectionError, Scope.Scope | R> {\n const serverId = transport.serverId;\n const protocol = yield* transport.protocol;\n\n const client = yield* RpcClient.make(McpSchema.ClientRpcs, {\n spanPrefix: \"McpClient\",\n spanAttributes: { \"mcp.server_id\": serverId },\n }).pipe(Effect.provideService(RpcClient.Protocol, protocol));\n\n const initialized = yield* client\n .initialize({\n protocolVersion: OFFERED_PROTOCOL_VERSION,\n capabilities: McpSchema.ClientCapabilities.make({}),\n clientInfo,\n })\n .pipe(failClosed(serverId, `MCP initialize with ${serverId} failed`));\n\n const negotiated = yield* Schema.decodeUnknownEffect(McpClientProtocolVersion)(\n initialized.protocolVersion,\n ).pipe(\n Effect.mapError(\n connectionError(\n serverId,\n `MCP server ${serverId} negotiated unsupported protocol version '${initialized.protocolVersion}'`,\n ),\n ),\n );\n\n yield* Effect.annotateCurrentSpan({ \"mcp.protocol_version\": negotiated });\n yield* client[\"notifications/initialized\"](undefined, { discard: true }).pipe(\n failClosed(serverId, `Could not acknowledge MCP initialization with ${serverId}`),\n );\n\n const tools: Array<McpSchema.Tool> = [];\n let cursor: string | undefined;\n let pages = 0;\n\n do {\n const page = yield* client[\"tools/list\"](\n cursor === undefined ? undefined : McpSchema.PaginatedRequestMeta.make({ cursor }),\n ).pipe(failClosed(serverId, `MCP tools/list with ${serverId} failed`));\n\n tools.push(...page.tools);\n cursor = page.nextCursor;\n pages += 1;\n // `validateMcpDiscovery` rejects the count; stop paying for more pages.\n if (tools.length > request.maxToolCount) break;\n if (cursor !== undefined && pages >= MAX_TOOL_LIST_PAGES) {\n return yield* McpConnectionError.make({\n serverId,\n message: `MCP server ${serverId} paginated tools/list beyond ${MAX_TOOL_LIST_PAGES} pages`,\n });\n }\n } while (cursor !== undefined);\n\n const callTool = Effect.fn(\"McpClient.callTool\")(function* (name: string, params: unknown) {\n const args = yield* decodeToolArguments(params ?? {}).pipe(\n Effect.mapError((cause) =>\n McpToolCallFailed.make({\n serverId,\n tool: name,\n reason: \"invalid-arguments\",\n message: `MCP tool arguments must be a JSON object: ${cause.message}`,\n }),\n ),\n );\n\n const result = yield* client[\"tools/call\"]({ name, arguments: args }).pipe(\n Effect.mapError((error) =>\n McpToolCallFailed.make({\n serverId,\n tool: name,\n reason: isRpcClientError(error) ? \"transport\" : \"protocol-error\",\n message: error.message,\n }),\n ),\n // A JSON-RPC error the MCP error union cannot decode (or any other\n // malformed reply) surfaces as a defect from the RPC client. It is still\n // the server's answer, so it reaches the model as a failed tool result\n // rather than aborting the batch.\n Effect.catchDefect((defect) =>\n Effect.fail(\n McpToolCallFailed.make({\n serverId,\n tool: name,\n reason: \"protocol-error\",\n message: describeDefect(defect),\n }),\n ),\n ),\n );\n\n if (result.isError === true) {\n return yield* McpToolCallFailed.make({\n serverId,\n tool: name,\n reason: \"tool-error\",\n message: errorText(result.content),\n content: result.content,\n });\n }\n\n return McpToolResult.make({\n content: result.content,\n ...(result.structuredContent === undefined\n ? {}\n : { structuredContent: result.structuredContent }),\n });\n });\n\n const toolkit: McpToolkit = yield* Effect.try({\n try: () =>\n Toolkit.make(...tools.map((tool) => makeMcpTool(tool, transport.trustToolAnnotations))),\n catch: connectionError(\n serverId,\n `MCP server ${serverId} advertised tools that cannot form a Toolkit`,\n ),\n });\n\n const handlers = toolkit.toLayer(\n Object.fromEntries(\n tools.map((tool) => [tool.name, (params: unknown) => callTool(tool.name, params)] as const),\n ),\n );\n\n return {\n identity: McpServerIdentity.make({ serverId, implementation: initialized.serverInfo }),\n capabilities: initialized.capabilities,\n tools,\n toolkit,\n handlers,\n } satisfies McpConnectedServer;\n});\n\n/** Platform services one transport needs, as declared by `McpServerTransport<R>`. */\nexport type McpTransportRequirements<Transport> =\n Transport extends McpServerTransport<infer R> ? R : never;\n\nconst makeConnectorLayer = <R>(\n transports: ReadonlyArray<McpServerTransport<R>>,\n options: { readonly clientInfo?: McpSchema.Implementation | undefined } | undefined,\n): Layer.Layer<McpConnector, never, R> =>\n Layer.effect(McpConnector)(\n Effect.gen(function* () {\n const services = yield* Effect.context<R>();\n const byServerId = new Map(transports.map((transport) => [transport.serverId, transport]));\n const clientInfo = options?.clientInfo ?? defaultMcpClientInfo;\n\n return McpConnector.of({\n connect: (request) => {\n const transport = byServerId.get(request.serverId);\n\n if (transport === undefined) {\n return Effect.fail(\n McpConnectionError.make({\n serverId: request.serverId,\n message: `No MCP transport is configured for server '${request.serverId}'`,\n }),\n );\n }\n\n // The Layer supplies the transport's platform services, but the\n // connection must live and die with the caller's Scope, never the\n // Layer's.\n return connectServer(transport, request, clientInfo).pipe(\n Effect.updateContext((caller: Context.Context<Scope.Scope>) =>\n Context.merge(Context.merge(caller, services), Context.pick(Scope.Scope)(caller)),\n ),\n );\n },\n });\n }),\n );\n\n/**\n * `McpConnector` over real transports. Each `connect` acquires the transport\n * in the caller's Scope, negotiates a protocol revision, lists tools within the\n * request bounds, and returns dynamic Effect AI Tools plus the handler Layer\n * that forwards their calls. The Layer requires the union of every\n * transport's platform services.\n */\nexport const layer = <const Transports extends ReadonlyArray<McpServerTransport<unknown>>>(\n transports: Transports,\n options?: { readonly clientInfo?: McpSchema.Implementation | undefined },\n): Layer.Layer<McpConnector, never, McpTransportRequirements<Transports[number]>> =>\n makeConnectorLayer(\n // Type-level only: each element declares its own `R`, and the Layer\n // requires their union. Nothing about the values changes.\n transports as ReadonlyArray<McpServerTransport<McpTransportRequirements<Transports[number]>>>,\n options,\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAM,4BAA4B;;AAElC,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAC9B,MAAM,8BAA8B;AACpC,MAAM,4BAA4B;;;;;;AAOlC,MAAa,2BAA2B,OAAO,SAAS;CACtD,YAAY,YAAY;CACxB,YAAY,YAAY;CACxB,YAAY,YAAY;CACxB,YAAY,YAAY;AAC1B,CAAC;AAID,MAAM,2BAAqD,YAAY,YAAY;;AAGnF,MAAa,uBAAuB,UAAU,eAAe,KAAK;CAChE,MAAM;CACN,SAAS;AACX,CAAC;;;;;;AAOD,IAAa,gBAAb,cAAmC,OAAO,MACxC,0CACF,CAAC,CAAC;CACA,SAAS,OAAO,MAAM,UAAU,YAAY;CAC5C,mBAAmB,OAAO,YAAY,OAAO,IAAI;AACnD,CAAC,CAAC,CAAC,CAAC;;;;;;AAOJ,IAAa,oBAAb,cAAuC,OAAO,YAA+B,CAAC,CAC5E,qBACA;CACE,UAAU,OAAO;CACjB,MAAM,OAAO;CACb,QAAQ,OAAO,SAAS;EAAC;EAAc;EAAqB;EAAkB;CAAW,CAAC;CAC1F,SAAS,OAAO;CAChB,SAAS,OAAO,YAAY,OAAO,MAAM,UAAU,YAAY,CAAC;AAClE,CACF,CAAC,CAAC,CAAC;AA6CH,MAAM,qBAAqB,QAAyB,IAAI,WAAW,gBAAgB;AACnF,MAAM,mBAAmB,OAAO,GAAG,eAAe,cAAc;AAEhE,MAAM,kBAAkB,SAAiB,UACvC,IAAI,eAAe,eAAe,EAChC,QAAQ,IAAI,eAAe,gBAAgB;CAAE;CAAS;AAAM,CAAC,EAC/D,CA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