@keyou007/agent-bot 0.1.12 → 0.1.13-alpha.1

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 (91) hide show
  1. package/.env.example +2 -2
  2. package/CHANGELOG.md +18 -0
  3. package/README.md +32 -13
  4. package/README.zh.md +32 -13
  5. package/config.example.yaml +0 -24
  6. package/dist/cli/AgentPrerequisites.js +262 -0
  7. package/dist/cli/AgentPrerequisites.js.map +1 -0
  8. package/dist/cli/DefaultAgentSelection.js +47 -0
  9. package/dist/cli/DefaultAgentSelection.js.map +1 -0
  10. package/dist/cli/Initializer.js +165 -2
  11. package/dist/cli/Initializer.js.map +1 -1
  12. package/dist/cli/ServerStarter.js +17 -2
  13. package/dist/cli/ServerStarter.js.map +1 -1
  14. package/dist/cli/controlProtocol.js.map +1 -1
  15. package/dist/cli/help.js +16 -6
  16. package/dist/cli/help.js.map +1 -1
  17. package/dist/cli.js +233 -4
  18. package/dist/cli.js.map +1 -1
  19. package/dist/codex/AppServerConnection.js +3 -3
  20. package/dist/codex/AppServerConnection.js.map +1 -1
  21. package/dist/codex/CodexProcessManager.js +4 -4
  22. package/dist/codex/CodexProcessManager.js.map +1 -1
  23. package/dist/codex/CodexRuntime.js +28 -16
  24. package/dist/codex/CodexRuntime.js.map +1 -1
  25. package/dist/commands/CommandRouter.js +5 -0
  26. package/dist/commands/CommandRouter.js.map +1 -1
  27. package/dist/config/FeishuUserOpenIdStore.js +76 -0
  28. package/dist/config/FeishuUserOpenIdStore.js.map +1 -0
  29. package/dist/config/loadConfig.js +3 -24
  30. package/dist/config/loadConfig.js.map +1 -1
  31. package/dist/console/ConsoleConnector.js +2 -2
  32. package/dist/console/ConsoleConnector.js.map +1 -1
  33. package/dist/feishu/CardRenderer.js +90 -30
  34. package/dist/feishu/CardRenderer.js.map +1 -1
  35. package/dist/index.js +104 -24
  36. package/dist/index.js.map +1 -1
  37. package/dist/presentation/turnGraph.js +36 -0
  38. package/dist/presentation/turnGraph.js.map +1 -0
  39. package/dist/proxy/ProxySessionController.js +321 -98
  40. package/dist/proxy/ProxySessionController.js.map +1 -1
  41. package/dist/runtime/AcpRuntimeAdapter.js +3 -2
  42. package/dist/runtime/AcpRuntimeAdapter.js.map +1 -1
  43. package/dist/startup/StartupNotifier.js +16 -7
  44. package/dist/startup/StartupNotifier.js.map +1 -1
  45. package/dist/startup/startFeishu.js +2 -2
  46. package/dist/startup/startFeishu.js.map +1 -1
  47. package/dist/state/StateStore.js +169 -0
  48. package/dist/state/StateStore.js.map +1 -1
  49. package/dist/state/migrations.js +21 -0
  50. package/dist/state/migrations.js.map +1 -1
  51. package/dist/supervision/SafeRestartNotifier.js +46 -3
  52. package/dist/supervision/SafeRestartNotifier.js.map +1 -1
  53. package/dist/supervision/SafeRestartScheduler.js +65 -6
  54. package/dist/supervision/SafeRestartScheduler.js.map +1 -1
  55. package/dist/supervision/replacementSupervisor.js +27 -2
  56. package/dist/supervision/replacementSupervisor.js.map +1 -1
  57. package/dist/supervisor.js +27 -2
  58. package/dist/supervisor.js.map +1 -1
  59. package/docs/technical-reference.md +42 -20
  60. package/docs/technical-reference.zh.md +42 -20
  61. package/npm-shrinkwrap.json +2 -2
  62. package/package.json +7 -3
  63. package/skills/agent-bot/SKILL.md +21 -9
  64. package/src/cli/AgentPrerequisites.ts +377 -0
  65. package/src/cli/DefaultAgentSelection.ts +56 -0
  66. package/src/cli/Initializer.ts +204 -3
  67. package/src/cli/ServerStarter.ts +25 -2
  68. package/src/cli/controlProtocol.ts +6 -1
  69. package/src/cli/help.ts +16 -6
  70. package/src/cli.ts +350 -5
  71. package/src/codex/AppServerConnection.ts +3 -3
  72. package/src/codex/CodexProcessManager.ts +4 -4
  73. package/src/codex/CodexRuntime.ts +38 -18
  74. package/src/commands/CommandRouter.ts +4 -0
  75. package/src/commands/commandTypes.ts +1 -0
  76. package/src/config/FeishuUserOpenIdStore.ts +81 -0
  77. package/src/config/loadConfig.ts +3 -24
  78. package/src/console/ConsoleConnector.ts +2 -2
  79. package/src/feishu/CardRenderer.ts +117 -30
  80. package/src/index.ts +162 -22
  81. package/src/presentation/turnGraph.ts +48 -0
  82. package/src/proxy/ProxySessionController.ts +375 -107
  83. package/src/runtime/AcpRuntimeAdapter.ts +3 -1
  84. package/src/startup/StartupNotifier.ts +23 -7
  85. package/src/startup/startFeishu.ts +3 -2
  86. package/src/state/StateStore.ts +221 -0
  87. package/src/state/migrations.ts +21 -0
  88. package/src/supervision/SafeRestartNotifier.ts +53 -4
  89. package/src/supervision/SafeRestartScheduler.ts +78 -7
  90. package/src/supervision/replacementSupervisor.ts +27 -1
  91. package/src/supervisor.ts +33 -2
