effect-agent 0.1.0-beta.164 → 0.1.0-beta.165
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/{Admin-Vhz6NdaH.d.mts → Admin-CbwoQEm8.d.mts} +24 -24
- package/dist/{Agent-BMATXYsI.mjs → Agent-B0WrUcHy.mjs} +9 -9
- package/dist/Agent-B0WrUcHy.mjs.map +1 -0
- package/dist/{Agent-ZfnNCQXs.d.mts → Agent-D0fbFT2d.d.mts} +27 -24
- package/dist/{AgentError-Bn1ytXRD.d.mts → AgentError-BMqPzIVt.d.mts} +3 -3
- package/dist/{AgentPolicy-B4oH8TbG.d.mts → AgentPolicy-CclAEpHn.d.mts} +2 -2
- package/dist/{AgentRuntime-D1MmB_0z.d.mts → AgentRuntime-BM36roNi.d.mts} +44 -30
- package/dist/{AgentRuntime-Q50HloUc.mjs → AgentRuntime-BTfPyMXN.mjs} +91 -30
- package/dist/AgentRuntime-BTfPyMXN.mjs.map +1 -0
- package/dist/{AgentUpdates-DMJ-_xow.d.mts → AgentUpdates-DksV4D0A.d.mts} +6 -3
- package/dist/{ContextCompactor-BoKQOjr5.d.mts → ContextCompactor-DLpX-HUG.d.mts} +18 -12
- package/dist/{ContextWindow-DRQ5Mbm2.d.mts → ContextWindow-aGZOPIPq.d.mts} +24 -22
- package/dist/{Digest-COAt3Orl.d.mts → Digest-3l_02jaM.d.mts} +2 -2
- package/dist/{DurableAgentRuntime-BTMOgDl_.mjs → DurableAgentRuntime-CWmWREPj.mjs} +11 -11
- package/dist/{DurableAgentRuntime-BTMOgDl_.mjs.map → DurableAgentRuntime-CWmWREPj.mjs.map} +1 -1
- package/dist/{DurableStep-Cry_iol4.d.mts → DurableStep-CTqx6DOV.d.mts} +13 -11
- package/dist/{EventSource-CtS0RBM7.d.mts → EventSource-D29Jsj5U.d.mts} +3 -3
- package/dist/{FailureDiagnostic-BElLOoED.mjs → FailureDiagnostic-D9oW23Cn.mjs} +16 -10
- package/dist/FailureDiagnostic-D9oW23Cn.mjs.map +1 -0
- package/dist/{FailureDiagnostic-CaAkzGHL.d.mts → FailureDiagnostic-DvHruCSJ.d.mts} +10 -9
- package/dist/InMemory.d.mts +28 -5
- package/dist/InMemory.mjs +37 -4
- package/dist/InMemory.mjs.map +1 -1
- package/dist/{Messaging-CICd_CSi.d.mts → Messaging-BbuaphiQ.d.mts} +6 -6
- package/dist/{Messaging-7VXQnWI3.d.mts → Messaging-DF_IWnxV.d.mts} +5 -5
- package/dist/{MessagingHost-DXwWnrMh.d.mts → MessagingHost-Bfbfkx6f.d.mts} +13 -12
- package/dist/{MessagingHost-DfsbMPvq.mjs → MessagingHost-DJZJZILu.mjs} +4 -3
- package/dist/MessagingHost-DJZJZILu.mjs.map +1 -0
- package/dist/{Output-CY7NZByV.d.mts → Output-UsQKiPhz.d.mts} +4 -4
- package/dist/{PreparedInputAdmission-CS_zlCvD.d.mts → PreparedInputAdmission-DXvjTe4U.d.mts} +6 -6
- package/dist/{Receipt-BAHyigAF.d.mts → Receipt-BkM21Qiu.d.mts} +2 -2
- package/dist/{Records-Bm4Qt70a.d.mts → Records-CAQktL0z.d.mts} +8 -8
- package/dist/{RunEvent-D0aepYwN.d.mts → RunEvent-B3CRIqIC.d.mts} +5 -5
- package/dist/{RunEventSink-9CUdI9Ar.d.mts → RunEventSink-sDXDkrAl.d.mts} +9 -7
- package/dist/{RunJournal-D8Vvf_io.mjs → RunJournal-NRgq1PNe.mjs} +3 -3
- package/dist/{RunJournal-D8Vvf_io.mjs.map → RunJournal-NRgq1PNe.mjs.map} +1 -1
- package/dist/{RunOptions-BHmBa05n.d.mts → RunOptions-CkSZSuIh.d.mts} +87 -83
- package/dist/{RunPolicyUsage-CUudVtg_.d.mts → RunPolicyUsage-QmYVw9z8.d.mts} +2 -2
- package/dist/{Schedule-Bi_XVKLF.d.mts → Schedule-rEIiYnRq.d.mts} +4 -4
- package/dist/{Subagent-Cxvuaius.mjs → Subagent-C-fyHbcp.mjs} +5 -5
- package/dist/{Subagent-Cxvuaius.mjs.map → Subagent-C-fyHbcp.mjs.map} +1 -1
- package/dist/{Subagent-D59om8SR.d.mts → Subagent-t3pJDZMN.d.mts} +15 -15
- package/dist/{SubagentContract-tyN9v-Jv.d.mts → SubagentContract-DdPzxYQj.d.mts} +3 -2
- package/dist/{SubagentHost-VTyf_wEF.d.mts → SubagentHost-CXFlEpj0.d.mts} +19 -16
- package/dist/{Subscription-nbSNY6Hs.d.mts → Subscription-BJj-R-6V.d.mts} +8 -8
- package/dist/{SubscriptionInput-DbXnOMS2.d.mts → SubscriptionInput-DyQtODg2.d.mts} +3 -3
- package/dist/Thread-DT8RTLIQ.d.mts +117 -0
- package/dist/{ThreadHistory-FD-o4TsR.d.mts → ThreadHistory-DQ-IC1hU.d.mts} +12 -9
- package/dist/{ToolBroker-DWs4tZra.d.mts → ToolBroker-DXwv2aUT.d.mts} +14 -12
- package/dist/{ToolExposure-UCN12eCd.d.mts → ToolExposure-BsaSH15e.d.mts} +5 -4
- package/dist/{ToolExposure-r2eOWk4F.d.mts → ToolExposure-Ckg3-sTf.d.mts} +3 -2
- package/dist/{ToolExposure-9uF_Yo0T.mjs → ToolExposure-DBATXxmL.mjs} +2 -2
- package/dist/ToolExposure-DBATXxmL.mjs.map +1 -0
- package/dist/{ToolExposure-C93U1sPu.mjs → ToolExposure-hTJT2ekj.mjs} +3 -2
- package/dist/ToolExposure-hTJT2ekj.mjs.map +1 -0
- package/dist/ToolExposure.d.mts +2 -2
- package/dist/ToolExposure.mjs +2 -2
- package/dist/{ToolResult-BKdqWRff.d.mts → ToolResult-DqyEhJLF.d.mts} +2 -2
- package/dist/{Usage-BNjPR7Zr.d.mts → Usage-CzZJ6A2n.d.mts} +3 -2
- package/dist/{Worker-XEBYxRQv.d.mts → Worker-DH5SAVIK.d.mts} +7 -7
- package/dist/{Worker-CfwzMZEK.mjs → Worker-DZjdMjZn.mjs} +3 -3
- package/dist/Worker-DZjdMjZn.mjs.map +1 -0
- package/dist/{WorkerAdmission-BVbSB8_A.mjs → WorkerAdmission-DJ76C2b-.mjs} +4 -4
- package/dist/{WorkerAdmission-BVbSB8_A.mjs.map → WorkerAdmission-DJ76C2b-.mjs.map} +1 -1
- package/dist/{agent-registration-BIOzAej4.mjs → agent-registration-D1dWV7KK.mjs} +3 -3
- package/dist/{agent-registration-BIOzAej4.mjs.map → agent-registration-D1dWV7KK.mjs.map} +1 -1
- package/dist/capabilities/BrowserUse.d.mts +1 -1
- package/dist/capabilities/BrowserUse.mjs +1 -1
- package/dist/capabilities/CodeMode.d.mts +2 -2
- package/dist/capabilities/CodeMode.mjs +3 -3
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/ContextTools.d.mts +2 -2
- package/dist/capabilities/ContextTools.mjs +1 -1
- package/dist/capabilities/Mcp.d.mts +1 -1
- package/dist/capabilities/Mcp.mjs +1 -1
- package/dist/capabilities/McpClient.d.mts +1 -1
- package/dist/capabilities/McpClient.mjs +1 -1
- package/dist/capabilities/MemoryNotes.d.mts +2 -2
- package/dist/capabilities/MemoryNotes.mjs +1 -1
- package/dist/capabilities/Messaging.d.mts +2 -2
- package/dist/capabilities/Messaging.mjs +3 -3
- package/dist/capabilities/ModelContext.d.mts +1 -1
- package/dist/capabilities/Redaction.d.mts +1 -1
- package/dist/capabilities/RunHooks.d.mts +7 -6
- package/dist/capabilities/RunHooks.mjs +2 -1
- package/dist/capabilities/RunHooks.mjs.map +1 -1
- package/dist/capabilities/SemanticMemory.d.mts +1 -1
- package/dist/capabilities/SemanticMemory.mjs +1 -1
- package/dist/capabilities/Subagent.d.mts +3 -3
- package/dist/capabilities/Subagent.mjs +2 -2
- package/dist/capabilities/SubagentReservations.d.mts +64 -60
- package/dist/capabilities/SubagentReservations.mjs +6 -1
- package/dist/capabilities/SubagentReservations.mjs.map +1 -1
- package/dist/capabilities/ToolDiscovery.d.mts +2 -2
- package/dist/capabilities/ToolDiscovery.mjs +3 -3
- package/dist/capabilities/WebCapture.d.mts +1 -1
- package/dist/capabilities/WebCapture.mjs +1 -1
- package/dist/capabilities/WebSearch.d.mts +1 -1
- package/dist/capabilities/WebSearch.mjs +1 -1
- package/dist/{compaction-BQK4MUg3.mjs → compaction-FDJhjbzH.mjs} +4 -3
- package/dist/compaction-FDJhjbzH.mjs.map +1 -0
- package/dist/core/Agent.d.mts +1 -1
- package/dist/core/Agent.mjs +1 -1
- package/dist/core/AgentError.d.mts +1 -1
- package/dist/core/AgentError.mjs +4 -4
- package/dist/core/AgentError.mjs.map +1 -1
- package/dist/core/AgentPolicy.d.mts +1 -1
- package/dist/core/AgentUpdates.d.mts +1 -1
- package/dist/core/AgentUpdates.mjs +5 -1
- package/dist/core/AgentUpdates.mjs.map +1 -1
- package/dist/core/FailureDiagnostic.d.mts +1 -1
- package/dist/core/FailureDiagnostic.mjs +1 -1
- package/dist/core/IdGenerator.d.mts +3 -1
- package/dist/core/IdGenerator.mjs +8 -5
- package/dist/core/IdGenerator.mjs.map +1 -1
- package/dist/core/Receipt.d.mts +1 -1
- package/dist/core/Receipt.mjs +1 -1
- package/dist/core/Receipt.mjs.map +1 -1
- package/dist/core/RunEvent.d.mts +1 -1
- package/dist/core/RunEvent.mjs +2 -2
- package/dist/core/RunEvent.mjs.map +1 -1
- package/dist/core/RunPolicyUsage.d.mts +1 -1
- package/dist/core/RunPolicyUsage.mjs +1 -1
- package/dist/core/RunPolicyUsage.mjs.map +1 -1
- package/dist/core/SubagentContract.d.mts +1 -1
- package/dist/core/SubagentContract.mjs +2 -1
- package/dist/core/SubagentContract.mjs.map +1 -1
- package/dist/core/Thread.d.mts +2 -2
- package/dist/core/Thread.mjs +82 -33
- package/dist/core/Thread.mjs.map +1 -1
- package/dist/core/ToolResult.d.mts +1 -1
- package/dist/core/ToolResult.mjs +1 -1
- package/dist/core/ToolResult.mjs.map +1 -1
- package/dist/core/Usage.d.mts +1 -1
- package/dist/core/Usage.mjs +2 -1
- package/dist/core/Usage.mjs.map +1 -1
- package/dist/core/Worker.d.mts +2 -2
- package/dist/core/Worker.mjs +1 -1
- package/dist/durable/ActivityStore.d.mts +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/AgentRegistration.d.mts +1 -1
- package/dist/durable/AgentRegistration.mjs +1 -1
- package/dist/durable/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +3 -3
- package/dist/durable/Digest.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +2 -2
- package/dist/durable/DurableAgentRuntime.mjs +2 -2
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +4 -4
- package/dist/durable/GitHubWorkflowSource.mjs +1 -1
- package/dist/durable/LifecyclePublication.d.mts +1 -1
- package/dist/durable/LifecyclePublication.mjs +1 -1
- package/dist/durable/MessageDelivery.d.mts +9 -9
- package/dist/durable/MessageDelivery.mjs +2 -2
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +28 -28
- package/dist/durable/MessageDeliveryStoreConformance.mjs +1 -1
- package/dist/durable/PersistentHistory.d.mts +2 -2
- package/dist/durable/PersistentHistory.mjs +2 -2
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/PreparedInputAdmission.mjs +1 -1
- package/dist/durable/Records.d.mts +1 -1
- package/dist/durable/Records.mjs +5 -5
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/RunJournal.d.mts +1 -1
- package/dist/durable/RunJournal.mjs +1 -1
- package/dist/durable/Schedule.d.mts +1 -1
- package/dist/durable/Schedule.mjs +1 -1
- package/dist/durable/ScheduleStoreConformance.d.mts +1 -1
- package/dist/durable/ScheduleTransition.d.mts +1 -1
- package/dist/durable/Scheduling.d.mts +4 -4
- package/dist/durable/SubmissionLedger.d.mts +2 -2
- package/dist/durable/SubmissionLedger.mjs +3 -3
- package/dist/durable/SubmissionLedgerConformance.d.mts +2 -2
- package/dist/durable/SubmissionLedgerConformance.mjs +3 -3
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/Subscription.mjs +1 -1
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionInput.mjs +1 -1
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionTools.d.mts +7 -7
- package/dist/durable/SubscriptionTools.mjs +1 -1
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/Subscriptions.d.mts +7 -7
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
- package/dist/durable/ThreadContextHistoryProjection.mjs +2 -2
- package/dist/durable/ThreadInvariants.d.mts +2 -2
- package/dist/durable/ThreadInvariants.mjs +1 -1
- package/dist/durable/ThreadProjection.d.mts +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStore.mjs +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.mjs +1 -1
- package/dist/durable/WorkerAdmission.d.mts +6 -6
- package/dist/durable/WorkerAdmission.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +7 -7
- package/dist/durable/WorkerHost.mjs +1 -1
- package/dist/engine/AgentRuntime.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/engine/Compaction.d.mts +1 -1
- package/dist/engine/Compaction.mjs +1 -1
- package/dist/engine/ContextCompactor.d.mts +1 -1
- package/dist/engine/ContextCompactor.mjs +8 -3
- package/dist/engine/ContextCompactor.mjs.map +1 -1
- package/dist/engine/ContextWindow.d.mts +1 -1
- package/dist/engine/ContextWindow.mjs +3 -1
- package/dist/engine/ContextWindow.mjs.map +1 -1
- package/dist/engine/DurableStep.d.mts +1 -1
- package/dist/engine/DurableStep.mjs +2 -1
- package/dist/engine/DurableStep.mjs.map +1 -1
- package/dist/engine/MessagingHost.d.mts +1 -1
- package/dist/engine/MessagingHost.mjs +1 -1
- package/dist/engine/Output.d.mts +1 -1
- package/dist/engine/Output.mjs +1 -1
- package/dist/engine/RunEventSink.d.mts +1 -1
- package/dist/engine/RunEventSink.mjs +2 -1
- package/dist/engine/RunEventSink.mjs.map +1 -1
- package/dist/engine/RunOptions.d.mts +1 -1
- package/dist/engine/RunOptions.mjs +5 -2
- package/dist/engine/RunOptions.mjs.map +1 -1
- package/dist/engine/SubagentHost.d.mts +1 -1
- package/dist/engine/SubagentHost.mjs +4 -2
- package/dist/engine/SubagentHost.mjs.map +1 -1
- package/dist/engine/ThreadHistory.d.mts +1 -1
- package/dist/engine/ThreadHistory.mjs +12 -10
- package/dist/engine/ThreadHistory.mjs.map +1 -1
- package/dist/engine/ToolBroker.d.mts +1 -1
- package/dist/engine/ToolBroker.mjs +2 -1
- package/dist/engine/ToolBroker.mjs.map +1 -1
- package/dist/index.d.mts +34 -34
- package/dist/index.mjs +9 -9
- package/dist/{output-contract-DS-S8mTv.mjs → output-contract-DUNIO6as.mjs} +4 -3
- package/dist/output-contract-DUNIO6as.mjs.map +1 -0
- package/package.json +1 -1
- package/src/InMemory.ts +61 -2
- package/src/capabilities/RunHooks.ts +6 -3
- package/src/capabilities/SubagentReservations.ts +7 -1
- package/src/core/Agent.ts +3 -8
- package/src/core/AgentError.ts +1 -1
- package/src/core/AgentUpdates.ts +5 -1
- package/src/core/FailureDiagnostic.ts +6 -8
- package/src/core/IdGenerator.ts +5 -2
- package/src/core/Messaging.ts +1 -1
- package/src/core/Receipt.ts +1 -1
- package/src/core/RunEvent.ts +1 -1
- package/src/core/RunPolicyUsage.ts +1 -1
- package/src/core/SubagentContract.ts +2 -1
- package/src/core/Thread.ts +163 -61
- package/src/core/ToolExposure.ts +2 -1
- package/src/core/ToolResult.ts +1 -1
- package/src/core/Usage.ts +2 -1
- package/src/core/Worker.ts +1 -1
- package/src/core/internal/agent-updates.ts +3 -2
- package/src/core/internal/message-status.ts +1 -1
- package/src/core/internal/strict-schema.ts +3 -1
- package/src/engine/ContextCompactor.ts +8 -2
- package/src/engine/ContextWindow.ts +4 -1
- package/src/engine/DurableStep.ts +2 -1
- package/src/engine/MessagingHost.ts +2 -1
- package/src/engine/RunEventSink.ts +2 -1
- package/src/engine/RunOptions.ts +5 -1
- package/src/engine/SubagentHost.ts +3 -1
- package/src/engine/ThreadHistory.ts +20 -10
- package/src/engine/ToolBroker.ts +2 -1
- package/src/engine/ToolExposure.ts +2 -1
- package/src/engine/internal/agent-runtime.ts +41 -49
- package/src/engine/internal/bounded-value.ts +2 -1
- package/src/engine/internal/compaction.ts +3 -2
- package/src/engine/internal/output-contract.ts +3 -2
- package/src/engine/internal/primitive-delta.ts +51 -10
- package/src/engine/internal/tool-derivative.ts +5 -1
- package/src/engine/internal/tool-exposure.ts +5 -2
- package/src/engine/internal/tool-telemetry.ts +12 -13
- package/dist/Agent-BMATXYsI.mjs.map +0 -1
- package/dist/AgentRuntime-Q50HloUc.mjs.map +0 -1
- package/dist/FailureDiagnostic-BElLOoED.mjs.map +0 -1
- package/dist/MessagingHost-DfsbMPvq.mjs.map +0 -1
- package/dist/Thread-DOBQ0QUY.d.mts +0 -96
- package/dist/ToolExposure-9uF_Yo0T.mjs.map +0 -1
- package/dist/ToolExposure-C93U1sPu.mjs.map +0 -1
- package/dist/Worker-CfwzMZEK.mjs.map +0 -1
- package/dist/compaction-BQK4MUg3.mjs.map +0 -1
- package/dist/output-contract-DS-S8mTv.mjs.map +0 -1
|
@@ -1,40 +1,36 @@
|
|
|
1
1
|
import type { Take } from "effect";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Response,
|
|
35
|
-
ResponseIdTracker,
|
|
36
|
-
Toolkit,
|
|
37
|
-
} from "effect/unstable/ai";
|
|
2
|
+
import * as Cause from "effect/Cause";
|
|
3
|
+
import * as Channel from "effect/Channel";
|
|
4
|
+
import * as Clock from "effect/Clock";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
import * as DateTime from "effect/DateTime";
|
|
7
|
+
import * as Duration from "effect/Duration";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Equal from "effect/Equal";
|
|
10
|
+
import * as Exit from "effect/Exit";
|
|
11
|
+
import * as Fiber from "effect/Fiber";
|
|
12
|
+
import * as Layer from "effect/Layer";
|
|
13
|
+
import * as Metric from "effect/Metric";
|
|
14
|
+
import * as Option from "effect/Option";
|
|
15
|
+
import * as PubSub from "effect/PubSub";
|
|
16
|
+
import * as Queue from "effect/Queue";
|
|
17
|
+
import * as Result from "effect/Result";
|
|
18
|
+
import * as Schedule from "effect/Schedule";
|
|
19
|
+
import * as Schema from "effect/Schema";
|
|
20
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
21
|
+
import * as SchemaGetter from "effect/SchemaGetter";
|
|
22
|
+
import * as Scope from "effect/Scope";
|
|
23
|
+
import * as Semaphore from "effect/Semaphore";
|
|
24
|
+
import * as Stream from "effect/Stream";
|
|
25
|
+
import * as Tracer from "effect/Tracer";
|
|
26
|
+
import * as AiError from "effect/unstable/ai/AiError";
|
|
27
|
+
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
28
|
+
import * as Model from "effect/unstable/ai/Model";
|
|
29
|
+
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
30
|
+
import * as Response from "effect/unstable/ai/Response";
|
|
31
|
+
import * as ResponseIdTracker from "effect/unstable/ai/ResponseIdTracker";
|
|
32
|
+
import * as Tool from "effect/unstable/ai/Tool";
|
|
33
|
+
import * as Toolkit from "effect/unstable/ai/Toolkit";
|
|
38
34
|
|
|
39
35
|
import * as Agent from "../../core/Agent.ts";
|
|
40
36
|
import {
|
|
@@ -143,7 +139,7 @@ import { ThreadHistory, ThreadHistoryError } from "../ThreadHistory.ts";
|
|
|
143
139
|
import { CurrentToolCatalog, RunToolVisibility, type CatalogEntry } from "../ToolExposure.ts";
|
|
144
140
|
import { boundedValueFootprint } from "./bounded-value.ts";
|
|
145
141
|
import { isTextOutput, outputSchemaContract, prepareModelPrompt } from "./output-contract.ts";
|
|
146
|
-
import {
|
|
142
|
+
import { ownPrimitiveTextPart } from "./primitive-delta.ts";
|
|
147
143
|
import {
|
|
148
144
|
boundedCanonicalJsonSnapshot,
|
|
149
145
|
boundedJsonSnapshot,
|
|
@@ -995,12 +991,10 @@ const ownModelResponsePartGeneral = Effect.fnUntraced(function* <
|
|
|
995
991
|
}
|
|
996
992
|
const codec = modelResponseCodecFor(toolkit);
|
|
997
993
|
|
|
998
|
-
const encodingFailure = ModelProtocolError.make({
|
|
999
|
-
message: "Model response part failed canonical encoding",
|
|
1000
|
-
});
|
|
1001
|
-
|
|
1002
994
|
const encoded = yield* Schema.encodeUnknownEffect(codec)(part).pipe(
|
|
1003
|
-
Effect.mapError(() =>
|
|
995
|
+
Effect.mapError(() =>
|
|
996
|
+
ModelProtocolError.make({ message: "Model response part failed canonical encoding" }),
|
|
997
|
+
),
|
|
1004
998
|
);
|
|
1005
999
|
|
|
1006
1000
|
const retainedBytes = yield* inspectModelResponsePartCapacity(usage, encoded, limits);
|
|
@@ -1020,12 +1014,10 @@ const ownModelResponsePartGeneral = Effect.fnUntraced(function* <
|
|
|
1020
1014
|
}),
|
|
1021
1015
|
});
|
|
1022
1016
|
|
|
1023
|
-
const decodingFailure = ModelProtocolError.make({
|
|
1024
|
-
message: "Model response part failed canonical decoding",
|
|
1025
|
-
});
|
|
1026
|
-
|
|
1027
1017
|
const ownedPart = yield* Schema.decodeUnknownEffect(codec)(ownedEncoded).pipe(
|
|
1028
|
-
Effect.mapError(() =>
|
|
1018
|
+
Effect.mapError(() =>
|
|
1019
|
+
ModelProtocolError.make({ message: "Model response part failed canonical decoding" }),
|
|
1020
|
+
),
|
|
1029
1021
|
);
|
|
1030
1022
|
|
|
1031
1023
|
return { ownedPart, retainedBytes };
|
|
@@ -1040,7 +1032,7 @@ const ownModelResponsePart = <Tools extends Record<string, Tool.Any>>(
|
|
|
1040
1032
|
Effect.suspend((): ReturnType<typeof ownModelResponsePartGeneral> => {
|
|
1041
1033
|
const primitive =
|
|
1042
1034
|
usage.responsePartCount < limits.maxModelResponseParts
|
|
1043
|
-
?
|
|
1035
|
+
? ownPrimitiveTextPart(part, limits.maxModelResponseBytes - usage.responsePartBytes)
|
|
1044
1036
|
: undefined;
|
|
1045
1037
|
|
|
1046
1038
|
return primitive === undefined
|
|
@@ -1992,7 +1984,7 @@ const terminalToolTelemetry = (
|
|
|
1992
1984
|
).pipe(
|
|
1993
1985
|
Effect.andThen(
|
|
1994
1986
|
(outcome === "success"
|
|
1995
|
-
? Effect.
|
|
1987
|
+
? Effect.logDebug("agent tool execution completed")
|
|
1996
1988
|
: Effect.logWarning("agent tool execution failed")
|
|
1997
1989
|
).pipe(
|
|
1998
1990
|
Effect.annotateLogs({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as Option from "effect/Option";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
3
4
|
|
|
4
5
|
import type { ContextMessageTokenEstimator } from "../ContextCompactor.ts";
|
|
5
6
|
import { boundedCanonicalJsonSnapshot } from "./provider-result-staging.ts";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
3
|
+
import * as Tool from "effect/unstable/ai/Tool";
|
|
3
4
|
|
|
4
5
|
import type * as Agent from "../../core/Agent.ts";
|
|
5
6
|
|
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as Option from "effect/Option";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as Response from "effect/unstable/ai/Response";
|
|
3
4
|
|
|
4
5
|
import { utf8ByteLength } from "../../core/internal/utf8.ts";
|
|
5
6
|
import { boundedValueFootprint } from "./bounded-value.ts";
|
|
6
7
|
|
|
7
8
|
const brand = "~effect/ai/Response/Part";
|
|
8
9
|
const keys = [brand, "type", "id", "delta", "metadata"];
|
|
10
|
+
const boundaryKeys = [brand, "type", "id", "metadata"];
|
|
9
11
|
|
|
10
12
|
const decode = Schema.decodeUnknownOption(
|
|
11
|
-
Schema.toType(
|
|
13
|
+
Schema.toType(
|
|
14
|
+
Schema.Union([
|
|
15
|
+
Response.TextDeltaPart,
|
|
16
|
+
Response.ReasoningDeltaPart,
|
|
17
|
+
Response.TextStartPart,
|
|
18
|
+
Response.TextEndPart,
|
|
19
|
+
Response.ReasoningStartPart,
|
|
20
|
+
Response.ReasoningEndPart,
|
|
21
|
+
]),
|
|
22
|
+
),
|
|
12
23
|
);
|
|
13
24
|
|
|
14
25
|
const overhead = (type: "text-delta" | "reasoning-delta") => ({
|
|
@@ -22,29 +33,49 @@ const overhead = (type: "text-delta" | "reasoning-delta") => ({
|
|
|
22
33
|
),
|
|
23
34
|
});
|
|
24
35
|
|
|
36
|
+
const boundaryOverhead = (
|
|
37
|
+
type: "text-start" | "text-end" | "reasoning-start" | "reasoning-end",
|
|
38
|
+
) => ({
|
|
39
|
+
source: boundedValueFootprint(Response.makePart(type, { id: "" }), Number.MAX_SAFE_INTEGER),
|
|
40
|
+
encoded: boundedValueFootprint({ type, id: "", metadata: {} }, Number.MAX_SAFE_INTEGER),
|
|
41
|
+
});
|
|
42
|
+
|
|
25
43
|
const overheads = {
|
|
26
44
|
"text-delta": overhead("text-delta"),
|
|
27
45
|
"reasoning-delta": overhead("reasoning-delta"),
|
|
46
|
+
"text-start": boundaryOverhead("text-start"),
|
|
47
|
+
"text-end": boundaryOverhead("text-end"),
|
|
48
|
+
"reasoning-start": boundaryOverhead("reasoning-start"),
|
|
49
|
+
"reasoning-end": boundaryOverhead("reasoning-end"),
|
|
28
50
|
};
|
|
29
51
|
|
|
30
52
|
/**
|
|
31
|
-
* Copy
|
|
53
|
+
* Copy primitive text and reasoning parts into owned data before native Schema validation.
|
|
32
54
|
* Descriptor checks select this optimization; they do not replace the native codec.
|
|
33
55
|
* Extra fields, accessors, and nonempty metadata use the general ownership path.
|
|
34
56
|
* No provider object survives, including an empty metadata object's hidden storage.
|
|
35
57
|
* Unlike a generic footprint shortcut, this cannot retain an exotic backing buffer.
|
|
36
58
|
*/
|
|
37
|
-
export const
|
|
59
|
+
export const ownPrimitiveTextPart = (part: unknown, maxBytes: number) => {
|
|
38
60
|
try {
|
|
39
61
|
if (part === null || typeof part !== "object") return undefined;
|
|
40
62
|
if (Array.isArray(part) || ArrayBuffer.isView(part)) return undefined;
|
|
41
63
|
const prototype = Object.getPrototypeOf(part);
|
|
42
64
|
|
|
43
65
|
if (prototype !== Object.prototype && prototype !== null) return undefined;
|
|
44
|
-
|
|
66
|
+
const typeDescriptor = Object.getOwnPropertyDescriptor(part, "type");
|
|
67
|
+
|
|
68
|
+
if (typeDescriptor === undefined || !("value" in typeDescriptor)) return undefined;
|
|
69
|
+
|
|
70
|
+
const isDelta =
|
|
71
|
+
typeDescriptor.value === "text-delta" || typeDescriptor.value === "reasoning-delta";
|
|
72
|
+
|
|
73
|
+
const selectedKeys = isDelta ? keys : boundaryKeys;
|
|
74
|
+
|
|
75
|
+
if (Reflect.ownKeys(part).length !== selectedKeys.length) return undefined;
|
|
45
76
|
const snapshot: Record<string, unknown> = {};
|
|
46
77
|
|
|
47
|
-
for (const key of
|
|
78
|
+
for (const key of selectedKeys) {
|
|
48
79
|
const descriptor = Object.getOwnPropertyDescriptor(part, key);
|
|
49
80
|
|
|
50
81
|
if (descriptor === undefined || !("value" in descriptor)) return undefined;
|
|
@@ -52,8 +83,18 @@ export const ownPrimitiveDelta = (part: unknown, maxBytes: number) => {
|
|
|
52
83
|
}
|
|
53
84
|
const { type, id, delta, metadata } = snapshot;
|
|
54
85
|
|
|
55
|
-
if (
|
|
56
|
-
|
|
86
|
+
if (
|
|
87
|
+
type !== "text-delta" &&
|
|
88
|
+
type !== "reasoning-delta" &&
|
|
89
|
+
type !== "text-start" &&
|
|
90
|
+
type !== "text-end" &&
|
|
91
|
+
type !== "reasoning-start" &&
|
|
92
|
+
type !== "reasoning-end"
|
|
93
|
+
) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
if (isDelta !== (type === "text-delta" || type === "reasoning-delta")) return undefined;
|
|
97
|
+
if (typeof id !== "string" || (isDelta && typeof delta !== "string")) return undefined;
|
|
57
98
|
if (metadata === null || typeof metadata !== "object") return undefined;
|
|
58
99
|
if (Array.isArray(metadata) || ArrayBuffer.isView(metadata)) return undefined;
|
|
59
100
|
const metadataPrototype = Object.getPrototypeOf(metadata);
|
|
@@ -63,7 +104,7 @@ export const ownPrimitiveDelta = (part: unknown, maxBytes: number) => {
|
|
|
63
104
|
const fixed = overheads[type];
|
|
64
105
|
|
|
65
106
|
if (fixed.source === undefined || fixed.encoded === undefined) return undefined;
|
|
66
|
-
const bytes = utf8ByteLength(id) + utf8ByteLength(delta);
|
|
107
|
+
const bytes = utf8ByteLength(id) + (typeof delta === "string" ? utf8ByteLength(delta) : 0);
|
|
67
108
|
|
|
68
109
|
if (bytes + fixed.source > maxBytes || bytes + fixed.encoded > maxBytes) return undefined;
|
|
69
110
|
// Never pass the provider's metadata object (or any other object) to the decoder.
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Cause from "effect/Cause";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as ErrorReporter from "effect/ErrorReporter";
|
|
4
|
+
import * as Exit from "effect/Exit";
|
|
5
|
+
import * as Stream from "effect/Stream";
|
|
2
6
|
|
|
3
7
|
import type { RunToolFailureObserver, ToolFailureObservation } from "../RunOptions.ts";
|
|
4
8
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import type { LanguageModel } from "effect/unstable/ai";
|
|
5
|
+
import * as Tool from "effect/unstable/ai/Tool";
|
|
3
6
|
|
|
4
7
|
import type { AnyDefinition } from "../../core/Agent.ts";
|
|
5
8
|
import { ModelProtocolError } from "../../core/AgentError.ts";
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import { AiError, type Tool } from "effect/unstable/ai";
|
|
1
|
+
import type { Fiber } from "effect";
|
|
2
|
+
import * as Cause from "effect/Cause";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as ErrorReporter from "effect/ErrorReporter";
|
|
6
|
+
import * as Exit from "effect/Exit";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
9
|
+
import * as Stream from "effect/Stream";
|
|
10
|
+
import * as Tracer from "effect/Tracer";
|
|
11
|
+
import type { Tool } from "effect/unstable/ai";
|
|
12
|
+
import * as AiError from "effect/unstable/ai/AiError";
|
|
14
13
|
|
|
15
14
|
import type { ToolFailureHandling } from "../../core/RunEvent.ts";
|
|
16
15
|
import { isolateToolDerivative } from "./tool-derivative.ts";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Agent-BMATXYsI.mjs","names":[],"sources":["../src/core/internal/agent-updates.ts","../src/core/Agent.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { Tool, Toolkit } from \"effect/unstable/ai\";\n\nimport { Emitter, UpdateError } from \"../AgentUpdates.ts\";\n\n/** Definition-owned native Tool. Runtime supplies its handler under the same identity. */\nexport const updateTool = <S extends Schema.Top>(schema: S) =>\n Tool.make(\"emit_update\", {\n description:\n \"Emit a structured intermediate update. Success acknowledges acceptance by this Run; \" +\n \"parent delivery and processing are separate. This does not complete the task.\",\n parameters: Schema.Struct({ value: schema }),\n success: Schema.Struct({ emitted: Schema.Literal(true) }),\n failure: UpdateError,\n failureMode: \"return\",\n }).addDependency(Emitter);\n\nexport type UpdateToolkit<\n T extends Toolkit.Any,\n S extends Schema.Top | undefined,\n> = S extends Schema.Top\n ? Toolkit.Toolkit<T[\"tools\"] & { readonly emit_update: ReturnType<typeof updateTool<S>> }>\n : T;\n\nexport const withUpdateTool = (\n toolkit: Toolkit.Any,\n schema: Schema.Top | undefined,\n): Toolkit.Any => {\n if (schema === undefined) return toolkit;\n if (Object.hasOwn(toolkit.tools, \"emit_update\"))\n throw new TypeError(\"emit_update is reserved for Agent updates\");\n\n return Toolkit.make(...Object.values(toolkit.tools), updateTool(schema));\n};\n","import type { Effect, Layer, Option, Schema } from \"effect\";\nimport * as S from \"effect/Schema\";\nimport {\n type AiError,\n type LanguageModel,\n type Model,\n type Prompt,\n Tool,\n Toolkit,\n} from \"effect/unstable/ai\";\n\nimport type { AgentInputError, AgentOutputError, AgentRunDispositionError } from \"./AgentError.ts\";\nimport { AgentPolicy, type AgentPolicyInput } from \"./AgentPolicy.ts\";\nimport { AgentId } from \"./Identifiers.ts\";\nimport { type UpdateToolkit, withUpdateTool } from \"./internal/agent-updates.ts\";\nimport type { Configuration } from \"./ToolExposure.ts\";\n\n/** Prompt input produced directly or by an Effect that preserves its failure and requirements. */\nexport type InstructionResult<E = never, R = never> =\n | Prompt.RawInput\n | Effect.Effect<Prompt.RawInput, E, R>;\n\n/** Static prompt input or an input-dependent source evaluated once while preparing a run. */\nexport type InstructionSource<Input, E = never, R = never> =\n | Prompt.RawInput\n | ((input: Input) => InstructionResult<E, R>);\n\n/** Definition-owned projection from decoded Agent input to model-visible prompt content. */\nexport type InputPromptSource<Input, E = never, R = never> = (\n input: Input,\n) => InstructionResult<E, R>;\n\n/** Native services needed to execute and identify model calls. */\nexport type ModelServices = LanguageModel.LanguageModel | Model.ProviderName | Model.ModelName;\n\n/**\n * An optional capability on a provided LanguageModel service. The runtime supplies\n * only model-visible task context and eligible Tool descriptions after validating input.\n * The resolver owns retaining one choice per Thread, including across Runs and\n * recovery; it captures client requirements and returns a closed native Layer\n * that the interpreter acquires for the Run. Context hooks may prepare prompts\n * but cannot replace this model through a per-Turn modelCall.\n * Selection failures remain AiError values and all selector/client services stay in R.\n */\nexport interface ModelResolver extends LanguageModel.LanguageModel {\n readonly resolve: (request: {\n readonly threadId: string;\n readonly state: Schema.JsonObject;\n }) => Effect.Effect<Layer.Layer<ModelServices>, AiError.AiError>;\n}\n\n/** Detect the deferred resolver capability on a trusted, host-provided model service. */\nexport const isModelResolver = (model: LanguageModel.LanguageModel): model is ModelResolver =>\n \"resolve\" in model && typeof model.resolve === \"function\";\n\n/** Accepts native model Layers that provide generation and model identity. */\nexport type NativeModel<ModelValue> =\n ModelValue extends Layer.Layer<infer Provides, never, infer _Requires>\n ? ModelServices extends Provides\n ? ModelValue\n : never\n : never;\n\n/** Definition-owned boundary for selecting and validating an application run disposition. */\nexport interface RunDispositionDeclaration<Output, DispositionSchema extends Schema.Top> {\n /**\n * Opt background workers into one retained assignment. The encoded disposition must be\n * Worker.AssignmentDisposition: completed seals the worker, waiting leaves it steerable.\n * Failures and exhausted Runs seal as failed; aborting an active Run seals as cancelled.\n * The worker origin retains this choice. Omission preserves reusable workers.\n */\n readonly workerLifecycle?: \"assignment\" | undefined;\n /** Canonical Schema used to validate and encode the selected disposition. */\n readonly schema: DispositionSchema;\n /** Pure selection from decoded output. `undefined` declares none, except for assignments. */\n readonly fromOutput: (output: Output) => unknown;\n}\n\n/** Values available to a Definition-owned completion Tool projector after canonical decoding. */\nexport interface CompletionProjectionInput<Parameters = unknown, Result = unknown> {\n readonly parameters: Parameters;\n readonly result: Result;\n}\n\n/**\n * One application Tool whose successful result can complete its owning Agent when it is the\n * only application call. Provider-executed calls may accompany it only with terminal results.\n * Mixed, wholly unexecuted application batches are rejected with failed Tool results so the\n * model can correct them within ordinary Run budgets; completed provider results are retained.\n * Missing provider results and invalid pending resumed batches fail closed. The completion\n * designation never permits side-effect replay.\n */\nexport interface CompletionToolDeclaration<\n Parameters = unknown,\n Result = unknown,\n Output = unknown,\n> {\n readonly tool: string;\n /** Require native Tool use on every model Turn and this Tool for final completion. */\n readonly required?: boolean | undefined;\n readonly project: (input: CompletionProjectionInput<Parameters, Result>) => Output;\n}\n\ntype CompletionToolFor<ToolkitValue extends Toolkit.Any, Output> = {\n readonly [Name in keyof ToolkitValue[\"tools\"] & string]: CompletionToolDeclaration<\n Tool.Parameters<ToolkitValue[\"tools\"][Name]>,\n Tool.Success<ToolkitValue[\"tools\"][Name]>,\n Output\n > & { readonly tool: Name };\n}[keyof ToolkitValue[\"tools\"] & string];\n\n/**\n * An ordinary action Tool whose canonical success may satisfy the whole request.\n * Projectors must be pure and deterministic: recovery re-evaluates them. None preserves\n * ordinary continuation; Some is validated as the Agent output. These Tools must be the sole\n * application call; terminal provider results may accompany them. They never receive the\n * required completion Tool's exhaustion allowance.\n */\nexport interface CompletionFromToolDeclaration<\n Parameters = unknown,\n Result = unknown,\n Output = unknown,\n> {\n readonly tool: string;\n readonly project: (input: CompletionProjectionInput<Parameters, Result>) => Option.Option<Output>;\n}\n\ntype CompletionFromToolFor<ToolkitValue extends Toolkit.Any, Output> = {\n readonly [Name in keyof ToolkitValue[\"tools\"] & string]: CompletionFromToolDeclaration<\n Tool.Parameters<ToolkitValue[\"tools\"][Name]>,\n Tool.Success<ToolkitValue[\"tools\"][Name]>,\n Output\n > & { readonly tool: Name };\n}[keyof ToolkitValue[\"tools\"] & string];\n\n/** Immutable, model-agnostic schemas, behavior, tools, and bounds for an agent. */\nexport interface Definition<\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions,\n ToolkitValue extends Toolkit.Any,\n RunDispositionValue = undefined,\n InputPromptValue = undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n> {\n /** Stable agent identity; changing it creates a distinct definition identity. */\n readonly id: AgentId;\n /** Canonical Schema for intermediate updates emitted by this Agent. */\n readonly updates?: UpdatesSchema;\n /** Canonical schema used to decode and encode run input. */\n readonly input: InputSchema;\n /** Canonical schema used to decode the final model output. */\n readonly output: OutputSchema;\n /**\n * Evaluated once while preparing each Run. OpenAI, xAI and native adapters advertising support\n * preserve chronological system messages, omitting exact repeats only when no distinct system\n * instruction intervenes. The actual selected model determines support on each call. Other\n * adapters group systems first and keep the last exact repeat, including provider options;\n * Anthropic requires an upstream adapter with mid-conversation system-message support.\n * Stored history is unchanged.\n */\n readonly instructions: Instructions;\n /** Optional projection from decoded input to model-visible native Effect AI prompt content. */\n readonly inputPrompt?: InputPromptValue | undefined;\n /** Native Effect AI toolkit whose failures and requirements remain visible. */\n readonly toolkit: ToolkitValue;\n readonly toolExposure?: Configuration | undefined;\n /** Finite execution bounds enforced by the runtime. */\n readonly policy: AgentPolicy;\n /** Explicit policy fields, retained so delegated runs can inherit omitted fields. */\n readonly policyOverrides?: Partial<AgentPolicyInput> | undefined;\n /** Optional successful Tool result that projects directly to the Agent output and settles. */\n readonly completion?: CompletionToolDeclaration | undefined;\n readonly completionFromTools?: ReadonlyArray<CompletionFromToolDeclaration> | undefined;\n readonly runDisposition?: RunDispositionValue | undefined;\n readonly description?: string | undefined;\n readonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\n/** Options for a model-agnostic agent definition. */\nexport interface DefinitionOptions<\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n RunDispositionValue extends\n | RunDispositionDeclaration<OutputSchema[\"Type\"], Schema.Top>\n | undefined = undefined,\n InputPromptValue extends InputPromptSource<InputSchema[\"Type\"], unknown, unknown> | undefined =\n undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n> {\n readonly updates?: UpdatesSchema;\n readonly input: InputSchema;\n readonly output: OutputSchema;\n readonly instructions: Instructions;\n readonly inputPrompt?: InputPromptValue | undefined;\n readonly toolkit: ToolkitValue;\n readonly toolExposure?: Configuration | undefined;\n readonly policy?: Partial<AgentPolicyInput> | undefined;\n readonly completion?: CompletionToolFor<ToolkitValue, OutputSchema[\"Type\"]> | undefined;\n readonly completionFromTools?:\n | ReadonlyArray<CompletionFromToolFor<ToolkitValue, OutputSchema[\"Type\"]>>\n | undefined;\n readonly runDisposition?: RunDispositionValue | undefined;\n readonly description?: string | undefined;\n readonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\ntype AnyDefinitionShape = Definition<\n Schema.Top,\n Schema.Top,\n unknown,\n Toolkit.Any,\n RunDispositionDeclaration<never, Schema.Top> | undefined,\n unknown,\n Schema.Top | undefined\n>;\n\n/** Immutable pairing of an agent definition with a native model Layer or thread resolver. */\nexport interface Binding<DefinitionValue extends AnyDefinitionShape, ModelValue> {\n readonly definition: DefinitionValue;\n readonly model: NativeModel<ModelValue>;\n}\n\ntype InstructionEffect<Instructions, Input> = Instructions extends (input: Input) => infer Result\n ? Result\n : Instructions;\n\ntype InputPromptEffect<InputPrompt, Input> = InputPrompt extends (input: Input) => infer Result\n ? Result\n : never;\n\ntype EffectError<Value> =\n Value extends Effect.Effect<infer _Success, infer Error, infer _Services> ? Error : never;\n\ntype EffectServices<Value> =\n Value extends Effect.Effect<infer _Success, infer _Error, infer Services> ? Services : never;\n\ntype ModelRequirements<Value> =\n Value extends Layer.Layer<infer _Provides, infer _Error, infer Services> ? Services : never;\n\n/** Constructors and type projections for definitions and runnable model bindings. */\n\n/** Type-erased definition used at generic framework boundaries. */\nexport type AnyDefinition = AnyDefinitionShape;\n\n/** Read-only interpreter program or binding used at inspection and projection boundaries. */\nexport interface Any {\n readonly definition: AnyDefinition;\n readonly model?: unknown;\n}\n\n/** Native Tool configuration for inspection; it does not predict an invocation's outcome. */\nexport const ToolInspection = S.Struct({\n name: S.String,\n failureMode: S.Literals([\"error\", \"return\"]),\n /** False for provider-executed Tools, whose results do not pass through local handlers. */\n requiresHandler: S.Boolean,\n});\n\nexport type ToolInspection = typeof ToolInspection.Type;\n\n/**\n * Inspect registered native Tools in declaration order without acquiring handlers or a Model.\n * This is the full Definition toolkit, before run-specific visibility or exposure filtering.\n * `failureMode` is Effect AI's configured mode, including its `\"error\"` default. Handler-level\n * recovery, programmatic invocation and Subagent containment can change where failures go;\n * consult execution diagnostics for the actual route. No arguments, results or services are read.\n */\nexport const inspectTools = (agent: AnyDefinition | Any): ReadonlyArray<ToolInspection> => {\n const definition = \"definition\" in agent ? agent.definition : agent;\n\n return Object.values(definition.toolkit.tools).map((tool) =>\n ToolInspection.make({\n name: tool.name,\n failureMode: tool.failureMode,\n requiresHandler: !Tool.isProviderDefined(tool) || tool.requiresHandler,\n }),\n );\n};\n\ntype DefinitionOf<AgentValue extends AnyDefinition | Any> = AgentValue extends {\n readonly definition: infer DefinitionValue extends AnyDefinition;\n}\n ? DefinitionValue\n : AgentValue;\n\ntype RunDispositionSchemaOf<DefinitionValue extends AnyDefinition> = [\n Exclude<DefinitionValue[\"runDisposition\"], undefined>,\n] extends [never]\n ? never\n : Exclude<DefinitionValue[\"runDisposition\"], undefined> extends RunDispositionDeclaration<\n never,\n infer DispositionSchema\n >\n ? DispositionSchema\n : never;\n\n/** Literal Agent ID, retained by Agent.make. */\nexport type Name<A extends AnyDefinition | Any> = DefinitionOf<A>[\"id\"] extends AgentId &\n (infer N extends string)\n ? N\n : string;\n\n/** Declared update Schema, or never for Agents without updates. */\nexport type UpdatesSchema<A extends AnyDefinition | Any> = Exclude<\n DefinitionOf<A>[\"updates\"],\n undefined\n>;\n\n/** Decoded intermediate update value. */\nexport type Update<A extends AnyDefinition | Any> = UpdatesSchema<A>[\"Type\"];\n\n/** Decoded input type of a definition or binding. */\nexport type Input<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"input\"][\"Type\"];\n\n/** Encoded input accepted by the primary execution operations. */\nexport type EncodedInput<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"input\"][\"Encoded\"];\n\n/** Decoded output type of a definition or binding. */\nexport type Output<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"output\"][\"Type\"];\n\n/** Input Schema carried by a definition or binding. */\nexport type InputSchema<AgentValue extends AnyDefinition | Any> = DefinitionOf<AgentValue>[\"input\"];\n\n/** Output Schema carried by a definition or binding. */\nexport type OutputSchema<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"output\"];\n\n/** Application run-disposition Schema carried by a definition or binding, or `never`. */\nexport type RunDispositionSchema<AgentValue extends AnyDefinition | Any> = RunDispositionSchemaOf<\n DefinitionOf<AgentValue>\n>;\n\n/** Decoded application run disposition declared by a definition or binding. */\nexport type RunDisposition<AgentValue extends AnyDefinition | Any> = [\n RunDispositionSchema<AgentValue>,\n] extends [never]\n ? never\n : RunDispositionSchema<AgentValue>[\"Type\"];\n\n/** Validation failure admitted only by definitions that declare a run disposition. */\nexport type RunDispositionFailure<AgentValue extends AnyDefinition | Any> = [\n RunDispositionSchemaOf<DefinitionOf<AgentValue>>,\n] extends [never]\n ? never\n : AgentRunDispositionError;\n\n/** Effect AI tool map carried by a definition or binding. */\nexport type Tools<AgentValue extends AnyDefinition | Any> = Toolkit.Tools<\n DefinitionOf<AgentValue>[\"toolkit\"]\n>;\n\ntype ApplicationTools<A extends AnyDefinition> = [UpdatesSchema<A>] extends [never]\n ? Tools<A>\n : Omit<Tools<A>, \"emit_update\">;\n\ntype ToolMapValues<ToolMap extends Record<string, Tool.Any>> = ToolMap extends unknown\n ? ToolMap[keyof ToolMap]\n : never;\n\n/** All possible tools, including keys present in only one definition or binding branch. */\nexport type ToolUnion<AgentValue extends AnyDefinition | Any> = ToolMapValues<Tools<AgentValue>>;\n\n/** Instruction, tool-handler, and Schema services required before a Model is bound. */\nexport type DefinitionRequirements<DefinitionValue extends AnyDefinition> =\n DefinitionValue extends unknown\n ?\n | EffectServices<InstructionEffect<DefinitionValue[\"instructions\"], Input<DefinitionValue>>>\n | EffectServices<InputPromptEffect<DefinitionValue[\"inputPrompt\"], Input<DefinitionValue>>>\n | Tool.HandlersFor<ApplicationTools<DefinitionValue>>\n | Tool.HandlerServices<ToolMapValues<ApplicationTools<DefinitionValue>>>\n // The interpreter canonically re-encodes decoded Tool parameters before recording them.\n | Tool.ParametersSchema<ToolUnion<DefinitionValue>>[\"EncodingServices\"]\n | Tool.SuccessSchema<ToolUnion<DefinitionValue>>[\"DecodingServices\"]\n | DefinitionValue[\"input\"][\"DecodingServices\"]\n | DefinitionValue[\"input\"][\"EncodingServices\"]\n | DefinitionValue[\"output\"][\"DecodingServices\"]\n | DefinitionValue[\"output\"][\"EncodingServices\"]\n | UpdatesSchema<DefinitionValue>[\"DecodingServices\"]\n | UpdatesSchema<DefinitionValue>[\"EncodingServices\"]\n | RunDispositionSchemaOf<DefinitionValue>[\"DecodingServices\"]\n | RunDispositionSchemaOf<DefinitionValue>[\"EncodingServices\"]\n : never;\n\n/** Definition services plus native model services, or a binding's model Layer requirements. */\nexport type Requirements<AgentValue extends AnyDefinition | Any> =\n | DefinitionRequirements<DefinitionOf<AgentValue>>\n | (AgentValue extends { readonly model: infer ModelValue }\n ? ModelRequirements<ModelValue>\n : ModelServices);\n\n// Distribute after unwrapping bindings too: withModel may itself contain a definition union.\ntype DefinitionFailure<DefinitionValue extends AnyDefinition> = DefinitionValue extends unknown\n ?\n | EffectError<InstructionEffect<DefinitionValue[\"instructions\"], Input<DefinitionValue>>>\n | EffectError<InputPromptEffect<DefinitionValue[\"inputPrompt\"], Input<DefinitionValue>>>\n | Tool.HandlerError<ToolUnion<DefinitionValue>>\n : never;\n\n/** Failures from every possible definition, preserving each branch's instruction input type. */\nexport type Failure<AgentValue extends AnyDefinition | Any> =\n | DefinitionFailure<DefinitionOf<AgentValue>>\n | AiError.AiError\n | AgentInputError\n | AgentOutputError\n | RunDispositionFailure<AgentValue>;\n\n/** Validate an agent ID and return a shallowly frozen, model-agnostic definition. */\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n DispositionSchema extends Schema.Top,\n InputPromptValue extends InputPromptSource<InputSchema[\"Type\"], unknown, unknown> | undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n InputPromptValue,\n UpdatesSchema\n > & {\n readonly runDisposition: RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>;\n readonly inputPrompt: InputPromptValue;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n InputPromptValue,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n DispositionSchema extends Schema.Top,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n undefined,\n UpdatesSchema\n > & {\n readonly runDisposition: RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>;\n readonly inputPrompt?: undefined;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n undefined,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n InputPromptValue extends InputPromptSource<InputSchema[\"Type\"], unknown, unknown> | undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n undefined,\n InputPromptValue,\n UpdatesSchema\n > & {\n readonly inputPrompt: InputPromptValue;\n readonly runDisposition?: undefined;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n undefined,\n InputPromptValue,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n undefined,\n undefined,\n UpdatesSchema\n > & {\n readonly inputPrompt?: undefined;\n readonly runDisposition?: undefined;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n undefined,\n undefined,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make(\n id: string,\n options: {\n readonly updates?: Schema.Top | undefined;\n readonly input: Schema.Top;\n readonly output: Schema.Top;\n readonly instructions: unknown;\n readonly inputPrompt?: unknown;\n readonly toolkit: Toolkit.Any;\n readonly toolExposure?: Configuration | undefined;\n readonly policy?: Partial<AgentPolicyInput> | undefined;\n readonly completion?: CompletionToolDeclaration | undefined;\n readonly completionFromTools?: ReadonlyArray<CompletionFromToolDeclaration> | undefined;\n readonly runDisposition?: RunDispositionDeclaration<never, Schema.Top> | undefined;\n readonly description?: string | undefined;\n readonly metadata?: Readonly<Record<string, string>> | undefined;\n },\n): AnyDefinition {\n const completionNames = new Set<string>();\n\n for (const declaration of options.completionFromTools ?? []) {\n if (declaration.tool === options.completion?.tool || completionNames.has(declaration.tool)) {\n throw new Error(`Tool ${declaration.tool} has more than one completion declaration`);\n }\n if (!Object.hasOwn(options.toolkit.tools, declaration.tool)) {\n throw new Error(`Unknown completion Tool ${declaration.tool}`);\n }\n completionNames.add(declaration.tool);\n }\n\n const tools = Object.values(options.toolkit.tools);\n\n const readonlyTools = tools.map((tool) =>\n Tool.isProviderDefined(tool) &&\n !tool.requiresHandler &&\n [\"web_search\", \"web_search_preview\", \"file_search\"].includes(tool.providerName)\n ? tool.annotate(Tool.Readonly, true)\n : tool,\n );\n\n const toolkit = readonlyTools.some((tool, index) => tool !== tools[index])\n ? Toolkit.make(...readonlyTools)\n : options.toolkit;\n\n return Object.freeze({\n ...options,\n toolkit: withUpdateTool(toolkit, options.updates),\n policy: AgentPolicy.resolve(options.policy),\n policyOverrides: Object.freeze({ ...options.policy }),\n toolExposure:\n options.toolExposure === undefined\n ? undefined\n : Object.freeze({\n ...options.toolExposure,\n initialToolNames: Object.freeze([...(options.toolExposure.initialToolNames ?? [])]),\n }),\n id: S.decodeSync(AgentId)(id),\n metadata: options.metadata === undefined ? undefined : Object.freeze({ ...options.metadata }),\n completion:\n options.completion === undefined ? undefined : Object.freeze({ ...options.completion }),\n completionFromTools:\n options.completionFromTools === undefined\n ? undefined\n : Object.freeze(\n options.completionFromTools.map((declaration) => Object.freeze({ ...declaration })),\n ),\n runDisposition:\n options.runDisposition === undefined\n ? undefined\n : Object.freeze({ ...options.runDisposition }),\n });\n}\n\n/** Bind a native model or thread resolver without acquiring or hiding its requirements. */\nexport const withModel = <DefinitionValue extends AnyDefinition, ModelValue>(\n definition: DefinitionValue,\n model: NativeModel<ModelValue>,\n): Binding<DefinitionValue, ModelValue> =>\n Object.freeze({\n definition,\n model,\n });\n"],"mappings":";;;;;;;;;AAMA,MAAa,cAAoC,WAC/C,KAAK,KAAK,eAAe;CACvB,aACE;CAEF,YAAY,OAAO,OAAO,EAAE,OAAO,OAAO,CAAC;CAC3C,SAAS,OAAO,OAAO,EAAE,SAAS,OAAO,QAAQ,IAAI,EAAE,CAAC;CACxD,SAAS;CACT,aAAa;AACf,CAAC,CAAC,CAAC,cAAc,OAAO;AAS1B,MAAa,kBACX,SACA,WACgB;CAChB,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI,OAAO,OAAO,QAAQ,OAAO,aAAa,GAC5C,MAAM,IAAI,UAAU,2CAA2C;CAEjE,OAAO,QAAQ,KAAK,GAAG,OAAO,OAAO,QAAQ,KAAK,GAAG,WAAW,MAAM,CAAC;AACzE;;;;;;;;;;;ACmBA,MAAa,mBAAmB,UAC9B,aAAa,SAAS,OAAO,MAAM,YAAY;;AAyMjD,MAAa,iBAAiB,EAAE,OAAO;CACrC,MAAM,EAAE;CACR,aAAa,EAAE,SAAS,CAAC,SAAS,QAAQ,CAAC;;CAE3C,iBAAiB,EAAE;AACrB,CAAC;;;;;;;;AAWD,MAAa,gBAAgB,UAA8D;CACzF,MAAM,aAAa,gBAAgB,QAAQ,MAAM,aAAa;CAE9D,OAAO,OAAO,OAAO,WAAW,QAAQ,KAAK,CAAC,CAAC,KAAK,SAClD,eAAe,KAAK;EAClB,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,iBAAiB,CAAC,KAAK,kBAAkB,IAAI,KAAK,KAAK;CACzD,CAAC,CACH;AACF;AAqQA,SAAgB,KACd,IACA,SAee;CACf,MAAM,kCAAkB,IAAI,IAAY;CAExC,KAAK,MAAM,eAAe,QAAQ,uBAAuB,CAAC,GAAG;EAC3D,IAAI,YAAY,SAAS,QAAQ,YAAY,QAAQ,gBAAgB,IAAI,YAAY,IAAI,GACvF,MAAM,IAAI,MAAM,QAAQ,YAAY,KAAK,0CAA0C;EAErF,IAAI,CAAC,OAAO,OAAO,QAAQ,QAAQ,OAAO,YAAY,IAAI,GACxD,MAAM,IAAI,MAAM,2BAA2B,YAAY,MAAM;EAE/D,gBAAgB,IAAI,YAAY,IAAI;CACtC;CAEA,MAAM,QAAQ,OAAO,OAAO,QAAQ,QAAQ,KAAK;CAEjD,MAAM,gBAAgB,MAAM,KAAK,SAC/B,KAAK,kBAAkB,IAAI,KAC3B,CAAC,KAAK,mBACN;EAAC;EAAc;EAAsB;CAAa,CAAC,CAAC,SAAS,KAAK,YAAY,IAC1E,KAAK,SAAS,KAAK,UAAU,IAAI,IACjC,IACN;CAEA,MAAM,UAAU,cAAc,MAAM,MAAM,UAAU,SAAS,MAAM,MAAM,IACrE,QAAQ,KAAK,GAAG,aAAa,IAC7B,QAAQ;CAEZ,OAAO,OAAO,OAAO;EACnB,GAAG;EACH,SAAS,eAAe,SAAS,QAAQ,OAAO;EAChD,QAAQ,YAAY,QAAQ,QAAQ,MAAM;EAC1C,iBAAiB,OAAO,OAAO,EAAE,GAAG,QAAQ,OAAO,CAAC;EACpD,cACE,QAAQ,iBAAiB,KAAA,IACrB,KAAA,IACA,OAAO,OAAO;GACZ,GAAG,QAAQ;GACX,kBAAkB,OAAO,OAAO,CAAC,GAAI,QAAQ,aAAa,oBAAoB,CAAC,CAAE,CAAC;EACpF,CAAC;EACP,IAAI,EAAE,WAAW,OAAO,CAAC,CAAC,EAAE;EAC5B,UAAU,QAAQ,aAAa,KAAA,IAAY,KAAA,IAAY,OAAO,OAAO,EAAE,GAAG,QAAQ,SAAS,CAAC;EAC5F,YACE,QAAQ,eAAe,KAAA,IAAY,KAAA,IAAY,OAAO,OAAO,EAAE,GAAG,QAAQ,WAAW,CAAC;EACxF,qBACE,QAAQ,wBAAwB,KAAA,IAC5B,KAAA,IACA,OAAO,OACL,QAAQ,oBAAoB,KAAK,gBAAgB,OAAO,OAAO,EAAE,GAAG,YAAY,CAAC,CAAC,CACpF;EACN,gBACE,QAAQ,mBAAmB,KAAA,IACvB,KAAA,IACA,OAAO,OAAO,EAAE,GAAG,QAAQ,eAAe,CAAC;CACnD,CAAC;AACH;;AAGA,MAAa,aACX,YACA,UAEA,OAAO,OAAO;CACZ;CACA;AACF,CAAC"}
|