@steerpane/cli 0.1.0 → 0.1.1

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 (5) hide show
  1. package/LICENSE +202 -202
  2. package/README.md +64 -58
  3. package/dist/cli.js +54 -44
  4. package/dist/login.js +97 -0
  5. package/package.json +23 -23
package/LICENSE CHANGED
@@ -1,202 +1,202 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,58 +1,64 @@
1
- # Steerpane CLI
2
-
3
- Start and watch remote Chromium sessions, fetch pages and run agent tasks from a terminal or from another agent. Built on `@steerpane/sdk`.
4
-
5
- ```bash
6
- npm install -g @steerpane/cli
7
- steerpane login
8
- ```
9
-
10
- Node 20 or newer. Create an API token in the dashboard first.
11
-
12
- ## Logging in
13
-
14
- `steerpane login` asks for the token and doesn't show it. In a script, pipe it in with `--token-stdin`. There is no `--token` option, because a value on the command line ends up in your shell history. Use `--api-url <url>` if your API isn't the default.
15
-
16
- ```bash
17
- printf '%s' "$MY_TOKEN" | steerpane login --token-stdin
18
- ```
19
-
20
- The token is checked against the API, then saved in `config.json` in `~/.config/steerpane` (`%APPDATA%\steerpane` on Windows). The file is owner-only on Linux and macOS; on Windows it relies on your user profile's permissions. The CLI never prints the token: `steerpane whoami` shows only its prefix. `steerpane logout` deletes the file.
21
-
22
- `STEERPANE_API_TOKEN` and `STEERPANE_API_URL` take priority over the file, which suits CI and agents.
23
-
24
- ## Commands
25
-
26
- ```bash
27
- steerpane sessions create --url https://example.com --auto-close
28
- steerpane sessions list --status live
29
- steerpane sessions live ses_123 # prints the page where a person can watch and take over
30
- steerpane sessions stop ses_123
31
-
32
- steerpane fetch https://example.com --mode auto
33
-
34
- steerpane run "Find the price of the first book on books.toscrape.com" --max-steps 10
35
- ```
36
-
37
- `sessions create` waits for the browser unless you pass `--no-wait`. `run` uses your organization's model key and waits for the result unless you pass `--no-wait`.
38
-
39
- ## For agents
40
-
41
- Add `--json` to any command. The result goes to stdout as one JSON object, with the API's own field names. Errors go to stderr as `{"error": {"code", "message"}}`.
42
-
43
- | Exit code | Meaning |
44
- |---|---|
45
- | 0 | Done |
46
- | 1 | The command failed |
47
- | 2 | Bad usage |
48
- | 3 | Not logged in, or the token was refused |
49
- | 4 | The agent run finished but didn't succeed |
50
-
51
- ```bash
52
- id=$(steerpane sessions create --url https://example.com --json | jq -r .id)
53
- steerpane sessions stop "$id" --json
54
- ```
55
-
56
- ## Licence
57
-
58
- Apache-2.0. This package is only the client. The Steerpane service is separate and has its own terms.
1
+ # Steerpane CLI
2
+
3
+ Start and watch remote Chromium sessions, fetch pages and run agent tasks from a terminal or from another agent. Built on `@steerpane/sdk`.
4
+
5
+ ```bash
6
+ npm install -g @steerpane/cli
7
+ steerpane login
8
+ ```
9
+
10
+ Node 20 or newer. Sign in with your Steerpane account in the browser, or use an API token.
11
+
12
+ ## Logging in
13
+
14
+ `steerpane login` shows two choices: continue in your browser, or paste an API token. Browser sign-in prints a confirmation code, opens Steerpane, and waits while you confirm the code, organization and permissions. An existing dashboard session is reused; otherwise sign in normally, including two-factor authentication. Nothing is granted until you click Authorize.
15
+
16
+ Use `steerpane login --no-browser` on a remote machine: open the printed link on any device. Use `steerpane login --paste-token` to go directly to a visible prompt with hidden input. On an older API that has no browser sign-in endpoint, use the token option.
17
+
18
+ In a script, pipe a token in with `--token-stdin`. There is no `--token` option, because a value on the command line ends up in your shell history. Use `--api-url <url>` if your API isn't the default.
19
+
20
+ ```bash
21
+ printf '%s' "$MY_TOKEN" | steerpane login --token-stdin
22
+ ```
23
+
24
+ The token is checked against the API, then saved in `config.json` in `~/.config/steerpane` (`%APPDATA%\steerpane` on Windows). The file is owner-only on Linux and macOS; on Windows it relies on your user profile's permissions. The CLI never prints the token: `steerpane whoami` shows only its prefix. `steerpane logout` deletes the file.
25
+
26
+ Browser sign-in creates a named, scoped credential that expires in 90 days. Revoke it in the dashboard's API tokens page; logging out locally does not revoke it. The Node and Python SDKs use their own `token` option or `STEERPANE_API_TOKEN`; they do not automatically read the CLI's saved credentials.
27
+
28
+ `STEERPANE_API_TOKEN` and `STEERPANE_API_URL` take priority over the file, which suits CI and agents.
29
+
30
+ ## Commands
31
+
32
+ ```bash
33
+ steerpane sessions create --url https://example.com --auto-close
34
+ steerpane sessions list --status live
35
+ steerpane sessions live ses_123 # prints the page where a person can watch and take over
36
+ steerpane sessions stop ses_123
37
+
38
+ steerpane fetch https://example.com --mode auto
39
+
40
+ steerpane run "Find the price of the first book on books.toscrape.com" --max-steps 10
41
+ ```
42
+
43
+ `sessions create` waits for the browser unless you pass `--no-wait`. `run` uses your organization's model key and waits for the result unless you pass `--no-wait`.
44
+
45
+ ## For agents
46
+
47
+ Add `--json` to any command. The result goes to stdout as one JSON object, with the API's own field names. Errors go to stderr as `{"error": {"code", "message"}}`.
48
+
49
+ | Exit code | Meaning |
50
+ |---|---|
51
+ | 0 | Done |
52
+ | 1 | The command failed |
53
+ | 2 | Bad usage |
54
+ | 3 | Not logged in, or the token was refused |
55
+ | 4 | The agent run finished but didn't succeed |
56
+
57
+ ```bash
58
+ id=$(steerpane sessions create --url https://example.com --json | jq -r .id)
59
+ steerpane sessions stop "$id" --json
60
+ ```
61
+
62
+ ## Licence
63
+
64
+ Apache-2.0. This package is only the client. The Steerpane service is separate and has its own terms.
package/dist/cli.js CHANGED
@@ -1,34 +1,36 @@
1
1
  #!/usr/bin/env node
