@keyou007/agent-bot 0.1.3 → 0.1.5

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 (65) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +14 -1
  3. package/README.zh.md +14 -1
  4. package/dist/cli/FeishuAppConfiguration.js +10 -10
  5. package/dist/cli/FeishuAppConfiguration.js.map +1 -1
  6. package/dist/cli/FeishuAppRegistration.js +9 -9
  7. package/dist/cli/FeishuAppRegistration.js.map +1 -1
  8. package/dist/cli/Initializer.js +64 -5
  9. package/dist/cli/Initializer.js.map +1 -1
  10. package/dist/cli/LocalControlClient.js +2 -2
  11. package/dist/cli/LocalControlClient.js.map +1 -1
  12. package/dist/cli/LocalControlServer.js +1 -1
  13. package/dist/cli/LocalControlServer.js.map +1 -1
  14. package/dist/cli/ServerStarter.js +3 -3
  15. package/dist/cli/ServerStarter.js.map +1 -1
  16. package/dist/cli/SkillRegistry.js +4 -4
  17. package/dist/cli/SkillRegistry.js.map +1 -1
  18. package/dist/cli/help.js +9 -57
  19. package/dist/cli/help.js.map +1 -1
  20. package/dist/cli/initOptions.js +24 -0
  21. package/dist/cli/initOptions.js.map +1 -0
  22. package/dist/cli/packageVersion.js +1 -1
  23. package/dist/cli/packageVersion.js.map +1 -1
  24. package/dist/cli/profile.js +3 -3
  25. package/dist/cli/profile.js.map +1 -1
  26. package/dist/cli/serverStatus.js +37 -0
  27. package/dist/cli/serverStatus.js.map +1 -0
  28. package/dist/cli/taskChatRoute.js +2 -2
  29. package/dist/cli/taskChatRoute.js.map +1 -1
  30. package/dist/cli.js +154 -136
  31. package/dist/cli.js.map +1 -1
  32. package/dist/feishu/CardRenderer.js +1 -1
  33. package/dist/feishu/CardRenderer.js.map +1 -1
  34. package/dist/feishu/transport.js +1 -1
  35. package/dist/feishu/transport.js.map +1 -1
  36. package/dist/index.js +8 -4
  37. package/dist/index.js.map +1 -1
  38. package/dist/proxy/ProxySessionController.js +10 -10
  39. package/dist/proxy/ProxySessionController.js.map +1 -1
  40. package/dist/startup/StartupNotifier.js +1 -0
  41. package/dist/startup/StartupNotifier.js.map +1 -1
  42. package/docs/technical-reference.md +5 -1
  43. package/docs/technical-reference.zh.md +5 -1
  44. package/npm-shrinkwrap.json +2 -2
  45. package/package.json +1 -1
  46. package/skills/agent-bot/SKILL.md +3 -1
  47. package/src/cli/FeishuAppConfiguration.ts +10 -10
  48. package/src/cli/FeishuAppRegistration.ts +9 -9
  49. package/src/cli/Initializer.ts +76 -6
  50. package/src/cli/LocalControlClient.ts +2 -2
  51. package/src/cli/LocalControlServer.ts +1 -1
  52. package/src/cli/ServerStarter.ts +3 -3
  53. package/src/cli/SkillRegistry.ts +4 -4
  54. package/src/cli/help.ts +9 -66
  55. package/src/cli/initOptions.ts +33 -0
  56. package/src/cli/packageVersion.ts +1 -1
  57. package/src/cli/profile.ts +3 -3
  58. package/src/cli/serverStatus.ts +39 -0
  59. package/src/cli/taskChatRoute.ts +2 -2
  60. package/src/cli.ts +158 -139
  61. package/src/feishu/CardRenderer.ts +2 -0
  62. package/src/feishu/transport.ts +1 -1
  63. package/src/index.ts +8 -4
  64. package/src/proxy/ProxySessionController.ts +10 -10
  65. package/src/startup/StartupNotifier.ts +2 -0
