@yielded/agent 0.1.0-beta.175 → 0.1.0-beta.177

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 (191) hide show
  1. package/dist/{Admin-Qa3I1oA5.d.mts → Admin-Bpg24yCK.d.mts} +19 -13
  2. package/dist/{Agent-BiRbr73L.mjs → Agent-B3J0B4l6.mjs} +6 -3
  3. package/dist/Agent-B3J0B4l6.mjs.map +1 -0
  4. package/dist/{AgentRuntime-DaDKMasp.mjs → AgentRuntime-DrQfy4cL.mjs} +7 -6
  5. package/dist/AgentRuntime-DrQfy4cL.mjs.map +1 -0
  6. package/dist/{AgentRuntime-CHDyRbSf.d.mts → AgentRuntime-Dx5u_FJD.d.mts} +6 -6
  7. package/dist/{Digest-C3EODOee.mjs → Digest-ft4ku9pj.mjs} +2 -2
  8. package/dist/{Digest-C3EODOee.mjs.map → Digest-ft4ku9pj.mjs.map} +1 -1
  9. package/dist/{DurableAgentRuntime-CPlw5_7e.mjs → DurableAgentRuntime-CGW93k81.mjs} +176 -63
  10. package/dist/DurableAgentRuntime-CGW93k81.mjs.map +1 -0
  11. package/dist/{DurableStep-DXGn7KQ4.d.mts → DurableStep-CAJnlgfL.d.mts} +5 -4
  12. package/dist/{EventSource-BTu68yDW.d.mts → EventSource-A6TB7t-f.d.mts} +2 -2
  13. package/dist/{MessageDelivery-DjAZJ4Fd.d.mts → MessageDelivery-BkWrcQUd.d.mts} +4 -4
  14. package/dist/{Messaging-SVu6rWV8.d.mts → Messaging-DpEZMTVE.d.mts} +2 -2
  15. package/dist/{MessagingHost-CZCyrnvJ.mjs → MessagingHost-BILcuj0V.mjs} +2 -2
  16. package/dist/{MessagingHost-CZCyrnvJ.mjs.map → MessagingHost-BILcuj0V.mjs.map} +1 -1
  17. package/dist/{MessagingHost-C6SOAcoG.d.mts → MessagingHost-BKxDskYj.d.mts} +2 -2
  18. package/dist/{PreparedInputAdmission-wgY4JMZY.d.mts → PreparedInputAdmission-DKIfqRZT.d.mts} +3 -3
  19. package/dist/{Records-DzL4Kbtw.mjs → Records-CZRedCE7.mjs} +3 -3
  20. package/dist/{Records-DzL4Kbtw.mjs.map → Records-CZRedCE7.mjs.map} +1 -1
  21. package/dist/{RunContinuation-3jB5pULC.d.mts → RunContinuation-Ce2pR8VD.d.mts} +4 -4
  22. package/dist/{RunContinuation-BiyKJK32.mjs → RunContinuation-D42RFqjS.mjs} +5 -5
  23. package/dist/RunContinuation-D42RFqjS.mjs.map +1 -0
  24. package/dist/{RunJournal-CPMKcfd0.mjs → RunJournal-oJLo-pjS.mjs} +7 -7
  25. package/dist/{RunJournal-CPMKcfd0.mjs.map → RunJournal-oJLo-pjS.mjs.map} +1 -1
  26. package/dist/{RunOptions-Be77lKVZ.d.mts → RunOptions-BANtohGk.d.mts} +3 -3
  27. package/dist/{RunStorage-CzutHJBE.mjs → RunStorage-BRGP3Tcu.mjs} +43 -33
  28. package/dist/RunStorage-BRGP3Tcu.mjs.map +1 -0
  29. package/dist/{Scheduling-07_dsGED.mjs → Scheduling-BebkRVc2.mjs} +3 -3
  30. package/dist/{Scheduling-07_dsGED.mjs.map → Scheduling-BebkRVc2.mjs.map} +1 -1
  31. package/dist/{Subagent-xhN_aD1r.d.mts → Subagent-5ulnV6An.d.mts} +9 -9
  32. package/dist/{Subagent-CexndZSp.mjs → Subagent-C7F7c8Op.mjs} +3 -3
  33. package/dist/{Subagent-CexndZSp.mjs.map → Subagent-C7F7c8Op.mjs.map} +1 -1
  34. package/dist/{SubagentHost-D1xBgn9g.d.mts → SubagentHost-CikdGpmk.d.mts} +2 -2
  35. package/dist/{Subscription-DmIHlOJK.d.mts → Subscription-D5sOrmlI.d.mts} +2 -2
  36. package/dist/{SubscriptionInput-DgcQhvbe.d.mts → SubscriptionInput-CxSXZUiC.d.mts} +2 -2
  37. package/dist/{ThreadImport-DP-vOk2F.d.mts → ThreadImport-C6IiPJMW.d.mts} +42 -42
  38. package/dist/{ThreadImport-CjlG57vH.mjs → ThreadImport-DUcPj5jC.mjs} +9 -9
  39. package/dist/{ThreadImport-CjlG57vH.mjs.map → ThreadImport-DUcPj5jC.mjs.map} +1 -1
  40. package/dist/{ThreadStore-EuUilthA.mjs → ThreadStore-Cn6FDWX9.mjs} +42 -21
  41. package/dist/ThreadStore-Cn6FDWX9.mjs.map +1 -0
  42. package/dist/{ThreadTransfer-DB_zsrtJ.mjs → ThreadTransfer-BWnAHIge.mjs} +4 -4
  43. package/dist/{ThreadTransfer-DB_zsrtJ.mjs.map → ThreadTransfer-BWnAHIge.mjs.map} +1 -1
  44. package/dist/{Worker-CHRaIsWu.d.mts → Worker-CLYgfqhF.d.mts} +7 -5
  45. package/dist/{Worker-DZjdMjZn.mjs → Worker-CtuUwYOK.mjs} +4 -2
  46. package/dist/Worker-CtuUwYOK.mjs.map +1 -0
  47. package/dist/{WorkerAdmission-eBeXt_mu.mjs → WorkerAdmission-cfiK9aRi.mjs} +6 -6
  48. package/dist/{WorkerAdmission-eBeXt_mu.mjs.map → WorkerAdmission-cfiK9aRi.mjs.map} +1 -1
  49. package/dist/{agent-registration-a6QYaG3h.mjs → agent-registration-Dt57NAP6.mjs} +5 -5
  50. package/dist/{agent-registration-a6QYaG3h.mjs.map → agent-registration-Dt57NAP6.mjs.map} +1 -1
  51. package/dist/capabilities/CodeMode.mjs +1 -1
  52. package/dist/capabilities/Commands.d.mts +1 -1
  53. package/dist/capabilities/ContextTools.mjs +1 -1
  54. package/dist/capabilities/McpClient.mjs +1 -1
  55. package/dist/capabilities/MemoryNotes.d.mts +1 -1
  56. package/dist/capabilities/MemoryNotes.mjs +2 -1
  57. package/dist/capabilities/MemoryNotes.mjs.map +1 -1
  58. package/dist/capabilities/Messaging.d.mts +1 -1
  59. package/dist/capabilities/Messaging.mjs +2 -2
  60. package/dist/capabilities/RunHooks.d.mts +1 -1
  61. package/dist/capabilities/Subagent.d.mts +2 -2
  62. package/dist/capabilities/Subagent.mjs +2 -2
  63. package/dist/capabilities/ToolDiscovery.mjs +1 -1
  64. package/dist/capabilities/WebCapture.mjs +1 -1
  65. package/dist/capabilities/WebSearch.mjs +1 -1
  66. package/dist/core/Agent.mjs +1 -1
  67. package/dist/core/Worker.d.mts +1 -1
  68. package/dist/core/Worker.mjs +1 -1
  69. package/dist/durable/ActivityStore.mjs +1 -1
  70. package/dist/durable/Admin.d.mts +1 -1
  71. package/dist/durable/Admin.mjs +1 -1
  72. package/dist/durable/AgentRegistration.d.mts +1 -1
  73. package/dist/durable/AgentRegistration.mjs +1 -1
  74. package/dist/durable/Certification.d.mts +1 -1
  75. package/dist/durable/CommittedActivity.d.mts +1 -1
  76. package/dist/durable/CommittedActivity.mjs +3 -3
  77. package/dist/durable/Digest.mjs +1 -1
  78. package/dist/durable/DurableAgentRuntime.d.mts +1 -1
  79. package/dist/durable/DurableAgentRuntime.mjs +2 -2
  80. package/dist/durable/EventSource.d.mts +1 -1
  81. package/dist/durable/EventSource.mjs +1 -1
  82. package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
  83. package/dist/durable/LifecyclePublication.d.mts +1 -1
  84. package/dist/durable/LifecyclePublication.mjs +3 -3
  85. package/dist/durable/MessageDelivery.d.mts +1 -1
  86. package/dist/durable/MessageDelivery.mjs +3 -3
  87. package/dist/durable/MessageDeliveryStoreConformance.d.mts +2 -2
  88. package/dist/durable/MessageDeliveryStoreConformance.mjs +3 -3
  89. package/dist/durable/PersistentHistory.d.mts +1 -1
  90. package/dist/durable/PersistentHistory.mjs +4 -4
  91. package/dist/durable/PreparedInputAdmission.d.mts +1 -1
  92. package/dist/durable/RecordFormat.mjs +1 -1
  93. package/dist/durable/Records.mjs +1 -1
  94. package/dist/durable/Recovery.d.mts +1 -1
  95. package/dist/durable/Recovery.mjs +1 -1
  96. package/dist/durable/RunContinuation.d.mts +2 -2
  97. package/dist/durable/RunContinuation.mjs +3 -3
  98. package/dist/durable/RunJournal.d.mts +1 -1
  99. package/dist/durable/RunJournal.mjs +1 -1
  100. package/dist/durable/RunStorage.d.mts +1 -1
  101. package/dist/durable/RunStorage.mjs +1 -1
  102. package/dist/durable/Schedule.mjs +1 -1
  103. package/dist/durable/ScheduleStoreConformance.mjs +1 -1
  104. package/dist/durable/ScheduleTransition.mjs +1 -1
  105. package/dist/durable/Scheduling.d.mts +1 -1
  106. package/dist/durable/Scheduling.mjs +1 -1
  107. package/dist/durable/SettlementPublisher.d.mts +1 -1
  108. package/dist/durable/SettlementPublisher.mjs +3 -3
  109. package/dist/durable/SubmissionLedger.d.mts +1 -1
  110. package/dist/durable/SubmissionLedger.mjs +4 -4
  111. package/dist/durable/SubmissionLedger.mjs.map +1 -1
  112. package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
  113. package/dist/durable/SubmissionLedgerConformance.mjs +7 -7
  114. package/dist/durable/SubmissionStatus.d.mts +1 -1
  115. package/dist/durable/Subscription.d.mts +1 -1
  116. package/dist/durable/Subscription.mjs +2 -2
  117. package/dist/durable/SubscriptionInput.d.mts +1 -1
  118. package/dist/durable/SubscriptionInput.mjs +2 -2
  119. package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
  120. package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
  121. package/dist/durable/SubscriptionTools.d.mts +3 -3
  122. package/dist/durable/SubscriptionTools.mjs +2 -1
  123. package/dist/durable/SubscriptionTools.mjs.map +1 -1
  124. package/dist/durable/SubscriptionTransition.d.mts +1 -1
  125. package/dist/durable/SubscriptionTransition.mjs +1 -1
  126. package/dist/durable/Subscriptions.d.mts +5 -5
  127. package/dist/durable/Subscriptions.mjs +2 -2
  128. package/dist/durable/ThreadArchiveRange.d.mts +1 -1
  129. package/dist/durable/ThreadArchiveRange.mjs +1 -1
  130. package/dist/durable/ThreadContextHistory.d.mts +1 -1
  131. package/dist/durable/ThreadContextHistory.mjs +2 -2
  132. package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
  133. package/dist/durable/ThreadImport.d.mts +1 -1
  134. package/dist/durable/ThreadImport.mjs +1 -1
  135. package/dist/durable/ThreadInvariants.d.mts +3 -3
  136. package/dist/durable/ThreadInvariants.mjs +4 -4
  137. package/dist/durable/ThreadProjection.mjs +1 -1
  138. package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
  139. package/dist/durable/ThreadReader.d.mts +1 -1
  140. package/dist/durable/ThreadReader.mjs +1 -1
  141. package/dist/durable/ThreadStore.d.mts +1 -1
  142. package/dist/durable/ThreadStore.mjs +2 -2
  143. package/dist/durable/ThreadStoreConformance.d.mts +1 -1
  144. package/dist/durable/ThreadStoreConformance.mjs +4 -4
  145. package/dist/durable/ThreadTransfer.d.mts +1 -1
  146. package/dist/durable/ThreadTransfer.mjs +1 -1
  147. package/dist/durable/ThreadWork.d.mts +1 -1
  148. package/dist/durable/ThreadWork.mjs +5 -5
  149. package/dist/durable/ToolReconciler.mjs +1 -1
  150. package/dist/durable/WorkerAdmission.d.mts +68 -68
  151. package/dist/durable/WorkerAdmission.mjs +1 -1
  152. package/dist/durable/WorkerHost.d.mts +2 -2
  153. package/dist/durable/WorkerHost.mjs +1 -1
  154. package/dist/engine/AgentRuntime.d.mts +1 -1
  155. package/dist/engine/AgentRuntime.mjs +1 -1
  156. package/dist/engine/DurableStep.d.mts +2 -2
  157. package/dist/engine/DurableStep.mjs +1 -11
  158. package/dist/engine/DurableStep.mjs.map +1 -1
  159. package/dist/engine/MessagingHost.d.mts +1 -1
  160. package/dist/engine/MessagingHost.mjs +1 -1
  161. package/dist/engine/RunOptions.d.mts +1 -1
  162. package/dist/engine/SubagentHost.d.mts +1 -1
  163. package/dist/engine/SubagentHost.mjs +1 -1
  164. package/dist/index.d.mts +16 -16
  165. package/dist/index.mjs +15 -15
  166. package/dist/{run-context-reader-DVhJZ1Qe.d.mts → run-context-reader-BtBPX_nC.d.mts} +2 -2
  167. package/dist/tool-execution-Ba7tO7Pt.mjs +17 -0
  168. package/dist/tool-execution-Ba7tO7Pt.mjs.map +1 -0
  169. package/package.json +1 -1
  170. package/src/core/Worker.ts +3 -1
  171. package/src/core/internal/agent-updates.ts +9 -1
  172. package/src/core/internal/tool-execution.ts +33 -0
  173. package/src/durable/DurableAgentRuntime.ts +243 -63
  174. package/src/durable/RunContinuation.ts +2 -2
  175. package/src/durable/RunJournal.ts +9 -5
  176. package/src/durable/RunStorage.ts +83 -61
  177. package/src/durable/SubmissionLedger.ts +8 -0
  178. package/src/durable/ThreadStore.ts +39 -19
  179. package/src/durable/internal/agent-updates.ts +59 -3
  180. package/src/durable/internal/initial-context.ts +17 -2
  181. package/src/durable/internal/prompt-history-cache.ts +13 -8
  182. package/src/durable/internal/worker-host.ts +3 -1
  183. package/src/engine/DurableStep.ts +5 -31
  184. package/src/engine/internal/agent-runtime.ts +2 -1
  185. package/dist/Agent-BiRbr73L.mjs.map +0 -1
  186. package/dist/AgentRuntime-DaDKMasp.mjs.map +0 -1
  187. package/dist/DurableAgentRuntime-CPlw5_7e.mjs.map +0 -1
  188. package/dist/RunContinuation-BiyKJK32.mjs.map +0 -1
  189. package/dist/RunStorage-CzutHJBE.mjs.map +0 -1
  190. package/dist/ThreadStore-EuUilthA.mjs.map +0 -1
  191. package/dist/Worker-DZjdMjZn.mjs.map +0 -1
