@browserbridge/bbx 1.2.0 → 1.4.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 (35) hide show
  1. package/README.md +8 -5
  2. package/package.json +2 -2
  3. package/packages/agent-client/src/cli.js +56 -31
  4. package/packages/agent-client/src/client.js +81 -65
  5. package/packages/agent-client/src/command-registry.js +4 -15
  6. package/packages/agent-client/src/detect.js +3 -3
  7. package/packages/agent-client/src/install.js +3 -7
  8. package/packages/agent-client/src/mcp-config.js +20 -5
  9. package/packages/agent-client/src/runtime.js +7 -41
  10. package/packages/agent-client/src/setup-status.js +3 -13
  11. package/packages/agent-client/src/types.ts +139 -0
  12. package/packages/mcp-server/src/guidance.js +241 -0
  13. package/packages/mcp-server/src/handlers-capture.js +91 -16
  14. package/packages/mcp-server/src/handlers-dom.js +59 -4
  15. package/packages/mcp-server/src/handlers-navigation.js +22 -2
  16. package/packages/mcp-server/src/handlers-page.js +6 -11
  17. package/packages/mcp-server/src/handlers-utils.js +69 -1
  18. package/packages/mcp-server/src/server.js +111 -28
  19. package/packages/native-host/bin/postinstall.js +42 -21
  20. package/packages/native-host/src/auth-token.js +92 -0
  21. package/packages/native-host/src/daemon-process.js +1 -2
  22. package/packages/native-host/src/daemon.js +199 -30
  23. package/packages/native-host/src/framing.js +13 -0
  24. package/packages/native-host/src/native-host.js +25 -7
  25. package/packages/protocol/src/defaults.js +3 -0
  26. package/packages/protocol/src/json-lines.js +29 -1
  27. package/packages/protocol/src/protocol.js +43 -0
  28. package/packages/protocol/src/registry.js +3 -9
  29. package/packages/protocol/src/types.ts +574 -0
  30. package/skills/browser-bridge/SKILL.md +21 -5
  31. package/skills/browser-bridge/agents/openai.yaml +1 -1
  32. package/skills/browser-bridge/references/interaction.md +6 -6
  33. package/skills/browser-bridge/references/protocol.md +57 -54
  34. package/skills/browser-bridge/references/ui-workflows.md +1 -1
  35. package/packages/protocol/src/types.js +0 -626
