qz-browser-agent 0.0.0-stage → 0.1.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.
- package/LICENSE +202 -0
- package/README.md +352 -2
- package/package.json +14 -4
- package/src/args.mjs +137 -0
- package/src/bin.mjs +25 -0
- package/src/catalog.json +851 -0
- package/src/cli-resources.mjs +25 -0
- package/src/cli.mjs +313 -0
- package/src/client.mjs +134 -0
- package/src/commands.mjs +123 -0
- package/src/daemon.mjs +265 -0
- package/src/open-browser.mjs +20 -0
- package/src/output.mjs +64 -0
- package/src/package-info.mjs +6 -0
- package/src/server.mjs +201 -0
- package/src/shell.mjs +24 -0
- package/src/state.mjs +225 -0
- package/src/task-stream.mjs +207 -0
- package/src/terminal.mjs +499 -0
- package/src/tools.mjs +208 -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,353 @@
|
|
|
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
|
+
Run the published package with npx:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npx qz-browser-agent@latest install
|
|
12
|
+
npx qz-browser-agent@latest connect
|
|
13
|
+
npx qz-browser-agent@latest create "Summarize the current page." --stream
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`install` opens the [latest extension release](https://github.com/alibaba/qz-browser-agent/releases/latest).
|
|
17
|
+
Extract its ZIP, open `chrome://extensions`, enable **Developer mode**, and choose **Load unpacked**.
|
|
18
|
+
Select the extracted extension folder. Open qz and accept its first-use data notice.
|
|
19
|
+
|
|
20
|
+
`connect` starts the local MCP service and opens a connection page if a browser has not connected.
|
|
21
|
+
Open that page in the Chrome profile where qz is installed. The connection page identifies the
|
|
22
|
+
local service to the extension; no token or DevTools configuration is required.
|
|
23
|
+
|
|
24
|
+
The examples and suggested next commands use `qz`. Replace it with
|
|
25
|
+
`npx qz-browser-agent@latest`, or install the command globally:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm install --global qz-browser-agent@latest
|
|
29
|
+
qz --version
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
On Windows, use PowerShell 7.3 or newer with its default native argument passing. After a global
|
|
33
|
+
install, use `qz.ps1` for commands containing JSON or quoted names; Windows command suggestions
|
|
34
|
+
use that wrapper. For automation, pin an exact npm version such as `qz-browser-agent@0.1.0`.
|
|
35
|
+
|
|
36
|
+
## Connect and stop
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
qz connect
|
|
40
|
+
qz status
|
|
41
|
+
qz mcp
|
|
42
|
+
qz stop
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`connect` reuses the healthy service already running for this installation and protocol. It prefers port
|
|
46
|
+
18765; if another program owns that port, it uses a free port chosen by the operating system.
|
|
47
|
+
It confirms that a browser responds before reporting success, and opens the connection page to
|
|
48
|
+
resume polling if a previously connected browser no longer responds.
|
|
49
|
+
`mcp` prints the actual MCP URL. `status` and `mcp` never start a service or open a browser.
|
|
50
|
+
`stop` shuts down the shared service and disconnects the extension and MCP clients.
|
|
51
|
+
|
|
52
|
+
After first-use consent, an unavailable local service gets up to three connection attempts.
|
|
53
|
+
Once a connection succeeds, later interruptions switch to one recovery attempt per minute after
|
|
54
|
+
three consecutive failed polls, using that same endpoint. Recovery continues across worker restarts;
|
|
55
|
+
disabling the bridge stops it. Run `qz connect` to retry immediately. Connected browsers use long polls
|
|
56
|
+
capped at 20 seconds and reload saved settings before each poll. The side panel and connection page
|
|
57
|
+
can be closed.
|
|
58
|
+
|
|
59
|
+
`status` distinguishes an unavailable local service from a running service with no connected
|
|
60
|
+
browser. A failed health check is retried once; an unresponsive live service is reported without
|
|
61
|
+
starting another instance. After updating the extension, reload it at `chrome://extensions` and
|
|
62
|
+
run `qz connect` to reconnect.
|
|
63
|
+
|
|
64
|
+
## Connect an MCP client
|
|
65
|
+
|
|
66
|
+
Run `qz connect`, then `qz mcp`. Copy the returned URL into your MCP client's HTTP configuration:
|
|
67
|
+
|
|
68
|
+
```toml
|
|
69
|
+
[mcp_servers.qz]
|
|
70
|
+
url = "http://127.0.0.1:18765/mcp"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Use the URL printed by your command if its port differs. `qz mcp --json` returns the URL as JSON
|
|
74
|
+
for scripts. The `qingzhou_*` MCP tool names and extension protocol remain available. Responses
|
|
75
|
+
to pending input bind to an explicit `waitId`. MCP initialization and streaming are handled by your
|
|
76
|
+
client's MCP implementation.
|
|
77
|
+
|
|
78
|
+
### Task and resource operations
|
|
79
|
+
|
|
80
|
+
CLI and MCP use the same task observer and browser operations. The task and resource commands map to these MCP operations:
|
|
81
|
+
|
|
82
|
+
| CLI | MCP tool |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| `create`, `send`, `cancel` | `qingzhou_create_session`, `qingzhou_send_message`, `qingzhou_stop_session` |
|
|
85
|
+
| `tasks`, `show`, `watch` | `qingzhou_list_sessions`, `qingzhou_get_session_snapshot`, `qingzhou_watch_task` |
|
|
86
|
+
| `show`, `submit` / `approve` / `reject` | `qingzhou_get_session_snapshot`, `qingzhou_respond_to_user_input` |
|
|
87
|
+
| `data list` / `delete` / `export` | `qingzhou_list_data_tables`, `qingzhou_delete_data_table`, `qingzhou_export_data_table` |
|
|
88
|
+
| `images list` / `delete` / `export` | `qingzhou_list_image_collections`, `qingzhou_delete_image_collection`, `qingzhou_export_image_collection` |
|
|
89
|
+
| `skills list` / `show` / `read` / `tools` / `export` | `qingzhou_list_skills`, `qingzhou_get_skill`, `qingzhou_get_skill_resource`, `qingzhou_list_plugins`, `qingzhou_export_skill` |
|
|
90
|
+
| `settings get` / `set` | `qingzhou_get_settings`, `qingzhou_update_settings` |
|
|
91
|
+
| `automations list` / `run` | `qingzhou_list_automations`, `qingzhou_run_automation` |
|
|
92
|
+
|
|
93
|
+
MCP creation, message submission, and input responses accept `wait: true` to wait for completion;
|
|
94
|
+
`stream: true` also sends assistant text through standard MCP progress notifications. A watch call
|
|
95
|
+
always waits. For example, call `qingzhou_create_session` with:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{"firstMessage":"Summarize the current page.","stream":true}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Supply `_meta.progressToken` on the MCP request to receive progress. Each notification includes a
|
|
102
|
+
readable `message` and its structured event in `params._meta["qz/task-event"]`. Events include
|
|
103
|
+
`created`, `status`, `text`, `replace`, and `input`. Input events include the current form, exact
|
|
104
|
+
field IDs, option values, and `responseTemplate`. Fill that template and pass it to
|
|
105
|
+
`qingzhou_respond_to_user_input`; another CLI or MCP connection can answer while the original call
|
|
106
|
+
keeps waiting. Native Chrome permissions still require the user's click in the side panel.
|
|
107
|
+
|
|
108
|
+
MCP `timeoutSeconds` bounds each browser request (180 seconds by default).
|
|
109
|
+
`waitTimeoutSeconds` bounds the whole observation; omit it for no overall deadline. Configure your
|
|
110
|
+
MCP client's own request deadline for long tasks. On timeout or cancellation, the browser task
|
|
111
|
+
continues; error details include the task ID and a recovery tool call. `send_message` supports
|
|
112
|
+
`steer: true` and follows its returned `clientMessageId`, including when steering stays in the same
|
|
113
|
+
run. A long observation stays bound to the browser selected when it started.
|
|
114
|
+
|
|
115
|
+
## Run a task
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
qz create "Compare these two laptops."
|
|
119
|
+
qz create "Summarize the current page." --title "Research" --wait
|
|
120
|
+
qz create "Find the main differences between these pages." --stream
|
|
121
|
+
qz send TASK_ID "Add the source links." --stream
|
|
122
|
+
qz send TASK_ID "Focus on open-source options." --steer --stream
|
|
123
|
+
qz tasks
|
|
124
|
+
qz show TASK_ID
|
|
125
|
+
qz cancel TASK_ID
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
`create` starts a task and returns its ID. The title is optional. `--wait` waits for the result;
|
|
129
|
+
`--stream` also displays progress as it arrives. Both stay connected while the task waits for user
|
|
130
|
+
input and continue automatically after you respond. Task observation has no default time limit.
|
|
131
|
+
Add `--timeout SECONDS` to set a total deadline, including time spent waiting for input. Each
|
|
132
|
+
individual connection request remains bounded (180 seconds by default). A timeout or Ctrl-C ends
|
|
133
|
+
watching; `qz watch TASK_ID --stream` resumes observation and `qz cancel TASK_ID` stops the task.
|
|
134
|
+
Each CLI command initializes one MCP connection on its first tool call and reuses it for subsequent
|
|
135
|
+
reads and responses. Completion, errors, and Ctrl-C close that connection. Transport failures are
|
|
136
|
+
reported without automatically repeating browser actions.
|
|
137
|
+
|
|
138
|
+
Provide the task text directly after `create`, or read it from stdin with `qz create -`.
|
|
139
|
+
Use `--parent TASK_ID` to create a child task, and `qz tasks --limit N` to limit the task list.
|
|
140
|
+
`send TASK_ID MESSAGE` sends a follow-up to the specified task; `qz send TASK_ID -` reads the message
|
|
141
|
+
from stdin. A busy task queues a follow-up for its next run. Add `--steer` to deliver the message
|
|
142
|
+
to the current run at its next safe boundary. Both start a new run when the task is idle. Pending
|
|
143
|
+
questions and permissions still require a response.
|
|
144
|
+
|
|
145
|
+
`--wait` and `--stream` track the submitted message. Streaming starts after that message, including
|
|
146
|
+
when steering continues the same run. Pending questions from the preceding run remain visible so
|
|
147
|
+
you can answer them and let a queued follow-up proceed. A connection failure never resends a message
|
|
148
|
+
automatically.
|
|
149
|
+
|
|
150
|
+
## Respond to a task
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
qz show TASK_ID
|
|
154
|
+
qz submit TASK_ID '{"selectedIds":["option-a"]}' --stream
|
|
155
|
+
qz approve TASK_ID --wait
|
|
156
|
+
qz reject TASK_ID
|
|
157
|
+
qz watch TASK_ID --stream
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`show` and pending-input notices include the current question, labeled field IDs,
|
|
161
|
+
option values, descriptions, image URLs, and a submission template with the actual field IDs.
|
|
162
|
+
Edit its placeholder values and run the displayed command to respond. `submit` takes a JSON object
|
|
163
|
+
keyed by field IDs; use option values for choices and arrays for multiple choices. Use
|
|
164
|
+
`qz submit TASK_ID -` to read answers from stdin. Invalid or stale submissions return the current
|
|
165
|
+
input and its template so you can correct the response directly.
|
|
166
|
+
`approve` continues a confirmation after you finish the requested action. `reject` declines the
|
|
167
|
+
current request; `cancel` stops the whole task.
|
|
168
|
+
|
|
169
|
+
Each response reads the current wait ID before sending. To answer a specific request you already
|
|
170
|
+
read, pass `--wait-id WAIT_ID` to `submit`, `approve`, or `reject`. A stale or invalid response
|
|
171
|
+
leaves the request pending. Review the application consent notice included in the pending input,
|
|
172
|
+
such as location sharing, before approving. Native Chrome permissions require a click in the qz side panel; CLI
|
|
173
|
+
approval reports that action is needed and preserves the wait without opening a browser page.
|
|
174
|
+
With `--wait` or `--stream`, the command stays connected while you grant permission in Chrome.
|
|
175
|
+
Location approval reads the current disclosure version and includes it in the response. Human
|
|
176
|
+
terminal output shows the notice before submitting the explicit approval; JSON output remains a
|
|
177
|
+
single final result. MCP callers should show the notice to the user before sending approval with
|
|
178
|
+
the returned `consentVersion`.
|
|
179
|
+
|
|
180
|
+
`submit`, `approve`, and `reject` accept `--wait` and `--stream` to follow the task until it finishes, including
|
|
181
|
+
further questions and permission requests. Each new request is shown once. Respond in the side
|
|
182
|
+
panel or another terminal; the original command continues automatically. `watch` follows an
|
|
183
|
+
existing task without resubmitting anything. Timeouts and Ctrl-C stop watching, while the task
|
|
184
|
+
continues in the browser.
|
|
185
|
+
|
|
186
|
+
## Browser selection and MCP tools
|
|
187
|
+
|
|
188
|
+
Use `--client ID` or `-c ID` to select a browser when several are connected. Find IDs in `qz status`.
|
|
189
|
+
Use `-t` for `--title`. Run `qz help COMMAND` or `qz COMMAND --help` for command-specific options.
|
|
190
|
+
|
|
191
|
+
MCP clients can inspect browser tool schemas with `qingzhou_list_tools` and `qingzhou_get_tool`,
|
|
192
|
+
then call `qingzhou_execute_tool` in a task. Set `wait: false` to receive a job ID and read the result
|
|
193
|
+
with `qingzhou_get_tool_job`. Pass `runId` to bind execution to a particular task run. MCP also
|
|
194
|
+
provides `qingzhou_get_trace` and `qingzhou_clear_trace` for diagnostics.
|
|
195
|
+
|
|
196
|
+
If a request times out or its connection is interrupted, an operation already started in the
|
|
197
|
+
browser may still be running. Check the task before repeating it. Disconnected MCP requests are
|
|
198
|
+
cancelled in the service, and reconnecting does not replay their browser actions.
|
|
199
|
+
|
|
200
|
+
## Data, images, and Skills
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
qz data
|
|
204
|
+
qz data export TABLE
|
|
205
|
+
qz data export TABLE --format csv
|
|
206
|
+
qz data delete TABLE
|
|
207
|
+
qz images
|
|
208
|
+
qz images export COLLECTION
|
|
209
|
+
qz images delete COLLECTION
|
|
210
|
+
qz skills --query research
|
|
211
|
+
qz skills show NAME
|
|
212
|
+
qz skills read NAME scripts/run.js --limit 20000
|
|
213
|
+
qz skills tools --session TASK_ID
|
|
214
|
+
qz skills export NAME
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Use the exact names printed by each list; quote names containing spaces. Data exports default to
|
|
218
|
+
Excel (`xlsx`); `--format csv` selects CSV. Image collections export as a ZIP containing available
|
|
219
|
+
image files and metadata. Missing local images are reported in the result. Skill exports contain
|
|
220
|
+
one user-installed Skill and its resources; built-in Skills require the extension and cannot be
|
|
221
|
+
exported independently.
|
|
222
|
+
|
|
223
|
+
`skills show` includes the resource paths. `skills read NAME PATH` reads one resource, with a
|
|
224
|
+
default limit of 20,000 characters. Use `--start` and `--limit` to select a chunk; truncated text
|
|
225
|
+
includes the command for the next chunk. `skills tools` lists contributed tools and whether they
|
|
226
|
+
are active in the selected task's context.
|
|
227
|
+
`skills --scope all|global|site|resident` filters by activation scope. Exports accept `--filename NAME`.
|
|
228
|
+
`automations --limit N` limits the automation list.
|
|
229
|
+
|
|
230
|
+
Exports use Chrome downloads. The result includes the download status, ID, filename, and path when
|
|
231
|
+
Chrome provides it. Check pending downloads in `chrome://downloads`. `delete` removes the named table
|
|
232
|
+
or image collection and its rows. Image blobs shared by other collections or task history remain
|
|
233
|
+
in the asset store.
|
|
234
|
+
|
|
235
|
+
## Settings and automations
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
qz settings
|
|
239
|
+
qz settings get model
|
|
240
|
+
qz settings set model MODEL_ID
|
|
241
|
+
qz settings set vision true
|
|
242
|
+
qz settings set '{"modelParameters":{"temperature":0.5}}'
|
|
243
|
+
qz settings set - < settings.json
|
|
244
|
+
qz automations
|
|
245
|
+
qz automations run AUTOMATION_ID
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
`settings` returns current values, editable fields, provider IDs, and protocol IDs. Credentials are
|
|
249
|
+
redacted; `qz settings get apiKey` reports whether a key is configured. `set KEY VALUE` parses JSON
|
|
250
|
+
values such as booleans, numbers, objects, and arrays; other values are strings. `set JSON` applies
|
|
251
|
+
a patch containing the supplied top-level fields. Follow the field descriptions for values that
|
|
252
|
+
replace an entire object, such as `modelParameters`.
|
|
253
|
+
|
|
254
|
+
Read credential patches from stdin to keep them out of shell history. JSON is validated before
|
|
255
|
+
connecting. The extension validates field names and values before saving. All commands accept
|
|
256
|
+
`--client ID` to select a browser profile. `automations run` starts an existing automation and
|
|
257
|
+
returns its task ID.
|
|
258
|
+
|
|
259
|
+
The CLI uses the same browser operations as MCP. Its commands correspond to tasks, data,
|
|
260
|
+
images, Skills, settings, and automations. `qz mcp` only returns the connection URL for MCP
|
|
261
|
+
clients.
|
|
262
|
+
|
|
263
|
+
## Terminal output
|
|
264
|
+
|
|
265
|
+
Interactive terminals show readable text; pipes and redirected output receive JSON. Use `--json`
|
|
266
|
+
to request JSON explicitly or `--plain` to keep text when redirecting output. `--no-color` or the
|
|
267
|
+
`NO_COLOR` environment variable disables color. `qz mcp` prints only the MCP URL by default;
|
|
268
|
+
`qz mcp --json` returns a JSON result.
|
|
269
|
+
|
|
270
|
+
In JSON mode, `--wait` and `--stream` emit one final JSON result on stdout. Complete pending-input
|
|
271
|
+
notices and submission templates appear on stderr so you can respond while preserving
|
|
272
|
+
machine-readable output. MCP snapshots and rejected responses include `input`, with a
|
|
273
|
+
`responseTemplate` that binds answers to the current session and wait. Chrome-native permission
|
|
274
|
+
requests provide user instructions instead of an approval template.
|
|
275
|
+
Exit codes are `0` for success (including reading pending input), `1` for an operation or
|
|
276
|
+
task failure or a rejected submission, `2` for invalid arguments, and `130` for Ctrl-C.
|
|
277
|
+
Connection errors include the GitHub setup guide and installation link.
|
|
278
|
+
|
|
279
|
+
## Local access
|
|
280
|
+
|
|
281
|
+
The service listens on loopback. It validates Host and Origin, rejects redirects, and accepts
|
|
282
|
+
extension polling only from extension origins or local clients. Ordinary websites cannot send
|
|
283
|
+
requests through the MCP endpoint. Local programs can control connected qz tasks while the
|
|
284
|
+
service is running. Run `qz stop` to disconnect.
|
|
285
|
+
|
|
286
|
+
Connection metadata is stored in `~/.qz-browser-agent/run/`; `QZ_STATE_DIR` selects another local
|
|
287
|
+
directory for isolated tests. Atomic startup locks prevent duplicate services. Development copies
|
|
288
|
+
and published installations use separate identities. The client verifies the service identity,
|
|
289
|
+
protocol version, instance, and process before reusing or stopping it. Editing source files or
|
|
290
|
+
running a newer package keeps the healthy service and its connections alive. `status` reports
|
|
291
|
+
when a different build is available. To load the new service code, finish active work, run
|
|
292
|
+
`qz stop`, then `qz connect`.
|
|
293
|
+
|
|
294
|
+
## Package development
|
|
295
|
+
|
|
296
|
+
The npm package name is `qz-browser-agent`; the executable name is `qz`. Local development uses
|
|
297
|
+
this same package name. The repository root stays private, and this service directory is the
|
|
298
|
+
publishable package. Publishing requires separate authorization and ownership of the npm name.
|
|
299
|
+
|
|
300
|
+
From the repository root, install the locked dependencies and run the local source:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
npm ci
|
|
304
|
+
npm run qz -- --version
|
|
305
|
+
npm run qz -- connect
|
|
306
|
+
npm run qz -- create "Summarize the current page." --stream
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Keep the `--` separator when forwarding options through npm. For a local `qz` executable,
|
|
310
|
+
run `npm link` in `services/mcp-bridge`. JavaScript runs directly on Node.js. The published
|
|
311
|
+
package contains the runtime files, tool catalog, README, and license.
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
npm test -- services --match node
|
|
315
|
+
node tests/release/npm-package.mjs
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
The package check packs the service and installs that tarball in two clean temporary directories
|
|
319
|
+
using the public npm registry. It checks the installed command, versions, MCP tools, service reuse,
|
|
320
|
+
and shutdown on an isolated port. The test owns its npm configuration, cache, connection state,
|
|
321
|
+
and service process. It requires network access to download dependencies.
|
|
322
|
+
|
|
323
|
+
Use `--output tests/results/npm/qz-browser-agent-0.1.0.tgz` to retain the verified tarball.
|
|
324
|
+
Use `--tarball PATH` to check an existing tarball. The check also runs through
|
|
325
|
+
`npm test -- release --match npm-package`.
|
|
326
|
+
|
|
327
|
+
## Publish to npm
|
|
328
|
+
|
|
329
|
+
Choose the package version in `services/mcp-bridge/package.json`, complete the repository checks,
|
|
330
|
+
and commit the intended source before publishing. CLI and MCP report that same package version.
|
|
331
|
+
Each published version identifies immutable package contents; use a new version for updates.
|
|
332
|
+
|
|
333
|
+
The **npm package** GitHub Actions workflow tests the CLI and the installed package on Linux,
|
|
334
|
+
macOS, and Windows. On a manual run, provide the expected version. With **publish** left unchecked,
|
|
335
|
+
it only validates the package and retains the tested tarball. Publishing requires a manual run
|
|
336
|
+
from `main` with **publish** checked; all three platforms must pass first.
|
|
337
|
+
|
|
338
|
+
Configure the npm package's trusted publisher for the `alibaba/qz-browser-agent` repository,
|
|
339
|
+
workflow `npm-package.yml`, and GitHub environment `npm`. Enable direct publishing in that
|
|
340
|
+
trusted publisher configuration. The publish job uses OIDC and uploads the exact Linux-tested
|
|
341
|
+
tarball. The npm package must be created under an account with publishing rights before this
|
|
342
|
+
trusted publisher can be configured. See [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/).
|
|
343
|
+
|
|
344
|
+
For the first manual release, log in with npm, verify the saved tarball, and publish it:
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
npm login --registry=https://registry.npmjs.org
|
|
348
|
+
node tests/release/npm-package.mjs --output tests/results/npm/qz-browser-agent-0.1.0.tgz
|
|
349
|
+
npm publish tests/results/npm/qz-browser-agent-0.1.0.tgz --access public --registry=https://registry.npmjs.org
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
The root package stays private. Publishing the service does not publish the Chrome extension.
|
|
353
|
+
After publication, check `npx qz-browser-agent@0.1.0 --version` from a directory outside the repository.
|
package/package.json
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qz-browser-agent",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
}
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Local browser tools and MCP access for the qz extension",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": { "node": ">=24" },
|
|
7
|
+
"bin": { "qz": "src/bin.mjs" },
|
|
8
|
+
"files": ["src/*.mjs", "src/catalog.json", "README.md", "LICENSE"],
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"homepage": "https://alibaba.github.io/qz-browser-agent/",
|
|
11
|
+
"bugs": { "url": "https://github.com/alibaba/qz-browser-agent/issues" },
|
|
12
|
+
"keywords": ["browser-agent", "cli", "mcp", "chrome", "automation"],
|
|
13
|
+
"publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
|
|
14
|
+
"repository": { "type": "git", "url": "https://github.com/alibaba/qz-browser-agent.git", "directory": "services/mcp-bridge" },
|
|
15
|
+
"dependencies": { "@modelcontextprotocol/sdk": "1.31.0" }
|
|
16
|
+
}
|