@inbrowser/driver 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.
Files changed (39) hide show
  1. package/AGENTS.md +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +112 -2
  4. package/THIRD_PARTY_NOTICES.txt +216 -0
  5. package/dist/LICENSE +21 -0
  6. package/dist/THIRD_PARTY_NOTICES.txt +216 -0
  7. package/dist/index.js +1631 -0
  8. package/dist/index.js.map +7 -0
  9. package/dist/preload.iife.js +5 -0
  10. package/dist/preload.js +2 -0
  11. package/dist/puppeteer.js +2569 -0
  12. package/dist/puppeteer.js.map +7 -0
  13. package/dist/tools.js +1283 -0
  14. package/dist/tools.js.map +7 -0
  15. package/dist/types/host/capture-seam.d.ts +17 -0
  16. package/dist/types/host/preview-backend.d.ts +9 -0
  17. package/dist/types/host/sandbox-connect.d.ts +38 -0
  18. package/dist/types/host/viewport-capture.d.ts +2 -0
  19. package/dist/types/index.d.ts +5 -0
  20. package/dist/types/preload/act.d.ts +4 -0
  21. package/dist/types/preload/capture-seam.d.ts +1 -0
  22. package/dist/types/preload/cursor-overlay.d.ts +5 -0
  23. package/dist/types/preload/diagnostics.d.ts +13 -0
  24. package/dist/types/preload/diff.d.ts +3 -0
  25. package/dist/types/preload/entry.d.ts +1 -0
  26. package/dist/types/preload/eval.d.ts +7 -0
  27. package/dist/types/preload/export.d.ts +11 -0
  28. package/dist/types/preload/intrinsics.d.ts +255 -0
  29. package/dist/types/preload/observe.d.ts +27 -0
  30. package/dist/types/preload/ref-registry.d.ts +44 -0
  31. package/dist/types/preload/silent-capture.d.ts +3 -0
  32. package/dist/types/protocol.d.ts +103 -0
  33. package/dist/types/puppeteer/cdp-driver.d.ts +11 -0
  34. package/dist/types/puppeteer/index.d.ts +2 -0
  35. package/dist/types/tools/format.d.ts +7 -0
  36. package/dist/types/tools/index.d.ts +9 -0
  37. package/dist/types/tools/schemas.d.ts +36 -0
  38. package/dist/types/types.d.ts +268 -0
  39. package/package.json +70 -4
