@keyou007/agent-bot 0.1.13-alpha.2 → 0.1.13-alpha.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SafeRestartNotifier.js","sourceRoot":"","sources":["../../src/supervision/SafeRestartNotifier.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,MAAM,6BAA6B,GAAG,KAAK,CAAC;AAM5C,MAAM,OAAO,mBAAmB;IAWX,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IAdT,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,mBAAmB,GAAG,IAAI,GAAG,EAAqC,CAAC;IAC5E,gBAAgB,CAAU;IAC1B,kBAAkB,CAAU;IAC5B,oBAAoB,CAAqB;IACzC,gBAAgB,CAAkB;IAClC,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAElC,YACmB,KAAiB,EACjB,QAAwB,EACxB,QAAsB,EACtB,MAA4B,EAC5B,OAAO,GAA+B,EAAE;qBAJxC,KAAK;wBACL,QAAQ;wBACR,QAAQ;sBACR,MAAM;uBACN,OAAO;IACvB,CAAC;IAEJ,MAAM,CAAC,MAAyB;QAC9B,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,IAAI,MAAM,CAAC,UAAU,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1F,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW;gBAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC7D,CAAC;QACD,IAAI,IAAI,CAAC,gBAAgB,KAAK,SAAS,IAAI,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACrF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CA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AAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC1D,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,cAAc,IAAI,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;gBACrE,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,UAAU,EAAE;oBACvC,UAAU;oBACV,GAAG,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC3F,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -60,7 +60,7 @@ Relative `storage.sqlitePath` and `logging.path` values resolve against the dire
60
60
 
61
61
  Early in initialization, `agentbot init` checks the supported Codex and TraeX CLIs in parallel and reports each installed version. Codex is compared with the latest stable `@openai/codex` package, while TraeX is compared with its Alpha channel. Missing or outdated Agents are gathered into one numbered list containing their exact install or upgrade commands. An interactive user can enter comma- or space-separated action numbers, `all`, or an empty answer to skip maintenance. Selected commands run sequentially with inherited stdio; skipped and failed actions are recorded and initialization continues. In a non-interactive terminal, commands are printed for manual use. With `--json`, progress and prompts use stderr and the final `agents` array records detection and assistance results. Codex upgrades first use `codex update` and fall back to the current npm package command when an older updater fails.
62
62
 
63
- After version and maintenance checks, an interactive `init` requires a default-Agent selection by number or standard name. Configured custom Agents remain selectable without a version check; Codex or TraeX is omitted while its CLI is missing. When the current default remains selectable, an empty answer confirms it. The selected standard name is written to `defaults.agent` through the same comment-preserving atomic YAML update used for configuration upgrades. A non-interactive invocation retains an existing valid configured default because it cannot prompt, and fails when no valid default exists. The JSON result reports this as `defaultAgent.name` and `defaultAgent.status` (`selected` or `existing`).
63
+ After version and maintenance checks, a first fresh interactive `init` and every explicit `--reset` build the Profile's Agent configuration from the supported Agents that were actually detected with an installed version. Missing Codex or TraeX entries are not selectable. When multiple Agents are available, the user may select one or more by number or standard name; `all` or an empty answer selects all. Unselected Agent definitions are removed from the new configuration through a comment-preserving atomic YAML update. One selected Agent becomes the default automatically. When multiple Agents are selected, a second prompt chooses `defaults.agent` by number or standard name. Later upgrades and refreshes preserve both the configured Agent list and default without showing either selector, including custom Agents already present in the Profile. A non-interactive first initialization or reset configures every detected installed Agent and keeps the template default when selected, otherwise the first detected Agent. An existing Profile without a valid configured default fails with an instruction to set `defaults.agent` in `config.yaml`. JSON output reports the final names in `configuredAgents`, adds `configured` to each supported-Agent inspection, and returns `defaultAgent.name` plus `defaultAgent.status` (`selected` or `existing`).
64
64
 
65
65
  `agentbot init` copies the packaged `config.example.yaml` and `.env.example` when their target files do not exist, creates the data and log directories, and restricts `.env` permissions where the platform supports POSIX modes.
66
66
 
