effect-agent 0.1.0-beta.133 → 0.1.0-beta.135
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-DKqg6zQa.d.mts} +38 -4
- package/dist/{DurableAgentRuntime-DH2baLGe.mjs → DurableAgentRuntime-DgzI83ng.mjs} +47 -9
- package/dist/DurableAgentRuntime-DgzI83ng.mjs.map +1 -0
- package/dist/{EventSource-DoiZF3xv.d.mts → EventSource-P4hq8Opp.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-B1bzyIuV.d.mts → PreparedInputAdmission-ChcWS1xV.d.mts} +3 -3
- package/dist/{Subscription-m_yNfNeN.d.mts → Subscription-jOOrT8Js.d.mts} +2 -2
- package/dist/{SubscriptionInput-ON3-b8Sl.d.mts → SubscriptionInput-CPyqenXR.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/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/RunJournal.d.mts +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/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 +68 -1
- 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/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/WorkerHost.d.mts +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/durable/DurableAgentRuntime.ts +94 -10
- package/src/durable/SubmissionLedger.ts +32 -0
- package/src/durable/SubmissionLedgerConformance.ts +120 -0
- package/dist/DurableAgentRuntime-DH2baLGe.mjs.map +0 -1
|
@@ -1160,7 +1160,10 @@ declare const DurableAgentRuntime_base: Context.ServiceClass<DurableAgentRuntime
|
|
|
1160
1160
|
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
1161
|
readonly processThreadResolved: (threadId: ThreadId) => Effect.Effect<ReadonlyArray<Settlement>, DurableWorkerFailure | DurableBindingFailure>;
|
|
1162
1162
|
/**
|
|
1163
|
-
* Advance the FIFO head, closing its Attempt resources before returning.
|
|
1163
|
+
* Advance the FIFO head, closing its Attempt resources before returning. With an opted-in
|
|
1164
|
+
* SubmissionScheduling policy, a complete Turn may hand off to the next same-Agent input;
|
|
1165
|
+
* the returned Settlement identifies the Submission actually completed. Each Attempt closes
|
|
1166
|
+
* before the next is claimed, and deferred Runs retain their original obligations. A vacant,
|
|
1164
1167
|
* owned, unknown, or suspended head returns None and leaves accepted work pending.
|
|
1165
1168
|
* Ready input may join this Run through the existing Turn seams and settle with its head.
|
|
1166
1169
|
* Interruption ends only this Attempt; ownership cleanup uses its latest renewed token.
|
|
@@ -1281,7 +1284,7 @@ declare class DurableAgentRuntime extends DurableAgentRuntime_base {
|
|
|
1281
1284
|
static readonly layer: Layer.Layer<DurableAgentRuntime, never, SubmissionLedger | ThreadStore | WakeScheduler | DurableRuntimeFailpoint | DurableRuntimeConfig | ToolReconciler | Crypto.Crypto>;
|
|
1282
1285
|
}
|
|
1283
1286
|
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 };
|
|
1287
|
+
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
1288
|
}
|
|
1286
1289
|
/**
|
|
1287
1290
|
* Opaque proof that one Attempt currently owns a Submission's lane. It authorizes ledger
|
|
@@ -1310,6 +1313,20 @@ type OwnershipToken = typeof OwnershipToken.Type;
|
|
|
1310
1313
|
*/
|
|
1311
1314
|
declare const SubmissionState: Schema.Literals<readonly ["admitted", "ready", "joining", "joined", "running", "input-applied", "suspended", "unknown", "terminalizing", "settled"]>;
|
|
1312
1315
|
type SubmissionState = typeof SubmissionState.Type;
|
|
1316
|
+
/**
|
|
1317
|
+
* Opt-in host policy for handling the next runnable same-Agent input in its own Run at a complete Turn
|
|
1318
|
+
* boundary. This never joins inputs or changes their principals, grants, or receipts. The
|
|
1319
|
+
* runtime selects the ordered candidate; policy cannot select an arbitrary Submission.
|
|
1320
|
+
* Approval waits, child waits and incomplete Tool batches are not handoff boundaries. Hosts
|
|
1321
|
+
* retaining independent replies must also leave those inputs unclaimed by `claimJoining`.
|
|
1322
|
+
* In-flight model requests and Tool batches run to their existing safe boundary.
|
|
1323
|
+
*/
|
|
1324
|
+
declare const SubmissionScheduling: Context.Reference<{
|
|
1325
|
+
readonly yieldTo?: (request: {
|
|
1326
|
+
readonly active: SubmissionSnapshot;
|
|
1327
|
+
readonly next: SubmissionSnapshot;
|
|
1328
|
+
}) => Effect.Effect<boolean, LedgerError>;
|
|
1329
|
+
}>;
|
|
1313
1330
|
/**
|
|
1314
1331
|
* Default ownership lease duration (D5). The lease is a liveness hint that makes an abandoned
|
|
1315
1332
|
* claim reclaimable; correctness never depends on it because every canonical append is fenced by
|
|
@@ -1738,9 +1755,21 @@ declare class AdmissionIndeterminate extends AdmissionIndeterminate_base {}
|
|
|
1738
1755
|
*/
|
|
1739
1756
|
declare const AdmissionResolution: Schema.Union<readonly [typeof AdmissionNotAdmitted, typeof AdmissionAdmitted, typeof AdmissionIndeterminate]>;
|
|
1740
1757
|
type AdmissionResolution = typeof AdmissionResolution.Type;
|
|
1758
|
+
declare const ClaimHandoff_base: Schema.Class<ClaimHandoff, Schema.Struct<{
|
|
1759
|
+
readonly producerEpoch: Schema.brand<Schema.Natural, "@effect-agent/thread/ProducerEpoch">;
|
|
1760
|
+
readonly deferredSubmissionIds: Schema.NonEmptyArray<Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">>;
|
|
1761
|
+
readonly submissionId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">;
|
|
1762
|
+
}>, {}>;
|
|
1763
|
+
/**
|
|
1764
|
+
* A trusted runtime's advisory handoff after committing a complete Turn and closing its
|
|
1765
|
+
* Attempt. The epoch fences the observation; an intervening claim invalidates it. Deferred
|
|
1766
|
+
* Runs retain their identities and obligations. Losing this hint resumes ordinary FIFO.
|
|
1767
|
+
*/
|
|
1768
|
+
declare class ClaimHandoff extends ClaimHandoff_base {}
|
|
1741
1769
|
declare const ClaimRequest_base: Schema.Class<ClaimRequest, Schema.Struct<{
|
|
1742
1770
|
readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
|
|
1743
1771
|
readonly producerId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/ProducerId">;
|
|
1772
|
+
readonly handoff: Schema.optionalKey<typeof ClaimHandoff>;
|
|
1744
1773
|
}>, {}>;
|
|
1745
1774
|
declare class ClaimRequest extends ClaimRequest_base {}
|
|
1746
1775
|
declare const Claim_base: Schema.Class<Claim, Schema.Struct<{
|
|
@@ -2457,6 +2486,11 @@ declare const SubmissionLedger_base: Context.ServiceClass<SubmissionLedger, "@ef
|
|
|
2457
2486
|
* `attemptId` and `ownershipToken`, and starts the ownership lease (D5: adapters default to
|
|
2458
2487
|
* `DEFAULT_OWNERSHIP_LEASE_DURATION`, configurable). An expired lease makes the head
|
|
2459
2488
|
* claimable; expiry alone never revokes correctness, only permission to assume liveness.
|
|
2489
|
+
* An optional trusted-runtime `handoff` can defer only the named `input-applied` prefix,
|
|
2490
|
+
* with no abort intent, to claim the exact next runnable Submission. It is checked atomically
|
|
2491
|
+
* against the current producer epoch and the same whole-Thread ownership fence. Admission
|
|
2492
|
+
* gaps, approval/child waits and joined work cannot be bypassed. Hints are not durable facts;
|
|
2493
|
+
* recovery resumes the same retained Runs and can select another complete-Turn handoff.
|
|
2460
2494
|
* - `renewOwnership` — extends the lease while the token still owns the lane; fails with
|
|
2461
2495
|
* `OwnershipLost` once superseded. Renewal after lease expiry succeeds if no other claim has
|
|
2462
2496
|
* taken the lane in between.
|
|
@@ -3195,5 +3229,5 @@ declare const RetryRefused_base: Schema.Class<RetryRefused, Schema.TaggedStruct<
|
|
|
3195
3229
|
*/
|
|
3196
3230
|
declare class RetryRefused extends RetryRefused_base {}
|
|
3197
3231
|
//#endregion
|
|
3198
|
-
export { RepairSubagentStartLink as $,
|
|
3199
|
-
//# sourceMappingURL=Admin-
|
|
3232
|
+
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 };
|
|
3233
|
+
//# sourceMappingURL=Admin-DKqg6zQa.d.mts.map
|
|
@@ -22,7 +22,7 @@ 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";
|
|
@@ -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;
|
|
@@ -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-DgzI83ng.mjs.map
|