package/.env.example CHANGED
@@ -1,6 +1,6 @@
1
1
  # agentbot init fills these through Feishu one-click registration.
2
- # Leave them blank for console-only mode. When binding an existing app manually,
3
- # FEISHU_USER_OPEN_ID is the private-chat fallback for startup notifications.
2
+ # Leave them blank for console-only mode. For an existing app, the first direct
3
+ # message fills FEISHU_USER_OPEN_ID for startup notifications and CLI group invites.
4
4
  FEISHU_APP_ID=
5
5
  FEISHU_APP_SECRET=
6
6
  FEISHU_USER_OPEN_ID=
package/CHANGELOG.md CHANGED
@@ -6,6 +6,24 @@ The project follows [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.13-alpha.1] - 2026-08-03
10
+
11
+ - Route safe-restart status cards and restarting acknowledgements to every conversation that triggers the pending restart plus every conversation active during the previous minute, retaining each enrolled route until the restart completes while preserving Feishu topic replies; add `agentbot server restart --task <task>` and reject ambiguous CLI routing when multiple conversations are active.
12
+ - Send every startup card to all known private chats, non-topic groups active during the previous minute, and every group enrolled for the current safe restart; fold topic routes into their parent group instead of sending startup cards into topics.
13
+ - Replace the expanding `More` action in `/sessions` with in-place five-task pagination using `Previous` and `Next`, preserving search terms, task actions, and global numbering across pages.
14
+ - Add `Reset` actions to successfully completed progress cards and a paginated `/turns` history card with 10 completed turns per page. Persist each new turn's parent, backfill existing tasks from Reset audits, and render true branch lanes and merges across page boundaries instead of connecting turns merely because their completion times are adjacent. The card marks the current conversation point and moves that marker after a successful Reset while preserving the Agent Bot task and leaving local files unchanged. Completed turns after the selected Reset point remain visible because history snapshots are retained, and the success notice identifies the selected Prompt, completion time, and Turn ID.
15
+ - Recover a missing `FEISHU_USER_OPEN_ID` from the first valid private-chat message, persist it atomically without allowing group or later messages to replace it, and reload it correctly after Worker restarts.
16
+ - Schedule a safe restart after `agentbot init` when the selected Profile server is already running, ensuring upgraded code and refreshed configuration take effect without interrupting active work.
17
+
18
+ ## [0.1.13-alpha.0] - 2026-08-03
19
+
20
+ - 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.
21
+ - Keep the generated Agent list focused on Codex and TraeX while preserving existing custom Agents and user configuration during Profile upgrades.
22
+ - Generalize runtime messages, cards, help, documentation, and package metadata from Codex-specific wording to the selected App Server Agent.
23
+ - Recognize known TraeX code-mode tool-channel failures in completed responses and guide users to switch models with `/model`.
24
+ - Make Alpha the default release channel, with tested Alpha sequencing and explicit stable promotion commands.
25
+ - Publish Alpha packages under npm's `alpha` dist-tag and mark their GitHub releases as prereleases while preserving `latest` for stable versions.
26
+
9
27
  ## [0.1.12] - 2026-08-03
