wtagent 0.1.0-alpha.6 → 0.2.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.
Files changed (36) hide show
  1. package/README.md +57 -93
  2. package/docs/technical-design.md +1 -0
  3. package/package.json +3 -2
  4. package/src/browser/base-web-adapter.js +1178 -0
  5. package/src/browser/cdp-browser.js +94 -4
  6. package/src/browser/cdp-state.js +52 -4
  7. package/src/browser/chatgpt-web-adapter.js +290 -730
  8. package/src/browser/claude-web-adapter.js +205 -0
  9. package/src/browser/deepseek-web-adapter.js +337 -0
  10. package/src/browser/fake-web-model-adapter.js +5 -1
  11. package/src/browser/gemini-web-adapter.js +465 -0
  12. package/src/browser/glm-web-adapter.js +246 -0
  13. package/src/browser/kimi-web-adapter.js +285 -0
  14. package/src/browser/provider-registry.js +199 -0
  15. package/src/cli/main.js +440 -56
  16. package/src/cli/notice-store.js +125 -0
  17. package/src/cli/prompt-input.js +505 -145
  18. package/src/cli/render-events.js +31 -3
  19. package/src/cli/self-update.js +145 -0
  20. package/src/cli/startup-notices.js +161 -0
  21. package/src/platform/paths.js +7 -0
  22. package/src/policy/approval-store.js +67 -0
  23. package/src/policy/policy-engine.js +16 -0
  24. package/src/protocol/markers.js +3 -2
  25. package/src/protocol/prompt-builder.js +14 -7
  26. package/src/protocol/xml-protocol.js +193 -11
  27. package/src/runtime/agent-runtime.js +313 -29
  28. package/src/session/agent-session.js +4 -1
  29. package/src/session/canonical-transcript.js +2 -2
  30. package/src/session/session-export.js +2 -2
  31. package/src/shared/fetch-json.js +24 -0
  32. package/src/shared/limits.js +17 -0
  33. package/src/shared/package-info.js +23 -0
  34. package/src/shared/usage-limit.js +21 -0
  35. package/src/tools/default-tools.js +23 -3
  36. package/src/tools/search-fallback.js +27 -3
package/README.md CHANGED
@@ -1,144 +1,108 @@
1
1
  # WTAgent
2
2
 
3
- Turn GPT Web into a local CLI agent.
3
+ Use your web AI account as a local CLI agent.
4
4
 
5
- 把 GPT 网页聊天变成一个本地 CLI Agent。
5
+ WTAgent connects ChatGPT, Claude, DeepSeek, Gemini, Kimi, or GLM Web to your local project: the model reasons in the browser while WTAgent reads and writes local files and runs commands on your machine.
6
6
 
