@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.
- package/dist/{Alarm-BMEAZo3p.mjs → Alarm-4J9B8Fg8.mjs} +54 -32
- package/dist/Alarm-4J9B8Fg8.mjs.map +1 -0
- package/dist/Alarm.mjs +1 -1
- package/dist/BrowserRestCapture.mjs.map +1 -1
- package/dist/BrowserRestCrawl.mjs.map +1 -1
- package/dist/{BrowserSession-Bx0V1-6_.d.mts → BrowserSession-Cojp7nth.d.mts} +3 -2
- package/dist/{BrowserSession-BfNmyayH.mjs → BrowserSession-aovMjfL4.mjs} +14 -14
- package/dist/BrowserSession-aovMjfL4.mjs.map +1 -0
- package/dist/BrowserSession.d.mts +1 -1
- package/dist/BrowserSession.mjs +2 -2
- package/dist/BrowserUse.d.mts +40 -64
- package/dist/BrowserUse.mjs +223 -2
- package/dist/BrowserUse.mjs.map +1 -0
- package/dist/CloudflareBrowser-Vt8qTdYW.mjs.map +1 -1
- package/dist/CloudflareCodeMode.mjs.map +1 -1
- package/dist/CloudflareScheduling.mjs +9 -9
- package/dist/CloudflareScheduling.mjs.map +1 -1
- package/dist/CloudflareSubscriptions.mjs +15 -15
- package/dist/CloudflareSubscriptions.mjs.map +1 -1
- package/dist/{CloudflareThreadClient-DgZVrZzF.mjs → CloudflareThreadClient-DU548EEj.mjs} +42 -39
- package/dist/CloudflareThreadClient-DU548EEj.mjs.map +1 -0
- package/dist/{CloudflareThreadClient-DuRG0MLd.d.mts → CloudflareThreadClient-lTm6baDP.d.mts} +353 -353
- package/dist/CloudflareThreadClient.d.mts +1 -1
- package/dist/CloudflareThreadClient.mjs +1 -1
- package/dist/{InteractiveBrowser-LdKzQeLR.mjs → InteractiveBrowser-BHNlwjZL.mjs} +40 -31
- package/dist/InteractiveBrowser-BHNlwjZL.mjs.map +1 -0
- package/dist/InteractiveBrowser.mjs +1 -1
- package/dist/{ThreadObject-CugPnWsJ.d.mts → ThreadObject-BLYgzcdT.d.mts} +6 -6
- package/dist/{ThreadObject-CGIaz6Jv.mjs → ThreadObject-C2LF3btz.mjs} +13 -14
- package/dist/ThreadObject-C2LF3btz.mjs.map +1 -0
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/ThreadObject.mjs +1 -1
- package/dist/WakeScheduler.d.mts +1 -1
- package/dist/WakeScheduler.mjs +8 -3
- package/dist/WakeScheduler.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +5 -5
- package/dist/{prepared-admission-CSdzFM_v.mjs → prepared-admission-BoUPHSNQ.mjs} +2 -2
- package/dist/{prepared-admission-CSdzFM_v.mjs.map → prepared-admission-BoUPHSNQ.mjs.map} +1 -1
- package/package.json +1 -1
- package/src/Alarm.ts +82 -39
- package/src/BrowserRestCapture.ts +1 -0
- package/src/BrowserRestCrawl.ts +1 -0
- package/src/BrowserSession.ts +3 -2
- package/src/BrowserUse.ts +287 -1504
- package/src/CloudflareCodeMode.ts +6 -0
- package/src/CloudflareScheduling.ts +103 -103
- package/src/CloudflareSubscriptions.ts +192 -199
- package/src/CloudflareThreadClient.ts +256 -268
- package/src/InteractiveBrowser.ts +43 -17
- package/src/ThreadObject.ts +35 -24
- package/src/WakeScheduler.ts +12 -9
- package/src/internal/browser-binding.ts +8 -0
- package/src/internal/browser-credentials.ts +18 -13
- package/src/internal/browser-file-selection.ts +13 -2
- package/src/internal/browser-quick-action.ts +1 -0
- package/src/internal/browser-session-lifecycle.ts +32 -36
- package/src/internal/due-queue.ts +38 -19
- package/src/internal/layers.ts +53 -53
- package/dist/Alarm-BMEAZo3p.mjs.map +0 -1
- package/dist/BrowserSession-BfNmyayH.mjs.map +0 -1
- package/dist/BrowserUse-Bc2JdLW2.mjs +0 -1528
- package/dist/BrowserUse-Bc2JdLW2.mjs.map +0 -1
- package/dist/CloudflareThreadClient-DgZVrZzF.mjs.map +0 -1
- package/dist/InteractiveBrowser-LdKzQeLR.mjs.map +0 -1
- package/dist/ThreadObject-CGIaz6Jv.mjs.map +0 -1
- package/dist/page-function-CmUCcyNP.mjs +0 -11
- package/dist/page-function-CmUCcyNP.mjs.map +0 -1
- package/src/internal/browser-dom.ts +0 -886
- 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: (
|
|
138
|
-
|
|
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
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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
|
-
|
|
457
|
-
|
|
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
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
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
|
-
|
|
476
|
-
|
|
475
|
+
if (response._tag === "Snapshot") return response.value;
|
|
476
|
+
const failure = failed(response);
|
|
477
477
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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
|
-
|
|
498
|
-
|
|
496
|
+
if (response._tag === "Snapshot") return response.value;
|
|
497
|
+
const failure = failed(response);
|
|
499
498
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
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
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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
|
-
|
|
520
|
-
|
|
531
|
+
if (response._tag === "Snapshot") return response.value;
|
|
532
|
+
const failure = failed(response);
|
|
521
533
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
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
|
-
|
|
535
|
-
|
|
552
|
+
if (response._tag === "DeliveryPage") return response.value;
|
|
553
|
+
const failure = failed(response);
|
|
536
554
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
)
|
|
541
|
-
return yield* failure;
|
|
555
|
+
return yield* failure._tag === "SubscriptionError" ? failure : asProtocolError();
|
|
556
|
+
}),
|
|
557
|
+
});
|
|
542
558
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
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
|
-
|
|
557
|
-
const failure = failed(response);
|
|
574
|
+
const response = yield* call(request.partition, request);
|
|
558
575
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
});
|
|
576
|
+
if (response._tag === "Acknowledgement") return response.value;
|
|
577
|
+
const failure = failed(response);
|
|
562
578
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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
|
-
|
|
605
|
-
|
|
598
|
+
if (response._tag === "Status") return response.value;
|
|
599
|
+
const failure = failed(response);
|
|
606
600
|
|
|
607
|
-
|
|
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
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
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
|
-
|
|
831
|
-
|
|
832
|
-
|
|
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
|
);
|