10
28
 
11
29
  - Add a ready-to-use TraeX App Server example to the checked-in and generated default configuration.
package/README.md CHANGED
@@ -4,16 +4,17 @@
4
4
 
5
5
  # Agent Bot
6
6
 
7
- Use local Codex and ACP agents directly from Feishu.
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 Codex environment. Send a message to start working; the bot updates a progress card while the agent runs and sends the final answer as Markdown.
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
+ - Reset the current conversation to any successfully completed progress card
17
18
  - Work with text, images, groups, and threads
18
19
  - Queue follow-up Prompts or add instructions while a task is running
19
20
  - Resume work after Agent Bot restarts
@@ -24,15 +25,20 @@ Agent Bot runs on your computer and connects a Feishu bot to your local Codex en
24
25
  ### Requirements
25
26
 
26
27
  - Node.js 22 or later
27
- - Codex CLI installed and available as `codex`
28
- - A completed local Codex login
28
+ - At least one supported App Server Agent: Codex or TraeX
29
+ - A completed local login for the Agent you intend to use
29
30
 
30
- Check the login:
31
+ Check the installed Agents and login state:
31
32
 
32
33
  ```powershell
34
+ codex --version
33
35
  codex login status
36
+ traex --version
37
+ traex login status
34
38
  ```
35
39
 
40
+ 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.
41
+
36
42
  ### Install
37
43
 
38
44
  ```powershell
@@ -41,6 +47,12 @@ agentbot --version
41
47
  agentbot --help
42
48
  ```
43
49
 
50
+ To try the current Alpha channel without replacing npm's stable `latest` tag:
51
+
52
+ ```powershell
53
+ npm install --global @keyou007/agent-bot@alpha
54
+ ```
55
+
44
56
  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
57
 
46
58
  ### Initialize
@@ -49,10 +61,14 @@ This installs `agentbot` as the primary command. The legacy `agent-bot` command
49
61
  agentbot init
