@effect-agent/platform-cloudflare 0.1.0-beta.121 → 0.1.0-beta.123
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/BrowserCredentials.d.mts +91 -0
- package/dist/BrowserCredentials.mjs +120 -0
- package/dist/BrowserCredentials.mjs.map +1 -0
- package/dist/BrowserSession-DuOUcC6G.mjs +442 -0
- package/dist/BrowserSession-DuOUcC6G.mjs.map +1 -0
- package/dist/BrowserSession-DxCN-5F9.d.mts +109 -0
- package/dist/BrowserSession.d.mts +3 -0
- package/dist/BrowserSession.mjs +4 -0
- package/dist/CloudflareThreadClient.d.mts +50 -50
- package/dist/{InteractiveBrowser-Cm4xgiGy.d.mts → InteractiveBrowser-BnqY_Y-F.d.mts} +2 -2
- package/dist/{InteractiveBrowser-DhOkdUx9.mjs → InteractiveBrowser-DeOlcu-2.mjs} +190 -50
- package/dist/InteractiveBrowser-DeOlcu-2.mjs.map +1 -0
- package/dist/InteractiveBrowser.d.mts +1 -1
- package/dist/InteractiveBrowser.mjs +1 -1
- package/dist/{ThreadObject-mt0uxvZZ.d.mts → ThreadObject-BTo1jqab.d.mts} +33 -33
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
- package/src/BrowserCredentials.ts +146 -0
- package/src/BrowserSession.ts +589 -0
- package/src/InteractiveBrowser.ts +1 -1
- package/src/index.ts +2 -0
- package/src/internal/browser-binding.ts +245 -57
- package/src/internal/browser-credentials.ts +362 -0
- package/dist/InteractiveBrowser-DhOkdUx9.mjs.map +0 -1
- package/dist/ProtectedBrowser.d.mts +0 -128
- package/dist/ProtectedBrowser.mjs +0 -1201
- package/dist/ProtectedBrowser.mjs.map +0 -1
- package/src/ProtectedBrowser.ts +0 -9
- package/src/protected-browser/binding.ts +0 -366
- package/src/protected-browser/host.ts +0 -382
- package/src/protected-browser/inspect-frame.ts +0 -140
- package/src/protected-browser/native.ts +0 -483
- package/src/protected-browser/policy.ts +0 -872
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { BrowserCredentialAccess, CredentialFillError, CredentialFillResult, FillCredentialRequest } from "./BrowserCredentials.mjs";
|
|
2
|
+
import { A as BrowserRunSessionLifecycle, O as BrowserRunCleanupError, _ as BrowserRunLiveViewRequest, i as BrowserRunHandoffState, k as BrowserRunLifecycleOptions, n as BrowserRunHandoffRequest, r as BrowserRunHandoffResult, v as BrowserRunLiveViewResult } from "./InteractiveBrowser-BnqY_Y-F.mjs";
|
|
3
|
+
import { Cause, Context, Effect, ErrorReporter, Layer, Redacted, Schema, Scope } from "effect";
|
|
4
|
+
import { Browser, Page } from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js";
|
|
5
|
+
//#region src/internal/browser-failure.d.ts
|
|
6
|
+
declare const BrowserRunFailure_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
7
|
+
readonly _tag: "BrowserRunFailure";
|
|
8
|
+
} & Readonly<A>;
|
|
9
|
+
/** Source-authored stages and classifications only; never retain SDK text or session capabilities. */
|
|
10
|
+
declare class BrowserRunFailure extends BrowserRunFailure_base<{
|
|
11
|
+
readonly operation: string;
|
|
12
|
+
readonly reason: "provider" | "timeout" | "malformed" | "configuration" | "authorization" | "rate-limited" | "pending";
|
|
13
|
+
readonly status?: number;
|
|
14
|
+
readonly cause?: BrowserRunFailure | {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
};
|
|
17
|
+
}> {
|
|
18
|
+
readonly [ErrorReporter.severity]: "Error";
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/internal/browser-binding.d.ts
|
|
22
|
+
/** Private attachment ownership is available before asynchronous SDK initialization completes. */
|
|
23
|
+
interface BrowserRunAttachment {
|
|
24
|
+
readonly browser: Promise<Browser>;
|
|
25
|
+
/** Fence SDK dispatch/callbacks and await local socket closure; never terminate the provider. */
|
|
26
|
+
readonly retire: Effect.Effect<void, BrowserRunFailure>;
|
|
27
|
+
}
|
|
28
|
+
declare const BrowserRunBinding_base: Context.ServiceClass<BrowserRunBinding, "@effect-agent/platform-cloudflare/internal/BrowserRunBinding", {
|
|
29
|
+
readonly acquire: (keepAliveMillis: number, operation: "interactive.acquire" | "session.acquire") => Promise<string>;
|
|
30
|
+
readonly connect: (sessionId: string, operation: string, signal?: AbortSignal) => BrowserRunAttachment;
|
|
31
|
+
readonly keepAlive: (sessionId: string) => Effect.Effect<void, BrowserRunFailure>;
|
|
32
|
+
}>;
|
|
33
|
+
/** Native transport port shared by both scoped adapters; the Layer owns the foreign binding. */
|
|
34
|
+
declare class BrowserRunBinding extends BrowserRunBinding_base {
|
|
35
|
+
static layer(browser: Pick<BrowserRun, "fetch">): Layer.Layer<BrowserRunBinding, never, never>;
|
|
36
|
+
}
|
|
37
|
+
declare namespace BrowserSession_d_exports {
|
|
38
|
+
export { BrowserRunHandoffRequest, BrowserRunHandoffResult, BrowserRunHandoffState, BrowserRunLiveViewRequest, BrowserRunLiveViewResult, BrowserSession, BrowserSessionError, BrowserSessionOptions, BrowserSessionReference, BrowserSessions, BrowserSessionsOptions };
|
|
39
|
+
}
|
|
40
|
+
declare const BrowserSessionReference_base: Schema.Class<BrowserSessionReference, Schema.Struct<{
|
|
41
|
+
readonly version: Schema.Literal<1>;
|
|
42
|
+
readonly sessionId: Schema.Redacted<Schema.String>;
|
|
43
|
+
readonly contextId: Schema.Redacted<Schema.NonEmptyString>;
|
|
44
|
+
readonly targetId: Schema.Redacted<Schema.NonEmptyString>;
|
|
45
|
+
readonly expiresAt: Schema.Int;
|
|
46
|
+
readonly commandTimeoutMillis: Schema.Int;
|
|
47
|
+
}>, {}>;
|
|
48
|
+
/** Private host record, not a model capability. Persist together with the owner's controller state. */
|
|
49
|
+
declare class BrowserSessionReference extends BrowserSessionReference_base {}
|
|
50
|
+
declare const BrowserSessionOptions_base: Schema.Class<BrowserSessionOptions, Schema.Struct<{
|
|
51
|
+
readonly maxElapsedMillis: Schema.Int;
|
|
52
|
+
readonly keepAliveMillis: Schema.optionalKey<Schema.Int>;
|
|
53
|
+
readonly commandTimeoutMillis: Schema.optionalKey<Schema.Int>;
|
|
54
|
+
}>, {}>;
|
|
55
|
+
declare class BrowserSessionOptions extends BrowserSessionOptions_base {}
|
|
56
|
+
declare const BrowserSessionError_base: Schema.Class<BrowserSessionError, Schema.TaggedStruct<"BrowserSessionError", {
|
|
57
|
+
readonly reason: Schema.Literals<readonly ["invalid", "expired", "missing-page", "busy", "closed", "provider", "timeout", "cleanup"]>;
|
|
58
|
+
readonly dispatch: Schema.Literals<readonly ["not-dispatched", "possibly-dispatched"]>;
|
|
59
|
+
readonly cleanup: Schema.Literals<readonly ["not-requested", "confirmed", "unconfirmed"]>;
|
|
60
|
+
}>, Cause.YieldableError>;
|
|
61
|
+
/** No SDK text, selectors, page data, or credential values are retained in public failures. */
|
|
62
|
+
declare class BrowserSessionError extends BrowserSessionError_base {}
|
|
63
|
+
/**
|
|
64
|
+
* One local attachment to an application-owned browser. Scope release disconnects; it never
|
|
65
|
+
* transfers ownership or closes a healthy remote session. The owner serializes attachments,
|
|
66
|
+
* fences old attempts, authorizes human access, and calls BrowserSessions.close on expiry/stop.
|
|
67
|
+
* Native callbacks are trusted host code: never retain SDK handles or start unawaited work.
|
|
68
|
+
*/
|
|
69
|
+
interface BrowserSession {
|
|
70
|
+
readonly reference: BrowserSessionReference;
|
|
71
|
+
/**
|
|
72
|
+
* Check current authority under the lock before native dispatch. A settled SDK rejection leaves
|
|
73
|
+
* the session available for inspection, but may have changed the website; never retry blindly.
|
|
74
|
+
* Timeout/interruption fences outstanding SDK work and terminates the exact browser.
|
|
75
|
+
*/
|
|
76
|
+
readonly run: <A, E, R>(authorize: Effect.Effect<void, E, R>, action: (page: Page) => Promise<A>) => Effect.Effect<A, E | BrowserSessionError, R>;
|
|
77
|
+
/**
|
|
78
|
+
* Resolves host-owned material under fresh credential grants. Never submits or retries a write.
|
|
79
|
+
* Credential timeouts retain acknowledged writes and dispatch evidence alongside cleanup.
|
|
80
|
+
*/
|
|
81
|
+
readonly fillCredential: (request: FillCredentialRequest) => Effect.Effect<CredentialFillResult, CredentialFillError | BrowserSessionError, BrowserCredentialAccess>;
|
|
82
|
+
readonly handoff: <E, R>(authorize: Effect.Effect<void, E, R>, request: BrowserRunHandoffRequest) => Effect.Effect<BrowserRunHandoffResult, E | BrowserSessionError, R>;
|
|
83
|
+
readonly getLiveView: <E, R>(authorize: Effect.Effect<void, E, R>, request: BrowserRunLiveViewRequest) => Effect.Effect<BrowserRunLiveViewResult, E | BrowserSessionError, R>;
|
|
84
|
+
readonly getHandoffState: <E, R>(authorize: Effect.Effect<void, E, R>) => Effect.Effect<BrowserRunHandoffState, E | BrowserSessionError, R>;
|
|
85
|
+
}
|
|
86
|
+
interface BrowserSessionsOptions extends BrowserRunLifecycleOptions {
|
|
87
|
+
readonly browser: Pick<BrowserRun, "fetch">;
|
|
88
|
+
}
|
|
89
|
+
declare const BrowserSessions_base: Context.ServiceClass<BrowserSessions, "@effect-agent/platform-cloudflare/BrowserSessions", {
|
|
90
|
+
/**
|
|
91
|
+
* Allocate once and commit its private reference in retain. Failed/uncommitted creation closes
|
|
92
|
+
* the allocation. After retain succeeds the application owns remote cleanup, independent of
|
|
93
|
+
* attempt Scopes. A lost allocation reply can remain indeterminate until provider idle expiry.
|
|
94
|
+
*/
|
|
95
|
+
readonly create: <E, R>(options: BrowserSessionOptions, retain: (reference: BrowserSessionReference) => Effect.Effect<void, E, R>) => Effect.Effect<BrowserSessionReference, E | BrowserSessionError, R>;
|
|
96
|
+
/** Attach only the exact saved context/page. Never recreate missing/expired state. */
|
|
97
|
+
readonly attach: (reference: BrowserSessionReference) => Effect.Effect<BrowserSession, BrowserSessionError, Scope.Scope>;
|
|
98
|
+
/** Refresh provider inactivity only; the owner must still enforce its expiresAt. */
|
|
99
|
+
readonly keepAlive: (sessionId: Redacted.Redacted<string>) => Effect.Effect<void, BrowserSessionError>;
|
|
100
|
+
readonly close: (sessionId: Redacted.Redacted<string>) => Effect.Effect<void, BrowserSessionError>;
|
|
101
|
+
}>;
|
|
102
|
+
/** Native Cloudflare sessions; no framework browser workflow, checkpoint transfer, or observation policy. */
|
|
103
|
+
declare class BrowserSessions extends BrowserSessions_base {
|
|
104
|
+
static readonly layerNoDeps: Layer.Layer<BrowserSessions, never, BrowserRunBinding | BrowserRunSessionLifecycle>;
|
|
105
|
+
static layer(options: BrowserSessionsOptions): Layer.Layer<BrowserSessions, BrowserRunCleanupError, import("effect/unstable/http/HttpClient").HttpClient>;
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { BrowserSession_d_exports as a, BrowserSessionReference as i, BrowserSessionError as n, BrowserSessions as o, BrowserSessionOptions as r, BrowserSessionsOptions as s, BrowserSession as t };
|
|
109
|
+
//# sourceMappingURL=BrowserSession-DxCN-5F9.d.mts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { _ as BrowserRunLiveViewRequest, i as BrowserRunHandoffState, n as BrowserRunHandoffRequest, r as BrowserRunHandoffResult, v as BrowserRunLiveViewResult } from "./InteractiveBrowser-BnqY_Y-F.mjs";
|
|
2
|
+
import { i as BrowserSessionReference, n as BrowserSessionError, o as BrowserSessions, r as BrowserSessionOptions, s as BrowserSessionsOptions, t as BrowserSession } from "./BrowserSession-DxCN-5F9.mjs";
|
|
3
|
+
export { BrowserRunHandoffRequest, BrowserRunHandoffResult, BrowserRunHandoffState, BrowserRunLiveViewRequest, BrowserRunLiveViewResult, BrowserSession, BrowserSessionError, BrowserSessionOptions, BrowserSessionReference, BrowserSessions, BrowserSessionsOptions };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import "./BrowserCredentials.mjs";
|
|
2
|
+
import { c as BrowserRunLiveViewResult, n as BrowserRunHandoffResult, r as BrowserRunHandoffState, s as BrowserRunLiveViewRequest, t as BrowserRunHandoffRequest } from "./InteractiveBrowser-DeOlcu-2.mjs";
|
|
3
|
+
import { a as BrowserSessions, n as BrowserSessionOptions, r as BrowserSessionReference, t as BrowserSessionError } from "./BrowserSession-DuOUcC6G.mjs";
|
|
4
|
+
export { BrowserRunHandoffRequest, BrowserRunHandoffResult, BrowserRunHandoffState, BrowserRunLiveViewRequest, BrowserRunLiveViewResult, BrowserSessionError, BrowserSessionOptions, BrowserSessionReference, BrowserSessions };
|
|
@@ -1545,50 +1545,8 @@ export declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorde
|
|
|
1545
1545
|
readonly message: string;
|
|
1546
1546
|
readonly cause?: Schema.Json | undefined;
|
|
1547
1547
|
} | {
|
|
1548
|
-
readonly _tag: "
|
|
1549
|
-
readonly message: string;
|
|
1550
|
-
} | {
|
|
1551
|
-
readonly _tag: "AgentInputError";
|
|
1552
|
-
readonly message: string;
|
|
1553
|
-
} | {
|
|
1554
|
-
readonly _tag: "DigestError";
|
|
1555
|
-
readonly message: string;
|
|
1556
|
-
readonly cause?: Schema.Json | undefined;
|
|
1557
|
-
} | {
|
|
1558
|
-
readonly _tag: "AdmissionConflict";
|
|
1548
|
+
readonly _tag: "ThreadNotMaterialized";
|
|
1559
1549
|
readonly threadId: string;
|
|
1560
|
-
readonly principal: string;
|
|
1561
|
-
readonly idempotencyKey: string;
|
|
1562
|
-
readonly existingInputDigest: string;
|
|
1563
|
-
readonly attemptedInputDigest: string;
|
|
1564
|
-
} | {
|
|
1565
|
-
readonly _tag: "AdmissionPolicyError";
|
|
1566
|
-
readonly reason: "occupied" | "refused" | "unavailable";
|
|
1567
|
-
readonly code: string;
|
|
1568
|
-
readonly cause?: import("effect-agent/failure-diagnostic").Diagnostic | undefined;
|
|
1569
|
-
readonly stack?: string | undefined;
|
|
1570
|
-
} | {
|
|
1571
|
-
readonly _tag: "SettlementConflict";
|
|
1572
|
-
readonly submissionId: string;
|
|
1573
|
-
readonly existingOutcome: "aborted" | "completed" | "failed";
|
|
1574
|
-
} | {
|
|
1575
|
-
readonly _tag: "ApprovalConflict";
|
|
1576
|
-
readonly submissionId: string;
|
|
1577
|
-
readonly toolCallId: string;
|
|
1578
|
-
readonly existingDecision: "approved" | "denied";
|
|
1579
|
-
} | {
|
|
1580
|
-
readonly _tag: "UnknownResolutionConflict";
|
|
1581
|
-
readonly submissionId: string;
|
|
1582
|
-
readonly toolCallId: string;
|
|
1583
|
-
} | {
|
|
1584
|
-
readonly _tag: "JoinedToHost";
|
|
1585
|
-
readonly submissionId: string;
|
|
1586
|
-
readonly hostSubmissionId: string;
|
|
1587
|
-
} | {
|
|
1588
|
-
readonly _tag: "LedgerError";
|
|
1589
|
-
readonly operation: string;
|
|
1590
|
-
readonly message: string;
|
|
1591
|
-
readonly cause?: import("effect-agent/failure-diagnostic").Diagnostic | undefined;
|
|
1592
1550
|
} | {
|
|
1593
1551
|
readonly _tag: "ThreadStoreError";
|
|
1594
1552
|
readonly operation: string;
|
|
@@ -1602,8 +1560,10 @@ export declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorde
|
|
|
1602
1560
|
readonly sequence?: number | undefined;
|
|
1603
1561
|
} | undefined;
|
|
1604
1562
|
} | {
|
|
1605
|
-
readonly _tag: "
|
|
1606
|
-
readonly
|
|
1563
|
+
readonly _tag: "LedgerError";
|
|
1564
|
+
readonly operation: string;
|
|
1565
|
+
readonly message: string;
|
|
1566
|
+
readonly cause?: import("effect-agent/failure-diagnostic").Diagnostic | undefined;
|
|
1607
1567
|
} | {
|
|
1608
1568
|
readonly _tag: "AppendConflict";
|
|
1609
1569
|
readonly threadId: string;
|
|
@@ -1616,20 +1576,60 @@ export declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorde
|
|
|
1616
1576
|
readonly threadId: string;
|
|
1617
1577
|
readonly actualEpoch: number;
|
|
1618
1578
|
readonly attemptedEpoch: number;
|
|
1579
|
+
} | {
|
|
1580
|
+
readonly _tag: "OperationDenied";
|
|
1581
|
+
readonly operation: "abort" | "awaitSettlement" | "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
|
|
1582
|
+
readonly reason: string;
|
|
1583
|
+
readonly threadId?: string | undefined;
|
|
1584
|
+
readonly submissionId?: string | undefined;
|
|
1585
|
+
} | {
|
|
1586
|
+
readonly _tag: "AdmissionConflict";
|
|
1587
|
+
readonly threadId: string;
|
|
1588
|
+
readonly principal: string;
|
|
1589
|
+
readonly idempotencyKey: string;
|
|
1590
|
+
readonly existingInputDigest: string;
|
|
1591
|
+
readonly attemptedInputDigest: string;
|
|
1592
|
+
} | {
|
|
1593
|
+
readonly _tag: "AdmissionPolicyError";
|
|
1594
|
+
readonly reason: "occupied" | "refused" | "unavailable";
|
|
1595
|
+
readonly code: string;
|
|
1596
|
+
readonly cause?: import("effect-agent/failure-diagnostic").Diagnostic | undefined;
|
|
1597
|
+
readonly stack?: string | undefined;
|
|
1598
|
+
} | {
|
|
1599
|
+
readonly _tag: "AgentInputError";
|
|
1600
|
+
readonly message: string;
|
|
1601
|
+
} | {
|
|
1602
|
+
readonly _tag: "DigestError";
|
|
1603
|
+
readonly message: string;
|
|
1604
|
+
readonly cause?: Schema.Json | undefined;
|
|
1619
1605
|
} | {
|
|
1620
1606
|
readonly _tag: "DurableRuntimeFailpointError";
|
|
1621
1607
|
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-duration-append" | "run:after-start-append" | "run:before-duration-append" | "run:before-start-append" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "subagent:before-join-append" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "tools:after-unavailable-append" | "tools:before-prepared-append" | "tools:before-unavailable-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "update:after-canonical-append" | "update:after-delivery-insert" | "update:before-canonical-append" | "update:before-delivery-insert" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-stop-append" | "worker:after-stop-seal" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-stop-append" | "worker:before-stop-seal" | "worker:before-subtree-append";
|
|
1608
|
+
} | {
|
|
1609
|
+
readonly _tag: "SettlementConflict";
|
|
1610
|
+
readonly submissionId: string;
|
|
1611
|
+
readonly existingOutcome: "aborted" | "completed" | "failed";
|
|
1612
|
+
} | {
|
|
1613
|
+
readonly _tag: "JoinedToHost";
|
|
1614
|
+
readonly submissionId: string;
|
|
1615
|
+
readonly hostSubmissionId: string;
|
|
1622
1616
|
} | {
|
|
1623
1617
|
readonly _tag: "AdmissionLimitExceeded";
|
|
1624
1618
|
readonly limit: "database-bytes" | "input-bytes" | "queue-depth";
|
|
1625
1619
|
readonly actual: number;
|
|
1626
1620
|
readonly maximum: number;
|
|
1627
1621
|
} | {
|
|
1628
|
-
readonly _tag: "
|
|
1629
|
-
readonly
|
|
1630
|
-
|
|
1631
|
-
readonly
|
|
1632
|
-
readonly submissionId
|
|
1622
|
+
readonly _tag: "HostProtocolError";
|
|
1623
|
+
readonly message: string;
|
|
1624
|
+
} | {
|
|
1625
|
+
readonly _tag: "ApprovalConflict";
|
|
1626
|
+
readonly submissionId: string;
|
|
1627
|
+
readonly toolCallId: string;
|
|
1628
|
+
readonly existingDecision: "approved" | "denied";
|
|
1629
|
+
} | {
|
|
1630
|
+
readonly _tag: "UnknownResolutionConflict";
|
|
1631
|
+
readonly submissionId: string;
|
|
1632
|
+
readonly toolCallId: string;
|
|
1633
1633
|
};
|
|
1634
1634
|
}, Schema.SchemaError, never>;
|
|
1635
1635
|
export declare const decodeHostResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AbortRecorded | ApprovalRecorded | HostFailed | ObservedPage | ProgressCancelled | ProgressObserved | SettlementReached | SubmissionStatusResponse | SubmitSucceeded | UnknownResolutionRecorded, Schema.SchemaError, never>;
|
|
@@ -224,5 +224,5 @@ declare const CloudflareInteractiveBrowser: {
|
|
|
224
224
|
hostLayer: (options: CloudflareInteractiveBrowserOptions) => Layer.Layer<BrowserRunInteractiveHost, BrowserRunCleanupError | InteractiveBrowserPolicyDeniedError, import("effect/unstable/http/HttpClient").HttpClient>;
|
|
225
225
|
};
|
|
226
226
|
//#endregion
|
|
227
|
-
export { CloudflareInteractiveBrowserOptions as C, isBrowserRunUndispatchedActionError as D, browserRunInteractiveLayer as E, BrowserRunCleanupError as O, CloudflareInteractiveBrowser as S, browserRunInteractiveImplementation as T, BrowserRunLiveViewRequest as _, BrowserRunInputState as a, BrowserRunPageObservation as b, BrowserRunInteractiveBrowser as c, BrowserRunInteractiveContext as d, BrowserRunInteractiveHost as f, BrowserRunInteractiveSession as g, BrowserRunInteractiveRequestListener as h, BrowserRunHandoffState as i,
|
|
228
|
-
//# sourceMappingURL=InteractiveBrowser-
|
|
227
|
+
export { BrowserRunSessionLifecycle as A, CloudflareInteractiveBrowserOptions as C, isBrowserRunUndispatchedActionError as D, browserRunInteractiveLayer as E, BrowserRunCleanupError as O, CloudflareInteractiveBrowser as S, browserRunInteractiveImplementation as T, BrowserRunLiveViewRequest as _, BrowserRunInputState as a, BrowserRunPageObservation as b, BrowserRunInteractiveBrowser as c, BrowserRunInteractiveContext as d, BrowserRunInteractiveHost as f, BrowserRunInteractiveSession as g, BrowserRunInteractiveRequestListener as h, BrowserRunHandoffState as i, BrowserRunLifecycleOptions as k, BrowserRunInteractiveCdpSession as l, BrowserRunInteractiveRequest as m, BrowserRunHandoffRequest as n, BrowserRunInteractiveAcquisition as o, BrowserRunInteractivePage as p, BrowserRunHandoffResult as r, BrowserRunInteractiveBinding as s, BrowserRunCloudflareCommand as t, BrowserRunInteractiveCheckpoint as u, BrowserRunLiveViewResult as v, browserRunInteractiveHostLayer as w, BrowserRunViewport as x, BrowserRunPageIdentity as y };
|
|
228
|
+
//# sourceMappingURL=InteractiveBrowser-BnqY_Y-F.d.mts.map
|
|
@@ -11,7 +11,6 @@ var BrowserRunFailure = class extends Data.TaggedError("BrowserRunFailure") {
|
|
|
11
11
|
};
|
|
12
12
|
/** A public projection of an already reported private failure must not produce another issue. */
|
|
13
13
|
const reportedBrowserError = (error) => Object.assign(error, { [ErrorReporter.ignore]: true });
|
|
14
|
-
const inheritBrowserReport = (original, error) => ErrorReporter.isIgnored(original) ? reportedBrowserError(error) : error;
|
|
15
14
|
const reasonSchema = Schema.Literals([
|
|
16
15
|
"provider",
|
|
17
16
|
"timeout",
|
|
@@ -49,9 +48,41 @@ const reportBrowserCause = (operation, cause) => ErrorReporter.report(Cause.from
|
|
|
49
48
|
//#endregion
|
|
50
49
|
//#region src/internal/browser-binding.ts
|
|
51
50
|
const Acquired = Schema.Struct({ sessionId: Schema.String.check(Schema.isUUID()) });
|
|
51
|
+
const VersionReply = Schema.fromJsonString(Schema.Struct({
|
|
52
|
+
id: Schema.optionalKey(Schema.Int),
|
|
53
|
+
result: Schema.optionalKey(Schema.Unknown),
|
|
54
|
+
error: Schema.optionalKey(Schema.Unknown)
|
|
55
|
+
}));
|
|
56
|
+
const Version = Schema.Struct({
|
|
57
|
+
product: Schema.NonEmptyString,
|
|
58
|
+
protocolVersion: Schema.NonEmptyString
|
|
59
|
+
});
|
|
52
60
|
/** Native transport port shared by both scoped adapters; the Layer owns the foreign binding. */
|
|
53
61
|
var BrowserRunBinding = class extends Context.Service()("@effect-agent/platform-cloudflare/internal/BrowserRunBinding") {
|
|
54
62
|
static layer(browser) {
|
|
63
|
+
const upgrade = async (sessionId, operation, signal) => {
|
|
64
|
+
const response = await browser.fetch(`https://browser-rendering.cloudflare.com/v1/devtools/browser/${sessionId}`, {
|
|
65
|
+
headers: { Upgrade: "websocket" },
|
|
66
|
+
...signal === void 0 ? {} : { signal }
|
|
67
|
+
});
|
|
68
|
+
if (response.status !== 101) {
|
|
69
|
+
const failure = new BrowserRunFailure({
|
|
70
|
+
operation,
|
|
71
|
+
reason: "provider",
|
|
72
|
+
status: response.status
|
|
73
|
+
});
|
|
74
|
+
try {
|
|
75
|
+
await response.body?.cancel();
|
|
76
|
+
} catch {}
|
|
77
|
+
throw failure;
|
|
78
|
+
}
|
|
79
|
+
const socket = response.webSocket;
|
|
80
|
+
if (socket === null) throw new BrowserRunFailure({
|
|
81
|
+
operation,
|
|
82
|
+
reason: "malformed"
|
|
83
|
+
});
|
|
84
|
+
return socket;
|
|
85
|
+
};
|
|
55
86
|
return Layer.succeed(this)({
|
|
56
87
|
acquire: async (keepAliveMillis, operation) => {
|
|
57
88
|
const response = await browser.fetch(`https://browser-rendering.cloudflare.com/v1/devtools/browser?keep_alive=${keepAliveMillis}&recording=false`, { method: "POST" });
|
|
@@ -68,62 +99,171 @@ var BrowserRunBinding = class extends Context.Service()("@effect-agent/platform-
|
|
|
68
99
|
}
|
|
69
100
|
return Schema.decodeUnknownSync(Acquired)(await response.json()).sessionId;
|
|
70
101
|
},
|
|
71
|
-
connect:
|
|
102
|
+
connect: (sessionId, operation, signal) => {
|
|
72
103
|
let socket;
|
|
104
|
+
let retired = false;
|
|
73
105
|
let closedByAbort = false;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (response.status !== 101) {
|
|
80
|
-
const failure = new BrowserRunFailure({
|
|
106
|
+
let retirementFailure;
|
|
107
|
+
const disconnectOperation = operation === "session.connect" ? "session.disconnect" : "interactive.disconnect";
|
|
108
|
+
const transport = {
|
|
109
|
+
send: (message) => {
|
|
110
|
+
if (retired || socket === void 0) throw new BrowserRunFailure({
|
|
81
111
|
operation,
|
|
82
|
-
reason: "provider"
|
|
83
|
-
status: response.status
|
|
112
|
+
reason: "provider"
|
|
84
113
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
114
|
+
socket.send(message);
|
|
115
|
+
},
|
|
116
|
+
close: () => retireNow()
|
|
117
|
+
};
|
|
118
|
+
const onMessage = (event) => {
|
|
119
|
+
if (!retired) transport.onmessage?.(event.data);
|
|
120
|
+
};
|
|
121
|
+
const fence = () => {
|
|
122
|
+
if (retired) return;
|
|
123
|
+
retired = true;
|
|
124
|
+
const notify = transport.onclose;
|
|
125
|
+
transport.onmessage = void 0;
|
|
126
|
+
transport.onclose = void 0;
|
|
127
|
+
try {
|
|
128
|
+
notify?.();
|
|
129
|
+
} finally {
|
|
130
|
+
socket?.removeEventListener("message", onMessage);
|
|
89
131
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
132
|
+
};
|
|
133
|
+
const retireNow = () => {
|
|
134
|
+
try {
|
|
135
|
+
fence();
|
|
136
|
+
} catch (cause) {
|
|
137
|
+
retirementFailure ??= browserFailure(disconnectOperation, cause);
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
if (socket !== void 0 && socket.readyState < WebSocket.CLOSING) socket.close();
|
|
141
|
+
} catch (cause) {
|
|
142
|
+
retirementFailure ??= browserFailure(disconnectOperation, cause);
|
|
143
|
+
}
|
|
144
|
+
if (retirementFailure !== void 0) throw retirementFailure;
|
|
145
|
+
};
|
|
146
|
+
const abort = () => {
|
|
147
|
+
closedByAbort = socket?.readyState === WebSocket.OPEN;
|
|
148
|
+
try {
|
|
149
|
+
retireNow();
|
|
150
|
+
} catch {}
|
|
151
|
+
};
|
|
152
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
153
|
+
return {
|
|
154
|
+
browser: (async () => {
|
|
155
|
+
try {
|
|
156
|
+
signal?.throwIfAborted();
|
|
157
|
+
socket = await upgrade(sessionId, operation, signal);
|
|
158
|
+
socket.accept();
|
|
159
|
+
if (retired || signal?.aborted) {
|
|
160
|
+
retireNow();
|
|
161
|
+
signal?.throwIfAborted();
|
|
162
|
+
throw new BrowserRunFailure({
|
|
163
|
+
operation,
|
|
164
|
+
reason: "provider"
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
socket.addEventListener("message", onMessage);
|
|
168
|
+
socket.addEventListener("close", () => {
|
|
169
|
+
try {
|
|
170
|
+
fence();
|
|
171
|
+
} catch (cause) {
|
|
172
|
+
retirementFailure ??= browserFailure(disconnectOperation, cause);
|
|
173
|
+
}
|
|
174
|
+
}, { once: true });
|
|
175
|
+
return await puppeteer.connect({ transport });
|
|
176
|
+
} catch (cause) {
|
|
177
|
+
try {
|
|
178
|
+
retireNow();
|
|
179
|
+
} catch {}
|
|
180
|
+
const failure = browserFailure(operation, cause);
|
|
181
|
+
throw cause instanceof Error && signal?.aborted === true && (cause === signal.reason || closedByAbort && cause.name === "TargetCloseError") ? reportedBrowserError(failure) : failure;
|
|
182
|
+
} finally {
|
|
183
|
+
signal?.removeEventListener("abort", abort);
|
|
184
|
+
}
|
|
185
|
+
})(),
|
|
186
|
+
retire: Effect.callback((resume) => {
|
|
187
|
+
const connected = socket;
|
|
188
|
+
const onClose = () => resume(Effect.void);
|
|
189
|
+
try {
|
|
190
|
+
retireNow();
|
|
191
|
+
if (connected === void 0 || connected.readyState === WebSocket.CLOSED) resume(Effect.void);
|
|
192
|
+
else connected.addEventListener("close", onClose, { once: true });
|
|
193
|
+
} catch (cause) {
|
|
194
|
+
resume(Effect.fail(browserFailure(disconnectOperation, cause)));
|
|
195
|
+
}
|
|
196
|
+
return Effect.sync(() => connected?.removeEventListener("close", onClose));
|
|
197
|
+
})
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
keepAlive: Effect.fnUntraced(function* (sessionId) {
|
|
201
|
+
const operation = "session.keepAlive";
|
|
202
|
+
const runReport = Effect.runPromiseWith(yield* Effect.context());
|
|
203
|
+
const release = (socket) => Effect.sync(() => socket.close()).pipe(Effect.catchCause((cause) => reportBrowserCause(operation, cause)));
|
|
204
|
+
const socket = yield* Effect.acquireRelease(Effect.tryPromise({
|
|
205
|
+
try: async (signal) => {
|
|
206
|
+
let acquired;
|
|
207
|
+
try {
|
|
208
|
+
acquired = await upgrade(sessionId, operation, signal);
|
|
209
|
+
acquired.accept();
|
|
210
|
+
signal.throwIfAborted();
|
|
211
|
+
return acquired;
|
|
212
|
+
} catch (cause) {
|
|
213
|
+
if (acquired !== void 0) await runReport(release(acquired));
|
|
214
|
+
if (signal.aborted && cause !== signal.reason) await runReport(reportBrowserCause(operation, Cause.fail(cause)));
|
|
215
|
+
throw cause;
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
catch: (cause) => browserFailure(operation, cause)
|
|
219
|
+
}), release, { interruptible: true });
|
|
220
|
+
yield* Effect.callback((resume) => {
|
|
221
|
+
const finish = (result) => {
|
|
222
|
+
removeListeners();
|
|
223
|
+
resume(result);
|
|
99
224
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const abort = () => {
|
|
225
|
+
const fail = (reason) => finish(Effect.fail(new BrowserRunFailure({
|
|
226
|
+
operation,
|
|
227
|
+
reason
|
|
228
|
+
})));
|
|
229
|
+
const onMessage = (event) => {
|
|
106
230
|
try {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
231
|
+
if (typeof event.data !== "string" || event.data.length > 16384) {
|
|
232
|
+
fail("malformed");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const reply = Schema.decodeSync(VersionReply)(event.data);
|
|
236
|
+
if (reply.id !== 1) return;
|
|
237
|
+
if (reply.error !== void 0) {
|
|
238
|
+
fail("provider");
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
Schema.decodeUnknownSync(Version)(reply.result);
|
|
242
|
+
finish(Effect.void);
|
|
243
|
+
} catch {
|
|
244
|
+
fail("malformed");
|
|
245
|
+
}
|
|
111
246
|
};
|
|
112
|
-
|
|
247
|
+
const onClose = () => fail("provider");
|
|
248
|
+
const removeListeners = () => {
|
|
249
|
+
socket.removeEventListener("message", onMessage);
|
|
250
|
+
socket.removeEventListener("close", onClose);
|
|
251
|
+
socket.removeEventListener("error", onClose);
|
|
252
|
+
};
|
|
253
|
+
socket.addEventListener("message", onMessage);
|
|
254
|
+
socket.addEventListener("close", onClose);
|
|
255
|
+
socket.addEventListener("error", onClose);
|
|
113
256
|
try {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
257
|
+
socket.send(JSON.stringify({
|
|
258
|
+
id: 1,
|
|
259
|
+
method: "Browser.getVersion"
|
|
260
|
+
}));
|
|
261
|
+
} catch (cause) {
|
|
262
|
+
finish(Effect.fail(browserFailure(operation, cause)));
|
|
118
263
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} catch {}
|
|
123
|
-
const failure = browserFailure(operation, cause);
|
|
124
|
-
throw cause instanceof Error && signal?.aborted === true && (cause === signal.reason || closedByAbort && cause.name === "TargetCloseError") ? reportedBrowserError(failure) : failure;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
264
|
+
return Effect.sync(removeListeners);
|
|
265
|
+
});
|
|
266
|
+
}, Effect.scoped)
|
|
127
267
|
});
|
|
128
268
|
}
|
|
129
269
|
};
|
|
@@ -443,7 +583,7 @@ var BrowserRunInteractiveBinding = class BrowserRunInteractiveBinding extends Co
|
|
|
443
583
|
const viewport = options.viewport === void 0 ? void 0 : yield* decodeViewport(options.viewport);
|
|
444
584
|
return {
|
|
445
585
|
acquire: async (keepAliveMillis) => binding.acquire(keepAliveMillis, "interactive.acquire"),
|
|
446
|
-
connect: async (sessionId, signal) => makeProductionBrowser(await binding.connect(sessionId, "interactive.connect", signal), sessionId, viewport),
|
|
586
|
+
connect: async (sessionId, signal) => makeProductionBrowser(await binding.connect(sessionId, "interactive.connect", signal).browser, sessionId, viewport),
|
|
447
587
|
closeSession: (sessionId) => lifecycle.close(sessionId).pipe(Effect.mapError((cause) => actionError("close", cause)))
|
|
448
588
|
};
|
|
449
589
|
})).pipe(Layer.provide(BrowserRunBinding.layer(options.browser)));
|
|
@@ -1775,6 +1915,6 @@ const CloudflareInteractiveBrowser = {
|
|
|
1775
1915
|
hostLayer: (options) => browserRunInteractiveHostLayer().pipe(Layer.provide(interactiveBindingLayer(options)))
|
|
1776
1916
|
};
|
|
1777
1917
|
//#endregion
|
|
1778
|
-
export {
|
|
1918
|
+
export { BrowserRunCleanupError as _, BrowserRunInteractiveCheckpoint as a, reportBrowserCause as b, BrowserRunLiveViewResult as c, BrowserRunViewport as d, CloudflareInteractiveBrowser as f, isBrowserRunUndispatchedActionError as g, browserRunInteractiveLayer as h, BrowserRunInteractiveBinding as i, BrowserRunPageIdentity as l, browserRunInteractiveImplementation as m, BrowserRunHandoffResult as n, BrowserRunInteractiveHost as o, browserRunInteractiveHostLayer as p, BrowserRunHandoffState as r, BrowserRunLiveViewRequest as s, BrowserRunHandoffRequest as t, BrowserRunPageObservation as u, BrowserRunSessionLifecycle as v, reportedBrowserError as x, BrowserRunBinding as y };
|
|
1779
1919
|
|
|
1780
|
-
//# sourceMappingURL=InteractiveBrowser-
|
|
1920
|
+
//# sourceMappingURL=InteractiveBrowser-DeOlcu-2.mjs.map
|