@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
@@ -4,6 +4,7 @@ export class SafeRestartScheduler {
4
4
  polling;
5
5
  pollAgain = false;
6
6
  reason;
7
+ notificationTargets = [];
7
8
  idleSince;
8
9
  idleInboundAt;
9
10
  scheduleId = 0;
@@ -16,10 +17,13 @@ export class SafeRestartScheduler {
16
17
  get pendingReason() {
17
18
  return this.reason;
18
19
  }
19
- schedule(reason) {
20
+ schedule(reason, notificationTarget) {
20
21
  const newlyScheduled = !this.reason;
21
- if (newlyScheduled)
22
+ if (newlyScheduled) {
22
23
  this.scheduleId += 1;
24
+ this.notificationTargets = [];
25
+ }
26
+ this.addNotificationTarget(notificationTarget);
23
27
  this.reason = reason;
24
28
  this.idleSince = undefined;
25
29
  this.idleInboundAt = undefined;
@@ -42,10 +46,12 @@ export class SafeRestartScheduler {
42
46
  if (!reason || this.scheduleId !== expectedScheduleId)
43
47
  return false;
44
48
  const activity = this.options.readActivity();
49
+ const notificationTargets = this.notificationTargetsSnapshot();
45
50
  this.clear();
46
51
  await this.emitStatus({
47
52
  scheduleId: expectedScheduleId,
48
53
  reason,
54
+ notificationTargets,
49
55
  phase: "cancelled",
50
56
  activity,
51
57
  });
@@ -56,6 +62,7 @@ export class SafeRestartScheduler {
56
62
  clearInterval(this.timer);
57
63
  this.timer = undefined;
58
64
  this.reason = undefined;
65
+ this.notificationTargets = [];
59
66
  this.idleSince = undefined;
60
67
  this.idleInboundAt = undefined;
61
68
  }
@@ -70,6 +77,7 @@ export class SafeRestartScheduler {
70
77
  await this.emitStatus({
71
78
  scheduleId: this.scheduleId,
72
79
  reason,
80
+ notificationTargets: this.notificationTargetsSnapshot(),
73
81
  phase: state.runningSessions > 0 ? "waiting_tasks" : "waiting_delivery",
74
82
  activity: state,
75
83
  });
@@ -80,12 +88,26 @@ export class SafeRestartScheduler {
80
88
  if (this.idleSince === undefined || this.idleInboundAt !== latestInboundAt) {
81
89
  this.idleSince = Date.now();
82
90
  this.idleInboundAt = latestInboundAt;
83
- await this.emitStatus({ scheduleId: this.scheduleId, reason, phase: "countdown", activity: state, remainingMs: quietPeriodMs });
91
+ await this.emitStatus({
92
+ scheduleId: this.scheduleId,
93
+ reason,
94
+ notificationTargets: this.notificationTargetsSnapshot(),
95
+ phase: "countdown",
96
+ activity: state,
97
+ remainingMs: quietPeriodMs,
98
+ });
84
99
  return;
85
100
  }
86
101
  const remainingMs = Math.max(0, quietPeriodMs - (Date.now() - this.idleSince));
87
102
  if (remainingMs > 0) {
88
- await this.emitStatus({ scheduleId: this.scheduleId, reason, phase: "countdown", activity: state, remainingMs });
103
+ await this.emitStatus({
104
+ scheduleId: this.scheduleId,
105
+ reason,
106
+ notificationTargets: this.notificationTargetsSnapshot(),
107
+ phase: "countdown",
108
+ activity: state,
109
+ remainingMs,
110
+ });
89
111
  return;
90
112
  }
91
113
  const confirmed = this.options.readActivity();
@@ -98,6 +120,7 @@ export class SafeRestartScheduler {
98
120
  await this.emitStatus({
99
121
  scheduleId: this.scheduleId,
100
122
  reason,
123
+ notificationTargets: this.notificationTargetsSnapshot(),
101
124
  phase: confirmed.runningSessions > 0 ? "waiting_tasks" : "waiting_delivery",
102
125
  activity: confirmed,
103
126
  });
@@ -106,6 +129,7 @@ export class SafeRestartScheduler {
106
129
  await this.emitStatus({
107
130
  scheduleId: this.scheduleId,
108
131
  reason,
132
+ notificationTargets: this.notificationTargetsSnapshot(),
109
133
  phase: "countdown",
110
134
  activity: confirmed,
111
135
  remainingMs: quietPeriodMs,
@@ -114,9 +138,17 @@ export class SafeRestartScheduler {
114
138
  return;
115
139
  }
116
140
  const scheduleId = this.scheduleId;
141
+ const notificationTargets = this.notificationTargetsSnapshot();
117
142
  this.clear();
118
- await this.emitStatus({ scheduleId, reason, phase: "restarting", activity: confirmed, remainingMs: 0 });
119
- await this.options.onReady(reason);
143
+ await this.emitStatus({
144
+ scheduleId,
145
+ reason,
146
+ notificationTargets,
147
+ phase: "restarting",
148
+ activity: confirmed,
149
+ remainingMs: 0,
150
+ });
151
+ await this.options.onReady(reason, notificationTargets);
120
152
  }
121
153
  requestPoll() {
122
154
  if (this.polling) {
@@ -142,5 +174,32 @@ export class SafeRestartScheduler {
142
174
  this.options.onStatusError?.(error);
143
175
  });
144
176
  }
177
+ addNotificationTarget(value) {
178
+ const target = normalizedNotificationTarget(value);
179
+ if (!target)
180
+ return;
181
+ const existingIndex = this.notificationTargets.findIndex((candidate) => candidate.contextKey === target.contextKey);
182
+ if (existingIndex < 0) {
183
+ this.notificationTargets.push(target);
184
+ return;
185
+ }
186
+ const existing = this.notificationTargets[existingIndex];
187
+ if (!existing.replyMessageId && target.replyMessageId) {
188
+ this.notificationTargets[existingIndex] = target;
189
+ }
190
+ }
191
+ notificationTargetsSnapshot() {
192
+ return this.notificationTargets.map((target) => ({ ...target }));
193
+ }
194
+ }
195
+ function normalizedNotificationTarget(value) {
196
+ const contextKey = value?.contextKey.trim();
197
+ if (!contextKey)
198
+ return undefined;
199
+ const replyMessageId = value?.replyMessageId?.trim();
200
+ return {
201
+ contextKey,
202
+ ...(replyMessageId ? { replyMessageId } : {}),
203
+ };
145
204
  }
146
205
  //# sourceMappingURL=SafeRestartScheduler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SafeRestartScheduler.js","sourceRoot":"","sources":["../../src/supervision/SafeRestartScheduler.ts"],"names":[],"mappings":"AA8BA,MAAM,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OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;CACF;AAED,SAAS,4BAA4B,CACnC,KAA4C;IAE5C,MAAM,UAAU,GAAG,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;IAC5C,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAClC,MAAM,cAAc,GAAG,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;IACrD,OAAO;QACL,UAAU;QACV,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC;AACJ,CAAC"}
@@ -1,8 +1,33 @@
1
- export function replacementSupervisorEnvironment(restartReason, environment = process.env) {
2
- return {
1
+ export const RESTART_GROUP_CONTEXTS_ENV = "AGENT_BOT_RESTART_GROUP_CONTEXTS";
2
+ export function replacementSupervisorEnvironment(restartReason, environment = process.env, restartGroupContextKeys = []) {
3
+ const result = {
3
4
  ...environment,
4
5
  AGENT_BOT_START_DELAY_MS: "250",
5
6
  AGENT_BOT_RESTART_REASON: restartReason,
6
7
  };
8
+ const normalized = normalizedContextKeys(restartGroupContextKeys);
9
+ if (normalized.length > 0) {
10
+ result[RESTART_GROUP_CONTEXTS_ENV] = JSON.stringify(normalized);
11
+ }
12
+ else {
13
+ delete result[RESTART_GROUP_CONTEXTS_ENV];
14
+ }
15
+ return result;
16
+ }
17
+ export function restartGroupContextKeysFromEnvironment(value) {
18
+ if (!value?.trim())
19
+ return [];
20
+ try {
21
+ const parsed = JSON.parse(value);
22
+ return Array.isArray(parsed)
23
+ ? normalizedContextKeys(parsed.filter((entry) => typeof entry === "string"))
24
+ : [];
25
+ }
26
+ catch {
27
+ return [];
28
+ }
29
+ }
30
+ function normalizedContextKeys(values) {
31
+ return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
7
32
  }
8
33
  //# sourceMappingURL=replacementSupervisor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"replacementSupervisor.js","sourceRoot":"","sources":["../../src/supervision/replacementSupervisor.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gCAAgC,CAC9C,aAAqB,EACrB,WAAW,GAAsB,OAAO,CAAC,GAAG;IAE5C,OAAO;QACL,GAAG,WAAW;QACd,wBAAwB,EAAE,KAAK;QAC/B,wBAAwB,EAAE,aAAa;KACxC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"replacementSupervisor.js","sourceRoot":"","sources":["../../src/supervision/replacementSupervisor.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,kCAAkC,CAAC;AAE7E,MAAM,UAAU,gCAAgC,CAC9C,aAAqB,EACrB,WAAW,GAAsB,OAAO,CAAC,GAAG,EAC5C,uBAAuB,GAAsB,EAAE;IAE/C,MAAM,MAAM,GAAsB;QAChC,GAAG,WAAW;QACd,wBAAwB,EAAE,KAAK;QAC/B,wBAAwB,EAAE,aAAa;KACxC,CAAC;IACF,MAAM,UAAU,GAAG,qBAAqB,CAAC,uBAAuB,CAAC,CAAC;IAClE,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,CAAC,0BAA0B,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAClE,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,sCAAsC,CAAC,KAAyB;IAC9E,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC;IAC9B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAY,CAAC;QAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAC1B,CAAC,CAAC,qBAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC;YAC7F,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAyB;IACtD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC"}
@@ -7,6 +7,7 @@ import { requireServerFeishuTransport } from "./feishu/transport.js";
7
7
  import { crashRestartDelayMs, describeRestartReason, INTENTIONAL_RESTART_DELAY_MS, RESTART_EXIT_CODE, STABLE_UPTIME_MS, STOP_EXIT_CODE, } from "./supervision/restartPolicy.js";
8
8
  import { SupervisorDiagnostics, nodeDiagnosticReportArguments } from "./supervision/SupervisorDiagnostics.js";
9
9
  import { refreshedSystemEnvironment } from "./supervision/systemEnvironment.js";
10
+ import { RESTART_GROUP_CONTEXTS_ENV, restartGroupContextKeysFromEnvironment, } from "./supervision/replacementSupervisor.js";
10
11
  const childEntry = fileURLToPath(new URL("./index.js", import.meta.url));
11
12
  const config = loadConfig();
12
13
  requireServerFeishuTransport(config.feishu);
@@ -16,9 +17,11 @@ const diagnostics = new SupervisorDiagnostics(config);
16
17
  diagnostics.initialize();
17
18
  let child;
18
19
  let restartTimer;
20
+ let restartGroupContextExpiryTimer;
19
21
  let stopping = false;
20
22
  let consecutiveFailures = 0;
21
23
  let nextStartReason = process.env.AGENT_BOT_RESTART_REASON?.trim() || "Supervisor 启动";
24
+ let nextRestartGroupContextKeys = restartGroupContextKeysFromEnvironment(process.env[RESTART_GROUP_CONTEXTS_ENV]);
22
25
  async function startChild() {
23
26
  if (stopping || child)
24
27
  return;
@@ -29,6 +32,7 @@ async function startChild() {
29
32
  }
30
33
  const startedAt = Date.now();
31
34
  const restartReason = nextStartReason;
35
+ const restartGroupContextKeys = nextRestartGroupContextKeys;
32
36
  nextStartReason = "Supervisor 重新拉起进程";
33
37
  const workerStderr = diagnostics.openWorkerStderr();
34
38
  const environmentRefresh = refreshedSystemEnvironment();
@@ -44,11 +48,11 @@ async function startChild() {
44
48
  childEntry,
45
49
  ], {
46
50
  cwd: process.cwd(),
47
- env: {
51
+ env: workerEnvironment({
48
52
  ...environmentRefresh.environment,
49
53
  AGENT_BOT_SUPERVISED: "1",
50
54
  AGENT_BOT_RESTART_REASON: restartReason,
51
- },
55
+ }, restartGroupContextKeys),
52
56
  stdio: ["ignore", "ignore", workerStderr],
53
57
  windowsHide: true,
54
58
  });
@@ -60,6 +64,7 @@ async function startChild() {
60
64
  writeSupervisorLog("started", {
61
65
  pid: child.pid,
62
66
  restartReason,
67
+ restartGroupContextKeys,
63
68
  workerStderrPath: diagnostics.paths.workerStderrPath,
64
69
  crashReportDirectory: diagnostics.paths.crashReportDirectory,
65
70
  });
@@ -69,6 +74,24 @@ async function startChild() {
69
74
  child.once("exit", (code, signal) => {
70
75
  void handleChildExit(code, signal, startedAt, workerPid);
71
76
  });
77
+ if (restartGroupContextKeys.length > 0) {
78
+ if (restartGroupContextExpiryTimer)
79
+ clearTimeout(restartGroupContextExpiryTimer);
80
+ restartGroupContextExpiryTimer = setTimeout(() => {
81
+ nextRestartGroupContextKeys = [];
82
+ restartGroupContextExpiryTimer = undefined;
83
+ }, STABLE_UPTIME_MS);
84
+ }
85
+ }
86
+ function workerEnvironment(environment, restartGroupContextKeys) {
87
+ const result = { ...environment };
88
+ if (restartGroupContextKeys.length > 0) {
89
+ result[RESTART_GROUP_CONTEXTS_ENV] = JSON.stringify(restartGroupContextKeys);
90
+ }
91
+ else {
92
+ delete result[RESTART_GROUP_CONTEXTS_ENV];
93
+ }
94
+ return result;
72
95
  }
73
96
  async function handleChildExit(code, signal, startedAt, workerPid) {
74
97
  child = undefined;
@@ -123,6 +146,8 @@ function stop(signal) {
123
146
  stopping = true;
124
147
  if (restartTimer)
125
148
  clearTimeout(restartTimer);
149
+ if (restartGroupContextExpiryTimer)
150
+ clearTimeout(restartGroupContextExpiryTimer);
126
151
  if (child && !child.killed) {
127
152
  child.kill(signal);
128
153
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.js","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAC9G,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAEhF,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACzE,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;AAC5B,4BAA4B,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;AAC7C,MAAM,cAAc,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;AACnD,MAAM,WAAW,GA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AkB,CAAC,KAAa,EAAE,IAA6B;IACtE,WAAW,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC3C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;AAC7C,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,CAAC,CAAC;AACzE,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;IAC1D,YAAY,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,UAAU,EAAE,EAAE,cAAc,CAAC,CAAC;AACrE,CAAC;KAAM,CAAC;IACN,KAAK,UAAU,EAAE,CAAC;AACpB,CAAC"}
@@ -9,7 +9,7 @@ This document covers deployment, configuration, runtime behavior, persistence, a
9
9
  Agent Bot is a Node.js 22+ ESM TypeScript application built around these components:
10
10
 
11
11
  - The supervisor owns the long-running service and restarts the worker.
12
- - The worker starts the configured Codex and ACP runtimes, Feishu transport, Console transport, local control server, and SQLite store.
12
+ - The worker starts the configured Agent runtimes, Feishu transport, Console transport, local control server, and SQLite store.
13
13
  - Feishu events and Console input are normalized into the same task controller.
14
14
  - Presentation components maintain one progress card per turn and send the final Markdown response separately.
15
15
  - App Server agents use the App Server protocol over stdio; other configured agents use ACP.
@@ -22,7 +22,7 @@ Relevant source areas:
22
22
  | `src/cli/` | Initialization, app registration, app auditing, and service/task commands |
23
23
  | `src/feishu/` | Feishu WebSocket events, API calls, cards, images, and context keys |
24
24
  | `src/runtime/` | Shared runtime abstraction |
25
- | `src/codex/` | Codex App Server protocol integration |
25
+ | `src/codex/` | App Server protocol integration for Codex, TraeX, and compatible Agents |
26
26
  | `src/acp/` | ACP process and JSON-RPC integration |
27
27
  | `src/proxy/` | Tasks, turns, steering, queues, forks, and command execution |
28
28
  | `src/presentation/` | Turn-state reduction and outbound routing |
@@ -58,13 +58,22 @@ Relative `storage.sqlitePath` and `logging.path` values resolve against the dire
58
58
 
59
59
  ## Initialization
60
60
 
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
+
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`).
64
+
61
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.
62
66
 
67
+ When `config.yaml` already exists, `init` treats the packaged `config.example.yaml` as the configuration upgrade template. It parses both files as YAML and recursively adds missing mapping entries while preserving existing scalar values, sequences, comments, and custom entries. An existing `agents` mapping is treated as user-owned: template Agents that the user omitted are not re-added, while missing fields are filled for same-named Agents. A missing `defaults.agent` is not inferred because doing so could silently change the selected Agent. Invalid YAML is reported without replacing the existing file. Changed configuration is written through an atomic replacement, and a second run is idempotent. Use `--reset` when a complete replacement from the current template is intended.
68
+
69
+ When `.env` already exists, `init` appends active assignments missing from the packaged `.env.example`. Existing values, comments, ordering, and line endings are preserved, and commented optional examples are not enabled. The update uses the same atomic replacement behavior and is idempotent.
70
+
63
71
  Credential behavior:
64
72
 
65
73
  - Environment values take precedence over values in `~/.agent-bot/.env`.
66
74
  - Both `FEISHU_APP_ID` and `FEISHU_APP_SECRET` are required.
67
75
  - One-click registration also stores the authorizing user's `open_id` as `FEISHU_USER_OPEN_ID`.
76
+ - When existing app credentials have no user Open ID, the first private-chat message with a valid `ou_` sender persists that sender atomically to the Profile `.env`; group messages and later users never replace it.
68
77
  - Complete credentials are preserved unless `--reconfigure-feishu` is used.
69
78
  - Missing or incomplete credentials cause a new app registration.
70
79
  - Newly registered credentials are fsynced, atomically replaced in `.env`, and read back before configuration begins.
@@ -92,7 +101,7 @@ The generated authorization links do not contain the app secret.
92
101
 
93
102
  `agentbot --profile <directory> init --reset` fully resets an explicitly selected Profile. The Profile server must be stopped first. The command moves the active `config.yaml`, `.env`, `data/`, and `logs/` into a unique timestamped directory under `<profile>/.reset-backups/`, creates clean replacements from the packaged templates, and proceeds through normal initialization. Existing reset backups and unrelated files are retained. Because backups can contain old app secrets and conversation data, protect the Profile directory accordingly. The remote Feishu app is not deleted. `--reset --skip-feishu` creates a clean Console-only Profile, while `--reset` and `--reconfigure-feishu` cannot be combined.
94
103
 
95
- 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. `--skip-feishu` skips automatic server startup, and `--json` includes the resulting `server.status` without adding non-JSON output.
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.
96
105
 
97
106
  ## Feishu App Requirements
98
107
 
@@ -142,6 +151,13 @@ agents:
142
151
  args: ["app-server", "--enable", "goals", "--listen", "stdio://"]
143
152
  env: {}
144
153
 
154
+ traex:
155
+ kind: "app-server"
156
+ title: "TraeX"
157
+ command: "traex"
158
+ args: ["app-server", "--listen", "stdio://"]
159
+ env: {}
160
+
145
161
  defaults:
146
162
  agent: "codex"
147
163
  cwd: "."
@@ -156,7 +172,7 @@ logging:
156
172
 
157
173
  `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.
158
174
 
159
- `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. It normally targets known private chats and recently active groups. If the database has no known 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. Missing credentials still fail startup with an initialization hint. `agentbot console` is the explicit local-only path and does not require Feishu credentials.
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.
160
176
 
161
177
  At least one agent must be configured. `defaults.agent` must name a configured agent.
162
178
 
@@ -187,7 +203,7 @@ The message route determines the current task:
187
203
 
188
204
  Commands, card callbacks, progress cards, and final responses stay on the originating route.
189
205
 
190
- Starting a Feishu thread from a mapped user message, progress card, or final response forks from the associated completed Codex turn. If no reliable completed source turn exists, the operation fails instead of selecting an arbitrary point.
206
+ Starting a Feishu thread from a mapped user message, progress card, or final response forks from the associated completed App Server turn. If no reliable completed source turn exists, the operation fails instead of selecting an arbitrary point.
191
207
 
192
208
  `/forkgroup` has thread-aware source selection. An unbound thread, or a bound thread task with no completed turn of its own, forks directly from the thread's original anchor turn without creating an intermediate thread task. Once the thread task has completed a turn, `/forkgroup` uses its latest locally persisted completed turn. A newer active turn does not block the command and is excluded from the fork point.
193
209
 
@@ -198,7 +214,7 @@ The new group's welcome message reports the persisted fork settings: Provider, m
198
214
  ## Turn And Message Behavior
199
215
 
200
216
  - Plain text creates a task when the route has no current task.
201
- - Text received during an active Codex turn is sent through steering.
217
+ - Text received during an active App Server turn is sent through steering.
202
218
  - A steering race at turn completion becomes the next queued request.
203
219
  - `/nosteer` always creates a persistent FIFO queue item.
204
220
  - Queue card actions can cancel individual pending items.
@@ -207,25 +223,27 @@ The new group's welcome message reports the persisted fork settings: Provider, m
207
223
 
208
224
  Each turn owns one progress card. Normal updates are throttled to one every two seconds; critical updates have a 500 ms minimum gap. On completion, Agent Bot updates the progress card to a terminal state before sending a separate final Markdown message.
209
225
 
226
+ Successfully completed progress cards include a `Reset` action with its compact effect warning directly below the action. `/turns` places the same effect warning at the top, then presents the current task's completed-turn snapshots in reverse chronological order, 10 per page. Each `turn_started` event persists the previous completed turn as its parent. Existing tasks are backfilled from snapshot timestamps and `session_reset_to_turn` audits, so the first turn after a historical Reset points to the selected turn instead of the time-adjacent abandoned branch. The renderer computes lanes across the complete history before slicing a page, then displays true continuations and merges in the graph column, indented content in the second column, and state or action in the third. The current conversation point is marked instead of showing an action; every other turn has a `Reset` action. Pagination and successful Reset actions update the same card, remain bound to the task that opened it, and move the current marker to the selected turn. The success text identifies the target with its Prompt summary, completion time, and Turn ID. Agent Bot records the App Server thread that originally owned each turn, forks that thread through the selected turn, and replaces the current task's remote thread binding without changing its local task ID, title, Agent, project directory, execution settings, or chat routing. Existing snapshots after the selected turn are not deleted, so the card shows retained turns from the old path together with turns later completed on the new branch. Reset is rejected while the current task is active, and it never reverts local file changes.
227
+
210
228
  After the durable message-deduplication claim, Agent Bot awaits the `OnIt` reaction before chat persistence, image downloads, queue waits, command execution, or runtime calls. It replaces that reaction with `DONE`, `ERROR`, or `CrossMark` when the turn succeeds, fails, or is canceled. Reaction failures are logged but do not block task execution.
211
229
 
212
- Incoming rich-text images are downloaded into the inbound image cache and passed to Codex as `localImage` inputs. An image-only message uses the default Prompt `请查看这张图片`. An ACP runtime that cannot accept image input returns an explicit error.
230
+ Incoming rich-text images are downloaded into the inbound image cache and passed to the App Server as `localImage` inputs. An image-only message uses the default Prompt `请查看这张图片`. An ACP runtime that cannot accept image input returns an explicit error.
213
231
 
214
- ## Tasks, Projects, And External Codex Work
232
+ ## Tasks, Projects, And External App Server Work
215
233
 
216
- `/sessions` reads Codex tasks through `thread/list` and can discover tasks created by Codex Desktop, CLI, Agent Bot, or another App Server client under the same `CODEX_HOME`.
234
+ `/sessions` reads tasks through `thread/list` from every configured App Server Agent. For Codex, this includes tasks created by Codex Desktop, CLI, Agent Bot, or another App Server client under the same `CODEX_HOME`; other Agents expose their own task stores through the same protocol. The merged, globally sorted result is displayed five tasks per page. `Previous` and `Next` replace the current card contents instead of appending more tasks, while preserving search terms and stable global task numbers.
217
235
 
218
236
  Each task entry exposes `NewGroup` and `ForkGroup` callbacks. The callback payload keeps the selected task ID and source context, while the Lark operator `open_id` is used to invite the user to the new group. `NewGroup` resolves the selected task's project and execution settings; `ForkGroup` resolves its latest available completed turn.
219
237
 
220
238
  The CLI exposes the same task-targeted operations through `agentbot task newgroup <task> [title] [--agent <name>] [--dir <cwd> | --nodir]` and `agentbot task forkgroup <task> [title]`. Both commands require a running Server and send the stable local task ID over the Profile's local control endpoint. Since a CLI process has no Lark operator, the Server invites `feishu.userOpenId`, which initialization stores as `FEISHU_USER_OPEN_ID`. New-group creation inherits the selected task's Agent and execution settings by default. `--agent <standard-name>` selects another configured runtime while retaining the source project shape; execution settings are omitted so that runtime applies its own defaults. ForkGroup uses the source task's latest available completed turn and leaves an active source turn running. Both control responses include the new chat, group context, source task, and created task; `--json` prints that structure without localization.
221
239
 
222
- ## Codex Provider Settings
240
+ ## App Server Provider Settings
223
241
 
224
- Provider is a task-level setting stored as `model_provider` alongside model, reasoning effort, and permission mode. Agent Bot passes `modelProvider` through `thread/start`, `thread/resume`, and `thread/fork` whenever a task explicitly inherits or selects one. For a brand-new task with no inherited Provider, Agent Bot omits `modelProvider`; the Codex App Server therefore uses the effective `model_provider` from Codex configuration and returns the selected Provider in its thread response for persistence.
242
+ Provider is a task-level setting stored as `model_provider` alongside model, reasoning effort, and permission mode. Agent Bot passes `modelProvider` through `thread/start`, `thread/resume`, and `thread/fork` whenever a task explicitly inherits or selects one. For a brand-new task with no inherited Provider, Agent Bot omits `modelProvider`; the selected App Server Agent uses its own effective default and returns the selected Provider in its thread response for persistence.
225
243
 
226
244
  `/provider`, `/model`, `/thinking`, and `/permissions` open one Card 2.0 execution-settings surface with the matching tab active. All four commands reject arguments; tab navigation and setting changes use card callbacks only. Provider choices come from App Server `config/read`. A Provider change resumes the thread with the selected Provider and the current compatible model, reasoning effort, and permission mode. Model, reasoning, and permission choices update their focused setting immediately, refresh the same card in place, and apply from the next request.
227
245
 
228
- Agent Bot keeps a local routing key for Feishu cards and delivery state, but presents the Codex task ID to users. It does not resume, steer, stop, or fork externally running Codex work without an explicit user action.
246
+ Agent Bot keeps a local routing key for Feishu cards and delivery state, but presents the owning App Server's task ID to users. It does not resume, steer, stop, or fork externally running Agent work without an explicit user action.
229
247
 
230
248
  Project behavior:
231
249
 
@@ -242,13 +260,13 @@ Forks use the latest available completed turn and do not interrupt an active sou
242
260
  SQLite stores:
243
261
 
244
262
  - Current and previous tasks for each route
245
- - Local and Codex task/thread identifiers
263
+ - Local and App Server task/thread identifiers
246
264
  - Model, reasoning effort, and permission mode
247
265
  - Queued Prompts
248
266
  - Progress snapshots and message bindings
249
267
  - Final-message delivery records
250
268
 
251
- On startup, Agent Bot reconciles persisted active work with Codex through `thread/read`. It also reconciles when turn identifiers change, terminal notifications arrive, or control requests fail.
269
+ On startup, Agent Bot reconciles persisted active work with its owning App Server through `thread/read`. It also reconciles when turn identifiers change, terminal notifications arrive, or control requests fail.
252
270
 
253
271
  The final-delivery ledger prevents duplicate successful replies. App Server requests use finite timeouts so a stalled request cannot permanently occupy a message route. Session lifecycle requests allow 60 seconds because compatible third-party Agents may need more than 30 seconds for `thread/start`; control requests remain shorter.
254
272
 
@@ -275,15 +293,19 @@ A safe restart waits for:
275
293
 
276
294
  The Feishu `/restart` command uses this safe path by default; `/restart --force` restarts immediately and may interrupt active work. The command rejects every other argument. New messages reset the quiet timer. CLI `--immediate` and `--force` also skip these checks. Exit code `75` identifies an intentional worker restart.
277
295
 
296
+ A pending safe-restart schedule accumulates the exact notification route of every conversation that triggers it. Every inbound user message, including slash commands, marks its base private or group conversation active. On every status update the notifier also enrolls every persisted conversation active during the preceding minute. Each enrolled route receives its own status card and final restarting acknowledgement and remains enrolled until the schedule ends, even after its activity becomes older than one minute. Repeated routes are deduplicated; when a topic route was first discovered without a message anchor, a later anchored trigger upgrades it. Topic requests retain the originating message ID and use a thread reply so restart updates cannot fall back to the group body. Recent topic activity is tracked on the parent group, while an explicit topic trigger remains in that topic. Later requests also update the restart reason. Before replacement, Agent Bot extracts and deduplicates the parent group of every enrolled route, passes that list through the replacement Supervisor, and adds those groups to the service-wide startup-card targets. The Supervisor retains the list until the Worker has remained stable for 60 seconds, so an early crash-driven relaunch does not lose required recipients.
297
+
298
+ Use `agentbot server restart --task <task>` when a CLI request belongs to a specific task. Task numbers, full IDs, and unambiguous ID prefixes are resolved before the control request is sent. Without `--task`, the Server infers the safe-restart status route only when all running tasks belong to one conversation; it rejects an ambiguous request spanning multiple running conversations. A CLI restart with no running task has no conversation owner for its waiting status.
299
+
278
300
  The first safe-restart status card is delayed by three seconds so a task's final response can usually arrive first. Status changes during that window are coalesced into the initial card. The delay does not block scheduler polling, and shutdown flushes any pending card immediately.
279
301
 
280
- Pending safe-restart cards include a bottom `Cancel` action. The action carries the scheduler's monotonic schedule ID, so an old card cannot cancel a newer restart. A successful cancellation updates every existing status card in place and removes the action; the action is also absent once the scheduler enters the irreversible restarting phase.
302
+ Pending safe-restart cards include a bottom `Cancel` action. The action carries the scheduler's monotonic schedule ID, so an old card cannot cancel a newer restart. A successful cancellation updates every enrolled conversation's existing status card in place and removes the action; the action is also absent once the scheduler enters the irreversible restarting phase.
281
303
 
282
304
  The local control server implements task mutations, task-targeted NewGroup and ForkGroup operations, and service restart requests. Read-only task queries access SQLite directly.
283
305
 
284
306
  ## Permission Modes
285
307
 
286
- - `auto`: Codex runs with `approvalPolicy=never` and `danger-full-access`.
308
+ - `auto`: the App Server Agent runs with `approvalPolicy=never` and `danger-full-access`.
287
309
  - `confirm`: approval requests are presented through card actions for one-time approval, session approval, denial, or task cancellation.
288
310
 
289
311
  Model, reasoning effort, permission mode, and project shape are inherited where applicable when creating or forking tasks.
@@ -312,18 +334,18 @@ Package lifecycle:
312
334
  - `prepack` builds a clean `dist/` and validates the tarball manifest.
313
335
  - `npm run package:smoke` packs the project, installs the tarball into a temporary directory, runs the CLI, and performs Console-only initialization.
314
336
 
315
- Prepare the next patch release from a clean worktree:
337
+ Prepare the next Alpha release from a clean worktree:
316
338
 
317
339
  ```powershell
318
340
  npm run release
319
341
  git add package.json npm-shrinkwrap.json CHANGELOG.md
320
- git commit -m "release: v0.1.1"
342
+ git commit -m "release: v0.1.13-alpha.0"
321
343
  git push origin master
322
344
  ```
323
345
 
324
- `npm run release` increments the patch version by default and moves the current `Unreleased` entries into a dated version section. Use `npm run release -- minor`, `npm run release -- major`, or `npm run release -- 0.2.0` to select another stable version. The command refuses to modify a dirty worktree or publish an empty changelog.
346
+ `npm run release` now defaults to the Alpha channel. A stable `0.1.12` becomes `0.1.13-alpha.0`; a current `0.1.13-alpha.0` becomes `0.1.13-alpha.1`. `npm run release:alpha` is the explicit equivalent. Use `npm run release:stable` to promote the current Alpha to its stable core version, or to increment the patch when the current version is already stable. `patch`, `minor`, `major`, and exact stable or `-alpha.N` versions remain available through `npm run release -- <version>`. Every release moves the current `Unreleased` entries into a dated version section. The command refuses to modify a dirty worktree or publish an empty changelog.
325
347
 
326
- No local publish command is required after the push. When CI succeeds for a first-party push to `master`, `publish.yml` checks the package version against npm. An existing version is skipped successfully. An unpublished stable version requires a matching `CHANGELOG.md` section, then runs verification and the package smoke test before publishing. After npm accepts the package, the workflow creates the matching `v<package version>` GitHub Release.
348
+ No local publish command is required after the push. When CI succeeds for a first-party push to `master`, `publish.yml` checks the package version against npm. An existing version is skipped successfully. An unpublished stable or Alpha version requires a matching `CHANGELOG.md` section, then runs verification and the package smoke test before publishing. Alpha versions use npm's `alpha` dist-tag and create a GitHub prerelease; stable versions use `latest` and create a regular GitHub Release.
327
349
 
328
350
  The workflow can also be retried manually from **GitHub Actions → Publish to npm → Run workflow** on `master`. Pull requests, forked repositories, failed CI runs, and pushes to other branches cannot enter the publish job.
329
351