50
62
  ```
51
63
 
52
- 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.
64
+ 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.
65
+
66
+ 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
67
 
54
68
  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
69
 
70
+ If an existing bot has an App ID and secret but no `FEISHU_USER_OPEN_ID`, Agent Bot fills it automatically from the first direct message sent to the bot. The value is stored in the Profile's `.env` and is never replaced by later messages. Group messages cannot claim this default user.
71
+
56
72
  The `im:message.group_msg` permission cannot be added through Feishu's one-click configuration. When it is missing, Agent Bot prints a QR code and a direct Developer Console link already filtered to that permission. Add it manually, publish the app version, and complete tenant approval if required. While Agent Bot waits for it to become active, enter `Y` to skip this permission and continue initialization; the final result warns that ordinary group messages which do not mention the bot will be unavailable.
57
73
 
58
74
  When optional permissions or subscriptions are missing, Agent Bot first shows their QR code and authorization link, then immediately waits up to five minutes for them to become active. The terminal offers only one choice: enter `Y` to skip optional authorization and continue. Otherwise, complete authorization in the browser while Agent Bot waits. Optional authorization failures or timeouts do not block startup, and Agent Bot reports which features may be unavailable.
@@ -66,7 +82,7 @@ When optional permissions or subscriptions are missing, Agent Bot first shows th
66
82
  | `--profile <directory>`| Use an isolated profile directory |
67
83
  | `--config <path>` | Use a specific configuration file |
68
84
 
69
- You can rerun `agentbot init` later to check or complete the bot configuration. If the server is already running, initialization leaves it running.
85
+ 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 schedules a safe restart so the current Agent Bot version and refreshed configuration take effect after active work finishes. In a non-interactive terminal, `init` cannot ask for a selection and keeps the already configured default Agent.
70
86
 
71
87
  To fully reconfigure a Profile, stop its server and select the Profile explicitly:
72
88
 
@@ -84,7 +100,7 @@ agentbot server status
84
100
 
85
101
  `agentbot init` starts the server automatically. If you stop it later, run `agentbot server start` to start it again. For local-only use, initialize with `--skip-feishu` and run `agentbot console` instead.
86
102
 
87
- The `Agent Bot 已启动` startup card shows the version of Agent Bot currently running.
103
+ The `Agent Bot 已启动` startup card shows the version currently running. It is sent to every known private chat, groups active in the previous minute, and every group enrolled for the current safe restart; topic routes receive it in their parent group.
88
104
 
89
105
  Open Feishu, find the bot, and send a message. Agent Bot automatically creates a task for a chat that does not have one yet.
90
106
 
@@ -124,7 +140,7 @@ agentbot server stop
124
140
  agentbot server restart
125
141
  ```
126
142
 
127
- `server restart` waits for current work to finish by default. Its status card includes a `Cancel` button while the restart is still waiting. Use `--immediate` only when interruption is acceptable.
143
+ `server restart` waits for current work to finish by default. Its status card includes a `Cancel` button while the restart is still waiting. Every conversation that triggers the pending restart and every conversation active during the previous minute receives the waiting status and restarting notice. Once included, a conversation stays in the notification set until that restart finishes. When restarting for a specific task, use `--task <task>` to add that task's Lark conversation. Use `--immediate` only when interruption is acceptable.
128
144
 
129
145
  On Windows, every Supervisor and Worker launch reloads the latest Machine and User environment variables. Restart the service after changing `PATH` or another system environment variable; the active Profile selection remains isolated.
130
146
 
@@ -164,6 +180,7 @@ Plain text continues the current task. Messages beginning with `/` are commands.
164
180
  | `/sessions [keyword]` | Browse available App Server tasks |
165
181
  | `/switch [task]` | Switch tasks or return to the previous task |
166
182
  | `/fork [task]` | Create and open a task branch |
183
+ | `/turns` | Browse historical turns and reset the conversation |
167
184
  | `/status [task]` | View task progress and results |
168
185
  | `/title <title>` | Rename the current task |
169
186
  | `/stop` | Stop the current execution |
@@ -183,11 +200,13 @@ Plain text continues the current task. Messages beginning with `/` are commands.
183
200
 
184
201
  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
