@keyou007/agent-bot 0.1.12 → 0.1.13-alpha.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/CHANGELOG.md +9 -0
- package/README.md +23 -10
- package/README.zh.md +23 -10
- package/config.example.yaml +0 -24
- package/dist/cli/AgentPrerequisites.js +262 -0
- package/dist/cli/AgentPrerequisites.js.map +1 -0
- package/dist/cli/DefaultAgentSelection.js +47 -0
- package/dist/cli/DefaultAgentSelection.js.map +1 -0
- package/dist/cli/Initializer.js +165 -2
- package/dist/cli/Initializer.js.map +1 -1
- package/dist/cli/help.js +4 -4
- package/dist/cli.js +194 -4
- package/dist/cli.js.map +1 -1
- package/dist/codex/AppServerConnection.js +3 -3
- package/dist/codex/AppServerConnection.js.map +1 -1
- package/dist/codex/CodexProcessManager.js +4 -4
- package/dist/codex/CodexProcessManager.js.map +1 -1
- package/dist/codex/CodexRuntime.js +28 -16
- package/dist/codex/CodexRuntime.js.map +1 -1
- package/dist/config/loadConfig.js +0 -24
- package/dist/config/loadConfig.js.map +1 -1
- package/dist/console/ConsoleConnector.js +2 -2
- package/dist/console/ConsoleConnector.js.map +1 -1
- package/dist/feishu/CardRenderer.js +8 -8
- package/dist/feishu/CardRenderer.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/proxy/ProxySessionController.js +51 -51
- package/dist/proxy/ProxySessionController.js.map +1 -1
- package/dist/runtime/AcpRuntimeAdapter.js +3 -2
- package/dist/runtime/AcpRuntimeAdapter.js.map +1 -1
- package/docs/technical-reference.md +32 -17
- package/docs/technical-reference.zh.md +32 -17
- package/npm-shrinkwrap.json +2 -2
- package/package.json +7 -3
- package/skills/agent-bot/SKILL.md +12 -6
- package/src/cli/AgentPrerequisites.ts +377 -0
- package/src/cli/DefaultAgentSelection.ts +56 -0
- package/src/cli/Initializer.ts +204 -3
- package/src/cli/help.ts +4 -4
- package/src/cli.ts +293 -5
- package/src/codex/AppServerConnection.ts +3 -3
- package/src/codex/CodexProcessManager.ts +4 -4
- package/src/codex/CodexRuntime.ts +38 -18
- package/src/config/loadConfig.ts +0 -24
- package/src/console/ConsoleConnector.ts +2 -2
- package/src/feishu/CardRenderer.ts +8 -8
- package/src/index.ts +1 -1
- package/src/proxy/ProxySessionController.ts +52 -52
- package/src/runtime/AcpRuntimeAdapter.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,15 @@ The project follows [Semantic Versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.13-alpha.0] - 2026-08-03
|
|
10
|
+
|
|
11
|
+
- Upgrade existing Profiles during `agentbot init` by filling missing `config.yaml` and `.env` settings, detecting Codex and TraeX versions, offering explicit install or upgrade actions, and requiring an interactive default-Agent selection.
|
|
12
|
+
- Keep the generated Agent list focused on Codex and TraeX while preserving existing custom Agents and user configuration during Profile upgrades.
|
|
13
|
+
- Generalize runtime messages, cards, help, documentation, and package metadata from Codex-specific wording to the selected App Server Agent.
|
|
14
|
+
- Recognize known TraeX code-mode tool-channel failures in completed responses and guide users to switch models with `/model`.
|
|
15
|
+
- Make Alpha the default release channel, with tested Alpha sequencing and explicit stable promotion commands.
|
|
16
|
+
- Publish Alpha packages under npm's `alpha` dist-tag and mark their GitHub releases as prereleases while preserving `latest` for stable versions.
|
|
17
|
+
|
|
9
18
|
## [0.1.12] - 2026-08-03
|
|
10
19
|
|
|
11
20
|
- Add a ready-to-use TraeX App Server example to the checked-in and generated default configuration.
|
package/README.md
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
# Agent Bot
|
|
6
6
|
|
|
7
|
-
Use
|
|
7
|
+
Use Codex, TraeX, and compatible ACP agents directly from Feishu.
|
|
8
8
|
|
|
9
9
|
English | [简体中文](README.zh.md)
|
|
10
10
|
|
|
11
|
-
Agent Bot runs on your computer and connects a Feishu bot to your local
|
|
11
|
+
Agent Bot runs on your computer and connects a Feishu bot to your local coding agents. Send a message to start working; the bot updates a progress card while the agent runs and sends the final answer as Markdown.
|
|
12
12
|
|
|
13
13
|
## What You Can Do
|
|
14
14
|
|
|
15
|
-
- Use your existing local Codex login from Feishu
|
|
15
|
+
- Use your existing local Codex or TraeX login from Feishu
|
|
16
16
|
- Create, continue, switch, fork, and stop tasks
|
|
17
17
|
- Work with text, images, groups, and threads
|
|
18
18
|
- Queue follow-up Prompts or add instructions while a task is running
|
|
@@ -24,15 +24,20 @@ Agent Bot runs on your computer and connects a Feishu bot to your local Codex en
|
|
|
24
24
|
### Requirements
|
|
25
25
|
|
|
26
26
|
- Node.js 22 or later
|
|
27
|
-
-
|
|
28
|
-
- A completed local
|
|
27
|
+
- At least one supported App Server Agent: Codex or TraeX
|
|
28
|
+
- A completed local login for the Agent you intend to use
|
|
29
29
|
|
|
30
|
-
Check the login:
|
|
30
|
+
Check the installed Agents and login state:
|
|
31
31
|
|
|
32
32
|
```powershell
|
|
33
|
+
codex --version
|
|
33
34
|
codex login status
|
|
35
|
+
traex --version
|
|
36
|
+
traex login status
|
|
34
37
|
```
|
|
35
38
|
|
|
39
|
+
You can continue to initialization when either Codex or TraeX is ready. `agentbot init` checks both Agents and can help install or upgrade either one.
|
|
40
|
+
|
|
36
41
|
### Install
|
|
37
42
|
|
|
38
43
|
```powershell
|
|
@@ -41,6 +46,12 @@ agentbot --version
|
|
|
41
46
|
agentbot --help
|
|
42
47
|
```
|
|
43
48
|
|
|
49
|
+
To try the current Alpha channel without replacing npm's stable `latest` tag:
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
npm install --global @keyou007/agent-bot@alpha
|
|
53
|
+
```
|
|
54
|
+
|
|
44
55
|
This installs `agentbot` as the primary command. The legacy `agent-bot` command remains available temporarily, prints a deprecation warning, and will be removed in a future release. Command-line help, status, progress, prompts, and errors follow the system language for Chinese and English locales; all other locales fall back to English. JSON output remains language-neutral and stable. See the [technical reference](docs/technical-reference.md#development-and-source-installation) to install from source.
|
|
45
56
|
|
|
46
57
|
### Initialize
|
|
@@ -49,7 +60,9 @@ This installs `agentbot` as the primary command. The legacy `agent-bot` command
|
|
|
49
60
|
agentbot init
|
|
50
61
|
```
|
|
51
62
|
|
|
52
|
-
|
|
63
|
+
Initialization detects Codex and TraeX and reports their installed versions. Missing or outdated Agents are summarized once with their exact install or upgrade commands. Enter one or more action numbers separated by commas, enter `all`, or press Enter to skip maintenance. A failed command does not block the remaining initialization steps. After these checks, select the default Agent by number or standard name; when the current default is still available, press Enter to confirm it. Agent Bot saves the selection to `defaults.agent` in `config.yaml` for future tasks.
|
|
64
|
+
|
|
65
|
+
Then follow the displayed link or scan the QR code to create and authorize the Feishu bot. Initialization prepares `~/.agent-bot`, saves the bot credentials and the authorizing user, checks the required permissions, and starts Agent Bot automatically.
|
|
53
66
|
|
|
54
67
|
Only a complete app ID and secret saved locally count as a successful bot creation. If initialization is interrupted before both credentials are saved, rerunning `agentbot init` creates a new bot. If credentials were saved, initialization resumes by auditing that bot's remote permissions and subscriptions.
|
|
55
68
|
|
|
@@ -66,7 +79,7 @@ When optional permissions or subscriptions are missing, Agent Bot first shows th
|
|
|
66
79
|
| `--profile <directory>`| Use an isolated profile directory |
|
|
67
80
|
| `--config <path>` | Use a specific configuration file |
|
|
68
81
|
|
|
69
|
-
|
|
82
|
+
After upgrading Agent Bot, rerun `agentbot init` to refresh the Profile. It preserves existing values in `config.yaml` and `.env`, fills settings and environment variables added by the current version, lets you confirm or change the default Agent, and rechecks the Agents and bot configuration. If the server is already running, initialization leaves it running. In a non-interactive terminal, `init` cannot ask for a selection and keeps the already configured default Agent.
|
|
70
83
|
|
|
71
84
|
To fully reconfigure a Profile, stop its server and select the Profile explicitly:
|
|
72
85
|
|
|
@@ -183,7 +196,7 @@ Plain text continues the current task. Messages beginning with `/` are commands.
|
|
|
183
196
|
|
|
184
197
|
Slash commands accept any unique prefix, and compound commands accept registered initialisms: `/sess` runs `/sessions`, `/fg` runs `/forkgroup`, `/ng` runs `/newgroup`, and `/ns` runs `/nosteer`. Exact command names take priority. An ambiguous prefix such as `/s` or `/f` is rejected and reports every matching command.
|
|
185
198
|
|
|
186
|
-
`/agent`, `/provider`, `/model`, `/thinking`, and `/permissions` use the same execution-settings card when there is something to select. When more than one Agent is configured, the card adds an Agent tab for selecting the default Agent used by future tasks; `/agent` opens that tab, including when the chat has no current task. With only one configured Agent, `/agent` reports the current Agent directly instead. Existing tasks keep their original Agent, and tasks using different Agents run independently. `/agent <name>` remains available for direct selection. `/provider` likewise reports the current Provider directly when no alternative Provider is configured. The other four commands activate their matching tabs and do not accept arguments. A task created without inherited settings uses the default Provider
|
|
199
|
+
`/agent`, `/provider`, `/model`, `/thinking`, and `/permissions` use the same execution-settings card when there is something to select. When more than one Agent is configured, the card adds an Agent tab for selecting the default Agent used by future tasks; `/agent` opens that tab, including when the chat has no current task. With only one configured Agent, `/agent` reports the current Agent directly instead. Existing tasks keep their original Agent, and tasks using different Agents run independently. `/agent <name>` remains available for direct selection. `/provider` likewise reports the current Provider directly when no alternative Provider is configured. The other four commands activate their matching tabs and do not accept arguments. A task created without inherited settings uses the selected Agent's default Provider.
|
|
187
200
|
|
|
188
201
|
Private chats, group timelines, and threads keep separate current tasks. You can send an image by itself or together with text. While a task is running, plain text adds instructions to the current work; use `/queue` (or `/nosteer`) to always create a later turn.
|
|
189
202
|
|
|
@@ -231,7 +244,7 @@ Alternative profiles are directory-based and are not registered by name. Each on
|
|
|
231
244
|
- **The bot does not respond:** run `agentbot server status` and check `~/.agent-bot/logs/agent-bot.log`.
|
|
232
245
|
- **The Worker restarted after a Node crash:** check `~/.agent-bot/data/last-crash.json`, `~/.agent-bot/logs/worker.stderr.log`, and `~/.agent-bot/data/crash-reports/`.
|
|
233
246
|
- **Feishu permissions are incomplete:** rerun `agentbot init` and follow the displayed authorization steps.
|
|
234
|
-
- **
|
|
247
|
+
- **An Agent cannot start:** run `codex login status` or `traex login status` as the same operating-system user that runs Agent Bot, then rerun `agentbot init` to check its version.
|
|
235
248
|
- **You only need local testing:** run `agentbot init --skip-feishu`, then `agentbot console`.
|
|
236
249
|
- **A safe restart keeps waiting:** inspect active tasks with `agentbot task list --status running`.
|
|
237
250
|
|
package/README.zh.md
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
# Agent Bot
|
|
6
6
|
|
|
7
|
-
通过飞书使用本机上的 Codex
|
|
7
|
+
通过飞书使用本机上的 Codex、TraeX 和兼容 ACP 的 Agent。
|
|
8
8
|
|
|
9
9
|
[English](README.md) | 简体中文
|
|
10
10
|
|
|
11
|
-
Agent Bot
|
|
11
|
+
Agent Bot 运行在你的电脑上,把飞书机器人连接到本机编程 Agent。发送消息即可开始工作;执行过程中机器人会更新进度卡,完成后发送 Markdown 最终回答。
|
|
12
12
|
|
|
13
13
|
## 可以做什么
|
|
14
14
|
|
|
15
|
-
- 在飞书中使用本机已有的 Codex 登录
|
|
15
|
+
- 在飞书中使用本机已有的 Codex 或 TraeX 登录
|
|
16
16
|
- 创建、继续、切换、分支和停止任务
|
|
17
17
|
- 使用文字、图片、群聊和话题协作
|
|
18
18
|
- 排队后续 Prompt,或在任务运行中追加指令
|
|
@@ -24,15 +24,20 @@ Agent Bot 运行在你的电脑上,把飞书机器人连接到本机 Codex 环
|
|
|
24
24
|
### 使用前提
|
|
25
25
|
|
|
26
26
|
- Node.js 22 或更高版本
|
|
27
|
-
-
|
|
28
|
-
-
|
|
27
|
+
- 至少安装一个支持的 App Server Agent:Codex 或 TraeX
|
|
28
|
+
- 已完成准备使用的 Agent 的本机登录
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
检查已安装的 Agent 和登录状态:
|
|
31
31
|
|
|
32
32
|
```powershell
|
|
33
|
+
codex --version
|
|
33
34
|
codex login status
|
|
35
|
+
traex --version
|
|
36
|
+
traex login status
|
|
34
37
|
```
|
|
35
38
|
|
|
39
|
+
Codex 或 TraeX 中任意一个准备完成后即可继续初始化。`agentbot init` 会检查两者,并可帮助安装或升级。
|
|
40
|
+
|
|
36
41
|
### 安装
|
|
37
42
|
|
|
38
43
|
```powershell
|
|
@@ -41,6 +46,12 @@ agentbot --version
|
|
|
41
46
|
agentbot --help
|
|
42
47
|
```
|
|
43
48
|
|
|
49
|
+
如需试用当前 Alpha 通道,同时不影响 npm 的稳定版 `latest` 标签:
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
npm install --global @keyou007/agent-bot@alpha
|
|
53
|
+
```
|
|
54
|
+
|
|
44
55
|
该命令会把 `agentbot` 安装为主命令。旧的 `agent-bot` 命令暂时保留,运行时会显示弃用警告,并将在后续版本中移除。命令行帮助、状态、进度、交互提示和错误会根据系统语言显示中文或英文;其他未支持语言统一回退英文。JSON 输出不做本地化并保持字段稳定。从源码安装的方法见[技术参考](docs/technical-reference.zh.md#开发与源码安装)。
|
|
45
56
|
|
|
46
57
|
### 初始化
|
|
@@ -49,7 +60,9 @@ agentbot --help
|
|
|
49
60
|
agentbot init
|
|
50
61
|
```
|
|
51
62
|
|
|
52
|
-
|
|
63
|
+
初始化会检测 Codex 和 TraeX,并显示已安装的版本。未安装或版本较旧的 Agent 会汇总显示对应的安装或升级命令;输入一个或多个操作编号(用逗号分隔)、输入 `all`,或直接回车跳过维护。命令执行失败不会阻塞后续初始化。检查完成后,可输入编号或标准名选择默认 Agent;当前默认值仍可用时,直接回车即可确认。Agent Bot 会把选择保存到 `config.yaml` 的 `defaults.agent`,供后续新任务使用。
|
|
64
|
+
|
|
65
|
+
然后打开命令显示的链接或扫描二维码,完成飞书机器人创建和授权。初始化会准备 `~/.agent-bot`、保存机器人凭据和授权用户、检查所需权限,并自动启动 Agent Bot。
|
|
53
66
|
|
|
54
67
|
只有 App ID 和 App Secret 都已保存到本地才视为机器人创建成功。如果初始化在完整凭据保存前中断,再次运行 `agentbot init` 会创建新机器人;如果凭据已经保存,则会继续检查该机器人的远端权限和订阅。
|
|
55
68
|
|
|
@@ -66,7 +79,7 @@ agentbot init
|
|
|
66
79
|
| `--profile <目录>` | 使用指定目录中的独立 Profile |
|
|
67
80
|
| `--config <路径>` | 使用指定配置文件 |
|
|
68
81
|
|
|
69
|
-
|
|
82
|
+
升级 Agent Bot 后,可以重新运行 `agentbot init` 刷新 Profile。它会保留现有 `config.yaml` 和 `.env` 中的值,补齐当前版本新增的配置项和环境变量,允许确认或更换默认 Agent,并重新检查 Agent 与机器人配置。如果 Server 已在运行,初始化会保留当前服务。非交互式终端无法询问选择,此时会保留配置中已有的默认 Agent。
|
|
70
83
|
|
|
71
84
|
如需完整重新配置一个 Profile,请先停止它的 Server,并显式指定 Profile:
|
|
72
85
|
|
|
@@ -183,7 +196,7 @@ agentbot task stop <任务>
|
|
|
183
196
|
|
|
184
197
|
斜杠命令支持任意唯一前缀,复合命令还支持首字母缩写:`/sess` 等同于 `/sessions`,`/fg` 等同于 `/forkgroup`,`/ng` 等同于 `/newgroup`,`/ns` 等同于 `/nosteer`。完整命令名优先;`/s`、`/f` 等匹配多个命令的前缀会被拒绝,并列出全部候选命令。
|
|
185
198
|
|
|
186
|
-
`/agent`、`/provider`、`/model`、`/thinking` 和 `/permissions` 在存在可选项时使用同一张运行设置卡片。配置了多个 Agent 时,卡片会增加 Agent tab,用于选择后续新任务使用的默认 Agent;即使当前聊天还没有任务,`/agent` 也能打开该 tab。只配置一个 Agent 时,`/agent` 直接显示当前 Agent,不打开卡片。现有任务仍保持原来的 Agent,使用不同 Agent 的任务可以相互独立地运行。`/agent <名称>` 继续支持直接选择。没有可切换的 Provider 时,`/provider` 同样只显示当前 Provider。其余四个命令激活各自对应的 tab
|
|
199
|
+
`/agent`、`/provider`、`/model`、`/thinking` 和 `/permissions` 在存在可选项时使用同一张运行设置卡片。配置了多个 Agent 时,卡片会增加 Agent tab,用于选择后续新任务使用的默认 Agent;即使当前聊天还没有任务,`/agent` 也能打开该 tab。只配置一个 Agent 时,`/agent` 直接显示当前 Agent,不打开卡片。现有任务仍保持原来的 Agent,使用不同 Agent 的任务可以相互独立地运行。`/agent <名称>` 继续支持直接选择。没有可切换的 Provider 时,`/provider` 同样只显示当前 Provider。其余四个命令激活各自对应的 tab,且不接受参数。没有可继承设置的新任务使用所选 Agent 的默认 Provider。
|
|
187
200
|
|
|
188
201
|
私聊、群正文和话题分别维护当前任务。可以单独发送图片,也可以同时发送文字和图片。任务运行中发送普通文字会追加指令;需要确保形成后续 turn 时使用 `/queue`(或 `/nosteer`)。
|
|
189
202
|
|
|
@@ -231,7 +244,7 @@ agentbot --profile ~/.agent-bot-rescue server status
|
|
|
231
244
|
- **机器人没有响应:** 运行 `agentbot server status`,并查看 `~/.agent-bot/logs/agent-bot.log`
|
|
232
245
|
- **Node 崩溃后 Worker 被自动重启:** 查看 `~/.agent-bot/data/last-crash.json`、`~/.agent-bot/logs/worker.stderr.log` 和 `~/.agent-bot/data/crash-reports/`
|
|
233
246
|
- **飞书权限不完整:** 重新运行 `agentbot init`,完成显示的授权步骤
|
|
234
|
-
- **
|
|
247
|
+
- **Agent 无法启动:** 使用运行 Agent Bot 的同一操作系统用户执行 `codex login status` 或 `traex login status`,然后重新运行 `agentbot init` 检查版本
|
|
235
248
|
- **只需要本地测试:** 运行 `agentbot init --skip-feishu`,然后执行 `agentbot console`
|
|
236
249
|
- **安全重启一直等待:** 使用 `agentbot task list --status running` 检查活动任务
|
|
237
250
|
|
package/config.example.yaml
CHANGED
|
@@ -31,30 +31,6 @@ agents:
|
|
|
31
31
|
- "stdio://"
|
|
32
32
|
env: {}
|
|
33
33
|
|
|
34
|
-
coco:
|
|
35
|
-
title: "Coco"
|
|
36
|
-
command: "coco"
|
|
37
|
-
args:
|
|
38
|
-
- "acp"
|
|
39
|
-
- "serve"
|
|
40
|
-
env: {}
|
|
41
|
-
|
|
42
|
-
coco-yolo:
|
|
43
|
-
title: "Coco YOLO"
|
|
44
|
-
command: "coco"
|
|
45
|
-
args:
|
|
46
|
-
- "acp"
|
|
47
|
-
- "serve"
|
|
48
|
-
- "--yolo"
|
|
49
|
-
env: {}
|
|
50
|
-
|
|
51
|
-
example:
|
|
52
|
-
title: "Example ACP Agent"
|
|
53
|
-
command: "node"
|
|
54
|
-
args:
|
|
55
|
-
- "./examples/example-acp-agent.js"
|
|
56
|
-
env: {}
|
|
57
|
-
|
|
58
34
|
defaults:
|
|
59
35
|
agent: "codex"
|
|
60
36
|
cwd: "."
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
const CODEX_PACKAGE = "@openai/codex";
|
|
3
|
+
const TRAEX_CHANNEL = "alpha";
|
|
4
|
+
const TRAEX_INSTALL_BASE_URL = "https://code.byted.org/api/tos-proxy/download";
|
|
5
|
+
export async function inspectSupportedAgents(options = {}) {
|
|
6
|
+
return Promise.all([
|
|
7
|
+
inspectSupportedAgent("codex", options),
|
|
8
|
+
inspectSupportedAgent("traex", options),
|
|
9
|
+
]);
|
|
10
|
+
}
|
|
11
|
+
export async function inspectSupportedAgent(id, options = {}) {
|
|
12
|
+
const platform = options.platform ?? process.platform;
|
|
13
|
+
const env = options.env ?? process.env;
|
|
14
|
+
const run = options.run ?? runAgentCommand;
|
|
15
|
+
return id === "codex"
|
|
16
|
+
? inspectCodex(platform, env, run)
|
|
17
|
+
: inspectTraex(platform, env, run);
|
|
18
|
+
}
|
|
19
|
+
export async function runSupportedAgentMaintenance(id, kind, options = {}) {
|
|
20
|
+
const platform = options.platform ?? process.platform;
|
|
21
|
+
const env = options.env ?? process.env;
|
|
22
|
+
const run = options.run ?? runAgentCommand;
|
|
23
|
+
const command = maintenanceCommand(id, kind, platform, env);
|
|
24
|
+
const result = await run({ ...command, inheritStdio: true });
|
|
25
|
+
if (id !== "codex" || kind !== "upgrade" || commandSucceeded(result))
|
|
26
|
+
return result;
|
|
27
|
+
const fallback = codexNpmInstallCommand(platform, env);
|
|
28
|
+
return run({ ...fallback, inheritStdio: true });
|
|
29
|
+
}
|
|
30
|
+
async function inspectCodex(platform, env, run) {
|
|
31
|
+
const installed = await run(capturedCommand("codex", ["--version"], platform, env, 5_000));
|
|
32
|
+
const installedVersion = commandVersion(installed);
|
|
33
|
+
if (!installedVersion)
|
|
34
|
+
return missingInspection("codex", "Codex", platform, env);
|
|
35
|
+
const latest = await run(capturedCommand("npm", ["view", CODEX_PACKAGE, "version", "--json"], platform, env, 15_000));
|
|
36
|
+
const latestVersion = npmVersion(latest);
|
|
37
|
+
if (!latestVersion) {
|
|
38
|
+
return { id: "codex", name: "Codex", state: "ready", installedVersion, latestCheckFailed: true };
|
|
39
|
+
}
|
|
40
|
+
if (compareSemanticVersions(installedVersion, latestVersion) < 0) {
|
|
41
|
+
return {
|
|
42
|
+
id: "codex",
|
|
43
|
+
name: "Codex",
|
|
44
|
+
state: "outdated",
|
|
45
|
+
installedVersion,
|
|
46
|
+
latestVersion,
|
|
47
|
+
action: maintenanceAction("codex", "upgrade", platform, env),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return { id: "codex", name: "Codex", state: "ready", installedVersion, latestVersion };
|
|
51
|
+
}
|
|
52
|
+
async function inspectTraex(platform, env, run) {
|
|
53
|
+
const installed = await run(capturedCommand("traex", ["--version"], platform, env, 5_000));
|
|
54
|
+
const installedVersion = commandVersion(installed);
|
|
55
|
+
if (!installedVersion)
|
|
56
|
+
return missingInspection("traex", "TraeX", platform, env);
|
|
57
|
+
const latest = await run(capturedCommand("traex", ["update", "--channel", TRAEX_CHANNEL, "check"], platform, env, 15_000));
|
|
58
|
+
const latestVersion = /^Latest TraeCode CLI version:\s*(\S+)/mu.exec(commandOutput(latest))?.[1];
|
|
59
|
+
if (!latestVersion) {
|
|
60
|
+
return { id: "traex", name: "TraeX", state: "ready", installedVersion, latestCheckFailed: true };
|
|
61
|
+
}
|
|
62
|
+
if (compareSemanticVersions(installedVersion, latestVersion) < 0) {
|
|
63
|
+
return {
|
|
64
|
+
id: "traex",
|
|
65
|
+
name: "TraeX",
|
|
66
|
+
state: "outdated",
|
|
67
|
+
installedVersion,
|
|
68
|
+
latestVersion,
|
|
69
|
+
action: maintenanceAction("traex", "upgrade", platform, env),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return { id: "traex", name: "TraeX", state: "ready", installedVersion, latestVersion };
|
|
73
|
+
}
|
|
74
|
+
function missingInspection(id, name, platform, env) {
|
|
75
|
+
return {
|
|
76
|
+
id,
|
|
77
|
+
name,
|
|
78
|
+
state: "missing",
|
|
79
|
+
action: maintenanceAction(id, "install", platform, env),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function maintenanceAction(id, kind, platform, env) {
|
|
83
|
+
const command = maintenanceCommand(id, kind, platform, env);
|
|
84
|
+
return { kind, command: command.display };
|
|
85
|
+
}
|
|
86
|
+
function maintenanceCommand(id, kind, platform, env) {
|
|
87
|
+
if (id === "codex") {
|
|
88
|
+
return kind === "install"
|
|
89
|
+
? codexNpmInstallCommand(platform, env)
|
|
90
|
+
: commandSpec("codex", ["update"], platform, env, 5 * 60_000);
|
|
91
|
+
}
|
|
92
|
+
if (kind === "upgrade") {
|
|
93
|
+
return commandSpec("traex", ["update", "--channel", TRAEX_CHANNEL], platform, env, 5 * 60_000);
|
|
94
|
+
}
|
|
95
|
+
const installEnv = {
|
|
96
|
+
...env,
|
|
97
|
+
TRAEX_INSTALL_ASSUME_YES: "1",
|
|
98
|
+
TRAEX_INSTALL_CHANNEL: TRAEX_CHANNEL,
|
|
99
|
+
};
|
|
100
|
+
if (platform === "win32") {
|
|
101
|
+
const scriptUrl = `${TRAEX_INSTALL_BASE_URL}/traex_install_windows.ps1`;
|
|
102
|
+
return {
|
|
103
|
+
command: "powershell.exe",
|
|
104
|
+
args: [
|
|
105
|
+
"-NoProfile",
|
|
106
|
+
"-ExecutionPolicy",
|
|
107
|
+
"Bypass",
|
|
108
|
+
"-Command",
|
|
109
|
+
`Invoke-RestMethod -Uri '${scriptUrl}' | Invoke-Expression`,
|
|
110
|
+
],
|
|
111
|
+
display: `$env:TRAEX_INSTALL_CHANNEL='${TRAEX_CHANNEL}'; irm '${scriptUrl}' | iex`,
|
|
112
|
+
timeoutMs: 5 * 60_000,
|
|
113
|
+
env: installEnv,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const scriptUrl = `${TRAEX_INSTALL_BASE_URL}/traex_install.sh`;
|
|
117
|
+
return {
|
|
118
|
+
command: "bash",
|
|
119
|
+
args: ["-c", `curl -fsSL '${scriptUrl}' | bash`],
|
|
120
|
+
display: `curl -fsSL '${scriptUrl}' | TRAEX_INSTALL_CHANNEL=${TRAEX_CHANNEL} bash`,
|
|
121
|
+
timeoutMs: 5 * 60_000,
|
|
122
|
+
env: installEnv,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function codexNpmInstallCommand(platform, env) {
|
|
126
|
+
return commandSpec("npm", ["install", "--global", `${CODEX_PACKAGE}@latest`], platform, env, 5 * 60_000);
|
|
127
|
+
}
|
|
128
|
+
function commandSucceeded(result) {
|
|
129
|
+
return result.status === 0 && !result.error;
|
|
130
|
+
}
|
|
131
|
+
function capturedCommand(command, args, platform, env, timeoutMs) {
|
|
132
|
+
return commandSpec(command, args, platform, env, timeoutMs);
|
|
133
|
+
}
|
|
134
|
+
function commandSpec(command, args, _platform, env, timeoutMs) {
|
|
135
|
+
return {
|
|
136
|
+
command,
|
|
137
|
+
args,
|
|
138
|
+
display: [command, ...args].join(" "),
|
|
139
|
+
timeoutMs,
|
|
140
|
+
env,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function commandVersion(result) {
|
|
144
|
+
if (result.status !== 0)
|
|
145
|
+
return undefined;
|
|
146
|
+
return versionInText(commandOutput(result));
|
|
147
|
+
}
|
|
148
|
+
function npmVersion(result) {
|
|
149
|
+
if (result.status !== 0)
|
|
150
|
+
return undefined;
|
|
151
|
+
const output = result.stdout.trim();
|
|
152
|
+
try {
|
|
153
|
+
const parsed = JSON.parse(output);
|
|
154
|
+
return typeof parsed === "string" ? versionInText(parsed) : undefined;
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return versionInText(output);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function commandOutput(result) {
|
|
161
|
+
return [result.stdout, result.stderr].filter(Boolean).join("\n");
|
|
162
|
+
}
|
|
163
|
+
function versionInText(value) {
|
|
164
|
+
return /\b(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)\b/u.exec(value)?.[1];
|
|
165
|
+
}
|
|
166
|
+
export function compareSemanticVersions(left, right) {
|
|
167
|
+
const leftVersion = parseSemanticVersion(left);
|
|
168
|
+
const rightVersion = parseSemanticVersion(right);
|
|
169
|
+
if (!leftVersion || !rightVersion)
|
|
170
|
+
return 0;
|
|
171
|
+
for (let index = 0; index < 3; index += 1) {
|
|
172
|
+
const difference = leftVersion.core[index] - rightVersion.core[index];
|
|
173
|
+
if (difference !== 0)
|
|
174
|
+
return difference;
|
|
175
|
+
}
|
|
176
|
+
if (!leftVersion.prerelease && !rightVersion.prerelease)
|
|
177
|
+
return 0;
|
|
178
|
+
if (!leftVersion.prerelease)
|
|
179
|
+
return 1;
|
|
180
|
+
if (!rightVersion.prerelease)
|
|
181
|
+
return -1;
|
|
182
|
+
const length = Math.max(leftVersion.prerelease.length, rightVersion.prerelease.length);
|
|
183
|
+
for (let index = 0; index < length; index += 1) {
|
|
184
|
+
const leftPart = leftVersion.prerelease[index];
|
|
185
|
+
const rightPart = rightVersion.prerelease[index];
|
|
186
|
+
if (leftPart === undefined)
|
|
187
|
+
return -1;
|
|
188
|
+
if (rightPart === undefined)
|
|
189
|
+
return 1;
|
|
190
|
+
if (leftPart === rightPart)
|
|
191
|
+
continue;
|
|
192
|
+
const leftNumber = /^\d+$/u.test(leftPart) ? Number(leftPart) : undefined;
|
|
193
|
+
const rightNumber = /^\d+$/u.test(rightPart) ? Number(rightPart) : undefined;
|
|
194
|
+
if (leftNumber !== undefined && rightNumber !== undefined)
|
|
195
|
+
return leftNumber - rightNumber;
|
|
196
|
+
if (leftNumber !== undefined)
|
|
197
|
+
return -1;
|
|
198
|
+
if (rightNumber !== undefined)
|
|
199
|
+
return 1;
|
|
200
|
+
return leftPart.localeCompare(rightPart);
|
|
201
|
+
}
|
|
202
|
+
return 0;
|
|
203
|
+
}
|
|
204
|
+
function parseSemanticVersion(value) {
|
|
205
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/u.exec(value);
|
|
206
|
+
if (!match)
|
|
207
|
+
return undefined;
|
|
208
|
+
return {
|
|
209
|
+
core: [Number(match[1]), Number(match[2]), Number(match[3])],
|
|
210
|
+
...(match[4] ? { prerelease: match[4].split(".") } : {}),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
export function runAgentCommand(command) {
|
|
214
|
+
return new Promise((resolve) => {
|
|
215
|
+
const invocation = resolveInvocation(command);
|
|
216
|
+
const child = spawn(invocation.command, invocation.args, {
|
|
217
|
+
env: command.env ?? process.env,
|
|
218
|
+
windowsHide: true,
|
|
219
|
+
stdio: command.inheritStdio ? "inherit" : ["ignore", "pipe", "pipe"],
|
|
220
|
+
});
|
|
221
|
+
const stdout = [];
|
|
222
|
+
const stderr = [];
|
|
223
|
+
if (!command.inheritStdio) {
|
|
224
|
+
child.stdout?.on("data", (chunk) => stdout.push(chunk));
|
|
225
|
+
child.stderr?.on("data", (chunk) => stderr.push(chunk));
|
|
226
|
+
}
|
|
227
|
+
let error;
|
|
228
|
+
let timedOut = false;
|
|
229
|
+
const timer = setTimeout(() => {
|
|
230
|
+
timedOut = true;
|
|
231
|
+
child.kill();
|
|
232
|
+
}, command.timeoutMs);
|
|
233
|
+
child.once("error", (spawnError) => {
|
|
234
|
+
error = spawnError.message;
|
|
235
|
+
});
|
|
236
|
+
child.once("close", (status) => {
|
|
237
|
+
clearTimeout(timer);
|
|
238
|
+
resolve({
|
|
239
|
+
status,
|
|
240
|
+
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
241
|
+
stderr: Buffer.concat(stderr).toString("utf8"),
|
|
242
|
+
...(error || timedOut ? { error: timedOut ? `Timed out after ${command.timeoutMs}ms.` : error } : {}),
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function resolveInvocation(command) {
|
|
248
|
+
if (process.platform !== "win32" || /\.exe$/iu.test(command.command)) {
|
|
249
|
+
return { command: command.command, args: command.args };
|
|
250
|
+
}
|
|
251
|
+
const commandLine = [command.command, ...command.args].map(quoteCmdArgument).join(" ");
|
|
252
|
+
return {
|
|
253
|
+
command: process.env.ComSpec ?? "cmd.exe",
|
|
254
|
+
args: ["/d", "/s", "/c", commandLine],
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function quoteCmdArgument(value) {
|
|
258
|
+
return /^[A-Za-z0-9_@./:\\=+-]+$/u.test(value)
|
|
259
|
+
? value
|
|
260
|
+
: `"${value.replaceAll('"', '""')}"`;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=AgentPrerequisites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentPrerequisites.js","sourceRoot":"","sources":["../../src/cli/AgentPrerequisites.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AA2C3C,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM,aAAa,GAAG,OAAO,CAAC;AAC9B,MAAM,sBAAsB,GAAG,+CAA+C,CAAC;AAE/E,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAO,GAAkC,EAAE;IAE3C,OAAO,OAAO,CAAC,GAAG,CAAC;QACjB,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC;QACvC,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC;KACxC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,EAAoB,EACpB,OAAO,GAAkC,EAAE;IAE3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SAAS,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACtG,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAyB;IAClD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACrE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvF,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,SAAS;QACzC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC;KACtC,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC;QAC5C,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function selectableDefaultAgents(configured, inspections) {
|
|
2
|
+
const supported = new Map(inspections.map((inspection) => [inspection.id, inspection]));
|
|
3
|
+
return configured.flatMap((agent) => {
|
|
4
|
+
const inspection = supported.get(agent.name);
|
|
5
|
+
if (inspection && !inspection.installedVersion)
|
|
6
|
+
return [];
|
|
7
|
+
return [{
|
|
8
|
+
...agent,
|
|
9
|
+
...(inspection?.installedVersion ? { installedVersion: inspection.installedVersion } : {}),
|
|
10
|
+
}];
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export function parseMaintenanceSelection(input, choiceCount) {
|
|
14
|
+
const value = input.trim();
|
|
15
|
+
if (!value)
|
|
16
|
+
return [];
|
|
17
|
+
if (/^(?:a|all)$/iu.test(value))
|
|
18
|
+
return Array.from({ length: choiceCount }, (_, index) => index);
|
|
19
|
+
const tokens = value.split(/[,,\s]+/u).filter(Boolean);
|
|
20
|
+
const selected = new Set();
|
|
21
|
+
for (const token of tokens) {
|
|
22
|
+
const number = Number(token);
|
|
23
|
+
if (!Number.isInteger(number) || number < 1 || number > choiceCount)
|
|
24
|
+
return undefined;
|
|
25
|
+
selected.add(number - 1);
|
|
26
|
+
}
|
|
27
|
+
return [...selected].sort((left, right) => left - right);
|
|
28
|
+
}
|
|
29
|
+
export function resolveDefaultAgentChoice(input, choices, currentAgent) {
|
|
30
|
+
const value = input.trim();
|
|
31
|
+
if (!value) {
|
|
32
|
+
const currentIndex = choices.findIndex((choice) => choice.name === currentAgent);
|
|
33
|
+
return currentIndex >= 0 ? currentIndex : undefined;
|
|
34
|
+
}
|
|
35
|
+
const number = Number(value);
|
|
36
|
+
if (Number.isInteger(number) && number >= 1 && number <= choices.length)
|
|
37
|
+
return number - 1;
|
|
38
|
+
const exactIndex = choices.findIndex((choice) => choice.name === value);
|
|
39
|
+
if (exactIndex >= 0)
|
|
40
|
+
return exactIndex;
|
|
41
|
+
const folded = value.toLocaleLowerCase("en-US");
|
|
42
|
+
const matches = choices
|
|
43
|
+
.map((choice, index) => ({ choice, index }))
|
|
44
|
+
.filter(({ choice }) => choice.name.toLocaleLowerCase("en-US") === folded);
|
|
45
|
+
return matches.length === 1 ? matches[0]?.index : undefined;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=DefaultAgentSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultAgentSelection.js","sourceRoot":"","sources":["../../src/cli/DefaultAgentSelection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