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,11 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
SchemaTransformation,
|
|
8
|
-
} from "effect";
|
|
1
|
+
import * as EffectCause from "effect/Cause";
|
|
2
|
+
import * as Exit from "effect/Exit";
|
|
3
|
+
import * as Predicate from "effect/Predicate";
|
|
4
|
+
import * as Redacted from "effect/Redacted";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
9
7
|
|
|
10
8
|
import { strictSchema } from "./internal/strict-schema.ts";
|
|
11
9
|
|
package/src/core/IdGenerator.ts
CHANGED
|
@@ -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 Layer from "effect/Layer";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import * as EffectAiIdGenerator from "effect/unstable/ai/IdGenerator";
|
|
3
6
|
|
|
4
7
|
import { ThreadId, RunId, TurnId } from "./Identifiers.ts";
|
|
5
8
|
|
package/src/core/Messaging.ts
CHANGED
package/src/core/Receipt.ts
CHANGED
package/src/core/RunEvent.ts
CHANGED
package/src/core/Thread.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { Scope } from "effect";
|
|
2
|
+
import * as Clock from "effect/Clock";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as DateTime from "effect/DateTime";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as SynchronizedRef from "effect/SynchronizedRef";
|
|
9
|
+
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
3
10
|
|
|
4
11
|
import { ThreadId, RunId } from "./Identifiers.ts";
|
|
5
12
|
import { utf8ByteLength } from "./internal/utf8.ts";
|
|
@@ -77,11 +84,18 @@ export class ThreadEncodingError extends Schema.TaggedError<ThreadEncodingError>
|
|
|
77
84
|
{ threadId: ThreadId, message: Schema.String },
|
|
78
85
|
) {}
|
|
79
86
|
|
|
87
|
+
/** A scoped view cannot access another owner's history or be used after closure. */
|
|
88
|
+
export class ThreadOwnershipError extends Schema.TaggedError<ThreadOwnershipError>()(
|
|
89
|
+
"ThreadOwnershipError",
|
|
90
|
+
{ threadId: ThreadId, reason: Schema.Literals(["closed", "foreign"]), message: Schema.String },
|
|
91
|
+
) {}
|
|
92
|
+
|
|
80
93
|
export type ThreadError =
|
|
81
94
|
| ThreadNotFound
|
|
82
95
|
| ThreadLimitExceeded
|
|
83
96
|
| ThreadHistoryDiverged
|
|
84
|
-
| ThreadEncodingError
|
|
97
|
+
| ThreadEncodingError
|
|
98
|
+
| ThreadOwnershipError;
|
|
85
99
|
|
|
86
100
|
/** Reconstruct exact Effect AI Prompt history, including tools, reasoning, files, and options. */
|
|
87
101
|
export const toPrompt = (snapshot: Thread): Prompt.Prompt =>
|
|
@@ -93,32 +107,51 @@ export const toPrompt = (snapshot: Thread): Prompt.Prompt =>
|
|
|
93
107
|
* ThreadHistory.layer uses this store for ordinary Runs and interactive history.
|
|
94
108
|
* Scope closure releases all in-memory state.
|
|
95
109
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
110
|
+
interface StoreService {
|
|
111
|
+
/**
|
|
112
|
+
* Acquire an isolated ownership view over this same bounded store. Newly created Threads
|
|
113
|
+
* belong to the supplied Scope; closing it releases only that view's Threads and bytes.
|
|
114
|
+
* Supplied by layerMemory; custom stores may omit this capability.
|
|
115
|
+
* The view rejects foreign IDs and all access after closure. Keep its Scope open through
|
|
116
|
+
* all users, including streams, child Runs, snapshots and history hooks.
|
|
117
|
+
*/
|
|
118
|
+
readonly scoped?: Effect.Effect<StoreService, never, Scope.Scope>;
|
|
119
|
+
readonly create: (
|
|
120
|
+
threadId: ThreadId,
|
|
121
|
+
) => Effect.Effect<Thread, ThreadLimitExceeded | ThreadOwnershipError>;
|
|
122
|
+
readonly append: (
|
|
123
|
+
threadId: ThreadId,
|
|
124
|
+
message: ThreadAppend,
|
|
125
|
+
) => Effect.Effect<
|
|
126
|
+
Thread,
|
|
127
|
+
ThreadNotFound | ThreadLimitExceeded | ThreadEncodingError | ThreadOwnershipError
|
|
128
|
+
>;
|
|
129
|
+
/**
|
|
130
|
+
* Record an engine-emitted full history only when it is an append-only
|
|
131
|
+
* extension of the exact official Prompt already stored. The entire
|
|
132
|
+
* suffix commits in one transaction or not at all: concurrent writers are
|
|
133
|
+
* serialized, a writer whose history no longer extends the committed
|
|
134
|
+
* official history fails with ThreadHistoryDiverged, and a limit
|
|
135
|
+
* failure inside the suffix records nothing. Earlier updates remain committed if the Run
|
|
136
|
+
* later fails or is interrupted; this transaction covers one update, not the whole Run.
|
|
137
|
+
*/
|
|
138
|
+
readonly recordHistory: (
|
|
139
|
+
threadId: ThreadId,
|
|
140
|
+
runId: RunId,
|
|
141
|
+
history: Prompt.Prompt,
|
|
142
|
+
) => Effect.Effect<Thread, ThreadError>;
|
|
143
|
+
readonly snapshot: (
|
|
144
|
+
threadId: ThreadId,
|
|
145
|
+
) => Effect.Effect<Thread, ThreadNotFound | ThreadOwnershipError>;
|
|
146
|
+
readonly export: (
|
|
147
|
+
threadId: ThreadId,
|
|
148
|
+
) => Effect.Effect<ThreadExport, ThreadNotFound | ThreadOwnershipError>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Process-local conversation store supplied by layerMemory. */
|
|
152
|
+
export class Store extends Context.Service<Store, StoreService>()(
|
|
153
|
+
"@effect-agent/capabilities/EphemeralThreads",
|
|
154
|
+
) {}
|
|
122
155
|
|
|
123
156
|
const encodeMessage = (
|
|
124
157
|
threadId: ThreadId,
|
|
@@ -134,27 +167,71 @@ const encodeMessage = (
|
|
|
134
167
|
),
|
|
135
168
|
);
|
|
136
169
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const snapshot = state.get(threadId);
|
|
170
|
+
interface Owner {
|
|
171
|
+
closed: boolean;
|
|
172
|
+
readonly parent?: Owner;
|
|
173
|
+
}
|
|
142
174
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
175
|
+
interface Entry {
|
|
176
|
+
readonly snapshot: Thread;
|
|
177
|
+
readonly owner: Owner;
|
|
178
|
+
}
|
|
147
179
|
|
|
148
|
-
|
|
149
|
-
|
|
180
|
+
interface State {
|
|
181
|
+
readonly threads: ReadonlyMap<ThreadId, Entry>;
|
|
182
|
+
readonly contentBytes: number;
|
|
183
|
+
}
|
|
150
184
|
|
|
151
|
-
|
|
185
|
+
const belongsTo = (owner: Owner, ancestor: Owner): boolean => {
|
|
186
|
+
for (let current: Owner | undefined = owner; current !== undefined; current = current.parent) {
|
|
187
|
+
if (current === ancestor) return true;
|
|
188
|
+
}
|
|
152
189
|
|
|
153
|
-
return
|
|
190
|
+
return false;
|
|
154
191
|
};
|
|
155
192
|
|
|
193
|
+
const access = (state: State, owner: Owner, threadId: ThreadId) => {
|
|
194
|
+
for (let current: Owner | undefined = owner; current !== undefined; current = current.parent) {
|
|
195
|
+
if (current.closed) {
|
|
196
|
+
return Effect.fail(
|
|
197
|
+
ThreadOwnershipError.make({
|
|
198
|
+
threadId,
|
|
199
|
+
reason: "closed",
|
|
200
|
+
message: "The in-memory conversation owner is closed",
|
|
201
|
+
}),
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const entry = state.threads.get(threadId);
|
|
206
|
+
|
|
207
|
+
return entry !== undefined && entry.owner !== owner
|
|
208
|
+
? Effect.fail(
|
|
209
|
+
ThreadOwnershipError.make({
|
|
210
|
+
threadId,
|
|
211
|
+
reason: "foreign",
|
|
212
|
+
message: "The Thread belongs to another in-memory conversation owner",
|
|
213
|
+
}),
|
|
214
|
+
)
|
|
215
|
+
: Effect.succeed(entry?.snapshot);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const findSnapshot = Effect.fnUntraced(function* (state: State, owner: Owner, threadId: ThreadId) {
|
|
219
|
+
const snapshot = yield* access(state, owner, threadId);
|
|
220
|
+
|
|
221
|
+
return snapshot === undefined ? yield* ThreadNotFound.make({ threadId }) : snapshot;
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const put = (state: State, owner: Owner, snapshot: Thread): State => ({
|
|
225
|
+
threads: new Map(state.threads).set(snapshot.threadId, { snapshot, owner }),
|
|
226
|
+
contentBytes:
|
|
227
|
+
state.contentBytes +
|
|
228
|
+
snapshot.contentBytes -
|
|
229
|
+
(state.threads.get(snapshot.threadId)?.snapshot.contentBytes ?? 0),
|
|
230
|
+
});
|
|
231
|
+
|
|
156
232
|
const appendEncoded = Effect.fn("Thread.Store.appendEncoded")(function* (
|
|
157
|
-
|
|
233
|
+
state: State,
|
|
234
|
+
owner: Owner,
|
|
158
235
|
current: Thread,
|
|
159
236
|
append: ThreadAppend,
|
|
160
237
|
encoded: string,
|
|
@@ -181,7 +258,7 @@ const appendEncoded = Effect.fn("Thread.Store.appendEncoded")(function* (
|
|
|
181
258
|
observedValue: contentBytes,
|
|
182
259
|
});
|
|
183
260
|
}
|
|
184
|
-
const storeBytes =
|
|
261
|
+
const storeBytes = state.contentBytes + messageBytes;
|
|
185
262
|
|
|
186
263
|
if (storeBytes > MAX_STORE_CONTENT_BYTES) {
|
|
187
264
|
return yield* ThreadLimitExceeded.make({
|
|
@@ -209,31 +286,52 @@ const appendEncoded = Effect.fn("Thread.Store.appendEncoded")(function* (
|
|
|
209
286
|
messages: [...current.messages, message],
|
|
210
287
|
});
|
|
211
288
|
|
|
212
|
-
return [next,
|
|
289
|
+
return [next, put(state, owner, next)] as const;
|
|
213
290
|
});
|
|
214
291
|
|
|
215
292
|
/** In-memory storage shared for the consumer's Scope; it does not survive process loss. */
|
|
216
293
|
export const layerMemory = Layer.effect(
|
|
217
294
|
Store,
|
|
218
295
|
Effect.gen(function* () {
|
|
219
|
-
const state = yield* SynchronizedRef.make<
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
296
|
+
const state = yield* SynchronizedRef.make<State>({ threads: new Map(), contentBytes: 0 });
|
|
297
|
+
const root: Owner = { closed: false };
|
|
298
|
+
|
|
299
|
+
const release = (owner: Owner) =>
|
|
300
|
+
SynchronizedRef.update(state, (current) => {
|
|
301
|
+
owner.closed = true;
|
|
302
|
+
const threads = new Map(current.threads);
|
|
303
|
+
let contentBytes = current.contentBytes;
|
|
304
|
+
|
|
305
|
+
for (const [id, entry] of threads) {
|
|
306
|
+
if (belongsTo(entry.owner, owner)) {
|
|
307
|
+
threads.delete(id);
|
|
308
|
+
contentBytes -= entry.snapshot.contentBytes;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return { threads, contentBytes };
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
yield* Effect.addFinalizer(() => release(root));
|
|
316
|
+
|
|
317
|
+
const view = (owner: Owner): StoreService => ({
|
|
318
|
+
scoped: Effect.acquireRelease(
|
|
319
|
+
Effect.sync((): Owner => ({ closed: false, parent: owner })),
|
|
320
|
+
release,
|
|
321
|
+
).pipe(Effect.map(view)),
|
|
224
322
|
create: (threadId) =>
|
|
225
323
|
SynchronizedRef.modifyEffect(
|
|
226
324
|
state,
|
|
227
325
|
Effect.fn(function* (threads) {
|
|
228
|
-
const existing = threads
|
|
326
|
+
const existing = yield* access(threads, owner, threadId);
|
|
229
327
|
|
|
230
328
|
if (existing !== undefined) return [existing, threads] as const;
|
|
231
|
-
if (threads.size >= MAX_THREADS) {
|
|
329
|
+
if (threads.threads.size >= MAX_THREADS) {
|
|
232
330
|
return yield* ThreadLimitExceeded.make({
|
|
233
331
|
threadId,
|
|
234
332
|
limit: "threads",
|
|
235
333
|
limitValue: MAX_THREADS,
|
|
236
|
-
observedValue: threads.size + 1,
|
|
334
|
+
observedValue: threads.threads.size + 1,
|
|
237
335
|
});
|
|
238
336
|
}
|
|
239
337
|
|
|
@@ -245,7 +343,7 @@ export const layerMemory = Layer.effect(
|
|
|
245
343
|
messages: [],
|
|
246
344
|
});
|
|
247
345
|
|
|
248
|
-
return [created,
|
|
346
|
+
return [created, put(threads, owner, created)] as const;
|
|
249
347
|
}),
|
|
250
348
|
),
|
|
251
349
|
append: Effect.fn("Thread.Store.append")(function* (threadId, message) {
|
|
@@ -255,9 +353,9 @@ export const layerMemory = Layer.effect(
|
|
|
255
353
|
return yield* SynchronizedRef.modifyEffect(
|
|
256
354
|
state,
|
|
257
355
|
Effect.fn(function* (threads) {
|
|
258
|
-
const current = yield* findSnapshot(threads, threadId);
|
|
356
|
+
const current = yield* findSnapshot(threads, owner, threadId);
|
|
259
357
|
|
|
260
|
-
return yield* appendEncoded(threads, current, message, encoded, timestamp);
|
|
358
|
+
return yield* appendEncoded(threads, owner, current, message, encoded, timestamp);
|
|
261
359
|
}),
|
|
262
360
|
);
|
|
263
361
|
}),
|
|
@@ -271,7 +369,7 @@ export const layerMemory = Layer.effect(
|
|
|
271
369
|
return yield* SynchronizedRef.modifyEffect(
|
|
272
370
|
state,
|
|
273
371
|
Effect.fn(function* (threads) {
|
|
274
|
-
const current = yield* findSnapshot(threads, threadId);
|
|
372
|
+
const current = yield* findSnapshot(threads, owner, threadId);
|
|
275
373
|
|
|
276
374
|
const currentEncoded = yield* Effect.forEach(current.messages, (entry) =>
|
|
277
375
|
encodeMessage(threadId, entry.message),
|
|
@@ -292,7 +390,7 @@ export const layerMemory = Layer.effect(
|
|
|
292
390
|
|
|
293
391
|
const messages = [...current.messages];
|
|
294
392
|
let contentBytes = current.contentBytes;
|
|
295
|
-
let storeBytes =
|
|
393
|
+
let storeBytes = threads.contentBytes;
|
|
296
394
|
let nextSequence = current.nextSequence;
|
|
297
395
|
|
|
298
396
|
for (const entry of incoming.slice(currentEncoded.length)) {
|
|
@@ -349,16 +447,18 @@ export const layerMemory = Layer.effect(
|
|
|
349
447
|
messages,
|
|
350
448
|
});
|
|
351
449
|
|
|
352
|
-
return [snapshot,
|
|
450
|
+
return [snapshot, put(threads, owner, snapshot)] as const;
|
|
353
451
|
}),
|
|
354
452
|
);
|
|
355
453
|
},
|
|
356
454
|
),
|
|
357
455
|
snapshot: (threadId) =>
|
|
358
|
-
SynchronizedRef.get(state).pipe(
|
|
456
|
+
SynchronizedRef.get(state).pipe(
|
|
457
|
+
Effect.flatMap((all) => findSnapshot(all, owner, threadId)),
|
|
458
|
+
),
|
|
359
459
|
export: (threadId) =>
|
|
360
460
|
Effect.gen(function* () {
|
|
361
|
-
const snapshot = yield* findSnapshot(yield* SynchronizedRef.get(state), threadId);
|
|
461
|
+
const snapshot = yield* findSnapshot(yield* SynchronizedRef.get(state), owner, threadId);
|
|
362
462
|
|
|
363
463
|
return ThreadExport.make({
|
|
364
464
|
format: "effect-agent/ephemeral-thread@1",
|
|
@@ -367,5 +467,7 @@ export const layerMemory = Layer.effect(
|
|
|
367
467
|
});
|
|
368
468
|
}),
|
|
369
469
|
});
|
|
470
|
+
|
|
471
|
+
return view(root);
|
|
370
472
|
}),
|
|
371
473
|
);
|
package/src/core/ToolExposure.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
2
3
|
import type { Tool } from "effect/unstable/ai";
|
|
3
4
|
|
|
4
5
|
/** Registered native names only. Empty selection deliberately clears non-pinned Tools. */
|
package/src/core/ToolResult.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
-
import
|
|
2
|
+
import * as AiError from "effect/unstable/ai/AiError";
|
|
3
3
|
|
|
4
4
|
import { ToolCallId } from "./Identifiers.ts";
|
|
5
5
|
import { codePointUtf8Length, utf8ByteLength } from "./internal/utf8.ts";
|
package/src/core/Usage.ts
CHANGED
package/src/core/Worker.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import * as Tool from "effect/unstable/ai/Tool";
|
|
3
|
+
import * as Toolkit from "effect/unstable/ai/Toolkit";
|
|
3
4
|
|
|
4
5
|
import { Emitter, UpdateError } from "../AgentUpdates.ts";
|
|
5
6
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import * as SchemaParser from "effect/SchemaParser";
|
|
3
|
+
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
2
4
|
|
|
3
5
|
/** Keep strict parsing on nested values even when an outer parser uses its defaults. */
|
|
4
6
|
export const strictSchema = <S extends Schema.Top>(schema: S) =>
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Stream from "effect/Stream";
|
|
7
|
+
import type { LanguageModel, Model } from "effect/unstable/ai";
|
|
8
|
+
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
3
9
|
|
|
4
10
|
import { type CompactionPolicy } from "../core/AgentPolicy.ts";
|
|
5
11
|
import { type RunId, type ThreadId } from "../core/Identifiers.ts";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Effect } from "effect";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Encoding from "effect/Encoding";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
2
5
|
|
|
3
6
|
import { RunId, ThreadId } from "../core/Identifiers.ts";
|
|
4
7
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Context, Schema } from "effect";
|
|
2
1
|
import type { Effect, Option } from "effect";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
3
4
|
import type { Tool } from "effect/unstable/ai";
|
|
4
5
|
|
|
5
6
|
import { ToolCallId } from "../core/Identifiers.ts";
|
package/src/engine/RunOptions.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Cause, DateTime } from "effect";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
2
6
|
import type { LanguageModel, Model, Prompt, Response } from "effect/unstable/ai";
|
|
3
7
|
|
|
4
8
|
import { type AnyDefinition } from "../core/Agent.ts";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Effect, Option } from "effect";
|
|
2
|
-
import
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as Stream from "effect/Stream";
|
|
3
5
|
|
|
4
6
|
import type * as Agent from "../core/Agent.ts";
|
|
5
7
|
import type { AgentPolicy } from "../core/AgentPolicy.ts";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
2
5
|
import type { Prompt } from "effect/unstable/ai";
|
|
3
6
|
|
|
4
7
|
import { ThreadId, type RunId } from "../core/Identifiers.ts";
|
|
@@ -57,6 +60,8 @@ export class ThreadHistory extends Context.Service<
|
|
|
57
60
|
ThreadHistory,
|
|
58
61
|
{
|
|
59
62
|
readonly retention: "incremental" | "on-success";
|
|
63
|
+
/** Present only for the in-memory adapter; identifies its exact Store ownership view. */
|
|
64
|
+
readonly memoryStore?: ConversationStore["Service"];
|
|
60
65
|
readonly open: (request: {
|
|
61
66
|
readonly threadId: ThreadId;
|
|
62
67
|
readonly runId: RunId;
|
|
@@ -64,12 +69,8 @@ export class ThreadHistory extends Context.Service<
|
|
|
64
69
|
readonly load: (threadId: ThreadId) => Effect.Effect<Prompt.Prompt, ThreadHistoryError>;
|
|
65
70
|
}
|
|
66
71
|
>()("@effect-agent/engine/ThreadHistory") {
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
* all Runs share the same store. The underlying Thread.Store service is exposed for
|
|
70
|
-
* snapshots and interactive hooks; separate Layer builds own separate stores.
|
|
71
|
-
*/
|
|
72
|
-
static readonly layer = Layer.effect(
|
|
72
|
+
/** Bind incremental history to the supplied Thread.Store, including scoped ownership views. */
|
|
73
|
+
static readonly layerFromStore = Layer.effect(
|
|
73
74
|
ThreadHistory,
|
|
74
75
|
Effect.gen(function* () {
|
|
75
76
|
const threads = yield* ConversationStore;
|
|
@@ -84,7 +85,11 @@ export class ThreadHistory extends Context.Service<
|
|
|
84
85
|
? "limit"
|
|
85
86
|
: cause._tag === "ThreadHistoryDiverged"
|
|
86
87
|
? "conflict"
|
|
87
|
-
: "
|
|
88
|
+
: cause._tag === "ThreadOwnershipError"
|
|
89
|
+
? cause.reason === "closed"
|
|
90
|
+
? "fenced"
|
|
91
|
+
: "conflict"
|
|
92
|
+
: "encoding",
|
|
88
93
|
message:
|
|
89
94
|
cause._tag === "ThreadNotFound"
|
|
90
95
|
? "Thread history is not present in this application Scope"
|
|
@@ -96,6 +101,7 @@ export class ThreadHistory extends Context.Service<
|
|
|
96
101
|
|
|
97
102
|
return ThreadHistory.of({
|
|
98
103
|
retention: "incremental",
|
|
104
|
+
memoryStore: threads,
|
|
99
105
|
load: (threadId) =>
|
|
100
106
|
threads.snapshot(threadId).pipe(Effect.map(toPrompt), Effect.mapError(historyError)),
|
|
101
107
|
open: Effect.fn("ThreadHistory.open")(function* ({ threadId, runId }) {
|
|
@@ -108,12 +114,16 @@ export class ThreadHistory extends Context.Service<
|
|
|
108
114
|
threads
|
|
109
115
|
.recordHistory(threadId, runId, history)
|
|
110
116
|
.pipe(Effect.asVoid, Effect.mapError(historyError)),
|
|
111
|
-
commit: () =>
|
|
117
|
+
commit: () =>
|
|
118
|
+
threads.snapshot(threadId).pipe(Effect.asVoid, Effect.mapError(historyError)),
|
|
112
119
|
};
|
|
113
120
|
}),
|
|
114
121
|
});
|
|
115
122
|
}),
|
|
116
|
-
)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
/** Retain bounded history for the application Scope. Separate Layer builds own separate stores. */
|
|
126
|
+
static readonly layer = ThreadHistory.layerFromStore.pipe(Layer.provideMerge(layerMemory));
|
|
117
127
|
}
|
|
118
128
|
|
|
119
129
|
/** Retain in-memory conversation history for the application Scope. */
|
package/src/engine/ToolBroker.ts
CHANGED