202
 
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 from your Codex configuration.
203
+ `/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
204
 
188
205
  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
206
 
190
- The `/sessions` card provides `NewGroup` and `ForkGroup` actions for each task, so you can create a project-matched group or fork a selected task directly into a new group.
207
+ The `/sessions` card shows five tasks per page and uses `Previous` and `Next` to update the card in place. It provides `NewGroup` and `ForkGroup` actions for each task, so you can create a project-matched group or fork a selected task directly into a new group.
208
+
209
+ `/turns` opens the current task's completed-turn history, 10 turns per page. Each turn is an indented numbered node in a compact commit graph whose lanes follow the actual parent turns, including branches and merges created by Reset. The active conversation point is marked as `Current`; every other entry has a `Reset` action that restores the conversation context to that completed turn and moves the marker there without reverting local file changes. The success notice identifies the selected Prompt, completion time, and Turn ID. Turns completed after the selected point remain in the history, alongside turns later completed on the new branch. Reset is unavailable while the task is running.
191
210
 
192
211
  Inside a thread, `/forkgroup` forks from the thread's original turn until the thread task completes its own turn. After that, it forks from the thread task's latest completed turn. A currently running turn is never used as a fork point.
193
212
 
@@ -231,7 +250,7 @@ Alternative profiles are directory-based and are not registered by name. Each on
231
250
  - **The bot does not respond:** run `agentbot server status` and check `~/.agent-bot/logs/agent-bot.log`.
232
251
  - **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
252
  - **Feishu permissions are incomplete:** rerun `agentbot init` and follow the displayed authorization steps.
234
- - **Codex cannot start:** run `codex login status` as the same operating-system user that runs Agent Bot.
253
+ - **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
254
  - **You only need local testing:** run `agentbot init --skip-feishu`, then `agentbot console`.
236
255
  - **A safe restart keeps waiting:** inspect active tasks with `agentbot task list --status running`.
237
256
 
package/README.zh.md CHANGED
@@ -4,16 +4,17 @@
4
4
 
5
5
  # Agent Bot
6
6
 
7
- 通过飞书使用本机上的 Codex 和 ACP Agent。
7
+ 通过飞书使用本机上的 Codex、TraeX 和兼容 ACP 的 Agent。
8
8
 
9
9
  [English](README.md) | 简体中文
10
10
 
11
- Agent Bot 运行在你的电脑上,把飞书机器人连接到本机 Codex 环境。发送消息即可开始工作;执行过程中机器人会更新进度卡,完成后发送 Markdown 最终回答。
11
+ Agent Bot 运行在你的电脑上,把飞书机器人连接到本机编程 Agent。发送消息即可开始工作;执行过程中机器人会更新进度卡,完成后发送 Markdown 最终回答。
12
12
 
13
13
  ## 可以做什么
14
14
 
15
- - 在飞书中使用本机已有的 Codex 登录
15
+ - 在飞书中使用本机已有的 Codex 或 TraeX 登录
16
16
  - 创建、继续、切换、分支和停止任务
17
+ - 从任意成功完成的思考卡片重置当前对话
17
18
  - 使用文字、图片、群聊和话题协作
18
19
  - 排队后续 Prompt,或在任务运行中追加指令
19
20
  - Agent Bot 重启后继续已有工作
@@ -24,15 +25,20 @@ Agent Bot 运行在你的电脑上,把飞书机器人连接到本机 Codex 环
24
25
  ### 使用前提
25
26
 
26
27
  - Node.js 22 或更高版本
27
- - 已安装 Codex CLI,并可直接执行 `codex`
28
- - 已完成本机 Codex 登录
28
+ - 至少安装一个支持的 App Server Agent:Codex 或 TraeX
29
+ - 已完成准备使用的 Agent 的本机登录
29
30
 
30
- 确认登录状态:
31
+ 检查已安装的 Agent 和登录状态:
31
32
 
32
33
  ```powershell
34
+ codex --version
33
35
  codex login status
36
+ traex --version
37
+ traex login status
34
38
  ```
35
39
 
40
+ Codex 或 TraeX 中任意一个准备完成后即可继续初始化。`agentbot init` 会检查两者,并可帮助安装或升级。
41
+
36
42
  ### 安装
37
43
 
38
44
  ```powershell
@@ -41,6 +47,12 @@ agentbot --version
41
47
  agentbot --help