@@ -4,6 +4,8 @@ import { n as utf8ByteLength } from "./utf8-B5pAmhTo.mjs";
4
4
  import { AgentPolicy } from "./core/AgentPolicy.mjs";
5
5
  import { IdempotencyKey, Principal, Receipt } from "./core/Receipt.mjs";
6
6
  import { Update, UpdateError } from "./core/AgentUpdates.mjs";
7
+ import { n as getToolExecutionClass } from "./tool-execution-Ba7tO7Pt.mjs";
8
+ import { s as nativeUpdateId } from "./Agent-B3J0B4l6.mjs";
7
9
  import { c as captureContext, s as capture } from "./FailureDiagnostic-D9oW23Cn.mjs";
8
10
  import { AgentApprovalDenied, AgentApprovalPending, AgentInputDecodeError, AgentInputError, AgentPersistenceCapacityError, AgentToolAuthorizationDenied, PolicyLimit } from "./core/AgentError.mjs";
9
11
  import { IdGenerator as IdGenerator$1 } from "./core/IdGenerator.mjs";
@@ -11,39 +13,38 @@ import { t as copyJson } from "./json-BlJVQZxN.mjs";
11
13
  import { DelegationDepth, SubagentBudgetReservation, SubagentDelegationCaps, SubagentGrant, SubagentParentLink, SubagentReservationAmounts, getToolExecutionKind } from "./core/SubagentContract.mjs";
12
14
  import { o as Selection, s as Snapshot } from "./ToolExposure-hTJT2ekj.mjs";
13
15
  import { ChildRunUsage, InputTokenUsage, ModelCallUsage, ModelResponseIdentity, ModelUsageGroup, OutputTokenUsage, RunUsageReport, RunUsageSummary, emptyRunTotals, runTotalsFromSummary, sumRunTotals, summarizeModelUsage, unknownRunTotals } from "./core/Usage.mjs";
14
- import { C as MessageStatus, S as MessageRef, _ as WorkerStop, b as WorkerUpdate, c as WorkerError, f as WorkerRef, l as WorkerHistoryEntry, o as WorkerCompletion, r as FrameworkMessage } from "./Worker-DZjdMjZn.mjs";
15
- import { a as PeerMessageCapacity, d as MessageAdmission, f as MessagingError, i as PeerDeliveryLifetime, o as PeerRoutes, p as PeerName, r as PeerAuthorizer, t as MessagingHost } from "./MessagingHost-CZCyrnvJ.mjs";
16
+ import { C as MessageStatus, S as MessageRef, _ as WorkerStop, b as WorkerUpdate, c as WorkerError, f as WorkerRef, l as WorkerHistoryEntry, o as WorkerCompletion, r as FrameworkMessage } from "./Worker-CtuUwYOK.mjs";
17
+ import { a as PeerMessageCapacity, d as MessageAdmission, f as MessagingError, i as PeerDeliveryLifetime, o as PeerRoutes, p as PeerName, r as PeerAuthorizer, t as MessagingHost } from "./MessagingHost-BILcuj0V.mjs";
16
18
  import { SubagentHost } from "./engine/SubagentHost.mjs";
17
19
  import { Store, makeMemoryStore } from "./core/Thread.mjs";
18
20
  import { ThreadHistory } from "./engine/ThreadHistory.mjs";
19
21
  import { n as RunToolVisibility } from "./ToolExposure-DBATXxmL.mjs";
20
- import { C as boundedValueFootprint, n as AgentChildPending, p as renderInputPrompt, u as executeWithUsageAccountingUnknown } from "./AgentRuntime-DaDKMasp.mjs";
22
+ import { C as boundedValueFootprint, n as AgentChildPending, p as renderInputPrompt, u as executeWithUsageAccountingUnknown } from "./AgentRuntime-DrQfy4cL.mjs";
21
23
  import { ContextRolloverTool } from "./engine/ContextWindow.mjs";
22
- import { getToolExecutionClass } from "./engine/DurableStep.mjs";
23
24
  import { CompactionError, ContextCompactor } from "./engine/ContextCompactor.mjs";
