@ref0/sdk 0.0.0-stage → 0.5.0

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,29 @@
1
+ import { t as Browser } from "./browse-DBqoeS-u.mjs";
2
+ import { BrowserContext, BrowserContext as BrowserContext$1, BrowserContextOptions, Locator, Page, Page as Page$1, Request, Response } from "@cloudflare/playwright";
3
+ import { expect as expect$1 } from "@cloudflare/playwright/test";
4
+ //#region src/browser-stub.d.ts
5
+ declare module '@ref0/sdk/browser' {
6
+ /**
7
+ * ref0's `Browser`, as `sb.browse` hands it to a check: Playwright's, pinned, connected through
8
+ * the browse's `BrowserLink`, with ref0's hooks on every context before it's handed out. It's a
9
+ * convenience, not a boundary: whoever holds the link drives the whole session, so ref0's host
10
+ * and Browser Run hold what the browser reaches.
11
+ *
12
+ * One limit they don't hold: the page has UDP egress through WebRTC. Browser Run's guardrails
13
+ * cover only HTTP, HTTPS and WebSocket. ref0 takes WebRTC's constructors from every frame and
14
+ * popup, and reports a frame that reaches for one, but that's a guard against accidents, not a
15
+ * wall, so a check's verdict mustn't depend on what the page can or can't reach over UDP.
16
+ */
17
+ interface Browser {
18
+ /** A context whose user agent names the browser's real Chrome version, unless one is set. */
19
+ readonly newContext: (options?: BrowserContextOptions) => Promise<BrowserContext$1>;
20
+ /** A page in a context of its own, closed with it. */
21
+ readonly newPage: (options?: BrowserContextOptions) => Promise<Page$1>;
22
+ readonly contexts: () => Promise<ReadonlyArray<BrowserContext$1>>;
23
+ }
24
+ }
25
+ /** Playwright's `expect`, which runs only in ref0's browser module: here, each part throws. */
26
+ export declare const expect: typeof expect$1;
27
+ //#endregion
28
+ export type { Browser, BrowserContext, Locator, Page, Request, Response };
29
+ //# sourceMappingURL=browser.d.mts.map
@@ -0,0 +1,28 @@
1
+ //#region src/browser-stub.ts
2
+ const unavailable = () => {
3
+ throw new Error("expect runs only on ref0, which loads its own @ref0/sdk/browser beside a check that imports it");
4
+ };
5
+ const asymmetric = {
6
+ any: unavailable,
7
+ anything: unavailable,
8
+ arrayContaining: unavailable,
9
+ arrayOf: unavailable,
10
+ closeTo: unavailable,
11
+ objectContaining: unavailable,
12
+ stringContaining: unavailable,
13
+ stringMatching: unavailable
14
+ };
15
+ /** Playwright's `expect`, which runs only in ref0's browser module: here, each part throws. */
16
+ const expect = Object.assign(() => unavailable(), {
17
+ ...asymmetric,
18
+ soft: unavailable,
19
+ poll: unavailable,
20
+ extend: unavailable,
21
+ configure: unavailable,
22
+ getState: unavailable,
23
+ not: asymmetric
24
+ });
25
+ //#endregion
26
+ export { expect };
27
+
28
+ //# sourceMappingURL=browser.mjs.map
@@ -0,0 +1,94 @@
1
+ import { $ as OwnerThreadView, A as ConnectionView, At as SignedIn, Bn as liveSocketUrl, Bt as TypedApprovalCode, C as ConnectChosen, D as ConnectionChanged, Dt as SentryRegion, Et as SentryOrg, F as EndpointName, Fn as connectEndpoint, Ft as ThreadId, G as LiveTrackName, H as ImportFailure, Hn as repoNameKey, Ht as Welcome, In as encodeSecret, It as ThreadStage, J as MirrorEntry, K as MachineConnected, Ln as hookTokenPrefix, Lt as TrackClosed, M as ConsentClient, N as ConsentProject, Nn as WrittenProject, O as ConnectionKind, Ot as SentryToken, P as CredentialView, Pn as commandLine, Pt as StatementView, Q as OwnerThreadPage, Rn as hookUrl, Rt as TrackSession, S as ConnectAgent, Tt as SecretHash, U as LiveTicket, Un as surfaceOf, V as Harness, Vn as projectParts, W as LiveTicketRequest, X as OwnerId, Y as MirrorView, Z as OwnerName, a as Api, b as ClientAccess, c as ApprovalPreview, ct as PreviewUnavailable, d as AttachmentFailed, dt as RanOf, et as OwnerTrackMessage, f as AttachmentRequestView, ft as ReadEvent, gt as RepoView, ht as RepoUrl, i as AgentView, j as ConsentAsked, jt as SocketUrl, k as ConnectionName, kt as SignInDestination, l as ApprovalState, lt as ProjectName, mt as RepoName, n as AgentPermissionChoice, nt as PasskeyCreated, o as ApiOrigin, ot as PasskeyRequestOptions, p as Authorization, q as MirrorChoice, r as AgentPermissionSetting, rt as PasskeyCreationOptions, s as ApprovalId, st as PreviewEcho, t as AgentHandle, tt as PasskeyAsserted, u as ApprovalView, ut as ProjectTrackMessage, w as ConnectableAgent, wn as WorkflowPreview, wt as ScopeAction, x as ClientGranted, zn as isRef0Path, zt as TrackThread } from "./index-Dns8tCkT.mjs";
2
+ import { Effect, Layer, Option, Redacted, Schema, Stream } from "effect";
3
+ import { HttpApi, HttpApiClient, HttpApiGroup, HttpApiMiddleware } from "effect/http-api";
4
+ import { HttpBody, HttpClient } from "effect/http";
5
+ //#region src/client/client.d.ts
6
+ type ApiGroups = typeof Api extends HttpApi.HttpApi<infer _Id, infer Groups> ? Groups : never;
7
+ /** The typed client for ref0's `/v1`, named because its full shape is too long to infer. */
8
+ type Ref0Client = HttpApiClient.ForApi<typeof Api>;
9
+ /**
10
+ * ref0's `/v1` as a typed client: every endpoint of the contracts' `Api`, its request encoded
11
+ * and its answer and errors decoded as they're declared. It needs an HTTP client and the
12
+ * credential it sends, a bearer token or a browser session.
13
+ */
14
+ export declare const ref0Client: (origin?: ApiOrigin) => Effect.Effect<Ref0Client, never, HttpClient.HttpClient | HttpApiGroup.MiddlewareClient<ApiGroups>>;
15
+ /** A bearer token: an agent's credential, sent with every request. */
16
+ export declare const bearerCredential: (token: Redacted.Redacted<string>) => Layer.Layer<HttpApiMiddleware.ForClient<Authorization> | HttpApiMiddleware.ForClient<SignedIn>, never, never>;
17
+ /** A browser session: the browser sends its cookie on ref0's own origin, so nothing is added. */
18
+ export declare const browserCredential: Layer.Layer<HttpApiMiddleware.ForClient<Authorization> | HttpApiMiddleware.ForClient<SignedIn>, never, never>;
19
+ /** No credential: a terminal asking its person, which sends nothing of theirs. */
20
+ export declare const anonymousCredential: Layer.Layer<HttpApiMiddleware.ForClient<Authorization> | HttpApiMiddleware.ForClient<SignedIn>, never, never>;
21
+ /** The platform's `fetch`, for a client in a browser or a Worker. */
22
+ export declare const fetchTransport: Layer.Layer<HttpClient.HttpClient, never, never>;
23
+ //#endregion
24
+ //#region src/client/approvals.d.ts
25
+ /**
26
+ * Following an approval until its command has run. Once its person says yes, ref0 runs the
27
+ * command as soon as it can, and again after a passing failure, so a yes can come back
28
+ * `approved`, or not come back at all, before the command has run. Whoever asked reads where it
29
+ * stands until it settles: run, refused, expired, or gone, which ref0 answers for a request that
30
+ * isn't the caller's or whose result's day is out. A read that fails or takes too long is read
31
+ * again, so following never stops on its own while the command may still run.
32
+ */
33
+ /**
34
+ * Where an approval settles, for whoever asked, its command's endpoint named: what it ran to,
35
+ * read as that endpoint's answer or refusal; `unreadable`, one that isn't, such as another
36
+ * endpoint's; refused; expired; or gone.
37
+ */
38
+ type SettledApproval<Name extends EndpointName> = {
39
+ readonly state: 'ran';
40
+ readonly status: number;
41
+ readonly result: RanOf<Name>;
42
+ } | {
43
+ readonly state: 'unreadable';
44
+ } | {
45
+ readonly state: 'refused';
46
+ } | {
47
+ readonly state: 'expired';
48
+ } | {
49
+ readonly state: 'gone';
50
+ };
51
+ /**
52
+ * Where an approval stands, as whoever asked for its endpoint's command reads it, if it has
53
+ * settled: what it ran to is read by that endpoint's schemas, so it's typed by them.
54
+ */
55
+ export declare const settledOf: <Name extends EndpointName>(endpoint: Name, state: ApprovalState) => Option.Option<SettledApproval<Name>>;
56
+ /** Where an approval for an endpoint's command settles, read again and again until it has. */
57
+ export declare const followApproval: <Name extends EndpointName>(client: Ref0Client, approval: ApprovalId, endpoint: Name) => Effect.Effect<SettledApproval<Name>>;
58
+ //#endregion
59
+ //#region src/client/live.d.ts
60
+ /**
61
+ * A live socket, as a page or the CLI hears it: the messages its track carries, decoded at the
62
+ * edge, as they come, until it closes. Opened with a one-use ticket, so the URL holds no token;
63
+ * anything on it that isn't one of the track's messages is dropped.
64
+ */
65
+ /** What a socket opened at `url` hears, as `message` decodes it, ending when it closes. */
66
+ export declare const liveMessages: <M>(url: SocketUrl, message: Schema.Codec<M, unknown>) => Stream.Stream<M>;
67
+ //#endregion
68
+ //#region src/client/request-id.d.ts
69
+ /**
70
+ * A new delivery ID, for a request that changes something's `Idempotency-Key`: a UUIDv7 from the
71
+ * clock and ten random bytes, so a retry sends the same one and gets the first answer.
72
+ */
73
+ export declare const newRequestId: Effect.Effect<`request_${string}` & import("effect/Brand").Brand<"RequestId">, never, never>;
74
+ //#endregion
75
+ //#region src/client/sign-in.d.ts
76
+ /**
77
+ * Starts signing in with GitHub, from ref0's own pages: GitHub's address to go to, with the
78
+ * sign-in's state in a cookie the browser keeps. Coming back, the person lands on `welcome`, or
79
+ * on `failed` with what went wrong in its `error`.
80
+ */
81
+ export declare const startGitHubSignIn: (landing: {
82
+ readonly welcome: SignInDestination;
83
+ readonly failed: SignInDestination;
84
+ readonly origin?: ApiOrigin;
85
+ }) => Effect.Effect<string & import("effect/Brand").Brand<"NavigationUrl">, HttpBody.HttpBodyError | import("effect/http/HttpClientError").HttpClientError | Schema.SchemaError, HttpClient.HttpClient>;
86
+ /**
87
+ * Signs this browser out: its session's credential revoked first, then its row, then its
88
+ * cookie cleared. Anything but success, such as ref0 not answering, is a failure to show: the
89
+ * session still works until it's done.
90
+ */
91
+ export declare const signOut: (origin?: ApiOrigin) => Effect.Effect<void, import("effect/http/HttpClientError").HttpClientError, HttpClient.HttpClient>;
92
+ //#endregion
93
+ export { AgentHandle, type AgentPermissionChoice, type AgentPermissionSetting, type AgentView, ApiOrigin, type ApprovalId, type ApprovalPreview, type ApprovalState, type ApprovalView, AttachmentFailed, type AttachmentRequestView, ClientAccess, ClientGranted, type ConnectAgent, type ConnectChosen, type ConnectableAgent, ConnectionChanged, ConnectionKind, ConnectionName, type ConnectionView, type ConsentAsked, type ConsentClient, ConsentProject, type CredentialView, type Harness, type ImportFailure, type LiveTicket, type LiveTicketRequest, LiveTrackName, MachineConnected, type MirrorChoice, type MirrorEntry, type MirrorView, type OwnerId, OwnerName, type OwnerThreadPage, type OwnerThreadView, OwnerTrackMessage, PasskeyAsserted, PasskeyCreated, type PasskeyCreationOptions, type PasskeyRequestOptions, type PreviewEcho, PreviewUnavailable, ProjectName, ProjectTrackMessage, type ReadEvent, type Ref0Client, RepoName, RepoUrl, type RepoView, type ScopeAction, SecretHash, SentryOrg, SentryRegion, SentryToken, type SettledApproval, SignInDestination, type StatementView, ThreadId, ThreadStage, type TrackClosed, type TrackSession, type TrackThread, TypedApprovalCode, type Welcome, WorkflowPreview, WrittenProject, commandLine, connectEndpoint, encodeSecret, hookTokenPrefix, hookUrl, isRef0Path, liveSocketUrl, projectParts, repoNameKey, surfaceOf };
94
+ //# sourceMappingURL=client.d.mts.map