effect-agent 0.1.0-beta.152 → 0.1.0-beta.154
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-CKIdJoP8.d.mts → Admin-BjmupLN3.d.mts} +36 -17
- package/dist/{Agent-Cjd_ZveM.d.mts → Agent-BCyrGaWg.d.mts} +2 -2
- package/dist/{AgentPolicy-BqDoSXO6.d.mts → AgentPolicy-CnXWWwdg.d.mts} +5 -1
- package/dist/{AgentRuntime-sXpKcyxu.d.mts → AgentRuntime-BAjT5gXl.d.mts} +10 -10
- package/dist/{AgentRuntime-D8U9gl9Q.mjs → AgentRuntime-IF_1GoUf.mjs} +54 -11
- package/dist/AgentRuntime-IF_1GoUf.mjs.map +1 -0
- package/dist/{ContextCompactor-WwSIG_Z2.d.mts → ContextCompactor-CPlStZRc.d.mts} +2 -2
- package/dist/{Digest-U69rDHuO.d.mts → Digest-CaJ2RIsF.d.mts} +2 -2
- package/dist/{DurableAgentRuntime-DQFV26SB.mjs → DurableAgentRuntime-BQzYkFVy.mjs} +185 -88
- package/dist/DurableAgentRuntime-BQzYkFVy.mjs.map +1 -0
- package/dist/{EventSource-CMbXXmwe.d.mts → EventSource-C8CKwQy5.d.mts} +3 -3
- package/dist/InMemory.d.mts +1 -1
- package/dist/{Messaging-ccQURKCf.d.mts → Messaging-B1zumorg.d.mts} +3 -3
- package/dist/{MessagingHost-D04wE-7W.d.mts → MessagingHost-B4jqlJmx.d.mts} +3 -3
- package/dist/{Output-CFD1CPfU.d.mts → Output-WL7JexCm.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-Bt6rgtVu.d.mts → PreparedInputAdmission-CU1PzUVD.d.mts} +4 -4
- package/dist/{Records-B5GFWCpn.d.mts → Records-BrEpibum.d.mts} +17 -6
- package/dist/{RunEvent-DIrzkjLr.d.mts → RunEvent-DV_llBcq.d.mts} +18 -4
- package/dist/{RunJournal-Gd83HYqG.mjs → RunJournal-ixFRCyW3.mjs} +29 -7
- package/dist/RunJournal-ixFRCyW3.mjs.map +1 -0
- package/dist/{RunOptions-Bv9NpkPZ.d.mts → RunOptions-CkRYnlJa.d.mts} +22 -8
- package/dist/{RunPolicyUsage-ClZxyR46.d.mts → RunPolicyUsage-CUudVtg_.d.mts} +3 -1
- package/dist/{Schedule-CtYREFnz.d.mts → Schedule-B_z7PMg-.d.mts} +2 -2
- package/dist/{Subagent-hG9lJ7tJ.mjs → Subagent-CmFtZaeI.mjs} +2 -2
- package/dist/{Subagent-hG9lJ7tJ.mjs.map → Subagent-CmFtZaeI.mjs.map} +1 -1
- package/dist/{Subagent-VHrANXFy.d.mts → Subagent-Dld4W1BY.d.mts} +7 -7
- package/dist/{SubagentHost-C-4A7tA2.d.mts → SubagentHost--HBuY8fF.d.mts} +4 -4
- package/dist/{Subscription-BJAzYNw1.d.mts → Subscription-BomcQ9_W.d.mts} +5 -5
- package/dist/{SubscriptionInput-CkBJt0AS.d.mts → SubscriptionInput-gpZSR9vB.d.mts} +3 -3
- package/dist/{ThreadHistory-tS1KwxHR.d.mts → ThreadHistory-ZEu_ja6L.d.mts} +2 -2
- package/dist/{Worker-fwWkBg12.d.mts → Worker-2r2zGDkh.d.mts} +2 -2
- package/dist/{WorkerAdmission-CJ_oWRuS.mjs → WorkerAdmission-CNbm4o_x.mjs} +3 -3
- package/dist/{WorkerAdmission-CJ_oWRuS.mjs.map → WorkerAdmission-CNbm4o_x.mjs.map} +1 -1
- package/dist/{agent-registration-CKNsrpwo.mjs → agent-registration-U3kmV7nW.mjs} +18 -18
- package/dist/agent-registration-U3kmV7nW.mjs.map +1 -0
- package/dist/capabilities/BrowserUse.d.mts +545 -0
- package/dist/capabilities/BrowserUse.mjs +254 -0
- package/dist/capabilities/BrowserUse.mjs.map +1 -0
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/Messaging.d.mts +1 -1
- package/dist/capabilities/Redaction.d.mts +1 -1
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/Subagent.d.mts +2 -2
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/core/Agent.d.mts +1 -1
- package/dist/core/AgentPolicy.d.mts +1 -1
- package/dist/core/AgentPolicy.mjs +2 -0
- package/dist/core/AgentPolicy.mjs.map +1 -1
- package/dist/core/RunEvent.d.mts +2 -2
- package/dist/core/RunEvent.mjs +10 -1
- package/dist/core/RunEvent.mjs.map +1 -1
- package/dist/core/RunPolicyUsage.d.mts +1 -1
- package/dist/core/RunPolicyUsage.mjs +6 -1
- package/dist/core/RunPolicyUsage.mjs.map +1 -1
- package/dist/core/Worker.d.mts +1 -1
- package/dist/durable/ActivityStore.d.mts +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/AgentRegistration.d.mts +2 -2
- package/dist/durable/AgentRegistration.mjs +3 -2
- package/dist/durable/AgentRegistration.mjs.map +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 +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +2 -2
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/LifecyclePublication.d.mts +1 -1
- package/dist/durable/MessageDelivery.d.mts +5 -5
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +42 -42
- package/dist/durable/PersistentHistory.d.mts +2 -2
- package/dist/durable/PersistentHistory.mjs +1 -1
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/Records.d.mts +2 -2
- package/dist/durable/Records.mjs +16 -1
- package/dist/durable/Records.mjs.map +1 -1
- 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/ScheduleStoreConformance.d.mts +1 -1
- package/dist/durable/ScheduleTransition.d.mts +1 -1
- package/dist/durable/Scheduling.d.mts +3 -3
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +2 -2
- package/dist/durable/SubmissionLedgerConformance.mjs +1 -1
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +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 +4 -4
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/Subscriptions.d.mts +6 -6
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
- 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 +3 -3
- package/dist/durable/WorkerAdmission.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +5 -5
- 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/ContextCompactor.d.mts +1 -1
- package/dist/engine/MessagingHost.d.mts +1 -1
- package/dist/engine/Output.d.mts +1 -1
- package/dist/engine/RunOptions.d.mts +1 -1
- package/dist/engine/RunOptions.mjs.map +1 -1
- package/dist/engine/SubagentHost.d.mts +1 -1
- package/dist/engine/ThreadHistory.d.mts +1 -1
- package/dist/index.d.mts +24 -23
- package/dist/index.mjs +7 -6
- package/package.json +1 -1
- package/src/capabilities/BrowserUse.ts +367 -0
- package/src/core/AgentPolicy.ts +2 -0
- package/src/core/RunEvent.ts +9 -0
- package/src/core/RunPolicyUsage.ts +2 -0
- package/src/durable/AgentRegistration.ts +2 -0
- package/src/durable/DurableAgentRuntime.ts +320 -137
- package/src/durable/Records.ts +12 -0
- package/src/durable/RunJournal.ts +88 -27
- package/src/durable/internal/agent-registration.ts +58 -35
- package/src/engine/RunOptions.ts +17 -2
- package/src/engine/internal/agent-runtime.ts +115 -8
- package/src/index.ts +1 -0
- package/dist/AgentRuntime-D8U9gl9Q.mjs.map +0 -1
- package/dist/DurableAgentRuntime-DQFV26SB.mjs.map +0 -1
- package/dist/RunJournal-Gd83HYqG.mjs.map +0 -1
- package/dist/agent-registration-CKNsrpwo.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as RunId, u as ThreadId } from "./Identifiers-CN2s30fF.mjs";
|
|
2
|
-
import { i as CompactionPolicy } from "./AgentPolicy-
|
|
2
|
+
import { i as CompactionPolicy } from "./AgentPolicy-CnXWWwdg.mjs";
|
|
3
3
|
import { n as ContextRolloverRequest } from "./ContextWindow-DRQ5Mbm2.mjs";
|
|
4
4
|
import { LanguageModel, Model, Prompt } from "effect/unstable/ai";
|
|
5
5
|
import { Context, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
@@ -158,4 +158,4 @@ declare class ContextCompactor extends ContextCompactor_base {
|
|
|
158
158
|
}
|
|
159
159
|
//#endregion
|
|
160
160
|
export { ContextCompaction as a, ContextMessageTokenEstimator as c, CONTEXT_ROLLOVER_PREFIX as d, ContextCompactionState as f, estimatePromptTokens as g, estimateMessageTokens as h, CompactionRequest as i, CLEARED_TOOL_RESULT as l, contextWindowMessage as m, CompactionError as n, ContextCompactor as o, contextWindowId as p, CompactionModelLayer as r, ContextCompactor_d_exports as s, CompactionDecision as t, COMPACTION_SUMMARY_PREFIX as u };
|
|
161
|
-
//# sourceMappingURL=ContextCompactor-
|
|
161
|
+
//# sourceMappingURL=ContextCompactor-CPlStZRc.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as Digest, h as DefinitionDigests, m as DefinitionDigestInput, s as CanonicalBatch } from "./Records-
|
|
1
|
+
import { _ as Digest, h as DefinitionDigests, m as DefinitionDigestInput, s as CanonicalBatch } from "./Records-BrEpibum.mjs";
|
|
2
2
|
import { Crypto, Effect, Schema } from "effect";
|
|
3
3
|
declare namespace Digest_d_exports {
|
|
4
4
|
export { DigestError, EMPTY_TAIL_DIGEST, digestCanonicalBatch, digestDefinition, digestDefinitions, digestJson };
|
|
@@ -19,4 +19,4 @@ declare const digestDefinitions: (definitions: DefinitionDigestInput) => Effect.
|
|
|
19
19
|
declare const EMPTY_TAIL_DIGEST: string & import("effect/Brand").Brand<"@effect-agent/thread/Digest">;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { digestDefinition as a, digestCanonicalBatch as i, Digest_d_exports as n, digestDefinitions as o, EMPTY_TAIL_DIGEST as r, digestJson as s, DigestError as t };
|
|
22
|
-
//# sourceMappingURL=Digest-
|
|
22
|
+
//# sourceMappingURL=Digest-CaJ2RIsF.d.mts.map
|
|
@@ -15,19 +15,19 @@ import { a as PeerMessageCapacity, d as MessageAdmission, f as MessagingError, i
|
|
|
15
15
|
import { SubagentHost } from "./engine/SubagentHost.mjs";
|
|
16
16
|
import { ThreadHistory } from "./engine/ThreadHistory.mjs";
|
|
17
17
|
import { n as RunToolVisibility } from "./ToolExposure-9uF_Yo0T.mjs";
|
|
18
|
-
import { f as renderInputPrompt, n as AgentChildPending, y as streamWithUsageAccountingUnknown } from "./AgentRuntime-
|
|
18
|
+
import { f as renderInputPrompt, n as AgentChildPending, y as streamWithUsageAccountingUnknown } from "./AgentRuntime-IF_1GoUf.mjs";
|
|
19
19
|
import { ContextRolloverTool } from "./engine/ContextWindow.mjs";
|
|
20
20
|
import { getToolExecutionClass } from "./engine/DurableStep.mjs";
|
|
21
21
|
import { CompactionError, ContextCompactor } from "./engine/ContextCompactor.mjs";
|
|
22
22
|
import { RunPolicyUsage } from "./core/RunPolicyUsage.mjs";
|
|
23
23
|
import { AgentUpdateAcceptance, CurrentToolFailureObserver, ModelUsageAccounting, RunContextPreparation, RunContextPreparationPassthrough, RunToolAuthorization, RunToolScheduling } from "./engine/RunOptions.mjs";
|
|
24
|
-
import { AbortRequested, AgentUpdateEmitted, BatchId, CanonicalBatch, CanonicalRecordEnvelope, CanonicalSequence, CompactionCreated, DefinitionDigests, Digest, ModelResponseInterrupted, PeerMessagePrepared, PersistedJson, ProducerEpoch, RecordEnvelope, RecordId, RepairAnnotated, RunDurationExhausted, RunPolicyUsageReserved, RunStartedRecord, SettlementFailureDiagnostic, SubagentJoined, SubagentLineageRecorded, SubagentRequested, SubagentStarted, SubmissionSettled, SubmissionSettledRecord, SubtreeBudgetReserved, ToolApprovalDecided, ToolApprovalRequested, ToolCallPrepared, ToolCallResolved, ToolCallSettled, ToolCallUnknown, ToolOperation, ToolStepSettled, ToolUnavailable, UserInputRecorded, WorkerAdmission, WorkerContinuation, WorkerInputCompleted, WorkerInputRequested, WorkerOrigin, WorkerReportPrepared, WorkerReportRefused, WorkerReportingIntent, WorkerStopRequested } from "./durable/Records.mjs";
|
|
24
|
+
import { AbortRequested, AgentUpdateEmitted, BatchId, CanonicalBatch, CanonicalRecordEnvelope, CanonicalSequence, CompactionCreated, DefinitionDigests, Digest, ModelCallAborted, ModelResponseInterrupted, PeerMessagePrepared, PersistedJson, ProducerEpoch, RecordEnvelope, RecordId, RepairAnnotated, RunDurationExhausted, RunPolicyUsageReserved, RunStartedRecord, SettlementFailureDiagnostic, SubagentJoined, SubagentLineageRecorded, SubagentRequested, SubagentStarted, SubmissionSettled, SubmissionSettledRecord, SubtreeBudgetReserved, ToolApprovalDecided, ToolApprovalRequested, ToolCallPrepared, ToolCallResolved, ToolCallSettled, ToolCallUnknown, ToolOperation, ToolStepSettled, ToolUnavailable, UserInputRecorded, WorkerAdmission, WorkerContinuation, WorkerInputCompleted, WorkerInputRequested, WorkerOrigin, WorkerReportPrepared, WorkerReportRefused, WorkerReportingIntent, WorkerStopRequested } from "./durable/Records.mjs";
|
|
25
25
|
import { AbortCommand, AbortIntentRequest, AdmissionPolicyError, AdmissionRequest, ApprovalDecisionCommand, ApprovalPendingSuspension, AttachChildToReservationRequest, BeginChildBudgetReleaseRequest, ChildBudgetReservationRequest, ChildReservationId, ChildSettledNotification, ClaimHandoff, ClaimJoiningRequest, ClaimRequest, LedgerError, MarkInputAppliedRequest, MarkJoinedRequest, MarkReadyRequest, MarkUnknownRequest, OwnershipToken, ParentLinkage, RecoverySnapshotRequest, ReleaseChildBudgetRequest, ReleaseOwnershipRequest, RenewOwnershipRequest, RevertJoiningRequest, Settlement, SettlementFinalization, SettlementReservation, SubmissionLedger, SubmissionLookupById, SubmissionLookupByKey, SubmissionScheduling, SuspendRequest, UnknownResolutionCommand, WaitingChild, WaitingForChildSuspension, WorkerLedgerState, submissionAbortBatchId, submissionAbortRecordId, submissionInputBatchId, submissionInputRecordId, submissionSettlementBatchId, submissionSettlementId, submissionSettlementRecordId } from "./durable/SubmissionLedger.mjs";
|
|
26
26
|
import { DeclaredPendingBatchEvidence, OpenDelegationCallEvidence, OpenToolCallEvidence, PendingApprovalEvidence, RecoveryDecision, RecoveryEvidence, classifyRecovery } from "./durable/Recovery.mjs";
|
|
27
27
|
import { ExplainedEvidence, ExplainedSubmission, ExplainedUnknownCall, IntegrityCheck, IntegrityReport, ObligationEntry, ObligationReport, RecoveryExplanation, RetryRefused, obligationSeverityOf, predictRecoveryDisposition, recoveryDecisionMeaning } from "./durable/Admin.mjs";
|
|
28
28
|
import { digestJson } from "./durable/Digest.mjs";
|
|
29
|
-
import { a as
|
|
30
|
-
import { $ as workerOriginRecordId, A as subagentRequestedRecordId, B as toolCallUnknownRecordId, C as runStartedBatchId, D as subagentLineageBatchId, E as subagentJoinedRecordId, F as toolCallPreparedRecordId, G as turnCanonicalBatch, H as toolStepSettledRecordId, I as toolCallResolutionBatchId, J as turnResponseBatch, K as turnIdForRun, L as toolCallResolvedRecordId, M as subagentStartedRecordId, N as toolApprovalDecisionRecordId, O as subagentLineageRecordId, P as toolApprovalRequestRecordId, Q as workerInputRecordId, R as toolCallResultBatchId, S as runIdForSubmission, T as subagentJoinBatchId, U as turnApprovalsBatchId, V as toolStepSettledBatchId, X as turnResultsBatch, a as childIdempotencyKeyFor, b as runDurationBatchId, c as compactionRecordId, d as modelResponseInterruptedBatchId, et as workerReportRecordId, f as modelResponseInterruptedRecordId, g as projectRunJournalStream, i as approvalDecisionBatchId, j as subagentStartedBatchId, k as subagentRequestedBatchId, l as firstWorkerInputRecordId, m as peerMessageRecordId, o as childThreadIdFor, p as modelResponseRecordId, q as turnPreparedBatchId, r as agentUpdateRecordId, s as compactionBatchId, t as RunJournalError, tt as makeJournalMetadata, u as markUnknownBatchId, v as runCompletedRecordId, w as runStartedRecordId, x as runDurationRecordId, y as runCompletionDigest, z as toolCallSettledRecordId } from "./RunJournal-
|
|
29
|
+
import { a as compileRegistrations, c as resolveDefinitionBinding, l as resolveWorkerBinding, n as CurrentBindingSelection, o as definitionDigestsEqual, s as makeLegacyWorkerBinding, t as BindingUnavailable, u as toolReplayContracts } from "./agent-registration-U3kmV7nW.mjs";
|
|
30
|
+
import { $ as workerOriginRecordId, A as subagentRequestedRecordId, B as toolCallUnknownRecordId, C as runStartedBatchId, D as subagentLineageBatchId, E as subagentJoinedRecordId, F as toolCallPreparedRecordId, G as turnCanonicalBatch, H as toolStepSettledRecordId, I as toolCallResolutionBatchId, J as turnResponseBatch, K as turnIdForRun, L as toolCallResolvedRecordId, M as subagentStartedRecordId, N as toolApprovalDecisionRecordId, O as subagentLineageRecordId, P as toolApprovalRequestRecordId, Q as workerInputRecordId, R as toolCallResultBatchId, S as runIdForSubmission, T as subagentJoinBatchId, U as turnApprovalsBatchId, V as toolStepSettledBatchId, X as turnResultsBatch, a as childIdempotencyKeyFor, b as runDurationBatchId, c as compactionRecordId, d as modelResponseInterruptedBatchId, et as workerReportRecordId, f as modelResponseInterruptedRecordId, g as projectRunJournalStream, i as approvalDecisionBatchId, j as subagentStartedBatchId, k as subagentRequestedBatchId, l as firstWorkerInputRecordId, m as peerMessageRecordId, o as childThreadIdFor, p as modelResponseRecordId, q as turnPreparedBatchId, r as agentUpdateRecordId, s as compactionBatchId, t as RunJournalError, tt as makeJournalMetadata, u as markUnknownBatchId, v as runCompletedRecordId, w as runStartedRecordId, x as runDurationRecordId, y as runCompletionDigest, z as toolCallSettledRecordId } from "./RunJournal-ixFRCyW3.mjs";
|
|
31
31
|
import { FencedAppendRequest, LoadCheckpointRequest, MAX_THREAD_EXPORT_RECORDS, SaveRecoveryCheckpointRequest, ThreadCheckpoint, ThreadExportRequest, ThreadIdentityRequest, ThreadMaterialization, ThreadObservation, ThreadRead, ThreadStore, ThreadStoreDiagnostic, ThreadStoreError, ThreadTailRequest, getRecord, getRunInput, readWorkerState } from "./durable/ThreadStore.mjs";
|
|
32
32
|
import { DurableRuntimeFailpoint } from "./durable/DurableFailpoint.mjs";
|
|
33
33
|
import { ScheduledInputRefused, ScheduledInputRetryable } from "./durable/Schedule.mjs";
|
|
@@ -36,7 +36,7 @@ import { PreparedInput } from "./durable/Subscription.mjs";
|
|
|
36
36
|
import { MessageDeliveryDriver, MessageDeliveryFailpoint, MessageDeliveryRecord, MessageDeliveryStore, messageDeliveryCapacity, messageDeliveryUsesCapacity, prepareMessageDelivery } from "./durable/MessageDelivery.mjs";
|
|
37
37
|
import { WakeScheduler } from "./durable/WakeScheduler.mjs";
|
|
38
38
|
import { n as safeUnknownString, t as inspectForeignDiagnostic } from "./foreign-diagnostic-DBQ1XHKh.mjs";
|
|
39
|
-
import { c as threadCreatedBatchId, l as threadCreatedRecordId, n as WorkerAdmissionPort, o as ensureThreadCreated, r as WorkerAdmissionRequest, s as ensureWorkerOrigin } from "./WorkerAdmission-
|
|
39
|
+
import { c as threadCreatedBatchId, l as threadCreatedRecordId, n as WorkerAdmissionPort, o as ensureThreadCreated, r as WorkerAdmissionRequest, s as ensureWorkerOrigin } from "./WorkerAdmission-CNbm4o_x.mjs";
|
|
40
40
|
import { WorkerBudgetAuthorizer, WorkerConcurrencyLimit, WorkerConcurrencyResolver, WorkerHostAuthorizer, WorkerHostConfig, WorkerPolicyResolver } from "./durable/WorkerHost.mjs";
|
|
41
41
|
import { OperationAuthorizationRequest, OperationAuthorizer, OperationDenied } from "./durable/OperationAuthorizer.mjs";
|
|
42
42
|
import { PendingSubmission, SettledSubmission } from "./durable/SubmissionStatus.mjs";
|
|
@@ -2369,10 +2369,12 @@ const declaredToolCalls = Effect.fn("DurableAgentRuntime.declaredToolCalls")((me
|
|
|
2369
2369
|
const declaredApplicationCalls = Effect.fn("DurableAgentRuntime.declaredApplicationCalls")((messages) => declaredToolCalls(messages).pipe(Effect.map(({ application }) => application)));
|
|
2370
2370
|
const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
2371
2371
|
const registeredBindings = [...bindings];
|
|
2372
|
+
const bindingSelection = yield* CurrentBindingSelection;
|
|
2372
2373
|
const workerAdmissionPort = yield* WorkerAdmissionPort;
|
|
2373
2374
|
const ledger = yield* SubmissionLedger;
|
|
2374
2375
|
const submissionScheduling = yield* SubmissionScheduling;
|
|
2375
2376
|
const store = yield* ThreadStore;
|
|
2377
|
+
let projectedJournal;
|
|
2376
2378
|
const wake = yield* WakeScheduler;
|
|
2377
2379
|
const failpoint = yield* DurableRuntimeFailpoint;
|
|
2378
2380
|
const config = yield* DurableRuntimeConfig;
|
|
@@ -2391,15 +2393,14 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
2391
2393
|
const toolFailureObserver = yield* CurrentToolFailureObserver;
|
|
2392
2394
|
const withCrypto = (effect) => Effect.provideService(effect, Crypto.Crypto, crypto);
|
|
2393
2395
|
const contractsFor = (definition) => {
|
|
2394
|
-
const registered = registeredBindings.filter((binding) => binding.agentId === definition.id);
|
|
2395
|
-
const
|
|
2396
|
-
const current = binding?.definition.toolkit === definition.toolkit && binding.definition.completion === definition.completion && binding.definition.completionFromTools === definition.completionFromTools ? binding : void 0;
|
|
2396
|
+
const registered = registeredBindings.filter((binding) => binding.agentId === definition.id && Object.is(binding.definition, definition));
|
|
2397
|
+
const current = registered.length === 1 ? registered[0] : void 0;
|
|
2397
2398
|
const contracts = current?.digests.replay?.tools;
|
|
2398
2399
|
return contracts === void 0 ? withCrypto(toolReplayContracts(definition, void 0, current?.digests.tools ?? config.deploymentId)) : Effect.succeed(contracts);
|
|
2399
2400
|
};
|
|
2400
|
-
const
|
|
2401
|
-
|
|
2402
|
-
const binding =
|
|
2401
|
+
const resolveCurrentBinding = (submission) => resolveWorkerBinding(registeredBindings, submission).pipe(Effect.provideService(CurrentBindingSelection, bindingSelection));
|
|
2402
|
+
const currentOperationsFor = Effect.fnUntraced(function* (submission) {
|
|
2403
|
+
const binding = yield* resolveCurrentBinding(submission).pipe(Effect.catchTag("BindingUnavailable", () => Effect.succeed(void 0)));
|
|
2403
2404
|
return binding === void 0 ? void 0 : {
|
|
2404
2405
|
definition: binding.definition,
|
|
2405
2406
|
contracts: yield* contractsFor(binding.definition)
|
|
@@ -4106,11 +4107,20 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4106
4107
|
* journal ends mid-batch,
|
|
4107
4108
|
* `RunOptions.resume` replays the declared batch without re-invoking the model (§2.4).
|
|
4108
4109
|
*/
|
|
4109
|
-
const runModel = (agent, ctx, submission, tokenRef, records, canonical, canonicalThrough, journalSeed, journalMetadata, lineage, approvalDecisions, runTiming, yieldAfter) => Effect.gen(function* () {
|
|
4110
|
+
const runModel = (agent, ctx, submission, tokenRef, records, canonical, canonicalThrough, journalSeed, journalMetadata, lineage, approvalDecisions, currentContracts, runTiming, yieldAfter) => Effect.gen(function* () {
|
|
4110
4111
|
const submissionId = submission.submissionId;
|
|
4111
4112
|
const runId = runIdForSubmission(submissionId);
|
|
4112
4113
|
const boundaries = [];
|
|
4113
|
-
const
|
|
4114
|
+
const cached = projectedJournal;
|
|
4115
|
+
const journal = cached !== void 0 && cached.threadId === ctx.threadId && cached.through === canonicalThrough && cached.runId === runId && cached.seedThrough === journalSeed?.throughSequence ? (boundaries.push(...cached.boundaries), cached.journal) : yield* projectRunJournalStream(canonical, runId, (boundary) => boundaries.push(boundary), journalSeed, journalMetadata);
|
|
4116
|
+
projectedJournal = {
|
|
4117
|
+
threadId: ctx.threadId,
|
|
4118
|
+
through: canonicalThrough,
|
|
4119
|
+
runId,
|
|
4120
|
+
seedThrough: journalSeed?.throughSequence,
|
|
4121
|
+
journal,
|
|
4122
|
+
boundaries
|
|
4123
|
+
};
|
|
4114
4124
|
const saveRecoveryCheckpoint = Effect.fn("DurableAgentRuntime.saveRecoveryCheckpoint")(function* (compactionId) {
|
|
4115
4125
|
if (store.recoveryCheckpoints === void 0) return;
|
|
4116
4126
|
const tail = yield* Ref.get(ctx.tailRef);
|
|
@@ -4252,7 +4262,6 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4252
4262
|
if (submission.parentLinkage !== void 0 && (childLineage?._tag !== "SubagentLineageRecorded" || childLineage.parentSubmissionId !== submission.parentLinkage.parentSubmissionId || childLineage.parentLink.parentToolCallId !== submission.parentLinkage.parentToolCallId || !definitionDigestsEqual(childLineage.childDefinitionDigests, submission.agentDigests) || childLineage.childInputDigest !== submission.inputDigest)) return yield* RunJournalError.make({ message: "The child Run has no matching canonical lineage and execution bounds" });
|
|
4253
4263
|
const pending = yield* pendingToolBatchFor(records, runId, agent.definition.completionFromTools?.map((declaration) => declaration.tool));
|
|
4254
4264
|
const resumeProjection = pending === void 0 ? journal : yield* projectRunJournalStream(withoutPendingBatch(canonical, pending, runId), runId, void 0, journalSeed);
|
|
4255
|
-
const currentContracts = yield* contractsFor(agent.definition);
|
|
4256
4265
|
const rolloverOperation = journal.pendingContextToolCallId === void 0 ? void 0 : operationsFor(records, runId).get(journal.pendingContextToolCallId);
|
|
4257
4266
|
const rolloverTool = rolloverOperation === void 0 ? void 0 : agent.definition.toolkit.tools[rolloverOperation.toolName];
|
|
4258
4267
|
const pendingContextToolCallId = rolloverOperation !== void 0 && rolloverTool !== void 0 && Context.get(rolloverTool.annotations, ContextRolloverTool) && currentContracts[rolloverOperation.toolName] === rolloverOperation.replay ? journal.pendingContextToolCallId : void 0;
|
|
@@ -4294,11 +4303,26 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4294
4303
|
const stagedToolSelections = /* @__PURE__ */ new Map();
|
|
4295
4304
|
const stagedUsage = /* @__PURE__ */ new Map();
|
|
4296
4305
|
const committedUsageLengths = /* @__PURE__ */ new Map();
|
|
4306
|
+
const committedUnobservedCalls = /* @__PURE__ */ new Map();
|
|
4307
|
+
const usageForCommit = (turn) => {
|
|
4308
|
+
const staged = stagedUsage.get(turn);
|
|
4309
|
+
if (staged === void 0) return void 0;
|
|
4310
|
+
const modelUsage = staged.modelUsage.slice(committedUsageLengths.get(turn) ?? 0);
|
|
4311
|
+
if (modelUsage.length === 0) return void 0;
|
|
4312
|
+
return {
|
|
4313
|
+
modelUsage,
|
|
4314
|
+
inputTokens: modelUsage.reduce((sum, call) => sum + call.inputTokens.total, 0),
|
|
4315
|
+
outputTokens: modelUsage.reduce((sum, call) => sum + call.outputTokens.total, 0),
|
|
4316
|
+
costMicrousd: modelUsage.reduce((sum, call) => sum + call.costMicrousd, 0)
|
|
4317
|
+
};
|
|
4318
|
+
};
|
|
4319
|
+
const unobservedForCommit = (turn) => (stagedUnobservedCalls.get(turn) ?? 0) - (committedUnobservedCalls.get(turn) ?? 0);
|
|
4297
4320
|
const recordCommittedUsage = (batch) => {
|
|
4298
4321
|
for (const record of batch.records) {
|
|
4299
|
-
if (record.payload._tag !== "ModelResponseRecorded") continue;
|
|
4322
|
+
if (record.payload._tag !== "ModelResponseRecorded" && record.payload._tag !== "ModelCallAborted") continue;
|
|
4300
4323
|
const payload = record.payload;
|
|
4301
|
-
committedUsageLengths.set(payload.turn,
|
|
4324
|
+
committedUsageLengths.set(payload.turn, (committedUsageLengths.get(payload.turn) ?? 0) + (payload.modelUsage?.length ?? 0));
|
|
4325
|
+
committedUnobservedCalls.set(payload.turn, (committedUnobservedCalls.get(payload.turn) ?? 0) + (payload.unobservedModelCalls ?? 0));
|
|
4302
4326
|
}
|
|
4303
4327
|
};
|
|
4304
4328
|
const uncommittedModelUsage = () => [...stagedUsage.entries()].flatMap(([turn, usage]) => usage.modelUsage.slice(committedUsageLengths.get(turn) ?? 0));
|
|
@@ -4450,7 +4474,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4450
4474
|
completedFinishReason: void 0,
|
|
4451
4475
|
completedExhausted: void 0
|
|
4452
4476
|
});
|
|
4453
|
-
const turnCounter = yield* Ref.make(journal.committedTurns);
|
|
4477
|
+
const turnCounter = yield* Ref.make(journal.committedTurns + (journal.policyUsage.modelRestarts ?? 0));
|
|
4454
4478
|
const idGenerator = {
|
|
4455
4479
|
nextThreadId: Effect.succeed(submission.threadId),
|
|
4456
4480
|
nextRunId: Effect.succeed(runId),
|
|
@@ -4499,6 +4523,25 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4499
4523
|
priorRunPrefixLength
|
|
4500
4524
|
}))) };
|
|
4501
4525
|
const durability = {
|
|
4526
|
+
commitModelRestart: (restart) => recordHalt(Effect.gen(function* () {
|
|
4527
|
+
if (knownIds.has(modelResponseRecordId(runId, restart.turn))) return yield* RunJournalError.make({ message: "Cannot restart a canonical model response" });
|
|
4528
|
+
const recordId = decodeRecordIdSync(`model-aborted:${runId}:${restart.restart}`);
|
|
4529
|
+
const record = yield* makeEnvelope(recordId, ModelCallAborted.make({
|
|
4530
|
+
runId,
|
|
4531
|
+
...restart,
|
|
4532
|
+
reason: "joined-input",
|
|
4533
|
+
modelUsage: usageForCommit(restart.turn)?.modelUsage ?? [],
|
|
4534
|
+
unobservedModelCalls: unobservedForCommit(restart.turn)
|
|
4535
|
+
}));
|
|
4536
|
+
const batch = CanonicalBatch.make({
|
|
4537
|
+
batchId: decodeBatchIdSync(recordId),
|
|
4538
|
+
producerId: config.producerId,
|
|
4539
|
+
records: [record]
|
|
4540
|
+
});
|
|
4541
|
+
yield* appendBatch(ctx, batch);
|
|
4542
|
+
recordCommittedUsage(batch);
|
|
4543
|
+
knownIds.add(recordId);
|
|
4544
|
+
})),
|
|
4502
4545
|
noteToolExposure: (turn, snapshot) => Effect.sync(() => {
|
|
4503
4546
|
stagedToolExposure.set(turn, snapshot);
|
|
4504
4547
|
}),
|
|
@@ -4553,8 +4596,8 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4553
4596
|
deploymentId: config.deploymentId,
|
|
4554
4597
|
createdAt,
|
|
4555
4598
|
...canonicalTurn === 1 && pendingSlice.length > 0 ? { runScopedPrefixLength: pendingSlice.length } : {},
|
|
4556
|
-
usage:
|
|
4557
|
-
unobservedModelCalls:
|
|
4599
|
+
usage: usageForCommit(canonicalTurn),
|
|
4600
|
+
unobservedModelCalls: unobservedForCommit(canonicalTurn)
|
|
4558
4601
|
}));
|
|
4559
4602
|
yield* appendBatch(ctx, batch);
|
|
4560
4603
|
recordCommittedUsage(batch);
|
|
@@ -4852,58 +4895,94 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4852
4895
|
const state = yield* Ref.get(stateRef);
|
|
4853
4896
|
if (state.pendingTurn !== void 0 && knownIds.has(modelResponseRecordId(runId, state.pendingTurn.turn))) yield* commitPendingTurn;
|
|
4854
4897
|
});
|
|
4855
|
-
const
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4898
|
+
const pendingJoinClaims = [];
|
|
4899
|
+
const claimInputs = Effect.fnUntraced(function* (maxCount) {
|
|
4900
|
+
const ownershipToken = yield* Ref.get(tokenRef);
|
|
4901
|
+
const claims = yield* ledger.claimJoining(ClaimJoiningRequest.make({
|
|
4902
|
+
threadId: submission.threadId,
|
|
4903
|
+
hostSubmissionId: submissionId,
|
|
4904
|
+
ownershipToken,
|
|
4905
|
+
maxCount
|
|
4906
|
+
}));
|
|
4907
|
+
pendingJoinClaims.push(...claims.map((claim) => ({ claim })));
|
|
4908
|
+
return claims.length;
|
|
4909
|
+
}, Effect.uninterruptible);
|
|
4910
|
+
const revertClaims = Effect.fnUntraced(function* (claims) {
|
|
4911
|
+
for (const pending of claims) {
|
|
4912
|
+
yield* ledger.revertJoining(RevertJoiningRequest.make({ submissionId: pending.claim.submissionId }));
|
|
4913
|
+
pendingJoinClaims.splice(pendingJoinClaims.indexOf(pending), 1);
|
|
4914
|
+
}
|
|
4915
|
+
}, Effect.uninterruptible);
|
|
4916
|
+
const prepareInputs = Effect.fnUntraced(function* (limit, firstReady = false) {
|
|
4917
|
+
if (pendingJoinClaims.length < limit && (yield* claimInputs(limit - pendingJoinClaims.length)) > 0) yield* hit("join:after-claim");
|
|
4918
|
+
const prepared = [];
|
|
4919
|
+
for (const pending of pendingJoinClaims.slice(0, limit)) {
|
|
4920
|
+
const claim = pending.claim;
|
|
4921
|
+
const snapshot = yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId: claim.submissionId }));
|
|
4922
|
+
if (snapshot.abortIntent !== void 0) {
|
|
4923
|
+
yield* revertClaims([pending]);
|
|
4924
|
+
continue;
|
|
4925
|
+
}
|
|
4926
|
+
if (pending.prepared === void 0) {
|
|
4927
|
+
const input = {
|
|
4928
|
+
input: claim.inputPayload,
|
|
4929
|
+
...snapshot.submission.messageAdmission === void 0 ? {} : { messageAdmission: snapshot.submission.messageAdmission }
|
|
4930
|
+
};
|
|
4931
|
+
const rendered = yield* Effect.result(renderJoinedInput(input));
|
|
4932
|
+
if (Result.isFailure(rendered)) {
|
|
4933
|
+
yield* revertClaims(pendingJoinClaims.slice(pendingJoinClaims.indexOf(pending)));
|
|
4934
|
+
break;
|
|
4875
4935
|
}
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
joinedInputs.push(payload);
|
|
4936
|
+
pending.prepared = {
|
|
4937
|
+
claim,
|
|
4938
|
+
input,
|
|
4939
|
+
rendered: rendered.success
|
|
4940
|
+
};
|
|
4882
4941
|
}
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4942
|
+
prepared.push(pending.prepared);
|
|
4943
|
+
if (firstReady) break;
|
|
4944
|
+
}
|
|
4945
|
+
return prepared;
|
|
4946
|
+
});
|
|
4947
|
+
const input = {
|
|
4948
|
+
awaitJoin: recordHalt(Effect.gen(function* () {
|
|
4949
|
+
while (true) if (yield* Effect.scoped(Effect.gen(function* () {
|
|
4950
|
+
const notified = yield* wake.subscribe(submission.threadId);
|
|
4951
|
+
if ((yield* prepareInputs(MAX_JOIN_DRAIN, true)).length > 0) return true;
|
|
4952
|
+
yield* notified;
|
|
4953
|
+
return false;
|
|
4954
|
+
}))) return;
|
|
4955
|
+
})),
|
|
4956
|
+
drain: (policy) => Effect.gen(function* () {
|
|
4957
|
+
const joinedInputs = yield* recordHalt(Effect.gen(function* () {
|
|
4958
|
+
const limit = policy === "one" ? 1 : MAX_JOIN_DRAIN;
|
|
4959
|
+
const joinedInputs = [];
|
|
4960
|
+
if (joinBacklog === void 0) joinBacklog = (yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId }))).joins;
|
|
4961
|
+
for (const join of joinBacklog) {
|
|
4962
|
+
const joinId = join.submissionId;
|
|
4963
|
+
if (deliveredJoinInputs.has(joinId)) continue;
|
|
4964
|
+
if (join.state !== "joining" && join.state !== "joined") continue;
|
|
4965
|
+
const existing = joinedInputEnvelopes.get(joinId);
|
|
4966
|
+
if (existing === void 0) continue;
|
|
4967
|
+
if (join.state === "joining") {
|
|
4968
|
+
const ownershipToken = yield* Ref.get(tokenRef);
|
|
4969
|
+
yield* ledger.markJoined(MarkJoinedRequest.make({
|
|
4970
|
+
submissionId: joinId,
|
|
4971
|
+
ownershipToken,
|
|
4972
|
+
recordId: existing.record.recordId,
|
|
4973
|
+
sequence: existing.sequence
|
|
4974
|
+
}));
|
|
4906
4975
|
}
|
|
4976
|
+
deliveredJoinInputs.add(joinId);
|
|
4977
|
+
if (lastHostResponseSequence !== void 0 && lastHostResponseSequence > existing.sequence) continue;
|
|
4978
|
+
const payload = existing.record.payload;
|
|
4979
|
+
if (payload._tag !== "UserInputRecorded") continue;
|
|
4980
|
+
yield* preserveToolResults;
|
|
4981
|
+
joinedInputs.push(payload);
|
|
4982
|
+
}
|
|
4983
|
+
const claims = yield* prepareInputs(limit);
|
|
4984
|
+
pendingJoinClaims.splice(0, claims.length);
|
|
4985
|
+
for (const { claim, input: payload, rendered } of claims) {
|
|
4907
4986
|
yield* preserveToolResults;
|
|
4908
4987
|
const recordId = submissionInputRecordId(claim.submissionId);
|
|
4909
4988
|
let sequence;
|
|
@@ -4915,7 +4994,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4915
4994
|
kind: "steering",
|
|
4916
4995
|
runId,
|
|
4917
4996
|
input: claim.inputPayload,
|
|
4918
|
-
...
|
|
4997
|
+
...payload.messageAdmission === void 0 ? {} : { messageAdmission: payload.messageAdmission }
|
|
4919
4998
|
}));
|
|
4920
4999
|
sequence = (yield* appendBatch(ctx, CanonicalBatch.make({
|
|
4921
5000
|
batchId: submissionInputBatchId(claim.submissionId),
|
|
@@ -4935,17 +5014,17 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4935
5014
|
deliveredJoinInputs.add(claim.submissionId);
|
|
4936
5015
|
joinedInputs.push({
|
|
4937
5016
|
...payload,
|
|
4938
|
-
rendered
|
|
5017
|
+
rendered
|
|
4939
5018
|
});
|
|
4940
5019
|
}
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
})
|
|
4948
|
-
}
|
|
5020
|
+
return joinedInputs;
|
|
5021
|
+
}).pipe(Effect.onExit((exit) => Exit.isFailure(exit) ? preserveToolResults : Effect.void)));
|
|
5022
|
+
return yield* Effect.forEach(joinedInputs, (joinedInput) => (joinedInput.rendered === void 0 ? renderJoinedInput(joinedInput) : Effect.succeed(joinedInput.rendered)).pipe(Effect.map((input) => ({
|
|
5023
|
+
kind: "steering",
|
|
5024
|
+
input
|
|
5025
|
+
}))));
|
|
5026
|
+
})
|
|
5027
|
+
};
|
|
4949
5028
|
/**
|
|
4950
5029
|
* Durable child establishment: `establish` performs or replays
|
|
4951
5030
|
* the idempotent get-or-create establishment protocol under the
|
|
@@ -5377,8 +5456,8 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5377
5456
|
createdAt,
|
|
5378
5457
|
...runScopedPrefixLength > 0 ? { runScopedPrefixLength } : {},
|
|
5379
5458
|
...completedRun === void 0 ? {} : { runCompletion: completedRun },
|
|
5380
|
-
usage:
|
|
5381
|
-
unobservedModelCalls:
|
|
5459
|
+
usage: usageForCommit(canonicalTurn),
|
|
5460
|
+
unobservedModelCalls: unobservedForCommit(canonicalTurn)
|
|
5382
5461
|
}));
|
|
5383
5462
|
yield* appendBatch(ctx, batch);
|
|
5384
5463
|
recordCommittedUsage(batch);
|
|
@@ -5416,6 +5495,10 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5416
5495
|
});
|
|
5417
5496
|
const handleEvent = (event) => {
|
|
5418
5497
|
switch (event._tag) {
|
|
5498
|
+
case "ModelRestarted": return Ref.update(stateRef, (state) => ({
|
|
5499
|
+
...state,
|
|
5500
|
+
pendingTurn: void 0
|
|
5501
|
+
}));
|
|
5419
5502
|
case "TurnStarted": return commitPendingTurn.pipe(Effect.andThen(Effect.sync(() => {
|
|
5420
5503
|
siblingResults.clear();
|
|
5421
5504
|
stagedToolSelections.clear();
|
|
@@ -5668,6 +5751,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5668
5751
|
policy: childPolicy
|
|
5669
5752
|
}
|
|
5670
5753
|
};
|
|
5754
|
+
const currentContracts = yield* contractsFor(registeredAgent.definition);
|
|
5671
5755
|
const evidence = yield* evidenceFor(records, submissionId, true, snapshot.hostSubmissionId);
|
|
5672
5756
|
const knownIds = knownRecordIdsOf(records);
|
|
5673
5757
|
if (evidence.recordedSettlementOutcome !== void 0) {
|
|
@@ -5710,7 +5794,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5710
5794
|
for (const envelope of reconciliationRecords) knownIds.add(envelope.record.recordId);
|
|
5711
5795
|
const review = yield* reconcileOpenCalls(ctx, submission, reconciliationSnapshot, reconciliationRecords, reconciliationEvidence.openToolCalls, knownIds, {
|
|
5712
5796
|
definition: agent.definition,
|
|
5713
|
-
contracts:
|
|
5797
|
+
contracts: currentContracts
|
|
5714
5798
|
});
|
|
5715
5799
|
if (review.uncertain.length > 0 || review.unproven.length > 0) {
|
|
5716
5800
|
if (review.uncertain.length > 0) yield* markCallsUnknown(ctx, submissionId, knownIds, review.uncertain, "An ordinary Tool call may have executed without a canonical outcome");
|
|
@@ -5729,7 +5813,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5729
5813
|
if (continuation !== void 0) {
|
|
5730
5814
|
const current = {
|
|
5731
5815
|
definition: agent.definition,
|
|
5732
|
-
contracts:
|
|
5816
|
+
contracts: currentContracts
|
|
5733
5817
|
};
|
|
5734
5818
|
const operations = operationsFor(continuationRecords, runIdForSubmission(submissionId));
|
|
5735
5819
|
const settled = new Set(continuation.settled.map((call) => call.id));
|
|
@@ -5802,7 +5886,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5802
5886
|
const tail = yield* store.inspectTail(ThreadTailRequest.make({ threadId }));
|
|
5803
5887
|
const canonical = Stream.concat(initialView.canonical, canonicalRange(threadId, tail.tailSequence, initialThrough));
|
|
5804
5888
|
const currentRecords = yield* refreshControl(tail.tailSequence);
|
|
5805
|
-
const outcome = yield* runModel(agent, ctx, submission, tokenRef, currentRecords, canonical, tail.tailSequence, initialView.seed, journalMetadata?.snapshot(), lineage, approvalDecisionIntents, runTiming, yieldAfter);
|
|
5889
|
+
const outcome = yield* runModel(agent, ctx, submission, tokenRef, currentRecords, canonical, tail.tailSequence, initialView.seed, journalMetadata?.snapshot(), lineage, approvalDecisionIntents, currentContracts, runTiming, yieldAfter);
|
|
5806
5890
|
if (outcome._tag === "yielded") {
|
|
5807
5891
|
if (outcome.nextSubmissionId !== void 0) onHandoff(outcome.nextSubmissionId);
|
|
5808
5892
|
return Option.none();
|
|
@@ -5992,7 +6076,6 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5992
6076
|
message: `This worker is bound to Agent ${binding.agentId}; the claimed head belongs to Agent ${submission.agentId} (SUB-023)`
|
|
5993
6077
|
})), threadId);
|
|
5994
6078
|
});
|
|
5995
|
-
const resolveCurrentBinding = (submission) => resolveWorkerBinding(registeredBindings, submission.agentId);
|
|
5996
6079
|
const processThreadResolvedImpl = (threadId) => drainThread(resolveCurrentBinding, threadId);
|
|
5997
6080
|
const processThreadHeadImpl = (threadId, options) => processThreadHead(resolveCurrentBinding, threadId, options);
|
|
5998
6081
|
const claimFor = Effect.fn("DurableAgentRuntime.claimFor")(function* (submission, decision) {
|
|
@@ -6113,7 +6196,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
6113
6196
|
const ctx = yield* attemptContextFor(submission.threadId, claim.producerEpoch);
|
|
6114
6197
|
const knownIds = knownRecordIdsOf(records);
|
|
6115
6198
|
const markableIds = new Set(decision.openToolCallIds);
|
|
6116
|
-
const review = yield* reconcileOpenCalls(ctx, submission, snapshot, records, evidence.openToolCalls.filter((call) => markableIds.has(call.toolCallId)), knownIds, yield* currentOperationsFor(submission
|
|
6199
|
+
const review = yield* reconcileOpenCalls(ctx, submission, snapshot, records, evidence.openToolCalls.filter((call) => markableIds.has(call.toolCallId)), knownIds, yield* currentOperationsFor(submission));
|
|
6117
6200
|
let disposition;
|
|
6118
6201
|
if (review.uncertain.length > 0) {
|
|
6119
6202
|
yield* markCallsUnknown(ctx, submission.submissionId, knownIds, review.uncertain, decision.reason);
|
|
@@ -6130,7 +6213,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
6130
6213
|
const hasUnsupportedRetry = Effect.fnUntraced(function* (snapshot, records) {
|
|
6131
6214
|
if (!snapshot.unknownResolutions.some((intent) => intent.resolution._tag === "SafeToRetry")) return false;
|
|
6132
6215
|
const submission = snapshot.submission;
|
|
6133
|
-
const current = yield* currentOperationsFor(submission
|
|
6216
|
+
const current = yield* currentOperationsFor(submission);
|
|
6134
6217
|
const operations = operationsFor(records, runIdForSubmission(submission.submissionId));
|
|
6135
6218
|
for (const intent of snapshot.unknownResolutions) if (intent.resolution._tag === "SafeToRetry") {
|
|
6136
6219
|
const prepared = records.map(({ record }) => record.payload).find((payload) => payload._tag === "ToolCallPrepared" && payload.runId === runIdForSubmission(submission.submissionId) && payload.toolCallId === intent.toolCallId);
|
|
@@ -7096,6 +7179,20 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
7096
7179
|
producerId: config.producerId
|
|
7097
7180
|
}).pipe(Effect.provideService(WorkerRuntime, workerRuntime));
|
|
7098
7181
|
return DurableAgentRuntime.of({
|
|
7182
|
+
bindingRegistryKey: yield* withCrypto(digestJson({
|
|
7183
|
+
selection: bindingSelection?.key ?? null,
|
|
7184
|
+
bindings: (yield* Effect.forEach(registeredBindings, (binding) => withCrypto(digestJson({
|
|
7185
|
+
agentId: binding.agentId,
|
|
7186
|
+
agent: binding.digests.agent,
|
|
7187
|
+
model: binding.digests.model,
|
|
7188
|
+
tools: binding.digests.tools,
|
|
7189
|
+
replay: binding.digests.replay === void 0 ? null : {
|
|
7190
|
+
agent: binding.digests.replay.agent,
|
|
7191
|
+
agentBehavior: binding.digests.replay.agentBehavior ?? null,
|
|
7192
|
+
tools: binding.digests.replay.tools
|
|
7193
|
+
}
|
|
7194
|
+
}))).pipe(Effect.orDie)).sort()
|
|
7195
|
+
})).pipe(Effect.orDie),
|
|
7099
7196
|
workerHost: workerRuntime.acquire,
|
|
7100
7197
|
messagingHost: messagingRuntime.acquire,
|
|
7101
7198
|
submitRegistered,
|
|
@@ -7186,7 +7283,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
7186
7283
|
var DurableAgentRuntime = class DurableAgentRuntime extends Context.Service()("@effect-agent/thread/DurableAgentRuntime") {
|
|
7187
7284
|
/**
|
|
7188
7285
|
* Resolve typed registrations and capture their services once in the runtime's Layer Scope.
|
|
7189
|
-
* Every claimed head must
|
|
7286
|
+
* Every claimed head must select exactly one current registered Definition. Worker calls
|
|
7190
7287
|
* cannot replace these registrations or their captured services. Tool authorization is required.
|
|
7191
7288
|
*/
|
|
7192
7289
|
static layerRegistered(registrations) {
|
|
@@ -7204,4 +7301,4 @@ var DurableAgentRuntime = class DurableAgentRuntime extends Context.Service()("@
|
|
|
7204
7301
|
//#endregion
|
|
7205
7302
|
export { DurableApprovalSuspension as a, RecoveryFailure as c, childReservationIdFor as d, isolateRecovery as f, DurableApprovalResolver as i, RecoveryReport as l, recoveryRepairRecordId as m, DurableAgentRuntime as n, DurableRuntimeConfig as o, recoveryRepairBatchId as p, DurableAgentRuntime_exports as r, RecoveryBlocked as s, ApprovalSuspensionError as t, RecoverySweepResult as u };
|
|
7206
7303
|
|
|
7207
|
-
//# sourceMappingURL=DurableAgentRuntime-
|
|
7304
|
+
//# sourceMappingURL=DurableAgentRuntime-BQzYkFVy.mjs.map
|