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,157 @@
|
|
|
1
|
+
import { s as ToolBroker } from "../ToolBroker-DWs4tZra.mjs";
|
|
2
|
+
import { CodeExecutionLimits, CodeExecutionNamespace, CodeExecutor } from "../sandbox/CodeExecutor.mjs";
|
|
3
|
+
import { Tool } from "effect/unstable/ai";
|
|
4
|
+
import { Cause, Effect, Layer, Schema, Scope } from "effect";
|
|
5
|
+
declare namespace CodeMode_d_exports {
|
|
6
|
+
export { CodeModeDefinition, CodeModeDescriptionError, CodeModeFailure, CodeModeLayerRequirements, CodeModeNamespaces, CodeModeOptions, CodeModeParameters, CodeModePassReport, CodeModeSelectedRecord, CodeModeSelectedTool, CodeModeSuccess, CodeModeTool, CodeModeTools, make };
|
|
7
|
+
}
|
|
8
|
+
/** A pass-local report, available to the host even when the caller interrupts execution. */
|
|
9
|
+
export declare const CodeModePassReport: Schema.Struct<{
|
|
10
|
+
readonly status: Schema.Literals<readonly ["completed", "failed", "interrupted", "defect"]>;
|
|
11
|
+
readonly calls: Schema.$Array<Schema.Struct<{
|
|
12
|
+
readonly sequenceIndex: Schema.Natural;
|
|
13
|
+
readonly toolName: Schema.String;
|
|
14
|
+
readonly status: Schema.Literals<readonly ["not-started", "succeeded", "failed", "uncertain"]>;
|
|
15
|
+
readonly errorTag: Schema.optionalKey<Schema.String>;
|
|
16
|
+
}>>;
|
|
17
|
+
}>;
|
|
18
|
+
export type CodeModePassReport = typeof CodeModePassReport.Type;
|
|
19
|
+
/** Model-decoded Code Mode parameters: one async function expression. */
|
|
20
|
+
export declare const CodeModeParameters: Schema.Struct<{
|
|
21
|
+
readonly code: Schema.NonEmptyString;
|
|
22
|
+
}>;
|
|
23
|
+
declare const CodeModeSuccess_base: Schema.Class<CodeModeSuccess, Schema.Struct<{
|
|
24
|
+
readonly result: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
25
|
+
readonly logs: Schema.$Array<Schema.String>;
|
|
26
|
+
}>, {}>;
|
|
27
|
+
/**
|
|
28
|
+
* The bounded model-visible success: the program's JSON result plus captured
|
|
29
|
+
* logs, both already passed through the aggregate egress budget (CAP-016).
|
|
30
|
+
*/
|
|
31
|
+
export declare class CodeModeSuccess extends CodeModeSuccess_base {}
|
|
32
|
+
declare const CodeModeFailure_base: Schema.Class<CodeModeFailure, Schema.TaggedStruct<"CodeModeFailure", {
|
|
33
|
+
readonly errorTag: Schema.NonEmptyString;
|
|
34
|
+
readonly message: Schema.String;
|
|
35
|
+
readonly logs: Schema.$Array<Schema.String>;
|
|
36
|
+
readonly thrown: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
37
|
+
/** Invocation-ordered evidence that fits the egress budget. This is not a replay plan. */
|
|
38
|
+
readonly calls: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
39
|
+
readonly sequenceIndex: Schema.Natural;
|
|
40
|
+
readonly toolName: Schema.String;
|
|
41
|
+
readonly status: Schema.Literals<readonly ["not-started", "succeeded", "failed", "uncertain"]>;
|
|
42
|
+
readonly errorTag: Schema.optionalKey<Schema.String>;
|
|
43
|
+
}>>>;
|
|
44
|
+
readonly omittedCalls: Schema.optionalKey<Schema.Natural>;
|
|
45
|
+
}>, Cause.YieldableError>;
|
|
46
|
+
/**
|
|
47
|
+
* The bounded model-visible failure envelope. `failureMode: "return"` turns
|
|
48
|
+
* it into a failed Tool result, so a model can correct a failing program
|
|
49
|
+
* without a blind retry; it carries the same bounded log capture as success
|
|
50
|
+
* plus the bounded thrown value where one exists, all inside the same
|
|
51
|
+
* aggregate egress budget (CAP-016).
|
|
52
|
+
*/
|
|
53
|
+
export declare class CodeModeFailure extends CodeModeFailure_base {}
|
|
54
|
+
declare const CodeModeDescriptionError_base: Schema.Class<CodeModeDescriptionError, Schema.TaggedStruct<"CodeModeDescriptionError", {
|
|
55
|
+
readonly reason: Schema.Literals<readonly ["invalid-selection", "unknown-method", "invalid-bound", "limit-exceeded"]>;
|
|
56
|
+
readonly message: Schema.String;
|
|
57
|
+
}>, Cause.YieldableError>;
|
|
58
|
+
/** A selective documentation request is invalid or cannot fit its declared byte budget. */
|
|
59
|
+
export declare class CodeModeDescriptionError extends CodeModeDescriptionError_base {}
|
|
60
|
+
/** The namespace-record shape accepted by `CodeMode.make`. */
|
|
61
|
+
export type CodeModeNamespaces = Record<string, Record<string, Tool.Any>>;
|
|
62
|
+
/**
|
|
63
|
+
* Union of every Tool selected across all namespaces, computed distributively
|
|
64
|
+
* per namespace: indexing the namespace union with the INTERSECTION of method
|
|
65
|
+
* keys would erase every Tool once two namespaces have disjoint methods.
|
|
66
|
+
*/
|
|
67
|
+
export type CodeModeSelectedTool<Namespaces extends CodeModeNamespaces> = { [Namespace in keyof Namespaces]: Namespaces[Namespace][keyof Namespaces[Namespace]]; }[keyof Namespaces];
|
|
68
|
+
/** The selected Tools re-keyed by their own Tool names. */
|
|
69
|
+
export type CodeModeSelectedRecord<Namespaces extends CodeModeNamespaces> = { readonly [T in CodeModeSelectedTool<Namespaces> as T["name"]]: T; };
|
|
70
|
+
/**
|
|
71
|
+
* The native Effect AI Tool created by `CodeMode.make` (CAP-014). Its only
|
|
72
|
+
* per-call dependency is the engine-provided `ToolBroker`; the `CodeExecutor`
|
|
73
|
+
* and every selected handler and redaction service are construction requirements of the handler
|
|
74
|
+
* Layer instead, so they stay visible in the composed `R`.
|
|
75
|
+
*/
|
|
76
|
+
export type CodeModeTool<Name extends string> = Tool.Tool<Name, {
|
|
77
|
+
readonly parameters: typeof CodeModeParameters;
|
|
78
|
+
readonly success: typeof CodeModeSuccess;
|
|
79
|
+
readonly failure: typeof CodeModeFailure;
|
|
80
|
+
readonly failureMode: "return";
|
|
81
|
+
}, ToolBroker>;
|
|
82
|
+
/** Singleton Tool record provided by one Code Mode handler Layer. */
|
|
83
|
+
export type CodeModeTools<Name extends string> = { readonly [Key in Name]: CodeModeTool<Name>; };
|
|
84
|
+
/** Construction requirements of the Code Mode handler Layer. */
|
|
85
|
+
export type CodeModeLayerRequirements<Namespaces extends CodeModeNamespaces, RedactionRequirements = never> = CodeExecutor | Exclude<RedactionRequirements, Scope.Scope> | Tool.HandlersFor<CodeModeSelectedRecord<Namespaces>> | Tool.HandlerServices<CodeModeSelectedTool<Namespaces>>;
|
|
86
|
+
export interface CodeModeOptions<Namespaces extends CodeModeNamespaces, RedactionRequirements = never> {
|
|
87
|
+
/** Model-visible description; the builder appends the sandbox contract. */
|
|
88
|
+
readonly description: string;
|
|
89
|
+
/** Include all sandbox declarations in the model-facing description. Defaults to true. */
|
|
90
|
+
readonly includeDeclarations?: boolean | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Explicit allowlist: namespace name → method name → native Effect AI
|
|
93
|
+
* Tool. Reads and mutations are allowed; calls requiring additional approval fail closed.
|
|
94
|
+
*/
|
|
95
|
+
readonly tools: Namespaces;
|
|
96
|
+
/** Executor limits for one pass; a bounded default applies when omitted. */
|
|
97
|
+
readonly limits?: CodeExecutionLimits | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Aggregate model-visible egress budget in UTF-8 bytes across the final
|
|
100
|
+
* result, captured logs, and any thrown value (CAP-016). Default 65536.
|
|
101
|
+
*/
|
|
102
|
+
readonly maxEgressBytes?: number | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Host-only ephemeral report after executor resources and invocation fibers close, including
|
|
105
|
+
* failure, defect, and interruption. It contains no arguments/results and is never a checkpoint.
|
|
106
|
+
* Keep this total callback bounded; its services are captured with the handler Layer.
|
|
107
|
+
*/
|
|
108
|
+
readonly onPassExit?: ((report: CodeModePassReport) => Effect.Effect<void, never, RedactionRequirements>) | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Optional aggregate redaction pass applied to the model-visible egress
|
|
111
|
+
* before the byte budget. Its services are acquired with the handler Layer;
|
|
112
|
+
* temporary resources close with each redaction invocation.
|
|
113
|
+
* It must be total; a defect stays a defect.
|
|
114
|
+
*/
|
|
115
|
+
readonly redactEgress?: ((egress: {
|
|
116
|
+
readonly result: Schema.Json;
|
|
117
|
+
readonly logs: ReadonlyArray<string>;
|
|
118
|
+
}) => Effect.Effect<{
|
|
119
|
+
readonly result: Schema.Json;
|
|
120
|
+
readonly logs: ReadonlyArray<string>;
|
|
121
|
+
}, never, RedactionRequirements>) | undefined;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* An immutable Code Mode definition: one model-facing Tool over an explicit
|
|
125
|
+
* allowlist, plus the handler Layer that runs generated programs through the
|
|
126
|
+
* `CodeExecutor` port and the engine-owned broker. It owns no acquired
|
|
127
|
+
* resources.
|
|
128
|
+
*/
|
|
129
|
+
export interface CodeModeDefinition<Name extends string, Namespaces extends CodeModeNamespaces, RedactionRequirements = never> {
|
|
130
|
+
readonly name: Name;
|
|
131
|
+
/** The assembled model-facing description, optionally including all declarations. */
|
|
132
|
+
readonly description: string;
|
|
133
|
+
/** Rendered TypeScript declarations of the sandbox globals (documentation only). */
|
|
134
|
+
readonly declarations: string;
|
|
135
|
+
/**
|
|
136
|
+
* Render complete encoded-schema declarations for 1–64 unique, exact namespace.method names.
|
|
137
|
+
* The UTF-8 byte limit defaults to 16384 and must be an integer from 1 through 262144.
|
|
138
|
+
* Oversized documentation fails rather than truncating a declaration. This host operation
|
|
139
|
+
* does not authorize a model to see the selected methods; filter selections by current
|
|
140
|
+
* visibility and inherited grants before returning its output to a model.
|
|
141
|
+
*/
|
|
142
|
+
readonly describe: (methods: ReadonlyArray<string>, options?: {
|
|
143
|
+
readonly maxBytes?: number | undefined;
|
|
144
|
+
}) => Effect.Effect<string, CodeModeDescriptionError>;
|
|
145
|
+
/** The executor-facing namespace catalog derived from the allowlist. */
|
|
146
|
+
readonly namespaces: ReadonlyArray<CodeExecutionNamespace>;
|
|
147
|
+
readonly limits: CodeExecutionLimits;
|
|
148
|
+
readonly maxEgressBytes: number;
|
|
149
|
+
/** The ordinary Effect AI Tool to include in the model-facing Toolkit. */
|
|
150
|
+
readonly tool: CodeModeTool<Name>;
|
|
151
|
+
/** Handler Layer; selected handler requirements stay visible in `R`. */
|
|
152
|
+
readonly handlers: Layer.Layer<Tool.HandlersFor<CodeModeTools<Name>>, never, CodeModeLayerRequirements<Namespaces, RedactionRequirements>>;
|
|
153
|
+
}
|
|
154
|
+
declare const make: <const Name extends string, Namespaces extends CodeModeNamespaces, RedactionRequirements = never>(name: Name, options: CodeModeOptions<Namespaces, RedactionRequirements>) => CodeModeDefinition<Name, Namespaces, RedactionRequirements>;
|
|
155
|
+
//#endregion
|
|
156
|
+
export { make, CodeMode_d_exports as t };
|
|
157
|
+
//# sourceMappingURL=CodeMode.d.mts.map
|
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
|
|
3
|
+
import { r as IncludesCatalogDocumentation, t as AdditionalToolCatalog } from "../ToolExposure-C93U1sPu.mjs";
|
|
4
|
+
import { t as CurrentToolCatalog } from "../ToolExposure-9uF_Yo0T.mjs";
|
|
5
|
+
import { ToolExecutionClass } from "../engine/DurableStep.mjs";
|
|
6
|
+
import { ProgrammaticCallRecord, ToolBroker } from "../engine/ToolBroker.mjs";
|
|
7
|
+
import { NetworkDisabled } from "../sandbox/Sandbox.mjs";
|
|
8
|
+
import { CodeExecutionHost, CodeExecutionLimits, CodeExecutionNamespace, CodeExecutionRequest, CodeExecutor, JsIdentifier } from "../sandbox/CodeExecutor.mjs";
|
|
9
|
+
import { Tool, Toolkit } from "effect/unstable/ai";
|
|
10
|
+
import { Cause, Context, Duration, Effect, Exit, Option, Schema } from "effect";
|
|
11
|
+
//#region src/capabilities/CodeMode.ts
|
|
12
|
+
var CodeMode_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
+
CodeModeDescriptionError: () => CodeModeDescriptionError,
|
|
14
|
+
CodeModeFailure: () => CodeModeFailure,
|
|
15
|
+
CodeModeParameters: () => CodeModeParameters,
|
|
16
|
+
CodeModePassReport: () => CodeModePassReport,
|
|
17
|
+
CodeModeSuccess: () => CodeModeSuccess,
|
|
18
|
+
make: () => make
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Code Mode (D-035, ADR-0017; capability spec §9.1): one native Effect AI
|
|
22
|
+
* Tool whose input is bounded JavaScript source, executed in one isolated
|
|
23
|
+
* `CodeExecutor` pass that may call an explicit construction-time allowlist
|
|
24
|
+
* of existing Tools through typed sandbox globals and the engine-owned
|
|
25
|
+
* `ToolBroker`. The builder follows the Delegation pattern: an explicit
|
|
26
|
+
* record of selected Tools plus namespace mapping fixed at construction,
|
|
27
|
+
* returning an ordinary Tool and a handler Layer, with no ambient registry
|
|
28
|
+
* (CAP-014). Deployment class `E` only.
|
|
29
|
+
*/
|
|
30
|
+
const maxFailureTextLength = 4096;
|
|
31
|
+
const BoundedFailureText = Schema.String.check(Schema.isMaxLength(maxFailureTextLength));
|
|
32
|
+
const BoundedErrorTag = Schema.NonEmptyString.check(Schema.isMaxLength(256));
|
|
33
|
+
const BoundedLogLine = Schema.String.check(Schema.isMaxLength(16384));
|
|
34
|
+
const BoundedLogs = Schema.Array(BoundedLogLine).check(Schema.isMaxLength(4096));
|
|
35
|
+
const BoundedCode = Schema.NonEmptyString.check(Schema.isMaxLength(524288));
|
|
36
|
+
/** A pass-local report, available to the host even when the caller interrupts execution. */
|
|
37
|
+
const CodeModePassReport = Schema.Struct({
|
|
38
|
+
status: Schema.Literals([
|
|
39
|
+
"completed",
|
|
40
|
+
"failed",
|
|
41
|
+
"interrupted",
|
|
42
|
+
"defect"
|
|
43
|
+
]),
|
|
44
|
+
calls: Schema.Array(ProgrammaticCallRecord)
|
|
45
|
+
});
|
|
46
|
+
const encodedJsonByteLength = (value) => {
|
|
47
|
+
try {
|
|
48
|
+
const encoded = JSON.stringify(value);
|
|
49
|
+
return encoded === void 0 ? void 0 : utf8ByteLength(encoded);
|
|
50
|
+
} catch {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/** Model-decoded Code Mode parameters: one async function expression. */
|
|
55
|
+
const CodeModeParameters = Schema.Struct({ code: BoundedCode });
|
|
56
|
+
/**
|
|
57
|
+
* The bounded model-visible success: the program's JSON result plus captured
|
|
58
|
+
* logs, both already passed through the aggregate egress budget (CAP-016).
|
|
59
|
+
*/
|
|
60
|
+
var CodeModeSuccess = class extends Schema.Class("@effect-agent/capabilities/CodeModeSuccess")({
|
|
61
|
+
result: Schema.Json,
|
|
62
|
+
logs: BoundedLogs
|
|
63
|
+
}) {};
|
|
64
|
+
/**
|
|
65
|
+
* The bounded model-visible failure envelope. `failureMode: "return"` turns
|
|
66
|
+
* it into a failed Tool result, so a model can correct a failing program
|
|
67
|
+
* without a blind retry; it carries the same bounded log capture as success
|
|
68
|
+
* plus the bounded thrown value where one exists, all inside the same
|
|
69
|
+
* aggregate egress budget (CAP-016).
|
|
70
|
+
*/
|
|
71
|
+
var CodeModeFailure = class extends Schema.TaggedError()("CodeModeFailure", {
|
|
72
|
+
errorTag: BoundedErrorTag,
|
|
73
|
+
message: BoundedFailureText,
|
|
74
|
+
logs: BoundedLogs,
|
|
75
|
+
thrown: Schema.optionalKey(Schema.Json),
|
|
76
|
+
/** Invocation-ordered evidence that fits the egress budget. This is not a replay plan. */
|
|
77
|
+
calls: Schema.optionalKey(Schema.Array(ProgrammaticCallRecord)),
|
|
78
|
+
omittedCalls: Schema.optionalKey(Schema.Natural)
|
|
79
|
+
}) {};
|
|
80
|
+
/** A selective documentation request is invalid or cannot fit its declared byte budget. */
|
|
81
|
+
var CodeModeDescriptionError = class extends Schema.TaggedError()("CodeModeDescriptionError", {
|
|
82
|
+
reason: Schema.Literals([
|
|
83
|
+
"invalid-selection",
|
|
84
|
+
"unknown-method",
|
|
85
|
+
"invalid-bound",
|
|
86
|
+
"limit-exceeded"
|
|
87
|
+
]),
|
|
88
|
+
message: BoundedFailureText
|
|
89
|
+
}) {};
|
|
90
|
+
const DescriptionMethods = Schema.Array(Schema.NonEmptyString.check(Schema.isMaxLength(257))).check(Schema.isMinLength(1), Schema.isMaxLength(64), Schema.isUnique());
|
|
91
|
+
const DescriptionByteLimit = Schema.Int.check(Schema.isBetween({
|
|
92
|
+
minimum: 1,
|
|
93
|
+
maximum: 262144
|
|
94
|
+
}));
|
|
95
|
+
const defaultLimits = CodeExecutionLimits.make({
|
|
96
|
+
maxSourceBytes: 262144,
|
|
97
|
+
maxWallTime: Duration.seconds(30),
|
|
98
|
+
maxLogBytes: 262144,
|
|
99
|
+
maxResultBytes: 1048576,
|
|
100
|
+
maxHostCalls: 64,
|
|
101
|
+
maxHostCallArgumentBytes: 262144,
|
|
102
|
+
maxHostCallResultBytes: 1048576
|
|
103
|
+
});
|
|
104
|
+
const defaultMaxEgressBytes = 65536;
|
|
105
|
+
const MAX_RENDER_DEPTH = 24;
|
|
106
|
+
const isJsonSchemaRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
107
|
+
const renderJsonSchemaType = (schema, defs, depth, indent) => {
|
|
108
|
+
if (depth > MAX_RENDER_DEPTH) throw new Error("Code Mode declaration rendering exceeded its depth bound");
|
|
109
|
+
if (!isJsonSchemaRecord(schema)) throw new Error(`Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema)}`);
|
|
110
|
+
const reference = schema.$ref;
|
|
111
|
+
if (typeof reference === "string") {
|
|
112
|
+
const match = /^#\/\$defs\/(.+)$/.exec(reference);
|
|
113
|
+
const key = match === null ? void 0 : match[1].replaceAll("~1", "/").replaceAll("~0", "~");
|
|
114
|
+
const resolved = key === void 0 ? void 0 : defs[key];
|
|
115
|
+
if (resolved === void 0) throw new Error(`Code Mode cannot resolve the JSON schema reference ${reference}`);
|
|
116
|
+
return renderJsonSchemaType(resolved, defs, depth + 1, indent);
|
|
117
|
+
}
|
|
118
|
+
if (Array.isArray(schema.enum)) return schema.enum.map((value) => JSON.stringify(value)).join(" | ");
|
|
119
|
+
if ("const" in schema) return JSON.stringify(schema.const);
|
|
120
|
+
const union = schema.anyOf ?? schema.oneOf;
|
|
121
|
+
if (Array.isArray(union)) return union.map((member) => renderJsonSchemaType(member, defs, depth + 1, indent)).join(" | ");
|
|
122
|
+
const type = schema.type;
|
|
123
|
+
if (Array.isArray(type)) return type.map((member) => renderJsonSchemaType({
|
|
124
|
+
...schema,
|
|
125
|
+
type: member
|
|
126
|
+
}, defs, depth + 1, indent)).join(" | ");
|
|
127
|
+
switch (type) {
|
|
128
|
+
case "string": return "string";
|
|
129
|
+
case "number":
|
|
130
|
+
case "integer": return "number";
|
|
131
|
+
case "boolean": return "boolean";
|
|
132
|
+
case "null": return "null";
|
|
133
|
+
case "array":
|
|
134
|
+
if (!("items" in schema)) throw new Error("Code Mode cannot render an array schema without items");
|
|
135
|
+
return `ReadonlyArray<${renderJsonSchemaType(schema.items, defs, depth + 1, indent)}>`;
|
|
136
|
+
case "object":
|
|
137
|
+
case void 0:
|
|
138
|
+
if (isJsonSchemaRecord(schema.properties)) {
|
|
139
|
+
const required = Array.isArray(schema.required) ? schema.required : [];
|
|
140
|
+
const inner = `${indent} `;
|
|
141
|
+
const fields = Object.entries(schema.properties).map(([key, property]) => {
|
|
142
|
+
const optional = required.includes(key) ? "" : "?";
|
|
143
|
+
const rendered = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
|
|
144
|
+
return `${inner}readonly ${rendered}${optional}: ${renderJsonSchemaType(property, defs, depth + 1, inner)};`;
|
|
145
|
+
});
|
|
146
|
+
return fields.length === 0 ? "{}" : `{\n${fields.join("\n")}\n${indent}}`;
|
|
147
|
+
}
|
|
148
|
+
if (isJsonSchemaRecord(schema.additionalProperties)) return `Record<string, ${renderJsonSchemaType(schema.additionalProperties, defs, depth + 1, indent)}>`;
|
|
149
|
+
if (type === "object" && !("properties" in schema) && !("additionalProperties" in schema)) return "Record<string, unknown>";
|
|
150
|
+
}
|
|
151
|
+
throw new Error(`Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema).slice(0, 200)}; fix or simplify the Tool's Schema`);
|
|
152
|
+
};
|
|
153
|
+
const renderTopLevel = (jsonSchema, indent) => {
|
|
154
|
+
const defs = isJsonSchemaRecord(jsonSchema) && isJsonSchemaRecord(jsonSchema.$defs) ? jsonSchema.$defs : {};
|
|
155
|
+
return renderJsonSchemaType(jsonSchema, defs, 0, indent);
|
|
156
|
+
};
|
|
157
|
+
const decodeIdentifier = Schema.decodeUnknownOption(JsIdentifier);
|
|
158
|
+
const renderDeclarations = (methods) => {
|
|
159
|
+
const namespaces = /* @__PURE__ */ new Map();
|
|
160
|
+
for (const method of methods) {
|
|
161
|
+
const existing = namespaces.get(method.namespace) ?? [];
|
|
162
|
+
existing.push(method);
|
|
163
|
+
namespaces.set(method.namespace, existing);
|
|
164
|
+
}
|
|
165
|
+
return [...namespaces.entries()].map(([namespace, members]) => {
|
|
166
|
+
return `declare const ${namespace}: {\n${members.map((member) => {
|
|
167
|
+
const parameters = renderTopLevel(Tool.getJsonSchema(member.tool), " ");
|
|
168
|
+
const success = renderTopLevel(Tool.getJsonSchemaFromSchema(member.tool.successSchema), " ");
|
|
169
|
+
const safeDescription = member.tool.description?.replaceAll("*/", "*\\/").replaceAll(/\s*\n\s*/g, " ");
|
|
170
|
+
return `${safeDescription === void 0 ? "" : ` /** ${safeDescription} */\n`} ${member.method}(input: ${parameters}): Promise<${success}>;`;
|
|
171
|
+
}).join("\n")}\n};`;
|
|
172
|
+
}).join("\n\n");
|
|
173
|
+
};
|
|
174
|
+
const truncationMarker = "… logs truncated by the egress budget";
|
|
175
|
+
const MAX_EGRESS_LOG_LINE_CHARACTERS = 16e3;
|
|
176
|
+
/**
|
|
177
|
+
* Budget charge of one log line as it actually crosses to the model: the
|
|
178
|
+
* JSON-encoded string (quotes, escapes) plus one array separator. Charging
|
|
179
|
+
* raw UTF-8 would undercount model-visible bytes for escape-heavy content.
|
|
180
|
+
*/
|
|
181
|
+
const encodedLogLineBytes = (line) => {
|
|
182
|
+
try {
|
|
183
|
+
return utf8ByteLength(JSON.stringify(line)) + 1;
|
|
184
|
+
} catch {
|
|
185
|
+
return Number.MAX_SAFE_INTEGER;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const budgetedLogs = (logs, remainingBytes) => {
|
|
189
|
+
const kept = [];
|
|
190
|
+
let used = 0;
|
|
191
|
+
let truncated = false;
|
|
192
|
+
for (const raw of logs) {
|
|
193
|
+
const line = raw.length > MAX_EGRESS_LOG_LINE_CHARACTERS ? `${raw.slice(0, 15999)}…` : raw;
|
|
194
|
+
const bytes = encodedLogLineBytes(line);
|
|
195
|
+
if (kept.length >= 4096 || used + bytes > remainingBytes) {
|
|
196
|
+
truncated = true;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
kept.push(line);
|
|
200
|
+
used += bytes;
|
|
201
|
+
}
|
|
202
|
+
if (truncated) {
|
|
203
|
+
const markerBytes = encodedLogLineBytes(truncationMarker);
|
|
204
|
+
while (kept.length > 0 && used + markerBytes > remainingBytes) used -= encodedLogLineBytes(kept.pop() ?? "");
|
|
205
|
+
if (markerBytes <= remainingBytes) kept.push(truncationMarker);
|
|
206
|
+
}
|
|
207
|
+
return kept;
|
|
208
|
+
};
|
|
209
|
+
const boundedMessage = (message) => message.slice(0, maxFailureTextLength);
|
|
210
|
+
const executionFailureMessage = (error) => {
|
|
211
|
+
switch (error._tag) {
|
|
212
|
+
case "CodeExecutionTimeoutError": return `The program exceeded its ${Duration.format(error.maxWallTime)} ${error.kind} budget`;
|
|
213
|
+
case "CodeOutputLimitError": return `The ${error.surface} limit of ${error.limit} bytes was exceeded (${error.observed} bytes observed)`;
|
|
214
|
+
case "CodeHostCallLimitError": return `The pass exceeded its executor cap of ${error.limit} host calls`;
|
|
215
|
+
default: return error.message;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
/** UTF-8-aware truncation so a message can never exceed the aggregate budget. */
|
|
219
|
+
const truncateToUtf8Bytes = (value, maxBytes) => {
|
|
220
|
+
if (utf8ByteLength(value) <= maxBytes) return value;
|
|
221
|
+
let output = "";
|
|
222
|
+
let used = 0;
|
|
223
|
+
for (const character of value) {
|
|
224
|
+
const bytes = utf8ByteLength(character);
|
|
225
|
+
if (used + bytes + 3 > maxBytes) break;
|
|
226
|
+
output += character;
|
|
227
|
+
used += bytes;
|
|
228
|
+
}
|
|
229
|
+
return `${output}…`;
|
|
230
|
+
};
|
|
231
|
+
const make = (name, options) => {
|
|
232
|
+
const limits = options.limits ?? defaultLimits;
|
|
233
|
+
const maxEgressBytes = options.maxEgressBytes ?? defaultMaxEgressBytes;
|
|
234
|
+
if (!Number.isSafeInteger(maxEgressBytes) || maxEgressBytes < 256 || maxEgressBytes > 4194304) throw new Error(`Code Mode maxEgressBytes must be an integer between 256 and 4194304; received ${String(maxEgressBytes)}`);
|
|
235
|
+
const methods = [];
|
|
236
|
+
const toolsByName = /* @__PURE__ */ new Map();
|
|
237
|
+
const methodToTool = /* @__PURE__ */ new Map();
|
|
238
|
+
for (const [namespace, namespaceMethods] of Object.entries(options.tools)) {
|
|
239
|
+
if (Option.isNone(decodeIdentifier(namespace))) throw new Error(`Code Mode namespace ${namespace} is not a valid JavaScript identifier`);
|
|
240
|
+
const entries = Object.entries(namespaceMethods);
|
|
241
|
+
if (entries.length === 0) throw new Error(`Code Mode namespace ${namespace} declares no methods`);
|
|
242
|
+
for (const [method, tool] of entries) {
|
|
243
|
+
if (Option.isNone(decodeIdentifier(method))) throw new Error(`Code Mode method ${namespace}.${method} is not a valid JavaScript identifier`);
|
|
244
|
+
const approval = tool.needsApproval;
|
|
245
|
+
if (approval !== void 0 && approval !== false) throw new Error(`Code Mode rejects Tool ${tool.name} (${namespace}.${method}): approval-requiring Tools cannot be invoked programmatically in the ephemeral slice`);
|
|
246
|
+
const existing = toolsByName.get(tool.name);
|
|
247
|
+
if (existing !== void 0 && existing !== tool) throw new Error(`Code Mode selected two different Tools named ${tool.name}; Tool names must identify one Tool`);
|
|
248
|
+
toolsByName.set(tool.name, tool);
|
|
249
|
+
methodToTool.set(`${namespace}.${method}`, tool.name);
|
|
250
|
+
methods.push({
|
|
251
|
+
namespace,
|
|
252
|
+
method,
|
|
253
|
+
tool
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (methods.length === 0) throw new Error("Code Mode requires at least one allowlisted Tool");
|
|
258
|
+
const declarations = renderDeclarations(methods);
|
|
259
|
+
const methodsByPath = new Map(methods.map((method) => [`${method.namespace}.${method.method}`, method]));
|
|
260
|
+
const describe = Effect.fn("CodeMode.describe")(function* (selected, options) {
|
|
261
|
+
const paths = yield* Schema.decodeEffect(DescriptionMethods)(selected).pipe(Effect.mapError(() => CodeModeDescriptionError.make({
|
|
262
|
+
reason: "invalid-selection",
|
|
263
|
+
message: "Select between 1 and 64 unique namespace.method names, each at most 257 characters"
|
|
264
|
+
})));
|
|
265
|
+
const maxBytes = yield* Schema.decodeEffect(DescriptionByteLimit)(options?.maxBytes ?? 16384).pipe(Effect.mapError(() => CodeModeDescriptionError.make({
|
|
266
|
+
reason: "invalid-bound",
|
|
267
|
+
message: "The documentation byte limit must be an integer between 1 and 262144"
|
|
268
|
+
})));
|
|
269
|
+
const selectedMethods = [];
|
|
270
|
+
for (const path of paths) {
|
|
271
|
+
const method = methodsByPath.get(path);
|
|
272
|
+
if (method === void 0) return yield* CodeModeDescriptionError.make({
|
|
273
|
+
reason: "unknown-method",
|
|
274
|
+
message: "The selection contains a method outside this Code Mode allowlist"
|
|
275
|
+
});
|
|
276
|
+
selectedMethods.push(method);
|
|
277
|
+
}
|
|
278
|
+
const documentation = renderDeclarations(selectedMethods);
|
|
279
|
+
if (utf8ByteLength(documentation) > maxBytes) return yield* CodeModeDescriptionError.make({
|
|
280
|
+
reason: "limit-exceeded",
|
|
281
|
+
message: `The selected declarations exceed the ${maxBytes}-byte documentation limit; select fewer methods or raise the limit`
|
|
282
|
+
});
|
|
283
|
+
return documentation;
|
|
284
|
+
});
|
|
285
|
+
const namespaces = [...new Set(methods.map((method) => method.namespace))].map((namespace) => CodeExecutionNamespace.make({
|
|
286
|
+
name: namespace,
|
|
287
|
+
methods: methods.filter((method) => method.namespace === namespace).map((method) => method.method)
|
|
288
|
+
}));
|
|
289
|
+
const description = [
|
|
290
|
+
options.description,
|
|
291
|
+
"",
|
|
292
|
+
"The `code` argument must be one JavaScript async function expression; the sandbox invokes it exactly once with no arguments. It runs isolated with no ambient network, filesystem, environment, or secrets. Return one JSON value. `console.log` output is captured within a bounded budget and returned alongside the result.",
|
|
293
|
+
"Namespace methods return Promises. An expected Tool failure rejects with a JSON envelope carrying a stable `_tag`; catch it to branch. Use Promise.all for independent calls; the host bounds concurrency. Await every call you need. Writes may complete before a failure: inspect call outcomes and never blindly retry a program.",
|
|
294
|
+
...options.includeDeclarations === false ? [] : [
|
|
295
|
+
"",
|
|
296
|
+
"Sandbox globals:",
|
|
297
|
+
"```ts",
|
|
298
|
+
declarations,
|
|
299
|
+
"```"
|
|
300
|
+
]
|
|
301
|
+
].join("\n");
|
|
302
|
+
const tool = Tool.make(name, {
|
|
303
|
+
description,
|
|
304
|
+
parameters: CodeModeParameters,
|
|
305
|
+
success: CodeModeSuccess,
|
|
306
|
+
failure: CodeModeFailure,
|
|
307
|
+
failureMode: "return"
|
|
308
|
+
}).annotate(Tool.Readonly, false).annotate(ToolExecutionClass, "uncertain").annotate(IncludesCatalogDocumentation, options.includeDeclarations !== false).annotate(AdditionalToolCatalog, Object.freeze(methods.map((method) => Object.freeze({ ...method })))).addDependency(ToolBroker);
|
|
309
|
+
const outerToolkit = Toolkit.make(tool);
|
|
310
|
+
/**
|
|
311
|
+
* The nested namespace record collapses into one Toolkit keyed by exact
|
|
312
|
+
* Tool names. The assertion restores the name-keyed record type TypeScript
|
|
313
|
+
* cannot compute from `Map` iteration; construction above guarantees the
|
|
314
|
+
* name uniqueness the type states.
|
|
315
|
+
*/
|
|
316
|
+
const selectedToolkit = Toolkit.make(...toolsByName.values());
|
|
317
|
+
const executionRequest = (code, visibleNamespaces) => CodeExecutionRequest.make({
|
|
318
|
+
language: "javascript",
|
|
319
|
+
source: code,
|
|
320
|
+
namespaces: visibleNamespaces,
|
|
321
|
+
network: NetworkDisabled.make({}),
|
|
322
|
+
limits
|
|
323
|
+
});
|
|
324
|
+
const routeHostCall = (pass, hostCall, visiblePaths) => Effect.gen(function* () {
|
|
325
|
+
const path = `${hostCall.namespace}.${hostCall.method}`;
|
|
326
|
+
const toolName = visiblePaths === void 0 || visiblePaths.has(path) ? methodToTool.get(path) : void 0;
|
|
327
|
+
if (toolName === void 0) return {
|
|
328
|
+
_tag: "CodeHostCallFailure",
|
|
329
|
+
error: {
|
|
330
|
+
_tag: "UnknownCodeModeMethod",
|
|
331
|
+
message: "The requested method is not available in this pass"
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
const outcome = yield* pass.invoke({
|
|
335
|
+
toolName,
|
|
336
|
+
encodedArguments: hostCall.argument
|
|
337
|
+
});
|
|
338
|
+
switch (outcome._tag) {
|
|
339
|
+
case "ProgrammaticCallSuccess": {
|
|
340
|
+
const value = decodeBrokerJson(outcome.encodedResult);
|
|
341
|
+
return Option.isSome(value) ? {
|
|
342
|
+
_tag: "CodeHostCallSuccess",
|
|
343
|
+
value: value.value
|
|
344
|
+
} : {
|
|
345
|
+
_tag: "CodeHostCallFailure",
|
|
346
|
+
error: brokerProtocolEnvelope
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
case "ProgrammaticCallFailure": {
|
|
350
|
+
const value = decodeBrokerJson(outcome.encodedResult);
|
|
351
|
+
return {
|
|
352
|
+
_tag: "CodeHostCallFailure",
|
|
353
|
+
error: Option.isSome(value) ? value.value : brokerProtocolEnvelope
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
case "ProgrammaticCallError": return {
|
|
357
|
+
_tag: "CodeHostCallFailure",
|
|
358
|
+
error: {
|
|
359
|
+
_tag: outcome.errorTag,
|
|
360
|
+
message: outcome.message
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
const build = Effect.gen(function* () {
|
|
366
|
+
const captured = yield* Effect.context();
|
|
367
|
+
const redactionServices = yield* Effect.context();
|
|
368
|
+
const configuredRedactor = options.redactEgress;
|
|
369
|
+
const redact = configuredRedactor === void 0 ? void 0 : (egress) => Effect.scoped(configuredRedactor(egress)).pipe(Effect.updateContext((current) => Context.merge(current, redactionServices)));
|
|
370
|
+
const withHandler = yield* selectedToolkit;
|
|
371
|
+
const executor = yield* CodeExecutor;
|
|
372
|
+
const successEgress = (execution) => Effect.gen(function* () {
|
|
373
|
+
let egress = {
|
|
374
|
+
result: execution.value,
|
|
375
|
+
logs: execution.logs
|
|
376
|
+
};
|
|
377
|
+
if (redact !== void 0) egress = yield* redact(egress);
|
|
378
|
+
const resultBytes = encodedJsonByteLength(egress.result);
|
|
379
|
+
if (resultBytes === void 0 || resultBytes > maxEgressBytes) return yield* CodeModeFailure.make({
|
|
380
|
+
errorTag: "CodeModeEgressExceeded",
|
|
381
|
+
message: `The program result of ${resultBytes ?? "unencodable"} bytes exceeds the ${maxEgressBytes}-byte model-visible egress budget; return a smaller value`,
|
|
382
|
+
logs: budgetedLogs(egress.logs, Math.max(0, maxEgressBytes - 256))
|
|
383
|
+
});
|
|
384
|
+
return CodeModeSuccess.make({
|
|
385
|
+
result: egress.result,
|
|
386
|
+
logs: budgetedLogs(egress.logs, maxEgressBytes - resultBytes)
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
/**
|
|
390
|
+
* The failure half of the aggregate egress policy (CAP-016): the configured
|
|
391
|
+
* redaction pass covers failure logs and thrown values exactly like success
|
|
392
|
+
* egress — a program cannot leak by logging and then throwing — and the
|
|
393
|
+
* message itself is bounded by the budget, not only by its own schema cap.
|
|
394
|
+
*/
|
|
395
|
+
const failureEgress = (error) => Effect.gen(function* () {
|
|
396
|
+
if (error._tag === "ToolBrokerUnavailableError" || error._tag === "ToolBrokerConfigurationError") return CodeModeFailure.make({
|
|
397
|
+
errorTag: error._tag,
|
|
398
|
+
message: truncateToUtf8Bytes(boundedMessage(error.message), maxEgressBytes),
|
|
399
|
+
logs: []
|
|
400
|
+
});
|
|
401
|
+
let logs = "logs" in error ? error.logs : [];
|
|
402
|
+
let candidateThrown = error._tag === "CodeProgramFailedError" ? error.thrown : void 0;
|
|
403
|
+
if (redact !== void 0) {
|
|
404
|
+
const redacted = yield* redact({
|
|
405
|
+
result: candidateThrown ?? null,
|
|
406
|
+
logs
|
|
407
|
+
});
|
|
408
|
+
logs = redacted.logs;
|
|
409
|
+
candidateThrown = candidateThrown === void 0 ? void 0 : redacted.result;
|
|
410
|
+
}
|
|
411
|
+
const message = truncateToUtf8Bytes(boundedMessage(executionFailureMessage(error)), maxEgressBytes);
|
|
412
|
+
const messageBytes = utf8ByteLength(message);
|
|
413
|
+
const candidateBytes = candidateThrown === void 0 ? void 0 : encodedJsonByteLength(candidateThrown);
|
|
414
|
+
const includeThrown = candidateThrown !== void 0 && candidateBytes !== void 0 && messageBytes + candidateBytes <= maxEgressBytes;
|
|
415
|
+
const remaining = Math.max(0, maxEgressBytes - messageBytes - (includeThrown ? candidateBytes ?? 0 : 0));
|
|
416
|
+
return CodeModeFailure.make({
|
|
417
|
+
errorTag: error._tag,
|
|
418
|
+
message,
|
|
419
|
+
logs: budgetedLogs(logs, remaining),
|
|
420
|
+
...includeThrown ? { thrown: candidateThrown } : {}
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
const invoke = Effect.fn(`CodeMode.${name}`)(function* (parameters) {
|
|
424
|
+
const broker = yield* ToolBroker;
|
|
425
|
+
const catalogue = yield* Effect.serviceOption(CurrentToolCatalog);
|
|
426
|
+
const visiblePaths = Option.isNone(catalogue) ? void 0 : new Set(catalogue.value.entries.flatMap((entry) => entry.kind === "code-mode" && entry.nativeToolName === name && methodsByPath.get(`${entry.namespace}.${entry.method}`)?.tool.name === entry.tool.name ? [`${entry.namespace}.${entry.method}`] : []));
|
|
427
|
+
const visibleNamespaces = visiblePaths === void 0 ? namespaces : namespaces.flatMap((namespace) => {
|
|
428
|
+
const allowed = namespace.methods.filter((method) => visiblePaths.has(`${namespace.name}.${method}`));
|
|
429
|
+
return allowed.length === 0 ? [] : [CodeExecutionNamespace.make({
|
|
430
|
+
name: namespace.name,
|
|
431
|
+
methods: allowed
|
|
432
|
+
})];
|
|
433
|
+
});
|
|
434
|
+
let calls = [];
|
|
435
|
+
return yield* Effect.gen(function* () {
|
|
436
|
+
const pass = yield* broker.openPass(withHandler, {
|
|
437
|
+
maxResultBytes: limits.maxHostCallResultBytes,
|
|
438
|
+
concurrency: limits.maxHostCallConcurrency ?? 4
|
|
439
|
+
});
|
|
440
|
+
const host = CodeExecutionHost.of({ call: (hostCall) => routeHostCall(pass, hostCall, visiblePaths) });
|
|
441
|
+
return yield* executor.execute(executionRequest(parameters.code, visibleNamespaces)).pipe(Effect.provideService(CodeExecutionHost, host), Effect.scoped, Effect.onExit((exit) => Effect.gen(function* () {
|
|
442
|
+
calls = yield* pass.snapshot;
|
|
443
|
+
if (options.onPassExit !== void 0) yield* Effect.scoped(options.onPassExit({
|
|
444
|
+
status: Exit.isSuccess(exit) ? "completed" : Cause.hasInterrupts(exit.cause) ? "interrupted" : Cause.hasDies(exit.cause) ? "defect" : "failed",
|
|
445
|
+
calls
|
|
446
|
+
})).pipe(Effect.provideContext(redactionServices));
|
|
447
|
+
})));
|
|
448
|
+
}).pipe(Effect.scoped, Effect.provideService(ToolBroker, broker), Effect.provideContext(captured)).pipe(Effect.catch((error) => failureEgress(error).pipe(Effect.flatMap(Effect.fail))), Effect.flatMap(successEgress), Effect.mapError((failure) => {
|
|
449
|
+
if (calls.length === 0) return failure;
|
|
450
|
+
const complete = CodeModeFailure.make({
|
|
451
|
+
errorTag: failure.errorTag,
|
|
452
|
+
message: failure.message,
|
|
453
|
+
logs: failure.logs,
|
|
454
|
+
...failure.thrown === void 0 ? {} : { thrown: failure.thrown },
|
|
455
|
+
calls,
|
|
456
|
+
omittedCalls: 0
|
|
457
|
+
});
|
|
458
|
+
if ((encodedJsonByteLength(complete) ?? Infinity) <= maxEgressBytes) return complete;
|
|
459
|
+
const base = {
|
|
460
|
+
errorTag: failure.errorTag,
|
|
461
|
+
message: truncateToUtf8Bytes(failure.message, Math.min(256, maxEgressBytes / 4)),
|
|
462
|
+
logs: []
|
|
463
|
+
};
|
|
464
|
+
const kept = [];
|
|
465
|
+
for (const call of calls) {
|
|
466
|
+
const candidate = CodeModeFailure.make({
|
|
467
|
+
...base,
|
|
468
|
+
calls: [...kept, call],
|
|
469
|
+
omittedCalls: calls.length - kept.length - 1
|
|
470
|
+
});
|
|
471
|
+
if ((encodedJsonByteLength(candidate) ?? Infinity) > maxEgressBytes) break;
|
|
472
|
+
kept.push(call);
|
|
473
|
+
}
|
|
474
|
+
return CodeModeFailure.make({
|
|
475
|
+
...base,
|
|
476
|
+
calls: kept,
|
|
477
|
+
omittedCalls: calls.length - kept.length
|
|
478
|
+
});
|
|
479
|
+
}));
|
|
480
|
+
});
|
|
481
|
+
return { [name]: invoke };
|
|
482
|
+
});
|
|
483
|
+
/**
|
|
484
|
+
* TypeScript cannot unify the two spellings of the singleton Tool record
|
|
485
|
+
* (`CodeModeTools<Name>` versus the toolkit's name-remapped form) over a
|
|
486
|
+
* generic `Name`, nor reduce the deferred `Exclude` when `toLayer`
|
|
487
|
+
* subtracts what `build` consumed; the assertions pin the layer to its
|
|
488
|
+
* documented requirement surface and never bypass validation.
|
|
489
|
+
*/
|
|
490
|
+
const handlers = outerToolkit.toLayer(build);
|
|
491
|
+
return Object.freeze({
|
|
492
|
+
name,
|
|
493
|
+
description,
|
|
494
|
+
declarations,
|
|
495
|
+
describe,
|
|
496
|
+
namespaces,
|
|
497
|
+
limits,
|
|
498
|
+
maxEgressBytes,
|
|
499
|
+
tool,
|
|
500
|
+
handlers
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Fail-closed JSON boundary for broker outcomes: hostile values can throw
|
|
505
|
+
* from trap getters during decode, and a value outside the JSON surface must
|
|
506
|
+
* become a typed failure envelope — never a fabricated success.
|
|
507
|
+
*/
|
|
508
|
+
const decodeBrokerJson = (value) => {
|
|
509
|
+
try {
|
|
510
|
+
return Schema.decodeUnknownOption(Schema.Json)(value);
|
|
511
|
+
} catch {
|
|
512
|
+
return Option.none();
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
const brokerProtocolEnvelope = {
|
|
516
|
+
_tag: "CodeModeProtocolError",
|
|
517
|
+
message: "The broker returned a value outside the JSON surface"
|
|
518
|
+
};
|
|
519
|
+
//#endregion
|
|
520
|
+
export { CodeModeDescriptionError, CodeModeFailure, CodeModeParameters, CodeModePassReport, CodeModeSuccess, make, CodeMode_exports as t };
|
|
521
|
+
|
|
522
|
+
//# sourceMappingURL=CodeMode.mjs.map
|