@yielded/agent-platform-cloudflare 0.1.0-beta.190 → 0.1.0-beta.192
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-CKrbIoSK.mjs → Alarm-7_Jj0pOG.mjs} +17 -14
- package/dist/Alarm-7_Jj0pOG.mjs.map +1 -0
- package/dist/Alarm.d.mts +4 -3
- package/dist/Alarm.mjs +1 -1
- package/dist/{BrowserSession-CGTFrWDJ.mjs → BrowserSession-FABUraYC.mjs} +9 -11
- package/dist/BrowserSession-FABUraYC.mjs.map +1 -0
- package/dist/BrowserSession.mjs +2 -2
- package/dist/BrowserUse.mjs +1 -1
- package/dist/CloudflareScheduling.d.mts +3 -2
- package/dist/CloudflareScheduling.mjs +6 -4
- package/dist/CloudflareScheduling.mjs.map +1 -1
- package/dist/CloudflareSubscriptions.d.mts +2 -1
- package/dist/CloudflareSubscriptions.mjs +6 -4
- package/dist/CloudflareSubscriptions.mjs.map +1 -1
- package/dist/{CloudflareThreadClient-DC45oGYI.mjs → CloudflareThreadClient-DQeTr13i.mjs} +21 -26
- package/dist/CloudflareThreadClient-DQeTr13i.mjs.map +1 -0
- package/dist/CloudflareThreadClient.d.mts +49 -49
- package/dist/CloudflareThreadClient.mjs +1 -1
- package/dist/{InteractiveBrowser-Bm5CgC_q.mjs → InteractiveBrowser-aBrlnxZk.mjs} +2 -2
- package/dist/{InteractiveBrowser-Bm5CgC_q.mjs.map → InteractiveBrowser-aBrlnxZk.mjs.map} +1 -1
- package/dist/InteractiveBrowser.mjs +1 -1
- package/dist/{ThreadObject-BOgzojP3.mjs → ThreadObject-CvWPlIYU.mjs} +5 -5
- package/dist/ThreadObject-CvWPlIYU.mjs.map +1 -0
- package/dist/{ThreadObject-CFGzCRTA.d.mts → ThreadObject-DSUvJ7MO.d.mts} +8 -7
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/ThreadObject.mjs +1 -1
- package/dist/WakeScheduler.mjs +1 -1
- package/dist/{browser-failure-B0Tfnsaw.mjs → browser-failure-Ct_mKoAm.mjs} +6 -2
- package/dist/browser-failure-Ct_mKoAm.mjs.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +4 -4
- package/dist/{prepared-admission-CP40vF-5.mjs → prepared-admission-CrbgwsHT.mjs} +2 -2
- package/dist/{prepared-admission-CP40vF-5.mjs.map → prepared-admission-CrbgwsHT.mjs.map} +1 -1
- package/package.json +1 -1
- package/src/Alarm.ts +14 -2
- package/src/BrowserSession.ts +20 -22
- package/src/CloudflareScheduling.ts +12 -4
- package/src/CloudflareSubscriptions.ts +9 -3
- package/src/CloudflareThreadClient.ts +6 -22
- package/src/ThreadObject.ts +1 -1
- package/src/internal/browser-failure.ts +21 -2
- package/src/internal/crypto.ts +27 -30
- package/src/internal/layers.ts +4 -2
- package/dist/Alarm-CKrbIoSK.mjs.map +0 -1
- package/dist/BrowserSession-CGTFrWDJ.mjs.map +0 -1
- package/dist/CloudflareThreadClient-DC45oGYI.mjs.map +0 -1
- package/dist/ThreadObject-BOgzojP3.mjs.map +0 -1
- package/dist/browser-failure-B0Tfnsaw.mjs.map +0 -1
|
@@ -13,6 +13,7 @@ import { DurableObjectAlarm, DurableObjectState, DurableObjectStorage } from "ef
|
|
|
13
13
|
import * as Cause from "effect/Cause";
|
|
14
14
|
import * as Clock from "effect/Clock";
|
|
15
15
|
import * as Context from "effect/Context";
|
|
16
|
+
import * as SecureRandom from "effect/crypto/SecureRandom";
|
|
16
17
|
import * as DateTime from "effect/DateTime";
|
|
17
18
|
import * as Deferred from "effect/Deferred";
|
|
18
19
|
import * as Effect from "effect/Effect";
|
|
@@ -387,10 +388,11 @@ const maintenanceAlarmInput = (deadline) => ({
|
|
|
387
388
|
var DurableAlarmService = class DurableAlarmService extends Context.Service()("@effect-agent/platform-cloudflare/DurableAlarmService") {
|
|
388
389
|
static layer = Layer.effect(DurableAlarmService)(Effect.gen(function* () {
|
|
389
390
|
const alarms = yield* ThreadMaintenanceAlarm;
|
|
391
|
+
const random = yield* SecureRandom.SecureRandom;
|
|
390
392
|
const { ctx } = yield* DurableObjectContext;
|
|
391
393
|
const run = yield* makeStorageEffect;
|
|
392
394
|
const inlineWork = yield* Ref.make(0);
|
|
393
|
-
const wrap = (operation, effect) => run(operation, effect.pipe(Effect.mapError(alarmFailure(operation))));
|
|
395
|
+
const wrap = (operation, effect) => run(operation, effect.pipe(Effect.provideService(SecureRandom.SecureRandom, random), Effect.mapError(alarmFailure(operation))));
|
|
394
396
|
return DurableAlarmService.of({
|
|
395
397
|
scheduled: wrap("read maintenance checkpoint", alarms.getAlarmStatus(maintenanceAlarmRef)).pipe(Effect.map((at) => at === void 0 ? Option.none() : Option.some(DateTime.toEpochMillis(at.runAt)))),
|
|
396
398
|
scheduleAt: (at) => wrap("replace maintenance checkpoint", alarms.scheduleAlarm(maintenanceAlarmInput(at))),
|
|
@@ -413,6 +415,7 @@ const CurrentCheckpoint = Context.Reference("@yielded/agent/cloudflare/CurrentCh
|
|
|
413
415
|
/** One source transaction owns queue intent and the library checkpoint through commit. */
|
|
414
416
|
const makeAlarmOperation = Effect.gen(function* () {
|
|
415
417
|
const alarms = yield* ThreadMaintenanceAlarm;
|
|
418
|
+
const random = yield* SecureRandom.SecureRandom;
|
|
416
419
|
const sql = yield* SqlClient.SqlClient;
|
|
417
420
|
const { ctx } = yield* DurableObjectContext;
|
|
418
421
|
const queue = make(ctx.storage);
|
|
@@ -487,7 +490,7 @@ const makeAlarmOperation = Effect.gen(function* () {
|
|
|
487
490
|
return Effect.tryPromise({
|
|
488
491
|
try: () => execute(ctx.storage, intent),
|
|
489
492
|
catch: alarmFailure(operation)
|
|
490
|
-
}).pipe(Effect.tap(() => checkpoint));
|
|
493
|
+
}).pipe(Effect.tap(() => checkpoint.pipe(Effect.provideService(SecureRandom.SecureRandom, random))));
|
|
491
494
|
});
|
|
492
495
|
return Effect.withFiber((fiber) => {
|
|
493
496
|
if (fiber.getRef(CurrentCheckpoint) !== void 0) return commit;
|
|
@@ -769,8 +772,8 @@ var ThreadMutationGate = class ThreadMutationGate extends Context.Service()("@ef
|
|
|
769
772
|
dirty: state.dirty + 1n
|
|
770
773
|
})));
|
|
771
774
|
}
|
|
772
|
-
const next$
|
|
773
|
-
if (Number.isFinite(next$
|
|
775
|
+
const next$2 = next(dueQueue.read());
|
|
776
|
+
if (Number.isFinite(next$2)) checkpoint.earlier(Math.max(next$2, now + (scheduling.dispatchAfterEvent === true ? 0 : minimumAlarmDelay)));
|
|
774
777
|
};
|
|
775
778
|
yield* runAlarmTransaction("schedule maintenance lane", enroll);
|
|
776
779
|
yield* notify;
|
|
@@ -952,8 +955,8 @@ var ThreadMaintenance = class ThreadMaintenance extends Context.Service()("@effe
|
|
|
952
955
|
const now = yield* Clock.currentTimeMillis;
|
|
953
956
|
const claimed = yield* runAlarmTransaction("charge maintenance attempt", async (_transaction, checkpoint) => {
|
|
954
957
|
const claimed = dueQueue.claim(selected, now);
|
|
955
|
-
const next$
|
|
956
|
-
if (Number.isFinite(next$
|
|
958
|
+
const next$4 = next(dueQueue.read());
|
|
959
|
+
if (Number.isFinite(next$4)) checkpoint.at(Math.max(now + minimumAlarmDelay, next$4));
|
|
957
960
|
else checkpoint.cancel();
|
|
958
961
|
return claimed;
|
|
959
962
|
});
|
|
@@ -1163,8 +1166,8 @@ var ThreadMaintenance = class ThreadMaintenance extends Context.Service()("@effe
|
|
|
1163
1166
|
if (!initialized) await transaction.put(MAINTENANCE_STATE_KEY, encodeMaintenanceState(state));
|
|
1164
1167
|
const native = state.dirty > state.processed ? state.retry?.generation === state.dirty ? state.retry.notBefore : rows.find((row) => row.id === "effect-agent:native")?.dueAt ?? now + minimumAlarmDelay : null;
|
|
1165
1168
|
dueQueue.checkpointNative(native);
|
|
1166
|
-
const next$
|
|
1167
|
-
if (Number.isFinite(next$
|
|
1169
|
+
const next$1 = next(dueQueue.read());
|
|
1170
|
+
if (Number.isFinite(next$1)) checkpoint.earlier(Math.max(now + minimumAlarmDelay, next$1));
|
|
1168
1171
|
});
|
|
1169
1172
|
yield* failpoint.hit("maintenance:ensure:after");
|
|
1170
1173
|
});
|
|
@@ -1238,8 +1241,8 @@ var ThreadMaintenance = class ThreadMaintenance extends Context.Service()("@effe
|
|
|
1238
1241
|
const charged = observed.charged.get(row.id) === row.revision ? row : dueQueue.claim(row, now);
|
|
1239
1242
|
if (charged !== void 0) dueQueue.complete(charged, now + backoffDelay(charged.stalls, jitter));
|
|
1240
1243
|
}
|
|
1241
|
-
const next$
|
|
1242
|
-
if (Number.isFinite(next$
|
|
1244
|
+
const next$6 = next(dueQueue.read());
|
|
1245
|
+
if (Number.isFinite(next$6)) checkpoint.at(Math.max(now + minimumAlarmDelay, next$6));
|
|
1243
1246
|
else checkpoint.cancel();
|
|
1244
1247
|
});
|
|
1245
1248
|
}));
|
|
@@ -1865,9 +1868,9 @@ var ThreadMaintenance = class ThreadMaintenance extends Context.Service()("@effe
|
|
|
1865
1868
|
const { state } = await readMaintenanceState(transaction);
|
|
1866
1869
|
const native = active > 0 || state.dirty > state.processed ? state.retry?.generation === state.dirty && active === 0 ? Math.max(now + minimumAlarmDelay, state.retry.notBefore) : state.dirty === observed.generation && active === 0 ? result.nextAttemptAt ?? now + minimumAlarmDelay : now + minimumAlarmDelay : Infinity;
|
|
1867
1870
|
dueQueue.checkpointNative(Number.isFinite(native) ? native : null);
|
|
1868
|
-
const next$
|
|
1869
|
-
if (Number.isFinite(next$
|
|
1870
|
-
checkpoint.at(Math.max(now + minimumAlarmDelay, next$
|
|
1871
|
+
const next$3 = next(dueQueue.read());
|
|
1872
|
+
if (Number.isFinite(next$3)) {
|
|
1873
|
+
checkpoint.at(Math.max(now + minimumAlarmDelay, next$3));
|
|
1871
1874
|
return "rearmed";
|
|
1872
1875
|
}
|
|
1873
1876
|
if (config.recoveryWindowMillis > 0 && observed.charged.size > 0) {
|
|
@@ -1927,4 +1930,4 @@ var ThreadMaintenance = class ThreadMaintenance extends Context.Service()("@effe
|
|
|
1927
1930
|
//#endregion
|
|
1928
1931
|
export { Messages as _, ThreadMaintenance as a, Publication as b, ThreadMessageDelivery as c, ThreadPublication as d, ThreadRecoveryEvents as f, Lifecycle as g, HostLaneId as h, ThreadHostMaintenance as i, ThreadMutationGate as l, publishCommitted as m, DurableAlarmService as n, ThreadMaintenanceAlarm as o, ThreadRecoveryFaultEvent as p, MaintenancePassReport as r, ThreadMaintenanceFailpoint as s, Alarm_exports as t, ThreadNativeMaintenance as u, Native as v, Projection as y };
|
|
1929
1932
|
|
|
1930
|
-
//# sourceMappingURL=Alarm-
|
|
1933
|
+
//# sourceMappingURL=Alarm-7_Jj0pOG.mjs.map
|