@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.
Files changed (81) hide show
  1. package/dist/Alarm.d.mts +4 -4
  2. package/dist/Alarm.mjs +6 -6
  3. package/dist/Alarm.mjs.map +1 -1
  4. package/dist/BrowserRestCapture.d.mts +3 -3
  5. package/dist/BrowserRestCapture.mjs +3 -3
  6. package/dist/BrowserRestCapture.mjs.map +1 -1
  7. package/dist/BrowserRestCrawl.d.mts +2 -2
  8. package/dist/BrowserRestCrawl.mjs +3 -3
  9. package/dist/BrowserRestCrawl.mjs.map +1 -1
  10. package/dist/CloudflareBindings.d.mts +2 -2
  11. package/dist/CloudflareBindings.mjs +2 -2
  12. package/dist/CloudflareBindings.mjs.map +1 -1
  13. package/dist/{CloudflareBrowser-D4YqaTAl.mjs → CloudflareBrowser-DV6kya1H.mjs} +4 -4
  14. package/dist/CloudflareBrowser-DV6kya1H.mjs.map +1 -0
  15. package/dist/{CloudflareBrowser-DJq53niJ.d.mts → CloudflareBrowser-Doe1M7R5.d.mts} +4 -4
  16. package/dist/CloudflareBrowser.d.mts +1 -1
  17. package/dist/CloudflareBrowser.mjs +1 -1
  18. package/dist/CloudflareCodeMode.d.mts +2 -2
  19. package/dist/CloudflareCodeMode.mjs +2 -2
  20. package/dist/CloudflareCodeMode.mjs.map +1 -1
  21. package/dist/CloudflareConfig.mjs +3 -3
  22. package/dist/CloudflareConfig.mjs.map +1 -1
  23. package/dist/CloudflareMemory.d.mts +26 -26
  24. package/dist/CloudflareMemory.mjs +16 -16
  25. package/dist/CloudflareMemory.mjs.map +1 -1
  26. package/dist/CloudflareScheduling.d.mts +3 -3
  27. package/dist/CloudflareScheduling.mjs +11 -11
  28. package/dist/CloudflareScheduling.mjs.map +1 -1
  29. package/dist/CloudflareSubscriptions.d.mts +5 -5
  30. package/dist/CloudflareSubscriptions.mjs +20 -14
  31. package/dist/CloudflareSubscriptions.mjs.map +1 -1
  32. package/dist/CloudflareThreadClient.d.mts +228 -18
  33. package/dist/CloudflareThreadClient.mjs +12 -12
  34. package/dist/CloudflareThreadClient.mjs.map +1 -1
  35. package/dist/InteractiveBrowser.d.mts +2 -2
  36. package/dist/InteractiveBrowser.mjs +18 -18
  37. package/dist/InteractiveBrowser.mjs.map +1 -1
  38. package/dist/ProtectedBrowser.d.mts +2 -2
  39. package/dist/ProtectedBrowser.mjs +14 -14
  40. package/dist/ProtectedBrowser.mjs.map +1 -1
  41. package/dist/{ThreadObject-mmWMMWdY.mjs → ThreadObject-B4gJ7t0d.mjs} +29 -27
  42. package/dist/ThreadObject-B4gJ7t0d.mjs.map +1 -0
  43. package/dist/{ThreadObject-BS1gRV0V.d.mts → ThreadObject-BT0c-_vx.d.mts} +61 -65
  44. package/dist/ThreadObject.d.mts +1 -1
  45. package/dist/ThreadObject.mjs +1 -1
  46. package/dist/WakeScheduler.d.mts +1 -1
  47. package/dist/WakeScheduler.mjs +2 -2
  48. package/dist/WakeScheduler.mjs.map +1 -1
  49. package/dist/{browser-session-lifecycle-CUbVfEgP.mjs → browser-session-lifecycle-CmbQABHC.mjs} +5 -5
  50. package/dist/browser-session-lifecycle-CmbQABHC.mjs.map +1 -0
  51. package/dist/index.d.mts +2 -2
  52. package/dist/index.mjs +2 -2
  53. package/dist/{prepared-admission-DSi55W-7.mjs → prepared-admission-DU0_T-ev.mjs} +7 -7
  54. package/dist/prepared-admission-DU0_T-ev.mjs.map +1 -0
  55. package/package.json +1 -1
  56. package/src/Alarm.ts +19 -19
  57. package/src/BrowserRestCapture.ts +3 -3
  58. package/src/BrowserRestCrawl.ts +13 -13
  59. package/src/CloudflareBindings.ts +2 -2
  60. package/src/CloudflareCodeMode.ts +4 -4
  61. package/src/CloudflareConfig.ts +3 -3
  62. package/src/CloudflareMemory.ts +29 -29
  63. package/src/CloudflareScheduling.ts +13 -13
  64. package/src/CloudflareSubscriptions.ts +28 -32
  65. package/src/CloudflareThreadClient.ts +14 -14
  66. package/src/InteractiveBrowser.ts +34 -37
  67. package/src/ThreadObject.ts +14 -14
  68. package/src/WakeScheduler.ts +2 -2
  69. package/src/internal/browser-quick-action.ts +4 -4
  70. package/src/internal/browser-session-lifecycle.ts +8 -8
  71. package/src/internal/layers.ts +47 -47
  72. package/src/internal/message-delivery.ts +9 -10
  73. package/src/internal/prepared-admission.ts +7 -7
  74. package/src/internal/transport.ts +1 -1
  75. package/src/protected-browser/binding.ts +3 -3
  76. package/src/protected-browser/native.ts +3 -3
  77. package/src/protected-browser/policy.ts +42 -44
  78. package/dist/CloudflareBrowser-D4YqaTAl.mjs.map +0 -1
  79. package/dist/ThreadObject-mmWMMWdY.mjs.map +0 -1
  80. package/dist/browser-session-lifecycle-CUbVfEgP.mjs.map +0 -1
  81. package/dist/prepared-admission-DSi55W-7.mjs.map +0 -1