@@ -103,6 +103,8 @@ The generated authorization links do not contain the app secret.
103
103
 
104
104
  After Feishu initialization succeeds, the CLI releases the initialization lock and starts the detached supervisor through the same readiness path as `agentbot server start`. It waits up to 45 seconds for the worker to connect to Feishu and become ready. If the selected profile is already running, no second supervisor is created; instead, initialization requests a safe restart so the current installed code and refreshed configuration are loaded after active work and final delivery finish. The JSON result reports this as `server.status: "restart-scheduled"`. `--skip-feishu` skips automatic server startup, and `--json` includes the resulting `server.status` without adding non-JSON output.
105
105
 
106
+ After the Server starts or a safe restart is successfully scheduled, `init` sends a Card 2.0 welcome card directly to `feishu.userOpenId`. The card uploads the packaged `assets/agent-bot-logo.png`, is always rendered in Chinese regardless of the CLI locale, and reports the installed version, default Agent, and configured Agents. When a safe restart is pending, the card says that the refreshed version takes effect after that restart instead of claiming it is already active. A Profile receipt at `<profile>/data/initialization.json` records the last successfully initialized package version so the card can distinguish first setup, version upgrade, and same-version refresh. Welcome delivery is reported in the JSON `welcome` object. A missing user Open ID or delivery failure produces an explicit warning without undoing completed configuration or stopping an already-ready Server; `--skip-feishu` records a skipped welcome.
107
+
106
108
  ## Feishu App Requirements
107
109
 
108
110
  Core configuration required for basic messaging:
@@ -172,7 +174,7 @@ logging:
172
174
 
173
175
  `feishu.respondToAllGroupMessages` defaults to `true`. Set it to `false` to ignore group messages unless they mention the current bot. The worker resolves the bot's Open ID at startup so mentioning another member does not trigger it. Private messages are always accepted. Initialization requests all-user group-message delivery regardless of this runtime option, allowing it to be changed later without another authorization.
174
176
 
175
- `agentbot server start` requires both Feishu credentials. The worker starts the SDK's persistent connection without inspecting SDK logs or private connection state, then sends startup status cards as an outbound readiness check. Each startup card includes the Agent Bot version read from the installed package metadata. Every startup sends a card to every known private chat, regardless of recent activity, plus each non-topic group active during the minute before this Worker started. After a safe restart, it also sends to every group enrolled in that restart's notification set regardless of activity age. A topic route is normalized to its parent group, so topic contexts are never startup-card targets. If the database has no eligible chat yet, it sends the card to `feishu.userOpenId` using an `open_id` private message. When notification targets exist, at least one card must be delivered before the server reports ready; individual target failures remain isolated. If neither a known chat nor `feishu.userOpenId` is available, startup continues without the outbound check. The first subsequent private message can persist the missing user Open ID for later startup notifications and CLI-created groups. Missing credentials still fail startup with an initialization hint. `agentbot console` is the explicit local-only path and does not require Feishu credentials.
177
+ `agentbot server start` requires both Feishu credentials. The worker starts the SDK's persistent connection without inspecting SDK logs or private connection state, then sends startup status cards as an outbound readiness check. Each startup card includes the Agent Bot version read from the installed package metadata. Every startup sends a card to every known private chat, regardless of recent activity, plus each non-topic group active during the minute before this Worker started. After a safe restart, it also sends to every group enrolled in that restart's notification set regardless of activity age. A topic route is normalized to its parent group, so topic contexts are never startup-card targets. Safe-restart progress cards have a narrower audience: only conversations that explicitly requested the current restart receive and update them; recently active chats are not enrolled automatically. If the database has no eligible chat yet, it sends the startup card to `feishu.userOpenId` using an `open_id` private message. When startup notification targets exist, at least one card must be delivered before the server reports ready; individual target failures remain isolated. If neither a known chat nor `feishu.userOpenId` is available, startup continues without the outbound check. The first subsequent private message can persist the missing user Open ID for later startup notifications and CLI-created groups. Missing credentials still fail startup with an initialization hint. `agentbot console` is the explicit local-only path and does not require Feishu credentials.
176
178
 
177
179
  At least one agent must be configured. `defaults.agent` must name a configured agent.
178
180
 
