@yielded/agent-platform-cloudflare 0.1.0-beta.173 → 0.1.0-beta.175

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-B44efvB1.mjs} +162 -103
  2. package/dist/Alarm-B44efvB1.mjs.map +1 -0
  3. package/dist/Alarm.d.mts +2 -0
  4. package/dist/Alarm.mjs +1 -1
  5. package/dist/BrowserRestCapture.mjs.map +1 -1
  6. package/dist/BrowserRestCrawl.mjs.map +1 -1
  7. package/dist/{BrowserSession-Bx0V1-6_.d.mts → BrowserSession-Cojp7nth.d.mts} +3 -2
  8. package/dist/{BrowserSession-BfNmyayH.mjs → BrowserSession-aovMjfL4.mjs} +14 -14
  9. package/dist/BrowserSession-aovMjfL4.mjs.map +1 -0
  10. package/dist/BrowserSession.d.mts +1 -1
  11. package/dist/BrowserSession.mjs +2 -2
  12. package/dist/BrowserUse.d.mts +40 -64
  13. package/dist/BrowserUse.mjs +223 -2
  14. package/dist/BrowserUse.mjs.map +1 -0
  15. package/dist/CloudflareBrowser-Vt8qTdYW.mjs.map +1 -1
  16. package/dist/CloudflareCodeMode.mjs.map +1 -1
  17. package/dist/CloudflareScheduling.mjs +9 -9
  18. package/dist/CloudflareScheduling.mjs.map +1 -1
  19. package/dist/CloudflareSubscriptions.mjs +15 -15
  20. package/dist/CloudflareSubscriptions.mjs.map +1 -1
  21. package/dist/{CloudflareThreadClient-DgZVrZzF.mjs → CloudflareThreadClient-Ai3MTs3X.mjs} +43 -40
  22. package/dist/CloudflareThreadClient-Ai3MTs3X.mjs.map +1 -0
  23. package/dist/CloudflareThreadClient.mjs +1 -1
  24. package/dist/{InteractiveBrowser-LdKzQeLR.mjs → InteractiveBrowser-BHNlwjZL.mjs} +40 -31
  25. package/dist/InteractiveBrowser-BHNlwjZL.mjs.map +1 -0
  26. package/dist/InteractiveBrowser.mjs +1 -1
  27. package/dist/{ThreadObject-CRbLbdXM.d.mts → ThreadObject-CxNlhoPL.d.mts} +3 -3
  28. package/dist/{ThreadObject-CGIaz6Jv.mjs → ThreadObject-DGvlHWYi.mjs} +50 -52
  29. package/dist/ThreadObject-DGvlHWYi.mjs.map +1 -0
  30. package/dist/ThreadObject.d.mts +1 -1
  31. package/dist/ThreadObject.mjs +1 -1
  32. package/dist/WakeScheduler.d.mts +1 -1
  33. package/dist/WakeScheduler.mjs +8 -3
  34. package/dist/WakeScheduler.mjs.map +1 -1
  35. package/dist/index.d.mts +2 -2
  36. package/dist/index.mjs +5 -5
  37. package/dist/{prepared-admission-CSdzFM_v.mjs → prepared-admission-DYdffQ8K.mjs} +2 -2
  38. package/dist/{prepared-admission-CSdzFM_v.mjs.map → prepared-admission-DYdffQ8K.mjs.map} +1 -1
  39. package/package.json +1 -1
  40. package/src/Alarm.ts +293 -155
  41. package/src/BrowserRestCapture.ts +1 -0
  42. package/src/BrowserRestCrawl.ts +1 -0
  43. package/src/BrowserSession.ts +3 -2
  44. package/src/BrowserUse.ts +287 -1504
  45. package/src/CloudflareCodeMode.ts +6 -0
  46. package/src/CloudflareScheduling.ts +103 -103
  47. package/src/CloudflareSubscriptions.ts +192 -199
  48. package/src/CloudflareThreadClient.ts +258 -269
  49. package/src/InteractiveBrowser.ts +43 -17
  50. package/src/ThreadObject.ts +51 -45
  51. package/src/WakeScheduler.ts +12 -9
  52. package/src/internal/browser-binding.ts +8 -0
  53. package/src/internal/browser-credentials.ts +18 -13
  54. package/src/internal/browser-file-selection.ts +13 -2
  55. package/src/internal/browser-quick-action.ts +1 -0
  56. package/src/internal/browser-session-lifecycle.ts +32 -36
  57. package/src/internal/due-queue.ts +38 -19
  58. package/src/internal/layers.ts +108 -87
  59. package/src/internal/message-delivery.ts +61 -37
  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
@@ -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"] = (agent, input, options) =>
259
- Effect.gen(function* () {
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"] = (agent, input, options) =>
279
- Effect.gen(function* () {
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
- return response._tag === "Snapshot"
308
- ? response.value
309
- : yield* ScheduleStorageError.make({
310
- operation: "Schedule Owner protocol",
311
- reason: "corrupt",
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
- const list: Scheduling["Service"]["list"] = (scope, options = {}) =>
316
- Effect.gen(function* () {
317
- const response = yield* call(scope.owner, {
318
- _tag: "List",
319
- schemaVersion: 1,
320
- scope,
321
- ...(options.after === undefined ? {} : { after: options.after }),
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
- return response._tag === "Page"
326
- ? response.value
327
- : yield* ScheduleStorageError.make({
328
- operation: "Schedule Owner protocol",
329
- reason: "corrupt",
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
- const control = (
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
- Effect.gen(function* () {
340
- const response = yield* call(scope.owner, {
341
- _tag: "Control",
342
- schemaVersion: 1,
343
- operation,
344
- scope,
345
- scheduleId,
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: (scope, scheduleId, expectedRevision, expectedGeneration) =>
365
- Effect.gen(function* () {
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
- Effect.gen(function* () {
438
- const nowMillis = yield* Clock.currentTimeMillis;
439
-
440
- return yield* alarms
441
- .transaction((transaction) =>
442
- body((replacement) =>
443
- replacement.deadlineAtMillis === null
444
- ? transaction
445
- .cancelAlarm({ id: SCHEDULE_ALARM_ID, tag: SCHEDULE_ALARM_TAG })
446
- .pipe(Effect.mapError(alarmStorageError("cancel Schedule Owner alarm")))
447
- : Effect.fromOption(
448
- DateTime.make(Math.max(replacement.deadlineAtMillis, nowMillis + 1)),
449
- ).pipe(
450
- Effect.mapError(() =>
451
- ScheduleStorageError.make({
452
- operation: "validate Schedule Owner alarm deadline",
453
- reason: "corrupt",
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
- .pipe(
475
- Effect.catchTag("StorageOperationError", () =>
476
- ScheduleStorageError.make({
477
- operation: "commit Schedule Owner transaction",
478
- reason: "unavailable",
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
  );