effect-agent 0.1.0-beta.96 → 0.1.0-beta.98

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 (142) hide show
  1. package/dist/{AgentRuntime-B64362Id.d.mts → AgentRuntime-BMzrJos6.d.mts} +2 -2
  2. package/dist/{AgentRuntime-Cdvqw7l_.mjs → AgentRuntime-BWOnNc0d.mjs} +78 -42
  3. package/dist/AgentRuntime-BWOnNc0d.mjs.map +1 -0
  4. package/dist/{DurableAgentRuntime-BGwGUIT-.mjs → DurableAgentRuntime-gF4YiEj2.mjs} +485 -262
  5. package/dist/DurableAgentRuntime-gF4YiEj2.mjs.map +1 -0
  6. package/dist/{DurableFailpoint-DQJet828.d.mts → DurableFailpoint-mx3-nsxU.d.mts} +3 -3
  7. package/dist/{EventSource-tCO_dAff.d.mts → EventSource-BZ73J0s5.d.mts} +3 -3
  8. package/dist/{PreparedInputAdmission-CFSddiT8.d.mts → PreparedInputAdmission-BkeI-Xvr.d.mts} +4 -4
  9. package/dist/{Records-CMByd1eD.d.mts → Records-BIiRLqlz.d.mts} +93 -101
  10. package/dist/{Records-BEz5IFUu.mjs → Records-DR1xtbXY.mjs} +36 -7
  11. package/dist/Records-DR1xtbXY.mjs.map +1 -0
  12. package/dist/{RunJournal-B_fxe57c.mjs → RunJournal-DNs3PM4K.mjs} +80 -23
  13. package/dist/RunJournal-DNs3PM4K.mjs.map +1 -0
  14. package/dist/{RunOptions-Clj8cLsp.d.mts → RunOptions-Bruk54SE.d.mts} +13 -4
  15. package/dist/{Schedule-BxCfnYr0.d.mts → Schedule-BNFlluAl.d.mts} +2 -2
  16. package/dist/{Scheduling-BW6BD_TP.mjs → Scheduling-HFH0pST1.mjs} +2 -2
  17. package/dist/{Scheduling-BW6BD_TP.mjs.map → Scheduling-HFH0pST1.mjs.map} +1 -1
  18. package/dist/{Subagent-Cbfzylz1.mjs → Subagent-C2s8PFrd.mjs} +2 -2
  19. package/dist/{Subagent-Cbfzylz1.mjs.map → Subagent-C2s8PFrd.mjs.map} +1 -1
  20. package/dist/{Subagent-Bm1dRecN.d.mts → Subagent-m7ywTCe4.d.mts} +3 -3
  21. package/dist/{Subscription-CrTIQKZR.d.mts → Subscription-BCQ3L9Zp.d.mts} +3 -3
  22. package/dist/{SubscriptionInput-BVOeFF1L.d.mts → SubscriptionInput-Cqu4_RW3.d.mts} +3 -3
  23. package/dist/{ToolReconciler-DQVaJfpE.d.mts → ToolReconciler-BmVRAHKs.d.mts} +8 -4
  24. package/dist/{agent-registration-BTa5vmQF.mjs → agent-registration-cXpB8cBU.mjs} +40 -95
  25. package/dist/agent-registration-cXpB8cBU.mjs.map +1 -0
  26. package/dist/capabilities/Commands.d.mts +1 -1
  27. package/dist/capabilities/RunHooks.d.mts +1 -1
  28. package/dist/capabilities/Subagent.d.mts +1 -1
  29. package/dist/capabilities/Subagent.mjs +1 -1
  30. package/dist/durable/ActivityStore.d.mts +1 -1
  31. package/dist/durable/ActivityStore.mjs +1 -1
  32. package/dist/durable/Admin.d.mts +1 -1
  33. package/dist/durable/Admin.mjs +12 -10
  34. package/dist/durable/Admin.mjs.map +1 -1
  35. package/dist/durable/AgentRegistration.d.mts +2 -2
  36. package/dist/durable/AgentRegistration.mjs +4 -7
  37. package/dist/durable/AgentRegistration.mjs.map +1 -1
  38. package/dist/durable/Certification.d.mts +2 -2
  39. package/dist/durable/CommittedActivity.d.mts +1 -1
  40. package/dist/durable/CommittedActivity.mjs +1 -1
  41. package/dist/durable/Digest.d.mts +1 -1
  42. package/dist/durable/Digest.mjs +1 -1
  43. package/dist/durable/DurableAgentRuntime.d.mts +1 -1
  44. package/dist/durable/DurableAgentRuntime.mjs +1 -1
  45. package/dist/durable/DurableFailpoint.d.mts +1 -1
  46. package/dist/durable/DurableFailpoint.mjs +2 -0
  47. package/dist/durable/DurableFailpoint.mjs.map +1 -1
  48. package/dist/durable/DurableFailpointTestControl.d.mts +1 -1
  49. package/dist/durable/EventSource.d.mts +1 -1
  50. package/dist/durable/EventSource.mjs +1 -1
  51. package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
  52. package/dist/durable/GitHubWorkflowSource.mjs +1 -1
  53. package/dist/durable/MessageDelivery.d.mts +3 -3
  54. package/dist/durable/MessageDelivery.mjs +1 -1
  55. package/dist/durable/MessageDeliveryStoreConformance.d.mts +39 -39
  56. package/dist/durable/MessageDeliveryStoreConformance.mjs +1 -1
  57. package/dist/durable/PersistentHistory.d.mts +1 -1
  58. package/dist/durable/PersistentHistory.mjs +2 -2
  59. package/dist/durable/PreparedInputAdmission.d.mts +1 -1
  60. package/dist/durable/Records.d.mts +2 -2
  61. package/dist/durable/Records.mjs +2 -2
  62. package/dist/durable/Recovery.d.mts +1 -1
  63. package/dist/durable/Recovery.mjs +9 -9
  64. package/dist/durable/Recovery.mjs.map +1 -1
  65. package/dist/durable/RunJournal.d.mts +2 -2
  66. package/dist/durable/RunJournal.mjs +2 -2
  67. package/dist/durable/Schedule.d.mts +1 -1
  68. package/dist/durable/Schedule.mjs +1 -1
  69. package/dist/durable/ScheduleStoreConformance.d.mts +1 -1
  70. package/dist/durable/ScheduleStoreConformance.mjs +1 -1
  71. package/dist/durable/ScheduleTransition.d.mts +1 -1
  72. package/dist/durable/ScheduleTransition.mjs +1 -1
  73. package/dist/durable/Scheduling.d.mts +2 -2
  74. package/dist/durable/Scheduling.mjs +1 -1
  75. package/dist/durable/SqlStorageV2Upgrade.d.mts +2 -2
  76. package/dist/durable/SqlStorageV2Upgrade.mjs +1 -1
  77. package/dist/durable/SqlSubscriptionStore.d.mts +2 -2
  78. package/dist/durable/SqlSubscriptionStore.mjs +1 -1
  79. package/dist/durable/SubmissionLedger.d.mts +1 -1
  80. package/dist/durable/SubmissionLedger.mjs +14 -13
  81. package/dist/durable/SubmissionLedger.mjs.map +1 -1
  82. package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
  83. package/dist/durable/SubmissionLedgerConformance.mjs +9 -2
  84. package/dist/durable/SubmissionLedgerConformance.mjs.map +1 -1
  85. package/dist/durable/SubmissionStatus.d.mts +1 -1
  86. package/dist/durable/Subscription.d.mts +1 -1
  87. package/dist/durable/Subscription.mjs +1 -1
  88. package/dist/durable/SubscriptionInput.d.mts +1 -1
  89. package/dist/durable/SubscriptionInput.mjs +2 -2
  90. package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
  91. package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
  92. package/dist/durable/SubscriptionTools.d.mts +3 -3
  93. package/dist/durable/SubscriptionTransition.d.mts +1 -1
  94. package/dist/durable/SubscriptionTransition.mjs +1 -1
  95. package/dist/durable/Subscriptions.d.mts +5 -5
  96. package/dist/durable/Subscriptions.mjs +1 -1
  97. package/dist/durable/ThreadContextHistory.d.mts +1 -1
  98. package/dist/durable/ThreadContextHistory.mjs +1 -1
  99. package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
  100. package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
  101. package/dist/durable/ThreadInvariants.d.mts +4 -2
  102. package/dist/durable/ThreadInvariants.mjs +49 -3
  103. package/dist/durable/ThreadInvariants.mjs.map +1 -1
  104. package/dist/durable/ThreadProjection.d.mts +1 -1
  105. package/dist/durable/ThreadProjection.mjs +1 -1
  106. package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
  107. package/dist/durable/ThreadStore.d.mts +1 -1
  108. package/dist/durable/ThreadStore.mjs +1 -1
  109. package/dist/durable/ThreadStoreConformance.d.mts +1 -1
  110. package/dist/durable/ThreadStoreConformance.mjs +1 -1
  111. package/dist/durable/ToolReconciler.d.mts +1 -1
  112. package/dist/durable/ToolReconciler.mjs +9 -5
  113. package/dist/durable/ToolReconciler.mjs.map +1 -1
  114. package/dist/durable/WorkerHost.d.mts +1 -1
  115. package/dist/engine/AgentRuntime.d.mts +1 -1
  116. package/dist/engine/AgentRuntime.mjs +1 -1
  117. package/dist/engine/RunOptions.d.mts +1 -1
  118. package/dist/engine/RunOptions.mjs.map +1 -1
  119. package/dist/index.d.mts +11 -11
  120. package/dist/index.mjs +6 -6
  121. package/package.json +1 -1
  122. package/src/durable/Admin.ts +20 -11
  123. package/src/durable/AgentRegistration.ts +1 -4
  124. package/src/durable/DurableAgentRuntime.ts +936 -462
  125. package/src/durable/DurableFailpoint.ts +2 -0
  126. package/src/durable/Records.ts +31 -4
  127. package/src/durable/Recovery.ts +8 -8
  128. package/src/durable/RunJournal.ts +128 -51
  129. package/src/durable/SubmissionLedger.ts +13 -12
  130. package/src/durable/SubmissionLedgerConformance.ts +13 -2
  131. package/src/durable/ThreadInvariants.ts +70 -5
  132. package/src/durable/ToolReconciler.ts +7 -3
  133. package/src/durable/internal/agent-registration.ts +77 -188
  134. package/src/durable/internal/messaging-host.ts +1 -6
  135. package/src/durable/internal/worker-host.ts +88 -116
  136. package/src/engine/RunOptions.ts +13 -3
  137. package/src/engine/internal/agent-runtime.ts +160 -106
  138. package/dist/AgentRuntime-Cdvqw7l_.mjs.map +0 -1
  139. package/dist/DurableAgentRuntime-BGwGUIT-.mjs.map +0 -1
  140. package/dist/Records-BEz5IFUu.mjs.map +0 -1
  141. package/dist/RunJournal-B_fxe57c.mjs.map +0 -1
  142. package/dist/agent-registration-BTa5vmQF.mjs.map +0 -1
