@effect-agent/platform-cloudflare 0.1.0-beta.84 → 0.1.0-beta.86
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.
- package/dist/Alarm.d.mts +4 -4
- package/dist/Alarm.mjs +6 -6
- package/dist/Alarm.mjs.map +1 -1
- package/dist/BrowserRestCapture.d.mts +3 -3
- package/dist/BrowserRestCapture.mjs +3 -3
- package/dist/BrowserRestCapture.mjs.map +1 -1
- package/dist/BrowserRestCrawl.d.mts +2 -2
- package/dist/BrowserRestCrawl.mjs +3 -3
- package/dist/BrowserRestCrawl.mjs.map +1 -1
- package/dist/CloudflareBindings.d.mts +2 -2
- package/dist/CloudflareBindings.mjs +2 -2
- package/dist/CloudflareBindings.mjs.map +1 -1
- package/dist/{CloudflareBrowser-D4YqaTAl.mjs → CloudflareBrowser-DV6kya1H.mjs} +4 -4
- package/dist/CloudflareBrowser-DV6kya1H.mjs.map +1 -0
- package/dist/{CloudflareBrowser-DJq53niJ.d.mts → CloudflareBrowser-Doe1M7R5.d.mts} +4 -4
- package/dist/CloudflareBrowser.d.mts +1 -1
- package/dist/CloudflareBrowser.mjs +1 -1
- package/dist/CloudflareCodeMode.d.mts +2 -2
- package/dist/CloudflareCodeMode.mjs +2 -2
- package/dist/CloudflareCodeMode.mjs.map +1 -1
- package/dist/CloudflareConfig.mjs +3 -3
- package/dist/CloudflareConfig.mjs.map +1 -1
- package/dist/CloudflareMemory.d.mts +26 -26
- package/dist/CloudflareMemory.mjs +16 -16
- package/dist/CloudflareMemory.mjs.map +1 -1
- package/dist/CloudflareScheduling.d.mts +3 -3
- package/dist/CloudflareScheduling.mjs +11 -11
- package/dist/CloudflareScheduling.mjs.map +1 -1
- package/dist/CloudflareSubscriptions.d.mts +5 -5
- package/dist/CloudflareSubscriptions.mjs +20 -14
- package/dist/CloudflareSubscriptions.mjs.map +1 -1
- package/dist/CloudflareThreadClient.d.mts +228 -18
- package/dist/CloudflareThreadClient.mjs +12 -12
- package/dist/CloudflareThreadClient.mjs.map +1 -1
- package/dist/InteractiveBrowser.d.mts +2 -2
- package/dist/InteractiveBrowser.mjs +18 -18
- package/dist/InteractiveBrowser.mjs.map +1 -1
- package/dist/ProtectedBrowser.d.mts +2 -2
- package/dist/ProtectedBrowser.mjs +14 -14
- package/dist/ProtectedBrowser.mjs.map +1 -1
- package/dist/{ThreadObject-mmWMMWdY.mjs → ThreadObject-B4gJ7t0d.mjs} +29 -27
- package/dist/ThreadObject-B4gJ7t0d.mjs.map +1 -0
- package/dist/{ThreadObject-BS1gRV0V.d.mts → ThreadObject-BT0c-_vx.d.mts} +61 -65
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/ThreadObject.mjs +1 -1
- package/dist/WakeScheduler.d.mts +1 -1
- package/dist/WakeScheduler.mjs +2 -2
- package/dist/WakeScheduler.mjs.map +1 -1
- package/dist/{browser-session-lifecycle-CUbVfEgP.mjs → browser-session-lifecycle-CmbQABHC.mjs} +5 -5
- package/dist/browser-session-lifecycle-CmbQABHC.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{prepared-admission-DSi55W-7.mjs → prepared-admission-DU0_T-ev.mjs} +7 -7
- package/dist/prepared-admission-DU0_T-ev.mjs.map +1 -0
- package/package.json +1 -1
- package/src/Alarm.ts +19 -19
- package/src/BrowserRestCapture.ts +3 -3
- package/src/BrowserRestCrawl.ts +13 -13
- package/src/CloudflareBindings.ts +2 -2
- package/src/CloudflareCodeMode.ts +4 -4
- package/src/CloudflareConfig.ts +3 -3
- package/src/CloudflareMemory.ts +29 -29
- package/src/CloudflareScheduling.ts +13 -13
- package/src/CloudflareSubscriptions.ts +28 -32
- package/src/CloudflareThreadClient.ts +14 -14
- package/src/InteractiveBrowser.ts +34 -37
- package/src/ThreadObject.ts +14 -14
- package/src/WakeScheduler.ts +2 -2
- package/src/internal/browser-quick-action.ts +4 -4
- package/src/internal/browser-session-lifecycle.ts +8 -8
- package/src/internal/layers.ts +47 -47
- package/src/internal/message-delivery.ts +9 -10
- package/src/internal/prepared-admission.ts +7 -7
- package/src/internal/transport.ts +1 -1
- package/src/protected-browser/binding.ts +3 -3
- package/src/protected-browser/native.ts +3 -3
- package/src/protected-browser/policy.ts +42 -44
- package/dist/CloudflareBrowser-D4YqaTAl.mjs.map +0 -1
- package/dist/ThreadObject-mmWMMWdY.mjs.map +0 -1
- package/dist/browser-session-lifecycle-CUbVfEgP.mjs.map +0 -1
- package/dist/prepared-admission-DSi55W-7.mjs.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ThreadObjectNamespace, ThreadObjectRpc } from "./CloudflareBindings.mjs";
|
|
2
2
|
import { t as AdmissionLimitExceeded } from "./CloudflareConfig-f3CqTel1.mjs";
|
|
3
3
|
import { DurableAlarmError } from "./Alarm.mjs";
|
|
4
|
-
import { ThreadId } from "@effect-agent/core/Identifiers";
|
|
5
|
-
import { DurableSubmitAgent, DurableSubmitOptions, Receipt } from "@effect-agent/thread/DurableAgentRuntime";
|
|
6
|
-
import { AbortCommand, AbortIntent, AdmissionConflict, AdmissionPolicyError, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, JoinedToHost, LedgerError, Settlement, SettlementConflict, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent } from "@effect-agent/thread/SubmissionLedger";
|
|
7
4
|
import { Context, Crypto, Effect, Layer, Schema } from "effect";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
5
|
+
import { DurableSubmitAgent, DurableSubmitOptions, Receipt } from "effect-agent/durable-agent-runtime";
|
|
6
|
+
import { ThreadId } from "effect-agent/identifiers";
|
|
7
|
+
import { AbortCommand, AbortIntent, AdmissionConflict, AdmissionPolicyError, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, JoinedToHost, LedgerError, Settlement, SettlementConflict, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent } from "effect-agent/submission-ledger";
|
|
8
|
+
import { CanonicalRecordEnvelope, CanonicalSequence, DefinitionDigests } from "effect-agent/records";
|
|
9
|
+
import { AgentInputError } from "effect-agent/agent-error";
|
|
10
|
+
import { DigestError } from "effect-agent/digest";
|
|
11
|
+
import { DurableRuntimeFailpointError } from "effect-agent/durable-failpoint";
|
|
12
|
+
import { OperationDenied } from "effect-agent/operation-authorizer";
|
|
13
|
+
import { SubmissionStatus } from "effect-agent/submission-status";
|
|
14
|
+
import { AppendConflict, FenceRejected, ThreadNotMaterialized, ThreadStoreError } from "effect-agent/thread-store";
|
|
15
15
|
declare namespace CloudflareThreadClient_d_exports {
|
|
16
16
|
export { AbortRecorded, ApprovalRecorded, AwaitProgressRequest, CancelProgressRequest, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientProgressFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareThreadClient, HostFailed, HostFailure, HostProtocolError, HostResponse, ObservePageRequest, ObservedPage, ProgressCancelled, ProgressObserved, SettlementReached, SubmissionStatusResponse, SubmitRequest, SubmitSucceeded, ThreadClientError, UnknownResolutionRecorded, boundHostDiagnostic, decodeAbortCommand, decodeApprovalDecisionCommand, decodeAwaitProgressRequest, decodeCancelProgressRequest, decodeHostResponse, decodeObservePageRequest, decodeReceipt, decodeSubmitRequest, decodeUnknownResolutionCommand, encodeAbortCommand, encodeApprovalDecisionCommand, encodeAwaitProgressRequest, encodeCancelProgressRequest, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand };
|
|
17
17
|
}
|
|
@@ -67,19 +67,20 @@ declare const SubmitRequest_base: Schema.Class<SubmitRequest, Schema.Struct<{
|
|
|
67
67
|
}>]>;
|
|
68
68
|
readonly budgetScope: Schema.optionalKey<Schema.Literals<readonly ["source-subtree", "worker-run"]>>;
|
|
69
69
|
readonly targetDigests: typeof DefinitionDigests;
|
|
70
|
-
readonly policy: Schema.toCodecJson<typeof import("
|
|
70
|
+
readonly policy: Schema.toCodecJson<typeof import("effect-agent/agent-policy").AgentPolicy>;
|
|
71
71
|
readonly budget: Schema.Struct<{
|
|
72
|
-
readonly caps: typeof import("
|
|
73
|
-
readonly allocation: typeof import("
|
|
72
|
+
readonly caps: typeof import("effect-agent/subagent-contract").SubagentDelegationCaps;
|
|
73
|
+
readonly allocation: typeof import("effect-agent/subagent-contract").SubagentReservationAmounts;
|
|
74
74
|
readonly descendantInvocations: Schema.optionalKey<Schema.Natural>;
|
|
75
75
|
}>;
|
|
76
|
-
readonly grant: typeof import("
|
|
76
|
+
readonly grant: typeof import("effect-agent/subagent-contract").SubagentGrant;
|
|
77
77
|
readonly depth: Schema.Int;
|
|
78
78
|
readonly toolCallAllowance: Schema.optionalKey<Schema.Int>;
|
|
79
79
|
readonly firstMessageId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/IdempotencyKey">;
|
|
80
80
|
readonly createdAtMillis: Schema.Natural;
|
|
81
81
|
readonly expiresAtMillis: Schema.Natural;
|
|
82
82
|
readonly reporting: Schema.optionalKey<Schema.Struct<{
|
|
83
|
+
readonly mode: Schema.optionalKey<Schema.Literal<"standard">>;
|
|
83
84
|
readonly sourceDigests: typeof DefinitionDigests;
|
|
84
85
|
readonly destinationDelegationId: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "@effect-agent/core/DelegationId">>;
|
|
85
86
|
}>>;
|
|
@@ -89,8 +90,9 @@ declare const SubmitRequest_base: Schema.Class<SubmitRequest, Schema.Struct<{
|
|
|
89
90
|
readonly createdAtMillis: Schema.Natural;
|
|
90
91
|
readonly sourceSubmissionId: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">>;
|
|
91
92
|
readonly deliveryPrincipal: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/Principal">>;
|
|
93
|
+
readonly reportKind: Schema.optionalKey<Schema.Literal<"update">>;
|
|
92
94
|
}>>;
|
|
93
|
-
readonly messageAdmission: Schema.optionalKey<Schema.Struct<{
|
|
95
|
+
readonly messageAdmission: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
94
96
|
readonly schemaVersion: Schema.Literal<1>;
|
|
95
97
|
readonly message: Schema.Struct<{
|
|
96
98
|
readonly ownerThreadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
|
|
@@ -109,7 +111,48 @@ declare const SubmitRequest_base: Schema.Class<SubmitRequest, Schema.Struct<{
|
|
|
109
111
|
readonly ownerThreadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
|
|
110
112
|
readonly messageId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/IdempotencyKey">;
|
|
111
113
|
}>>;
|
|
112
|
-
}
|
|
114
|
+
}>, Schema.Union<readonly [Schema.Struct<{
|
|
115
|
+
readonly _tag: Schema.Literal<"WorkerCompletion">;
|
|
116
|
+
readonly budgetExhausted: Schema.Boolean;
|
|
117
|
+
readonly schemaVersion: Schema.Literal<1>;
|
|
118
|
+
readonly report: Schema.Union<readonly [Schema.Struct<{
|
|
119
|
+
readonly _tag: Schema.Literal<"Settled">;
|
|
120
|
+
readonly worker: Schema.Struct<{
|
|
121
|
+
readonly schemaVersion: Schema.Literal<1>;
|
|
122
|
+
readonly delegationId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/DelegationId">;
|
|
123
|
+
readonly targetAgentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
|
|
124
|
+
readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
|
|
125
|
+
}>;
|
|
126
|
+
readonly receipt: typeof Receipt;
|
|
127
|
+
readonly runId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/RunId">;
|
|
128
|
+
readonly settlementId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SettlementId">;
|
|
129
|
+
readonly outcome: Schema.Literal<"completed">;
|
|
130
|
+
readonly result: Schema.Union<readonly [Schema.Codec<Schema.Json, Schema.Json, never, never>]>;
|
|
131
|
+
}>, Schema.Struct<{
|
|
132
|
+
readonly _tag: Schema.Literal<"Settled">;
|
|
133
|
+
readonly worker: Schema.Struct<{
|
|
134
|
+
readonly schemaVersion: Schema.Literal<1>;
|
|
135
|
+
readonly delegationId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/DelegationId">;
|
|
136
|
+
readonly targetAgentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
|
|
137
|
+
readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
|
|
138
|
+
}>;
|
|
139
|
+
readonly receipt: typeof Receipt;
|
|
140
|
+
readonly runId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/RunId">;
|
|
141
|
+
readonly settlementId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SettlementId">;
|
|
142
|
+
readonly outcome: Schema.Literals<readonly ["failed", "aborted"]>;
|
|
143
|
+
readonly failure: typeof import("effect-agent/subagent-contract").SubagentExecutionFailure;
|
|
144
|
+
}>]>;
|
|
145
|
+
}>, Schema.Struct<{
|
|
146
|
+
readonly _tag: Schema.Literal<"WorkerUpdate">;
|
|
147
|
+
readonly schemaVersion: Schema.Literal<1>;
|
|
148
|
+
readonly worker: Schema.Struct<{
|
|
149
|
+
readonly schemaVersion: Schema.Literal<1>;
|
|
150
|
+
readonly delegationId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/DelegationId">;
|
|
151
|
+
readonly targetAgentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/AgentId">;
|
|
152
|
+
readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
|
|
153
|
+
}>;
|
|
154
|
+
readonly update: typeof import("effect-agent/agent-updates").Update;
|
|
155
|
+
}>]>]>>;
|
|
113
156
|
readonly definitions: typeof DefinitionDigests;
|
|
114
157
|
readonly inputPayload: Schema.declare<Schema.Json, Schema.Json>;
|
|
115
158
|
}>, {}>;
|
|
@@ -150,7 +193,7 @@ declare const SubmitSucceeded_base: Schema.Class<SubmitSucceeded, Schema.TaggedS
|
|
|
150
193
|
}>, {}>;
|
|
151
194
|
declare class SubmitSucceeded extends SubmitSucceeded_base {}
|
|
152
195
|
declare const SubmissionStatusResponse_base: Schema.Class<SubmissionStatusResponse, Schema.TaggedStruct<"SubmissionStatusResponse", {
|
|
153
|
-
readonly status: Schema.Union<readonly [typeof import("
|
|
196
|
+
readonly status: Schema.Union<readonly [typeof import("effect-agent/submission-status").PendingSubmission, typeof import("effect-agent/submission-status").SettledSubmission]>;
|
|
154
197
|
}>, {}>;
|
|
155
198
|
declare class SubmissionStatusResponse extends SubmissionStatusResponse_base {}
|
|
156
199
|
declare const SettlementReached_base: Schema.Class<SettlementReached, Schema.TaggedStruct<"SettlementReached", {
|
|
@@ -257,6 +300,7 @@ declare const encodeSubmitRequest: (input: SubmitRequest, options?: import("effe
|
|
|
257
300
|
readonly createdAtMillis: number;
|
|
258
301
|
readonly expiresAtMillis: number;
|
|
259
302
|
readonly reporting?: {
|
|
303
|
+
readonly mode?: "standard" | undefined;
|
|
260
304
|
readonly sourceDigests: {
|
|
261
305
|
readonly agent: string;
|
|
262
306
|
readonly model: string;
|
|
@@ -270,6 +314,7 @@ declare const encodeSubmitRequest: (input: SubmitRequest, options?: import("effe
|
|
|
270
314
|
readonly createdAtMillis: number;
|
|
271
315
|
readonly sourceSubmissionId?: string | undefined;
|
|
272
316
|
readonly deliveryPrincipal?: string | undefined;
|
|
317
|
+
readonly reportKind?: "update" | undefined;
|
|
273
318
|
} | undefined;
|
|
274
319
|
readonly messageAdmission?: {
|
|
275
320
|
readonly schemaVersion: 1;
|
|
@@ -290,6 +335,75 @@ declare const encodeSubmitRequest: (input: SubmitRequest, options?: import("effe
|
|
|
290
335
|
readonly ownerThreadId: string;
|
|
291
336
|
readonly messageId: string;
|
|
292
337
|
} | undefined;
|
|
338
|
+
} | {
|
|
339
|
+
readonly _tag: "WorkerCompletion";
|
|
340
|
+
readonly budgetExhausted: boolean;
|
|
341
|
+
readonly schemaVersion: 1;
|
|
342
|
+
readonly report: {
|
|
343
|
+
readonly _tag: "Settled";
|
|
344
|
+
readonly worker: {
|
|
345
|
+
readonly schemaVersion: 1;
|
|
346
|
+
readonly delegationId: string;
|
|
347
|
+
readonly targetAgentId: string;
|
|
348
|
+
readonly threadId: string;
|
|
349
|
+
};
|
|
350
|
+
readonly receipt: {
|
|
351
|
+
readonly receiptId: string;
|
|
352
|
+
readonly submissionId: string;
|
|
353
|
+
readonly threadId: string;
|
|
354
|
+
readonly queueSequence: number;
|
|
355
|
+
};
|
|
356
|
+
readonly runId: string;
|
|
357
|
+
readonly settlementId: string;
|
|
358
|
+
readonly outcome: "completed";
|
|
359
|
+
readonly result: Schema.Json;
|
|
360
|
+
} | {
|
|
361
|
+
readonly _tag: "Settled";
|
|
362
|
+
readonly worker: {
|
|
363
|
+
readonly schemaVersion: 1;
|
|
364
|
+
readonly delegationId: string;
|
|
365
|
+
readonly targetAgentId: string;
|
|
366
|
+
readonly threadId: string;
|
|
367
|
+
};
|
|
368
|
+
readonly receipt: {
|
|
369
|
+
readonly receiptId: string;
|
|
370
|
+
readonly submissionId: string;
|
|
371
|
+
readonly threadId: string;
|
|
372
|
+
readonly queueSequence: number;
|
|
373
|
+
};
|
|
374
|
+
readonly runId: string;
|
|
375
|
+
readonly settlementId: string;
|
|
376
|
+
readonly outcome: "aborted" | "failed";
|
|
377
|
+
readonly failure: {
|
|
378
|
+
readonly _tag: "SubagentExecutionFailure";
|
|
379
|
+
readonly delegationId: string;
|
|
380
|
+
readonly targetAgentId: string;
|
|
381
|
+
readonly classification: "child-aborted" | "child-compatibility" | "child-failed" | "declaration-unavailable" | "establishment-denied";
|
|
382
|
+
readonly childThreadId?: string | undefined;
|
|
383
|
+
readonly childSubmissionId?: string | undefined;
|
|
384
|
+
readonly childRunId?: string | undefined;
|
|
385
|
+
readonly errorTag: string;
|
|
386
|
+
readonly message: string;
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
} | {
|
|
390
|
+
readonly _tag: "WorkerUpdate";
|
|
391
|
+
readonly schemaVersion: 1;
|
|
392
|
+
readonly worker: {
|
|
393
|
+
readonly schemaVersion: 1;
|
|
394
|
+
readonly delegationId: string;
|
|
395
|
+
readonly targetAgentId: string;
|
|
396
|
+
readonly threadId: string;
|
|
397
|
+
};
|
|
398
|
+
readonly update: {
|
|
399
|
+
readonly schemaVersion: 1;
|
|
400
|
+
readonly agentId: string;
|
|
401
|
+
readonly threadId: string;
|
|
402
|
+
readonly runId: string;
|
|
403
|
+
readonly updateId: string;
|
|
404
|
+
readonly sequence: number;
|
|
405
|
+
readonly value: Schema.Json;
|
|
406
|
+
};
|
|
293
407
|
} | undefined;
|
|
294
408
|
readonly definitions: {
|
|
295
409
|
readonly agent: string;
|
|
@@ -514,6 +628,75 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
514
628
|
readonly ownerThreadId: string;
|
|
515
629
|
readonly messageId: string;
|
|
516
630
|
} | undefined;
|
|
631
|
+
} | {
|
|
632
|
+
readonly _tag: "WorkerCompletion";
|
|
633
|
+
readonly budgetExhausted: boolean;
|
|
634
|
+
readonly schemaVersion: 1;
|
|
635
|
+
readonly report: {
|
|
636
|
+
readonly _tag: "Settled";
|
|
637
|
+
readonly worker: {
|
|
638
|
+
readonly schemaVersion: 1;
|
|
639
|
+
readonly delegationId: string;
|
|
640
|
+
readonly targetAgentId: string;
|
|
641
|
+
readonly threadId: string;
|
|
642
|
+
};
|
|
643
|
+
readonly receipt: {
|
|
644
|
+
readonly receiptId: string;
|
|
645
|
+
readonly submissionId: string;
|
|
646
|
+
readonly threadId: string;
|
|
647
|
+
readonly queueSequence: number;
|
|
648
|
+
};
|
|
649
|
+
readonly runId: string;
|
|
650
|
+
readonly settlementId: string;
|
|
651
|
+
readonly outcome: "completed";
|
|
652
|
+
readonly result: Schema.Json;
|
|
653
|
+
} | {
|
|
654
|
+
readonly _tag: "Settled";
|
|
655
|
+
readonly worker: {
|
|
656
|
+
readonly schemaVersion: 1;
|
|
657
|
+
readonly delegationId: string;
|
|
658
|
+
readonly targetAgentId: string;
|
|
659
|
+
readonly threadId: string;
|
|
660
|
+
};
|
|
661
|
+
readonly receipt: {
|
|
662
|
+
readonly receiptId: string;
|
|
663
|
+
readonly submissionId: string;
|
|
664
|
+
readonly threadId: string;
|
|
665
|
+
readonly queueSequence: number;
|
|
666
|
+
};
|
|
667
|
+
readonly runId: string;
|
|
668
|
+
readonly settlementId: string;
|
|
669
|
+
readonly outcome: "aborted" | "failed";
|
|
670
|
+
readonly failure: {
|
|
671
|
+
readonly _tag: "SubagentExecutionFailure";
|
|
672
|
+
readonly delegationId: string;
|
|
673
|
+
readonly targetAgentId: string;
|
|
674
|
+
readonly classification: "child-aborted" | "child-compatibility" | "child-failed" | "declaration-unavailable" | "establishment-denied";
|
|
675
|
+
readonly childThreadId?: string | undefined;
|
|
676
|
+
readonly childSubmissionId?: string | undefined;
|
|
677
|
+
readonly childRunId?: string | undefined;
|
|
678
|
+
readonly errorTag: string;
|
|
679
|
+
readonly message: string;
|
|
680
|
+
};
|
|
681
|
+
};
|
|
682
|
+
} | {
|
|
683
|
+
readonly _tag: "WorkerUpdate";
|
|
684
|
+
readonly schemaVersion: 1;
|
|
685
|
+
readonly worker: {
|
|
686
|
+
readonly schemaVersion: 1;
|
|
687
|
+
readonly delegationId: string;
|
|
688
|
+
readonly targetAgentId: string;
|
|
689
|
+
readonly threadId: string;
|
|
690
|
+
};
|
|
691
|
+
readonly update: {
|
|
692
|
+
readonly schemaVersion: 1;
|
|
693
|
+
readonly agentId: string;
|
|
694
|
+
readonly threadId: string;
|
|
695
|
+
readonly runId: string;
|
|
696
|
+
readonly updateId: string;
|
|
697
|
+
readonly sequence: number;
|
|
698
|
+
readonly value: Schema.Json;
|
|
699
|
+
};
|
|
517
700
|
} | undefined;
|
|
518
701
|
} | {
|
|
519
702
|
readonly _tag: "RunStarted";
|
|
@@ -936,6 +1119,7 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
936
1119
|
readonly createdAtMillis: number;
|
|
937
1120
|
readonly expiresAtMillis: number;
|
|
938
1121
|
readonly reporting?: {
|
|
1122
|
+
readonly mode?: "standard" | undefined;
|
|
939
1123
|
readonly sourceDigests: {
|
|
940
1124
|
readonly agent: string;
|
|
941
1125
|
readonly model: string;
|
|
@@ -949,6 +1133,7 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
949
1133
|
readonly createdAtMillis: number;
|
|
950
1134
|
readonly sourceSubmissionId?: string | undefined;
|
|
951
1135
|
readonly deliveryPrincipal?: string | undefined;
|
|
1136
|
+
readonly reportKind?: "update" | undefined;
|
|
952
1137
|
};
|
|
953
1138
|
readonly inputDigest: string;
|
|
954
1139
|
} | {
|
|
@@ -1012,6 +1197,7 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1012
1197
|
readonly createdAtMillis: number;
|
|
1013
1198
|
readonly expiresAtMillis: number;
|
|
1014
1199
|
readonly reporting?: {
|
|
1200
|
+
readonly mode?: "standard" | undefined;
|
|
1015
1201
|
readonly sourceDigests: {
|
|
1016
1202
|
readonly agent: string;
|
|
1017
1203
|
readonly model: string;
|
|
@@ -1035,6 +1221,30 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1035
1221
|
readonly envelope: Schema.Json;
|
|
1036
1222
|
readonly createdAtMillis: number;
|
|
1037
1223
|
readonly deadlineAtMillis: number;
|
|
1224
|
+
readonly predecessor?: string | undefined;
|
|
1225
|
+
} | {
|
|
1226
|
+
readonly _tag: "AgentUpdateEmitted";
|
|
1227
|
+
readonly update: {
|
|
1228
|
+
readonly schemaVersion: 1;
|
|
1229
|
+
readonly agentId: string;
|
|
1230
|
+
readonly threadId: string;
|
|
1231
|
+
readonly runId: string;
|
|
1232
|
+
readonly updateId: string;
|
|
1233
|
+
readonly sequence: number;
|
|
1234
|
+
readonly value: Schema.Json;
|
|
1235
|
+
};
|
|
1236
|
+
readonly definitions: {
|
|
1237
|
+
readonly agent: string;
|
|
1238
|
+
readonly model: string;
|
|
1239
|
+
readonly tools: string;
|
|
1240
|
+
};
|
|
1241
|
+
readonly delivery?: {
|
|
1242
|
+
readonly messageId: string;
|
|
1243
|
+
readonly envelope: Schema.Json;
|
|
1244
|
+
readonly createdAtMillis: number;
|
|
1245
|
+
readonly deadlineAtMillis: number;
|
|
1246
|
+
readonly predecessor?: string | undefined;
|
|
1247
|
+
} | undefined;
|
|
1038
1248
|
} | {
|
|
1039
1249
|
readonly _tag: "WorkerReportRefused";
|
|
1040
1250
|
readonly runId: string;
|
|
@@ -1188,7 +1398,7 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1188
1398
|
readonly cause?: Schema.Json | undefined;
|
|
1189
1399
|
} | {
|
|
1190
1400
|
readonly _tag: "DurableRuntimeFailpointError";
|
|
1191
|
-
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "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-start-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:after-reserve" | "tools:after-prepared-append" | "tools:before-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "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-subtree-append";
|
|
1401
|
+
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "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-start-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:after-reserve" | "tools:after-prepared-append" | "tools:before-prepared-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-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-subtree-append";
|
|
1192
1402
|
} | {
|
|
1193
1403
|
readonly _tag: "SettlementConflict";
|
|
1194
1404
|
readonly submissionId: string;
|
|
@@ -3,20 +3,20 @@ import { ThreadObjectNamespace, callThreadObject } from "./CloudflareBindings.mj
|
|
|
3
3
|
import { AdmissionLimitExceeded } from "./CloudflareConfig.mjs";
|
|
4
4
|
import { r as safeCauseMessage, t as cloudflareFailureSignals } from "./boundary-BguazVkh.mjs";
|
|
5
5
|
import { DurableAlarmError } from "./Alarm.mjs";
|
|
6
|
-
import { AgentId } from "@effect-agent/core/Identifiers";
|
|
7
|
-
import { Receipt } from "@effect-agent/thread/DurableAgentRuntime";
|
|
8
|
-
import { AbortCommand, AbortIntent, AdmissionConflict, AdmissionFence, AdmissionGroup, AdmissionPolicyError, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, IdempotencyKey, JoinedToHost, LedgerError, Principal, Settlement, SettlementConflict, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent } from "@effect-agent/thread/SubmissionLedger";
|
|
9
6
|
import { Context, Crypto, Duration, Effect, Layer, Schema } from "effect";
|
|
10
|
-
import {
|
|
7
|
+
import { Receipt } from "effect-agent/durable-agent-runtime";
|
|
8
|
+
import { AgentId } from "effect-agent/identifiers";
|
|
9
|
+
import { AbortCommand, AbortIntent, AdmissionConflict, AdmissionFence, AdmissionGroup, AdmissionPolicyError, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, IdempotencyKey, JoinedToHost, LedgerError, Principal, Settlement, SettlementConflict, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent } from "effect-agent/submission-ledger";
|
|
10
|
+
import { CanonicalRecordEnvelope, CanonicalSequence, DefinitionDigests, PersistedJson, WorkerAdmission } from "effect-agent/records";
|
|
11
11
|
import { RpcTracing } from "effect-cf";
|
|
12
12
|
import { BrowserCrypto } from "@effect/platform-browser";
|
|
13
|
-
import { AgentInputError } from "
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { OperationDenied } from "
|
|
18
|
-
import { SubmissionStatus } from "
|
|
19
|
-
import { AppendConflict, FenceRejected, ThreadNotMaterialized, ThreadStoreError } from "
|
|
13
|
+
import { AgentInputError } from "effect-agent/agent-error";
|
|
14
|
+
import { DigestError } from "effect-agent/digest";
|
|
15
|
+
import { DurableRuntimeFailpointError } from "effect-agent/durable-failpoint";
|
|
16
|
+
import { InputMessage } from "effect-agent/messaging";
|
|
17
|
+
import { OperationDenied } from "effect-agent/operation-authorizer";
|
|
18
|
+
import { SubmissionStatus } from "effect-agent/submission-status";
|
|
19
|
+
import { AppendConflict, FenceRejected, ThreadNotMaterialized, ThreadStoreError } from "effect-agent/thread-store";
|
|
20
20
|
//#region src/CloudflareThreadClient.ts
|
|
21
21
|
var CloudflareThreadClient_exports = /* @__PURE__ */ __exportAll({
|
|
22
22
|
AbortRecorded: () => AbortRecorded,
|
|
@@ -100,7 +100,7 @@ var SubmitRequest = class extends Schema.Class("@effect-agent/platform-cloudflar
|
|
|
100
100
|
admissionGroup: Schema.optionalKey(AdmissionGroup),
|
|
101
101
|
admissionFence: Schema.optionalKey(AdmissionFence),
|
|
102
102
|
workerAdmission: Schema.optionalKey(WorkerAdmission),
|
|
103
|
-
messageAdmission: Schema.optionalKey(
|
|
103
|
+
messageAdmission: Schema.optionalKey(InputMessage),
|
|
104
104
|
definitions: DefinitionDigests,
|
|
105
105
|
inputPayload: PersistedJson
|
|
106
106
|
}) {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudflareThreadClient.mjs","names":[],"sources":["../src/CloudflareThreadClient.ts"],"sourcesContent":["import { AgentInputError } from \"@effect-agent/core/AgentError\";\nimport { AgentId, type ThreadId } from \"@effect-agent/core/Identifiers\";\nimport { MessageAdmission } from \"@effect-agent/core/Messaging\";\nimport { DigestError } from \"@effect-agent/thread/Digest\";\nimport {\n Receipt,\n type DurableSubmitAgent,\n type DurableSubmitOptions,\n} from \"@effect-agent/thread/DurableAgentRuntime\";\nimport { DurableRuntimeFailpointError } from \"@effect-agent/thread/DurableFailpoint\";\nimport { OperationDenied } from \"@effect-agent/thread/OperationAuthorizer\";\nimport {\n CanonicalRecordEnvelope,\n CanonicalSequence,\n DefinitionDigests,\n PersistedJson,\n WorkerAdmission,\n} from \"@effect-agent/thread/Records\";\nimport {\n AdmissionFence,\n AdmissionGroup,\n AbortCommand,\n AbortIntent,\n AdmissionConflict,\n AdmissionPolicyError,\n ApprovalConflict,\n ApprovalDecisionCommand,\n ApprovalDecisionIntent,\n IdempotencyKey,\n JoinedToHost,\n LedgerError,\n Principal,\n Settlement,\n SettlementConflict,\n UnknownResolutionCommand,\n UnknownResolutionConflict,\n UnknownResolutionIntent,\n} from \"@effect-agent/thread/SubmissionLedger\";\nimport { SubmissionStatus } from \"@effect-agent/thread/SubmissionStatus\";\nimport {\n AppendConflict,\n ThreadNotMaterialized,\n ThreadStoreError,\n FenceRejected,\n} from \"@effect-agent/thread/ThreadStore\";\nimport { BrowserCrypto } from \"@effect/platform-browser\";\nimport { Context, Crypto, Duration, Effect, Layer, Schema } from \"effect\";\nimport { RpcTracing } from \"effect-cf\";\n\nimport { DurableAlarmError } from \"./Alarm.ts\";\nimport {\n callThreadObject,\n ThreadObjectNamespace,\n type ThreadObjectRpc,\n} from \"./CloudflareBindings.ts\";\nimport { AdmissionLimitExceeded } from \"./CloudflareConfig.ts\";\nimport { cloudflareFailureSignals, safeCauseMessage } from \"./internal/boundary.ts\";\n\n/**\n * The Worker↔Thread-Object host protocol (plan §1.4): Schema envelopes for the host\n * entry points (`submitEncoded`, `awaitSettlementEncoded`, `observePage`, `abortEncoded`,\n * `resolveApprovalEncoded`, `resolveUnknownEncoded`) plus the Worker-side client that speaks\n * it. Mirrors the WP2 port protocol: requests and responses are closed Schema unions, typed\n * failures travel as their own tagged classes and RE-DECODE to identical tags on the caller\n * (error-tag fidelity), and protocol anomalies are answered typed instead of thrown.\n */\n\n/** Ceiling for host protocol diagnostic strings. */\nconst MAX_HOST_DIAGNOSTIC_LENGTH = 4_096;\nconst PROGRESS_CANCELLATION_TIMEOUT = \"1 second\";\n\nconst BoundedDiagnostic = Schema.String.check(Schema.isMaxLength(MAX_HOST_DIAGNOSTIC_LENGTH));\n\n/** Truncate a diagnostic string to the host protocol's bounded length. */\nexport const boundHostDiagnostic = (value: string): string =>\n value.length > MAX_HOST_DIAGNOSTIC_LENGTH\n ? `${value.slice(0, MAX_HOST_DIAGNOSTIC_LENGTH - 3)}...`\n : value;\n\n/**\n * The envelope itself could not be honored: the Object could not decode the request, or a\n * response could not be encoded/decoded. Never carries operation semantics.\n */\nexport class HostProtocolError extends Schema.TaggedError<HostProtocolError>()(\n \"HostProtocolError\",\n {\n message: BoundedDiagnostic,\n },\n) {}\n\n/** The Worker-side stub call itself failed (RPC rejection, overload, eviction mid-call). */\nexport class ThreadClientError extends Schema.TaggedError<ThreadClientError>()(\n \"ThreadClientError\",\n {\n threadId: Schema.String,\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n /** Cloudflare's own classification for a failure safe to retry with a fresh stub. */\n retryable: Schema.optionalKey(Schema.Boolean),\n /** Cloudflare overloads are surfaced immediately instead of adding retry pressure. */\n overloaded: Schema.optionalKey(Schema.Boolean),\n },\n) {}\n\n// ---------------------------------------------------------------------------\n// Requests\n// ---------------------------------------------------------------------------\n\n/**\n * One durable submission, input ALREADY encoded by the caller through the Agent Binding's\n * input schema (the Worker bundles the same Agent definitions as the Object, so schema\n * validation happens client-side; the resolved Binding re-validates at claim time). The\n * Thread identity is deliberately absent — the addressed Object IS the lane.\n */\nexport class SubmitRequest extends Schema.Class<SubmitRequest>(\n \"@effect-agent/platform-cloudflare/SubmitRequest\",\n)({\n agentId: AgentId,\n principal: Principal,\n idempotencyKey: IdempotencyKey,\n admissionGroup: Schema.optionalKey(AdmissionGroup),\n admissionFence: Schema.optionalKey(AdmissionFence),\n workerAdmission: Schema.optionalKey(WorkerAdmission),\n messageAdmission: Schema.optionalKey(MessageAdmission),\n definitions: DefinitionDigests,\n inputPayload: PersistedJson,\n}) {}\n\n/** One bounded page of canonical records after an optional sequence. */\nexport class ObservePageRequest extends Schema.Class<ObservePageRequest>(\n \"@effect-agent/platform-cloudflare/ObservePageRequest\",\n)({\n afterSequence: Schema.optionalKey(CanonicalSequence),\n limit: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(1_024)),\n}) {}\n\n/** One event-driven wait for canonical progress strictly after this sequence. */\nexport class AwaitProgressRequest extends Schema.Class<AwaitProgressRequest>(\n \"@effect-agent/platform-cloudflare/AwaitProgressRequest\",\n)({\n afterSequence: CanonicalSequence,\n waiterId: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256)),\n}) {}\n\n/** Best-effort cancellation of one in-flight progress RPC. */\nexport class CancelProgressRequest extends Schema.Class<CancelProgressRequest>(\n \"@effect-agent/platform-cloudflare/CancelProgressRequest\",\n)({\n waiterId: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256)),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Responses\n// ---------------------------------------------------------------------------\n\n/**\n * Every typed failure a host entry point can produce, plus the protocol's own errors. Same\n * closed-union discipline as the WP2 `PortFailure`: members re-decode to the SAME tagged\n * classes on the Worker side; `cause` chains travel as Schema defects without instance\n * fidelity (plan §2.8).\n */\nexport const HostFailure = Schema.Union([\n AgentInputError,\n DigestError,\n AdmissionConflict,\n AdmissionPolicyError,\n SettlementConflict,\n ApprovalConflict,\n UnknownResolutionConflict,\n JoinedToHost,\n LedgerError,\n ThreadStoreError,\n ThreadNotMaterialized,\n AppendConflict,\n FenceRejected,\n DurableRuntimeFailpointError,\n AdmissionLimitExceeded,\n DurableAlarmError,\n OperationDenied,\n HostProtocolError,\n]);\n\nexport type HostFailure = typeof HostFailure.Type;\n\nexport class SubmitSucceeded extends Schema.TaggedClass<SubmitSucceeded>(\n \"@effect-agent/platform-cloudflare/SubmitSucceeded\",\n)(\"SubmitSucceeded\", {\n receipt: Receipt,\n}) {}\n\nexport class SubmissionStatusResponse extends Schema.TaggedClass<SubmissionStatusResponse>(\n \"@effect-agent/platform-cloudflare/SubmissionStatusResponse\",\n)(\"SubmissionStatusResponse\", { status: SubmissionStatus }) {}\n\nexport class SettlementReached extends Schema.TaggedClass<SettlementReached>(\n \"@effect-agent/platform-cloudflare/SettlementReached\",\n)(\"SettlementReached\", {\n settlement: Settlement,\n}) {}\n\nexport class ObservedPage extends Schema.TaggedClass<ObservedPage>(\n \"@effect-agent/platform-cloudflare/ObservedPage\",\n)(\"ObservedPage\", {\n records: Schema.Array(CanonicalRecordEnvelope).check(Schema.isMaxLength(1_024)),\n}) {}\n\n/** A record was already committed or an incarnation-local hint says the caller should re-read. */\nexport class ProgressObserved extends Schema.TaggedClass<ProgressObserved>(\n \"@effect-agent/platform-cloudflare/ProgressObserved\",\n)(\"ProgressObserved\", {}) {}\n\nexport class ProgressCancelled extends Schema.TaggedClass<ProgressCancelled>(\n \"@effect-agent/platform-cloudflare/ProgressCancelled\",\n)(\"ProgressCancelled\", {}) {}\n\nexport class AbortRecorded extends Schema.TaggedClass<AbortRecorded>(\n \"@effect-agent/platform-cloudflare/AbortRecorded\",\n)(\"AbortRecorded\", {\n intent: AbortIntent,\n}) {}\n\nexport class ApprovalRecorded extends Schema.TaggedClass<ApprovalRecorded>(\n \"@effect-agent/platform-cloudflare/ApprovalRecorded\",\n)(\"ApprovalRecorded\", {\n intent: ApprovalDecisionIntent,\n}) {}\n\nexport class UnknownResolutionRecorded extends Schema.TaggedClass<UnknownResolutionRecorded>(\n \"@effect-agent/platform-cloudflare/UnknownResolutionRecorded\",\n)(\"UnknownResolutionRecorded\", {\n intent: UnknownResolutionIntent,\n}) {}\n\n/** The entry point failed TYPED on the Object; the failure re-decodes verbatim. */\nexport class HostFailed extends Schema.TaggedClass<HostFailed>(\n \"@effect-agent/platform-cloudflare/HostFailed\",\n)(\"HostFailed\", {\n failure: HostFailure,\n}) {}\n\n/** The uniform answer of one host entry point. Callers narrow by the tag their call implies. */\nexport const HostResponse = Schema.Union([\n SubmitSucceeded,\n SettlementReached,\n SubmissionStatusResponse,\n ObservedPage,\n ProgressObserved,\n ProgressCancelled,\n AbortRecorded,\n ApprovalRecorded,\n UnknownResolutionRecorded,\n HostFailed,\n]);\n\nexport type HostResponse = typeof HostResponse.Type;\n\n// ---------------------------------------------------------------------------\n// Codecs (shared by the Object endpoints and the Worker client)\n// ---------------------------------------------------------------------------\n\nexport const decodeSubmitRequest = Schema.decodeUnknownEffect(SubmitRequest);\nexport const encodeSubmitRequest = Schema.encodeEffect(SubmitRequest);\nexport const decodeReceipt = Schema.decodeUnknownEffect(Receipt);\nexport const encodeReceipt = Schema.encodeEffect(Receipt);\nexport const decodeObservePageRequest = Schema.decodeUnknownEffect(ObservePageRequest);\nexport const encodeObservePageRequest = Schema.encodeEffect(ObservePageRequest);\nexport const decodeAwaitProgressRequest = Schema.decodeUnknownEffect(AwaitProgressRequest);\nexport const encodeAwaitProgressRequest = Schema.encodeEffect(AwaitProgressRequest);\nexport const decodeCancelProgressRequest = Schema.decodeUnknownEffect(CancelProgressRequest);\nexport const encodeCancelProgressRequest = Schema.encodeEffect(CancelProgressRequest);\nexport const decodeAbortCommand = Schema.decodeUnknownEffect(AbortCommand);\nexport const encodeAbortCommand = Schema.encodeEffect(AbortCommand);\nexport const decodeApprovalDecisionCommand = Schema.decodeUnknownEffect(ApprovalDecisionCommand);\nexport const encodeApprovalDecisionCommand = Schema.encodeEffect(ApprovalDecisionCommand);\nexport const decodeUnknownResolutionCommand = Schema.decodeUnknownEffect(UnknownResolutionCommand);\nexport const encodeUnknownResolutionCommand = Schema.encodeEffect(UnknownResolutionCommand);\nexport const encodeHostResponse = Schema.encodeEffect(HostResponse);\nexport const decodeHostResponse = Schema.decodeUnknownEffect(HostResponse);\n\n// ---------------------------------------------------------------------------\n// Worker-side client\n// ---------------------------------------------------------------------------\n\n/** Failure surface of `CloudflareThreadClient.submit`. */\nconst ClientSubmitHostFailure = Schema.Union([\n AgentInputError,\n DigestError,\n AdmissionConflict,\n AdmissionPolicyError,\n LedgerError,\n ThreadStoreError,\n ThreadNotMaterialized,\n AppendConflict,\n FenceRejected,\n DurableRuntimeFailpointError,\n AdmissionLimitExceeded,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nconst ClientAwaitHostFailure = Schema.Union([\n LedgerError,\n SettlementConflict,\n OperationDenied,\n HostProtocolError,\n]);\n\nconst ClientObserveHostFailure = Schema.Union([\n ThreadStoreError,\n ThreadNotMaterialized,\n OperationDenied,\n HostProtocolError,\n]);\n\nconst ClientAbortHostFailure = Schema.Union([\n OperationDenied,\n LedgerError,\n SettlementConflict,\n JoinedToHost,\n DurableRuntimeFailpointError,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nconst ClientApprovalHostFailure = Schema.Union([\n LedgerError,\n SettlementConflict,\n ApprovalConflict,\n OperationDenied,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nconst ClientUnknownHostFailure = Schema.Union([\n LedgerError,\n SettlementConflict,\n UnknownResolutionConflict,\n JoinedToHost,\n DurableRuntimeFailpointError,\n OperationDenied,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nexport type ClientSubmitFailure = typeof ClientSubmitHostFailure.Type | ThreadClientError;\nexport type ClientAwaitFailure = typeof ClientAwaitHostFailure.Type | ThreadClientError;\nexport type ClientObserveFailure = typeof ClientObserveHostFailure.Type | ThreadClientError;\nexport type ClientProgressFailure = ClientObserveFailure;\nexport type ClientAbortFailure = typeof ClientAbortHostFailure.Type | ThreadClientError;\nexport type ClientApprovalFailure = typeof ClientApprovalHostFailure.Type | ThreadClientError;\nexport type ClientUnknownFailure = typeof ClientUnknownHostFailure.Type | ThreadClientError;\n\nconst outOfContract = (threadId: string, operation: string, observed: string): ThreadClientError =>\n ThreadClientError.make({\n threadId,\n message: boundHostDiagnostic(\n `The Thread Object answered ${operation} with the out-of-contract ${observed}.`,\n ),\n });\n\nconst hostRpcMethods = {\n submit: \"submitEncoded\",\n awaitSettlement: \"awaitSettlementEncoded\",\n submissionStatus: \"submissionStatusEncoded\",\n awaitProgress: \"awaitProgressEncoded\",\n cancelProgress: \"cancelProgressEncoded\",\n observePage: \"observePage\",\n abort: \"abortEncoded\",\n resolveApproval: \"resolveApprovalEncoded\",\n resolveUnknown: \"resolveUnknownEncoded\",\n} as const satisfies Record<string, keyof ThreadObjectRpc>;\n\n/** Worker-side client over the Thread Object namespace (DEPLOY-010). */\nexport class CloudflareThreadClient extends Context.Service<\n CloudflareThreadClient,\n {\n /** Encode the input client-side, then durably submit to the owning Object. */\n readonly submit: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ) => Effect.Effect<Receipt, ClientSubmitFailure, InputSchema[\"EncodingServices\"]>;\n /** Wake-hinted, poll-guaranteed settlement wait executed inside the owning Object. */\n readonly submissionStatus: (\n receipt: Receipt,\n ) => Effect.Effect<SubmissionStatus, ClientAwaitFailure>;\n readonly awaitSettlement: (receipt: Receipt) => Effect.Effect<Settlement, ClientAwaitFailure>;\n /**\n * Wait without polling until progress after `afterSequence` is already durable or hinted.\n * The result is deliberately void: canonical records remain authoritative and must be read.\n * Interruption waits at most one second for best-effort remote cancellation.\n */\n readonly awaitProgress: (\n threadId: ThreadId,\n afterSequence: CanonicalSequence,\n ) => Effect.Effect<void, ClientProgressFailure>;\n /** One bounded page of canonical records. */\n readonly readPage: (\n threadId: ThreadId,\n options?: {\n readonly afterSequence?: CanonicalSequence | undefined;\n readonly limit?: number | undefined;\n },\n ) => Effect.Effect<ReadonlyArray<CanonicalRecordEnvelope>, ClientObserveFailure>;\n /**\n * Every canonical record up to the CURRENT committed tail, via repeated pages. A\n * snapshot read, not a live observation — callers wanting liveness re-read after\n * `awaitSettlement`.\n */\n readonly readAll: (\n threadId: ThreadId,\n ) => Effect.Effect<ReadonlyArray<CanonicalRecordEnvelope>, ClientObserveFailure>;\n /**\n * Submission-addressed operations take the owning Thread explicitly (from the\n * Receipt): minted Submission identities stay OPAQUE outside the storage adapter that\n * minted them (D-P6-5), so the client never parses one to find the lane.\n */\n readonly abort: (\n threadId: ThreadId,\n command: AbortCommand,\n ) => Effect.Effect<AbortIntent, ClientAbortFailure>;\n readonly resolveApproval: (\n threadId: ThreadId,\n command: ApprovalDecisionCommand,\n ) => Effect.Effect<ApprovalDecisionIntent, ClientApprovalFailure>;\n readonly resolveUnknown: (\n threadId: ThreadId,\n command: UnknownResolutionCommand,\n ) => Effect.Effect<UnknownResolutionIntent, ClientUnknownFailure>;\n }\n>()(\"@effect-agent/platform-cloudflare/CloudflareThreadClient\") {\n /**\n * Assemble the client from a resolved namespace and the platform Crypto implementation.\n * rpcTracing is the binding name and remains opt-in. Caller authentication, principals,\n * idempotency keys, and definition digests are still explicit submission inputs.\n */\n static layerFromBinding(options: {\n readonly namespace: DurableObjectNamespace<ThreadObjectRpc>;\n readonly rpcTracing?: string;\n }): Layer.Layer<CloudflareThreadClient> {\n return CloudflareThreadClient.layer.pipe(\n Layer.provide([ThreadObjectNamespace.layer(options.namespace, options), BrowserCrypto.layer]),\n );\n }\n\n static readonly layer: Layer.Layer<\n CloudflareThreadClient,\n never,\n ThreadObjectNamespace | Crypto.Crypto\n > = Layer.effect(CloudflareThreadClient)(\n Effect.gen(function* () {\n const namespace = yield* ThreadObjectNamespace;\n const { rpcTracing } = namespace;\n const crypto = yield* Crypto.Crypto;\n\n const call = Effect.fn(\n function* (\n threadId: ThreadId,\n operation: keyof typeof hostRpcMethods,\n encoded: unknown,\n ): Effect.fn.Return<HostResponse, ThreadClientError | HostProtocolError> {\n // Empty arguments preserve native arity. Passing `undefined` still adds an argument.\n const traceArgs =\n rpcTracing === undefined ? [] : yield* RpcTracing.withRpcTraceContext([]);\n\n const raw = yield* callThreadObject(\n threadId,\n (stub) => stub[hostRpcMethods[operation]](encoded, ...traceArgs),\n (cause) =>\n ThreadClientError.make({\n threadId,\n message: boundHostDiagnostic(\n `${operation} did not reach the Thread Object: ${safeCauseMessage(\n cause,\n \"the RPC failed without a diagnostic\",\n )}`,\n ),\n cause,\n ...cloudflareFailureSignals(cause),\n }),\n ).pipe(Effect.provideService(ThreadObjectNamespace, namespace));\n\n return yield* decodeHostResponse(raw).pipe(\n Effect.mapError((error): HostProtocolError =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `The ${operation} answer could not be decoded: ${error.message}`,\n ),\n }),\n ),\n );\n },\n (effect, threadId, operation) =>\n rpcTracing === undefined\n ? Effect.withSpan(effect, \"CloudflareThreadClient.call\", {\n attributes: { threadId, operation },\n })\n : RpcTracing.withRpcClientSpan(effect, rpcTracing, hostRpcMethods[operation]),\n );\n\n const expect = <ResultSchema extends Schema.Top, FailureSchema extends Schema.Top>(\n threadId: string,\n operation: string,\n resultSchema: ResultSchema,\n failureSchema: FailureSchema,\n ) => {\n const isExpectedResult = Schema.is(resultSchema);\n const isExpectedFailure = Schema.is(failureSchema);\n\n return (\n response: HostResponse,\n ): Effect.Effect<ResultSchema[\"Type\"], FailureSchema[\"Type\"] | ThreadClientError> => {\n if (response._tag === \"HostFailed\") {\n const failure = response.failure;\n\n return isExpectedFailure(failure)\n ? Effect.fail(failure)\n : Effect.fail(outOfContract(threadId, operation, `failure ${failure._tag}`));\n }\n if (!isExpectedResult(response)) {\n return Effect.fail(outOfContract(threadId, operation, `result ${response._tag}`));\n }\n\n return Effect.succeed(response);\n };\n };\n\n const readPage = (\n threadId: ThreadId,\n options?: {\n readonly afterSequence?: CanonicalSequence | undefined;\n readonly limit?: number | undefined;\n },\n ) =>\n Effect.gen(function* () {\n const request = ObservePageRequest.make({\n ...(options?.afterSequence === undefined\n ? {}\n : { afterSequence: options.afterSequence }),\n limit: options?.limit ?? 256,\n });\n\n const encoded = yield* encodeObservePageRequest(request).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`observePage request encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"observePage\", encoded);\n\n const page = yield* expect(\n threadId,\n \"observePage\",\n ObservedPage,\n ClientObserveHostFailure,\n )(response);\n\n return page.records;\n });\n\n const cancelProgress = (threadId: ThreadId, waiterId: string): Effect.Effect<void> =>\n encodeCancelProgressRequest(CancelProgressRequest.make({ waiterId })).pipe(\n Effect.mapError(() => undefined),\n Effect.flatMap((encoded) => call(threadId, \"cancelProgress\", encoded)),\n // Finalizers are uninterruptible; only the foreign RPC branch must remain\n // interruptible so a lost cancellation reply cannot prevent local shutdown.\n Effect.interruptible,\n Effect.timeout(PROGRESS_CANCELLATION_TIMEOUT),\n Effect.asVoid,\n Effect.ignore,\n );\n\n return CloudflareThreadClient.of({\n submit: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ) =>\n Effect.gen(function* () {\n // Client-side half of `DurableAgentRuntime.submit`'s input boundary: encode\n // through the Agent's input schema and prove the canonical persistence bounds.\n const encodedInput = yield* Schema.encodeEffect(agent.definition.input)(input).pipe(\n Effect.mapError((cause) =>\n AgentInputError.make({ message: `Unable to encode Agent input: ${cause.message}` }),\n ),\n );\n\n const inputPayload = yield* Schema.decodeUnknownEffect(PersistedJson)(\n encodedInput,\n ).pipe(\n Effect.mapError(() =>\n AgentInputError.make({\n message: \"Agent input does not satisfy the canonical persistence bounds\",\n }),\n ),\n );\n\n const request = SubmitRequest.make({\n agentId: agent.definition.id,\n principal: options.principal,\n idempotencyKey: options.idempotencyKey,\n ...(options.admissionGroup === undefined\n ? {}\n : { admissionGroup: options.admissionGroup }),\n ...(options.admissionFence === undefined\n ? {}\n : { admissionFence: options.admissionFence }),\n ...(options.workerAdmission === undefined\n ? {}\n : { workerAdmission: options.workerAdmission }),\n ...(options.messageAdmission === undefined\n ? {}\n : { messageAdmission: options.messageAdmission }),\n definitions: options.definitions,\n inputPayload,\n });\n\n const encoded = yield* encodeSubmitRequest(request).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`submit request encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(options.threadId, \"submit\", encoded);\n\n const succeeded = yield* expect(\n options.threadId,\n \"submit\",\n SubmitSucceeded,\n ClientSubmitHostFailure,\n )(response);\n\n return succeeded.receipt;\n }),\n\n submissionStatus: (receipt) =>\n Effect.gen(function* () {\n const encoded = yield* encodeReceipt(receipt).pipe(\n Effect.mapError(() => HostProtocolError.make({ message: \"Invalid receipt\" })),\n );\n\n const response = yield* call(receipt.threadId, \"submissionStatus\", encoded);\n\n const result = yield* expect(\n receipt.threadId,\n \"submissionStatus\",\n SubmissionStatusResponse,\n ClientAwaitHostFailure,\n )(response);\n\n return result.status;\n }),\n awaitSettlement: (receipt) =>\n Effect.gen(function* () {\n const encoded = yield* encodeReceipt(receipt).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`receipt encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(receipt.threadId, \"awaitSettlement\", encoded);\n\n const settled = yield* expect(\n receipt.threadId,\n \"awaitSettlement\",\n SettlementReached,\n ClientAwaitHostFailure,\n )(response);\n\n return settled.settlement;\n }),\n\n awaitProgress: (threadId, afterSequence) =>\n Effect.gen(function* () {\n const waiterId = yield* crypto.randomUUIDv4.pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `awaitProgress cancellation identity generation failed: ${error.message}`,\n ),\n }),\n ),\n );\n\n const request = AwaitProgressRequest.make({ afterSequence, waiterId });\n\n const encoded = yield* encodeAwaitProgressRequest(request).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `awaitProgress request encode failed: ${error.message}`,\n ),\n }),\n ),\n );\n\n const attempt = (retry: number): Effect.Effect<void, ClientProgressFailure> =>\n call(threadId, \"awaitProgress\", encoded).pipe(\n Effect.flatMap(\n expect(threadId, \"awaitProgress\", ProgressObserved, ClientObserveHostFailure),\n ),\n Effect.asVoid,\n Effect.catchTag(\"ThreadClientError\", (error) =>\n error.retryable === true && error.overloaded !== true && retry < 5\n ? Effect.sleep(Duration.millis(10 * 2 ** retry)).pipe(\n Effect.andThen(attempt(retry + 1)),\n )\n : Effect.fail(error),\n ),\n );\n\n yield* attempt(0).pipe(Effect.onInterrupt(() => cancelProgress(threadId, waiterId)));\n }),\n\n readPage,\n\n readAll: (threadId) =>\n Effect.gen(function* () {\n const all: Array<CanonicalRecordEnvelope> = [];\n let after: CanonicalSequence | undefined;\n\n for (;;) {\n const page = yield* readPage(threadId, { afterSequence: after, limit: 1_024 });\n\n all.push(...page);\n const last = page.at(-1);\n\n if (page.length < 1_024 || last === undefined) return all;\n after = last.sequence;\n }\n }),\n\n abort: (threadId, command) =>\n Effect.gen(function* () {\n const encoded = yield* encodeAbortCommand(command).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`abort command encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"abort\", encoded);\n\n const recorded = yield* expect(\n threadId,\n \"abort\",\n AbortRecorded,\n ClientAbortHostFailure,\n )(response);\n\n return recorded.intent;\n }),\n\n resolveApproval: (threadId, command) =>\n Effect.gen(function* () {\n const encoded = yield* encodeApprovalDecisionCommand(command).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`approval command encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"resolveApproval\", encoded);\n\n const recorded = yield* expect(\n threadId,\n \"resolveApproval\",\n ApprovalRecorded,\n ClientApprovalHostFailure,\n )(response);\n\n return recorded.intent;\n }),\n\n resolveUnknown: (threadId, command) =>\n Effect.gen(function* () {\n const encoded = yield* encodeUnknownResolutionCommand(command).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `resolution command encode failed: ${error.message}`,\n ),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"resolveUnknown\", encoded);\n\n const recorded = yield* expect(\n threadId,\n \"resolveUnknown\",\n UnknownResolutionRecorded,\n ClientUnknownHostFailure,\n )(response);\n\n return recorded.intent;\n }),\n });\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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kB,UAAU,YAC1B,OAAO,IAAI,aAAa;IACtB,MAAM,UAAU,OAAO,8BAA8B,OAAO,CAAC,CAAC,KAC5D,OAAO,UAAU,UACf,kBAAkB,KAAK,EACrB,SAAS,oBAAoB,mCAAmC,MAAM,SAAS,EACjF,CAAC,CACH,CACF;IAEA,MAAM,WAAW,OAAO,KAAK,UAAU,mBAAmB,OAAO;IASjE,QAAO,OAPiB,OACtB,UACA,mBACA,kBACA,yBACF,CAAC,CAAC,QAAQ,EAAA,CAEM;GAClB,CAAC;GAEH,iBAAiB,UAAU,YACzB,OAAO,IAAI,aAAa;IACtB,MAAM,UAAU,OAAO,+BAA+B,OAAO,CAAC,CAAC,KAC7D,OAAO,UAAU,UACf,kBAAkB,KAAK,EACrB,SAAS,oBACP,qCAAqC,MAAM,SAC7C,EACF,CAAC,CACH,CACF;IAEA,MAAM,WAAW,OAAO,KAAK,UAAU,kBAAkB,OAAO;IAShE,QAAO,OAPiB,OACtB,UACA,kBACA,2BACA,wBACF,CAAC,CAAC,QAAQ,EAAA,CAEM;GAClB,CAAC;EACL,CAAC;CACH,CAAC,CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"CloudflareThreadClient.mjs","names":[],"sources":["../src/CloudflareThreadClient.ts"],"sourcesContent":["import { BrowserCrypto } from \"@effect/platform-browser\";\nimport { Context, Crypto, Duration, Effect, Layer, Schema } from \"effect\";\nimport { AgentInputError } from \"effect-agent/agent-error\";\nimport { DigestError } from \"effect-agent/digest\";\nimport {\n Receipt,\n type DurableSubmitAgent,\n type DurableSubmitOptions,\n} from \"effect-agent/durable-agent-runtime\";\nimport { DurableRuntimeFailpointError } from \"effect-agent/durable-failpoint\";\nimport { AgentId, type ThreadId } from \"effect-agent/identifiers\";\nimport { InputMessage } from \"effect-agent/messaging\";\nimport { OperationDenied } from \"effect-agent/operation-authorizer\";\nimport {\n CanonicalRecordEnvelope,\n CanonicalSequence,\n DefinitionDigests,\n PersistedJson,\n WorkerAdmission,\n} from \"effect-agent/records\";\nimport {\n AdmissionFence,\n AdmissionGroup,\n AbortCommand,\n AbortIntent,\n AdmissionConflict,\n AdmissionPolicyError,\n ApprovalConflict,\n ApprovalDecisionCommand,\n ApprovalDecisionIntent,\n IdempotencyKey,\n JoinedToHost,\n LedgerError,\n Principal,\n Settlement,\n SettlementConflict,\n UnknownResolutionCommand,\n UnknownResolutionConflict,\n UnknownResolutionIntent,\n} from \"effect-agent/submission-ledger\";\nimport { SubmissionStatus } from \"effect-agent/submission-status\";\nimport {\n AppendConflict,\n ThreadNotMaterialized,\n ThreadStoreError,\n FenceRejected,\n} from \"effect-agent/thread-store\";\nimport { RpcTracing } from \"effect-cf\";\n\nimport { DurableAlarmError } from \"./Alarm.ts\";\nimport {\n callThreadObject,\n ThreadObjectNamespace,\n type ThreadObjectRpc,\n} from \"./CloudflareBindings.ts\";\nimport { AdmissionLimitExceeded } from \"./CloudflareConfig.ts\";\nimport { cloudflareFailureSignals, safeCauseMessage } from \"./internal/boundary.ts\";\n\n/**\n * The Worker↔Thread-Object host protocol (plan §1.4): Schema envelopes for the host\n * entry points (`submitEncoded`, `awaitSettlementEncoded`, `observePage`, `abortEncoded`,\n * `resolveApprovalEncoded`, `resolveUnknownEncoded`) plus the Worker-side client that speaks\n * it. Mirrors the WP2 port protocol: requests and responses are closed Schema unions, typed\n * failures travel as their own tagged classes and RE-DECODE to identical tags on the caller\n * (error-tag fidelity), and protocol anomalies are answered typed instead of thrown.\n */\n\n/** Ceiling for host protocol diagnostic strings. */\nconst MAX_HOST_DIAGNOSTIC_LENGTH = 4_096;\nconst PROGRESS_CANCELLATION_TIMEOUT = \"1 second\";\n\nconst BoundedDiagnostic = Schema.String.check(Schema.isMaxLength(MAX_HOST_DIAGNOSTIC_LENGTH));\n\n/** Truncate a diagnostic string to the host protocol's bounded length. */\nexport const boundHostDiagnostic = (value: string): string =>\n value.length > MAX_HOST_DIAGNOSTIC_LENGTH\n ? `${value.slice(0, MAX_HOST_DIAGNOSTIC_LENGTH - 3)}...`\n : value;\n\n/**\n * The envelope itself could not be honored: the Object could not decode the request, or a\n * response could not be encoded/decoded. Never carries operation semantics.\n */\nexport class HostProtocolError extends Schema.TaggedError<HostProtocolError>()(\n \"HostProtocolError\",\n {\n message: BoundedDiagnostic,\n },\n) {}\n\n/** The Worker-side stub call itself failed (RPC rejection, overload, eviction mid-call). */\nexport class ThreadClientError extends Schema.TaggedError<ThreadClientError>()(\n \"ThreadClientError\",\n {\n threadId: Schema.String,\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n /** Cloudflare's own classification for a failure safe to retry with a fresh stub. */\n retryable: Schema.optionalKey(Schema.Boolean),\n /** Cloudflare overloads are surfaced immediately instead of adding retry pressure. */\n overloaded: Schema.optionalKey(Schema.Boolean),\n },\n) {}\n\n// ---------------------------------------------------------------------------\n// Requests\n// ---------------------------------------------------------------------------\n\n/**\n * One durable submission, input ALREADY encoded by the caller through the Agent Binding's\n * input schema (the Worker bundles the same Agent definitions as the Object, so schema\n * validation happens client-side; the resolved Binding re-validates at claim time). The\n * Thread identity is deliberately absent — the addressed Object IS the lane.\n */\nexport class SubmitRequest extends Schema.Class<SubmitRequest>(\n \"@effect-agent/platform-cloudflare/SubmitRequest\",\n)({\n agentId: AgentId,\n principal: Principal,\n idempotencyKey: IdempotencyKey,\n admissionGroup: Schema.optionalKey(AdmissionGroup),\n admissionFence: Schema.optionalKey(AdmissionFence),\n workerAdmission: Schema.optionalKey(WorkerAdmission),\n messageAdmission: Schema.optionalKey(InputMessage),\n definitions: DefinitionDigests,\n inputPayload: PersistedJson,\n}) {}\n\n/** One bounded page of canonical records after an optional sequence. */\nexport class ObservePageRequest extends Schema.Class<ObservePageRequest>(\n \"@effect-agent/platform-cloudflare/ObservePageRequest\",\n)({\n afterSequence: Schema.optionalKey(CanonicalSequence),\n limit: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(1_024)),\n}) {}\n\n/** One event-driven wait for canonical progress strictly after this sequence. */\nexport class AwaitProgressRequest extends Schema.Class<AwaitProgressRequest>(\n \"@effect-agent/platform-cloudflare/AwaitProgressRequest\",\n)({\n afterSequence: CanonicalSequence,\n waiterId: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256)),\n}) {}\n\n/** Best-effort cancellation of one in-flight progress RPC. */\nexport class CancelProgressRequest extends Schema.Class<CancelProgressRequest>(\n \"@effect-agent/platform-cloudflare/CancelProgressRequest\",\n)({\n waiterId: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256)),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Responses\n// ---------------------------------------------------------------------------\n\n/**\n * Every typed failure a host entry point can produce, plus the protocol's own errors. Same\n * closed-union discipline as the WP2 `PortFailure`: members re-decode to the SAME tagged\n * classes on the Worker side; `cause` chains travel as Schema defects without instance\n * fidelity (plan §2.8).\n */\nexport const HostFailure = Schema.Union([\n AgentInputError,\n DigestError,\n AdmissionConflict,\n AdmissionPolicyError,\n SettlementConflict,\n ApprovalConflict,\n UnknownResolutionConflict,\n JoinedToHost,\n LedgerError,\n ThreadStoreError,\n ThreadNotMaterialized,\n AppendConflict,\n FenceRejected,\n DurableRuntimeFailpointError,\n AdmissionLimitExceeded,\n DurableAlarmError,\n OperationDenied,\n HostProtocolError,\n]);\n\nexport type HostFailure = typeof HostFailure.Type;\n\nexport class SubmitSucceeded extends Schema.TaggedClass<SubmitSucceeded>(\n \"@effect-agent/platform-cloudflare/SubmitSucceeded\",\n)(\"SubmitSucceeded\", {\n receipt: Receipt,\n}) {}\n\nexport class SubmissionStatusResponse extends Schema.TaggedClass<SubmissionStatusResponse>(\n \"@effect-agent/platform-cloudflare/SubmissionStatusResponse\",\n)(\"SubmissionStatusResponse\", { status: SubmissionStatus }) {}\n\nexport class SettlementReached extends Schema.TaggedClass<SettlementReached>(\n \"@effect-agent/platform-cloudflare/SettlementReached\",\n)(\"SettlementReached\", {\n settlement: Settlement,\n}) {}\n\nexport class ObservedPage extends Schema.TaggedClass<ObservedPage>(\n \"@effect-agent/platform-cloudflare/ObservedPage\",\n)(\"ObservedPage\", {\n records: Schema.Array(CanonicalRecordEnvelope).check(Schema.isMaxLength(1_024)),\n}) {}\n\n/** A record was already committed or an incarnation-local hint says the caller should re-read. */\nexport class ProgressObserved extends Schema.TaggedClass<ProgressObserved>(\n \"@effect-agent/platform-cloudflare/ProgressObserved\",\n)(\"ProgressObserved\", {}) {}\n\nexport class ProgressCancelled extends Schema.TaggedClass<ProgressCancelled>(\n \"@effect-agent/platform-cloudflare/ProgressCancelled\",\n)(\"ProgressCancelled\", {}) {}\n\nexport class AbortRecorded extends Schema.TaggedClass<AbortRecorded>(\n \"@effect-agent/platform-cloudflare/AbortRecorded\",\n)(\"AbortRecorded\", {\n intent: AbortIntent,\n}) {}\n\nexport class ApprovalRecorded extends Schema.TaggedClass<ApprovalRecorded>(\n \"@effect-agent/platform-cloudflare/ApprovalRecorded\",\n)(\"ApprovalRecorded\", {\n intent: ApprovalDecisionIntent,\n}) {}\n\nexport class UnknownResolutionRecorded extends Schema.TaggedClass<UnknownResolutionRecorded>(\n \"@effect-agent/platform-cloudflare/UnknownResolutionRecorded\",\n)(\"UnknownResolutionRecorded\", {\n intent: UnknownResolutionIntent,\n}) {}\n\n/** The entry point failed TYPED on the Object; the failure re-decodes verbatim. */\nexport class HostFailed extends Schema.TaggedClass<HostFailed>(\n \"@effect-agent/platform-cloudflare/HostFailed\",\n)(\"HostFailed\", {\n failure: HostFailure,\n}) {}\n\n/** The uniform answer of one host entry point. Callers narrow by the tag their call implies. */\nexport const HostResponse = Schema.Union([\n SubmitSucceeded,\n SettlementReached,\n SubmissionStatusResponse,\n ObservedPage,\n ProgressObserved,\n ProgressCancelled,\n AbortRecorded,\n ApprovalRecorded,\n UnknownResolutionRecorded,\n HostFailed,\n]);\n\nexport type HostResponse = typeof HostResponse.Type;\n\n// ---------------------------------------------------------------------------\n// Codecs (shared by the Object endpoints and the Worker client)\n// ---------------------------------------------------------------------------\n\nexport const decodeSubmitRequest = Schema.decodeUnknownEffect(SubmitRequest);\nexport const encodeSubmitRequest = Schema.encodeEffect(SubmitRequest);\nexport const decodeReceipt = Schema.decodeUnknownEffect(Receipt);\nexport const encodeReceipt = Schema.encodeEffect(Receipt);\nexport const decodeObservePageRequest = Schema.decodeUnknownEffect(ObservePageRequest);\nexport const encodeObservePageRequest = Schema.encodeEffect(ObservePageRequest);\nexport const decodeAwaitProgressRequest = Schema.decodeUnknownEffect(AwaitProgressRequest);\nexport const encodeAwaitProgressRequest = Schema.encodeEffect(AwaitProgressRequest);\nexport const decodeCancelProgressRequest = Schema.decodeUnknownEffect(CancelProgressRequest);\nexport const encodeCancelProgressRequest = Schema.encodeEffect(CancelProgressRequest);\nexport const decodeAbortCommand = Schema.decodeUnknownEffect(AbortCommand);\nexport const encodeAbortCommand = Schema.encodeEffect(AbortCommand);\nexport const decodeApprovalDecisionCommand = Schema.decodeUnknownEffect(ApprovalDecisionCommand);\nexport const encodeApprovalDecisionCommand = Schema.encodeEffect(ApprovalDecisionCommand);\nexport const decodeUnknownResolutionCommand = Schema.decodeUnknownEffect(UnknownResolutionCommand);\nexport const encodeUnknownResolutionCommand = Schema.encodeEffect(UnknownResolutionCommand);\nexport const encodeHostResponse = Schema.encodeEffect(HostResponse);\nexport const decodeHostResponse = Schema.decodeUnknownEffect(HostResponse);\n\n// ---------------------------------------------------------------------------\n// Worker-side client\n// ---------------------------------------------------------------------------\n\n/** Failure surface of `CloudflareThreadClient.submit`. */\nconst ClientSubmitHostFailure = Schema.Union([\n AgentInputError,\n DigestError,\n AdmissionConflict,\n AdmissionPolicyError,\n LedgerError,\n ThreadStoreError,\n ThreadNotMaterialized,\n AppendConflict,\n FenceRejected,\n DurableRuntimeFailpointError,\n AdmissionLimitExceeded,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nconst ClientAwaitHostFailure = Schema.Union([\n LedgerError,\n SettlementConflict,\n OperationDenied,\n HostProtocolError,\n]);\n\nconst ClientObserveHostFailure = Schema.Union([\n ThreadStoreError,\n ThreadNotMaterialized,\n OperationDenied,\n HostProtocolError,\n]);\n\nconst ClientAbortHostFailure = Schema.Union([\n OperationDenied,\n LedgerError,\n SettlementConflict,\n JoinedToHost,\n DurableRuntimeFailpointError,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nconst ClientApprovalHostFailure = Schema.Union([\n LedgerError,\n SettlementConflict,\n ApprovalConflict,\n OperationDenied,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nconst ClientUnknownHostFailure = Schema.Union([\n LedgerError,\n SettlementConflict,\n UnknownResolutionConflict,\n JoinedToHost,\n DurableRuntimeFailpointError,\n OperationDenied,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nexport type ClientSubmitFailure = typeof ClientSubmitHostFailure.Type | ThreadClientError;\nexport type ClientAwaitFailure = typeof ClientAwaitHostFailure.Type | ThreadClientError;\nexport type ClientObserveFailure = typeof ClientObserveHostFailure.Type | ThreadClientError;\nexport type ClientProgressFailure = ClientObserveFailure;\nexport type ClientAbortFailure = typeof ClientAbortHostFailure.Type | ThreadClientError;\nexport type ClientApprovalFailure = typeof ClientApprovalHostFailure.Type | ThreadClientError;\nexport type ClientUnknownFailure = typeof ClientUnknownHostFailure.Type | ThreadClientError;\n\nconst outOfContract = (threadId: string, operation: string, observed: string): ThreadClientError =>\n ThreadClientError.make({\n threadId,\n message: boundHostDiagnostic(\n `The Thread Object answered ${operation} with the out-of-contract ${observed}.`,\n ),\n });\n\nconst hostRpcMethods = {\n submit: \"submitEncoded\",\n awaitSettlement: \"awaitSettlementEncoded\",\n submissionStatus: \"submissionStatusEncoded\",\n awaitProgress: \"awaitProgressEncoded\",\n cancelProgress: \"cancelProgressEncoded\",\n observePage: \"observePage\",\n abort: \"abortEncoded\",\n resolveApproval: \"resolveApprovalEncoded\",\n resolveUnknown: \"resolveUnknownEncoded\",\n} as const satisfies Record<string, keyof ThreadObjectRpc>;\n\n/** Worker-side client over the Thread Object namespace (DEPLOY-010). */\nexport class CloudflareThreadClient extends Context.Service<\n CloudflareThreadClient,\n {\n /** Encode the input client-side, then durably submit to the owning Object. */\n readonly submit: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ) => Effect.Effect<Receipt, ClientSubmitFailure, InputSchema[\"EncodingServices\"]>;\n /** Wake-hinted, poll-guaranteed settlement wait executed inside the owning Object. */\n readonly submissionStatus: (\n receipt: Receipt,\n ) => Effect.Effect<SubmissionStatus, ClientAwaitFailure>;\n readonly awaitSettlement: (receipt: Receipt) => Effect.Effect<Settlement, ClientAwaitFailure>;\n /**\n * Wait without polling until progress after `afterSequence` is already durable or hinted.\n * The result is deliberately void: canonical records remain authoritative and must be read.\n * Interruption waits at most one second for best-effort remote cancellation.\n */\n readonly awaitProgress: (\n threadId: ThreadId,\n afterSequence: CanonicalSequence,\n ) => Effect.Effect<void, ClientProgressFailure>;\n /** One bounded page of canonical records. */\n readonly readPage: (\n threadId: ThreadId,\n options?: {\n readonly afterSequence?: CanonicalSequence | undefined;\n readonly limit?: number | undefined;\n },\n ) => Effect.Effect<ReadonlyArray<CanonicalRecordEnvelope>, ClientObserveFailure>;\n /**\n * Every canonical record up to the CURRENT committed tail, via repeated pages. A\n * snapshot read, not a live observation — callers wanting liveness re-read after\n * `awaitSettlement`.\n */\n readonly readAll: (\n threadId: ThreadId,\n ) => Effect.Effect<ReadonlyArray<CanonicalRecordEnvelope>, ClientObserveFailure>;\n /**\n * Submission-addressed operations take the owning Thread explicitly (from the\n * Receipt): minted Submission identities stay OPAQUE outside the storage adapter that\n * minted them (D-P6-5), so the client never parses one to find the lane.\n */\n readonly abort: (\n threadId: ThreadId,\n command: AbortCommand,\n ) => Effect.Effect<AbortIntent, ClientAbortFailure>;\n readonly resolveApproval: (\n threadId: ThreadId,\n command: ApprovalDecisionCommand,\n ) => Effect.Effect<ApprovalDecisionIntent, ClientApprovalFailure>;\n readonly resolveUnknown: (\n threadId: ThreadId,\n command: UnknownResolutionCommand,\n ) => Effect.Effect<UnknownResolutionIntent, ClientUnknownFailure>;\n }\n>()(\"@effect-agent/platform-cloudflare/CloudflareThreadClient\") {\n /**\n * Assemble the client from a resolved namespace and the platform Crypto implementation.\n * rpcTracing is the binding name and remains opt-in. Caller authentication, principals,\n * idempotency keys, and definition digests are still explicit submission inputs.\n */\n static layerFromBinding(options: {\n readonly namespace: DurableObjectNamespace<ThreadObjectRpc>;\n readonly rpcTracing?: string;\n }): Layer.Layer<CloudflareThreadClient> {\n return CloudflareThreadClient.layer.pipe(\n Layer.provide([ThreadObjectNamespace.layer(options.namespace, options), BrowserCrypto.layer]),\n );\n }\n\n static readonly layer: Layer.Layer<\n CloudflareThreadClient,\n never,\n ThreadObjectNamespace | Crypto.Crypto\n > = Layer.effect(CloudflareThreadClient)(\n Effect.gen(function* () {\n const namespace = yield* ThreadObjectNamespace;\n const { rpcTracing } = namespace;\n const crypto = yield* Crypto.Crypto;\n\n const call = Effect.fn(\n function* (\n threadId: ThreadId,\n operation: keyof typeof hostRpcMethods,\n encoded: unknown,\n ): Effect.fn.Return<HostResponse, ThreadClientError | HostProtocolError> {\n // Empty arguments preserve native arity. Passing `undefined` still adds an argument.\n const traceArgs =\n rpcTracing === undefined ? [] : yield* RpcTracing.withRpcTraceContext([]);\n\n const raw = yield* callThreadObject(\n threadId,\n (stub) => stub[hostRpcMethods[operation]](encoded, ...traceArgs),\n (cause) =>\n ThreadClientError.make({\n threadId,\n message: boundHostDiagnostic(\n `${operation} did not reach the Thread Object: ${safeCauseMessage(\n cause,\n \"the RPC failed without a diagnostic\",\n )}`,\n ),\n cause,\n ...cloudflareFailureSignals(cause),\n }),\n ).pipe(Effect.provideService(ThreadObjectNamespace, namespace));\n\n return yield* decodeHostResponse(raw).pipe(\n Effect.mapError((error): HostProtocolError =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `The ${operation} answer could not be decoded: ${error.message}`,\n ),\n }),\n ),\n );\n },\n (effect, threadId, operation) =>\n rpcTracing === undefined\n ? Effect.withSpan(effect, \"CloudflareThreadClient.call\", {\n attributes: { threadId, operation },\n })\n : RpcTracing.withRpcClientSpan(effect, rpcTracing, hostRpcMethods[operation]),\n );\n\n const expect = <ResultSchema extends Schema.Top, FailureSchema extends Schema.Top>(\n threadId: string,\n operation: string,\n resultSchema: ResultSchema,\n failureSchema: FailureSchema,\n ) => {\n const isExpectedResult = Schema.is(resultSchema);\n const isExpectedFailure = Schema.is(failureSchema);\n\n return (\n response: HostResponse,\n ): Effect.Effect<ResultSchema[\"Type\"], FailureSchema[\"Type\"] | ThreadClientError> => {\n if (response._tag === \"HostFailed\") {\n const failure = response.failure;\n\n return isExpectedFailure(failure)\n ? Effect.fail(failure)\n : Effect.fail(outOfContract(threadId, operation, `failure ${failure._tag}`));\n }\n if (!isExpectedResult(response)) {\n return Effect.fail(outOfContract(threadId, operation, `result ${response._tag}`));\n }\n\n return Effect.succeed(response);\n };\n };\n\n const readPage = (\n threadId: ThreadId,\n options?: {\n readonly afterSequence?: CanonicalSequence | undefined;\n readonly limit?: number | undefined;\n },\n ) =>\n Effect.gen(function* () {\n const request = ObservePageRequest.make({\n ...(options?.afterSequence === undefined\n ? {}\n : { afterSequence: options.afterSequence }),\n limit: options?.limit ?? 256,\n });\n\n const encoded = yield* encodeObservePageRequest(request).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`observePage request encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"observePage\", encoded);\n\n const page = yield* expect(\n threadId,\n \"observePage\",\n ObservedPage,\n ClientObserveHostFailure,\n )(response);\n\n return page.records;\n });\n\n const cancelProgress = (threadId: ThreadId, waiterId: string): Effect.Effect<void> =>\n encodeCancelProgressRequest(CancelProgressRequest.make({ waiterId })).pipe(\n Effect.mapError(() => undefined),\n Effect.flatMap((encoded) => call(threadId, \"cancelProgress\", encoded)),\n // Finalizers are uninterruptible; only the foreign RPC branch must remain\n // interruptible so a lost cancellation reply cannot prevent local shutdown.\n Effect.interruptible,\n Effect.timeout(PROGRESS_CANCELLATION_TIMEOUT),\n Effect.asVoid,\n Effect.ignore,\n );\n\n return CloudflareThreadClient.of({\n submit: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ) =>\n Effect.gen(function* () {\n // Client-side half of `DurableAgentRuntime.submit`'s input boundary: encode\n // through the Agent's input schema and prove the canonical persistence bounds.\n const encodedInput = yield* Schema.encodeEffect(agent.definition.input)(input).pipe(\n Effect.mapError((cause) =>\n AgentInputError.make({ message: `Unable to encode Agent input: ${cause.message}` }),\n ),\n );\n\n const inputPayload = yield* Schema.decodeUnknownEffect(PersistedJson)(\n encodedInput,\n ).pipe(\n Effect.mapError(() =>\n AgentInputError.make({\n message: \"Agent input does not satisfy the canonical persistence bounds\",\n }),\n ),\n );\n\n const request = SubmitRequest.make({\n agentId: agent.definition.id,\n principal: options.principal,\n idempotencyKey: options.idempotencyKey,\n ...(options.admissionGroup === undefined\n ? {}\n : { admissionGroup: options.admissionGroup }),\n ...(options.admissionFence === undefined\n ? {}\n : { admissionFence: options.admissionFence }),\n ...(options.workerAdmission === undefined\n ? {}\n : { workerAdmission: options.workerAdmission }),\n ...(options.messageAdmission === undefined\n ? {}\n : { messageAdmission: options.messageAdmission }),\n definitions: options.definitions,\n inputPayload,\n });\n\n const encoded = yield* encodeSubmitRequest(request).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`submit request encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(options.threadId, \"submit\", encoded);\n\n const succeeded = yield* expect(\n options.threadId,\n \"submit\",\n SubmitSucceeded,\n ClientSubmitHostFailure,\n )(response);\n\n return succeeded.receipt;\n }),\n\n submissionStatus: (receipt) =>\n Effect.gen(function* () {\n const encoded = yield* encodeReceipt(receipt).pipe(\n Effect.mapError(() => HostProtocolError.make({ message: \"Invalid receipt\" })),\n );\n\n const response = yield* call(receipt.threadId, \"submissionStatus\", encoded);\n\n const result = yield* expect(\n receipt.threadId,\n \"submissionStatus\",\n SubmissionStatusResponse,\n ClientAwaitHostFailure,\n )(response);\n\n return result.status;\n }),\n awaitSettlement: (receipt) =>\n Effect.gen(function* () {\n const encoded = yield* encodeReceipt(receipt).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`receipt encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(receipt.threadId, \"awaitSettlement\", encoded);\n\n const settled = yield* expect(\n receipt.threadId,\n \"awaitSettlement\",\n SettlementReached,\n ClientAwaitHostFailure,\n )(response);\n\n return settled.settlement;\n }),\n\n awaitProgress: (threadId, afterSequence) =>\n Effect.gen(function* () {\n const waiterId = yield* crypto.randomUUIDv4.pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `awaitProgress cancellation identity generation failed: ${error.message}`,\n ),\n }),\n ),\n );\n\n const request = AwaitProgressRequest.make({ afterSequence, waiterId });\n\n const encoded = yield* encodeAwaitProgressRequest(request).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `awaitProgress request encode failed: ${error.message}`,\n ),\n }),\n ),\n );\n\n const attempt = (retry: number): Effect.Effect<void, ClientProgressFailure> =>\n call(threadId, \"awaitProgress\", encoded).pipe(\n Effect.flatMap(\n expect(threadId, \"awaitProgress\", ProgressObserved, ClientObserveHostFailure),\n ),\n Effect.asVoid,\n Effect.catchTag(\"ThreadClientError\", (error) =>\n error.retryable === true && error.overloaded !== true && retry < 5\n ? Effect.sleep(Duration.millis(10 * 2 ** retry)).pipe(\n Effect.andThen(attempt(retry + 1)),\n )\n : Effect.fail(error),\n ),\n );\n\n yield* attempt(0).pipe(Effect.onInterrupt(() => cancelProgress(threadId, waiterId)));\n }),\n\n readPage,\n\n readAll: (threadId) =>\n Effect.gen(function* () {\n const all: Array<CanonicalRecordEnvelope> = [];\n let after: CanonicalSequence | undefined;\n\n for (;;) {\n const page = yield* readPage(threadId, { afterSequence: after, limit: 1_024 });\n\n all.push(...page);\n const last = page.at(-1);\n\n if (page.length < 1_024 || last === undefined) return all;\n after = last.sequence;\n }\n }),\n\n abort: (threadId, command) =>\n Effect.gen(function* () {\n const encoded = yield* encodeAbortCommand(command).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`abort command encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"abort\", encoded);\n\n const recorded = yield* expect(\n threadId,\n \"abort\",\n AbortRecorded,\n ClientAbortHostFailure,\n )(response);\n\n return recorded.intent;\n }),\n\n resolveApproval: (threadId, command) =>\n Effect.gen(function* () {\n const encoded = yield* encodeApprovalDecisionCommand(command).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`approval command encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"resolveApproval\", encoded);\n\n const recorded = yield* expect(\n threadId,\n \"resolveApproval\",\n ApprovalRecorded,\n ClientApprovalHostFailure,\n )(response);\n\n return recorded.intent;\n }),\n\n resolveUnknown: (threadId, command) =>\n Effect.gen(function* () {\n const encoded = yield* encodeUnknownResolutionCommand(command).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `resolution command encode failed: ${error.message}`,\n ),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"resolveUnknown\", encoded);\n\n const recorded = yield* expect(\n threadId,\n \"resolveUnknown\",\n UnknownResolutionRecorded,\n ClientUnknownHostFailure,\n )(response);\n\n return recorded.intent;\n }),\n });\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,6BAA6B;AACnC,MAAM,gCAAgC;AAEtC,MAAM,oBAAoB,OAAO,OAAO,MAAM,OA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,UACf,kBAAkB,KAAK,EACrB,SAAS,oBAAoB,mCAAmC,MAAM,SAAS,EACjF,CAAC,CACH,CACF;IAEA,MAAM,WAAW,OAAO,KAAK,UAAU,mBAAmB,OAAO;IASjE,QAAO,OAPiB,OACtB,UACA,mBACA,kBACA,yBACF,CAAC,CAAC,QAAQ,EAAA,CAEM;GAClB,CAAC;GAEH,iBAAiB,UAAU,YACzB,OAAO,IAAI,aAAa;IACtB,MAAM,UAAU,OAAO,+BAA+B,OAAO,CAAC,CAAC,KAC7D,OAAO,UAAU,UACf,kBAAkB,KAAK,EACrB,SAAS,oBACP,qCAAqC,MAAM,SAC7C,EACF,CAAC,CACH,CACF;IAEA,MAAM,WAAW,OAAO,KAAK,UAAU,kBAAkB,OAAO;IAShE,QAAO,OAPiB,OACtB,UACA,kBACA,2BACA,wBACF,CAAC,CAAC,QAAQ,EAAA,CAEM;GAClB,CAAC;EACL,CAAC;CACH,CAAC,CACH;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as BrowserRunLifecycleOptions, r as BrowserRunSessionLifecycle, t as BrowserRunCleanupError } from "./browser-session-lifecycle-DJpqLXy_.mjs";
|
|
2
2
|
import { Context, Effect, Layer, Redacted, Schema, Scope } from "effect";
|
|
3
|
-
import { SandboxImplementation } from "
|
|
4
|
-
import { BrowserHandle, InteractiveBrowser, InteractiveBrowserError, InteractiveBrowserPolicy, InteractiveBrowserPolicyDeniedError } from "
|
|
3
|
+
import { SandboxImplementation } from "effect-agent/sandbox";
|
|
4
|
+
import { BrowserHandle, InteractiveBrowser, InteractiveBrowserError, InteractiveBrowserPolicy, InteractiveBrowserPolicyDeniedError } from "effect-agent/interactive-browser";
|
|
5
5
|
//#region src/InteractiveBrowser.d.ts
|
|
6
6
|
declare const browserRunInteractiveImplementation: SandboxImplementation;
|
|
7
7
|
declare const BrowserRunViewport_base: Schema.Class<BrowserRunViewport, Schema.Struct<{
|