@effect-agent/platform-cloudflare 0.1.0-beta.87 → 0.1.0-beta.89

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.
@@ -0,0 +1,161 @@
1
+ import { Context, Effect, Layer, Redacted, Schema, Scope } from "effect";
2
+ import { SandboxImplementation } from "effect-agent/sandbox";
3
+ import { HttpClient } from "effect/unstable/http";
4
+ import { BrowserHandle, InteractiveBrowser, InteractiveBrowserError, InteractiveBrowserPolicy, InteractiveBrowserPolicyDeniedError } from "effect-agent/interactive-browser";
5
+ //#region src/internal/browser-session-lifecycle.d.ts
6
+ declare const BrowserRunCleanupError_base: Schema.Class<BrowserRunCleanupError, Schema.TaggedStruct<"BrowserRunCleanupError", {
7
+ readonly reason: Schema.Literals<readonly ["configuration", "authorization", "rate-limited", "provider", "malformed", "timeout", "pending"]>;
8
+ readonly status: Schema.optionalKey<Schema.Int>;
9
+ }>, import("effect/Cause").YieldableError>;
10
+ declare class BrowserRunCleanupError extends BrowserRunCleanupError_base {}
11
+ interface BrowserRunLifecycleOptions {
12
+ readonly accountId: string;
13
+ readonly apiToken: Redacted.Redacted<string>;
14
+ }
15
+ declare const BrowserRunSessionLifecycle_base: Context.ServiceClass<BrowserRunSessionLifecycle, "@effect-agent/platform-cloudflare/BrowserRunSessionLifecycle", {
16
+ readonly close: (sessionId: Redacted.Redacted<string>) => Effect.Effect<void, BrowserRunCleanupError>;
17
+ }>;
18
+ declare class BrowserRunSessionLifecycle extends BrowserRunSessionLifecycle_base {
19
+ static layer(options: BrowserRunLifecycleOptions): Layer.Layer<BrowserRunSessionLifecycle, BrowserRunCleanupError, HttpClient.HttpClient>;
20
+ }
21
+ //#endregion
22
+ //#region src/InteractiveBrowser.d.ts
23
+ declare const browserRunInteractiveImplementation: SandboxImplementation;
24
+ declare const BrowserRunViewport_base: Schema.Class<BrowserRunViewport, Schema.Struct<{
25
+ readonly width: Schema.Int;
26
+ readonly height: Schema.Int;
27
+ readonly deviceScaleFactor: Schema.optionalKey<Schema.Finite>;
28
+ }>, {}>;
29
+ /**
30
+ * Host presentation state in CSS pixels. Dimensions are integers in 1..2048,
31
+ * density is finite in 1..2 (default 1), and neither scaled dimension may exceed
32
+ * 2048 pixels. Mobile, touch, and orientation emulation are not supported.
33
+ */
34
+ declare class BrowserRunViewport extends BrowserRunViewport_base {}
35
+ declare const BrowserRunLiveViewRequest_base: Schema.Class<BrowserRunLiveViewRequest, Schema.Struct<{
36
+ readonly mode: Schema.Literal<"tab">;
37
+ readonly expiresInMs: Schema.Int;
38
+ }>, {}>;
39
+ /** Host-only request for a redacted Cloudflare Live View URL. */
40
+ declare class BrowserRunLiveViewRequest extends BrowserRunLiveViewRequest_base {}
41
+ declare const BrowserRunLiveViewResult_base: Schema.Class<BrowserRunLiveViewResult, Schema.Struct<{
42
+ readonly devtoolsFrontendUrl: Schema.Redacted<Schema.String>;
43
+ }>, {}>;
44
+ declare class BrowserRunLiveViewResult extends BrowserRunLiveViewResult_base {}
45
+ declare const BrowserRunHandoffRequest_base: Schema.Class<BrowserRunHandoffRequest, Schema.Struct<{
46
+ readonly instructions: Schema.String;
47
+ readonly timeout: Schema.Int;
48
+ }>, {}>;
49
+ /** Start one bounded handoff; controller ownership remains a consumer concern. */
50
+ declare class BrowserRunHandoffRequest extends BrowserRunHandoffRequest_base {}
51
+ declare const BrowserRunHandoffResult_base: Schema.Class<BrowserRunHandoffResult, Schema.Struct<{
52
+ readonly handoffId: Schema.Redacted<Schema.String>;
53
+ }>, {}>;
54
+ declare class BrowserRunHandoffResult extends BrowserRunHandoffResult_base {}
55
+ declare const BrowserRunHandoffState_base: Schema.Class<BrowserRunHandoffState, Schema.Struct<{
56
+ readonly active: Schema.Boolean;
57
+ readonly handoffId: Schema.optionalKey<Schema.Redacted<Schema.String>>;
58
+ readonly durationMs: Schema.optionalKey<Schema.Natural>;
59
+ }>, {}>;
60
+ declare class BrowserRunHandoffState extends BrowserRunHandoffState_base {}
61
+ /** One intercepted Puppeteer request, narrowed to the policy-relevant surface. */
62
+ interface BrowserRunInteractiveRequest {
63
+ readonly url: () => string;
64
+ readonly abort: () => Promise<void>;
65
+ readonly continue: () => Promise<void>;
66
+ }
67
+ type BrowserRunInteractiveRequestListener = (request: BrowserRunInteractiveRequest) => void;
68
+ type BrowserRunCloudflareCommand = "Cloudflare.getLiveView" | "Cloudflare.handoff" | "Cloudflare.getHandoffState";
69
+ /** Narrow CDP boundary for Cloudflare commands absent from the pinned protocol types. */
70
+ interface BrowserRunInteractiveCdpSession {
71
+ readonly send: (command: BrowserRunCloudflareCommand, parameters: unknown) => Promise<unknown>;
72
+ readonly detach: () => Promise<void>;
73
+ }
74
+ /** Narrow page boundary used by deterministic tests; SDK values remain in this package. */
75
+ interface BrowserRunInteractivePage {
76
+ readonly close: () => Promise<void>;
77
+ readonly setBypassServiceWorker: (enabled: boolean) => Promise<void>;
78
+ readonly setRequestInterception: (enabled: boolean) => Promise<void>;
79
+ readonly onRequest: (listener: BrowserRunInteractiveRequestListener) => void;
80
+ readonly offRequest: (listener: BrowserRunInteractiveRequestListener) => void;
81
+ readonly goto: (url: string) => Promise<void>;
82
+ readonly url: () => unknown;
83
+ readonly readText: (selector: string | undefined, maximumBytes: number) => Promise<unknown>;
84
+ readonly fill: (selector: string, value: string, signal: AbortSignal, onDispatch: () => void) => Promise<unknown>;
85
+ readonly click: (selector: string, signal: AbortSignal, onDispatch: () => void) => Promise<unknown>;
86
+ readonly screenshot: (fullPage: boolean) => Promise<unknown>;
87
+ readonly scroll: (deltaX: number, deltaY: number) => Promise<void>;
88
+ readonly setViewport: (viewport: BrowserRunViewport) => Promise<void>;
89
+ readonly createCdpSession: () => Promise<BrowserRunInteractiveCdpSession>;
90
+ }
91
+ interface BrowserRunInteractiveContext {
92
+ readonly newPage: () => Promise<BrowserRunInteractivePage>;
93
+ readonly close: () => Promise<void>;
94
+ }
95
+ interface BrowserRunInteractiveBrowser {
96
+ readonly createContext: () => Promise<BrowserRunInteractiveContext>;
97
+ readonly close: () => Promise<void>;
98
+ readonly sessionId: () => unknown;
99
+ readonly isConnected: () => boolean;
100
+ readonly onDisconnected: (listener: () => void) => void;
101
+ readonly offDisconnected: (listener: () => void) => void;
102
+ }
103
+ declare const BrowserRunInteractiveBinding_base: Context.ServiceClass<BrowserRunInteractiveBinding, "@effect-agent/platform-cloudflare/BrowserRunInteractiveBinding", {
104
+ readonly launch: (keepAliveMillis: number) => Promise<BrowserRunInteractiveBrowser>;
105
+ /** Success proves whole-browser termination or exact-session absence. */
106
+ readonly closeSession: (sessionId: Redacted.Redacted<string>) => Effect.Effect<void, InteractiveBrowserError>;
107
+ }>;
108
+ /** Host-supplied Browser Run binding projected into one fakeable launch operation. */
109
+ declare class BrowserRunInteractiveBinding extends BrowserRunInteractiveBinding_base {
110
+ static layer(options: {
111
+ readonly browser: BrowserRun;
112
+ readonly viewport?: BrowserRunViewport;
113
+ }): Layer.Layer<BrowserRunInteractiveBinding, InteractiveBrowserPolicyDeniedError, BrowserRunSessionLifecycle>;
114
+ }
115
+ interface BrowserRunInteractiveSession {
116
+ readonly handle: BrowserHandle;
117
+ readonly sessionId: Redacted.Redacted<string>;
118
+ /**
119
+ * Resize without charging an agent action or changing emulation modes. Shares
120
+ * the handle's fail-fast lock, page-policy preflight, and elapsed deadline.
121
+ * A timeout or interruption leaves the session unusable; no resize is retried.
122
+ * The host must authorize callers. No viewer ownership or durable state is added.
123
+ */
124
+ readonly resizeViewport: (viewport: BrowserRunViewport) => Effect.Effect<void, InteractiveBrowserError>;
125
+ readonly getLiveView: (request: BrowserRunLiveViewRequest) => Effect.Effect<BrowserRunLiveViewResult, InteractiveBrowserError>;
126
+ readonly handoff: (request: BrowserRunHandoffRequest) => Effect.Effect<BrowserRunHandoffResult, InteractiveBrowserError>;
127
+ readonly getHandoffState: Effect.Effect<BrowserRunHandoffState, InteractiveBrowserError>;
128
+ readonly close: Effect.Effect<void, InteractiveBrowserError>;
129
+ }
130
+ declare const BrowserRunInteractiveHost_base: Context.ServiceClass<BrowserRunInteractiveHost, "@effect-agent/platform-cloudflare/BrowserRunInteractiveHost", {
131
+ readonly cleanupSemantics?: "confirmed-terminal";
132
+ readonly open: (policy: InteractiveBrowserPolicy) => Effect.Effect<BrowserRunInteractiveSession, InteractiveBrowserError, Scope.Scope>;
133
+ readonly closeSession: (sessionId: Redacted.Redacted<string>) => Effect.Effect<void, InteractiveBrowserError>;
134
+ }>;
135
+ /** Cloudflare host authority kept separate from the provider-neutral browser handle. */
136
+ declare class BrowserRunInteractiveHost extends BrowserRunInteractiveHost_base {}
137
+ /** Recognizes a local pre-dispatch refusal without exposing selector or page content. */
138
+ declare const isBrowserRunUndispatchedActionError: (error: unknown) => boolean;
139
+ /** Cloudflare host controls and private session identity for one scoped Browser Run pass. */
140
+ declare const browserRunInteractiveHostLayer: () => Layer.Layer<BrowserRunInteractiveHost, never, BrowserRunInteractiveBinding>;
141
+ /** Worker-only generic adapter; Cloudflare identity and controls remain host-only. */
142
+ declare const browserRunInteractiveLayer: () => Layer.Layer<InteractiveBrowser, never, BrowserRunInteractiveBinding>;
143
+ /** Resolved Worker binding, cleanup credentials, and optional initial viewport. */
144
+ interface CloudflareInteractiveBrowserOptions extends BrowserRunLifecycleOptions {
145
+ readonly browser: BrowserRun;
146
+ readonly viewport?: BrowserRunViewport;
147
+ }
148
+ /** Worker-only assembly; importing ordinary capture never loads Puppeteer. */
149
+ declare const CloudflareInteractiveBrowser: {
150
+ /**
151
+ * Assemble binding, confirmed-session cleanup, and the generic browser service.
152
+ * HttpClient and construction errors remain visible. Opening a pass still requires
153
+ * an explicit policy and Scope; no browser is launched during Layer construction.
154
+ */
155
+ layer: (options: CloudflareInteractiveBrowserOptions) => Layer.Layer<InteractiveBrowser, BrowserRunCleanupError | InteractiveBrowserPolicyDeniedError, import("effect/unstable/http/HttpClient").HttpClient>;
156
+ /** Opt into private host controls instead of exposing them through the generic service. */
157
+ hostLayer: (options: CloudflareInteractiveBrowserOptions) => Layer.Layer<BrowserRunInteractiveHost, BrowserRunCleanupError | InteractiveBrowserPolicyDeniedError, import("effect/unstable/http/HttpClient").HttpClient>;
158
+ };
159
+ //#endregion
160
+ export { BrowserRunCleanupError as C, isBrowserRunUndispatchedActionError as S, CloudflareInteractiveBrowser as _, BrowserRunInteractiveBinding as a, browserRunInteractiveImplementation as b, BrowserRunInteractiveContext as c, BrowserRunInteractiveRequest as d, BrowserRunInteractiveRequestListener as f, BrowserRunViewport as g, BrowserRunLiveViewResult as h, BrowserRunHandoffState as i, BrowserRunInteractiveHost as l, BrowserRunLiveViewRequest as m, BrowserRunHandoffRequest as n, BrowserRunInteractiveBrowser as o, BrowserRunInteractiveSession as p, BrowserRunHandoffResult as r, BrowserRunInteractiveCdpSession as s, BrowserRunCloudflareCommand as t, BrowserRunInteractivePage as u, CloudflareInteractiveBrowserOptions as v, BrowserRunSessionLifecycle as w, browserRunInteractiveLayer as x, browserRunInteractiveHostLayer as y };
161
+ //# sourceMappingURL=InteractiveBrowser-DUE_m12-.d.mts.map