browser-pilot 0.0.16 → 0.0.18

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 (34) hide show
  1. package/README.md +39 -0
  2. package/dist/actions.cjs +797 -69
  3. package/dist/actions.d.cts +101 -4
  4. package/dist/actions.d.ts +101 -4
  5. package/dist/actions.mjs +17 -1
  6. package/dist/{browser-ZCR6AA4D.mjs → browser-GHQRYU4R.mjs} +2 -2
  7. package/dist/browser.cjs +1366 -72
  8. package/dist/browser.d.cts +230 -6
  9. package/dist/browser.d.ts +230 -6
  10. package/dist/browser.mjs +37 -5
  11. package/dist/{chunk-EZNZ72VA.mjs → chunk-ASEIFKKV.mjs} +126 -0
  12. package/dist/{chunk-TJ5B56NV.mjs → chunk-FSB25GRR.mjs} +129 -1
  13. package/dist/chunk-MIJ7UIKB.mjs +96 -0
  14. package/dist/{chunk-6GBYX7C2.mjs → chunk-MRY3HRFJ.mjs} +799 -353
  15. package/dist/chunk-OIHU7OFY.mjs +91 -0
  16. package/dist/{chunk-NNEHWWHL.mjs → chunk-SW52ALBD.mjs} +588 -5
  17. package/dist/{chunk-V3VLBQAM.mjs → chunk-ZDODXEBD.mjs} +586 -69
  18. package/dist/cli.mjs +784 -176
  19. package/dist/combobox-RAKBA2BW.mjs +6 -0
  20. package/dist/index.cjs +1669 -71
  21. package/dist/index.d.cts +58 -7
  22. package/dist/index.d.ts +58 -7
  23. package/dist/index.mjs +192 -3
  24. package/dist/{page-IUUTJ3SW.mjs → page-SD64DY3F.mjs} +1 -1
  25. package/dist/providers.cjs +127 -0
  26. package/dist/providers.d.cts +38 -3
  27. package/dist/providers.d.ts +38 -3
  28. package/dist/providers.mjs +3 -1
  29. package/dist/{types-BzM-IfsL.d.ts → types-B_v62K7C.d.ts} +146 -2
  30. package/dist/{types-DeVSWhXj.d.cts → types-D2pJQpWs.d.cts} +7 -1
  31. package/dist/{types-DeVSWhXj.d.ts → types-D2pJQpWs.d.ts} +7 -1
  32. package/dist/{types-BflRmiDz.d.cts → types-Yuybzq53.d.cts} +146 -2
  33. package/dist/upload-E6MCC2OF.mjs +6 -0
  34. package/package.json +10 -3
@@ -1,5 +1,40 @@
1
- import { P as Provider, C as CreateSessionOptions, a as ProviderSession, b as ConnectOptions } from './types-DeVSWhXj.js';
2
- export { B as BrowserEndpointResolutionError, d as ChromeChannel, e as ChromeUserDataDirOptions, D as DiscoverLocalBrowsersOptions, i as ProxyConfig, R as ResolvedBrowserEndpoint, g as ResolvedBrowserSource, c as buildLocalBrowserScanTargets, f as discoverLocalBrowsers, p as parseDevToolsActivePortFile, r as resolveBrowserEndpoint, h as resolveChromeUserDataDirs } from './types-DeVSWhXj.js';
1
+ import { P as Provider, C as CreateSessionOptions, a as ProviderSession, b as ConnectOptions } from './types-D2pJQpWs.js';
2
+ export { B as BrowserEndpointResolutionError, d as ChromeChannel, e as ChromeUserDataDirOptions, D as DiscoverLocalBrowsersOptions, i as ProxyConfig, R as ResolvedBrowserEndpoint, g as ResolvedBrowserSource, c as buildLocalBrowserScanTargets, f as discoverLocalBrowsers, p as parseDevToolsActivePortFile, r as resolveBrowserEndpoint, h as resolveChromeUserDataDirs } from './types-D2pJQpWs.js';
3
+
4
+ /**
5
+ * Browser Use provider implementation
6
+ * https://browser-use.com/
7
+ */
8
+
9
+ interface BrowserUseOptions {
10
+ apiKey: string;
11
+ baseUrl?: string;
12
+ proxyCountryCode?: string | null;
13
+ profileId?: string;
14
+ timeout?: number;
15
+ allowResizing?: boolean;
16
+ customProxy?: {
17
+ host: string;
18
+ port: number;
19
+ username?: string;
20
+ password?: string;
21
+ };
22
+ }
23
+ declare class BrowserUseProvider implements Provider {
24
+ readonly name = "browser-use";
25
+ private readonly apiKey;
26
+ private readonly baseUrl;
27
+ private readonly proxyCountryCode;
28
+ private readonly profileId?;
29
+ private readonly timeout?;
30
+ private readonly allowResizing?;
31
+ private readonly customProxy?;
32
+ constructor(options: BrowserUseOptions);
33
+ createSession(options?: CreateSessionOptions): Promise<ProviderSession>;
34
+ resumeSession(sessionId: string): Promise<ProviderSession>;
35
+ private toProviderSession;
36
+ private throwApiError;
37
+ }
3
38
 