2
2
  import { readFileSync } from "node:fs";
3
- import { createInterface } from "node:readline";
4
3
  import { parseArgs } from "node:util";
5
4
  import { APIError, DEFAULT_BASE_URL, Steerpane, SteerpaneError } from "@steerpane/sdk";
6
5
  import { configPath, deleteConfig, readConfig, writeConfig } from "./config.js";
6
+ import { browserLogin, prompt } from "./login.js";
7
7
  const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
8
8
  const EXIT = { ok: 0, failed: 1, usage: 2, auth: 3, task_failed: 4 };
9
- const HELP = `steerpane ${VERSION}: remote browsers for AI agents
10
-
11
- Usage: steerpane <command> [options]
12
-
13
- login Save an API token (asks for it, or --token-stdin)
14
- --token-stdin Read the token from stdin
15
- --api-url <url> API to use from now on
16
- logout Delete the saved token
17
- whoami Show which API and token prefix are in use
18
-
19
- sessions list --status <s> --limit <n>
20
- sessions create --url <u> --profile <id> --auto-close --timeout-min <n> --no-wait
21
- sessions get <id>
22
- sessions stop <id>
23
- sessions live <id> Print the page where a person can watch and take over
24
-
25
- fetch <url> --mode fast|deep|auto --format markdown|html|raw
26
- run "<task>" --profile <id> --model <m> --max-steps <n> --max-cost-usd <n> --no-wait --timeout-s <n>
27
-
28
- Every command takes --json, for machine-readable output on stdout and errors on stderr as
29
- {"error": {"code", "message"}}. STEERPANE_API_TOKEN and STEERPANE_API_URL override the saved values.
30
-
31
- Exit codes: 0 ok, 1 failed, 2 bad usage, 3 not logged in or token refused, 4 the run finished but failed.
9
+ const HELP = `steerpane ${VERSION}: remote browsers for AI agents
10
+
11
+ Usage: steerpane <command> [options]
12
+
13
+ login Sign in with your browser, or paste an API token
14
+ --paste-token Paste an API token at a visible, hidden-input prompt
15
+ --token-stdin Read the token from stdin
16
+ --no-browser Print the browser sign-in link without opening it
17
+ --api-url <url> API to use from now on
18
+ logout Delete the saved token
19
+ whoami Show which API and token prefix are in use
20
+
21
+ sessions list --status <s> --limit <n>
22
+ sessions create --url <u> --profile <id> --auto-close --timeout-min <n> --no-wait
23
+ sessions get <id>
24
+ sessions stop <id>
25
+ sessions live <id> Print the page where a person can watch and take over
26
+
27
+ fetch <url> --mode fast|deep|auto --format markdown|html|raw
28
+ run "<task>" --profile <id> --model <m> --max-steps <n> --max-cost-usd <n> --no-wait --timeout-s <n>
29
+
30
+ Every command takes --json, for machine-readable output on stdout and errors on stderr as
31
+ {"error": {"code", "message"}}. STEERPANE_API_TOKEN and STEERPANE_API_URL override the saved values.
32
+
33
+ Exit codes: 0 ok, 1 failed, 2 bad usage, 3 not logged in or token refused, 4 the run finished but failed.
32
34
  `;
33
35
  class UsageError extends Error {
34
36
  }
@@ -62,22 +64,6 @@ function emit(asJson, value, text) {
62
64
  function sessionLine(s) {
63
65
  return [s.id, s.status, s.controller, s.current_url ?? "-"].join("\t");
64
66
  }
65
- /** Hidden prompt on a terminal. A pipe or a redirect is read as it comes. */
66
- async function readTokenInteractive() {
67
- if (!process.stdin.isTTY)
68
- throw new UsageError("Pass the token on stdin with --token-stdin, or run this in a terminal.");
69
- return new Promise((resolve) => {
70
- const rl = createInterface({ input: process.stdin, output: process.stderr, terminal: true });
71
- const output = rl;
72
- process.stderr.write("API token (not shown): ");
73
- output._writeToOutput = () => { };
74
- rl.question("", (answer) => {
75
- rl.close();
76
- process.stderr.write("\n");
77
- resolve(answer.trim());
78
- });
79
- });
80
- }
81
67
  async function readStdin() {
82
68
  const chunks = [];
83
69
  for await (const chunk of process.stdin)
@@ -85,14 +71,38 @@ async function readStdin() {
85
71
  return Buffer.concat(chunks).toString("utf8").trim();
86
72
  }
87
73
  async function login(args) {
88
- const { values } = parse(args, { "token-stdin": { type: "boolean" }, "api-url": { type: "string" }, token: { type: "string" } });
74
+ const { values } = parse(args, { "token-stdin": { type: "boolean" }, "paste-token": { type: "boolean" }, "no-browser": { type: "boolean" }, "api-url": { type: "string" }, token: { type: "string" } });
89
75
  if (values.token !== undefined)
90
76
  throw new UsageError("--token isn't accepted, because it would end up in your shell history. Use --token-stdin, or run `steerpane login` and paste it.");
91
- const token = values["token-stdin"] ? await readStdin() : await readTokenInteractive();
77
+ if ((values["token-stdin"] || values["paste-token"]) && values["no-browser"])
78
+ throw new UsageError("Choose token sign-in or browser sign-in, not both.");
79
+ if (values["token-stdin"] && values["paste-token"])
80
+ throw new UsageError("Choose --token-stdin or --paste-token, not both.");
81
+ const previous = readConfig();
82
+ const apiUrl = (values["api-url"] ?? process.env["STEERPANE_API_URL"] ?? previous.api_url ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
83
+ // Validate HTTPS / loopback before sending any token or opening a returned link.
84
+ new Steerpane({ token: "configuration-check", baseUrl: apiUrl });
85
+ let token;
86
+ if (values["token-stdin"])
87
+ token = await readStdin();
88
+ else if (values["paste-token"])
89
+ token = await prompt("API token (input hidden): ", true);
90
+ else {
91
+ if (!values["no-browser"]) {
92
+ if (!process.stdin.isTTY)
93
+ throw new UsageError("Run this in a terminal, use --no-browser for a sign-in link, or --token-stdin to pipe an API token.");
94
+ process.stderr.write("Sign in to Steerpane\n 1. Continue in your browser (default)\n 2. Paste an API token\n");
95
+ const choice = await prompt("Choose [1]: ");
96
+ if (choice && !["1", "2"].includes(choice))
97
+ throw new UsageError("Choose 1 for browser sign-in or 2 to paste a token.");
98
+ token = choice === "2" ? await prompt("API token (input hidden): ", true) : await browserLogin(apiUrl, false);
99
+ }
100
+ else
101
+ token = await browserLogin(apiUrl, true);
102
+ }
92
103
  if (!token)
93
104
  throw new UsageError("No token given");
94
- const previous = readConfig();
95
- const apiUrl = values["api-url"] ?? process.env["STEERPANE_API_URL"] ?? previous.api_url ?? DEFAULT_BASE_URL;
105
+ process.stderr.write("Checking credentials…\n");
96
106
  await new Steerpane({ token, baseUrl: apiUrl }).sessions.list({ limit: 1 }); // refuses a bad token before saving it
97
107
  const path = writeConfig({ token, api_url: apiUrl });
98
108
  emit(Boolean(values.json), { ok: true, api_url: apiUrl, config: path }, `Logged in to ${apiUrl}. Token saved in ${path}.`);
package/dist/login.js ADDED
@@ -0,0 +1,97 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createInterface } from "node:readline";
3
+ import { Writable } from "node:stream";
4
+ import { SteerpaneError } from "@steerpane/sdk";
5
+ export async function prompt(message, hidden = false) {
6
+ if (!process.stdin.isTTY)
7
+ throw new SteerpaneError("Use --token-stdin to pipe a token, or --no-browser for a remote terminal.");
8
+ const silent = new Writable({ write(_chunk, _encoding, done) { done(); } });
9
+ const rl = createInterface({ input: process.stdin, output: hidden ? silent : process.stderr, terminal: true });
10
+ if (hidden)
11
+ process.stderr.write(message);
12
+ return new Promise((resolve, reject) => {
13
+ let answered = false;
14
+ rl.on("SIGINT", () => rl.close());
15
+ rl.on("close", () => {
16
+ if (!answered)
17
+ reject(new SteerpaneError("Sign-in cancelled."));
18
+ });
19
+ rl.question(hidden ? "" : message, (answer) => {
20
+ answered = true;
21
+ rl.close();
22
+ if (hidden)
23
+ process.stderr.write("\n");
24
+ resolve(answer.trim());
25
+ });
26
+ });
27
+ }
28
+ function openBrowser(uri) {
29
+ const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32" : "xdg-open";
30
+ const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", uri] : [uri];
31
+ const child = spawn(command, args, { stdio: "ignore", detached: true, shell: false });
32
+ child.on("error", () => process.stderr.write("Couldn't open a browser. Open the sign-in link above on any device.\n"));
33
+ child.on("exit", (code) => { if (code)
34
+ process.stderr.write("Open the sign-in link above in your browser to continue.\n"); });
35
+ child.unref();
36
+ }
37
+ async function form(apiUrl, path, values) {
38
+ let response;
39
+ try {
40
+ response = await fetch(apiUrl + path, { method: "POST", body: new URLSearchParams(values), signal: AbortSignal.timeout(15000), redirect: "error" });
41
+ }
42
+ catch {
43
+ throw new SteerpaneError(`Can't reach ${apiUrl}. Check the API URL and connection, then try again.`);
44
+ }
45
+ let data;
46
+ try {
47
+ data = await response.json();
48
+ }
49
+ catch {
50
+ throw new SteerpaneError("The API returned an invalid sign-in response.");
51
+ }
52
+ return { ok: response.ok, status: response.status, data };
53
+ }
54
+ export async function browserLogin(apiUrl, noBrowser) {
55
+ const device = await form(apiUrl, "/v1/oauth/device/code", { client_id: "steerpane-cli" });
56
+ if (!device.ok) {
57
+ if (device.status === 404)
58
+ throw new SteerpaneError("This API doesn't support browser sign-in yet. Use `steerpane login --paste-token`.");
59
+ throw new SteerpaneError("Couldn't start browser sign-in. Try again, or use `steerpane login --paste-token`.");
60
+ }
61
+ const { device_code, user_code, verification_uri_complete, expires_in, interval } = device.data;
62
+ if (typeof device_code !== "string" || typeof user_code !== "string" || typeof verification_uri_complete !== "string" || typeof expires_in !== "number" || expires_in <= 0 || typeof interval !== "number" || interval < 1) {
63
+ throw new SteerpaneError("The API returned an invalid device sign-in response.");
64
+ }
65
+ const uri = new URL(verification_uri_complete);
66
+ if (uri.protocol !== "https:" && !(uri.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(uri.hostname))) {
67
+ throw new SteerpaneError("The API returned an insecure sign-in link.");
68
+ }
69
+ process.stderr.write(`\nOpen this link to sign in:\n${uri.href}\n\nConfirm code: ${user_code}\n`);
70
+ if (!noBrowser) {
71
+ process.stderr.write("Opening your browser…\n");
72
+ openBrowser(uri.href);
73
+ }
74
+ process.stderr.write("Waiting for approval. Your existing dashboard session can be used.\nTo use an API token instead, cancel and run `steerpane login --paste-token`.\n");
75
+ const deadline = Date.now() + Math.min(expires_in, 900) * 1000;
76
+ let delay = interval * 1000;
77
+ while (Date.now() < deadline) {
78
+ await new Promise((resolve) => setTimeout(resolve, Math.min(delay, Math.max(0, deadline - Date.now()))));
79
+ if (Date.now() >= deadline)
80
+ break;
81
+ const poll = await form(apiUrl, "/v1/oauth/token", { grant_type: "urn:ietf:params:oauth:grant-type:device_code", client_id: "steerpane-cli", device_code });
82
+ if (poll.ok && typeof poll.data.access_token === "string")
83
+ return poll.data.access_token;
84
+ if (poll.data.error === "authorization_pending")
85
+ continue;
86
+ if (poll.data.error === "slow_down") {
87
+ delay += 5000;
88
+ continue;
89
+ }
90
+ if (poll.data.error === "access_denied")
91
+ throw new SteerpaneError("Sign-in was denied in the browser. No token was saved.");
92
+ if (poll.data.error === "expired_token")
93
+ break;
94
+ throw new SteerpaneError("Browser sign-in failed. Start `steerpane login` again.");
95
+ }
96
+ throw new SteerpaneError("Sign-in expired. Run `steerpane login` to start again.");
97
+ }
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
- {
2
- "name": "@steerpane/cli",
3
- "version": "0.1.0",
4
- "description": "Command line for Steerpane: remote browsers for AI agents, with human takeover.",
5
- "license": "Apache-2.0",
1
+ {
2
+ "name": "@steerpane/cli",
3
+ "version": "0.1.1",
4
+ "description": "Command line for Steerpane: remote browsers for AI agents, with human takeover.",
5
+ "license": "Apache-2.0",
6
6
  "homepage": "https://steerpane.app",
7
- "repository": { "type": "git", "url": "git+https://github.com/Steerpane/sdks.git", "directory": "cli" },
8
- "keywords": ["browser", "automation", "agents", "cli"],
9
- "type": "module",
10
- "bin": { "steerpane": "dist/cli.js" },
11
- "files": ["dist", "README.md", "LICENSE"],
12
- "engines": { "node": ">=20" },
13
- "publishConfig": { "access": "public" },
14
- "scripts": {
15
- "build": "tsc -p tsconfig.json",
16
- "test": "node --test test/*.test.mjs",
17
- "prepack": "npm run build"
18
- },
19
- "dependencies": { "@steerpane/sdk": "^0.1.0" },
20
- "devDependencies": {
21
- "@types/node": "^22.0.0",
22
- "typescript": "^5.6.0"
23
- }
24
- }
7
+ "repository": { "type": "git", "url": "git+https://github.com/Steerpane/sdks.git", "directory": "cli" },
8
+ "keywords": ["browser", "automation", "agents", "cli"],
9
+ "type": "module",
10
+ "bin": { "steerpane": "dist/cli.js" },
11
+ "files": ["dist", "README.md", "LICENSE"],
12
+ "engines": { "node": ">=20" },
13
+ "publishConfig": { "access": "public" },
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json",
16
+ "test": "node --test test/*.test.mjs",
17
+ "prepack": "npm run build"
18
+ },
19
+ "dependencies": { "@steerpane/sdk": "^0.1.0" },
20
+ "devDependencies": {
21
+ "@types/node": "^22.0.0",
22
+ "typescript": "^5.6.0"
23
+ }
24
+ }