@@ -8,7 +8,7 @@ type FeishuTransportConfig = Pick<
8
8
  export function requireServerFeishuTransport(config: FeishuTransportConfig): "sdk" {
9
9
  if (!config.appId || !config.appSecret) {
10
10
  throw new Error(
11
- "飞书机器人尚未配置。请先运行 agent-bot init 完成初始化;仅需本地调试时请使用 agent-bot console。",
11
+ "The Lark bot is not configured. Run agent-bot init first, or use agent-bot console for local-only testing.",
12
12
  );
13
13
  }
14
14
  return "sdk";
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import { CodexProcessManager } from "./codex/CodexProcessManager.js";
7
7
  import { CodexRuntime } from "./codex/CodexRuntime.js";
8
8
  import { LocalControlServer } from "./cli/LocalControlServer.js";
9
9
  import { controlEndpoint, type ControlRequest, type ControlResponse } from "./cli/controlProtocol.js";
10
+ import { readPackageVersion } from "./cli/packageVersion.js";
10
11
  import { loadConfig } from "./config/loadConfig.js";
11
12
  import { ConsoleConnector } from "./console/ConsoleConnector.js";
12
13
  import { ConsoleTurnPresenter } from "./console/ConsoleTurnPresenter.js";
@@ -36,6 +37,7 @@ import {
36
37
  } from "./supervision/SupervisorDiagnostics.js";
37
38
 
38
39
  const processStartedAt = new Date();
40
+ const agentBotVersion = readPackageVersion();
39
41
  const supervised = process.env.AGENT_BOT_SUPERVISED === "1";
40
42
  const startupReason = process.env.AGENT_BOT_RESTART_REASON?.trim()
41
43
  || (supervised ? "Supervisor 启动" : "直接启动");
@@ -79,6 +81,7 @@ if (feishuOutbound) {
79
81
  const defaultAgent = config.agents[defaultAgentName];
80
82
  const metadataHydrator = new SessionMetadataHydrator(store, runtimes);
81
83
  startupNotifier = new StartupNotifier(store, feishuOutbound, renderer, logger, {
84
+ agentBotVersion,
82
85
  defaultAgentName,
83
86
  defaultAgentTitle: defaultAgent?.title ?? defaultAgentName,
84
87
  cwd: path.resolve(config.defaults.cwd),
@@ -177,6 +180,7 @@ async function handleControlRequest(request: ControlRequest): Promise<ControlRes
177
180
  pid: process.pid,
178
181
  startedAt: processStartedAt.toISOString(),
179
182
  supervised,
183
+ feishuAppId: config.feishu.appId ?? null,
180
184
  safeRestartScheduled: safeRestart.scheduled,
181
185
  safeRestartReason: safeRestart.pendingReason,
182
186
  activity: store.getServerActivityState(),
@@ -188,16 +192,16 @@ async function handleControlRequest(request: ControlRequest): Promise<ControlRes
188
192
  return {
189
193
  ok: true,
190
194
  message: newlyScheduled
191
- ? "已安排安全重启;将在全部任务完成并持续空闲 15 秒后执行。"
192
- : "安全重启已在等待中,已更新重启原因。",
195
+ ? "Safe restart scheduled. It will run after all tasks finish and the server stays idle for 15 seconds."
196
+ : "A safe restart is already pending. Its reason has been updated.",
193
197
  };
194
198
  }
195
199
  setTimeout(() => void initiateRestart(request.reason), 25);
196
- return { ok: true, message: "已请求立即重启。" };
200
+ return { ok: true, message: "Immediate restart requested." };
197
201
  case "server_stop":
198
202
  safeRestart.cancel();
199
203
  setTimeout(() => void shutdown(STOP_EXIT_CODE), 25);
200
- return { ok: true, message: "已请求停止 Agent Bot server。" };
204
+ return { ok: true, message: "Agent Bot server stop requested." };
201
205
  case "task_status":
202
206
  return { ok: true, data: await controller.controlGetTaskStatus(request.localSessionId) };
203
207
  case "task_stop":
@@ -415,9 +415,9 @@ export class ProxySessionController {
415
415
 
416
416
  async controlStopTask(localSessionId: string): Promise<string> {
417
417
  const record = this.store.getSession(localSessionId);
418
- if (!record || record.status === "closed") throw new Error(`找不到任务:${localSessionId}`);
418
+ if (!record || record.status === "closed") throw new Error(`Task not found: ${localSessionId}`);
419
419
  await this.cancelSession(record);
420
- return `已请求停止任务:${record.title ?? record.remoteSessionId ?? record.localSessionId}`;
420
+ return `Task stop requested: ${record.title ?? record.remoteSessionId ?? record.localSessionId}`;
421
421
  }
422
422
 
423
423
  async controlGetTaskStatus(localSessionId: string): Promise<{
@@ -426,7 +426,7 @@ export class ProxySessionController {
426
426
  remote?: RemoteSessionSummary;
427
427
  }> {
428
428
  const record = this.store.getSession(localSessionId);
429
- if (!record) throw new Error(`找不到任务:${localSessionId}`);
429
+ if (!record) throw new Error(`Task not found: ${localSessionId}`);
430
430
  let remote: RemoteSessionSummary | undefined;
431
431
  if (record.remoteSessionId) {
432
432
  const runtime = this.runtimes.forAgent(this.ensureAgent(record.agentName));
@@ -447,9 +447,9 @@ export class ProxySessionController {
447
447
 
448
448
  async controlSetTaskTitle(localSessionId: string, title: string): Promise<string> {
449
449
  const normalizedTitle = normalizeTaskTitle(title);
450
- if (!normalizedTitle) throw new Error("任务标题不能为空。");
450
+ if (!normalizedTitle) throw new Error("The task title cannot be empty.");
451
451
  const record = this.store.getSession(localSessionId);
452
- if (!record || record.status === "closed") throw new Error(`找不到任务:${localSessionId}`);
452
+ if (!record || record.status === "closed") throw new Error(`Task not found: ${localSessionId}`);
453
453
  const loaded = await this.loadSession(record);
454
454
  if (loaded.runtime.setTitle) await loaded.runtime.setTitle(record.localSessionId, normalizedTitle);
455
455
  else loaded.session.title = normalizedTitle;
@@ -460,14 +460,14 @@ export class ProxySessionController {
460
460
  title: normalizedTitle,
461
461
  source: "cli",
462
462
  });
463
- return `任务标题已修改为:${normalizedTitle}`;
463
+ return `Task title changed to: ${normalizedTitle}`;
464
464
  }
465
465
 
466
466
  async controlSendTaskPrompt(localSessionId: string, text: string): Promise<string> {
467
467
  const promptText = text.trim();
468
- if (!promptText) throw new Error("Prompt 不能为空。");
468
+ if (!promptText) throw new Error("The Prompt cannot be empty.");
469
469
  const record = this.store.getSession(localSessionId);
470
- if (!record || record.status === "closed") throw new Error(`找不到任务:${localSessionId}`);
470
+ if (!record || record.status === "closed") throw new Error(`Task not found: ${localSessionId}`);
471
471
  const runtime = this.runtimes.forAgent(this.ensureAgent(record.agentName));
472
472
  const activeTurnId = runtime.getSession(localSessionId)?.activeTurnId;
473
473
  const routedContextKey = this.outbound.getSessionContextKey(localSessionId);
@@ -487,7 +487,7 @@ export class ProxySessionController {
487
487
  ?? lastSnapshot?.replyTarget
488
488
  ?? routedReplyTarget;
489
489
  if (isThreadContextKey(responseContextKey) && !existingReplyTarget) {
490
- throw new Error("无法确定目标任务的话题回复位置,未发送 Prompt。");
490
+ throw new Error("Could not resolve the target task's thread reply location. The Prompt was not sent.");
491
491
  }
492
492
  const scopedRecord = this.store.getSessionForContext(localSessionId, responseContextKey)
493
493
  ?? { ...record, contextKey: responseContextKey };
@@ -521,7 +521,7 @@ export class ProxySessionController {
521
521
  } finally {
522
522
  if (this.messageQueues.get(responseContextKey) === next) this.messageQueues.delete(responseContextKey);
523
523
  }
524
- return `已通过机器人向原会话发送 Prompt,并提交给任务:${record.title ?? record.remoteSessionId ?? record.localSessionId}`;
524
+ return `The Prompt was posted to the original chat and submitted to the task: ${record.title ?? record.remoteSessionId ?? record.localSessionId}`;
525
525
  }
526
526
 
527
527
  private cardActionContextKey(action: CardAction): string {
@@ -5,6 +5,7 @@ import type { FeishuOutbound } from "../feishu/types.js";
5
5
  import type { SessionRecord, StateStore, UserContextRecord } from "../state/StateStore.js";
6
6
 
7
7
  export interface StartupNotificationOptions {
8
+ agentBotVersion: string;
8
9
  defaultAgentName: string;
9
10
  defaultAgentTitle: string;
10
11
  cwd: string;
@@ -74,6 +75,7 @@ export class StartupNotifier {
74
75
  const card = this.renderer.renderStartupStatus({
75
76
  startedAt,
76
77
  restartReason,
78
+ agentBotVersion: this.options.agentBotVersion,
77
79
  defaultAgentName: this.options.defaultAgentName,
78
80
  defaultAgentTitle: this.options.defaultAgentTitle,
79
81
  cwd,