4
39
  /**
5
40
  * BrowserBase provider implementation
@@ -83,4 +118,4 @@ declare function getBrowserWebSocketUrl(host?: string): Promise<string>;
83
118
  */
84
119
  declare function createProvider(options: ConnectOptions): Provider;
85
120
 
86
- export { type BrowserBaseOptions, BrowserBaseProvider, type BrowserlessOptions, BrowserlessProvider, ConnectOptions, CreateSessionOptions, GenericProvider, type GenericProviderOptions, Provider, ProviderSession, createProvider, discoverTargets, getBrowserWebSocketUrl };
121
+ export { type BrowserBaseOptions, BrowserBaseProvider, type BrowserUseOptions, BrowserUseProvider, type BrowserlessOptions, BrowserlessProvider, ConnectOptions, CreateSessionOptions, GenericProvider, type GenericProviderOptions, Provider, ProviderSession, createProvider, discoverTargets, getBrowserWebSocketUrl };
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  BrowserBaseProvider,
3
3
  BrowserEndpointResolutionError,
4
+ BrowserUseProvider,
4
5
  BrowserlessProvider,
5
6
  GenericProvider,
6
7
  buildLocalBrowserScanTargets,
@@ -11,12 +12,13 @@ import {
11
12
  parseDevToolsActivePortFile,
12
13
  resolveBrowserEndpoint,
13
14
  resolveChromeUserDataDirs
14
- } from "./chunk-EZNZ72VA.mjs";
15
+ } from "./chunk-ASEIFKKV.mjs";
15
16
  import "./chunk-BVZALQT4.mjs";
16
17
  import "./chunk-JXAUPHZM.mjs";
