@effect-agent/platform-cloudflare 0.1.0-beta.38 → 0.1.0-beta.40
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/bindings-BrVEOkfe.d.mts +102 -0
- package/dist/browser-quick-action.d.mts +18 -1
- package/dist/browser-quick-action.mjs +14 -1
- package/dist/browser-quick-action.mjs.map +1 -1
- package/dist/browser-rest-capture.d.mts +17 -2
- package/dist/browser-rest-capture.mjs +12 -1
- package/dist/browser-rest-capture.mjs.map +1 -1
- package/dist/browser-rest-crawl.mjs +2 -2
- package/dist/browser-rest-crawl.mjs.map +1 -1
- package/dist/index.d.mts +245 -237
- package/dist/index.mjs +168 -164
- package/dist/index.mjs.map +1 -1
- package/dist/interactive-browser.d.mts +160 -2
- package/dist/interactive-browser.mjs +1166 -2
- package/dist/interactive-browser.mjs.map +1 -0
- package/dist/{scheduling-B-OFqoS9.mjs → prepared-admission-BKp_Upw2.mjs} +134 -433
- package/dist/prepared-admission-BKp_Upw2.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/scheduling.d.mts +47 -2
- package/dist/scheduling.mjs +339 -1
- package/dist/scheduling.mjs.map +1 -0
- package/dist/subscriptions.d.mts +52 -0
- package/dist/subscriptions.mjs +346 -0
- package/dist/subscriptions.mjs.map +1 -0
- package/package.json +20 -13
- package/src/alarm.ts +264 -265
- package/src/bindings.ts +34 -30
- package/src/browser-quick-action.ts +31 -0
- package/src/browser-rest-capture.ts +27 -0
- package/src/client.ts +111 -105
- package/src/code-mode-executor.ts +19 -0
- package/src/config.ts +7 -7
- package/src/index.ts +10 -11
- package/src/interactive-browser.ts +29 -1
- package/src/layers.ts +178 -257
- package/src/prepared-admission.ts +90 -0
- package/src/scheduling.ts +19 -55
- package/src/subscriptions.ts +661 -0
- package/src/{conversation-object.ts → thread-object.ts} +167 -136
- package/src/transport.ts +15 -15
- package/src/wake-scheduler.ts +17 -22
- package/dist/interactive-browser-BRo-Bfvb.d.mts +0 -144
- package/dist/interactive-browser-Cy5q-ldl.mjs +0 -1154
- package/dist/interactive-browser-Cy5q-ldl.mjs.map +0 -1
- package/dist/scheduling-B-OFqoS9.mjs.map +0 -1
- package/dist/scheduling-BJs_kHTx.d.mts +0 -142
package/src/scheduling.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { AgentId } from "@effect-agent/core";
|
|
2
|
+
import {
|
|
3
|
+
DoScheduleAlarmControl,
|
|
4
|
+
DoScheduleTransaction,
|
|
5
|
+
scheduleStoreLayer,
|
|
6
|
+
} from "@effect-agent/storage-cloudflare";
|
|
2
7
|
import {
|
|
3
8
|
DefinitionDigests,
|
|
4
9
|
PersistedJson,
|
|
@@ -20,21 +25,13 @@ import {
|
|
|
20
25
|
ScheduleStorageError,
|
|
21
26
|
ScheduleTimingRequest,
|
|
22
27
|
ScheduleValidationError,
|
|
23
|
-
ScheduledInputAdmission,
|
|
24
|
-
ScheduledInputRetryable,
|
|
25
|
-
type ScheduledEnvelope,
|
|
26
28
|
Scheduling,
|
|
27
29
|
ScheduleDriver,
|
|
28
30
|
type ScheduleManagementFailure,
|
|
29
31
|
defaultSchedulingLimits,
|
|
30
32
|
scheduleOwnerKey,
|
|
31
33
|
ScheduleWakeNoop,
|
|
32
|
-
} from "@effect-agent/
|
|
33
|
-
import {
|
|
34
|
-
DoScheduleAlarmControl,
|
|
35
|
-
DoScheduleTransaction,
|
|
36
|
-
scheduleStoreLayer,
|
|
37
|
-
} from "@effect-agent/storage-cloudflare";
|
|
34
|
+
} from "@effect-agent/thread";
|
|
38
35
|
import { BrowserCrypto } from "@effect/platform-browser";
|
|
39
36
|
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
40
37
|
import { Clock, Context, DateTime, Effect, Layer, Schema } from "effect";
|
|
@@ -45,8 +42,12 @@ import {
|
|
|
45
42
|
type WorkerEnvironment,
|
|
46
43
|
} from "effect-cf";
|
|
47
44
|
|
|
48
|
-
import type {
|
|
49
|
-
import {
|
|
45
|
+
import type { ThreadObjectNamespace } from "./bindings.ts";
|
|
46
|
+
import { CloudflareThreadClient } from "./client.ts";
|
|
47
|
+
import {
|
|
48
|
+
cloudflarePreparedInputAdmissionLayer,
|
|
49
|
+
cloudflareScheduledInputAdmissionLayer,
|
|
50
|
+
} from "./prepared-admission.ts";
|
|
50
51
|
|
|
51
52
|
const SCHEDULE_ALARM_TAG = "effect-agent/ScheduleOwnerWake";
|
|
52
53
|
const SCHEDULE_ALARM_ID = "driver";
|
|
@@ -421,48 +422,6 @@ const transactionLayer: Layer.Layer<
|
|
|
421
422
|
}),
|
|
422
423
|
);
|
|
423
424
|
|
|
424
|
-
const admissionLayer: Layer.Layer<ScheduledInputAdmission, never, CloudflareConversationClient> =
|
|
425
|
-
Layer.effect(
|
|
426
|
-
ScheduledInputAdmission,
|
|
427
|
-
Effect.gen(function* () {
|
|
428
|
-
const client = yield* CloudflareConversationClient;
|
|
429
|
-
const submit = (envelope: ScheduledEnvelope) =>
|
|
430
|
-
client
|
|
431
|
-
.submit(passthroughAgent(envelope.agentId), envelope.input, {
|
|
432
|
-
conversationId: envelope.conversationId,
|
|
433
|
-
principal: envelope.deliveryPrincipal,
|
|
434
|
-
idempotencyKey: envelope.admissionKey,
|
|
435
|
-
definitions: envelope.definitions,
|
|
436
|
-
})
|
|
437
|
-
.pipe(
|
|
438
|
-
Effect.catchTags({
|
|
439
|
-
AdmissionConflict: () =>
|
|
440
|
-
ScheduleStorageError.make({ operation: "scheduled admission", reason: "corrupt" }),
|
|
441
|
-
AdmissionLimitExceeded: () => ScheduledInputRetryable.make({ reason: "capacity" }),
|
|
442
|
-
ConversationClientError: (error: ConversationClientError) =>
|
|
443
|
-
ScheduledInputRetryable.make({
|
|
444
|
-
reason: error.overloaded === true ? "capacity" : "transport",
|
|
445
|
-
}),
|
|
446
|
-
HostProtocolError: () => ScheduledInputRetryable.make({ reason: "ambiguous" }),
|
|
447
|
-
LedgerError: () => ScheduledInputRetryable.make({ reason: "storage" }),
|
|
448
|
-
ConversationStoreError: () => ScheduledInputRetryable.make({ reason: "storage" }),
|
|
449
|
-
DurableAlarmError: () => ScheduledInputRetryable.make({ reason: "storage" }),
|
|
450
|
-
AgentInputError: () =>
|
|
451
|
-
ScheduleStorageError.make({ operation: "scheduled admission", reason: "corrupt" }),
|
|
452
|
-
DigestError: () =>
|
|
453
|
-
ScheduleStorageError.make({ operation: "scheduled admission", reason: "corrupt" }),
|
|
454
|
-
ConversationNotMaterialized: () =>
|
|
455
|
-
ScheduledInputRetryable.make({ reason: "storage" }),
|
|
456
|
-
AppendConflict: () => ScheduledInputRetryable.make({ reason: "ambiguous" }),
|
|
457
|
-
FenceRejected: () => ScheduledInputRetryable.make({ reason: "ambiguous" }),
|
|
458
|
-
DurableRuntimeFailpointError: () =>
|
|
459
|
-
ScheduledInputRetryable.make({ reason: "ambiguous" }),
|
|
460
|
-
}),
|
|
461
|
-
);
|
|
462
|
-
return ScheduledInputAdmission.of({ submit });
|
|
463
|
-
}),
|
|
464
|
-
);
|
|
465
|
-
|
|
466
425
|
type ScheduleRuntimeServices =
|
|
467
426
|
| Scheduling
|
|
468
427
|
| ScheduleDriver
|
|
@@ -616,7 +575,7 @@ export interface ScheduleOwnerObjectClass {
|
|
|
616
575
|
*/
|
|
617
576
|
export const makeScheduleOwnerObjectClass = <E>(
|
|
618
577
|
host: Layer.Layer<
|
|
619
|
-
ScheduleAuthorizer |
|
|
578
|
+
ScheduleAuthorizer | ThreadObjectNamespace,
|
|
620
579
|
E,
|
|
621
580
|
EffectCfDurableObjectState.DurableObjectState | WorkerEnvironment | ScheduleOwnerIdentity
|
|
622
581
|
>,
|
|
@@ -638,7 +597,12 @@ export const makeScheduleOwnerObjectClass = <E>(
|
|
|
638
597
|
Layer.provideMerge(
|
|
639
598
|
scheduleStoreLayer.pipe(Layer.provide(transactionLayer), Layer.provide(sqlLayer)),
|
|
640
599
|
),
|
|
641
|
-
Layer.provide(
|
|
600
|
+
Layer.provide(
|
|
601
|
+
cloudflareScheduledInputAdmissionLayer.pipe(
|
|
602
|
+
Layer.provide(cloudflarePreparedInputAdmissionLayer),
|
|
603
|
+
Layer.provide(CloudflareThreadClient.layer),
|
|
604
|
+
),
|
|
605
|
+
),
|
|
642
606
|
Layer.provide(ScheduleWakeNoop),
|
|
643
607
|
Layer.provide(BrowserCrypto.layer),
|
|
644
608
|
Layer.provideMerge(DurableObjectAlarm.DurableObjectAlarm.layer),
|