@@ -6,9 +6,9 @@ import { s as RunTotals } from "./Usage-Dx0aknfk.mjs";
6
6
  import { t as ThreadHistory } from "./ThreadHistory-tS1KwxHR.mjs";
7
7
  import { T as RunDispositionDeclaration, _ as InstructionSource, c as Definition, m as InputPromptSource, r as AnyDefinition } from "./Agent-CM6JubNX.mjs";
8
8
  import { a as WorkerError, c as WorkerRef, l as WorkerReport, n as WorkerBudgetScope, r as WorkerCompletion } from "./Worker--j87JI__.mjs";
9
- import { V as RunSubagentDigests, x as RunContextPreparation } from "./RunOptions-Clj8cLsp.mjs";
9
+ import { V as RunSubagentDigests, x as RunContextPreparation } from "./RunOptions-Bruk54SE.mjs";
10
10
  import { i as SubagentHost, l as WorkerReporting } from "./SubagentHost-DaFMZnVR.mjs";
11
- import { S as ToolCallWaiting, _ as SubagentDurability, b as SubagentDurabilityError, c as AgentSpawner, h as SpawnRunOptions, l as AgentSpawnerParent, o as AgentRuntimeFailure, p as RuntimeBinding, s as AgentRuntimeRequirements } from "./AgentRuntime-B64362Id.mjs";
11
+ import { S as ToolCallWaiting, _ as SubagentDurability, b as SubagentDurabilityError, c as AgentSpawner, h as SpawnRunOptions, l as AgentSpawnerParent, o as AgentRuntimeFailure, p as RuntimeBinding, s as AgentRuntimeRequirements } from "./AgentRuntime-BMzrJos6.mjs";
12
12
  import { t as RunEventSink } from "./RunEventSink-D5aVhISG.mjs";
13
13
  import { Tool, Toolkit } from "effect/unstable/ai";
14
14
  import { Crypto, Duration, Effect, Layer, Schema, Scope, Stream } from "effect";
@@ -823,4 +823,4 @@ declare function background<const Name extends string, Input extends Schema.Top,
823
823
  declare function background<const Name extends string, Input extends Schema.Top, Output extends Schema.Top, Parameters extends Schema.Top, Success extends Schema.Top, Failure extends Schema.Top, Prepare, Project, const Selected extends BackgroundOptions>(declaration: Declaration<Name, Input, Output, Parameters, Success, Failure, Prepare, Project>, selected: Selected): ReturnType<typeof background$1<Name, Input, Output, Parameters, Success, Failure, Prepare, Project, Selected>>;
824
824
  //#endregion
825
825
  export { cancel as A, delegationAllocationFromPolicy as B, reporting as C, Worker as D, BackgroundTools as E, start as F, SubagentPolicy as I, SubagentPolicyInput as L, inspect as M, list as N, WorkerObservation as O, observe as P, SubagentPrestartDenied as R, make as S, BackgroundOptions as T, delegationCapsFromPolicy as V, SubagentTools as _, SubagentDelegation as a, define as b, SubagentFailureMode as c, SubagentResult as d, SubagentResultContext as f, SubagentToolFailure as g, SubagentTool as h, SubagentDefineOptions as i, followUp as j, awaitWorker as k, SubagentLayerRequirements as l, SubagentRuntimeOptions as m, SubagentContainedFailure as n, SubagentDurableAccounting as o, SubagentReturnModeFailure as p, SubagentDeclarationOptions as r, SubagentDurableOptions as s, SubagentChildRunFailure as t, SubagentPrepareContext as u, Subagent_d_exports as v, reportingToWorker as w, layer as x, background as y, SubagentProjectionFailure as z };
826
- //# sourceMappingURL=Subagent-Bm1dRecN.d.mts.map
826
+ //# sourceMappingURL=Subagent-m7ywTCe4.d.mts.map
@@ -2,8 +2,8 @@ import { d as SubagentReservationAmounts, l as SubagentGrant, o as SubagentDeleg
2
2
  import { a as Receipt, r as Principal } from "./Receipt-BAHyigAF.mjs";
3
3
  import { r as Update } from "./AgentUpdates-DMJ-_xow.mjs";
4
4
  import { t as AgentPolicy } from "./AgentPolicy-BqDoSXO6.mjs";
5
- import { _ as Digest, h as DefinitionDigests } from "./Records-CMByd1eD.mjs";
6
- import { t as ScheduleAuthorizationDecision } from "./Schedule-BxCfnYr0.mjs";
5
+ import { _ as Digest, h as DefinitionDigests } from "./Records-BIiRLqlz.mjs";
6
+ import { t as ScheduleAuthorizationDecision } from "./Schedule-BNFlluAl.mjs";
7
7
  import { Context, Effect, Schema } from "effect";
8
8
  declare namespace Subscription_d_exports {
9
9
  export { AcceptedEvent, DeliveryChange, EventAcknowledgement, EventSourceVersion, PreparedInput, SourcePartition, SourceRecovery, SubscriptionAuthorizer, SubscriptionChange, SubscriptionConfiguration, SubscriptionDelivery, SubscriptionDeliveryKey, SubscriptionDeliverySnapshot, SubscriptionError, SubscriptionFailpoint, SubscriptionFailpointError, SubscriptionKey, SubscriptionLimits, SubscriptionName, SubscriptionRecord, SubscriptionRefusal, SubscriptionRetentionPolicy, SubscriptionScanCursors, SubscriptionScope, SubscriptionSnapshot, SubscriptionSourceError, SubscriptionStore, SubscriptionStoreFailure, defaultSubscriptionLimits, subscriptionDeliveryKeyString, subscriptionKeyString };
@@ -918,4 +918,4 @@ declare const subscriptionKeyString: (key: SubscriptionKey) => string;
918
918
  declare const subscriptionDeliveryKeyString: (key: SubscriptionDeliveryKey) => string;
919
919
  //#endregion
920
920
  export { defaultSubscriptionLimits as A, SubscriptionScanCursors as C, SubscriptionStore as D, SubscriptionSourceError as E, subscriptionKeyString as M, SubscriptionStoreFailure as O, SubscriptionRetentionPolicy as S, SubscriptionSnapshot as T, SubscriptionKey as _, PreparedInput as a, SubscriptionRecord as b, SubscriptionAuthorizer as c, SubscriptionDelivery as d, SubscriptionDeliveryKey as f, SubscriptionFailpointError as g, SubscriptionFailpoint as h, EventSourceVersion as i, subscriptionDeliveryKeyString as j, Subscription_d_exports as k, SubscriptionChange as l, SubscriptionError as m, DeliveryChange as n, SourcePartition as o, SubscriptionDeliverySnapshot as p, EventAcknowledgement as r, SourceRecovery as s, AcceptedEvent as t, SubscriptionConfiguration as u, SubscriptionLimits as v, SubscriptionScope as w, SubscriptionRefusal as x, SubscriptionName as y };
921
- //# sourceMappingURL=Subscription-CrTIQKZR.d.mts.map
921
+ //# sourceMappingURL=Subscription-BCQ3L9Zp.d.mts.map
@@ -1,6 +1,6 @@
1
1
  import { t as AgentId } from "./Identifiers-CN2s30fF.mjs";
2
- import { O as PersistedJson, h as DefinitionDigests } from "./Records-CMByd1eD.mjs";
3
- import { E as SubscriptionSourceError, b as SubscriptionRecord, i as EventSourceVersion, m as SubscriptionError, t as AcceptedEvent, u as SubscriptionConfiguration } from "./Subscription-CrTIQKZR.mjs";
2
+ import { O as PersistedJson, h as DefinitionDigests } from "./Records-BIiRLqlz.mjs";
3
+ import { E as SubscriptionSourceError, b as SubscriptionRecord, i as EventSourceVersion, m as SubscriptionError, t as AcceptedEvent, u as SubscriptionConfiguration } from "./Subscription-BCQ3L9Zp.mjs";
4
4
  import { Context, Effect, Schema, Scope } from "effect";
5
5
  declare namespace SubscriptionInput_d_exports {
6
6
  export { SubscriptionInputBinding, SubscriptionInputBindings, makeSubscriptionInputBinding, resolveSubscriptionInput };
@@ -38,4 +38,4 @@ declare const makeSubscriptionInputBinding: <Event extends Schema.Top, Parameter
38
38
  }) => Effect.Effect<SubscriptionInputBinding, never, Exclude<R, Scope.Scope> | Exclude<Continuation["DecodingServices"], Scope.Scope> | Exclude<Continuation["EncodingServices"], Scope.Scope> | Exclude<Event["DecodingServices"], Scope.Scope> | Exclude<Input["EncodingServices"], Scope.Scope> | Exclude<Parameters["DecodingServices"], Scope.Scope>>;
39
39
  //#endregion
40
40
  export { resolveSubscriptionInput as a, makeSubscriptionInputBinding as i, SubscriptionInputBindings as n, SubscriptionInput_d_exports as r, SubscriptionInputBinding as t };
41
- //# sourceMappingURL=SubscriptionInput-BVOeFF1L.d.mts.map
41
+ //# sourceMappingURL=SubscriptionInput-Cqu4_RW3.d.mts.map
@@ -11,6 +11,9 @@ declare const PreparedToolCallEvidence_base: Schema.Class<PreparedToolCallEviden
11
11
  readonly toolName: Schema.NonEmptyString;
12
12
  readonly parameters: Schema.declare<Schema.Json, Schema.Json>;
13
13
  readonly parametersDigest: Schema.brand<Schema.String, "@effect-agent/thread/Digest">;
14
+ readonly executionKind: Schema.optionalKey<Schema.Literals<readonly ["ordinary", "delegation", "orchestration"]>>;
15
+ readonly executionClass: Schema.optionalKey<Schema.Literals<readonly ["readonly", "idempotent", "uncertain"]>>;
16
+ readonly replay: Schema.optionalKey<Schema.brand<Schema.String, "@effect-agent/thread/Digest">>;
14
17
  }>, {}>;