17
18
  export {
18
19
  BrowserBaseProvider,
19
20
  BrowserEndpointResolutionError,
21
+ BrowserUseProvider,
20
22
  BrowserlessProvider,
21
23
  GenericProvider,
22
24
  buildLocalBrowserScanTargets,
@@ -718,6 +718,88 @@ interface ClearCookiesOptions {
718
718
  domain?: string;
719
719
  }
720
720
 
721
+ /**
722
+ * Delta extraction — compares page state before/after actions
723
+ */
724
+
725
+ interface PageState {
726
+ url: string;
727
+ title: string;
728
+ headings: string[];
729
+ formFields: Array<{
730
+ label?: string;
731
+ name?: string;
732
+ id?: string;
733
+ value: unknown;
734
+ type: string;
735
+ }>;
736
+ buttons: Array<{
737
+ text: string;
738
+ disabled: boolean;
739
+ ref?: string;
740
+ }>;
741
+ alerts: string[];
742
+ visibleText: string;
743
+ }
744
+ interface DeltaChange {
745
+ kind: 'url' | 'title' | 'heading_added' | 'heading_removed' | 'field_changed' | 'button_changed' | 'alert_added' | 'alert_removed' | 'text_changed';
746
+ before?: string;
747
+ after?: string;
748
+ detail?: string;
749
+ }
750
+ interface DeltaResult {
751
+ changes: DeltaChange[];
752
+ before: PageState;
753
+ after: PageState;
754
+ hasChanges: boolean;
755
+ }
756
+ /**
757
+ * Extract a lightweight page state from snapshot + forms data.
758
+ * Used for delta comparison.
759
+ */
760
+ declare function extractPageState(url: string, title: string, snapshot: PageSnapshot, forms: FormField[], pageText: string): PageState;
761
+ /**
762
+ * Compute delta between two page states
763
+ */
764
+ declare function computeDelta(before: PageState, after: PageState): DeltaResult;
765
+
766
+ /**
767
+ * Review surface extraction — structured business state from current page
768
+ */
769
+
770
+ interface KeyValuePair {
771
+ key: string;
772
+ value: string;
773
+ }
774
+ interface SummaryCard {
775
+ heading?: string;
776
+ items: KeyValuePair[];
777
+ }
778
+ interface TableData {
779
+ headers: string[];
780
+ rows: string[][];
781
+ }
782
+ interface ReviewResult {
783
+ url: string;
784
+ title: string;
785
+ headings: string[];
786
+ forms: Array<{
787
+ label?: string;
788
+ value: unknown;
789
+ type: string;
790
+ disabled: boolean;
791
+ }>;
792
+ alerts: string[];
793
+ summaryCards: SummaryCard[];
794
+ tables: TableData[];
795
+ keyValues: KeyValuePair[];
796
+ statusLabels: string[];
797
+ }
798
+ /**
799
+ * Extract review surface from page state
800
+ */
801
+ declare function extractReview(url: string, title: string, snapshot: PageSnapshot, forms: FormField[], pageText: string): ReviewResult;
802
+
721
803
  /**
722
804
  * Page class - provides high-level browser automation API
723
805
  */
@@ -970,6 +1052,22 @@ declare class Page {
970
1052
  * Import a ref map previously captured from a snapshot.
971
1053
  */
972
1054
  importRefMap(refMap: Record<string, number>): void;
1055
+ /**
1056
+ * Capture current page state for delta comparison.
1057
+ * Call before an action, then call delta() again after and use computeDelta().
1058
+ */
1059
+ captureState(): Promise<PageState>;
1060
+ /**
1061
+ * Compute what changed between two page states.
1062
+ * If no arguments: captures current state and returns it (for use as "before").
1063
+ * If one argument (before state): captures current state and computes delta.
1064
+ */
1065
+ delta(before?: PageState): Promise<DeltaResult | PageState>;
1066
+ /**
1067
+ * Extract structured review surface from the current page.
1068
+ * Returns headings, form values, alerts, key-value pairs, tables, and status labels.
1069
+ */
1070
+ review(): Promise<ReviewResult>;
973
1071
  /**
974
1072
  * Execute a batch of steps
975
1073
  */
@@ -1247,7 +1345,37 @@ declare class Page {
1247
1345
  */
1248
1346
 
1249
1347
  type FailureReason = 'missing' | 'hidden' | 'covered' | 'disabled' | 'readonly' | 'detached' | 'replaced' | 'notEditable' | 'timeout' | 'navigation' | 'cdpError' | 'unknown';
1250
- type ActionType = 'goto' | 'click' | 'fill' | 'type' | 'select' | 'check' | 'uncheck' | 'submit' | 'press' | 'shortcut' | 'focus' | 'hover' | 'scroll' | 'wait' | 'snapshot' | 'forms' | 'screenshot' | 'evaluate' | 'text' | 'newTab' | 'closeTab' | 'switchFrame' | 'switchToMain' | 'assertVisible' | 'assertExists' | 'assertText' | 'assertUrl' | 'assertValue' | 'waitForWsMessage' | 'assertNoConsoleErrors' | 'assertTextChanged' | 'assertPermission' | 'assertMediaTrackLive';
1348
+ type OutcomeStatus = 'success' | 'failed' | 'ambiguous' | 'unsafe_to_retry';
1349
+ type Condition = {
1350
+ kind: 'urlMatches';
1351
+ pattern: string;
1352
+ } | {
1353
+ kind: 'elementVisible';
1354
+ selector: string | string[];
1355
+ } | {
1356
+ kind: 'elementHidden';
1357
+ selector: string | string[];
1358
+ } | {
1359
+ kind: 'textAppears';
1360
+ selector?: string | string[];
1361
+ text: string;
1362
+ } | {
1363
+ kind: 'textChanges';
1364
+ selector?: string | string[];
1365
+ to?: string;
1366
+ } | {
1367
+ kind: 'networkResponse';
1368
+ urlPattern: string;
1369
+ status?: number;
1370
+ } | {
1371
+ kind: 'stateSignatureChanges';
1372
+ };
1373
+ interface MatchedCondition {
1374
+ condition: Condition;
1375
+ matched: boolean;
1376
+ detail?: string;
1377
+ }
1378
+ type ActionType = 'goto' | 'click' | 'fill' | 'type' | 'select' | 'check' | 'uncheck' | 'submit' | 'press' | 'shortcut' | 'focus' | 'hover' | 'scroll' | 'wait' | 'snapshot' | 'forms' | 'screenshot' | 'evaluate' | 'text' | 'newTab' | 'closeTab' | 'switchFrame' | 'switchToMain' | 'assertVisible' | 'assertExists' | 'assertText' | 'assertUrl' | 'assertValue' | 'waitForWsMessage' | 'assertNoConsoleErrors' | 'assertTextChanged' | 'assertPermission' | 'assertMediaTrackLive' | 'delta' | 'review' | 'chooseOption' | 'upload';
1251
1379
  interface Step {
1252
1380
  /** Action type */
1253
1381
  action: ActionType;
@@ -1314,8 +1442,18 @@ interface Step {
1314
1442
  state?: string;
1315
1443
  /** Media track kind */
1316
1444
  kind?: 'audio' | 'video';
1445
+ /** File paths for upload action */
1446
+ files?: string[];
1317
1447
  /** Assertion observation window in milliseconds */
1318
1448
  windowMs?: number;
1449
+ /** Conditions where ANY matching means success */
1450
+ expectAny?: Condition[];
1451
+ /** Conditions where ALL must match for success */
1452
+ expectAll?: Condition[];
1453
+ /** Conditions that indicate failure (checked before success conditions) */
1454
+ failIf?: Condition[];
1455
+ /** Mark step as dangerous - never auto-retry after ambiguous outcome */
1456
+ dangerous?: boolean;
1319
1457
  }
1320
1458
  interface RecordOptions {
1321
1459
  /** Base directory for screenshots and recording.json. */
@@ -1391,6 +1529,12 @@ interface StepResult {
1391
1529
  };
1392
1530
  /** Path to screenshot file captured after this step (when recording enabled) */
1393
1531
  screenshotPath?: string;
1532
+ /** Outcome classification when conditions were specified */
1533
+ outcomeStatus?: OutcomeStatus;
1534
+ /** Which conditions matched during evaluation */
1535
+ matchedConditions?: MatchedCondition[];
1536
+ /** Whether it's safe to retry this step */
1537
+ retrySafe?: boolean;
1394
1538
  }
1395
1539
  interface BatchResult {
1396
1540
  /** Whether all steps succeeded */
@@ -1405,4 +1549,4 @@ interface BatchResult {
1405
1549
  recordingManifest?: string;
1406
1550
  }
1407
1551
 
1408
- export { devices as $, type ActionType as A, type BatchOptions as B, type CaptureResult as C, type Dialog as D, type ElementInfo as E, type FileInput as F, type GeolocationOptions as G, type NetworkIdleOptions as H, type InteractiveElement as I, Page as J, type PageError as K, type PageSnapshot as L, type SnapshotNode as M, NavigationError as N, type SnapshotOptions as O, type PlayOptions as P, type SubmitOptions as Q, type RequestPattern as R, type Step as S, TimeoutError as T, type TypeOptions as U, type UserAgentMetadata as V, type UserAgentOptions as W, type ViewportOptions as X, type WaitForOptions as Y, type DeviceDescriptor as Z, type DeviceName as _, type RequestHandler as a, type ContinueRequestOptions as a0, type FailRequestOptions as a1, type FulfillRequestOptions as a2, type InterceptedRequest as a3, type RequestActions as a4, type ResourceType as a5, type RouteOptions as a6, type ClearCookiesOptions as a7, type Cookie as a8, type DeleteCookieOptions as a9, type SetCookieOptions as aa, type WaitOptions as ab, type WaitResult as ac, type WaitState as ad, waitForAnyElement as ae, waitForElement as af, waitForNavigation as ag, waitForNetworkIdle as ah, type FailureHint as ai, type FailureReason as aj, type BatchResult as b, type RecordOptions as c, type StepResult as d, type AudioChunk as e, AudioInput as f, type AudioInputState as g, AudioOutput as h, type CaptureOptions as i, type RoundTripOptions as j, type RoundTripResult as k, type ActionOptions as l, type ActionResult as m, type ConsoleHandler as n, type ConsoleMessage as o, type ConsoleMessageType as p, type CustomSelectConfig as q, type DialogHandler as r, type DialogType as s, type Download as t, ElementNotFoundError as u, type EmulationState as v, type ErrorHandler as w, type FillOptions as x, type FormField as y, type FormOption as z };
1552
+ export { type SnapshotNode as $, type ActionType as A, type BatchResult as B, type CaptureResult as C, type DeltaChange as D, type ElementInfo as E, type ErrorHandler as F, extractPageState as G, extractReview as H, type FileInput as I, type FillOptions as J, type FormField as K, type FormOption as L, type MatchedCondition as M, type GeolocationOptions as N, type OutcomeStatus as O, type PlayOptions as P, type InteractiveElement as Q, type RequestPattern as R, type Step as S, type KeyValuePair as T, NavigationError as U, type NetworkIdleOptions as V, Page as W, type PageError as X, type PageSnapshot as Y, type PageState as Z, type ReviewResult as _, type RequestHandler as a, type SnapshotOptions as a0, type SubmitOptions as a1, type SummaryCard as a2, type TableData as a3, TimeoutError as a4, type TypeOptions as a5, type UserAgentMetadata as a6, type UserAgentOptions as a7, type ViewportOptions as a8, type WaitForOptions as a9, type DeviceDescriptor as aa, type DeviceName as ab, devices as ac, type ContinueRequestOptions as ad, type FailRequestOptions as ae, type FulfillRequestOptions as af, type InterceptedRequest as ag, type RequestActions as ah, type ResourceType as ai, type RouteOptions as aj, type ClearCookiesOptions as ak, type Cookie as al, type DeleteCookieOptions as am, type SetCookieOptions as an, type WaitOptions as ao, type WaitResult as ap, type WaitState as aq, waitForAnyElement as ar, waitForElement as as, waitForNavigation as at, waitForNetworkIdle as au, type FailureHint as av, type FailureReason as aw, type BatchOptions as b, type Condition as c, type RecordOptions as d, type StepResult as e, type AudioChunk as f, AudioInput as g, type AudioInputState as h, AudioOutput as i, type CaptureOptions as j, type RoundTripOptions as k, type RoundTripResult as l, type ActionOptions as m, type ActionResult as n, type ConsoleHandler as o, type ConsoleMessage as p, type ConsoleMessageType as q, type CustomSelectConfig as r, computeDelta as s, type DeltaResult as t, type Dialog as u, type DialogHandler as v, type DialogType as w, type Download as x, ElementNotFoundError as y, type EmulationState as z };
@@ -120,7 +120,7 @@ interface ProxyConfig {
120
120
  }
121
121
  interface ConnectOptions {
122
122
  /** Provider type */
123
- provider: 'browserbase' | 'browserless' | 'generic';
123
+ provider: 'browserbase' | 'browserless' | 'browser-use' | 'generic';
124
124
  /** API key for hosted providers */
125
125
  apiKey?: string;
126
126
  /** Project ID (for BrowserBase) */
@@ -137,6 +137,12 @@ interface ConnectOptions {
137
137
  debug?: boolean;
138
138
  /** Connection timeout in ms */
139
139
  timeout?: number;
140
+ /** Proxy country code for Browser Use provider (default: 'uk'). Set null to disable. */
141
+ proxyCountryCode?: string | null;
142
+ /** Browser profile ID for Browser Use provider */
143
+ profileId?: string;
144
+ /** Session timeout in minutes for Browser Use provider (max 240) */
145
+ cloudTimeout?: number;
140
146
  }
141
147
 
142
148
  export { BrowserEndpointResolutionError as B, type CreateSessionOptions as C, type DiscoverLocalBrowsersOptions as D, type Provider as P, type ResolvedBrowserEndpoint as R, type ProviderSession as a, type ConnectOptions as b, buildLocalBrowserScanTargets as c, type ChromeChannel as d, type ChromeUserDataDirOptions as e, discoverLocalBrowsers as f, type ResolvedBrowserSource as g, resolveChromeUserDataDirs as h, type ProxyConfig as i, parseDevToolsActivePortFile as p, resolveBrowserEndpoint as r };
@@ -120,7 +120,7 @@ interface ProxyConfig {
120
120
  }
121
121
  interface ConnectOptions {
122
122
  /** Provider type */
123
- provider: 'browserbase' | 'browserless' | 'generic';
123
+ provider: 'browserbase' | 'browserless' | 'browser-use' | 'generic';
124
124
  /** API key for hosted providers */
125
125
  apiKey?: string;
126
126
  /** Project ID (for BrowserBase) */
@@ -137,6 +137,12 @@ interface ConnectOptions {
137
137
  debug?: boolean;
138
138
  /** Connection timeout in ms */
139
139
  timeout?: number;
140
+ /** Proxy country code for Browser Use provider (default: 'uk'). Set null to disable. */
141
+ proxyCountryCode?: string | null;
142
+ /** Browser profile ID for Browser Use provider */
143
+ profileId?: string;
144
+ /** Session timeout in minutes for Browser Use provider (max 240) */
145
+ cloudTimeout?: number;
140
146
  }
141
147
 
142
148
  export { BrowserEndpointResolutionError as B, type CreateSessionOptions as C, type DiscoverLocalBrowsersOptions as D, type Provider as P, type ResolvedBrowserEndpoint as R, type ProviderSession as a, type ConnectOptions as b, buildLocalBrowserScanTargets as c, type ChromeChannel as d, type ChromeUserDataDirOptions as e, discoverLocalBrowsers as f, type ResolvedBrowserSource as g, resolveChromeUserDataDirs as h, type ProxyConfig as i, parseDevToolsActivePortFile as p, resolveBrowserEndpoint as r };
@@ -718,6 +718,88 @@ interface ClearCookiesOptions {
718
718
  domain?: string;
719
719
  }
720
720
 
721
+ /**
722
+ * Delta extraction — compares page state before/after actions
723
+ */
724
+
725
+ interface PageState {
726
+ url: string;
727
+ title: string;
728
+ headings: string[];
729
+ formFields: Array<{
730
+ label?: string;
731
+ name?: string;
732
+ id?: string;
733
+ value: unknown;
734
+ type: string;
735
+ }>;
736
+ buttons: Array<{
737
+ text: string;
738
+ disabled: boolean;
739
+ ref?: string;
740
+ }>;
741
+ alerts: string[];
742
+ visibleText: string;
743
+ }
744
+ interface DeltaChange {
745
+ kind: 'url' | 'title' | 'heading_added' | 'heading_removed' | 'field_changed' | 'button_changed' | 'alert_added' | 'alert_removed' | 'text_changed';
746
+ before?: string;
747
+ after?: string;
748
+ detail?: string;
749
+ }
750
+ interface DeltaResult {
751
+ changes: DeltaChange[];
752
+ before: PageState;
753
+ after: PageState;
754
+ hasChanges: boolean;
755
+ }
756
+ /**
757
+ * Extract a lightweight page state from snapshot + forms data.
758
+ * Used for delta comparison.
759
+ */
760
+ declare function extractPageState(url: string, title: string, snapshot: PageSnapshot, forms: FormField[], pageText: string): PageState;
761
+ /**
762
+ * Compute delta between two page states
763
+ */
764
+ declare function computeDelta(before: PageState, after: PageState): DeltaResult;
765
+
766
+ /**
767
+ * Review surface extraction — structured business state from current page
768
+ */
769
+
770
+ interface KeyValuePair {
771
+ key: string;
772
+ value: string;
773
+ }
774
+ interface SummaryCard {
775
+ heading?: string;
776
+ items: KeyValuePair[];
777
+ }
778
+ interface TableData {
779
+ headers: string[];
780
+ rows: string[][];
781
+ }
782
+ interface ReviewResult {
783
+ url: string;
784
+ title: string;
785
+ headings: string[];
786
+ forms: Array<{
787
+ label?: string;
788
+ value: unknown;
789
+ type: string;
790
+ disabled: boolean;
791
+ }>;
792
+ alerts: string[];
793
+ summaryCards: SummaryCard[];
794
+ tables: TableData[];
795
+ keyValues: KeyValuePair[];
796
+ statusLabels: string[];
797
+ }
798
+ /**
799
+ * Extract review surface from page state
800
+ */
801
+ declare function extractReview(url: string, title: string, snapshot: PageSnapshot, forms: FormField[], pageText: string): ReviewResult;
802
+
721
803
  /**
722
804
  * Page class - provides high-level browser automation API
723
805
  */
@@ -970,6 +1052,22 @@ declare class Page {
970
1052
  * Import a ref map previously captured from a snapshot.
971
1053
  */
972
1054
  importRefMap(refMap: Record<string, number>): void;
1055
+ /**
1056
+ * Capture current page state for delta comparison.
1057
+ * Call before an action, then call delta() again after and use computeDelta().
1058
+ */
1059
+ captureState(): Promise<PageState>;
1060
+ /**
1061
+ * Compute what changed between two page states.
1062
+ * If no arguments: captures current state and returns it (for use as "before").
1063
+ * If one argument (before state): captures current state and computes delta.
1064
+ */
1065
+ delta(before?: PageState): Promise<DeltaResult | PageState>;
1066
+ /**
1067
+ * Extract structured review surface from the current page.
1068
+ * Returns headings, form values, alerts, key-value pairs, tables, and status labels.
1069
+ */
1070
+ review(): Promise<ReviewResult>;
973
1071
  /**
974
1072
  * Execute a batch of steps
975
1073
  */
@@ -1247,7 +1345,37 @@ declare class Page {
1247
1345
  */
1248
1346
 
1249
1347
  type FailureReason = 'missing' | 'hidden' | 'covered' | 'disabled' | 'readonly' | 'detached' | 'replaced' | 'notEditable' | 'timeout' | 'navigation' | 'cdpError' | 'unknown';
1250
- type ActionType = 'goto' | 'click' | 'fill' | 'type' | 'select' | 'check' | 'uncheck' | 'submit' | 'press' | 'shortcut' | 'focus' | 'hover' | 'scroll' | 'wait' | 'snapshot' | 'forms' | 'screenshot' | 'evaluate' | 'text' | 'newTab' | 'closeTab' | 'switchFrame' | 'switchToMain' | 'assertVisible' | 'assertExists' | 'assertText' | 'assertUrl' | 'assertValue' | 'waitForWsMessage' | 'assertNoConsoleErrors' | 'assertTextChanged' | 'assertPermission' | 'assertMediaTrackLive';
1348
+ type OutcomeStatus = 'success' | 'failed' | 'ambiguous' | 'unsafe_to_retry';
1349
+ type Condition = {
1350
+ kind: 'urlMatches';
1351
+ pattern: string;
1352
+ } | {
1353
+ kind: 'elementVisible';
1354
+ selector: string | string[];
1355
+ } | {
1356
+ kind: 'elementHidden';
1357
+ selector: string | string[];
1358
+ } | {
1359
+ kind: 'textAppears';
1360
+ selector?: string | string[];
1361
+ text: string;
1362
+ } | {
1363
+ kind: 'textChanges';
1364
+ selector?: string | string[];
1365
+ to?: string;
1366
+ } | {
1367
+ kind: 'networkResponse';
1368
+ urlPattern: string;
1369
+ status?: number;
1370
+ } | {
1371
+ kind: 'stateSignatureChanges';
1372
+ };
1373
+ interface MatchedCondition {
1374
+ condition: Condition;
1375
+ matched: boolean;
1376
+ detail?: string;
1377
+ }
1378
+ type ActionType = 'goto' | 'click' | 'fill' | 'type' | 'select' | 'check' | 'uncheck' | 'submit' | 'press' | 'shortcut' | 'focus' | 'hover' | 'scroll' | 'wait' | 'snapshot' | 'forms' | 'screenshot' | 'evaluate' | 'text' | 'newTab' | 'closeTab' | 'switchFrame' | 'switchToMain' | 'assertVisible' | 'assertExists' | 'assertText' | 'assertUrl' | 'assertValue' | 'waitForWsMessage' | 'assertNoConsoleErrors' | 'assertTextChanged' | 'assertPermission' | 'assertMediaTrackLive' | 'delta' | 'review' | 'chooseOption' | 'upload';
1251
1379
  interface Step {
1252
1380
  /** Action type */
1253
1381
  action: ActionType;
@@ -1314,8 +1442,18 @@ interface Step {
1314
1442
  state?: string;
1315
1443
  /** Media track kind */
1316
1444
  kind?: 'audio' | 'video';
1445
+ /** File paths for upload action */
1446
+ files?: string[];
1317
1447
  /** Assertion observation window in milliseconds */
1318
1448
  windowMs?: number;
1449
+ /** Conditions where ANY matching means success */
1450
+ expectAny?: Condition[];
1451
+ /** Conditions where ALL must match for success */
1452
+ expectAll?: Condition[];
1453
+ /** Conditions that indicate failure (checked before success conditions) */
1454
+ failIf?: Condition[];
1455
+ /** Mark step as dangerous - never auto-retry after ambiguous outcome */
1456
+ dangerous?: boolean;
1319
1457
  }
1320
1458
  interface RecordOptions {
1321
1459
  /** Base directory for screenshots and recording.json. */
@@ -1391,6 +1529,12 @@ interface StepResult {
1391
1529
  };
1392
1530
  /** Path to screenshot file captured after this step (when recording enabled) */
1393
1531
  screenshotPath?: string;
1532
+ /** Outcome classification when conditions were specified */
1533
+ outcomeStatus?: OutcomeStatus;
1534
+ /** Which conditions matched during evaluation */
1535
+ matchedConditions?: MatchedCondition[];
1536
+ /** Whether it's safe to retry this step */
1537
+ retrySafe?: boolean;
1394
1538
  }
1395
1539
  interface BatchResult {
1396
1540
  /** Whether all steps succeeded */
@@ -1405,4 +1549,4 @@ interface BatchResult {
1405
1549
  recordingManifest?: string;
1406
1550
  }
1407
1551
 
1408
- export { devices as $, type ActionType as A, type BatchOptions as B, type CaptureResult as C, type Dialog as D, type ElementInfo as E, type FileInput as F, type GeolocationOptions as G, type NetworkIdleOptions as H, type InteractiveElement as I, Page as J, type PageError as K, type PageSnapshot as L, type SnapshotNode as M, NavigationError as N, type SnapshotOptions as O, type PlayOptions as P, type SubmitOptions as Q, type RequestPattern as R, type Step as S, TimeoutError as T, type TypeOptions as U, type UserAgentMetadata as V, type UserAgentOptions as W, type ViewportOptions as X, type WaitForOptions as Y, type DeviceDescriptor as Z, type DeviceName as _, type RequestHandler as a, type ContinueRequestOptions as a0, type FailRequestOptions as a1, type FulfillRequestOptions as a2, type InterceptedRequest as a3, type RequestActions as a4, type ResourceType as a5, type RouteOptions as a6, type ClearCookiesOptions as a7, type Cookie as a8, type DeleteCookieOptions as a9, type SetCookieOptions as aa, type WaitOptions as ab, type WaitResult as ac, type WaitState as ad, waitForAnyElement as ae, waitForElement as af, waitForNavigation as ag, waitForNetworkIdle as ah, type FailureHint as ai, type FailureReason as aj, type BatchResult as b, type RecordOptions as c, type StepResult as d, type AudioChunk as e, AudioInput as f, type AudioInputState as g, AudioOutput as h, type CaptureOptions as i, type RoundTripOptions as j, type RoundTripResult as k, type ActionOptions as l, type ActionResult as m, type ConsoleHandler as n, type ConsoleMessage as o, type ConsoleMessageType as p, type CustomSelectConfig as q, type DialogHandler as r, type DialogType as s, type Download as t, ElementNotFoundError as u, type EmulationState as v, type ErrorHandler as w, type FillOptions as x, type FormField as y, type FormOption as z };
1552
+ export { type SnapshotNode as $, type ActionType as A, type BatchResult as B, type CaptureResult as C, type DeltaChange as D, type ElementInfo as E, type ErrorHandler as F, extractPageState as G, extractReview as H, type FileInput as I, type FillOptions as J, type FormField as K, type FormOption as L, type MatchedCondition as M, type GeolocationOptions as N, type OutcomeStatus as O, type PlayOptions as P, type InteractiveElement as Q, type RequestPattern as R, type Step as S, type KeyValuePair as T, NavigationError as U, type NetworkIdleOptions as V, Page as W, type PageError as X, type PageSnapshot as Y, type PageState as Z, type ReviewResult as _, type RequestHandler as a, type SnapshotOptions as a0, type SubmitOptions as a1, type SummaryCard as a2, type TableData as a3, TimeoutError as a4, type TypeOptions as a5, type UserAgentMetadata as a6, type UserAgentOptions as a7, type ViewportOptions as a8, type WaitForOptions as a9, type DeviceDescriptor as aa, type DeviceName as ab, devices as ac, type ContinueRequestOptions as ad, type FailRequestOptions as ae, type FulfillRequestOptions as af, type InterceptedRequest as ag, type RequestActions as ah, type ResourceType as ai, type RouteOptions as aj, type ClearCookiesOptions as ak, type Cookie as al, type DeleteCookieOptions as am, type SetCookieOptions as an, type WaitOptions as ao, type WaitResult as ap, type WaitState as aq, waitForAnyElement as ar, waitForElement as as, waitForNavigation as at, waitForNetworkIdle as au, type FailureHint as av, type FailureReason as aw, type BatchOptions as b, type Condition as c, type RecordOptions as d, type StepResult as e, type AudioChunk as f, AudioInput as g, type AudioInputState as h, AudioOutput as i, type CaptureOptions as j, type RoundTripOptions as k, type RoundTripResult as l, type ActionOptions as m, type ActionResult as n, type ConsoleHandler as o, type ConsoleMessage as p, type ConsoleMessageType as q, type CustomSelectConfig as r, computeDelta as s, type DeltaResult as t, type Dialog as u, type DialogHandler as v, type DialogType as w, type Download as x, ElementNotFoundError as y, type EmulationState as z };
@@ -0,0 +1,6 @@
1
+ import {
2
+ uploadFiles
3
+ } from "./chunk-OIHU7OFY.mjs";
4
+ export {
5
+ uploadFiles
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-pilot",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Lightweight CDP-based browser automation for Node.js, Bun, and Cloudflare Workers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -52,15 +52,19 @@
52
52
  "test:unit": "bun test tests/unit",
53
53
  "test:integration": "bun test tests/integration --timeout 30000",
54
54
  "test:cli": "bun test tests/cli --timeout 30000",
55
- "test:e2e": "bun test tests/e2e --timeout 30000",
56
55
  "test:all": "bun test tests/ --timeout 30000",
57
56
  "typecheck": "tsc --noEmit",
58
57
  "lint": "biome check .",
59
58
  "lint:fix": "biome check --write .",
60
- "lint:type": "oxlint --type-aware --tsconfig ./tsconfig.json src/",
59
+ "lint:type": "oxlint --type-aware --tsconfig ./tsconfig.json src/ tests/ scripts/",
61
60
  "format": "biome format --write .",
62
61
  "check": "bun run typecheck && bun run lint && bun run lint:type",
63
62
  "check:quiet": "bash scripts/check.sh",
63
+ "prepare": "bunx prek install",
64
+ "harden": "./scripts/prek-run.sh run --all-files --stage manual",
65
+ "harden:quick": "./scripts/prek-run.sh run --stage pre-commit",
66
+ "gate:agent": "./scripts/prek-run.sh run --from-ref HEAD~1",
67
+ "api:check": "api-extractor run --local",
64
68
  "prepublishOnly": "bun run build",
65
69
  "bp": "bun ./src/cli/index.ts",
66
70
  "dev:bp": "bun ./src/cli/index.ts",
@@ -68,7 +72,10 @@
68
72
  "fixtures:serve": "bun tests/fixtures/server.ts"
69
73
  },
70
74
  "devDependencies": {
75
+ "@ast-grep/cli": "^0.41.1",
71
76
  "@biomejs/biome": "^2.4.6",
77
+ "@j178/prek": "^0.3.5",
78
+ "@microsoft/api-extractor": "^7.57.7",
72
79
  "@types/bun": "latest",
73
80
  "chrome-launcher": "^1.2.1",
74
81
  "oxlint": "^1.51.0",