24
25
  import { AgentUpdateAcceptance, CurrentToolFailureObserver, ModelUsageAccounting, RunContextPreparation, RunContextPreparationPassthrough, RunToolAuthorization, RunToolScheduling } from "./engine/RunOptions.mjs";
25
- import { A as MAX_RUN_EVIDENCE_RECORDS, At as WorkHandoffCompleted, Bt as WorkerReportingIntent, Ct as ToolCallResolved, Dt as ToolStepSettled, Et as ToolOperation, Ft as WorkerInputRequested, G as PromptRecord, H as PeerMessagePrepared, I as ModelCallAborted, It as WorkerOrigin, Mt as WorkerContinuation, Nt as WorkerInputCompleted, O as MAX_RUN_CONTINUATION_BYTES, Ot as ToolUnavailable, P as MAX_RUN_TOOL_CALL_IDENTITIES, Pt as WorkerInputRefused, R as ModelResponseInterrupted, Rt as WorkerReportPrepared, Tt as ToolCallUnknown, U as PersistedJson, V as PROMPT_EVIDENCE_TAGS, Vt as WorkerStopRequested, X as RecordEnvelope, Z as RecordId, _t as SubmissionSettledRecord, at as RunDurationExhausted, bt as ToolApprovalDecided, c as CanonicalBatch, et as RepairAnnotated, f as CanonicalSequence, ft as SubagentJoined, g as DeclaredToolCall, gt as SubmissionSettled, ht as SubagentStarted, i as BatchId, jt as WorkerAdmission, kt as UserInputRecorded, lt as RunStartedRecord, mt as SubagentRequested, n as AgentUpdateEmitted, o as CURRENT_RECORD_FORMAT, p as CompactionCreated, pt as SubagentLineageRecorded, rt as RunContextRecorded, st as RunPolicyUsageReserved, t as AbortRequested, ut as SettlementFailureDiagnostic, v as DefinitionDigests, vt as SubtreeBudgetReserved, w as MAX_PERSISTED_JSON_BYTES, wt as ToolCallSettled, xt as ToolApprovalRequested, zt as WorkerReportRefused } from "./Records-DzL4Kbtw.mjs";
26
- import { i as digestCanonicalJson, r as canonicalJson, s as digestJson } from "./Digest-C3EODOee.mjs";
26
+ import { A as MAX_RUN_EVIDENCE_RECORDS, At as WorkHandoffCompleted, Bt as WorkerReportingIntent, Ct as ToolCallResolved, Dt as ToolStepSettled, Et as ToolOperation, Ft as WorkerInputRequested, G as PromptRecord, H as PeerMessagePrepared, I as ModelCallAborted, It as WorkerOrigin, Mt as WorkerContinuation, Nt as WorkerInputCompleted, O as MAX_RUN_CONTINUATION_BYTES, Ot as ToolUnavailable, P as MAX_RUN_TOOL_CALL_IDENTITIES, Pt as WorkerInputRefused, R as ModelResponseInterrupted, Rt as WorkerReportPrepared, Tt as ToolCallUnknown, U as PersistedJson, V as PROMPT_EVIDENCE_TAGS, Vt as WorkerStopRequested, X as RecordEnvelope, Z as RecordId, _t as SubmissionSettledRecord, at as RunDurationExhausted, bt as ToolApprovalDecided, c as CanonicalBatch, et as RepairAnnotated, f as CanonicalSequence, ft as SubagentJoined, g as DeclaredToolCall, gt as SubmissionSettled, ht as SubagentStarted, i as BatchId, jt as WorkerAdmission, kt as UserInputRecorded, lt as RunStartedRecord, mt as SubagentRequested, n as AgentUpdateEmitted, o as CURRENT_RECORD_FORMAT, p as CompactionCreated, pt as SubagentLineageRecorded, rt as RunContextRecorded, st as RunPolicyUsageReserved, t as AbortRequested, ut as SettlementFailureDiagnostic, v as DefinitionDigests, vt as SubtreeBudgetReserved, w as MAX_PERSISTED_JSON_BYTES, wt as ToolCallSettled, xt as ToolApprovalRequested, zt as WorkerReportRefused } from "./Records-CZRedCE7.mjs";
27
+ import { i as digestCanonicalJson, r as canonicalJson, s as digestJson } from "./Digest-ft4ku9pj.mjs";
27
28
  import { AbortCommand, AbortIntentRequest, AdmissionPolicyError, AdmissionRequest, ApprovalDecisionCommand, ApprovalPendingSuspension, BeginChildBudgetReleaseRequest, ChildReservationId, ChildSettledNotification, ClaimHandoff, ClaimRequest, FundingOwnerRequest, LedgerError, MarkReadyRequest, MarkUnknownRequest, ParentLinkage, RecoverySnapshotRequest, ReleaseChildBudgetRequest, RevertJoiningRequest, Settlement, SettlementFinalization, SubmissionLedger, SubmissionLookupById, SubmissionLookupByKey, SubmissionScheduling, UnknownResolutionCommand, WaitingChild, WaitingForChildSuspension, WorkerLedgerState, submissionAbortBatchId, submissionAbortRecordId, submissionInputBatchId, submissionInputRecordId, submissionSettlementBatchId, submissionSettlementId, submissionSettlementRecordId, unknownResolutionKind } from "./durable/SubmissionLedger.mjs";
28
29
  import { DeclaredPendingBatchEvidence, OpenDelegationCallEvidence, OpenToolCallEvidence, PendingApprovalEvidence, RecoveryDecision, RecoveryEvidence, classifyRecovery, pendingApprovalForRecovery } from "./durable/Recovery.mjs";
29
30
  import { ExplainedEvidence, ExplainedSubmission, ExplainedUnknownCall, ObligationEntry, ObligationReport, RecoveryExplanation, RetryRefused, obligationSeverityOf, predictRecoveryDisposition, recoveryDecisionMeaning } from "./durable/Admin.mjs";
30
- import { a as compileRegistrations, c as resolveDefinitionBinding, l as resolveWorkerBinding, n as CurrentBindingSelection, o as definitionDigestsEqual, s as makeLegacyWorkerBinding, t as BindingUnavailable, u as toolReplayContracts } from "./agent-registration-a6QYaG3h.mjs";
31
- import { $ as makeJournalMetadata, A as subagentRequestedRecordId, B as toolStepSettledRecordId, C as runStartedBatchId, D as subagentLineageBatchId, E as subagentJoinedRecordId, F as toolCallResolutionBatchId, G as turnResponseBatch, I as toolCallResolvedRecordId, K as turnResponseBatchId, L as toolCallResultBatchId, M as subagentStartedRecordId, N as toolApprovalDecisionRecordId, O as subagentLineageRecordId, P as toolApprovalRequestRecordId, R as toolCallUnknownRecordId, S as runIdForSubmission, T as subagentJoinBatchId, U as turnCanonicalBatch, V as turnApprovalsBatchId, W as turnIdForRun, X as workerOriginRecordId, Y as workerInputRecordId, Z as workerReportRecordId, _ as projectRunJournalStream, a as childIdempotencyKeyFor, b as runDurationBatchId, c as compactionRecordId, d as markUnknownBatchId, et as toolCallSettledRecordId, f as modelResponseInterruptedBatchId, h as peerMessageRecordId, i as approvalDecisionBatchId, j as subagentStartedBatchId, k as subagentRequestedBatchId, l as firstWorkerInputRecordId, m as modelResponseRecordId, o as childThreadIdFor, p as modelResponseInterruptedRecordId, q as turnResultsBatch, r as agentUpdateRecordId, s as compactionBatchId, t as RunJournalError, u as initialRunJournal, w as runStartedRecordId, x as runDurationRecordId, y as runCompletedRecordId, z as toolStepSettledBatchId } from "./RunJournal-CPMKcfd0.mjs";
32
- import { $ as ThreadTailRequest, B as ThreadPromptRead, F as ThreadIdentityRequest, I as ThreadMaterialization, J as ThreadStore, R as ThreadObservation, U as ThreadReader, V as ThreadRead, X as ThreadStoreError, Y as ThreadStoreDiagnostic, _t as isPreContinuationFact, bt as terminalUsageCharge, gt as executionRunIds, ht as canonicalRunIds, lt as readWorkerState, n as AppendRequest, ot as getRecord, p as MAX_THREAD_EXPORT_PAGE_BYTES, pt as captureRecord, st as getRunInput } from "./ThreadStore-EuUilthA.mjs";
31
+ import { a as compileRegistrations, c as resolveDefinitionBinding, l as resolveWorkerBinding, n as CurrentBindingSelection, o as definitionDigestsEqual$1, s as makeLegacyWorkerBinding, t as BindingUnavailable, u as toolReplayContracts } from "./agent-registration-Dt57NAP6.mjs";
32
+ import { $ as makeJournalMetadata, A as subagentRequestedRecordId, B as toolStepSettledRecordId, C as runStartedBatchId, D as subagentLineageBatchId, E as subagentJoinedRecordId, F as toolCallResolutionBatchId, G as turnResponseBatch, I as toolCallResolvedRecordId, K as turnResponseBatchId, L as toolCallResultBatchId, M as subagentStartedRecordId, N as toolApprovalDecisionRecordId, O as subagentLineageRecordId, P as toolApprovalRequestRecordId, R as toolCallUnknownRecordId, S as runIdForSubmission, T as subagentJoinBatchId, U as turnCanonicalBatch, V as turnApprovalsBatchId, W as turnIdForRun, X as workerOriginRecordId, Y as workerInputRecordId, Z as workerReportRecordId, _ as projectRunJournalStream, a as childIdempotencyKeyFor, b as runDurationBatchId, c as compactionRecordId, d as markUnknownBatchId, et as toolCallSettledRecordId, f as modelResponseInterruptedBatchId, h as peerMessageRecordId, i as approvalDecisionBatchId, j as subagentStartedBatchId, k as subagentRequestedBatchId, l as firstWorkerInputRecordId, m as modelResponseRecordId, o as childThreadIdFor, p as modelResponseInterruptedRecordId, q as turnResultsBatch, r as agentUpdateRecordId, s as compactionBatchId, t as RunJournalError, u as initialRunJournal, w as runStartedRecordId, x as runDurationRecordId, y as runCompletedRecordId, z as toolStepSettledBatchId } from "./RunJournal-oJLo-pjS.mjs";
33
+ import { $ as ThreadTailRequest, B as ThreadPromptRead, F as ThreadIdentityRequest, I as ThreadMaterialization, J as ThreadStore, R as ThreadObservation, U as ThreadReader, V as ThreadRead, X as ThreadStoreError, Y as ThreadStoreDiagnostic, _t as isPreContinuationFact, bt as terminalUsageCharge, gt as executionRunIds, h as PreparedAppend, ht as canonicalRunIds, lt as readWorkerState, n as AppendRequest, ot as getRecord, p as MAX_THREAD_EXPORT_PAGE_BYTES, pt as captureRecord, st as getRunInput } from "./ThreadStore-Cn6FDWX9.mjs";
33
34
  import { ScheduledInputRefused, ScheduledInputRetryable } from "./durable/Schedule.mjs";
