effect-agent 0.1.0-beta.134 → 0.1.0-beta.136
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-CUja0lmO.d.mts → Admin-Fx85KT-W.d.mts} +42 -4
- package/dist/{DurableAgentRuntime-DH2baLGe.mjs → DurableAgentRuntime-Bso5grIH.mjs} +50 -12
- package/dist/DurableAgentRuntime-Bso5grIH.mjs.map +1 -0
- package/dist/{EventSource-DoiZF3xv.d.mts → EventSource-DLT8oDK8.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-B1bzyIuV.d.mts → PreparedInputAdmission-CKFgG6Em.d.mts} +3 -3
- package/dist/{RunJournal-BXrq0VIK.mjs → RunJournal-Gd83HYqG.mjs} +50 -27
- package/dist/RunJournal-Gd83HYqG.mjs.map +1 -0
- package/dist/{Subscription-m_yNfNeN.d.mts → Subscription-CCmHgOYM.d.mts} +2 -2
- package/dist/{SubscriptionInput-ON3-b8Sl.d.mts → SubscriptionInput-BFJMhu4K.d.mts} +2 -2
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/AgentRegistration.d.mts +1 -1
- package/dist/durable/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +1 -1
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/MessageDelivery.d.mts +41 -41
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +1 -1
- package/dist/durable/PersistentHistory.d.mts +1 -1
- package/dist/durable/PersistentHistory.mjs +1 -1
- package/dist/durable/PreparedInputAdmission.d.mts +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/Scheduling.d.mts +1 -1
- package/dist/durable/SqlStorageV2Upgrade.d.mts +1 -1
- package/dist/durable/SqlSubscriptionStore.d.mts +1 -1
- package/dist/durable/SqlThreadNativeReads.d.mts +1 -1
- package/dist/durable/SqlThreadNativeReads.mjs +1 -1
- package/dist/durable/SubmissionLedger.d.mts +2 -2
- package/dist/durable/SubmissionLedger.mjs +29 -2
- package/dist/durable/SubmissionLedger.mjs.map +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.mjs +69 -2
- package/dist/durable/SubmissionLedgerConformance.mjs.map +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/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionTools.d.mts +2 -2
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/Subscriptions.d.mts +5 -5
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadInvariants.d.mts +1 -1
- package/dist/durable/ThreadInvariants.mjs +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/WorkerHost.d.mts +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/src/durable/DurableAgentRuntime.ts +94 -10
- package/src/durable/RunJournal.ts +120 -56
- package/src/durable/SubmissionLedger.ts +32 -0
- package/src/durable/SubmissionLedgerConformance.ts +120 -0
- package/src/durable/internal/journal-checkpoint.ts +1 -1
- package/src/durable/internal/journal-metadata.ts +10 -3
- package/dist/DurableAgentRuntime-DH2baLGe.mjs.map +0 -1
- package/dist/RunJournal-BXrq0VIK.mjs.map +0 -1
|
@@ -177,6 +177,7 @@ interface JournalMetadata {
|
|
|
177
177
|
readonly settledSpans: ReadonlyArray<{
|
|
178
178
|
readonly from: number;
|
|
179
179
|
readonly to: number;
|
|
180
|
+
readonly runId: RunId;
|
|
180
181
|
}>;
|
|
181
182
|
readonly toolExecutionEvidence: ReadonlySet<string>;
|
|
182
183
|
readonly settledToolCallRecordIds: ReadonlySet<string>;
|
|
@@ -402,6 +403,9 @@ interface RunJournalProjection {
|
|
|
402
403
|
* are never canonical settlements or evidence for compaction, recovery or accounting. Real
|
|
403
404
|
* results replace them at the original declaration, including results appended after another Run.
|
|
404
405
|
* Prior user intent and assistant text remain visible; prior system instructions do not.
|
|
406
|
+
* Each Run retains the history preceding its start and its own continuation. Other Runs'
|
|
407
|
+
* subsequent Turns cannot replace its input. Compaction covers only its creator's Run view;
|
|
408
|
+
* a projection without an owner retains interleaved exchanges from the complete Thread history.
|
|
405
409
|
*/
|
|
406
410
|
/** @internal Lightweight canonical boundaries collected without retaining record payloads. */
|
|
407
411
|
interface JournalBoundary {
|
|
@@ -1160,7 +1164,10 @@ declare const DurableAgentRuntime_base: Context.ServiceClass<DurableAgentRuntime
|
|
|
1160
1164
|
readonly processThread: <InputSchema extends Schema.Top, OutputSchema extends Schema.Top, Instructions, Tools extends Record<string, Tool.Any>, Provider, ModelProvides, ModelRequires, InstructionError = InstructionErrorOf<Instructions, InputSchema["Type"]>, InstructionRequirements = InstructionRequirementsOf<Instructions, InputSchema["Type"]>, RunDispositionValue extends RunDispositionDeclaration<OutputSchema["Type"], Schema.Top> | undefined = undefined, InputPromptValue extends InputPromptSource<InputSchema["Type"], unknown, unknown> | undefined = undefined, UpdatesSchema extends Schema.Top | undefined = undefined>(agent: RuntimeBinding<InputSchema, OutputSchema, Instructions, Tools, Provider, ModelProvides, ModelRequires, InstructionError, InstructionRequirements, RunDispositionValue, InputPromptValue, UpdatesSchema>, threadId: ThreadId) => Effect.Effect<ReadonlyArray<Settlement>, DurableWorkerFailure | DurableBindingFailure, DurableWorkerRequirements<RuntimeBinding<InputSchema, OutputSchema, Instructions, Tools, Provider, ModelProvides, ModelRequires, InstructionError, InstructionRequirements, RunDispositionValue, InputPromptValue, UpdatesSchema>, InstructionRequirements>>;
|
|
1161
1165
|
readonly processThreadResolved: (threadId: ThreadId) => Effect.Effect<ReadonlyArray<Settlement>, DurableWorkerFailure | DurableBindingFailure>;
|
|
1162
1166
|
/**
|
|
1163
|
-
* Advance the FIFO head, closing its Attempt resources before returning.
|
|
1167
|
+
* Advance the FIFO head, closing its Attempt resources before returning. With an opted-in
|
|
1168
|
+
* SubmissionScheduling policy, a complete Turn may hand off to the next same-Agent input;
|
|
1169
|
+
* the returned Settlement identifies the Submission actually completed. Each Attempt closes
|
|
1170
|
+
* before the next is claimed, and deferred Runs retain their original obligations. A vacant,
|
|
1164
1171
|
* owned, unknown, or suspended head returns None and leaves accepted work pending.
|
|
1165
1172
|
* Ready input may join this Run through the existing Turn seams and settle with its head.
|
|
1166
1173
|
* Interruption ends only this Attempt; ownership cleanup uses its latest renewed token.
|
|
@@ -1281,7 +1288,7 @@ declare class DurableAgentRuntime extends DurableAgentRuntime_base {
|
|
|
1281
1288
|
static readonly layer: Layer.Layer<DurableAgentRuntime, never, SubmissionLedger | ThreadStore | WakeScheduler | DurableRuntimeFailpoint | DurableRuntimeConfig | ToolReconciler | Crypto.Crypto>;
|
|
1282
1289
|
}
|
|
1283
1290
|
declare namespace SubmissionLedger_d_exports {
|
|
1284
|
-
export { AbortCommand, AbortIntent, AbortIntentRequest, AdmissionAdmitted, AdmissionConflict, AdmissionFence, AdmissionGroup, AdmissionIndeterminate, AdmissionNotAdmitted, AdmissionPolicyError, AdmissionRequest, AdmissionResolution, AdmissionResult, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, ApprovalPendingSuspension, AttachChildToReservationRequest, BeginChildBudgetReleaseRequest, ChildAttachmentSnapshot, ChildBudgetReservationRequest, ChildBudgetReservationSnapshot, ChildReservationConflict, ChildReservationId, ChildReservationStatus, ChildSettledNotification, ChildSettledOutcome, Claim, ClaimJoiningRequest, ClaimRequest, DEFAULT_OWNERSHIP_LEASE_DURATION, IdempotencyKey, InputAppliedMarker, JoinSnapshot, JoinedToHost, JoiningClaim, LedgerCapabilities, LedgerError, MarkInputAppliedRequest, MarkJoinedRequest, MarkReadyRequest, MarkUnknownRequest, OwnershipLost, OwnershipRenewal, OwnershipSnapshot, OwnershipToken, ParentLinkage, Principal, QueueSequence, RecoverySnapshot, RecoverySnapshotRequest, ReleaseChildBudgetRequest, ReleaseOwnershipRequest, RenewOwnershipRequest, ReservedChildBudget, ReservedSettlement, ResolutionAbortSubmission, ResolutionCompletedWithResult, ResolutionNeverHappened, ResolutionSafeToRetry, RevertJoiningRequest, Settlement, SettlementConflict, SettlementFinalization, SettlementReservation, SettlementReservationSnapshot, SubmissionAdmissionFence, SubmissionLedger, SubmissionLedgerFailure, SubmissionLookup, SubmissionLookupById, SubmissionLookupByKey, SubmissionSnapshot, SubmissionState, SubmissionWorkItem, SuspendRequest, SuspensionOutcome, SuspensionReason, SuspensionSnapshot, UnknownResolution, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent, WaitingChild, WaitingForChildSuspension, WorkerLedgerState, WorkerStopCommand, settlementFailureFromRecord, submissionAbortBatchId, submissionAbortRecordId, submissionInputBatchId, submissionInputRecordId, submissionSettlementBatchId, submissionSettlementId, submissionSettlementRecordId, workerTerminalFromRecord };
|
|
1291
|
+
export { AbortCommand, AbortIntent, AbortIntentRequest, AdmissionAdmitted, AdmissionConflict, AdmissionFence, AdmissionGroup, AdmissionIndeterminate, AdmissionNotAdmitted, AdmissionPolicyError, AdmissionRequest, AdmissionResolution, AdmissionResult, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, ApprovalPendingSuspension, AttachChildToReservationRequest, BeginChildBudgetReleaseRequest, ChildAttachmentSnapshot, ChildBudgetReservationRequest, ChildBudgetReservationSnapshot, ChildReservationConflict, ChildReservationId, ChildReservationStatus, ChildSettledNotification, ChildSettledOutcome, Claim, ClaimHandoff, ClaimJoiningRequest, ClaimRequest, DEFAULT_OWNERSHIP_LEASE_DURATION, IdempotencyKey, InputAppliedMarker, JoinSnapshot, JoinedToHost, JoiningClaim, LedgerCapabilities, LedgerError, MarkInputAppliedRequest, MarkJoinedRequest, MarkReadyRequest, MarkUnknownRequest, OwnershipLost, OwnershipRenewal, OwnershipSnapshot, OwnershipToken, ParentLinkage, Principal, QueueSequence, RecoverySnapshot, RecoverySnapshotRequest, ReleaseChildBudgetRequest, ReleaseOwnershipRequest, RenewOwnershipRequest, ReservedChildBudget, ReservedSettlement, ResolutionAbortSubmission, ResolutionCompletedWithResult, ResolutionNeverHappened, ResolutionSafeToRetry, RevertJoiningRequest, Settlement, SettlementConflict, SettlementFinalization, SettlementReservation, SettlementReservationSnapshot, SubmissionAdmissionFence, SubmissionLedger, SubmissionLedgerFailure, SubmissionLookup, SubmissionLookupById, SubmissionLookupByKey, SubmissionScheduling, SubmissionSnapshot, SubmissionState, SubmissionWorkItem, SuspendRequest, SuspensionOutcome, SuspensionReason, SuspensionSnapshot, UnknownResolution, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent, WaitingChild, WaitingForChildSuspension, WorkerLedgerState, WorkerStopCommand, settlementFailureFromRecord, submissionAbortBatchId, submissionAbortRecordId, submissionInputBatchId, submissionInputRecordId, submissionSettlementBatchId, submissionSettlementId, submissionSettlementRecordId, workerTerminalFromRecord };
|
|
1285
1292
|
}
|
|
1286
1293
|
/**
|
|
1287
1294
|
* Opaque proof that one Attempt currently owns a Submission's lane. It authorizes ledger
|
|
@@ -1310,6 +1317,20 @@ type OwnershipToken = typeof OwnershipToken.Type;
|
|
|
1310
1317
|
*/
|
|
1311
1318
|
declare const SubmissionState: Schema.Literals<readonly ["admitted", "ready", "joining", "joined", "running", "input-applied", "suspended", "unknown", "terminalizing", "settled"]>;
|
|
1312
1319
|
type SubmissionState = typeof SubmissionState.Type;
|
|
1320
|
+
/**
|
|
1321
|
+
* Opt-in host policy for handling the next runnable same-Agent input in its own Run at a complete Turn
|
|
1322
|
+
* boundary. This never joins inputs or changes their principals, grants, or receipts. The
|
|
1323
|
+
* runtime selects the ordered candidate; policy cannot select an arbitrary Submission.
|
|
1324
|
+
* Approval waits, child waits and incomplete Tool batches are not handoff boundaries. Hosts
|
|
1325
|
+
* retaining independent replies must also leave those inputs unclaimed by `claimJoining`.
|
|
1326
|
+
* In-flight model requests and Tool batches run to their existing safe boundary.
|
|
1327
|
+
*/
|
|
1328
|
+
declare const SubmissionScheduling: Context.Reference<{
|
|
1329
|
+
readonly yieldTo?: (request: {
|
|
1330
|
+
readonly active: SubmissionSnapshot;
|
|
1331
|
+
readonly next: SubmissionSnapshot;
|
|
1332
|
+
}) => Effect.Effect<boolean, LedgerError>;
|
|
1333
|
+
}>;
|
|
1313
1334
|
/**
|
|
1314
1335
|
* Default ownership lease duration (D5). The lease is a liveness hint that makes an abandoned
|
|
1315
1336
|
* claim reclaimable; correctness never depends on it because every canonical append is fenced by
|
|
@@ -1738,9 +1759,21 @@ declare class AdmissionIndeterminate extends AdmissionIndeterminate_base {}
|
|
|
1738
1759
|
*/
|
|
1739
1760
|
declare const AdmissionResolution: Schema.Union<readonly [typeof AdmissionNotAdmitted, typeof AdmissionAdmitted, typeof AdmissionIndeterminate]>;
|
|
1740
1761
|
type AdmissionResolution = typeof AdmissionResolution.Type;
|
|
1762
|
+
declare const ClaimHandoff_base: Schema.Class<ClaimHandoff, Schema.Struct<{
|
|
1763
|
+
readonly producerEpoch: Schema.brand<Schema.Natural, "@effect-agent/thread/ProducerEpoch">;
|
|
1764
|
+
readonly deferredSubmissionIds: Schema.NonEmptyArray<Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">>;
|
|
1765
|
+
readonly submissionId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">;
|
|
1766
|
+
}>, {}>;
|
|
1767
|
+
/**
|
|
1768
|
+
* A trusted runtime's advisory handoff after committing a complete Turn and closing its
|
|
1769
|
+
* Attempt. The epoch fences the observation; an intervening claim invalidates it. Deferred
|
|
1770
|
+
* Runs retain their identities and obligations. Losing this hint resumes ordinary FIFO.
|
|
1771
|
+
*/
|
|
1772
|
+
declare class ClaimHandoff extends ClaimHandoff_base {}
|
|
1741
1773
|
declare const ClaimRequest_base: Schema.Class<ClaimRequest, Schema.Struct<{
|
|
1742
1774
|
readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
|
|
1743
1775
|
readonly producerId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/ProducerId">;
|
|
1776
|
+
readonly handoff: Schema.optionalKey<typeof ClaimHandoff>;
|
|
1744
1777
|
}>, {}>;
|
|
1745
1778
|
declare class ClaimRequest extends ClaimRequest_base {}
|
|
1746
1779
|
declare const Claim_base: Schema.Class<Claim, Schema.Struct<{
|
|
@@ -2457,6 +2490,11 @@ declare const SubmissionLedger_base: Context.ServiceClass<SubmissionLedger, "@ef
|
|
|
2457
2490
|
* `attemptId` and `ownershipToken`, and starts the ownership lease (D5: adapters default to
|
|
2458
2491
|
* `DEFAULT_OWNERSHIP_LEASE_DURATION`, configurable). An expired lease makes the head
|
|
2459
2492
|
* claimable; expiry alone never revokes correctness, only permission to assume liveness.
|
|
2493
|
+
* An optional trusted-runtime `handoff` can defer only the named `input-applied` prefix,
|
|
2494
|
+
* with no abort intent, to claim the exact next runnable Submission. It is checked atomically
|
|
2495
|
+
* against the current producer epoch and the same whole-Thread ownership fence. Admission
|
|
2496
|
+
* gaps, approval/child waits and joined work cannot be bypassed. Hints are not durable facts;
|
|
2497
|
+
* recovery resumes the same retained Runs and can select another complete-Turn handoff.
|
|
2460
2498
|
* - `renewOwnership` — extends the lease while the token still owns the lane; fails with
|
|
2461
2499
|
* `OwnershipLost` once superseded. Renewal after lease expiry succeeds if no other claim has
|
|
2462
2500
|
* taken the lane in between.
|
|
@@ -3195,5 +3233,5 @@ declare const RetryRefused_base: Schema.Class<RetryRefused, Schema.TaggedStruct<
|
|
|
3195
3233
|
*/
|
|
3196
3234
|
declare class RetryRefused extends RetryRefused_base {}
|
|
3197
3235
|
//#endregion
|
|
3198
|
-
export { RepairSubagentStartLink as $,
|
|
3199
|
-
//# sourceMappingURL=Admin-
|
|
3236
|
+
export { RepairSubagentStartLink as $, subagentStartedRecordId as $i, DurableApprovalFailure as $n, ThreadRecoveryCheckpoints as $r, ParentLinkage as $t, AwaitChildSettlement as A, ResolvedBinding as Aa, firstWorkerInputRecordId as Ai, SuspensionReason as An, CheckpointRejected as Ar, ChildReservationConflict as At, MarkUnknown as B, runCompletionDigest as Bi, settlementFailureFromRecord as Bn, ThreadExport as Br, InputAppliedMarker as Bt, renderRecoveryExplanation as C, AgentAttemptContext as Ca, TurnCommitInput as Ci, SubmissionLookupByKey as Cn, isolateRecovery as Cr, ApprovalDecisionIntent as Ct, ApplyUnknownResolutions as D, DurableWorkerBinding as Da, childThreadIdFor as Di, SubmissionWorkItem as Dn, threadCreatedRecordId as Dr, ChildAttachmentSnapshot as Dt, ApplyJoinAccounting as E, DurableBindingFailure as Ea, childIdempotencyKeyFor as Ei, SubmissionState as En, threadCreatedBatchId as Er, BeginChildBudgetReleaseRequest as Et, CompleteMaterialization as F, peerMessageRecordId as Fi, UnknownResolutionIntent as Fn, SaveCheckpointRequest as Fr, Claim as Ft, PropagateChildAbort as G, runStartedRecordId as Gi, submissionSettlementBatchId as Gn, ThreadNotMaterialized as Gr, MarkInputAppliedRequest as Gt, OpenDelegationCallEvidence as H, runDurationRecordId as Hi, submissionAbortRecordId as Hn, ThreadIdentity as Hr, JoiningClaim as Ht, DeclaredPendingBatchEvidence as I, projectRunJournal as Ii, WaitingChild as In, SaveRecoveryCheckpointRequest as Ir, ClaimHandoff as It, Recovery_d_exports as J, subagentLineageBatchId as Ji, workerTerminalFromRecord as Jn, ThreadOutstandingRequest as Jr, MarkUnknownRequest as Jt, RecoveryDecision as K, subagentJoinBatchId as Ki, submissionSettlementId as Kn, ThreadObservation as Kr, MarkJoinedRequest as Kt, DelegationAdmissionEvidence as L, projectRunJournalStream as Li, WaitingForChildSuspension as Ln, SelectedThreadRead as Lr, ClaimJoiningRequest as Lt, AwaitParentEstablishment as M, compileRegistrations as Ma, modelResponseInterruptedBatchId as Mi, UnknownResolution as Mn, FencedAppendRequest as Mr, ChildReservationStatus as Mt, AwaitUnknownResolution as N, definitionDigestsEqual as Na, modelResponseInterruptedRecordId as Ni, UnknownResolutionCommand as Nn, LoadCheckpointRequest as Nr, ChildSettledNotification as Nt, AwaitApprovalDecision as O, ExecutableAgentBinding as Oa, compactionBatchId as Oi, SuspendRequest as On, AppendConflict as Or, ChildBudgetReservationRequest as Ot, CompleteChildAdmission as P, modelResponseRecordId as Pi, UnknownResolutionConflict as Pn, MAX_THREAD_EXPORT_RECORDS as Pr, ChildSettledOutcome as Pt, RepairReadiness as Q, subagentStartedBatchId as Qi, DurableAgentRuntime_d_exports as Qn, ThreadRecordRequest as Qr, OwnershipToken as Qt, EnsureWaitingForChild as R, promptFromCanonicalRecords as Ri, WorkerLedgerState as Rn, ThreadCheckpoint as Rr, ClaimRequest as Rt, recoveryDecisionMeaning as S, AgentRegistration_d_exports as Sa, RunJournal_d_exports as Si, SubmissionLookupById as Sn, childReservationIdFor as Sr, ApprovalDecisionCommand as St, ApplyInput as T, BindingUnavailable as Ta, approvalDecisionBatchId as Ti, SubmissionSnapshot as Tn, recoveryRepairRecordId as Tr, AttachChildToReservationRequest as Tt, OpenToolCallEvidence as U, runIdForSubmission as Ui, submissionInputBatchId as Un, ThreadIdentityRequest as Ur, LedgerCapabilities as Ut, NoAction as V, runDurationBatchId as Vi, submissionAbortBatchId as Vn, ThreadExportRequest as Vr, JoinSnapshot as Vt, PendingApprovalEvidence as W, runStartedBatchId as Wi, submissionInputRecordId as Wn, ThreadMaterialization as Wr, LedgerError as Wt, RepairInputMarker as X, subagentRequestedBatchId as Xi, DurableAbortFailure as Xn, ThreadRead as Xr, OwnershipRenewal as Xt, ReleaseOrphanChildReservation as Y, subagentLineageRecordId as Yi, ApprovalSuspensionError as Yn, ThreadPeerCountRequest as Yr, OwnershipLost as Yt, RepairJoinMarker as Z, subagentRequestedRecordId as Zi, DurableAgentRuntime as Zn, ThreadReadRequest as Zr, OwnershipSnapshot as Zt, RetryCommand as _, turnResultsBatch as _a, SubmissionStatus_d_exports as _i, SubmissionAdmissionFence as _n, RecoveryBlocked as _r, AdmissionPolicyError as _t, IntegrityCheck as a, toolCallResultBatchId as aa, ThreadStoreFailure as ai, ReservedChildBudget as an, DurableObserveOptions as ar, SettleAborted as at, obligationSeverityOf as b, workerOriginRecordId as ba, RunJournalProjection as bi, SubmissionLedger_d_exports as bn, RecoverySweepOptions as br, AdmissionResult as bt, IntegrityReport as c, toolStepSettledBatchId as ca, ThreadTailRequest as ci, ResolutionCompletedWithResult as cn, DurableRetryFailure as cr, AbortCommand as ct, ObligationReport as d, turnBatchId as da, getRunInput as di, RevertJoiningRequest as dn, DurableSubmitAgent as dr, AdmissionAdmitted as dt, toolApprovalDecisionRecordId as ea, ThreadRunInputRequest as ei, RecoverySnapshot as en, DurableApprovalResolver as er, ResumeFromTurnBoundary as et, ObligationSeverity as f, turnCanonicalBatch as fa, readOutstanding as fi, Settlement as fn, DurableSubmitFailure as fr, AdmissionConflict as ft, RecoveryExplanation as g, turnResponseBatchId as ga, SubmissionStatus as gi, SettlementReservationSnapshot as gn, DurableWorkerRequirements as gr, AdmissionNotAdmitted as gt, RecoveryDisposition as h, turnResponseBatch as ha, SettledSubmission as hi, SettlementReservation as hn, DurableWorkerFailure as hr, AdmissionIndeterminate as ht, ExplainedUnknownCall as i, toolCallResolvedRecordId as ia, ThreadStoreError as ii, RenewOwnershipRequest as in, DurableObligationFailure as ir, RevertJoining as it, AwaitHostSettlement as j, compileBindingContracts as ja, markUnknownBatchId as ji, SuspensionSnapshot as jn, FenceRejected as jr, ChildReservationId as jt, AwaitChildAdmissionResolution as k, ReplayVersions as ka, compactionRecordId as ki, SuspensionOutcome as kn, AppendResult as kr, ChildBudgetReservationSnapshot as kt, ObligationBlockedOn as l, toolStepSettledRecordId as la, ThreadWorkerStateRequest as li, ResolutionNeverHappened as ln, DurableRuntimeConfig as lr, AbortIntent as lt, RECOVERY_DECISION_MEANINGS as m, turnPreparedBatchId as ma, PendingSubmission as mi, SettlementFinalization as mn, DurableVerifyFailure as mr, AdmissionGroup as mt, ExplainedEvidence as n, toolCallPreparedRecordId as na, ThreadStore as ni, ReleaseChildBudgetRequest as nn, DurableAwaitFailure as nr, ResumeSuspended as nt, IntegrityCheckName as o, toolCallSettledRecordId as oa, ThreadStore_d_exports as oi, ReservedSettlement as on, DurableProgressFailure as or, SettleJoinedWithHost as ot, ObligationThresholds as p, turnIdForRun as pa, readWorkerState as pi, SettlementConflict as pn, DurableSubmitOptions as pr, AdmissionFence as pt, RecoveryEvidence as q, subagentJoinedRecordId as qi, submissionSettlementRecordId as qn, ThreadOutstanding as qr, MarkReadyRequest as qt, ExplainedSubmission as r, toolCallResolutionBatchId as ra, ThreadStoreDiagnostic as ri, ReleaseOwnershipRequest as rn, DurableExplainFailure as rr, ResumeWaitingParent as rt, IntegrityCheckStatus as s, toolCallUnknownRecordId as sa, ThreadTail as si, ResolutionAbortSubmission as sn, DurableResolveFailure as sr, classifyRecovery as st, Admin_d_exports as t, toolApprovalRequestRecordId as ta, ThreadSelection as ti, RecoverySnapshotRequest as tn, DurableApprovalSuspension as tr, ResumePendingToolBatch as tt, ObligationEntry as u, turnApprovalsBatchId as ua, getRecord as ui, ResolutionSafeToRetry as un, DurableRuntimeConfigOptions as ur, AbortIntentRequest as ut, RetryRefusalReason as v, turnResultsBatchId as va, JournalBoundary as vi, SubmissionLedger as vn, RecoveryFailure as vr, AdmissionRequest as vt, AppendReservedSettlement as w, AgentRegistration as wa, agentUpdateRecordId as wi, SubmissionScheduling as wn, recoveryRepairBatchId as wr, ApprovalPendingSuspension as wt, predictRecoveryDisposition as x, workerReportRecordId as xa, RunJournalUsage as xi, SubmissionLookup as xn, RecoverySweepResult as xr, ApprovalConflict as xt, RetryRefused as y, workerInputRecordId as ya, RunJournalError as yi, SubmissionLedgerFailure as yn, RecoveryReport as yr, AdmissionResolution as yt, FinalizeLedgerFromHistory as z, runCompletedRecordId as zi, WorkerStopCommand as zn, ThreadCheckpoints as zr, DEFAULT_OWNERSHIP_LEASE_DURATION as zt };
|
|
3237
|
+
//# sourceMappingURL=Admin-Fx85KT-W.d.mts.map
|
|
@@ -22,12 +22,12 @@ 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
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, ThreadCreated, ToolApprovalDecided, ToolApprovalRequested, ToolCallPrepared, ToolCallResolved, ToolCallSettled, ToolCallUnknown, ToolOperation, ToolStepSettled, ToolUnavailable, UserInputRecorded, WorkerAdmission, WorkerContinuation, WorkerInputCompleted, WorkerInputRequested, WorkerOrigin, WorkerOriginRecorded, WorkerReportPrepared, WorkerReportRefused, WorkerReportingIntent, WorkerStopRequested } from "./durable/Records.mjs";
|
|
25
|
-
import { AbortCommand, AbortIntentRequest, AdmissionPolicyError, AdmissionRequest, ApprovalDecisionCommand, ApprovalPendingSuspension, AttachChildToReservationRequest, BeginChildBudgetReleaseRequest, ChildBudgetReservationRequest, ChildReservationId, ChildSettledNotification, ClaimJoiningRequest, ClaimRequest, LedgerError, MarkInputAppliedRequest, MarkJoinedRequest, MarkReadyRequest, MarkUnknownRequest, OwnershipToken, ParentLinkage, RecoverySnapshotRequest, ReleaseChildBudgetRequest, ReleaseOwnershipRequest, RenewOwnershipRequest, RevertJoiningRequest, Settlement, SettlementFinalization, SettlementReservation, SubmissionLedger, SubmissionLookupById, SubmissionLookupByKey, SuspendRequest, UnknownResolutionCommand, WaitingChild, WaitingForChildSuspension, WorkerLedgerState, submissionAbortBatchId, submissionAbortRecordId, submissionInputBatchId, submissionInputRecordId, submissionSettlementBatchId, submissionSettlementId, submissionSettlementRecordId } from "./durable/SubmissionLedger.mjs";
|
|
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
29
|
import { a as definitionDigestsEqual, c as resolveWorkerBinding, i as compileRegistrations, l as toolReplayContracts, o as makeLegacyWorkerBinding, s as resolveDefinitionBinding, t as BindingUnavailable } from "./agent-registration-CKNsrpwo.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-
|
|
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-Gd83HYqG.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";
|
|
@@ -82,7 +82,7 @@ var RecoveryCheckpointContents = class extends Schema.Class("@effect-agent/threa
|
|
|
82
82
|
state: RecoveryCheckpointState,
|
|
83
83
|
digest: Digest
|
|
84
84
|
}) {};
|
|
85
|
-
const RECOVERY_ENGINE_VERSION = "effect-agent/recovery@
|
|
85
|
+
const RECOVERY_ENGINE_VERSION = "effect-agent/recovery@2";
|
|
86
86
|
/**
|
|
87
87
|
* Late evidence can invalidate an old compaction. Such histories use full canonical replay;
|
|
88
88
|
* an omitted run/turn must never be treated as proven absent by a sparse projection.
|
|
@@ -2336,6 +2336,7 @@ const declaredApplicationCalls = Effect.fn("DurableAgentRuntime.declaredApplicat
|
|
|
2336
2336
|
const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
2337
2337
|
const registeredBindings = [...bindings];
|
|
2338
2338
|
const ledger = yield* SubmissionLedger;
|
|
2339
|
+
const submissionScheduling = yield* SubmissionScheduling;
|
|
2339
2340
|
const store = yield* ThreadStore;
|
|
2340
2341
|
const wake = yield* WakeScheduler;
|
|
2341
2342
|
const failpoint = yield* DurableRuntimeFailpoint;
|
|
@@ -2471,7 +2472,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
2471
2472
|
})).pipe(Effect.catchTag("CheckpointRejected", () => Effect.succeed(Option.none())));
|
|
2472
2473
|
if (Option.isNone(loaded)) return full;
|
|
2473
2474
|
const checkpoint = loaded.value;
|
|
2474
|
-
if (checkpoint.engineVersion !== "effect-agent/recovery@
|
|
2475
|
+
if (checkpoint.engineVersion !== "effect-agent/recovery@2" || checkpoint.threadId !== threadId || checkpoint.throughSequence > throughSequence || throughSequence - checkpoint.throughSequence > 4096) return full;
|
|
2475
2476
|
const decoded = yield* Schema.decodeUnknownEffect(RecoveryCheckpointContents)(checkpoint.state).pipe(Effect.option);
|
|
2476
2477
|
if (Option.isNone(decoded)) return full;
|
|
2477
2478
|
const { state, digest } = decoded.value;
|
|
@@ -5233,6 +5234,19 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5233
5234
|
yield* Deferred.succeed(yieldSignal, void 0);
|
|
5234
5235
|
return yield* Effect.never;
|
|
5235
5236
|
}
|
|
5237
|
+
if (submissionScheduling.yieldTo !== void 0 && (yield* Ref.get(turnCounter)) > 0) {
|
|
5238
|
+
const candidate = yield* recordHalt(eligibleThreadHead(submission.threadId, submission.queueSequence));
|
|
5239
|
+
if (Option.isSome(candidate) && (candidate.value.state === "ready" || candidate.value.state === "running" || candidate.value.state === "input-applied")) {
|
|
5240
|
+
const next = yield* recordHalt(ledger.lookup(SubmissionLookupById.make({ submissionId: candidate.value.submissionId })));
|
|
5241
|
+
if (Option.isSome(next) && next.value.agentId === submission.agentId && (next.value.state === "ready" || next.value.state === "running" || next.value.state === "input-applied") && (yield* recordHalt(submissionScheduling.yieldTo({
|
|
5242
|
+
active: submission,
|
|
5243
|
+
next: next.value
|
|
5244
|
+
})))) {
|
|
5245
|
+
yield* Deferred.succeed(yieldSignal, next.value.submissionId);
|
|
5246
|
+
return yield* Effect.never;
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
}
|
|
5236
5250
|
}),
|
|
5237
5251
|
...runContextPreparation.transientContext === void 0 ? {} : { transientContext: runContextPreparation.transientContext },
|
|
5238
5252
|
...config.estimateCostMicrousd === void 0 ? {} : { estimateCostMicrousd: config.estimateCostMicrousd },
|
|
@@ -5491,7 +5505,10 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5491
5505
|
yield* Ref.set(tokenRef, renewal.ownershipToken);
|
|
5492
5506
|
}).pipe(Effect.uninterruptible), { schedule: Schedule.spaced(config.leaseRenewalInterval) }).pipe(Effect.andThen(Effect.never)));
|
|
5493
5507
|
const execution = Effect.raceFirst(consume, Effect.raceFirst(abortWatcher, renewal));
|
|
5494
|
-
const result = yield* (yieldAfter === void 0 ? execution : Effect.raceFirst(execution, Deferred.await(yieldSignal).pipe(Effect.
|
|
5508
|
+
const result = yield* (yieldAfter === void 0 && submissionScheduling.yieldTo === void 0 ? execution : Effect.raceFirst(execution, Deferred.await(yieldSignal).pipe(Effect.map((nextSubmissionId) => ({
|
|
5509
|
+
_tag: "yielded",
|
|
5510
|
+
...nextSubmissionId === void 0 ? {} : { nextSubmissionId }
|
|
5511
|
+
}))))).pipe(Effect.provideService(IdGenerator$1, idGenerator)).pipe(Effect.catchCauseFilter(Cause.findError, (error, cause) => {
|
|
5495
5512
|
if (isCoordinatorHaltCause(cause)) return Effect.failCause(Cause.map(cause, (halt) => halt.failure));
|
|
5496
5513
|
const approvalPending = agentApprovalPendingOption(cause);
|
|
5497
5514
|
if (Option.isSome(approvalPending)) {
|
|
@@ -5570,7 +5587,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5570
5587
|
* (Unknown Outcomes, or a durable approval suspension) — no settlement occurs and the
|
|
5571
5588
|
* obligation stays owed.
|
|
5572
5589
|
*/
|
|
5573
|
-
const runAttempt = (registeredAgent, threadId, claim, tokenRef, resumeAfterRetention, yieldAfter) => Effect.gen(function* () {
|
|
5590
|
+
const runAttempt = (registeredAgent, threadId, claim, tokenRef, resumeAfterRetention, onHandoff, yieldAfter) => Effect.gen(function* () {
|
|
5574
5591
|
const submissionId = claim.submissionId;
|
|
5575
5592
|
const supersededEpoch = yield* store.inspectTail(ThreadTailRequest.make({ threadId })).pipe(Effect.map((tail) => tail.producerEpoch), Effect.catchTag("ThreadNotMaterialized", () => Effect.succeed(ZERO_EPOCH)));
|
|
5576
5593
|
yield* store.materialize(ThreadMaterialization.make({
|
|
@@ -5753,7 +5770,10 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5753
5770
|
const canonical = Stream.concat(initialView.canonical, canonicalRange(threadId, tail.tailSequence, initialThrough));
|
|
5754
5771
|
const currentRecords = yield* refreshControl(tail.tailSequence);
|
|
5755
5772
|
const outcome = yield* runModel(agent, ctx, submission, tokenRef, currentRecords, canonical, tail.tailSequence, initialView.seed, journalMetadata?.snapshot(), lineage, approvalDecisionIntents, runTiming, yieldAfter);
|
|
5756
|
-
if (outcome._tag === "yielded")
|
|
5773
|
+
if (outcome._tag === "yielded") {
|
|
5774
|
+
if (outcome.nextSubmissionId !== void 0) onHandoff(outcome.nextSubmissionId);
|
|
5775
|
+
return Option.none();
|
|
5776
|
+
}
|
|
5757
5777
|
if (outcome._tag === "suspendedChild") {
|
|
5758
5778
|
const [firstChild, ...restChildren] = outcome.children;
|
|
5759
5779
|
const waitingChildren = [WaitingChild.make({
|
|
@@ -5834,10 +5854,11 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5834
5854
|
return Option.some(yield* terminalize(ctx, submission, tokenRef, outcome, true));
|
|
5835
5855
|
}
|
|
5836
5856
|
}).pipe(Effect.scoped);
|
|
5837
|
-
const acquireClaim = Effect.fn("DurableAgentRuntime.acquireClaim")(function* (threadId) {
|
|
5857
|
+
const acquireClaim = Effect.fn("DurableAgentRuntime.acquireClaim")(function* (threadId, handoff) {
|
|
5838
5858
|
const claimed = yield* ledger.claim(ClaimRequest.make({
|
|
5839
5859
|
threadId,
|
|
5840
|
-
producerId: config.producerId
|
|
5860
|
+
producerId: config.producerId,
|
|
5861
|
+
...handoff === void 0 ? {} : { handoff }
|
|
5841
5862
|
}));
|
|
5842
5863
|
if (Option.isNone(claimed)) return Option.none();
|
|
5843
5864
|
const claim = claimed.value;
|
|
@@ -5846,6 +5867,10 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5846
5867
|
submissionId: claim.submissionId,
|
|
5847
5868
|
ownershipToken
|
|
5848
5869
|
}))), Effect.catchTag("OwnershipLost", () => Effect.void), Effect.catchTag("LedgerError", () => Effect.logWarning("Attempt ownership release failed; lease recovery remains required").pipe(Effect.annotateLogs({ submissionId: claim.submissionId })))));
|
|
5870
|
+
if (handoff !== void 0 && claim.submissionId !== handoff.submissionId) return yield* LedgerError.make({
|
|
5871
|
+
operation: "claim handoff",
|
|
5872
|
+
message: "The submission adapter did not honor the requested handoff"
|
|
5873
|
+
});
|
|
5849
5874
|
return Option.some({
|
|
5850
5875
|
claim,
|
|
5851
5876
|
tokenRef
|
|
@@ -5853,8 +5878,10 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5853
5878
|
}, Effect.uninterruptible);
|
|
5854
5879
|
const processThreadHead = (resolve, threadId, options) => Effect.gen(function* () {
|
|
5855
5880
|
let resumeAfterRetention = false;
|
|
5881
|
+
let handoff;
|
|
5882
|
+
let nextHandoff;
|
|
5856
5883
|
const attempt = Effect.scoped(Effect.gen(function* () {
|
|
5857
|
-
const claimed = yield* acquireClaim(threadId);
|
|
5884
|
+
const claimed = yield* acquireClaim(threadId, handoff);
|
|
5858
5885
|
if (Option.isNone(claimed)) return Option.none();
|
|
5859
5886
|
const { claim, tokenRef } = claimed.value;
|
|
5860
5887
|
const attributes = {
|
|
@@ -5892,15 +5919,26 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5892
5919
|
if (resolution._tag === "refused") return yield* resolution.failure;
|
|
5893
5920
|
return yield* resolution.binding.attempt((agent, attemptThreadId, attemptClaim) => runAttempt(agent, attemptThreadId, attemptClaim, tokenRef, () => {
|
|
5894
5921
|
resumeAfterRetention = true;
|
|
5922
|
+
}, (nextSubmissionId) => {
|
|
5923
|
+
nextHandoff = ClaimHandoff.make({
|
|
5924
|
+
producerEpoch: claim.producerEpoch,
|
|
5925
|
+
deferredSubmissionIds: [...handoff?.deferredSubmissionIds ?? [], claim.submissionId],
|
|
5926
|
+
submissionId: nextSubmissionId
|
|
5927
|
+
});
|
|
5895
5928
|
}, options?.yieldAfter), threadId, claim);
|
|
5896
5929
|
}));
|
|
5897
5930
|
while (true) {
|
|
5898
5931
|
resumeAfterRetention = false;
|
|
5932
|
+
nextHandoff = void 0;
|
|
5899
5933
|
const settlement = yield* attempt;
|
|
5934
|
+
if (nextHandoff !== void 0) {
|
|
5935
|
+
handoff = nextHandoff;
|
|
5936
|
+
continue;
|
|
5937
|
+
}
|
|
5900
5938
|
if (!resumeAfterRetention) return settlement;
|
|
5901
5939
|
}
|
|
5902
5940
|
}).pipe(withThreadHeadSpan);
|
|
5903
|
-
const eligibleThreadHead = (threadId) => Stream.runHead(ledger.scanNonterminal.pipe(Stream.filter((entry) => entry.threadId === threadId), Stream.filterEffect((entry) => entry.state !== "unknown" ? Effect.succeed(true) : ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId: entry.submissionId })).pipe(Effect.map((snapshot) => snapshot.abortIntent !== void 0)))));
|
|
5941
|
+
const eligibleThreadHead = (threadId, afterQueueSequence) => Stream.runHead(ledger.scanNonterminal.pipe(Stream.filter((entry) => entry.threadId === threadId && (afterQueueSequence === void 0 || entry.queueSequence > afterQueueSequence)), Stream.filterEffect((entry) => entry.state !== "unknown" ? Effect.succeed(true) : ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId: entry.submissionId })).pipe(Effect.map((snapshot) => snapshot.abortIntent !== void 0)))));
|
|
5904
5942
|
const drainThread = (resolve, threadId) => Effect.gen(function* () {
|
|
5905
5943
|
const settlements = [];
|
|
5906
5944
|
while (true) {
|
|
@@ -7124,4 +7162,4 @@ var DurableAgentRuntime = class DurableAgentRuntime extends Context.Service()("@
|
|
|
7124
7162
|
//#endregion
|
|
7125
7163
|
export { DurableApprovalSuspension as a, RecoveryFailure as c, childReservationIdFor as d, isolateRecovery as f, threadCreatedRecordId as g, threadCreatedBatchId as h, 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 };
|
|
7126
7164
|
|
|
7127
|
-
//# sourceMappingURL=DurableAgentRuntime-
|
|
7165
|
+
//# sourceMappingURL=DurableAgentRuntime-Bso5grIH.mjs.map
|