@@ -1,626 +0,0 @@
1
- // @ts-check
2
-
3
- export {};
4
-
5
- /**
6
- * @typedef {'cli' | 'mcp'} BridgeRequestSource
7
- */
8
-
9
- /**
10
- * @typedef {'page.read' | 'page.evaluate' | 'dom.read' | 'styles.read' | 'layout.read' | 'viewport.control' | 'navigation.control' | 'screenshot.partial' | 'patch.dom' | 'patch.styles' | 'cdp.dom_snapshot' | 'cdp.box_model' | 'cdp.styles' | 'cdp.input' | 'automation.input' | 'tabs.manage' | 'performance.read' | 'network.read'} Capability
11
- */
12
-
13
- /**
14
- * @typedef {'ACCESS_DENIED' | 'TAB_MISMATCH' | 'ELEMENT_STALE' | 'RESULT_TRUNCATED' | 'RATE_LIMITED' | 'INTERNAL_ERROR' | 'INVALID_REQUEST' | 'NATIVE_HOST_UNAVAILABLE' | 'EXTENSION_DISCONNECTED' | 'TIMEOUT'} ErrorCode
15
- */
16
-
17
- /**
18
- * @typedef {'access.request' | 'tabs.list' | 'tabs.create' | 'tabs.close' | 'skill.get_runtime_context' | 'setup.get_status' | 'setup.install' | 'page.get_state' | 'page.evaluate' | 'page.get_console' | 'page.wait_for_load_state' | 'page.get_storage' | 'page.get_text' | 'page.get_network' | 'navigation.navigate' | 'navigation.reload' | 'navigation.go_back' | 'navigation.go_forward' | 'dom.query' | 'dom.describe' | 'dom.get_text' | 'dom.get_attributes' | 'dom.wait_for' | 'dom.find_by_text' | 'dom.find_by_role' | 'dom.get_html' | 'dom.get_accessibility_tree' | 'layout.get_box_model' | 'layout.hit_test' | 'styles.get_computed' | 'styles.get_matched_rules' | 'viewport.scroll' | 'viewport.resize' | 'input.click' | 'input.focus' | 'input.type' | 'input.press_key' | 'input.set_checked' | 'input.select_option' | 'input.hover' | 'input.drag' | 'input.scroll_into_view' | 'screenshot.capture_region' | 'screenshot.capture_element' | 'screenshot.capture_full_page' | 'patch.apply_styles' | 'patch.apply_dom' | 'patch.list' | 'patch.rollback' | 'patch.commit_session_baseline' | 'cdp.get_document' | 'cdp.get_dom_snapshot' | 'cdp.get_box_model' | 'cdp.get_computed_styles_for_node' | 'cdp.dispatch_key_event' | 'performance.get_metrics' | 'log.tail' | 'health.ping' | 'daemon.metrics'} BridgeMethod
19
- */
20
-
21
- /**
22
- * @typedef {{
23
- * protocol_version?: string,
24
- * token_budget?: number | null,
25
- * transport_bytes?: number,
26
- * transport_approx_tokens?: number,
27
- * transport_cost_class?: 'cheap' | 'moderate' | 'heavy' | 'extreme',
28
- * text_bytes?: number,
29
- * text_approx_tokens?: number,
30
- * text_cost_class?: 'cheap' | 'moderate' | 'heavy' | 'extreme',
31
- * image_approx_tokens?: number,
32
- * image_bytes?: number,
33
- * source?: BridgeRequestSource,
34
- * response_bytes?: number,
35
- * approx_tokens?: number,
36
- * cost_class?: 'cheap' | 'moderate' | 'heavy' | 'extreme',
37
- * debugger_backed?: boolean,
38
- * budget_applied?: boolean,
39
- * budget_truncated?: boolean,
40
- * continuation_hint?: string | null,
41
- * [key: string]: unknown
42
- * }} BridgeMeta
43
- */
44
-
45
- /**
46
- * @typedef {{
47
- * id: string,
48
- * method: BridgeMethod,
49
- * tab_id: number | null,
50
- * params: Record<string, unknown>,
51
- * meta: Required<Pick<BridgeMeta, 'protocol_version' | 'token_budget'>> & Record<string, unknown>
52
- * }} BridgeRequest
53
- */
54
-
55
- /**
56
- * @typedef {{
57
- * hint: string,
58
- * retry?: boolean,
59
- * retryAfterMs?: number
60
- * }} BridgeRecovery
61
- */
62
-
63
- /**
64
- * @typedef {{
65
- * code: ErrorCode,
66
- * message: string,
67
- * details: unknown,
68
- * recovery?: BridgeRecovery
69
- * }} BridgeFailure
70
- */
71
-
72
- /**
73
- * @typedef {{
74
- * id: string,
75
- * ok: true,
76
- * result: unknown,
77
- * error: null,
78
- * meta: { protocol_version: string } & Record<string, unknown>
79
- * }} BridgeSuccessResponse
80
- */
81
-
82
- /**
83
- * @typedef {{
84
- * id: string,
85
- * ok: false,
86
- * result: null,
87
- * error: BridgeFailure,
88
- * meta: { protocol_version: string } & Record<string, unknown>
89
- * }} BridgeFailureResponse
90
- */
91
-
92
- /**
93
- * @typedef {BridgeSuccessResponse | BridgeFailureResponse} BridgeResponse
94
- */
95
-
96
- /**
97
- * @typedef {{
98
- * maxNodes?: number,
99
- * maxDepth?: number,
100
- * textBudget?: number,
101
- * includeBbox?: boolean,
102
- * attributeAllowlist?: string[]
103
- * }} BudgetOptions
104
- */
105
-
106
- /**
107
- * @typedef {{
108
- * maxNodes: number,
109
- * maxDepth: number,
110
- * textBudget: number,
111
- * includeBbox: boolean,
112
- * attributeAllowlist: string[]
113
- * }} Budget
114
- */
115
-
116
- /**
117
- * @typedef {{
118
- * value: string,
119
- * truncated: boolean,
120
- * omitted: number
121
- * }} TruncateResult
122
- */
123
-
124
- /**
125
- * @typedef {{
126
- * selector?: string,
127
- * withinRef?: string | null,
128
- * maxNodes?: number,
129
- * maxDepth?: number,
130
- * textBudget?: number,
131
- * includeBbox?: boolean,
132
- * attributeAllowlist?: string[]
133
- * }} DomQueryParams
134
- */
135
-
136
- /**
137
- * @typedef {{
138
- * selector: string,
139
- * withinRef: string | null,
140
- * budget: Budget
141
- * }} NormalizedDomQuery
142
- */
143
-
144
- /**
145
- * @typedef {{
146
- * elementRef?: string,
147
- * target?: {
148
- * elementRef?: string,
149
- * selector?: string
150
- * },
151
- * properties?: string[]
152
- * }} StyleQueryParams
153
- */
154
-
155
- /**
156
- * @typedef {{
157
- * elementRef: string,
158
- * target: {
159
- * elementRef?: string,
160
- * selector?: string
161
- * },
162
- * properties: string[]
163
- * }} NormalizedStyleQuery
164
- */
165
-
166
- /**
167
- * @typedef {{
168
- * elementRef?: string,
169
- * selector?: string
170
- * }} InputTarget
171
- */
172
-
173
- /**
174
- * @typedef {{
175
- * target?: InputTarget,
176
- * button?: 'left' | 'middle' | 'right',
177
- * clickCount?: number,
178
- * text?: string,
179
- * clear?: boolean,
180
- * submit?: boolean,
181
- * key?: string,
182
- * modifiers?: string[]
183
- * }} InputActionParams
184
- */
185
-
186
- /**
187
- * @typedef {{
188
- * target: InputTarget,
189
- * button: 'left' | 'middle' | 'right',
190
- * clickCount: number,
191
- * text: string,
192
- * clear: boolean,
193
- * submit: boolean,
194
- * key: string,
195
- * modifiers: string[]
196
- * }} NormalizedInputAction
197
- */
198
-
199
- /**
200
- * @typedef {{
201
- * key?: string,
202
- * code?: string,
203
- * modifiers?: string[] | number
204
- * }} CdpDispatchKeyEventParams
205
- */
206
-
207
- /**
208
- * @typedef {{
209
- * key: string,
210
- * code: string,
211
- * modifiers: string[] | number
212
- * }} NormalizedCdpDispatchKeyEventParams
213
- */
214
-
215
- /**
216
- * @typedef {{
217
- * target?: InputTarget,
218
- * checked?: boolean
219
- * }} CheckedActionParams
220
- */
221
-
222
- /**
223
- * @typedef {{
224
- * target: InputTarget,
225
- * checked: boolean
226
- * }} NormalizedCheckedAction
227
- */
228
-
229
- /**
230
- * @typedef {{
231
- * target?: InputTarget,
232
- * values?: string[],
233
- * labels?: string[],
234
- * indexes?: number[]
235
- * }} SelectActionParams
236
- */
237
-
238
- /**
239
- * @typedef {{
240
- * target: InputTarget,
241
- * values: string[],
242
- * labels: string[],
243
- * indexes: number[]
244
- * }} NormalizedSelectAction
245
- */
246
-
247
- /**
248
- * @typedef {{
249
- * target?: InputTarget,
250
- * top?: number,
251
- * left?: number,
252
- * behavior?: 'auto' | 'smooth',
253
- * relative?: boolean
254
- * }} ViewportActionParams
255
- */
256
-
257
- /**
258
- * @typedef {{
259
- * target: InputTarget,
260
- * top: number,
261
- * left: number,
262
- * behavior: 'auto' | 'smooth',
263
- * relative: boolean
264
- * }} NormalizedViewportAction
265
- */
266
-
267
- /**
268
- * @typedef {{
269
- * url?: string,
270
- * waitForLoad?: boolean,
271
- * timeoutMs?: number
272
- * }} NavigationActionParams
273
- */
274
-
275
- /**
276
- * @typedef {{
277
- * url: string,
278
- * waitForLoad: boolean,
279
- * timeoutMs: number
280
- * }} NormalizedNavigationAction
281
- */
282
-
283
- /**
284
- * @typedef {{
285
- * patchId?: string | null,
286
- * target?: Record<string, unknown>,
287
- * operation?: string | null,
288
- * name?: string | null,
289
- * declarations?: Record<string, string>,
290
- * value?: unknown,
291
- * important?: boolean,
292
- * verify?: boolean
293
- * }} PatchOperationParams
294
- */
295
-
296
- /**
297
- * @typedef {{
298
- * patchId: string | null,
299
- * target: Record<string, unknown>,
300
- * operation: string | null,
301
- * name: string | null,
302
- * declarations: Record<string, string>,
303
- * value: unknown,
304
- * important: boolean,
305
- * verify: boolean
306
- * }} NormalizedPatchOperation
307
- */
308
-
309
- /**
310
- * @typedef {{
311
- * key: string,
312
- * label: string,
313
- * detected: boolean,
314
- * configPath: string,
315
- * configExists: boolean,
316
- * configured: boolean
317
- * }} McpClientStatus
318
- */
319
-
320
- /**
321
- * @typedef {{
322
- * name: string,
323
- * path: string,
324
- * exists: boolean,
325
- * managed: boolean,
326
- * version: string | null
327
- * }} SkillInstallationStatus
328
- */
329
-
330
- /**
331
- * @typedef {{
332
- * key: string,
333
- * label: string,
334
- * detected: boolean,
335
- * basePath: string,
336
- * installed: boolean,
337
- * managed: boolean,
338
- * installedVersion: string | null,
339
- * currentVersion: string | null,
340
- * updateAvailable: boolean,
341
- * skills: SkillInstallationStatus[]
342
- * }} SkillTargetStatus
343
- */
344
-
345
- /**
346
- * @typedef {{
347
- * scope: 'global' | 'local',
348
- * mcpClients: McpClientStatus[],
349
- * skillTargets: SkillTargetStatus[]
350
- * }} SetupStatus
351
- */
352
-
353
- /**
354
- * @typedef {{
355
- * action?: 'install' | 'uninstall',
356
- * kind?: 'mcp' | 'skill',
357
- * target?: string
358
- * }} SetupInstallParams
359
- */
360
-
361
- /**
362
- * @typedef {{
363
- * action: 'install' | 'uninstall',
364
- * kind: 'mcp' | 'skill',
365
- * target: string,
366
- * paths: string[]
367
- * }} SetupInstallResult
368
- */
369
-
370
- /**
371
- * @typedef {{
372
- * expression?: string,
373
- * awaitPromise?: boolean,
374
- * timeoutMs?: number,
375
- * returnByValue?: boolean
376
- * }} EvaluateParams
377
- */
378
-
379
- /**
380
- * @typedef {{
381
- * expression: string,
382
- * awaitPromise: boolean,
383
- * timeoutMs: number,
384
- * returnByValue: boolean
385
- * }} NormalizedEvaluateParams
386
- */
387
-
388
- /**
389
- * @typedef {{
390
- * level?: string,
391
- * clear?: boolean,
392
- * limit?: number
393
- * }} ConsoleParams
394
- */
395
-
396
- /**
397
- * @typedef {{
398
- * level: string,
399
- * clear: boolean,
400
- * limit: number
401
- * }} NormalizedConsoleParams
402
- */
403
-
404
- /**
405
- * @typedef {{
406
- * selector?: string,
407
- * text?: string,
408
- * state?: 'attached' | 'detached' | 'visible' | 'hidden',
409
- * timeoutMs?: number
410
- * }} WaitForParams
411
- */
412
-
413
- /**
414
- * @typedef {{
415
- * selector: string,
416
- * text: string | null,
417
- * state: 'attached' | 'detached' | 'visible' | 'hidden',
418
- * timeoutMs: number
419
- * }} NormalizedWaitForParams
420
- */
421
-
422
- /**
423
- * @typedef {{
424
- * text?: string,
425
- * exact?: boolean,
426
- * selector?: string,
427
- * maxResults?: number
428
- * }} FindByTextParams
429
- */
430
-
431
- /**
432
- * @typedef {{
433
- * text: string,
434
- * exact: boolean,
435
- * selector: string,
436
- * maxResults: number
437
- * }} NormalizedFindByTextParams
438
- */
439
-
440
- /**
441
- * @typedef {{
442
- * role?: string,
443
- * name?: string,
444
- * selector?: string,
445
- * maxResults?: number
446
- * }} FindByRoleParams
447
- */
448
-
449
- /**
450
- * @typedef {{
451
- * role: string,
452
- * name: string,
453
- * selector: string,
454
- * maxResults: number
455
- * }} NormalizedFindByRoleParams
456
- */
457
-
458
- /**
459
- * @typedef {{
460
- * elementRef?: string,
461
- * target?: {
462
- * elementRef?: string,
463
- * selector?: string
464
- * },
465
- * outer?: boolean,
466
- * maxLength?: number
467
- * }} GetHtmlParams
468
- */
469
-
470
- /**
471
- * @typedef {{
472
- * elementRef: string,
473
- * target: {
474
- * elementRef?: string,
475
- * selector?: string
476
- * },
477
- * outer: boolean,
478
- * maxLength: number
479
- * }} NormalizedGetHtmlParams
480
- */
481
-
482
- /**
483
- * @typedef {{
484
- * target?: InputTarget,
485
- * duration?: number
486
- * }} HoverParams
487
- */
488
-
489
- /**
490
- * @typedef {{
491
- * target: InputTarget,
492
- * duration: number
493
- * }} NormalizedHoverParams
494
- */
495
-
496
- /**
497
- * @typedef {{
498
- * source?: InputTarget,
499
- * destination?: InputTarget,
500
- * offsetX?: number,
501
- * offsetY?: number
502
- * }} DragParams
503
- */
504
-
505
- /**
506
- * @typedef {{
507
- * source: InputTarget,
508
- * destination: InputTarget,
509
- * offsetX: number,
510
- * offsetY: number
511
- * }} NormalizedDragParams
512
- */
513
-
514
- /**
515
- * @typedef {{
516
- * type?: 'local' | 'session',
517
- * keys?: string[]
518
- * }} StorageParams
519
- */
520
-
521
- /**
522
- * @typedef {{
523
- * type: 'local' | 'session',
524
- * keys: string[] | null
525
- * }} NormalizedStorageParams
526
- */
527
-
528
- /**
529
- * @typedef {{
530
- * waitForLoad?: boolean,
531
- * timeoutMs?: number
532
- * }} WaitForLoadStateParams
533
- */
534
-
535
- /**
536
- * @typedef {{
537
- * waitForLoad: boolean,
538
- * timeoutMs: number
539
- * }} NormalizedWaitForLoadStateParams
540
- */
541
-
542
- /**
543
- * @typedef {{
544
- * url?: string,
545
- * active?: boolean
546
- * }} TabCreateParams
547
- */
548
-
549
- /**
550
- * @typedef {{
551
- * url: string,
552
- * active: boolean
553
- * }} NormalizedTabCreateParams
554
- */
555
-
556
- /**
557
- * @typedef {{
558
- * tabId?: number
559
- * }} TabCloseParams
560
- */
561
-
562
- /**
563
- * @typedef {{
564
- * tabId: number
565
- * }} NormalizedTabCloseParams
566
- */
567
-
568
- /**
569
- * @typedef {{
570
- * maxDepth?: number,
571
- * maxNodes?: number
572
- * }} AccessibilityTreeParams
573
- */
574
-
575
- /**
576
- * @typedef {{
577
- * maxDepth: number,
578
- * maxNodes: number
579
- * }} NormalizedAccessibilityTreeParams
580
- */
581
-
582
- /**
583
- * @typedef {{
584
- * clear?: boolean,
585
- * limit?: number,
586
- * urlPattern?: string
587
- * }} NetworkParams
588
- */
589
-
590
- /**
591
- * @typedef {{
592
- * clear: boolean,
593
- * limit: number,
594
- * urlPattern: string | null
595
- * }} NormalizedNetworkParams
596
- */
597
-
598
- /**
599
- * @typedef {{
600
- * textBudget?: number
601
- * }} PageTextParams
602
- */
603
-
604
- /**
605
- * @typedef {{
606
- * textBudget: number
607
- * }} NormalizedPageTextParams
608
- */
609
-
610
- /**
611
- * @typedef {{
612
- * width?: number,
613
- * height?: number,
614
- * deviceScaleFactor?: number,
615
- * reset?: boolean
616
- * }} ViewportResizeParams
617
- */
618
-
619
- /**
620
- * @typedef {{
621
- * width: number,
622
- * height: number,
623
- * deviceScaleFactor: number,
624
- * reset: boolean
625
- * }} NormalizedViewportResizeParams
626
- */