@yielded/agent-platform-cloudflare 0.1.0-beta.173 → 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-HO_3rkM7.d.mts → CloudflareThreadClient-lTm6baDP.d.mts} +362 -362
- 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-CRbLbdXM.d.mts → ThreadObject-BLYgzcdT.d.mts} +15 -15
- 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
|
@@ -556,9 +556,11 @@ const makeExecute = (
|
|
|
556
556
|
}),
|
|
557
557
|
Effect.flatMap((outcome) => deliverHostOutcome(queued, outcome)),
|
|
558
558
|
Effect.tapError(() =>
|
|
559
|
+
// oxlint-disable-next-line effect/no-native-error -- Native Worker RPC rejection settles the sandbox program Promise; typed host failure is tracked separately.
|
|
559
560
|
Effect.sync(() => queued.reject(new Error("Code Mode host call failed"))),
|
|
560
561
|
),
|
|
561
562
|
Effect.onInterrupt(() =>
|
|
563
|
+
// oxlint-disable-next-line effect/no-native-error -- Native Worker RPC rejection settles the sandbox program Promise; typed host failure is tracked separately.
|
|
562
564
|
Effect.sync(() => queued.reject(new Error("Code Mode pass is closing"))),
|
|
563
565
|
),
|
|
564
566
|
);
|
|
@@ -574,6 +576,7 @@ const makeExecute = (
|
|
|
574
576
|
|
|
575
577
|
const dispatch = (hostCall: unknown): Promise<unknown> => {
|
|
576
578
|
if (!passOpen) {
|
|
579
|
+
// oxlint-disable-next-line effect/no-native-error -- Native Worker RPC rejection settles the sandbox program Promise; typed host failure is tracked separately.
|
|
577
580
|
return Promise.reject(new Error("Code Mode pass is closing"));
|
|
578
581
|
}
|
|
579
582
|
issuedHostCalls += 1;
|
|
@@ -587,11 +590,13 @@ const makeExecute = (
|
|
|
587
590
|
failPass(error);
|
|
588
591
|
Queue.offerUnsafe(queue, { _tag: "limit" });
|
|
589
592
|
|
|
593
|
+
// oxlint-disable-next-line effect/no-native-error -- Native Worker RPC rejection settles the sandbox program Promise; typed host failure is tracked separately.
|
|
590
594
|
return Promise.reject(new Error("host-call limit exceeded"));
|
|
591
595
|
}
|
|
592
596
|
const decoded = decodeHostCall(hostCall);
|
|
593
597
|
|
|
594
598
|
if (Option.isNone(decoded)) {
|
|
599
|
+
// oxlint-disable-next-line effect/no-native-error -- Native sandbox RPC rejects invalid input through its Promise; the Effect host classifies the result.
|
|
595
600
|
return Promise.reject(new TypeError("host calls must match the CodeHostCall schema"));
|
|
596
601
|
}
|
|
597
602
|
|
|
@@ -605,6 +610,7 @@ const makeExecute = (
|
|
|
605
610
|
|
|
606
611
|
const closeAdmission = Effect.sync(() => {
|
|
607
612
|
passOpen = false;
|
|
613
|
+
// oxlint-disable-next-line effect/no-native-error -- Native Worker RPC rejection settles the sandbox program Promise; typed host failure is tracked separately.
|
|
608
614
|
rejectQueuedHostCalls(new Error("Code Mode pass is closing"));
|
|
609
615
|
});
|
|
610
616
|
|
|
@@ -255,8 +255,8 @@ export class CloudflareSchedulingClient {
|
|
|
255
255
|
);
|
|
256
256
|
});
|
|
257
257
|
|
|
258
|
-
const create: Scheduling["Service"]["create"] = (
|
|
259
|
-
|
|
258
|
+
const create: Scheduling["Service"]["create"] = Effect.fnUntraced(
|
|
259
|
+
function* (agent, input, options) {
|
|
260
260
|
const payload = yield* encodeInput(agent, input);
|
|
261
261
|
|
|
262
262
|
const response = yield* call(options.scope.owner, {
|
|
@@ -273,10 +273,11 @@ export class CloudflareSchedulingClient {
|
|
|
273
273
|
operation: "Schedule Owner protocol",
|
|
274
274
|
reason: "corrupt",
|
|
275
275
|
});
|
|
276
|
-
}
|
|
276
|
+
},
|
|
277
|
+
);
|
|
277
278
|
|
|
278
|
-
const update: Scheduling["Service"]["update"] = (
|
|
279
|
-
|
|
279
|
+
const update: Scheduling["Service"]["update"] = Effect.fnUntraced(
|
|
280
|
+
function* (agent, input, options) {
|
|
280
281
|
const payload = yield* encodeInput(agent, input);
|
|
281
282
|
|
|
282
283
|
const response = yield* call(options.scope.owner, {
|
|
@@ -293,67 +294,68 @@ export class CloudflareSchedulingClient {
|
|
|
293
294
|
operation: "Schedule Owner protocol",
|
|
294
295
|
reason: "corrupt",
|
|
295
296
|
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const get: Scheduling["Service"]["get"] = (scope, scheduleId) =>
|
|
299
|
-
Effect.gen(function* () {
|
|
300
|
-
const response = yield* call(scope.owner, {
|
|
301
|
-
_tag: "Get",
|
|
302
|
-
schemaVersion: 1,
|
|
303
|
-
scope,
|
|
304
|
-
scheduleId,
|
|
305
|
-
});
|
|
297
|
+
},
|
|
298
|
+
);
|
|
306
299
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
300
|
+
const get: Scheduling["Service"]["get"] = Effect.fnUntraced(function* (scope, scheduleId) {
|
|
301
|
+
const response = yield* call(scope.owner, {
|
|
302
|
+
_tag: "Get",
|
|
303
|
+
schemaVersion: 1,
|
|
304
|
+
scope,
|
|
305
|
+
scheduleId,
|
|
313
306
|
});
|
|
314
307
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
...(options.limit === undefined ? {} : { limit: options.limit }),
|
|
323
|
-
});
|
|
308
|
+
return response._tag === "Snapshot"
|
|
309
|
+
? response.value
|
|
310
|
+
: yield* ScheduleStorageError.make({
|
|
311
|
+
operation: "Schedule Owner protocol",
|
|
312
|
+
reason: "corrupt",
|
|
313
|
+
});
|
|
314
|
+
});
|
|
324
315
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
316
|
+
const list: Scheduling["Service"]["list"] = Effect.fnUntraced(function* (
|
|
317
|
+
scope,
|
|
318
|
+
options = {},
|
|
319
|
+
) {
|
|
320
|
+
const response = yield* call(scope.owner, {
|
|
321
|
+
_tag: "List",
|
|
322
|
+
schemaVersion: 1,
|
|
323
|
+
scope,
|
|
324
|
+
...(options.after === undefined ? {} : { after: options.after }),
|
|
325
|
+
...(options.limit === undefined ? {} : { limit: options.limit }),
|
|
331
326
|
});
|
|
332
327
|
|
|
333
|
-
|
|
328
|
+
return response._tag === "Page"
|
|
329
|
+
? response.value
|
|
330
|
+
: yield* ScheduleStorageError.make({
|
|
331
|
+
operation: "Schedule Owner protocol",
|
|
332
|
+
reason: "corrupt",
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
const control = Effect.fnUntraced(function* (
|
|
334
337
|
operation: "pause" | "resume" | "cancel",
|
|
335
338
|
scope: ScheduleScope,
|
|
336
339
|
scheduleId: ScheduleId,
|
|
337
340
|
expectedRevision: number,
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
expectedRevision,
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
return response._tag === "Snapshot"
|
|
350
|
-
? response.value
|
|
351
|
-
: yield* ScheduleStorageError.make({
|
|
352
|
-
operation: "Schedule Owner protocol",
|
|
353
|
-
reason: "corrupt",
|
|
354
|
-
});
|
|
341
|
+
) {
|
|
342
|
+
const response = yield* call(scope.owner, {
|
|
343
|
+
_tag: "Control",
|
|
344
|
+
schemaVersion: 1,
|
|
345
|
+
operation,
|
|
346
|
+
scope,
|
|
347
|
+
scheduleId,
|
|
348
|
+
expectedRevision,
|
|
355
349
|
});
|
|
356
350
|
|
|
351
|
+
return response._tag === "Snapshot"
|
|
352
|
+
? response.value
|
|
353
|
+
: yield* ScheduleStorageError.make({
|
|
354
|
+
operation: "Schedule Owner protocol",
|
|
355
|
+
reason: "corrupt",
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
|
|
357
359
|
return Scheduling.of({
|
|
358
360
|
create,
|
|
359
361
|
update,
|
|
@@ -361,8 +363,8 @@ export class CloudflareSchedulingClient {
|
|
|
361
363
|
list,
|
|
362
364
|
pause: (scope, id, revision) => control("pause", scope, id, revision),
|
|
363
365
|
resume: (scope, id, revision) => control("resume", scope, id, revision),
|
|
364
|
-
recover: (
|
|
365
|
-
|
|
366
|
+
recover: Effect.fnUntraced(
|
|
367
|
+
function* (scope, scheduleId, expectedRevision, expectedGeneration) {
|
|
366
368
|
const response = yield* call(scope.owner, {
|
|
367
369
|
_tag: "Recover",
|
|
368
370
|
schemaVersion: 1,
|
|
@@ -378,7 +380,8 @@ export class CloudflareSchedulingClient {
|
|
|
378
380
|
operation: "Schedule Owner protocol",
|
|
379
381
|
reason: "corrupt",
|
|
380
382
|
});
|
|
381
|
-
}
|
|
383
|
+
},
|
|
384
|
+
),
|
|
382
385
|
cancel: (scope, id, revision) => control("cancel", scope, id, revision),
|
|
383
386
|
});
|
|
384
387
|
}),
|
|
@@ -433,53 +436,50 @@ const transactionLayer: Layer.Layer<
|
|
|
433
436
|
const alarms = yield* DurableObjectAlarm.DurableObjectAlarm;
|
|
434
437
|
|
|
435
438
|
return DoScheduleTransaction.of({
|
|
436
|
-
run: (body)
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}),
|
|
455
|
-
),
|
|
456
|
-
Effect.flatMap((runAt) =>
|
|
457
|
-
transaction
|
|
458
|
-
.scheduleAlarm({
|
|
459
|
-
id: SCHEDULE_ALARM_ID,
|
|
460
|
-
tag: SCHEDULE_ALARM_TAG,
|
|
461
|
-
runAt,
|
|
462
|
-
payload: {
|
|
463
|
-
schemaVersion: 1,
|
|
464
|
-
generation: replacement.generation,
|
|
465
|
-
},
|
|
466
|
-
})
|
|
467
|
-
.pipe(
|
|
468
|
-
Effect.mapError(alarmStorageError("schedule Schedule Owner alarm")),
|
|
469
|
-
),
|
|
470
|
-
),
|
|
439
|
+
run: Effect.fnUntraced(function* (body) {
|
|
440
|
+
const nowMillis = yield* Clock.currentTimeMillis;
|
|
441
|
+
|
|
442
|
+
return yield* alarms
|
|
443
|
+
.transaction((transaction) =>
|
|
444
|
+
body((replacement) =>
|
|
445
|
+
replacement.deadlineAtMillis === null
|
|
446
|
+
? transaction
|
|
447
|
+
.cancelAlarm({ id: SCHEDULE_ALARM_ID, tag: SCHEDULE_ALARM_TAG })
|
|
448
|
+
.pipe(Effect.mapError(alarmStorageError("cancel Schedule Owner alarm")))
|
|
449
|
+
: Effect.fromOption(
|
|
450
|
+
DateTime.make(Math.max(replacement.deadlineAtMillis, nowMillis + 1)),
|
|
451
|
+
).pipe(
|
|
452
|
+
Effect.mapError(() =>
|
|
453
|
+
ScheduleStorageError.make({
|
|
454
|
+
operation: "validate Schedule Owner alarm deadline",
|
|
455
|
+
reason: "corrupt",
|
|
456
|
+
}),
|
|
471
457
|
),
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
458
|
+
Effect.flatMap((runAt) =>
|
|
459
|
+
transaction
|
|
460
|
+
.scheduleAlarm({
|
|
461
|
+
id: SCHEDULE_ALARM_ID,
|
|
462
|
+
tag: SCHEDULE_ALARM_TAG,
|
|
463
|
+
runAt,
|
|
464
|
+
payload: {
|
|
465
|
+
schemaVersion: 1,
|
|
466
|
+
generation: replacement.generation,
|
|
467
|
+
},
|
|
468
|
+
})
|
|
469
|
+
.pipe(Effect.mapError(alarmStorageError("schedule Schedule Owner alarm"))),
|
|
470
|
+
),
|
|
471
|
+
),
|
|
472
|
+
),
|
|
473
|
+
)
|
|
474
|
+
.pipe(
|
|
475
|
+
Effect.catchTag("StorageOperationError", () =>
|
|
476
|
+
ScheduleStorageError.make({
|
|
477
|
+
operation: "commit Schedule Owner transaction",
|
|
478
|
+
reason: "unavailable",
|
|
479
|
+
}),
|
|
480
|
+
),
|
|
481
|
+
);
|
|
482
|
+
}),
|
|
483
483
|
});
|
|
484
484
|
}),
|
|
485
485
|
);
|