@@ -2,10 +2,13 @@ import {
2
2
  DoSubscriptionAlarmControl,
3
3
  DoSubscriptionTransaction,
4
4
  doSubscriptionStoreLayer,
5
- } from "@effect-agent/storage-cloudflare/DoSubscriptionStore";
6
- import { type EventSources } from "@effect-agent/thread/EventSource";
7
- import { PersistedJson } from "@effect-agent/thread/Records";
8
- import { Principal } from "@effect-agent/thread/SubmissionLedger";
5
+ } from "@effect-agent/storage-cloudflare/do-subscription-store";
6
+ import { BrowserCrypto } from "@effect/platform-browser";
7
+ import { SqliteClient } from "@effect/sql-sqlite-do";
8
+ import { Cause, Clock, Context, DateTime, Effect, Layer, Schema, type Scope } from "effect";
9
+ import { type EventSources } from "effect-agent/event-source";
10
+ import { PersistedJson } from "effect-agent/records";
11
+ import { Principal } from "effect-agent/submission-ledger";
9
12
  import {
10
13
  EventAcknowledgement,
11
14
  EventSourceVersion,
@@ -22,16 +25,9 @@ import {
22
25
  SubscriptionSnapshot,
23
26
  SubscriptionSourceError,
24
27
  defaultSubscriptionLimits,
25
- } from "@effect-agent/thread/Subscription";
26
- import { type SubscriptionInputBindings } from "@effect-agent/thread/SubscriptionInput";
27
- import {
28
- SubscriptionDriver,
29
- SubscriptionIntake,
30
- Subscriptions,
31
- } from "@effect-agent/thread/Subscriptions";
32
- import { BrowserCrypto } from "@effect/platform-browser";
33
- import { SqliteClient } from "@effect/sql-sqlite-do";
34
- import { Cause, Clock, Context, DateTime, Effect, Layer, Schema, type Scope } from "effect";
28
+ } from "effect-agent/subscription";
29
+ import { type SubscriptionInputBindings } from "effect-agent/subscription-input";
30
+ import { SubscriptionDriver, SubscriptionIntake, Subscriptions } from "effect-agent/subscriptions";
35
31
  import {
36
32
  DurableObject as EffectCfDurableObject,
37
33
  DurableObjectAlarm,
@@ -140,7 +136,7 @@ export const makeSubscriptionPartitionAlarmHandler = Effect.fn(
140
136
  message: "Ancillary alarm tag mismatch",
141
137
  });
142
138
 
143
- const payload = yield* Schema.decodeUnknownEffect(options.payload)(event.payload).pipe(
139
+ const payload = yield* Schema.decodeEffect(options.payload)(event.payload).pipe(
144
140
  Effect.mapError(() =>
145
141
  SubscriptionAlarmProtocolError.make({ message: "Invalid ancillary alarm payload" }),
146
142
  ),
@@ -149,10 +145,10 @@ export const makeSubscriptionPartitionAlarmHandler = Effect.fn(
149
145
  yield* options.handle({ ...event, payload });
150
146
  }).pipe(
151
147
  Effect.scoped,
152
- Effect.timeout(options.timeoutMillis),
153
- Effect.catchTag("TimeoutError", () =>
154
- SubscriptionAlarmExtensionError.make({ code: "timeout" }),
155
- ),
148
+ Effect.timeoutOrElse({
149
+ duration: options.timeoutMillis,
150
+ orElse: () => SubscriptionAlarmExtensionError.make({ code: "timeout" }),
151
+ }),
156
152
  Effect.provideContext(services),
157
153
  ),
158
154
  };
@@ -629,7 +625,7 @@ const decodePartitionName = Effect.fn("decodeSubscriptionPartitionName")(functio
629
625
  });
630
626
  }
631
627
 