42
48
  ```
43
49
 
50
+ 如需试用当前 Alpha 通道,同时不影响 npm 的稳定版 `latest` 标签:
51
+
52
+ ```powershell
53
+ npm install --global @keyou007/agent-bot@alpha
54
+ ```
55
+
44
56
  该命令会把 `agentbot` 安装为主命令。旧的 `agent-bot` 命令暂时保留,运行时会显示弃用警告,并将在后续版本中移除。命令行帮助、状态、进度、交互提示和错误会根据系统语言显示中文或英文;其他未支持语言统一回退英文。JSON 输出不做本地化并保持字段稳定。从源码安装的方法见[技术参考](docs/technical-reference.zh.md#开发与源码安装)。
45
57
 
46
58
  ### 初始化
@@ -49,10 +61,14 @@ agentbot --help
49
61
  agentbot init
50
62
  ```
51
63
 
52
- 打开命令显示的链接或扫描二维码,完成飞书机器人创建和授权。初始化会准备 `~/.agent-bot`、保存机器人凭据和授权用户、检查所需权限,并自动启动 Agent Bot。
64
+ 初始化会检测 Codex 和 TraeX,并显示已安装的版本。未安装或版本较旧的 Agent 会汇总显示对应的安装或升级命令;输入一个或多个操作编号(用逗号分隔)、输入 `all`,或直接回车跳过维护。命令执行失败不会阻塞后续初始化。检查完成后,可输入编号或标准名选择默认 Agent;当前默认值仍可用时,直接回车即可确认。Agent Bot 会把选择保存到 `config.yaml` 的 `defaults.agent`,供后续新任务使用。
65
+
66
+ 然后打开命令显示的链接或扫描二维码,完成飞书机器人创建和授权。初始化会准备 `~/.agent-bot`、保存机器人凭据和授权用户、检查所需权限,并自动启动 Agent Bot。
53
67
 
54
68
  只有 App ID 和 App Secret 都已保存到本地才视为机器人创建成功。如果初始化在完整凭据保存前中断,再次运行 `agentbot init` 会创建新机器人;如果凭据已经保存,则会继续检查该机器人的远端权限和订阅。
55
69
 
70
+ 如果已有机器人保存了 App ID 和 App Secret,但缺少 `FEISHU_USER_OPEN_ID`,Agent Bot 会在用户第一次私聊机器人时自动补全。该值会写入对应 Profile 的 `.env`,后续消息不会覆盖它,群消息也不会认领这个默认用户。
71
+
56
72
  `im:message.group_msg` 无法通过飞书一键配置新增。缺少该权限时,Agent Bot 会显示二维码,以及已筛选该权限的开发者后台直达链接。请手动新增权限、发布应用版本,并在需要时完成租户管理员审批。Agent Bot 等待权限生效时,可输入 `Y` 跳过该权限并继续初始化;最终结果会提示机器人无法响应未 @ 它的普通群消息。
57
73
 
58
74
  缺少非核心权限或订阅时,Agent Bot 会先显示二维码和授权链接,然后立即等待最多 5 分钟使配置生效。终端只提供一个选项:输入 `Y` 跳过可选授权并继续;否则直接在浏览器中完成授权,Agent Bot 会持续等待。可选授权失败或超时不会阻止启动,Agent Bot 会提示可能无法使用的功能。
@@ -66,7 +82,7 @@ agentbot init
66
82
  | `--profile <目录>` | 使用指定目录中的独立 Profile |
67
83
  | `--config <路径>` | 使用指定配置文件 |
68
84
 
69
- 之后可以重新运行 `agentbot init` 检查或补齐机器人配置。如果 Server 已在运行,初始化会保留当前服务。
85
+ 升级 Agent Bot 后,可以重新运行 `agentbot init` 刷新 Profile。它会保留现有 `config.yaml` 和 `.env` 中的值,补齐当前版本新增的配置项和环境变量,允许确认或更换默认 Agent,并重新检查 Agent 与机器人配置。如果 Server 已在运行,初始化会安排安全重启,在活动任务完成后加载当前 Agent Bot 版本和更新后的配置。非交互式终端无法询问选择,此时会保留配置中已有的默认 Agent。
70
86
 
