browserbeam 0.2.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 968540abd1c037b539260f27cf439d8f49d05a25f16e398cd56f56dc6d2c4591
4
- data.tar.gz: fb7920bc04046dd96d62277826d2e3b4a83fce58d96961b65643686326c510d3
3
+ metadata.gz: 6b0481857f0872498c855f5c1cc7611f468f348e406299601fde653abb148487
4
+ data.tar.gz: 989f1e433800e1d2132cadb9bb83e8497884939da70deffe0e5148c21b74c647
5
5
  SHA512:
6
- metadata.gz: bfe0019f622ff4273922faa8bc386264e013c33706f4ae3fe4921c68e04a42e9b7340b61874801df22d14efbc98529de2b5ef6937469e857f78377461a8a8f66
7
- data.tar.gz: f4708420e29384d4a70d4ec10fe21d1d0b43a9cd83a9973c35d90991337e4175e1cd693da190cf0271d2e65b132958c1425ef1bd0b811171c18f12fd82aeee7e
6
+ metadata.gz: 0605be53e22028d51513793fb6f0542caac9a131135ea1566fff865f7a5087f3c8b168569749fefc4cb1473f46b9e0accc22020c66495d4493caae72f46815f9
7
+ data.tar.gz: c5d700fbcac26e7757a891729071e7cb959007e0b4f8d8b7b51a16d34a145af168db7f108b726f0e24f67ed41f67d571c33db1d1992c76320a2091656fbb1764
data/README.md CHANGED
@@ -71,7 +71,7 @@ session = client.sessions.create(
71
71
  | Method | Description |
72
72
  |--------|-------------|
73
73
  | `session.goto(url)` | Navigate to a URL |
74
- | `session.observe` | Get page state as markdown |
74
+ | `session.observe` | Get page state as markdown. Supports `mode: "full"` for all sections. |
75
75
  | `session.click(ref:)` | Click an element by ref, text, or label |
76
76
  | `session.fill(value, ref:)` | Fill an input field |
77
77
  | `session.type(value, label:)` | Type text character by character |
@@ -87,6 +87,37 @@ session = client.sessions.create(
87
87
  | `session.execute_js(code)` | Run JavaScript |
88
88
  | `session.close` | Close the session |
89
89
 
90
+ ## Page Map & Full Mode
91
+
92
+ The first `observe` call automatically includes a `page.map` — a lightweight structural outline of the page's landmark regions (header, nav, main, aside, footer) with CSS selectors and descriptive hints. Use it to discover what content is available outside the main area.
93
+
94
+ ```ruby
95
+ res = session.observe
96
+ res.page.map.each { |entry| puts "#{entry.section}: #{entry.hint}" }
97
+ # nav: Home · Docs · Pricing
98
+ # main: Getting started with Browserbeam...
99
+ # aside: Related posts · Popular tags
100
+ ```
101
+
102
+ To re-request the map on subsequent calls:
103
+
104
+ ```ruby
105
+ session.observe(include_page_map: true)
106
+ ```
107
+
108
+ When you need content from **all** page sections (sidebars, footer links, nav items), use `mode: "full"`. The response markdown is organized by region headers:
109
+
110
+ ```ruby
111
+ full = session.observe(mode: "full", max_text_length: 20_000)
112
+ puts full.page.markdown.content
113
+ # ## [nav]
114
+ # Home · Docs · Pricing
115
+ # ## [main]
116
+ # ...article content...
117
+ # ## [aside]
118
+ # Related posts · ...
119
+ ```
120
+
90
121
  ## Session Management
91
122
 
92
123
  ```ruby
@@ -27,10 +27,12 @@ module Browserbeam
27
27
  act([{ goto: params }])
28
28
  end
29
29
 
30
- def observe(scope: nil, format: nil, include_links: nil, max_text_length: nil)
30
+ def observe(scope: nil, format: nil, mode: nil, include_page_map: nil, include_links: nil, max_text_length: nil)
31
31
  params = {}
32
32
  params[:scope] = scope if scope
33
33
  params[:format] = format if format
34
+ params[:mode] = mode if mode
35
+ params[:include_page_map] = include_page_map unless include_page_map.nil?
34
36
  params[:include_links] = include_links unless include_links.nil?
35
37
  params[:max_text_length] = max_text_length if max_text_length
36
38
  act([{ observe: params }])
@@ -18,6 +18,12 @@ module Browserbeam
18
18
  end
19
19
  end
20
20
 
21
+ MapEntry = Struct.new(:section, :selector, :hint, keyword_init: true) do
22
+ def self.from_hash(data)
23
+ new(section: data["section"] || "", selector: data["selector"] || "", hint: data["hint"] || "")
24
+ end
25
+ end
26
+
21
27
  Changes = Struct.new(:content_changed, :content_delta, :elements_added, :elements_removed, keyword_init: true) do
22
28
  def self.from_hash(data)
23
29
  return nil unless data.is_a?(Hash)
@@ -37,7 +43,7 @@ module Browserbeam
37
43
  end
38
44
  end
39
45
 
40
- PageState = Struct.new(:url, :title, :stable, :markdown, :interactive_elements, :forms, :changes, :scroll, keyword_init: true) do
46
+ PageState = Struct.new(:url, :title, :stable, :markdown, :map, :interactive_elements, :forms, :changes, :scroll, keyword_init: true) do
41
47
  def self.from_hash(data)
42
48
  return nil unless data.is_a?(Hash)
43
49
  new(
@@ -45,6 +51,7 @@ module Browserbeam
45
51
  title: data["title"] || "",
46
52
  stable: data["stable"] || false,
47
53
  markdown: MarkdownContent.from_hash(data["markdown"]),
54
+ map: data["map"] ? data["map"].map { |m| MapEntry.from_hash(m) } : nil,
48
55
  interactive_elements: (data["interactive_elements"] || []).map { |el| InteractiveElement.from_hash(el) },
49
56
  forms: data["forms"] || [],
50
57
  changes: Changes.from_hash(data["changes"]),
@@ -1,3 +1,3 @@
1
1
  module Browserbeam
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browserbeam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Browserbeam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-25 00:00:00.000000000 Z
11
+ date: 2026-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday