@bwanamaker/brandobot 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 +201 -0
- package/README.md +94 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +210 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# @bwanamaker/brandobot
|
|
2
|
+
|
|
3
|
+
An [OpenCode](https://opencode.ai) plugin that controls a browser through [Playwright CLI](https://playwright.dev/agent-cli/introduction).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Add the published package to your OpenCode configuration:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"$schema": "https://opencode.ai/config.json",
|
|
12
|
+
"plugin": ["@bwanamaker/brandobot"]
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Restart OpenCode after changing its configuration. OpenCode installs the package and its Playwright CLI dependency when it starts.
|
|
17
|
+
|
|
18
|
+
Playwright CLI requires Node.js 20 or later. Install its managed browsers before the first browser session with `browser({ args: ["install-browser"] })`. On Linux, pass `--with-deps` when system browser dependencies also need installing. The default CLI browser is a system Chrome installation; pass `--browser=chromium` to use Playwright-managed Chromium.
|
|
19
|
+
|
|
20
|
+
## URL Routing
|
|
21
|
+
|
|
22
|
+
Brandobot gives the agent routing guidance for selecting the appropriate tool:
|
|
23
|
+
|
|
24
|
+
| Request | Tool |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| Open a URL in the OpenCode host's browser | `open_url` |
|
|
27
|
+
| Test, inspect, navigate, interact with, or screenshot a page | `browser` |
|
|
28
|
+
| Read, summarize, or extract content from a URL | OpenCode `webfetch` |
|
|
29
|
+
|
|
30
|
+
For requests that mix these intents or are unclear, the guidance instructs the agent to ask a short clarifying question.
|
|
31
|
+
|
|
32
|
+
`open_url` launches the OpenCode host's platform-default browser, not a Playwright browser. When OpenCode runs locally, this is normally the user's default browser:
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
open_url({ url: "https://www.brandonwanamaker.com" })
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
It supports only `http` and `https` URLs and returns an error on unsupported platforms or headless Linux environments.
|
|
39
|
+
|
|
40
|
+
## Browser Tool
|
|
41
|
+
|
|
42
|
+
The plugin adds a `browser` tool with these arguments:
|
|
43
|
+
|
|
44
|
+
| Argument | Required | Description |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| `args` | Yes | Each token after `playwright-cli`; do not include the executable name. |
|
|
47
|
+
| `session` | No | A labeled browser isolated to the current OpenCode conversation. |
|
|
48
|
+
|
|
49
|
+
Use the tool in the same order as the CLI. Start with `open --browser=chromium`, call `snapshot` to obtain element refs, use those refs for interactions, and close the session when finished. Browser sessions are isolated automatically for each OpenCode conversation. Set `session` to create a separate labeled browser within that same conversation; labels never share state across conversations. Attaching to an existing browser, persistent profiles, external endpoints, and custom Playwright configuration are not supported.
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
browser({ args: ["open", "https://demo.playwright.dev/todomvc", "--browser=chromium"] })
|
|
53
|
+
browser({ args: ["type", "Buy groceries"] })
|
|
54
|
+
browser({ args: ["press", "Enter"] })
|
|
55
|
+
browser({ args: ["snapshot"] })
|
|
56
|
+
browser({ args: ["screenshot", "--filename", "artifacts/todo.png"] })
|
|
57
|
+
browser({ args: ["close"] })
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Screenshot and video filenames receive a UTC timestamp automatically, such as `artifacts/todo-20260905-203834123.png`, to prevent overwriting prior captures.
|
|
61
|
+
|
|
62
|
+
Labeled sessions retain their own browser, navigation history, cookies, and storage between tool calls within the current OpenCode conversation:
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
browser({ session: "admin", args: ["open", "https://example.com", "--browser=chromium"] })
|
|
66
|
+
browser({ session: "admin", args: ["goto", "/settings"] })
|
|
67
|
+
browser({ session: "admin", args: ["close"] })
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The browser runs headlessly by default. Pass `--headed` to `open` to display it. Brandobot uses an isolated Playwright configuration and temporary per-session internal output for browser launches.
|
|
71
|
+
|
|
72
|
+
To require approval before browser operations, configure the OpenCode permission by tool name:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"$schema": "https://opencode.ai/config.json",
|
|
77
|
+
"permission": {
|
|
78
|
+
"browser": "ask",
|
|
79
|
+
"open_url": "ask"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Development
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
bun install
|
|
88
|
+
bun run typecheck
|
|
89
|
+
bun test
|
|
90
|
+
bun run build
|
|
91
|
+
npm pack --dry-run
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The test runs `playwright-cli --help` through the plugin tool and does not launch or download a browser.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Plugin } from "@opencode-ai/plugin";
|
|
2
|
+
export declare function defaultBrowserCommand(url: string, platform?: NodeJS.Platform, environment?: NodeJS.ProcessEnv): string[];
|
|
3
|
+
export declare function playwrightArgs(args: string[], sessionID: string, session?: string): string[];
|
|
4
|
+
export declare function playwrightEnvironment(source?: NodeJS.ProcessEnv): {
|
|
5
|
+
[k: string]: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare function playwrightCommand(args: string[]): string[];
|
|
8
|
+
export declare function playwrightOutputDirectory(args: string[]): string;
|
|
9
|
+
declare const Brandobot: Plugin;
|
|
10
|
+
export default Brandobot;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdir } from "node:fs/promises";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { dirname, extname, join } from "node:path";
|
|
6
|
+
import { tool } from "@opencode-ai/plugin";
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
// Resolve our direct dependency so no globally installed CLI is required.
|
|
9
|
+
const playwrightCli = join(dirname(require.resolve("@playwright/cli/package.json")), "playwright-cli.js");
|
|
10
|
+
const globalCommands = new Set(["install", "install-browser"]);
|
|
11
|
+
const restrictedCommands = new Set(["attach", "close-all", "kill-all", "list", "show"]);
|
|
12
|
+
const sessionName = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
13
|
+
const playwrightConfigDirectory = join(tmpdir(), `brandobot-playwright-${process.pid}`);
|
|
14
|
+
const playwrightConfig = join(playwrightConfigDirectory, "cli.config.json");
|
|
15
|
+
export function defaultBrowserCommand(url, platform = process.platform, environment = process.env) {
|
|
16
|
+
const parsed = new URL(url);
|
|
17
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
18
|
+
throw new Error("Only http: and https: URLs can be opened in the default browser.");
|
|
19
|
+
}
|
|
20
|
+
if (platform === "darwin")
|
|
21
|
+
return ["open", parsed.href];
|
|
22
|
+
if (platform === "win32")
|
|
23
|
+
return ["explorer.exe", parsed.href];
|
|
24
|
+
if (platform === "linux") {
|
|
25
|
+
if (!environment.DISPLAY && !environment.WAYLAND_DISPLAY) {
|
|
26
|
+
throw new Error("Cannot open the default browser from a headless Linux environment.");
|
|
27
|
+
}
|
|
28
|
+
return ["xdg-open", parsed.href];
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`Opening the default browser is not supported on ${platform}.`);
|
|
31
|
+
}
|
|
32
|
+
function commandName(args) {
|
|
33
|
+
for (const arg of args) {
|
|
34
|
+
if (arg.startsWith("-s") || arg.startsWith("--session")) {
|
|
35
|
+
throw new Error("Use the browser tool's session argument instead of Playwright CLI session flags.");
|
|
36
|
+
}
|
|
37
|
+
if (arg === "--config" ||
|
|
38
|
+
arg.startsWith("--config=") ||
|
|
39
|
+
arg === "--profile" ||
|
|
40
|
+
arg.startsWith("--profile=") ||
|
|
41
|
+
arg === "--persistent" ||
|
|
42
|
+
arg.startsWith("--persistent=") ||
|
|
43
|
+
arg === "--cdp" ||
|
|
44
|
+
arg.startsWith("--cdp=") ||
|
|
45
|
+
arg === "--endpoint" ||
|
|
46
|
+
arg.startsWith("--endpoint=") ||
|
|
47
|
+
arg === "--extension" ||
|
|
48
|
+
arg.startsWith("--extension=")) {
|
|
49
|
+
throw new Error(`${arg.split("=")[0]} is not available because it can access external browser state.`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (args.length === 1 && (args[0] === "--help" || args[0] === "--version"))
|
|
53
|
+
return;
|
|
54
|
+
if (!args[0] || args[0].startsWith("-")) {
|
|
55
|
+
throw new Error("Pass the Playwright CLI command as the first args token.");
|
|
56
|
+
}
|
|
57
|
+
return args[0];
|
|
58
|
+
}
|
|
59
|
+
function artifactFilename(command, args) {
|
|
60
|
+
if (command === "video-start")
|
|
61
|
+
return args[1];
|
|
62
|
+
if (command !== "screenshot")
|
|
63
|
+
return;
|
|
64
|
+
const filename = args.find((arg) => arg.startsWith("--filename="));
|
|
65
|
+
if (filename)
|
|
66
|
+
return filename.slice("--filename=".length);
|
|
67
|
+
const filenameIndex = args.indexOf("--filename");
|
|
68
|
+
return filenameIndex === -1 ? undefined : args[filenameIndex + 1];
|
|
69
|
+
}
|
|
70
|
+
function timestampedArtifactFilename(filename) {
|
|
71
|
+
if (/-\d{8}-\d{9}(?=\.[^/\\]+$|$)/.test(filename))
|
|
72
|
+
return filename;
|
|
73
|
+
const timestamp = new Date().toISOString().replace(/\D/g, "");
|
|
74
|
+
const extension = extname(filename);
|
|
75
|
+
return `${filename.slice(0, extension ? -extension.length : undefined)}-${timestamp.slice(0, 8)}-${timestamp.slice(8)}${extension}`;
|
|
76
|
+
}
|
|
77
|
+
function timestampedArtifactArgs(command, args) {
|
|
78
|
+
const filename = artifactFilename(command, args);
|
|
79
|
+
if (!filename)
|
|
80
|
+
return args;
|
|
81
|
+
const timestampedFilename = timestampedArtifactFilename(filename);
|
|
82
|
+
if (command === "video-start")
|
|
83
|
+
return [args[0], timestampedFilename, ...args.slice(2)];
|
|
84
|
+
return args.map((arg, index) => {
|
|
85
|
+
if (arg.startsWith("--filename="))
|
|
86
|
+
return `--filename=${timestampedFilename}`;
|
|
87
|
+
return arg === filename && args[index - 1] === "--filename" ? timestampedFilename : arg;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function requiresArtifactDirectory(command, args) {
|
|
91
|
+
if (command !== "screenshot" && command !== "video-start")
|
|
92
|
+
return;
|
|
93
|
+
const filename = artifactFilename(command, args);
|
|
94
|
+
if (filename?.includes("/") || filename?.includes("\\"))
|
|
95
|
+
return;
|
|
96
|
+
throw new Error(`Ask the user where to store the ${command === "screenshot" ? "screenshot" : "video"}, then provide a filename with that directory.`);
|
|
97
|
+
}
|
|
98
|
+
function derivedSessionName(sessionID, session) {
|
|
99
|
+
return `brandobot-${createHash("sha256").update(`${sessionID}:${session ?? ""}`).digest("hex").slice(0, 54)}`;
|
|
100
|
+
}
|
|
101
|
+
export function playwrightArgs(args, sessionID, session) {
|
|
102
|
+
const command = commandName(args);
|
|
103
|
+
const timestampedArgs = timestampedArtifactArgs(command, args);
|
|
104
|
+
requiresArtifactDirectory(command, timestampedArgs);
|
|
105
|
+
if (command && restrictedCommands.has(command)) {
|
|
106
|
+
throw new Error(`${command} is not available because it can access other Playwright sessions.`);
|
|
107
|
+
}
|
|
108
|
+
if (!command || globalCommands.has(command))
|
|
109
|
+
return timestampedArgs;
|
|
110
|
+
if (session) {
|
|
111
|
+
if (!sessionName.test(session))
|
|
112
|
+
throw new Error("Playwright session names may contain only letters, numbers, hyphens, and underscores.");
|
|
113
|
+
return [`-s=${derivedSessionName(sessionID, session)}`, ...timestampedArgs];
|
|
114
|
+
}
|
|
115
|
+
return [`-s=${derivedSessionName(sessionID)}`, ...timestampedArgs];
|
|
116
|
+
}
|
|
117
|
+
async function execute(name, command, context, environment = process.env) {
|
|
118
|
+
// Use argv directly rather than a shell to preserve argument boundaries.
|
|
119
|
+
const process = Bun.spawn({
|
|
120
|
+
cmd: command,
|
|
121
|
+
cwd: context.directory,
|
|
122
|
+
env: environment,
|
|
123
|
+
signal: context.abort,
|
|
124
|
+
stderr: "pipe",
|
|
125
|
+
stdin: "ignore",
|
|
126
|
+
stdout: "pipe",
|
|
127
|
+
});
|
|
128
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
129
|
+
new Response(process.stdout).text(),
|
|
130
|
+
new Response(process.stderr).text(),
|
|
131
|
+
process.exited,
|
|
132
|
+
]);
|
|
133
|
+
// Preserve CLI snapshots on success and diagnostics when the command fails.
|
|
134
|
+
const output = [stdout.trim(), stderr.trim()].filter(Boolean).join("\n");
|
|
135
|
+
if (exitCode !== 0) {
|
|
136
|
+
throw new Error(`${name} exited with status ${exitCode}${output ? `:\n${output}` : ""}`);
|
|
137
|
+
}
|
|
138
|
+
return output;
|
|
139
|
+
}
|
|
140
|
+
export function playwrightEnvironment(source = process.env) {
|
|
141
|
+
const environment = Object.fromEntries(Object.entries(source).filter(([key]) => !key.startsWith("PLAYWRIGHT_MCP_")));
|
|
142
|
+
environment.PLAYWRIGHT_MCP_CONFIG = playwrightConfig;
|
|
143
|
+
environment.PLAYWRIGHT_MCP_ISOLATED = "true";
|
|
144
|
+
environment.PWTEST_CLI_GLOBAL_CONFIG = playwrightConfigDirectory;
|
|
145
|
+
return environment;
|
|
146
|
+
}
|
|
147
|
+
export function playwrightCommand(args) {
|
|
148
|
+
const command = args[0]?.startsWith("-s=") ? args[1] : args[0];
|
|
149
|
+
return command === "open" ? [playwrightCli, "--config", playwrightConfig, ...args] : [playwrightCli, ...args];
|
|
150
|
+
}
|
|
151
|
+
export function playwrightOutputDirectory(args) {
|
|
152
|
+
const session = args.find((arg) => arg.startsWith("-s="))?.slice(3) ?? "global";
|
|
153
|
+
return join(playwrightConfigDirectory, "artifacts", session);
|
|
154
|
+
}
|
|
155
|
+
async function executePlaywright(args, context) {
|
|
156
|
+
// This prevents project config and inherited Playwright settings from attaching to shared browser state.
|
|
157
|
+
const outputDirectory = playwrightOutputDirectory(args);
|
|
158
|
+
await mkdir(playwrightConfigDirectory, { recursive: true });
|
|
159
|
+
await Bun.write(playwrightConfig, JSON.stringify({ browser: { isolated: true } }));
|
|
160
|
+
const environment = playwrightEnvironment();
|
|
161
|
+
environment.PLAYWRIGHT_MCP_OUTPUT_DIR = outputDirectory;
|
|
162
|
+
return execute("playwright-cli", playwrightCommand(args), context, environment);
|
|
163
|
+
}
|
|
164
|
+
const browserGuidance = `## Browser routing
|
|
165
|
+
- Use open_url when the user explicitly asks to open an http(s) URL in the OpenCode host's default browser. Do not use it for testing or page inspection.
|
|
166
|
+
- Use browser for browser testing, navigation, interaction, DOM or accessibility inspection, screenshots, visual checks, storage, tracing, or other automated browser work. Do not attach to an existing browser or use external browser profiles/configuration.
|
|
167
|
+
- For browser, open an absolute URL with --browser=chromium, then call snapshot before using element refs. Take another snapshot after page-changing actions.
|
|
168
|
+
- Use webfetch to read, summarize, or extract content from a URL without browser automation.
|
|
169
|
+
- Before taking a screenshot or recording video without a destination directory, MUST call the question tool before any browser command or text response. Set header to "Save location" and offer these options in order: label "artifacts/", description "Save this capture in the workspace artifacts directory."; label "artifacts/ (Always)", description "Save this and future captures in this conversation in the workspace artifacts directory." If the user selects the second option, remember artifacts/ as the destination for later screenshots and videos in this conversation and do not ask again. Do not ask this question in plain text and do not add a custom option: the question tool provides its automatic custom-answer choice. Use "--filename artifacts/name.png" for screenshots or "video-start artifacts/name.webm" for video after the user answers; a UTC timestamp is appended automatically.
|
|
170
|
+
- Ask a brief clarification only when a request mixes these intents or is ambiguous. Use browser with --headed only when the user explicitly requests a visible Playwright-controlled browser.`;
|
|
171
|
+
const Brandobot = async () => ({
|
|
172
|
+
"experimental.chat.system.transform": async (_input, output) => {
|
|
173
|
+
output.system.push(browserGuidance);
|
|
174
|
+
},
|
|
175
|
+
tool: {
|
|
176
|
+
open_url: tool({
|
|
177
|
+
description: "Open an http(s) URL in the OpenCode host's platform-default browser. Use only for an explicit request to open a URL for the user, not for browser testing, inspection, or automation.",
|
|
178
|
+
args: {
|
|
179
|
+
url: tool.schema.string().url().describe("The http(s) URL to open in the user's default browser."),
|
|
180
|
+
},
|
|
181
|
+
async execute(input, context) {
|
|
182
|
+
const command = defaultBrowserCommand(input.url);
|
|
183
|
+
await execute("default browser", command, context);
|
|
184
|
+
return `Opened ${new URL(input.url).href} in the default browser.`;
|
|
185
|
+
},
|
|
186
|
+
}),
|
|
187
|
+
// A single generic tool exposes the Playwright CLI automation surface.
|
|
188
|
+
browser: tool({
|
|
189
|
+
description: "Run a Playwright CLI command for automated browser testing and inspection. Pass each token after playwright-cli in args, without a shell or the executable name. For page work, open with --browser=chromium and call snapshot to obtain element refs before interacting. Sessions are isolated per OpenCode conversation unless session is set explicitly.",
|
|
190
|
+
args: {
|
|
191
|
+
args: tool.schema
|
|
192
|
+
.array(tool.schema.string())
|
|
193
|
+
.min(1)
|
|
194
|
+
.describe('Playwright CLI argv tokens, for example ["open", "https://example.com"] or ["click", "e12"].'),
|
|
195
|
+
session: tool.schema
|
|
196
|
+
.string()
|
|
197
|
+
.regex(sessionName, "Use letters, numbers, hyphens, and underscores only.")
|
|
198
|
+
.optional()
|
|
199
|
+
.describe("Optional browser label scoped to the current OpenCode conversation."),
|
|
200
|
+
},
|
|
201
|
+
async execute(input, context) {
|
|
202
|
+
// Playwright CLI namespaces browser state by an optional named session.
|
|
203
|
+
const args = playwrightArgs(input.args, context.sessionID, input.session);
|
|
204
|
+
return executePlaywright(args, context);
|
|
205
|
+
},
|
|
206
|
+
}),
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
export default Brandobot;
|
|
210
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,IAAI,EAAiC,MAAM,qBAAqB,CAAA;AAEzE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,0EAA0E;AAC1E,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAA;AACzG,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAA;AAC9D,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;AACvF,MAAM,WAAW,GAAG,kCAAkC,CAAA;AACtD,MAAM,yBAAyB,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,wBAAwB,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;AACvF,MAAM,g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MAAM,OAAO,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;gBAChD,MAAM,OAAO,CAAC,iBAAiB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;gBAClD,OAAO,UAAU,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,0BAA0B,CAAA;YACpE,CAAC;SACF,CAAC;QACF,uEAAuE;QACvE,OAAO,EAAE,IAAI,CAAC;YACZ,WAAW,EACT,6VAA6V;YAC/V,IAAI,EAAE;gBACJ,IAAI,EAAE,IAAI,CAAC,MAAM;qBACd,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;qBAC3B,GAAG,CAAC,CAAC,CAAC;qBACN,QAAQ,CAAC,8FAA8F,CAAC;gBAC3G,OAAO,EAAE,IAAI,CAAC,MAAM;qBACjB,MAAM,EAAE;qBACR,KAAK,CAAC,WAAW,EAAE,sDAAsD,CAAC;qBAC1E,QAAQ,EAAE;qBACV,QAAQ,CAAC,qEAAqE,CAAC;aACnF;YACD,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO;gBAC1B,wEAAwE;gBACxE,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;gBACzE,OAAO,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;YACzC,CAAC;SACF,CAAC;KACH;CACF,CAAC,CAAA;AAEF,eAAe,SAAS,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bwanamaker/brandobot",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "An OpenCode plugin that controls browsers through Playwright CLI.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/bwanamaker/brandobot.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": "https://github.com/bwanamaker/brandobot/issues",
|
|
11
|
+
"homepage": "https://github.com/bwanamaker/brandobot#readme",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -p tsconfig.json",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"test": "bun test",
|
|
33
|
+
"prepack": "npm run build"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=20"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"opencode",
|
|
40
|
+
"plugin",
|
|
41
|
+
"playwright",
|
|
42
|
+
"browser-automation"
|
|
43
|
+
],
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@opencode-ai/plugin": "^1.18.25",
|
|
46
|
+
"@playwright/cli": "^0.1.18"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"bun-types": "^1.3.9",
|
|
50
|
+
"typescript": "^5.9.3"
|
|
51
|
+
}
|
|
52
|
+
}
|