opensteer 0.1.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,718 @@
1
+ import * as playwright from 'playwright';
2
+ import { BrowserContextOptions, Page, BrowserContext, Cookie, ElementHandle, Browser } from 'playwright';
3
+
4
+ type MatchOperator = 'exact' | 'startsWith' | 'contains';
5
+ interface AttributeMatchClause {
6
+ kind: 'attr';
7
+ key: string;
8
+ op?: MatchOperator;
9
+ value?: string;
10
+ }
11
+ interface PositionMatchClause {
12
+ kind: 'position';
13
+ axis: 'nthOfType' | 'nthChild';
14
+ }
15
+ type MatchClause = AttributeMatchClause | PositionMatchClause;
16
+ interface PathNodePosition {
17
+ nthChild: number;
18
+ nthOfType: number;
19
+ }
20
+ interface PathNode {
21
+ tag: string;
22
+ attrs: Record<string, string>;
23
+ position: PathNodePosition;
24
+ match: MatchClause[];
25
+ }
26
+ type DomPath = PathNode[];
27
+ interface ContextHop {
28
+ kind: 'iframe' | 'shadow';
29
+ host: DomPath;
30
+ }
31
+ interface ElementPath {
32
+ context: ContextHop[];
33
+ nodes: DomPath;
34
+ }
35
+
36
+ type ActionFailureCode = 'TARGET_NOT_FOUND' | 'TARGET_UNAVAILABLE' | 'TARGET_STALE' | 'TARGET_AMBIGUOUS' | 'BLOCKED_BY_INTERCEPTOR' | 'NOT_VISIBLE' | 'NOT_ENABLED' | 'NOT_EDITABLE' | 'INVALID_TARGET' | 'INVALID_OPTIONS' | 'ACTION_TIMEOUT' | 'UNKNOWN';
37
+ type ActionFailureClassificationSource = 'typed_error' | 'playwright_call_log' | 'dom_probe' | 'message_heuristic' | 'unknown';
38
+ interface ActionFailureBlocker {
39
+ tag: string;
40
+ id: string | null;
41
+ classes: string[];
42
+ role: string | null;
43
+ text: string | null;
44
+ }
45
+ interface ActionFailureDetails {
46
+ blocker?: ActionFailureBlocker;
47
+ observation?: string;
48
+ }
49
+ interface ActionFailure {
50
+ code: ActionFailureCode;
51
+ message: string;
52
+ retryable: boolean;
53
+ classificationSource: ActionFailureClassificationSource;
54
+ details?: ActionFailureDetails;
55
+ }
56
+
57
+ type SnapshotMode = 'action' | 'extraction' | 'clickable' | 'scrollable' | 'full';
58
+ interface SnapshotOptions {
59
+ mode?: SnapshotMode;
60
+ withCounters?: boolean;
61
+ markInteractive?: boolean;
62
+ }
63
+ interface ScreenshotOptions {
64
+ fullPage?: boolean;
65
+ type?: 'png' | 'jpeg';
66
+ /** Ignored for PNG. */
67
+ quality?: number;
68
+ omitBackground?: boolean;
69
+ }
70
+ interface AiResolveArgs {
71
+ html: string;
72
+ action: string;
73
+ description: string;
74
+ url: string | null;
75
+ }
76
+ interface AiResolveResult {
77
+ element?: number;
78
+ selector?: string;
79
+ path?: ElementPath;
80
+ }
81
+ type AiResolveCallbackResult = AiResolveResult | number | string | null | undefined;
82
+ type AiResolveCallback = (args: AiResolveArgs) => Promise<AiResolveCallbackResult>;
83
+ interface AiExtractArgs<TSchema = ExtractSchema> {
84
+ html: string;
85
+ schema: TSchema;
86
+ description?: string;
87
+ prompt?: string;
88
+ url: string | null;
89
+ }
90
+ type AiExtractResult<TData = unknown> = TData | ExtractionPlan | string;
91
+ type AiExtractCallback = <TSchema = ExtractSchema, TData = unknown>(args: AiExtractArgs<TSchema>) => Promise<AiExtractResult<TData>>;
92
+ interface GotoOptions {
93
+ timeout?: number;
94
+ waitUntil?: 'commit' | 'domcontentloaded' | 'load' | 'networkidle';
95
+ settleMs?: number;
96
+ }
97
+ interface LaunchOptions {
98
+ headless?: boolean;
99
+ executablePath?: string;
100
+ slowMo?: number;
101
+ context?: BrowserContextOptions;
102
+ /** Connect to a running browser. Example: "http://localhost:9222" */
103
+ connectUrl?: string;
104
+ /** Browser channel: "chrome", "chrome-beta", or "msedge" */
105
+ channel?: string;
106
+ /** Browser profile directory. Preserves cookies, extensions, and sessions. */
107
+ profileDir?: string;
108
+ /** Connection timeout in milliseconds. */
109
+ timeout?: number;
110
+ }
111
+ interface OpensteerBrowserConfig {
112
+ headless?: boolean;
113
+ executablePath?: string;
114
+ slowMo?: number;
115
+ /** Connect to a running browser. Example: "http://localhost:9222" */
116
+ connectUrl?: string;
117
+ /** Browser channel: "chrome", "chrome-beta", or "msedge" */
118
+ channel?: string;
119
+ /** Browser profile directory. Preserves cookies, extensions, and sessions. */
120
+ profileDir?: string;
121
+ }
122
+ interface OpensteerStorageConfig {
123
+ rootDir?: string;
124
+ }
125
+ type OpensteerMode = 'local' | 'remote';
126
+ interface OpensteerRemoteOptions {
127
+ apiKey?: string;
128
+ baseUrl?: string;
129
+ }
130
+ interface OpensteerConfig {
131
+ name?: string;
132
+ browser?: OpensteerBrowserConfig;
133
+ storage?: OpensteerStorageConfig;
134
+ mode?: OpensteerMode;
135
+ remote?: OpensteerRemoteOptions;
136
+ model?: string;
137
+ debug?: boolean;
138
+ }
139
+ interface ActionWaitOptions {
140
+ enabled?: boolean;
141
+ timeout?: number;
142
+ settleMs?: number;
143
+ networkQuietMs?: number;
144
+ includeNetwork?: boolean;
145
+ }
146
+ interface BaseActionOptions {
147
+ description?: string;
148
+ element?: number;
149
+ selector?: string;
150
+ wait?: false | ActionWaitOptions;
151
+ }
152
+ interface ClickOptions extends BaseActionOptions {
153
+ button?: 'left' | 'right' | 'middle';
154
+ clickCount?: number;
155
+ modifiers?: Array<'Alt' | 'Control' | 'Meta' | 'Shift'>;
156
+ }
157
+ interface HoverOptions extends BaseActionOptions {
158
+ force?: boolean;
159
+ position?: {
160
+ x: number;
161
+ y: number;
162
+ };
163
+ }
164
+ interface InputOptions extends BaseActionOptions {
165
+ text: string;
166
+ clear?: boolean;
167
+ pressEnter?: boolean;
168
+ }
169
+ interface SelectOptions extends BaseActionOptions {
170
+ value?: string;
171
+ label?: string;
172
+ index?: number;
173
+ }
174
+ interface ScrollOptions extends BaseActionOptions {
175
+ direction?: 'up' | 'down' | 'left' | 'right';
176
+ amount?: number;
177
+ }
178
+ interface ExtractSchemaField {
179
+ element?: number;
180
+ selector?: string;
181
+ attribute?: string;
182
+ source?: 'current_url';
183
+ }
184
+ type ExtractSchemaValue = ExtractSchemaField | string | number | boolean | null | ExtractSchema | ExtractSchema[];
185
+ interface ExtractSchema {
186
+ [key: string]: ExtractSchemaValue;
187
+ }
188
+ interface ExtractOptions<TSchema = ExtractSchema> extends BaseActionOptions {
189
+ schema?: TSchema;
190
+ prompt?: string;
191
+ snapshot?: SnapshotOptions;
192
+ }
193
+ interface ExtractionFieldPlan {
194
+ element?: number;
195
+ selector?: string;
196
+ attribute?: string;
197
+ source?: 'current_url';
198
+ }
199
+ interface ExtractionPlan {
200
+ fields?: Record<string, ExtractionFieldPlan>;
201
+ paths?: Record<string, ElementPath>;
202
+ data?: unknown;
203
+ }
204
+ interface ExtractFromPlanOptions<TSchema = ExtractSchema> {
205
+ description?: string;
206
+ schema: TSchema;
207
+ plan: ExtractionPlan;
208
+ }
209
+ interface ActionResult {
210
+ method: string;
211
+ namespace: string;
212
+ persisted: boolean;
213
+ pathFile: string | null;
214
+ selectorUsed?: string | null;
215
+ }
216
+ interface ExtractionRunResult<T = unknown> {
217
+ namespace: string;
218
+ persisted: boolean;
219
+ pathFile: string | null;
220
+ data: T;
221
+ paths: Record<string, ElementPath>;
222
+ }
223
+ interface StateResult {
224
+ url: string;
225
+ title: string;
226
+ html: string;
227
+ }
228
+ interface TabInfo {
229
+ index: number;
230
+ url: string;
231
+ title: string;
232
+ active: boolean;
233
+ }
234
+ interface CookieParam {
235
+ name: string;
236
+ value: string;
237
+ url?: string;
238
+ domain?: string;
239
+ path?: string;
240
+ expires?: number;
241
+ httpOnly?: boolean;
242
+ secure?: boolean;
243
+ sameSite?: 'Strict' | 'Lax' | 'None';
244
+ }
245
+ interface FileUploadOptions extends BaseActionOptions {
246
+ paths: string[];
247
+ }
248
+ interface BoundingBox {
249
+ x: number;
250
+ y: number;
251
+ width: number;
252
+ height: number;
253
+ }
254
+
255
+ interface RegistryEntry {
256
+ file: string;
257
+ method: string;
258
+ description?: string;
259
+ createdAt: number;
260
+ updatedAt?: number;
261
+ }
262
+ interface SelectorRegistry {
263
+ name: string;
264
+ selectors: Record<string, RegistryEntry>;
265
+ }
266
+ declare function createEmptyRegistry(name: string): SelectorRegistry;
267
+
268
+ interface SelectorFile<T = unknown> {
269
+ id: string;
270
+ method: string;
271
+ description: string;
272
+ path: T;
273
+ schemaHash?: string;
274
+ metadata: {
275
+ createdAt: number;
276
+ updatedAt?: number;
277
+ sourceUrl?: string | null;
278
+ };
279
+ }
280
+ declare class LocalSelectorStorage {
281
+ private rootDir;
282
+ private namespace;
283
+ constructor(rootDir: string, namespace: string);
284
+ getRootDir(): string;
285
+ getNamespace(): string;
286
+ getSelectorFileName(id: string): string;
287
+ getOpensteerDir(): string;
288
+ getNamespaceDir(): string;
289
+ getRegistryPath(): string;
290
+ getSelectorPath(id: string): string;
291
+ ensureDirs(): void;
292
+ loadRegistry(): SelectorRegistry;
293
+ saveRegistry(registry: SelectorRegistry): void;
294
+ readSelector<T = unknown>(id: string): SelectorFile<T> | null;
295
+ writeSelector<T = unknown>(payload: SelectorFile<T>): void;
296
+ clearNamespace(): void;
297
+ }
298
+
299
+ declare class Opensteer {
300
+ private readonly config;
301
+ private readonly aiResolve;
302
+ private readonly aiExtract;
303
+ private readonly namespace;
304
+ private readonly storage;
305
+ private readonly pool;
306
+ private readonly remote;
307
+ private browser;
308
+ private pageRef;
309
+ private contextRef;
310
+ private ownsBrowser;
311
+ private snapshotCache;
312
+ constructor(config?: OpensteerConfig);
313
+ private createLazyResolveCallback;
314
+ private createLazyExtractCallback;
315
+ private invokeRemoteActionAndResetCache;
316
+ private invokeRemoteAction;
317
+ private buildActionError;
318
+ get page(): Page;
319
+ get context(): BrowserContext;
320
+ launch(options?: LaunchOptions): Promise<void>;
321
+ static from(page: Page, config?: OpensteerConfig): Opensteer;
322
+ close(): Promise<void>;
323
+ private syncLocalSelectorCacheToRemote;
324
+ goto(url: string, options?: GotoOptions): Promise<void>;
325
+ snapshot(options?: SnapshotOptions): Promise<string>;
326
+ state(): Promise<StateResult>;
327
+ screenshot(options?: ScreenshotOptions): Promise<Buffer>;
328
+ click(options: ClickOptions): Promise<ActionResult>;
329
+ dblclick(options: ClickOptions): Promise<ActionResult>;
330
+ rightclick(options: ClickOptions): Promise<ActionResult>;
331
+ hover(options: HoverOptions): Promise<ActionResult>;
332
+ input(options: InputOptions): Promise<ActionResult>;
333
+ select(options: SelectOptions): Promise<ActionResult>;
334
+ scroll(options?: ScrollOptions): Promise<ActionResult>;
335
+ tabs(): Promise<TabInfo[]>;
336
+ newTab(url?: string): Promise<TabInfo>;
337
+ switchTab(index: number): Promise<void>;
338
+ closeTab(index?: number): Promise<void>;
339
+ getCookies(url?: string): Promise<playwright.Cookie[]>;
340
+ setCookie(cookie: CookieParam): Promise<void>;
341
+ clearCookies(): Promise<void>;
342
+ exportCookies(filePath: string, url?: string): Promise<void>;
343
+ importCookies(filePath: string): Promise<void>;
344
+ pressKey(key: string): Promise<void>;
345
+ type(text: string): Promise<void>;
346
+ getElementText(options: BaseActionOptions): Promise<string>;
347
+ getElementValue(options: BaseActionOptions): Promise<string>;
348
+ getElementAttributes(options: BaseActionOptions): Promise<Record<string, string>>;
349
+ getElementBoundingBox(options: BaseActionOptions): Promise<BoundingBox | null>;
350
+ getHtml(selector?: string): Promise<string>;
351
+ getTitle(): Promise<string>;
352
+ private executeElementInfoAction;
353
+ uploadFile(options: FileUploadOptions): Promise<ActionResult>;
354
+ waitForText(text: string, options?: {
355
+ timeout?: number;
356
+ }): Promise<void>;
357
+ extract<T = unknown>(options: ExtractOptions): Promise<T>;
358
+ extractFromPlan<T = unknown>(options: ExtractFromPlanOptions): Promise<ExtractionRunResult<T>>;
359
+ getNamespace(): string;
360
+ getConfig(): OpensteerConfig;
361
+ getStorage(): LocalSelectorStorage;
362
+ clearCache(): void;
363
+ private runWithPostActionWait;
364
+ private executeClickVariant;
365
+ private resolvePath;
366
+ private resolvePathWithAi;
367
+ private buildPathFromElement;
368
+ private tryBuildPathFromCounter;
369
+ private resolveCounterHandle;
370
+ private resolveCounterHandleForAction;
371
+ private buildPathFromResolvedHandle;
372
+ private withIndexedIframeContext;
373
+ private readPathFromCounterIndex;
374
+ private buildPathFromSelector;
375
+ private ensureSnapshotWithCounters;
376
+ private persistPath;
377
+ private persistExtractPaths;
378
+ private extractPersistedPayload;
379
+ private extractPersistedObjectNode;
380
+ private extractPersistedArrayVariants;
381
+ private extractPersistedArrayVariantRows;
382
+ private parseAiExtractPlan;
383
+ private buildFieldTargetsFromSchema;
384
+ private collectFieldTargetsFromSchemaObject;
385
+ private collectFieldTargetsFromValue;
386
+ private buildFieldTargetsFromPlan;
387
+ private buildFieldTargetsFromData;
388
+ private extractFields;
389
+ private resolveFieldTargetsToPersistableFields;
390
+ private buildActionResult;
391
+ private resolveStorageKey;
392
+ private normalizePath;
393
+ }
394
+
395
+ interface VisualStabilityOptions {
396
+ timeout?: number;
397
+ settleMs?: number;
398
+ }
399
+ declare function waitForVisualStability(page: Page, options?: VisualStabilityOptions): Promise<void>;
400
+
401
+ interface ActionExecutionResult {
402
+ ok: boolean;
403
+ path?: ElementPath;
404
+ usedSelector?: string;
405
+ error?: string;
406
+ failure?: ActionFailure;
407
+ }
408
+
409
+ interface OpensteerActionErrorOptions {
410
+ action: string;
411
+ failure: ActionFailure;
412
+ selectorUsed?: string | null;
413
+ message?: string;
414
+ cause?: unknown;
415
+ }
416
+ declare class OpensteerActionError extends Error {
417
+ readonly action: string;
418
+ readonly code: ActionFailureCode;
419
+ readonly failure: ActionFailure;
420
+ readonly selectorUsed: string | null;
421
+ constructor(options: OpensteerActionErrorOptions);
422
+ }
423
+
424
+ declare function performClick(page: Page, path: ElementPath, options: ClickOptions): Promise<ActionExecutionResult>;
425
+
426
+ declare function performHover(page: Page, path: ElementPath, options: HoverOptions): Promise<ActionExecutionResult>;
427
+
428
+ declare function performInput(page: Page, path: ElementPath, options: InputOptions): Promise<ActionExecutionResult>;
429
+
430
+ declare function performSelect(page: Page, path: ElementPath, options: SelectOptions): Promise<ActionExecutionResult>;
431
+
432
+ declare function performScroll(page: Page, path: ElementPath | null, options: ScrollOptions): Promise<ActionExecutionResult>;
433
+
434
+ interface FieldSelector {
435
+ key: string;
436
+ path: ElementPath;
437
+ attribute?: string;
438
+ }
439
+ interface ArraySelector {
440
+ itemParentPath: ElementPath;
441
+ fields: FieldSelector[];
442
+ }
443
+ interface ArrayRowMetadata {
444
+ key: string;
445
+ order: number;
446
+ }
447
+ interface ArrayExtractedRow {
448
+ values: Record<string, unknown>;
449
+ meta: ArrayRowMetadata;
450
+ }
451
+ declare function extractWithPaths(page: Page, fields: FieldSelector[]): Promise<Record<string, unknown>>;
452
+ declare function extractArrayWithPaths(page: Page, array: ArraySelector): Promise<Array<Record<string, unknown>>>;
453
+ declare function extractArrayRowsWithPaths(page: Page, array: ArraySelector): Promise<Array<ArrayExtractedRow>>;
454
+ declare function countArrayItemsWithPath(page: Page, itemParentPath: ElementPath): Promise<number>;
455
+
456
+ declare function listTabs(context: BrowserContext, activePage: Page): Promise<TabInfo[]>;
457
+ declare function createTab(context: BrowserContext, url?: string, gotoOptions?: GotoOptions): Promise<{
458
+ page: Page;
459
+ info: TabInfo;
460
+ }>;
461
+ declare function switchTab(context: BrowserContext, index: number): Promise<Page>;
462
+ declare function closeTab(context: BrowserContext, activePage: Page, index?: number): Promise<Page | null>;
463
+
464
+ declare function getCookies(context: BrowserContext, url?: string): Promise<Cookie[]>;
465
+ declare function setCookie(context: BrowserContext, cookie: CookieParam): Promise<void>;
466
+ declare function clearCookies(context: BrowserContext): Promise<void>;
467
+ declare function exportCookies(context: BrowserContext, filePath: string, url?: string): Promise<void>;
468
+ declare function importCookies(context: BrowserContext, filePath: string): Promise<void>;
469
+
470
+ declare function pressKey(page: Page, key: string): Promise<void>;
471
+ declare function typeText(page: Page, text: string): Promise<void>;
472
+
473
+ declare function getElementText(page: Page, path: ElementPath): Promise<string>;
474
+ declare function getElementValue(page: Page, path: ElementPath): Promise<string>;
475
+ declare function getElementAttributes(page: Page, path: ElementPath): Promise<Record<string, string>>;
476
+ declare function getElementBoundingBox(page: Page, path: ElementPath): Promise<BoundingBox | null>;
477
+ declare function getPageHtml(page: Page, selector?: string): Promise<string>;
478
+ declare function getPageTitle(page: Page): Promise<string>;
479
+
480
+ declare function performFileUpload(page: Page, path: ElementPath, filePaths: string[]): Promise<ActionExecutionResult>;
481
+
482
+ declare function cloneElementPath(path: ElementPath): ElementPath;
483
+ declare function buildPathSelectorHint(path: ElementPath): string;
484
+ declare function buildElementPathFromSelector(page: Page, selector: string): Promise<ElementPath | null>;
485
+ declare function buildElementPathFromHandle(handle: ElementHandle): Promise<ElementPath | null>;
486
+ declare function sanitizeElementPath(path: ElementPath): ElementPath;
487
+
488
+ interface ResolvedElementPath {
489
+ element: ElementHandle<Element>;
490
+ usedSelector: string;
491
+ }
492
+ declare function resolveElementPath(page: Page, rawPath: ElementPath): Promise<ResolvedElementPath>;
493
+
494
+ type ElementPathErrorCode = 'ERR_PATH_CONTEXT_HOST_NOT_FOUND' | 'ERR_PATH_IFRAME_UNAVAILABLE' | 'ERR_PATH_SHADOW_ROOT_UNAVAILABLE' | 'ERR_PATH_TARGET_NOT_FOUND' | 'ERR_PATH_TARGET_NOT_UNIQUE';
495
+ declare class ElementPathError extends Error {
496
+ readonly code: ElementPathErrorCode;
497
+ constructor(code: ElementPathErrorCode, message: string);
498
+ }
499
+
500
+ declare const OS_NODE_ID_ATTR = "data-os-node-id";
501
+ declare const OS_BOUNDARY_ATTR = "data-os-boundary";
502
+ declare const OS_UNAVAILABLE_ATTR = "data-os-unavailable";
503
+ declare const OS_IFRAME_BOUNDARY_TAG = "os-iframe-root";
504
+ declare const OS_SHADOW_BOUNDARY_TAG = "os-shadow-root";
505
+ interface SerializeOptions {
506
+ detectOverlays?: boolean;
507
+ }
508
+ interface SerializedPageHTML {
509
+ html: string;
510
+ nodePaths: Map<string, ElementPath>;
511
+ nodeMeta: Map<string, SerializedNodeMeta>;
512
+ }
513
+ interface SerializedNodeMeta {
514
+ frameToken: string;
515
+ instanceToken: string;
516
+ }
517
+ declare function serializePageHTML(page: Page, _options?: SerializeOptions): Promise<SerializedPageHTML>;
518
+
519
+ declare const OPENSTEER_INTERACTIVE_ATTR = "data-opensteer-interactive";
520
+ declare const OPENSTEER_HIDDEN_ATTR = "data-opensteer-hidden";
521
+ declare const OPENSTEER_SCROLLABLE_ATTR = "data-opensteer-scrollable";
522
+ interface MarkInteractivityOptions {
523
+ markAttribute?: string;
524
+ skipIfAlreadyMarked?: boolean;
525
+ }
526
+ declare function markInteractiveElements(page: Page, { markAttribute, skipIfAlreadyMarked, }?: MarkInteractivityOptions): Promise<void>;
527
+
528
+ declare function cleanForFull(html: string): string;
529
+ /**
530
+ * Clean HTML for extraction mode. Mirrors the server's cleanHtmlContent()
531
+ * with leaveAttributes=false, leaveImage=true, leaveLinks=true.
532
+ *
533
+ * 1. Remove noise (scripts, styles, hidden elements, comments).
534
+ * 2. Strip ALL attributes, then re-add only:
535
+ * - `c` and internal pipeline attrs on every element
536
+ * - `src`, `srcset`, `alt` on <img>
537
+ * - `src`, `srcset` on <source> inside <picture>
538
+ * - `href` on <a>
539
+ * 3. Flatten tree (preserve images and links, collapse wrappers).
540
+ * 4. Deduplicate images.
541
+ * 5. Serialize with compact LLM-friendly serializer.
542
+ */
543
+ declare function cleanForExtraction(html: string): string;
544
+ declare function cleanForClickable(html: string): string;
545
+ declare function cleanForScrollable(html: string): string;
546
+ declare function cleanForAction(html: string): string;
547
+
548
+ interface CounterBinding {
549
+ sessionId: string;
550
+ frameToken: string;
551
+ nodeId: string;
552
+ instanceToken: string;
553
+ }
554
+ interface CounterRequest {
555
+ key: string;
556
+ counter: number;
557
+ attribute?: string;
558
+ }
559
+ interface CounterSnapshotLike {
560
+ snapshotSessionId: string;
561
+ counterBindings: Map<number, CounterBinding> | null;
562
+ }
563
+ type CounterResolutionErrorCode = 'ERR_COUNTER_NOT_FOUND' | 'ERR_COUNTER_FRAME_UNAVAILABLE' | 'ERR_COUNTER_STALE_OR_NOT_FOUND' | 'ERR_COUNTER_AMBIGUOUS';
564
+ declare class CounterResolutionError extends Error {
565
+ readonly code: CounterResolutionErrorCode;
566
+ constructor(code: CounterResolutionErrorCode, message: string);
567
+ }
568
+ declare function ensureLiveCounters(page: Page, nodeMeta: Map<string, SerializedNodeMeta>, nodeIds: string[]): Promise<Map<string, number>>;
569
+ declare function resolveCounterElement(page: Page, snapshot: CounterSnapshotLike, counter: number): Promise<ElementHandle<Element>>;
570
+ declare function resolveCountersBatch(page: Page, snapshot: CounterSnapshotLike, requests: CounterRequest[]): Promise<Record<string, unknown>>;
571
+
572
+ interface PreparedSnapshot {
573
+ snapshotSessionId: string;
574
+ mode: SnapshotMode;
575
+ url: string | null;
576
+ rawHtml: string;
577
+ processedHtml: string;
578
+ reducedHtml: string;
579
+ cleanedHtml: string;
580
+ counterIndex: Map<number, ElementPath> | null;
581
+ counterBindings: Map<number, CounterBinding> | null;
582
+ }
583
+ declare function prepareSnapshot(page: Page, options?: SnapshotOptions): Promise<PreparedSnapshot>;
584
+
585
+ declare function normalizeNamespace(input?: string): string;
586
+ declare function resolveNamespaceDir(rootDir: string, namespace: string): string;
587
+
588
+ declare function createResolveCallback(model: string, options?: {
589
+ temperature?: number;
590
+ maxTokens?: number | null;
591
+ }): AiResolveCallback;
592
+
593
+ declare function createExtractCallback(model: string, options?: {
594
+ temperature?: number;
595
+ maxTokens?: number | null;
596
+ }): AiExtractCallback;
597
+
598
+ declare function getModelProvider(modelStr: string): Promise<unknown>;
599
+
600
+ interface AiModelConfig {
601
+ model: string;
602
+ temperature?: number;
603
+ maxTokens?: number | null;
604
+ }
605
+
606
+ type RemoteActionMethod = 'goto' | 'snapshot' | 'state' | 'click' | 'dblclick' | 'rightclick' | 'hover' | 'input' | 'select' | 'scroll' | 'tabs' | 'newTab' | 'switchTab' | 'closeTab' | 'getCookies' | 'setCookie' | 'clearCookies' | 'pressKey' | 'type' | 'getElementText' | 'getElementValue' | 'getElementAttributes' | 'getElementBoundingBox' | 'getHtml' | 'getTitle' | 'waitForText' | 'extract' | 'extractFromPlan' | 'clearCache' | 'uploadFile' | 'exportCookies' | 'importCookies' | 'screenshot';
607
+ type RemoteErrorCode = 'REMOTE_AUTH_FAILED' | 'REMOTE_SESSION_NOT_FOUND' | 'REMOTE_SESSION_CLOSED' | 'REMOTE_UNSUPPORTED_METHOD' | 'REMOTE_INVALID_REQUEST' | 'REMOTE_MODEL_NOT_ALLOWED' | 'REMOTE_ACTION_FAILED' | 'REMOTE_CAPACITY_EXHAUSTED' | 'REMOTE_RUNTIME_UNAVAILABLE' | 'REMOTE_RUNTIME_MISMATCH' | 'REMOTE_SESSION_STALE' | 'REMOTE_CONTROL_PLANE_ERROR' | 'REMOTE_INTERNAL';
608
+ interface RemoteSessionCreateRequest {
609
+ name?: string;
610
+ model?: string;
611
+ launchContext?: Record<string, unknown>;
612
+ }
613
+ interface RemoteSessionCreateResponse {
614
+ sessionId: string;
615
+ actionWsUrl: string;
616
+ cdpWsUrl: string;
617
+ actionToken: string;
618
+ cdpToken: string;
619
+ expiresAt?: number;
620
+ }
621
+ interface RemoteSelectorCacheImportEntry {
622
+ namespace: string;
623
+ siteOrigin: string;
624
+ method: string;
625
+ descriptionHash: string;
626
+ path: unknown;
627
+ schemaHash?: string;
628
+ createdAt: number;
629
+ updatedAt: number;
630
+ }
631
+ interface RemoteSelectorCacheImportRequest {
632
+ entries: RemoteSelectorCacheImportEntry[];
633
+ }
634
+ interface RemoteSelectorCacheImportResponse {
635
+ imported: number;
636
+ inserted: number;
637
+ updated: number;
638
+ skipped: number;
639
+ }
640
+ interface RemoteActionRequest {
641
+ id: number;
642
+ method: RemoteActionMethod;
643
+ args: Record<string, unknown>;
644
+ sessionId: string;
645
+ token: string;
646
+ }
647
+ interface RemoteActionSuccess {
648
+ id: number;
649
+ ok: true;
650
+ result: unknown;
651
+ }
652
+ interface RemoteActionFailure {
653
+ id: number;
654
+ ok: false;
655
+ error: string;
656
+ code: RemoteErrorCode;
657
+ details?: RemoteActionFailureDetails;
658
+ }
659
+ type RemoteActionResponse = RemoteActionSuccess | RemoteActionFailure;
660
+ interface RemoteActionFailureDetails {
661
+ actionFailure?: ActionFailure;
662
+ }
663
+
664
+ declare class OpensteerRemoteError extends Error {
665
+ readonly code: RemoteErrorCode | 'REMOTE_TRANSPORT_ERROR';
666
+ readonly status?: number;
667
+ readonly details?: RemoteActionFailureDetails | Record<string, unknown>;
668
+ constructor(code: RemoteErrorCode | 'REMOTE_TRANSPORT_ERROR', message: string, status?: number, details?: RemoteActionFailureDetails | Record<string, unknown>);
669
+ }
670
+ declare function remoteUnsupportedMethodError(method: string, message?: string): OpensteerRemoteError;
671
+ declare function remoteNotLaunchedError(): OpensteerRemoteError;
672
+
673
+ declare class RemoteSessionClient {
674
+ private readonly baseUrl;
675
+ private readonly key;
676
+ constructor(baseUrl: string, key: string);
677
+ create(request: RemoteSessionCreateRequest): Promise<RemoteSessionCreateResponse>;
678
+ close(sessionId: string): Promise<void>;
679
+ importSelectorCache(request: RemoteSelectorCacheImportRequest): Promise<RemoteSelectorCacheImportResponse>;
680
+ private importSelectorCacheBatch;
681
+ }
682
+
683
+ interface ActionWsClientOptions {
684
+ url: string;
685
+ token: string;
686
+ sessionId: string;
687
+ }
688
+ declare class ActionWsClient {
689
+ private readonly ws;
690
+ private readonly sessionId;
691
+ private readonly token;
692
+ private nextRequestId;
693
+ private readonly pending;
694
+ private closed;
695
+ private constructor();
696
+ static connect(options: ActionWsClientOptions): Promise<ActionWsClient>;
697
+ request<T>(method: RemoteActionMethod, args: Record<string, unknown>): Promise<T>;
698
+ close(): Promise<void>;
699
+ private handleMessage;
700
+ private rejectAll;
701
+ }
702
+
703
+ interface RemoteCdpConnectArgs {
704
+ wsUrl: string;
705
+ token: string;
706
+ }
707
+ interface RemoteCdpConnection {
708
+ browser: Browser;
709
+ context: BrowserContext;
710
+ page: Page;
711
+ }
712
+ declare class RemoteCdpClient {
713
+ connect(args: RemoteCdpConnectArgs): Promise<RemoteCdpConnection>;
714
+ }
715
+
716
+ declare function collectLocalSelectorCacheEntries(storage: LocalSelectorStorage): RemoteSelectorCacheImportEntry[];
717
+
718
+ export { type ActionExecutionResult, type ActionFailure, type ActionFailureBlocker, type ActionFailureClassificationSource, type ActionFailureCode, type ActionFailureDetails, type ActionResult, type ActionWaitOptions, ActionWsClient, type AiExtractArgs, type AiExtractCallback, type AiExtractResult, type AiModelConfig, type AiResolveArgs, type AiResolveCallback, type AiResolveCallbackResult, type AiResolveResult, type ArrayExtractedRow, type ArrayRowMetadata, type ArraySelector, type AttributeMatchClause, type BaseActionOptions, type BoundingBox, type ClickOptions, type ContextHop, type CookieParam, type CounterBinding, type CounterRequest, CounterResolutionError, type CounterResolutionErrorCode, type CounterSnapshotLike, type DomPath, type ElementPath, ElementPathError, type ElementPathErrorCode, type ExtractFromPlanOptions, type ExtractOptions, type ExtractSchema, type ExtractSchemaField, type ExtractSchemaValue, type ExtractionFieldPlan, type ExtractionPlan, type ExtractionRunResult, type FieldSelector, type FileUploadOptions, type GotoOptions, type HoverOptions, type InputOptions, type LaunchOptions, LocalSelectorStorage, type MarkInteractivityOptions, type MatchClause, type MatchOperator, OPENSTEER_HIDDEN_ATTR, OPENSTEER_INTERACTIVE_ATTR, OPENSTEER_SCROLLABLE_ATTR, OS_BOUNDARY_ATTR, OS_IFRAME_BOUNDARY_TAG, OS_NODE_ID_ATTR, OS_SHADOW_BOUNDARY_TAG, OS_UNAVAILABLE_ATTR, Opensteer, OpensteerActionError, type OpensteerBrowserConfig, type OpensteerConfig, type OpensteerMode, OpensteerRemoteError, type OpensteerRemoteOptions, type OpensteerStorageConfig, type PathNode, type PathNodePosition, type PositionMatchClause, type PreparedSnapshot, type RegistryEntry, type RemoteActionFailure, type RemoteActionFailureDetails, type RemoteActionMethod, type RemoteActionRequest, type RemoteActionResponse, type RemoteActionSuccess, RemoteCdpClient, type RemoteCdpConnectArgs, type RemoteCdpConnection, type RemoteErrorCode, type RemoteSelectorCacheImportEntry, type RemoteSelectorCacheImportRequest, type RemoteSelectorCacheImportResponse, RemoteSessionClient, type RemoteSessionCreateRequest, type RemoteSessionCreateResponse, type ResolvedElementPath, type ScreenshotOptions, type ScrollOptions, type SelectOptions, type SelectorFile, type SelectorRegistry, type SerializeOptions, type SerializedNodeMeta, type SerializedPageHTML, type SnapshotMode, type SnapshotOptions, type StateResult, type TabInfo, buildElementPathFromHandle, buildElementPathFromSelector, buildPathSelectorHint, cleanForAction, cleanForClickable, cleanForExtraction, cleanForFull, cleanForScrollable, clearCookies, cloneElementPath, closeTab, collectLocalSelectorCacheEntries, countArrayItemsWithPath, createEmptyRegistry, createExtractCallback, createResolveCallback, createTab, ensureLiveCounters, exportCookies, extractArrayRowsWithPaths, extractArrayWithPaths, extractWithPaths, getCookies, getElementAttributes, getElementBoundingBox, getElementText, getElementValue, getModelProvider, getPageHtml, getPageTitle, importCookies, listTabs, markInteractiveElements, normalizeNamespace, performClick, performFileUpload, performHover, performInput, performScroll, performSelect, prepareSnapshot, pressKey, remoteNotLaunchedError, remoteUnsupportedMethodError, resolveCounterElement, resolveCountersBatch, resolveElementPath, resolveNamespaceDir, sanitizeElementPath, serializePageHTML, setCookie, switchTab, typeText, waitForVisualStability };