34
35
  import { PreparedInputAdmission } from "./durable/PreparedInputAdmission.mjs";
35
36
  import { PreparedInput } from "./durable/Subscription.mjs";
36
37
  import { MessageDeliveryDriver, MessageDeliveryFailpoint, MessageDeliveryRecord, MessageDeliveryStore, prepareMessageDelivery } from "./durable/MessageDelivery.mjs";
37
38
  import { DurableRuntimeFailpoint } from "./durable/DurableFailpoint.mjs";
38
- import { _ as readRunContext, a as canonicalRecordBytes, b as reference, f as runEvidence, g as digestRunHistory, l as readContinuation, m as validateSuffix, n as CurrentRunWriter, s as makeProgressWriter, t as CurrentRunSettlement, u as readRunEvidenceSnapshot, x as resolveEvidence, y as RunContextReader } from "./RunContinuation-BiyKJK32.mjs";
39
+ import { _ as readRunContext, a as canonicalRecordBytes, b as reference, f as runEvidence, g as digestRunHistory, l as readContinuation, m as validateSuffix, n as CurrentRunWriter, s as makeProgressWriter, t as CurrentRunSettlement, u as readRunEvidenceSnapshot, x as resolveEvidence, y as RunContextReader } from "./RunContinuation-D42RFqjS.mjs";
39
40
  import { MAX_WORK_CURSOR_CHARS, ThreadWorkDiscovery, ThreadWorkEntry, ThreadWorkRequest, WorkDiscoveryUnavailable, decodeWorkCursor, deliveryPredecessor, encodeWorkCursor, operationEvidence, resolveWorkEvidence, validateWorkPage, workId } from "./durable/ThreadWork.mjs";
40
41
  import { WakeScheduler } from "./durable/WakeScheduler.mjs";
41
42
  import { n as safeUnknownString, t as inspectForeignDiagnostic } from "./foreign-diagnostic-DBQ1XHKh.mjs";
42
- import { c as threadCreatedBatchId, l as threadCreatedRecordId, n as WorkerAdmissionPort, o as ensureThreadCreated, r as WorkerAdmissionRequest, s as ensureWorkerOrigin } from "./WorkerAdmission-eBeXt_mu.mjs";
43
+ import { c as threadCreatedBatchId, l as threadCreatedRecordId, n as WorkerAdmissionPort, o as ensureThreadCreated, r as WorkerAdmissionRequest, s as ensureWorkerOrigin } from "./WorkerAdmission-cfiK9aRi.mjs";
43
44
  import { i as unresolvedToolOperations, n as isUnresolvedToolOperation, r as toolOperationStates, t as initialDispatchBlockedTurns } from "./tool-operations-BXBmagY1.mjs";
44
45
  import { WorkerBudgetAuthorizer, WorkerConcurrencyLimit, WorkerConcurrencyResolver, WorkerHostAuthorizer, WorkerHostConfig, WorkerPolicyResolver } from "./durable/WorkerHost.mjs";
45
46
  import { OperationAuthorizationRequest, OperationAuthorizer, OperationDenied } from "./durable/OperationAuthorizer.mjs";
46
- import { o as makeRunWriter, r as RunStorage, s as StorageOwner } from "./RunStorage-CzutHJBE.mjs";
47
+ import { o as makeRunWriter, r as RunStorage, s as StorageOwner } from "./RunStorage-BRGP3Tcu.mjs";
47
48
  import { SettlementPublication } from "./durable/SettlementPublisher.mjs";
48
49
  import { PendingSubmission, SettledSubmission } from "./durable/SubmissionStatus.mjs";
49
50
  import { DeclaredToolCallEvidence, ToolReconciler } from "./durable/ToolReconciler.mjs";
@@ -59,6 +60,23 @@ const storage = () => LedgerError.make({
59
60
  message: "Durable update persistence failed"
60
61
  });
61
62
  const rejected = (reason) => UpdateError.make({ reason });
63
+ const updateDigest = (threadId, runId, updateId) => digestJson([
64
+ threadId,
65
+ runId,
66
+ updateId
67
+ ]);
68
+ const nativeParameters = Schema.Struct({ value: Schema.Json });
69
+ const isNativeParameters = Schema.is(nativeParameters);
70
+ const definitionDigestsEqual = Schema.toEquivalence(DefinitionDigests);
71
+ const updateValuesEqual = Schema.toEquivalence(Schema.Json);
72
+ /** Canonical native acceptance proves only this exact update call, never an external effect.
73
+ * Its frozen delivery remains independently recoverable even when its Tool acknowledgement is lost.
74
+ */
75
+ const nativeUpdateAccepted = (submission, call, records) => {
76
+ if (call.toolName !== "emit_update" || !isNativeParameters(call.parameters)) return false;
77
+ const value = call.parameters.value;
78
+ return records.some(({ record: { payload } }) => payload._tag === "AgentUpdateEmitted" && payload.update.threadId === submission.threadId && payload.update.agentId === submission.agentId && payload.update.runId === call.runId && payload.update.updateId === nativeUpdateId(call.runId, call.toolCallId) && definitionDigestsEqual(payload.definitions, submission.agentDigests) && updateValuesEqual(payload.update.value, value));
79
+ };
62
80
  /** Acceptance is fenced by the actual emitting Attempt; recovery only recreates frozen outbox rows. */
