@yielded/agent-platform-cloudflare 0.1.0-beta.172 → 0.1.0-beta.174

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 (70) hide show
  1. package/dist/{Alarm-BMEAZo3p.mjs → Alarm-4J9B8Fg8.mjs} +54 -32
  2. package/dist/Alarm-4J9B8Fg8.mjs.map +1 -0
  3. package/dist/Alarm.mjs +1 -1
  4. package/dist/BrowserRestCapture.mjs.map +1 -1
  5. package/dist/BrowserRestCrawl.mjs.map +1 -1
  6. package/dist/{BrowserSession-Bx0V1-6_.d.mts → BrowserSession-Cojp7nth.d.mts} +3 -2
  7. package/dist/{BrowserSession-BfNmyayH.mjs → BrowserSession-aovMjfL4.mjs} +14 -14
  8. package/dist/BrowserSession-aovMjfL4.mjs.map +1 -0
  9. package/dist/BrowserSession.d.mts +1 -1
  10. package/dist/BrowserSession.mjs +2 -2
  11. package/dist/BrowserUse.d.mts +40 -64
  12. package/dist/BrowserUse.mjs +223 -2
  13. package/dist/BrowserUse.mjs.map +1 -0
  14. package/dist/CloudflareBrowser-Vt8qTdYW.mjs.map +1 -1
  15. package/dist/CloudflareCodeMode.mjs.map +1 -1
  16. package/dist/CloudflareScheduling.mjs +9 -9
  17. package/dist/CloudflareScheduling.mjs.map +1 -1
  18. package/dist/CloudflareSubscriptions.mjs +15 -15
  19. package/dist/CloudflareSubscriptions.mjs.map +1 -1
  20. package/dist/{CloudflareThreadClient-DgZVrZzF.mjs → CloudflareThreadClient-DU548EEj.mjs} +42 -39
  21. package/dist/CloudflareThreadClient-DU548EEj.mjs.map +1 -0
  22. package/dist/{CloudflareThreadClient-DuRG0MLd.d.mts → CloudflareThreadClient-lTm6baDP.d.mts} +353 -353
  23. package/dist/CloudflareThreadClient.d.mts +1 -1
  24. package/dist/CloudflareThreadClient.mjs +1 -1
  25. package/dist/{InteractiveBrowser-LdKzQeLR.mjs → InteractiveBrowser-BHNlwjZL.mjs} +40 -31
  26. package/dist/InteractiveBrowser-BHNlwjZL.mjs.map +1 -0
  27. package/dist/InteractiveBrowser.mjs +1 -1
  28. package/dist/{ThreadObject-CugPnWsJ.d.mts → ThreadObject-BLYgzcdT.d.mts} +6 -6
  29. package/dist/{ThreadObject-CGIaz6Jv.mjs → ThreadObject-C2LF3btz.mjs} +13 -14
  30. package/dist/ThreadObject-C2LF3btz.mjs.map +1 -0
  31. package/dist/ThreadObject.d.mts +1 -1
  32. package/dist/ThreadObject.mjs +1 -1
  33. package/dist/WakeScheduler.d.mts +1 -1
  34. package/dist/WakeScheduler.mjs +8 -3
  35. package/dist/WakeScheduler.mjs.map +1 -1
  36. package/dist/index.d.mts +3 -3
  37. package/dist/index.mjs +5 -5
  38. package/dist/{prepared-admission-CSdzFM_v.mjs → prepared-admission-BoUPHSNQ.mjs} +2 -2
  39. package/dist/{prepared-admission-CSdzFM_v.mjs.map → prepared-admission-BoUPHSNQ.mjs.map} +1 -1
  40. package/package.json +1 -1
  41. package/src/Alarm.ts +82 -39
  42. package/src/BrowserRestCapture.ts +1 -0
  43. package/src/BrowserRestCrawl.ts +1 -0
  44. package/src/BrowserSession.ts +3 -2
  45. package/src/BrowserUse.ts +287 -1504
  46. package/src/CloudflareCodeMode.ts +6 -0
  47. package/src/CloudflareScheduling.ts +103 -103
  48. package/src/CloudflareSubscriptions.ts +192 -199
  49. package/src/CloudflareThreadClient.ts +256 -268
  50. package/src/InteractiveBrowser.ts +43 -17
  51. package/src/ThreadObject.ts +35 -24
  52. package/src/WakeScheduler.ts +12 -9
  53. package/src/internal/browser-binding.ts +8 -0
  54. package/src/internal/browser-credentials.ts +18 -13
  55. package/src/internal/browser-file-selection.ts +13 -2
  56. package/src/internal/browser-quick-action.ts +1 -0
  57. package/src/internal/browser-session-lifecycle.ts +32 -36
  58. package/src/internal/due-queue.ts +38 -19
  59. package/src/internal/layers.ts +53 -53
  60. package/dist/Alarm-BMEAZo3p.mjs.map +0 -1
  61. package/dist/BrowserSession-BfNmyayH.mjs.map +0 -1
  62. package/dist/BrowserUse-Bc2JdLW2.mjs +0 -1528
  63. package/dist/BrowserUse-Bc2JdLW2.mjs.map +0 -1
  64. package/dist/CloudflareThreadClient-DgZVrZzF.mjs.map +0 -1
  65. package/dist/InteractiveBrowser-LdKzQeLR.mjs.map +0 -1
  66. package/dist/ThreadObject-CGIaz6Jv.mjs.map +0 -1
  67. package/dist/page-function-CmUCcyNP.mjs +0 -11
  68. package/dist/page-function-CmUCcyNP.mjs.map +0 -1
  69. package/src/internal/browser-dom.ts +0 -886
  70. package/src/internal/browser-jev-dom.ts +0 -362