71
87
  如需完整重新配置一个 Profile,请先停止它的 Server,并显式指定 Profile:
72
88
 
@@ -84,7 +100,7 @@ agentbot server status
84
100
 
85
101
  `agentbot init` 会自动启动 Server。之后如果手动停止了服务,可执行 `agentbot server start` 再次启动。仅在本地使用时,请通过 `--skip-feishu` 初始化并运行 `agentbot console`。
86
102
 
87
- `Agent Bot 已启动` 启动卡片会显示当前正在运行的 Agent Bot 版本。
103
+ `Agent Bot 已启动` 启动卡片会显示当前正在运行的 Agent Bot 版本。每次都会发送到所有已知私聊、最近 1 分钟活跃的普通群,以及所有已加入本次安全重启通知范围的群;话题路由会折算到话题所属群的主会话。
88
104
 
89
105
  打开飞书,找到机器人并发送消息。当前会话没有任务时,Agent Bot 会自动创建。
90
106
 
@@ -124,7 +140,7 @@ agentbot server stop
124
140
  agentbot server restart
125
141
  ```
126
142
 
127
- `server restart` 默认等待当前工作完成后再重启;等待期间可通过状态卡片下方的 `Cancel` 按钮取消。只有可接受中断时才使用 `--immediate`。
143
+ `server restart` 默认等待当前工作完成后再重启;等待期间可通过状态卡片下方的 `Cancel` 按钮取消。所有触发同一待执行安全重启的会话,以及最近 1 分钟内活跃的所有会话,都会收到等待状态和开始重启提示;会话一旦加入通知范围,就会保留到本次重启完成。为指定任务安排重启时,请使用 `--task <任务>`,将该任务所在的飞书会话加入通知范围。只有可接受中断时才使用 `--immediate`。
128
144
 
129
145
  Windows 下每次启动 Supervisor 或 Worker 都会重新读取最新的系统和用户环境变量。修改 `PATH` 或其他系统环境变量后重启服务即可生效,当前 Profile 选择仍保持隔离。
130
146
 
@@ -164,6 +180,7 @@ agentbot task stop <任务>
164
180
  | `/sessions [关键词]` | 浏览可用的 App Server 任务 |
165
181
  | `/switch [任务]` | 切换任务,或返回上一个任务 |
166
182
  | `/fork [任务]` | 创建并打开任务分支 |
183
+ | `/turns` | 浏览历史对话轮次并重置对话 |
167
184
  | `/status [任务]` | 查看任务进度和结果 |
168
185
  | `/title <标题>` | 修改当前任务标题 |
169
186
  | `/stop` | 停止当前执行 |
@@ -183,11 +200,13 @@ agentbot task stop <任务>
183
200
 
184
201
  斜杠命令支持任意唯一前缀,复合命令还支持首字母缩写:`/sess` 等同于 `/sessions`,`/fg` 等同于 `/forkgroup`,`/ng` 等同于 `/newgroup`,`/ns` 等同于 `/nosteer`。完整命令名优先;`/s`、`/f` 等匹配多个命令的前缀会被拒绝,并列出全部候选命令。
185
202
 
186
- `/agent`、`/provider`、`/model`、`/thinking` 和 `/permissions` 在存在可选项时使用同一张运行设置卡片。配置了多个 Agent 时,卡片会增加 Agent tab,用于选择后续新任务使用的默认 Agent;即使当前聊天还没有任务,`/agent` 也能打开该 tab。只配置一个 Agent 时,`/agent` 直接显示当前 Agent,不打开卡片。现有任务仍保持原来的 Agent,使用不同 Agent 的任务可以相互独立地运行。`/agent <名称>` 继续支持直接选择。没有可切换的 Provider 时,`/provider` 同样只显示当前 Provider。其余四个命令激活各自对应的 tab,且不接受参数。没有可继承设置的新任务使用 Codex 配置中的默认 Provider。
203
+ `/agent`、`/provider`、`/model`、`/thinking` 和 `/permissions` 在存在可选项时使用同一张运行设置卡片。配置了多个 Agent 时,卡片会增加 Agent tab,用于选择后续新任务使用的默认 Agent;即使当前聊天还没有任务,`/agent` 也能打开该 tab。只配置一个 Agent 时,`/agent` 直接显示当前 Agent,不打开卡片。现有任务仍保持原来的 Agent,使用不同 Agent 的任务可以相互独立地运行。`/agent <名称>` 继续支持直接选择。没有可切换的 Provider 时,`/provider` 同样只显示当前 Provider。其余四个命令激活各自对应的 tab,且不接受参数。没有可继承设置的新任务使用所选 Agent 的默认 Provider。
187
204
 
188
205
  私聊、群正文和话题分别维护当前任务。可以单独发送图片,也可以同时发送文字和图片。任务运行中发送普通文字会追加指令;需要确保形成后续 turn 时使用 `/queue`(或 `/nosteer`)。
189
206
 
190
- `/sessions` 卡片为每个任务提供 `NewGroup` 和 `ForkGroup` 操作,可直接按所选任务创建同项目的新群,或把所选任务 Fork 到新群。
207
+ `/sessions` 卡片每页显示 5 个任务,通过 `Previous` 和 `Next` 原地翻页。每个任务都提供 `NewGroup` 和 `ForkGroup` 操作,可直接按所选任务创建同项目的新群,或把所选任务 Fork 到新群。
208
+
209
+ `/turns` 会打开当前任务的已完成轮次列表,每页显示 10 个 turn。每条 turn 使用独立的序号节点和缩进内容;图谱 lane 按真实父轮次绘制 Reset 产生的分支与合并,并跨分页保持连续,不再按完成时间相邻关系直接连线。当前对话位置标记为“当前”,其余记录后的 `Reset` 按钮会把对话上下文恢复到该轮完成时并将标记移动到这里,但不会回退本地文件。成功提示会显示目标轮次的 Prompt 摘要、完成时间和 Turn ID。所选位置之后原本已经完成的轮次仍会保留在历史列表中,Reset 后新分支产生的轮次也会显示;任务执行期间不能 Reset。
191
210
 
192
211
  在话题中使用 `/forkgroup` 时,如果话题任务还没有完成过自己的 turn,则从话题原始 turn fork;完成过后则从话题任务最近完成的 turn fork。正在执行的 turn 不会作为 fork 点。
193
212
 
@@ -231,7 +250,7 @@ agentbot --profile ~/.agent-bot-rescue server status
231
250
  - **机器人没有响应:** 运行 `agentbot server status`,并查看 `~/.agent-bot/logs/agent-bot.log`
232
251
  - **Node 崩溃后 Worker 被自动重启:** 查看 `~/.agent-bot/data/last-crash.json`、`~/.agent-bot/logs/worker.stderr.log` 和 `~/.agent-bot/data/crash-reports/`
233
252
  - **飞书权限不完整:** 重新运行 `agentbot init`,完成显示的授权步骤
234
- - **Codex 无法启动:** 使用运行 Agent Bot 的同一操作系统用户执行 `codex login status`
253
+ - **Agent 无法启动:** 使用运行 Agent Bot 的同一操作系统用户执行 `codex login status` 或 `traex login status`,然后重新运行 `agentbot init` 检查版本
235
254
  - **只需要本地测试:** 运行 `agentbot init --skip-feishu`,然后执行 `agentbot console`
236
255
  - **安全重启一直等待:** 使用 `agentbot task list --status running` 检查活动任务
237
256
 
@@ -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;IAE3C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IACtD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,eAAe,CAAC;IAC3C,OAAO,EAAE,KAAK,OAAO;QACnB,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC;QAClC,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,EA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