stagehand 0.0.4 → 3.6.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 (148) hide show
  1. checksums.yaml +7 -0
  2. data/.ignore +2 -0
  3. data/CHANGELOG.md +193 -0
  4. data/README.md +403 -31
  5. data/SECURITY.md +23 -0
  6. data/lib/stagehand/client.rb +123 -4
  7. data/lib/stagehand/errors.rb +228 -0
  8. data/lib/stagehand/file_part.rb +58 -0
  9. data/lib/stagehand/internal/stream.rb +56 -0
  10. data/lib/stagehand/internal/transport/base_client.rb +575 -0
  11. data/lib/stagehand/internal/transport/pooled_net_requester.rb +210 -0
  12. data/lib/stagehand/internal/type/array_of.rb +168 -0
  13. data/lib/stagehand/internal/type/base_model.rb +531 -0
  14. data/lib/stagehand/internal/type/base_page.rb +55 -0
  15. data/lib/stagehand/internal/type/base_stream.rb +83 -0
  16. data/lib/stagehand/internal/type/boolean.rb +77 -0
  17. data/lib/stagehand/internal/type/converter.rb +327 -0
  18. data/lib/stagehand/internal/type/enum.rb +131 -0
  19. data/lib/stagehand/internal/type/file_input.rb +111 -0
  20. data/lib/stagehand/internal/type/hash_of.rb +188 -0
  21. data/lib/stagehand/internal/type/request_parameters.rb +42 -0
  22. data/lib/stagehand/internal/type/union.rb +237 -0
  23. data/lib/stagehand/internal/type/unknown.rb +81 -0
  24. data/lib/stagehand/internal/util.rb +920 -0
  25. data/lib/stagehand/internal.rb +20 -0
  26. data/lib/stagehand/local.rb +439 -0
  27. data/lib/stagehand/models/action.rb +50 -0
  28. data/lib/stagehand/models/model_config.rb +55 -0
  29. data/lib/stagehand/models/session_act_params.rb +112 -0
  30. data/lib/stagehand/models/session_act_response.rb +127 -0
  31. data/lib/stagehand/models/session_end_params.rb +33 -0
  32. data/lib/stagehand/models/session_end_response.rb +17 -0
  33. data/lib/stagehand/models/session_execute_params.rb +212 -0
  34. data/lib/stagehand/models/session_execute_response.rb +212 -0
  35. data/lib/stagehand/models/session_extract_params.rb +107 -0
  36. data/lib/stagehand/models/session_extract_response.rb +46 -0
  37. data/lib/stagehand/models/session_navigate_params.rb +107 -0
  38. data/lib/stagehand/models/session_navigate_response.rb +44 -0
  39. data/lib/stagehand/models/session_observe_params.rb +99 -0
  40. data/lib/stagehand/models/session_observe_response.rb +91 -0
  41. data/lib/stagehand/models/session_replay_params.rb +33 -0
  42. data/lib/stagehand/models/session_replay_response.rb +142 -0
  43. data/lib/stagehand/models/session_start_params.rb +762 -0
  44. data/lib/stagehand/models/session_start_response.rb +55 -0
  45. data/lib/stagehand/models/stream_event.rb +120 -0
  46. data/lib/stagehand/models.rb +63 -0
  47. data/lib/stagehand/request_options.rb +77 -0
  48. data/lib/stagehand/resources/sessions.rb +488 -0
  49. data/lib/stagehand/version.rb +3 -1
  50. data/lib/stagehand.rb +74 -29
  51. data/manifest.yaml +17 -0
  52. data/rbi/stagehand/client.rbi +89 -0
  53. data/rbi/stagehand/errors.rbi +205 -0
  54. data/rbi/stagehand/file_part.rbi +37 -0
  55. data/rbi/stagehand/internal/stream.rbi +20 -0
  56. data/rbi/stagehand/internal/transport/base_client.rbi +314 -0
  57. data/rbi/stagehand/internal/transport/pooled_net_requester.rbi +83 -0
  58. data/rbi/stagehand/internal/type/array_of.rbi +104 -0
  59. data/rbi/stagehand/internal/type/base_model.rbi +308 -0
  60. data/rbi/stagehand/internal/type/base_page.rbi +42 -0
  61. data/rbi/stagehand/internal/type/base_stream.rbi +75 -0
  62. data/rbi/stagehand/internal/type/boolean.rbi +58 -0
  63. data/rbi/stagehand/internal/type/converter.rbi +216 -0
  64. data/rbi/stagehand/internal/type/enum.rbi +82 -0
  65. data/rbi/stagehand/internal/type/file_input.rbi +59 -0
  66. data/rbi/stagehand/internal/type/hash_of.rbi +104 -0
  67. data/rbi/stagehand/internal/type/request_parameters.rbi +29 -0
  68. data/rbi/stagehand/internal/type/union.rbi +128 -0
  69. data/rbi/stagehand/internal/type/unknown.rbi +58 -0
  70. data/rbi/stagehand/internal/util.rbi +487 -0
  71. data/rbi/stagehand/internal.rbi +18 -0
  72. data/rbi/stagehand/models/action.rbi +77 -0
  73. data/rbi/stagehand/models/model_config.rbi +94 -0
  74. data/rbi/stagehand/models/session_act_params.rbi +204 -0
  75. data/rbi/stagehand/models/session_act_response.rbi +250 -0
  76. data/rbi/stagehand/models/session_end_params.rbi +87 -0
  77. data/rbi/stagehand/models/session_end_response.rbi +30 -0
  78. data/rbi/stagehand/models/session_execute_params.rbi +440 -0
  79. data/rbi/stagehand/models/session_execute_response.rbi +414 -0
  80. data/rbi/stagehand/models/session_extract_params.rbi +209 -0
  81. data/rbi/stagehand/models/session_extract_response.rbi +91 -0
  82. data/rbi/stagehand/models/session_navigate_params.rbi +240 -0
  83. data/rbi/stagehand/models/session_navigate_response.rbi +91 -0
  84. data/rbi/stagehand/models/session_observe_params.rbi +198 -0
  85. data/rbi/stagehand/models/session_observe_response.rbi +184 -0
  86. data/rbi/stagehand/models/session_replay_params.rbi +89 -0
  87. data/rbi/stagehand/models/session_replay_response.rbi +303 -0
  88. data/rbi/stagehand/models/session_start_params.rbi +1703 -0
  89. data/rbi/stagehand/models/session_start_response.rbi +102 -0
  90. data/rbi/stagehand/models/stream_event.rbi +237 -0
  91. data/rbi/stagehand/models.rbi +25 -0
  92. data/rbi/stagehand/request_options.rbi +59 -0
  93. data/rbi/stagehand/resources/sessions.rbi +421 -0
  94. data/rbi/stagehand/version.rbi +5 -0
  95. data/sig/stagehand/client.rbs +41 -0
  96. data/sig/stagehand/errors.rbs +117 -0
  97. data/sig/stagehand/file_part.rbs +21 -0
  98. data/sig/stagehand/internal/stream.rbs +9 -0
  99. data/sig/stagehand/internal/transport/base_client.rbs +133 -0
  100. data/sig/stagehand/internal/transport/pooled_net_requester.rbs +48 -0
  101. data/sig/stagehand/internal/type/array_of.rbs +48 -0
  102. data/sig/stagehand/internal/type/base_model.rbs +102 -0
  103. data/sig/stagehand/internal/type/base_page.rbs +24 -0
  104. data/sig/stagehand/internal/type/base_stream.rbs +38 -0
  105. data/sig/stagehand/internal/type/boolean.rbs +26 -0
  106. data/sig/stagehand/internal/type/converter.rbs +79 -0
  107. data/sig/stagehand/internal/type/enum.rbs +32 -0
  108. data/sig/stagehand/internal/type/file_input.rbs +25 -0
  109. data/sig/stagehand/internal/type/hash_of.rbs +48 -0
  110. data/sig/stagehand/internal/type/request_parameters.rbs +19 -0
  111. data/sig/stagehand/internal/type/union.rbs +52 -0
  112. data/sig/stagehand/internal/type/unknown.rbs +26 -0
  113. data/sig/stagehand/internal/util.rbs +185 -0
  114. data/sig/stagehand/internal.rbs +9 -0
  115. data/sig/stagehand/models/action.rbs +46 -0
  116. data/sig/stagehand/models/model_config.rbs +56 -0
  117. data/sig/stagehand/models/session_act_params.rbs +111 -0
  118. data/sig/stagehand/models/session_act_response.rbs +121 -0
  119. data/sig/stagehand/models/session_end_params.rbs +41 -0
  120. data/sig/stagehand/models/session_end_response.rbs +13 -0
  121. data/sig/stagehand/models/session_execute_params.rbs +193 -0
  122. data/sig/stagehand/models/session_execute_response.rbs +215 -0
  123. data/sig/stagehand/models/session_extract_params.rbs +112 -0
  124. data/sig/stagehand/models/session_extract_response.rbs +36 -0
  125. data/sig/stagehand/models/session_navigate_params.rbs +114 -0
  126. data/sig/stagehand/models/session_navigate_response.rbs +36 -0
  127. data/sig/stagehand/models/session_observe_params.rbs +105 -0
  128. data/sig/stagehand/models/session_observe_response.rbs +89 -0
  129. data/sig/stagehand/models/session_replay_params.rbs +41 -0
  130. data/sig/stagehand/models/session_replay_response.rbs +166 -0
  131. data/sig/stagehand/models/session_start_params.rbs +866 -0
  132. data/sig/stagehand/models/session_start_response.rbs +44 -0
  133. data/sig/stagehand/models/stream_event.rbs +109 -0
  134. data/sig/stagehand/models.rbs +23 -0
  135. data/sig/stagehand/request_options.rbs +34 -0
  136. data/sig/stagehand/resources/sessions.rbs +121 -0
  137. data/sig/stagehand/version.rbs +3 -0
  138. metadata +170 -54
  139. data/.gitignore +0 -16
  140. data/Gemfile +0 -4
  141. data/Rakefile +0 -10
  142. data/lib/stagehand/client/oauth.rb +0 -32
  143. data/lib/stagehand/client/user.rb +0 -10
  144. data/lib/stagehand/rack/middleware.rb +0 -33
  145. data/lib/stagehand/railtie.rb +0 -19
  146. data/spec/spec_helper.rb +0 -7
  147. data/spec/stagehand_spec.rb +0 -44
  148. data/stagehand.gemspec +0 -25
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 50f660b2c567e5cc200d36aedaebafd5de79c1d41f9402a73a5f7c1ebb539f8a
4
+ data.tar.gz: 70f5dd300c85f94fd3ef9e6e083bb12e6469d6cb2dce31e08d8e1610e532618f
5
+ SHA512:
6
+ metadata.gz: 955bb2a558c4167c28d8ea9d14ba9fe0ba4b520d9828018faa57c0ea3795535214d4838f9010ffab06c3553469ceb518ce7a11d2bac35ab6f7b3d9b81db9457b
7
+ data.tar.gz: fd0464bc25e63eeb06c9799631d527fe5239214024eab2f2faef41a556716644c460f517d250470659c53dd3d69e21f100beda01f21e4bef548ac3bbee94865b
data/.ignore ADDED
@@ -0,0 +1,2 @@
1
+ rbi/*
2
+ sig/*
data/CHANGELOG.md ADDED
@@ -0,0 +1,193 @@
1
+ # Changelog
2
+
3
+ ## 3.6.0 (2026-02-18)
4
+
5
+ Full Changelog: [v3.5.2...v3.6.0](https://github.com/browserbase/stagehand-ruby/compare/v3.5.2...v3.6.0)
6
+
7
+ ### Features
8
+
9
+ * randomize region used for evals, split out pnpm and turbo cache, veri… ([a68a9d2](https://github.com/browserbase/stagehand-ruby/commit/a68a9d2705b2c3b3b35dcaab4b5693184194774b))
10
+
11
+ ## 3.5.2 (2026-02-07)
12
+
13
+ Full Changelog: [v3.5.1...v3.5.2](https://github.com/browserbase/stagehand-ruby/compare/v3.5.1...v3.5.2)
14
+
15
+ ### Bug Fixes
16
+
17
+ * **client:** loosen json header parsing ([ea4142c](https://github.com/browserbase/stagehand-ruby/commit/ea4142cc5973c9207a81c7336c8425c9dbe63a30))
18
+
19
+
20
+ ### Chores
21
+
22
+ * **docs:** remove www prefix ([8498bdd](https://github.com/browserbase/stagehand-ruby/commit/8498bdd34e0288b8a1c28e789d35dcecf91cd8b7))
23
+
24
+ ## 3.5.1 (2026-02-03)
25
+
26
+ Full Changelog: [v3.5.0...v3.5.1](https://github.com/browserbase/stagehand-ruby/compare/v3.5.0...v3.5.1)
27
+
28
+ ### Bug Fixes
29
+
30
+ * **client:** always add content-length to post body, even when empty ([7c7c43e](https://github.com/browserbase/stagehand-ruby/commit/7c7c43e51dd621d74dab8d1fa47de0dcc9bc0a28))
31
+
32
+ ## 3.5.0 (2026-02-03)
33
+
34
+ Full Changelog: [v3.4.0...v3.5.0](https://github.com/browserbase/stagehand-ruby/compare/v3.4.0...v3.5.0)
35
+
36
+ ### Features
37
+
38
+ * Removed MCP from readme for now ([ad8d58e](https://github.com/browserbase/stagehand-ruby/commit/ad8d58ef0e542592e9001b32ef3e921f480218da))
39
+
40
+ ## 3.4.0 (2026-01-29)
41
+
42
+ Full Changelog: [v3.3.0...v3.4.0](https://github.com/browserbase/stagehand-ruby/compare/v3.3.0...v3.4.0)
43
+
44
+ ### Features
45
+
46
+ * Add executionModel serialization to api client ([2042742](https://github.com/browserbase/stagehand-ruby/commit/20427425012c9ee785d18a74596808471be2dc7b))
47
+
48
+ ## 3.3.0 (2026-01-29)
49
+
50
+ Full Changelog: [v3.2.1...v3.3.0](https://github.com/browserbase/stagehand-ruby/compare/v3.2.1...v3.3.0)
51
+
52
+ ### Features
53
+
54
+ * Update stainless.yml for project and publish settings ([c55365a](https://github.com/browserbase/stagehand-ruby/commit/c55365a3bbc0ba0bdea32a10e13c58e5863e3ce4))
55
+
56
+
57
+ ### Bug Fixes
58
+
59
+ * **docs:** fix mcp installation instructions for remote servers ([cd5418d](https://github.com/browserbase/stagehand-ruby/commit/cd5418d7b003862fcee89f5723a1e6449bdee8fa))
60
+
61
+ ## 3.2.1 (2026-01-27)
62
+
63
+ Full Changelog: [v3.2.0...v3.2.1](https://github.com/browserbase/stagehand-ruby/compare/v3.2.0...v3.2.1)
64
+
65
+ ## 3.2.0 (2026-01-27)
66
+
67
+ Full Changelog: [v3.1.0...v3.2.0](https://github.com/browserbase/stagehand-ruby/compare/v3.1.0...v3.2.0)
68
+
69
+ ### Features
70
+
71
+ * add auto-bedrock support based on bedrock/provider.model-name ([fb3762b](https://github.com/browserbase/stagehand-ruby/commit/fb3762b610c4f3049bc74790424556c770bffcf4))
72
+
73
+ ## 3.1.0 (2026-01-27)
74
+
75
+ Full Changelog: [v3.0.3...v3.1.0](https://github.com/browserbase/stagehand-ruby/compare/v3.0.3...v3.1.0)
76
+
77
+ ### Features
78
+
79
+ * **api:** manual updates ([eb975f5](https://github.com/browserbase/stagehand-ruby/commit/eb975f5fa5718d2b8e715e8315ea66f898a0dfdc))
80
+
81
+ ## 3.0.3 (2026-01-27)
82
+
83
+ Full Changelog: [v3.0.2...v3.0.3](https://github.com/browserbase/stagehand-ruby/compare/v3.0.2...v3.0.3)
84
+
85
+ ## 3.0.2 (2026-01-22)
86
+
87
+ Full Changelog: [v3.0.1...v3.0.2](https://github.com/browserbase/stagehand-ruby/compare/v3.0.1...v3.0.2)
88
+
89
+ ### Chores
90
+
91
+ * remove custom code ([3943364](https://github.com/browserbase/stagehand-ruby/commit/394336419ed210704639af03445858f44f03ba13))
92
+
93
+ ## 3.0.1 (2026-01-15)
94
+
95
+ Full Changelog: [v0.6.2...v3.0.1](https://github.com/browserbase/stagehand-ruby/compare/v0.6.2...v3.0.1)
96
+
97
+ ## 0.6.2 (2026-01-13)
98
+
99
+ Full Changelog: [v0.6.1...v0.6.2](https://github.com/browserbase/stagehand-ruby/compare/v0.6.1...v0.6.2)
100
+
101
+ ## 0.6.1 (2026-01-06)
102
+
103
+ Full Changelog: [v0.6.0...v0.6.1](https://github.com/browserbase/stagehand-ruby/compare/v0.6.0...v0.6.1)
104
+
105
+ ### Documentation
106
+
107
+ * 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))
108
+ * prominently feature MCP server setup in root SDK readmes ([f9a368b](https://github.com/browserbase/stagehand-ruby/commit/f9a368b0508862cd3ee53198ac92fe1265c5050f))
109
+
110
+ ## 0.6.0 (2026-01-05)
111
+
112
+ Full Changelog: [v0.5.0...v0.6.0](https://github.com/browserbase/stagehand-ruby/compare/v0.5.0...v0.6.0)
113
+
114
+ ### Features
115
+
116
+ * **api:** manual updates ([ffa5258](https://github.com/browserbase/stagehand-ruby/commit/ffa5258d23db78c2aa398289bc4d775fd5d145f0))
117
+
118
+ ## 0.5.0 (2025-12-23)
119
+
120
+ Full Changelog: [v0.4.0...v0.5.0](https://github.com/browserbase/stagehand-ruby/compare/v0.4.0...v0.5.0)
121
+
122
+ ### Features
123
+
124
+ * [STG-1053] [server] Use fastify-zod-openapi + zod v4 for openapi generation ([926a819](https://github.com/browserbase/stagehand-ruby/commit/926a819a4bbe2b260d3dbd46b860c444f60857bf))
125
+ * **api:** manual updates ([0619302](https://github.com/browserbase/stagehand-ruby/commit/061930217b3efce30e29cf8b2511970b21c86c57))
126
+
127
+
128
+ ### Documentation
129
+
130
+ * add more examples ([3e81eba](https://github.com/browserbase/stagehand-ruby/commit/3e81eba0b962a3ec0c9a8b13fc9ae30f0961663e))
131
+
132
+ ## 0.4.0 (2025-12-19)
133
+
134
+ Full Changelog: [v0.3.0...v0.4.0](https://github.com/browserbase/stagehand-ruby/compare/v0.3.0...v0.4.0)
135
+
136
+ ### Features
137
+
138
+ * **api:** manual updates ([c93a988](https://github.com/browserbase/stagehand-ruby/commit/c93a988374918f841643a84145b3008970b665a7))
139
+
140
+
141
+ ### Bug Fixes
142
+
143
+ * issue where json.parse errors when receiving HTTP 204 with nobody ([fc3e31e](https://github.com/browserbase/stagehand-ruby/commit/fc3e31e00944a7fdf89e367e281bc0510847d15e))
144
+
145
+ ## 0.3.0 (2025-12-17)
146
+
147
+ Full Changelog: [v0.2.0...v0.3.0](https://github.com/browserbase/stagehand-ruby/compare/v0.2.0...v0.3.0)
148
+
149
+ ### Features
150
+
151
+ * **api:** manual updates ([7dcf75c](https://github.com/browserbase/stagehand-ruby/commit/7dcf75cc0c580743b8bb0bbdb41077a6a7aa6dfb))
152
+ * **api:** manual updates ([3162ca0](https://github.com/browserbase/stagehand-ruby/commit/3162ca00c75b37ccb869d7a082f25b263e15d93d))
153
+ * **api:** manual updates ([a972ef7](https://github.com/browserbase/stagehand-ruby/commit/a972ef7dc9040af201ee8e87db013fc077a7ab3f))
154
+ * **api:** manual updates ([be169eb](https://github.com/browserbase/stagehand-ruby/commit/be169ebb8a61b86f4d1caee63aeded39139f10aa))
155
+ * **api:** manual updates ([2a98da9](https://github.com/browserbase/stagehand-ruby/commit/2a98da9563a1ab4e33d6bf3398083d772b61e07f))
156
+ * **api:** manual updates ([05879da](https://github.com/browserbase/stagehand-ruby/commit/05879da16a92ae6199ca2c4e323a6602fbc5d841))
157
+ * **api:** manual updates ([69e4183](https://github.com/browserbase/stagehand-ruby/commit/69e418398b943df8b7454b50ab02d17ba3feb212))
158
+ * **api:** manual updates ([9176bca](https://github.com/browserbase/stagehand-ruby/commit/9176bcaf88f115335199a44a52c8e1d697920822))
159
+ * **api:** manual updates ([36f0681](https://github.com/browserbase/stagehand-ruby/commit/36f0681452a11e25da7126e0270855bbdd3fe8df))
160
+
161
+
162
+ ### Bug Fixes
163
+
164
+ * calling `break` out of streams should be instantaneous ([369b9d0](https://github.com/browserbase/stagehand-ruby/commit/369b9d0d37390d96fa673d08e64594cefc6a04fa))
165
+
166
+ ## 0.2.0 (2025-12-16)
167
+
168
+ Full Changelog: [v0.1.0...v0.2.0](https://github.com/browserbase/stagehand-ruby/compare/v0.1.0...v0.2.0)
169
+
170
+ ### Features
171
+
172
+ * **api:** manual updates ([d660a3a](https://github.com/browserbase/stagehand-ruby/commit/d660a3ad9cd54238d2bc6598b576e7677ebf120f))
173
+ * **api:** manual updates ([c21cb20](https://github.com/browserbase/stagehand-ruby/commit/c21cb20650bbad1ba8f6a89ad33dcf5ddfc53c81))
174
+ * **api:** manual updates ([f04453c](https://github.com/browserbase/stagehand-ruby/commit/f04453c6c2050b7815e3f62d14343dee4698879d))
175
+
176
+ ## 0.1.0 (2025-12-16)
177
+
178
+ Full Changelog: [v0.0.1...v0.1.0](https://github.com/browserbase/stagehand-ruby/compare/v0.0.1...v0.1.0)
179
+
180
+ ### Features
181
+
182
+ * **api:** manual updates ([5deaf8f](https://github.com/browserbase/stagehand-ruby/commit/5deaf8ff2011a2808dcfe66ef14470029bb3590e))
183
+ * **api:** manual updates ([87ce5f3](https://github.com/browserbase/stagehand-ruby/commit/87ce5f320056fb34770be2f0c87985960e995e92))
184
+ * **api:** manual updates ([2a8b9e7](https://github.com/browserbase/stagehand-ruby/commit/2a8b9e7d219360a5e783c650fc7c9544a9a6fbb5))
185
+ * **api:** manual updates ([0bcedba](https://github.com/browserbase/stagehand-ruby/commit/0bcedbaf26918822abdc958e6020f68b263ffee0))
186
+ * **api:** manual updates ([8355d5e](https://github.com/browserbase/stagehand-ruby/commit/8355d5e6b83f6c31f6494f771fba51b6e31023e7))
187
+ * **api:** manual updates ([655f517](https://github.com/browserbase/stagehand-ruby/commit/655f51718008b4c512eed1ce65660dae80039e49))
188
+ * **api:** tweak branding and fix some config fields ([c48f36e](https://github.com/browserbase/stagehand-ruby/commit/c48f36e307aafd9a2d6ac59d9857be789f29eaa1))
189
+
190
+
191
+ ### Chores
192
+
193
+ * configure new SDK language ([3be44a3](https://github.com/browserbase/stagehand-ruby/commit/3be44a344d5bc49e7c2e16129c2b24db175f4eb6))
data/README.md CHANGED
@@ -1,31 +1,403 @@
1
- Stagehand
2
- =========
3
-
4
- Stagehand is a client-side library for manipulating RESTful resources provided by Personas, a Rails + Backbone user managment service.
5
-
6
- Usage
7
- =====
8
-
9
- YourApp::Application.configure do
10
- config.stagehand.client_id = 'YOUR_APP_CLIENT_ID'
11
- config.stagehand.client_secret = 'YOUR_APP_CLIENT_SECRET'
12
- config.stagehand.resource_host = 'YOUR_APP_RESOURCE_HOST'
13
- config.stagehand.client_host = 'YOUR_APP_HOST_WITH_PORT'
14
- end
15
-
16
- class SessionsController < ApplicationController
17
- # stagehand.authorize_url is an OAuth 2.0 url created by the
18
- # configuration variables above. After the user is authenticated
19
- # and grants the client app access, the resource host performs
20
- # a callback setting the session[:access_token] and redirects
21
- # to the client app's root_url.
22
- def new
23
- redirect_to Stagehand.authorize_url
24
- end
25
-
26
- # Destroy the access_token (but leave the OAuth host cookie intact)
27
- def destroy
28
- session[:access_token] = nil
29
- redirect_to root_url, :notice => "Logged out!"
30
- end
31
- end
1
+ # Stagehand Ruby API library
2
+
3
+ <!-- x-stagehand-custom-start -->
4
+ <div id="toc" align="center" style="margin-bottom: 0;">
5
+ <ul style="list-style: none; margin: 0; padding: 0;">
6
+ <a href="https://stagehand.dev">
7
+ <picture>
8
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/browserbase/stagehand/main/media/dark_logo.png" />
9
+ <img alt="Stagehand" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/light_logo.png" width="200" style="margin-right: 30px;" />
10
+ </picture>
11
+ </a>
12
+ </ul>
13
+ </div>
14
+ <p align="center">
15
+ <strong>The AI Browser Automation Framework</strong><br>
16
+ <a href="https://docs.stagehand.dev/v3/sdk/ruby">Read the Docs</a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="https://github.com/browserbase/stagehand/tree/main?tab=MIT-1-ov-file#MIT-1-ov-file">
21
+ <picture>
22
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/browserbase/stagehand/main/media/dark_license.svg" />
23
+ <img alt="MIT License" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/light_license.svg" />
24
+ </picture>
25
+ </a>
26
+ <a href="https://stagehand.dev/discord">
27
+ <picture>
28
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/browserbase/stagehand/main/media/dark_discord.svg" />
29
+ <img alt="Discord Community" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/light_discord.svg" />
30
+ </picture>
31
+ </a>
32
+ </p>
33
+
34
+ <p align="center">
35
+ <a href="https://trendshift.io/repositories/12122" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12122" alt="browserbase%2Fstagehand | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
36
+ </p>
37
+
38
+ <p align="center">
39
+ If you're looking for other languages, you can find them
40
+ <a href="https://docs.stagehand.dev/v3/first-steps/introduction"> here</a>
41
+ </p>
42
+
43
+ <div align="center" style="display: flex; align-items: center; justify-content: center; gap: 4px; margin-bottom: 0;">
44
+ <b>Vibe code</b>
45
+ <span style="font-size: 1.05em;"> Stagehand with </span>
46
+ <a href="https://director.ai" style="display: flex; align-items: center;">
47
+ <span>Director</span>
48
+ </a>
49
+ <span> </span>
50
+ <picture>
51
+ <img alt="Director" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/director_icon.svg" width="25" />
52
+ </picture>
53
+ </div>
54
+ <!-- x-stagehand-custom-end -->
55
+
56
+ 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.
57
+
58
+ It is generated with [Stainless](https://www.stainless.com/).
59
+
60
+ ## Documentation
61
+
62
+ Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/stagehand).
63
+
64
+ The REST API documentation can be found on [docs.stagehand.dev](https://docs.stagehand.dev).
65
+
66
+ ## Installation
67
+
68
+ To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
69
+
70
+ <!-- x-release-please-start-version -->
71
+
72
+ ```ruby
73
+ gem "stagehand", :git => "git://github.com/browserbase/stagehand-ruby.git"
74
+ ```
75
+
76
+ <!-- x-release-please-end -->
77
+
78
+ ## Usage
79
+
80
+ This mirrors `examples/remote_browser_playwright_example.rb`.
81
+
82
+ ```ruby
83
+ require "bundler/setup"
84
+ require "stagehand"
85
+
86
+ require_relative "examples/env"
87
+ ExampleEnv.load!
88
+
89
+ require "playwright"
90
+
91
+ client = Stagehand::Client.new(
92
+ browserbase_api_key: ENV["BROWSERBASE_API_KEY"],
93
+ browserbase_project_id: ENV["BROWSERBASE_PROJECT_ID"],
94
+ model_api_key: ENV["MODEL_API_KEY"],
95
+ server: "remote"
96
+ )
97
+
98
+ start_response = client.sessions.start(
99
+ model_name: "anthropic/claude-sonnet-4-6",
100
+ browser: { type: :browserbase }
101
+ )
102
+
103
+ session_id = start_response.data.session_id
104
+ cdp_url = start_response.data.cdp_url
105
+ raise "No CDP URL returned for this session." if cdp_url.to_s.empty?
106
+
107
+ Playwright.create(playwright_cli_executable_path: "./node_modules/.bin/playwright") do |playwright|
108
+ browser = playwright.chromium.connect_over_cdp(cdp_url)
109
+ context = browser.contexts.first || browser.new_context
110
+ page = context.pages.first || context.new_page
111
+
112
+ client.sessions.navigate(session_id, url: "https://news.ycombinator.com")
113
+ page.wait_for_load_state(state: "domcontentloaded")
114
+
115
+ observe_stream = client.sessions.observe_streaming(
116
+ session_id,
117
+ instruction: "find the link to view comments for the top post"
118
+ )
119
+ observe_stream.each { |_event| }
120
+
121
+ act_stream = client.sessions.act_streaming(
122
+ session_id,
123
+ input: "Click the comments link for the top post"
124
+ )
125
+ act_stream.each { |_event| }
126
+
127
+ extract_stream = client.sessions.extract_streaming(
128
+ session_id,
129
+ instruction: "extract the text of the top comment on this page",
130
+ schema: {
131
+ type: "object",
132
+ properties: {
133
+ commentText: {type: "string"},
134
+ author: {type: "string"}
135
+ },
136
+ required: ["commentText"]
137
+ }
138
+ )
139
+ extract_stream.each { |_event| }
140
+
141
+ execute_stream = client.sessions.execute_streaming(
142
+ session_id,
143
+ execute_options: {
144
+ instruction: "Click the 'Learn more' link if available",
145
+ max_steps: 3
146
+ },
147
+ agent_config: {
148
+ model: Stagehand::ModelConfig.new(
149
+ model_name: "anthropic/claude-opus-4-6",
150
+ api_key: ENV["MODEL_API_KEY"]
151
+ ),
152
+ cua: false
153
+ }
154
+ )
155
+ execute_stream.each { |_event| }
156
+ end
157
+
158
+ client.sessions.end_(session_id)
159
+ ```
160
+
161
+ ## Running the Example
162
+
163
+ Set your environment variables (from `examples/.env.example`):
164
+
165
+ - `STAGEHAND_API_URL`
166
+ - `MODEL_API_KEY`
167
+ - `BROWSERBASE_API_KEY`
168
+ - `BROWSERBASE_PROJECT_ID`
169
+
170
+ ```bash
171
+ cp examples/.env.example examples/.env
172
+ # Edit examples/.env with your credentials.
173
+ ```
174
+
175
+ The examples load `examples/.env` automatically.
176
+
177
+ Examples and dependencies:
178
+
179
+ - `examples/remote_browser_example.rb`: stagehand only
180
+ - `examples/local_browser_example.rb`: stagehand only
181
+ - `examples/remote_browser_playwright_example.rb`: `playwright-ruby-client` + Playwright browsers
182
+ - `examples/local_browser_playwright_example.rb`: `playwright-ruby-client` + Playwright browsers
183
+ - `examples/local_playwright_example.rb`: `playwright-ruby-client` + Playwright browsers
184
+ - `examples/local_watir_example.rb`: `watir`
185
+
186
+ Install dependencies for the example you want to run, then execute it:
187
+
188
+ ```bash
189
+ bundle install
190
+ bundle exec ruby examples/remote_browser_playwright_example.rb
191
+ ```
192
+
193
+ ### Streaming
194
+
195
+ We provide support for streaming responses using Server-Sent Events (SSE).
196
+
197
+ ```ruby
198
+ stream = stagehand.sessions.act_streaming(
199
+ "00000000-your-session-id-000000000000",
200
+ input: "click the first link on the page"
201
+ )
202
+
203
+ stream.each do |session|
204
+ puts(session.data)
205
+ end
206
+ ```
207
+
208
+ ### Handling errors
209
+
210
+ 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:
211
+
212
+ ```ruby
213
+ begin
214
+ session = stagehand.sessions.start(model_name: "anthropic/claude-sonnet-4-6")
215
+ rescue Stagehand::Errors::APIConnectionError => e
216
+ puts("The server could not be reached")
217
+ puts(e.cause) # an underlying Exception, likely raised within `net/http`
218
+ rescue Stagehand::Errors::RateLimitError => e
219
+ puts("A 429 status code was received; we should back off a bit.")
220
+ rescue Stagehand::Errors::APIStatusError => e
221
+ puts("Another non-200-range status code was received")
222
+ puts(e.status)
223
+ end
224
+ ```
225
+
226
+ Error codes are as follows:
227
+
228
+ | Cause | Error Type |
229
+ | ---------------- | -------------------------- |
230
+ | HTTP 400 | `BadRequestError` |
231
+ | HTTP 401 | `AuthenticationError` |
232
+ | HTTP 403 | `PermissionDeniedError` |
233
+ | HTTP 404 | `NotFoundError` |
234
+ | HTTP 409 | `ConflictError` |
235
+ | HTTP 422 | `UnprocessableEntityError` |
236
+ | HTTP 429 | `RateLimitError` |
237
+ | HTTP >= 500 | `InternalServerError` |
238
+ | Other HTTP error | `APIStatusError` |
239
+ | Timeout | `APITimeoutError` |
240
+ | Network error | `APIConnectionError` |
241
+
242
+ ### Retries
243
+
244
+ Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
245
+
246
+ 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.
247
+
248
+ You can use the `max_retries` option to configure or disable this:
249
+
250
+ ```ruby
251
+ # Configure the default for all requests:
252
+ stagehand = Stagehand::Client.new(
253
+ max_retries: 0 # default is 2
254
+ )
255
+
256
+ # Or, configure per-request:
257
+ stagehand.sessions.start(model_name: "anthropic/claude-sonnet-4-6", request_options: {max_retries: 5})
258
+ ```
259
+
260
+ ### Timeouts
261
+
262
+ By default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:
263
+
264
+ ```ruby
265
+ # Configure the default for all requests:
266
+ stagehand = Stagehand::Client.new(
267
+ timeout: nil # default is 60
268
+ )
269
+
270
+ # Or, configure per-request:
271
+ stagehand.sessions.start(model_name: "anthropic/claude-sonnet-4-6", request_options: {timeout: 5})
272
+ ```
273
+
274
+ On timeout, `Stagehand::Errors::APITimeoutError` is raised.
275
+
276
+ Note that requests that time out are retried by default.
277
+
278
+ ## Advanced concepts
279
+
280
+ ### BaseModel
281
+
282
+ All parameter and response objects inherit from `Stagehand::Internal::Type::BaseModel`, which provides several conveniences, including:
283
+
284
+ 1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.
285
+
286
+ 2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.
287
+
288
+ 3. Both instances and the classes themselves can be pretty-printed.
289
+
290
+ 4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.
291
+
292
+ ### Making custom or undocumented requests
293
+
294
+ #### Undocumented properties
295
+
296
+ You can send undocumented parameters to any endpoint, and read undocumented response properties, like so:
297
+
298
+ Note: the `extra_` parameters of the same name overrides the documented parameters.
299
+
300
+ ```ruby
301
+ response =
302
+ stagehand.sessions.start(
303
+ model_name: "anthropic/claude-sonnet-4-6",
304
+ request_options: {
305
+ extra_query: {my_query_parameter: value},
306
+ extra_body: {my_body_parameter: value},
307
+ extra_headers: {"my-header": value}
308
+ }
309
+ )
310
+
311
+ puts(response[:my_undocumented_property])
312
+ ```
313
+
314
+ #### Undocumented request params
315
+
316
+ 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.
317
+
318
+ #### Undocumented endpoints
319
+
320
+ 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:
321
+
322
+ ```ruby
323
+ response = client.request(
324
+ method: :post,
325
+ path: '/undocumented/endpoint',
326
+ query: {"dog": "woof"},
327
+ headers: {"useful-header": "interesting-value"},
328
+ body: {"hello": "world"}
329
+ )
330
+ ```
331
+
332
+ ### Concurrency & connection pooling
333
+
334
+ The `Stagehand::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.
335
+
336
+ 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.
337
+
338
+ 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.
339
+
340
+ Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.
341
+
342
+ ## Sorbet
343
+
344
+ This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.
345
+
346
+ You can provide typesafe request parameters like so:
347
+
348
+ ```ruby
349
+ stagehand.sessions.act("00000000-your-session-id-000000000000", input: "click the first link on the page")
350
+ ```
351
+
352
+ Or, equivalently:
353
+
354
+ ```ruby
355
+ # Hashes work, but are not typesafe:
356
+ stagehand.sessions.act("00000000-your-session-id-000000000000", input: "click the first link on the page")
357
+
358
+ # You can also splat a full Params class:
359
+ params = Stagehand::SessionActParams.new(input: "click the first link on the page")
360
+ stagehand.sessions.act("00000000-your-session-id-000000000000", **params)
361
+ ```
362
+
363
+ ### Enums
364
+
365
+ 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:
366
+
367
+ ```ruby
368
+ # :true
369
+ puts(Stagehand::SessionActParams::XStreamResponse::TRUE)
370
+
371
+ # Revealed type: `T.all(Stagehand::SessionActParams::XStreamResponse, Symbol)`
372
+ T.reveal_type(Stagehand::SessionActParams::XStreamResponse::TRUE)
373
+ ```
374
+
375
+ Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
376
+
377
+ ```ruby
378
+ # Using the enum constants preserves the tagged type information:
379
+ stagehand.sessions.act(
380
+ x_stream_response: Stagehand::SessionActParams::XStreamResponse::TRUE,
381
+ # …
382
+ )
383
+
384
+ # Literal values are also permissible:
385
+ stagehand.sessions.act(
386
+ x_stream_response: :true,
387
+ # …
388
+ )
389
+ ```
390
+
391
+ ## Versioning
392
+
393
+ 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.
394
+
395
+ This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.
396
+
397
+ ## Requirements
398
+
399
+ Ruby 3.2.0 or higher.
400
+
401
+ ## Contributing
402
+
403
+ 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.