@yielded/agent-platform-cloudflare 0.1.0-beta.166 → 0.1.0-beta.168

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 (97) hide show
  1. package/dist/{Alarm-B0ODr1NE.mjs → Alarm-DxODgAZZ.mjs} +259 -159
  2. package/dist/Alarm-DxODgAZZ.mjs.map +1 -0
  3. package/dist/Alarm.d.mts +27 -36
  4. package/dist/Alarm.mjs +2 -2
  5. package/dist/BrowserCredentials-C5IWfi7f.d.mts +91 -0
  6. package/dist/BrowserCredentials.d.mts +2 -91
  7. package/dist/BrowserRestCapture.mjs +3 -3
  8. package/dist/BrowserRestCapture.mjs.map +1 -1
  9. package/dist/BrowserRestCrawl.mjs +6 -6
  10. package/dist/BrowserRestCrawl.mjs.map +1 -1
  11. package/dist/{BrowserSession-RfIzxGCH.mjs → BrowserSession-BfNmyayH.mjs} +5 -5
  12. package/dist/BrowserSession-BfNmyayH.mjs.map +1 -0
  13. package/dist/{BrowserSession-B969Xg-2.d.mts → BrowserSession-Bx0V1-6_.d.mts} +6 -3
  14. package/dist/BrowserSession.d.mts +1 -1
  15. package/dist/BrowserSession.mjs +2 -2
  16. package/dist/BrowserUse-AstK0jKX.mjs +1467 -0
  17. package/dist/BrowserUse-AstK0jKX.mjs.map +1 -0
  18. package/dist/BrowserUse.d.mts +83 -0
  19. package/dist/BrowserUse.mjs +2 -0
  20. package/dist/CloudflareBindings.d.mts +8 -1
  21. package/dist/CloudflareBindings.mjs +2 -2
  22. package/dist/CloudflareBindings.mjs.map +1 -1
  23. package/dist/{CloudflareBrowser-5an6m-Qb.mjs → CloudflareBrowser-Vt8qTdYW.mjs} +11 -13
  24. package/dist/CloudflareBrowser-Vt8qTdYW.mjs.map +1 -0
  25. package/dist/CloudflareBrowser.mjs +1 -1
  26. package/dist/CloudflareCodeMode.mjs +1 -1
  27. package/dist/CloudflareCodeMode.mjs.map +1 -1
  28. package/dist/{CloudflareConfig-qDrRLofL.d.mts → CloudflareConfig-C9MvPbX8.d.mts} +9 -11
  29. package/dist/CloudflareConfig.d.mts +1 -1
  30. package/dist/CloudflareConfig.mjs +9 -12
  31. package/dist/CloudflareConfig.mjs.map +1 -1
  32. package/dist/CloudflareMemory.d.mts +3 -25
  33. package/dist/CloudflareMemory.mjs +33 -31
  34. package/dist/CloudflareMemory.mjs.map +1 -1
  35. package/dist/CloudflareScheduling.mjs +8 -15
  36. package/dist/CloudflareScheduling.mjs.map +1 -1
  37. package/dist/CloudflareSubscriptions.mjs +9 -16
  38. package/dist/CloudflareSubscriptions.mjs.map +1 -1
  39. package/dist/CloudflareThreadClient-CZm0TvUe.mjs +588 -0
  40. package/dist/CloudflareThreadClient-CZm0TvUe.mjs.map +1 -0
  41. package/dist/CloudflareThreadClient-QsVzLGGZ.d.mts +2033 -0
  42. package/dist/CloudflareThreadClient.d.mts +2 -1796
  43. package/dist/CloudflareThreadClient.mjs +2 -382
  44. package/dist/{InteractiveBrowser-BbG3kGA9.mjs → InteractiveBrowser-LdKzQeLR.mjs} +18 -19
  45. package/dist/InteractiveBrowser-LdKzQeLR.mjs.map +1 -0
  46. package/dist/InteractiveBrowser.mjs +1 -1
  47. package/dist/{ThreadObject-BcfXbzSO.d.mts → ThreadObject-7s5XnlH-.d.mts} +103 -79
  48. package/dist/{ThreadObject-DHjrnlX4.mjs → ThreadObject-C0vrcDrw.mjs} +265 -66
  49. package/dist/ThreadObject-C0vrcDrw.mjs.map +1 -0
  50. package/dist/ThreadObject.d.mts +2 -2
  51. package/dist/ThreadObject.mjs +2 -3
  52. package/dist/WakeScheduler.d.mts +6 -5
  53. package/dist/WakeScheduler.mjs +15 -11
  54. package/dist/WakeScheduler.mjs.map +1 -1
  55. package/dist/index.d.mts +7 -6
  56. package/dist/index.mjs +7 -6
  57. package/dist/page-function-CmUCcyNP.mjs +11 -0
  58. package/dist/page-function-CmUCcyNP.mjs.map +1 -0
  59. package/dist/{prepared-admission-DMX5p9dC.mjs → prepared-admission-3UUq0zth.mjs} +3 -3
  60. package/dist/{prepared-admission-DMX5p9dC.mjs.map → prepared-admission-3UUq0zth.mjs.map} +1 -1
  61. package/package.json +1 -1
  62. package/src/Alarm.ts +510 -279
  63. package/src/BrowserRestCapture.ts +2 -2
  64. package/src/BrowserRestCrawl.ts +10 -14
  65. package/src/BrowserSession.ts +10 -2
  66. package/src/BrowserUse.ts +1541 -0
  67. package/src/CloudflareBindings.ts +13 -4
  68. package/src/CloudflareCodeMode.ts +1 -1
  69. package/src/CloudflareConfig.ts +9 -12
  70. package/src/CloudflareMemory.ts +21 -28
  71. package/src/CloudflareScheduling.ts +7 -15
  72. package/src/CloudflareSubscriptions.ts +11 -20
  73. package/src/CloudflareThreadClient.ts +289 -9
  74. package/src/InteractiveBrowser.ts +325 -323
  75. package/src/ThreadObject.ts +172 -52
  76. package/src/WakeScheduler.ts +29 -18
  77. package/src/index.ts +1 -0
  78. package/src/internal/browser-dom.ts +845 -0
  79. package/src/internal/browser-file-selection.ts +8 -1
  80. package/src/internal/browser-jev-dom.ts +344 -0
  81. package/src/internal/browser-quick-action.ts +7 -8
  82. package/src/internal/browser-session-lifecycle.ts +2 -5
  83. package/src/internal/crypto.ts +41 -0
  84. package/src/internal/due-queue.ts +5 -69
  85. package/src/internal/layers.ts +100 -17
  86. package/src/internal/live-text-protocol.ts +51 -0
  87. package/src/internal/live-text.ts +256 -0
  88. package/src/internal/page-function.ts +12 -0
  89. package/src/internal/prepared-admission.ts +1 -1
  90. package/src/internal/progress-wait.ts +19 -24
  91. package/src/internal/transport.ts +1 -1
  92. package/dist/Alarm-B0ODr1NE.mjs.map +0 -1
  93. package/dist/BrowserSession-RfIzxGCH.mjs.map +0 -1
  94. package/dist/CloudflareBrowser-5an6m-Qb.mjs.map +0 -1
  95. package/dist/CloudflareThreadClient.mjs.map +0 -1
  96. package/dist/InteractiveBrowser-BbG3kGA9.mjs.map +0 -1
  97. package/dist/ThreadObject-DHjrnlX4.mjs.map +0 -1
