@keyou007/agent-bot 0.1.14-alpha.0 → 0.1.14-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +82 -55
- package/README.zh.md +82 -55
- package/config.example.yaml +5 -1
- package/dist/cli/AutostartManager.js +431 -0
- package/dist/cli/AutostartManager.js.map +1 -0
- package/dist/cli/FeishuAppConfiguration.js +17 -13
- package/dist/cli/FeishuAppConfiguration.js.map +1 -1
- package/dist/cli/Initializer.js +35 -0
- package/dist/cli/Initializer.js.map +1 -1
- package/dist/cli/SelfUpdateRunner.js +552 -0
- package/dist/cli/SelfUpdateRunner.js.map +1 -0
- package/dist/cli/SelfUpdater.js +431 -0
- package/dist/cli/SelfUpdater.js.map +1 -0
- package/dist/cli/autostartOutput.js +63 -0
- package/dist/cli/autostartOutput.js.map +1 -0
- package/dist/cli/controlProtocol.js.map +1 -1
- package/dist/cli/help.js +92 -18
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/taskGroupOptions.js +14 -11
- package/dist/cli/taskGroupOptions.js.map +1 -1
- package/dist/cli/taskListOutput.js +3 -0
- package/dist/cli/taskListOutput.js.map +1 -1
- package/dist/cli/taskTarget.js +99 -0
- package/dist/cli/taskTarget.js.map +1 -0
- package/dist/cli.js +643 -58
- package/dist/cli.js.map +1 -1
- package/dist/codex/CodexRuntime.js +16 -5
- package/dist/codex/CodexRuntime.js.map +1 -1
- package/dist/commands/CommandRouter.js +20 -1
- package/dist/commands/CommandRouter.js.map +1 -1
- package/dist/config/loadConfig.js +2 -0
- package/dist/config/loadConfig.js.map +1 -1
- package/dist/config/schema.js +2 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/console/ConsoleTurnPresenter.js +2 -0
- package/dist/console/ConsoleTurnPresenter.js.map +1 -1
- package/dist/feishu/CardRenderer.js +584 -16
- package/dist/feishu/CardRenderer.js.map +1 -1
- package/dist/feishu/FeishuConnector.js +29 -8
- package/dist/feishu/FeishuConnector.js.map +1 -1
- package/dist/feishu/FeishuMarkdown.js +25 -1
- package/dist/feishu/FeishuMarkdown.js.map +1 -1
- package/dist/feishu/FeishuMessageClient.js +43 -0
- package/dist/feishu/FeishuMessageClient.js.map +1 -1
- package/dist/feishu/FeishuTurnPresenter.js +29 -1
- package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
- package/dist/feishu/ownerAccess.js +7 -0
- package/dist/feishu/ownerAccess.js.map +1 -0
- package/dist/index.js +148 -19
- package/dist/index.js.map +1 -1
- package/dist/presentation/OutboundRouter.js +19 -1
- package/dist/presentation/OutboundRouter.js.map +1 -1
- package/dist/proxy/ProxySessionController.js +1444 -66
- package/dist/proxy/ProxySessionController.js.map +1 -1
- package/dist/startup/StartupNotifier.js +65 -16
- package/dist/startup/StartupNotifier.js.map +1 -1
- package/dist/startup/startFeishu.js +2 -2
- package/dist/startup/startFeishu.js.map +1 -1
- package/dist/state/StateStore.js +268 -67
- package/dist/state/StateStore.js.map +1 -1
- package/dist/state/migrations.js +26 -0
- package/dist/state/migrations.js.map +1 -1
- package/dist/supervision/SafeRestartNotifier.js +17 -16
- package/dist/supervision/SafeRestartNotifier.js.map +1 -1
- package/dist/supervision/SafeRestartScheduler.js +12 -7
- package/dist/supervision/SafeRestartScheduler.js.map +1 -1
- package/dist/supervision/replacementSupervisor.js +45 -4
- package/dist/supervision/replacementSupervisor.js.map +1 -1
- package/dist/supervisor.js +30 -18
- package/dist/supervisor.js.map +1 -1
- package/docs/technical-reference.md +33 -10
- package/docs/technical-reference.zh.md +33 -10
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/skills/agent-bot/SKILL.md +107 -182
- package/src/cli/AutostartManager.ts +579 -0
- package/src/cli/FeishuAppConfiguration.ts +22 -7
- package/src/cli/Initializer.ts +57 -0
- package/src/cli/SelfUpdateRunner.ts +817 -0
- package/src/cli/SelfUpdater.ts +688 -0
- package/src/cli/autostartOutput.ts +75 -0
- package/src/cli/controlProtocol.ts +111 -1
- package/src/cli/help.ts +92 -18
- package/src/cli/taskGroupOptions.ts +27 -17
- package/src/cli/taskListOutput.ts +10 -0
- package/src/cli/taskTarget.ts +168 -0
- package/src/cli.ts +781 -65
- package/src/codex/CodexRuntime.ts +17 -5
- package/src/commands/CommandRouter.ts +19 -1
- package/src/commands/commandTypes.ts +3 -0
- package/src/config/loadConfig.ts +2 -0
- package/src/config/schema.ts +2 -0
- package/src/console/ConsoleTurnPresenter.ts +4 -1
- package/src/feishu/CardRenderer.ts +716 -16
- package/src/feishu/FeishuConnector.ts +44 -10
- package/src/feishu/FeishuMarkdown.ts +27 -1
- package/src/feishu/FeishuMessageClient.ts +58 -0
- package/src/feishu/FeishuTurnPresenter.ts +35 -2
- package/src/feishu/ownerAccess.ts +7 -0
- package/src/feishu/types.ts +7 -0
- package/src/index.ts +192 -22
- package/src/presentation/OutboundRouter.ts +28 -3
- package/src/proxy/ProxySessionController.ts +1707 -70
- package/src/runtime/types.ts +1 -0
- package/src/startup/StartupNotifier.ts +67 -17
- package/src/startup/startFeishu.ts +5 -3
- package/src/state/StateStore.ts +413 -65
- package/src/state/migrations.ts +26 -0
- package/src/supervision/SafeRestartNotifier.ts +17 -17
- package/src/supervision/SafeRestartScheduler.ts +13 -6
- package/src/supervision/replacementSupervisor.ts +50 -4
- package/src/supervisor.ts +35 -16
|
@@ -355,12 +355,18 @@ export class CodexRuntime implements AgentRuntime {
|
|
|
355
355
|
|
|
356
356
|
async closeSession(sessionId: string): Promise<void> {
|
|
357
357
|
const session = this.requireSession(sessionId);
|
|
358
|
+
await this.archiveRemoteSession(session.remoteSessionId);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async archiveRemoteSession(remoteSessionId: string): Promise<void> {
|
|
358
362
|
await (await this.client()).request(
|
|
359
363
|
"thread/archive",
|
|
360
|
-
{ threadId:
|
|
364
|
+
{ threadId: remoteSessionId },
|
|
361
365
|
CONTROL_REQUEST_TIMEOUT_MS,
|
|
362
366
|
);
|
|
363
|
-
this.sessions
|
|
367
|
+
for (const [localSessionId, session] of this.sessions) {
|
|
368
|
+
if (session.remoteSessionId === remoteSessionId) this.sessions.delete(localSessionId);
|
|
369
|
+
}
|
|
364
370
|
}
|
|
365
371
|
|
|
366
372
|
async setTitle(sessionId: string, title: string): Promise<void> {
|
|
@@ -770,11 +776,17 @@ export class CodexRuntime implements AgentRuntime {
|
|
|
770
776
|
const activeTurnId = session.activeTurnId;
|
|
771
777
|
|
|
772
778
|
if (!activeTurnId) {
|
|
773
|
-
if (latestInProgress
|
|
779
|
+
if (latestInProgress && thread.status?.type === "active") {
|
|
780
|
+
this.adoptTurn(session, latestInProgress.id, turnStartedAt(latestInProgress));
|
|
781
|
+
}
|
|
774
782
|
return;
|
|
775
783
|
}
|
|
776
784
|
|
|
777
|
-
if (latestInProgress?.id === activeTurnId)
|
|
785
|
+
if (latestInProgress?.id === activeTurnId) {
|
|
786
|
+
if (thread.status?.type === "active") return;
|
|
787
|
+
this.supersedeTurn(session, activeTurnId);
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
778
790
|
if (latestInProgress) {
|
|
779
791
|
this.supersedeTurn(session, activeTurnId);
|
|
780
792
|
this.adoptTurn(session, latestInProgress.id, turnStartedAt(latestInProgress));
|
|
@@ -1091,7 +1103,7 @@ function remoteSessionSummary(thread: CodexThreadSnapshot): RemoteSessionSummary
|
|
|
1091
1103
|
// that owned it. Only the owning app-server's active thread status (or the
|
|
1092
1104
|
// rollout activity detector applied below) is evidence that it is still live.
|
|
1093
1105
|
const lastTurnStatus = lastTurn?.status === "inProgress" && status !== "active"
|
|
1094
|
-
?
|
|
1106
|
+
? "interrupted"
|
|
1095
1107
|
: lastTurn?.status;
|
|
1096
1108
|
const lastText = [...(lastTurn?.items ?? [])]
|
|
1097
1109
|
.reverse()
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { Command } from "./commandTypes.js";
|
|
2
2
|
|
|
3
|
-
const COMMAND_NAMES = [
|
|
3
|
+
export const COMMAND_NAMES = [
|
|
4
4
|
"agent",
|
|
5
|
+
"archive",
|
|
6
|
+
"dir",
|
|
5
7
|
"fork",
|
|
6
8
|
"forkgroup",
|
|
7
9
|
"goal",
|
|
8
10
|
"help",
|
|
9
11
|
"model",
|
|
12
|
+
"mute",
|
|
10
13
|
"new",
|
|
11
14
|
"newgroup",
|
|
12
15
|
"nosteer",
|
|
@@ -49,6 +52,8 @@ export class CommandRouter {
|
|
|
49
52
|
const command = resolveCommandName(rawCommand);
|
|
50
53
|
|
|
51
54
|
switch (command) {
|
|
55
|
+
case "dir":
|
|
56
|
+
return { type: "dir", directory: args.join(" ").trim() || undefined };
|
|
52
57
|
case "new":
|
|
53
58
|
return parseNewCommand(args);
|
|
54
59
|
case "newgroup":
|
|
@@ -72,6 +77,10 @@ export class CommandRouter {
|
|
|
72
77
|
return args[0] ? { type: "switch", sessionId: args[0] } : { type: "switch" };
|
|
73
78
|
case "agent":
|
|
74
79
|
return args[0] ? { type: "agent", agent: args[0] } : { type: "agent" };
|
|
80
|
+
case "archive":
|
|
81
|
+
rejectOptions("/archive", args);
|
|
82
|
+
if (args.length > 1) throw new Error("/archive 只接受一个可选的任务序号或任务 ID。");
|
|
83
|
+
return args[0] ? { type: "archive", sessionId: args[0] } : { type: "archive" };
|
|
75
84
|
case "stop":
|
|
76
85
|
return { type: "stop" };
|
|
77
86
|
case "status":
|
|
@@ -94,6 +103,15 @@ export class CommandRouter {
|
|
|
94
103
|
if (args.length === 0) return { type: "restart" };
|
|
95
104
|
if (args.length === 1 && args[0] === "--force") return { type: "restart", force: true };
|
|
96
105
|
throw new Error("/restart 只接受一个可选的 --force 参数。");
|
|
106
|
+
case "mute": {
|
|
107
|
+
if (args.length === 0 || (args.length === 1 && args[0]!.toLowerCase() === "on")) {
|
|
108
|
+
return { type: "mute", enabled: true };
|
|
109
|
+
}
|
|
110
|
+
if (args.length === 1 && args[0]!.toLowerCase() === "off") {
|
|
111
|
+
return { type: "mute", enabled: false };
|
|
112
|
+
}
|
|
113
|
+
throw new Error("/mute 只接受 on 或 off;不传参数等同于 /mute on。");
|
|
114
|
+
}
|
|
97
115
|
case "turns":
|
|
98
116
|
if (args.length > 0) throw new Error("/turns 不接受参数,请在历史轮次卡片中选择 turn。");
|
|
99
117
|
return { type: "turns" };
|
|
@@ -2,6 +2,7 @@ export type Command =
|
|
|
2
2
|
| { type: "shell"; command: string }
|
|
3
3
|
| { type: "new"; title?: string; cwd?: string; projectless?: boolean }
|
|
4
4
|
| { type: "newgroup"; title?: string; cwd?: string; projectless?: boolean }
|
|
5
|
+
| { type: "dir"; directory?: string }
|
|
5
6
|
| { type: "forkgroup"; title?: string }
|
|
6
7
|
| { type: "fork"; sessionId?: string }
|
|
7
8
|
| { type: "title"; title: string }
|
|
@@ -9,12 +10,14 @@ export type Command =
|
|
|
9
10
|
| { type: "sessions"; searchTerm?: string }
|
|
10
11
|
| { type: "switch"; sessionId?: string }
|
|
11
12
|
| { type: "agent"; agent?: string }
|
|
13
|
+
| { type: "archive"; sessionId?: string }
|
|
12
14
|
| { type: "stop" }
|
|
13
15
|
| { type: "status"; sessionId?: string }
|
|
14
16
|
| { type: "goal"; action: "show" }
|
|
15
17
|
| { type: "goal"; action: "set" | "edit"; objective: string }
|
|
16
18
|
| { type: "goal"; action: "pause" | "resume" | "clear" }
|
|
17
19
|
| { type: "restart"; force?: boolean }
|
|
20
|
+
| { type: "mute"; enabled: boolean }
|
|
18
21
|
| { type: "turns" }
|
|
19
22
|
| { type: "model" }
|
|
20
23
|
| { type: "provider" }
|
package/src/config/loadConfig.ts
CHANGED
|
@@ -15,7 +15,9 @@ const DEFAULT_CONFIG = `feishu:
|
|
|
15
15
|
appId: "\${FEISHU_APP_ID}"
|
|
16
16
|
appSecret: "\${FEISHU_APP_SECRET}"
|
|
17
17
|
userOpenId: "\${FEISHU_USER_OPEN_ID}"
|
|
18
|
+
respondToOwnerOnly: true
|
|
18
19
|
respondToAllGroupMessages: true
|
|
20
|
+
thinkingCardLayout: "grouped"
|
|
19
21
|
|
|
20
22
|
console:
|
|
21
23
|
enabled: true
|
package/src/config/schema.ts
CHANGED
|
@@ -28,7 +28,9 @@ export const appConfigSchema = z.object({
|
|
|
28
28
|
appId: z.string().optional(),
|
|
29
29
|
appSecret: z.string().optional(),
|
|
30
30
|
userOpenId: z.string().optional(),
|
|
31
|
+
respondToOwnerOnly: z.boolean().default(true),
|
|
31
32
|
respondToAllGroupMessages: z.boolean().default(true),
|
|
33
|
+
thinkingCardLayout: z.enum(["grouped", "timeline"]).default("grouped"),
|
|
32
34
|
useConsoleWhenMissingCredentials: z.boolean().default(false),
|
|
33
35
|
}),
|
|
34
36
|
agents: z.record(z.string().min(1), agentConfigSchema).refine(
|
|
@@ -27,8 +27,9 @@ export class ConsoleTurnPresenter implements TurnPresenter {
|
|
|
27
27
|
this.agentLabels.delete(sessionId);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
async startPendingTurn(sessionId: string, contextKey: string): Promise<
|
|
30
|
+
async startPendingTurn(sessionId: string, contextKey: string): Promise<string | undefined> {
|
|
31
31
|
await this.outbound.sendText(contextKey, `Connecting to ${this.agentLabel(sessionId)}...`);
|
|
32
|
+
return undefined;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
async failPendingTurn(sessionId: string, message: string): Promise<void> {
|
|
@@ -36,6 +37,8 @@ export class ConsoleTurnPresenter implements TurnPresenter {
|
|
|
36
37
|
if (contextKey) await this.outbound.sendText(contextKey, `${this.agentLabel(sessionId)} failed to start: ${message}`);
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
async interruptTurnForRecovery(): Promise<void> {}
|
|
41
|
+
|
|
39
42
|
async appendSteerMessage(): Promise<void> {}
|
|
40
43
|
|
|
41
44
|
async onEvent(event: AgentEvent): Promise<void> {
|