@@ -134,8 +134,8 @@ export const makeSubscriptionPartitionAlarmHandler = Effect.fnUntraced(function*
134
134
 
135
135
  return {
136
136
  tag: options.tag,
137
- handle: (event) =>
138
- Effect.gen(function* () {
137
+ handle: Effect.fnUntraced(
138
+ function* (event) {
139
139
  if (event.tag !== options.tag)
140
140
  return yield* SubscriptionAlarmProtocolError.make({
141
141
  message: "Ancillary alarm tag mismatch",
@@ -148,14 +148,17 @@ export const makeSubscriptionPartitionAlarmHandler = Effect.fnUntraced(function*
148
148
  );
149
149
 
150
150
  yield* options.handle({ ...event, payload });
151
- }).pipe(
152
- Effect.scoped,
153
- Effect.timeoutOrElse({
154
- duration: options.timeoutMillis,
155
- orElse: () => SubscriptionAlarmExtensionError.make({ code: "timeout" }),
156
- }),
157
- Effect.provideContext(services),
158
- ),
151
+ },
152
+ (effect) =>
153
+ effect.pipe(
154
+ Effect.scoped,
155
+ Effect.timeoutOrElse({
156
+ duration: options.timeoutMillis,
157
+ orElse: () => SubscriptionAlarmExtensionError.make({ code: "timeout" }),
158
+ }),
159
+ Effect.provideContext(services),
160
+ ),
161
+ ),
159
162
  };
160
163
  });
161
164
 
@@ -429,183 +432,174 @@ export class CloudflareSubscriptionsClient {
429
432
  const subscriptions = Subscriptions.of({
430
433
  recoverSubscription: (scope, key, revision) =>
431
434
  changeState(scope, key, revision, "RecoverSubscription"),
432
- getSubscription: (scope, key) =>
433
- Effect.gen(function* () {
434
- const response = yield* call(scope.partition, {
435
- _tag: "GetSubscription",
436
- schemaVersion: 1,
437
- scope,
438
- key,
439
- });
440
-
441
- if (response._tag === "Snapshot") return response.value;
442
- const failure = failed(response);
443
-
444
- return yield* failure._tag === "SubscriptionError" ? failure : asProtocolError();
445
- }),
446
- recoverDelivery: (scope, key, expectedGeneration) =>
447
- Effect.gen(function* () {
448
- const response = yield* call(scope.partition, {
449
- _tag: "RecoverDelivery",
450
- expectedGeneration,
451
- schemaVersion: 1,
452
- scope,
453
- key,
454
- });
435
+ getSubscription: Effect.fnUntraced(function* (scope, key) {
436
+ const response = yield* call(scope.partition, {
437
+ _tag: "GetSubscription",
438
+ schemaVersion: 1,
439
+ scope,
440
+ key,
441
+ });
455
442
 
456
- if (response._tag === "DeliverySnapshot") return response.value;
457
- const failure = failed(response);
443
+ if (response._tag === "Snapshot") return response.value;
444
+ const failure = failed(response);
445
+
446
+ return yield* failure._tag === "SubscriptionError" ? failure : asProtocolError();
447
+ }),
448
+ recoverDelivery: Effect.fnUntraced(function* (scope, key, expectedGeneration) {
449
+ const response = yield* call(scope.partition, {
450
+ _tag: "RecoverDelivery",
451
+ expectedGeneration,
452
+ schemaVersion: 1,
453
+ scope,
454
+ key,
455
+ });
458
456
 
459
- return yield* failure._tag === "SubscriptionError" ||
460
- failure._tag === "SubscriptionFailpointError"
461
- ? failure
462
- : asProtocolError();
463
- }),
464
- updateSubscription: (scope, key, expectedRevision, options) =>
465
- Effect.gen(function* () {
466
- const response = yield* call(scope.partition, {
467
- _tag: "UpdateSubscription",
468
- schemaVersion: 1,
469
- scope,
470
- key,
471
- expectedRevision,
472
- options,
473
- });
457
+ if (response._tag === "DeliverySnapshot") return response.value;
458
+ const failure = failed(response);
459
+
460
+ return yield* failure._tag === "SubscriptionError" ||
461
+ failure._tag === "SubscriptionFailpointError"
462
+ ? failure
463
+ : asProtocolError();
464
+ }),
465
+ updateSubscription: Effect.fnUntraced(function* (scope, key, expectedRevision, options) {
466
+ const response = yield* call(scope.partition, {
467
+ _tag: "UpdateSubscription",
468
+ schemaVersion: 1,
469
+ scope,
470
+ key,
471
+ expectedRevision,
472
+ options,
473
+ });
474
474
 
475
- if (response._tag === "Snapshot") return response.value;
476
- const failure = failed(response);
475
+ if (response._tag === "Snapshot") return response.value;
476
+ const failure = failed(response);
477
477
 
478
- return yield* failure._tag === "SubscriptionError" ||
479
- failure._tag === "SubscriptionFailpointError" ||
480
- failure._tag === "SubscriptionSourceError"
481
- ? failure
482
- : asProtocolError();
483
- }),
478
+ return yield* failure._tag === "SubscriptionError" ||
479
+ failure._tag === "SubscriptionFailpointError" ||
480
+ failure._tag === "SubscriptionSourceError"
481
+ ? failure
482
+ : asProtocolError();
483
+ }),
484
484
  pauseSubscription: (scope, key, revision) =>
485
485
  changeState(scope, key, revision, "PauseSubscription"),
486
486
  resumeSubscription: (scope, key, revision) =>
487
487
  changeState(scope, key, revision, "ResumeSubscription"),
488
- subscribe: (scope, options) =>
489
- Effect.gen(function* () {
490
- const response = yield* call(scope.partition, {
491
- _tag: "Subscribe",
492
- schemaVersion: 1,
493
- scope,
494
- options,
495
- });
488
+ subscribe: Effect.fnUntraced(function* (scope, options) {
489
+ const response = yield* call(scope.partition, {
490
+ _tag: "Subscribe",
491
+ schemaVersion: 1,
492
+ scope,
493
+ options,
494
+ });
496
495
 
497
- if (response._tag === "Snapshot") return response.value;
498
- const failure = failed(response);
496
+ if (response._tag === "Snapshot") return response.value;
497
+ const failure = failed(response);
499
498
 
500
- if (
501
- failure._tag === "SubscriptionError" ||
502
- failure._tag === "SubscriptionSourceError" ||
503
- failure._tag === "SubscriptionFailpointError"
504
- )
505
- return yield* failure;
499
+ if (
500
+ failure._tag === "SubscriptionError" ||
501
+ failure._tag === "SubscriptionSourceError" ||
502
+ failure._tag === "SubscriptionFailpointError"
503
+ )
504
+ return yield* failure;
505
+
506
+ return yield* asProtocolError();
507
+ }),
508
+ listSubscriptions: Effect.fnUntraced(function* (scope, after, limit) {
509
+ const response = yield* call(scope.partition, {
510
+ _tag: "ListSubscriptions",
511
+ schemaVersion: 1,
512
+ scope,
513
+ ...(after === undefined ? {} : { after }),
514
+ ...(limit === undefined ? {} : { limit }),
515
+ });
506
516
 
507
- return yield* asProtocolError();
508
- }),
509
- listSubscriptions: (scope, after, limit) =>
510
- Effect.gen(function* () {
511
- const response = yield* call(scope.partition, {
512
- _tag: "ListSubscriptions",
513
- schemaVersion: 1,
514
- scope,
515
- ...(after === undefined ? {} : { after }),
516
- ...(limit === undefined ? {} : { limit }),
517
- });
517
+ if (response._tag === "SubscriptionPage") return response.value;
518
+ const failure = failed(response);
519
+
520
+ return yield* failure._tag === "SubscriptionError" ? failure : asProtocolError();
521
+ }),
522
+ cancelSubscription: Effect.fnUntraced(function* (scope, key, expectedRevision) {
523
+ const response = yield* call(scope.partition, {
524
+ _tag: "CancelSubscription",
525
+ ...(expectedRevision === undefined ? {} : { expectedRevision }),
526
+ schemaVersion: 1,
527
+ scope,
528
+ key,
529
+ });
518
530
 
519
- if (response._tag === "SubscriptionPage") return response.value;
520
- const failure = failed(response);
531
+ if (response._tag === "Snapshot") return response.value;
532
+ const failure = failed(response);
521
533
 
522
- return yield* failure._tag === "SubscriptionError" ? failure : asProtocolError();
523
- }),
524
- cancelSubscription: (scope, key, expectedRevision) =>
525
- Effect.gen(function* () {
526
- const response = yield* call(scope.partition, {
527
- _tag: "CancelSubscription",
528
- ...(expectedRevision === undefined ? {} : { expectedRevision }),
529
- schemaVersion: 1,
530
- scope,
531
- key,
532
- });
534
+ if (
535
+ failure._tag === "SubscriptionError" ||
536
+ failure._tag === "SubscriptionFailpointError"
537
+ )
538
+ return yield* failure;
539
+
540
+ return yield* asProtocolError();
541
+ }),
542
+ listDeliveries: Effect.fnUntraced(function* (scope, key, after, limit) {
543
+ const response = yield* call(scope.partition, {
544
+ _tag: "ListDeliveries",
545
+ schemaVersion: 1,
546
+ scope,
547
+ key,
548
+ ...(after === undefined ? {} : { after }),
549
+ ...(limit === undefined ? {} : { limit }),
550
+ });
533
551
 
534
- if (response._tag === "Snapshot") return response.value;
535
- const failure = failed(response);
552
+ if (response._tag === "DeliveryPage") return response.value;
553
+ const failure = failed(response);
536
554
 
537
- if (
538
- failure._tag === "SubscriptionError" ||
539
- failure._tag === "SubscriptionFailpointError"
540
- )
541
- return yield* failure;
555
+ return yield* failure._tag === "SubscriptionError" ? failure : asProtocolError();
556
+ }),
557
+ });
542
558
 
543
- return yield* asProtocolError();
544
- }),
545
- listDeliveries: (scope, key, after, limit) =>
546
- Effect.gen(function* () {
547
- const response = yield* call(scope.partition, {
548
- _tag: "ListDeliveries",
549
- schemaVersion: 1,
550
- scope,
551
- key,
552
- ...(after === undefined ? {} : { after }),
553
- ...(limit === undefined ? {} : { limit }),
554
- });
559
+ const intake = SubscriptionIntake.of({
560
+ accept: Effect.fnUntraced(function* (principal, source, payload) {
561
+ const request = yield* Schema.decodeUnknownEffect(AcceptRequest)({
562
+ _tag: "Accept",
563
+ schemaVersion: 1,
564
+ partition,
565
+ principal,
566
+ source,
567
+ payload,
568
+ }).pipe(
569
+ Effect.mapError(() =>
570
+ SubscriptionError.make({ reason: "validation", code: "event-payload" }),
571
+ ),
572
+ );
555
573
 
556
- if (response._tag === "DeliveryPage") return response.value;
557
- const failure = failed(response);
574
+ const response = yield* call(request.partition, request);
558
575
 
559
- return yield* failure._tag === "SubscriptionError" ? failure : asProtocolError();
560
- }),
561
- });
576
+ if (response._tag === "Acknowledgement") return response.value;
577
+ const failure = failed(response);
562
578
 
563
- const intake = SubscriptionIntake.of({
564
- accept: (principal, source, payload) =>
565
- Effect.gen(function* () {
566
- const request = yield* Schema.decodeUnknownEffect(AcceptRequest)({
567
- _tag: "Accept",
568
- schemaVersion: 1,
569
- partition,
570
- principal,
571
- source,
572
- payload,
573
- }).pipe(
574
- Effect.mapError(() =>
575
- SubscriptionError.make({ reason: "validation", code: "event-payload" }),
576
- ),
577
- );
578
-
579
- const response = yield* call(request.partition, request);
580
-
581
- if (response._tag === "Acknowledgement") return response.value;
582
- const failure = failed(response);
583
-
584
- if (
585
- failure._tag === "SubscriptionError" ||
586
- failure._tag === "SubscriptionSourceError" ||
587
- failure._tag === "SubscriptionFailpointError"
588
- )
589
- return yield* failure;
590
-
591
- return yield* asProtocolError();
592
- }),
593
- status: (principal, source, eventId) =>
594
- Effect.gen(function* () {
595
- const response = yield* call(partition, {
596
- _tag: "Status",
597
- schemaVersion: 1,
598
- partition,
599
- principal,
600
- source,
601
- eventId,
602
- });
579
+ if (
580
+ failure._tag === "SubscriptionError" ||
581
+ failure._tag === "SubscriptionSourceError" ||
582
+ failure._tag === "SubscriptionFailpointError"
583
+ )
584
+ return yield* failure;
585
+
586
+ return yield* asProtocolError();
587
+ }),
588
+ status: Effect.fnUntraced(function* (principal, source, eventId) {
589
+ const response = yield* call(partition, {
590
+ _tag: "Status",
591
+ schemaVersion: 1,
592
+ partition,
593
+ principal,
594
+ source,
595
+ eventId,
596
+ });
603
597
 
604
- if (response._tag === "Status") return response.value;
605
- const failure = failed(response);
598
+ if (response._tag === "Status") return response.value;
599
+ const failure = failed(response);
606
600
 
607
- return yield* failure._tag === "SubscriptionError" ? failure : asProtocolError();
608
- }),
601
+ return yield* failure._tag === "SubscriptionError" ? failure : asProtocolError();
602
+ }),
609
603
  });
610
604
 
611
605
  return Context.make(Subscriptions, subscriptions).pipe(
@@ -799,40 +793,39 @@ const transactionLayer: Layer.Layer<
799
793
  const alarms = yield* DurableObjectAlarm.DurableObjectAlarm;
800
794
 
801
795
  return DoSubscriptionTransaction.of({
802
- run: (body) =>
803
- Effect.gen(function* () {
804
- const nowMillis = yield* Clock.currentTimeMillis;
805
-
806
- return yield* alarms
807
- .transaction((transaction) =>
808
- body((replacement) =>
809
- replacement.deadlineAtMillis === null
810
- ? transaction
811
- .cancelAlarm({ id: SUBSCRIPTION_ALARM_ID, tag: SUBSCRIPTION_ALARM_TAG })
812
- .pipe(Effect.mapError(alarmStorageError("cancel-subscription-alarm")))
813
- : Effect.fromOption(
814
- DateTime.make(Math.max(replacement.deadlineAtMillis, nowMillis + 1)),
815
- ).pipe(
816
- Effect.mapError(() => corruptFailure("subscription-alarm-deadline")),
817
- Effect.flatMap((runAt) =>
818
- transaction
819
- .scheduleAlarm({
820
- id: SUBSCRIPTION_ALARM_ID,
821
- tag: SUBSCRIPTION_ALARM_TAG,
822
- runAt,
823
- payload: { schemaVersion: 1, generation: replacement.generation },
824
- })
825
- .pipe(Effect.mapError(alarmStorageError("schedule-subscription-alarm"))),
826
- ),
796
+ run: Effect.fnUntraced(function* (body) {
797
+ const nowMillis = yield* Clock.currentTimeMillis;
798
+
799
+ return yield* alarms
800
+ .transaction((transaction) =>
801
+ body((replacement) =>
802
+ replacement.deadlineAtMillis === null
803
+ ? transaction
804
+ .cancelAlarm({ id: SUBSCRIPTION_ALARM_ID, tag: SUBSCRIPTION_ALARM_TAG })
805
+ .pipe(Effect.mapError(alarmStorageError("cancel-subscription-alarm")))
806
+ : Effect.fromOption(
807
+ DateTime.make(Math.max(replacement.deadlineAtMillis, nowMillis + 1)),
808
+ ).pipe(
809
+ Effect.mapError(() => corruptFailure("subscription-alarm-deadline")),
810
+ Effect.flatMap((runAt) =>
811
+ transaction
812
+ .scheduleAlarm({
813
+ id: SUBSCRIPTION_ALARM_ID,
814
+ tag: SUBSCRIPTION_ALARM_TAG,
815
+ runAt,
816
+ payload: { schemaVersion: 1, generation: replacement.generation },
817
+ })
818
+ .pipe(Effect.mapError(alarmStorageError("schedule-subscription-alarm"))),
827
819
  ),
828
- ),
829
- )
830
- .pipe(
831
- Effect.catchTag("StorageOperationError", () =>
832
- storageFailure("commit-subscription-transaction"),
833
- ),
834
- );
835
- }),
820
+ ),
821
+ ),
822
+ )
823
+ .pipe(
824
+ Effect.catchTag("StorageOperationError", () =>
825
+ storageFailure("commit-subscription-transaction"),
826
+ ),
827
+ );
828
+ }),
836
829
  });
837
830
  }),
838
831
  );