@@ -60,7 +60,7 @@ CLI 通过 Node.js 国际化能力读取系统 Locale。以 `zh` 开头的 Local
60
60
 
61
61
  初始化开始阶段,`agentbot init` 会并行检查目前支持的 Codex 和 TraeX CLI,并显示各自已安装的版本。Codex 与最新稳定版 `@openai/codex` 比较,TraeX 与 Alpha 通道比较。未安装或版本较旧的 Agent 会汇总到一个编号列表,并显示准确的安装或升级命令。交互式用户可以输入用逗号或空格分隔的操作编号、输入 `all`,或直接回车跳过维护;所选命令按顺序执行并继承终端输入输出,跳过或失败的操作都会记录结果,初始化继续。非交互式终端只显示供手动执行的命令。使用 `--json` 时,进度与询问写入 stderr,最终 `agents` 数组记录检测和辅助执行结果。Codex 升级会先执行 `codex update`,旧版 updater 失败时回退到当前 npm 包安装命令。
62
62
 
63
- 版本与维护检查完成后,交互式 `init` 会要求用户输入编号或标准名选择默认 Agent。自定义 Agent 无需版本检测即可选择;Codex 或 TraeX CLI 仍缺失时,对应 Agent 不会进入候选列表。当前默认 Agent 仍可选择时,直接回车即可确认。所选标准名通过保留注释的 YAML 原子更新写入 `defaults.agent`。非交互式调用无法询问,因此保留已有且仍在配置中的默认 Agent;没有有效默认值时会失败并提示改用交互式终端。JSON 结果通过 `defaultAgent.name` 和 `defaultAgent.status`(`selected` 或 `existing`)报告选择状态。
63
+ 版本与维护检查完成后,第一次全新交互式 `init` 和每次显式 `--reset` 都会根据实际检测到安装版本的受支持 Agent 生成 Profile 的 Agent 配置;仍未安装的 Codex 或 TraeX 不会进入候选列表。检测到多个 Agent 时,用户可以通过编号或标准名选择一个或多个,输入 `all` 或直接回车选择全部。未选择的 Agent 定义会通过保留注释的 YAML 原子更新从新配置中移除。只选择一个 Agent 时自动将其设为默认值;选择多个时再显示一次默认 Agent 选择,可输入编号或标准名写入 `defaults.agent`。后续升级和同版本刷新直接保留已配置 Agent 列表与默认值,不再显示这两类选择器,已有自定义 Agent 也会保留。第一次非交互式初始化或 reset 会配置所有检测到且已安装的 Agent;模板默认值在所选列表中时继续使用,否则选择第一个检测结果。已有 Profile 没有有效默认值时会失败,并提示在 `config.yaml` 中设置 `defaults.agent`。JSON 输出通过 `configuredAgents` 报告最终列表,在每个受支持 Agent 的检测结果中增加 `configured`,并通过 `defaultAgent.name` 和 `defaultAgent.status`(`selected` 或 `existing`)报告默认值。
64
64
 
65
65
  目标文件不存在时,`agentbot init` 会复制随包提供的 `config.example.yaml` 和 `.env.example`,创建数据和日志目录,并在平台支持时把 `.env` 权限限制为 POSIX `0600`。
66
66
 
@@ -103,6 +103,8 @@ https://open.feishu.cn/app/<appId>/auth?q=im%3Amessage.group_msg&op_from=openapi
103
103
 
104
104
  飞书初始化成功后,CLI 会先释放初始化锁,再通过与 `agentbot server start` 相同的就绪检查流程启动后台 Supervisor,并等待最多 45 秒,直到 Worker 连接飞书并进入就绪状态。如果当前 Profile 的服务已经运行,不会创建第二个 Supervisor,而是安排安全重启,在活动任务和最终结果投递完成后加载当前安装的代码及更新后的配置;JSON 结果将其表示为 `server.status: "restart-scheduled"`。`--skip-feishu` 会跳过自动启动;`--json` 会把结果写入 `server.status`,不会混入非 JSON 文本。
105
105
 
