stagehand 0.0.3 → 3.5.2
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 +7 -0
- data/.ignore +2 -0
- data/CHANGELOG.md +185 -0
- data/README.md +394 -31
- data/SECURITY.md +23 -0
- data/lib/stagehand/client.rb +126 -0
- data/lib/stagehand/errors.rb +228 -0
- data/lib/stagehand/file_part.rb +58 -0
- data/lib/stagehand/internal/stream.rb +56 -0
- data/lib/stagehand/internal/transport/base_client.rb +575 -0
- data/lib/stagehand/internal/transport/pooled_net_requester.rb +210 -0
- data/lib/stagehand/internal/type/array_of.rb +168 -0
- data/lib/stagehand/internal/type/base_model.rb +531 -0
- data/lib/stagehand/internal/type/base_page.rb +55 -0
- data/lib/stagehand/internal/type/base_stream.rb +83 -0
- data/lib/stagehand/internal/type/boolean.rb +77 -0
- data/lib/stagehand/internal/type/converter.rb +327 -0
- data/lib/stagehand/internal/type/enum.rb +131 -0
- data/lib/stagehand/internal/type/file_input.rb +111 -0
- data/lib/stagehand/internal/type/hash_of.rb +188 -0
- data/lib/stagehand/internal/type/request_parameters.rb +42 -0
- data/lib/stagehand/internal/type/union.rb +237 -0
- data/lib/stagehand/internal/type/unknown.rb +81 -0
- data/lib/stagehand/internal/util.rb +920 -0
- data/lib/stagehand/internal.rb +20 -0
- data/lib/stagehand/local.rb +439 -0
- data/lib/stagehand/models/action.rb +50 -0
- data/lib/stagehand/models/model_config.rb +55 -0
- data/lib/stagehand/models/session_act_params.rb +112 -0
- data/lib/stagehand/models/session_act_response.rb +127 -0
- data/lib/stagehand/models/session_end_params.rb +33 -0
- data/lib/stagehand/models/session_end_response.rb +17 -0
- data/lib/stagehand/models/session_execute_params.rb +212 -0
- data/lib/stagehand/models/session_execute_response.rb +212 -0
- data/lib/stagehand/models/session_extract_params.rb +107 -0
- data/lib/stagehand/models/session_extract_response.rb +46 -0
- data/lib/stagehand/models/session_navigate_params.rb +107 -0
- data/lib/stagehand/models/session_navigate_response.rb +44 -0
- data/lib/stagehand/models/session_observe_params.rb +99 -0
- data/lib/stagehand/models/session_observe_response.rb +91 -0
- data/lib/stagehand/models/session_replay_params.rb +33 -0
- data/lib/stagehand/models/session_replay_response.rb +100 -0
- data/lib/stagehand/models/session_start_params.rb +762 -0
- data/lib/stagehand/models/session_start_response.rb +55 -0
- data/lib/stagehand/models/stream_event.rb +120 -0
- data/lib/stagehand/models.rb +63 -0
- data/lib/stagehand/request_options.rb +77 -0
- data/lib/stagehand/resources/sessions.rb +488 -0
- data/lib/stagehand/version.rb +3 -1
- data/lib/stagehand.rb +74 -21
- data/manifest.yaml +17 -0
- data/rbi/stagehand/client.rbi +89 -0
- data/rbi/stagehand/errors.rbi +205 -0
- data/rbi/stagehand/file_part.rbi +37 -0
- data/rbi/stagehand/internal/stream.rbi +20 -0
- data/rbi/stagehand/internal/transport/base_client.rbi +314 -0
- data/rbi/stagehand/internal/transport/pooled_net_requester.rbi +83 -0
- data/rbi/stagehand/internal/type/array_of.rbi +104 -0
- data/rbi/stagehand/internal/type/base_model.rbi +308 -0
- data/rbi/stagehand/internal/type/base_page.rbi +42 -0
- data/rbi/stagehand/internal/type/base_stream.rbi +75 -0
- data/rbi/stagehand/internal/type/boolean.rbi +58 -0
- data/rbi/stagehand/internal/type/converter.rbi +216 -0
- data/rbi/stagehand/internal/type/enum.rbi +82 -0
- data/rbi/stagehand/internal/type/file_input.rbi +59 -0
- data/rbi/stagehand/internal/type/hash_of.rbi +104 -0
- data/rbi/stagehand/internal/type/request_parameters.rbi +29 -0
- data/rbi/stagehand/internal/type/union.rbi +128 -0
- data/rbi/stagehand/internal/type/unknown.rbi +58 -0
- data/rbi/stagehand/internal/util.rbi +487 -0
- data/rbi/stagehand/internal.rbi +18 -0
- data/rbi/stagehand/models/action.rbi +77 -0
- data/rbi/stagehand/models/model_config.rbi +94 -0
- data/rbi/stagehand/models/session_act_params.rbi +204 -0
- data/rbi/stagehand/models/session_act_response.rbi +250 -0
- data/rbi/stagehand/models/session_end_params.rbi +87 -0
- data/rbi/stagehand/models/session_end_response.rbi +30 -0
- data/rbi/stagehand/models/session_execute_params.rbi +440 -0
- data/rbi/stagehand/models/session_execute_response.rbi +414 -0
- data/rbi/stagehand/models/session_extract_params.rbi +209 -0
- data/rbi/stagehand/models/session_extract_response.rbi +91 -0
- data/rbi/stagehand/models/session_navigate_params.rbi +240 -0
- data/rbi/stagehand/models/session_navigate_response.rbi +91 -0
- data/rbi/stagehand/models/session_observe_params.rbi +198 -0
- data/rbi/stagehand/models/session_observe_response.rbi +184 -0
- data/rbi/stagehand/models/session_replay_params.rbi +89 -0
- data/rbi/stagehand/models/session_replay_response.rbi +286 -0
- data/rbi/stagehand/models/session_start_params.rbi +1703 -0
- data/rbi/stagehand/models/session_start_response.rbi +102 -0
- data/rbi/stagehand/models/stream_event.rbi +237 -0
- data/rbi/stagehand/models.rbi +25 -0
- data/rbi/stagehand/request_options.rbi +59 -0
- data/rbi/stagehand/resources/sessions.rbi +421 -0
- data/rbi/stagehand/version.rbi +5 -0
- data/sig/stagehand/client.rbs +41 -0
- data/sig/stagehand/errors.rbs +117 -0
- data/sig/stagehand/file_part.rbs +21 -0
- data/sig/stagehand/internal/stream.rbs +9 -0
- data/sig/stagehand/internal/transport/base_client.rbs +133 -0
- data/sig/stagehand/internal/transport/pooled_net_requester.rbs +48 -0
- data/sig/stagehand/internal/type/array_of.rbs +48 -0
- data/sig/stagehand/internal/type/base_model.rbs +102 -0
- data/sig/stagehand/internal/type/base_page.rbs +24 -0
- data/sig/stagehand/internal/type/base_stream.rbs +38 -0
- data/sig/stagehand/internal/type/boolean.rbs +26 -0
- data/sig/stagehand/internal/type/converter.rbs +79 -0
- data/sig/stagehand/internal/type/enum.rbs +32 -0
- data/sig/stagehand/internal/type/file_input.rbs +25 -0
- data/sig/stagehand/internal/type/hash_of.rbs +48 -0
- data/sig/stagehand/internal/type/request_parameters.rbs +19 -0
- data/sig/stagehand/internal/type/union.rbs +52 -0
- data/sig/stagehand/internal/type/unknown.rbs +26 -0
- data/sig/stagehand/internal/util.rbs +185 -0
- data/sig/stagehand/internal.rbs +9 -0
- data/sig/stagehand/models/action.rbs +46 -0
- data/sig/stagehand/models/model_config.rbs +56 -0
- data/sig/stagehand/models/session_act_params.rbs +111 -0
- data/sig/stagehand/models/session_act_response.rbs +121 -0
- data/sig/stagehand/models/session_end_params.rbs +41 -0
- data/sig/stagehand/models/session_end_response.rbs +13 -0
- data/sig/stagehand/models/session_execute_params.rbs +193 -0
- data/sig/stagehand/models/session_execute_response.rbs +215 -0
- data/sig/stagehand/models/session_extract_params.rbs +112 -0
- data/sig/stagehand/models/session_extract_response.rbs +36 -0
- data/sig/stagehand/models/session_navigate_params.rbs +114 -0
- data/sig/stagehand/models/session_navigate_response.rbs +36 -0
- data/sig/stagehand/models/session_observe_params.rbs +105 -0
- data/sig/stagehand/models/session_observe_response.rbs +89 -0
- data/sig/stagehand/models/session_replay_params.rbs +41 -0
- data/sig/stagehand/models/session_replay_response.rbs +137 -0
- data/sig/stagehand/models/session_start_params.rbs +866 -0
- data/sig/stagehand/models/session_start_response.rbs +44 -0
- data/sig/stagehand/models/stream_event.rbs +109 -0
- data/sig/stagehand/models.rbs +23 -0
- data/sig/stagehand/request_options.rbs +34 -0
- data/sig/stagehand/resources/sessions.rbs +121 -0
- data/sig/stagehand/version.rbs +3 -0
- metadata +173 -42
- data/.gitignore +0 -16
- data/Gemfile +0 -4
- data/Rakefile +0 -10
- data/lib/stagehand/railtie.rb +0 -14
- data/spec/spec_helper.rb +0 -7
- data/spec/stagehand_spec.rb +0 -15
- data/stagehand.gemspec +0 -24
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5e0513be55529f0ad806e4fd1e2b3b89b55706ed068e3e0aa920c89fcfedb727
|
|
4
|
+
data.tar.gz: 724490e4403e3ca03f63f37e2afb1ecc6cf2916f07cb0c4f0bfa7f52132e3540
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7bf071914a086aab51f7180bdbb39f56adc738647a038e14040b90102485e329a7f00e92d719b3db546ef2b43d517482936c3fdef842223b0e3e0b6c1cf85644
|
|
7
|
+
data.tar.gz: 131d96b16ec2210f9eeea9fea4acdc1853436c8d82055fe9f300c3e409e78a1b385c828a3c39bdb2946d712fc532a3c68739400ec9f4164a02c6e105b5ba3e76
|
data/.ignore
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 3.5.2 (2026-02-07)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v3.5.1...v3.5.2](https://github.com/browserbase/stagehand-ruby/compare/v3.5.1...v3.5.2)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* **client:** loosen json header parsing ([ea4142c](https://github.com/browserbase/stagehand-ruby/commit/ea4142cc5973c9207a81c7336c8425c9dbe63a30))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Chores
|
|
13
|
+
|
|
14
|
+
* **docs:** remove www prefix ([8498bdd](https://github.com/browserbase/stagehand-ruby/commit/8498bdd34e0288b8a1c28e789d35dcecf91cd8b7))
|
|
15
|
+
|
|
16
|
+
## 3.5.1 (2026-02-03)
|
|
17
|
+
|
|
18
|
+
Full Changelog: [v3.5.0...v3.5.1](https://github.com/browserbase/stagehand-ruby/compare/v3.5.0...v3.5.1)
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **client:** always add content-length to post body, even when empty ([7c7c43e](https://github.com/browserbase/stagehand-ruby/commit/7c7c43e51dd621d74dab8d1fa47de0dcc9bc0a28))
|
|
23
|
+
|
|
24
|
+
## 3.5.0 (2026-02-03)
|
|
25
|
+
|
|
26
|
+
Full Changelog: [v3.4.0...v3.5.0](https://github.com/browserbase/stagehand-ruby/compare/v3.4.0...v3.5.0)
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* Removed MCP from readme for now ([ad8d58e](https://github.com/browserbase/stagehand-ruby/commit/ad8d58ef0e542592e9001b32ef3e921f480218da))
|
|
31
|
+
|
|
32
|
+
## 3.4.0 (2026-01-29)
|
|
33
|
+
|
|
34
|
+
Full Changelog: [v3.3.0...v3.4.0](https://github.com/browserbase/stagehand-ruby/compare/v3.3.0...v3.4.0)
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* Add executionModel serialization to api client ([2042742](https://github.com/browserbase/stagehand-ruby/commit/20427425012c9ee785d18a74596808471be2dc7b))
|
|
39
|
+
|
|
40
|
+
## 3.3.0 (2026-01-29)
|
|
41
|
+
|
|
42
|
+
Full Changelog: [v3.2.1...v3.3.0](https://github.com/browserbase/stagehand-ruby/compare/v3.2.1...v3.3.0)
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
* Update stainless.yml for project and publish settings ([c55365a](https://github.com/browserbase/stagehand-ruby/commit/c55365a3bbc0ba0bdea32a10e13c58e5863e3ce4))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Bug Fixes
|
|
50
|
+
|
|
51
|
+
* **docs:** fix mcp installation instructions for remote servers ([cd5418d](https://github.com/browserbase/stagehand-ruby/commit/cd5418d7b003862fcee89f5723a1e6449bdee8fa))
|
|
52
|
+
|
|
53
|
+
## 3.2.1 (2026-01-27)
|
|
54
|
+
|
|
55
|
+
Full Changelog: [v3.2.0...v3.2.1](https://github.com/browserbase/stagehand-ruby/compare/v3.2.0...v3.2.1)
|
|
56
|
+
|
|
57
|
+
## 3.2.0 (2026-01-27)
|
|
58
|
+
|
|
59
|
+
Full Changelog: [v3.1.0...v3.2.0](https://github.com/browserbase/stagehand-ruby/compare/v3.1.0...v3.2.0)
|
|
60
|
+
|
|
61
|
+
### Features
|
|
62
|
+
|
|
63
|
+
* add auto-bedrock support based on bedrock/provider.model-name ([fb3762b](https://github.com/browserbase/stagehand-ruby/commit/fb3762b610c4f3049bc74790424556c770bffcf4))
|
|
64
|
+
|
|
65
|
+
## 3.1.0 (2026-01-27)
|
|
66
|
+
|
|
67
|
+
Full Changelog: [v3.0.3...v3.1.0](https://github.com/browserbase/stagehand-ruby/compare/v3.0.3...v3.1.0)
|
|
68
|
+
|
|
69
|
+
### Features
|
|
70
|
+
|
|
71
|
+
* **api:** manual updates ([eb975f5](https://github.com/browserbase/stagehand-ruby/commit/eb975f5fa5718d2b8e715e8315ea66f898a0dfdc))
|
|
72
|
+
|
|
73
|
+
## 3.0.3 (2026-01-27)
|
|
74
|
+
|
|
75
|
+
Full Changelog: [v3.0.2...v3.0.3](https://github.com/browserbase/stagehand-ruby/compare/v3.0.2...v3.0.3)
|
|
76
|
+
|
|
77
|
+
## 3.0.2 (2026-01-22)
|
|
78
|
+
|
|
79
|
+
Full Changelog: [v3.0.1...v3.0.2](https://github.com/browserbase/stagehand-ruby/compare/v3.0.1...v3.0.2)
|
|
80
|
+
|
|
81
|
+
### Chores
|
|
82
|
+
|
|
83
|
+
* remove custom code ([3943364](https://github.com/browserbase/stagehand-ruby/commit/394336419ed210704639af03445858f44f03ba13))
|
|
84
|
+
|
|
85
|
+
## 3.0.1 (2026-01-15)
|
|
86
|
+
|
|
87
|
+
Full Changelog: [v0.6.2...v3.0.1](https://github.com/browserbase/stagehand-ruby/compare/v0.6.2...v3.0.1)
|
|
88
|
+
|
|
89
|
+
## 0.6.2 (2026-01-13)
|
|
90
|
+
|
|
91
|
+
Full Changelog: [v0.6.1...v0.6.2](https://github.com/browserbase/stagehand-ruby/compare/v0.6.1...v0.6.2)
|
|
92
|
+
|
|
93
|
+
## 0.6.1 (2026-01-06)
|
|
94
|
+
|
|
95
|
+
Full Changelog: [v0.6.0...v0.6.1](https://github.com/browserbase/stagehand-ruby/compare/v0.6.0...v0.6.1)
|
|
96
|
+
|
|
97
|
+
### Documentation
|
|
98
|
+
|
|
99
|
+
* add full example and update examples in README ([#8](https://github.com/browserbase/stagehand-ruby/issues/8)) ([3d8b897](https://github.com/browserbase/stagehand-ruby/commit/3d8b8978c4623f906fd809fdd44c91539098fe00))
|
|
100
|
+
* prominently feature MCP server setup in root SDK readmes ([f9a368b](https://github.com/browserbase/stagehand-ruby/commit/f9a368b0508862cd3ee53198ac92fe1265c5050f))
|
|
101
|
+
|
|
102
|
+
## 0.6.0 (2026-01-05)
|
|
103
|
+
|
|
104
|
+
Full Changelog: [v0.5.0...v0.6.0](https://github.com/browserbase/stagehand-ruby/compare/v0.5.0...v0.6.0)
|
|
105
|
+
|
|
106
|
+
### Features
|
|
107
|
+
|
|
108
|
+
* **api:** manual updates ([ffa5258](https://github.com/browserbase/stagehand-ruby/commit/ffa5258d23db78c2aa398289bc4d775fd5d145f0))
|
|
109
|
+
|
|
110
|
+
## 0.5.0 (2025-12-23)
|
|
111
|
+
|
|
112
|
+
Full Changelog: [v0.4.0...v0.5.0](https://github.com/browserbase/stagehand-ruby/compare/v0.4.0...v0.5.0)
|
|
113
|
+
|
|
114
|
+
### Features
|
|
115
|
+
|
|
116
|
+
* [STG-1053] [server] Use fastify-zod-openapi + zod v4 for openapi generation ([926a819](https://github.com/browserbase/stagehand-ruby/commit/926a819a4bbe2b260d3dbd46b860c444f60857bf))
|
|
117
|
+
* **api:** manual updates ([0619302](https://github.com/browserbase/stagehand-ruby/commit/061930217b3efce30e29cf8b2511970b21c86c57))
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
### Documentation
|
|
121
|
+
|
|
122
|
+
* add more examples ([3e81eba](https://github.com/browserbase/stagehand-ruby/commit/3e81eba0b962a3ec0c9a8b13fc9ae30f0961663e))
|
|
123
|
+
|
|
124
|
+
## 0.4.0 (2025-12-19)
|
|
125
|
+
|
|
126
|
+
Full Changelog: [v0.3.0...v0.4.0](https://github.com/browserbase/stagehand-ruby/compare/v0.3.0...v0.4.0)
|
|
127
|
+
|
|
128
|
+
### Features
|
|
129
|
+
|
|
130
|
+
* **api:** manual updates ([c93a988](https://github.com/browserbase/stagehand-ruby/commit/c93a988374918f841643a84145b3008970b665a7))
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
### Bug Fixes
|
|
134
|
+
|
|
135
|
+
* issue where json.parse errors when receiving HTTP 204 with nobody ([fc3e31e](https://github.com/browserbase/stagehand-ruby/commit/fc3e31e00944a7fdf89e367e281bc0510847d15e))
|
|
136
|
+
|
|
137
|
+
## 0.3.0 (2025-12-17)
|
|
138
|
+
|
|
139
|
+
Full Changelog: [v0.2.0...v0.3.0](https://github.com/browserbase/stagehand-ruby/compare/v0.2.0...v0.3.0)
|
|
140
|
+
|
|
141
|
+
### Features
|
|
142
|
+
|
|
143
|
+
* **api:** manual updates ([7dcf75c](https://github.com/browserbase/stagehand-ruby/commit/7dcf75cc0c580743b8bb0bbdb41077a6a7aa6dfb))
|
|
144
|
+
* **api:** manual updates ([3162ca0](https://github.com/browserbase/stagehand-ruby/commit/3162ca00c75b37ccb869d7a082f25b263e15d93d))
|
|
145
|
+
* **api:** manual updates ([a972ef7](https://github.com/browserbase/stagehand-ruby/commit/a972ef7dc9040af201ee8e87db013fc077a7ab3f))
|
|
146
|
+
* **api:** manual updates ([be169eb](https://github.com/browserbase/stagehand-ruby/commit/be169ebb8a61b86f4d1caee63aeded39139f10aa))
|
|
147
|
+
* **api:** manual updates ([2a98da9](https://github.com/browserbase/stagehand-ruby/commit/2a98da9563a1ab4e33d6bf3398083d772b61e07f))
|
|
148
|
+
* **api:** manual updates ([05879da](https://github.com/browserbase/stagehand-ruby/commit/05879da16a92ae6199ca2c4e323a6602fbc5d841))
|
|
149
|
+
* **api:** manual updates ([69e4183](https://github.com/browserbase/stagehand-ruby/commit/69e418398b943df8b7454b50ab02d17ba3feb212))
|
|
150
|
+
* **api:** manual updates ([9176bca](https://github.com/browserbase/stagehand-ruby/commit/9176bcaf88f115335199a44a52c8e1d697920822))
|
|
151
|
+
* **api:** manual updates ([36f0681](https://github.com/browserbase/stagehand-ruby/commit/36f0681452a11e25da7126e0270855bbdd3fe8df))
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
### Bug Fixes
|
|
155
|
+
|
|
156
|
+
* calling `break` out of streams should be instantaneous ([369b9d0](https://github.com/browserbase/stagehand-ruby/commit/369b9d0d37390d96fa673d08e64594cefc6a04fa))
|
|
157
|
+
|
|
158
|
+
## 0.2.0 (2025-12-16)
|
|
159
|
+
|
|
160
|
+
Full Changelog: [v0.1.0...v0.2.0](https://github.com/browserbase/stagehand-ruby/compare/v0.1.0...v0.2.0)
|
|
161
|
+
|
|
162
|
+
### Features
|
|
163
|
+
|
|
164
|
+
* **api:** manual updates ([d660a3a](https://github.com/browserbase/stagehand-ruby/commit/d660a3ad9cd54238d2bc6598b576e7677ebf120f))
|
|
165
|
+
* **api:** manual updates ([c21cb20](https://github.com/browserbase/stagehand-ruby/commit/c21cb20650bbad1ba8f6a89ad33dcf5ddfc53c81))
|
|
166
|
+
* **api:** manual updates ([f04453c](https://github.com/browserbase/stagehand-ruby/commit/f04453c6c2050b7815e3f62d14343dee4698879d))
|
|
167
|
+
|
|
168
|
+
## 0.1.0 (2025-12-16)
|
|
169
|
+
|
|
170
|
+
Full Changelog: [v0.0.1...v0.1.0](https://github.com/browserbase/stagehand-ruby/compare/v0.0.1...v0.1.0)
|
|
171
|
+
|
|
172
|
+
### Features
|
|
173
|
+
|
|
174
|
+
* **api:** manual updates ([5deaf8f](https://github.com/browserbase/stagehand-ruby/commit/5deaf8ff2011a2808dcfe66ef14470029bb3590e))
|
|
175
|
+
* **api:** manual updates ([87ce5f3](https://github.com/browserbase/stagehand-ruby/commit/87ce5f320056fb34770be2f0c87985960e995e92))
|
|
176
|
+
* **api:** manual updates ([2a8b9e7](https://github.com/browserbase/stagehand-ruby/commit/2a8b9e7d219360a5e783c650fc7c9544a9a6fbb5))
|
|
177
|
+
* **api:** manual updates ([0bcedba](https://github.com/browserbase/stagehand-ruby/commit/0bcedbaf26918822abdc958e6020f68b263ffee0))
|
|
178
|
+
* **api:** manual updates ([8355d5e](https://github.com/browserbase/stagehand-ruby/commit/8355d5e6b83f6c31f6494f771fba51b6e31023e7))
|
|
179
|
+
* **api:** manual updates ([655f517](https://github.com/browserbase/stagehand-ruby/commit/655f51718008b4c512eed1ce65660dae80039e49))
|
|
180
|
+
* **api:** tweak branding and fix some config fields ([c48f36e](https://github.com/browserbase/stagehand-ruby/commit/c48f36e307aafd9a2d6ac59d9857be789f29eaa1))
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
### Chores
|
|
184
|
+
|
|
185
|
+
* configure new SDK language ([3be44a3](https://github.com/browserbase/stagehand-ruby/commit/3be44a344d5bc49e7c2e16129c2b24db175f4eb6))
|
data/README.md
CHANGED
|
@@ -1,31 +1,394 @@
|
|
|
1
|
-
Stagehand
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
# Stagehand Ruby API library
|
|
2
|
+
|
|
3
|
+
The Stagehand Ruby library provides convenient access to the Stagehand REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/browserbase/stagehand-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
|
|
4
|
+
|
|
5
|
+
It is generated with [Stainless](https://www.stainless.com/).
|
|
6
|
+
|
|
7
|
+
## Documentation
|
|
8
|
+
|
|
9
|
+
Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/stagehand).
|
|
10
|
+
|
|
11
|
+
The REST API documentation can be found on [docs.stagehand.dev](https://docs.stagehand.dev).
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
|
|
16
|
+
|
|
17
|
+
<!-- x-release-please-start-version -->
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
gem "stagehand", :git => "git://github.com/browserbase/stagehand-ruby.git"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
<!-- x-release-please-end -->
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
require "bundler/setup"
|
|
29
|
+
require "stagehand"
|
|
30
|
+
|
|
31
|
+
# Create a new Stagehand client with your credentials
|
|
32
|
+
client = Stagehand::Client.new(
|
|
33
|
+
browserbase_api_key: ENV["BROWSERBASE_API_KEY"], # defaults to ENV["BROWSERBASE_API_KEY"]
|
|
34
|
+
browserbase_project_id: ENV["BROWSERBASE_PROJECT_ID"], # defaults to ENV["BROWSERBASE_PROJECT_ID"]
|
|
35
|
+
model_api_key: ENV["MODEL_API_KEY"] # defaults to ENV["MODEL_API_KEY"]
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
# Start a new browser session
|
|
39
|
+
start_response = client.sessions.start(
|
|
40
|
+
model_name: "openai/gpt-5-nano"
|
|
41
|
+
)
|
|
42
|
+
puts "Session started: #{start_response.data.session_id}"
|
|
43
|
+
|
|
44
|
+
session_id = start_response.data.session_id
|
|
45
|
+
|
|
46
|
+
# Navigate to a webpage
|
|
47
|
+
client.sessions.navigate(
|
|
48
|
+
session_id,
|
|
49
|
+
url: "https://news.ycombinator.com"
|
|
50
|
+
)
|
|
51
|
+
puts "Navigated to Hacker News"
|
|
52
|
+
|
|
53
|
+
# Use Observe to find possible actions on the page
|
|
54
|
+
observe_response = client.sessions.observe(
|
|
55
|
+
session_id,
|
|
56
|
+
instruction: "find the link to view comments for the top post"
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
actions = observe_response.data.result
|
|
60
|
+
puts "Found #{actions.length} possible actions"
|
|
61
|
+
|
|
62
|
+
# Take the first action returned by Observe
|
|
63
|
+
action = actions.first
|
|
64
|
+
puts "Acting on: #{action.description}"
|
|
65
|
+
|
|
66
|
+
# Pass the structured action to Act
|
|
67
|
+
# Convert the observe result to a hash and ensure method is set to "click"
|
|
68
|
+
act_response = client.sessions.act(
|
|
69
|
+
session_id,
|
|
70
|
+
input: action.to_h.merge(method: "click")
|
|
71
|
+
)
|
|
72
|
+
puts "Act completed: #{act_response.data.result[:message]}"
|
|
73
|
+
|
|
74
|
+
# Extract data from the page
|
|
75
|
+
# We're now on the comments page, so extract the top comment text
|
|
76
|
+
extract_response = client.sessions.extract(
|
|
77
|
+
session_id,
|
|
78
|
+
instruction: "extract the text of the top comment on this page",
|
|
79
|
+
schema: {
|
|
80
|
+
type: "object",
|
|
81
|
+
properties: {
|
|
82
|
+
comment_text: {
|
|
83
|
+
type: "string",
|
|
84
|
+
description: "The text content of the top comment"
|
|
85
|
+
},
|
|
86
|
+
author: {
|
|
87
|
+
type: "string",
|
|
88
|
+
description: "The username of the comment author"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
required: ["comment_text"]
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
puts "Extracted data: #{extract_response.data.result}"
|
|
95
|
+
|
|
96
|
+
# Get the author from the extracted data
|
|
97
|
+
extracted_data = extract_response.data.result
|
|
98
|
+
author = extracted_data[:author]
|
|
99
|
+
puts "Looking up profile for author: #{author}"
|
|
100
|
+
|
|
101
|
+
# Use the Agent to find the author's profile
|
|
102
|
+
# Execute runs an autonomous agent that can navigate and interact with pages
|
|
103
|
+
execute_response = client.sessions.execute(
|
|
104
|
+
session_id,
|
|
105
|
+
execute_options: {
|
|
106
|
+
instruction: "Find any personal website, GitHub, LinkedIn, or other best profile URL for the Hacker News user '#{author}'. " \
|
|
107
|
+
"Click on their username to go to their profile page and look for any links they have shared.",
|
|
108
|
+
max_steps: 15
|
|
109
|
+
},
|
|
110
|
+
agent_config: {
|
|
111
|
+
model: Stagehand::ModelConfig::ModelConfigObject.new(
|
|
112
|
+
model_name: "openai/gpt-5-nano",
|
|
113
|
+
api_key: ENV["MODEL_API_KEY"]
|
|
114
|
+
),
|
|
115
|
+
cua: false
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
puts "Agent completed: #{execute_response.data.result[:message]}"
|
|
119
|
+
puts "Agent success: #{execute_response.data.result[:success]}"
|
|
120
|
+
puts "Agent actions taken: #{execute_response.data.result[:actions]&.length || 0}"
|
|
121
|
+
|
|
122
|
+
# End the session to cleanup browser resources
|
|
123
|
+
client.sessions.end_(session_id)
|
|
124
|
+
puts "Session ended"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Running the Examples
|
|
128
|
+
|
|
129
|
+
Install dependencies, set credentials, and run the scripts below.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Install the gem dependencies
|
|
133
|
+
bundle install
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Remote browser example:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
export BROWSERBASE_API_KEY="your-browserbase-api-key"
|
|
140
|
+
export BROWSERBASE_PROJECT_ID="your-browserbase-project-id"
|
|
141
|
+
export MODEL_API_KEY="your-openai-api-key"
|
|
142
|
+
bundle exec ruby examples/remote_browser_example.rb
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Local mode example (embedded server, local Chrome/Chromium):
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
export MODEL_API_KEY="your-openai-api-key"
|
|
149
|
+
bundle exec ruby examples/local_browser_example.rb
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Playwright local example (SSE streaming):
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
gem install playwright-ruby-client
|
|
156
|
+
npm install playwright
|
|
157
|
+
./node_modules/.bin/playwright install chromium
|
|
158
|
+
export MODEL_API_KEY="your-openai-api-key"
|
|
159
|
+
bundle exec ruby examples/local_playwright_example.rb
|
|
160
|
+
|
|
161
|
+
bundle exec ruby examples/local_browser_playwright_example.rb
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Playwright remote example:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
gem install playwright-ruby-client
|
|
168
|
+
npm install playwright
|
|
169
|
+
./node_modules/.bin/playwright install chromium
|
|
170
|
+
export BROWSERBASE_API_KEY="your-browserbase-api-key"
|
|
171
|
+
export BROWSERBASE_PROJECT_ID="your-browserbase-project-id"
|
|
172
|
+
export MODEL_API_KEY="your-openai-api-key"
|
|
173
|
+
bundle exec ruby examples/remote_browser_playwright_example.rb
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Watir local example:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
gem install watir
|
|
180
|
+
export MODEL_API_KEY="your-openai-api-key"
|
|
181
|
+
bundle exec ruby examples/local_watir_example.rb
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Streaming
|
|
185
|
+
|
|
186
|
+
We provide support for streaming responses using Server-Sent Events (SSE).
|
|
187
|
+
|
|
188
|
+
```ruby
|
|
189
|
+
stream = stagehand.sessions.act_streaming(
|
|
190
|
+
"00000000-your-session-id-000000000000",
|
|
191
|
+
input: "click the first link on the page"
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
stream.each do |session|
|
|
195
|
+
puts(session.data)
|
|
196
|
+
end
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Handling errors
|
|
200
|
+
|
|
201
|
+
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Stagehand::Errors::APIError` will be thrown:
|
|
202
|
+
|
|
203
|
+
```ruby
|
|
204
|
+
begin
|
|
205
|
+
session = stagehand.sessions.start(model_name: "openai/gpt-5-nano")
|
|
206
|
+
rescue Stagehand::Errors::APIConnectionError => e
|
|
207
|
+
puts("The server could not be reached")
|
|
208
|
+
puts(e.cause) # an underlying Exception, likely raised within `net/http`
|
|
209
|
+
rescue Stagehand::Errors::RateLimitError => e
|
|
210
|
+
puts("A 429 status code was received; we should back off a bit.")
|
|
211
|
+
rescue Stagehand::Errors::APIStatusError => e
|
|
212
|
+
puts("Another non-200-range status code was received")
|
|
213
|
+
puts(e.status)
|
|
214
|
+
end
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Error codes are as follows:
|
|
218
|
+
|
|
219
|
+
| Cause | Error Type |
|
|
220
|
+
| ---------------- | -------------------------- |
|
|
221
|
+
| HTTP 400 | `BadRequestError` |
|
|
222
|
+
| HTTP 401 | `AuthenticationError` |
|
|
223
|
+
| HTTP 403 | `PermissionDeniedError` |
|
|
224
|
+
| HTTP 404 | `NotFoundError` |
|
|
225
|
+
| HTTP 409 | `ConflictError` |
|
|
226
|
+
| HTTP 422 | `UnprocessableEntityError` |
|
|
227
|
+
| HTTP 429 | `RateLimitError` |
|
|
228
|
+
| HTTP >= 500 | `InternalServerError` |
|
|
229
|
+
| Other HTTP error | `APIStatusError` |
|
|
230
|
+
| Timeout | `APITimeoutError` |
|
|
231
|
+
| Network error | `APIConnectionError` |
|
|
232
|
+
|
|
233
|
+
### Retries
|
|
234
|
+
|
|
235
|
+
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
|
|
236
|
+
|
|
237
|
+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.
|
|
238
|
+
|
|
239
|
+
You can use the `max_retries` option to configure or disable this:
|
|
240
|
+
|
|
241
|
+
```ruby
|
|
242
|
+
# Configure the default for all requests:
|
|
243
|
+
stagehand = Stagehand::Client.new(
|
|
244
|
+
max_retries: 0 # default is 2
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
# Or, configure per-request:
|
|
248
|
+
stagehand.sessions.start(model_name: "openai/gpt-5-nano", request_options: {max_retries: 5})
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Timeouts
|
|
252
|
+
|
|
253
|
+
By default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:
|
|
254
|
+
|
|
255
|
+
```ruby
|
|
256
|
+
# Configure the default for all requests:
|
|
257
|
+
stagehand = Stagehand::Client.new(
|
|
258
|
+
timeout: nil # default is 60
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
# Or, configure per-request:
|
|
262
|
+
stagehand.sessions.start(model_name: "openai/gpt-5-nano", request_options: {timeout: 5})
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
On timeout, `Stagehand::Errors::APITimeoutError` is raised.
|
|
266
|
+
|
|
267
|
+
Note that requests that time out are retried by default.
|
|
268
|
+
|
|
269
|
+
## Advanced concepts
|
|
270
|
+
|
|
271
|
+
### BaseModel
|
|
272
|
+
|
|
273
|
+
All parameter and response objects inherit from `Stagehand::Internal::Type::BaseModel`, which provides several conveniences, including:
|
|
274
|
+
|
|
275
|
+
1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.
|
|
276
|
+
|
|
277
|
+
2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.
|
|
278
|
+
|
|
279
|
+
3. Both instances and the classes themselves can be pretty-printed.
|
|
280
|
+
|
|
281
|
+
4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.
|
|
282
|
+
|
|
283
|
+
### Making custom or undocumented requests
|
|
284
|
+
|
|
285
|
+
#### Undocumented properties
|
|
286
|
+
|
|
287
|
+
You can send undocumented parameters to any endpoint, and read undocumented response properties, like so:
|
|
288
|
+
|
|
289
|
+
Note: the `extra_` parameters of the same name overrides the documented parameters.
|
|
290
|
+
|
|
291
|
+
```ruby
|
|
292
|
+
response =
|
|
293
|
+
stagehand.sessions.start(
|
|
294
|
+
model_name: "openai/gpt-5-nano",
|
|
295
|
+
request_options: {
|
|
296
|
+
extra_query: {my_query_parameter: value},
|
|
297
|
+
extra_body: {my_body_parameter: value},
|
|
298
|
+
extra_headers: {"my-header": value}
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
puts(response[:my_undocumented_property])
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
#### Undocumented request params
|
|
306
|
+
|
|
307
|
+
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.
|
|
308
|
+
|
|
309
|
+
#### Undocumented endpoints
|
|
310
|
+
|
|
311
|
+
To make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:
|
|
312
|
+
|
|
313
|
+
```ruby
|
|
314
|
+
response = client.request(
|
|
315
|
+
method: :post,
|
|
316
|
+
path: '/undocumented/endpoint',
|
|
317
|
+
query: {"dog": "woof"},
|
|
318
|
+
headers: {"useful-header": "interesting-value"},
|
|
319
|
+
body: {"hello": "world"}
|
|
320
|
+
)
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Concurrency & connection pooling
|
|
324
|
+
|
|
325
|
+
The `Stagehand::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.
|
|
326
|
+
|
|
327
|
+
Each instance of `Stagehand::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.
|
|
328
|
+
|
|
329
|
+
When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.
|
|
330
|
+
|
|
331
|
+
Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.
|
|
332
|
+
|
|
333
|
+
## Sorbet
|
|
334
|
+
|
|
335
|
+
This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.
|
|
336
|
+
|
|
337
|
+
You can provide typesafe request parameters like so:
|
|
338
|
+
|
|
339
|
+
```ruby
|
|
340
|
+
stagehand.sessions.act("00000000-your-session-id-000000000000", input: "click the first link on the page")
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Or, equivalently:
|
|
344
|
+
|
|
345
|
+
```ruby
|
|
346
|
+
# Hashes work, but are not typesafe:
|
|
347
|
+
stagehand.sessions.act("00000000-your-session-id-000000000000", input: "click the first link on the page")
|
|
348
|
+
|
|
349
|
+
# You can also splat a full Params class:
|
|
350
|
+
params = Stagehand::SessionActParams.new(input: "click the first link on the page")
|
|
351
|
+
stagehand.sessions.act("00000000-your-session-id-000000000000", **params)
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Enums
|
|
355
|
+
|
|
356
|
+
Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:
|
|
357
|
+
|
|
358
|
+
```ruby
|
|
359
|
+
# :true
|
|
360
|
+
puts(Stagehand::SessionActParams::XStreamResponse::TRUE)
|
|
361
|
+
|
|
362
|
+
# Revealed type: `T.all(Stagehand::SessionActParams::XStreamResponse, Symbol)`
|
|
363
|
+
T.reveal_type(Stagehand::SessionActParams::XStreamResponse::TRUE)
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
|
|
367
|
+
|
|
368
|
+
```ruby
|
|
369
|
+
# Using the enum constants preserves the tagged type information:
|
|
370
|
+
stagehand.sessions.act(
|
|
371
|
+
x_stream_response: Stagehand::SessionActParams::XStreamResponse::TRUE,
|
|
372
|
+
# …
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
# Literal values are also permissible:
|
|
376
|
+
stagehand.sessions.act(
|
|
377
|
+
x_stream_response: :true,
|
|
378
|
+
# …
|
|
379
|
+
)
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Versioning
|
|
383
|
+
|
|
384
|
+
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
|
|
385
|
+
|
|
386
|
+
This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.
|
|
387
|
+
|
|
388
|
+
## Requirements
|
|
389
|
+
|
|
390
|
+
Ruby 3.2.0 or higher.
|
|
391
|
+
|
|
392
|
+
## Contributing
|
|
393
|
+
|
|
394
|
+
See [the contributing documentation](https://github.com/browserbase/stagehand-ruby/tree/main/CONTRIBUTING.md).
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting Security Issues
|
|
4
|
+
|
|
5
|
+
This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.
|
|
6
|
+
|
|
7
|
+
To report a security issue, please contact the Stainless team at security@stainless.com.
|
|
8
|
+
|
|
9
|
+
## Responsible Disclosure
|
|
10
|
+
|
|
11
|
+
We appreciate the efforts of security researchers and individuals who help us maintain the security of
|
|
12
|
+
SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible
|
|
13
|
+
disclosure practices by allowing us a reasonable amount of time to investigate and address the issue
|
|
14
|
+
before making any information public.
|
|
15
|
+
|
|
16
|
+
## Reporting Non-SDK Related Security Issues
|
|
17
|
+
|
|
18
|
+
If you encounter security issues that are not directly related to SDKs but pertain to the services
|
|
19
|
+
or products provided by Stagehand, please follow the respective company's security reporting guidelines.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
Thank you for helping us keep the SDKs and systems they interact with secure.
|