effect-agent 0.1.0-beta.161 → 0.1.0-beta.163

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.
Files changed (44) hide show
  1. package/dist/{Admin-Dirux8PR.d.mts → Admin-Vhz6NdaH.d.mts} +10 -2
  2. package/dist/{EventSource-DOXB0RJR.d.mts → EventSource-CtS0RBM7.d.mts} +2 -2
  3. package/dist/{PreparedInputAdmission-B7r401xJ.d.mts → PreparedInputAdmission-CS_zlCvD.d.mts} +3 -3
  4. package/dist/{Subscription-B3ScCBaN.d.mts → Subscription-nbSNY6Hs.d.mts} +2 -2
  5. package/dist/{SubscriptionInput-BP5WVsX_.d.mts → SubscriptionInput-DbXnOMS2.d.mts} +2 -2
  6. package/dist/durable/Admin.d.mts +1 -1
  7. package/dist/durable/AgentRegistration.d.mts +1 -1
  8. package/dist/durable/Certification.d.mts +1 -1
  9. package/dist/durable/CommittedActivity.d.mts +1 -1
  10. package/dist/durable/DurableAgentRuntime.d.mts +1 -1
  11. package/dist/durable/EventSource.d.mts +1 -1
  12. package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
  13. package/dist/durable/LifecyclePublication.d.mts +1 -1
  14. package/dist/durable/LifecyclePublication.mjs +25 -16
  15. package/dist/durable/LifecyclePublication.mjs.map +1 -1
  16. package/dist/durable/MessageDelivery.d.mts +3 -3
  17. package/dist/durable/MessageDeliveryStoreConformance.d.mts +39 -39
  18. package/dist/durable/PersistentHistory.d.mts +1 -1
  19. package/dist/durable/PreparedInputAdmission.d.mts +1 -1
  20. package/dist/durable/Records.mjs +2 -1
  21. package/dist/durable/Records.mjs.map +1 -1
  22. package/dist/durable/Recovery.d.mts +1 -1
  23. package/dist/durable/RunJournal.d.mts +1 -1
  24. package/dist/durable/Scheduling.d.mts +1 -1
  25. package/dist/durable/SubmissionLedger.d.mts +1 -1
  26. package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
  27. package/dist/durable/SubmissionStatus.d.mts +1 -1
  28. package/dist/durable/Subscription.d.mts +1 -1
  29. package/dist/durable/SubscriptionInput.d.mts +1 -1
  30. package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
  31. package/dist/durable/SubscriptionTools.d.mts +2 -2
  32. package/dist/durable/SubscriptionTransition.d.mts +1 -1
  33. package/dist/durable/Subscriptions.d.mts +5 -5
  34. package/dist/durable/ThreadContextHistory.d.mts +1 -1
  35. package/dist/durable/ThreadInvariants.d.mts +1 -1
  36. package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
  37. package/dist/durable/ThreadStore.d.mts +1 -1
  38. package/dist/durable/ThreadStoreConformance.d.mts +1 -1
  39. package/dist/durable/WorkerAdmission.d.mts +1 -1
  40. package/dist/durable/WorkerHost.d.mts +1 -1
  41. package/dist/index.d.mts +5 -5
  42. package/package.json +1 -1
  43. package/src/durable/LifecyclePublication.ts +52 -29
  44. package/src/durable/Records.ts +11 -1
@@ -1511,6 +1511,12 @@ interface LifecyclePublicationStorage {
1511
1511
  }) => Effect.Effect<ReadonlyArray<LifecyclePublicationBatch>, LifecyclePublicationError>;
1512
1512
  /** Atomically acknowledge the exact batch, retaining its identities and fingerprints. */
1513
1513
  readonly acknowledge: (publications: LifecyclePublicationBatch) => Effect.Effect<void, LifecyclePublicationError>;
1514
+ /** Optional atomic acknowledgement of up to 100 successfully published owner batches.
1515
+ * Validate every exact batch before consuming any debt. Empty waves succeed without writes.
1516
+ * Wrappers that validate acknowledgement authority must wrap this method too.
1517
+ * Custom services may omit this; drains then acknowledge each batch immediately.
1518
+ */
1519
+ readonly acknowledgeMany?: (batches: ReadonlyArray<LifecyclePublicationBatch>) => Effect.Effect<void, LifecyclePublicationError>;
1514
1520
  /**
1515
1521
  * Claim a due owner batch and persist its retry before dispatch. Eight automatic attempts;
1516
1522
  * 1s exponential backoff capped at 60s, after the dispatch timeout. The final attempt parks
@@ -1547,7 +1553,9 @@ declare const lifecyclePublicationLayer: Layer.Layer<never, never, Crypto.Crypto
1547
1553
  * One finite wave for the host's existing maintenance coordinator. Persist the next deadline
1548
1554
  * before dispatch, so interruption and process loss retain the same facts without another timer.
1549
1555
  * Finish independent owner batches before surfacing failures; interruption stops the wave.
1550
- * Acknowledgements are exact and idempotent. No producer or external Tool is re-executed here.
1556
+ * Acknowledgements are exact and idempotent. An optional storage wave acknowledgement commits
1557
+ * completed batches in groups of up to 100, including when a later dispatch is interrupted. No producer or
1558
+ * external Tool is re-executed here.
1551
1559
  */
1552
1560
  declare const drainLifecyclePublications: (storage: LifecyclePublicationStorage, timeoutMillis?: any, limit?: any, options?: {
1553
1561
  readonly retainedOnly?: boolean;
@@ -4267,4 +4275,4 @@ declare const RetryRefused_base: Schema.Class<RetryRefused, Schema.TaggedStruct<
4267
4275
  declare class RetryRefused extends RetryRefused_base {}
4268
4276
  //#endregion
4269
4277
  export { RepairSubagentStartLink as $, runDurationBatchId as $i, DurableApprovalFailure as $n, ThreadRecoveryCheckpoints as $r, ParentLinkage as $t, AwaitChildSettlement as A, turnResultsBatchId as Aa, JournalBoundary as Ai, SuspensionReason as An, CheckpointRejected as Ar, ChildReservationConflict as At, MarkUnknown as B, DurableBindingFailure as Ba, compactionBatchId as Bi, settlementFailureFromRecord as Bn, ThreadExport as Br, InputAppliedMarker as Bt, renderRecoveryExplanation as C, turnBatchId as Ca, drainLifecyclePublications as Ci, SubmissionLookupByKey as Cn, isolateRecovery as Cr, ApprovalDecisionIntent as Ct, ApplyUnknownResolutions as D, turnResponseBatch as Da, SettledSubmission as Di, SubmissionWorkItem as Dn, threadCreatedRecordId as Dr, ChildAttachmentSnapshot as Dt, ApplyJoinAccounting as E, turnPreparedBatchId as Ea, PendingSubmission as Ei, SubmissionState as En, threadCreatedBatchId as Er, BeginChildBudgetReleaseRequest as Et, CompleteMaterialization as F, AgentAttemptContext as Fa, TurnCommitInput as Fi, UnknownResolutionIntent as Fn, SaveCheckpointRequest as Fr, Claim as Ft, PropagateChildAbort as G, compileBindingContracts as Ga, modelResponseInterruptedRecordId as Gi, submissionSettlementBatchId as Gn, ThreadNotMaterialized as Gr, MarkInputAppliedRequest as Gt, OpenDelegationCallEvidence as H, ExecutableAgentBinding as Ha, firstWorkerInputRecordId as Hi, submissionAbortRecordId as Hn, ThreadIdentity as Hr, JoiningClaim as Ht, DeclaredPendingBatchEvidence as I, AgentRegistration as Ia, agentUpdateRecordId as Ii, WaitingChild as In, SaveRecoveryCheckpointRequest as Ir, ClaimHandoff as It, Recovery_d_exports as J, projectRunJournal as Ji, workerTerminalFromRecord as Jn, ThreadOutstandingRequest as Jr, MarkUnknownRequest as Jt, RecoveryDecision as K, compileRegistrations as Ka, modelResponseRecordId as Ki, submissionSettlementId as Kn, ThreadObservation as Kr, MarkJoinedRequest as Kt, DelegationAdmissionEvidence as L, BindingSelection as La, approvalDecisionBatchId as Li, WaitingForChildSuspension as Ln, SelectedThreadRead as Lr, ClaimJoiningRequest as Lt, AwaitParentEstablishment as M, workerOriginRecordId as Ma, RunJournalProjection as Mi, UnknownResolution as Mn, FencedAppendRequest as Mr, ChildReservationStatus as Mt, AwaitUnknownResolution as N, workerReportRecordId as Na, RunJournalUsage as Ni, UnknownResolutionCommand as Nn, LoadCheckpointRequest as Nr, ChildSettledNotification as Nt, AwaitApprovalDecision as O, turnResponseBatchId as Oa, SubmissionStatus as Oi, SuspendRequest as On, AppendConflict as Or, ChildBudgetReservationRequest as Ot, CompleteChildAdmission as P, AgentRegistration_d_exports as Pa, RunJournal_d_exports as Pi, UnknownResolutionConflict as Pn, MAX_THREAD_EXPORT_RECORDS as Pr, ChildSettledOutcome as Pt, RepairReadiness as Q, runCompletionDigest as Qi, DurableAgentRuntime_d_exports as Qn, ThreadRecordRequest as Qr, OwnershipToken as Qt, EnsureWaitingForChild as R, BindingUnavailable as Ra, childIdempotencyKeyFor as Ri, WorkerLedgerState as Rn, ThreadCheckpoint as Rr, ClaimRequest as Rt, recoveryDecisionMeaning as S, turnApprovalsBatchId as Sa, LifecyclePublication_d_exports as Si, SubmissionLookupById as Sn, childReservationIdFor as Sr, ApprovalDecisionCommand as St, ApplyInput as T, turnIdForRun as Ta, lifecyclePublicationLayer as Ti, SubmissionSnapshot as Tn, recoveryRepairRecordId as Tr, AttachChildToReservationRequest as Tt, OpenToolCallEvidence as U, ReplayVersions as Ua, markUnknownBatchId as Ui, submissionInputBatchId as Un, ThreadIdentityRequest as Ur, LedgerCapabilities as Ut, NoAction as V, DurableWorkerBinding as Va, compactionRecordId as Vi, submissionAbortBatchId as Vn, ThreadExportRequest as Vr, JoinSnapshot as Vt, PendingApprovalEvidence as W, ResolvedBinding as Wa, modelResponseInterruptedBatchId as Wi, submissionInputRecordId as Wn, ThreadMaterialization as Wr, LedgerError as Wt, RepairInputMarker as X, promptFromCanonicalRecords as Xi, DurableAbortFailure as Xn, ThreadRead as Xr, OwnershipRenewal as Xt, ReleaseOrphanChildReservation as Y, projectRunJournalStream as Yi, ApprovalSuspensionError as Yn, ThreadPeerCountRequest as Yr, OwnershipLost as Yt, RepairJoinMarker as Z, runCompletedRecordId as Zi, DurableAgentRuntime as Zn, ThreadReadRequest as Zr, OwnershipSnapshot as Zt, RetryCommand as _, toolCallResultBatchId as _a, LifecyclePublicationError as _i, SubmissionAdmissionFence as _n, RecoveryBlocked as _r, AdmissionPolicyError as _t, IntegrityCheck as a, subagentJoinedRecordId as aa, ThreadStoreFailure as ai, ReservedChildBudget as an, DurableObserveOptions as ar, SettleAborted as at, obligationSeverityOf as b, toolStepSettledBatchId as ba, LifecyclePublicationSource as bi, SubmissionLedger_d_exports as bn, RecoverySweepOptions as br, AdmissionResult as bt, IntegrityReport as c, subagentRequestedBatchId as ca, ThreadTailRequest as ci, ResolutionCompletedWithResult as cn, DurableRetryFailure as cr, AbortCommand as ct, ObligationReport as d, subagentStartedRecordId as da, getRunInput as di, RevertJoiningRequest as dn, DurableSubmitAgent as dr, AdmissionAdmitted as dt, runDurationRecordId as ea, ThreadRunInputRequest as ei, RecoverySnapshot as en, DurableApprovalResolver as er, ResumeFromTurnBoundary as et, ObligationSeverity as f, toolApprovalDecisionRecordId as fa, readOutstanding as fi, Settlement as fn, DurableSubmitFailure as fr, AdmissionConflict as ft, RecoveryExplanation as g, toolCallResolvedRecordId as ga, LifecyclePublicationConfig as gi, SettlementReservationSnapshot as gn, DurableWorkerRequirements as gr, AdmissionNotAdmitted as gt, RecoveryDisposition as h, toolCallResolutionBatchId as ha, LifecyclePublicationBatch as hi, SettlementReservation as hn, DurableWorkerFailure as hr, AdmissionIndeterminate as ht, ExplainedUnknownCall as i, subagentJoinBatchId as ia, ThreadStoreError as ii, RenewOwnershipRequest as in, DurableObligationFailure as ir, RevertJoining as it, AwaitHostSettlement as j, workerInputRecordId as ja, RunJournalError as ji, SuspensionSnapshot as jn, FenceRejected as jr, ChildReservationId as jt, AwaitChildAdmissionResolution as k, turnResultsBatch as ka, SubmissionStatus_d_exports as ki, SuspensionOutcome as kn, AppendResult as kr, ChildBudgetReservationSnapshot as kt, ObligationBlockedOn as l, subagentRequestedRecordId as la, ThreadWorkerStateRequest as li, ResolutionNeverHappened as ln, DurableRuntimeConfig as lr, AbortIntent as lt, RECOVERY_DECISION_MEANINGS as m, toolCallPreparedRecordId as ma, LifecyclePublication as mi, SettlementFinalization as mn, DurableVerifyFailure as mr, AdmissionGroup as mt, ExplainedEvidence as n, runStartedBatchId as na, ThreadStore as ni, ReleaseChildBudgetRequest as nn, DurableAwaitFailure as nr, ResumeSuspended as nt, IntegrityCheckName as o, subagentLineageBatchId as oa, ThreadStore_d_exports as oi, ReservedSettlement as on, DurableProgressFailure as or, SettleJoinedWithHost as ot, ObligationThresholds as p, toolApprovalRequestRecordId as pa, readWorkerState as pi, SettlementConflict as pn, DurableSubmitOptions as pr, AdmissionFence as pt, RecoveryEvidence as q, definitionDigestsEqual as qa, peerMessageRecordId as qi, submissionSettlementRecordId as qn, ThreadOutstanding as qr, MarkReadyRequest as qt, ExplainedSubmission as r, runStartedRecordId as ra, ThreadStoreDiagnostic as ri, ReleaseOwnershipRequest as rn, DurableExplainFailure as rr, ResumeWaitingParent as rt, IntegrityCheckStatus as s, subagentLineageRecordId as sa, ThreadTail as si, ResolutionAbortSubmission as sn, DurableResolveFailure as sr, classifyRecovery as st, Admin_d_exports as t, runIdForSubmission as ta, ThreadSelection as ti, RecoverySnapshotRequest as tn, DurableApprovalSuspension as tr, ResumePendingToolBatch as tt, ObligationEntry as u, subagentStartedBatchId as ua, getRecord as ui, ResolutionSafeToRetry as un, DurableRuntimeConfigOptions as ur, AbortIntentRequest as ut, RetryRefusalReason as v, toolCallSettledRecordId as va, LifecyclePublicationFact as vi, SubmissionLedger as vn, RecoveryFailure as vr, AdmissionRequest as vt, AppendReservedSettlement as w, turnCanonicalBatch as wa, lifecyclePublicationBatchMaxFacts as wi, SubmissionScheduling as wn, recoveryRepairBatchId as wr, ApprovalPendingSuspension as wt, predictRecoveryDisposition as x, toolStepSettledRecordId as xa, LifecyclePublicationStorage as xi, SubmissionLookup as xn, RecoverySweepResult as xr, ApprovalConflict as xt, RetryRefused as y, toolCallUnknownRecordId as ya, LifecyclePublicationHandler as yi, SubmissionLedgerFailure as yn, RecoveryReport as yr, AdmissionResolution as yt, FinalizeLedgerFromHistory as z, CurrentBindingSelection as za, childThreadIdFor as zi, WorkerStopCommand as zn, ThreadCheckpoints as zr, DEFAULT_OWNERSHIP_LEASE_DURATION as zt };
4270
- //# sourceMappingURL=Admin-Dirux8PR.d.mts.map
4278
+ //# sourceMappingURL=Admin-Vhz6NdaH.d.mts.map
@@ -1,5 +1,5 @@
1
1
  import { k as PersistedJson } from "./Records-Bm4Qt70a.mjs";
2
- import { E as SubscriptionSourceError, b as SubscriptionRecord, i as EventSourceVersion, t as AcceptedEvent } from "./Subscription-B3ScCBaN.mjs";
2
+ import { E as SubscriptionSourceError, b as SubscriptionRecord, i as EventSourceVersion, t as AcceptedEvent } from "./Subscription-nbSNY6Hs.mjs";
3
3
  import { Context, Effect, Schema, Scope } from "effect";
4
4
  declare namespace EventSource_d_exports {
5
5
  export { EventSource, EventSources, NormalizedEvent, makeEventSource };
@@ -48,4 +48,4 @@ declare const makeEventSource: <Event extends Schema.Top, Parameters extends Sch
48
48
  }) => Effect.Effect<EventSource, never, Exclude<R, Scope.Scope> | Exclude<Event["DecodingServices"], Scope.Scope> | Exclude<Event["EncodingServices"], Scope.Scope> | Exclude<Parameters["DecodingServices"], Scope.Scope> | Exclude<Parameters["EncodingServices"], Scope.Scope>>;
49
49
  //#endregion
50
50
  export { makeEventSource as a, NormalizedEvent as i, EventSource_d_exports as n, EventSources as r, EventSource as t };
51
- //# sourceMappingURL=EventSource-DOXB0RJR.d.mts.map
51
+ //# sourceMappingURL=EventSource-CtS0RBM7.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { a as Receipt } from "./Receipt-BAHyigAF.mjs";
2
2
  import { a as FailureDiagnostic_d_exports, r as Diagnostic } from "./FailureDiagnostic-CaAkzGHL.mjs";
3
- import { Oi as SubmissionStatus } from "./Admin-Dirux8PR.mjs";
3
+ import { Oi as SubmissionStatus } from "./Admin-Vhz6NdaH.mjs";
4
4
  import { H as ScheduledInputRefused, V as ScheduledInputFailure, j as ScheduleStorageError } from "./Schedule-Bi_XVKLF.mjs";
5
- import { a as PreparedInput } from "./Subscription-B3ScCBaN.mjs";
5
+ import { a as PreparedInput } from "./Subscription-nbSNY6Hs.mjs";
6
6
  import { Context, Effect } from "effect";
7
7
  declare namespace PreparedInputAdmission_d_exports {
8
8
  export { PreparedInputAdmission, admitPreparedInput };
@@ -39,4 +39,4 @@ declare const admitPreparedInput: <R>(submit: Effect.Effect<Receipt, ScheduledIn
39
39
  }, ScheduleStorageError, R>;
40
40
  //#endregion
41
41
  export { PreparedInputAdmission_d_exports as n, admitPreparedInput as r, PreparedInputAdmission as t };
42
- //# sourceMappingURL=PreparedInputAdmission-B7r401xJ.d.mts.map
42
+ //# sourceMappingURL=PreparedInputAdmission-CS_zlCvD.d.mts.map
@@ -3,7 +3,7 @@ import { a as Receipt, r as Principal } from "./Receipt-BAHyigAF.mjs";
3
3
  import { r as Update } from "./AgentUpdates-DMJ-_xow.mjs";
4
4
  import { t as AgentPolicy } from "./AgentPolicy-B4oH8TbG.mjs";
5
5
  import { _ as Digest, h as DefinitionDigests } from "./Records-Bm4Qt70a.mjs";
6
- import "./Admin-Dirux8PR.mjs";
6
+ import "./Admin-Vhz6NdaH.mjs";
7
7
  import { t as ScheduleAuthorizationDecision } from "./Schedule-Bi_XVKLF.mjs";
8
8
  import { Context, Effect, Schema } from "effect";
9
9
  declare namespace Subscription_d_exports {
@@ -976,4 +976,4 @@ declare const subscriptionKeyString: (key: SubscriptionKey) => string;
976
976
  declare const subscriptionDeliveryKeyString: (key: SubscriptionDeliveryKey) => string;
977
977
  //#endregion
978
978
  export { defaultSubscriptionLimits as A, SubscriptionScanCursors as C, SubscriptionStore as D, SubscriptionSourceError as E, subscriptionKeyString as M, SubscriptionStoreFailure as O, SubscriptionRetentionPolicy as S, SubscriptionSnapshot as T, SubscriptionKey as _, PreparedInput as a, SubscriptionRecord as b, SubscriptionAuthorizer as c, SubscriptionDelivery as d, SubscriptionDeliveryKey as f, SubscriptionFailpointError as g, SubscriptionFailpoint as h, EventSourceVersion as i, subscriptionDeliveryKeyString as j, Subscription_d_exports as k, SubscriptionChange as l, SubscriptionError as m, DeliveryChange as n, SourcePartition as o, SubscriptionDeliverySnapshot as p, EventAcknowledgement as r, SourceRecovery as s, AcceptedEvent as t, SubscriptionConfiguration as u, SubscriptionLimits as v, SubscriptionScope as w, SubscriptionRefusal as x, SubscriptionName as y };
979
- //# sourceMappingURL=Subscription-B3ScCBaN.d.mts.map
979
+ //# sourceMappingURL=Subscription-nbSNY6Hs.d.mts.map
@@ -1,6 +1,6 @@
1
1
  import { t as AgentId } from "./Identifiers-CN2s30fF.mjs";
2
2
  import { h as DefinitionDigests, k as PersistedJson } from "./Records-Bm4Qt70a.mjs";
3
- import { E as SubscriptionSourceError, b as SubscriptionRecord, i as EventSourceVersion, m as SubscriptionError, t as AcceptedEvent, u as SubscriptionConfiguration } from "./Subscription-B3ScCBaN.mjs";
3
+ import { E as SubscriptionSourceError, b as SubscriptionRecord, i as EventSourceVersion, m as SubscriptionError, t as AcceptedEvent, u as SubscriptionConfiguration } from "./Subscription-nbSNY6Hs.mjs";
4
4
  import { Context, Effect, Schema, Scope } from "effect";
5
5
  declare namespace SubscriptionInput_d_exports {
6
6
  export { SubscriptionInputBinding, SubscriptionInputBindings, makeSubscriptionInputBinding, resolveSubscriptionInput };
@@ -38,4 +38,4 @@ declare const makeSubscriptionInputBinding: <Event extends Schema.Top, Parameter
38
38
  }) => Effect.Effect<SubscriptionInputBinding, never, Exclude<R, Scope.Scope> | Exclude<Continuation["DecodingServices"], Scope.Scope> | Exclude<Continuation["EncodingServices"], Scope.Scope> | Exclude<Event["DecodingServices"], Scope.Scope> | Exclude<Input["EncodingServices"], Scope.Scope> | Exclude<Parameters["DecodingServices"], Scope.Scope>>;
39
39
  //#endregion
40
40
  export { resolveSubscriptionInput as a, makeSubscriptionInputBinding as i, SubscriptionInputBindings as n, SubscriptionInput_d_exports as r, SubscriptionInputBinding as t };
41
- //# sourceMappingURL=SubscriptionInput-BP5WVsX_.d.mts.map
41
+ //# sourceMappingURL=SubscriptionInput-DbXnOMS2.d.mts.map
@@ -1,2 +1,2 @@
1
- import { C as renderRecoveryExplanation, S as recoveryDecisionMeaning, _ as RetryCommand, a as IntegrityCheck, b as obligationSeverityOf, c as IntegrityReport, d as ObligationReport, f as ObligationSeverity, g as RecoveryExplanation, h as RecoveryDisposition, i as ExplainedUnknownCall, l as ObligationBlockedOn, m as RECOVERY_DECISION_MEANINGS, n as ExplainedEvidence, o as IntegrityCheckName, p as ObligationThresholds, r as ExplainedSubmission, s as IntegrityCheckStatus, u as ObligationEntry, v as RetryRefusalReason, x as predictRecoveryDisposition, y as RetryRefused } from "../Admin-Dirux8PR.mjs";
1
+ import { C as renderRecoveryExplanation, S as recoveryDecisionMeaning, _ as RetryCommand, a as IntegrityCheck, b as obligationSeverityOf, c as IntegrityReport, d as ObligationReport, f as ObligationSeverity, g as RecoveryExplanation, h as RecoveryDisposition, i as ExplainedUnknownCall, l as ObligationBlockedOn, m as RECOVERY_DECISION_MEANINGS, n as ExplainedEvidence, o as IntegrityCheckName, p as ObligationThresholds, r as ExplainedSubmission, s as IntegrityCheckStatus, u as ObligationEntry, v as RetryRefusalReason, x as predictRecoveryDisposition, y as RetryRefused } from "../Admin-Vhz6NdaH.mjs";
2
2
  export { ExplainedEvidence, ExplainedSubmission, ExplainedUnknownCall, IntegrityCheck, IntegrityCheckName, IntegrityCheckStatus, IntegrityReport, ObligationBlockedOn, ObligationEntry, ObligationReport, ObligationSeverity, ObligationThresholds, RECOVERY_DECISION_MEANINGS, RecoveryDisposition, RecoveryExplanation, RetryCommand, RetryRefusalReason, RetryRefused, obligationSeverityOf, predictRecoveryDisposition, recoveryDecisionMeaning, renderRecoveryExplanation };
@@ -1,2 +1,2 @@
1
- import { Ba as DurableBindingFailure, Fa as AgentAttemptContext, Ga as compileBindingContracts, Ha as ExecutableAgentBinding, Ia as AgentRegistration, Ka as compileRegistrations, La as BindingSelection, Ra as BindingUnavailable, Ua as ReplayVersions, Va as DurableWorkerBinding, Wa as ResolvedBinding, qa as definitionDigestsEqual, za as CurrentBindingSelection } from "../Admin-Dirux8PR.mjs";
1
+ import { Ba as DurableBindingFailure, Fa as AgentAttemptContext, Ga as compileBindingContracts, Ha as ExecutableAgentBinding, Ia as AgentRegistration, Ka as compileRegistrations, La as BindingSelection, Ra as BindingUnavailable, Ua as ReplayVersions, Va as DurableWorkerBinding, Wa as ResolvedBinding, qa as definitionDigestsEqual, za as CurrentBindingSelection } from "../Admin-Vhz6NdaH.mjs";
2
2
  export { type AgentAttemptContext, type AgentRegistration, type BindingSelection, BindingUnavailable, CurrentBindingSelection, type DurableBindingFailure, DurableWorkerBinding, type ExecutableAgentBinding, type ReplayVersions, type ResolvedBinding, compileBindingContracts, compileRegistrations, definitionDigestsEqual };
@@ -1,4 +1,4 @@
1
- import { ni as ThreadStore, vn as SubmissionLedger } from "../Admin-Dirux8PR.mjs";
1
+ import { ni as ThreadStore, vn as SubmissionLedger } from "../Admin-Vhz6NdaH.mjs";
2
2
  import { Crypto, Effect, Schema } from "effect";
3
3
  //#region src/durable/Certification.d.ts
4
4
  declare const CertifiedAdapterIdentity_base: Schema.Class<CertifiedAdapterIdentity, Schema.Struct<{
@@ -1,7 +1,7 @@
1
1
  import { k as PersistedJson, l as CanonicalRecordEnvelope } from "../Records-Bm4Qt70a.mjs";
2
2
  import { ActivityProcessorKey, ActivityProcessorStore, ActivityStoreFailure, PreparedActivity } from "./ActivityStore.mjs";
3
3
  import { t as DigestError } from "../Digest-COAt3Orl.mjs";
4
- import { Gr as ThreadNotMaterialized, ii as ThreadStoreError, ni as ThreadStore } from "../Admin-Dirux8PR.mjs";
4
+ import { Gr as ThreadNotMaterialized, ii as ThreadStoreError, ni as ThreadStore } from "../Admin-Vhz6NdaH.mjs";
5
5
  import { Crypto, Effect, Schema, Scope } from "effect";
6
6
  declare namespace CommittedActivity_d_exports {
7
7
  export { ActivityPassLimits, ActivityPassResult, ActivityProcessingError, CommittedActivityProcessor, activityWorkId, processCommittedActivity };
@@ -1,3 +1,3 @@
1
1
  import { a as Receipt } from "../Receipt-BAHyigAF.mjs";
2
- import { $n as DurableApprovalFailure, Cr as isolateRecovery, Dr as threadCreatedRecordId, Er as threadCreatedBatchId, Sr as childReservationIdFor, Tr as recoveryRepairRecordId, Xn as DurableAbortFailure, Yn as ApprovalSuspensionError, Zn as DurableAgentRuntime, _r as RecoveryBlocked, ar as DurableObserveOptions, br as RecoverySweepOptions, cr as DurableRetryFailure, dr as DurableSubmitAgent, er as DurableApprovalResolver, fr as DurableSubmitFailure, gr as DurableWorkerRequirements, hr as DurableWorkerFailure, ir as DurableObligationFailure, lr as DurableRuntimeConfig, mr as DurableVerifyFailure, nr as DurableAwaitFailure, or as DurableProgressFailure, pr as DurableSubmitOptions, rr as DurableExplainFailure, sr as DurableResolveFailure, tr as DurableApprovalSuspension, ur as DurableRuntimeConfigOptions, vr as RecoveryFailure, wr as recoveryRepairBatchId, xr as RecoverySweepResult, yr as RecoveryReport } from "../Admin-Dirux8PR.mjs";
2
+ import { $n as DurableApprovalFailure, Cr as isolateRecovery, Dr as threadCreatedRecordId, Er as threadCreatedBatchId, Sr as childReservationIdFor, Tr as recoveryRepairRecordId, Xn as DurableAbortFailure, Yn as ApprovalSuspensionError, Zn as DurableAgentRuntime, _r as RecoveryBlocked, ar as DurableObserveOptions, br as RecoverySweepOptions, cr as DurableRetryFailure, dr as DurableSubmitAgent, er as DurableApprovalResolver, fr as DurableSubmitFailure, gr as DurableWorkerRequirements, hr as DurableWorkerFailure, ir as DurableObligationFailure, lr as DurableRuntimeConfig, mr as DurableVerifyFailure, nr as DurableAwaitFailure, or as DurableProgressFailure, pr as DurableSubmitOptions, rr as DurableExplainFailure, sr as DurableResolveFailure, tr as DurableApprovalSuspension, ur as DurableRuntimeConfigOptions, vr as RecoveryFailure, wr as recoveryRepairBatchId, xr as RecoverySweepResult, yr as RecoveryReport } from "../Admin-Vhz6NdaH.mjs";
3
3
  export { ApprovalSuspensionError, DurableAbortFailure, DurableAgentRuntime, DurableApprovalFailure, DurableApprovalResolver, DurableApprovalSuspension, DurableAwaitFailure, DurableExplainFailure, DurableObligationFailure, DurableObserveOptions, DurableProgressFailure, DurableResolveFailure, DurableRetryFailure, DurableRuntimeConfig, DurableRuntimeConfigOptions, DurableSubmitAgent, DurableSubmitFailure, DurableSubmitOptions, DurableVerifyFailure, DurableWorkerFailure, DurableWorkerRequirements, Receipt, RecoveryBlocked, RecoveryFailure, RecoveryReport, RecoverySweepOptions, RecoverySweepResult, childReservationIdFor, isolateRecovery, recoveryRepairBatchId, recoveryRepairRecordId, threadCreatedBatchId, threadCreatedRecordId };
@@ -1,2 +1,2 @@
1
- import { a as makeEventSource, i as NormalizedEvent, r as EventSources, t as EventSource } from "../EventSource-DOXB0RJR.mjs";
1
+ import { a as makeEventSource, i as NormalizedEvent, r as EventSources, t as EventSource } from "../EventSource-CtS0RBM7.mjs";
2
2
  export { EventSource, EventSources, NormalizedEvent, makeEventSource };
@@ -1,7 +1,7 @@
1
1
  import { r as Principal } from "../Receipt-BAHyigAF.mjs";
2
- import "../Admin-Dirux8PR.mjs";
3
- import { E as SubscriptionSourceError } from "../Subscription-B3ScCBaN.mjs";
4
- import { t as EventSource } from "../EventSource-DOXB0RJR.mjs";
2
+ import "../Admin-Vhz6NdaH.mjs";
3
+ import { E as SubscriptionSourceError } from "../Subscription-nbSNY6Hs.mjs";
4
+ import { t as EventSource } from "../EventSource-CtS0RBM7.mjs";
5
5
  import { SubscriptionFailure, SubscriptionIntake } from "./Subscriptions.mjs";
6
6
  import { Context, Effect, Layer, Redacted, Schema } from "effect";
7
7
  import { HttpClient } from "effect/unstable/http";
@@ -1,2 +1,2 @@
1
- import { Ci as drainLifecyclePublications, Ti as lifecyclePublicationLayer, _i as LifecyclePublicationError, bi as LifecyclePublicationSource, gi as LifecyclePublicationConfig, hi as LifecyclePublicationBatch, mi as LifecyclePublication, vi as LifecyclePublicationFact, wi as lifecyclePublicationBatchMaxFacts, xi as LifecyclePublicationStorage, yi as LifecyclePublicationHandler } from "../Admin-Dirux8PR.mjs";
1
+ import { Ci as drainLifecyclePublications, Ti as lifecyclePublicationLayer, _i as LifecyclePublicationError, bi as LifecyclePublicationSource, gi as LifecyclePublicationConfig, hi as LifecyclePublicationBatch, mi as LifecyclePublication, vi as LifecyclePublicationFact, wi as lifecyclePublicationBatchMaxFacts, xi as LifecyclePublicationStorage, yi as LifecyclePublicationHandler } from "../Admin-Vhz6NdaH.mjs";
2
2
  export { LifecyclePublication, LifecyclePublicationBatch, LifecyclePublicationConfig, LifecyclePublicationError, LifecyclePublicationFact, LifecyclePublicationHandler, LifecyclePublicationSource, LifecyclePublicationStorage, drainLifecyclePublications, lifecyclePublicationBatchMaxFacts, lifecyclePublicationLayer };
@@ -160,28 +160,37 @@ const withSource = Effect.fn("LifecyclePublication.withSource")(function* (publi
160
160
  * One finite wave for the host's existing maintenance coordinator. Persist the next deadline
161
161
  * before dispatch, so interruption and process loss retain the same facts without another timer.
162
162
  * Finish independent owner batches before surfacing failures; interruption stops the wave.
163
- * Acknowledgements are exact and idempotent. No producer or external Tool is re-executed here.
163
+ * Acknowledgements are exact and idempotent. An optional storage wave acknowledgement commits
164
+ * completed batches in groups of up to 100, including when a later dispatch is interrupted. No producer or
165
+ * external Tool is re-executed here.
164
166
  */
165
167
  const drainLifecyclePublications = Effect.fn("LifecyclePublication.drain")(function* (storage, timeoutMillis = 1e4, limit = 4, options) {
166
168
  const handler = yield* LifecyclePublicationHandler;
167
169
  const pending = yield* storage.pending(yield* Clock.currentTimeMillis, limit, options);
170
+ const acknowledgeMany = storage.acknowledgeMany;
171
+ const published = [];
168
172
  let failures = Cause.empty;
169
- for (const batch of pending) yield* Effect.gen(function* () {
170
- if (!(yield* storage.claim(batch, yield* Clock.currentTimeMillis, timeoutMillis))) return;
171
- yield* Effect.scoped(Effect.gen(function* () {
172
- const publications = yield* Effect.forEach(batch, withSource);
173
- yield* handler.publish(publications);
174
- })).pipe(Effect.timeoutOrElse({
175
- duration: timeoutMillis,
176
- orElse: () => LifecyclePublicationError.make({ reason: "unavailable" })
173
+ return yield* Effect.gen(function* () {
174
+ for (const batch of pending) yield* Effect.gen(function* () {
175
+ if (!(yield* storage.claim(batch, yield* Clock.currentTimeMillis, timeoutMillis))) return;
176
+ yield* Effect.scoped(Effect.gen(function* () {
177
+ const publications = yield* Effect.forEach(batch, withSource);
178
+ yield* handler.publish(publications);
179
+ })).pipe(Effect.timeoutOrElse({
180
+ duration: timeoutMillis,
181
+ orElse: () => LifecyclePublicationError.make({ reason: "unavailable" })
182
+ }));
183
+ if (acknowledgeMany === void 0) yield* storage.acknowledge(batch);
184
+ else published.push(batch);
185
+ }).pipe(Effect.catchCauseIf((cause) => !Cause.hasInterrupts(cause), (cause) => {
186
+ failures = Cause.combine(failures, cause);
187
+ return Effect.void;
177
188
  }));
178
- yield* storage.acknowledge(batch);
179
- }).pipe(Effect.catchCauseIf((cause) => !Cause.hasInterrupts(cause), (cause) => {
180
- failures = Cause.combine(failures, cause);
181
- return Effect.void;
182
- }));
183
- if (failures.reasons.length > 0) return yield* Effect.failCause(failures);
184
- return pending.length;
189
+ if (failures.reasons.length > 0) return yield* Effect.failCause(failures);
190
+ return pending.length;
191
+ }).pipe(Effect.onExit(() => acknowledgeMany === void 0 || published.length === 0 ? Effect.void : Effect.gen(function* () {
192
+ for (let offset = 0; offset < published.length; offset += 100) yield* acknowledgeMany(published.slice(offset, offset + 100));
193
+ })));
185
194
  });
186
195
  //#endregion
187
196
  export { LifecyclePublication, LifecyclePublicationBatch, LifecyclePublicationConfig, LifecyclePublicationError, LifecyclePublicationFact, LifecyclePublicationHandler, LifecyclePublicationSource, drainLifecyclePublications, lifecyclePublicationBatchMaxFacts, lifecyclePublicationLayer, LifecyclePublication_exports as t };
@@ -1 +1 @@
1
- {"version":3,"file":"LifecyclePublication.mjs","names":[],"sources":["../../src/durable/LifecyclePublication.ts"],"sourcesContent":["import { Cause, Clock, Context, Crypto, Effect, Layer, Option, Schema, type Scope } from \"effect\";\n\nimport { SubmissionId, ThreadId } from \"../core/Identifiers.ts\";\nimport { Receipt } from \"../core/Receipt.ts\";\nimport { AssignmentTerminal } from \"../core/Worker.ts\";\nimport { MessageDeliveryKey } from \"./MessageDelivery.ts\";\nimport {\n AbortRequested,\n AgentUpdateEmitted,\n CanonicalSequence,\n RunStartedRecord,\n SubagentJoined,\n SubagentRequested,\n SubagentStarted,\n SubmissionSettledRecord,\n ToolApprovalDecided,\n ToolApprovalRequested,\n UserInputRecorded,\n WorkerInputCompleted,\n WorkerInputRequested,\n WorkerStopRequested,\n} from \"./Records.ts\";\nimport {\n AbortIntent,\n Settlement,\n SubmissionLedger,\n SubmissionLookupById,\n SubmissionSnapshot,\n SuspensionReason,\n} from \"./SubmissionLedger.ts\";\nimport { PreparedInput } from \"./Subscription.ts\";\nimport { getRunInput } from \"./ThreadStore.ts\";\n\n/** Immutable native admission evidence. It is private and grants no application authority. */\nexport const LifecyclePublicationSource = SubmissionSnapshot.mapFields((fields) => ({\n submissionId: fields.submissionId,\n threadId: fields.threadId,\n queueSequence: fields.queueSequence,\n principal: fields.principal,\n idempotencyKey: fields.idempotencyKey,\n agentId: fields.agentId,\n agentDigests: fields.agentDigests,\n inputPayload: fields.inputPayload,\n inputDigest: fields.inputDigest,\n receiptId: fields.receiptId,\n parentLinkage: fields.parentLinkage,\n workerAdmission: fields.workerAdmission,\n messageAdmission: fields.messageAdmission,\n createdAt: fields.createdAt,\n}));\n\nexport type LifecyclePublicationSource = typeof LifecyclePublicationSource.Type;\n\n/** Closed producer facts; model history, Tool payloads and diagnostics are not a publication API. */\nexport const LifecyclePublicationFact = Schema.Union([\n Schema.TaggedStruct(\"DeliveryRetained\", {\n key: MessageDeliveryKey,\n envelope: PreparedInput,\n createdAtMillis: Schema.Natural,\n }),\n Schema.TaggedStruct(\"DeliveryChanged\", {\n key: MessageDeliveryKey,\n envelope: PreparedInput,\n status: Schema.Literals([\"pending\", \"accepted\", \"processed\", \"refused\", \"parked\"]),\n receipt: Schema.NullOr(Receipt),\n settlement: Schema.NullOr(Settlement),\n version: Schema.Natural,\n }),\n Schema.TaggedStruct(\"WorkerInboxSealed\", {\n threadId: ThreadId,\n activeSubmissionIds: Schema.Array(SubmissionId),\n /** First native seal winner; null is an explicit stop rather than assignment completion. */\n terminal: Schema.NullOr(AssignmentTerminal),\n }),\n Schema.TaggedStruct(\"SubmissionReady\", { submissionId: SubmissionId }),\n Schema.TaggedStruct(\"SubmissionSuspended\", {\n submissionId: SubmissionId,\n reason: SuspensionReason,\n }),\n Schema.TaggedStruct(\"SubmissionUnknown\", { submissionId: SubmissionId }),\n Schema.TaggedStruct(\"SubmissionResumed\", { submissionId: SubmissionId }),\n Schema.TaggedStruct(\"AbortIntentRecorded\", { intent: AbortIntent }),\n UserInputRecorded,\n RunStartedRecord,\n AgentUpdateEmitted,\n ToolApprovalRequested,\n ToolApprovalDecided,\n AbortRequested,\n WorkerInputCompleted,\n WorkerInputRequested,\n WorkerStopRequested,\n SubagentRequested,\n SubagentStarted,\n SubagentJoined,\n SubmissionSettledRecord,\n]);\n\nexport type LifecyclePublicationFact = typeof LifecyclePublicationFact.Type;\n\n/**\n * An exact undelivered native fact. `id` is stable across retries and lost acknowledgements.\n * Ordinals order facts only within ownerThreadId. Accepted input order is source.queueSequence;\n * never compare ordinals from the launching Thread and its worker Thread.\n */\nexport class LifecyclePublication extends Schema.Class<LifecyclePublication>(\n \"@effect-agent/thread/LifecyclePublication\",\n)({\n id: Schema.NonEmptyString.check(Schema.isMaxLength(4096)),\n ownerThreadId: ThreadId,\n ordinal: Schema.Int.check(Schema.isGreaterThan(0)),\n createdAt: Schema.DateTimeUtcFromString,\n canonicalSequence: Schema.optionalKey(CanonicalSequence),\n source: Schema.optionalKey(LifecyclePublicationSource),\n fact: LifecyclePublicationFact,\n}) {}\n\nexport class LifecyclePublicationError extends Schema.TaggedError<LifecyclePublicationError>()(\n \"LifecyclePublicationError\",\n {\n reason: Schema.Literals([\"unavailable\", \"conflict\", \"corrupt\", \"capacity\"]),\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/** Bound both retained facts and the immutable admission evidence resolved before dispatch. */\nexport const lifecyclePublicationBatchMaxFacts = 8;\n\n/** One owner's bounded pending prefix, strictly ordered by its durable ordinals. */\nexport const LifecyclePublicationBatch = Schema.NonEmptyArray(LifecyclePublication).check(\n Schema.isMaxLength(lifecyclePublicationBatchMaxFacts),\n Schema.makeFilter(\n (facts) =>\n facts.every((fact, index) => {\n const previous = facts[index - 1];\n\n return (\n fact.ownerThreadId === facts[0].ownerThreadId &&\n (previous === undefined || fact.ordinal > previous.ordinal)\n );\n }),\n { expected: \"One owner with strictly increasing publication ordinals\" },\n ),\n);\n\nexport type LifecyclePublicationBatch = typeof LifecyclePublicationBatch.Type;\n\n/** Native recovery state, independent of Attempts. Hosts serialize drains per storage owner. */\nexport interface LifecyclePublicationStorage {\n /** Select up to `limit` due owners, with a bounded pending prefix for each selected owner.\n * `retainedOnly` excludes unmaterialized source facts, for a precommitted start prefix.\n */\n readonly pending: (\n nowMillis: number,\n limit: number,\n options?: { readonly retainedOnly?: boolean },\n ) => Effect.Effect<ReadonlyArray<LifecyclePublicationBatch>, LifecyclePublicationError>;\n /** Atomically acknowledge the exact batch, retaining its identities and fingerprints. */\n readonly acknowledge: (\n publications: LifecyclePublicationBatch,\n ) => Effect.Effect<void, LifecyclePublicationError>;\n /**\n * Claim a due owner batch and persist its retry before dispatch. Eight automatic attempts;\n * 1s exponential backoff capped at 60s, after the dispatch timeout. The final attempt parks\n * the payload before dispatch so process loss cannot renew its budget. False means not due.\n */\n readonly claim: (\n publications: LifecyclePublicationBatch,\n nowMillis: number,\n timeoutMillis: number,\n ) => Effect.Effect<boolean, LifecyclePublicationError>;\n readonly pendingDeadline: Effect.Effect<Option.Option<number>, LifecyclePublicationError>;\n /**\n * Deadline for `pending(..., { retainedOnly: true })`, excluding unmaterialized source facts.\n * Source-backed stores provide this when `pendingDeadline` also includes source intent.\n * Otherwise `pendingDeadline` already describes retained work.\n */\n readonly retainedPendingDeadline?: Effect.Effect<\n Option.Option<number>,\n LifecyclePublicationError\n >;\n /** Explicit operator retry after repairing a parked owner's destination. */\n readonly retryParked: (\n ownerThreadId: ThreadId,\n nowMillis: number,\n ) => Effect.Effect<void, LifecyclePublicationError>;\n}\n\n/**\n * Publish one owner's ordered batch in one idempotent host transaction, including authorization,\n * records, receipts and delivery intents. Larger backlogs continue in later batches.\n * Return only after the entire batch commits. Retries\n * may include already committed identities plus later facts; deduplicate each fact's `id`.\n * Private input/update/result fields remain private; select declared public fields explicitly.\n * Revocation/deletion is an acknowledged domain decision, not an infrastructure retry.\n */\nexport class LifecyclePublicationHandler extends Context.Service<\n LifecyclePublicationHandler,\n {\n readonly publish: (\n publications: LifecyclePublicationBatch,\n ) => Effect.Effect<void, LifecyclePublicationError, Scope.Scope>;\n }\n>()(\"@effect-agent/thread/LifecyclePublicationHandler\") {}\n\n/** Adapter configuration; the opt-in layer captures its explicit Crypto requirement once. */\nexport const LifecyclePublicationConfig = Context.Reference<Option.Option<Crypto.Crypto>>(\n \"@effect-agent/thread/LifecyclePublicationConfig\",\n { defaultValue: () => Option.none() },\n);\n\n/** Enable native SQL obligations without changing dependencies of disabled storage assemblies. */\nexport const lifecyclePublicationLayer = Layer.effect(LifecyclePublicationConfig)(\n Effect.map(Crypto.Crypto, Option.some),\n);\n\n/** Resolve immutable evidence by its exact native identity, never by scanning execution history. */\nconst withSource = Effect.fn(\"LifecyclePublication.withSource\")(\n function* (publication: LifecyclePublication) {\n if (\n publication.source !== undefined ||\n (publication.fact._tag === \"WorkerInputCompleted\" &&\n publication.fact.workerThreadId !== publication.ownerThreadId)\n )\n return publication;\n const fact = publication.fact;\n\n let submissionId =\n fact._tag === \"AbortIntentRecorded\"\n ? fact.intent.submissionId\n : \"submissionId\" in fact\n ? fact.submissionId\n : undefined;\n\n const runId =\n fact._tag === \"AgentUpdateEmitted\"\n ? fact.update.runId\n : \"runId\" in fact\n ? fact.runId\n : undefined;\n\n if (submissionId === undefined && runId !== undefined) {\n const input = yield* getRunInput({ threadId: publication.ownerThreadId, runId });\n\n if (Option.isNone(input) || input.value.record.payload._tag !== \"UserInputRecorded\")\n return yield* LifecyclePublicationError.make({ reason: \"unavailable\" });\n submissionId = input.value.record.payload.submissionId;\n }\n if (submissionId === undefined) return publication;\n const ledger = yield* SubmissionLedger;\n const found = yield* ledger.lookup(SubmissionLookupById.make({ submissionId }));\n\n if (Option.isNone(found))\n return yield* LifecyclePublicationError.make({ reason: \"unavailable\" });\n\n const source = yield* Schema.decodeEffect(Schema.toType(LifecyclePublicationSource))(\n found.value,\n );\n\n return LifecyclePublication.make({ ...publication, source });\n },\n Effect.mapError((cause) => LifecyclePublicationError.make({ reason: \"unavailable\", cause })),\n);\n\n/**\n * One finite wave for the host's existing maintenance coordinator. Persist the next deadline\n * before dispatch, so interruption and process loss retain the same facts without another timer.\n * Finish independent owner batches before surfacing failures; interruption stops the wave.\n * Acknowledgements are exact and idempotent. No producer or external Tool is re-executed here.\n */\nexport const drainLifecyclePublications = Effect.fn(\"LifecyclePublication.drain\")(function* (\n storage: LifecyclePublicationStorage,\n timeoutMillis = 10_000,\n limit = 4,\n options?: { readonly retainedOnly?: boolean },\n) {\n const handler = yield* LifecyclePublicationHandler;\n const pending = yield* storage.pending(yield* Clock.currentTimeMillis, limit, options);\n\n let failures: Cause.Cause<LifecyclePublicationError> = Cause.empty;\n\n for (const batch of pending) {\n yield* Effect.gen(function* () {\n if (!(yield* storage.claim(batch, yield* Clock.currentTimeMillis, timeoutMillis))) return;\n yield* Effect.scoped(\n Effect.gen(function* () {\n const publications = yield* Effect.forEach(batch, withSource);\n\n yield* handler.publish(publications);\n }),\n ).pipe(\n Effect.timeoutOrElse({\n duration: timeoutMillis,\n orElse: () => LifecyclePublicationError.make({ reason: \"unavailable\" }),\n }),\n );\n yield* storage.acknowledge(batch);\n }).pipe(\n Effect.catchCauseIf(\n (cause) => !Cause.hasInterrupts(cause),\n (cause) => {\n failures = Cause.combine(failures, cause);\n\n return Effect.void;\n },\n ),\n );\n }\n if (failures.reasons.length > 0) return yield* Effect.failCause(failures);\n\n return pending.length;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,6BAA6B,mBAAmB,WAAW,YAAY;CAClF,cAAc,OAAO;CACrB,UAAU,OAAO;CACjB,eAAe,OAAO;CACtB,WAAW,OAAO;CAClB,gBAAgB,OAAO;CACvB,SAAS,OAAO;CAChB,cAAc,OAAO;CACrB,cAAc,OAAO;CACrB,aAAa,OAAO;CACpB,WAAW,OAAO;CAClB,eAAe,OAAO;CACtB,iBAAiB,OAAO;CACxB,kBAAkB,OAAO;CACzB,WAAW,OAAO;AACpB,EAAE;;AAKF,MAAa,2BAA2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,OAAO,OAAO;CAChB,CACF,CACF;CAEF,IAAI,SAAS,QAAQ,SAAS,GAAG,OAAO,OAAO,OAAO,UAAU,QAAQ;CAExE,OAAO,QAAQ;AACjB,CAAC"}
1
+ {"version":3,"file":"LifecyclePublication.mjs","names":[],"sources":["../../src/durable/LifecyclePublication.ts"],"sourcesContent":["import { Cause, Clock, Context, Crypto, Effect, Layer, Option, Schema, type Scope } from \"effect\";\n\nimport { SubmissionId, ThreadId } from \"../core/Identifiers.ts\";\nimport { Receipt } from \"../core/Receipt.ts\";\nimport { AssignmentTerminal } from \"../core/Worker.ts\";\nimport { MessageDeliveryKey } from \"./MessageDelivery.ts\";\nimport {\n AbortRequested,\n AgentUpdateEmitted,\n CanonicalSequence,\n RunStartedRecord,\n SubagentJoined,\n SubagentRequested,\n SubagentStarted,\n SubmissionSettledRecord,\n ToolApprovalDecided,\n ToolApprovalRequested,\n UserInputRecorded,\n WorkerInputCompleted,\n WorkerInputRequested,\n WorkerStopRequested,\n} from \"./Records.ts\";\nimport {\n AbortIntent,\n Settlement,\n SubmissionLedger,\n SubmissionLookupById,\n SubmissionSnapshot,\n SuspensionReason,\n} from \"./SubmissionLedger.ts\";\nimport { PreparedInput } from \"./Subscription.ts\";\nimport { getRunInput } from \"./ThreadStore.ts\";\n\n/** Immutable native admission evidence. It is private and grants no application authority. */\nexport const LifecyclePublicationSource = SubmissionSnapshot.mapFields((fields) => ({\n submissionId: fields.submissionId,\n threadId: fields.threadId,\n queueSequence: fields.queueSequence,\n principal: fields.principal,\n idempotencyKey: fields.idempotencyKey,\n agentId: fields.agentId,\n agentDigests: fields.agentDigests,\n inputPayload: fields.inputPayload,\n inputDigest: fields.inputDigest,\n receiptId: fields.receiptId,\n parentLinkage: fields.parentLinkage,\n workerAdmission: fields.workerAdmission,\n messageAdmission: fields.messageAdmission,\n createdAt: fields.createdAt,\n}));\n\nexport type LifecyclePublicationSource = typeof LifecyclePublicationSource.Type;\n\n/** Closed producer facts; model history, Tool payloads and diagnostics are not a publication API. */\nexport const LifecyclePublicationFact = Schema.Union([\n Schema.TaggedStruct(\"DeliveryRetained\", {\n key: MessageDeliveryKey,\n envelope: PreparedInput,\n createdAtMillis: Schema.Natural,\n }),\n Schema.TaggedStruct(\"DeliveryChanged\", {\n key: MessageDeliveryKey,\n envelope: PreparedInput,\n status: Schema.Literals([\"pending\", \"accepted\", \"processed\", \"refused\", \"parked\"]),\n receipt: Schema.NullOr(Receipt),\n settlement: Schema.NullOr(Settlement),\n version: Schema.Natural,\n }),\n Schema.TaggedStruct(\"WorkerInboxSealed\", {\n threadId: ThreadId,\n activeSubmissionIds: Schema.Array(SubmissionId),\n /** First native seal winner; null is an explicit stop rather than assignment completion. */\n terminal: Schema.NullOr(AssignmentTerminal),\n }),\n Schema.TaggedStruct(\"SubmissionReady\", { submissionId: SubmissionId }),\n Schema.TaggedStruct(\"SubmissionSuspended\", {\n submissionId: SubmissionId,\n reason: SuspensionReason,\n }),\n Schema.TaggedStruct(\"SubmissionUnknown\", { submissionId: SubmissionId }),\n Schema.TaggedStruct(\"SubmissionResumed\", { submissionId: SubmissionId }),\n Schema.TaggedStruct(\"AbortIntentRecorded\", { intent: AbortIntent }),\n UserInputRecorded,\n RunStartedRecord,\n AgentUpdateEmitted,\n ToolApprovalRequested,\n ToolApprovalDecided,\n AbortRequested,\n WorkerInputCompleted,\n WorkerInputRequested,\n WorkerStopRequested,\n SubagentRequested,\n SubagentStarted,\n SubagentJoined,\n SubmissionSettledRecord,\n]);\n\nexport type LifecyclePublicationFact = typeof LifecyclePublicationFact.Type;\n\n/**\n * An exact undelivered native fact. `id` is stable across retries and lost acknowledgements.\n * Ordinals order facts only within ownerThreadId. Accepted input order is source.queueSequence;\n * never compare ordinals from the launching Thread and its worker Thread.\n */\nexport class LifecyclePublication extends Schema.Class<LifecyclePublication>(\n \"@effect-agent/thread/LifecyclePublication\",\n)({\n id: Schema.NonEmptyString.check(Schema.isMaxLength(4096)),\n ownerThreadId: ThreadId,\n ordinal: Schema.Int.check(Schema.isGreaterThan(0)),\n createdAt: Schema.DateTimeUtcFromString,\n canonicalSequence: Schema.optionalKey(CanonicalSequence),\n source: Schema.optionalKey(LifecyclePublicationSource),\n fact: LifecyclePublicationFact,\n}) {}\n\nexport class LifecyclePublicationError extends Schema.TaggedError<LifecyclePublicationError>()(\n \"LifecyclePublicationError\",\n {\n reason: Schema.Literals([\"unavailable\", \"conflict\", \"corrupt\", \"capacity\"]),\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/** Bound both retained facts and the immutable admission evidence resolved before dispatch. */\nexport const lifecyclePublicationBatchMaxFacts = 8;\n\n/** One owner's bounded pending prefix, strictly ordered by its durable ordinals. */\nexport const LifecyclePublicationBatch = Schema.NonEmptyArray(LifecyclePublication).check(\n Schema.isMaxLength(lifecyclePublicationBatchMaxFacts),\n Schema.makeFilter(\n (facts) =>\n facts.every((fact, index) => {\n const previous = facts[index - 1];\n\n return (\n fact.ownerThreadId === facts[0].ownerThreadId &&\n (previous === undefined || fact.ordinal > previous.ordinal)\n );\n }),\n { expected: \"One owner with strictly increasing publication ordinals\" },\n ),\n);\n\nexport type LifecyclePublicationBatch = typeof LifecyclePublicationBatch.Type;\n\n/** Native recovery state, independent of Attempts. Hosts serialize drains per storage owner. */\nexport interface LifecyclePublicationStorage {\n /** Select up to `limit` due owners, with a bounded pending prefix for each selected owner.\n * `retainedOnly` excludes unmaterialized source facts, for a precommitted start prefix.\n */\n readonly pending: (\n nowMillis: number,\n limit: number,\n options?: { readonly retainedOnly?: boolean },\n ) => Effect.Effect<ReadonlyArray<LifecyclePublicationBatch>, LifecyclePublicationError>;\n /** Atomically acknowledge the exact batch, retaining its identities and fingerprints. */\n readonly acknowledge: (\n publications: LifecyclePublicationBatch,\n ) => Effect.Effect<void, LifecyclePublicationError>;\n /** Optional atomic acknowledgement of up to 100 successfully published owner batches.\n * Validate every exact batch before consuming any debt. Empty waves succeed without writes.\n * Wrappers that validate acknowledgement authority must wrap this method too.\n * Custom services may omit this; drains then acknowledge each batch immediately.\n */\n readonly acknowledgeMany?: (\n batches: ReadonlyArray<LifecyclePublicationBatch>,\n ) => Effect.Effect<void, LifecyclePublicationError>;\n /**\n * Claim a due owner batch and persist its retry before dispatch. Eight automatic attempts;\n * 1s exponential backoff capped at 60s, after the dispatch timeout. The final attempt parks\n * the payload before dispatch so process loss cannot renew its budget. False means not due.\n */\n readonly claim: (\n publications: LifecyclePublicationBatch,\n nowMillis: number,\n timeoutMillis: number,\n ) => Effect.Effect<boolean, LifecyclePublicationError>;\n readonly pendingDeadline: Effect.Effect<Option.Option<number>, LifecyclePublicationError>;\n /**\n * Deadline for `pending(..., { retainedOnly: true })`, excluding unmaterialized source facts.\n * Source-backed stores provide this when `pendingDeadline` also includes source intent.\n * Otherwise `pendingDeadline` already describes retained work.\n */\n readonly retainedPendingDeadline?: Effect.Effect<\n Option.Option<number>,\n LifecyclePublicationError\n >;\n /** Explicit operator retry after repairing a parked owner's destination. */\n readonly retryParked: (\n ownerThreadId: ThreadId,\n nowMillis: number,\n ) => Effect.Effect<void, LifecyclePublicationError>;\n}\n\n/**\n * Publish one owner's ordered batch in one idempotent host transaction, including authorization,\n * records, receipts and delivery intents. Larger backlogs continue in later batches.\n * Return only after the entire batch commits. Retries\n * may include already committed identities plus later facts; deduplicate each fact's `id`.\n * Private input/update/result fields remain private; select declared public fields explicitly.\n * Revocation/deletion is an acknowledged domain decision, not an infrastructure retry.\n */\nexport class LifecyclePublicationHandler extends Context.Service<\n LifecyclePublicationHandler,\n {\n readonly publish: (\n publications: LifecyclePublicationBatch,\n ) => Effect.Effect<void, LifecyclePublicationError, Scope.Scope>;\n }\n>()(\"@effect-agent/thread/LifecyclePublicationHandler\") {}\n\n/** Adapter configuration; the opt-in layer captures its explicit Crypto requirement once. */\nexport const LifecyclePublicationConfig = Context.Reference<Option.Option<Crypto.Crypto>>(\n \"@effect-agent/thread/LifecyclePublicationConfig\",\n { defaultValue: () => Option.none() },\n);\n\n/** Enable native SQL obligations without changing dependencies of disabled storage assemblies. */\nexport const lifecyclePublicationLayer = Layer.effect(LifecyclePublicationConfig)(\n Effect.map(Crypto.Crypto, Option.some),\n);\n\n/** Resolve immutable evidence by its exact native identity, never by scanning execution history. */\nconst withSource = Effect.fn(\"LifecyclePublication.withSource\")(\n function* (publication: LifecyclePublication) {\n if (\n publication.source !== undefined ||\n (publication.fact._tag === \"WorkerInputCompleted\" &&\n publication.fact.workerThreadId !== publication.ownerThreadId)\n )\n return publication;\n const fact = publication.fact;\n\n let submissionId =\n fact._tag === \"AbortIntentRecorded\"\n ? fact.intent.submissionId\n : \"submissionId\" in fact\n ? fact.submissionId\n : undefined;\n\n const runId =\n fact._tag === \"AgentUpdateEmitted\"\n ? fact.update.runId\n : \"runId\" in fact\n ? fact.runId\n : undefined;\n\n if (submissionId === undefined && runId !== undefined) {\n const input = yield* getRunInput({ threadId: publication.ownerThreadId, runId });\n\n if (Option.isNone(input) || input.value.record.payload._tag !== \"UserInputRecorded\")\n return yield* LifecyclePublicationError.make({ reason: \"unavailable\" });\n submissionId = input.value.record.payload.submissionId;\n }\n if (submissionId === undefined) return publication;\n const ledger = yield* SubmissionLedger;\n const found = yield* ledger.lookup(SubmissionLookupById.make({ submissionId }));\n\n if (Option.isNone(found))\n return yield* LifecyclePublicationError.make({ reason: \"unavailable\" });\n\n const source = yield* Schema.decodeEffect(Schema.toType(LifecyclePublicationSource))(\n found.value,\n );\n\n return LifecyclePublication.make({ ...publication, source });\n },\n Effect.mapError((cause) => LifecyclePublicationError.make({ reason: \"unavailable\", cause })),\n);\n\n/**\n * One finite wave for the host's existing maintenance coordinator. Persist the next deadline\n * before dispatch, so interruption and process loss retain the same facts without another timer.\n * Finish independent owner batches before surfacing failures; interruption stops the wave.\n * Acknowledgements are exact and idempotent. An optional storage wave acknowledgement commits\n * completed batches in groups of up to 100, including when a later dispatch is interrupted. No producer or\n * external Tool is re-executed here.\n */\nexport const drainLifecyclePublications = Effect.fn(\"LifecyclePublication.drain\")(function* (\n storage: LifecyclePublicationStorage,\n timeoutMillis = 10_000,\n limit = 4,\n options?: { readonly retainedOnly?: boolean },\n) {\n const handler = yield* LifecyclePublicationHandler;\n const pending = yield* storage.pending(yield* Clock.currentTimeMillis, limit, options);\n const acknowledgeMany = storage.acknowledgeMany;\n const published: Array<LifecyclePublicationBatch> = [];\n let failures: Cause.Cause<LifecyclePublicationError> = Cause.empty;\n\n return yield* Effect.gen(function* () {\n for (const batch of pending) {\n yield* Effect.gen(function* () {\n if (!(yield* storage.claim(batch, yield* Clock.currentTimeMillis, timeoutMillis))) return;\n yield* Effect.scoped(\n Effect.gen(function* () {\n const publications = yield* Effect.forEach(batch, withSource);\n\n yield* handler.publish(publications);\n }),\n ).pipe(\n Effect.timeoutOrElse({\n duration: timeoutMillis,\n orElse: () => LifecyclePublicationError.make({ reason: \"unavailable\" }),\n }),\n );\n if (acknowledgeMany === undefined) yield* storage.acknowledge(batch);\n else published.push(batch);\n }).pipe(\n Effect.catchCauseIf(\n (cause) => !Cause.hasInterrupts(cause),\n (cause) => {\n failures = Cause.combine(failures, cause);\n\n return Effect.void;\n },\n ),\n );\n }\n if (failures.reasons.length > 0) return yield* Effect.failCause(failures);\n\n return pending.length;\n }).pipe(\n Effect.onExit(() =>\n acknowledgeMany === undefined || published.length === 0\n ? Effect.void\n : Effect.gen(function* () {\n for (let offset = 0; offset < published.length; offset += 100)\n yield* acknowledgeMany(published.slice(offset, offset + 100));\n }),\n ),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,6BAA6B,mBAAmB,WAAW,YAAY;CAClF,cAAc,OAAO;CACrB,UAAU,OAAO;CACjB,eAAe,OAAO;CACtB,WAAW,OAAO;CAClB,gBAAgB,OAAO;CACvB,SAAS,OAAO;CAChB,cAAc,OAAO;CACrB,cAAc,OAAO;CACrB,aAAa,OAAO;CACpB,WAAW,OAAO;CAClB,eAAe,OAAO;CACtB,iBAAiB,OAAO;CACxB,kBAAkB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AAI,oBAAoB,KAAA,GAAW,OAAO,QAAQ,YAAY,KAAK;QAC9D,UAAU,KAAK,KAAK;EAC3B,CAAC,CAAC,CAAC,KACD,OAAO,cACJ,UAAU,CAAC,MAAM,cAAc,KAAK,IACpC,UAAU;GACT,WAAW,MAAM,QAAQ,UAAU,KAAK;GAExC,OAAO,OAAO;EAChB,CACF,CACF;EAEF,IAAI,SAAS,QAAQ,SAAS,GAAG,OAAO,OAAO,OAAO,UAAU,QAAQ;EAExE,OAAO,QAAQ;CACjB,CAAC,CAAC,CAAC,KACD,OAAO,aACL,oBAAoB,KAAA,KAAa,UAAU,WAAW,IAClD,OAAO,OACP,OAAO,IAAI,aAAa;EACtB,KAAK,IAAI,SAAS,GAAG,SAAS,UAAU,QAAQ,UAAU,KACxD,OAAO,gBAAgB,UAAU,MAAM,QAAQ,SAAS,GAAG,CAAC;CAChE,CAAC,CACP,CACF;AACF,CAAC"}
@@ -5,9 +5,9 @@ import { r as Update } from "../AgentUpdates-DMJ-_xow.mjs";
5
5
  import { a as FailureDiagnostic_d_exports, r as Diagnostic } from "../FailureDiagnostic-CaAkzGHL.mjs";
6
6
  import { t as AgentPolicy } from "../AgentPolicy-B4oH8TbG.mjs";
7
7
  import { h as DefinitionDigests } from "../Records-Bm4Qt70a.mjs";
8
- import { fn as Settlement, xi as LifecyclePublicationStorage } from "../Admin-Dirux8PR.mjs";
9
- import { a as PreparedInput } from "../Subscription-B3ScCBaN.mjs";
10
- import { t as PreparedInputAdmission } from "../PreparedInputAdmission-B7r401xJ.mjs";
8
+ import { fn as Settlement, xi as LifecyclePublicationStorage } from "../Admin-Vhz6NdaH.mjs";
9
+ import { a as PreparedInput } from "../Subscription-nbSNY6Hs.mjs";
10
+ import { t as PreparedInputAdmission } from "../PreparedInputAdmission-CS_zlCvD.mjs";
11
11
  import { Context, Crypto, Effect, Layer, Result, Schema } from "effect";
12
12
  declare namespace MessageDelivery_d_exports {
13
13
  export { MessageDeliveryChange, MessageDeliveryCompletion, MessageDeliveryDriver, MessageDeliveryDriverLimits, MessageDeliveryError, MessageDeliveryFailpoint, MessageDeliveryFailpointError, MessageDeliveryFailure, MessageDeliveryKey, MessageDeliveryPage, MessageDeliveryPageRequest, MessageDeliveryPolicy, MessageDeliveryRecord, MessageDeliveryStore, MessageDeliveryStoreLimits, applyMessageDeliveryChange, defaultMessageDeliveryPolicy, defaultMessageDeliveryStoreLimits, isWorkerUpdateDelivery, messageDeliveryCapacity, messageDeliveryDeadline, messageDeliveryKeyString, messageDeliveryUsesCapacity, prepareMessageDelivery, readPending, sameMessageDeliveryIdentity, validateMessageDelivery };
@@ -5,7 +5,7 @@ import { r as Diagnostic } from "../FailureDiagnostic-CaAkzGHL.mjs";
5
5
  import { t as AgentPolicy } from "../AgentPolicy-B4oH8TbG.mjs";
6
6
  import { h as DefinitionDigests } from "../Records-Bm4Qt70a.mjs";
7
7
  import { t as DigestError } from "../Digest-COAt3Orl.mjs";
8
- import { fn as Settlement } from "../Admin-Dirux8PR.mjs";
8
+ import { fn as Settlement } from "../Admin-Vhz6NdaH.mjs";
9
9
  import { MessageDeliveryError, MessageDeliveryFailure, MessageDeliveryStore } from "./MessageDelivery.mjs";
10
10
  import { Effect, Schema } from "effect";
11
11
  //#region src/durable/MessageDeliveryStoreConformance.d.ts
@@ -105,25 +105,6 @@ export declare const makeMessageDeliveryFixture: (messageId?: any, owner?: any,
105
105
  readonly reportKind?: "update" | undefined;
106
106
  } | undefined;
107
107
  readonly messageAdmission?: {
108
- readonly schemaVersion: 1;
109
- readonly message: {
110
- readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
111
- readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
112
- };
113
- readonly peerName: string;
114
- readonly sender: {
115
- readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
116
- readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
117
- };
118
- readonly returnAddress: {
119
- readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
120
- readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
121
- };
122
- readonly inReplyTo?: {
123
- readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
124
- readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
125
- } | undefined;
126
- } | {
127
108
  readonly _tag: "WorkerCompletion";
128
109
  readonly budgetExhausted: boolean;
129
110
  readonly schemaVersion: 1;
@@ -164,6 +145,25 @@ export declare const makeMessageDeliveryFixture: (messageId?: any, owner?: any,
164
145
  readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
165
146
  };
166
147
  readonly update: Update;
148
+ } | {
149
+ readonly schemaVersion: 1;
150
+ readonly message: {
151
+ readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
152
+ readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
153
+ };
154
+ readonly peerName: string;
155
+ readonly sender: {
156
+ readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
157
+ readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
158
+ };
159
+ readonly returnAddress: {
160
+ readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
161
+ readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
162
+ };
163
+ readonly inReplyTo?: {
164
+ readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
165
+ readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
166
+ } | undefined;
167
167
  } | undefined;
168
168
  };
169
169
  readonly envelopeDigest: string & import("effect/Brand").Brand<"@effect-agent/thread/Digest">;
@@ -288,25 +288,6 @@ export declare const makeWorkerUpdateDeliveryFixture: (id: string) => Effect.Eff
288
288
  readonly reportKind?: "update" | undefined;
289
289
  } | undefined;
290
290
  readonly messageAdmission?: {
291
- readonly schemaVersion: 1;
292
- readonly message: {
293
- readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
294
- readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
295
- };
296
- readonly peerName: string;
297
- readonly sender: {
298
- readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
299
- readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
300
- };
301
- readonly returnAddress: {
302
- readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
303
- readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
304
- };
305
- readonly inReplyTo?: {
306
- readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
307
- readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
308
- } | undefined;
309
- } | {
310
291
  readonly _tag: "WorkerCompletion";
311
292
  readonly budgetExhausted: boolean;
312
293
  readonly schemaVersion: 1;
@@ -347,6 +328,25 @@ export declare const makeWorkerUpdateDeliveryFixture: (id: string) => Effect.Eff
347
328
  readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
348
329
  };
349
330
  readonly update: Update;
331
+ } | {
332
+ readonly schemaVersion: 1;
333
+ readonly message: {
334
+ readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
335
+ readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
336
+ };
337
+ readonly peerName: string;
338
+ readonly sender: {
339
+ readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
340
+ readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
341
+ };
342
+ readonly returnAddress: {
343
+ readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
344
+ readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
345
+ };
346
+ readonly inReplyTo?: {
347
+ readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
348
+ readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
349
+ } | undefined;
350
350
  } | undefined;
351
351
  };
352
352
  readonly envelopeDigest: string & import("effect/Brand").Brand<"@effect-agent/thread/Digest">;
@@ -1,5 +1,5 @@
1
1
  import { t as ThreadHistory } from "../ThreadHistory-FD-o4TsR.mjs";
2
- import { ni as ThreadStore } from "../Admin-Dirux8PR.mjs";
2
+ import { ni as ThreadStore } from "../Admin-Vhz6NdaH.mjs";
3
3
  import { Layer } from "effect";
4
4
  declare namespace PersistentHistory_d_exports {
5
5
  export { layer };
@@ -1,2 +1,2 @@
1
- import { r as admitPreparedInput, t as PreparedInputAdmission } from "../PreparedInputAdmission-B7r401xJ.mjs";
1
+ import { r as admitPreparedInput, t as PreparedInputAdmission } from "../PreparedInputAdmission-CS_zlCvD.mjs";
2
2
  export { PreparedInputAdmission, admitPreparedInput };
@@ -126,6 +126,7 @@ const MAX_PERSISTED_JSON_BYTES = 1048576;
126
126
  * Schema.Json still owns the accepted value shape after this resource preflight succeeds.
127
127
  */
128
128
  const isJson = Schema.is(Schema.Json);
129
+ const nonAscii = /[\u0080-\uFFFF]/;
129
130
  const isPersistedJson = (input) => {
130
131
  const pending = [{
131
132
  _tag: "visit",
@@ -175,7 +176,7 @@ const isPersistedJson = (input) => {
175
176
  }
176
177
  if (!isJson(input)) return false;
177
178
  const encoded = JSON.stringify(input);
178
- return encoded !== void 0 && utf8ByteLength(encoded) <= 1048576;
179
+ return encoded !== void 0 && encoded.length <= 1048576 && (encoded.length <= 1048576 / 3 || !nonAscii.test(encoded) || utf8ByteLength(encoded) <= 1048576);
179
180
  } catch {
180
181
  return false;
181
182
  }