@effect-agent/platform-cloudflare 0.1.0-beta.15 → 0.1.0-beta.16
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/index.d.mts +142 -73
- package/dist/index.mjs +148 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/bindings.ts +4 -0
- package/src/client.ts +150 -2
- package/src/conversation-object.ts +63 -42
- package/src/index.ts +1 -0
- package/src/layers.ts +18 -2
- package/src/progress-wait.ts +103 -0
- package/src/wake-scheduler.ts +5 -2
package/src/wake-scheduler.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConversationId } from "@effect-agent/core";
|
|
2
|
-
import { WakeScheduler } from "@effect-agent/session";
|
|
2
|
+
import { makeWakeSubscriptionHub, WakeScheduler } from "@effect-agent/session";
|
|
3
3
|
import { Effect, Layer, PubSub, Schema, Stream } from "effect";
|
|
4
4
|
|
|
5
5
|
import { DurableAlarmService } from "./alarm.ts";
|
|
@@ -42,10 +42,12 @@ export const cloudflareWakeSchedulerLayer: Layer.Layer<
|
|
|
42
42
|
const identity = yield* ConversationObjectIdentity;
|
|
43
43
|
const { namespace } = yield* ConversationObjectNamespace;
|
|
44
44
|
const hints = yield* PubSub.sliding<ConversationId>(WAKE_BUFFER_CAPACITY);
|
|
45
|
+
const progress = yield* makeWakeSubscriptionHub;
|
|
45
46
|
yield* Effect.addFinalizer(() => PubSub.shutdown(hints));
|
|
46
47
|
|
|
47
48
|
const notifyLocal = (conversationId: ConversationId) =>
|
|
48
|
-
|
|
49
|
+
progress.notify(conversationId).pipe(
|
|
50
|
+
Effect.andThen(PubSub.publish(hints, conversationId)),
|
|
49
51
|
Effect.andThen(alarm.scheduleNow),
|
|
50
52
|
Effect.catch((error) =>
|
|
51
53
|
// `notify` never fails by contract; a failed alarm write degrades to "hint lost"
|
|
@@ -79,6 +81,7 @@ export const cloudflareWakeSchedulerLayer: Layer.Layer<
|
|
|
79
81
|
conversationId === identity.conversationId
|
|
80
82
|
? notifyLocal(conversationId)
|
|
81
83
|
: notifyRemote(conversationId),
|
|
84
|
+
subscribe: progress.subscribe,
|
|
82
85
|
wakes: Stream.fromPubSub(hints),
|
|
83
86
|
});
|
|
84
87
|
}),
|