@alfe.ai/browser 0.2.0 → 0.2.1
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/README.md +21 -0
- package/dist/index.cjs +537 -139
- package/dist/index.d.cts +24 -9
- package/dist/index.d.ts +24 -9
- package/dist/index.js +538 -140
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -125,16 +125,11 @@ interface BrowserSessionOptions {
|
|
|
125
125
|
idleShutdownMs?: number;
|
|
126
126
|
/** Extra Chrome args. */
|
|
127
127
|
extraArgs?: string[];
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
interface BrowserSurfaceOptions extends BrowserSessionOptions {
|
|
131
|
-
/**
|
|
132
|
-
* Guard consulted before agent-driven or human navigation. Return false to
|
|
133
|
-
* block (SSRF policy). Defaults to allow-all; Phase 11 wires the integration
|
|
134
|
-
* SSRF allowlist here.
|
|
135
|
-
*/
|
|
128
|
+
/** Guard applied to every intercepted HTTP(S) page request. */
|
|
136
129
|
isNavigationAllowed?: (url: string) => boolean;
|
|
130
|
+
logger?: Logger;
|
|
137
131
|
}
|
|
132
|
+
type BrowserSurfaceOptions = BrowserSessionOptions;
|
|
138
133
|
//#endregion
|
|
139
134
|
//#region src/browser-session.d.ts
|
|
140
135
|
declare class BrowserSession {
|
|
@@ -144,6 +139,9 @@ declare class BrowserSession {
|
|
|
144
139
|
private launching;
|
|
145
140
|
private holds;
|
|
146
141
|
private idleTimer;
|
|
142
|
+
private generation;
|
|
143
|
+
private readonly preparedPages;
|
|
144
|
+
private readonly activePageListeners;
|
|
147
145
|
private readonly log;
|
|
148
146
|
private readonly idleMs;
|
|
149
147
|
constructor(options: BrowserSessionOptions);
|
|
@@ -158,6 +156,7 @@ declare class BrowserSession {
|
|
|
158
156
|
private adoptIfNavigable;
|
|
159
157
|
/** The current active page, launching Chrome first if needed. */
|
|
160
158
|
getActivePage(): Promise<Page>;
|
|
159
|
+
onActivePageChange(listener: (page: Page) => void | Promise<void>): () => void;
|
|
161
160
|
/** Prevent idle shutdown while a viewer or op is active. */
|
|
162
161
|
addHold(): void;
|
|
163
162
|
/** Release a hold; arm idle shutdown when the last one is released. */
|
|
@@ -167,6 +166,9 @@ declare class BrowserSession {
|
|
|
167
166
|
private armIdleTimer;
|
|
168
167
|
private clearIdleTimer;
|
|
169
168
|
shutdown(): Promise<void>;
|
|
169
|
+
private setActivePage;
|
|
170
|
+
private preparePage;
|
|
171
|
+
private isLaunchCurrent;
|
|
170
172
|
}
|
|
171
173
|
//#endregion
|
|
172
174
|
//#region src/automation.d.ts
|
|
@@ -178,6 +180,7 @@ declare class BrowserAutomation {
|
|
|
178
180
|
private readonly session;
|
|
179
181
|
private readonly turn;
|
|
180
182
|
private readonly isNavigationAllowed;
|
|
183
|
+
private operationTail;
|
|
181
184
|
constructor(session: BrowserSession, turn: TurnController, isNavigationAllowed: (url: string) => boolean);
|
|
182
185
|
navigate(url: string): Promise<NavigateResult>;
|
|
183
186
|
click(selector: string): Promise<void>;
|
|
@@ -192,6 +195,9 @@ declare class BrowserAutomation {
|
|
|
192
195
|
screenshot(): Promise<string>;
|
|
193
196
|
/** Evaluate an expression in the page context via CDP (no eval on our side). */
|
|
194
197
|
evaluate(expression: string): Promise<unknown>;
|
|
198
|
+
/** Wait until all agent operations that were already queued have settled. */
|
|
199
|
+
waitUntilIdle(): Promise<void>;
|
|
200
|
+
private run;
|
|
195
201
|
}
|
|
196
202
|
//#endregion
|
|
197
203
|
//#region src/browser-surface.d.ts
|
|
@@ -213,6 +219,12 @@ declare class BrowserSurface implements SurfaceHandler {
|
|
|
213
219
|
private readonly viewers;
|
|
214
220
|
private viewport;
|
|
215
221
|
private handoff;
|
|
222
|
+
private controllerSessionId;
|
|
223
|
+
private pendingControllerSessionId;
|
|
224
|
+
private streamGeneration;
|
|
225
|
+
private streamQueue;
|
|
226
|
+
private closed;
|
|
227
|
+
private readonly removePageListener;
|
|
216
228
|
private readonly log;
|
|
217
229
|
constructor(options: BrowserSurfaceOptions, sendFrame: (buf: Buffer) => void);
|
|
218
230
|
openSession(sessionId: number, open: SessionOpenPayload): Promise<void>;
|
|
@@ -244,13 +256,16 @@ declare class BrowserSurface implements SurfaceHandler {
|
|
|
244
256
|
removeHold(): void;
|
|
245
257
|
shutdown(): Promise<void>;
|
|
246
258
|
private releaseToAgent;
|
|
247
|
-
private
|
|
259
|
+
private restartStreaming;
|
|
260
|
+
private enqueueStreamCleanup;
|
|
261
|
+
private shouldStream;
|
|
248
262
|
private applyResize;
|
|
249
263
|
private broadcastFrame;
|
|
250
264
|
private broadcast;
|
|
251
265
|
private broadcastState;
|
|
252
266
|
private sendState;
|
|
253
267
|
private currentPageInfo;
|
|
268
|
+
private sendFrameSafe;
|
|
254
269
|
}
|
|
255
270
|
//#endregion
|
|
256
271
|
export { BrowserAutomation, BrowserSession, type BrowserSessionOptions, BrowserSurface, type BrowserSurfaceOptions, type HandoffResult, type Logger, type NavigateResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -125,16 +125,11 @@ interface BrowserSessionOptions {
|
|
|
125
125
|
idleShutdownMs?: number;
|
|
126
126
|
/** Extra Chrome args. */
|
|
127
127
|
extraArgs?: string[];
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
interface BrowserSurfaceOptions extends BrowserSessionOptions {
|
|
131
|
-
/**
|
|
132
|
-
* Guard consulted before agent-driven or human navigation. Return false to
|
|
133
|
-
* block (SSRF policy). Defaults to allow-all; Phase 11 wires the integration
|
|
134
|
-
* SSRF allowlist here.
|
|
135
|
-
*/
|
|
128
|
+
/** Guard applied to every intercepted HTTP(S) page request. */
|
|
136
129
|
isNavigationAllowed?: (url: string) => boolean;
|
|
130
|
+
logger?: Logger;
|
|
137
131
|
}
|
|
132
|
+
type BrowserSurfaceOptions = BrowserSessionOptions;
|
|
138
133
|
//#endregion
|
|
139
134
|
//#region src/browser-session.d.ts
|
|
140
135
|
declare class BrowserSession {
|
|
@@ -144,6 +139,9 @@ declare class BrowserSession {
|
|
|
144
139
|
private launching;
|
|
145
140
|
private holds;
|
|
146
141
|
private idleTimer;
|
|
142
|
+
private generation;
|
|
143
|
+
private readonly preparedPages;
|
|
144
|
+
private readonly activePageListeners;
|
|
147
145
|
private readonly log;
|
|
148
146
|
private readonly idleMs;
|
|
149
147
|
constructor(options: BrowserSessionOptions);
|
|
@@ -158,6 +156,7 @@ declare class BrowserSession {
|
|
|
158
156
|
private adoptIfNavigable;
|
|
159
157
|
/** The current active page, launching Chrome first if needed. */
|
|
160
158
|
getActivePage(): Promise<Page>;
|
|
159
|
+
onActivePageChange(listener: (page: Page) => void | Promise<void>): () => void;
|
|
161
160
|
/** Prevent idle shutdown while a viewer or op is active. */
|
|
162
161
|
addHold(): void;
|
|
163
162
|
/** Release a hold; arm idle shutdown when the last one is released. */
|
|
@@ -167,6 +166,9 @@ declare class BrowserSession {
|
|
|
167
166
|
private armIdleTimer;
|
|
168
167
|
private clearIdleTimer;
|
|
169
168
|
shutdown(): Promise<void>;
|
|
169
|
+
private setActivePage;
|
|
170
|
+
private preparePage;
|
|
171
|
+
private isLaunchCurrent;
|
|
170
172
|
}
|
|
171
173
|
//#endregion
|
|
172
174
|
//#region src/automation.d.ts
|
|
@@ -178,6 +180,7 @@ declare class BrowserAutomation {
|
|
|
178
180
|
private readonly session;
|
|
179
181
|
private readonly turn;
|
|
180
182
|
private readonly isNavigationAllowed;
|
|
183
|
+
private operationTail;
|
|
181
184
|
constructor(session: BrowserSession, turn: TurnController, isNavigationAllowed: (url: string) => boolean);
|
|
182
185
|
navigate(url: string): Promise<NavigateResult>;
|
|
183
186
|
click(selector: string): Promise<void>;
|
|
@@ -192,6 +195,9 @@ declare class BrowserAutomation {
|
|
|
192
195
|
screenshot(): Promise<string>;
|
|
193
196
|
/** Evaluate an expression in the page context via CDP (no eval on our side). */
|
|
194
197
|
evaluate(expression: string): Promise<unknown>;
|
|
198
|
+
/** Wait until all agent operations that were already queued have settled. */
|
|
199
|
+
waitUntilIdle(): Promise<void>;
|
|
200
|
+
private run;
|
|
195
201
|
}
|
|
196
202
|
//#endregion
|
|
197
203
|
//#region src/browser-surface.d.ts
|
|
@@ -213,6 +219,12 @@ declare class BrowserSurface implements SurfaceHandler {
|
|
|
213
219
|
private readonly viewers;
|
|
214
220
|
private viewport;
|
|
215
221
|
private handoff;
|
|
222
|
+
private controllerSessionId;
|
|
223
|
+
private pendingControllerSessionId;
|
|
224
|
+
private streamGeneration;
|
|
225
|
+
private streamQueue;
|
|
226
|
+
private closed;
|
|
227
|
+
private readonly removePageListener;
|
|
216
228
|
private readonly log;
|
|
217
229
|
constructor(options: BrowserSurfaceOptions, sendFrame: (buf: Buffer) => void);
|
|
218
230
|
openSession(sessionId: number, open: SessionOpenPayload): Promise<void>;
|
|
@@ -244,13 +256,16 @@ declare class BrowserSurface implements SurfaceHandler {
|
|
|
244
256
|
removeHold(): void;
|
|
245
257
|
shutdown(): Promise<void>;
|
|
246
258
|
private releaseToAgent;
|
|
247
|
-
private
|
|
259
|
+
private restartStreaming;
|
|
260
|
+
private enqueueStreamCleanup;
|
|
261
|
+
private shouldStream;
|
|
248
262
|
private applyResize;
|
|
249
263
|
private broadcastFrame;
|
|
250
264
|
private broadcast;
|
|
251
265
|
private broadcastState;
|
|
252
266
|
private sendState;
|
|
253
267
|
private currentPageInfo;
|
|
268
|
+
private sendFrameSafe;
|
|
254
269
|
}
|
|
255
270
|
//#endregion
|
|
256
271
|
export { BrowserAutomation, BrowserSession, type BrowserSessionOptions, BrowserSurface, type BrowserSurfaceOptions, type HandoffResult, type Logger, type NavigateResult };
|