106
+ Server 成功启动或安全重启成功安排后,`init` 会直接向 `feishu.userOpenId` 发送 Card 2.0 私聊欢迎卡。无论 CLI 使用什么系统语言,欢迎卡都固定显示中文;卡片会上传随包提供的 `assets/agent-bot-logo.png`,并显示当前安装版本、默认 Agent 和已配置 Agent。如果安全重启仍在等待,卡片会明确说明刷新后的版本将在重启完成后生效,而不会声称新版已经接管。`<profile>/data/initialization.json` 会记录上次成功初始化的包版本,用于区分首次初始化、版本升级和同版本配置刷新。JSON 输出通过 `welcome` 对象报告发送结果。缺少用户 Open ID 或卡片发送失败时会明确警告,但不会撤销已完成的配置,也不会停止已经就绪的 Server;`--skip-feishu` 会记录欢迎卡已跳过。
107
+
106
108
  ## 飞书应用要求
107
109
 
108
110
  基础消息能力依赖以下核心配置:
@@ -172,7 +174,7 @@ logging:
172
174
 
173
175
  `feishu.respondToAllGroupMessages` 默认为 `true`。设为 `false` 后,未 @ 当前机器人的群消息会被忽略;Worker 启动时会解析机器人的 Open ID,因此 @ 其他成员不会误触发。私聊始终正常处理。无论该运行时配置如何,初始化都会申请接收全部群消息的权限,之后切换配置无需再次授权。
174
176
 
175
- `agentbot server start` 要求同时配置飞书 `appId` 和 `appSecret`。Worker 启动 SDK 长连接时不读取 SDK 日志或私有连接状态,随后通过发送启动状态卡片检查出站能力。每张启动卡片都会显示从已安装包元数据读取的 Agent Bot 版本。每次启动都会向所有已知私聊发送卡片,不受最近活跃时间影响;同时向本次 Worker 启动前 1 分钟内活跃的非话题群聊发送卡片。安全重启后,还会向所有已加入本次重启通知范围的群发送,不受活跃时间限制;话题路由会折算为所属普通群,因此话题会话永远不会成为启动卡目标。数据库里尚无符合条件的会话时,改用 `feishu.userOpenId`,按 `open_id` 私聊发送。存在通知目标时,至少一张卡片发送成功后 Server 才报告就绪,单个目标发送失败仍相互隔离。如果既没有已知会话,也没有 `feishu.userOpenId`,启动会跳过出站检查并继续;之后收到的第一条私聊消息可以补全用户 Open ID,供后续启动通知和 CLI 建群使用。缺少凭据时仍会启动失败并提示先初始化。`agentbot console` 是明确的纯本地入口,不需要飞书凭据。
177
+ `agentbot server start` 要求同时配置飞书 `appId` 和 `appSecret`。Worker 启动 SDK 长连接时不读取 SDK 日志或私有连接状态,随后通过发送启动状态卡片检查出站能力。每张启动卡片都会显示从已安装包元数据读取的 Agent Bot 版本。每次启动都会向所有已知私聊发送卡片,不受最近活跃时间影响;同时向本次 Worker 启动前 1 分钟内活跃的非话题群聊发送卡片。安全重启后,还会向所有已加入本次重启通知范围的群发送,不受活跃时间限制;话题路由会折算为所属普通群,因此话题会话永远不会成为启动卡目标。安全重启进度卡的范围更窄:只有明确触发本次安全重启的会话会收到并持续更新,最近活跃会话不会被自动加入。数据库里尚无符合条件的会话时,启动卡改用 `feishu.userOpenId`,按 `open_id` 私聊发送。存在启动通知目标时,至少一张卡片发送成功后 Server 才报告就绪,单个目标发送失败仍相互隔离。如果既没有已知会话,也没有 `feishu.userOpenId`,启动会跳过出站检查并继续;之后收到的第一条私聊消息可以补全用户 Open ID,供后续启动通知和 CLI 建群使用。缺少凭据时仍会启动失败并提示先初始化。`agentbot console` 是明确的纯本地入口,不需要飞书凭据。
176
178
 
177
179
  必须至少配置一个 Agent,`defaults.agent` 必须指向已配置的 Agent。
