@tulipe1735/prism 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 +21 -0
- package/README.md +87 -0
- package/dist/cli.js +1190 -0
- package/dist/cli.js.map +1 -0
- package/dist/mcp.js +1124 -0
- package/dist/mcp.js.map +1 -0
- package/dist/snapshot.js +112 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Minghan Wang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Prism
|
|
2
|
+
|
|
3
|
+
Prism 是一个 TypeScript 浏览器智能体 CLI。给它一个网址和一句目标,它会把页面读成一张带编号的可见控件表,让决策模型选择「对哪个元素执行哪个操作」,通过 Chrome
|
|
4
|
+
DevTools Protocol 执行,直到决策模型判定目标达成。
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
架构图源文件为 [docs/architecture.excalidraw](docs/architecture.excalidraw),可用 VSCode Excalidraw 插件编辑。
|
|
9
|
+
|
|
10
|
+
## 环境要求
|
|
11
|
+
|
|
12
|
+
- Node.js >= 22.19
|
|
13
|
+
- 可通过 CDP 连接的 Chrome
|
|
14
|
+
- `TYPESAFE_API_KEY`
|
|
15
|
+
- 一个 OpenAI 兼容的 key
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g @tulipe1735/prism
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
包含两个可执行入口:`prism`(CLI)和 `prism-mcp`(MCP server)。也可以从源码构建——包管理器使用 pnpm(仓库锁定 9.15.9,执行 `corepack enable` 可自动匹配):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/Tulipe1735/Prism.git
|
|
27
|
+
cd Prism
|
|
28
|
+
pnpm install
|
|
29
|
+
pnpm build
|
|
30
|
+
pnpm link --global
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 连接 Chrome
|
|
34
|
+
|
|
35
|
+
请以远程调试模式启动 Chrome。Chrome
|
|
36
|
+
136+ 默认 profile 不允许开启远程调试,因此使用独立 profile 并在其中登录一次:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# macOS
|
|
40
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
|
|
41
|
+
--remote-debugging-port=9222 --user-data-dir="$HOME/.prism-chrome"
|
|
42
|
+
|
|
43
|
+
# Linux
|
|
44
|
+
google-chrome --remote-debugging-port=9222 --user-data-dir="$HOME/.prism-chrome"
|
|
45
|
+
|
|
46
|
+
# Windows
|
|
47
|
+
"%PROGRAMFILES%\Google\Chrome\Application\chrome.exe" ^
|
|
48
|
+
--remote-debugging-port=9222 --user-data-dir="%USERPROFILE%\.prism-chrome"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 作为 MCP server 使用
|
|
52
|
+
|
|
53
|
+
`prism-mcp` 是一个 stdio MCP server,只暴露一个任务级工具:
|
|
54
|
+
|
|
55
|
+
| 工具 | 输入 | 返回 |
|
|
56
|
+
| -------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `browser_task` | `url`、`goal`、`max_steps?`、`record_dir?` | `status`、`reason`、`final_url`、`final_title`、`final_text`、`steps`、`elapsed_ms`、judge 字段 |
|
|
58
|
+
|
|
59
|
+
宿主把整个浏览子任务委托出去;observe/decide/act 循环、新鲜度校验、预算和判定都由 Prism 自己负责。每步进度会以 MCP
|
|
60
|
+
progress notification 上报;取消请求会中止运行并关闭标签页。
|
|
61
|
+
|
|
62
|
+
opencode(`opencode.json`):
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"$schema": "https://opencode.ai/config.json",
|
|
67
|
+
"mcp": {
|
|
68
|
+
"prism": {
|
|
69
|
+
"type": "local",
|
|
70
|
+
"command": ["prism-mcp"]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`prism-mcp` 需要在 PATH 上(在仓库根目录执行 `pnpm link --global`),或把 `command` 指向
|
|
77
|
+
`["node", "/absolute/path/to/prism/dist/mcp.js"]`。其他 MCP 客户端同理。key 和
|
|
78
|
+
`PRISM_BROWSER_URL` 从 server 进程的环境变量及其工作目录下的 `.env` 读取。
|
|
79
|
+
|
|
80
|
+
注意:不要在配置里用 `"environment": { "TYPESAFE_API_KEY": "{env:TYPESAFE_API_KEY}" }`
|
|
81
|
+
传未设置的变量——空值会覆盖 `.env` 里的同名 key,导致加载失败。
|
|
82
|
+
|
|
83
|
+
## Respect
|
|
84
|
+
|
|
85
|
+
`src/browser/snapshot.js` 来自
|
|
86
|
+
[browser-use/jev-ultrafast](https://github.com/browser-use/jev-ultrafast),以 MIT
|
|
87
|
+
License 使用。详见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
|