@yielded/agent 0.1.0-beta.176 → 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 (180) hide show
  1. package/dist/{Admin-DTDihBra.d.mts → Admin-Bpg24yCK.d.mts} +7 -7
  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-CGW93k81.mjs} +98 -32
  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-Cc58uEso.d.mts → EventSource-A6TB7t-f.d.mts} +2 -2
  13. package/dist/{MessageDelivery-ClHg7c0O.d.mts → MessageDelivery-BkWrcQUd.d.mts} +42 -42
  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-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-DSnUTSSb.d.mts → RunContinuation-Ce2pR8VD.d.mts} +3 -3
  22. package/dist/{RunContinuation-CWHuciup.mjs → RunContinuation-D42RFqjS.mjs} +5 -5
  23. package/dist/{RunContinuation-CWHuciup.mjs.map → RunContinuation-D42RFqjS.mjs.map} +1 -1
  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-BRGP3Tcu.mjs} +2 -2
  28. package/dist/{RunStorage-BF2YgWkg.mjs.map → RunStorage-BRGP3Tcu.mjs.map} +1 -1
  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-D5sOrmlI.d.mts} +2 -2
  36. package/dist/{SubscriptionInput-B1IeAEDi.d.mts → SubscriptionInput-CxSXZUiC.d.mts} +2 -2
  37. package/dist/{ThreadImport-D_Biid6w.d.mts → ThreadImport-C6IiPJMW.d.mts} +4 -4
  38. package/dist/{ThreadImport-ZgWxf7bB.mjs → ThreadImport-DUcPj5jC.mjs} +9 -9
  39. package/dist/{ThreadImport-ZgWxf7bB.mjs.map → ThreadImport-DUcPj5jC.mjs.map} +1 -1
  40. package/dist/{ThreadStore-BC4V-mY-.mjs → ThreadStore-Cn6FDWX9.mjs} +5 -5
  41. package/dist/{ThreadStore-BC4V-mY-.mjs.map → ThreadStore-Cn6FDWX9.mjs.map} +1 -1
  42. package/dist/{ThreadTransfer-S7FnTRHt.mjs → ThreadTransfer-BWnAHIge.mjs} +4 -4
  43. package/dist/{ThreadTransfer-S7FnTRHt.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-C47Vy_cK.mjs → WorkerAdmission-cfiK9aRi.mjs} +6 -6
  48. package/dist/{WorkerAdmission-C47Vy_cK.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/SubmissionLedgerConformance.d.mts +1 -1
  112. package/dist/durable/SubmissionLedgerConformance.mjs +7 -7
  113. package/dist/durable/SubmissionStatus.d.mts +1 -1
  114. package/dist/durable/Subscription.d.mts +1 -1
  115. package/dist/durable/Subscription.mjs +2 -2
  116. package/dist/durable/SubscriptionInput.d.mts +1 -1
  117. package/dist/durable/SubscriptionInput.mjs +2 -2
  118. package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
  119. package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
  120. package/dist/durable/SubscriptionTools.d.mts +3 -3
  121. package/dist/durable/SubscriptionTools.mjs +2 -1
  122. package/dist/durable/SubscriptionTools.mjs.map +1 -1
  123. package/dist/durable/SubscriptionTransition.d.mts +1 -1
  124. package/dist/durable/SubscriptionTransition.mjs +1 -1
  125. package/dist/durable/Subscriptions.d.mts +5 -5
  126. package/dist/durable/Subscriptions.mjs +2 -2
  127. package/dist/durable/ThreadArchiveRange.d.mts +1 -1
  128. package/dist/durable/ThreadArchiveRange.mjs +1 -1
  129. package/dist/durable/ThreadContextHistory.d.mts +1 -1
  130. package/dist/durable/ThreadContextHistory.mjs +2 -2
  131. package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
  132. package/dist/durable/ThreadImport.d.mts +1 -1
  133. package/dist/durable/ThreadImport.mjs +1 -1
  134. package/dist/durable/ThreadInvariants.d.mts +3 -3
  135. package/dist/durable/ThreadInvariants.mjs +4 -4
  136. package/dist/durable/ThreadProjection.mjs +1 -1
  137. package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
  138. package/dist/durable/ThreadReader.d.mts +1 -1
  139. package/dist/durable/ThreadReader.mjs +1 -1
  140. package/dist/durable/ThreadStore.d.mts +1 -1
  141. package/dist/durable/ThreadStore.mjs +2 -2
  142. package/dist/durable/ThreadStoreConformance.d.mts +1 -1
  143. package/dist/durable/ThreadStoreConformance.mjs +4 -4
  144. package/dist/durable/ThreadTransfer.d.mts +1 -1
  145. package/dist/durable/ThreadTransfer.mjs +1 -1
  146. package/dist/durable/ThreadWork.d.mts +1 -1
  147. package/dist/durable/ThreadWork.mjs +5 -5
  148. package/dist/durable/ToolReconciler.mjs +1 -1
  149. package/dist/durable/WorkerAdmission.d.mts +1 -1
  150. package/dist/durable/WorkerAdmission.mjs +1 -1
  151. package/dist/durable/WorkerHost.d.mts +2 -2
  152. package/dist/durable/WorkerHost.mjs +1 -1
  153. package/dist/engine/AgentRuntime.d.mts +1 -1
  154. package/dist/engine/AgentRuntime.mjs +1 -1
  155. package/dist/engine/DurableStep.d.mts +2 -2
  156. package/dist/engine/DurableStep.mjs +1 -11
  157. package/dist/engine/DurableStep.mjs.map +1 -1
  158. package/dist/engine/MessagingHost.d.mts +1 -1
  159. package/dist/engine/MessagingHost.mjs +1 -1
  160. package/dist/engine/RunOptions.d.mts +1 -1
  161. package/dist/engine/SubagentHost.d.mts +1 -1
  162. package/dist/engine/SubagentHost.mjs +1 -1
  163. package/dist/index.d.mts +16 -16
  164. package/dist/index.mjs +15 -15
  165. package/dist/{run-context-reader-DvTEq2RC.d.mts → run-context-reader-BtBPX_nC.d.mts} +2 -2
  166. package/dist/tool-execution-Ba7tO7Pt.mjs +17 -0
  167. package/dist/tool-execution-Ba7tO7Pt.mjs.map +1 -0
  168. package/package.json +1 -1
  169. package/src/core/Worker.ts +3 -1
  170. package/src/core/internal/agent-updates.ts +9 -1
  171. package/src/core/internal/tool-execution.ts +33 -0
  172. package/src/durable/DurableAgentRuntime.ts +74 -8
  173. package/src/durable/internal/agent-updates.ts +59 -3
  174. package/src/durable/internal/worker-host.ts +3 -1
  175. package/src/engine/DurableStep.ts +5 -31
  176. package/src/engine/internal/agent-runtime.ts +2 -1
  177. package/dist/Agent-BiRbr73L.mjs.map +0 -1
  178. package/dist/AgentRuntime-DaDKMasp.mjs.map +0 -1
  179. package/dist/DurableAgentRuntime-BJbuIqQq.mjs.map +0 -1
  180. 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 { $ 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-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-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-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-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-BF2YgWkg.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
  })
