qz-browser-agent 0.0.0-stage → 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.
- package/LICENSE +202 -0
- package/README.md +466 -2
- package/package.json +14 -4
- package/src/args.mjs +153 -0
- package/src/bin.mjs +25 -0
- package/src/browser-registry.mjs +101 -0
- package/src/catalog.json +849 -0
- package/src/cli-resources.mjs +25 -0
- package/src/cli.mjs +360 -0
- package/src/client.mjs +134 -0
- package/src/commands.mjs +126 -0
- package/src/daemon.mjs +280 -0
- package/src/open-browser.mjs +20 -0
- package/src/output.mjs +64 -0
- package/src/package-info.mjs +7 -0
- package/src/server.mjs +211 -0
- package/src/shell.mjs +24 -0
- package/src/state.mjs +329 -0
- package/src/task-stream.mjs +207 -0
- package/src/terminal.mjs +519 -0
- package/src/tools.mjs +197 -0
package/LICENSE
ADDED
|
@@ -0,0 +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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,467 @@
|
|
|
1
|
-
#
|
|
1
|
+
# qz command line and MCP
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Run browser tasks, manage results, and connect external agents to qz through CLI or MCP.
|
|
4
|
+
Requires Node.js 24 or later and Chrome. CLI and MCP share the same browser connection.
|
|
5
|
+
|
|
6
|
+
## Quick start
|
|
7
|
+
|
|
8
|
+
Install [qz from the Chrome Web Store](https://chromewebstore.google.com/detail/dknbdgkgoinlgjpfebapkklbmjjgdblm)
|
|
9
|
+
with **Add to Chrome**. Open the qz side panel, complete its first-use data notice, and configure
|
|
10
|
+
your provider and model in Settings.
|
|
11
|
+
|
|
12
|
+
Run the published package with npx:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx qz-browser-agent@latest connect
|
|
16
|
+
npx qz-browser-agent@latest create "Summarize the current page." --stream
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`npx qz-browser-agent@latest install` opens the same Chrome Web Store page. For a manual ZIP
|
|
20
|
+
installation, download the [latest GitHub release](https://github.com/alibaba/qz-browser-agent/releases/latest)
|
|
21
|
+
and follow the [manual installation steps](https://github.com/alibaba/qz-browser-agent/blob/main/README.md#manual-installation).
|
|
22
|
+
|
|
23
|
+
`connect` starts the local MCP service and opens its connection page for first pairing. Use the
|
|
24
|
+
Chrome profile where qz is installed. The first new profile is named `default`;
|
|
25
|
+
accepting the data notice alone does not enable the local connection. Repeating `connect` reuses
|
|
26
|
+
an online browser. Add further profiles with a [pairing URL](#pair-a-selected-browser-from-the-shell)
|
|
27
|
+
or from their own qz Settings.
|
|
28
|
+
|
|
29
|
+
The examples and suggested next commands use `qz`. Replace it with
|
|
30
|
+
`npx qz-browser-agent@latest`, or install the command globally:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npm install --global qz-browser-agent@latest
|
|
34
|
+
qz --version
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
On Windows, use PowerShell 7.3 or newer with its default native argument passing. After a global
|
|
38
|
+
install, use `qz.ps1` for commands containing JSON or quoted names; Windows command suggestions
|
|
39
|
+
use that wrapper. For automation, pin a compatible release version verified with your extension.
|
|
40
|
+
|
|
41
|
+
## Connect and stop
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
qz connect
|
|
45
|
+
qz status
|
|
46
|
+
qz browsers
|
|
47
|
+
qz mcp
|
|
48
|
+
qz stop
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`connect` reuses the healthy service already running for this installation. It prefers port 18765;
|
|
52
|
+
if that port belongs to another program, the service chooses a free port. `status` shows the actual
|
|
53
|
+
service address, and `mcp` prints its MCP URL. Both commands are read-only. To request a custom port,
|
|
54
|
+
run `qz connect --port 18766`; an existing service on another port remains running and the command
|
|
55
|
+
reports its address. The extension connects only to its configured address.
|
|
56
|
+
|
|
57
|
+
The connection page can be closed once `qz browsers` shows the profile online. Connections start
|
|
58
|
+
only through `qz connect` or **qz Settings → Advanced → CLI → Connect CLI**. For ordinary connection
|
|
59
|
+
failures, the extension makes at most three recovery attempts, 30 seconds apart, then pauses.
|
|
60
|
+
After a browser or background restart, it may first wait once for the previous connection to expire.
|
|
61
|
+
The saved retry budget survives worker restarts. Click **Connect CLI** in that browser's settings to retry.
|
|
62
|
+
|
|
63
|
+
To disconnect one browser, click **Disconnect: NAME** in its qz Settings. `qz stop` stops the local
|
|
64
|
+
service and disconnects every browser and MCP client using it. Browser tasks already running
|
|
65
|
+
remain in the extension; stopping the service does not cancel them. Use `qz cancel TASK_ID` to stop
|
|
66
|
+
a task, adding `--client NAME|UUID` when needed.
|
|
67
|
+
|
|
68
|
+
### Pair a selected browser from the shell
|
|
69
|
+
|
|
70
|
+
Get a pairing URL without opening the default browser or waiting for a connection:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
qz connect --no-open --json
|
|
74
|
+
qz connect --no-open --name work --json
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The JSON envelope contains `result.endpoint`, `result.url`, `result.mcpUrl`, and
|
|
78
|
+
`result.opened: false`. The command starts or reuses the service even when other browsers are
|
|
79
|
+
already connected. Open the exact returned URL in the intended browser Profile with qz installed.
|
|
80
|
+
|
|
81
|
+
Set `QZ_PAIRING_URL` to that URL and `QZ_PROFILE_DIRECTORY` to the selected profile's directory
|
|
82
|
+
name, such as `Default` or `Profile 2`. These are directory names, not Chrome's display labels.
|
|
83
|
+
Use a Profile already chosen by the user. On macOS:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
open -na "Google Chrome" --args --profile-directory="$QZ_PROFILE_DIRECTORY" "$QZ_PAIRING_URL"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For Chrome on Linux:
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
google-chrome --profile-directory="$QZ_PROFILE_DIRECTORY" "$QZ_PAIRING_URL"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For Chrome installed under Program Files on Windows, set `$QzProfileDirectory` and
|
|
96
|
+
`$QzPairingUrl` to those same values in PowerShell:
|
|
97
|
+
|
|
98
|
+
```powershell
|
|
99
|
+
& "$env:ProgramFiles\Google\Chrome\Application\chrome.exe" "--profile-directory=$QzProfileDirectory" $QzPairingUrl
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Use the installed browser's executable or app name. For an existing custom data directory, also
|
|
103
|
+
pass `--user-data-dir` with its exact path; for example on macOS:
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
open -na "Google Chrome" --args --user-data-dir="$QZ_USER_DATA_DIR" --profile-directory="$QZ_PROFILE_DIRECTORY" "$QZ_PAIRING_URL"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The [Chrome profile documentation](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md)
|
|
110
|
+
distinguishes the data directory from the Profile inside it. A new data directory needs its own
|
|
111
|
+
extension installation and first-use setup.
|
|
112
|
+
|
|
113
|
+
`--name work` adds `?name=work` to the URL. The Profile opening it receives that identifier,
|
|
114
|
+
including when it already has a connection. Without `--name`, a registered Profile keeps its name;
|
|
115
|
+
a new Profile receives the next available name: `default`, `browser-2`, and so on. A name conflict
|
|
116
|
+
requires another name. `qz connect --name work` opens the URL automatically and returns immediately.
|
|
117
|
+
These URL-returning commands do not confirm that a browser connected. Verify it with:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
qz browsers --json
|
|
121
|
+
qz create "Summarize the current page." --client UUID --stream
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Read `result.browsers`, then use the intended online entry's `clientId` UUID. `--client` selects an
|
|
125
|
+
existing connection and cannot be combined with `--no-open` or `--name`. `--port` works with either
|
|
126
|
+
pairing mode and follows the existing-service behavior above.
|
|
127
|
+
|
|
128
|
+
### Add and select browsers
|
|
129
|
+
|
|
130
|
+
You can also pair from **qz Settings → Advanced → CLI** in the intended Profile. Enter a distinct
|
|
131
|
+
browser identifier and connect. Use the service address printed by `qz status` in **Local service address** if
|
|
132
|
+
its port differs from 18765. Names use 1–64 letters, digits, underscores, or hyphens, beginning with
|
|
133
|
+
a letter or digit; names are case-sensitive. UUID-shaped names are reserved for profile IDs.
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
qz browsers
|
|
137
|
+
qz create "Summarize the current page." --client work --stream
|
|
138
|
+
qz show TASK_ID --client work
|
|
139
|
+
qz data --client work
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`--client NAME|UUID` and `-c NAME|UUID` select a profile. With exactly one online browser, the CLI
|
|
143
|
+
selects it automatically. With several online browsers, a selection is required; `default` is a
|
|
144
|
+
name, not a routing preference. An unknown or offline selection fails without opening or using
|
|
145
|
+
another browser. Each command resolves its name once and carries the UUID through subsequent
|
|
146
|
+
requests. JSON task results and suggested next commands include that UUID.
|
|
147
|
+
|
|
148
|
+
Names remain registered while their browsers are offline and across service restarts. To release
|
|
149
|
+
an offline name, remove its registration explicitly:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
qz browsers forget work
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
An online browser must first disconnect in its settings. Forgetting a registration leaves the
|
|
156
|
+
browser's tasks and data intact. A browser can then explicitly pair using the released name.
|
|
157
|
+
|
|
158
|
+
### Update the connection
|
|
159
|
+
|
|
160
|
+
Use the current CLI and extension together. Source edits and a newer npm package leave a healthy
|
|
161
|
+
running service in place; `qz status` reports an available update. An incompatible service returns
|
|
162
|
+
an update instruction instead of being stopped automatically.
|
|
163
|
+
|
|
164
|
+
1. Use the latest CLI and let current tasks finish.
|
|
165
|
+
2. Run `npx --yes qz-browser-agent@latest stop`. This disconnects all browsers using that service.
|
|
166
|
+
3. Update qz from the [Chrome Web Store](https://chromewebstore.google.com/detail/dknbdgkgoinlgjpfebapkklbmjjgdblm).
|
|
167
|
+
For a manual ZIP installation, replace its extracted files with the
|
|
168
|
+
[latest release](https://github.com/alibaba/qz-browser-agent/releases/latest) and reload it at `chrome://extensions`.
|
|
169
|
+
4. Run `npx --yes qz-browser-agent@latest connect`, then reconnect additional profiles using their
|
|
170
|
+
pairing URL or settings.
|
|
171
|
+
|
|
172
|
+
## Connect an MCP client
|
|
173
|
+
|
|
174
|
+
Run `qz connect`, then `qz mcp`. Copy the returned URL into your MCP client's HTTP configuration:
|
|
175
|
+
|
|
176
|
+
```toml
|
|
177
|
+
[mcp_servers.qz]
|
|
178
|
+
url = "http://127.0.0.1:18765/mcp"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Use the URL printed by your command if its port differs. `qz mcp --json` returns the URL as JSON
|
|
182
|
+
for scripts. The `qingzhou_*` MCP tool names and extension protocol remain available. Responses
|
|
183
|
+
to pending input bind to an explicit `waitId`. Use `qingzhou_bridge_status` to list browser names
|
|
184
|
+
and UUIDs, then pass `clientId: "work"` or a UUID to browser tools. Selection is required with
|
|
185
|
+
multiple online browsers. Task results include the resolved `clientId`. MCP initialization and streaming are handled by your
|
|
186
|
+
client's MCP implementation.
|
|
187
|
+
|
|
188
|
+
### Task and resource operations
|
|
189
|
+
|
|
190
|
+
CLI and MCP use the same task observer and browser operations. The task and resource commands map to these MCP operations:
|
|
191
|
+
|
|
192
|
+
| CLI | MCP tool |
|
|
193
|
+
| --- | --- |
|
|
194
|
+
| `browsers`, `browsers forget` | `qingzhou_bridge_status`, `qingzhou_forget_browser` |
|
|
195
|
+
| `create`, `send`, `cancel` | `qingzhou_create_session`, `qingzhou_send_message`, `qingzhou_stop_session` |
|
|
196
|
+
| `tasks`, `show`, `watch` | `qingzhou_list_sessions`, `qingzhou_get_session_snapshot`, `qingzhou_watch_task` |
|
|
197
|
+
| `show`, `submit` / `approve` / `reject` | `qingzhou_get_session_snapshot`, `qingzhou_respond_to_user_input` |
|
|
198
|
+
| `data list` / `delete` / `export` | `qingzhou_list_data_tables`, `qingzhou_delete_data_table`, `qingzhou_export_data_table` |
|
|
199
|
+
| `images list` / `delete` / `export` | `qingzhou_list_image_collections`, `qingzhou_delete_image_collection`, `qingzhou_export_image_collection` |
|
|
200
|
+
| `skills list` / `show` / `read` / `tools` / `export` | `qingzhou_list_skills`, `qingzhou_get_skill`, `qingzhou_get_skill_resource`, `qingzhou_list_plugins`, `qingzhou_export_skill` |
|
|
201
|
+
| `settings get` / `set` | `qingzhou_get_settings`, `qingzhou_update_settings` |
|
|
202
|
+
| `automations list` / `run` | `qingzhou_list_automations`, `qingzhou_run_automation` |
|
|
203
|
+
|
|
204
|
+
MCP creation, message submission, and input responses accept `wait: true` to wait for completion;
|
|
205
|
+
`stream: true` also sends assistant text through standard MCP progress notifications. A watch call
|
|
206
|
+
always waits. For example, call `qingzhou_create_session` with:
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{"firstMessage":"Summarize the current page.","stream":true}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Supply `_meta.progressToken` on the MCP request to receive progress. Each notification includes a
|
|
213
|
+
readable `message` and its structured event in `params._meta["qz/task-event"]`. Events include
|
|
214
|
+
`created`, `status`, `text`, `replace`, and `input`. Input events include the current form, exact
|
|
215
|
+
field IDs, option values, and `responseTemplate`. Fill that template and pass it to
|
|
216
|
+
`qingzhou_respond_to_user_input`; another CLI or MCP connection can answer while the original call
|
|
217
|
+
keeps waiting. Native Chrome permissions still require the user's click in the side panel.
|
|
218
|
+
|
|
219
|
+
MCP `timeoutSeconds` bounds each browser request (180 seconds by default).
|
|
220
|
+
`waitTimeoutSeconds` bounds the whole observation; omit it for no overall deadline. Configure your
|
|
221
|
+
MCP client's own request deadline for long tasks. On timeout or cancellation, the browser task
|
|
222
|
+
continues; error details include the task ID and a recovery tool call. `send_message` supports
|
|
223
|
+
`steer: true` and follows its returned `clientMessageId`, including when steering stays in the same
|
|
224
|
+
run. A long observation stays bound to the browser selected when it started.
|
|
225
|
+
|
|
226
|
+
## Run a task
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
qz create "Compare these two laptops."
|
|
230
|
+
qz create "Summarize the current page." --title "Research" --wait
|
|
231
|
+
qz create "Find the main differences between these pages." --stream
|
|
232
|
+
qz send TASK_ID "Add the source links." --stream
|
|
233
|
+
qz send TASK_ID "Focus on open-source options." --steer --stream
|
|
234
|
+
qz tasks
|
|
235
|
+
qz show TASK_ID
|
|
236
|
+
qz cancel TASK_ID
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
`create` starts a task and returns its ID. The title is optional. `--wait` waits for the result;
|
|
240
|
+
`--stream` also displays progress as it arrives. Both stay connected while the task waits for user
|
|
241
|
+
input and continue automatically after you respond. Task observation has no default time limit.
|
|
242
|
+
Add `--timeout SECONDS` to set a total deadline, including time spent waiting for input. Each
|
|
243
|
+
individual connection request remains bounded (180 seconds by default). A timeout or Ctrl-C ends
|
|
244
|
+
watching; `qz watch TASK_ID --stream` resumes observation and `qz cancel TASK_ID` stops the task.
|
|
245
|
+
Each CLI command initializes one MCP connection on its first tool call and reuses it for subsequent
|
|
246
|
+
reads and responses. Completion, errors, and Ctrl-C close that connection. Transport failures are
|
|
247
|
+
reported without automatically repeating browser actions.
|
|
248
|
+
|
|
249
|
+
Provide the task text directly after `create`, or read it from stdin with `qz create -`.
|
|
250
|
+
Use `--parent TASK_ID` to create a child task, and `qz tasks --limit N` to limit the task list.
|
|
251
|
+
`send TASK_ID MESSAGE` sends a follow-up to the specified task; `qz send TASK_ID -` reads the message
|
|
252
|
+
from stdin. A busy task queues a follow-up for its next run. Add `--steer` to deliver the message
|
|
253
|
+
to the current run at its next safe boundary. Both start a new run when the task is idle. Pending
|
|
254
|
+
questions and permissions still require a response.
|
|
255
|
+
|
|
256
|
+
`--wait` and `--stream` track the submitted message. Streaming starts after that message, including
|
|
257
|
+
when steering continues the same run. Pending questions from the preceding run remain visible so
|
|
258
|
+
you can answer them and let a queued follow-up proceed. A connection failure never resends a message
|
|
259
|
+
automatically.
|
|
260
|
+
|
|
261
|
+
## Respond to a task
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
qz show TASK_ID
|
|
265
|
+
qz submit TASK_ID '{"selectedIds":["option-a"]}' --stream
|
|
266
|
+
qz approve TASK_ID --wait
|
|
267
|
+
qz reject TASK_ID
|
|
268
|
+
qz watch TASK_ID --stream
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
`show` and pending-input notices include the current question, labeled field IDs,
|
|
272
|
+
option values, descriptions, image URLs, and a submission template with the actual field IDs.
|
|
273
|
+
Edit its placeholder values and run the displayed command to respond. `submit` takes a JSON object
|
|
274
|
+
keyed by field IDs; use option values for choices and arrays for multiple choices. Use
|
|
275
|
+
`qz submit TASK_ID -` to read answers from stdin. Invalid or stale submissions return the current
|
|
276
|
+
input and its template so you can correct the response directly.
|
|
277
|
+
`approve` continues a confirmation after you finish the requested action. `reject` declines the
|
|
278
|
+
current request; `cancel` stops the whole task.
|
|
279
|
+
|
|
280
|
+
Each response reads the current wait ID before sending. To answer a specific request you already
|
|
281
|
+
read, pass `--wait-id WAIT_ID` to `submit`, `approve`, or `reject`. A stale or invalid response
|
|
282
|
+
leaves the request pending. Review the application consent notice included in the pending input,
|
|
283
|
+
such as location sharing, before approving. Native Chrome permissions require a click in the qz side panel; CLI
|
|
284
|
+
approval reports that action is needed and preserves the wait without opening a browser page.
|
|
285
|
+
With `--wait` or `--stream`, the command stays connected while you grant permission in Chrome.
|
|
286
|
+
Location approval reads the current disclosure version and includes it in the response. Human
|
|
287
|
+
terminal output shows the notice before submitting the explicit approval; JSON output remains a
|
|
288
|
+
single final result. MCP callers should show the notice to the user before sending approval with
|
|
289
|
+
the returned `consentVersion`.
|
|
290
|
+
|
|
291
|
+
`submit`, `approve`, and `reject` accept `--wait` and `--stream` to follow the task until it finishes, including
|
|
292
|
+
further questions and permission requests. Each new request is shown once. Respond in the side
|
|
293
|
+
panel or another terminal; the original command continues automatically. `watch` follows an
|
|
294
|
+
existing task without resubmitting anything. Timeouts and Ctrl-C stop watching, while the task
|
|
295
|
+
continues in the browser.
|
|
296
|
+
|
|
297
|
+
## Browser selection and MCP tools
|
|
298
|
+
|
|
299
|
+
Use `--client NAME|UUID` or `-c NAME|UUID` to select a browser. `qz browsers` lists registered names,
|
|
300
|
+
UUIDs, and online status. See [browser selection](#add-and-select-browsers) for pairing and name reuse.
|
|
301
|
+
Use `-t` for `--title`. Run `qz help COMMAND` or `qz COMMAND --help` for command-specific options.
|
|
302
|
+
|
|
303
|
+
MCP clients can inspect browser tool schemas with `qingzhou_list_tools` and `qingzhou_get_tool`,
|
|
304
|
+
then call `qingzhou_execute_tool` in a task. Set `wait: false` to receive a job ID and read the result
|
|
305
|
+
with `qingzhou_get_tool_job`. Pass `runId` to bind execution to a particular task run. MCP also
|
|
306
|
+
provides `qingzhou_get_trace` and `qingzhou_clear_trace` for diagnostics.
|
|
307
|
+
|
|
308
|
+
If a request times out or its connection is interrupted, an operation already started in the
|
|
309
|
+
browser may still be running. Check the task before repeating it. Disconnected MCP requests are
|
|
310
|
+
cancelled in the service, and reconnecting does not replay their browser actions.
|
|
311
|
+
|
|
312
|
+
## Data, images, and Skills
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
qz data
|
|
316
|
+
qz data export TABLE
|
|
317
|
+
qz data export TABLE --format csv
|
|
318
|
+
qz data delete TABLE
|
|
319
|
+
qz images
|
|
320
|
+
qz images export COLLECTION
|
|
321
|
+
qz images delete COLLECTION
|
|
322
|
+
qz skills --query research
|
|
323
|
+
qz skills show NAME
|
|
324
|
+
qz skills read NAME scripts/run.js --limit 20000
|
|
325
|
+
qz skills tools --session TASK_ID
|
|
326
|
+
qz skills export NAME
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Use the exact names printed by each list; quote names containing spaces. Data exports default to
|
|
330
|
+
Excel (`xlsx`); `--format csv` selects CSV. Image collections export as a ZIP containing available
|
|
331
|
+
image files and metadata. Missing local images are reported in the result. Skill exports contain
|
|
332
|
+
one user-installed Skill and its resources; built-in Skills require the extension and cannot be
|
|
333
|
+
exported independently.
|
|
334
|
+
|
|
335
|
+
`skills show` includes the resource paths. `skills read NAME PATH` reads one resource, with a
|
|
336
|
+
default limit of 20,000 characters. Use `--start` and `--limit` to select a chunk; truncated text
|
|
337
|
+
includes the command for the next chunk. `skills tools` lists contributed tools and whether they
|
|
338
|
+
are active in the selected task's context.
|
|
339
|
+
`skills --scope all|global|site|resident` filters by activation scope. Exports accept `--filename NAME`.
|
|
340
|
+
`automations --limit N` limits the automation list.
|
|
341
|
+
|
|
342
|
+
Exports use Chrome downloads. The result includes the download status, ID, filename, and path when
|
|
343
|
+
Chrome provides it. Check pending downloads in `chrome://downloads`. `delete` removes the named table
|
|
344
|
+
or image collection and its rows. Image blobs shared by other collections or task history remain
|
|
345
|
+
in the asset store.
|
|
346
|
+
|
|
347
|
+
## Settings and automations
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
qz settings
|
|
351
|
+
qz settings get model
|
|
352
|
+
qz settings set model MODEL_ID
|
|
353
|
+
qz settings set vision true
|
|
354
|
+
qz settings set '{"modelParameters":{"temperature":0.5}}'
|
|
355
|
+
qz settings set - < settings.json
|
|
356
|
+
qz automations
|
|
357
|
+
qz automations run AUTOMATION_ID
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
`settings` returns current values, editable fields, provider IDs, and protocol IDs. Credentials are
|
|
361
|
+
redacted; `qz settings get apiKey` reports whether a key is configured. `set KEY VALUE` parses JSON
|
|
362
|
+
values such as booleans, numbers, objects, and arrays; other values are strings. `set JSON` applies
|
|
363
|
+
a patch containing the supplied top-level fields. Follow the field descriptions for values that
|
|
364
|
+
replace an entire object, such as `modelParameters`.
|
|
365
|
+
|
|
366
|
+
Read credential patches from stdin to keep them out of shell history. JSON is validated before
|
|
367
|
+
connecting. The extension validates field names and values before saving. Browser commands accept
|
|
368
|
+
`--client NAME|UUID` to select a profile. `automations run` starts an existing automation and
|
|
369
|
+
returns its task ID.
|
|
370
|
+
|
|
371
|
+
The CLI uses the same browser operations as MCP. Its commands correspond to tasks, data,
|
|
372
|
+
images, Skills, settings, and automations. `qz mcp` only returns the connection URL for MCP
|
|
373
|
+
clients.
|
|
374
|
+
|
|
375
|
+
## Terminal output
|
|
376
|
+
|
|
377
|
+
Interactive terminals show readable text; pipes and redirected output receive JSON. Use `--json`
|
|
378
|
+
to request JSON explicitly or `--plain` to keep text when redirecting output. `--no-color` or the
|
|
379
|
+
`NO_COLOR` environment variable disables color. `qz mcp` prints only the MCP URL by default;
|
|
380
|
+
`qz mcp --json` returns a JSON result.
|
|
381
|
+
|
|
382
|
+
In JSON mode, `--wait` and `--stream` emit one final JSON result on stdout. Complete pending-input
|
|
383
|
+
notices and submission templates appear on stderr so you can respond while preserving
|
|
384
|
+
machine-readable output. MCP snapshots and rejected responses include `input`, with a
|
|
385
|
+
`responseTemplate` that binds answers to the current session and wait. Chrome-native permission
|
|
386
|
+
requests provide user instructions instead of an approval template.
|
|
387
|
+
Exit codes are `0` for success (including reading pending input), `1` for an operation or
|
|
388
|
+
task failure or a rejected submission, `2` for invalid arguments, and `130` for Ctrl-C.
|
|
389
|
+
Connection errors include the GitHub setup guide and installation link.
|
|
390
|
+
|
|
391
|
+
## Local access
|
|
392
|
+
|
|
393
|
+
The service listens on loopback. It validates Host and Origin, rejects redirects, and accepts
|
|
394
|
+
extension polling only from extension origins or local clients. Ordinary websites cannot send
|
|
395
|
+
requests through the MCP endpoint. Local programs can control connected qz tasks while the
|
|
396
|
+
service is running. Run `qz stop` to disconnect.
|
|
397
|
+
|
|
398
|
+
Connection metadata and browser registrations are stored in `~/.qz-browser-agent/run/`;
|
|
399
|
+
`QZ_STATE_DIR` selects another local directory for isolated tests. Registration writes are atomic;
|
|
400
|
+
a failed write leaves the previous registration active. Private pairing proofs stay in local storage
|
|
401
|
+
and are omitted from status output. Atomic startup locks prevent duplicate services. Development copies
|
|
402
|
+
and published installations use separate identities. The client verifies the service identity,
|
|
403
|
+
protocol version, instance, and process before reusing or stopping it. Editing source files or
|
|
404
|
+
running a newer package keeps the healthy service and its connections alive. `status` reports
|
|
405
|
+
when a different build is available. To load the new service code, finish active work, run
|
|
406
|
+
`qz stop`, then `qz connect`.
|
|
407
|
+
|
|
408
|
+
## Package development
|
|
409
|
+
|
|
410
|
+
The npm package name is `qz-browser-agent`; the executable name is `qz`. Local development uses
|
|
411
|
+
this same package name. The repository root stays private, and this service directory is the
|
|
412
|
+
publishable package. Publishing requires separate authorization and ownership of the npm name.
|
|
413
|
+
|
|
414
|
+
From the repository root, install the locked dependencies and run the local source:
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
npm ci
|
|
418
|
+
npm run qz -- --version
|
|
419
|
+
npm run qz -- connect
|
|
420
|
+
npm run qz -- create "Summarize the current page." --stream
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
Keep the `--` separator when forwarding options through npm. For a local `qz` executable,
|
|
424
|
+
run `npm link` in `services/mcp-bridge`. JavaScript runs directly on Node.js. The published
|
|
425
|
+
package contains the runtime files, tool catalog, README, and license.
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
npm test -- services --match node
|
|
429
|
+
node tests/release/npm-package.mjs
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
The package check packs the service and installs that tarball in two clean temporary directories
|
|
433
|
+
using the public npm registry. It checks the installed command, versions, MCP tools, service reuse,
|
|
434
|
+
and shutdown on an isolated port. The test owns its npm configuration, cache, connection state,
|
|
435
|
+
and service process. It requires network access to download dependencies.
|
|
436
|
+
|
|
437
|
+
Use `--output tests/results/npm/qz-browser-agent-0.1.1.tgz` to retain the verified tarball.
|
|
438
|
+
Use `--tarball PATH` to check an existing tarball. The check also runs through
|
|
439
|
+
`npm test -- release --match npm-package`.
|
|
440
|
+
|
|
441
|
+
## Publish to npm
|
|
442
|
+
|
|
443
|
+
Choose the package version in `services/mcp-bridge/package.json`, complete the repository checks,
|
|
444
|
+
and commit the intended source before publishing. CLI and MCP report that same package version.
|
|
445
|
+
Each published version identifies immutable package contents; use a new version for updates.
|
|
446
|
+
|
|
447
|
+
The **npm package** GitHub Actions workflow tests the CLI and the installed package on Linux,
|
|
448
|
+
macOS, and Windows. On a manual run, provide the expected version. With **publish** left unchecked,
|
|
449
|
+
it only validates the package and retains the tested tarball. Publishing requires a manual run
|
|
450
|
+
from `main` with **publish** checked; all three platforms must pass first.
|
|
451
|
+
|
|
452
|
+
Configure the npm package's trusted publisher for the `alibaba/qz-browser-agent` repository,
|
|
453
|
+
workflow `npm-package.yml`, and GitHub environment `npm`. Enable direct publishing in that
|
|
454
|
+
trusted publisher configuration. The publish job uses OIDC and uploads the exact Linux-tested
|
|
455
|
+
tarball. The npm package must be created under an account with publishing rights before this
|
|
456
|
+
trusted publisher can be configured. See [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/).
|
|
457
|
+
|
|
458
|
+
For the first manual release, log in with npm, verify the saved tarball, and publish it:
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
npm login --registry=https://registry.npmjs.org
|
|
462
|
+
node tests/release/npm-package.mjs --output tests/results/npm/qz-browser-agent-0.1.1.tgz
|
|
463
|
+
npm publish tests/results/npm/qz-browser-agent-0.1.1.tgz --access public --registry=https://registry.npmjs.org
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
The root package stays private. Publishing the service does not publish the Chrome extension.
|
|
467
|
+
After publication, check `npx qz-browser-agent@0.1.1 --version` from a directory outside the repository.
|