15
18
  /**
16
19
  * Everything a reconciliation policy can consult about one prepared-but-unsettled ordinary Tool
@@ -20,7 +23,7 @@ declare const PreparedToolCallEvidence_base: Schema.Class<PreparedToolCallEviden
20
23
  */
21
24
  declare class PreparedToolCallEvidence extends PreparedToolCallEvidence_base {}
22
25
  declare const ReconciliationNeverStarted_base: Schema.Class<ReconciliationNeverStarted, Schema.TaggedStruct<"NeverStarted", {}>, {}>;
23
- /** Proof that the external execution never started: the call may re-execute on resume. */
26
+ /** Proof of nonexecution: resume the original operation or report it unavailable. */
24
27
  declare class ReconciliationNeverStarted extends ReconciliationNeverStarted_base {}
25
28
  declare const ReconciliationCompleted_base: Schema.Class<ReconciliationCompleted, Schema.TaggedStruct<"CompletedWithResult", {
26
29
  readonly result: Schema.declare<Schema.Json, Schema.Json>;
@@ -32,7 +35,7 @@ declare const ReconciliationCompleted_base: Schema.Class<ReconciliationCompleted
32
35
  */
33
36
  declare class ReconciliationCompleted extends ReconciliationCompleted_base {}
34
37
  declare const ReconciliationSafeToRetry_base: Schema.Class<ReconciliationSafeToRetry, Schema.TaggedStruct<"SafeToRetry", {}>, {}>;
35
- /** The call is safe to repeat under a stable external idempotency contract. */
38
+ /** Only the original operation, identity and parameters may repeat under supported semantics. */
36
39
  declare class ReconciliationSafeToRetry extends ReconciliationSafeToRetry_base {}
37
40
  declare const ReconciliationUncertain_base: Schema.Class<ReconciliationUncertain, Schema.TaggedStruct<"Uncertain", {
38
41
  readonly reason: Schema.String;
@@ -43,7 +46,8 @@ declare class ReconciliationUncertain extends ReconciliationUncertain_base {}
43
46
  * What a reconciliation policy can prove about one prepared-but-unsettled ordinary Tool Call
44
47
  * (durability §10): execution never started, execution completed with a recoverable result,
45
48
  * execution is safe to repeat, or nothing — in which case the Run enters Unknown. The engine
46
- * never manufactures an error result and continues.
49
+ * never invents an external result. Proven nonexecution can close a retired operation with
50
+ * an explicit not-executed result; uncertainty stays parked.
47
51
  */
48
52
  declare const ReconciliationDecision: Schema.Union<readonly [typeof ReconciliationNeverStarted, typeof ReconciliationCompleted, typeof ReconciliationSafeToRetry, typeof ReconciliationUncertain]>;
49
53
  type ReconciliationDecision = typeof ReconciliationDecision.Type;
@@ -73,4 +77,4 @@ declare class ToolReconciler extends ToolReconciler_base {
73
77
  }
74
78
  //#endregion
75
79
  export { ReconciliationSafeToRetry as a, ToolReconcilerError as c, ReconciliationNeverStarted as i, ToolReconciler_d_exports as l, ReconciliationCompleted as n, ReconciliationUncertain as o, ReconciliationDecision as r, ToolReconciler as s, PreparedToolCallEvidence as t };
76
- //# sourceMappingURL=ToolReconciler-DQVaJfpE.d.mts.map
80
+ //# sourceMappingURL=ToolReconciler-BmVRAHKs.d.mts.map
@@ -2,97 +2,62 @@ import { AgentId } from "./core/Identifiers.mjs";
2
2
  import { getToolExecutionKind } from "./core/SubagentContract.mjs";
3
3
  import { a as PinnedTool, l as ToolNamespace, n as DiscoveryTool, r as IncludesCatalogDocumentation, t as AdditionalToolCatalog } from "./ToolExposure-C93U1sPu.mjs";
4
4
  import { BackgroundReporting, WorkerReportPreparationFailure } from "./engine/SubagentHost.mjs";
5
+ import { ContextRolloverTool } from "./engine/ContextWindow.mjs";
5
6
  import { getToolExecutionClass } from "./engine/DurableStep.mjs";
6
- import { M as ReplayContract, f as DefinitionDigestInput, p as DefinitionDigests } from "./Records-BEz5IFUu.mjs";
7
+ import { M as ReplayContract, p as DefinitionDigests } from "./Records-DR1xtbXY.mjs";
7
8
  import { DigestError, digestDefinitions, digestJson } from "./durable/Digest.mjs";
8
9
  import { Tool } from "effect/unstable/ai";
9
10
  import { Context, Effect, Layer, Schema } from "effect";
10
11
  //#region src/durable/internal/agent-registration.ts
11
- /**
12
- * No Agent Binding is registered for the requested stable identity. Recovery
13
- * fails closed: it never substitutes the latest Binding or runs different
14
- * code.
15
- */
12
+ /** No unique current executable is registered for the stable Agent identity. */
16
13
  var BindingUnavailable = class extends Schema.TaggedError()("BindingUnavailable", {
17
14
  agentId: AgentId,
18
15
  message: Schema.String
19
16
  }) {};
20
- /**
21
- * A Binding is registered for the identity but neither the exact admission fingerprints
22
- * nor its declared replay contract support the retained pending operations. Refusal leaves
23
- * the original Submission pending until compatible code is available.
24
- */
25
- var BindingDigestMismatch = class extends Schema.TaggedError()("BindingDigestMismatch", {
26
- agentId: AgentId,
27
- message: Schema.String
28
- }) {};
29
- /** Byte-for-byte equality of two stored definition digest triples (SUB-023). */
17
+ /** Exact immutable admission, lineage and delivery evidence; never an executable-code gate. */
30
18
  const definitionDigestsEqual = (left, right) => left.agent === right.agent && left.model === right.model && left.tools === right.tools && Schema.toEquivalence(Schema.UndefinedOr(ReplayContract))(left.replay, right.replay);
31
- /**
32
- * Data exported from a definition, never an old executable Binding. A host may supply an audited
33
- * manifest from the original release for work admitted before replay contracts were retained.
34
- * Its original declarations must hash to that admission; a bare old digest is not a manifest.
35
- */
36
- var BindingManifest = class extends Schema.Class("BindingManifest")({
37
- agentId: AgentId,
38
- definitions: DefinitionDigestInput,
39
- replay: ReplayContract
40
- }) {};
41
- const makeBindingManifest = Effect.fn("AgentRegistration.makeBindingManifest")(function* (definition, definitions, versions) {
42
- const jsonSchema = (schema) => Schema.decodeUnknownSync(Schema.Json)(Tool.getJsonSchemaFromSchema(schema));
43
- const contracts = yield* Effect.try({
19
+ /** Hash current operation contracts; no historical definitions or schemas are retained. */
20
+ const toolReplayContracts = Effect.fn("AgentRegistration.toolReplayContracts")(function* (definition, versions, fallbackVersion = null) {
21
+ const declarations = yield* Effect.try({
44
22
  try: () => {
45
- const tools = Object.values(definition.toolkit.tools);
46
- if (tools.some((tool) => !Object.hasOwn(versions.tools, tool.name))) throw new Error("Every Tool needs an explicit replay semantic version");
47
- return {
48
- agent: {
49
- version: versions.agent,
50
- id: definition.id,
51
- input: jsonSchema(definition.input),
52
- output: jsonSchema(definition.output),
53
- updates: definition.updates === void 0 ? null : jsonSchema(definition.updates),
54
- completion: definition.completion === void 0 ? null : {
55
- tool: definition.completion.tool,
56
- required: definition.completion.required ?? false
57
- },
58
- completionFromTools: definition.completionFromTools?.map((entry) => entry.tool).sort() ?? [],
59
- disposition: definition.runDisposition === void 0 ? null : jsonSchema(definition.runDisposition.schema)
60
- },
61
- tools: tools.map((tool) => ({
23
+ const jsonSchema = (schema) => Schema.decodeUnknownSync(Schema.Json)(Tool.getJsonSchemaFromSchema(schema));
24
+ return Object.values(definition.toolkit.tools).map((tool) => {
25
+ const version = versions === void 0 ? fallbackVersion : versions.tools[tool.name];
26
+ if (version === void 0 || versions !== void 0 && !Object.hasOwn(versions.tools, tool.name)) throw new Error("Every Tool needs an explicit replay semantic version");
27
+ return {
62
28
  name: tool.name,
63
29
  contract: {
64
- version: versions.tools[tool.name],
30
+ version,
65
31
  parameters: jsonSchema(tool.parametersSchema),
66
32
  success: jsonSchema(tool.successSchema),
67
33
  failure: jsonSchema(tool.failureSchema),
68
34
  failureMode: tool.failureMode,
69
35
  needsApproval: typeof tool.needsApproval === "function" ? "dynamic" : tool.needsApproval ?? false,
70
36
  executionClass: getToolExecutionClass(tool),
71
- executionKind: getToolExecutionKind(tool.annotations)
37
+ executionKind: getToolExecutionKind(tool.annotations),
38
+ contextRollover: Context.get(tool.annotations, ContextRolloverTool),
39
+ completion: definition.completion?.tool === tool.name,
40
+ completionFromTool: definition.completionFromTools?.some((declaration) => declaration.tool === tool.name) ?? false
72
41
  }
73
- }))
74
- };
42
+ };
43
+ });
75
44
  },
76
- catch: () => DigestError.make({ message: "Replay contracts require serializable codecs and an explicit semantic version for every Tool" })
45
+ catch: () => DigestError.make({ message: "Operation contracts require serializable codecs and a version for every Tool" })
77
46
  });
78
- const agent = yield* digestJson(contracts.agent);
79
- const tools = yield* Effect.forEach(contracts.tools, ({ name, contract }) => digestJson(contract).pipe(Effect.map((digest) => [name, digest])));
80
- return BindingManifest.make({
81
- agentId: definition.id,
82
- definitions,
47
+ return Object.fromEntries(yield* Effect.forEach(declarations, ({ name, contract }) => digestJson(contract).pipe(Effect.map((digest) => [name, digest]))));
48
+ });
49
+ /** Compile current metadata without acquiring executable services. */
50
+ const compileBindingContracts = Effect.fn("AgentRegistration.compileBindingContracts")(function* (definition, definitions, versions) {
51
+ const digests = yield* digestDefinitions(definitions);
52
+ const tools = yield* toolReplayContracts(definition, versions, definitions.tools);
53
+ return { digests: DefinitionDigests.make({
54
+ ...digests,
83
55
  replay: ReplayContract.make({
84
- agent,
85
- tools: Object.fromEntries(tools)
56
+ agent: digests.agent,
57
+ tools
86
58
  })
87
- });
59
+ }) };
88
60
  });
89
- const replaySupports = (current, retained, requiredTools) => current.agent === retained.agent && (requiredTools ?? Object.keys(retained.tools)).every((name) => retained.tools[name] !== void 0 && current.tools[name] === retained.tools[name]);
90
- /** Resolve executable code only. Admission, delivery, lineage and receipt comparisons stay exact. */
91
- const bindingSupports = (binding, digests, requiredTools) => {
92
- if (definitionDigestsEqual(binding.digests, digests)) return true;
93
- const retained = digests.replay ?? binding.retainedManifests?.find((entry) => definitionDigestsEqual(entry.digests, digests))?.replay;
94
- return binding.digests.replay !== void 0 && retained !== void 0 && replaySupports(binding.digests.replay, retained, requiredTools);
95
- };
96
61
  const captureReporting = (reports) => Effect.map(Effect.context(), (context) => reports.map((report) => ({
97
62
  ...report,
98
63
  prepare: (value) => Effect.scoped(Effect.suspend(() => report.prepare(value))).pipe(Effect.provide(context), Effect.mapError((error) => Schema.is(WorkerReportPreparationFailure)(error) ? error : WorkerReportPreparationFailure.make({ stage: "preparation" })))
@@ -133,18 +98,13 @@ const DurableWorkerBinding = { make: (agent, digests, reporting) => Effect.gen(f
133
98
  }) };
134
99
  /** INTERNAL identity-only capture retained for the legacy direct worker path. */
135
100
  const makeLegacyWorkerBinding = capture;
136
- const resolveWorkerBinding = (bindings, agentId, digests, requiredTools) => {
101
+ const resolveWorkerBinding = (bindings, agentId) => {
137
102
  const registered = bindings.filter((binding) => binding.agentId === agentId);
138
- if (registered.length === 0) return Effect.fail(BindingUnavailable.make({
139
- agentId,
140
- message: `No Agent Binding is registered for ${agentId}; recovery never substitutes different code (SUB-023)`
141
- }));
142
- const compatible = registered.find((binding) => definitionDigestsEqual(binding.digests, digests)) ?? (registered.length === 1 && bindingSupports(registered[0], digests, requiredTools) ? registered[0] : void 0);
143
- if (compatible === void 0) return Effect.fail(BindingDigestMismatch.make({
103
+ const binding = registered[0];
104
+ return registered.length === 1 && binding !== void 0 ? Effect.succeed(binding) : Effect.fail(BindingUnavailable.make({
144
105
  agentId,
145
- message: `No registered Binding proves the retained replay contracts for ${agentId}; the original request and receipts remain pending`
106
+ message: `Exactly one current Agent Binding must be registered for ${agentId}`
146
107
  }));
147
- return Effect.succeed(compatible);
148
108
  };
149
109
  /** Resolve authoring-time admission through the one exact host registration, never by identity alone. */
150
110
  const resolveDefinitionBinding = (bindings, definition) => {
@@ -216,31 +176,16 @@ const registrationDefinitions = (entry) => {
216
176
  const compileRegistration = (entry) => Effect.flatMap(Effect.try({
217
177
  try: () => registrationDefinitions(entry),
218
178
  catch: () => DigestError.make({ message: "Agent update schema has no serializable wire contract" })
219
- }).pipe(Effect.flatMap(digestDefinitions)), (digests) => Effect.gen(function* () {
179
+ }), (definitions) => Effect.gen(function* () {
220
180
  const binding = yield* capture(entry.model === void 0 ? entry.agent : {
221
181
  definition: entry.agent,
222
182
  model: entry.model
223
183
  }, entry.attemptLayer);
224
184
  const reporting = yield* captureReporting([...entry.reporting ?? [], ...backgroundReports(binding.definition)]);
225
- if (entry.continuity === void 0) return {
226
- ...binding,
227
- digests,
228
- reporting
229
- };
230
- const manifest = yield* makeBindingManifest(binding.definition, registrationDefinitions(entry), entry.continuity.versions);
231
- const retainedManifests = yield* Effect.forEach(entry.continuity.retainedManifests ?? [], (retained) => retained.agentId === binding.agentId ? digestDefinitions(retained.definitions).pipe(Effect.map((digests) => ({
232
- digests,
233
- replay: retained.replay
234
- }))) : Effect.fail(DigestError.make({ message: "A retained manifest belongs to another Agent" })));
235
185
  return {
236
186
  ...binding,
237
- digests: DefinitionDigests.make({
238
- ...digests,
239
- replay: manifest.replay
240
- }),
241
- reporting,
242
- manifest,
243
- retainedManifests
187
+ ...yield* compileBindingContracts(binding.definition, definitions, entry.continuity?.versions),
188
+ reporting
244
189
  };
245
190
  }));
246
191
  /** Compile heterogeneous Agent descriptors into exact, dependency-closed worker registrations. */
@@ -249,6 +194,6 @@ const compileRegistrations = (entries) => {
249
194
  return Effect.forEach(entries, compileEntry);
250
195
  };
251
196
  //#endregion
252
- export { bindingSupports as a, makeBindingManifest as c, resolveWorkerBinding as d, DurableWorkerBinding as i, makeLegacyWorkerBinding as l, BindingManifest as n, compileRegistrations as o, BindingUnavailable as r, definitionDigestsEqual as s, BindingDigestMismatch as t, resolveDefinitionBinding as u };
197
+ export { definitionDigestsEqual as a, resolveWorkerBinding as c, compileRegistrations as i, toolReplayContracts as l, DurableWorkerBinding as n, makeLegacyWorkerBinding as o, compileBindingContracts as r, resolveDefinitionBinding as s, BindingUnavailable as t };
253
198
 
254
- //# sourceMappingURL=agent-registration-BTa5vmQF.mjs.map
199
+ //# sourceMappingURL=agent-registration-cXpB8cBU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-registration-cXpB8cBU.mjs","names":["run"],"sources":["../src/durable/internal/agent-registration.ts"],"sourcesContent":["import { type Crypto, type Option, type Scope, Context, Effect, Layer, Schema } from \"effect\";\nimport { Tool } from \"effect/unstable/ai\";\n\nimport type * as Agent from \"../../core/Agent.ts\";\nimport {\n type InputPromptSource,\n type InstructionSource,\n type ModelServices,\n type RunDispositionDeclaration,\n} from \"../../core/Agent.ts\";\nimport { type ThreadId, AgentId } from \"../../core/Identifiers.ts\";\nimport { getToolExecutionKind } from \"../../core/SubagentContract.ts\";\nimport {\n AdditionalToolCatalog,\n DiscoveryTool,\n IncludesCatalogDocumentation,\n PinnedTool,\n ToolNamespace,\n} from \"../../core/ToolExposure.ts\";\nimport { type RuntimeBinding } from \"../../engine/AgentRuntime.ts\";\nimport { ContextRolloverTool } from \"../../engine/ContextWindow.ts\";\nimport { getToolExecutionClass } from \"../../engine/DurableStep.ts\";\nimport {\n BackgroundReporting,\n WorkerReportPreparationFailure,\n type WorkerReporting,\n} from \"../../engine/SubagentHost.ts\";\nimport { digestDefinitions, digestJson, DigestError } from \"../Digest.ts\";\nimport type { DurableWorkerFailure, DurableWorkerRequirements } from \"../DurableAgentRuntime.ts\";\nimport type { DefinitionDigestInput, PersistedJson } from \"../Records.ts\";\nimport { DefinitionDigests, ReplayContract } from \"../Records.ts\";\nimport type { Claim, Settlement } from \"../SubmissionLedger.ts\";\n\n/** No unique current executable is registered for the stable Agent identity. */\nexport class BindingUnavailable extends Schema.TaggedError<BindingUnavailable>()(\n \"BindingUnavailable\",\n { agentId: AgentId, message: Schema.String },\n) {}\n\nexport type DurableBindingFailure = BindingUnavailable;\n\n/** Exact immutable admission, lineage and delivery evidence; never an executable-code gate. */\nexport const definitionDigestsEqual = (\n left: DefinitionDigests,\n right: DefinitionDigests,\n): boolean =>\n left.agent === right.agent &&\n left.model === right.model &&\n left.tools === right.tools &&\n Schema.toEquivalence(Schema.UndefinedOr(ReplayContract))(left.replay, right.replay);\n\n/** Change an operation version when its meaning, durable Steps or idempotency keys change. */\nexport interface ReplayVersions {\n readonly tools: Readonly<Record<string, PersistedJson>>;\n}\n\n/** Hash current operation contracts; no historical definitions or schemas are retained. */\nexport const toolReplayContracts = Effect.fn(\"AgentRegistration.toolReplayContracts\")(function* (\n definition: Agent.AnyDefinition,\n versions?: ReplayVersions,\n fallbackVersion: PersistedJson = null,\n) {\n const declarations = yield* Effect.try({\n try: () => {\n const jsonSchema = (schema: Schema.Top) =>\n Schema.decodeUnknownSync(Schema.Json)(Tool.getJsonSchemaFromSchema(schema));\n\n return Object.values(definition.toolkit.tools).map((tool) => {\n const version = versions === undefined ? fallbackVersion : versions.tools[tool.name];\n\n if (\n version === undefined ||\n (versions !== undefined && !Object.hasOwn(versions.tools, tool.name))\n )\n throw new Error(\"Every Tool needs an explicit replay semantic version\");\n\n return {\n name: tool.name,\n contract: {\n version,\n parameters: jsonSchema(tool.parametersSchema),\n success: jsonSchema(tool.successSchema),\n failure: jsonSchema(tool.failureSchema),\n failureMode: tool.failureMode,\n needsApproval:\n typeof tool.needsApproval === \"function\" ? \"dynamic\" : (tool.needsApproval ?? false),\n executionClass: getToolExecutionClass(tool),\n executionKind: getToolExecutionKind(tool.annotations),\n contextRollover: Context.get(tool.annotations, ContextRolloverTool),\n completion: definition.completion?.tool === tool.name,\n completionFromTool:\n definition.completionFromTools?.some(\n (declaration) => declaration.tool === tool.name,\n ) ?? false,\n },\n };\n });\n },\n catch: () =>\n DigestError.make({\n message: \"Operation contracts require serializable codecs and a version for every Tool\",\n }),\n });\n\n return Object.fromEntries(\n yield* Effect.forEach(declarations, ({ name, contract }) =>\n digestJson(contract).pipe(Effect.map((digest) => [name, digest] as const)),\n ),\n );\n});\n\n/** Compile current metadata without acquiring executable services. */\nexport const compileBindingContracts = Effect.fn(\"AgentRegistration.compileBindingContracts\")(\n function* (\n definition: Agent.AnyDefinition,\n definitions: DefinitionDigestInput,\n versions?: ReplayVersions,\n ): Effect.fn.Return<Pick<ResolvedBinding, \"digests\">, DigestError, Crypto.Crypto> {\n const digests = yield* digestDefinitions(definitions);\n const tools = yield* toolReplayContracts(definition, versions, definitions.tools);\n\n return {\n digests: DefinitionDigests.make({\n ...digests,\n replay: ReplayContract.make({ agent: digests.agent, tools }),\n }),\n };\n },\n);\n\ntype ExecutableDefinition = Agent.AnyDefinition & {\n readonly instructions: InstructionSource<never, unknown, unknown>;\n readonly inputPrompt?: InputPromptSource<never, unknown, unknown> | undefined;\n};\n\n/** Executable model Binding accepted by durable registration descriptors. */\nexport type ExecutableAgentBinding = {\n readonly definition: ExecutableDefinition;\n readonly model: Layer.Layer<ModelServices, never, unknown>;\n};\n\n/**\n * Internal coordinator entry point for one fenced Attempt over an already-granted claim.\n * The generic signature matches `runAttempt` and is specialized for each captured Agent.\n */\ntype ResolvedAttemptDriver = <\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions,\n Tools extends Record<string, Tool.Any>,\n Provider,\n ModelProvides,\n ModelRequires,\n InstructionError,\n InstructionRequirements,\n RunDispositionValue extends\n | RunDispositionDeclaration<OutputSchema[\"Type\"], Schema.Top>\n | undefined,\n InputPromptValue extends InputPromptSource<InputSchema[\"Type\"], unknown, unknown> | undefined,\n UpdatesSchema extends Schema.Top | undefined,\n>(\n agent: RuntimeBinding<\n InputSchema,\n OutputSchema,\n Instructions,\n Tools,\n Provider,\n ModelProvides,\n ModelRequires,\n InstructionError,\n InstructionRequirements,\n RunDispositionValue,\n InputPromptValue,\n UpdatesSchema\n >,\n threadId: ThreadId,\n claim: Claim,\n) => Effect.Effect<\n Option.Option<Settlement>,\n DurableWorkerFailure,\n DurableWorkerRequirements<\n RuntimeBinding<\n InputSchema,\n OutputSchema,\n Instructions,\n Tools,\n Provider,\n ModelProvides,\n ModelRequires,\n InstructionError,\n InstructionRequirements,\n RunDispositionValue,\n InputPromptValue,\n UpdatesSchema\n >,\n InstructionRequirements\n >\n>;\n\ntype CapturedAttempt<A extends ExecutableAgentBinding> = (\n agent: A,\n threadId: ThreadId,\n claim: Claim,\n) => Effect.Effect<Option.Option<Settlement>, DurableWorkerFailure, DurableWorkerRequirements<A>>;\n\n/**\n * An Agent with its worker services captured, ready to drive a fenced Attempt.\n * Concrete Schema and model types stay inside this closure when registrations are collected.\n */\ninterface CapturedBinding {\n readonly agentId: AgentId;\n /** Exact immutable definition whose codecs and behavior the worker captured. */\n readonly definition: Agent.AnyDefinition;\n /** Captured independently from per-Attempt services: report preparation has no fenced Claim. */\n readonly reporting?: ReadonlyArray<WorkerReporting<WorkerReportPreparationFailure>>;\n readonly attempt: (\n driver: ResolvedAttemptDriver,\n threadId: ThreadId,\n claim: Claim,\n ) => Effect.Effect<Option.Option<Settlement>, DurableWorkerFailure>;\n}\n\ntype ReportRequirements<Reports> =\n Reports extends ReadonlyArray<WorkerReporting<unknown, unknown>>\n ? [Reports[number]] extends [never]\n ? never\n : Reports[number] extends WorkerReporting<unknown, infer R>\n ? Exclude<R, Scope.Scope>\n : never\n : never;\n\nconst captureReporting = <R>(reports: ReadonlyArray<WorkerReporting<unknown, R>>) =>\n Effect.map(Effect.context<Exclude<R, Scope.Scope>>(), (context) =>\n reports.map((report): WorkerReporting<WorkerReportPreparationFailure> => ({\n ...report,\n prepare: (value) =>\n Effect.scoped(Effect.suspend(() => report.prepare(value))).pipe(\n Effect.provide(context),\n Effect.mapError((error) =>\n Schema.is(WorkerReportPreparationFailure)(error)\n ? error\n : WorkerReportPreparationFailure.make({ stage: \"preparation\" }),\n ),\n ),\n })),\n );\n\nconst backgroundReports = (definition: Agent.AnyDefinition) => [\n ...new Set(\n Object.values(definition.toolkit.tools).flatMap((tool) => {\n const report = Context.get(tool.annotations, BackgroundReporting);\n\n return report === undefined ? [] : [report];\n }),\n ),\n];\n\n/** One exact executable registration used by durable claim-time resolution. */\nexport interface ResolvedBinding extends CapturedBinding {\n readonly digests: DefinitionDigests;\n}\n\n/** Trusted claim identity for resolving per-Attempt application services. Not model input. */\nexport interface AgentAttemptContext {\n readonly threadId: ThreadId;\n readonly submissionId: Claim[\"submissionId\"];\n readonly attemptId: Claim[\"attemptId\"];\n}\n\nconst capture = <A extends ExecutableAgentBinding, Provides = never, Requires = never>(\n agent: A,\n attemptLayer?: (context: AgentAttemptContext) => Layer.Layer<Provides, never, Requires>,\n): Effect.Effect<\n CapturedBinding,\n never,\n Exclude<DurableWorkerRequirements<A>, Provides> | Requires\n> =>\n Effect.map(\n Effect.context<Exclude<DurableWorkerRequirements<A>, Provides> | Requires>(),\n (context): CapturedBinding => ({\n agentId: agent.definition.id,\n definition: agent.definition,\n attempt: (driver, threadId, claim) => {\n // Registration closes one concrete Binding before heterogeneous registrations are\n // collected. TypeScript cannot instantiate the higher-rank RuntimeBinding parameters\n // from the intentionally erased public shape, so specialize the driver back to A here.\n const run = driver as unknown as CapturedAttempt<A>;\n const execute = run(agent, threadId, claim);\n\n const scoped =\n attemptLayer === undefined\n ? execute\n : execute.pipe(\n Effect.provide(\n Layer.fresh(\n attemptLayer({\n threadId,\n submissionId: claim.submissionId,\n attemptId: claim.attemptId,\n }),\n ),\n ),\n );\n\n return scoped.pipe(Effect.provide(context)) as Effect.Effect<\n Option.Option<Settlement>,\n DurableWorkerFailure\n >;\n },\n }),\n );\n\n/**\n * Build one exact worker registration from an executable Agent Binding and\n * its already-computed definition digests.\n *\n * `make(agent, digests)` captures the binding plus its worker-requirement\n * Context at Layer/effect construction time. Hosts that start from application\n * version declarations should use `compileRegistrations`; low-level fixtures\n * may supply a previously computed digest triple directly.\n */\nexport const DurableWorkerBinding = {\n make: <\n A extends ExecutableAgentBinding,\n const Reports extends ReadonlyArray<WorkerReporting<unknown, unknown>> = readonly [],\n >(\n agent: A,\n digests: DefinitionDigests,\n reporting?: Reports,\n ): Effect.Effect<\n ResolvedBinding,\n never,\n DurableWorkerRequirements<A> | ReportRequirements<Reports>\n > =>\n Effect.gen(function* () {\n const binding = yield* capture(agent);\n\n const reports = yield* captureReporting([\n ...(reporting ?? []),\n ...backgroundReports(agent.definition),\n ]);\n\n return { ...binding, digests, reporting: reports };\n }) as Effect.Effect<\n ResolvedBinding,\n never,\n DurableWorkerRequirements<A> | ReportRequirements<Reports>\n >,\n} as const;\n\n/** INTERNAL identity-only capture retained for the legacy direct worker path. */\nexport const makeLegacyWorkerBinding = capture;\n\nexport const resolveWorkerBinding = (\n bindings: ReadonlyArray<ResolvedBinding>,\n agentId: AgentId,\n): Effect.Effect<ResolvedBinding, BindingUnavailable> => {\n const registered = bindings.filter((binding) => binding.agentId === agentId);\n const binding = registered[0];\n\n return registered.length === 1 && binding !== undefined\n ? Effect.succeed(binding)\n : Effect.fail(\n BindingUnavailable.make({\n agentId,\n message: `Exactly one current Agent Binding must be registered for ${agentId}`,\n }),\n );\n};\n\n/** Resolve authoring-time admission through the one exact host registration, never by identity alone. */\nexport const resolveDefinitionBinding = (\n bindings: ReadonlyArray<ResolvedBinding>,\n definition: Pick<Agent.AnyDefinition, \"id\">,\n): Effect.Effect<ResolvedBinding, BindingUnavailable> => {\n const candidates = bindings.filter((binding) => binding.agentId === definition.id);\n const binding = candidates[0];\n\n if (candidates.length !== 1 || binding === undefined) {\n return Effect.fail(\n BindingUnavailable.make({\n agentId: definition.id,\n message: \"Registered admission requires exactly one binding for the Agent identity\",\n }),\n );\n }\n\n if (!Object.is(binding.definition, definition)) {\n return Effect.fail(\n BindingUnavailable.make({\n agentId: definition.id,\n message: \"Registered admission requires the exact Agent Definition used in registration\",\n }),\n );\n }\n\n return Effect.succeed(binding);\n};\n\n/** Application versions and a model Layer, supplied directly or through an existing Binding. */\nexport type AgentRegistration<A extends ExecutableAgentBinding = ExecutableAgentBinding> = (\n | { readonly agent: A; readonly model?: never; readonly definitions: DefinitionDigestInput }\n | {\n readonly agent: A[\"definition\"];\n readonly model: A[\"model\"];\n readonly definitions: DefinitionDigestInput;\n }\n) & {\n /** Explicit operation versions let unchanged unfinished handlers survive toolbox changes. */\n readonly continuity?: {\n readonly versions: ReplayVersions;\n };\n /**\n * Source-owned reports capture services outside attemptLayer and open a fresh Scope per\n * preparation. Version changes with this registration. Missing exact code and preparation\n * failures become retained report refusals; durable delivery retries reuse the frozen input.\n */\n readonly reporting?: ReadonlyArray<WorkerReporting<unknown, unknown>>;\n /**\n * Build fresh services for exactly one fenced Attempt, across all its Tool/model turns.\n * Finalizes on completion, suspension, failure and interruption. Never reused after eviction.\n * Resolve invocation authority from the trusted claim identity, not captured caller state.\n * Keep fallible resource acquisition lazy in typed Tool operations; this Layer cannot fail.\n */\n readonly attemptLayer?: (context: AgentAttemptContext) => Layer.Layer<never, never, unknown>;\n};\n\ntype EntryWorkerRequirements<Entry> = Entry extends {\n readonly agent: infer A extends ExecutableAgentBinding;\n}\n ? DurableWorkerRequirements<A>\n : Entry extends {\n readonly agent: infer D extends ExecutableDefinition;\n readonly model: infer M extends ExecutableAgentBinding[\"model\"];\n }\n ? DurableWorkerRequirements<{ readonly definition: D; readonly model: M }>\n : never;\n\ntype AttemptLayerRequirements<Requirements, AttemptLayer> = AttemptLayer extends (\n context: AgentAttemptContext,\n) => Layer.Layer<infer Provides, never, infer Requires>\n ? Exclude<Requirements, Provides> | Requires\n : Requirements;\n\n// Conditional options retain every service they may consume. An absent attempt Layer\n// still needs the original worker services; only a definite Layer can remove them.\ntype EntryRequirements<Entry> = Entry extends unknown\n ?\n | AttemptLayerRequirements<\n EntryWorkerRequirements<Entry>,\n \"attemptLayer\" extends keyof Entry ? Entry[\"attemptLayer\"] : undefined\n >\n | (\"reporting\" extends keyof Entry ? ReportRequirements<Entry[\"reporting\"]> : never)\n : never;\n\ntype RegistrationRequirements<Entries extends ReadonlyArray<AgentRegistration>> = [\n Entries[number],\n] extends [never]\n ? never\n : EntryRequirements<Entries[number]>;\n\nconst registrationDefinitions = (entry: AgentRegistration): DefinitionDigestInput => {\n const definition = entry.model === undefined ? entry.agent.definition : entry.agent;\n const automatic = backgroundReports(definition);\n\n const declaredDefinitions =\n definition.updates === undefined\n ? entry.definitions\n : {\n ...entry.definitions,\n agent: {\n declaration: entry.definitions.agent,\n updates: Schema.decodeUnknownSync(Schema.Json)(\n Tool.getJsonSchemaFromSchema(definition.updates),\n ),\n updateProtocol: { schemaVersion: 1, tool: \"emit_update\" },\n },\n };\n\n const definitions =\n automatic.length === 0\n ? declaredDefinitions\n : {\n ...declaredDefinitions,\n agent: {\n declaration: declaredDefinitions.agent,\n backgroundReporting: automatic.map((report) => ({\n delegationId: report.delegationId,\n targetAgentId: report.target.id,\n mode: report.mode ?? \"custom\",\n destinationDelegationId: report.destination?.delegationId ?? null,\n })),\n },\n };\n\n const exposure = definition.toolExposure;\n\n if (\n exposure === undefined &&\n !Object.values(definition.toolkit.tools).some(\n (tool) =>\n Context.get(tool.annotations, DiscoveryTool) || Context.get(tool.annotations, PinnedTool),\n )\n )\n return definitions;\n\n return {\n ...definitions,\n agent: {\n declaration: definitions.agent,\n toolExposure: {\n initialToolNames: exposure === undefined ? null : [...(exposure.initialToolNames ?? [])],\n maxTools: exposure?.maxTools ?? 64,\n maxSchemaBytes: exposure?.maxSchemaBytes ?? 262_144,\n requiredCompletion:\n definition.completion?.required === true ? definition.completion.tool : null,\n tools: Object.values(definition.toolkit.tools).map((tool) => ({\n name: tool.name,\n pinned: Context.get(tool.annotations, PinnedTool),\n discovery: Context.get(tool.annotations, DiscoveryTool),\n namespace: Context.get(tool.annotations, ToolNamespace) ?? null,\n includesCatalogDocumentation: Context.get(tool.annotations, IncludesCatalogDocumentation),\n additional: Context.get(tool.annotations, AdditionalToolCatalog).map((entry) => ({\n name: entry.tool.name,\n namespace: entry.namespace,\n method: entry.method,\n })),\n })),\n },\n },\n };\n};\n\nconst compileRegistration = <Entry extends AgentRegistration>(\n entry: Entry,\n): Effect.Effect<ResolvedBinding, DigestError, Crypto.Crypto | EntryRequirements<Entry>> =>\n Effect.flatMap(\n Effect.try({\n try: () => registrationDefinitions(entry),\n catch: () =>\n DigestError.make({ message: \"Agent update schema has no serializable wire contract\" }),\n }),\n (definitions) =>\n Effect.gen(function* () {\n const binding = yield* capture(\n entry.model === undefined ? entry.agent : { definition: entry.agent, model: entry.model },\n entry.attemptLayer,\n );\n\n const reporting = yield* captureReporting([\n ...(entry.reporting ?? []),\n ...backgroundReports(binding.definition),\n ]);\n\n return {\n ...binding,\n ...(yield* compileBindingContracts(\n binding.definition,\n definitions,\n entry.continuity?.versions,\n )),\n reporting,\n };\n }),\n // The erased descriptor accepts arbitrary provided services. Restore the concrete entry's\n // Exclude<worker requirements, provided services> | layer requirements at this collection seam.\n ) as Effect.Effect<ResolvedBinding, DigestError, Crypto.Crypto | EntryRequirements<Entry>>;\n\n/** Compile heterogeneous Agent descriptors into exact, dependency-closed worker registrations. */\nexport const compileRegistrations = <const Entries extends ReadonlyArray<AgentRegistration>>(\n entries: Entries,\n): Effect.Effect<\n ReadonlyArray<ResolvedBinding>,\n DigestError,\n Crypto.Crypto | RegistrationRequirements<Entries>\n> => {\n // `Effect.forEach` instantiates a generic callback at its constraint. Specialize the callback to\n // this tuple's distributed requirement union before collection so empty and heterogeneous tuples\n // retain their exact service requirements.\n const compileEntry = compileRegistration as unknown as (\n entry: Entries[number],\n ) => Effect.Effect<\n ResolvedBinding,\n DigestError,\n Crypto.Crypto | RegistrationRequirements<Entries>\n >;\n\n return Effect.forEach(entries, compileEntry);\n};\n"],"mappings":";;;;;;;;;;;;AAkCA,IAAa,qBAAb,cAAwC,OAAO,YAAgC,CAAC,CAC9E,sBACA;CAAE,SAAS;CAAS,SAAS,OAAO;AAAO,CAC7C,CAAC,CAAC,CAAC;;AAKH,MAAa,0BACX,MACA,UAEA,KAAK,UAAU,MAAM,SACrB,KAAK,UAAU,MAAM,SACrB,KAAK,UAAU,MAAM,SACrB,OAAO,cAAc,OAAO,YAAY,cAAc,CAAC,CAAC,CA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,MAAM;KAChB,EAAE;IACJ,EAAE;GACJ;EACF;CACF;AACF;AAEA,MAAM,uBACJ,UAEA,OAAO,QACL,OAAO,IAAI;CACT,WAAW,wBAAwB,KAAK;CACxC,aACE,YAAY,KAAK,EAAE,SAAS,wDAAwD,CAAC;AACzF,CAAC,IACA,gBACC,OAAO,IAAI,aAAa;CACtB,MAAM,UAAU,OAAO,QACrB,MAAM,UAAU,KAAA,IAAY,MAAM,QAAQ;EAAE,YAAY,MAAM;EAAO,OAAO,MAAM;CAAM,GACxF,MAAM,YACR;CAEA,MAAM,YAAY,OAAO,iBAAiB,CACxC,GAAI,MAAM,aAAa,CAAC,GACxB,GAAG,kBAAkB,QAAQ,UAAU,CACzC,CAAC;CAED,OAAO;EACL,GAAG;EACH,GAAI,OAAO,wBACT,QAAQ,YACR,aACA,MAAM,YAAY,QACpB;EACA;CACF;AACF,CAAC,CAGL;;AAGF,MAAa,wBACX,YAKG;CAIH,MAAM,eAAe;CAQrB,OAAO,OAAO,QAAQ,SAAS,YAAY;AAC7C"}
@@ -1,4 +1,4 @@
1
- import { o as CommandDrainPolicy } from "../RunOptions-Clj8cLsp.mjs";
1
+ import { o as CommandDrainPolicy } from "../RunOptions-Bruk54SE.mjs";
2
2
  import { Effect, Schema } from "effect";
3
3
  declare namespace Commands_d_exports {
4
4
  export { FollowUpCommand, RunCommand, RunCommandQueue, RunCommandQueueClosed, RunCommandQueueConfig, SteeringCommand, makeRunCommandQueue };
@@ -2,7 +2,7 @@ import { c as ThreadLimitExceeded, i as ThreadEncodingError, s as ThreadHistoryD
2
2
  import { RedactionError, Redactor } from "./Redaction.mjs";
3
3
  import { ApprovalAudit, ApprovalAuditLimitExceeded, ApprovalDecisionMismatch, ApprovalRequestDraft, ApprovalResolver, ApprovalResolverError } from "./Approval.mjs";
4
4
  import { BudgetExceeded, UsageBudgetNode } from "./Budget.mjs";
5
- import { M as RunOptions, R as RunSchedulingHook, _ as RunBudgetHook, b as RunContextHook, g as RunApprovalRequest, h as RunApprovalHook, j as RunInputHook, w as RunContextRequest } from "../RunOptions-Clj8cLsp.mjs";
5
+ import { M as RunOptions, R as RunSchedulingHook, _ as RunBudgetHook, b as RunContextHook, g as RunApprovalRequest, h as RunApprovalHook, j as RunInputHook, w as RunContextRequest } from "../RunOptions-Bruk54SE.mjs";
6
6
  import { RunCommandQueue } from "./Commands.mjs";
7
7
  import { Prompt } from "effect/unstable/ai";
8
8
  import { Effect, Schema } from "effect";
@@ -1,4 +1,4 @@
1
1
  import { c as SubagentExecutionFailureClassification, l as SubagentGrant, s as SubagentExecutionFailure } from "../SubagentContract-DdT7Cqe6.mjs";
2
2
  import { l as WorkerReport, r as WorkerCompletion } from "../Worker--j87JI__.mjs";
3
- import { A as cancel, B as delegationAllocationFromPolicy, C as reporting, D as Worker, E as BackgroundTools, F as start, I as SubagentPolicy, L as SubagentPolicyInput, M as inspect, N as list, O as WorkerObservation, P as observe, R as SubagentPrestartDenied, S as make, T as BackgroundOptions, V as delegationCapsFromPolicy, _ as SubagentTools, a as SubagentDelegation, b as define, c as SubagentFailureMode, d as SubagentResult, f as SubagentResultContext, g as SubagentToolFailure, h as SubagentTool, i as SubagentDefineOptions, j as followUp, k as awaitWorker, l as SubagentLayerRequirements, m as SubagentRuntimeOptions, n as SubagentContainedFailure, o as SubagentDurableAccounting, p as SubagentReturnModeFailure, r as SubagentDeclarationOptions, s as SubagentDurableOptions, t as SubagentChildRunFailure, u as SubagentPrepareContext, w as reportingToWorker, x as layer, y as background, z as SubagentProjectionFailure } from "../Subagent-Bm1dRecN.mjs";
3
+ import { A as cancel, B as delegationAllocationFromPolicy, C as reporting, D as Worker, E as BackgroundTools, F as start, I as SubagentPolicy, L as SubagentPolicyInput, M as inspect, N as list, O as WorkerObservation, P as observe, R as SubagentPrestartDenied, S as make, T as BackgroundOptions, V as delegationCapsFromPolicy, _ as SubagentTools, a as SubagentDelegation, b as define, c as SubagentFailureMode, d as SubagentResult, f as SubagentResultContext, g as SubagentToolFailure, h as SubagentTool, i as SubagentDefineOptions, j as followUp, k as awaitWorker, l as SubagentLayerRequirements, m as SubagentRuntimeOptions, n as SubagentContainedFailure, o as SubagentDurableAccounting, p as SubagentReturnModeFailure, r as SubagentDeclarationOptions, s as SubagentDurableOptions, t as SubagentChildRunFailure, u as SubagentPrepareContext, w as reportingToWorker, x as layer, y as background, z as SubagentProjectionFailure } from "../Subagent-m7ywTCe4.mjs";
4
4
  export { type BackgroundOptions, type BackgroundTools, SubagentChildRunFailure, SubagentContainedFailure, SubagentDeclarationOptions, SubagentDefineOptions, SubagentDelegation, SubagentDurableAccounting, SubagentDurableOptions, SubagentExecutionFailure, SubagentExecutionFailureClassification, SubagentFailureMode, SubagentGrant, SubagentLayerRequirements, SubagentPolicy, type SubagentPolicyInput, SubagentPrepareContext, SubagentPrestartDenied, SubagentProjectionFailure, SubagentResult, SubagentResultContext, SubagentReturnModeFailure, SubagentRuntimeOptions, SubagentTool, SubagentToolFailure, SubagentTools, Worker, WorkerCompletion, WorkerObservation, WorkerReport, awaitWorker as await, background, cancel, define, delegationAllocationFromPolicy, delegationCapsFromPolicy, followUp, inspect, layer, list, make, observe, reporting, reportingToWorker, start };
@@ -1,5 +1,5 @@
1
1
  import { SubagentExecutionFailure, SubagentExecutionFailureClassification, SubagentGrant } from "../core/SubagentContract.mjs";
2
2
  import { WorkerCompletion, WorkerReport } from "../core/Worker.mjs";
3
3
  import "./SubagentReservations.mjs";
4
- import { C as delegationCapsFromPolicy, S as delegationAllocationFromPolicy, _ as reporting, a as define, b as SubagentPrestartDenied, c as Worker, d as cancel, f as followUp, g as start, h as observe, i as background, l as WorkerObservation, m as list, n as SubagentResult, o as layer, p as inspect, s as make, t as SubagentDurableAccounting, u as awaitWorker, v as reportingToWorker, x as SubagentProjectionFailure, y as SubagentPolicy } from "../Subagent-Cbfzylz1.mjs";
4
+ import { C as delegationCapsFromPolicy, S as delegationAllocationFromPolicy, _ as reporting, a as define, b as SubagentPrestartDenied, c as Worker, d as cancel, f as followUp, g as start, h as observe, i as background, l as WorkerObservation, m as list, n as SubagentResult, o as layer, p as inspect, s as make, t as SubagentDurableAccounting, u as awaitWorker, v as reportingToWorker, x as SubagentProjectionFailure, y as SubagentPolicy } from "../Subagent-C2s8PFrd.mjs";
5
5
  export { SubagentDurableAccounting, SubagentExecutionFailure, SubagentExecutionFailureClassification, SubagentGrant, SubagentPolicy, SubagentPrestartDenied, SubagentProjectionFailure, SubagentResult, Worker, WorkerCompletion, WorkerObservation, WorkerReport, awaitWorker as await, background, cancel, define, delegationAllocationFromPolicy, delegationCapsFromPolicy, followUp, inspect, layer, list, make, observe, reporting, reportingToWorker, start };
@@ -1,4 +1,4 @@
1
- import { _ as Digest } from "../Records-CMByd1eD.mjs";
1
+ import { _ as Digest } from "../Records-BIiRLqlz.mjs";
2
2
  import { Context, Effect, Layer, Schema } from "effect";
3
3
  declare namespace ActivityStore_d_exports {
4
4
  export { ActivityBusy, ActivityClaim, ActivityClaimRequest, ActivityMutationFailpoint, ActivityMutationFailure, ActivityMutationPoint, ActivityOwnershipLost, ActivityProcessorKey, ActivityProcessorStore, ActivityProgress, ActivityStoreError, ActivityStoreFailure, ActivityWorkConflict, PreparedActivity };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { ThreadId } from "../core/Identifiers.mjs";
3
- import { T as PersistedJson, h as Digest, k as RecordId, u as CanonicalSequence } from "../Records-BEz5IFUu.mjs";
3
+ import { T as PersistedJson, h as Digest, k as RecordId, u as CanonicalSequence } from "../Records-DR1xtbXY.mjs";
4
4
  import { Context, Effect, Layer, Schema } from "effect";
5
5
  //#region src/durable/ActivityStore.ts
6
6
  var ActivityStore_exports = /* @__PURE__ */ __exportAll({
@@ -1,2 +1,2 @@
1
- import { Ar as obligationSeverityOf, Cr as ObligationThresholds, Dr as RetryCommand, Er as RecoveryExplanation, Mr as recoveryDecisionMeaning, Nr as renderRecoveryExplanation, Or as RetryRefusalReason, Sr as ObligationSeverity, Tr as RecoveryDisposition, _r as IntegrityCheckStatus, br as ObligationEntry, fr as ExplainedEvidence, gr as IntegrityCheckName, hr as IntegrityCheck, jr as predictRecoveryDisposition, kr as RetryRefused, mr as ExplainedUnknownCall, pr as ExplainedSubmission, vr as IntegrityReport, wr as RECOVERY_DECISION_MEANINGS, xr as ObligationReport, yr as ObligationBlockedOn } from "../Records-CMByd1eD.mjs";
1
+ import { Ar as RetryCommand, Cr as ObligationEntry, Dr as RECOVERY_DECISION_MEANINGS, Er as ObligationThresholds, Fr as recoveryDecisionMeaning, Ir as renderRecoveryExplanation, Mr as RetryRefused, Nr as obligationSeverityOf, Or as RecoveryDisposition, Pr as predictRecoveryDisposition, Sr as ObligationBlockedOn, Tr as ObligationSeverity, _r as ExplainedUnknownCall, br as IntegrityCheckStatus, gr as ExplainedSubmission, hr as ExplainedEvidence, jr as RetryRefusalReason, kr as RecoveryExplanation, vr as IntegrityCheck, wr as ObligationReport, xr as IntegrityReport, yr as IntegrityCheckName } from "../Records-BIiRLqlz.mjs";
2
2
  export { ExplainedEvidence, ExplainedSubmission, ExplainedUnknownCall, IntegrityCheck, IntegrityCheckName, IntegrityCheckStatus, IntegrityReport, ObligationBlockedOn, ObligationEntry, ObligationReport, ObligationSeverity, ObligationThresholds, RECOVERY_DECISION_MEANINGS, RecoveryDisposition, RecoveryExplanation, RetryCommand, RetryRefusalReason, RetryRefused, obligationSeverityOf, predictRecoveryDisposition, recoveryDecisionMeaning, renderRecoveryExplanation };
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { SubmissionId, ThreadId, ToolCallId } from "../core/Identifiers.mjs";
3
3
  import { QueueSequence } from "../core/Receipt.mjs";
4
- import { et as ToolCallUnknown, u as CanonicalSequence, z as SettlementOutcome } from "../Records-BEz5IFUu.mjs";
4
+ import { X as ToolCallPrepared, et as ToolCallUnknown, u as CanonicalSequence, z as SettlementOutcome } from "../Records-DR1xtbXY.mjs";
5
5
  import { AbortCommand, AbortIntent, ApprovalDecisionIntent, ChildAttachmentSnapshot, JoinSnapshot, ParentLinkage, SubmissionState, SuspensionSnapshot, UnknownResolutionIntent } from "./SubmissionLedger.mjs";
6
6
  import { OpenDelegationCallEvidence, OpenToolCallEvidence, PendingApprovalEvidence, RecoveryDecision } from "./Recovery.mjs";
7
- import { DateTime, Schema } from "effect";
7
+ import { DateTime, Effect, Schema } from "effect";
8
8
  //#region src/durable/Admin.ts
9
9
  var Admin_exports = /* @__PURE__ */ __exportAll({
10
10
  ExplainedEvidence: () => ExplainedEvidence,
@@ -63,13 +63,13 @@ var ExplainedSubmission = class extends Schema.Class("@effect-agent/thread/Expla
63
63
  readyAgeSeconds: Schema.optionalKey(AgeSeconds),
64
64
  parentLinkage: Schema.optionalKey(ParentLinkage)
65
65
  }) {};
66
- /** One durable Unknown Outcome and whether a covering resolution intent exists (DUR-017). */
66
+ /** One durable Unknown Outcome and whether its result is canonical (DUR-017). */
67
67
  var ExplainedUnknownCall = class extends Schema.Class("@effect-agent/thread/ExplainedUnknownCall")({
68
68
  toolCallId: ToolCallId,
69
69
  toolName: ToolCallUnknown.fields.toolName,
70
70
  reason: ToolCallUnknown.fields.reason,
71
71
  recordedAt: Schema.DateTimeUtcFromString,
72
- /** A durable `resolveUnknown` intent covers this call. */
72
+ /** A real canonical ToolCallSettled closes this call; an intent alone is not an outcome. */
73
73
  resolved: Schema.Boolean
74
74
  }) {};
75
75
  /**
@@ -84,6 +84,8 @@ var ExplainedEvidence = class extends Schema.Class("@effect-agent/thread/Explain
84
84
  recordedSettlementOutcome: Schema.optionalKey(SettlementOutcome),
85
85
  /** Prepared ordinary Tool Calls without a canonical outcome (DUR-009). */
86
86
  openToolCalls: Schema.Array(OpenToolCallEvidence),
87
+ /** Original prepared operation identities, arguments and recovery contracts; settled calls are excluded. */
88
+ pendingOperations: Schema.Array(ToolCallPrepared).pipe(Schema.withConstructorDefault(Effect.succeed([]))),
87
89
  /** Delegation Tool Calls with an open parent-side obligation. */
88
90
  openDelegationCalls: Schema.Array(OpenDelegationCallEvidence),
89
91
  /** Canonically requested approvals without a canonical decision. */
@@ -140,11 +142,11 @@ const RECOVERY_DECISION_MEANINGS = {
140
142
  FinalizeLedgerFromHistory: "The canonical settlement record exists: recovery rebuilds/finalizes the ledger from history and never rewrites history from the cached ledger status (DUR-011, DUR-015).",
141
143
  SettleAborted: "A durable abort intent exists with no reserved outcome and no open attached-child obligation: recovery settles aborted, first recording ToolCallUnknown audits for open ordinary calls — abort never asserts external rollback (durability §13).",
142
144
  MarkUnknown: "Prepared ordinary Tool Calls have no canonical outcome: recovery reconciles each open call and marks the remainder Unknown — never an automatic replay (DUR-009/DUR-017).",
143
- ResumePendingToolBatch: "A committed tool-declaring response has zero prepared and zero settled records: a claiming worker resumes the declared batch without model re-invocation and without Unknown (durability §15).",
145
+ ResumePendingToolBatch: "A committed tool-declaring response has zero prepared and zero settled records: a claiming worker checks unfinished operation contracts and resumes the declared batch without model re-invocation (durability §15).",
144
146
  AwaitApprovalDecision: "Canonically requested approvals lack decisions: the lane waits durably for the authorized resolveApproval path (recovery repairs a lost suspend transition from history).",
145
147
  ResumeSuspended: "Every pending approval has a durable decision: a claiming worker resumes the declared batch, appending the canonical ToolApprovalDecided records first.",
146
- AwaitUnknownResolution: "Unknown Outcomes lack covering resolutions: the lane stays blocked awaiting the authorized DUR-017 resolveUnknown path; the obligation stays visible, nothing replays.",
147
- ApplyUnknownResolutions: "Durable resolution intents cover every open call: recovery applies them canonically and reopens the lane.",
148
+ AwaitUnknownResolution: "Unknown Outcomes lack covering resolutions: this Submission stays parked awaiting the authorized DUR-017 resolveUnknown path; later eligible input may run, and the original obligation stays visible.",
149
+ ApplyUnknownResolutions: "Durable resolution intents cover every open call: recovery wakes the original Submission when required retry contracts are supported; its next claim applies canonical outcomes.",
148
150
  RevertJoining: "The Submission is joining without a canonical input record: recovery reverts it to ready — the input was never consumed and will be delivered exactly once later (DUR-016).",
149
151
  RepairJoinMarker: "The canonical joined input exists but the joined marker was lost: recovery repairs the marker only; the input reattaches, never duplicates (DUR-015/DUR-016).",
150
152
  SettleJoinedWithHost: "The host Run settled canonically: recovery settles this joined Submission with the host outcome — each joined Submission is owed its own settlement (DUR-002).",
@@ -297,8 +299,8 @@ const obligationSeverityOf = (ageSeconds, thresholds) => ageSeconds >= threshold
297
299
  /**
298
300
  * The mandatory-audit retry command (SEC-011): `author`/`reason` carry the same bounds as the
299
301
  * canonical abort command so every mutating administrative operation stays attributable. The
300
- * executed repair itself appends the deterministic `RepairAnnotated` audit record (DUR-013) —
301
- * retry adds no new canonical record type.
302
+ * operator and decision are logged. A repair with a claim also appends a best-effort
303
+ * `RepairAnnotated` attempt using that claim's epoch; state-only repairs do not append audits.
302
304
  */
303
305
  var RetryCommand = class extends Schema.Class("@effect-agent/thread/RetryCommand")({
304
306
  submissionId: SubmissionId,
@@ -312,7 +314,7 @@ const RetryRefusalReason = Schema.Literals([
312
314
  "await-approval-decision"
313
315
  ]);
314
316
  /**
315
- * Typed refusal of `retry` (plan §3): lanes blocked on `AwaitUnknownResolution` or
317
+ * Typed refusal of `retry` (plan §3): Submissions waiting on `AwaitUnknownResolution` or
316
318
  * `AwaitApprovalDecision` have their own authorized operations, and settled work is never
317
319
  * re-driven. The refusal names the classifier decision so the operator sees WHY.
318
320
  */