632
- const tuple = yield* Schema.decodeUnknownEffect(
628
+ const tuple = yield* Schema.decodeEffect(
633
629
  Schema.fromJsonString(Schema.Tuple([Schema.String, Schema.String])),
634
630
  )(name).pipe(
635
631
  Effect.mapError(() =>
@@ -639,7 +635,7 @@ const decodePartitionName = Effect.fn("decodeSubscriptionPartitionName")(functio
639
635
  ),
640
636
  );
641
637
 
642
- return yield* Schema.decodeUnknownEffect(SourcePartition)({
638
+ return yield* Schema.decodeEffect(SourcePartition)({
643
639
  tenantId: tuple[0],
644
640
  address: tuple[1],
645
641
  }).pipe(
@@ -860,10 +856,10 @@ const alarmHandler = (limits: SubscriptionLimits) =>
860
856
 
861
857
  return yield* handler.handle(event).pipe(
862
858
  Effect.scoped,
863
- Effect.timeout(MAX_ANCILLARY_ALARM_MILLIS),
864
- Effect.catchTag("TimeoutError", () =>
865
- SubscriptionAlarmExtensionError.make({ code: "timeout" }),
866
- ),
859
+ Effect.timeoutOrElse({
860
+ duration: MAX_ANCILLARY_ALARM_MILLIS,
861
+ orElse: () => SubscriptionAlarmExtensionError.make({ code: "timeout" }),
862
+ }),
867
863
  );
868
864
  }
869
865
  if (event.id !== SUBSCRIPTION_ALARM_ID) {
@@ -884,13 +880,13 @@ const alarmHandler = (limits: SubscriptionLimits) =>
884
880
  yield* alarmControl.prearm((yield* Clock.currentTimeMillis) + limits.retryMillis);
885
881
 
886
882
  const pass = yield* driver.runDue.pipe(
887
- Effect.catchCause((cause) =>
888
- Cause.hasInterrupts(cause)
889
- ? Effect.failCause(cause)
890
- : Clock.currentTimeMillis.pipe(
891
- Effect.flatMap((time) => alarmControl.prearm(time + limits.retryMillis)),
892
- Effect.andThen(Effect.failCause(cause)),
893
- ),
883
+ Effect.catchCauseIf(
884
+ (cause) => !Cause.hasInterrupts(cause),
885
+ (cause) =>
886
+ Clock.currentTimeMillis.pipe(
887
+ Effect.flatMap((time) => alarmControl.prearm(time + limits.retryMillis)),
888
+ Effect.andThen(Effect.failCause(cause)),
889
+ ),
894
890
  ),
895
891
  );
896
892
 
@@ -1,21 +1,23 @@
1
- import { AgentInputError } from "@effect-agent/core/AgentError";
2
- import { AgentId, type ThreadId } from "@effect-agent/core/Identifiers";
3
- import { MessageAdmission } from "@effect-agent/core/Messaging";
4
- import { DigestError } from "@effect-agent/thread/Digest";
1
+ import { BrowserCrypto } from "@effect/platform-browser";
2
+ import { Context, Crypto, Duration, Effect, Layer, Schema } from "effect";
3
+ import { AgentInputError } from "effect-agent/agent-error";
4
+ import { DigestError } from "effect-agent/digest";
5
5
  import {
6
6
  Receipt,
7
7
  type DurableSubmitAgent,
8
8
  type DurableSubmitOptions,
9
- } from "@effect-agent/thread/DurableAgentRuntime";
10
- import { DurableRuntimeFailpointError } from "@effect-agent/thread/DurableFailpoint";
11
- import { OperationDenied } from "@effect-agent/thread/OperationAuthorizer";
9
+ } from "effect-agent/durable-agent-runtime";
10
+ import { DurableRuntimeFailpointError } from "effect-agent/durable-failpoint";
11
+ import { AgentId, type ThreadId } from "effect-agent/identifiers";
12
+ import { InputMessage } from "effect-agent/messaging";
13
+ import { OperationDenied } from "effect-agent/operation-authorizer";
12
14
  import {
13
15
  CanonicalRecordEnvelope,
14
16
  CanonicalSequence,
15
17
  DefinitionDigests,
16
18
  PersistedJson,
17
19
  WorkerAdmission,
18
- } from "@effect-agent/thread/Records";
20
+ } from "effect-agent/records";
19
21
  import {
20
22
  AdmissionFence,
21
23
  AdmissionGroup,
@@ -35,16 +37,14 @@ import {
35
37
  UnknownResolutionCommand,
36
38
  UnknownResolutionConflict,
37
39
  UnknownResolutionIntent,
38
- } from "@effect-agent/thread/SubmissionLedger";
39
- import { SubmissionStatus } from "@effect-agent/thread/SubmissionStatus";
40
+ } from "effect-agent/submission-ledger";
41
+ import { SubmissionStatus } from "effect-agent/submission-status";
40
42
  import {
41
43
  AppendConflict,
42
44
  ThreadNotMaterialized,
43
45
  ThreadStoreError,
44
46
  FenceRejected,
45
- } from "@effect-agent/thread/ThreadStore";
46
- import { BrowserCrypto } from "@effect/platform-browser";
47
- import { Context, Crypto, Duration, Effect, Layer, Schema } from "effect";
47
+ } from "effect-agent/thread-store";
48
48
  import { RpcTracing } from "effect-cf";
49
49
 
50
50
  import { DurableAlarmError } from "./Alarm.ts";
@@ -121,7 +121,7 @@ export class SubmitRequest extends Schema.Class<SubmitRequest>(
121
121
  admissionGroup: Schema.optionalKey(AdmissionGroup),
122
122
  admissionFence: Schema.optionalKey(AdmissionFence),
123
123
  workerAdmission: Schema.optionalKey(WorkerAdmission),
124
- messageAdmission: Schema.optionalKey(MessageAdmission),
124
+ messageAdmission: Schema.optionalKey(InputMessage),
125
125
  definitions: DefinitionDigests,
126
126
  inputPayload: PersistedJson,
127
127
  }) {}
@@ -7,6 +7,18 @@ import puppeteer, {
7
7
  type HTTPRequest,
8
8
  type Page,
9
9
  } from "@cloudflare/puppeteer";
10
+ import {
11
+ Context,
12
+ Clock,
13
+ Duration,
14
+ Effect,
15
+ Layer,
16
+ Redacted,
17
+ Ref,
18
+ Schema,
19
+ Semaphore,
20
+ type Scope,
21
+ } from "effect";
10
22
  import {
11
23
  BrowserActionResult,
12
24
  BrowserScreenshotRequest,
@@ -27,22 +39,9 @@ import {
27
39
  type BrowserHandle,
28
40
  type InteractiveBrowserError,
29
41
  type InteractiveBrowserNetworkPolicy,
30
- } from "@effect-agent/sandbox/InteractiveBrowser";
31
- import { PageScreenshotResult } from "@effect-agent/sandbox/PageScreenshot";
32
- import { SandboxImplementation } from "@effect-agent/sandbox/Sandbox";
33
- import {
34
- Context,
35
- Clock,
36
- Duration,
37
- Effect,
38
- Layer,
39
- Option,
40
- Redacted,
41
- Ref,
42
- Schema,
43
- Semaphore,
44
- type Scope,
45
- } from "effect";
42
+ } from "effect-agent/interactive-browser";
43
+ import { PageScreenshotResult } from "effect-agent/page-screenshot";
44
+ import { SandboxImplementation } from "effect-agent/sandbox";
46
45
 
47
46
  import {
48
47
  BrowserRunSessionLifecycle,
@@ -231,7 +230,7 @@ export class BrowserRunViewport extends Schema.Class<BrowserRunViewport>("Browse
231
230
  ) {}
232
231
 
233
232
  const decodeViewport = (input: BrowserRunViewport) =>
234
- Schema.decodeUnknownEffect(BrowserRunViewport)(input, { onExcessProperty: "error" }).pipe(
233
+ Schema.decodeEffect(BrowserRunViewport)(input, { onExcessProperty: "error" }).pipe(
235
234
  Effect.mapError(() => policyError("The browser viewport is malformed")),
236
235
  // Copy only presentation fields, including for Schema class instances.
237
236
  Effect.map((viewport) => ({
@@ -1043,7 +1042,7 @@ const makeProductionPage = (page: Page): BrowserRunInteractivePage => {
1043
1042
  ),
1044
1043
  );
1045
1044
 
1046
- if (observation._tag === "Text") Schema.decodeUnknownSync(PageObservation)(observation.text);
1045
+ if (observation._tag === "Text") Schema.decodeSync(PageObservation)(observation.text);
1047
1046
 
1048
1047
  return observation;
1049
1048
  },
@@ -1177,7 +1176,7 @@ const snapshotPolicy = Effect.fn("BrowserRunInteractive.snapshotPolicy")(functio
1177
1176
  InteractiveBrowserPolicySnapshot,
1178
1177
  InteractiveBrowserPolicyDeniedError | InteractiveBrowserUnsupportedError
1179
1178
  > {
1180
- const decoded = yield* Schema.decodeUnknownEffect(InteractiveBrowserPolicy)(input).pipe(
1179
+ const decoded = yield* Schema.decodeEffect(InteractiveBrowserPolicy)(input).pipe(
1181
1180
  Effect.mapError(() => policyError("The interactive browser policy is malformed")),
1182
1181
  );
1183
1182
 
@@ -1651,15 +1650,13 @@ const makeHandle = Effect.fn("BrowserRunInteractive.makeHandle")(function* (
1651
1650
  }),
1652
1651
  )
1653
1652
  .pipe(
1654
- Effect.flatMap((result) =>
1655
- Option.isSome(result)
1656
- ? Effect.succeed(result.value)
1657
- : Effect.fail(
1658
- InteractiveBrowserBusyError.make({
1659
- implementation: browserRunInteractiveImplementation,
1660
- message: "The browser handle already has an operation in flight",
1661
- }),
1662
- ),
1653
+ Effect.flatMap(
1654
+ Effect.fromOption(() =>
1655
+ InteractiveBrowserBusyError.make({
1656
+ implementation: browserRunInteractiveImplementation,
1657
+ message: "The browser handle already has an operation in flight",
1658
+ }),
1659
+ ),
1663
1660
  ),
1664
1661
  );
1665
1662
 
@@ -1714,7 +1711,7 @@ const makeHandle = Effect.fn("BrowserRunInteractive.makeHandle")(function* (
1714
1711
  });
1715
1712
  }
1716
1713
 
1717
- return yield* Schema.decodeUnknownEffect(BrowserTextResult)({
1714
+ return yield* Schema.decodeEffect(BrowserTextResult)({
1718
1715
  text: observation.text,
1719
1716
  }).pipe(
1720
1717
  Effect.mapError((cause) =>
@@ -1748,7 +1745,7 @@ const makeHandle = Effect.fn("BrowserRunInteractive.makeHandle")(function* (
1748
1745
  }),
1749
1746
  ),
1750
1747
  screenshot: (request) =>
1751
- Schema.decodeUnknownEffect(BrowserScreenshotRequest)(request).pipe(
1748
+ Schema.decodeEffect(BrowserScreenshotRequest)(request).pipe(
1752
1749
  Effect.mapError(() => policyError("The browser screenshot request is malformed")),
1753
1750
  Effect.flatMap((decoded) =>
1754
1751
  run(
@@ -1771,7 +1768,7 @@ const makeHandle = Effect.fn("BrowserRunInteractive.makeHandle")(function* (
1771
1768
  });
1772
1769
  }
1773
1770
 
1774
- return yield* Schema.decodeUnknownEffect(PageScreenshotResult)({
1771
+ return yield* Schema.decodeEffect(PageScreenshotResult)({
1775
1772
  implementation: browserRunInteractiveImplementation,
1776
1773
  mediaType: "image/png",
1777
1774
  bytes: new Uint8Array(bytes),
@@ -1786,7 +1783,7 @@ const makeHandle = Effect.fn("BrowserRunInteractive.makeHandle")(function* (
1786
1783
  ),
1787
1784
  ),
1788
1785
  scroll: (request) =>
1789
- Schema.decodeUnknownEffect(BrowserScrollRequest)(request).pipe(
1786
+ Schema.decodeEffect(BrowserScrollRequest)(request).pipe(
1790
1787
  Effect.mapError(() => policyError("The browser scroll request is malformed")),
1791
1788
  Effect.flatMap((decoded) =>
1792
1789
  run(
@@ -2209,7 +2206,7 @@ const makeHostService = (
2209
2206
  ),
2210
2207
  ),
2211
2208
  getLiveView: (request) =>
2212
- Schema.decodeUnknownEffect(BrowserRunLiveViewRequest)(request).pipe(
2209
+ Schema.decodeEffect(BrowserRunLiveViewRequest)(request).pipe(
2213
2210
  Effect.mapError(() => policyError("The Live View request is malformed")),
2214
2211
  Effect.flatMap((decoded) =>
2215
2212
  runtime.run(
@@ -2222,7 +2219,7 @@ const makeHostService = (
2222
2219
  "Cloudflare returned a malformed Live View response",
2223
2220
  ).pipe(
2224
2221
  Effect.flatMap((observation) =>
2225
- Schema.decodeUnknownEffect(BrowserRunLiveViewResult)({
2222
+ Schema.decodeEffect(BrowserRunLiveViewResult)({
2226
2223
  devtoolsFrontendUrl: Redacted.make(observation.devtoolsFrontendUrl),
2227
2224
  }).pipe(
2228
2225
  Effect.mapError(() =>
@@ -2236,7 +2233,7 @@ const makeHostService = (
2236
2233
  ),
2237
2234
  ),
2238
2235
  handoff: (request) =>
2239
- Schema.decodeUnknownEffect(BrowserRunHandoffRequest)(request).pipe(
2236
+ Schema.decodeEffect(BrowserRunHandoffRequest)(request).pipe(
2240
2237
  Effect.mapError(() => policyError("The browser handoff request is malformed")),
2241
2238
  Effect.flatMap((decoded) =>
2242
2239
  runtime.run(
@@ -2249,7 +2246,7 @@ const makeHostService = (
2249
2246
  "Cloudflare returned a malformed browser handoff response",
2250
2247
  ).pipe(
2251
2248
  Effect.flatMap((observation) =>
2252
- Schema.decodeUnknownEffect(BrowserRunHandoffResult)({
2249
+ Schema.decodeEffect(BrowserRunHandoffResult)({
2253
2250
  handoffId: Redacted.make(observation.handoffId),
2254
2251
  }).pipe(
2255
2252
  Effect.mapError(() =>
@@ -2272,7 +2269,7 @@ const makeHostService = (
2272
2269
  "Cloudflare returned a malformed browser handoff state",
2273
2270
  ).pipe(
2274
2271
  Effect.flatMap((observation) =>
2275
- Schema.decodeUnknownEffect(BrowserRunHandoffState)({
2272
+ Schema.decodeEffect(BrowserRunHandoffState)({
2276
2273
  active: observation.active,
2277
2274
  ...(observation.handoffId === undefined
2278
2275
  ? {}
@@ -1,5 +1,3 @@
1
- import { type AgentId, type ThreadId } from "@effect-agent/core/Identifiers";
2
- import { SubmissionId } from "@effect-agent/core/Identifiers";
3
1
  import {
4
2
  decodePortRequest,
5
3
  encodePortResponse,
@@ -9,7 +7,8 @@ import {
9
7
  PortSucceeded,
10
8
  type PortRequest,
11
9
  type PortResponse,
12
- } from "@effect-agent/storage-cloudflare/PortProtocol";
10
+ } from "@effect-agent/storage-cloudflare/port-protocol";
11
+ import { Effect, Layer, Option, Schema, Stream } from "effect";
13
12
  import {
14
13
  IntegrityReport,
15
14
  ObligationReport,
@@ -17,22 +16,24 @@ import {
17
16
  RecoveryExplanation,
18
17
  RetryCommand,
19
18
  RetryRefused,
20
- } from "@effect-agent/thread/Admin";
21
- import { DigestError } from "@effect-agent/thread/Digest";
19
+ } from "effect-agent/admin";
20
+ import { DigestError } from "effect-agent/digest";
22
21
  import {
23
22
  DurableAgentRuntime,
24
23
  DurableRuntimeConfig,
25
24
  RecoveryReport,
26
25
  type DurableSubmitAgent,
27
- } from "@effect-agent/thread/DurableAgentRuntime";
28
- import { DurableRuntimeFailpointError } from "@effect-agent/thread/DurableFailpoint";
26
+ } from "effect-agent/durable-agent-runtime";
27
+ import { DurableRuntimeFailpointError } from "effect-agent/durable-failpoint";
28
+ import { type AgentId, type ThreadId } from "effect-agent/identifiers";
29
+ import { SubmissionId } from "effect-agent/identifiers";
29
30
  import {
30
31
  OperationAuthorizationRequest,
31
32
  OperationAuthorizer,
32
33
  OperationDenied,
33
- } from "@effect-agent/thread/OperationAuthorizer";
34
- import { PersistedJson } from "@effect-agent/thread/Records";
35
- import { RunJournalError } from "@effect-agent/thread/RunJournal";
34
+ } from "effect-agent/operation-authorizer";
35
+ import { PersistedJson } from "effect-agent/records";
36
+ import { RunJournalError } from "effect-agent/run-journal";
36
37
  import {
37
38
  AdmissionPolicyError,
38
39
  LedgerError,
@@ -40,7 +41,7 @@ import {
40
41
  SettlementConflict,
41
42
  SubmissionLedger,
42
43
  SubmissionLookupByKey,
43
- } from "@effect-agent/thread/SubmissionLedger";
44
+ } from "effect-agent/submission-ledger";
44
45
  import {
45
46
  AppendConflict,
46
47
  ThreadNotMaterialized,
@@ -48,9 +49,8 @@ import {
48
49
  ThreadStore,
49
50
  ThreadStoreError,
50
51
  FenceRejected,
51
- } from "@effect-agent/thread/ThreadStore";
52
- import { WakeScheduler } from "@effect-agent/thread/WakeScheduler";
53
- import { Effect, Layer, Option, Schema, Stream } from "effect";
52
+ } from "effect-agent/thread-store";
53
+ import { WakeScheduler } from "effect-agent/wake-scheduler";
54
54
  import {
55
55
  DurableObject as EffectCfDurableObject,
56
56
  DurableObjectState as EffectCfDurableObjectState,
@@ -1,6 +1,6 @@
1
- import { type ThreadId } from "@effect-agent/core/Identifiers";
2
- import { makeWakeSubscriptionHub, WakeScheduler } from "@effect-agent/thread/WakeScheduler";
3
1
  import { Effect, Layer, PubSub, Schema, Stream } from "effect";
2
+ import { type ThreadId } from "effect-agent/identifiers";
3
+ import { makeWakeSubscriptionHub, WakeScheduler } from "effect-agent/wake-scheduler";
4
4
 
5
5
  import { DurableAlarmService } from "./Alarm.ts";
6
6
  import {
@@ -1,5 +1,6 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
2
 
3
+ import { Context, Effect, Layer, Option, Schema } from "effect";
3
4
  import {
4
5
  PageCapture,
5
6
  PageCaptureInferenceUse,
@@ -21,7 +22,7 @@ import {
21
22
  type PageCaptureError,
22
23
  type PageCaptureOutput,
23
24
  type PageCaptureRequest,
24
- } from "@effect-agent/sandbox/PageCapture";
25
+ } from "effect-agent/page-capture";
25
26
  import {
26
27
  PageScreenshot,
27
28
  PageScreenshotOutputLimitError,
@@ -29,9 +30,8 @@ import {
29
30
  type PageScreenshotCapture,
30
31
  type PageScreenshotError,
31
32
  type PageScreenshotRequest,
32
- } from "@effect-agent/sandbox/PageScreenshot";
33
- import { SandboxImplementation } from "@effect-agent/sandbox/Sandbox";
34
- import { Context, Effect, Layer, Option, Schema } from "effect";
33
+ } from "effect-agent/page-screenshot";
34
+ import { SandboxImplementation } from "effect-agent/sandbox";
35
35
 
36
36
  /**
37
37
  * The Cloudflare Browser Run Quick Action `PageCapture` adapter (capability
@@ -107,7 +107,7 @@ export class BrowserRunSessionLifecycle extends Context.Service<
107
107
  });
108
108
 
109
109
  if (response.status === 404) {
110
- const absent = Schema.decodeUnknownOption(Schema.fromJsonString(Absent))(body, {
110
+ const absent = Schema.decodeOption(Schema.fromJsonString(Absent))(body, {
111
111
  onExcessProperty: "error",
112
112
  });
113
113
 
@@ -116,16 +116,16 @@ export class BrowserRunSessionLifecycle extends Context.Service<
116
116
  return yield* new BrowserRunCleanupError({ reason: "malformed" });
117
117
  }
118
118
  if (method === "DELETE") {
119
- const result = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Closed))(
120
- body,
121
- ).pipe(Effect.mapError(() => new BrowserRunCleanupError({ reason: "malformed" })));
119
+ const result = yield* Schema.decodeEffect(Schema.fromJsonString(Closed))(body).pipe(
120
+ Effect.mapError(() => new BrowserRunCleanupError({ reason: "malformed" })),
121
+ );
122
122
 
123
123
  return result.status === "closed";
124
124
  }
125
125
 
126
- const result = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Metadata))(
127
- body,
128
- ).pipe(Effect.mapError(() => new BrowserRunCleanupError({ reason: "malformed" })));
126
+ const result = yield* Schema.decodeEffect(Schema.fromJsonString(Metadata))(body).pipe(
127
+ Effect.mapError(() => new BrowserRunCleanupError({ reason: "malformed" })),
128
+ );
129
129
 
130
130
  if (result.sessionId !== sessionId)
131
131
  return yield* new BrowserRunCleanupError({ reason: "malformed" });
@@ -135,7 +135,7 @@ export class BrowserRunSessionLifecycle extends Context.Service<
135
135
 
136
136
  const close = Effect.fn("BrowserRunSessionLifecycle.close")(
137
137
  function* (sessionId: Redacted.Redacted<string>) {
138
- const id = yield* Schema.decodeUnknownEffect(Identity)(Redacted.value(sessionId)).pipe(
138
+ const id = yield* Schema.decodeEffect(Identity)(Redacted.value(sessionId)).pipe(
139
139
  Effect.mapError(() => new BrowserRunCleanupError({ reason: "configuration" })),
140
140
  );
141
141
 
@@ -1,82 +1,82 @@
1
- import { ThreadId, type SubmissionId } from "@effect-agent/core/Identifiers";
2
- import {
3
- type RunContextPreparation,
4
- type RunCostEstimator,
5
- type RunToolFailureObserver,
6
- } from "@effect-agent/engine/RunOptions";
7
- import {
8
- CurrentToolFailureObserver,
9
- RunContextPreparationPassthrough,
10
- RunToolAuthorization,
11
- toolFailureObserverLayer,
12
- } from "@effect-agent/engine/RunOptions";
13
- import { doMessageDeliveryStoreLayer } from "@effect-agent/storage-cloudflare/DoMessageDeliveryStore";
1
+ import { doMessageDeliveryStoreLayer } from "@effect-agent/storage-cloudflare/do-message-delivery-store";
14
2
  import {
15
3
  type DoStorageFailpointHandler,
16
4
  type DoStorageFailpoint,
17
- } from "@effect-agent/storage-cloudflare/DoStorageFailpoint";
18
- import { submissionLedgerLayer } from "@effect-agent/storage-cloudflare/DoSubmissionLedger";
5
+ } from "@effect-agent/storage-cloudflare/do-storage-failpoint";
6
+ import { submissionLedgerLayer } from "@effect-agent/storage-cloudflare/do-submission-ledger";
19
7
  import {
20
8
  threadStoreLayer,
21
9
  storageConfigLayer,
22
10
  storageFailpointLayer,
23
11
  type DoStorageInitializationError,
24
12
  type DoStorageOptions,
25
- } from "@effect-agent/storage-cloudflare/DoThreadStore";
26
- import { type PortRequest, type PortResponse } from "@effect-agent/storage-cloudflare/PortProtocol";
13
+ } from "@effect-agent/storage-cloudflare/do-thread-store";
14
+ import {
15
+ type PortRequest,
16
+ type PortResponse,
17
+ } from "@effect-agent/storage-cloudflare/port-protocol";
27
18
  import {
28
19
  executePortRequest,
29
20
  routedThreadStoreLayer,
30
21
  routedSubmissionLedgerLayer,
31
- } from "@effect-agent/storage-cloudflare/PortRouting";
22
+ } from "@effect-agent/storage-cloudflare/port-routing";
23
+ import { BrowserCrypto } from "@effect/platform-browser";
24
+ import { SqliteClient } from "@effect/sql-sqlite-do";
25
+ import {
26
+ type Crypto,
27
+ Cause,
28
+ Context,
29
+ Duration,
30
+ Effect,
31
+ Layer,
32
+ Schema,
33
+ Semaphore,
34
+ type Option,
35
+ } from "effect";
32
36
  import {
33
37
  compileRegistrations,
34
38
  type AgentRegistration,
35
39
  type ResolvedBinding,
36
- } from "@effect-agent/thread/AgentRegistration";
37
- import { type DigestError } from "@effect-agent/thread/Digest";
38
- import {
39
- DurableAgentRuntime,
40
- DurableRuntimeConfig,
41
- } from "@effect-agent/thread/DurableAgentRuntime";
40
+ } from "effect-agent/agent-registration";
41
+ import { type DigestError } from "effect-agent/digest";
42
+ import { DurableAgentRuntime, DurableRuntimeConfig } from "effect-agent/durable-agent-runtime";
42
43
  import {
43
44
  DurableRuntimeFailpoint,
44
45
  type DurableRuntimeFailpointHandler,
45
- } from "@effect-agent/thread/DurableFailpoint";
46
+ } from "effect-agent/durable-failpoint";
47
+ import { ThreadId, type SubmissionId } from "effect-agent/identifiers";
46
48
  import {
47
49
  type MessageDeliveryStore,
48
50
  MessageDeliveryDriver,
49
51
  type MessageDeliveryError,
50
- } from "@effect-agent/thread/MessageDelivery";
52
+ } from "effect-agent/message-delivery";
51
53
  import {
52
54
  operationAuthorizerLayer,
53
55
  type OperationAuthorizerService,
54
- } from "@effect-agent/thread/OperationAuthorizer";
55
- import { type PreparedInputAdmission } from "@effect-agent/thread/PreparedInputAdmission";
56
- import { ProducerId } from "@effect-agent/thread/Records";
56
+ } from "effect-agent/operation-authorizer";
57
+ import { type PreparedInputAdmission } from "effect-agent/prepared-input-admission";
58
+ import { ProducerId } from "effect-agent/records";
59
+ import {
60
+ type RunContextPreparation,
61
+ type RunCostEstimator,
62
+ type RunToolFailureObserver,
63
+ } from "effect-agent/run-options";
64
+ import {
65
+ CurrentToolFailureObserver,
66
+ RunContextPreparationPassthrough,
67
+ RunToolAuthorization,
68
+ toolFailureObserverLayer,
69
+ } from "effect-agent/run-options";
57
70
  import {
58
71
  LedgerError,
59
72
  SubmissionLedger,
60
73
  SubmissionLookupById,
61
74
  type SubmissionSnapshot,
62
- } from "@effect-agent/thread/SubmissionLedger";
63
- import { ThreadProjectionMaintenance } from "@effect-agent/thread/ThreadProjectionMaintenance";
64
- import { ThreadStoreError, ThreadStore } from "@effect-agent/thread/ThreadStore";
65
- import { ToolReconciler } from "@effect-agent/thread/ToolReconciler";
66
- import { type WakeScheduler } from "@effect-agent/thread/WakeScheduler";
67
- import { BrowserCrypto } from "@effect/platform-browser";
68
- import { SqliteClient } from "@effect/sql-sqlite-do";
69
- import {
70
- type Crypto,
71
- Cause,
72
- Context,
73
- Duration,
74
- Effect,
75
- Layer,
76
- Schema,
77
- Semaphore,
78
- type Option,
79
- } from "effect";
75
+ } from "effect-agent/submission-ledger";
76
+ import { ThreadProjectionMaintenance } from "effect-agent/thread-projection-maintenance";
77
+ import { ThreadStoreError, ThreadStore } from "effect-agent/thread-store";
78
+ import { ToolReconciler } from "effect-agent/tool-reconciler";
79
+ import { type WakeScheduler } from "effect-agent/wake-scheduler";
80
80
  import { SqlClient } from "effect/unstable/sql/SqlClient";
81
81
 
82
82
  import {
@@ -1,11 +1,11 @@
1
- import { type ThreadId } from "@effect-agent/core/Identifiers";
1
+ import { Clock, Context, Deferred, Effect, Layer, Option, Ref, Semaphore, Stream } from "effect";
2
+ import { type ThreadId } from "effect-agent/identifiers";
2
3
  import {
3
4
  MessageDeliveryDriver,
4
5
  MessageDeliveryError,
5
6
  MessageDeliveryStore,
6
- } from "@effect-agent/thread/MessageDelivery";
7
- import { WakeScheduler } from "@effect-agent/thread/WakeScheduler";
8
- import { Clock, Context, Deferred, Effect, Layer, Option, Ref, Semaphore, Stream } from "effect";
7
+ } from "effect-agent/message-delivery";
8
+ import { WakeScheduler } from "effect-agent/wake-scheduler";
9
9
 
10
10
  import { DurableAlarmError, ThreadMessageDelivery, ThreadMutationGate } from "../Alarm.ts";
11
11
  import { ThreadObjectPlacement } from "../CloudflareBindings.ts";
@@ -57,6 +57,8 @@ export const guardedMessageDeliveryStoreLayer = Layer.effect(
57
57
  );
58
58
 
59
59
  return MessageDeliveryStore.of({
60
+ limits: store.limits,
61
+ maxStoredValueBytes: store.maxStoredValueBytes,
60
62
  insert: (record) =>
61
63
  local(
62
64
  record.key.ownerThreadId,
@@ -71,12 +73,9 @@ export const guardedMessageDeliveryStoreLayer = Layer.effect(
71
73
  // pass placement validation before the driver may dispatch any of the wave.
72
74
  due: (nowMillis, limit, owner) =>
73
75
  local(owner, store.due(nowMillis, limit, owner)).pipe(
74
- Effect.flatMap((keys) =>
75
- keys.every((key) => ownsThread(key.ownerThreadId))
76
- ? Effect.succeed(keys)
77
- : Effect.fail(
78
- MessageDeliveryError.make({ reason: "validation", operation: "message owner" }),
79
- ),
76
+ Effect.filterOrFail(
77
+ (keys) => keys.every((key) => ownsThread(key.ownerThreadId)),
78
+ () => MessageDeliveryError.make({ reason: "validation", operation: "message owner" }),
80
79
  ),
81
80
  ),
82
81
  nextDeadline: (owner) =>