effect-agent 0.1.0-beta.12 → 0.1.0-beta.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Agent-1DMSO_Fl.mjs +86 -0
- package/dist/Agent-1DMSO_Fl.mjs.map +1 -0
- package/dist/Agent-D9cXqfF3.d.mts +252 -0
- package/dist/AgentError-Bn1ytXRD.d.mts +117 -0
- package/dist/AgentPolicy-BqDoSXO6.d.mts +96 -0
- package/dist/AgentRuntime-BUxDdLpw.d.mts +346 -0
- package/dist/AgentRuntime-Cp1hAb-W.mjs +4739 -0
- package/dist/AgentRuntime-Cp1hAb-W.mjs.map +1 -0
- package/dist/AgentUpdates-DMJ-_xow.d.mts +53 -0
- package/dist/ContextCompactor-WwSIG_Z2.d.mts +161 -0
- package/dist/ContextWindow-DRQ5Mbm2.d.mts +58 -0
- package/dist/DurableAgentRuntime-B-9w7jDt.mjs +7061 -0
- package/dist/DurableAgentRuntime-B-9w7jDt.mjs.map +1 -0
- package/dist/DurableFailpoint-Cnr3wx1L.d.mts +41 -0
- package/dist/DurableStep-Cry_iol4.d.mts +103 -0
- package/dist/EventSource-CnlZ3Kma.d.mts +51 -0
- package/dist/FailureDiagnostic-BElLOoED.mjs +274 -0
- package/dist/FailureDiagnostic-BElLOoED.mjs.map +1 -0
- package/dist/FailureDiagnostic-CaAkzGHL.d.mts +223 -0
- package/dist/Identifiers-CN2s30fF.d.mts +40 -0
- package/dist/InMemory.d.mts +24 -0
- package/dist/InMemory.mjs +24 -0
- package/dist/InMemory.mjs.map +1 -0
- package/dist/MemoryNamespace-BbRW5p71.d.mts +36 -0
- package/dist/MemoryReference-B8Q3UJoJ.d.mts +79 -0
- package/dist/Messaging-Dkg87ebg.d.mts +221 -0
- package/dist/Messaging-JYYN3oYS.d.mts +1067 -0
- package/dist/MessagingHost-CqzpxbGz.d.mts +74 -0
- package/dist/MessagingHost-DfsbMPvq.mjs +110 -0
- package/dist/MessagingHost-DfsbMPvq.mjs.map +1 -0
- package/dist/OperationAuthorizer-TzcQtpX5.d.mts +61 -0
- package/dist/Output-V-6YL1_Z.d.mts +25 -0
- package/dist/PageCapture-Df8Xwskw.d.mts +583 -0
- package/dist/PageScreenshot-BpgZKAxl.d.mts +48 -0
- package/dist/PreparedInputAdmission-BQLGldl-.d.mts +42 -0
- package/dist/Receipt-BAHyigAF.d.mts +33 -0
- package/dist/Records-D88mgvyS.d.mts +4214 -0
- package/dist/RunEvent-DIrzkjLr.d.mts +460 -0
- package/dist/RunEventSink-D5aVhISG.d.mts +108 -0
- package/dist/RunJournal-BXrq0VIK.mjs +931 -0
- package/dist/RunJournal-BXrq0VIK.mjs.map +1 -0
- package/dist/RunOptions-CSBsSj0X.d.mts +935 -0
- package/dist/RunPolicyUsage-ClZxyR46.d.mts +21 -0
- package/dist/Sandbox-CEsDWBLq.d.mts +173 -0
- package/dist/Schedule-BIOHA6RR.d.mts +847 -0
- package/dist/Scheduling-DPb2QyAK.mjs +691 -0
- package/dist/Scheduling-DPb2QyAK.mjs.map +1 -0
- package/dist/Subagent-CNik9RiA.d.mts +1635 -0
- package/dist/Subagent-DCrB7an7.mjs +1498 -0
- package/dist/Subagent-DCrB7an7.mjs.map +1 -0
- package/dist/SubagentContract-DdT7Cqe6.d.mts +116 -0
- package/dist/SubagentHost-4WB8Hj0C.d.mts +164 -0
- package/dist/Subscription-CRteOKRf.d.mts +948 -0
- package/dist/SubscriptionInput-oNcwTPti.d.mts +41 -0
- package/dist/Thread-DOBQ0QUY.d.mts +96 -0
- package/dist/ThreadHistory-tS1KwxHR.d.mts +60 -0
- package/dist/ToolBroker-DWs4tZra.d.mts +133 -0
- package/dist/ToolExposure-9uF_Yo0T.mjs +10 -0
- package/dist/ToolExposure-9uF_Yo0T.mjs.map +1 -0
- package/dist/ToolExposure-C93U1sPu.mjs +30 -0
- package/dist/ToolExposure-C93U1sPu.mjs.map +1 -0
- package/dist/ToolExposure-UCN12eCd.d.mts +39 -0
- package/dist/ToolExposure-r2eOWk4F.d.mts +46 -0
- package/dist/ToolExposure.d.mts +8 -0
- package/dist/ToolExposure.mjs +21 -0
- package/dist/ToolExposure.mjs.map +1 -0
- package/dist/ToolReconciler-BmVRAHKs.d.mts +80 -0
- package/dist/ToolResult-BKdqWRff.d.mts +78 -0
- package/dist/Usage-Dx0aknfk.d.mts +121 -0
- package/dist/WakeScheduler-EjUF-GhC.d.mts +56 -0
- package/dist/Worker-CfwzMZEK.mjs +271 -0
- package/dist/Worker-CfwzMZEK.mjs.map +1 -0
- package/dist/Worker-fwWkBg12.d.mts +472 -0
- package/dist/agent-registration-CKNsrpwo.mjs +201 -0
- package/dist/agent-registration-CKNsrpwo.mjs.map +1 -0
- package/dist/capabilities/Approval.d.mts +114 -0
- package/dist/capabilities/Approval.mjs +226 -0
- package/dist/capabilities/Approval.mjs.map +1 -0
- package/dist/capabilities/Budget.d.mts +112 -0
- package/dist/capabilities/Budget.mjs +346 -0
- package/dist/capabilities/Budget.mjs.map +1 -0
- package/dist/capabilities/CodeMode.d.mts +157 -0
- package/dist/capabilities/CodeMode.mjs +522 -0
- package/dist/capabilities/CodeMode.mjs.map +1 -0
- package/dist/capabilities/Commands.d.mts +55 -0
- package/dist/capabilities/Commands.mjs +57 -0
- package/dist/capabilities/Commands.mjs.map +1 -0
- package/dist/capabilities/ContextTools.d.mts +321 -0
- package/dist/capabilities/ContextTools.mjs +126 -0
- package/dist/capabilities/ContextTools.mjs.map +1 -0
- package/dist/capabilities/Mcp.d.mts +108 -0
- package/dist/capabilities/Mcp.mjs +259 -0
- package/dist/capabilities/Mcp.mjs.map +1 -0
- package/dist/capabilities/McpClient.d.mts +115 -0
- package/dist/capabilities/McpClient.mjs +506 -0
- package/dist/capabilities/McpClient.mjs.map +1 -0
- package/dist/capabilities/MemoryNotes.d.mts +424 -0
- package/dist/capabilities/MemoryNotes.mjs +128 -0
- package/dist/capabilities/MemoryNotes.mjs.map +1 -0
- package/dist/capabilities/Messaging.d.mts +3 -0
- package/dist/capabilities/Messaging.mjs +152 -0
- package/dist/capabilities/Messaging.mjs.map +1 -0
- package/dist/capabilities/ModelContext.d.mts +89 -0
- package/dist/capabilities/ModelContext.mjs +168 -0
- package/dist/capabilities/ModelContext.mjs.map +1 -0
- package/dist/capabilities/Redaction.d.mts +37 -0
- package/dist/capabilities/Redaction.mjs +104 -0
- package/dist/capabilities/Redaction.mjs.map +1 -0
- package/dist/capabilities/Remembering.d.mts +434 -0
- package/dist/capabilities/Remembering.mjs +290 -0
- package/dist/capabilities/Remembering.mjs.map +1 -0
- package/dist/capabilities/RunHooks.d.mts +82 -0
- package/dist/capabilities/RunHooks.mjs +144 -0
- package/dist/capabilities/RunHooks.mjs.map +1 -0
- package/dist/capabilities/SemanticMemory.d.mts +431 -0
- package/dist/capabilities/SemanticMemory.mjs +315 -0
- package/dist/capabilities/SemanticMemory.mjs.map +1 -0
- package/dist/capabilities/Subagent.d.mts +4 -0
- package/dist/capabilities/Subagent.mjs +5 -0
- package/dist/capabilities/SubagentReservations.d.mts +186 -0
- package/dist/capabilities/SubagentReservations.mjs +479 -0
- package/dist/capabilities/SubagentReservations.mjs.map +1 -0
- package/dist/capabilities/ToolDiscovery.d.mts +124 -0
- package/dist/capabilities/ToolDiscovery.mjs +230 -0
- package/dist/capabilities/ToolDiscovery.mjs.map +1 -0
- package/dist/capabilities/WebCapture.d.mts +163 -0
- package/dist/capabilities/WebCapture.mjs +335 -0
- package/dist/capabilities/WebCapture.mjs.map +1 -0
- package/dist/capabilities/WebSearch.d.mts +71 -0
- package/dist/capabilities/WebSearch.mjs +115 -0
- package/dist/capabilities/WebSearch.mjs.map +1 -0
- package/dist/compaction-C2OTceKw.mjs +505 -0
- package/dist/compaction-C2OTceKw.mjs.map +1 -0
- package/dist/core/Agent.d.mts +2 -0
- package/dist/core/Agent.mjs +2 -0
- package/dist/core/AgentError.d.mts +2 -0
- package/dist/core/AgentError.mjs +134 -0
- package/dist/core/AgentError.mjs.map +1 -0
- package/dist/core/AgentPolicy.d.mts +2 -0
- package/dist/core/AgentPolicy.mjs +94 -0
- package/dist/core/AgentPolicy.mjs.map +1 -0
- package/dist/core/AgentUpdates.d.mts +2 -0
- package/dist/core/AgentUpdates.mjs +63 -0
- package/dist/core/AgentUpdates.mjs.map +1 -0
- package/dist/core/FailureDiagnostic.d.mts +2 -0
- package/dist/core/FailureDiagnostic.mjs +2 -0
- package/dist/core/IdGenerator.d.mts +26 -0
- package/dist/core/IdGenerator.mjs +27 -0
- package/dist/core/IdGenerator.mjs.map +1 -0
- package/dist/core/Identifiers.d.mts +2 -0
- package/dist/core/Identifiers.mjs +43 -0
- package/dist/core/Identifiers.mjs.map +1 -0
- package/dist/core/Memory.d.mts +57 -0
- package/dist/core/Memory.mjs +203 -0
- package/dist/core/Memory.mjs.map +1 -0
- package/dist/core/MemoryNamespace.d.mts +2 -0
- package/dist/core/MemoryNamespace.mjs +116 -0
- package/dist/core/MemoryNamespace.mjs.map +1 -0
- package/dist/core/MemoryReference.d.mts +2 -0
- package/dist/core/MemoryReference.mjs +109 -0
- package/dist/core/MemoryReference.mjs.map +1 -0
- package/dist/core/MemoryRevalidation.d.mts +65 -0
- package/dist/core/MemoryRevalidation.mjs +126 -0
- package/dist/core/MemoryRevalidation.mjs.map +1 -0
- package/dist/core/MemoryStore.d.mts +186 -0
- package/dist/core/MemoryStore.mjs +243 -0
- package/dist/core/MemoryStore.mjs.map +1 -0
- package/dist/core/Receipt.d.mts +2 -0
- package/dist/core/Receipt.mjs +36 -0
- package/dist/core/Receipt.mjs.map +1 -0
- package/dist/core/RememberingStore.d.mts +1562 -0
- package/dist/core/RememberingStore.mjs +190 -0
- package/dist/core/RememberingStore.mjs.map +1 -0
- package/dist/core/RunEvent.d.mts +2 -0
- package/dist/core/RunEvent.mjs +337 -0
- package/dist/core/RunEvent.mjs.map +1 -0
- package/dist/core/RunPolicyUsage.d.mts +2 -0
- package/dist/core/RunPolicyUsage.mjs +21 -0
- package/dist/core/RunPolicyUsage.mjs.map +1 -0
- package/dist/core/SemanticMemoryIndex.d.mts +826 -0
- package/dist/core/SemanticMemoryIndex.mjs +185 -0
- package/dist/core/SemanticMemoryIndex.mjs.map +1 -0
- package/dist/core/SemanticMemoryRevalidation.d.mts +45 -0
- package/dist/core/SemanticMemoryRevalidation.mjs +191 -0
- package/dist/core/SemanticMemoryRevalidation.mjs.map +1 -0
- package/dist/core/SubagentContract.d.mts +2 -0
- package/dist/core/SubagentContract.mjs +148 -0
- package/dist/core/SubagentContract.mjs.map +1 -0
- package/dist/core/Thread.d.mts +2 -0
- package/dist/core/Thread.mjs +250 -0
- package/dist/core/Thread.mjs.map +1 -0
- package/dist/core/ToolResult.d.mts +2 -0
- package/dist/core/ToolResult.mjs +156 -0
- package/dist/core/ToolResult.mjs.map +1 -0
- package/dist/core/Usage.d.mts +2 -0
- package/dist/core/Usage.mjs +319 -0
- package/dist/core/Usage.mjs.map +1 -0
- package/dist/core/Worker.d.mts +3 -0
- package/dist/core/Worker.mjs +3 -0
- package/dist/durable/ActivityStore.d.mts +116 -0
- package/dist/durable/ActivityStore.mjs +131 -0
- package/dist/durable/ActivityStore.mjs.map +1 -0
- package/dist/durable/Admin.d.mts +2 -0
- package/dist/durable/Admin.mjs +330 -0
- package/dist/durable/Admin.mjs.map +1 -0
- package/dist/durable/AgentRegistration.d.mts +2 -0
- package/dist/durable/AgentRegistration.mjs +14 -0
- package/dist/durable/AgentRegistration.mjs.map +1 -0
- package/dist/durable/Certification.d.mts +110 -0
- package/dist/durable/Certification.mjs +159 -0
- package/dist/durable/Certification.mjs.map +1 -0
- package/dist/durable/CommittedActivity.d.mts +62 -0
- package/dist/durable/CommittedActivity.mjs +159 -0
- package/dist/durable/CommittedActivity.mjs.map +1 -0
- package/dist/durable/Digest.d.mts +2 -0
- package/dist/durable/Digest.mjs +50 -0
- package/dist/durable/Digest.mjs.map +1 -0
- package/dist/durable/DurableAgentRuntime.d.mts +3 -0
- package/dist/durable/DurableAgentRuntime.mjs +3 -0
- package/dist/durable/DurableFailpoint.d.mts +2 -0
- package/dist/durable/DurableFailpoint.mjs +102 -0
- package/dist/durable/DurableFailpoint.mjs.map +1 -0
- package/dist/durable/DurableFailpointTestControl.d.mts +14 -0
- package/dist/durable/DurableFailpointTestControl.mjs +19 -0
- package/dist/durable/DurableFailpointTestControl.mjs.map +1 -0
- package/dist/durable/EventSource.d.mts +2 -0
- package/dist/durable/EventSource.mjs +65 -0
- package/dist/durable/EventSource.mjs.map +1 -0
- package/dist/durable/GitHubWorkflowSource.d.mts +185 -0
- package/dist/durable/GitHubWorkflowSource.mjs +209 -0
- package/dist/durable/GitHubWorkflowSource.mjs.map +1 -0
- package/dist/durable/MessageDelivery.d.mts +893 -0
- package/dist/durable/MessageDelivery.mjs +557 -0
- package/dist/durable/MessageDelivery.mjs.map +1 -0
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +378 -0
- package/dist/durable/MessageDeliveryStoreConformance.mjs +270 -0
- package/dist/durable/MessageDeliveryStoreConformance.mjs.map +1 -0
- package/dist/durable/OperationAuthorizer.d.mts +2 -0
- package/dist/durable/OperationAuthorizer.mjs +70 -0
- package/dist/durable/OperationAuthorizer.mjs.map +1 -0
- package/dist/durable/PersistentHistory.d.mts +16 -0
- package/dist/durable/PersistentHistory.mjs +125 -0
- package/dist/durable/PersistentHistory.mjs.map +1 -0
- package/dist/durable/PreparedInputAdmission.d.mts +2 -0
- package/dist/durable/PreparedInputAdmission.mjs +38 -0
- package/dist/durable/PreparedInputAdmission.mjs.map +1 -0
- package/dist/durable/Records.d.mts +2 -0
- package/dist/durable/Records.mjs +848 -0
- package/dist/durable/Records.mjs.map +1 -0
- package/dist/durable/Recovery.d.mts +2 -0
- package/dist/durable/Recovery.mjs +739 -0
- package/dist/durable/Recovery.mjs.map +1 -0
- package/dist/durable/RunJournal.d.mts +2 -0
- package/dist/durable/RunJournal.mjs +2 -0
- package/dist/durable/Schedule.d.mts +2 -0
- package/dist/durable/Schedule.mjs +391 -0
- package/dist/durable/Schedule.mjs.map +1 -0
- package/dist/durable/ScheduleStoreConformance.d.mts +17 -0
- package/dist/durable/ScheduleStoreConformance.mjs +420 -0
- package/dist/durable/ScheduleStoreConformance.mjs.map +1 -0
- package/dist/durable/ScheduleTransition.d.mts +24 -0
- package/dist/durable/ScheduleTransition.mjs +180 -0
- package/dist/durable/ScheduleTransition.mjs.map +1 -0
- package/dist/durable/Scheduling.d.mts +54 -0
- package/dist/durable/Scheduling.mjs +2 -0
- package/dist/durable/SqlMemoryStore.d.mts +29 -0
- package/dist/durable/SqlMemoryStore.mjs +436 -0
- package/dist/durable/SqlMemoryStore.mjs.map +1 -0
- package/dist/durable/SqlMessageDeliveryStore.d.mts +42 -0
- package/dist/durable/SqlMessageDeliveryStore.mjs +179 -0
- package/dist/durable/SqlMessageDeliveryStore.mjs.map +1 -0
- package/dist/durable/SqlStorageV2Upgrade.d.mts +21 -0
- package/dist/durable/SqlStorageV2Upgrade.mjs +459 -0
- package/dist/durable/SqlStorageV2Upgrade.mjs.map +1 -0
- package/dist/durable/SqlSubscriptionStore.d.mts +62 -0
- package/dist/durable/SqlSubscriptionStore.mjs +751 -0
- package/dist/durable/SqlSubscriptionStore.mjs.map +1 -0
- package/dist/durable/SqlThreadNativeReads.d.mts +53 -0
- package/dist/durable/SqlThreadNativeReads.mjs +159 -0
- package/dist/durable/SqlThreadNativeReads.mjs.map +1 -0
- package/dist/durable/SubmissionLedger.d.mts +3 -0
- package/dist/durable/SubmissionLedger.mjs +959 -0
- package/dist/durable/SubmissionLedger.mjs.map +1 -0
- package/dist/durable/SubmissionLedgerConformance.d.mts +29 -0
- package/dist/durable/SubmissionLedgerConformance.mjs +2187 -0
- package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -0
- package/dist/durable/SubmissionStatus.d.mts +2 -0
- package/dist/durable/SubmissionStatus.mjs +18 -0
- package/dist/durable/SubmissionStatus.mjs.map +1 -0
- package/dist/durable/Subscription.d.mts +2 -0
- package/dist/durable/Subscription.mjs +360 -0
- package/dist/durable/Subscription.mjs.map +1 -0
- package/dist/durable/SubscriptionInput.d.mts +2 -0
- package/dist/durable/SubscriptionInput.mjs +52 -0
- package/dist/durable/SubscriptionInput.mjs.map +1 -0
- package/dist/durable/SubscriptionStoreConformance.d.mts +16 -0
- package/dist/durable/SubscriptionStoreConformance.mjs +625 -0
- package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -0
- package/dist/durable/SubscriptionTools.d.mts +273 -0
- package/dist/durable/SubscriptionTools.mjs +190 -0
- package/dist/durable/SubscriptionTools.mjs.map +1 -0
- package/dist/durable/SubscriptionTransition.d.mts +21 -0
- package/dist/durable/SubscriptionTransition.mjs +148 -0
- package/dist/durable/SubscriptionTransition.mjs.map +1 -0
- package/dist/durable/Subscriptions.d.mts +73 -0
- package/dist/durable/Subscriptions.mjs +627 -0
- package/dist/durable/Subscriptions.mjs.map +1 -0
- package/dist/durable/ThreadContextHistory.d.mts +32 -0
- package/dist/durable/ThreadContextHistory.mjs +152 -0
- package/dist/durable/ThreadContextHistory.mjs.map +1 -0
- package/dist/durable/ThreadContextHistoryProjection.d.mts +60 -0
- package/dist/durable/ThreadContextHistoryProjection.mjs +149 -0
- package/dist/durable/ThreadContextHistoryProjection.mjs.map +1 -0
- package/dist/durable/ThreadInvariants.d.mts +76 -0
- package/dist/durable/ThreadInvariants.mjs +246 -0
- package/dist/durable/ThreadInvariants.mjs.map +1 -0
- package/dist/durable/ThreadProjection.d.mts +78 -0
- package/dist/durable/ThreadProjection.mjs +158 -0
- package/dist/durable/ThreadProjection.mjs.map +1 -0
- package/dist/durable/ThreadProjectionMaintenance.d.mts +49 -0
- package/dist/durable/ThreadProjectionMaintenance.mjs +33 -0
- package/dist/durable/ThreadProjectionMaintenance.mjs.map +1 -0
- package/dist/durable/ThreadStore.d.mts +2 -0
- package/dist/durable/ThreadStore.mjs +355 -0
- package/dist/durable/ThreadStore.mjs.map +1 -0
- package/dist/durable/ThreadStoreConformance.d.mts +28 -0
- package/dist/durable/ThreadStoreConformance.mjs +503 -0
- package/dist/durable/ThreadStoreConformance.mjs.map +1 -0
- package/dist/durable/ToolReconciler.d.mts +2 -0
- package/dist/durable/ToolReconciler.mjs +85 -0
- package/dist/durable/ToolReconciler.mjs.map +1 -0
- package/dist/durable/WakeScheduler.d.mts +2 -0
- package/dist/durable/WakeScheduler.mjs +85 -0
- package/dist/durable/WakeScheduler.mjs.map +1 -0
- package/dist/durable/WorkerHost.d.mts +129 -0
- package/dist/durable/WorkerHost.mjs +77 -0
- package/dist/durable/WorkerHost.mjs.map +1 -0
- package/dist/engine/AgentRuntime.d.mts +2 -0
- package/dist/engine/AgentRuntime.mjs +2 -0
- package/dist/engine/Compaction.d.mts +7 -0
- package/dist/engine/Compaction.mjs +16 -0
- package/dist/engine/Compaction.mjs.map +1 -0
- package/dist/engine/ContextCompactor.d.mts +2 -0
- package/dist/engine/ContextCompactor.mjs +119 -0
- package/dist/engine/ContextCompactor.mjs.map +1 -0
- package/dist/engine/ContextHistory.d.mts +65 -0
- package/dist/engine/ContextHistory.mjs +76 -0
- package/dist/engine/ContextHistory.mjs.map +1 -0
- package/dist/engine/ContextWindow.d.mts +2 -0
- package/dist/engine/ContextWindow.mjs +59 -0
- package/dist/engine/ContextWindow.mjs.map +1 -0
- package/dist/engine/DurableStep.d.mts +2 -0
- package/dist/engine/DurableStep.mjs +62 -0
- package/dist/engine/DurableStep.mjs.map +1 -0
- package/dist/engine/MessagingHost.d.mts +2 -0
- package/dist/engine/MessagingHost.mjs +2 -0
- package/dist/engine/Output.d.mts +2 -0
- package/dist/engine/Output.mjs +8 -0
- package/dist/engine/Output.mjs.map +1 -0
- package/dist/engine/RunEventSink.d.mts +2 -0
- package/dist/engine/RunEventSink.mjs +22 -0
- package/dist/engine/RunEventSink.mjs.map +1 -0
- package/dist/engine/RunOptions.d.mts +2 -0
- package/dist/engine/RunOptions.mjs +124 -0
- package/dist/engine/RunOptions.mjs.map +1 -0
- package/dist/engine/SubagentHost.d.mts +2 -0
- package/dist/engine/SubagentHost.mjs +76 -0
- package/dist/engine/SubagentHost.mjs.map +1 -0
- package/dist/engine/ThreadHistory.d.mts +2 -0
- package/dist/engine/ThreadHistory.mjs +67 -0
- package/dist/engine/ThreadHistory.mjs.map +1 -0
- package/dist/engine/ToolBroker.d.mts +2 -0
- package/dist/engine/ToolBroker.mjs +42 -0
- package/dist/engine/ToolBroker.mjs.map +1 -0
- package/dist/foreign-diagnostic-DBQ1XHKh.mjs +37 -0
- package/dist/foreign-diagnostic-DBQ1XHKh.mjs.map +1 -0
- package/dist/index.d.mts +91 -6
- package/dist/index.mjs +100 -6
- package/dist/output-contract-BC7tjlGw.mjs +84 -0
- package/dist/output-contract-BC7tjlGw.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/sandbox/CodeExecutor.d.mts +194 -0
- package/dist/sandbox/CodeExecutor.mjs +278 -0
- package/dist/sandbox/CodeExecutor.mjs.map +1 -0
- package/dist/sandbox/InteractiveBrowser.d.mts +257 -0
- package/dist/sandbox/InteractiveBrowser.mjs +236 -0
- package/dist/sandbox/InteractiveBrowser.mjs.map +1 -0
- package/dist/sandbox/PageCapture.d.mts +2 -0
- package/dist/sandbox/PageCapture.mjs +450 -0
- package/dist/sandbox/PageCapture.mjs.map +1 -0
- package/dist/sandbox/PageCrawl.d.mts +88 -0
- package/dist/sandbox/PageCrawl.mjs +124 -0
- package/dist/sandbox/PageCrawl.mjs.map +1 -0
- package/dist/sandbox/PageScreenshot.d.mts +2 -0
- package/dist/sandbox/PageScreenshot.mjs +53 -0
- package/dist/sandbox/PageScreenshot.mjs.map +1 -0
- package/dist/sandbox/ProtectedBrowser.d.mts +283 -0
- package/dist/sandbox/ProtectedBrowser.mjs +298 -0
- package/dist/sandbox/ProtectedBrowser.mjs.map +1 -0
- package/dist/sandbox/Sandbox.d.mts +2 -0
- package/dist/sandbox/Sandbox.mjs +208 -0
- package/dist/sandbox/Sandbox.mjs.map +1 -0
- package/dist/utf8-BYfhEkcj.mjs +11 -0
- package/dist/utf8-BYfhEkcj.mjs.map +1 -0
- package/dist/utf8-DchGZRBd.mjs +23 -0
- package/dist/utf8-DchGZRBd.mjs.map +1 -0
- package/package.json +1 -40
- package/src/InMemory.ts +19 -0
- package/src/ToolExposure.ts +2 -0
- package/src/capabilities/Approval.ts +352 -0
- package/src/capabilities/Budget.ts +536 -0
- package/src/capabilities/CodeMode.ts +1090 -0
- package/src/capabilities/Commands.ts +86 -0
- package/src/capabilities/ContextTools.ts +184 -0
- package/src/capabilities/Mcp.ts +426 -0
- package/src/capabilities/McpClient.ts +967 -0
- package/src/capabilities/MemoryNotes.ts +174 -0
- package/src/capabilities/Messaging.ts +261 -0
- package/src/capabilities/ModelContext.ts +354 -0
- package/src/capabilities/Redaction.ts +157 -0
- package/src/capabilities/Remembering.ts +550 -0
- package/src/capabilities/RunHooks.ts +280 -0
- package/src/capabilities/SemanticMemory.ts +447 -0
- package/src/capabilities/Subagent.ts +2489 -0
- package/src/capabilities/SubagentReservations.ts +850 -0
- package/src/capabilities/ToolDiscovery.ts +369 -0
- package/src/capabilities/WebCapture.ts +722 -0
- package/src/capabilities/WebSearch.ts +190 -0
- package/src/capabilities/internal/subagent-background.ts +1273 -0
- package/src/capabilities/internal/subagent-contract.ts +146 -0
- package/src/capabilities/internal/subagent-policy.ts +235 -0
- package/src/capabilities/internal/subagent-reporting.ts +136 -0
- package/src/capabilities/internal/utf8.ts +10 -0
- package/src/core/Agent.ts +602 -0
- package/src/core/AgentError.ts +172 -0
- package/src/core/AgentPolicy.ts +153 -0
- package/src/core/AgentUpdates.ts +100 -0
- package/src/core/FailureDiagnostic.ts +343 -0
- package/src/core/IdGenerator.ts +39 -0
- package/src/core/Identifiers.ts +48 -0
- package/src/core/Memory.ts +290 -0
- package/src/core/MemoryNamespace.ts +196 -0
- package/src/core/MemoryReference.ts +121 -0
- package/src/core/MemoryRevalidation.ts +185 -0
- package/src/core/MemoryStore.ts +368 -0
- package/src/core/Messaging.ts +72 -0
- package/src/core/Receipt.ts +42 -0
- package/src/core/RememberingStore.ts +300 -0
- package/src/core/RunEvent.ts +366 -0
- package/src/core/RunPolicyUsage.ts +17 -0
- package/src/core/SemanticMemoryIndex.ts +250 -0
- package/src/core/SemanticMemoryRevalidation.ts +254 -0
- package/src/core/SubagentContract.ts +196 -0
- package/src/core/Thread.ts +371 -0
- package/src/core/ToolExposure.ts +74 -0
- package/src/core/ToolResult.ts +190 -0
- package/src/core/Usage.ts +529 -0
- package/src/core/Worker.ts +240 -0
- package/src/core/internal/agent-updates.ts +34 -0
- package/src/core/internal/message-status.ts +60 -0
- package/src/core/internal/strict-schema.ts +14 -0
- package/src/core/internal/utf8.ts +23 -0
- package/src/durable/ActivityStore.ts +160 -0
- package/src/durable/Admin.ts +505 -0
- package/src/durable/AgentRegistration.ts +14 -0
- package/src/durable/Certification.ts +210 -0
- package/src/durable/CommittedActivity.ts +296 -0
- package/src/durable/Digest.ts +87 -0
- package/src/durable/DurableAgentRuntime.ts +11275 -0
- package/src/durable/DurableFailpoint.ts +111 -0
- package/src/durable/DurableFailpointTestControl.ts +39 -0
- package/src/durable/EventSource.ts +172 -0
- package/src/durable/GitHubWorkflowSource.ts +447 -0
- package/src/durable/MessageDelivery.ts +832 -0
- package/src/durable/MessageDeliveryStoreConformance.ts +410 -0
- package/src/durable/OperationAuthorizer.ts +85 -0
- package/src/durable/PersistentHistory.ts +260 -0
- package/src/durable/PreparedInputAdmission.ts +57 -0
- package/src/durable/Records.ts +1075 -0
- package/src/durable/Recovery.ts +1018 -0
- package/src/durable/RunJournal.ts +1631 -0
- package/src/durable/Schedule.ts +513 -0
- package/src/durable/ScheduleStoreConformance.ts +638 -0
- package/src/durable/ScheduleTransition.ts +265 -0
- package/src/durable/Scheduling.ts +1077 -0
- package/src/durable/SqlMemoryStore.ts +778 -0
- package/src/durable/SqlMessageDeliveryStore.ts +335 -0
- package/src/durable/SqlStorageV2Upgrade.ts +500 -0
- package/src/durable/SqlSubscriptionStore.ts +1440 -0
- package/src/durable/SqlThreadNativeReads.ts +270 -0
- package/src/durable/SubmissionLedger.ts +1265 -0
- package/src/durable/SubmissionLedgerConformance.ts +4820 -0
- package/src/durable/SubmissionStatus.ts +14 -0
- package/src/durable/Subscription.ts +544 -0
- package/src/durable/SubscriptionInput.ts +144 -0
- package/src/durable/SubscriptionStoreConformance.ts +945 -0
- package/src/durable/SubscriptionTools.ts +327 -0
- package/src/durable/SubscriptionTransition.ts +302 -0
- package/src/durable/Subscriptions.ts +1210 -0
- package/src/durable/ThreadContextHistory.ts +227 -0
- package/src/durable/ThreadContextHistoryProjection.ts +216 -0
- package/src/durable/ThreadInvariants.ts +507 -0
- package/src/durable/ThreadProjection.ts +269 -0
- package/src/durable/ThreadProjectionMaintenance.ts +67 -0
- package/src/durable/ThreadStore.ts +573 -0
- package/src/durable/ThreadStoreConformance.ts +1156 -0
- package/src/durable/ToolReconciler.ts +109 -0
- package/src/durable/WakeScheduler.ts +134 -0
- package/src/durable/WorkerHost.ts +171 -0
- package/src/durable/internal/agent-registration.ts +587 -0
- package/src/durable/internal/agent-updates.ts +302 -0
- package/src/durable/internal/foreign-diagnostic.ts +47 -0
- package/src/durable/internal/journal-checkpoint.ts +104 -0
- package/src/durable/internal/journal-metadata.ts +117 -0
- package/src/durable/internal/message-status.ts +20 -0
- package/src/durable/internal/messaging-host.ts +637 -0
- package/src/durable/internal/schedule-time.ts +303 -0
- package/src/durable/internal/storage-v2-layout.ts +163 -0
- package/src/durable/internal/storage-v2.ts +73 -0
- package/src/durable/internal/worker-host.ts +2885 -0
- package/src/durable/internal/worker-runtime.ts +9 -0
- package/src/engine/AgentRuntime.ts +37 -0
- package/src/engine/Compaction.ts +11 -0
- package/src/engine/ContextCompactor.ts +277 -0
- package/src/engine/ContextHistory.ts +73 -0
- package/src/engine/ContextWindow.ts +72 -0
- package/src/engine/DurableStep.ts +132 -0
- package/src/engine/MessagingHost.ts +110 -0
- package/src/engine/Output.ts +2 -0
- package/src/engine/RunEventSink.ts +132 -0
- package/src/engine/RunOptions.ts +1101 -0
- package/src/engine/SubagentHost.ts +230 -0
- package/src/engine/ThreadHistory.ts +120 -0
- package/src/engine/ToolBroker.ts +157 -0
- package/src/engine/ToolExposure.ts +48 -0
- package/src/engine/internal/agent-runtime.ts +10500 -0
- package/src/engine/internal/bounded-value.ts +315 -0
- package/src/engine/internal/compaction.ts +678 -0
- package/src/engine/internal/error-diagnostic.ts +39 -0
- package/src/engine/internal/output-contract.ts +173 -0
- package/src/engine/internal/primitive-delta.ts +80 -0
- package/src/engine/internal/provider-result-staging.ts +211 -0
- package/src/engine/internal/tool-derivative.ts +106 -0
- package/src/engine/internal/tool-exposure.ts +224 -0
- package/src/engine/internal/tool-telemetry.ts +484 -0
- package/src/index.ts +99 -21
- package/src/sandbox/CodeExecutor.ts +352 -0
- package/src/sandbox/InteractiveBrowser.ts +339 -0
- package/src/sandbox/PageCapture.ts +691 -0
- package/src/sandbox/PageCrawl.ts +148 -0
- package/src/sandbox/PageScreenshot.ts +81 -0
- package/src/sandbox/ProtectedBrowser.ts +452 -0
- package/src/sandbox/Sandbox.ts +241 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { McpConnectionError, McpConnector } from "./Mcp.mjs";
|
|
2
|
+
import { Tool, Toolkit } from "effect/unstable/ai";
|
|
3
|
+
import { Cause, Effect, Layer, Schema, Scope } from "effect";
|
|
4
|
+
import * as McpSchema from "effect/unstable/ai/McpSchema";
|
|
5
|
+
import { Headers, HttpClient } from "effect/unstable/http";
|
|
6
|
+
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
7
|
+
import { RpcClient } from "effect/unstable/rpc";
|
|
8
|
+
declare namespace McpClient_d_exports {
|
|
9
|
+
export { McpClientProtocolVersion, McpHttpTransport, McpHttpTransportOptions, McpServerTransport, McpStdioTransport, McpStdioTransportOptions, McpTool, McpToolCallFailed, McpToolResult, McpToolkit, McpTransportRequirements, defaultMcpClientInfo, layer };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The protocol revisions this client negotiates, as implemented by Effect AI's
|
|
13
|
+
* native MCP protocol adapters. The newest revision is offered first; a server
|
|
14
|
+
* answering with any other listed revision is accepted, anything else fails.
|
|
15
|
+
*/
|
|
16
|
+
export declare const McpClientProtocolVersion: Schema.Literals<readonly ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"]>;
|
|
17
|
+
export type McpClientProtocolVersion = typeof McpClientProtocolVersion.Type;
|
|
18
|
+
/** Identity this client presents to servers during `initialize`. */
|
|
19
|
+
export declare const defaultMcpClientInfo: McpSchema.Implementation;
|
|
20
|
+
declare const McpToolResult_base: Schema.Class<McpToolResult, Schema.Struct<{
|
|
21
|
+
readonly content: Schema.$Array<Schema.Union<readonly [typeof McpSchema.TextContent, typeof McpSchema.ImageContent, typeof McpSchema.AudioContent, typeof McpSchema.EmbeddedResource, typeof McpSchema.ResourceLink]>>;
|
|
22
|
+
readonly structuredContent: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
23
|
+
}>, {}>;
|
|
24
|
+
/**
|
|
25
|
+
* The model-visible result of a remote MCP tool call: the server's content
|
|
26
|
+
* blocks and, when the tool declares an `outputSchema`, its structured result.
|
|
27
|
+
* A result with `isError` never becomes this value; it fails the Tool Call.
|
|
28
|
+
*/
|
|
29
|
+
export declare class McpToolResult extends McpToolResult_base {}
|
|
30
|
+
declare const McpToolCallFailed_base: Schema.Class<McpToolCallFailed, Schema.TaggedStruct<"McpToolCallFailed", {
|
|
31
|
+
readonly serverId: Schema.NonEmptyString;
|
|
32
|
+
readonly tool: Schema.NonEmptyString;
|
|
33
|
+
readonly reason: Schema.Literals<readonly ["tool-error", "invalid-arguments", "protocol-error", "transport"]>;
|
|
34
|
+
readonly message: Schema.String;
|
|
35
|
+
readonly content: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [typeof McpSchema.TextContent, typeof McpSchema.ImageContent, typeof McpSchema.AudioContent, typeof McpSchema.EmbeddedResource, typeof McpSchema.ResourceLink]>>>;
|
|
36
|
+
}>, Cause.YieldableError>;
|
|
37
|
+
/**
|
|
38
|
+
* Typed failure of one remote MCP tool call. `tool-error` carries the server's
|
|
39
|
+
* error content; the other reasons describe why no trustworthy result exists.
|
|
40
|
+
* None of them claims the remote effect did not happen.
|
|
41
|
+
*/
|
|
42
|
+
export declare class McpToolCallFailed extends McpToolCallFailed_base {}
|
|
43
|
+
/**
|
|
44
|
+
* One reachable MCP server. `protocol` acquires a JSON-RPC transport in the
|
|
45
|
+
* caller's Scope; `R` names the platform services that transport needs so the
|
|
46
|
+
* connector Layer keeps them in its requirements.
|
|
47
|
+
*/
|
|
48
|
+
export interface McpServerTransport<R = never> {
|
|
49
|
+
readonly serverId: string;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the server's `readOnlyHint`, `idempotentHint`, and
|
|
52
|
+
* `destructiveHint` may set the framework execution class of its tools.
|
|
53
|
+
* Hints are server-declared and untrusted, so the default leaves every
|
|
54
|
+
* remote tool `uncertain`.
|
|
55
|
+
*/
|
|
56
|
+
readonly trustToolAnnotations: boolean;
|
|
57
|
+
readonly protocol: Effect.Effect<RpcClient.Protocol["Service"], McpConnectionError, Scope.Scope | R>;
|
|
58
|
+
}
|
|
59
|
+
/** Streamable HTTP server address. Header values may carry credentials the application owns. */
|
|
60
|
+
export interface McpHttpTransportOptions {
|
|
61
|
+
readonly serverId: string;
|
|
62
|
+
readonly url: string;
|
|
63
|
+
readonly headers?: Headers.Input | undefined;
|
|
64
|
+
/** Largest accepted response message. Defaults to 4 MiB. */
|
|
65
|
+
readonly maxMessageBytes?: number | undefined;
|
|
66
|
+
readonly trustToolAnnotations?: boolean | undefined;
|
|
67
|
+
}
|
|
68
|
+
/** A local MCP server process speaking newline-delimited JSON-RPC on stdio. */
|
|
69
|
+
export interface McpStdioTransportOptions {
|
|
70
|
+
readonly serverId: string;
|
|
71
|
+
readonly command: string;
|
|
72
|
+
readonly args?: ReadonlyArray<string> | undefined;
|
|
73
|
+
readonly cwd?: string | undefined;
|
|
74
|
+
readonly env?: Readonly<Record<string, string>> | undefined;
|
|
75
|
+
/** Largest accepted stdout frame. Defaults to 4 MiB. */
|
|
76
|
+
readonly maxMessageBytes?: number | undefined;
|
|
77
|
+
readonly trustToolAnnotations?: boolean | undefined;
|
|
78
|
+
}
|
|
79
|
+
/** Streamable HTTP transport for one remote MCP server; requires `HttpClient`. */
|
|
80
|
+
export declare const McpHttpTransport: {
|
|
81
|
+
readonly make: (options: McpHttpTransportOptions) => McpServerTransport<HttpClient.HttpClient>;
|
|
82
|
+
};
|
|
83
|
+
/** stdio transport for one local MCP server process; requires `ChildProcessSpawner`. */
|
|
84
|
+
export declare const McpStdioTransport: {
|
|
85
|
+
readonly make: (options: McpStdioTransportOptions) => McpServerTransport<ChildProcessSpawner.ChildProcessSpawner>;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Effect AI Tool derived from one discovered MCP tool. Its parameters are the
|
|
89
|
+
* server's JSON Schema, so handlers receive `unknown` and the server validates
|
|
90
|
+
* arguments; `Tool.getJsonSchema` still advertises the discovered schema. A
|
|
91
|
+
* failed call returns `McpToolCallFailed` to the model as a failed tool result.
|
|
92
|
+
*/
|
|
93
|
+
export type McpTool = Tool.Tool<string, {
|
|
94
|
+
readonly parameters: typeof Schema.Unknown;
|
|
95
|
+
readonly success: typeof McpToolResult;
|
|
96
|
+
readonly failure: typeof McpToolCallFailed;
|
|
97
|
+
readonly failureMode: "return";
|
|
98
|
+
}>;
|
|
99
|
+
/** Toolkit of discovered MCP tools; every member forwards `tools/call` to its server. */
|
|
100
|
+
export type McpToolkit = Toolkit.Toolkit<Record<string, McpTool>>;
|
|
101
|
+
/** Platform services one transport needs, as declared by `McpServerTransport<R>`. */
|
|
102
|
+
export type McpTransportRequirements<Transport> = Transport extends McpServerTransport<infer R> ? R : never;
|
|
103
|
+
/**
|
|
104
|
+
* `McpConnector` over real transports. Each `connect` acquires the transport
|
|
105
|
+
* in the caller's Scope, negotiates a protocol revision, lists tools within the
|
|
106
|
+
* request bounds, and returns dynamic Effect AI Tools plus the handler Layer
|
|
107
|
+
* that forwards their calls. The Layer requires the union of every
|
|
108
|
+
* transport's platform services.
|
|
109
|
+
*/
|
|
110
|
+
export declare const layer: <const Transports extends ReadonlyArray<McpServerTransport<unknown>>>(transports: Transports, options?: {
|
|
111
|
+
readonly clientInfo?: McpSchema.Implementation | undefined;
|
|
112
|
+
}) => Layer.Layer<McpConnector, never, McpTransportRequirements<Transports[number]>>;
|
|
113
|
+
//#endregion
|
|
114
|
+
export { McpClient_d_exports as t };
|
|
115
|
+
//# sourceMappingURL=McpClient.d.mts.map
|
|
@@ -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
|