@@ -1625,7 +1649,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
1625
1649
  ...admission.origin.continuationOf === void 0 ? {} : { continuationOf: admission.origin.continuationOf }
1626
1650
  });
1627
1651
  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");
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");
1629
1653
  const retainedFrameworkInput = Schema.is(FrameworkMessage)(options.messageAdmission);
1630
1654
  if (retainedFrameworkInput && admission.reportKind !== "update") yield* validateCompletion(options.messageAdmission, options, agentId, inputDigest);
1631
1655
  yield* reservation(admission, inputDigest, input, options.principal, retainedFrameworkInput, authorization);
@@ -1642,7 +1666,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
1642
1666
  const sourceBinding = currentBinding(origin.source.agentId);
1643
1667
  const targetBinding = currentBinding(origin.worker.targetAgentId);
1644
1668
  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");
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");
1646
1670
  const receivingOrigin = retained?.origin;
1647
1671
  if (destination.depth !== 0 && receivingOrigin === void 0) return yield* failure("followUp", "denied");
1648
1672
  const now = yield* Clock.currentTimeMillis;
@@ -2329,7 +2353,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
2329
2353
  return {
2330
2354
  worker: origin.worker,
2331
2355
  latestReceipt: acceptedInput?.receipt ?? null,
2332
- 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"),
2333
2357
  acceptedInput,
2334
2358
  appliedInput,
2335
2359
  run,
@@ -2648,7 +2672,7 @@ const makeWorkerRuntime = Effect.fnUntraced(function* (options) {
2648
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;
2649
2673
  if (frozen === void 0) return yield* failure("followUp", "denied");
2650
2674
  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");
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");
2652
2676
  const recorded = Option.getOrUndefined(yield* exactRecord(childThreadId, workerOriginRecordId(childThreadId), "followUp"))?.record.payload;
2653
2677
  if (recorded?._tag !== "WorkerOriginRecorded" || recorded.origin.worker.threadId !== childThreadId || recorded.origin.reporting?.mode !== "standard") return yield* failure("followUp", "denied");
2654
2678
  const origin = recorded.origin;
@@ -3972,6 +3996,19 @@ const make = Effect.fnUntraced(function* (bindings) {
3972
3996
  yield* hit("tools:after-unavailable-append");
3973
3997
  recovered += 1;
3974
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
+ }
3975
4012
  if (intent !== void 0) switch (intent.resolution._tag) {
3976
4013
  case "AbortSubmission": continue;
3977
4014
  case "CompletedWithResult":
@@ -4446,7 +4483,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4446
4483
  case "Admitted": {
4447
4484
  const child = resolution.submission;
4448
4485
  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({
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({
4450
4487
  operation: "establishChildFromRequest",
4451
4488
  message: `The admitted child ${child.submissionId} diverges from the canonical SubagentRequested record for Tool Call ${request.toolCallId}; establishment fails closed (SUB-016)`
4452
4489
  });
@@ -4524,7 +4561,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4524
4561
  const child = childLookup.value;
4525
4562
  if (child.threadId !== request.childThreadId) return mismatch("The child Thread does not match the intended child identity");
4526
4563
  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");
4564
+ if (!definitionDigestsEqual$1(child.agentDigests, request.targetDigests)) return mismatch("The child definition digests do not match the stored target digests");
4528
4565
  if (child.inputDigest !== request.childInputDigest) return mismatch("The child input digest does not match the canonical request");
4529
4566
  const linkage = child.parentLinkage;
4530
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");
@@ -4532,7 +4569,7 @@ const make = Effect.fnUntraced(function* (bindings) {
4532
4569
  const lineage = childRecords.find((envelope) => envelope.record.recordId === subagentLineageRecordId(request.childThreadId))?.record.payload;
4533
4570
  if (lineage === void 0 || lineage._tag !== "SubagentLineageRecorded") return mismatch("The child Thread carries no immutable lineage record");
4534
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");
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");
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");
4536
4573
  const settlement = childRecords.find((envelope) => envelope.record.recordId === submissionSettlementRecordId(childSubmissionId))?.record.payload;
4537
4574
  if (settlement === void 0 || settlement._tag !== "SubmissionSettled") return mismatch("The child has no canonical Settlement record");
4538
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");
@@ -5046,7 +5083,7 @@ const make = Effect.fnUntraced(function* (bindings) {
5046
5083
  const inheritedGrant = submission.workerAdmission?.origin.grant ?? (childLineage?._tag === "SubagentLineageRecorded" ? childLineage.grant : void 0);
5047
5084
  const delegationDepth = submission.workerAdmission?.origin.depth ?? (childLineage?._tag === "SubagentLineageRecorded" ? childLineage.parentLink.depth : 0);
5048
5085
  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" });
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" });
5050
5087
  const completionTools = [...agent.definition.completion === void 0 ? [] : [agent.definition.completion.tool], ...agent.definition.completionFromTools?.map((declaration) => declaration.tool) ?? []];
5051
5088
  const pending = yield* pendingToolBatchFor(records, runId, completionTools);
5052
5089
  const resumeProjection = pending === void 0 ? journal : yield* projectRunJournalStream(withoutPendingBatch(canonical, pending, runId), runId, void 0, priorContext);
@@ -7052,6 +7089,7 @@ const make = Effect.fnUntraced(function* (bindings) {
7052
7089
  const declared = yield* declaredCallsFor(records, runIdForSubmission(submission.submissionId), new Set(intents.map((intent) => intent.toolCallId)));
7053
7090
  for (const intent of intents) {
7054
7091
  const original = declared.get(intent.toolCallId);
7092
+ if (original !== void 0 && nativeUpdateAccepted(submission, original, records)) continue;
7055
7093
  if (original === void 0 || current !== void 0 && !supportsOperation(OpenToolCallEvidence.make(original), operations.get(intent.toolCallId), current)) return true;
7056
7094
  }
7057
7095
  return false;
@@ -7135,7 +7173,31 @@ const make = Effect.fnUntraced(function* (bindings) {
7135
7173
  case "ResumePendingToolBatch": return "deferred";
7136
7174
  case "MarkUnknown": return yield* markUnknownForRecovery(snapshot, evidence, records, decision);
7137
7175
  case "ApplyUnknownResolutions": return yield* applyUnknownResolutionsForRecovery(snapshot, evidence, records);
7138
- 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
+ }
7139
7201
  case "AwaitApprovalDecision": return yield* awaitApprovalForRecovery(snapshot, evidence, decision);
7140
7202
  case "ResumeSuspended": return yield* resumeSuspendedForRecovery(snapshot);
7141
7203
  case "RevertJoining":
@@ -7429,12 +7491,16 @@ const make = Effect.fnUntraced(function* (bindings) {
7429
7491
  if (selected.state.settled || selected.state.resolved) return "none";
7430
7492
  const intent = (yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId: submission.submissionId }))).unknownResolutions.find((intent) => intent.toolCallId === selected.declared.toolCallId && unknownResolutionKind(intent.resolution) === "factual");
7431
7493
  const factual = intent?.resolution;
7432
- 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({
7433
7496
  threadId,
7434
7497
  submissionId: submission.submissionId,
7435
7498
  ...selected.declared
7436
7499
  })).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;
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;
7438
7504
  const neverStarted = factual?._tag === "NeverHappened" || selected.state.dispatchBlocked || Option.isSome(reconciliation) && reconciliation.value._tag === "NeverStarted";
7439
7505
  if (completed === void 0 && !neverStarted) return "unknown";
7440
7506
  const result = completed === void 0 ? yield* Schema.encodeEffect(ToolUnavailable)(ToolUnavailable.make({
@@ -7815,13 +7881,13 @@ const make = Effect.fnUntraced(function* (bindings) {
7815
7881
  code: `message-${cause.reason}`,
7816
7882
  cause
7817
7883
  })));
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))) {
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))) {
7819
7885
  const retained = yield* ledger.lookup(SubmissionLookupByKey.make({
7820
7886
  threadId: options.threadId,
7821
7887
  principal: options.principal,
7822
7888
  idempotencyKey: options.idempotencyKey
7823
7889
  }));
7824
- 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({
7825
7891
  reason: "refused",
7826
7892
  code: "unregistered-replay-contract"
7827
7893
  });
@@ -8494,4 +8560,4 @@ var DurableAgentRuntime = class DurableAgentRuntime extends Context.Service()("@
8494
8560
  //#endregion
8495
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 };
8496
8562
 
8497
- //# sourceMappingURL=DurableAgentRuntime-BJbuIqQq.mjs.map
8563
+ //# sourceMappingURL=DurableAgentRuntime-CGW93k81.mjs.map