@yielded/agent 0.1.0-beta.176 → 0.1.0-beta.178

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 (198) hide show
  1. package/dist/{Admin-DTDihBra.d.mts → Admin-NvXFPDIM.d.mts} +32 -12
  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-BJbuIqQq.mjs → DurableAgentRuntime-CWhu1exp.mjs} +142 -96
  10. package/dist/DurableAgentRuntime-CWhu1exp.mjs.map +1 -0
  11. package/dist/{DurableStep-DXGn7KQ4.d.mts → DurableStep-CAJnlgfL.d.mts} +5 -4
  12. package/dist/{EventSource-Cc58uEso.d.mts → EventSource-DNyaWmyQ.d.mts} +2 -2
  13. package/dist/{MessageDelivery-ClHg7c0O.d.mts → MessageDelivery-CLzWJImC.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-CjcX1OP0.d.mts → PreparedInputAdmission-BQ9UCLFS.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-CWHuciup.mjs → RunContinuation-BF95Ncv2.mjs} +12 -14
  22. package/dist/RunContinuation-BF95Ncv2.mjs.map +1 -0
  23. package/dist/{RunContinuation-DSnUTSSb.d.mts → RunContinuation-CL0wBsQE.d.mts} +3 -6
  24. package/dist/{RunJournal-DGblbFas.mjs → RunJournal-oJLo-pjS.mjs} +3 -3
  25. package/dist/{RunJournal-DGblbFas.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-BF2YgWkg.mjs → RunStorage-DlfvMfHM.mjs} +20 -6
  28. package/dist/RunStorage-DlfvMfHM.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-DuC_PcGx.d.mts → Subscription-D2yn6Eo3.d.mts} +2 -2
  36. package/dist/{SubscriptionInput-B1IeAEDi.d.mts → SubscriptionInput-Cog4x7Rd.d.mts} +2 -2
  37. package/dist/{ThreadImport-ZgWxf7bB.mjs → ThreadImport-BoTfjjrz.mjs} +9 -9
  38. package/dist/{ThreadImport-ZgWxf7bB.mjs.map → ThreadImport-BoTfjjrz.mjs.map} +1 -1
  39. package/dist/{ThreadImport-D_Biid6w.d.mts → ThreadImport-CMKa8U7y.d.mts} +42 -42
  40. package/dist/{ThreadStore-BC4V-mY-.mjs → ThreadStore-D2rqtt7k.mjs} +17 -12
  41. package/dist/ThreadStore-D2rqtt7k.mjs.map +1 -0
  42. package/dist/{ThreadTransfer-S7FnTRHt.mjs → ThreadTransfer-BFolkpEp.mjs} +4 -4
  43. package/dist/{ThreadTransfer-S7FnTRHt.mjs.map → ThreadTransfer-BFolkpEp.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-C47Vy_cK.mjs → WorkerAdmission-CtX1HRkm.mjs} +6 -6
  48. package/dist/{WorkerAdmission-C47Vy_cK.mjs.map → WorkerAdmission-CtX1HRkm.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/BrowserUse.d.mts +6 -2
  52. package/dist/capabilities/BrowserUse.mjs +23 -5
  53. package/dist/capabilities/BrowserUse.mjs.map +1 -1
  54. package/dist/capabilities/CodeMode.mjs +2 -1
  55. package/dist/capabilities/CodeMode.mjs.map +1 -1
  56. package/dist/capabilities/Commands.d.mts +1 -1
  57. package/dist/capabilities/ContextTools.mjs +1 -1
  58. package/dist/capabilities/McpClient.mjs +1 -1
  59. package/dist/capabilities/MemoryNotes.d.mts +1 -1
  60. package/dist/capabilities/MemoryNotes.mjs +2 -1
  61. package/dist/capabilities/MemoryNotes.mjs.map +1 -1
  62. package/dist/capabilities/Messaging.d.mts +1 -1
  63. package/dist/capabilities/Messaging.mjs +2 -2
  64. package/dist/capabilities/RunHooks.d.mts +1 -1
  65. package/dist/capabilities/Subagent.d.mts +2 -2
  66. package/dist/capabilities/Subagent.mjs +2 -2
  67. package/dist/capabilities/ToolDiscovery.mjs +1 -1
  68. package/dist/capabilities/WebCapture.mjs +1 -1
  69. package/dist/capabilities/WebSearch.mjs +1 -1
  70. package/dist/core/Agent.mjs +1 -1
  71. package/dist/core/Worker.d.mts +1 -1
  72. package/dist/core/Worker.mjs +1 -1
  73. package/dist/durable/ActivityStore.mjs +1 -1
  74. package/dist/durable/Admin.d.mts +1 -1
  75. package/dist/durable/Admin.mjs +1 -1
  76. package/dist/durable/AgentRegistration.d.mts +1 -1
  77. package/dist/durable/AgentRegistration.mjs +1 -1
  78. package/dist/durable/Certification.d.mts +1 -1
  79. package/dist/durable/CommittedActivity.d.mts +1 -1
  80. package/dist/durable/CommittedActivity.mjs +3 -3
  81. package/dist/durable/Digest.mjs +1 -1
  82. package/dist/durable/DurableAgentRuntime.d.mts +1 -1
  83. package/dist/durable/DurableAgentRuntime.mjs +2 -2
  84. package/dist/durable/EventSource.d.mts +1 -1
  85. package/dist/durable/EventSource.mjs +1 -1
  86. package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
  87. package/dist/durable/LifecyclePublication.d.mts +1 -1
  88. package/dist/durable/LifecyclePublication.mjs +3 -3
  89. package/dist/durable/MessageDelivery.d.mts +1 -1
  90. package/dist/durable/MessageDelivery.mjs +3 -3
  91. package/dist/durable/MessageDeliveryStoreConformance.d.mts +40 -40
  92. package/dist/durable/MessageDeliveryStoreConformance.mjs +3 -3
  93. package/dist/durable/PersistentHistory.d.mts +1 -1
  94. package/dist/durable/PersistentHistory.mjs +4 -4
  95. package/dist/durable/PreparedInputAdmission.d.mts +1 -1
  96. package/dist/durable/RecordFormat.mjs +1 -1
  97. package/dist/durable/Records.mjs +1 -1
  98. package/dist/durable/Recovery.d.mts +1 -1
  99. package/dist/durable/Recovery.mjs +1 -1
  100. package/dist/durable/RunContinuation.d.mts +2 -2
  101. package/dist/durable/RunContinuation.mjs +3 -3
  102. package/dist/durable/RunJournal.d.mts +1 -1
  103. package/dist/durable/RunJournal.mjs +1 -1
  104. package/dist/durable/RunStorage.d.mts +1 -1
  105. package/dist/durable/RunStorage.mjs +1 -1
  106. package/dist/durable/Schedule.mjs +1 -1
  107. package/dist/durable/ScheduleStoreConformance.mjs +1 -1
  108. package/dist/durable/ScheduleTransition.mjs +1 -1
  109. package/dist/durable/Scheduling.d.mts +1 -1
  110. package/dist/durable/Scheduling.mjs +1 -1
  111. package/dist/durable/SettlementPublisher.d.mts +1 -1
  112. package/dist/durable/SettlementPublisher.mjs +3 -3
  113. package/dist/durable/SubmissionLedger.d.mts +1 -1
  114. package/dist/durable/SubmissionLedger.mjs +4 -4
  115. package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
  116. package/dist/durable/SubmissionLedgerConformance.mjs +7 -7
  117. package/dist/durable/SubmissionStatus.d.mts +1 -1
  118. package/dist/durable/Subscription.d.mts +1 -1
  119. package/dist/durable/Subscription.mjs +2 -2
  120. package/dist/durable/SubscriptionInput.d.mts +1 -1
  121. package/dist/durable/SubscriptionInput.mjs +2 -2
  122. package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
  123. package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
  124. package/dist/durable/SubscriptionTools.d.mts +3 -3
  125. package/dist/durable/SubscriptionTools.mjs +2 -1
  126. package/dist/durable/SubscriptionTools.mjs.map +1 -1
  127. package/dist/durable/SubscriptionTransition.d.mts +1 -1
  128. package/dist/durable/SubscriptionTransition.mjs +1 -1
  129. package/dist/durable/Subscriptions.d.mts +5 -5
  130. package/dist/durable/Subscriptions.mjs +2 -2
  131. package/dist/durable/ThreadArchiveRange.d.mts +1 -1
  132. package/dist/durable/ThreadArchiveRange.mjs +1 -1
  133. package/dist/durable/ThreadContextHistory.d.mts +1 -1
  134. package/dist/durable/ThreadContextHistory.mjs +2 -2
  135. package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
  136. package/dist/durable/ThreadImport.d.mts +1 -1
  137. package/dist/durable/ThreadImport.mjs +1 -1
  138. package/dist/durable/ThreadInvariants.d.mts +3 -3
  139. package/dist/durable/ThreadInvariants.mjs +4 -4
  140. package/dist/durable/ThreadProjection.mjs +1 -1
  141. package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
  142. package/dist/durable/ThreadReader.d.mts +1 -1
  143. package/dist/durable/ThreadReader.mjs +1 -1
  144. package/dist/durable/ThreadStore.d.mts +2 -2
  145. package/dist/durable/ThreadStore.mjs +3 -3
  146. package/dist/durable/ThreadStoreConformance.d.mts +2 -1
  147. package/dist/durable/ThreadStoreConformance.mjs +4 -4
  148. package/dist/durable/ThreadTransfer.d.mts +1 -1
  149. package/dist/durable/ThreadTransfer.mjs +1 -1
  150. package/dist/durable/ThreadWork.d.mts +1 -1
  151. package/dist/durable/ThreadWork.mjs +5 -5
  152. package/dist/durable/ToolReconciler.mjs +1 -1
  153. package/dist/durable/WorkerAdmission.d.mts +1 -1
  154. package/dist/durable/WorkerAdmission.mjs +1 -1
  155. package/dist/durable/WorkerHost.d.mts +2 -2
  156. package/dist/durable/WorkerHost.mjs +1 -1
  157. package/dist/engine/AgentRuntime.d.mts +1 -1
  158. package/dist/engine/AgentRuntime.mjs +1 -1
  159. package/dist/engine/DurableStep.d.mts +2 -2
  160. package/dist/engine/DurableStep.mjs +1 -11
  161. package/dist/engine/DurableStep.mjs.map +1 -1
  162. package/dist/engine/MessagingHost.d.mts +1 -1
  163. package/dist/engine/MessagingHost.mjs +1 -1
  164. package/dist/engine/RunOptions.d.mts +1 -1
  165. package/dist/engine/SubagentHost.d.mts +1 -1
  166. package/dist/engine/SubagentHost.mjs +1 -1
  167. package/dist/index.d.mts +16 -16
  168. package/dist/index.mjs +15 -15
  169. package/dist/{run-context-reader-DvTEq2RC.d.mts → run-context-reader-kpO9xhP2.d.mts} +2 -2
  170. package/dist/sandbox/CodeExecutor.d.mts +3 -1
  171. package/dist/sandbox/CodeExecutor.mjs +3 -1
  172. package/dist/sandbox/CodeExecutor.mjs.map +1 -1
  173. package/dist/tool-execution-Ba7tO7Pt.mjs +17 -0
  174. package/dist/tool-execution-Ba7tO7Pt.mjs.map +1 -0
  175. package/package.json +1 -1
  176. package/src/capabilities/BrowserUse.ts +25 -5
  177. package/src/capabilities/CodeMode.ts +1 -0
  178. package/src/core/Worker.ts +3 -1
  179. package/src/core/internal/agent-updates.ts +9 -1
  180. package/src/core/internal/tool-execution.ts +33 -0
  181. package/src/durable/DurableAgentRuntime.ts +152 -151
  182. package/src/durable/RunContinuation.ts +44 -32
  183. package/src/durable/RunStorage.ts +56 -15
  184. package/src/durable/ThreadStore.ts +11 -0
  185. package/src/durable/internal/agent-updates.ts +59 -3
  186. package/src/durable/internal/prompt-history-cache.ts +19 -3
  187. package/src/durable/internal/record-encoding.ts +8 -7
  188. package/src/durable/internal/worker-host.ts +3 -1
  189. package/src/engine/DurableStep.ts +5 -31
  190. package/src/engine/internal/agent-runtime.ts +2 -1
  191. package/src/sandbox/CodeExecutor.ts +3 -1
  192. package/dist/Agent-BiRbr73L.mjs.map +0 -1
  193. package/dist/AgentRuntime-DaDKMasp.mjs.map +0 -1
  194. package/dist/DurableAgentRuntime-BJbuIqQq.mjs.map +0 -1
  195. package/dist/RunContinuation-CWHuciup.mjs.map +0 -1
  196. package/dist/RunStorage-BF2YgWkg.mjs.map +0 -1
  197. package/dist/ThreadStore-BC4V-mY-.mjs.map +0 -1
  198. package/dist/Worker-DZjdMjZn.mjs.map +0 -1
@@ -9,13 +9,13 @@ import { s as ToolBroker } from "./ToolBroker-P5t4ZN78.mjs";
9
9
  import { c as AgentOutputError, f as AgentToolAuthorizationCheckError, g as ModelProtocolError, h as ContextOverflowError, l as AgentPersistenceCapacityError, m as ContextBudgetError, n as AgentApprovalPending, o as AgentInputError, p as AgentToolAuthorizationDenied, t as AgentApprovalDenied, u as AgentPolicyError } from "./AgentError-CBH7_MjG.mjs";
10
10
  import { t as AgentPolicy } from "./AgentPolicy-B4lbCU2T.mjs";
11
11
  import { A as ToolUnion, C as OutputSchema, D as RunDispositionFailure, E as RunDispositionDeclaration, N as UpdatesSchema, O as RunDispositionSchema, S as Output, _ as InstructionSource, a as CompletionFromToolDeclaration, c as Definition, d as EncodedInput, f as Failure, m as InputPromptSource, n as Any, r as AnyDefinition, s as CompletionToolDeclaration, t as Agent_d_exports, w as Requirements } from "./Agent-B39jRnFv.mjs";
12
- import { a as WorkerBudgetScope } from "./Worker-CHRaIsWu.mjs";
12
+ import { a as WorkerBudgetScope } from "./Worker-CLYgfqhF.mjs";
13
13
  import { a as ContextWindow } from "./ContextWindow-Cvv8N9Xy.mjs";
14
14
  import { n as CompactionError } from "./ContextCompactor-Bz91grmO.mjs";
15
- import { t as DurableStep } from "./DurableStep-DXGn7KQ4.mjs";
16
- import { B as RunSubagentChildIdentity, H as RunSubagentEstablishRequest, M as RunOptions, S as RunContextPreparationError, W as RunSubagentJoinRequest, i as ChildEstablishStatus, l as ModelUsageAccounting, t as AgentUpdateAcceptance, x as RunContextPreparation } from "./RunOptions-Be77lKVZ.mjs";
17
- import { t as MessagingHost } from "./MessagingHost-C6SOAcoG.mjs";
18
- import { o as SubagentHost } from "./SubagentHost-D1xBgn9g.mjs";
15
+ import { t as DurableStep } from "./DurableStep-CAJnlgfL.mjs";
16
+ import { B as RunSubagentChildIdentity, H as RunSubagentEstablishRequest, M as RunOptions, S as RunContextPreparationError, W as RunSubagentJoinRequest, i as ChildEstablishStatus, l as ModelUsageAccounting, t as AgentUpdateAcceptance, x as RunContextPreparation } from "./RunOptions-BANtohGk.mjs";
17
+ import { t as MessagingHost } from "./MessagingHost-BKxDskYj.mjs";
18
+ import { o as SubagentHost } from "./SubagentHost-CikdGpmk.mjs";
19
19
  import { t as RunEventSink } from "./RunEventSink-shh6Qf9E.mjs";
20
20
  import * as Tool$1 from "effect/ai/Tool";
21
21
  import * as Toolkit$1 from "effect/ai/Toolkit";
@@ -359,4 +359,4 @@ declare namespace AgentRuntime_d_exports {
359
359
  }
360
360
  //#endregion
361
361
  export { runUnknown as A, decodeFinalOutput as C, projectCompletionOutput as D, projectCompletionFromToolOutput as E, streamWithUsageAccountingUnknown as F, withTerminalDefectEvent as I, startUnknown as M, stream as N, renderInputPrompt as O, streamUnknown as P, ToolCallWaiting as S, executeWithUsageAccountingUnknown as T, SubagentDurability as _, AgentResultSchema as a, SubagentDurabilityError as b, AgentSpawner as c, DetachedRun as d, EngineProvidedToolServices as f, SpawnedChildRun as g, SpawnRunOptions as h, AgentResult as i, start as j, run as k, AgentSpawnerParent as l, SpawnDelegation as m, AgentChildPending as n, AgentRuntimeFailure as o, RuntimeBinding as p, AgentCompletionProjectionRequirements as r, AgentRuntimeRequirements as s, AgentRuntime_d_exports as t, AgentSpawnerService as u, SubagentDurabilityDurable as v, encodeRunDisposition as w, SubagentDurabilityService as x, SubagentDurabilityEphemeral as y };
362
- //# sourceMappingURL=AgentRuntime-CHDyRbSf.d.mts.map
362
+ //# sourceMappingURL=AgentRuntime-Dx5u_FJD.d.mts.map
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { n as utf8ByteLength } from "./utf8-B5pAmhTo.mjs";
3
- import { b as Digest, v as DefinitionDigests } from "./Records-DzL4Kbtw.mjs";
3
+ import { b as Digest, v as DefinitionDigests } from "./Records-CZRedCE7.mjs";
4
4
  import { Array, Crypto, Effect, Predicate, Result, Schema } from "effect";
5
5
  import { Hex } from "effect/encoding";
6
6
  //#region src/durable/internal/canonical-json.ts
@@ -104,4 +104,4 @@ const digestDefinitions = (definitions) => Effect.all({
104
104
  //#endregion
105
105
  export { digestDefinition as a, boundedCanonicalJson as c, digestCanonicalJson as i, canonicalJson$1 as l, Digest_exports as n, digestDefinitions as o, canonicalJson as r, digestJson as s, DigestError as t };
106
106
 
107
- //# sourceMappingURL=Digest-C3EODOee.mjs.map
107
+ //# sourceMappingURL=Digest-ft4ku9pj.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Digest-C3EODOee.mjs","names":["canonicalJson","stringifyCanonicalJson"],"sources":["../src/durable/internal/canonical-json.ts","../src/durable/Digest.ts"],"sourcesContent":["import { Array, Predicate, Result, Schema } from \"effect\";\n\ninterface JsonLimits {\n readonly depth: number;\n readonly nodes: number;\n readonly collectionLength: number;\n readonly textUnits: number;\n}\n\nexport class CanonicalJsonLimitError extends Schema.TaggedError<CanonicalJsonLimitError>()(\n \"CanonicalJsonLimitError\",\n { message: Schema.String },\n) {}\n\n// Only this codec's private synchronous aborts become typed bounds failures.\nconst boundsFailures = new WeakMap<object, string>();\n\nconst exceeded = (bound: \"text\" | \"traversal\" | \"collection\"): never => {\n const message = `Canonical JSON exceeds its ${bound} bound`;\n // oxlint-disable-next-line effect/no-native-error -- Private synchronous codec abort; the Result boundary translates only errors owned here.\n const error = new RangeError(message);\n\n boundsFailures.set(error, message);\n // oxlint-disable-next-line effect/no-untyped-throw -- Abort synchronous JSON traversal at the first exceeded bound; the Result boundary catches this owned error.\n throw error;\n};\n\n/** Values have already crossed their Schema boundary; visit each serialized occurrence. */\nconst serialize = (value: Schema.Json, limits?: JsonLimits): string => {\n let nodes = 0;\n let textUnits = 0;\n\n const charge = (length: number) => {\n if (limits !== undefined && (textUnits += length) > limits.textUnits) return exceeded(\"text\");\n };\n\n const visit = (value: Schema.Json, depth: number): string => {\n if (limits !== undefined && (depth > limits.depth || ++nodes > limits.nodes))\n return exceeded(\"traversal\");\n if (\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"number\" ||\n typeof value === \"string\"\n ) {\n const encoded = JSON.stringify(value);\n\n charge(encoded.length);\n\n return encoded;\n }\n if (Array.isArray<Schema.Json>(value)) {\n if (limits !== undefined && value.length > limits.collectionLength)\n return exceeded(\"collection\");\n charge(2 + Math.max(0, value.length - 1));\n\n let json = \"[\";\n\n for (let index = 0; index < value.length; index++) {\n if (index > 0) json += \",\";\n json += visit(value[index], depth + 1);\n }\n\n return `${json}]`;\n }\n\n const keys = Object.keys(value).sort();\n\n if (limits !== undefined && keys.length > limits.collectionLength)\n return exceeded(\"collection\");\n charge(2 + Math.max(0, keys.length - 1));\n let json = \"{\";\n\n for (let index = 0; index < keys.length; index++) {\n const key = keys[index];\n const encodedKey = JSON.stringify(key);\n\n charge(encodedKey.length + 1);\n if (index > 0) json += \",\";\n json += `${encodedKey}:${visit(value[key], depth + 1)}`;\n }\n\n return `${json}}`;\n };\n\n return visit(value, 0);\n};\n\nexport const canonicalJson = (value: Schema.Json): string => serialize(value);\n\nexport const boundedCanonicalJson = (\n value: Schema.Json,\n limits: JsonLimits,\n): Result.Result<string, CanonicalJsonLimitError> => {\n try {\n return Result.succeed(serialize(value, limits));\n } catch (cause) {\n const message = Predicate.isObjectKeyword(cause) ? boundsFailures.get(cause) : undefined;\n\n if (message !== undefined) return Result.fail(CanonicalJsonLimitError.make({ message }));\n // oxlint-disable-next-line effect/no-untyped-throw -- Foreign JSON/getter errors retain their identity for the caller's typed capture boundary.\n throw cause;\n }\n};\n","import type { PlatformError } from \"effect\";\nimport { Crypto, Effect, Schema } from \"effect\";\nimport { Hex } from \"effect/encoding\";\n\nimport { canonicalJson as stringifyCanonicalJson } from \"./internal/canonical-json.ts\";\nimport type { DefinitionDigestInput } from \"./Records.ts\";\nimport { DefinitionDigests, Digest } from \"./Records.ts\";\n\n/** Measure persisted text without allocating a UTF-8 copy. */\nexport { utf8ByteLength } from \"../core/internal/utf8.ts\";\n\nexport class DigestError extends Schema.TaggedError<DigestError>()(\"DigestError\", {\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n}) {}\n\nconst utf8 = new TextEncoder();\nconst decodeDigest = Schema.decodeEffect(Digest);\n\n/** Serialize schema-encoded JSON with the canonical digest's locale-independent key order. */\nexport const canonicalJson = (value: Schema.Json): string => stringifyCanonicalJson(value);\n\nconst digestText = Effect.fnUntraced(function* (\n value: string,\n): Effect.fn.Return<Digest, DigestError, Crypto.Crypto> {\n const crypto = yield* Crypto.Crypto;\n\n const bytes = utf8.encode(value);\n\n const digest = yield* crypto\n .digest(\"SHA-256\", bytes)\n .pipe(\n Effect.mapError((error: PlatformError.PlatformError) =>\n DigestError.make({ message: `SHA-256 failed: ${error.message}`, cause: error }),\n ),\n );\n\n return yield* decodeDigest(Hex.encode(digest)).pipe(\n Effect.mapError(() => DigestError.make({ message: \"SHA-256 returned an invalid digest\" })),\n );\n});\n\n/** Digest a JSON value using a stable, locale-independent object-key ordering (UTF-16 code units, RFC 8785 style). */\nexport const digestJson = (value: Schema.Json): Effect.Effect<Digest, DigestError, Crypto.Crypto> =>\n Effect.suspend(() => digestText(canonicalJson(value)));\n\n/** Hash captured canonical JSON directly, sharing its encoding with accounting and storage. */\nexport const digestCanonicalJson = (json: string) => digestText(json);\n\n/** Digest one schema-encoded Agent, Model, or Toolkit definition. */\nexport const digestDefinition = (definition: Schema.Json) => digestJson(definition);\n\n/** Digest all replay-relevant definitions without hiding which authority changed. */\nexport const digestDefinitions = (\n definitions: DefinitionDigestInput,\n): Effect.Effect<DefinitionDigests, DigestError, Crypto.Crypto> =>\n Effect.all({\n agent: digestDefinition(definitions.agent),\n model: digestDefinition(definitions.model),\n tools: digestDefinition(definitions.tools),\n }).pipe(Effect.map((digests) => DefinitionDigests.make(digests)));\n"],"mappings":"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"}
1
+ {"version":3,"file":"Digest-ft4ku9pj.mjs","names":["canonicalJson","stringifyCanonicalJson"],"sources":["../src/durable/internal/canonical-json.ts","../src/durable/Digest.ts"],"sourcesContent":["import { Array, Predicate, Result, Schema } from \"effect\";\n\ninterface JsonLimits {\n readonly depth: number;\n readonly nodes: number;\n readonly collectionLength: number;\n readonly textUnits: number;\n}\n\nexport class CanonicalJsonLimitError extends Schema.TaggedError<CanonicalJsonLimitError>()(\n \"CanonicalJsonLimitError\",\n { message: Schema.String },\n) {}\n\n// Only this codec's private synchronous aborts become typed bounds failures.\nconst boundsFailures = new WeakMap<object, string>();\n\nconst exceeded = (bound: \"text\" | \"traversal\" | \"collection\"): never => {\n const message = `Canonical JSON exceeds its ${bound} bound`;\n // oxlint-disable-next-line effect/no-native-error -- Private synchronous codec abort; the Result boundary translates only errors owned here.\n const error = new RangeError(message);\n\n boundsFailures.set(error, message);\n // oxlint-disable-next-line effect/no-untyped-throw -- Abort synchronous JSON traversal at the first exceeded bound; the Result boundary catches this owned error.\n throw error;\n};\n\n/** Values have already crossed their Schema boundary; visit each serialized occurrence. */\nconst serialize = (value: Schema.Json, limits?: JsonLimits): string => {\n let nodes = 0;\n let textUnits = 0;\n\n const charge = (length: number) => {\n if (limits !== undefined && (textUnits += length) > limits.textUnits) return exceeded(\"text\");\n };\n\n const visit = (value: Schema.Json, depth: number): string => {\n if (limits !== undefined && (depth > limits.depth || ++nodes > limits.nodes))\n return exceeded(\"traversal\");\n if (\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"number\" ||\n typeof value === \"string\"\n ) {\n const encoded = JSON.stringify(value);\n\n charge(encoded.length);\n\n return encoded;\n }\n if (Array.isArray<Schema.Json>(value)) {\n if (limits !== undefined && value.length > limits.collectionLength)\n return exceeded(\"collection\");\n charge(2 + Math.max(0, value.length - 1));\n\n let json = \"[\";\n\n for (let index = 0; index < value.length; index++) {\n if (index > 0) json += \",\";\n json += visit(value[index], depth + 1);\n }\n\n return `${json}]`;\n }\n\n const keys = Object.keys(value).sort();\n\n if (limits !== undefined && keys.length > limits.collectionLength)\n return exceeded(\"collection\");\n charge(2 + Math.max(0, keys.length - 1));\n let json = \"{\";\n\n for (let index = 0; index < keys.length; index++) {\n const key = keys[index];\n const encodedKey = JSON.stringify(key);\n\n charge(encodedKey.length + 1);\n if (index > 0) json += \",\";\n json += `${encodedKey}:${visit(value[key], depth + 1)}`;\n }\n\n return `${json}}`;\n };\n\n return visit(value, 0);\n};\n\nexport const canonicalJson = (value: Schema.Json): string => serialize(value);\n\nexport const boundedCanonicalJson = (\n value: Schema.Json,\n limits: JsonLimits,\n): Result.Result<string, CanonicalJsonLimitError> => {\n try {\n return Result.succeed(serialize(value, limits));\n } catch (cause) {\n const message = Predicate.isObjectKeyword(cause) ? boundsFailures.get(cause) : undefined;\n\n if (message !== undefined) return Result.fail(CanonicalJsonLimitError.make({ message }));\n // oxlint-disable-next-line effect/no-untyped-throw -- Foreign JSON/getter errors retain their identity for the caller's typed capture boundary.\n throw cause;\n }\n};\n","import type { PlatformError } from \"effect\";\nimport { Crypto, Effect, Schema } from \"effect\";\nimport { Hex } from \"effect/encoding\";\n\nimport { canonicalJson as stringifyCanonicalJson } from \"./internal/canonical-json.ts\";\nimport type { DefinitionDigestInput } from \"./Records.ts\";\nimport { DefinitionDigests, Digest } from \"./Records.ts\";\n\n/** Measure persisted text without allocating a UTF-8 copy. */\nexport { utf8ByteLength } from \"../core/internal/utf8.ts\";\n\nexport class DigestError extends Schema.TaggedError<DigestError>()(\"DigestError\", {\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n}) {}\n\nconst utf8 = new TextEncoder();\nconst decodeDigest = Schema.decodeEffect(Digest);\n\n/** Serialize schema-encoded JSON with the canonical digest's locale-independent key order. */\nexport const canonicalJson = (value: Schema.Json): string => stringifyCanonicalJson(value);\n\nconst digestText = Effect.fnUntraced(function* (\n value: string,\n): Effect.fn.Return<Digest, DigestError, Crypto.Crypto> {\n const crypto = yield* Crypto.Crypto;\n\n const bytes = utf8.encode(value);\n\n const digest = yield* crypto\n .digest(\"SHA-256\", bytes)\n .pipe(\n Effect.mapError((error: PlatformError.PlatformError) =>\n DigestError.make({ message: `SHA-256 failed: ${error.message}`, cause: error }),\n ),\n );\n\n return yield* decodeDigest(Hex.encode(digest)).pipe(\n Effect.mapError(() => DigestError.make({ message: \"SHA-256 returned an invalid digest\" })),\n );\n});\n\n/** Digest a JSON value using a stable, locale-independent object-key ordering (UTF-16 code units, RFC 8785 style). */\nexport const digestJson = (value: Schema.Json): Effect.Effect<Digest, DigestError, Crypto.Crypto> =>\n Effect.suspend(() => digestText(canonicalJson(value)));\n\n/** Hash captured canonical JSON directly, sharing its encoding with accounting and storage. */\nexport const digestCanonicalJson = (json: string) => digestText(json);\n\n/** Digest one schema-encoded Agent, Model, or Toolkit definition. */\nexport const digestDefinition = (definition: Schema.Json) => digestJson(definition);\n\n/** Digest all replay-relevant definitions without hiding which authority changed. */\nexport const digestDefinitions = (\n definitions: DefinitionDigestInput,\n): Effect.Effect<DefinitionDigests, DigestError, Crypto.Crypto> =>\n Effect.all({\n agent: digestDefinition(definitions.agent),\n model: digestDefinition(definitions.model),\n tools: digestDefinition(definitions.tools),\n }).pipe(Effect.map((digests) => DefinitionDigests.make(digests)));\n"],"mappings":"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"}
@@ -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-DGblbFas.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, 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-BC4V-mY-.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 { H as ThreadRead, I as ThreadIdentityRequest, L as ThreadMaterialization, V as ThreadPromptRead, W as ThreadReader, X as ThreadStoreDiagnostic, Y as ThreadStore, Z as ThreadStoreError, _t as executionRunIds, ct as getRunInput, et as ThreadTailRequest, gt as canonicalRunIds, m as MAX_THREAD_EXPORT_PAGE_BYTES, mt as captureRecord, n as AppendRequest, st as getRecord, ut as readWorkerState, vt as isPreContinuationFact, xt as terminalUsageCharge, z as ThreadObservation } from "./ThreadStore-D2rqtt7k.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-CWHuciup.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-BF95Ncv2.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-C47Vy_cK.mjs";
43
+ import { c as threadCreatedBatchId, l as threadCreatedRecordId, n as WorkerAdmissionPort, o as ensureThreadCreated, r as WorkerAdmissionRequest, s as ensureWorkerOrigin } from "./WorkerAdmission-CtX1HRkm.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-BF2YgWkg.mjs";
47
+ import { o as makeRunWriter, r as RunStorage, s as StorageOwner } from "./RunStorage-DlfvMfHM.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
  })
@@ -870,10 +894,19 @@ const makeCommittedPromptSuffix = (original) => {
870
894
  discard();
871
895
  return;
872
896
  }
897
+ const record = payload._tag === "UserInputRecorded" ? {
898
+ recordId: owned.canonical.recordId,
899
+ payload: {
900
+ _tag: payload._tag,
901
+ kind: payload.kind,
902
+ ...payload.runId === void 0 ? {} : { runId: payload.runId },
903
+ ...payload.submissionId === void 0 ? {} : { submissionId: payload.submissionId }
904
+ }
905
+ } : decodeCommittedPromptRecord(owned.wire);
873
906
  const entry = {
874
907
  threadId: original.threadId,
875
908
  sequence: CanonicalSequence.make(through + 1),
876
- record: decodeCommittedPromptRecord(owned.wire)
909
+ record
877
910
  };
878
911
  const footprint = suffixRecordFootprint(entry, remaining);
879
912
  if (footprint === void 0) {
@@ -1625,7 +1658,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
1625
1658
  ...admission.origin.continuationOf === void 0 ? {} : { continuationOf: admission.origin.continuationOf }
1626
1659
  });
