@olib-ai/owl-browser-sdk 1.0.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,163 @@
1
+ import { BrowserContext } from './context';
2
+ import type { BrowserConfig, LLMStatus, DemographicsInfo, LocationInfo, DateTimeInfo, WeatherInfo, ContextOptions } from './types';
3
+ /**
4
+ * Main Browser class for automation
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { Browser } from 'owl-browser-sdk';
9
+ *
10
+ * const browser = new Browser();
11
+ * await browser.launch();
12
+ *
13
+ * const page = await browser.newPage();
14
+ * await page.goto('https://example.com');
15
+ * await page.screenshot();
16
+ *
17
+ * await browser.close();
18
+ * ```
19
+ */
20
+ export declare class Browser {
21
+ private core;
22
+ private contexts;
23
+ private isLaunched;
24
+ constructor(config?: BrowserConfig);
25
+ /**
26
+ * Launch the browser process
27
+ */
28
+ launch(): Promise<void>;
29
+ /**
30
+ * Create a new page (browser context)
31
+ * @param options - Optional context configuration (LLM, proxy, profile, etc.)
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Create a simple page
36
+ * const page = await browser.newPage();
37
+ *
38
+ * // Create a page with proxy
39
+ * const proxyPage = await browser.newPage({
40
+ * proxy: {
41
+ * type: 'socks5h',
42
+ * host: 'proxy.example.com',
43
+ * port: 1080,
44
+ * stealth: true,
45
+ * timezoneOverride: 'America/New_York'
46
+ * }
47
+ * });
48
+ *
49
+ * // Create a page with external LLM
50
+ * const llmPage = await browser.newPage({
51
+ * llm: {
52
+ * endpoint: 'https://api.openai.com',
53
+ * model: 'gpt-4-vision-preview',
54
+ * apiKey: 'sk-...'
55
+ * }
56
+ * });
57
+ *
58
+ * // Create a page with browser profile (persistent identity)
59
+ * const profilePage = await browser.newPage({
60
+ * profilePath: '/path/to/profile.json'
61
+ * });
62
+ * await profilePage.goto('https://example.com/login');
63
+ * // ... login ...
64
+ * await profilePage.saveProfile(); // Save cookies and fingerprints
65
+ *
66
+ * // Later, restore the session
67
+ * const restoredPage = await browser.newPage({
68
+ * profilePath: '/path/to/profile.json'
69
+ * });
70
+ * await restoredPage.goto('https://example.com'); // Already logged in!
71
+ * ```
72
+ */
73
+ newPage(options?: ContextOptions): Promise<BrowserContext>;
74
+ /**
75
+ * Get all active pages
76
+ */
77
+ pages(): BrowserContext[];
78
+ /**
79
+ * Check if on-device LLM is ready
80
+ */
81
+ getLLMStatus(): Promise<LLMStatus>;
82
+ /**
83
+ * List available extraction templates
84
+ */
85
+ listTemplates(): Promise<string[]>;
86
+ /**
87
+ * Get complete demographics information (location, time, weather)
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const demographics = await browser.getDemographics();
92
+ * console.log(`Location: ${demographics.location?.city}, ${demographics.location?.country}`);
93
+ * console.log(`Weather: ${demographics.weather?.temperature_c}°C, ${demographics.weather?.condition}`);
94
+ * console.log(`Time: ${demographics.datetime.time} ${demographics.datetime.timezone}`);
95
+ * ```
96
+ */
97
+ getDemographics(): Promise<DemographicsInfo>;
98
+ /**
99
+ * Get geographic location information based on IP address
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const location = await browser.getLocation();
104
+ * if (location.success) {
105
+ * console.log(`You are in ${location.city}, ${location.country}`);
106
+ * console.log(`Coordinates: ${location.latitude}, ${location.longitude}`);
107
+ * }
108
+ * ```
109
+ */
110
+ getLocation(): Promise<LocationInfo>;
111
+ /**
112
+ * Get current date and time information
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const datetime = await browser.getDateTime();
117
+ * console.log(`Current time: ${datetime.time} on ${datetime.date}`);
118
+ * console.log(`Day: ${datetime.day_of_week}, Timezone: ${datetime.timezone}`);
119
+ * ```
120
+ */
121
+ getDateTime(): Promise<DateTimeInfo>;
122
+ /**
123
+ * Get current weather information for user's location
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const weather = await browser.getWeather();
128
+ * if (weather.success) {
129
+ * console.log(`Temperature: ${weather.temperature_c}°C`);
130
+ * console.log(`Condition: ${weather.condition} - ${weather.description}`);
131
+ * console.log(`Humidity: ${weather.humidity}%`);
132
+ * }
133
+ * ```
134
+ */
135
+ getWeather(): Promise<WeatherInfo>;
136
+ /**
137
+ * Get the custom browser homepage HTML
138
+ *
139
+ * Shows demographics, weather, LLM status, and browser information
140
+ * in a beautiful branded interface.
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const html = await browser.getHomepage();
145
+ * // Save to file or display in a page
146
+ * await fs.writeFile('homepage.html', html);
147
+ * ```
148
+ */
149
+ getHomepage(): Promise<string>;
150
+ /**
151
+ * Close all contexts and shutdown browser
152
+ */
153
+ close(): Promise<void>;
154
+ /**
155
+ * Synchronous cleanup (for process exit)
156
+ */
157
+ private cleanupSync;
158
+ /**
159
+ * Check if browser is running
160
+ */
161
+ isRunning(): boolean;
162
+ }
163
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EACV,aAAa,EAEb,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,QAAQ,CAA6C;IAC7D,OAAO,CAAC,UAAU,CAAS;gBAEf,MAAM,CAAC,EAAE,aAAa;IAIlC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAYhE;;OAEG;IACH,KAAK,IAAI,cAAc,EAAE;IAIzB;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC;IAOxC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAOxC;;;;;;;;;;OAUG;IACG,eAAe,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAOlD;;;;;;;;;;;OAWG;IACG,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAO1C;;;;;;;;;OASG;IACG,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAO1C;;;;;;;;;;;;OAYG;IACG,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;IAOxC;;;;;;;;;;;;OAYG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAOpC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5B;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB"}
@@ -0,0 +1,252 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Browser = void 0;
4
+ const core_1 = require("./core");
5
+ const context_1 = require("./context");
6
+ /**
7
+ * Main Browser class for automation
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Browser } from 'owl-browser-sdk';
12
+ *
13
+ * const browser = new Browser();
14
+ * await browser.launch();
15
+ *
16
+ * const page = await browser.newPage();
17
+ * await page.goto('https://example.com');
18
+ * await page.screenshot();
19
+ *
20
+ * await browser.close();
21
+ * ```
22
+ */
23
+ class Browser {
24
+ constructor(config) {
25
+ this.contexts = new Map();
26
+ this.isLaunched = false;
27
+ this.core = new core_1.BrowserCore(config);
28
+ }
29
+ /**
30
+ * Launch the browser process
31
+ */
32
+ async launch() {
33
+ if (this.isLaunched) {
34
+ throw new Error('Browser already launched');
35
+ }
36
+ await this.core.initialize();
37
+ this.isLaunched = true;
38
+ // Setup cleanup on exit
39
+ process.on('exit', () => this.cleanupSync());
40
+ process.on('SIGINT', async () => {
41
+ await this.close();
42
+ process.exit(0);
43
+ });
44
+ process.on('SIGTERM', async () => {
45
+ await this.close();
46
+ process.exit(0);
47
+ });
48
+ }
49
+ /**
50
+ * Create a new page (browser context)
51
+ * @param options - Optional context configuration (LLM, proxy, profile, etc.)
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * // Create a simple page
56
+ * const page = await browser.newPage();
57
+ *
58
+ * // Create a page with proxy
59
+ * const proxyPage = await browser.newPage({
60
+ * proxy: {
61
+ * type: 'socks5h',
62
+ * host: 'proxy.example.com',
63
+ * port: 1080,
64
+ * stealth: true,
65
+ * timezoneOverride: 'America/New_York'
66
+ * }
67
+ * });
68
+ *
69
+ * // Create a page with external LLM
70
+ * const llmPage = await browser.newPage({
71
+ * llm: {
72
+ * endpoint: 'https://api.openai.com',
73
+ * model: 'gpt-4-vision-preview',
74
+ * apiKey: 'sk-...'
75
+ * }
76
+ * });
77
+ *
78
+ * // Create a page with browser profile (persistent identity)
79
+ * const profilePage = await browser.newPage({
80
+ * profilePath: '/path/to/profile.json'
81
+ * });
82
+ * await profilePage.goto('https://example.com/login');
83
+ * // ... login ...
84
+ * await profilePage.saveProfile(); // Save cookies and fingerprints
85
+ *
86
+ * // Later, restore the session
87
+ * const restoredPage = await browser.newPage({
88
+ * profilePath: '/path/to/profile.json'
89
+ * });
90
+ * await restoredPage.goto('https://example.com'); // Already logged in!
91
+ * ```
92
+ */
93
+ async newPage(options) {
94
+ if (!this.isLaunched) {
95
+ throw new Error('Browser not launched. Call launch() first.');
96
+ }
97
+ const contextId = await this.core.createContext(options);
98
+ const context = new context_1.BrowserContext(contextId, this.core);
99
+ this.contexts.set(contextId, context);
100
+ return context;
101
+ }
102
+ /**
103
+ * Get all active pages
104
+ */
105
+ pages() {
106
+ return Array.from(this.contexts.values());
107
+ }
108
+ /**
109
+ * Check if on-device LLM is ready
110
+ */
111
+ async getLLMStatus() {
112
+ if (!this.isLaunched) {
113
+ throw new Error('Browser not launched. Call launch() first.');
114
+ }
115
+ return await this.core.getLLMStatus();
116
+ }
117
+ /**
118
+ * List available extraction templates
119
+ */
120
+ async listTemplates() {
121
+ if (!this.isLaunched) {
122
+ throw new Error('Browser not launched. Call launch() first.');
123
+ }
124
+ return await this.core.listTemplates();
125
+ }
126
+ /**
127
+ * Get complete demographics information (location, time, weather)
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const demographics = await browser.getDemographics();
132
+ * console.log(`Location: ${demographics.location?.city}, ${demographics.location?.country}`);
133
+ * console.log(`Weather: ${demographics.weather?.temperature_c}°C, ${demographics.weather?.condition}`);
134
+ * console.log(`Time: ${demographics.datetime.time} ${demographics.datetime.timezone}`);
135
+ * ```
136
+ */
137
+ async getDemographics() {
138
+ if (!this.isLaunched) {
139
+ throw new Error('Browser not launched. Call launch() first.');
140
+ }
141
+ return await this.core.getDemographics();
142
+ }
143
+ /**
144
+ * Get geographic location information based on IP address
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const location = await browser.getLocation();
149
+ * if (location.success) {
150
+ * console.log(`You are in ${location.city}, ${location.country}`);
151
+ * console.log(`Coordinates: ${location.latitude}, ${location.longitude}`);
152
+ * }
153
+ * ```
154
+ */
155
+ async getLocation() {
156
+ if (!this.isLaunched) {
157
+ throw new Error('Browser not launched. Call launch() first.');
158
+ }
159
+ return await this.core.getLocation();
160
+ }
161
+ /**
162
+ * Get current date and time information
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const datetime = await browser.getDateTime();
167
+ * console.log(`Current time: ${datetime.time} on ${datetime.date}`);
168
+ * console.log(`Day: ${datetime.day_of_week}, Timezone: ${datetime.timezone}`);
169
+ * ```
170
+ */
171
+ async getDateTime() {
172
+ if (!this.isLaunched) {
173
+ throw new Error('Browser not launched. Call launch() first.');
174
+ }
175
+ return await this.core.getDateTime();
176
+ }
177
+ /**
178
+ * Get current weather information for user's location
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * const weather = await browser.getWeather();
183
+ * if (weather.success) {
184
+ * console.log(`Temperature: ${weather.temperature_c}°C`);
185
+ * console.log(`Condition: ${weather.condition} - ${weather.description}`);
186
+ * console.log(`Humidity: ${weather.humidity}%`);
187
+ * }
188
+ * ```
189
+ */
190
+ async getWeather() {
191
+ if (!this.isLaunched) {
192
+ throw new Error('Browser not launched. Call launch() first.');
193
+ }
194
+ return await this.core.getWeather();
195
+ }
196
+ /**
197
+ * Get the custom browser homepage HTML
198
+ *
199
+ * Shows demographics, weather, LLM status, and browser information
200
+ * in a beautiful branded interface.
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * const html = await browser.getHomepage();
205
+ * // Save to file or display in a page
206
+ * await fs.writeFile('homepage.html', html);
207
+ * ```
208
+ */
209
+ async getHomepage() {
210
+ if (!this.isLaunched) {
211
+ throw new Error('Browser not launched. Call launch() first.');
212
+ }
213
+ return await this.core.getHomepage();
214
+ }
215
+ /**
216
+ * Close all contexts and shutdown browser
217
+ */
218
+ async close() {
219
+ if (!this.isLaunched) {
220
+ return;
221
+ }
222
+ // Close all contexts
223
+ for (const [contextId, context] of this.contexts) {
224
+ try {
225
+ await context.close();
226
+ }
227
+ catch (err) {
228
+ // Silently ignore context close errors
229
+ }
230
+ }
231
+ this.contexts.clear();
232
+ // Shutdown browser
233
+ await this.core.shutdown();
234
+ this.isLaunched = false;
235
+ }
236
+ /**
237
+ * Synchronous cleanup (for process exit)
238
+ */
239
+ cleanupSync() {
240
+ if (this.core.isRunning()) {
241
+ this.core.shutdown();
242
+ }
243
+ }
244
+ /**
245
+ * Check if browser is running
246
+ */
247
+ isRunning() {
248
+ return this.isLaunched && this.core.isRunning();
249
+ }
250
+ }
251
+ exports.Browser = Browser;
252
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AACrC,uCAA2C;AAY3C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,OAAO;IAKlB,YAAY,MAAsB;QAH1B,aA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ACH,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;IAClD,CAAC;CACF;AAvPD,0BAuPC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Connection abstraction for Owl Browser SDK
3
+ *
4
+ * Provides a unified interface for communicating with the browser,
5
+ * supporting both local (IPC) and remote (HTTP) modes.
6
+ */
7
+ import type { BrowserConfig } from './types';
8
+ /**
9
+ * Common interface for browser connections
10
+ */
11
+ export interface BrowserConnection {
12
+ /** Initialize the connection */
13
+ initialize(): Promise<void>;
14
+ /** Send a command and receive a response */
15
+ sendCommand(method: string, params?: Record<string, any>): Promise<any>;
16
+ /** Shutdown the connection */
17
+ shutdown(): Promise<void>;
18
+ /** Check if the connection is active */
19
+ isRunning(): boolean;
20
+ }
21
+ /**
22
+ * Local connection using child process IPC (stdin/stdout)
23
+ */
24
+ export declare class LocalConnection implements BrowserConnection {
25
+ private browserProcess;
26
+ private commandId;
27
+ private pendingCommands;
28
+ private buffer;
29
+ private instanceId;
30
+ private browserPath;
31
+ private initTimeout;
32
+ private verbose;
33
+ private licenseError;
34
+ private hardwareFingerprint;
35
+ constructor(config: BrowserConfig);
36
+ /**
37
+ * Auto-detect browser binary path
38
+ */
39
+ private detectBrowserPath;
40
+ initialize(): Promise<void>;
41
+ /**
42
+ * Handle JSON response from browser
43
+ */
44
+ private handleResponse;
45
+ sendCommand(method: string, params?: Record<string, any>): Promise<any>;
46
+ shutdown(): Promise<void>;
47
+ isRunning(): boolean;
48
+ }
49
+ /**
50
+ * HTTP connection using REST API to remote browser server
51
+ */
52
+ export declare class HttpConnection implements BrowserConnection {
53
+ private baseUrl;
54
+ private token;
55
+ private timeout;
56
+ private verbose;
57
+ private connected;
58
+ constructor(config: BrowserConfig);
59
+ initialize(): Promise<void>;
60
+ /**
61
+ * Map SDK method names to HTTP API tool names
62
+ */
63
+ private mapMethodToTool;
64
+ /**
65
+ * Map SDK parameters to HTTP API parameters
66
+ */
67
+ private mapParams;
68
+ sendCommand(method: string, params?: Record<string, any>): Promise<any>;
69
+ shutdown(): Promise<void>;
70
+ isRunning(): boolean;
71
+ /**
72
+ * Make an HTTP request to the browser server
73
+ */
74
+ private httpRequest;
75
+ }
76
+ /**
77
+ * Factory function to create the appropriate connection based on config
78
+ */
79
+ export declare function createConnection(config: BrowserConfig): BrowserConnection;
80
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,aAAa,EAA8B,MAAM,SAAS,CAAC;AASzE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B,4CAA4C;IAC5C,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAExE,8BAA8B;IAC9B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B,wCAAwC;IACxC,SAAS,IAAI,OAAO,CAAC;CACtB;AA0BD;;GAEG;AACH,qBAAa,eAAgB,YAAW,iBAAiB;IACvD,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAU;IAGzB,OAAO,CAAC,YAAY,CAA2D;IAC/E,OAAO,CAAC,mBAAmB,CAAuB;gBAEtC,MAAM,EAAE,aAAa;IAOjC;;OAEG;IACH,OAAO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