63
81
  const makeAgentUpdateRuntime = Effect.fnUntraced(function* (options) {
64
82
  const store = yield* ThreadStore;
@@ -68,6 +86,15 @@ const makeAgentUpdateRuntime = Effect.fnUntraced(function* (options) {
68
86
  const crypto = yield* Crypto.Crypto;
69
87
  const failpoint = yield* DurableRuntimeFailpoint;
70
88
  const reader = ThreadReader.fromStore(store);
89
+ const accepted = Effect.fnUntraced(function* (submission, call) {
90
+ if (call.toolName !== "emit_update") return false;
91
+ const digest = yield* updateDigest(submission.threadId, call.runId, nativeUpdateId(call.runId, call.toolCallId)).pipe(Effect.provideService(Crypto.Crypto, crypto), Effect.mapError(storage));
92
+ const record = yield* getRecord({
93
+ threadId: submission.threadId,
94
+ recordId: RecordId.make(`agent-update:${digest}`)
95
+ }).pipe(Effect.provideService(ThreadReader, reader), Effect.mapError(storage));
96
+ return Option.isSome(record) && nativeUpdateAccepted(submission, call, [record.value]);
97
+ });
71
98
  const readRun = Effect.fnUntraced(function* (threadId, submissionId) {
72
99
  const tail = yield* store.inspectTail(ThreadTailRequest.make({ threadId })).pipe(Effect.mapError(storage));
73
100
  const records = yield* readRunEvidenceSnapshot(threadId, submissionId, tail.tailSequence).pipe(Effect.provideService(ThreadReader, reader), Effect.provideService(Crypto.Crypto, crypto), Effect.mapError(storage));
@@ -151,11 +178,7 @@ const makeAgentUpdateRuntime = Effect.fnUntraced(function* (options) {
151
178
  emit: Effect.fnUntraced(function* (request) {
152
179
  const value = yield* Schema.encodeEffect(Schema.fromJsonString(PersistedJson))(request.value).pipe(Effect.flatMap(Schema.decodeEffect(Schema.fromJsonString(PersistedJson))), Effect.mapError(() => rejected("validation")));
153
180
  const updateId = yield* Schema.decodeEffect(IdempotencyKey)(request.updateId).pipe(Effect.mapError(() => rejected("validation")));
154
- const digest = yield* digestJson([
155
- request.submission.threadId,
156
- request.runId,
157
- updateId
158
- ]).pipe(Effect.provideService(Crypto.Crypto, crypto), Effect.mapError(storage));
181
+ const digest = yield* updateDigest(request.submission.threadId, request.runId, updateId).pipe(Effect.provideService(Crypto.Crypto, crypto), Effect.mapError(storage));
159
182
  const id = `agent-update:${digest}`;
160
183
  const messageId = Schema.decodeSync(IdempotencyKey)(`worker-update:${digest}`);
161
184
  const maxCount = request.maxCount ?? 32;
@@ -231,6 +254,7 @@ const makeAgentUpdateRuntime = Effect.fnUntraced(function* (options) {
231
254
  ThreadNotMaterialized: () => storage(),
232
255
  AppendConflict: () => storage()
233
256
  })))),
257
+ accepted,
234
258
  repair: insert,
235
259
  repairRun
236
260
  };
@@ -671,7 +695,7 @@ const makeMessagingRuntime = Effect.fnUntraced(function* (options) {
671
695
  const admission = yield* Schema.decodeEffect(MessageAdmission)(unvalidated).pipe(Effect.mapError(() => failure$1("send", "invalid-input")));
672
696
  const saved = yield* proof(admission.message);
673
697
  const envelope = saved.envelope;
674
- if (!Schema.is(MessageAdmission)(envelope.messageAdmission) || !sameAdmission$1(envelope.messageAdmission, admission) || envelope.threadId !== options.threadId || envelope.agentId !== agentId || envelope.inputDigest !== inputDigest || envelope.deliveryPrincipal !== options.principal || envelope.admissionKey !== options.idempotencyKey || !definitionDigestsEqual(envelope.definitions, options.definitions)) return yield* failure$1("send", "denied");
698
+ if (!Schema.is(MessageAdmission)(envelope.messageAdmission) || !sameAdmission$1(envelope.messageAdmission, admission) || envelope.threadId !== options.threadId || envelope.agentId !== agentId || envelope.inputDigest !== inputDigest || envelope.deliveryPrincipal !== options.principal || envelope.admissionKey !== options.idempotencyKey || !definitionDigestsEqual$1(envelope.definitions, options.definitions)) return yield* failure$1("send", "denied");
675
699
  yield* authorizeEnvelope(saved, "send");
676
700
  return admission;
677
701
  })
@@ -769,14 +793,13 @@ const retainedBytes = (value, json, allowance) => {
769
793
  const footprint = promptJsonFootprint(value, Math.floor((allowance - encodedBytes) / 2));
770
794
  return footprint === void 0 ? void 0 : encodedBytes + 2 * footprint;
771
795
  };
772
- const encodeHistory = Effect.fnUntraced(function* (prompt, allowance) {
773
- const value = yield* encodePrompt(prompt);
796
+ const encodeHistory = (prompt, allowance) => Effect.suspend(() => Effect.mapEager(encodePrompt(prompt), (value) => {
774
797
  const encoded = canonicalJson(value);
775
798
  return {
776
799
  encoded,
777
800
  bytes: retainedBytes(value, encoded, allowance)
778
801
  };
779
- });
802
+ }));
780
803
  const decodeCheckpointPrefix = Effect.fnUntraced(function* (encoded, length) {
781
804
  const value = yield* parseJson(encoded);
782
805
  const bytes = retainedBytes(value, encoded, MAX_BYTES);
@@ -1626,7 +1649,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
1626
1649
  ...admission.origin.continuationOf === void 0 ? {} : { continuationOf: admission.origin.continuationOf }
1627
1650
  });
1628
1651
  yield* authorizeBudget(admission.origin, options.principal, authorization);
1629
- if (admission.origin.worker.threadId !== options.threadId || admission.origin.worker.targetAgentId !== agentId || !definitionDigestsEqual(admission.origin.targetDigests, options.definitions) || options.idempotencyKey !== admission.messageId || admission.deliveryPrincipal !== void 0 && admission.deliveryPrincipal !== options.principal) return yield* failure("start", "worker-mismatch");
1652
+ if (admission.origin.worker.threadId !== options.threadId || admission.origin.worker.targetAgentId !== agentId || !definitionDigestsEqual$1(admission.origin.targetDigests, options.definitions) || options.idempotencyKey !== admission.messageId || admission.deliveryPrincipal !== void 0 && admission.deliveryPrincipal !== options.principal) return yield* failure("start", "worker-mismatch");
1630
1653
  const retainedFrameworkInput = Schema.is(FrameworkMessage)(options.messageAdmission);
1631
1654
  if (retainedFrameworkInput && admission.reportKind !== "update") yield* validateCompletion(options.messageAdmission, options, agentId, inputDigest);
1632
1655
  yield* reservation(admission, inputDigest, input, options.principal, retainedFrameworkInput, authorization);
@@ -1643,7 +1666,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
1643
1666
  const sourceBinding = currentBinding(origin.source.agentId);
1644
1667
  const targetBinding = currentBinding(origin.worker.targetAgentId);
1645
1668
  const reports = sourceBinding?.reporting?.filter((entry) => entry.delegationId === origin.worker.delegationId) ?? [];
1646
- if (sourceBinding === void 0 || targetBinding === void 0 || reports.length !== 1 || reports[0] === void 0 || reports[0].target !== targetBinding.definition || !definitionDigestsEqual(submission.agentDigests, origin.targetDigests)) return yield* failure("followUp", "declaration-unavailable");
1669
+ if (sourceBinding === void 0 || targetBinding === void 0 || reports.length !== 1 || reports[0] === void 0 || reports[0].target !== targetBinding.definition || !definitionDigestsEqual$1(submission.agentDigests, origin.targetDigests)) return yield* failure("followUp", "declaration-unavailable");
1647
1670
  const receivingOrigin = retained?.origin;
1648
1671
  if (destination.depth !== 0 && receivingOrigin === void 0) return yield* failure("followUp", "denied");
1649
1672
  const now = yield* Clock.currentTimeMillis;
@@ -2330,7 +2353,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
2330
2353
  return {
2331
2354
  worker: origin.worker,
2332
2355
  latestReceipt: acceptedInput?.receipt ?? null,
2333
- state: control.terminal ?? (control.stopped ? control.active === null ? "stopped" : "stopping" : control.active !== null ? "active" : delivery !== void 0 ? "starting" : "idle"),
2356
+ state: control.terminal ?? (control.stopped ? control.active === null ? "stopped" : "stopping" : control.active !== null ? control.active.state === "unknown" ? "unknown" : "active" : delivery !== void 0 ? "starting" : "idle"),
2334
2357
  acceptedInput,
2335
2358
  appliedInput,
2336
2359
  run,
@@ -2649,7 +2672,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
2649
2672
  const frozen = message._tag === "WorkerCompletion" ? proof?._tag === "WorkerReportPrepared" && proof.runId === message.report.runId && proof.messageId === options.idempotencyKey ? proof.envelope : void 0 : proof?._tag === "AgentUpdateEmitted" && Schema.toEquivalence(Update)(proof.update, message.update) ? proof.delivery?.envelope : void 0;
2650
2673
  if (frozen === void 0) return yield* failure("followUp", "denied");
2651
2674
  const envelope = yield* Schema.decodeUnknownEffect(PreparedInput)(frozen).pipe(Effect.mapError((cause) => failure("followUp", "corrupt", cause)));
2652
- if (!Schema.is(FrameworkMessage)(envelope.messageAdmission) || !Schema.toEquivalence(FrameworkMessage)(envelope.messageAdmission, message) || envelope.threadId !== options.threadId || envelope.agentId !== agentId || envelope.inputDigest !== inputDigest || envelope.deliveryPrincipal !== options.principal || envelope.admissionKey !== options.idempotencyKey || !definitionDigestsEqual(envelope.definitions, options.definitions) || !Schema.toEquivalence(Schema.UndefinedOr(WorkerAdmission))(envelope.workerAdmission, options.workerAdmission)) return yield* failure("followUp", "denied");
2675
+ if (!Schema.is(FrameworkMessage)(envelope.messageAdmission) || !Schema.toEquivalence(FrameworkMessage)(envelope.messageAdmission, message) || envelope.threadId !== options.threadId || envelope.agentId !== agentId || envelope.inputDigest !== inputDigest || envelope.deliveryPrincipal !== options.principal || envelope.admissionKey !== options.idempotencyKey || !definitionDigestsEqual$1(envelope.definitions, options.definitions) || !Schema.toEquivalence(Schema.UndefinedOr(WorkerAdmission))(envelope.workerAdmission, options.workerAdmission)) return yield* failure("followUp", "denied");
2653
2676
  const recorded = Option.getOrUndefined(yield* exactRecord(childThreadId, workerOriginRecordId(childThreadId), "followUp"))?.record.payload;
2654
2677
  if (recorded?._tag !== "WorkerOriginRecorded" || recorded.origin.worker.threadId !== childThreadId || recorded.origin.reporting?.mode !== "standard") return yield* failure("followUp", "denied");
2655
2678
  const origin = recorded.origin;
@@ -2830,6 +2853,7 @@ const childUsageReportsOf = (state) => [...state.started.entries()].map(([toolCa
2830
2853
  });
2831
2854
  /** Deterministic batch identity of one executed recovery decision's audit append (DUR-013). */
2832
2855
  const recoveryRepairBatchId = (submissionId, decisionTag) => decodeBatchId(`repair:${submissionId}:${decisionTag}`);
2856
+ const isOriginalInputRecord = (record) => record.payload._tag === "UserInputRecorded";
2833
2857
  /** Deterministic record identity of one executed recovery decision's `RepairAnnotated` record. */
2834
2858
  const recoveryRepairRecordId = (submissionId, decisionTag) => decodeRecordId(`repair:${submissionId}:${decisionTag}`);
2835
2859
  const RecoveryCauseTag = Schema.Literals([
@@ -3741,15 +3765,25 @@ const make = Effect.fnUntraced(function* (bindings) {
3741
3765
  };
3742
3766
  });
3743
3767
  const attemptContextAtTail = (threadId) => makeRunWriter(threadId).pipe(Effect.provideService(ThreadStore, store), Effect.provideService(StorageOwner, storageOwner), Effect.flatMap(withProgress), Effect.map(({ owned }) => owned));
3744
- const withProgressSession = Effect.fnUntraced(function* (session) {
3768
+ const withProgressSession = Effect.fnUntraced(function* (session, originalInput) {
3745
3769
  const { owned, progress } = yield* withProgress(session);
3746
3770
  activeProgress.set(session.threadId, { writer: progress });
3747
3771
  yield* Effect.addFinalizer(() => Effect.sync(() => {
3748
3772
  if (activeProgress.get(session.threadId)?.writer === progress) activeProgress.delete(session.threadId);
3749
3773
  }));
3774
+ const inputWriter = session.appendInput === void 0 ? void 0 : {
3775
+ ...session,
3776
+ append: session.appendInput
3777
+ };
3750
3778
  const wrapped = {
3751
3779
  ...session,
3752
3780
  append: owned.append,
3781
+ ...inputWriter === void 0 ? {} : { appendInput: (batch) => storageOwner.withProgress(session.threadId, storageOwner.withMutation(Effect.gen(function* () {
3782
+ yield* session.checkActive;
3783
+ const original = originalInput?.();
3784
+ const commit = progress.commit(batch);
3785
+ return yield* (original === void 0 ? commit : progress.withVerifiedEmptyRun(runIdForSubmission(session.claim.submissionId), CanonicalSequence.make(original.sequence - 1), commit)).pipe(Effect.provideService(CurrentRunWriter, inputWriter));
3786
+ }))) },
3753
3787
  publishSettlement: (batch) => progress.publish(batch).pipe(Effect.provideService(CurrentRunSettlement, session))
3754
3788
  };
3755
3789
  progressWriters.set(wrapped, progress);
@@ -3962,6 +3996,19 @@ const make = Effect.fnUntraced(function* (bindings) {
3962
3996
  yield* hit("tools:after-unavailable-append");
3963
3997
  recovered += 1;
3964
3998
  });
3999
+ if ((intent === void 0 || intent.resolution._tag === "SafeToRetry") && declared !== void 0 && nativeUpdateAccepted(submission, declared, records)) {
4000
+ yield* appendClosedCall(ctx, submissionId, knownIds, call, {
4001
+ result: {
4002
+ value: { emitted: true },
4003
+ isFailure: false
4004
+ },
4005
+ resolution: "completed-with-result",
4006
+ author: RECONCILER_AUTHOR,
4007
+ reason: "The exact native update was canonically accepted"
4008
+ });
4009
+ recovered += 1;
4010
+ continue;
4011
+ }
3965
4012
  if (intent !== void 0) switch (intent.resolution._tag) {
3966
4013
  case "AbortSubmission": continue;
3967
4014
  case "CompletedWithResult":
@@ -4054,6 +4101,13 @@ const make = Effect.fnUntraced(function* (bindings) {
4054
4101
  reason
4055
4102
  }));
4056
4103
  });
4104
+ const prepareOriginalInput = (submission) => makeEnvelope(submissionInputRecordId(submission.submissionId), UserInputRecorded.make({
4105
+ submissionId: submission.submissionId,
4106
+ kind: "user",
4107
+ runId: runIdForSubmission(submission.submissionId),
4108
+ input: submission.inputPayload,
4109
+ ...submission.messageAdmission === void 0 ? {} : { messageAdmission: submission.messageAdmission }
4110
+ }));
4057
4111
  /**
4058
4112
  * Plan step 2: append the deterministic `UserInputRecorded` record (batch idempotency makes it
4059
4113
  * exactly-once canonical, DUR-007) and mark it applied. When canonical history already carries
@@ -4071,13 +4125,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4071
4125
  });
4072
4126
  return;
4073
4127
  }
4074
- const envelope = yield* makeEnvelope(recordId, UserInputRecorded.make({
4075
- submissionId,
4076
- kind: "user",
4077
- runId: runIdForSubmission(submissionId),
4078
- input: submission.inputPayload,
4079
- ...submission.messageAdmission === void 0 ? {} : { messageAdmission: submission.messageAdmission }
4080
- }));
4128
+ const envelope = yield* prepareOriginalInput(submission);
4081
4129
  const result = yield* appendBatch(ctx, CanonicalBatch.make({
4082
4130
  batchId: submissionInputBatchId(submissionId),
4083
4131
  producerId: config.producerId,
@@ -4104,8 +4152,10 @@ const make = Effect.fnUntraced(function* (bindings) {
4104
4152
  if (starts.length > 1 || starts.length === 1 && starts[0]?.recordId !== recordId || existing !== void 0 && (existing.payload._tag !== "RunStarted" || existing.payload.runId !== runId)) return yield* RunJournalError.make({ message: `Run ${runId} has conflicting active start state` });
4105
4153
  return existing;
4106
4154
  });
4107
- const makeRunStart = Effect.fnUntraced(function* (submission, maxDurationMillis, records, operational) {
4155
+ const makeRunStart = Effect.fnUntraced(function* (submission, maxDurationMillis, records, operational, input) {
4108
4156
  const writer = yield* CurrentRunWriter;
4157
+ const append = input === void 0 ? writer.append : writer.appendInput;
4158
+ if (append === void 0) return yield* RunJournalError.make({ message: "Fresh startup requires an input publisher" });
4109
4159
  const runId = runIdForSubmission(submission.submissionId);
4110
4160
  const recordId = runStartedRecordId(runId);
4111
4161
  const existing = yield* readRunStart(submission.threadId, runId, operational);
@@ -4133,11 +4183,19 @@ const make = Effect.fnUntraced(function* (bindings) {
4133
4183
  return;
4134
4184
  }
4135
4185
  yield* hit("run:before-start-append");
4136
- yield* appendBatch(writer, CanonicalBatch.make({
4137
- batchId: runStartedBatchId(runId),
4186
+ yield* appendBatch({
4187
+ threadId: writer.threadId,
4188
+ append
4189
+ }, CanonicalBatch.make({
4190
+ batchId: input === void 0 ? runStartedBatchId(runId) : submissionInputBatchId(submission.submissionId),
4138
4191
  producerId: config.producerId,
4139
- records: [start, ...context === void 0 ? [] : [context]]
4192
+ records: [
4193
+ input ?? start,
4194
+ ...input === void 0 ? [] : [start],
4195
+ ...context === void 0 ? [] : [context]
4196
+ ]
4140
4197
  }));
4198
+ if (input !== void 0) yield* hit("input:after-canonical-append");
4141
4199
  committed = true;
4142
4200
  yield* hit("run:after-start-append");
4143
4201
  });
@@ -4425,7 +4483,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4425
4483
  case "Admitted": {
4426
4484
  const child = resolution.submission;
4427
4485
  const linkage = child.parentLinkage;
4428
- if (child.agentId !== request.targetAgentId || !definitionDigestsEqual(child.agentDigests, request.targetDigests) || child.inputDigest !== request.childInputDigest || linkage === void 0 || linkage.parentSubmissionId !== parent.submissionId || linkage.parentToolCallId !== request.toolCallId) return yield* LedgerError.make({
4486
+ if (child.agentId !== request.targetAgentId || !definitionDigestsEqual$1(child.agentDigests, request.targetDigests) || child.inputDigest !== request.childInputDigest || linkage === void 0 || linkage.parentSubmissionId !== parent.submissionId || linkage.parentToolCallId !== request.toolCallId) return yield* LedgerError.make({
4429
4487
  operation: "establishChildFromRequest",
4430
4488
  message: `The admitted child ${child.submissionId} diverges from the canonical SubagentRequested record for Tool Call ${request.toolCallId}; establishment fails closed (SUB-016)`
4431
4489
  });
@@ -4503,7 +4561,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4503
4561
  const child = childLookup.value;
4504
4562
  if (child.threadId !== request.childThreadId) return mismatch("The child Thread does not match the intended child identity");
4505
4563
  if (child.agentId !== request.targetAgentId) return mismatch("The child Agent identity does not match the declared delegation target");
4506
- if (!definitionDigestsEqual(child.agentDigests, request.targetDigests)) return mismatch("The child definition digests do not match the stored target digests");
4564
+ if (!definitionDigestsEqual$1(child.agentDigests, request.targetDigests)) return mismatch("The child definition digests do not match the stored target digests");
4507
4565
  if (child.inputDigest !== request.childInputDigest) return mismatch("The child input digest does not match the canonical request");
4508
4566
  const linkage = child.parentLinkage;
4509
4567
  if (linkage === void 0 || linkage.parentSubmissionId !== parent.submissionId || linkage.parentToolCallId !== request.toolCallId) return mismatch("The child admission linkage does not name this parent Tool Call");
@@ -4511,7 +4569,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4511
4569
  const lineage = childRecords.find((envelope) => envelope.record.recordId === subagentLineageRecordId(request.childThreadId))?.record.payload;
4512
4570
  if (lineage === void 0 || lineage._tag !== "SubagentLineageRecorded") return mismatch("The child Thread carries no immutable lineage record");
4513
4571
  if (lineage.parentLink.delegationId !== request.delegationId || lineage.parentLink.parentAgentId !== parent.agentId || lineage.parentLink.parentThreadId !== parent.threadId || lineage.parentLink.parentRunId !== request.runId || lineage.parentLink.parentToolCallId !== request.toolCallId || lineage.parentLink.depth !== (request.depth ?? CHILD_DELEGATION_DEPTH) || lineage.parentSubmissionId !== parent.submissionId) return mismatch("The child Parent Link does not name exactly this parent Run and Tool Call");
4514
- if (!definitionDigestsEqual(lineage.childDefinitionDigests, request.targetDigests) || lineage.childInputDigest !== request.childInputDigest || lineage.grantDigest !== request.grantDigest || lineage.toolCallAllowance !== request.toolCallAllowance || !Equal.equals(lineage.policy, request.policy) || !Equal.equals(lineage.budget, request.budget) || !Equal.equals(lineage.grant, request.grant)) return mismatch("The child lineage digests or allowance do not match the canonical request");
4572
+ if (!definitionDigestsEqual$1(lineage.childDefinitionDigests, request.targetDigests) || lineage.childInputDigest !== request.childInputDigest || lineage.grantDigest !== request.grantDigest || lineage.toolCallAllowance !== request.toolCallAllowance || !Equal.equals(lineage.policy, request.policy) || !Equal.equals(lineage.budget, request.budget) || !Equal.equals(lineage.grant, request.grant)) return mismatch("The child lineage digests or allowance do not match the canonical request");
4515
4573
  const settlement = childRecords.find((envelope) => envelope.record.recordId === submissionSettlementRecordId(childSubmissionId))?.record.payload;
4516
4574
  if (settlement === void 0 || settlement._tag !== "SubmissionSettled") return mismatch("The child has no canonical Settlement record");
4517
4575
  if (settlement.submissionId !== childSubmissionId || settlement.settlementId !== submissionSettlementId(childSubmissionId) || settlement.receiptId !== child.receiptId) return mismatch("The child Settlement identity does not match the child Receipt");
@@ -4974,7 +5032,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4974
5032
  const boundaries = [];
4975
5033
  const cached = projectedJournal;
4976
5034
  const projectionThrough = Math.max(progressThrough ?? 0, records.at(-1)?.sequence ?? 0);
4977
- const originalInput = records.find(({ record: { payload } }) => payload._tag === "UserInputRecorded" && payload.kind === "user" && payload.submissionId === submissionId);
5035
+ const originalInput = initialJournal?.original ?? records.find(({ record: { payload } }) => payload._tag === "UserInputRecorded" && payload.kind === "user" && payload.submissionId === submissionId);
4978
5036
  if (originalInput === void 0) return yield* RunJournalError.make({ message: "Run has no original context boundary" });
4979
5037
  const historyEvidence = /* @__PURE__ */ new Map();
4980
5038
  const retainHistory = (entry) => {
@@ -5025,7 +5083,7 @@ const make = Effect.fnUntraced(function* (bindings) {
5025
5083
  const inheritedGrant = submission.workerAdmission?.origin.grant ?? (childLineage?._tag === "SubagentLineageRecorded" ? childLineage.grant : void 0);
5026
5084
  const delegationDepth = submission.workerAdmission?.origin.depth ?? (childLineage?._tag === "SubagentLineageRecorded" ? childLineage.parentLink.depth : 0);
5027
5085
  const inheritedBudget = submission.workerAdmission?.origin.budget ?? (childLineage?._tag === "SubagentLineageRecorded" ? childLineage.budget : void 0);
5028
- if (submission.parentLinkage !== void 0 && (childLineage?._tag !== "SubagentLineageRecorded" || childLineage.parentSubmissionId !== submission.parentLinkage.parentSubmissionId || childLineage.parentLink.parentToolCallId !== submission.parentLinkage.parentToolCallId || !definitionDigestsEqual(childLineage.childDefinitionDigests, submission.agentDigests) || childLineage.childInputDigest !== submission.inputDigest)) return yield* RunJournalError.make({ message: "The child Run has no matching canonical lineage and execution bounds" });
5086
+ if (submission.parentLinkage !== void 0 && (childLineage?._tag !== "SubagentLineageRecorded" || childLineage.parentSubmissionId !== submission.parentLinkage.parentSubmissionId || childLineage.parentLink.parentToolCallId !== submission.parentLinkage.parentToolCallId || !definitionDigestsEqual$1(childLineage.childDefinitionDigests, submission.agentDigests) || childLineage.childInputDigest !== submission.inputDigest)) return yield* RunJournalError.make({ message: "The child Run has no matching canonical lineage and execution bounds" });
5029
5087
  const completionTools = [...agent.definition.completion === void 0 ? [] : [agent.definition.completion.tool], ...agent.definition.completionFromTools?.map((declaration) => declaration.tool) ?? []];
5030
5088
  const pending = yield* pendingToolBatchFor(records, runId, completionTools);
5031
5089
  const resumeProjection = pending === void 0 ? journal : yield* projectRunJournalStream(withoutPendingBatch(canonical, pending, runId), runId, void 0, priorContext);
@@ -5200,14 +5258,6 @@ const make = Effect.fnUntraced(function* (bindings) {
5200
5258
  usageSummary: yield* currentUsageSummary()
5201
5259
  };
5202
5260
  }
5203
- let ownerFirstSequence;
5204
- for (const envelope of records) {
5205
- const payload = envelope.record.payload;
5206
- if ("runId" in payload && payload.runId === runId) {
5207
- ownerFirstSequence = envelope.sequence;
5208
- break;
5209
- }
5210
- }
5211
5261
  /** Only canonical joined inputs can require restoration from an earlier Attempt. */
5212
5262
  let joinBacklog = joinedInputEnvelopes.size === 0 ? [] : void 0;
5213
5263
  /** Joined inputs already handed to the engine during THIS Attempt (never re-deliver). */
@@ -5369,6 +5419,7 @@ const make = Effect.fnUntraced(function* (bindings) {
5369
5419
  cause
5370
5420
  })));
5371
5421
  yield* (yield* CurrentRunStart).commit(yield* makeEnvelope(recordId, payload));
5422
+ knownIds.add(originalInput.record.recordId);
5372
5423
  knownIds.add(runStartedRecordId(runId));
5373
5424
  knownIds.add(recordId);
5374
5425
  historyEvidence.clear();
@@ -5665,7 +5716,7 @@ const make = Effect.fnUntraced(function* (bindings) {
5665
5716
  sourceBoundaries = [];
5666
5717
  sourceJournal = yield* recordHalt(projectRunJournalStream(Stream.concat(source, Stream.fromIterable(yield* recordHalt(selectedRange(ctx.threadId, [submissionId], tail.sequence, canonicalThrough)))).pipe(Stream.filter((envelope) => envelope.record.payload._tag !== "CompactionCreated" || envelope.sequence <= canonicalThrough)), runId, (boundary) => sourceBoundaries.push(boundary), priorContext));
5667
5718
  }
5668
- const coverable = sourceBoundaries.filter((boundary) => commit.kind !== "summarize" || ownerFirstSequence === void 0 || boundary.sequence < ownerFirstSequence);
5719
+ const coverable = sourceBoundaries.filter((boundary) => commit.kind !== "summarize" || boundary.sequence < originalInput.sequence);
5669
5720
  if (coverable.length === 0) return yield* CompactionError.make({ message: commit.kind === "rollover" ? "Durable rollover requires complete canonical records" : "Durable compaction requires eligible canonical records" });
5670
5721
  const comparisonView = instructionView(sourceJournal.prompt.content, initialInstructions, false, sourceJournal.historyBefore.content.length);
5671
5722
  let matchingPrefix = 0;
@@ -6445,12 +6496,20 @@ const make = Effect.fnUntraced(function* (bindings) {
6445
6496
  const checkpointPrompt = yield* promptHistory.take({ threadId: session.threadId }).pipe(Effect.provideService(ThreadStore, store), Effect.provideContext(journalServices));
6446
6497
  let committedPromptSuffix;
6447
6498
  const storageSession = session;
6499
+ let pendingOriginal;
6448
6500
  yield* Effect.addFinalizer(() => Effect.sync(() => {
6449
6501
  committedPromptSuffix?.discard();
6450
6502
  committedPromptSuffix = void 0;
6451
6503
  }));
6452
6504
  const promptSession = {
6453
6505
  ...storageSession,
6506
+ ...storageSession.appendInput === void 0 ? {} : { appendInput: (batch, executions) => storageSession.appendInput(batch, executions).pipe(Effect.tap((result) => Effect.sync(() => {
6507
+ if (pendingOriginal !== void 0 && !result.replayed && result.firstSequence === pendingOriginal.sequence) committedPromptSuffix = makeCommittedPromptSuffix({
6508
+ threadId: storageSession.threadId,
6509
+ sequence: result.firstSequence,
6510
+ record: batch.records[0]
6511
+ });
6512
+ }))) },
6454
6513
  append: (batch, executions) => {
6455
6514
  const suffix = committedPromptSuffix;
6456
6515
  const append = storageSession.append(batch, executions);
@@ -6469,7 +6528,7 @@ const make = Effect.fnUntraced(function* (bindings) {
6469
6528
  }))), Effect.tapCause(() => Effect.sync(() => suffix.discard())));
6470
6529
  }
6471
6530
  };
6472
- session = yield* withProgressSession(promptSession);
6531
+ session = yield* withProgressSession(promptSession, () => pendingOriginal);
6473
6532
  const { claim, threadId } = session;
6474
6533
  const submissionId = claim.submissionId;
6475
6534
  let prepared = freshlyAdmitted && session.withInitialization !== void 0 ? yield* session.withInitialization(Effect.gen(function* () {
@@ -6481,6 +6540,30 @@ const make = Effect.fnUntraced(function* (bindings) {
6481
6540
  const before = (yield* session.tail).sequence;
6482
6541
  const view = yield* recoveryView(threadId, before, [submissionId], runIdForSubmission(submissionId));
6483
6542
  if (view.progress !== void 0 || view.context !== void 0 || view.operational.length !== 0 || view.records.some(({ record }) => record.payload._tag !== "ThreadCreated")) return void 0;
6543
+ if (session.appendInput !== void 0) {
6544
+ const record = (yield* PreparedAppend.capture(AppendRequest.make({
6545
+ threadId,
6546
+ expectedTailSequence: before,
6547
+ batch: CanonicalBatch.make({
6548
+ batchId: submissionInputBatchId(submissionId),
6549
+ producerId: config.producerId,
6550
+ records: [yield* prepareOriginalInput(submission)]
6551
+ })
6552
+ }))).records[0].canonical;
6553
+ if (!isOriginalInputRecord(record)) return yield* RunJournalError.make({ message: "Captured startup has no original input" });
6554
+ pendingOriginal = {
6555
+ threadId,
6556
+ sequence: CanonicalSequence.make(before + 1),
6557
+ record
6558
+ };
6559
+ return {
6560
+ snapshot,
6561
+ through: before,
6562
+ view,
6563
+ start: yield* makeRunStart(submission, Duration.toMillis(registeredAgent.definition.policy.maxDuration), view.records, view.operational, record).pipe(Effect.provideService(CurrentRunWriter, session)),
6564
+ input: pendingOriginal
6565
+ };
6566
+ }
6484
6567
  const progress = progressWriters.get(session);
6485
6568
  const applyInput = applyCanonicalInput(session, submission, session, view.records, void 0);
6486
6569
  yield* progress === void 0 ? applyInput : progress.withVerifiedEmptyRun(runIdForSubmission(submissionId), before, applyInput).pipe(Effect.provideService(CurrentRunWriter, promptSession));
@@ -6500,7 +6583,8 @@ const make = Effect.fnUntraced(function* (bindings) {
6500
6583
  progressThrough: accepted.throughSequence,
6501
6584
  operational: accepted.operational
6502
6585
  },
6503
- start
6586
+ start,
6587
+ input: void 0
6504
6588
  };
6505
6589
  })) : void 0;
6506
6590
  const preparedInput = prepared !== void 0;
@@ -6689,10 +6773,10 @@ const make = Effect.fnUntraced(function* (bindings) {
6689
6773
  let canonical = Stream.fromIterable(view.records);
6690
6774
  let initialJournal;
6691
6775
  if (view.context === void 0) {
6692
- const original = currentRecords.find(({ record }) => record.payload._tag === "UserInputRecorded" && record.payload.kind === "user" && record.payload.submissionId === submissionId);
6776
+ const original = initialization?.input ?? currentRecords.find(({ record }) => record.payload._tag === "UserInputRecorded" && record.payload.kind === "user" && record.payload.submissionId === submissionId);
6693
6777
  if (original === void 0) return yield* RunJournalError.make({ message: "Run has no exact original input context boundary" });
6694
6778
  const suffix = currentRecords.filter((entry) => entry.sequence > original.sequence);
6695
- const fresh = !lineage.inputWasRecorded && tail.sequence === original.sequence && suffix.length === 0;
6779
+ const fresh = initialization?.input !== void 0 || !lineage.inputWasRecorded && tail.sequence === original.sequence && suffix.length === 0;
6696
6780
  const source = yield* Effect.gen(function* () {
6697
6781
  if (checkpointPrompt !== void 0 && fresh && original.sequence === checkpointPrompt.through + 1) {
6698
6782
  const records = [original, ...suffix];
@@ -6724,8 +6808,8 @@ const make = Effect.fnUntraced(function* (bindings) {
6724
6808
  canonical = Stream.fromIterableEffect(Effect.suspend(() => source.records === void 0 ? readInitialJournal(source.original, source.suffix) : Effect.succeed(source.records)));
6725
6809
  }
6726
6810
  committedPromptSuffix?.discard();
6727
- committedPromptSuffix = initialJournal?.cacheable ? makeCommittedPromptSuffix(initialJournal.original) : void 0;
6728
- const outcome = yield* runModel(agent, ctx, submission, session, currentRecords, canonical, initialJournal, tail.sequence, view.progressThrough, view.progress, view.context, takeJournalMetadata(), lineage, approvalDecisionIntents, currentContracts, runTiming, yieldAfter).pipe(Effect.provideService(CurrentRunStart, start.publication), Effect.ensuring(Effect.sync(() => {
6811
+ committedPromptSuffix = initialJournal?.cacheable && initialization?.input === void 0 ? makeCommittedPromptSuffix(initialJournal.original) : void 0;
6812
+ const outcome = yield* runModel(agent, ctx, submission, session, currentRecords, canonical, initialJournal, initialization?.input?.sequence ?? tail.sequence, view.progressThrough, view.progress, view.context, takeJournalMetadata(), lineage, approvalDecisionIntents, currentContracts, runTiming, yieldAfter).pipe(Effect.provideService(CurrentRunStart, start.publication), Effect.ensuring(Effect.sync(() => {
6729
6813
  if (initialJournal !== void 0) initialJournal.records = void 0;
6730
6814
  })));
6731
6815
  if (outcome._tag === "yielded") {
@@ -7005,6 +7089,7 @@ const make = Effect.fnUntraced(function* (bindings) {
7005
7089
  const declared = yield* declaredCallsFor(records, runIdForSubmission(submission.submissionId), new Set(intents.map((intent) => intent.toolCallId)));
7006
7090
  for (const intent of intents) {
7007
7091
  const original = declared.get(intent.toolCallId);
7092
+ if (original !== void 0 && nativeUpdateAccepted(submission, original, records)) continue;
7008
7093
  if (original === void 0 || current !== void 0 && !supportsOperation(OpenToolCallEvidence.make(original), operations.get(intent.toolCallId), current)) return true;
7009
7094
  }
7010
7095
  return false;
@@ -7088,7 +7173,31 @@ const make = Effect.fnUntraced(function* (bindings) {
7088
7173
  case "ResumePendingToolBatch": return "deferred";
7089
7174
  case "MarkUnknown": return yield* markUnknownForRecovery(snapshot, evidence, records, decision);
7090
7175
  case "ApplyUnknownResolutions": return yield* applyUnknownResolutionsForRecovery(snapshot, evidence, records);
7091
- case "AwaitUnknownResolution": return "unknown";
7176
+ case "AwaitUnknownResolution": {
7177
+ const declared = yield* declaredCallsFor(records, runId, new Set(evidence.openToolCalls.map((call) => call.toolCallId)));
7178
+ let repaired = false;
7179
+ for (const call of declared.values()) {
7180
+ if (snapshot.unknownResolutions.some((intent) => intent.toolCallId === call.toolCallId) || !nativeUpdateAccepted(submission, call, records)) continue;
7181
+ yield* ledger.recordUnknownResolution(UnknownResolutionCommand.make({
7182
+ submissionId: submission.submissionId,
7183
+ toolCallId: call.toolCallId,
7184
+ author: RECONCILER_AUTHOR,
7185
+ reason: "The exact native update was canonically accepted",
7186
+ resolution: {
7187
+ _tag: "CompletedWithResult",
7188
+ result: { emitted: true },
7189
+ isFailure: false
7190
+ }
7191
+ })).pipe(Effect.catchTag("UnknownResolutionConflict", (cause) => LedgerError.make({
7192
+ operation: "recover native update",
7193
+ message: "Native acceptance conflicts with a retained resolution",
7194
+ cause
7195
+ })));
7196
+ repaired = true;
7197
+ }
7198
+ if (repaired) yield* wake.notify(submission.threadId);
7199
+ return repaired ? "repaired" : "unknown";
7200
+ }
7092
7201
  case "AwaitApprovalDecision": return yield* awaitApprovalForRecovery(snapshot, evidence, decision);
7093
7202
  case "ResumeSuspended": return yield* resumeSuspendedForRecovery(snapshot);
7094
7203
  case "RevertJoining":
@@ -7382,12 +7491,16 @@ const make = Effect.fnUntraced(function* (bindings) {
7382
7491
  if (selected.state.settled || selected.state.resolved) return "none";
7383
7492
  const intent = (yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId: submission.submissionId }))).unknownResolutions.find((intent) => intent.toolCallId === selected.declared.toolCallId && unknownResolutionKind(intent.resolution) === "factual");
7384
7493
  const factual = intent?.resolution;
7385
- const reconciliation = factual === void 0 && selected.declared.executionKind === "ordinary" ? yield* reconciler.reconcile(DeclaredToolCallEvidence.make({
7494
+ const acceptedNative = factual === void 0 && (yield* updateRuntime.accepted(submission, selected.declared));
7495
+ const reconciliation = factual === void 0 && !acceptedNative && selected.declared.executionKind === "ordinary" ? yield* reconciler.reconcile(DeclaredToolCallEvidence.make({
7386
7496
  threadId,
7387
7497
  submissionId: submission.submissionId,
7388
7498
  ...selected.declared
7389
7499
  })).pipe(Effect.map(Option.some), Effect.catchTag("ToolReconcilerError", () => Effect.succeed(Option.none()))) : Option.none();
7390
- const completed = factual?._tag === "CompletedWithResult" ? factual : Option.isSome(reconciliation) && reconciliation.value._tag === "CompletedWithResult" ? reconciliation.value : void 0;
7500
+ const completed = factual?._tag === "CompletedWithResult" ? factual : acceptedNative ? {
7501
+ result: { emitted: true },
7502
+ isFailure: false
7503
+ } : Option.isSome(reconciliation) && reconciliation.value._tag === "CompletedWithResult" ? reconciliation.value : void 0;
7391
7504
  const neverStarted = factual?._tag === "NeverHappened" || selected.state.dispatchBlocked || Option.isSome(reconciliation) && reconciliation.value._tag === "NeverStarted";
7392
7505
  if (completed === void 0 && !neverStarted) return "unknown";
7393
7506
  const result = completed === void 0 ? yield* Schema.encodeEffect(ToolUnavailable)(ToolUnavailable.make({
@@ -7768,13 +7881,13 @@ const make = Effect.fnUntraced(function* (bindings) {
7768
7881
  code: `message-${cause.reason}`,
7769
7882
  cause
7770
7883
  })));
7771
- if (options.definitions.replay !== void 0 && workerAdmission === void 0 && messageAdmission === void 0 && !registeredBindings.some((binding) => binding.agentId === agent.definition.id && definitionDigestsEqual(binding.digests, options.definitions))) {
7884
+ if (options.definitions.replay !== void 0 && workerAdmission === void 0 && messageAdmission === void 0 && !registeredBindings.some((binding) => binding.agentId === agent.definition.id && definitionDigestsEqual$1(binding.digests, options.definitions))) {
7772
7885
  const retained = yield* ledger.lookup(SubmissionLookupByKey.make({
7773
7886
  threadId: options.threadId,
7774
7887
  principal: options.principal,
7775
7888
  idempotencyKey: options.idempotencyKey
7776
7889
  }));
7777
- if (Option.isNone(retained) || retained.value.agentId !== agent.definition.id || !definitionDigestsEqual(retained.value.agentDigests, options.definitions)) return yield* AdmissionPolicyError.make({
7890
+ if (Option.isNone(retained) || retained.value.agentId !== agent.definition.id || !definitionDigestsEqual$1(retained.value.agentDigests, options.definitions)) return yield* AdmissionPolicyError.make({
7778
7891
  reason: "refused",
7779
7892
  code: "unregistered-replay-contract"
7780
7893
  });
@@ -8447,4 +8560,4 @@ var DurableAgentRuntime = class DurableAgentRuntime extends Context.Service()("@
8447
8560
  //#endregion
8448
8561
  export { DurableApprovalSuspension as a, RecoveryFailure as c, WorkRecoveryReport as d, WorkRecoveryRequest as f, recoveryRepairRecordId as g, recoveryRepairBatchId as h, DurableApprovalResolver as i, RecoveryReport as l, isolateRecovery as m, DurableAgentRuntime as n, DurableRuntimeConfig as o, childReservationIdFor as p, DurableAgentRuntime_exports as r, RecoveryBlocked as s, ApprovalSuspensionError as t, RecoverySweepResult as u };
8449
8562
 
8450
- //# sourceMappingURL=DurableAgentRuntime-CPlw5_7e.mjs.map
8563
+ //# sourceMappingURL=DurableAgentRuntime-CGW93k81.mjs.map