178
180
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@keyou007/agent-bot",
3
- "version": "0.1.13-alpha.2",
3
+ "version": "0.1.13-alpha.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@keyou007/agent-bot",
9
- "version": "0.1.13-alpha.2",
9
+ "version": "0.1.13-alpha.4",
10
10
  "license": "GPL-3.0-only",
11
11
  "dependencies": {
12
12
  "@agentclientprotocol/sdk": "1.2.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyou007/agent-bot",
3
- "version": "0.1.13-alpha.2",
3
+ "version": "0.1.13-alpha.4",
4
4
  "type": "module",
5
5
  "description": "Use Codex, TraeX, and compatible coding agents from Lark/Feishu.",
6
6
  "license": "GPL-3.0-only",
@@ -61,7 +61,7 @@ agentbot init
61
61
 
62
62
  Initialization detects the supported Codex and TraeX CLIs and reports each installed version. Missing or outdated Agents are presented in one numbered maintenance list with their exact commands. In an interactive terminal, the user may enter comma-separated action numbers, `all`, or press Enter to skip maintenance. A failed maintenance command or the absence of an interactive terminal does not block the remaining initialization. Do not select maintenance actions on the user's behalf without permission. Agent Bot uses the latest stable Codex release and the TraeX Alpha channel for these checks.
63
63
 
64
- After the maintenance choice, interactive initialization requires the user to select the default Agent by number or standard name. It lists configured custom Agents and installed supported Agents, omits Codex or TraeX when that CLI is still missing, and writes the selected standard name to `defaults.agent` in `config.yaml`. If the current default remains available, an empty answer explicitly confirms it. Always relay the choices and let the user decide. A non-interactive invocation keeps an already configured default; it fails with an instruction to rerun interactively when no valid default exists. With `--json`, read the result from `defaultAgent.name` and `defaultAgent.status`.
64
+ After the maintenance choice, a first fresh interactive initialization and every explicit `--reset` ask which detected installed Agents to configure. Missing supported Agents are omitted. The user may select one or more by number or standard name; `all` or an empty answer selects all. Relay the choices and let the user decide. Agent Bot removes unselected Agent definitions from the newly generated Profile. One selected Agent becomes the default automatically; multiple selected Agents produce a second number-or-name prompt for `defaults.agent`. Later upgrades and refreshes preserve the existing Agent list and default without either prompt, including custom configured Agents. A non-interactive first initialization or reset configures all detected installed Agents and chooses the template default when available, otherwise the first detected Agent. With `--json`, read the final list from `configuredAgents`, each supported inspection's `configured` flag, and `defaultAgent.name` plus `defaultAgent.status`.
65
65
 
66
66
  Initialization creates the Agent Bot home, `config.yaml`, `.env`, `data/`, and `logs/` from the bundled examples. If Feishu credentials are absent, it starts Feishu one-click app registration, prints a QR code followed by its authorization URL, waits for the user to approve the request, and stores the returned app ID and secret in `.env`. It then audits the app's currently published tenant permissions, event subscriptions, and callbacks. Core and optional missing items produce separate configuration challenges. Core configuration is polled until ready, except that the manually configured all-group-message permission may be explicitly skipped with `Y`. For optional configuration, the CLI prints the QR code followed by the authorization URL and immediately waits up to five minutes for activation. The only terminal choice is also `Y`, which skips optional authorization and continues initialization.
67
67
 
@@ -12,14 +12,31 @@ export function selectableDefaultAgents(
12
12
  const supported = new Map(inspections.map((inspection) => [inspection.id, inspection]));
13
13
  return configured.flatMap((agent) => {
14
14
  const inspection = supported.get(agent.name as SupportedAgentInspection["id"]);
15
- if (inspection && !inspection.installedVersion) return [];
15
+ if (!inspection?.installedVersion) return [];
16
16
  return [{
17
17
  ...agent,
18
- ...(inspection?.installedVersion ? { installedVersion: inspection.installedVersion } : {}),
18
+ installedVersion: inspection.installedVersion,
19
19
  }];
20
20
  });
21
21
  }
22
22
 
23
+ export function resolveAgentConfigurationChoices(
24
+ input: string,
25
+ choices: SelectableDefaultAgent[],
26
+ ): number[] | undefined {
27
+ const value = input.trim();
28
+ if (!value || /^(?:a|all)$/iu.test(value)) {
29
+ return choices.map((_choice, index) => index);
30
+ }
31
+ const selected = new Set<number>();
32
+ for (const token of value.split(/[,,\s]+/u).filter(Boolean)) {
33
+ const index = resolveDefaultAgentChoice(token, choices);
34
+ if (index === undefined) return undefined;
35
+ selected.add(index);
36
+ }
37
+ return selected.size > 0 ? [...selected].sort((left, right) => left - right) : undefined;
38
+ }
39
+
23
40
  export function parseMaintenanceSelection(input: string, choiceCount: number): number[] | undefined {
24
41
  const value = input.trim();
25
42
  if (!value) return [];
@@ -0,0 +1,135 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import pino from "pino";
5
+ import { loadConfig } from "../config/loadConfig.js";
6
+ import type { AppConfig } from "../config/schema.js";
7
+ import {
8
+ CardRenderer,
9
+ type InitializationWelcomeFeature,
10
+ type InitializationWelcomeKind,
11
+ } from "../feishu/CardRenderer.js";
12
+ import { FeishuMessageClient } from "../feishu/FeishuMessageClient.js";
13
+
14
+ export interface InitializationReceipt {
15
+ version: string;
16
+ initializedAt: string;
17
+ }
18
+
19
+ export type InitializationWelcomeResult =
20
+ | { status: "sent"; kind: InitializationWelcomeKind }
21
+ | { status: "skipped"; kind: InitializationWelcomeKind; reason: "feishu-skipped" | "missing-user-open-id" }
22
+ | { status: "failed"; kind: InitializationWelcomeKind; message: string };
23
+
24
+ export interface SendInitializationWelcomeInput {
25
+ configPath?: string;
26
+ version: string;
27
+ previousVersion?: string;
28
+ kind: InitializationWelcomeKind;
29
+ activationPending?: boolean;
30
+ }
31
+
32
+ export interface InitializationWelcomeDependencies {
33
+ loadConfig(configPath?: string): AppConfig;
34
+ sendCard(config: AppConfig, contextKey: string, card: Record<string, unknown>): Promise<void>;
35
+ logoPath: string;
36
+ }
37
+
38
+ const INITIALIZATION_RECEIPT_FILE = "initialization.json";
39
+ const DEFAULT_LOGO_PATH = fileURLToPath(new URL("../../assets/agent-bot-logo.png", import.meta.url));
40
+
41
+ export function resolveInitializationWelcomeKind(input: {
42
+ firstInitialization: boolean;
43
+ previousVersion?: string;
44
+ currentVersion: string;
45
+ }): InitializationWelcomeKind {
46
+ if (input.firstInitialization) return "first";
47
+ return input.previousVersion === input.currentVersion ? "refresh" : "upgrade";
48
+ }
49
+
50
+ export function readInitializationReceipt(homePath: string): InitializationReceipt | undefined {
51
+ try {
52
+ const value = JSON.parse(fs.readFileSync(initializationReceiptPath(homePath), "utf8")) as Partial<InitializationReceipt>;
53
+ if (typeof value.version !== "string" || !value.version.trim()) return undefined;
54
+ if (typeof value.initializedAt !== "string" || !value.initializedAt.trim()) return undefined;
55
+ return { version: value.version.trim(), initializedAt: value.initializedAt.trim() };
56
+ } catch {
57
+ return undefined;
58
+ }
59
+ }
60
+
61
+ export function writeInitializationReceipt(homePath: string, version: string, initializedAt = new Date()): void {
62
+ const filePath = initializationReceiptPath(homePath);
63
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
64
+ fs.writeFileSync(filePath, `${JSON.stringify({
65
+ version,
66
+ initializedAt: initializedAt.toISOString(),
67
+ }, null, 2)}\n`, { mode: 0o600 });
68
+ }
69
+
70
+ export async function sendInitializationWelcome(
71
+ input: SendInitializationWelcomeInput,
72
+ dependencies: InitializationWelcomeDependencies = defaultDependencies,
73
+ ): Promise<Exclude<InitializationWelcomeResult, { status: "failed" }>> {
74
+ const config = dependencies.loadConfig(input.configPath);
75
+ const userOpenId = config.feishu.userOpenId?.trim();
76
+ if (!userOpenId) {
77
+ return { status: "skipped", kind: input.kind, reason: "missing-user-open-id" };
78
+ }
79
+ const defaultAgentName = config.defaults.agent!;
80
+ const defaultAgent = config.agents[defaultAgentName]!;
81
+ const renderer = new CardRenderer();
82
+ const card = renderer.renderInitializationWelcome({
83
+ kind: input.kind,
84
+ version: input.version,
85
+ previousVersion: input.previousVersion,
86
+ activationPending: input.activationPending,
87
+ defaultAgentName,
88
+ defaultAgentTitle: defaultAgent.title,
89
+ availableAgents: Object.values(config.agents).map((agent) => agent.title),
90
+ logoPath: dependencies.logoPath,
91
+ features: welcomeFeatures(input.kind),
92
+ });
93
+ await dependencies.sendCard(config, `open_id:${userOpenId}`, card);
94
+ return { status: "sent", kind: input.kind };
95
+ }
96
+
97
+ function initializationReceiptPath(homePath: string): string {
98
+ return path.join(homePath, "data", INITIALIZATION_RECEIPT_FILE);
99
+ }
100
+
101
+ function welcomeFeatures(
102
+ kind: InitializationWelcomeKind,
103
+ ): InitializationWelcomeFeature[] {
104
+ if (kind === "upgrade") {
105
+ return [
106
+ { icon: "⚙️", title: "Agent 状态更透明", description: "Server 状态会显示每个 Agent 的 PID 与版本。" },
107
+ { icon: "🧭", title: "快速定位当前任务", description: "CLI 可识别正在调用它的 Codex 或 TraeX 任务。" },
108
+ { icon: "🗂️", title: "卡片操作更顺手", description: "Help 命令可点击,Sessions 翻页与操作更清晰。" },
109
+ { icon: "🛡️", title: "Crash 恢复更完整", description: "服务重启后会修复历史 Turn 的父子连接。" },
110
+ ];
111
+ }
112
+ if (kind === "refresh") {
113
+ return [
114
+ { icon: "💬", title: "随时开始对话", description: "私聊或群聊发送消息,即可继续当前任务。" },
115
+ { icon: "🧠", title: "统一运行设置", description: "在同一张卡片中切换 Agent、模型、思考和权限。" },
116
+ { icon: "🌿", title: "任务分支", description: "使用 New Group 或 Fork Group 并行处理工作。" },
117
+ { icon: "🔄", title: "安全恢复", description: "任务、进度与服务状态会持久保存并恢复。" },
118
+ ];
119
+ }
120
+ return [
121
+ { icon: "💬", title: "飞书直接对话", description: "私聊、群聊和话题分别维护自己的任务上下文。" },
122
+ { icon: "🤖", title: "连接本地 Agent", description: "目前支持 Codex、TraeX 和兼容的编程 Agent。" },
123
+ { icon: "🌿", title: "新建与分支", description: "把新任务或对话分支放进独立群聊并行推进。" },
124
+ { icon: "📍", title: "进度始终可见", description: "通过思考卡片查看工具调用、文件变更和最终结果。" },
125
+ ];
126
+ }
127
+
128
+ const defaultDependencies: InitializationWelcomeDependencies = {
129
+ loadConfig,
130
+ logoPath: DEFAULT_LOGO_PATH,
131
+ sendCard: async (config, contextKey, card) => {
132
+ const logger = pino({ level: "silent" });
133
+ await new FeishuMessageClient(config, logger).sendInteractiveCard(contextKey, card);
134
+ },
135
+ };
@@ -39,6 +39,10 @@ export interface InitializationOptions {
39
39
  reset?: boolean;
40
40
  }
41
41
 
42
+ export function shouldConfigureAgentsDuringInitialization(status: InitializationStatus): boolean {
43
+ return status === "created" || status === "reset";
44
+ }
45
+
42
46
  export interface ConfiguredAgentOption {
43
47
  name: string;
44
48
  title: string;
@@ -171,6 +175,69 @@ export function writeDefaultAgent(configPath: string, agentName: string): boolea
171
175
  return true;
172
176
  }
173
177
 
178
+ export function writeConfiguredAgentSelection(
179
+ configPath: string,
180
+ agentNames: string[],
181
+ defaultAgent: string,
182
+ ): boolean {
183
+ const selected = new Set(agentNames.map((name) => name.trim()).filter(Boolean));
184
+ if (selected.size === 0) {
185
+ throw new Error(cliText(
186
+ "At least one Agent must be configured.",
187
+ "必须至少配置一个 Agent。",
188
+ ));
189
+ }
190
+ if (!selected.has(defaultAgent)) {
191
+ throw new Error(cliText(
192
+ `Default Agent must be included in the configured Agents: ${defaultAgent}`,
193
+ `默认 Agent 必须包含在已配置 Agent 中:${defaultAgent}`,
194
+ ));
195
+ }
196
+
197
+ const original = fs.readFileSync(configPath, "utf8");
198
+ const document = parseConfigurationDocument(original, configPath);
199
+ if (!isMap(document.contents)) {
200
+ throw new Error(cliText(
201
+ `Configuration file must contain a YAML mapping: ${configPath}`,
202
+ `配置文件必须包含 YAML 映射:${configPath}`,
203
+ ));
204
+ }
205
+ const configuredAgents = document.contents.get("agents", true);
206
+ if (!isMap(configuredAgents)) {
207
+ throw new Error(cliText(
208
+ `Configuration file must contain an agents mapping: ${configPath}`,
209
+ `配置文件必须包含 agents 映射:${configPath}`,
210
+ ));
211
+ }
212
+ for (const agentName of selected) {
213
+ if (!configuredAgents.has(agentName)) {
214
+ throw new Error(cliText(
215
+ `Cannot configure an Agent that is not defined: ${agentName}`,
216
+ `不能配置尚未定义的 Agent:${agentName}`,
217
+ ));
218
+ }
219
+ }
220
+ for (const pair of [...configuredAgents.items]) {
221
+ const name = yamlMappingKey(pair.key);
222
+ if (name && !selected.has(name)) configuredAgents.delete(name);
223
+ }
224
+
225
+ const defaults = document.contents.get("defaults", true);
226
+ if (defaults !== undefined && !isMap(defaults)) {
227
+ throw new Error(cliText(
228
+ `Configuration defaults must contain a YAML mapping: ${configPath}`,
229
+ `配置文件的 defaults 必须是 YAML 映射:${configPath}`,
230
+ ));
231
+ }
232
+ if (isMap(defaults)) defaults.set("agent", defaultAgent);
233
+ else document.setIn(["defaults"], { agent: defaultAgent });
234
+
235
+ const updated = document.toString();
236
+ if (updated === original) return false;
237
+ writeFileAtomically(configPath, updated);
238
+ return true;
239
+ }
240
+
174
241
  export function readFeishuCredentials(envPath: string, env: NodeJS.ProcessEnv = process.env): FeishuCredentialState {
175
242
  const fileValues = fs.existsSync(envPath) ? parseDotEnv(fs.readFileSync(envPath, "utf8")) : {};
176
243
  const appId = firstNonBlank(env.FEISHU_APP_ID, fileValues.FEISHU_APP_ID);
package/src/cli/help.ts CHANGED
@@ -9,7 +9,7 @@ export function renderCliHelp(version: string, language: CliLanguage = cliLangua
9
9
  agentbot [选项] <命令>
10
10
 
11
11
  常用命令:
12
- init 检查并选择 Agent,初始化飞书应用和服务
12
+ init 检查并配置 Agent,初始化飞书应用和服务
13
13
  init --reset 重置并重新配置显式指定的 Profile
14
14
  console 打开本地控制台
15
15
  server start 在后台启动 Agent Bot
@@ -63,7 +63,7 @@ Usage:
63
63
  agentbot [options] <command>
64
64
 
65
65
  Common commands:
66
- init Check and select an Agent; initialize the Lark app and service
66
+ init Check and configure Agents; initialize the Lark app and service
67
67
  init --reset Reset and reconfigure an explicit profile
68
68
  console Open the local console
69
69
  server start Start Agent Bot in the background