@@ -0,0 +1,255 @@
1
+ /**
2
+ * Saved browser and JavaScript intrinsics captured synchronously before guest scripts execute.
3
+ *
4
+ * Reused across `entry.ts`, `diagnostics.ts`, `ref-registry.ts`, `observe.ts`, `diff.ts`, `act.ts`, and `eval.ts`.
5
+ * Guards browser constructors via `globalThis` so preload modules remain importable in Node unit tests.
6
+ */
7
+ export declare const reflectApply: typeof Reflect.apply;
8
+ export declare const reflectGet: typeof Reflect.get;
9
+ export declare const reflectSet: typeof Reflect.set;
10
+ export declare const reflectHas: typeof Reflect.has;
11
+ export declare const reflectDefineProperty: typeof Reflect.defineProperty;
12
+ export declare const HostWeakRef: WeakRefConstructor;
13
+ export declare const HostWeakMap: WeakMapConstructor;
14
+ export declare const HostWeakSet: WeakSetConstructor;
15
+ export declare const HostMap: MapConstructor;
16
+ export declare const HostSet: SetConstructor;
17
+ export declare function wordSet(words: string): Set<string>;
18
+ export declare function pairRecord(pairs: string): Record<string, string>;
19
+ type AnyCtor<T> = abstract new (...args: never[]) => T;
20
+ export declare function is<T>(value: unknown, ctor: AnyCtor<T> | undefined): value is T;
21
+ export declare const win: (Window & typeof globalThis) | undefined;
22
+ export declare const doc: Document | undefined;
23
+ export declare const HostMessageEvent: {
24
+ new <T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>;
25
+ prototype: MessageEvent;
26
+ } | undefined;
27
+ export declare const HostErrorEvent: {
28
+ new (type: string, eventInitDict?: ErrorEventInit): ErrorEvent;
29
+ prototype: ErrorEvent;
30
+ } | undefined;
31
+ export declare const HostPromiseRejectionEvent: {
32
+ new (type: string, eventInitDict: PromiseRejectionEventInit): PromiseRejectionEvent;
33
+ prototype: PromiseRejectionEvent;
34
+ } | undefined;
35
+ export declare const HostMutationObserver: {
36
+ new (callback: MutationCallback): MutationObserver;
37
+ prototype: MutationObserver;
38
+ } | undefined;
39
+ export declare const HostEvent: {
40
+ new (type: string, eventInitDict?: EventInit): Event;
41
+ prototype: Event;
42
+ readonly NONE: 0;
43
+ readonly CAPTURING_PHASE: 1;
44
+ readonly AT_TARGET: 2;
45
+ readonly BUBBLING_PHASE: 3;
46
+ } | undefined;
47
+ export declare const HostMouseEvent: {
48
+ new (type: string, eventInitDict?: MouseEventInit): MouseEvent;
49
+ prototype: MouseEvent;
50
+ } | undefined;
51
+ export declare const HostPointerEvent: {
52
+ new (type: string, eventInitDict?: PointerEventInit): PointerEvent;
53
+ prototype: PointerEvent;
54
+ } | undefined;
55
+ export declare const HostKeyboardEvent: {
56
+ new (type: string, eventInitDict?: KeyboardEventInit): KeyboardEvent;
57
+ prototype: KeyboardEvent;
58
+ readonly DOM_KEY_LOCATION_STANDARD: 0;
59
+ readonly DOM_KEY_LOCATION_LEFT: 1;
60
+ readonly DOM_KEY_LOCATION_RIGHT: 2;
61
+ readonly DOM_KEY_LOCATION_NUMPAD: 3;
62
+ } | undefined;
63
+ export declare const HostInputEvent: {
64
+ new (type: string, eventInitDict?: InputEventInit): InputEvent;
65
+ prototype: InputEvent;
66
+ } | undefined;
67
+ export declare const NodeCtor: {
68
+ new (): Node;
69
+ prototype: Node;
70
+ readonly ELEMENT_NODE: 1;
71
+ readonly ATTRIBUTE_NODE: 2;
72
+ readonly TEXT_NODE: 3;
73
+ readonly CDATA_SECTION_NODE: 4;
74
+ readonly ENTITY_REFERENCE_NODE: 5;
75
+ readonly ENTITY_NODE: 6;
76
+ readonly PROCESSING_INSTRUCTION_NODE: 7;
77
+ readonly COMMENT_NODE: 8;
78
+ readonly DOCUMENT_NODE: 9;
79
+ readonly DOCUMENT_TYPE_NODE: 10;
80
+ readonly DOCUMENT_FRAGMENT_NODE: 11;
81
+ readonly NOTATION_NODE: 12;
82
+ readonly DOCUMENT_POSITION_DISCONNECTED: 1;
83
+ readonly DOCUMENT_POSITION_PRECEDING: 2;
84
+ readonly DOCUMENT_POSITION_FOLLOWING: 4;
85
+ readonly DOCUMENT_POSITION_CONTAINS: 8;
86
+ readonly DOCUMENT_POSITION_CONTAINED_BY: 16;
87
+ readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32;
88
+ } | undefined;
89
+ export declare const El: {
90
+ new (): Element;
91
+ prototype: Element;
92
+ } | undefined;
93
+ export declare const HtmlEl: {
94
+ new (): HTMLElement;
95
+ prototype: HTMLElement;
96
+ } | undefined;
97
+ export declare const ShadowEl: {
98
+ new (): ShadowRoot;
99
+ prototype: ShadowRoot;
100
+ } | undefined;
101
+ export declare const DocEl: {
102
+ new (): Document;
103
+ prototype: Document;
104
+ parseHTMLUnsafe(html: string): Document;
105
+ } | undefined;
106
+ export declare const SlotEl: {
107
+ new (): HTMLSlotElement;
108
+ prototype: HTMLSlotElement;
109
+ } | undefined;
110
+ export declare const InputEl: {
111
+ new (): HTMLInputElement;
112
+ prototype: HTMLInputElement;
113
+ } | undefined;
114
+ export declare const TextAreaEl: {
115
+ new (): HTMLTextAreaElement;
116
+ prototype: HTMLTextAreaElement;
117
+ } | undefined;
118
+ export declare const SelectEl: {
119
+ new (): HTMLSelectElement;
120
+ prototype: HTMLSelectElement;
121
+ } | undefined;
122
+ export declare const OptionEl: {
123
+ new (): HTMLOptionElement;
124
+ prototype: HTMLOptionElement;
125
+ } | undefined;
126
+ export declare const FormEl: {
127
+ new (): HTMLFormElement;
128
+ prototype: HTMLFormElement;
129
+ } | undefined;
130
+ export declare const LabelEl: {
131
+ new (): HTMLLabelElement;
132
+ prototype: HTMLLabelElement;
133
+ } | undefined;
134
+ export declare const ButtonEl: {
135
+ new (): HTMLButtonElement;
136
+ prototype: HTMLButtonElement;
137
+ } | undefined;
138
+ export declare const AnchorEl: {
139
+ new (): HTMLAnchorElement;
140
+ prototype: HTMLAnchorElement;
141
+ } | undefined;
142
+ export declare const DialogEl: {
143
+ new (): HTMLDialogElement;
144
+ prototype: HTMLDialogElement;
145
+ } | undefined;
146
+ export declare const MediaEl: {
147
+ new (): HTMLMediaElement;
148
+ prototype: HTMLMediaElement;
149
+ readonly NETWORK_EMPTY: 0;
150
+ readonly NETWORK_IDLE: 1;
151
+ readonly NETWORK_LOADING: 2;
152
+ readonly NETWORK_NO_SOURCE: 3;
153
+ readonly HAVE_NOTHING: 0;
154
+ readonly HAVE_METADATA: 1;
155
+ readonly HAVE_CURRENT_DATA: 2;
156
+ readonly HAVE_FUTURE_DATA: 3;
157
+ readonly HAVE_ENOUGH_DATA: 4;
158
+ } | undefined;
159
+ export declare const VideoEl: {
160
+ new (): HTMLVideoElement;
161
+ prototype: HTMLVideoElement;
162
+ } | undefined;
163
+ export declare const CanvasEl: {
164
+ new (): HTMLCanvasElement;
165
+ prototype: HTMLCanvasElement;
166
+ } | undefined;
167
+ export declare const Ctx2dEl: {
168
+ new (): CanvasRenderingContext2D;
169
+ prototype: CanvasRenderingContext2D;
170
+ } | undefined;
171
+ export declare const HostImage: (new (width?: number, height?: number) => HTMLImageElement) | undefined;
172
+ export declare const HostXMLSerializer: {
173
+ new (): XMLSerializer;
174
+ prototype: XMLSerializer;
175
+ } | undefined;
176
+ export declare const UrlCtor: {
177
+ new (url: string | URL, base?: string | URL): URL;
178
+ prototype: URL;
179
+ canParse(url: string | URL, base?: string | URL): boolean;
180
+ createObjectURL(obj: Blob | MediaSource): string;
181
+ parse(url: string | URL, base?: string | URL): URL | null;
182
+ revokeObjectURL(url: string): void;
183
+ } | undefined;
184
+ export declare const ReqCtor: {
185
+ new (input: RequestInfo | URL, init?: RequestInit): Request;
186
+ prototype: Request;
187
+ } | undefined;
188
+ export declare const XhrCtor: {
189
+ new (): XMLHttpRequest;
190
+ prototype: XMLHttpRequest;
191
+ readonly UNSENT: 0;
192
+ readonly OPENED: 1;
193
+ readonly HEADERS_RECEIVED: 2;
194
+ readonly LOADING: 3;
195
+ readonly DONE: 4;
196
+ } | undefined;
197
+ export declare const FunctionCtor: FunctionConstructor;
198
+ export declare const origSetTimeout: (fn: () => void, ms: number) => ReturnType<typeof setTimeout>;
199
+ export declare const origClearTimeout: (id: ReturnType<typeof setTimeout>) => void;
200
+ export declare const origRequestAnimationFrame: (cb: FrameRequestCallback) => number | null;
201
+ export declare const nowMs: () => number;
202
+ export declare const isTrustedEvent: (ev: Event) => boolean;
203
+ export declare const onEvent: (self: EventTarget, args_0: string, args_1: EventListenerOrEventListenerObject, args_2?: boolean | AddEventListenerOptions | undefined) => void;
204
+ export declare const offEvent: (self: EventTarget, args_0: string, args_1: EventListenerOrEventListenerObject, args_2?: boolean | EventListenerOptions | undefined) => void;
205
+ export declare const targetDispatchEvent: (self: EventTarget, args_0: Event) => boolean;
206
+ export declare const getComputedStyleSafe: (el: Element) => CSSStyleDeclaration | null;
207
+ export declare const portPostMessage: (self: MessagePort, args_0: unknown) => void;
208
+ export declare const portStart: (self: MessagePort) => void;
209
+ export declare const portClose: (self: MessagePort) => void;
210
+ export declare const getBoundingClientRect: (self: Element) => DOMRect;
211
+ export declare const getOpenShadowRoot: (self: Element) => ShadowRoot | null;
212
+ export declare const attachOpenShadow: (el: Element) => ShadowRoot | null;
213
+ export declare const elementFromPointSafe: (root: Document | ShadowRoot, x: number, y: number) => Element | null;
214
+ export declare const scrollIntoViewSafe: (el: Element) => void;
215
+ export declare const focusElement: (el: HTMLElement) => void;
216
+ export declare const clickElement: (self: HTMLElement) => void;
217
+ export declare const submitFormSafe: (form: HTMLFormElement) => void;
218
+ export declare const setAttr: (self: Element, args_0: string, args_1: string) => void;
219
+ export declare const cloneNode: (self: Node, args_0?: boolean | undefined) => Node;
220
+ export declare const querySelectorSafe: (root: ParentNode, selector: string) => Element | null;
221
+ declare const getInputValue: (self: HTMLInputElement) => string, setInputValue: (self: HTMLInputElement, value: string) => void;
222
+ declare const setTextAreaValue: (self: HTMLTextAreaElement, value: string) => void;
223
+ declare const setSelectValue: (self: HTMLSelectElement, value: string) => void;
224
+ export { getInputValue, setInputValue, setSelectValue, setTextAreaValue };
225
+ export declare const setOptionSelected: (self: HTMLOptionElement, value: boolean) => void;
226
+ export declare const formControlValue: (el: Element) => string | null;
227
+ export declare const setMediaCurrentTime: (self: HTMLMediaElement, value: number) => void;
228
+ export declare const origCanvasGetContext: {
229
+ (contextId: "2d", options?: CanvasRenderingContext2DSettings): CanvasRenderingContext2D | null;
230
+ (contextId: "bitmaprenderer", options?: ImageBitmapRenderingContextSettings): ImageBitmapRenderingContext | null;
231
+ (contextId: "webgl", options?: WebGLContextAttributes): WebGLRenderingContext | null;
232
+ (contextId: "webgl2", options?: WebGLContextAttributes): WebGL2RenderingContext | null;
233
+ (contextId: string, options?: any): RenderingContext | null;
234
+ } | undefined;
235
+ export declare const origCanvasTransferOffscreen: (() => OffscreenCanvas) | undefined;
236
+ export declare const origConsoleError: {
237
+ (...data: any[]): void;
238
+ (message?: any, ...optionalParams: any[]): void;
239
+ } | undefined;
240
+ export declare const origFetch: (((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) & typeof fetch) | undefined;
241
+ export declare const origXhrOpen: {
242
+ (method: string, url: string | URL): void;
243
+ (method: string, url: string | URL, async: boolean, username?: string | null, password?: string | null): void;
244
+ } | undefined;
245
+ export declare const origXhrSend: ((body?: Document | XMLHttpRequestBodyInit | null) => void) | undefined;
246
+ export declare const origAlert: (((message?: any) => void) & typeof alert) | undefined;
247
+ export declare const origConfirm: (((message?: string) => boolean) & typeof confirm) | undefined;
248
+ export declare const origPrompt: (((message?: string, _default?: string) => string | null) & typeof prompt) | undefined;
249
+ export declare const DRIVER_UI_ATTRIBUTE = "data-inbrowser-driver-ui";
250
+ export declare const normSpace: (value: string) => string;
251
+ export declare const tag: (el: Element) => string;
252
+ export declare const rawAttr: (self: Element, args_0: string) => string | null;
253
+ export declare const attr: (el: Element, name: string) => string;
254
+ export declare const has: (self: Element, args_0: string) => boolean;
255
+ export declare function getComposedChildNodes(node: Node): readonly Node[];
@@ -0,0 +1,27 @@
1
+ import type { ObserveRpcParams } from '../protocol.js';
2
+ import { type ObservationSnapshot } from '../types.js';
3
+ import { DRIVER_UI_ATTRIBUTE, getComposedChildNodes, normSpace } from './intrinsics.js';
4
+ import { type SemanticCandidateItem } from './ref-registry.js';
5
+ export { DRIVER_UI_ATTRIBUTE, getComposedChildNodes, normSpace as normalizeWhitespace };
6
+ export declare const LANDMARK_ROLES: ReadonlySet<string>;
7
+ export declare const INTERACTIVE_ROLES: ReadonlySet<string>;
8
+ export declare function installCanvasContextTracker(): void;
9
+ export declare function getComposedParentElement(node: Node): Element | null;
10
+ export declare function isComposedDescendant(ancestor: Node, candidate: Node): boolean;
11
+ export declare function isElementObservableInScope(el: Element, scopeRoot: ParentNode): boolean;
12
+ export declare function findComposedAncestor(el: Element | null, pred: (candidate: Element) => boolean, includeSelf?: boolean): Element | null;
13
+ export declare function isElementHidden(el: Element, includeAriaHidden?: boolean): boolean;
14
+ export declare function isElementDisabled(el: Element): boolean;
15
+ export declare const readDriverId: (el: Element) => string;
16
+ export declare function computeElementRole(el: Element): string | null;
17
+ export declare function computeAccessibleName(el: Element, role: string, visited?: Set<Element>): string;
18
+ export declare function shouldAssignRef(el: Element, role: string): boolean;
19
+ export interface LiveDomCandidate extends SemanticCandidateItem<Element> {
20
+ readonly text: string;
21
+ }
22
+ /**
23
+ * Side-effect-free live composed DOM query for `resolveTarget` (does not advance `rev` or drain diagnostics).
24
+ */
25
+ export declare function scanLiveDom(scopeRoot: ParentNode, withText: boolean): readonly LiveDomCandidate[];
26
+ export declare function getLastFullSnapshot(): ObservationSnapshot | null;
27
+ export declare function observeDocument(params?: ObserveRpcParams, passive?: boolean): ObservationSnapshot;
@@ -0,0 +1,44 @@
1
+ import { type DriverErrorCode, type RefId, type SemanticFingerprint, type SnapshotRevision, type TargetSpec } from '../types.js';
2
+ export interface SemanticCandidateItem<T = Element> {
3
+ readonly target: T;
4
+ readonly fingerprint: SemanticFingerprint;
5
+ }
6
+ export type FingerprintMatchOutcome<C> = {
7
+ readonly status: 'matched';
8
+ readonly candidate: C;
9
+ } | {
10
+ readonly status: 'ambiguous';
11
+ readonly candidates: readonly SemanticFingerprint[];
12
+ } | {
13
+ readonly status: 'not_found';
14
+ readonly candidates: readonly SemanticFingerprint[];
15
+ };
16
+ export declare function failDriver(code: DriverErrorCode, msg: string, candidates?: readonly SemanticFingerprint[]): never;
17
+ export declare function failNotFound(msg: string, c?: readonly SemanticFingerprint[]): never;
18
+ export declare function failAmbiguous(msg: string, c: readonly SemanticFingerprint[]): never;
19
+ export declare function rankNearestCandidates<T>(candidates: readonly SemanticCandidateItem<T>[], q: {
20
+ readonly role: string;
21
+ readonly name: string;
22
+ readonly landmark?: string;
23
+ readonly driverId?: string;
24
+ readonly nth?: number;
25
+ }, limit?: number): readonly SemanticFingerprint[];
26
+ export declare function matchStoredFingerprint<C extends SemanticCandidateItem<unknown>>(stored: {
27
+ readonly fingerprint: SemanticFingerprint;
28
+ readonly cohortSize: number;
29
+ }, candidates: readonly C[]): FingerprintMatchOutcome<C>;
30
+ export declare function isRefId(value: string): value is RefId;
31
+ type StoredRefTuple = [
32
+ weakEl: WeakRef<Element>,
33
+ fingerprint: SemanticFingerprint,
34
+ cohortSize: number,
35
+ lastSeenRev: SnapshotRevision
36
+ ];
37
+ export declare const currentRevision: () => SnapshotRevision;
38
+ export declare const syncMinRevision: (minRev: SnapshotRevision) => void;
39
+ export declare const nextRevision: () => SnapshotRevision;
40
+ export declare const getRefEntry: (ref: RefId) => StoredRefTuple | undefined;
41
+ export declare function assignRef(el: Element, fp: SemanticFingerprint, cohortSize: number, rev: SnapshotRevision): RefId;
42
+ export declare function failMiss(msg: string, root: ParentNode, role?: string, name?: string, pool?: readonly SemanticCandidateItem<unknown>[], driverId?: string): never;
43
+ export declare function resolveTarget(spec: TargetSpec, scopeRoot?: ParentNode): Element;
44
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { CaptureRpcParams } from '../protocol.js';
2
+ import type { CaptureResult } from '../types.js';
3
+ export declare function captureInPreload(params: CaptureRpcParams): Promise<CaptureResult>;
@@ -0,0 +1,103 @@
1
+ import type { ActOptions, ActResult, CaptureResult, DiagnosticsDelta, DriverCapabilities, DriverErrorCode, EvalOptions, EvalResult, ObservationOptions, ObservationSnapshot, ScreenshotCaptureOptions, SemanticFingerprint, StartRecordingCaptureOptions, StopRecordingCaptureOptions } from './types.js';
2
+ export declare const DRIVER_CHANNEL: "@inbrowser/driver:v1";
3
+ export declare const PROTOCOL_VERSION: 1;
4
+ export interface DriverBindPortMessage {
5
+ readonly channel: typeof DRIVER_CHANNEL;
6
+ readonly kind: 'bind_port';
7
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
8
+ }
9
+ export interface DriverHelloMessage {
10
+ readonly channel: typeof DRIVER_CHANNEL;
11
+ readonly kind: 'hello';
12
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
13
+ readonly allowEval: boolean;
14
+ readonly sessionId?: string;
15
+ readonly rebindOnlyIfUnbound?: boolean;
16
+ readonly minRev?: number;
17
+ }
18
+ export interface DriverHelloAckMessage {
19
+ readonly channel: typeof DRIVER_CHANNEL;
20
+ readonly kind: 'hello_ack';
21
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
22
+ readonly capabilities: DriverCapabilities;
23
+ }
24
+ export interface DriverNavigatingMessage {
25
+ readonly channel: typeof DRIVER_CHANNEL;
26
+ readonly kind: 'navigating';
27
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
28
+ readonly id: number;
29
+ readonly fromRev: number;
30
+ readonly completedSteps: number;
31
+ readonly totalSteps: number;
32
+ readonly diagnostics: DiagnosticsDelta;
33
+ }
34
+ export type ObserveRpcParams = Omit<ObservationOptions, 'signal'>;
35
+ export type ActRpcParams = Omit<ActOptions, 'signal'>;
36
+ export type CaptureRpcParams = Omit<ScreenshotCaptureOptions, 'signal'> | Omit<StartRecordingCaptureOptions, 'signal'> | Omit<StopRecordingCaptureOptions, 'signal'>;
37
+ export type EvalRpcParams = Omit<EvalOptions, 'signal'>;
38
+ export type DriverRpcMethod = 'observe' | 'act' | 'capture' | 'eval';
39
+ export type DriverRpcRequest = {
40
+ readonly channel: typeof DRIVER_CHANNEL;
41
+ readonly kind: 'rpc_request';
42
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
43
+ readonly id: number;
44
+ readonly method: 'observe';
45
+ readonly params?: ObserveRpcParams;
46
+ } | {
47
+ readonly channel: typeof DRIVER_CHANNEL;
48
+ readonly kind: 'rpc_request';
49
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
50
+ readonly id: number;
51
+ readonly method: 'act';
52
+ readonly params: ActRpcParams;
53
+ } | {
54
+ readonly channel: typeof DRIVER_CHANNEL;
55
+ readonly kind: 'rpc_request';
56
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
57
+ readonly id: number;
58
+ readonly method: 'capture';
59
+ readonly params: CaptureRpcParams;
60
+ } | {
61
+ readonly channel: typeof DRIVER_CHANNEL;
62
+ readonly kind: 'rpc_request';
63
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
64
+ readonly id: number;
65
+ readonly method: 'eval';
66
+ readonly params: EvalRpcParams;
67
+ };
68
+ export interface SerializedDriverError {
69
+ readonly code: DriverErrorCode;
70
+ readonly message: string;
71
+ readonly candidates?: readonly SemanticFingerprint[];
72
+ }
73
+ export interface DriverRpcSuccessResponse<R = unknown> {
74
+ readonly channel: typeof DRIVER_CHANNEL;
75
+ readonly kind: 'rpc_response';
76
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
77
+ readonly id: number;
78
+ readonly ok: true;
79
+ readonly result: R;
80
+ }
81
+ export interface DriverRpcErrorResponse {
82
+ readonly channel: typeof DRIVER_CHANNEL;
83
+ readonly kind: 'rpc_response';
84
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
85
+ readonly id: number;
86
+ readonly ok: false;
87
+ readonly error: SerializedDriverError;
88
+ }
89
+ export type DriverRpcResponse<R = unknown> = DriverRpcSuccessResponse<R> | DriverRpcErrorResponse;
90
+ export declare const isRecord: (v: unknown) => v is Record<string, unknown>;
91
+ export declare const isPosSafeInt: (v: unknown) => v is number;
92
+ export declare function isVersionedEnvelope(v: unknown, kind: string): v is Record<string, unknown>;
93
+ export declare function isDriverChannelEnvelope(value: unknown): boolean;
94
+ export declare function isDriverBindPort(value: unknown): value is DriverBindPortMessage;
95
+ export declare function isDriverHello(value: unknown): value is DriverHelloMessage;
96
+ export declare function isDriverHelloAck(value: unknown): value is DriverHelloAckMessage;
97
+ export declare function isDriverRpcRequest(value: unknown): value is DriverRpcRequest;
98
+ export declare function isDriverRpcResponse(value: unknown): value is DriverRpcResponse;
99
+ export declare function isDriverNavigating(value: unknown): value is DriverNavigatingMessage;
100
+ export declare function isObservationSnapshot(value: unknown): value is ObservationSnapshot;
101
+ export declare function isActResult(value: unknown): value is ActResult;
102
+ export declare function isCaptureResult(value: unknown): value is CaptureResult;
103
+ export declare function isEvalResult(value: unknown): value is EvalResult;
@@ -0,0 +1,11 @@
1
+ import { type ConnectionTransport } from 'puppeteer-core';
2
+ import { type PageDriver } from '../types.js';
3
+ export interface PuppeteerDriverOptions {
4
+ readonly browserWSEndpoint?: string;
5
+ readonly transport?: ConnectionTransport;
6
+ readonly targetUrl?: string;
7
+ readonly allowEval?: boolean;
8
+ readonly timeoutMs?: number;
9
+ readonly signal?: AbortSignal;
10
+ }
11
+ export declare function connectPuppeteerDriver(options: PuppeteerDriverOptions): Promise<PageDriver>;
@@ -0,0 +1,2 @@
1
+ export type { ConnectionTransport } from 'puppeteer-core';
2
+ export { connectPuppeteerDriver, type PuppeteerDriverOptions } from './cdp-driver.js';
@@ -0,0 +1,7 @@
1
+ import { type ActResult, type CaptureResult, type EvalResult, type ObservationSnapshot } from '../types.js';
2
+ export declare function formatValidationErrorYaml(message: string): string;
3
+ export declare function formatToolErrorYaml(err: unknown): string;
4
+ export declare function formatObservationYaml(snapshot: ObservationSnapshot, maxChars?: number): string;
5
+ export declare function formatActResultYaml(result: ActResult, maxChars?: number): string;
6
+ export declare function formatCaptureResultYaml(result: CaptureResult): string;
7
+ export declare function formatEvalResultYaml(result: EvalResult, maxChars?: number): string;
@@ -0,0 +1,9 @@
1
+ import { type DriverTool, type PageDriver } from '../types.js';
2
+ import { formatActResultYaml, formatCaptureResultYaml, formatEvalResultYaml, formatObservationYaml } from './format.js';
3
+ import { UI_ACT_SCHEMA, UI_CAPTURE_SCHEMA, UI_EVAL_SCHEMA, UI_OBSERVE_SCHEMA, type UiActInput, type UiCaptureInput, type UiEvalInput, type UiObserveInput } from './schemas.js';
4
+ export { formatActResultYaml, formatCaptureResultYaml, formatEvalResultYaml, formatObservationYaml, UI_ACT_SCHEMA, UI_CAPTURE_SCHEMA, UI_EVAL_SCHEMA, UI_OBSERVE_SCHEMA, type UiActInput, type UiCaptureInput, type UiEvalInput, type UiObserveInput, };
5
+ export interface CreateDriverToolsOptions {
6
+ readonly allowEval?: boolean;
7
+ readonly maxYamlChars?: number;
8
+ }
9
+ export declare function createDriverTools(driver: PageDriver, options?: CreateDriverToolsOptions): DriverTool[];
@@ -0,0 +1,36 @@
1
+ import type { CaptureOptions, DriverJsonSchema, DriverStep, SnapshotRevision, TargetSpec } from '../types.js';
2
+ export interface UiObserveInput {
3
+ readonly scope?: string;
4
+ readonly includeAllText?: boolean;
5
+ }
6
+ export interface UiActInput {
7
+ readonly rev: SnapshotRevision;
8
+ readonly steps: readonly DriverStep[];
9
+ readonly timeoutMs?: number;
10
+ }
11
+ export interface UiCaptureInput {
12
+ readonly mode: 'screenshot' | 'start_recording' | 'stop_recording';
13
+ readonly target?: TargetSpec;
14
+ readonly format?: 'webp' | 'png';
15
+ readonly quality?: number;
16
+ }
17
+ export interface UiEvalInput {
18
+ readonly expression: string;
19
+ readonly timeoutMs?: number;
20
+ }
21
+ export type ParseArgsResult<T> = {
22
+ readonly ok: true;
23
+ readonly value: T;
24
+ } | {
25
+ readonly ok: false;
26
+ readonly error: string;
27
+ };
28
+ export declare const UI_OBSERVE_SCHEMA: DriverJsonSchema;
29
+ export declare const UI_ACT_SCHEMA: DriverJsonSchema;
30
+ export declare const UI_CAPTURE_SCHEMA: DriverJsonSchema;
31
+ export declare const UI_EVAL_SCHEMA: DriverJsonSchema;
32
+ export declare function parseTargetSpec(raw: unknown, pathLabel: string): ParseArgsResult<TargetSpec>;
33
+ export declare function parseUiObserveArgs(raw: unknown): ParseArgsResult<UiObserveInput>;
34
+ export declare function parseUiActArgs(raw: unknown): ParseArgsResult<UiActInput>;
35
+ export declare function parseUiCaptureArgs(raw: unknown): ParseArgsResult<Omit<CaptureOptions, 'signal'>>;
36
+ export declare function parseUiEvalArgs(raw: unknown): ParseArgsResult<UiEvalInput>;