7
- [中文](#中文) · [English](#english)
7
+ [中文](#中文)
8
8
 
9
- ## 中文
10
-
11
- WTAgent 把 GPT 网页聊天连接到本地工具,提供类似 Codex 的 CLI Agent 体验。当前首个适配器支持 ChatGPT Web。
12
-
13
- 网页 GPT 负责思考,WTAgent 在本机:
14
-
15
- - 读取和修改本地文件
16
- - 调用结构化本地命令,运行构建、测试和开发服务
17
-
18
- 不需要 OpenAI API Key,也不要求 ChatGPT Pro。WTAgent 使用独立的 Chrome Profile 保存你的网页登录状态,并使用该账号在网页上实际可用的模型和额度;如果账号拥有 Pro,它会成为额外优势。
19
-
20
- 支持矩阵:
21
-
22
- - macOS
23
- - Linux
24
- - Windows 10 1809+ / Windows 11 x64
25
- - Windows ARM64 目前为预览支持
26
-
27
- 边界:
9
+ ## Quick start
28
10
 
29
- - 需要 Chrome 或 Chromium;首版不支持 Edge
30
- - Git 和 `rg` 是可选项,不是运行前提
31
- - WSL 不在首版支持范围内;请直接在原生 PowerShell / CMD / Windows Terminal 中运行
32
-
33
- ### 快速开始
34
-
35
- 需要 Node.js 20.17+ 和 Chrome/Chromium。
11
+ Requires Node.js 20.17+ and Chrome/Chromium. WTAgent supports macOS, Linux, and native Windows. WSL is not currently supported.
36
12
 
37
13
  ```bash
38
- npm install -g wtagent --registry=https://registry.npmjs.org/
39
- wtagent login
40
- ```
41
-
42
- Windows PowerShell:
43
-
44
- ```powershell
45
- npm install -g wtagent --registry=https://registry.npmjs.org/
46
- wtagent doctor
47
- wtagent login
14
+ npm install -g wtagent
48
15
  ```
49
16
 
50
- 登录完成后,进入项目目录:
17
+ Open a working directory and start WTAgent:
51
18
 
52
19
  ```bash
53
- cd my-project
20
+ mkdir wtagent-demo
21
+ cd wtagent-demo
54
22
  wtagent
55
23
  ```
56
24
 
57
- 启动后先选择 ChatGPT 模式:`Pro` 会为新对话选择 Pro,`Current` 会保留网页当前设置且不执行模型切换。非交互调用默认使用 `Current`;需要 Pro 时可显式传入 `--mode Pro`。
25
+ ChatGPT asks you to choose `Pro` or `Current`; other providers keep or silently select their configured default. Then type a task:
58
26
 
59
- 也可以直接附带任务:
60
-
61
- ```bash
62
- wtagent "检查这个项目并修复测试"
63
- wtagent -C ./my-project "创建一个网站"
27
+ ```text
28
+ $ wtagent
29
+ you › Create hello.js that writes "Hello from WTAgent" to hello.txt. Run it with Node.js and verify the result.
64
30
  ```
65
31
 
66
- 之后直接在终端中继续对话。WTAgent 会把任务交给 GPT Web,并在本地执行文件操作和结构化本地命令。可以一次粘贴多行内容,粘贴后按 Enter 作为一条消息发送;使用 `↑` / `↓` 浏览本次 CLI 会话的历史输入。
32
+ WTAgent creates the files in the current directory, runs the script locally, and checks its output. You can continue chatting in the same terminal after the task finishes.
67
33
 
68
- 按 `Ctrl+C` 或 `Ctrl+D` 可退出并关闭专用 Chrome。若上一次异常退出留下了 Chrome,WTAgent 会在验证其 CDP 身份后复用并接管它。
34
+ Choose a provider with `--model` (ChatGPT is the default). Supported values are `chatgpt`, `claude`, `deepseek`, `gemini`, `kimi`, and `glm`:
69
35
 
70
- 常见说明:
71
-
72
- - `wtagent doctor` 会检查 Node、Chrome、目录权限和运行环境
73
- - 首次登录只会写入 WTAgent 的专用 Chrome Profile,不会接管你的日常浏览器 Profile
74
- - 如果系统没有 Git 或 `rg`,WTAgent 仍应保留核心文件读写与搜索能力
75
-
76
- ## English
36
+ ```bash
37
+ wtagent --model claude "inspect this project and summarize its architecture"
38
+ wtagent --model gemini "inspect this project and summarize its architecture"
39
+ ```
77
40
 
78
- WTAgent connects GPT Web chat to local tools, providing a Codex-like CLI agent experience. The first adapter currently supports ChatGPT Web.
41
+ Claude keeps the model selected by claude.ai in its browser profile; WTAgent does not override it.
42
+ Gemini likewise keeps the model selected in its browser profile.
79
43
 
80
- GPT Web handles reasoning. WTAgent runs locally to:
44
+ If the provider is not signed in, WTAgent opens its dedicated Chrome profile and asks you to sign in. Each provider has an independent profile, and your task continues automatically after login.
81
45
 
82
- - Read and edit local files
83
- - Run structured local commands, builds, tests, and development servers
46
+ WTAgent itself does not require an API key. It uses your own web account, available models, and quota.
84
47
 
85
- No OpenAI API key or ChatGPT Pro subscription is required. WTAgent stores your web login in a dedicated Chrome profile and uses the models and quota actually available to that account. Pro is an optional bonus when the account has it.
48
+ You can also provide the first task directly:
86
49
 
87
- Support matrix:
50
+ ```bash
51
+ wtagent "create hello.js, run it, and verify the output"
52
+ ```
88
53
 
89
- - macOS
90
- - Linux
91
- - Windows 10 1809+ / Windows 11 x64
92
- - Windows ARM64 is currently preview only
54
+ Multiline paste and `↑` / `↓` input history are supported. Press `Ctrl+C` or `Ctrl+D` to exit.
93
55
 
94
- Boundaries:
56
+ ## 中文
95
57
 
96
- - Requires Chrome or Chromium; Edge is out of scope for the first Windows release
97
- - Git and `rg` are optional accelerators, not runtime requirements
98
- - WSL is not supported in v1; run WTAgent from native PowerShell, CMD, or Windows Terminal
58
+ WTAgent 将 ChatGPT、Claude、DeepSeek、Gemini、Kimi 或 GLM 网页聊天连接到本地项目:模型在浏览器中思考,WTAgent 在你的电脑上读写本地文件并运行命令。
99
59
 
100
- ### Quick start
60
+ ### 快速开始
101
61
 
102
- Requires Node.js 20.17+ and Chrome/Chromium.
62
+ 需要 Node.js 20.17+ 和 Chrome/Chromium。支持 macOS、Linux 和原生 Windows,暂不支持 WSL。
103
63
 
104
64
  ```bash
105
- npm install -g wtagent --registry=https://registry.npmjs.org/
106
- wtagent login
65
+ npm install -g wtagent
107
66
  ```
108
67
 
109
- Windows PowerShell:
68
+ 进入工作目录并启动:
110
69
 
111
- ```powershell
112
- npm install -g wtagent --registry=https://registry.npmjs.org/
113
- wtagent doctor
114
- wtagent login
70
+ ```bash
71
+ mkdir wtagent-demo
72
+ cd wtagent-demo
73
+ wtagent
115
74
  ```
116
75
 
117
- After signing in, start WTAgent inside a project:
76
+ ChatGPT 会让你选择 `Pro` 或 `Current`;其他 provider 会保持或自动选择配置的默认模式。然后直接输入任务:
118
77
 
119
- ```bash
120
- cd my-project
121
- wtagent
78
+ ```text
79
+ $ wtagent
80
+ you › 创建 hello.js,将“Hello from WTAgent”写入 hello.txt。用 Node.js 运行并验证结果。
122
81
  ```
123
82
 
124
- At startup, choose a ChatGPT mode: `Pro` selects Pro for the new conversation, while `Current` keeps the current web setting without changing it. Non-interactive runs default to `Current`; pass `--mode Pro` to opt in explicitly.
83
+ WTAgent 会在当前目录创建文件、运行本地脚本并检查输出。任务完成后,可以继续在同一个终端中对话。
125
84
 
126
- Or provide the first task directly:
85
+ 通过 `--model` 选择 provider(默认是 ChatGPT)。可选值包括 `chatgpt`、`claude`、`deepseek`、`gemini`、`kimi` 和 `glm`:
127
86
 
128
87
  ```bash
129
- wtagent "inspect this project and fix the tests"
130
- wtagent -C ./my-project "build a website"
88
+ wtagent --model claude "分析这个项目并总结架构"
89
+ wtagent --model gemini "分析这个项目并总结架构"
131
90
  ```
132
91
 
133
- Continue chatting in the terminal. WTAgent sends tasks to GPT Web and executes file operations and structured local commands. You can paste multiple lines and then press Enter to send them as one message. Use `↑` / `↓` to browse input history from the current CLI session.
92
+ Claude 会沿用 claude.ai 在该浏览器 Profile 中选择的模型,WTAgent 不会自动切换模型。
93
+ Gemini 同样沿用其浏览器 Profile 当前选择的模型。
134
94
 
135
- Press `Ctrl+C` or `Ctrl+D` to exit and close the dedicated Chrome. If an abnormal exit leaves Chrome running, WTAgent verifies and adopts that CDP instance on the next start.
95
+ 如果尚未登录对应 provider,WTAgent 会打开它的独立专用 Chrome Profile 并提示登录;登录成功后任务会自动继续。
136
96
 
137
- Notes:
97
+ WTAgent 本身无需 API Key,而是使用你自己的网页账号、可用模型和额度。
98
+
99
+ 也可以在启动时直接附带第一个任务:
100
+
101
+ ```bash
102
+ wtagent "创建 hello.js,运行并验证输出"
103
+ ```
138
104
 
139
- - `wtagent doctor` checks Node, Chrome, writable data paths, and runtime support
140
- - WTAgent always uses its own Chrome profile and does not reuse your daily browsing profile
141
- - Core file and search capabilities must continue to work even when Git or `rg` is missing
105
+ 支持多行粘贴和 `↑` / `↓` 输入历史。使用 `Ctrl+C` 或 `Ctrl+D` 退出。
142
106
 
143
107
  ## License
144
108
 
@@ -652,6 +652,7 @@ sessionId + assistantMessageIdentity + normalizedToolCall
652
652
  - Chrome 崩溃:用相同 Profile 重启并打开会话 URL。
653
653
  - 同一 CLI 进程中的 follow-up 保持在当前会话 Page,不重复导航;跨进程恢复需要等待本地记录的最近 assistant message ID 出现在 DOM 后才能发送。
654
654
  - 每次发送记录已有消息 ID 和新 user turn,只接受位于该 user turn 之后的新 assistant turn;无法建立可靠消息身份时超时并保存诊断,禁止退化为基于数量或文本变化猜测。
655
+ - 新 assistant 节点在停止生成后持续 10 秒仍为空时,Runtime 只发送“继续上一轮”的短提示,不重发原任务、附件或工具结果;自动恢复最多 3 次。仍为空时保留 Chrome、Session 和待确认工具结果并回到 CLI,允许用户输入 `/retry` 或新的指令。
655
656
  - 同一 Profile 同时只允许一个 WTAgent CLI Session;启动和接管过程使用 Profile 级互斥锁。
656
657
  - 登录失效或出现验证:进入 `AUTH_REQUIRED`/`PAUSED`,让用户接管。
657
658
  - 会话页面丢失:从本地记录打开原会话;无法恢复时创建新的本地 Session 和新的网页对话,不向旧 rollout 继续追加。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wtagent",
3
- "version": "0.1.0-alpha.6",
3
+ "version": "0.2.0",
4
4
  "description": "Turn your own web AI session into a local tool-using agent.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,13 +30,14 @@
30
30
  ],
31
31
  "scripts": {
32
32
  "test": "node --test",
33
- "test:unit": "node --test test/protocol.test.js test/policy.test.js test/tools.test.js test/prompt-builder.test.js test/session-export.test.js test/platform.test.js test/cli.test.js test/at-files.test.js",
33
+ "test:unit": "node --test test/protocol.test.js test/policy.test.js test/tools.test.js test/prompt-builder.test.js test/session-export.test.js test/platform.test.js test/cli.test.js test/at-files.test.js test/self-update.test.js test/startup-notices.test.js test/provider-registry.test.js test/claude-adapter.test.js test/deepseek-adapter.test.js test/gemini-adapter.test.js test/kimi-adapter.test.js test/glm-adapter.test.js",
34
34
  "test:integration": "node --test test/runtime.test.js",
35
35
  "test:windows": "node --test test/windows-command-launcher.test.js test/windows-diagnostics.test.js test/windows-search-path.test.js test/atomic-write.test.js test/process-utils.test.js test/cdp-state.test.js test/windows-fixtures.test.js test/windows-package-smoke.test.js",
36
36
  "check": "node scripts/check-syntax.js",
37
37
  "doctor": "node src/cli/main.js doctor",
38
38
  "login": "node src/cli/main.js login",
39
39
  "prepack": "npm run check && npm test",
40
+ "release": "npm publish --tag latest",
40
41
  "release:alpha": "npm publish --tag alpha"
41
42
  },
42
43
  "engines": {