@@ -0,0 +1,2033 @@
1
+ import { ThreadObjectNamespace, ThreadObjectRpc } from "./CloudflareBindings.mjs";
2
+ import { t as AdmissionLimitExceeded } from "./CloudflareConfig-C9MvPbX8.mjs";
3
+ import { DurableAlarmError } from "./Alarm.mjs";
4
+ import { DurableSubmitAgent, DurableSubmitOptions, Receipt } from "@yielded/agent/durable-agent-runtime";
5
+ import { ThreadId } from "@yielded/agent/identifiers";
6
+ import { AbortCommand, AbortIntent, AdmissionConflict, AdmissionPolicyError, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, JoinedToHost, LedgerError, OwnershipLost, Settlement, SettlementConflict, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent } from "@yielded/agent/submission-ledger";
7
+ import { Context, Crypto, Effect, Layer, Schema, Stream } from "effect";
8
+ import { CanonicalRecordEnvelope, CanonicalSequence, DefinitionDigests, SubmissionSettledRecord } from "@yielded/agent/records";
9
+ import { AgentInputError } from "@yielded/agent/agent-error";
10
+ import { DigestError } from "@yielded/agent/digest";
11
+ import { DurableRuntimeFailpointError } from "@yielded/agent/durable-failpoint";
12
+ import { OperationDenied } from "@yielded/agent/operation-authorizer";
13
+ import { SubmissionStatus } from "@yielded/agent/submission-status";
14
+ import { AppendConflict, ThreadNotMaterialized, ThreadStoreError } from "@yielded/agent/thread-store";
15
+ import { Event } from "@yielded/agent/provisional-text";
16
+ //#region src/internal/live-text-protocol.d.ts
17
+ /**
18
+ * Reset replaces all drafts with a snapshot, streamed as native Text parts before live deltas.
19
+ * Each snapshot starts a fresh streamId. Its sequences are unrelated to canonical sequences.
20
+ */
21
+ declare const Frame: Schema.Union<readonly [Schema.TaggedStruct<"Reset", {
22
+ readonly schemaVersion: Schema.Literal<1>;
23
+ readonly streamId: Schema.NonEmptyString;
24
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
25
+ readonly sequence: Schema.Literal<0>;
26
+ }>, Schema.TaggedStruct<"Event", {
27
+ readonly schemaVersion: Schema.Literal<1>;
28
+ readonly streamId: Schema.NonEmptyString;
29
+ readonly sequence: Schema.Int;
30
+ readonly event: Schema.Union<readonly [Schema.TaggedStruct<"Text", {
31
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
32
+ readonly submissionId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">;
33
+ readonly attemptId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AttemptId">;
34
+ readonly runId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/RunId">;
35
+ readonly turnId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/TurnId">;
36
+ readonly generation: Schema.Int;
37
+ readonly part: Schema.Union<readonly [Schema.Struct<{
38
+ readonly type: Schema.tag<"text-start">;
39
+ readonly id: Schema.String;
40
+ readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>;
41
+ readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>;
42
+ }>, Schema.Struct<{
43
+ readonly type: Schema.tag<"text-delta">;
44
+ readonly id: Schema.String;
45
+ readonly delta: Schema.String;
46
+ readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>;
47
+ readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>;
48
+ }>, Schema.Struct<{
49
+ readonly type: Schema.tag<"text-end">;
50
+ readonly id: Schema.String;
51
+ readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>;
52
+ readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>;
53
+ }>]>;
54
+ }>, Schema.TaggedStruct<"Discard", {
55
+ threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
56
+ submissionId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">;
57
+ attemptId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AttemptId">;
58
+ runId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/RunId">;
59
+ turnId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/TurnId">;
60
+ generation: Schema.Int;
61
+ }>, Schema.TaggedStruct<"AttemptEnded", {
62
+ threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
63
+ submissionId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">;
64
+ attemptId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AttemptId">;
65
+ }>]>;
66
+ }>]>;
67
+ type Frame = typeof Frame.Type;
68
+ declare namespace CloudflareThreadClient_d_exports {
69
+ export { AbortRecorded, ApprovalRecorded, AwaitProgressRequest, CancelProgressRequest, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientProgressFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareThreadClient, HostFailed, HostFailure, HostProtocolError, HostResponse, Frame as LiveTextFrame, ObservePageRequest, ObservedPage, ProgressCancelled, ProgressObserved, SettlementReached, SettlementRecordReached, SubmissionStatusResponse, SubmitRequest, SubmitSucceeded, ThreadClientError, UnknownResolutionRecorded, boundHostDiagnostic, decodeAbortCommand, decodeApprovalDecisionCommand, decodeAwaitProgressRequest, decodeCancelProgressRequest, decodeHostResponse, decodeObservePageRequest, decodeReceipt, decodeSubmitRequest, decodeUnknownResolutionCommand, encodeAbortCommand, encodeApprovalDecisionCommand, encodeAwaitProgressRequest, encodeCancelProgressRequest, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand };
70
+ }
71
+ /** Truncate a diagnostic string to the host protocol's bounded length. */
72
+ declare const boundHostDiagnostic: (value: string) => string;
73
+ declare const HostProtocolError_base: Schema.Class<HostProtocolError, Schema.TaggedStruct<"HostProtocolError", {
74
+ readonly message: Schema.String;
75
+ }>, import("effect/Cause").YieldableError>;
76
+ /**
77
+ * The envelope itself could not be honored: the Object could not decode the request, or a
78
+ * response could not be encoded/decoded. Never carries operation semantics.
79
+ */
80
+ declare class HostProtocolError extends HostProtocolError_base {}
81
+ declare const ThreadClientError_base: Schema.Class<ThreadClientError, Schema.TaggedStruct<"ThreadClientError", {
82
+ readonly threadId: Schema.String;
83
+ readonly message: Schema.String;
84
+ readonly cause: Schema.optionalKey<Schema.Defect>;
85
+ /** Cloudflare's own classification for a failure safe to retry with a fresh stub. */
86
+ readonly retryable: Schema.optionalKey<Schema.Boolean>;
87
+ /** Cloudflare overloads are surfaced immediately instead of adding retry pressure. */
88
+ readonly overloaded: Schema.optionalKey<Schema.Boolean>;
89
+ }>, import("effect/Cause").YieldableError>;
90
+ /** The Worker-side stub call itself failed (RPC rejection, overload, eviction mid-call). */
91
+ declare class ThreadClientError extends ThreadClientError_base {}
92
+ declare const SubmitRequest_base: Schema.Class<SubmitRequest, Schema.Struct<{
93
+ readonly agentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
94
+ readonly principal: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/Principal">;
95
+ readonly idempotencyKey: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/IdempotencyKey">;
96
+ readonly admissionGroup: Schema.optionalKey<Schema.NonEmptyString>;
97
+ readonly admissionFence: Schema.optionalKey<Schema.Struct<{
98
+ readonly policyId: Schema.NonEmptyString;
99
+ readonly key: Schema.NonEmptyString;
100
+ readonly revision: Schema.NonEmptyString;
101
+ }>>;
102
+ readonly workerAdmission: Schema.optionalKey<Schema.Struct<{
103
+ readonly origin: Schema.Struct<{
104
+ readonly worker: Schema.Struct<{
105
+ readonly schemaVersion: Schema.Literal<1>;
106
+ readonly delegationId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/DelegationId">;
107
+ readonly targetAgentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
108
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
109
+ }>;
110
+ readonly source: Schema.Union<readonly [Schema.Struct<{
111
+ readonly _tag: Schema.Literal<"tool">;
112
+ readonly agentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
113
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
114
+ readonly runId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/RunId">;
115
+ readonly toolCallId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ToolCallId">;
116
+ }>, Schema.Struct<{
117
+ readonly _tag: Schema.Literal<"programmatic">;
118
+ readonly agentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
119
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
120
+ }>]>;
121
+ readonly continuationOf: Schema.optionalKey<Schema.Struct<{
122
+ readonly worker: Schema.Struct<{
123
+ readonly schemaVersion: Schema.Literal<1>;
124
+ readonly delegationId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/DelegationId">;
125
+ readonly targetAgentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
126
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
127
+ }>;
128
+ readonly receipt: typeof Receipt;
129
+ readonly settlementId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SettlementId">;
130
+ }>>;
131
+ readonly budgetScope: Schema.Literals<readonly ["source-subtree", "worker-run"]>;
132
+ readonly lifecycle: Schema.optionalKey<Schema.Literal<"assignment">>;
133
+ readonly targetDigests: typeof DefinitionDigests;
134
+ readonly policy: Schema.toCodecJson<typeof import("@yielded/agent/agent-policy").AgentPolicy>;
135
+ readonly budget: Schema.Struct<{
136
+ readonly caps: typeof import("@yielded/agent/subagent-contract").SubagentDelegationCaps;
137
+ readonly allocation: typeof import("@yielded/agent/subagent-contract").SubagentReservationAmounts;
138
+ readonly descendantInvocations: Schema.optionalKey<Schema.Natural>;
139
+ }>;
140
+ readonly grant: typeof import("@yielded/agent/subagent-contract").SubagentGrant;
141
+ readonly depth: Schema.Int;
142
+ readonly toolCallAllowance: Schema.optionalKey<Schema.Int>;
143
+ readonly firstMessageId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/IdempotencyKey">;
144
+ readonly createdAtMillis: Schema.Natural;
145
+ readonly expiresAtMillis: Schema.Natural;
146
+ readonly reporting: Schema.optionalKey<Schema.Struct<{
147
+ readonly mode: Schema.optionalKey<Schema.Literal<"standard">>;
148
+ readonly sourceDigests: typeof DefinitionDigests;
149
+ readonly destinationDelegationId: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "@effect-agent/core/DelegationId">>;
150
+ readonly returnAddress: Schema.optionalKey<Schema.Struct<{
151
+ readonly input: Schema.declare<Schema.Json, Schema.Json>;
152
+ readonly principal: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/Principal">;
153
+ readonly policy: Schema.toCodecJson<typeof import("@yielded/agent/agent-policy").AgentPolicy>;
154
+ readonly depth: Schema.Natural;
155
+ readonly grant: Schema.optionalKey<typeof import("@yielded/agent/subagent-contract").SubagentGrant>;
156
+ readonly workerAdmission: Schema.optionalKey<Schema.declare<Schema.Json, Schema.Json>>;
157
+ }>>;
158
+ }>>;
159
+ }>;
160
+ readonly executionRunId: Schema.NullOr<Schema.brand<Schema.NonEmptyString, "@effect-agent/core/RunId">>;
161
+ readonly messageId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/IdempotencyKey">;
162
+ readonly parameters: Schema.declare<Schema.Json, Schema.Json>;
163
+ readonly createdAtMillis: Schema.Natural;
164
+ readonly sourceSubmissionId: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">>;
165
+ readonly deliveryPrincipal: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/Principal">>;
166
+ readonly reportKind: Schema.optionalKey<Schema.Literal<"update">>;
167
+ }>>;
168
+ readonly messageAdmission: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
169
+ readonly schemaVersion: Schema.Literal<1>;
170
+ readonly message: Schema.Struct<{
171
+ readonly ownerThreadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
172
+ readonly messageId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/IdempotencyKey">;
173
+ }>;
174
+ readonly peerName: Schema.NonEmptyString;
175
+ readonly sender: Schema.Struct<{
176
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
177
+ readonly agentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
178
+ }>;
179
+ readonly returnAddress: Schema.Struct<{
180
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
181
+ readonly agentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
182
+ }>;
183
+ readonly inReplyTo: Schema.optionalKey<Schema.Struct<{
184
+ readonly ownerThreadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
185
+ readonly messageId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/IdempotencyKey">;
186
+ }>>;
187
+ }>, Schema.Union<readonly [Schema.Struct<{
188
+ readonly _tag: Schema.Literal<"WorkerCompletion">;
189
+ readonly budgetExhausted: Schema.Boolean;
190
+ readonly schemaVersion: Schema.Literal<1>;
191
+ readonly report: Schema.Union<readonly [Schema.Struct<{
192
+ readonly _tag: Schema.Literal<"Settled">;
193
+ readonly worker: Schema.Struct<{
194
+ readonly schemaVersion: Schema.Literal<1>;
195
+ readonly delegationId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/DelegationId">;
196
+ readonly targetAgentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
197
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
198
+ }>;
199
+ readonly receipt: typeof Receipt;
200
+ readonly runId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/RunId">;
201
+ readonly settlementId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SettlementId">;
202
+ readonly outcome: Schema.Literal<"completed">;
203
+ readonly result: Schema.Union<readonly [Schema.Codec<Schema.Json, Schema.Json, never, never>]>;
204
+ }>, Schema.Struct<{
205
+ readonly _tag: Schema.Literal<"Settled">;
206
+ readonly worker: Schema.Struct<{
207
+ readonly schemaVersion: Schema.Literal<1>;
208
+ readonly delegationId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/DelegationId">;
209
+ readonly targetAgentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
210
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
211
+ }>;
212
+ readonly receipt: typeof Receipt;
213
+ readonly runId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/RunId">;
214
+ readonly settlementId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SettlementId">;
215
+ readonly outcome: Schema.Literals<readonly ["failed", "aborted"]>;
216
+ readonly failure: typeof import("@yielded/agent/subagent-contract").SubagentExecutionFailure;
217
+ }>]>;
218
+ }>, Schema.Struct<{
219
+ readonly _tag: Schema.Literal<"WorkerUpdate">;
220
+ readonly schemaVersion: Schema.Literal<1>;
221
+ readonly worker: Schema.Struct<{
222
+ readonly schemaVersion: Schema.Literal<1>;
223
+ readonly delegationId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/DelegationId">;
224
+ readonly targetAgentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
225
+ readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
226
+ }>;
227
+ readonly update: typeof import("@yielded/agent/agent-updates").Update;
228
+ }>]>]>>;
229
+ readonly definitions: typeof DefinitionDigests;
230
+ readonly inputPayload: Schema.declare<Schema.Json, Schema.Json>;
231
+ }>, {}>;
232
+ /**
233
+ * One durable submission, input ALREADY encoded by the caller through the Agent Binding's
234
+ * input schema (the Worker bundles the same Agent definitions as the Object, so schema
235
+ * validation happens client-side; the resolved Binding re-validates at claim time). The
236
+ * Thread identity is deliberately absent — the addressed Object IS the lane.
237
+ */
238
+ declare class SubmitRequest extends SubmitRequest_base {}
239
+ declare const ObservePageRequest_base: Schema.Class<ObservePageRequest, Schema.Struct<{
240
+ readonly afterSequence: Schema.optionalKey<Schema.brand<Schema.Natural, "@effect-agent/thread/CanonicalSequence">>;
241
+ readonly limit: Schema.Int;
242
+ }>, {}>;
243
+ /** One bounded page of canonical records after an optional sequence. */
244
+ declare class ObservePageRequest extends ObservePageRequest_base {}
245
+ declare const AwaitProgressRequest_base: Schema.Class<AwaitProgressRequest, Schema.Struct<{
246
+ readonly afterSequence: Schema.brand<Schema.Natural, "@effect-agent/thread/CanonicalSequence">;
247
+ readonly waiterId: Schema.String;
248
+ }>, {}>;
249
+ /** One event-driven wait for canonical progress strictly after this sequence. */
250
+ declare class AwaitProgressRequest extends AwaitProgressRequest_base {}
251
+ declare const CancelProgressRequest_base: Schema.Class<CancelProgressRequest, Schema.Struct<{
252
+ readonly waiterId: Schema.String;
253
+ }>, {}>;
254
+ /** Best-effort cancellation of one in-flight progress RPC. */
255
+ declare class CancelProgressRequest extends CancelProgressRequest_base {}
256
+ /**
257
+ * Every typed failure a host entry point can produce, plus the protocol's own errors. Same
258
+ * closed-union discipline as the WP2 `PortFailure`: members re-decode to the SAME tagged
259
+ * classes on the Worker side; `cause` chains travel as Schema defects without instance
260
+ * fidelity (plan §2.8).
261
+ */
262
+ declare const HostFailure: Schema.Union<readonly [typeof AgentInputError, typeof DigestError, typeof AdmissionConflict, typeof AdmissionPolicyError, typeof SettlementConflict, typeof ApprovalConflict, typeof UnknownResolutionConflict, typeof JoinedToHost, typeof LedgerError, typeof OwnershipLost, typeof ThreadStoreError, typeof ThreadNotMaterialized, typeof AppendConflict, typeof DurableRuntimeFailpointError, typeof AdmissionLimitExceeded, typeof DurableAlarmError, typeof OperationDenied, typeof HostProtocolError]>;
263
+ type HostFailure = typeof HostFailure.Type;
264
+ declare const SubmitSucceeded_base: Schema.Class<SubmitSucceeded, Schema.TaggedStruct<"SubmitSucceeded", {
265
+ readonly receipt: typeof Receipt;
266
+ }>, {}>;
267
+ declare class SubmitSucceeded extends SubmitSucceeded_base {}
268
+ declare const SubmissionStatusResponse_base: Schema.Class<SubmissionStatusResponse, Schema.TaggedStruct<"SubmissionStatusResponse", {
269
+ readonly status: Schema.Union<readonly [typeof import("@yielded/agent/submission-status").PendingSubmission, typeof import("@yielded/agent/submission-status").SettledSubmission]>;
270
+ }>, {}>;
271
+ declare class SubmissionStatusResponse extends SubmissionStatusResponse_base {}
272
+ declare const SettlementReached_base: Schema.Class<SettlementReached, Schema.TaggedStruct<"SettlementReached", {
273
+ readonly settlement: typeof Settlement;
274
+ }>, {}>;
275
+ declare class SettlementReached extends SettlementReached_base {}
276
+ declare const SettlementRecordReached_base: Schema.Class<SettlementRecordReached, Schema.TaggedStruct<"SettlementRecordReached", {
277
+ readonly record: Schema.refine<SubmissionSettledRecord, typeof import("@yielded/agent/records").SubmissionSettled>;
278
+ }>, {}>;
279
+ /** The exact canonical record of an operationally finalized Submission. */
280
+ declare class SettlementRecordReached extends SettlementRecordReached_base {}
281
+ declare const ObservedPage_base: Schema.Class<ObservedPage, Schema.TaggedStruct<"ObservedPage", {
282
+ readonly records: Schema.$Array<typeof CanonicalRecordEnvelope>;
283
+ }>, {}>;
284
+ declare class ObservedPage extends ObservedPage_base {}
285
+ declare const ProgressObserved_base: Schema.Class<ProgressObserved, Schema.TaggedStruct<"ProgressObserved", {}>, {}>;
286
+ /** A record was already committed or an incarnation-local hint says the caller should re-read. */
287
+ declare class ProgressObserved extends ProgressObserved_base {}
288
+ declare const ProgressCancelled_base: Schema.Class<ProgressCancelled, Schema.TaggedStruct<"ProgressCancelled", {}>, {}>;
289
+ declare class ProgressCancelled extends ProgressCancelled_base {}
290
+ declare const AbortRecorded_base: Schema.Class<AbortRecorded, Schema.TaggedStruct<"AbortRecorded", {
291
+ readonly intent: typeof AbortIntent;
292
+ }>, {}>;
293
+ declare class AbortRecorded extends AbortRecorded_base {}
294
+ declare const ApprovalRecorded_base: Schema.Class<ApprovalRecorded, Schema.TaggedStruct<"ApprovalRecorded", {
295
+ readonly intent: typeof ApprovalDecisionIntent;
296
+ }>, {}>;
297
+ declare class ApprovalRecorded extends ApprovalRecorded_base {}
298
+ declare const UnknownResolutionRecorded_base: Schema.Class<UnknownResolutionRecorded, Schema.TaggedStruct<"UnknownResolutionRecorded", {
299
+ readonly intent: typeof UnknownResolutionIntent;
300
+ }>, {}>;
301
+ declare class UnknownResolutionRecorded extends UnknownResolutionRecorded_base {}
302
+ declare const HostFailed_base: Schema.Class<HostFailed, Schema.TaggedStruct<"HostFailed", {
303
+ readonly failure: Schema.Union<readonly [typeof AgentInputError, typeof DigestError, typeof AdmissionConflict, typeof AdmissionPolicyError, typeof SettlementConflict, typeof ApprovalConflict, typeof UnknownResolutionConflict, typeof JoinedToHost, typeof LedgerError, typeof OwnershipLost, typeof ThreadStoreError, typeof ThreadNotMaterialized, typeof AppendConflict, typeof DurableRuntimeFailpointError, typeof AdmissionLimitExceeded, typeof DurableAlarmError, typeof OperationDenied, typeof HostProtocolError]>;
304
+ }>, {}>;
305
+ /** The entry point failed TYPED on the Object; the failure re-decodes verbatim. */
306
+ declare class HostFailed extends HostFailed_base {}
307
+ /** The uniform answer of one host entry point. Callers narrow by the tag their call implies. */
308
+ declare const HostResponse: Schema.Union<readonly [typeof SubmitSucceeded, typeof SettlementReached, typeof SettlementRecordReached, typeof SubmissionStatusResponse, typeof ObservedPage, typeof ProgressObserved, typeof ProgressCancelled, typeof AbortRecorded, typeof ApprovalRecorded, typeof UnknownResolutionRecorded, typeof HostFailed]>;
309
+ type HostResponse = typeof HostResponse.Type;
310
+ declare const decodeSubmitRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<SubmitRequest, Schema.SchemaError, never>;
311
+ declare const encodeSubmitRequest: (input: SubmitRequest, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
312
+ readonly agentId: string;
313
+ readonly principal: string;
314
+ readonly idempotencyKey: string;
315
+ readonly admissionGroup?: string | undefined;
316
+ readonly admissionFence?: {
317
+ readonly policyId: string;
318
+ readonly key: string;
319
+ readonly revision: string;
320
+ } | undefined;
321
+ readonly workerAdmission?: {
322
+ readonly origin: {
323
+ readonly worker: {
324
+ readonly schemaVersion: 1;
325
+ readonly delegationId: string;
326
+ readonly targetAgentId: string;
327
+ readonly threadId: string;
328
+ };
329
+ readonly source: {
330
+ readonly _tag: "tool";
331
+ readonly agentId: string;
332
+ readonly threadId: string;
333
+ readonly runId: string;
334
+ readonly toolCallId: string;
335
+ } | {
336
+ readonly _tag: "programmatic";
337
+ readonly agentId: string;
338
+ readonly threadId: string;
339
+ };
340
+ readonly continuationOf?: {
341
+ readonly worker: {
342
+ readonly schemaVersion: 1;
343
+ readonly delegationId: string;
344
+ readonly targetAgentId: string;
345
+ readonly threadId: string;
346
+ };
347
+ readonly receipt: {
348
+ readonly receiptId: string;
349
+ readonly submissionId: string;
350
+ readonly threadId: string;
351
+ readonly queueSequence: number;
352
+ };
353
+ readonly settlementId: string;
354
+ } | undefined;
355
+ readonly budgetScope: "source-subtree" | "worker-run";
356
+ readonly lifecycle?: "assignment" | undefined;
357
+ readonly targetDigests: {
358
+ readonly agent: string;
359
+ readonly model: string;
360
+ readonly tools: string;
361
+ readonly replay?: {
362
+ readonly agent: string;
363
+ readonly agentBehavior?: string | undefined;
364
+ readonly tools: {
365
+ readonly [x: string]: string;
366
+ };
367
+ } | undefined;
368
+ };
369
+ readonly policy: Schema.Json;
370
+ readonly budget: {
371
+ readonly caps: {
372
+ readonly maxTotalChildInvocations?: number | undefined;
373
+ readonly maxConcurrentChildren?: number | undefined;
374
+ readonly maxTurns?: number | undefined;
375
+ readonly maxToolCalls?: number | undefined;
376
+ readonly maxDurationMillis?: number | undefined;
377
+ readonly maxInputTokens?: number | undefined;
378
+ readonly maxOutputTokens?: number | undefined;
379
+ readonly maxCostMicrousd?: number | undefined;
380
+ readonly maxResultBytes?: number | undefined;
381
+ };
382
+ readonly allocation: {
383
+ readonly turns: number;
384
+ readonly toolCalls: number;
385
+ readonly durationMillis: number;
386
+ readonly inputTokens: number;
387
+ readonly outputTokens: number;
388
+ readonly costMicrousd: number;
389
+ readonly resultBytes: number;
390
+ };
391
+ readonly descendantInvocations?: number | undefined;
392
+ };
393
+ readonly grant: {
394
+ readonly allowedToolNames: readonly string[];
395
+ readonly maxDepth: number;
396
+ readonly childLifetimes?: readonly ("attached" | "background")[] | undefined;
397
+ };
398
+ readonly depth: number;
399
+ readonly toolCallAllowance?: number | undefined;
400
+ readonly firstMessageId: string;
401
+ readonly createdAtMillis: number;
402
+ readonly expiresAtMillis: number;
403
+ readonly reporting?: {
404
+ readonly mode?: "standard" | undefined;
405
+ readonly sourceDigests: {
406
+ readonly agent: string;
407
+ readonly model: string;
408
+ readonly tools: string;
409
+ readonly replay?: {
410
+ readonly agent: string;
411
+ readonly agentBehavior?: string | undefined;
412
+ readonly tools: {
413
+ readonly [x: string]: string;
414
+ };
415
+ } | undefined;
416
+ };
417
+ readonly destinationDelegationId?: string | undefined;
418
+ readonly returnAddress?: {
419
+ readonly input: Schema.Json;
420
+ readonly principal: string;
421
+ readonly policy: Schema.Json;
422
+ readonly depth: number;
423
+ readonly grant?: {
424
+ readonly allowedToolNames: readonly string[];
425
+ readonly maxDepth: number;
426
+ readonly childLifetimes?: readonly ("attached" | "background")[] | undefined;
427
+ } | undefined;
428
+ readonly workerAdmission?: Schema.Json | undefined;
429
+ } | undefined;
430
+ } | undefined;
431
+ };
432
+ readonly executionRunId: string | null;
433
+ readonly messageId: string;
434
+ readonly parameters: Schema.Json;
435
+ readonly createdAtMillis: number;
436
+ readonly sourceSubmissionId?: string | undefined;
437
+ readonly deliveryPrincipal?: string | undefined;
438
+ readonly reportKind?: "update" | undefined;
439
+ } | undefined;
440
+ readonly messageAdmission?: {
441
+ readonly schemaVersion: 1;
442
+ readonly message: {
443
+ readonly ownerThreadId: string;
444
+ readonly messageId: string;
445
+ };
446
+ readonly peerName: string;
447
+ readonly sender: {
448
+ readonly threadId: string;
449
+ readonly agentId: string;
450
+ };
451
+ readonly returnAddress: {
452
+ readonly threadId: string;
453
+ readonly agentId: string;
454
+ };
455
+ readonly inReplyTo?: {
456
+ readonly ownerThreadId: string;
457
+ readonly messageId: string;
458
+ } | undefined;
459
+ } | {
460
+ readonly _tag: "WorkerCompletion";
461
+ readonly budgetExhausted: boolean;
462
+ readonly schemaVersion: 1;
463
+ readonly report: {
464
+ readonly _tag: "Settled";
465
+ readonly worker: {
466
+ readonly schemaVersion: 1;
467
+ readonly delegationId: string;
468
+ readonly targetAgentId: string;
469
+ readonly threadId: string;
470
+ };
471
+ readonly receipt: {
472
+ readonly receiptId: string;
473
+ readonly submissionId: string;
474
+ readonly threadId: string;
475
+ readonly queueSequence: number;
476
+ };
477
+ readonly runId: string;
478
+ readonly settlementId: string;
479
+ readonly outcome: "completed";
480
+ readonly result: Schema.Json;
481
+ } | {
482
+ readonly _tag: "Settled";
483
+ readonly worker: {
484
+ readonly schemaVersion: 1;
485
+ readonly delegationId: string;
486
+ readonly targetAgentId: string;
487
+ readonly threadId: string;
488
+ };
489
+ readonly receipt: {
490
+ readonly receiptId: string;
491
+ readonly submissionId: string;
492
+ readonly threadId: string;
493
+ readonly queueSequence: number;
494
+ };
495
+ readonly runId: string;
496
+ readonly settlementId: string;
497
+ readonly outcome: "aborted" | "failed";
498
+ readonly failure: {
499
+ readonly _tag: "SubagentExecutionFailure";
500
+ readonly delegationId: string;
501
+ readonly targetAgentId: string;
502
+ readonly classification: "child-aborted" | "child-compatibility" | "child-failed" | "declaration-unavailable" | "establishment-denied";
503
+ readonly childThreadId?: string | undefined;
504
+ readonly childSubmissionId?: string | undefined;
505
+ readonly childRunId?: string | undefined;
506
+ readonly errorTag: string;
507
+ readonly message: string;
508
+ };
509
+ };
510
+ } | {
511
+ readonly _tag: "WorkerUpdate";
512
+ readonly schemaVersion: 1;
513
+ readonly worker: {
514
+ readonly schemaVersion: 1;
515
+ readonly delegationId: string;
516
+ readonly targetAgentId: string;
517
+ readonly threadId: string;
518
+ };
519
+ readonly update: {
520
+ readonly schemaVersion: 1;
521
+ readonly agentId: string;
522
+ readonly threadId: string;
523
+ readonly runId: string;
524
+ readonly updateId: string;
525
+ readonly sequence: number;
526
+ readonly value: Schema.Json;
527
+ };
528
+ } | undefined;
529
+ readonly definitions: {
530
+ readonly agent: string;
531
+ readonly model: string;
532
+ readonly tools: string;
533
+ readonly replay?: {
534
+ readonly agent: string;
535
+ readonly agentBehavior?: string | undefined;
536
+ readonly tools: {
537
+ readonly [x: string]: string;
538
+ };
539
+ } | undefined;
540
+ };
541
+ readonly inputPayload: Schema.Json;
542
+ }, Schema.SchemaError, never>;
543
+ declare const decodeReceipt: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<Receipt, Schema.SchemaError, never>;
544
+ declare const encodeReceipt: (input: Receipt, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
545
+ readonly receiptId: string;
546
+ readonly submissionId: string;
547
+ readonly threadId: string;
548
+ readonly queueSequence: number;
549
+ }, Schema.SchemaError, never>;
550
+ declare const decodeObservePageRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<ObservePageRequest, Schema.SchemaError, never>;
551
+ declare const encodeObservePageRequest: (input: ObservePageRequest, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
552
+ readonly afterSequence?: number | undefined;
553
+ readonly limit: number;
554
+ }, Schema.SchemaError, never>;
555
+ declare const decodeAwaitProgressRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AwaitProgressRequest, Schema.SchemaError, never>;
556
+ declare const encodeAwaitProgressRequest: (input: AwaitProgressRequest, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
557
+ readonly afterSequence: number;
558
+ readonly waiterId: string;
559
+ }, Schema.SchemaError, never>;
560
+ declare const decodeCancelProgressRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<CancelProgressRequest, Schema.SchemaError, never>;
561
+ declare const encodeCancelProgressRequest: (input: CancelProgressRequest, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
562
+ readonly waiterId: string;
563
+ }, Schema.SchemaError, never>;
564
+ declare const decodeAbortCommand: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AbortCommand, Schema.SchemaError, never>;
565
+ declare const encodeAbortCommand: (input: AbortCommand, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
566
+ readonly submissionId: string;
567
+ readonly author: string;
568
+ readonly reason: string;
569
+ }, Schema.SchemaError, never>;
570
+ declare const decodeApprovalDecisionCommand: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<ApprovalDecisionCommand, Schema.SchemaError, never>;
571
+ declare const encodeApprovalDecisionCommand: (input: ApprovalDecisionCommand, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
572
+ readonly submissionId: string;
573
+ readonly toolCallId: string;
574
+ readonly decision: "approved" | "denied";
575
+ readonly resolver: string;
576
+ readonly reason: string;
577
+ }, Schema.SchemaError, never>;
578
+ declare const decodeUnknownResolutionCommand: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<UnknownResolutionCommand, Schema.SchemaError, never>;
579
+ declare const encodeUnknownResolutionCommand: (input: UnknownResolutionCommand, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
580
+ readonly submissionId: string;
581
+ readonly toolCallId: string;
582
+ readonly author: string;
583
+ readonly reason: string;
584
+ readonly resolution: {
585
+ readonly _tag: "SafeToRetry";
586
+ } | {
587
+ readonly _tag: "CompletedWithResult";
588
+ readonly result: Schema.Json;
589
+ readonly isFailure: boolean;
590
+ } | {
591
+ readonly _tag: "NeverHappened";
592
+ } | {
593
+ readonly _tag: "AbortSubmission";
594
+ };
595
+ }, Schema.SchemaError, never>;
596
+ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | HostFailed | ObservedPage | ProgressCancelled | ProgressObserved | SettlementReached | SettlementRecordReached | SubmissionStatusResponse | SubmitSucceeded | UnknownResolutionRecorded, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
597
+ readonly _tag: "SubmitSucceeded";
598
+ readonly receipt: {
599
+ readonly receiptId: string;
600
+ readonly submissionId: string;
601
+ readonly threadId: string;
602
+ readonly queueSequence: number;
603
+ };
604
+ } | {
605
+ readonly _tag: "SubmissionStatusResponse";
606
+ readonly status: {
607
+ readonly _tag: "pending";
608
+ } | {
609
+ readonly _tag: "settled";
610
+ readonly settlement: {
611
+ readonly submissionId: string;
612
+ readonly settlementId: string;
613
+ readonly receiptId: string;
614
+ readonly outcome: "aborted" | "completed" | "failed";
615
+ readonly runDisposition?: Schema.Json | undefined;
616
+ readonly usageSummary?: {
617
+ readonly modelCalls: number;
618
+ readonly inputTokens: {
619
+ readonly total: number;
620
+ readonly uncached: number;
621
+ readonly cacheRead: number;
622
+ readonly cacheWrite: number;
623
+ };
624
+ readonly outputTokens: {
625
+ readonly total: number;
626
+ readonly text: number;
627
+ readonly reasoning: number;
628
+ };
629
+ readonly webSearchCalls?: number | undefined;
630
+ readonly costMicrousd: number;
631
+ readonly byModel: readonly {
632
+ readonly provider: string;
633
+ readonly model: string;
634
+ readonly responseModel?: string | undefined;
635
+ readonly serviceTier?: string | undefined;
636
+ readonly pricingVersion?: string | undefined;
637
+ readonly modelCalls: number;
638
+ readonly inputTokens: {
639
+ readonly total: number;
640
+ readonly uncached: number;
641
+ readonly cacheRead: number;
642
+ readonly cacheWrite: number;
643
+ };
644
+ readonly outputTokens: {
645
+ readonly total: number;
646
+ readonly text: number;
647
+ readonly reasoning: number;
648
+ };
649
+ readonly webSearchCalls?: number | undefined;
650
+ readonly costMicrousd: number;
651
+ }[];
652
+ readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
653
+ readonly pricingStatus?: "complete" | "partial" | "unknown" | undefined;
654
+ readonly unobservedModelCalls?: number | undefined;
655
+ } | undefined;
656
+ readonly failure?: {
657
+ readonly errorTag: string;
658
+ readonly message: string;
659
+ readonly diagnostic?: import("@yielded/agent/failure-diagnostic").Diagnostic | undefined;
660
+ readonly context?: {
661
+ readonly agentId?: string | undefined;
662
+ readonly threadId?: string | undefined;
663
+ readonly runId?: string | undefined;
664
+ readonly submissionId?: string | undefined;
665
+ readonly attemptId?: string | undefined;
666
+ readonly turnId?: string | undefined;
667
+ readonly toolCallId?: string | undefined;
668
+ readonly toolName?: string | undefined;
669
+ readonly callId?: string | undefined;
670
+ readonly check?: string | undefined;
671
+ readonly operation?: string | undefined;
672
+ } | undefined;
673
+ } | undefined;
674
+ readonly settledAt: string;
675
+ };
676
+ };
677
+ } | {
678
+ readonly _tag: "SettlementReached";
679
+ readonly settlement: {
680
+ readonly submissionId: string;
681
+ readonly settlementId: string;
682
+ readonly receiptId: string;
683
+ readonly outcome: "aborted" | "completed" | "failed";
684
+ readonly runDisposition?: Schema.Json | undefined;
685
+ readonly usageSummary?: {
686
+ readonly modelCalls: number;
687
+ readonly inputTokens: {
688
+ readonly total: number;
689
+ readonly uncached: number;
690
+ readonly cacheRead: number;
691
+ readonly cacheWrite: number;
692
+ };
693
+ readonly outputTokens: {
694
+ readonly total: number;
695
+ readonly text: number;
696
+ readonly reasoning: number;
697
+ };
698
+ readonly webSearchCalls?: number | undefined;
699
+ readonly costMicrousd: number;
700
+ readonly byModel: readonly {
701
+ readonly provider: string;
702
+ readonly model: string;
703
+ readonly responseModel?: string | undefined;
704
+ readonly serviceTier?: string | undefined;
705
+ readonly pricingVersion?: string | undefined;
706
+ readonly modelCalls: number;
707
+ readonly inputTokens: {
708
+ readonly total: number;
709
+ readonly uncached: number;
710
+ readonly cacheRead: number;
711
+ readonly cacheWrite: number;
712
+ };
713
+ readonly outputTokens: {
714
+ readonly total: number;
715
+ readonly text: number;
716
+ readonly reasoning: number;
717
+ };
718
+ readonly webSearchCalls?: number | undefined;
719
+ readonly costMicrousd: number;
720
+ }[];
721
+ readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
722
+ readonly pricingStatus?: "complete" | "partial" | "unknown" | undefined;
723
+ readonly unobservedModelCalls?: number | undefined;
724
+ } | undefined;
725
+ readonly failure?: {
726
+ readonly errorTag: string;
727
+ readonly message: string;
728
+ readonly diagnostic?: import("@yielded/agent/failure-diagnostic").Diagnostic | undefined;
729
+ readonly context?: {
730
+ readonly agentId?: string | undefined;
731
+ readonly threadId?: string | undefined;
732
+ readonly runId?: string | undefined;
733
+ readonly submissionId?: string | undefined;
734
+ readonly attemptId?: string | undefined;
735
+ readonly turnId?: string | undefined;
736
+ readonly toolCallId?: string | undefined;
737
+ readonly toolName?: string | undefined;
738
+ readonly callId?: string | undefined;
739
+ readonly check?: string | undefined;
740
+ readonly operation?: string | undefined;
741
+ } | undefined;
742
+ } | undefined;
743
+ readonly settledAt: string;
744
+ };
745
+ } | {
746
+ readonly _tag: "SettlementRecordReached";
747
+ readonly record: {
748
+ readonly _tag: "SubmissionSettled";
749
+ readonly submissionId: string;
750
+ readonly settlementId: string;
751
+ readonly receiptId: string;
752
+ readonly outcome: "aborted" | "completed" | "failed";
753
+ readonly runId?: string | undefined;
754
+ readonly historyRecordCount?: number | undefined;
755
+ readonly result?: Schema.Json | undefined;
756
+ readonly runDisposition?: Schema.Json | undefined;
757
+ readonly finishReason?: "budget-exhausted" | undefined;
758
+ readonly exhausted?: "tokens" | "tool-calls" | "turns" | undefined;
759
+ readonly policyLimit?: "cost" | "duration" | "repeated-failures" | "tokens" | "tool-calls" | "turns" | "usage" | undefined;
760
+ readonly usageSummary?: {
761
+ readonly modelCalls: number;
762
+ readonly inputTokens: {
763
+ readonly total: number;
764
+ readonly uncached: number;
765
+ readonly cacheRead: number;
766
+ readonly cacheWrite: number;
767
+ };
768
+ readonly outputTokens: {
769
+ readonly total: number;
770
+ readonly text: number;
771
+ readonly reasoning: number;
772
+ };
773
+ readonly webSearchCalls?: number | undefined;
774
+ readonly costMicrousd: number;
775
+ readonly byModel: readonly {
776
+ readonly provider: string;
777
+ readonly model: string;
778
+ readonly responseModel?: string | undefined;
779
+ readonly serviceTier?: string | undefined;
780
+ readonly pricingVersion?: string | undefined;
781
+ readonly modelCalls: number;
782
+ readonly inputTokens: {
783
+ readonly total: number;
784
+ readonly uncached: number;
785
+ readonly cacheRead: number;
786
+ readonly cacheWrite: number;
787
+ };
788
+ readonly outputTokens: {
789
+ readonly total: number;
790
+ readonly text: number;
791
+ readonly reasoning: number;
792
+ };
793
+ readonly webSearchCalls?: number | undefined;
794
+ readonly costMicrousd: number;
795
+ }[];
796
+ readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
797
+ readonly pricingStatus?: "complete" | "partial" | "unknown" | undefined;
798
+ readonly unobservedModelCalls?: number | undefined;
799
+ } | undefined;
800
+ readonly uncommittedModelUsage?: readonly {
801
+ readonly provider: string;
802
+ readonly model: string;
803
+ readonly serviceTier?: string | undefined;
804
+ readonly pricingVersion?: string | undefined;
805
+ readonly response?: {
806
+ readonly id?: string | undefined;
807
+ readonly model?: string | undefined;
808
+ } | undefined;
809
+ readonly purpose?: "summary" | "turn" | undefined;
810
+ readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
811
+ readonly pricingStatus?: "estimated" | "unknown" | undefined;
812
+ readonly inputTokens: {
813
+ readonly total: number;
814
+ readonly uncached: number;
815
+ readonly cacheRead: number;
816
+ readonly cacheWrite: number;
817
+ };
818
+ readonly outputTokens: {
819
+ readonly total: number;
820
+ readonly text: number;
821
+ readonly reasoning: number;
822
+ };
823
+ readonly webSearchCalls?: number | undefined;
824
+ readonly costMicrousd: number;
825
+ }[] | undefined;
826
+ };
827
+ } | {
828
+ readonly _tag: "ObservedPage";
829
+ readonly records: readonly {
830
+ readonly threadId: string;
831
+ readonly batchId: string;
832
+ readonly sequence: number;
833
+ readonly offset: string;
834
+ readonly record: {
835
+ readonly recordId: string;
836
+ readonly family: "thread";
837
+ readonly schemaVersion: 1;
838
+ readonly createdAt: string;
839
+ readonly deploymentId: string;
840
+ readonly payload: {
841
+ readonly _tag: "UserInputRecorded";
842
+ readonly submissionId?: string | undefined;
843
+ readonly kind: "follow-up" | "steering" | "user";
844
+ readonly runId?: string | undefined;
845
+ readonly input: Schema.Json;
846
+ readonly messageAdmission?: {
847
+ readonly schemaVersion: 1;
848
+ readonly message: {
849
+ readonly ownerThreadId: string;
850
+ readonly messageId: string;
851
+ };
852
+ readonly peerName: string;
853
+ readonly sender: {
854
+ readonly threadId: string;
855
+ readonly agentId: string;
856
+ };
857
+ readonly returnAddress: {
858
+ readonly threadId: string;
859
+ readonly agentId: string;
860
+ };
861
+ readonly inReplyTo?: {
862
+ readonly ownerThreadId: string;
863
+ readonly messageId: string;
864
+ } | undefined;
865
+ } | {
866
+ readonly _tag: "WorkerCompletion";
867
+ readonly budgetExhausted: boolean;
868
+ readonly schemaVersion: 1;
869
+ readonly report: {
870
+ readonly _tag: "Settled";
871
+ readonly worker: {
872
+ readonly schemaVersion: 1;
873
+ readonly delegationId: string;
874
+ readonly targetAgentId: string;
875
+ readonly threadId: string;
876
+ };
877
+ readonly receipt: {
878
+ readonly receiptId: string;
879
+ readonly submissionId: string;
880
+ readonly threadId: string;
881
+ readonly queueSequence: number;
882
+ };
883
+ readonly runId: string;
884
+ readonly settlementId: string;
885
+ readonly outcome: "completed";
886
+ readonly result: Schema.Json;
887
+ } | {
888
+ readonly _tag: "Settled";
889
+ readonly worker: {
890
+ readonly schemaVersion: 1;
891
+ readonly delegationId: string;
892
+ readonly targetAgentId: string;
893
+ readonly threadId: string;
894
+ };
895
+ readonly receipt: {
896
+ readonly receiptId: string;
897
+ readonly submissionId: string;
898
+ readonly threadId: string;
899
+ readonly queueSequence: number;
900
+ };
901
+ readonly runId: string;
902
+ readonly settlementId: string;
903
+ readonly outcome: "aborted" | "failed";
904
+ readonly failure: {
905
+ readonly _tag: "SubagentExecutionFailure";
906
+ readonly delegationId: string;
907
+ readonly targetAgentId: string;
908
+ readonly classification: "child-aborted" | "child-compatibility" | "child-failed" | "declaration-unavailable" | "establishment-denied";
909
+ readonly childThreadId?: string | undefined;
910
+ readonly childSubmissionId?: string | undefined;
911
+ readonly childRunId?: string | undefined;
912
+ readonly errorTag: string;
913
+ readonly message: string;
914
+ };
915
+ };
916
+ } | {
917
+ readonly _tag: "WorkerUpdate";
918
+ readonly schemaVersion: 1;
919
+ readonly worker: {
920
+ readonly schemaVersion: 1;
921
+ readonly delegationId: string;
922
+ readonly targetAgentId: string;
923
+ readonly threadId: string;
924
+ };
925
+ readonly update: {
926
+ readonly schemaVersion: 1;
927
+ readonly agentId: string;
928
+ readonly threadId: string;
929
+ readonly runId: string;
930
+ readonly updateId: string;
931
+ readonly sequence: number;
932
+ readonly value: Schema.Json;
933
+ };
934
+ } | undefined;
935
+ } | {
936
+ readonly _tag: "ModelResponseRecorded";
937
+ readonly toolResultMaxBytes: number;
938
+ readonly toolSelectionMaxBytes: number;
939
+ readonly toolOperations: readonly {
940
+ readonly toolCallId: string;
941
+ readonly toolName: string;
942
+ readonly executionClass: "idempotent" | "readonly" | "uncertain";
943
+ readonly executionKind: "delegation" | "orchestration" | "ordinary";
944
+ readonly replay: string;
945
+ }[];
946
+ readonly toolParameterRejections?: readonly {
947
+ readonly toolCallId: string;
948
+ readonly parameters: Schema.Json;
949
+ readonly error: {
950
+ readonly _tag: "AiError";
951
+ readonly module: string;
952
+ readonly method: string;
953
+ readonly reason: {
954
+ readonly _tag: "ToolParameterValidationError";
955
+ readonly toolName: string;
956
+ readonly description: string;
957
+ };
958
+ };
959
+ }[] | undefined;
960
+ readonly toolExposure?: {
961
+ readonly exposedToolNames: readonly string[];
962
+ readonly selection?: {
963
+ readonly toolNames: readonly string[];
964
+ } | undefined;
965
+ } | undefined;
966
+ readonly runId: string;
967
+ readonly turnId: string;
968
+ readonly turn: number;
969
+ readonly messages: Schema.Json;
970
+ readonly runScopedPrefixLength?: number | undefined;
971
+ readonly modelUsage?: readonly {
972
+ readonly provider: string;
973
+ readonly model: string;
974
+ readonly serviceTier?: string | undefined;
975
+ readonly pricingVersion?: string | undefined;
976
+ readonly response?: {
977
+ readonly id?: string | undefined;
978
+ readonly model?: string | undefined;
979
+ } | undefined;
980
+ readonly purpose?: "summary" | "turn" | undefined;
981
+ readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
982
+ readonly pricingStatus?: "estimated" | "unknown" | undefined;
983
+ readonly inputTokens: {
984
+ readonly total: number;
985
+ readonly uncached: number;
986
+ readonly cacheRead: number;
987
+ readonly cacheWrite: number;
988
+ };
989
+ readonly outputTokens: {
990
+ readonly total: number;
991
+ readonly text: number;
992
+ readonly reasoning: number;
993
+ };
994
+ readonly webSearchCalls?: number | undefined;
995
+ readonly costMicrousd: number;
996
+ }[] | undefined;
997
+ readonly unobservedModelCalls?: number | undefined;
998
+ readonly inputTokens?: number | undefined;
999
+ readonly outputTokens?: number | undefined;
1000
+ readonly costMicrousd?: number | undefined;
1001
+ } | {
1002
+ readonly _tag: "CompactionCreated";
1003
+ readonly runId: string;
1004
+ readonly turn: number;
1005
+ readonly kind: "clear-tool-results" | "rollover" | "summarize";
1006
+ readonly coversThrough: number;
1007
+ readonly summary?: string | undefined;
1008
+ readonly handoff?: string | undefined;
1009
+ } | {
1010
+ readonly _tag: "ThreadCreated";
1011
+ readonly agentId: string;
1012
+ readonly definitions: {
1013
+ readonly agent: string;
1014
+ readonly model: string;
1015
+ readonly tools: string;
1016
+ readonly replay?: {
1017
+ readonly agent: string;
1018
+ readonly agentBehavior?: string | undefined;
1019
+ readonly tools: {
1020
+ readonly [x: string]: string;
1021
+ };
1022
+ } | undefined;
1023
+ };
1024
+ } | {
1025
+ readonly _tag: "RunStarted";
1026
+ readonly runId: string;
1027
+ readonly policyAccountingVersion: 1;
1028
+ readonly maxDurationMillis: number;
1029
+ } | {
1030
+ readonly _tag: "RunDurationExhausted";
1031
+ readonly runId: string;
1032
+ } | {
1033
+ readonly _tag: "RunPolicyUsageReserved";
1034
+ readonly runId: string;
1035
+ readonly programmaticToolCalls: number;
1036
+ readonly finalizationUsed: boolean;
1037
+ } | {
1038
+ readonly _tag: "ModelCompleted";
1039
+ readonly runId: string;
1040
+ readonly output: Schema.Json;
1041
+ readonly messages?: Schema.Json | undefined;
1042
+ readonly history?: Schema.Json | undefined;
1043
+ } | {
1044
+ readonly _tag: "ToolCallSettled";
1045
+ readonly toolSelection?: {
1046
+ readonly toolNames: readonly string[];
1047
+ } | undefined;
1048
+ readonly runId: string;
1049
+ readonly toolCallId: string;
1050
+ readonly toolName: string;
1051
+ readonly result: Schema.Json;
1052
+ readonly isFailure: boolean;
1053
+ readonly budgetRejected?: true | undefined;
1054
+ } | {
1055
+ readonly _tag: "ToolCallUnknown";
1056
+ readonly runId: string;
1057
+ readonly turn: number;
1058
+ readonly toolCallId: string;
1059
+ readonly toolName: string;
1060
+ readonly reason: string;
1061
+ } | {
1062
+ readonly _tag: "ToolCallResolved";
1063
+ readonly runId: string;
1064
+ readonly toolCallId: string;
1065
+ readonly resolution: "completed-with-result" | "failed-with-error" | "never-started" | "safe-retry";
1066
+ readonly author: string;
1067
+ readonly reason: string;
1068
+ } | {
1069
+ readonly _tag: "ToolStepSettled";
1070
+ readonly runId: string;
1071
+ readonly toolCallId: string;
1072
+ readonly stepName: string;
1073
+ readonly output: Schema.Json;
1074
+ readonly outputDigest: string;
1075
+ } | {
1076
+ readonly _tag: "ToolApprovalRequested";
1077
+ readonly runId: string;
1078
+ readonly turnId: string;
1079
+ readonly turn: number;
1080
+ readonly toolCallId: string;
1081
+ readonly toolName: string;
1082
+ readonly parametersDigest: string;
1083
+ readonly blocksInitialDispatch: boolean;
1084
+ } | {
1085
+ readonly _tag: "ToolApprovalDecided";
1086
+ readonly runId: string;
1087
+ readonly turn: number;
1088
+ readonly toolCallId: string;
1089
+ readonly decision: "approved" | "denied";
1090
+ readonly resolver: string;
1091
+ readonly reason: string;
1092
+ } | {
1093
+ readonly _tag: "ModelResponseInterrupted";
1094
+ readonly runId: string;
1095
+ } | {
1096
+ readonly _tag: "ModelCallAborted";
1097
+ readonly runId: string;
1098
+ readonly turnId: string;
1099
+ readonly turn: number;
1100
+ readonly restart: number;
1101
+ readonly reason: "joined-input";
1102
+ readonly modelUsage: readonly {
1103
+ readonly provider: string;
1104
+ readonly model: string;
1105
+ readonly serviceTier?: string | undefined;
1106
+ readonly pricingVersion?: string | undefined;
1107
+ readonly response?: {
1108
+ readonly id?: string | undefined;
1109
+ readonly model?: string | undefined;
1110
+ } | undefined;
1111
+ readonly purpose?: "summary" | "turn" | undefined;
1112
+ readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
1113
+ readonly pricingStatus?: "estimated" | "unknown" | undefined;
1114
+ readonly inputTokens: {
1115
+ readonly total: number;
1116
+ readonly uncached: number;
1117
+ readonly cacheRead: number;
1118
+ readonly cacheWrite: number;
1119
+ };
1120
+ readonly outputTokens: {
1121
+ readonly total: number;
1122
+ readonly text: number;
1123
+ readonly reasoning: number;
1124
+ };
1125
+ readonly webSearchCalls?: number | undefined;
1126
+ readonly costMicrousd: number;
1127
+ }[];
1128
+ readonly unobservedModelCalls: number;
1129
+ } | {
1130
+ readonly _tag: "RunFailed";
1131
+ readonly runId: string;
1132
+ readonly failure: Schema.Json;
1133
+ } | {
1134
+ readonly _tag: "RunCompleted";
1135
+ readonly runId: string;
1136
+ readonly output: Schema.Json;
1137
+ readonly runDisposition?: Schema.Json | undefined;
1138
+ readonly finishReason?: "budget-exhausted" | undefined;
1139
+ readonly exhausted?: "tokens" | "tool-calls" | "turns" | undefined;
1140
+ } | {
1141
+ readonly _tag: "AbortRequested";
1142
+ readonly submissionId: string;
1143
+ readonly author: string;
1144
+ readonly reason: string;
1145
+ } | {
1146
+ readonly _tag: "SubmissionSettled";
1147
+ readonly submissionId: string;
1148
+ readonly settlementId: string;
1149
+ readonly receiptId: string;
1150
+ readonly outcome: "aborted" | "completed" | "failed";
1151
+ readonly runId?: string | undefined;
1152
+ readonly historyRecordCount?: number | undefined;
1153
+ readonly result?: Schema.Json | undefined;
1154
+ readonly runDisposition?: Schema.Json | undefined;
1155
+ readonly finishReason?: "budget-exhausted" | undefined;
1156
+ readonly exhausted?: "tokens" | "tool-calls" | "turns" | undefined;
1157
+ readonly policyLimit?: "cost" | "duration" | "repeated-failures" | "tokens" | "tool-calls" | "turns" | "usage" | undefined;
1158
+ readonly usageSummary?: {
1159
+ readonly modelCalls: number;
1160
+ readonly inputTokens: {
1161
+ readonly total: number;
1162
+ readonly uncached: number;
1163
+ readonly cacheRead: number;
1164
+ readonly cacheWrite: number;
1165
+ };
1166
+ readonly outputTokens: {
1167
+ readonly total: number;
1168
+ readonly text: number;
1169
+ readonly reasoning: number;
1170
+ };
1171
+ readonly webSearchCalls?: number | undefined;
1172
+ readonly costMicrousd: number;
1173
+ readonly byModel: readonly {
1174
+ readonly provider: string;
1175
+ readonly model: string;
1176
+ readonly responseModel?: string | undefined;
1177
+ readonly serviceTier?: string | undefined;
1178
+ readonly pricingVersion?: string | undefined;
1179
+ readonly modelCalls: number;
1180
+ readonly inputTokens: {
1181
+ readonly total: number;
1182
+ readonly uncached: number;
1183
+ readonly cacheRead: number;
1184
+ readonly cacheWrite: number;
1185
+ };
1186
+ readonly outputTokens: {
1187
+ readonly total: number;
1188
+ readonly text: number;
1189
+ readonly reasoning: number;
1190
+ };
1191
+ readonly webSearchCalls?: number | undefined;
1192
+ readonly costMicrousd: number;
1193
+ }[];
1194
+ readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
1195
+ readonly pricingStatus?: "complete" | "partial" | "unknown" | undefined;
1196
+ readonly unobservedModelCalls?: number | undefined;
1197
+ } | undefined;
1198
+ readonly uncommittedModelUsage?: readonly {
1199
+ readonly provider: string;
1200
+ readonly model: string;
1201
+ readonly serviceTier?: string | undefined;
1202
+ readonly pricingVersion?: string | undefined;
1203
+ readonly response?: {
1204
+ readonly id?: string | undefined;
1205
+ readonly model?: string | undefined;
1206
+ } | undefined;
1207
+ readonly purpose?: "summary" | "turn" | undefined;
1208
+ readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
1209
+ readonly pricingStatus?: "estimated" | "unknown" | undefined;
1210
+ readonly inputTokens: {
1211
+ readonly total: number;
1212
+ readonly uncached: number;
1213
+ readonly cacheRead: number;
1214
+ readonly cacheWrite: number;
1215
+ };
1216
+ readonly outputTokens: {
1217
+ readonly total: number;
1218
+ readonly text: number;
1219
+ readonly reasoning: number;
1220
+ };
1221
+ readonly webSearchCalls?: number | undefined;
1222
+ readonly costMicrousd: number;
1223
+ }[] | undefined;
1224
+ } | {
1225
+ readonly _tag: "SubagentRequested";
1226
+ readonly runId: string;
1227
+ readonly turnId: string;
1228
+ readonly turn: number;
1229
+ readonly toolCallId: string;
1230
+ readonly delegationId: string;
1231
+ readonly targetAgentId: string;
1232
+ readonly targetDigests: {
1233
+ readonly agent: string;
1234
+ readonly model: string;
1235
+ readonly tools: string;
1236
+ readonly replay?: {
1237
+ readonly agent: string;
1238
+ readonly agentBehavior?: string | undefined;
1239
+ readonly tools: {
1240
+ readonly [x: string]: string;
1241
+ };
1242
+ } | undefined;
1243
+ };
1244
+ readonly childInput: Schema.Json;
1245
+ readonly childInputDigest: string;
1246
+ readonly grantDigest: string;
1247
+ readonly reservationId: string;
1248
+ readonly reservationDigest: string;
1249
+ readonly childThreadId: string;
1250
+ readonly childPrincipal: string;
1251
+ readonly childIdempotencyKey: string;
1252
+ readonly toolCallAllowance?: number | undefined;
1253
+ readonly policy?: Schema.Json | undefined;
1254
+ readonly budget?: {
1255
+ readonly caps: {
1256
+ readonly maxTotalChildInvocations?: number | undefined;
1257
+ readonly maxConcurrentChildren?: number | undefined;
1258
+ readonly maxTurns?: number | undefined;
1259
+ readonly maxToolCalls?: number | undefined;
1260
+ readonly maxDurationMillis?: number | undefined;
1261
+ readonly maxInputTokens?: number | undefined;
1262
+ readonly maxOutputTokens?: number | undefined;
1263
+ readonly maxCostMicrousd?: number | undefined;
1264
+ readonly maxResultBytes?: number | undefined;
1265
+ };
1266
+ readonly allocation: {
1267
+ readonly turns: number;
1268
+ readonly toolCalls: number;
1269
+ readonly durationMillis: number;
1270
+ readonly inputTokens: number;
1271
+ readonly outputTokens: number;
1272
+ readonly costMicrousd: number;
1273
+ readonly resultBytes: number;
1274
+ };
1275
+ readonly descendantInvocations?: number | undefined;
1276
+ } | undefined;
1277
+ readonly grant?: {
1278
+ readonly allowedToolNames: readonly string[];
1279
+ readonly maxDepth: number;
1280
+ readonly childLifetimes?: readonly ("attached" | "background")[] | undefined;
1281
+ } | undefined;
1282
+ readonly depth?: number | undefined;
1283
+ } | {
1284
+ readonly _tag: "SubagentStarted";
1285
+ readonly runId: string;
1286
+ readonly toolCallId: string;
1287
+ readonly childThreadId: string;
1288
+ readonly childSubmissionId: string;
1289
+ readonly childReceiptId: string;
1290
+ readonly childRunId: string;
1291
+ } | {
1292
+ readonly _tag: "SubagentJoined";
1293
+ readonly runId: string;
1294
+ readonly toolCallId: string;
1295
+ readonly childSubmissionId: string;
1296
+ readonly childSettlementId: string;
1297
+ readonly childOutcome: "aborted" | "completed" | "failed";
1298
+ readonly usageSummary: Schema.Json;
1299
+ readonly usage?: {
1300
+ readonly modelCalls: number;
1301
+ readonly inputTokens: number;
1302
+ readonly outputTokens: number;
1303
+ readonly webSearchCalls?: number | undefined;
1304
+ readonly costMicrousd: number;
1305
+ readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
1306
+ readonly pricingStatus?: "complete" | "partial" | "unknown" | undefined;
1307
+ readonly unobservedModelCalls?: number | undefined;
1308
+ } | undefined;
1309
+ readonly delegatedUsage?: {
1310
+ readonly modelCalls: number;
1311
+ readonly inputTokens: number;
1312
+ readonly outputTokens: number;
1313
+ readonly webSearchCalls?: number | undefined;
1314
+ readonly costMicrousd: number;
1315
+ readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
1316
+ readonly pricingStatus?: "complete" | "partial" | "unknown" | undefined;
1317
+ readonly unobservedModelCalls?: number | undefined;
1318
+ } | undefined;
1319
+ readonly reservationId: string;
1320
+ readonly finalAccounting: Schema.Json;
1321
+ } | {
1322
+ readonly _tag: "SubagentLineageRecorded";
1323
+ readonly parentLink: {
1324
+ readonly delegationId: string;
1325
+ readonly parentAgentId: string;
1326
+ readonly parentThreadId: string;
1327
+ readonly parentRunId: string;
1328
+ readonly parentToolCallId: string;
1329
+ readonly depth: number;
1330
+ };
1331
+ readonly parentSubmissionId: string;
1332
+ readonly childDefinitionDigests: {
1333
+ readonly agent: string;
1334
+ readonly model: string;
1335
+ readonly tools: string;
1336
+ readonly replay?: {
1337
+ readonly agent: string;
1338
+ readonly agentBehavior?: string | undefined;
1339
+ readonly tools: {
1340
+ readonly [x: string]: string;
1341
+ };
1342
+ } | undefined;
1343
+ };
1344
+ readonly childInputDigest: string;
1345
+ readonly grantDigest: string;
1346
+ readonly toolCallAllowance?: number | undefined;
1347
+ readonly policy?: Schema.Json | undefined;
1348
+ readonly budget?: {
1349
+ readonly caps: {
1350
+ readonly maxTotalChildInvocations?: number | undefined;
1351
+ readonly maxConcurrentChildren?: number | undefined;
1352
+ readonly maxTurns?: number | undefined;
1353
+ readonly maxToolCalls?: number | undefined;
1354
+ readonly maxDurationMillis?: number | undefined;
1355
+ readonly maxInputTokens?: number | undefined;
1356
+ readonly maxOutputTokens?: number | undefined;
1357
+ readonly maxCostMicrousd?: number | undefined;
1358
+ readonly maxResultBytes?: number | undefined;
1359
+ };
1360
+ readonly allocation: {
1361
+ readonly turns: number;
1362
+ readonly toolCalls: number;
1363
+ readonly durationMillis: number;
1364
+ readonly inputTokens: number;
1365
+ readonly outputTokens: number;
1366
+ readonly costMicrousd: number;
1367
+ readonly resultBytes: number;
1368
+ };
1369
+ readonly descendantInvocations?: number | undefined;
1370
+ } | undefined;
1371
+ readonly grant?: {
1372
+ readonly allowedToolNames: readonly string[];
1373
+ readonly maxDepth: number;
1374
+ readonly childLifetimes?: readonly ("attached" | "background")[] | undefined;
1375
+ } | undefined;
1376
+ } | {
1377
+ readonly _tag: "WorkerInputRequested";
1378
+ readonly admission: {
1379
+ readonly origin: {
1380
+ readonly worker: {
1381
+ readonly schemaVersion: 1;
1382
+ readonly delegationId: string;
1383
+ readonly targetAgentId: string;
1384
+ readonly threadId: string;
1385
+ };
1386
+ readonly source: {
1387
+ readonly _tag: "tool";
1388
+ readonly agentId: string;
1389
+ readonly threadId: string;
1390
+ readonly runId: string;
1391
+ readonly toolCallId: string;
1392
+ } | {
1393
+ readonly _tag: "programmatic";
1394
+ readonly agentId: string;
1395
+ readonly threadId: string;
1396
+ };
1397
+ readonly continuationOf?: {
1398
+ readonly worker: {
1399
+ readonly schemaVersion: 1;
1400
+ readonly delegationId: string;
1401
+ readonly targetAgentId: string;
1402
+ readonly threadId: string;
1403
+ };
1404
+ readonly receipt: {
1405
+ readonly receiptId: string;
1406
+ readonly submissionId: string;
1407
+ readonly threadId: string;
1408
+ readonly queueSequence: number;
1409
+ };
1410
+ readonly settlementId: string;
1411
+ } | undefined;
1412
+ readonly budgetScope: "source-subtree" | "worker-run";
1413
+ readonly lifecycle?: "assignment" | undefined;
1414
+ readonly targetDigests: {
1415
+ readonly agent: string;
1416
+ readonly model: string;
1417
+ readonly tools: string;
1418
+ readonly replay?: {
1419
+ readonly agent: string;
1420
+ readonly agentBehavior?: string | undefined;
1421
+ readonly tools: {
1422
+ readonly [x: string]: string;
1423
+ };
1424
+ } | undefined;
1425
+ };
1426
+ readonly policy: Schema.Json;
1427
+ readonly budget: {
1428
+ readonly caps: {
1429
+ readonly maxTotalChildInvocations?: number | undefined;
1430
+ readonly maxConcurrentChildren?: number | undefined;
1431
+ readonly maxTurns?: number | undefined;
1432
+ readonly maxToolCalls?: number | undefined;
1433
+ readonly maxDurationMillis?: number | undefined;
1434
+ readonly maxInputTokens?: number | undefined;
1435
+ readonly maxOutputTokens?: number | undefined;
1436
+ readonly maxCostMicrousd?: number | undefined;
1437
+ readonly maxResultBytes?: number | undefined;
1438
+ };
1439
+ readonly allocation: {
1440
+ readonly turns: number;
1441
+ readonly toolCalls: number;
1442
+ readonly durationMillis: number;
1443
+ readonly inputTokens: number;
1444
+ readonly outputTokens: number;
1445
+ readonly costMicrousd: number;
1446
+ readonly resultBytes: number;
1447
+ };
1448
+ readonly descendantInvocations?: number | undefined;
1449
+ };
1450
+ readonly grant: {
1451
+ readonly allowedToolNames: readonly string[];
1452
+ readonly maxDepth: number;
1453
+ readonly childLifetimes?: readonly ("attached" | "background")[] | undefined;
1454
+ };
1455
+ readonly depth: number;
1456
+ readonly toolCallAllowance?: number | undefined;
1457
+ readonly firstMessageId: string;
1458
+ readonly createdAtMillis: number;
1459
+ readonly expiresAtMillis: number;
1460
+ readonly reporting?: {
1461
+ readonly mode?: "standard" | undefined;
1462
+ readonly sourceDigests: {
1463
+ readonly agent: string;
1464
+ readonly model: string;
1465
+ readonly tools: string;
1466
+ readonly replay?: {
1467
+ readonly agent: string;
1468
+ readonly agentBehavior?: string | undefined;
1469
+ readonly tools: {
1470
+ readonly [x: string]: string;
1471
+ };
1472
+ } | undefined;
1473
+ };
1474
+ readonly destinationDelegationId?: string | undefined;
1475
+ readonly returnAddress?: {
1476
+ readonly input: Schema.Json;
1477
+ readonly principal: string;
1478
+ readonly policy: Schema.Json;
1479
+ readonly depth: number;
1480
+ readonly grant?: {
1481
+ readonly allowedToolNames: readonly string[];
1482
+ readonly maxDepth: number;
1483
+ readonly childLifetimes?: readonly ("attached" | "background")[] | undefined;
1484
+ } | undefined;
1485
+ readonly workerAdmission?: Schema.Json | undefined;
1486
+ } | undefined;
1487
+ } | undefined;
1488
+ };
1489
+ readonly executionRunId: string | null;
1490
+ readonly messageId: string;
1491
+ readonly parameters: Schema.Json;
1492
+ readonly createdAtMillis: number;
1493
+ readonly sourceSubmissionId?: string | undefined;
1494
+ readonly deliveryPrincipal?: string | undefined;
1495
+ readonly reportKind?: "update" | undefined;
1496
+ };
1497
+ readonly inputDigest: string;
1498
+ } | {
1499
+ readonly _tag: "WorkerStopRequested";
1500
+ readonly command: {
1501
+ readonly worker: {
1502
+ readonly schemaVersion: 1;
1503
+ readonly delegationId: string;
1504
+ readonly targetAgentId: string;
1505
+ readonly threadId: string;
1506
+ };
1507
+ readonly idempotencyKey: string;
1508
+ };
1509
+ readonly principal: string;
1510
+ readonly sourceSubmissionId?: string | undefined;
1511
+ } | {
1512
+ readonly _tag: "WorkHandoffCompleted";
1513
+ readonly preparationId: string;
1514
+ readonly ownerId: string;
1515
+ } | {
1516
+ readonly _tag: "WorkerOriginRecorded";
1517
+ readonly origin: {
1518
+ readonly worker: {
1519
+ readonly schemaVersion: 1;
1520
+ readonly delegationId: string;
1521
+ readonly targetAgentId: string;
1522
+ readonly threadId: string;
1523
+ };
1524
+ readonly source: {
1525
+ readonly _tag: "tool";
1526
+ readonly agentId: string;
1527
+ readonly threadId: string;
1528
+ readonly runId: string;
1529
+ readonly toolCallId: string;
1530
+ } | {
1531
+ readonly _tag: "programmatic";
1532
+ readonly agentId: string;
1533
+ readonly threadId: string;
1534
+ };
1535
+ readonly continuationOf?: {
1536
+ readonly worker: {
1537
+ readonly schemaVersion: 1;
1538
+ readonly delegationId: string;
1539
+ readonly targetAgentId: string;
1540
+ readonly threadId: string;
1541
+ };
1542
+ readonly receipt: {
1543
+ readonly receiptId: string;
1544
+ readonly submissionId: string;
1545
+ readonly threadId: string;
1546
+ readonly queueSequence: number;
1547
+ };
1548
+ readonly settlementId: string;
1549
+ } | undefined;
1550
+ readonly budgetScope: "source-subtree" | "worker-run";
1551
+ readonly lifecycle?: "assignment" | undefined;
1552
+ readonly targetDigests: {
1553
+ readonly agent: string;
1554
+ readonly model: string;
1555
+ readonly tools: string;
1556
+ readonly replay?: {
1557
+ readonly agent: string;
1558
+ readonly agentBehavior?: string | undefined;
1559
+ readonly tools: {
1560
+ readonly [x: string]: string;
1561
+ };
1562
+ } | undefined;
1563
+ };
1564
+ readonly policy: Schema.Json;
1565
+ readonly budget: {
1566
+ readonly caps: {
1567
+ readonly maxTotalChildInvocations?: number | undefined;
1568
+ readonly maxConcurrentChildren?: number | undefined;
1569
+ readonly maxTurns?: number | undefined;
1570
+ readonly maxToolCalls?: number | undefined;
1571
+ readonly maxDurationMillis?: number | undefined;
1572
+ readonly maxInputTokens?: number | undefined;
1573
+ readonly maxOutputTokens?: number | undefined;
1574
+ readonly maxCostMicrousd?: number | undefined;
1575
+ readonly maxResultBytes?: number | undefined;
1576
+ };
1577
+ readonly allocation: {
1578
+ readonly turns: number;
1579
+ readonly toolCalls: number;
1580
+ readonly durationMillis: number;
1581
+ readonly inputTokens: number;
1582
+ readonly outputTokens: number;
1583
+ readonly costMicrousd: number;
1584
+ readonly resultBytes: number;
1585
+ };
1586
+ readonly descendantInvocations?: number | undefined;
1587
+ };
1588
+ readonly grant: {
1589
+ readonly allowedToolNames: readonly string[];
1590
+ readonly maxDepth: number;
1591
+ readonly childLifetimes?: readonly ("attached" | "background")[] | undefined;
1592
+ };
1593
+ readonly depth: number;
1594
+ readonly toolCallAllowance?: number | undefined;
1595
+ readonly firstMessageId: string;
1596
+ readonly createdAtMillis: number;
1597
+ readonly expiresAtMillis: number;
1598
+ readonly reporting?: {
1599
+ readonly mode?: "standard" | undefined;
1600
+ readonly sourceDigests: {
1601
+ readonly agent: string;
1602
+ readonly model: string;
1603
+ readonly tools: string;
1604
+ readonly replay?: {
1605
+ readonly agent: string;
1606
+ readonly agentBehavior?: string | undefined;
1607
+ readonly tools: {
1608
+ readonly [x: string]: string;
1609
+ };
1610
+ } | undefined;
1611
+ };
1612
+ readonly destinationDelegationId?: string | undefined;
1613
+ readonly returnAddress?: {
1614
+ readonly input: Schema.Json;
1615
+ readonly principal: string;
1616
+ readonly policy: Schema.Json;
1617
+ readonly depth: number;
1618
+ readonly grant?: {
1619
+ readonly allowedToolNames: readonly string[];
1620
+ readonly maxDepth: number;
1621
+ readonly childLifetimes?: readonly ("attached" | "background")[] | undefined;
1622
+ } | undefined;
1623
+ readonly workerAdmission?: Schema.Json | undefined;
1624
+ } | undefined;
1625
+ } | undefined;
1626
+ };
1627
+ } | {
1628
+ readonly _tag: "WorkerInputCompleted";
1629
+ readonly messageId: string;
1630
+ readonly workerThreadId: string;
1631
+ readonly submissionId: string;
1632
+ readonly receiptId: string;
1633
+ readonly settlementId: string;
1634
+ readonly completedAtMillis: number;
1635
+ readonly effectsResolved?: true | undefined;
1636
+ } | {
1637
+ readonly _tag: "WorkerInputRefused";
1638
+ readonly messageId: string;
1639
+ readonly workerThreadId: string;
1640
+ readonly reservation: {
1641
+ readonly recordId: string;
1642
+ };
1643
+ readonly stop: {
1644
+ readonly recordId: string;
1645
+ };
1646
+ readonly deliveryVersion: number;
1647
+ readonly envelopeDigest: string;
1648
+ readonly receiver: {
1649
+ readonly threadId: string;
1650
+ readonly principal: string;
1651
+ readonly idempotencyKey: string;
1652
+ readonly inputDigest: string;
1653
+ readonly stopped: true;
1654
+ readonly resolution: "NotAdmitted";
1655
+ };
1656
+ } | {
1657
+ readonly _tag: "WorkerReportPrepared";
1658
+ readonly runId: string;
1659
+ readonly messageId: string;
1660
+ readonly envelope: Schema.Json;
1661
+ readonly createdAtMillis: number;
1662
+ readonly deadlineAtMillis: number;
1663
+ readonly predecessor?: string | undefined;
1664
+ } | {
1665
+ readonly _tag: "AgentUpdateEmitted";
1666
+ readonly update: {
1667
+ readonly schemaVersion: 1;
1668
+ readonly agentId: string;
1669
+ readonly threadId: string;
1670
+ readonly runId: string;
1671
+ readonly updateId: string;
1672
+ readonly sequence: number;
1673
+ readonly value: Schema.Json;
1674
+ };
1675
+ readonly definitions: {
1676
+ readonly agent: string;
1677
+ readonly model: string;
1678
+ readonly tools: string;
1679
+ readonly replay?: {
1680
+ readonly agent: string;
1681
+ readonly agentBehavior?: string | undefined;
1682
+ readonly tools: {
1683
+ readonly [x: string]: string;
1684
+ };
1685
+ } | undefined;
1686
+ };
1687
+ readonly delivery?: {
1688
+ readonly messageId: string;
1689
+ readonly envelope: Schema.Json;
1690
+ readonly createdAtMillis: number;
1691
+ readonly deadlineAtMillis: number;
1692
+ readonly predecessor?: string | undefined;
1693
+ } | undefined;
1694
+ } | {
1695
+ readonly _tag: "WorkerReportRefused";
1696
+ readonly runId: string;
1697
+ readonly messageId: string;
1698
+ readonly reason: "capacity" | "declaration-unavailable" | "defect" | "denied" | "destination" | "expired" | "filtered" | "input" | "preparation" | "projection" | "timeout";
1699
+ } | {
1700
+ readonly _tag: "PeerMessagePrepared";
1701
+ readonly messageId: string;
1702
+ readonly source: {
1703
+ readonly _tag: "tool";
1704
+ readonly agentId: string;
1705
+ readonly threadId: string;
1706
+ readonly runId: string;
1707
+ readonly toolCallId: string;
1708
+ } | {
1709
+ readonly _tag: "programmatic";
1710
+ readonly agentId: string;
1711
+ readonly threadId: string;
1712
+ };
1713
+ readonly sourcePrincipal: string;
1714
+ readonly operation: "reply" | "send";
1715
+ readonly deadlineAtMillis: number;
1716
+ readonly encodedEnvelope: Schema.Json;
1717
+ } | {
1718
+ readonly _tag: "SubtreeBudgetReserved";
1719
+ readonly reservationId: string;
1720
+ readonly executionRunId: string | null;
1721
+ readonly sourceSubmissionId?: string | undefined;
1722
+ readonly childThreadId: string;
1723
+ readonly lifetime: "attached" | "background";
1724
+ readonly depth: number;
1725
+ readonly policy: Schema.Json;
1726
+ readonly grant: {
1727
+ readonly allowedToolNames: readonly string[];
1728
+ readonly maxDepth: number;
1729
+ readonly childLifetimes?: readonly ("attached" | "background")[] | undefined;
1730
+ };
1731
+ readonly budget: {
1732
+ readonly caps: {
1733
+ readonly maxTotalChildInvocations?: number | undefined;
1734
+ readonly maxConcurrentChildren?: number | undefined;
1735
+ readonly maxTurns?: number | undefined;
1736
+ readonly maxToolCalls?: number | undefined;
1737
+ readonly maxDurationMillis?: number | undefined;
1738
+ readonly maxInputTokens?: number | undefined;
1739
+ readonly maxOutputTokens?: number | undefined;
1740
+ readonly maxCostMicrousd?: number | undefined;
1741
+ readonly maxResultBytes?: number | undefined;
1742
+ };
1743
+ readonly allocation: {
1744
+ readonly turns: number;
1745
+ readonly toolCalls: number;
1746
+ readonly durationMillis: number;
1747
+ readonly inputTokens: number;
1748
+ readonly outputTokens: number;
1749
+ readonly costMicrousd: number;
1750
+ readonly resultBytes: number;
1751
+ };
1752
+ readonly descendantInvocations?: number | undefined;
1753
+ };
1754
+ } | {
1755
+ readonly _tag: "RepairAnnotated";
1756
+ readonly reason: string;
1757
+ readonly details: Schema.Json;
1758
+ } | {
1759
+ readonly _tag: "RunContextRecorded";
1760
+ readonly version: 1;
1761
+ readonly runId: string;
1762
+ readonly runScopedInput: Schema.Json;
1763
+ readonly historyFrom: number;
1764
+ readonly historyThrough: number;
1765
+ readonly retained: readonly {
1766
+ readonly recordId: string;
1767
+ readonly sequence: number;
1768
+ }[];
1769
+ readonly historyDigest: string;
1770
+ readonly priorHistoryLength: number;
1771
+ readonly contextWindowId?: string | undefined;
1772
+ } | {
1773
+ readonly _tag: "RunContinuation";
1774
+ readonly version: 1;
1775
+ readonly runId: string;
1776
+ readonly submissionId: string;
1777
+ readonly revision: number;
1778
+ readonly recordCount: number;
1779
+ readonly recordBytes: number;
1780
+ readonly turn: number;
1781
+ readonly turnBytes: number;
1782
+ readonly terminalBytes: number;
1783
+ readonly terminalRecords: number;
1784
+ readonly terminalUsageBytes: number;
1785
+ readonly originalInput: {
1786
+ readonly recordId: string;
1787
+ };
1788
+ readonly savedContext?: {
1789
+ readonly recordId: string;
1790
+ } | undefined;
1791
+ readonly latestResponse?: {
1792
+ readonly recordId: string;
1793
+ } | undefined;
1794
+ readonly terminal?: {
1795
+ readonly recordId: string;
1796
+ } | undefined;
1797
+ readonly lastFact: {
1798
+ readonly recordId: string;
1799
+ };
1800
+ readonly position: "awaiting-model" | "processing-operations" | "settled" | "settling" | "starting" | "unknown" | "waiting-approval" | "waiting-dependency";
1801
+ readonly accounting: {
1802
+ readonly committedTurns: number;
1803
+ readonly toolCalls: number;
1804
+ readonly programmaticToolCalls: number;
1805
+ readonly consecutiveToolFailures: number;
1806
+ readonly finalizationUsed: boolean;
1807
+ readonly modelRestarts: number;
1808
+ readonly modelCalls: number;
1809
+ readonly unobservedModelCalls: number;
1810
+ readonly inputTokens: number;
1811
+ readonly outputTokens: number;
1812
+ readonly lastInputTokens: number;
1813
+ readonly lastOutputTokens: number;
1814
+ readonly costMicrousd: number;
1815
+ readonly accountedToolTurn: number;
1816
+ };
1817
+ };
1818
+ };
1819
+ }[];
1820
+ } | {
1821
+ readonly _tag: "ProgressObserved";
1822
+ } | {
1823
+ readonly _tag: "ProgressCancelled";
1824
+ } | {
1825
+ readonly _tag: "AbortRecorded";
1826
+ readonly intent: {
1827
+ readonly submissionId: string;
1828
+ readonly author: string;
1829
+ readonly reason: string;
1830
+ readonly requestedAt: string;
1831
+ readonly canonicalRecordId?: string | undefined;
1832
+ };
1833
+ } | {
1834
+ readonly _tag: "ApprovalRecorded";
1835
+ readonly intent: {
1836
+ readonly submissionId: string;
1837
+ readonly toolCallId: string;
1838
+ readonly decision: "approved" | "denied";
1839
+ readonly resolver: string;
1840
+ readonly reason: string;
1841
+ readonly decidedAt: string;
1842
+ readonly canonicalRecordId?: string | undefined;
1843
+ };
1844
+ } | {
1845
+ readonly _tag: "UnknownResolutionRecorded";
1846
+ readonly intent: {
1847
+ readonly submissionId: string;
1848
+ readonly toolCallId: string;
1849
+ readonly author: string;
1850
+ readonly reason: string;
1851
+ readonly resolution: {
1852
+ readonly _tag: "SafeToRetry";
1853
+ } | {
1854
+ readonly _tag: "CompletedWithResult";
1855
+ readonly result: Schema.Json;
1856
+ readonly isFailure: boolean;
1857
+ } | {
1858
+ readonly _tag: "NeverHappened";
1859
+ } | {
1860
+ readonly _tag: "AbortSubmission";
1861
+ };
1862
+ readonly resolvedAt: string;
1863
+ readonly canonicalRecordId?: string | undefined;
1864
+ };
1865
+ } | {
1866
+ readonly _tag: "HostFailed";
1867
+ readonly failure: {
1868
+ readonly _tag: "LedgerError";
1869
+ readonly operation: string;
1870
+ readonly message: string;
1871
+ readonly cause?: import("@yielded/agent/failure-diagnostic").Diagnostic | undefined;
1872
+ } | {
1873
+ readonly _tag: "ThreadStoreError";
1874
+ readonly operation: string;
1875
+ readonly message: string;
1876
+ readonly cause?: Schema.Json | undefined;
1877
+ readonly diagnostic?: {
1878
+ readonly causeTag: string;
1879
+ readonly operation: string;
1880
+ readonly decoder?: string | undefined;
1881
+ readonly issueTag?: string | undefined;
1882
+ readonly sequence?: number | undefined;
1883
+ } | undefined;
1884
+ } | {
1885
+ readonly _tag: "ThreadNotMaterialized";
1886
+ readonly threadId: string;
1887
+ } | {
1888
+ readonly _tag: "AppendConflict";
1889
+ readonly threadId: string;
1890
+ readonly batchId: string;
1891
+ readonly reason: "batch-content" | "record-identity" | "stale-command" | "tail";
1892
+ readonly actualTailSequence?: number | undefined;
1893
+ } | {
1894
+ readonly _tag: "OwnershipLost";
1895
+ readonly submissionId: string;
1896
+ } | {
1897
+ readonly _tag: "OperationDenied";
1898
+ readonly operation: "abort" | "awaitSettlement" | "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
1899
+ readonly reason: string;
1900
+ readonly threadId?: string | undefined;
1901
+ readonly submissionId?: string | undefined;
1902
+ } | {
1903
+ readonly _tag: "SettlementConflict";
1904
+ readonly submissionId: string;
1905
+ readonly existingOutcome: "aborted" | "completed" | "failed";
1906
+ } | {
1907
+ readonly _tag: "AdmissionPolicyError";
1908
+ readonly reason: "occupied" | "refused" | "unavailable";
1909
+ readonly code: string;
1910
+ readonly cause?: import("@yielded/agent/failure-diagnostic").Diagnostic | undefined;
1911
+ readonly stack?: string | undefined;
1912
+ } | {
1913
+ readonly _tag: "DigestError";
1914
+ readonly message: string;
1915
+ readonly cause?: Schema.Json | undefined;
1916
+ } | {
1917
+ readonly _tag: "DurableRuntimeFailpointError";
1918
+ readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-duration-append" | "run:after-start-append" | "run:before-duration-append" | "run:before-start-append" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "subagent:before-join-append" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:before-publication" | "tools:after-dispatch-fence" | "tools:after-unavailable-append" | "tools:before-dispatch-fence" | "tools:before-unavailable-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "update:after-canonical-append" | "update:after-delivery-insert" | "update:before-canonical-append" | "update:before-delivery-insert" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-stop-append" | "worker:after-stop-seal" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-stop-append" | "worker:before-stop-seal" | "worker:before-subtree-append";
1919
+ } | {
1920
+ readonly _tag: "AdmissionConflict";
1921
+ readonly threadId: string;
1922
+ readonly principal: string;
1923
+ readonly idempotencyKey: string;
1924
+ readonly existingInputDigest: string;
1925
+ readonly attemptedInputDigest: string;
1926
+ } | {
1927
+ readonly _tag: "AgentInputError";
1928
+ readonly message: string;
1929
+ } | {
1930
+ readonly _tag: "AdmissionLimitExceeded";
1931
+ readonly limit: "database-bytes" | "input-bytes" | "queue-depth";
1932
+ readonly actual: number;
1933
+ readonly maximum: number;
1934
+ } | {
1935
+ readonly _tag: "DurableAlarmError";
1936
+ readonly operation: string;
1937
+ readonly message: string;
1938
+ readonly cause?: Schema.Json | undefined;
1939
+ } | {
1940
+ readonly _tag: "HostProtocolError";
1941
+ readonly message: string;
1942
+ } | {
1943
+ readonly _tag: "JoinedToHost";
1944
+ readonly submissionId: string;
1945
+ readonly hostSubmissionId: string;
1946
+ } | {
1947
+ readonly _tag: "ApprovalConflict";
1948
+ readonly submissionId: string;
1949
+ readonly toolCallId: string;
1950
+ readonly existingDecision: "approved" | "denied";
1951
+ } | {
1952
+ readonly _tag: "UnknownResolutionConflict";
1953
+ readonly submissionId: string;
1954
+ readonly toolCallId: string;
1955
+ };
1956
+ }, Schema.SchemaError, never>;
1957
+ declare const decodeHostResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AbortRecorded | ApprovalRecorded | HostFailed | ObservedPage | ProgressCancelled | ProgressObserved | SettlementReached | SettlementRecordReached | SubmissionStatusResponse | SubmitSucceeded | UnknownResolutionRecorded, Schema.SchemaError, never>;
1958
+ /** Failure surface of `CloudflareThreadClient.submit`. */
1959
+ declare const ClientSubmitHostFailure: Schema.Union<readonly [typeof AgentInputError, typeof DigestError, typeof AdmissionConflict, typeof AdmissionPolicyError, typeof LedgerError, typeof OwnershipLost, typeof ThreadStoreError, typeof ThreadNotMaterialized, typeof AppendConflict, typeof DurableRuntimeFailpointError, typeof AdmissionLimitExceeded, typeof DurableAlarmError, typeof HostProtocolError]>;
1960
+ declare const ClientAwaitHostFailure: Schema.Union<readonly [typeof LedgerError, typeof OwnershipLost, typeof SettlementConflict, typeof OperationDenied, typeof HostProtocolError]>;
1961
+ declare const ClientObserveHostFailure: Schema.Union<readonly [typeof ThreadStoreError, typeof ThreadNotMaterialized, typeof OperationDenied, typeof HostProtocolError]>;
1962
+ declare const ClientAbortHostFailure: Schema.Union<readonly [typeof OperationDenied, typeof LedgerError, typeof OwnershipLost, typeof SettlementConflict, typeof JoinedToHost, typeof DurableRuntimeFailpointError, typeof DurableAlarmError, typeof HostProtocolError]>;
1963
+ declare const ClientApprovalHostFailure: Schema.Union<readonly [typeof LedgerError, typeof OwnershipLost, typeof SettlementConflict, typeof ApprovalConflict, typeof OperationDenied, typeof DurableAlarmError, typeof HostProtocolError]>;
1964
+ declare const ClientUnknownHostFailure: Schema.Union<readonly [typeof LedgerError, typeof OwnershipLost, typeof SettlementConflict, typeof UnknownResolutionConflict, typeof JoinedToHost, typeof DurableRuntimeFailpointError, typeof OperationDenied, typeof DurableAlarmError, typeof HostProtocolError]>;
1965
+ type ClientSubmitFailure = typeof ClientSubmitHostFailure.Type | ThreadClientError;
1966
+ type ClientAwaitFailure = typeof ClientAwaitHostFailure.Type | ThreadClientError;
1967
+ type ClientObserveFailure = typeof ClientObserveHostFailure.Type | ThreadClientError;
1968
+ type ClientProgressFailure = ClientObserveFailure;
1969
+ type ClientAbortFailure = typeof ClientAbortHostFailure.Type | ThreadClientError;
1970
+ type ClientApprovalFailure = typeof ClientApprovalHostFailure.Type | ThreadClientError;
1971
+ type ClientUnknownFailure = typeof ClientUnknownHostFailure.Type | ThreadClientError;
1972
+ declare const CloudflareThreadClient_base: Context.ServiceClass<CloudflareThreadClient, "@effect-agent/platform-cloudflare/CloudflareThreadClient", {
1973
+ /** Encode the input client-side, then durably submit to the owning Object. */
1974
+ readonly submit: <InputSchema extends Schema.Top>(agent: DurableSubmitAgent<InputSchema>, input: InputSchema["Type"], options: DurableSubmitOptions) => Effect.Effect<Receipt, ClientSubmitFailure, InputSchema["EncodingServices"]>;
1975
+ /** Wake-hinted, poll-guaranteed settlement wait executed inside the owning Object. */
1976
+ readonly submissionStatus: (receipt: Receipt) => Effect.Effect<SubmissionStatus, ClientAwaitFailure>;
1977
+ readonly awaitSettlement: (receipt: Receipt) => Effect.Effect<Settlement, ClientAwaitFailure>;
1978
+ /**
1979
+ * Wait for finalization and return this Receipt's canonical terminal record in one RPC.
1980
+ * Requires both settlement and observation authority. Decode an ordinary completed
1981
+ * record's result through the Agent output Schema; joined completion may have no result.
1982
+ */
1983
+ readonly awaitSettlementRecord: (receipt: Receipt) => Effect.Effect<SubmissionSettledRecord, ClientAwaitFailure>;
1984
+ /**
1985
+ * Wait without polling until progress after `afterSequence` is already durable or hinted.
1986
+ * The result is deliberately void: canonical records remain authoritative and must be read.
1987
+ * Interruption waits at most one second for best-effort remote cancellation.
1988
+ */
1989
+ readonly awaitProgress: (threadId: ThreadId, afterSequence: CanonicalSequence) => Effect.Effect<void, ClientProgressFailure>;
1990
+ /**
1991
+ * Current provisional text followed by native deltas. Reset starts a replacement snapshot,
1992
+ * including when a slow consumer exceeds the fixed backlog. Reconcile by
1993
+ * Run/Turn identity to canonical records; discard drafts on Discard, AttemptEnded,
1994
+ * Reset or stream failure. Snapshots exist only in the Object incarnation's memory.
1995
+ * Scope the stream: interruption cancels its remote subscription.
1996
+ */
1997
+ readonly watchText: (threadId: ThreadId) => Stream.Stream<Frame, ClientObserveFailure>;
1998
+ /** One bounded page of canonical records. */
1999
+ readonly readPage: (threadId: ThreadId, options?: {
2000
+ readonly afterSequence?: CanonicalSequence | undefined;
2001
+ readonly limit?: number | undefined;
2002
+ }) => Effect.Effect<ReadonlyArray<CanonicalRecordEnvelope>, ClientObserveFailure>;
2003
+ /**
2004
+ * Every canonical record up to the CURRENT committed tail, via repeated pages. A
2005
+ * snapshot read, not a live observation — callers wanting liveness re-read after
2006
+ * `awaitSettlement`.
2007
+ */
2008
+ readonly readAll: (threadId: ThreadId) => Effect.Effect<ReadonlyArray<CanonicalRecordEnvelope>, ClientObserveFailure>;
2009
+ /**
2010
+ * Submission-addressed operations take the owning Thread explicitly (from the
2011
+ * Receipt): minted Submission identities stay OPAQUE outside the storage adapter that
2012
+ * minted them (D-P6-5), so the client never parses one to find the lane.
2013
+ */
2014
+ readonly abort: (threadId: ThreadId, command: AbortCommand) => Effect.Effect<AbortIntent, ClientAbortFailure>;
2015
+ readonly resolveApproval: (threadId: ThreadId, command: ApprovalDecisionCommand) => Effect.Effect<ApprovalDecisionIntent, ClientApprovalFailure>;
2016
+ readonly resolveUnknown: (threadId: ThreadId, command: UnknownResolutionCommand) => Effect.Effect<UnknownResolutionIntent, ClientUnknownFailure>;
2017
+ }>;
2018
+ /** Worker-side client over the Thread Object namespace (DEPLOY-010). */
2019
+ declare class CloudflareThreadClient extends CloudflareThreadClient_base {
2020
+ /**
2021
+ * Assemble the client from a resolved namespace and the platform Crypto implementation.
2022
+ * rpcTracing is the binding name and remains opt-in. Caller authentication, principals,
2023
+ * idempotency keys, and definition digests are still explicit submission inputs.
2024
+ */
2025
+ static layerFromBinding(options: {
2026
+ readonly namespace: DurableObjectNamespace<ThreadObjectRpc>;
2027
+ readonly rpcTracing?: string;
2028
+ }): Layer.Layer<CloudflareThreadClient>;
2029
+ static readonly layer: Layer.Layer<CloudflareThreadClient, never, ThreadObjectNamespace | Crypto.Crypto>;
2030
+ }
2031
+ //#endregion
2032
+ export { decodeAbortCommand as A, encodeApprovalDecisionCommand as B, SettlementRecordReached as C, ThreadClientError as D, SubmitSucceeded as E, decodeObservePageRequest as F, encodeReceipt as G, encodeCancelProgressRequest as H, decodeReceipt as I, Frame as J, encodeSubmitRequest as K, decodeSubmitRequest as L, decodeAwaitProgressRequest as M, decodeCancelProgressRequest as N, UnknownResolutionRecorded as O, decodeHostResponse as P, decodeUnknownResolutionCommand as R, SettlementReached as S, SubmitRequest as T, encodeHostResponse as U, encodeAwaitProgressRequest as V, encodeObservePageRequest as W, HostResponse as _, ClientAbortFailure as a, ProgressCancelled as b, ClientObserveFailure as c, ClientUnknownFailure as d, CloudflareThreadClient as f, HostProtocolError as g, HostFailure as h, CancelProgressRequest as i, decodeApprovalDecisionCommand as j, boundHostDiagnostic as k, ClientProgressFailure as l, HostFailed as m, ApprovalRecorded as n, ClientApprovalFailure as o, CloudflareThreadClient_d_exports as p, encodeUnknownResolutionCommand as q, AwaitProgressRequest as r, ClientAwaitFailure as s, AbortRecorded as t, ClientSubmitFailure as u, ObservePageRequest as v, SubmissionStatusResponse as w, ProgressObserved as x, ObservedPage as y, encodeAbortCommand as z };
2033
+ //# sourceMappingURL=CloudflareThreadClient-QsVzLGGZ.d.mts.map