1627
1660
  yield* authorizeBudget(admission.origin, options.principal, authorization);
1628
- 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");
1661
+ 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");
1629
1662
  const retainedFrameworkInput = Schema.is(FrameworkMessage)(options.messageAdmission);
1630
1663
  if (retainedFrameworkInput && admission.reportKind !== "update") yield* validateCompletion(options.messageAdmission, options, agentId, inputDigest);
1631
1664
  yield* reservation(admission, inputDigest, input, options.principal, retainedFrameworkInput, authorization);
@@ -1642,7 +1675,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
1642
1675
  const sourceBinding = currentBinding(origin.source.agentId);
1643
1676
  const targetBinding = currentBinding(origin.worker.targetAgentId);
1644
1677
  const reports = sourceBinding?.reporting?.filter((entry) => entry.delegationId === origin.worker.delegationId) ?? [];
1645
- 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");
1678
+ 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");
1646
1679
  const receivingOrigin = retained?.origin;
1647
1680
  if (destination.depth !== 0 && receivingOrigin === void 0) return yield* failure("followUp", "denied");
1648
1681
  const now = yield* Clock.currentTimeMillis;
@@ -2329,7 +2362,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
2329
2362
  return {
2330
2363
  worker: origin.worker,
2331
2364
  latestReceipt: acceptedInput?.receipt ?? null,
2332
- state: control.terminal ?? (control.stopped ? control.active === null ? "stopped" : "stopping" : control.active !== null ? "active" : delivery !== void 0 ? "starting" : "idle"),
2365
+ state: control.terminal ?? (control.stopped ? control.active === null ? "stopped" : "stopping" : control.active !== null ? control.active.state === "unknown" ? "unknown" : "active" : delivery !== void 0 ? "starting" : "idle"),
2333
2366
  acceptedInput,
2334
2367
  appliedInput,
2335
2368
  run,
@@ -2648,7 +2681,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
2648
2681
  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;
2649
2682
  if (frozen === void 0) return yield* failure("followUp", "denied");
2650
2683
  const envelope = yield* Schema.decodeUnknownEffect(PreparedInput)(frozen).pipe(Effect.mapError((cause) => failure("followUp", "corrupt", cause)));
2651
- 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");
2684
+ 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");
2652
2685
  const recorded = Option.getOrUndefined(yield* exactRecord(childThreadId, workerOriginRecordId(childThreadId), "followUp"))?.record.payload;
2653
2686
  if (recorded?._tag !== "WorkerOriginRecorded" || recorded.origin.worker.threadId !== childThreadId || recorded.origin.reporting?.mode !== "standard") return yield* failure("followUp", "denied");
2654
2687
  const origin = recorded.origin;
@@ -3972,6 +4005,19 @@ const make = Effect.fnUntraced(function* (bindings) {
3972
4005
  yield* hit("tools:after-unavailable-append");
3973
4006
  recovered += 1;
3974
4007
  });
4008
+ if ((intent === void 0 || intent.resolution._tag === "SafeToRetry") && declared !== void 0 && nativeUpdateAccepted(submission, declared, records)) {
4009
+ yield* appendClosedCall(ctx, submissionId, knownIds, call, {
4010
+ result: {
4011
+ value: { emitted: true },
4012
+ isFailure: false
4013
+ },
4014
+ resolution: "completed-with-result",
4015
+ author: RECONCILER_AUTHOR,
4016
+ reason: "The exact native update was canonically accepted"
4017
+ });
4018
+ recovered += 1;
4019
+ continue;
4020
+ }
3975
4021
  if (intent !== void 0) switch (intent.resolution._tag) {
3976
4022
  case "AbortSubmission": continue;
3977
4023
  case "CompletedWithResult":
@@ -4446,7 +4492,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4446
4492
  case "Admitted": {
4447
4493
  const child = resolution.submission;
4448
4494
  const linkage = child.parentLinkage;
4449
- 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({
4495
+ 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({
4450
4496
  operation: "establishChildFromRequest",
4451
4497
  message: `The admitted child ${child.submissionId} diverges from the canonical SubagentRequested record for Tool Call ${request.toolCallId}; establishment fails closed (SUB-016)`
4452
4498
  });
@@ -4524,7 +4570,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4524
4570
  const child = childLookup.value;
4525
4571
  if (child.threadId !== request.childThreadId) return mismatch("The child Thread does not match the intended child identity");
4526
4572
  if (child.agentId !== request.targetAgentId) return mismatch("The child Agent identity does not match the declared delegation target");
4527
- if (!definitionDigestsEqual(child.agentDigests, request.targetDigests)) return mismatch("The child definition digests do not match the stored target digests");
4573
+ if (!definitionDigestsEqual$1(child.agentDigests, request.targetDigests)) return mismatch("The child definition digests do not match the stored target digests");
4528
4574
  if (child.inputDigest !== request.childInputDigest) return mismatch("The child input digest does not match the canonical request");
4529
4575
  const linkage = child.parentLinkage;
4530
4576
  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");
@@ -4532,7 +4578,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4532
4578
  const lineage = childRecords.find((envelope) => envelope.record.recordId === subagentLineageRecordId(request.childThreadId))?.record.payload;
4533
4579
  if (lineage === void 0 || lineage._tag !== "SubagentLineageRecorded") return mismatch("The child Thread carries no immutable lineage record");
4534
4580
  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");
4535
- 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");
4581
+ 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");
4536
4582
  const settlement = childRecords.find((envelope) => envelope.record.recordId === submissionSettlementRecordId(childSubmissionId))?.record.payload;
4537
4583
  if (settlement === void 0 || settlement._tag !== "SubmissionSettled") return mismatch("The child has no canonical Settlement record");
4538
4584
  if (settlement.submissionId !== childSubmissionId || settlement.settlementId !== submissionSettlementId(childSubmissionId) || settlement.receiptId !== child.receiptId) return mismatch("The child Settlement identity does not match the child Receipt");
@@ -4989,7 +5035,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4989
5035
  * precedes its terminal-only completion batch, so recovery can repeat a pure output projection
4990
5036
  * without replaying the handler. Pending batches resume from their canonical declarations.
4991
5037
  */
4992
- function* (agent, ctx, submission, session, records, canonical, initialJournal, canonicalThrough, progressThrough, continuation, priorContext, journalMetadata, lineage, approvalDecisions, currentContracts, runTiming, yieldAfter) {
5038
+ function* (agent, ctx, submission, session, records, canonical, initialJournal, canonicalThrough, progressThrough, continuation, priorContext, operational, journalMetadata, lineage, approvalDecisions, currentContracts, runTiming, yieldAfter) {
4993
5039
  const submissionId = submission.submissionId;
4994
5040
  const runId = runIdForSubmission(submissionId);
4995
5041
  const boundaries = [];
@@ -5046,7 +5092,7 @@ const make = Effect.fnUntraced(function* (bindings) {
5046
5092
  const inheritedGrant = submission.workerAdmission?.origin.grant ?? (childLineage?._tag === "SubagentLineageRecorded" ? childLineage.grant : void 0);
5047
5093
  const delegationDepth = submission.workerAdmission?.origin.depth ?? (childLineage?._tag === "SubagentLineageRecorded" ? childLineage.parentLink.depth : 0);
5048
5094
  const inheritedBudget = submission.workerAdmission?.origin.budget ?? (childLineage?._tag === "SubagentLineageRecorded" ? childLineage.budget : void 0);
5049
- 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" });
5095
+ 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" });
5050
5096
  const completionTools = [...agent.definition.completion === void 0 ? [] : [agent.definition.completion.tool], ...agent.definition.completionFromTools?.map((declaration) => declaration.tool) ?? []];
5051
5097
  const pending = yield* pendingToolBatchFor(records, runId, completionTools);
5052
5098
  const resumeProjection = pending === void 0 ? journal : yield* projectRunJournalStream(withoutPendingBatch(canonical, pending, runId), runId, void 0, priorContext);
@@ -5197,11 +5243,7 @@ const make = Effect.fnUntraced(function* (bindings) {
5197
5243
  cause
5198
5244
  })));
5199
5245
  });
5200
- const activeExecution = yield* reader.readExecution({
5201
- threadId: ctx.threadId,
5202
- runId
5203
- });
5204
- const recordedCompletion = Option.isSome(activeExecution) ? activeExecution.value.operational.find((record) => record.recordId === runCompletedRecordId(runId))?.payload : void 0;
5246
+ const recordedCompletion = operational.find((record) => record.recordId === runCompletedRecordId(runId))?.payload;
5205
5247
  if (recordedCompletion !== void 0) {
5206
5248
  if (recordedCompletion._tag !== "RunCompleted" || recordedCompletion.runId !== runId) return yield* RunJournalError.make({ message: `Run ${runId} has an invalid terminal completion marker` });
5207
5249
  const response = [...records].reverse().find((envelope) => envelope.record.payload._tag === "ModelResponseRecorded" && envelope.record.payload.runId === runId)?.record.payload;
@@ -6322,12 +6364,12 @@ const make = Effect.fnUntraced(function* (bindings) {
6322
6364
  }),
6323
6365
  ...runContextPreparation.transientContext === void 0 ? {} : { transientContext: runContextPreparation.transientContext },
6324
6366
  ...config.estimateCostMicrousd === void 0 ? {} : { estimateCostMicrousd: config.estimateCostMicrousd },
6325
- resumeUsage: {
6367
+ ...freshPrefix !== void 0 && continuation === void 0 ? {} : { resumeUsage: {
6326
6368
  ...journal.usage,
6327
6369
  ...journal.policyUsage,
6328
6370
  ...journal.usage.modelCalls === 0 && (journal.usage.unobservedModelCalls ?? 0) === 0 && !records.some(({ record }) => record.payload._tag === "ModelResponseInterrupted" && record.payload.runId === runId) ? emptyRunTotals() : runTotalsFromSummary(yield* currentUsageSummary()),
6329
6371
  children: childUsageReportsOf(subagentState)
6330
- },
6372
+ } },
6331
6373
  ...journal.contextWindowId === void 0 ? {} : { initialContextWindowId: journal.contextWindowId },
6332
6374
  ...journal.protectedContext === void 0 ? {} : { protectedContext: journal.protectedContext },
6333
6375
  ...pendingContextToolCallId === void 0 ? {} : { pendingContextToolCallId }
@@ -6494,62 +6536,37 @@ const make = Effect.fnUntraced(function* (bindings) {
6494
6536
  session = yield* withProgressSession(promptSession, () => pendingOriginal);
6495
6537
  const { claim, threadId } = session;
6496
6538
  const submissionId = claim.submissionId;
6497
- let prepared = freshlyAdmitted && session.withInitialization !== void 0 ? yield* session.withInitialization(Effect.gen(function* () {
6498
- const snapshot = yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId }));
6499
- const submission = snapshot.submission;
6500
- if (submission.state !== "ready" || submission.workerAdmission !== void 0 || submission.messageAdmission !== void 0 || submission.parentLinkage !== void 0 || snapshot.inputApplied !== void 0 || snapshot.abortIntent !== void 0 || snapshot.approvalDecisions.length !== 0) return void 0;
6501
- yield* ensureThreadCreated$1(threadId, submission.agentId, submission.agentDigests);
6502
- yield* session.refresh;
6503
- const before = (yield* session.tail).sequence;
6504
- const view = yield* recoveryView(threadId, before, [submissionId], runIdForSubmission(submissionId));
6505
- if (view.progress !== void 0 || view.context !== void 0 || view.operational.length !== 0 || view.records.some(({ record }) => record.payload._tag !== "ThreadCreated")) return void 0;
6506
- if (session.appendInput !== void 0) {
6507
- const record = (yield* PreparedAppend.capture(AppendRequest.make({
6508
- threadId,
6509
- expectedTailSequence: before,
6510
- batch: CanonicalBatch.make({
6511
- batchId: submissionInputBatchId(submissionId),
6512
- producerId: config.producerId,
6513
- records: [yield* prepareOriginalInput(submission)]
6514
- })
6515
- }))).records[0].canonical;
6516
- if (!isOriginalInputRecord(record)) return yield* RunJournalError.make({ message: "Captured startup has no original input" });
6517
- pendingOriginal = {
6518
- threadId,
6519
- sequence: CanonicalSequence.make(before + 1),
6520
- record
6521
- };
6522
- return {
6523
- snapshot,
6524
- through: before,
6525
- view,
6526
- start: yield* makeRunStart(submission, Duration.toMillis(registeredAgent.definition.policy.maxDuration), view.records, view.operational, record).pipe(Effect.provideService(CurrentRunWriter, session)),
6527
- input: pendingOriginal
6528
- };
6529
- }
6530
- const progress = progressWriters.get(session);
6531
- const applyInput = applyCanonicalInput(session, submission, session, view.records, void 0);
6532
- yield* progress === void 0 ? applyInput : progress.withVerifiedEmptyRun(runIdForSubmission(submissionId), before, applyInput).pipe(Effect.provideService(CurrentRunWriter, promptSession));
6533
- const through = (yield* session.tail).sequence;
6534
- const added = yield* selectedRange(threadId, [submissionId], through, before);
6535
- const records = [...view.records, ...added];
6536
- const accepted = progressWriters.get(session)?.acceptedCheckpoint(runIdForSubmission(submissionId));
6537
- if (accepted === void 0 || accepted.throughSequence !== through || accepted.progress.runId !== runIdForSubmission(submissionId) || accepted.progress.submissionId !== submissionId) return void 0;
6538
- const start = yield* makeRunStart(submission, Duration.toMillis(registeredAgent.definition.policy.maxDuration), records, view.operational).pipe(Effect.provideService(CurrentRunWriter, session));
6539
- return {
6539
+ const preparation = freshlyAdmitted ? yield* session.prepareStart ?? Effect.void : void 0;
6540
+ let prepared;
6541
+ if (preparation !== void 0) {
6542
+ const { snapshot, identity } = preparation;
6543
+ const before = identity.tailSequence;
6544
+ const record = (yield* Effect.fromResult(captureRecord(yield* prepareOriginalInput(snapshot.submission))).pipe(Effect.mapError((cause) => ThreadStoreError.make({
6545
+ operation: "capture startup input",
6546
+ message: cause.message,
6547
+ cause
6548
+ })))).canonical;
6549
+ if (!isOriginalInputRecord(record)) return yield* RunJournalError.make({ message: "Captured startup has no original input" });
6550
+ pendingOriginal = {
6551
+ threadId,
6552
+ sequence: CanonicalSequence.make(before + 1),
6553
+ record
6554
+ };
6555
+ const view = {
6556
+ records: identity.records,
6557
+ context: void 0,
6558
+ progress: void 0,
6559
+ progressThrough: void 0,
6560
+ operational: []
6561
+ };
6562
+ prepared = {
6540
6563
  snapshot,
6541
- through,
6542
- view: {
6543
- ...view,
6544
- records,
6545
- progress: accepted.progress,
6546
- progressThrough: accepted.throughSequence,
6547
- operational: accepted.operational
6548
- },
6549
- start,
6550
- input: void 0
6564
+ through: before,
6565
+ view,
6566
+ start: yield* makeRunStart(snapshot.submission, Duration.toMillis(registeredAgent.definition.policy.maxDuration), view.records, view.operational, record).pipe(Effect.provideService(CurrentRunWriter, session)),
6567
+ input: pendingOriginal
6551
6568
  };
6552
- })) : void 0;
6569
+ }
6553
6570
  const preparedInput = prepared !== void 0;
6554
6571
  const snapshot = prepared?.snapshot ?? (yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId })));
6555
6572
  const submission = snapshot.submission;
@@ -6772,7 +6789,7 @@ const make = Effect.fnUntraced(function* (bindings) {
6772
6789
  }
6773
6790
  committedPromptSuffix?.discard();
6774
6791
  committedPromptSuffix = initialJournal?.cacheable && initialization?.input === void 0 ? makeCommittedPromptSuffix(initialJournal.original) : void 0;
6775
- 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(() => {
6792
+ const outcome = yield* runModel(agent, ctx, submission, session, currentRecords, canonical, initialJournal, initialization?.input?.sequence ?? tail.sequence, view.progressThrough, view.progress, view.context, view.operational, takeJournalMetadata(), lineage, approvalDecisionIntents, currentContracts, runTiming, yieldAfter).pipe(Effect.provideService(CurrentRunStart, start.publication), Effect.ensuring(Effect.sync(() => {
6776
6793
  if (initialJournal !== void 0) initialJournal.records = void 0;
6777
6794
  })));
6778
6795
  if (outcome._tag === "yielded") {
@@ -7052,6 +7069,7 @@ const make = Effect.fnUntraced(function* (bindings) {
7052
7069
  const declared = yield* declaredCallsFor(records, runIdForSubmission(submission.submissionId), new Set(intents.map((intent) => intent.toolCallId)));
7053
7070
  for (const intent of intents) {
7054
7071
  const original = declared.get(intent.toolCallId);
7072
+ if (original !== void 0 && nativeUpdateAccepted(submission, original, records)) continue;
7055
7073
  if (original === void 0 || current !== void 0 && !supportsOperation(OpenToolCallEvidence.make(original), operations.get(intent.toolCallId), current)) return true;
7056
7074
  }
7057
7075
  return false;
@@ -7135,7 +7153,31 @@ const make = Effect.fnUntraced(function* (bindings) {
7135
7153
  case "ResumePendingToolBatch": return "deferred";
7136
7154
  case "MarkUnknown": return yield* markUnknownForRecovery(snapshot, evidence, records, decision);
7137
7155
  case "ApplyUnknownResolutions": return yield* applyUnknownResolutionsForRecovery(snapshot, evidence, records);
7138
- case "AwaitUnknownResolution": return "unknown";
7156
+ case "AwaitUnknownResolution": {
7157
+ const declared = yield* declaredCallsFor(records, runId, new Set(evidence.openToolCalls.map((call) => call.toolCallId)));
7158
+ let repaired = false;
7159
+ for (const call of declared.values()) {
7160
+ if (snapshot.unknownResolutions.some((intent) => intent.toolCallId === call.toolCallId) || !nativeUpdateAccepted(submission, call, records)) continue;
7161
+ yield* ledger.recordUnknownResolution(UnknownResolutionCommand.make({
7162
+ submissionId: submission.submissionId,
7163
+ toolCallId: call.toolCallId,
7164
+ author: RECONCILER_AUTHOR,
7165
+ reason: "The exact native update was canonically accepted",
7166
+ resolution: {
7167
+ _tag: "CompletedWithResult",
7168
+ result: { emitted: true },
7169
+ isFailure: false
7170
+ }
7171
+ })).pipe(Effect.catchTag("UnknownResolutionConflict", (cause) => LedgerError.make({
7172
+ operation: "recover native update",
7173
+ message: "Native acceptance conflicts with a retained resolution",
7174
+ cause
7175
+ })));
7176
+ repaired = true;
7177
+ }
7178
+ if (repaired) yield* wake.notify(submission.threadId);
7179
+ return repaired ? "repaired" : "unknown";
7180
+ }
7139
7181
  case "AwaitApprovalDecision": return yield* awaitApprovalForRecovery(snapshot, evidence, decision);
7140
7182
  case "ResumeSuspended": return yield* resumeSuspendedForRecovery(snapshot);
7141
7183
  case "RevertJoining":
@@ -7429,12 +7471,16 @@ const make = Effect.fnUntraced(function* (bindings) {
7429
7471
  if (selected.state.settled || selected.state.resolved) return "none";
7430
7472
  const intent = (yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId: submission.submissionId }))).unknownResolutions.find((intent) => intent.toolCallId === selected.declared.toolCallId && unknownResolutionKind(intent.resolution) === "factual");
7431
7473
  const factual = intent?.resolution;
7432
- const reconciliation = factual === void 0 && selected.declared.executionKind === "ordinary" ? yield* reconciler.reconcile(DeclaredToolCallEvidence.make({
7474
+ const acceptedNative = factual === void 0 && (yield* updateRuntime.accepted(submission, selected.declared));
7475
+ const reconciliation = factual === void 0 && !acceptedNative && selected.declared.executionKind === "ordinary" ? yield* reconciler.reconcile(DeclaredToolCallEvidence.make({
7433
7476
  threadId,
7434
7477
  submissionId: submission.submissionId,
7435
7478
  ...selected.declared
7436
7479
  })).pipe(Effect.map(Option.some), Effect.catchTag("ToolReconcilerError", () => Effect.succeed(Option.none()))) : Option.none();
7437
- const completed = factual?._tag === "CompletedWithResult" ? factual : Option.isSome(reconciliation) && reconciliation.value._tag === "CompletedWithResult" ? reconciliation.value : void 0;
7480
+ const completed = factual?._tag === "CompletedWithResult" ? factual : acceptedNative ? {
7481
+ result: { emitted: true },
7482
+ isFailure: false
7483
+ } : Option.isSome(reconciliation) && reconciliation.value._tag === "CompletedWithResult" ? reconciliation.value : void 0;
7438
7484
  const neverStarted = factual?._tag === "NeverHappened" || selected.state.dispatchBlocked || Option.isSome(reconciliation) && reconciliation.value._tag === "NeverStarted";
7439
7485
  if (completed === void 0 && !neverStarted) return "unknown";
7440
7486
  const result = completed === void 0 ? yield* Schema.encodeEffect(ToolUnavailable)(ToolUnavailable.make({
@@ -7815,13 +7861,13 @@ const make = Effect.fnUntraced(function* (bindings) {
7815
7861
  code: `message-${cause.reason}`,
7816
7862
  cause
7817
7863
  })));
7818
- 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))) {
7864
+ 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))) {
7819
7865
  const retained = yield* ledger.lookup(SubmissionLookupByKey.make({
7820
7866
  threadId: options.threadId,
7821
7867
  principal: options.principal,
7822
7868
  idempotencyKey: options.idempotencyKey
7823
7869
  }));
7824
- if (Option.isNone(retained) || retained.value.agentId !== agent.definition.id || !definitionDigestsEqual(retained.value.agentDigests, options.definitions)) return yield* AdmissionPolicyError.make({
7870
+ if (Option.isNone(retained) || retained.value.agentId !== agent.definition.id || !definitionDigestsEqual$1(retained.value.agentDigests, options.definitions)) return yield* AdmissionPolicyError.make({
7825
7871
  reason: "refused",
7826
7872
  code: "unregistered-replay-contract"
7827
7873
  });
@@ -8494,4 +8540,4 @@ var DurableAgentRuntime = class DurableAgentRuntime extends Context.Service()("@
8494
8540
  //#endregion
8495
8541
  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 };
8496
8542
 
8497
- //# sourceMappingURL=DurableAgentRuntime-BJbuIqQq.mjs.map
8543
+ //# sourceMappingURL=DurableAgentRuntime-CWhu1exp.mjs.map