@keyou007/agent-bot 0.1.13-alpha.1 → 0.1.13-alpha.3
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 +11 -0
- package/README.md +106 -103
- package/README.zh.md +76 -73
- package/dist/acp/AcpProcessManager.js +8 -3
- package/dist/acp/AcpProcessManager.js.map +1 -1
- package/dist/acp/AcpSessionManager.js +15 -0
- package/dist/acp/AcpSessionManager.js.map +1 -1
- package/dist/cli/InitializationWelcome.js +116 -0
- package/dist/cli/InitializationWelcome.js.map +1 -0
- package/dist/cli/help.js +4 -2
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/serverStatus.js +27 -0
- package/dist/cli/serverStatus.js.map +1 -1
- package/dist/cli/taskListOutput.js +72 -0
- package/dist/cli/taskListOutput.js.map +1 -0
- package/dist/cli.js +103 -56
- package/dist/cli.js.map +1 -1
- package/dist/codex/CodexProcessManager.js +34 -4
- package/dist/codex/CodexProcessManager.js.map +1 -1
- package/dist/codex/CodexRuntime.js +3 -0
- package/dist/codex/CodexRuntime.js.map +1 -1
- package/dist/feishu/CardRenderer.js +164 -2
- package/dist/feishu/CardRenderer.js.map +1 -1
- package/dist/feishu/FeishuConnector.js +16 -5
- package/dist/feishu/FeishuConnector.js.map +1 -1
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/proxy/ProxySessionController.js +157 -59
- package/dist/proxy/ProxySessionController.js.map +1 -1
- package/dist/runtime/AcpRuntimeAdapter.js +3 -0
- package/dist/runtime/AcpRuntimeAdapter.js.map +1 -1
- package/dist/runtime/agentEnvironment.js +24 -4
- package/dist/runtime/agentEnvironment.js.map +1 -1
- package/dist/runtime/createAgentRuntimeRegistry.js +7 -3
- package/dist/runtime/createAgentRuntimeRegistry.js.map +1 -1
- package/dist/state/StateStore.js +12 -9
- package/dist/state/StateStore.js.map +1 -1
- package/dist/supervision/SafeRestartNotifier.js +1 -9
- package/dist/supervision/SafeRestartNotifier.js.map +1 -1
- package/docs/technical-reference.md +12 -4
- package/docs/technical-reference.zh.md +12 -4
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/skills/agent-bot/SKILL.md +53 -22
- package/src/acp/AcpProcessManager.ts +16 -3
- package/src/acp/AcpSessionManager.ts +14 -0
- package/src/cli/InitializationWelcome.ts +160 -0
- package/src/cli/help.ts +4 -2
- package/src/cli/serverStatus.ts +28 -0
- package/src/cli/taskListOutput.ts +91 -0
- package/src/cli.ts +140 -55
- package/src/codex/CodexProcessManager.ts +38 -3
- package/src/codex/CodexRuntime.ts +6 -0
- package/src/feishu/CardRenderer.ts +204 -1
- package/src/feishu/FeishuConnector.ts +13 -4
- package/src/index.ts +35 -3
- package/src/proxy/ProxySessionController.ts +186 -59
- package/src/runtime/AcpRuntimeAdapter.ts +5 -0
- package/src/runtime/agentEnvironment.ts +41 -3
- package/src/runtime/createAgentRuntimeRegistry.ts +18 -3
- package/src/runtime/types.ts +5 -0
- package/src/state/StateStore.ts +12 -9
- package/src/supervision/SafeRestartNotifier.ts +1 -11
|
@@ -18,6 +18,109 @@ const MESSAGE_CANCELLED_REACTION = "CrossMark";
|
|
|
18
18
|
const SESSION_PAGE_SIZE = 5;
|
|
19
19
|
const RESET_HISTORY_PAGE_SIZE = 10;
|
|
20
20
|
const REMOTE_SESSION_REFERENCE_PREFIX = "agent-runtime:";
|
|
21
|
+
const HELP_COMMAND_SECTIONS = [
|
|
22
|
+
{
|
|
23
|
+
title: "任务管理",
|
|
24
|
+
commands: [
|
|
25
|
+
{
|
|
26
|
+
command: "/new",
|
|
27
|
+
usage: "[title] [--dir <cwd> | --nodir]",
|
|
28
|
+
description: "使用默认 Agent 创建任务;--nodir 创建 Projectless 任务",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
command: "/newgroup",
|
|
32
|
+
usage: "[title] [--dir <cwd> | --nodir]",
|
|
33
|
+
description: "创建飞书群和新任务",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
command: "/forkgroup",
|
|
37
|
+
usage: "[title]",
|
|
38
|
+
description: "从当前任务最近完成轮次创建分支群",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
command: "/fork",
|
|
42
|
+
usage: "[序号或任务 ID]",
|
|
43
|
+
description: "从当前或指定任务最近完成轮次创建分支",
|
|
44
|
+
},
|
|
45
|
+
{ command: "/turns", description: "浏览历史轮次,并可 Reset 对话上下文" },
|
|
46
|
+
{
|
|
47
|
+
command: "/title",
|
|
48
|
+
usage: "<新标题>",
|
|
49
|
+
description: "修改当前任务标题",
|
|
50
|
+
requiresArgument: true,
|
|
51
|
+
},
|
|
52
|
+
{ command: "/sessions", usage: "[关键词]", description: "查找本机任务" },
|
|
53
|
+
{
|
|
54
|
+
command: "/switch",
|
|
55
|
+
usage: "[序号或任务 ID]",
|
|
56
|
+
description: "切换任务;不填参数切回上一个任务",
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: "执行设置",
|
|
62
|
+
commands: [
|
|
63
|
+
{
|
|
64
|
+
command: "!",
|
|
65
|
+
usage: "<命令>",
|
|
66
|
+
description: "在当前任务目录执行本地命令",
|
|
67
|
+
requiresArgument: true,
|
|
68
|
+
},
|
|
69
|
+
{ command: "/stop", description: "停止当前执行" },
|
|
70
|
+
{
|
|
71
|
+
command: "/queue",
|
|
72
|
+
usage: "<prompt>",
|
|
73
|
+
description: "将 Prompt 排队为后续轮次",
|
|
74
|
+
requiresArgument: true,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
command: "/nosteer",
|
|
78
|
+
usage: "<prompt>",
|
|
79
|
+
description: "与 /queue 相同",
|
|
80
|
+
requiresArgument: true,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
command: "/goal",
|
|
84
|
+
usage: "<目标或操作>",
|
|
85
|
+
description: "查看或创建长任务 Goal;支持 pause、resume、edit、clear",
|
|
86
|
+
requiresArgument: true,
|
|
87
|
+
},
|
|
88
|
+
{ command: "/provider", description: "选择 AI 服务提供商" },
|
|
89
|
+
{ command: "/model", description: "选择当前任务使用的模型" },
|
|
90
|
+
{ command: "/thinking", description: "设置模型的思考强度" },
|
|
91
|
+
{ command: "/permissions", description: "设置执行工具前是否需要确认" },
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title: "Agent",
|
|
96
|
+
commands: [
|
|
97
|
+
{
|
|
98
|
+
command: "/agent",
|
|
99
|
+
usage: "[name]",
|
|
100
|
+
description: "选择新任务使用的默认 Agent",
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
title: "系统",
|
|
106
|
+
commands: [
|
|
107
|
+
{
|
|
108
|
+
command: "/status",
|
|
109
|
+
usage: "[序号或任务 ID]",
|
|
110
|
+
description: "查看当前或指定任务状态",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
command: "/restart",
|
|
114
|
+
usage: "[--force]",
|
|
115
|
+
description: "默认安全重启;--force 立即重启",
|
|
116
|
+
},
|
|
117
|
+
{ command: "/help", description: "显示本帮助" },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
const HELP_DEFAULT_COMMANDS = new Set(HELP_COMMAND_SECTIONS.flatMap((section) => section.commands)
|
|
122
|
+
.filter((command) => !command.requiresArgument)
|
|
123
|
+
.map((command) => command.command));
|
|
21
124
|
export class ProxySessionController {
|
|
22
125
|
config;
|
|
23
126
|
store;
|
|
@@ -169,7 +272,10 @@ export class ProxySessionController {
|
|
|
169
272
|
await this.outbound.withReplyTarget(contextKey, replyTarget, async () => {
|
|
170
273
|
try {
|
|
171
274
|
const kind = String(scopedAction.value.action ?? "");
|
|
172
|
-
if (kind === "
|
|
275
|
+
if (kind === "help_command") {
|
|
276
|
+
await this.executeHelpCommandAction(scopedAction, contextKey, replyTarget);
|
|
277
|
+
}
|
|
278
|
+
else if (kind === "turn_details") {
|
|
173
279
|
await this.outbound.showDetails(contextKey, String(scopedAction.value.turnId ?? ""));
|
|
174
280
|
}
|
|
175
281
|
else if (kind === "activity_history") {
|
|
@@ -1564,7 +1670,7 @@ export class ProxySessionController {
|
|
|
1564
1670
|
this.store.saveTurnRuntimeOrigin(event.turnId, source.localSessionId, source.agentName, source.remoteSessionId);
|
|
1565
1671
|
}
|
|
1566
1672
|
if (event.type === "turn_started") {
|
|
1567
|
-
this.store.saveTurnParent(event.turnId, event.sessionId, source
|
|
1673
|
+
this.store.saveTurnParent(event.turnId, event.sessionId, this.completedParentTurnId(source));
|
|
1568
1674
|
}
|
|
1569
1675
|
}
|
|
1570
1676
|
if (event.type === "session_metadata_updated") {
|
|
@@ -1658,6 +1764,14 @@ export class ProxySessionController {
|
|
|
1658
1764
|
}
|
|
1659
1765
|
}
|
|
1660
1766
|
}
|
|
1767
|
+
completedParentTurnId(source) {
|
|
1768
|
+
if (!source?.lastTurnId)
|
|
1769
|
+
return undefined;
|
|
1770
|
+
if (source.lastTurnStatus === "completed")
|
|
1771
|
+
return source.lastTurnId;
|
|
1772
|
+
const snapshot = turnViewSnapshot(this.store.getTurnSnapshot(source.lastTurnId));
|
|
1773
|
+
return snapshot?.status === "completed" ? source.lastTurnId : undefined;
|
|
1774
|
+
}
|
|
1661
1775
|
async finalizeStandaloneMessageReaction(messageId, status) {
|
|
1662
1776
|
const reaction = this.store.claimMessageReaction(messageId);
|
|
1663
1777
|
if (reaction)
|
|
@@ -2498,11 +2612,9 @@ export class ProxySessionController {
|
|
|
2498
2612
|
const card = this.cardRenderer.renderTaskListCard(searchTerm ? `App Server 任务:${searchTerm}` : "App Server 任务", activeCount > 0 ? `任务(${activeCount} 个活跃)` : "任务", cardEntries, [
|
|
2499
2613
|
...(remoteHint ? [remoteHint] : []),
|
|
2500
2614
|
`第 ${page + 1} 页 · 每页 ${SESSION_PAGE_SIZE} 个任务${hasNext ? "" : ` · 当前共 ${entries.length} 个任务`}`,
|
|
2501
|
-
"
|
|
2502
|
-
"
|
|
2503
|
-
"
|
|
2504
|
-
"发送 **/fork [序号或任务 ID]**,可从当前或指定任务创建分支;任务运行中时使用最近已完成轮次。",
|
|
2505
|
-
"点击 **Status**,或发送 **/status [序号或任务 ID]**,查看当前或指定任务状态。",
|
|
2615
|
+
"",
|
|
2616
|
+
"> **Switch** 切换任务;**Stop** 停止运行;**Status** 查看状态。",
|
|
2617
|
+
"> **New** / **Fork** 新建 / 分支任务;**NewGroup** / **ForkGroup** 新建 / 分支群。",
|
|
2506
2618
|
], [
|
|
2507
2619
|
...(hasPrevious ? [{
|
|
2508
2620
|
text: "Previous",
|
|
@@ -2915,59 +3027,45 @@ export class ProxySessionController {
|
|
|
2915
3027
|
else
|
|
2916
3028
|
await this.outbound.sendInteractiveCard(contextKey, card);
|
|
2917
3029
|
}
|
|
3030
|
+
async executeHelpCommandAction(action, contextKey, replyTarget) {
|
|
3031
|
+
const commandText = typeof action.value.command === "string"
|
|
3032
|
+
? action.value.command.trim()
|
|
3033
|
+
: "";
|
|
3034
|
+
if (!HELP_DEFAULT_COMMANDS.has(commandText)) {
|
|
3035
|
+
throw new Error("帮助卡片中的命令无效,请发送 /help 获取最新卡片。");
|
|
3036
|
+
}
|
|
3037
|
+
const command = this.router.parse(commandText);
|
|
3038
|
+
await this.execute(contextKey, command, undefined, replyTarget, undefined, action.userId);
|
|
3039
|
+
}
|
|
2918
3040
|
async help(contextKey) {
|
|
2919
|
-
const sections =
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
"**/queue <prompt>**(兼容 **/nosteer**) 不追加到当前轮次,按顺序排队为后续轮次",
|
|
2948
|
-
"**/goal [目标]** 查看或创建长任务 Goal;支持 pause、resume、edit、clear",
|
|
2949
|
-
"**/provider** 选择 AI 服务提供商;没有其他候选时仅显示当前 Provider",
|
|
2950
|
-
"**/model** 选择当前任务使用的模型",
|
|
2951
|
-
"**/thinking** 设置模型的思考强度",
|
|
2952
|
-
"**/permissions** 设置执行工具前是否需要确认",
|
|
2953
|
-
],
|
|
2954
|
-
},
|
|
2955
|
-
{
|
|
2956
|
-
title: "Agent",
|
|
2957
|
-
lines: [
|
|
2958
|
-
"**/agent [name]** 选择新任务使用的默认 Agent;仅配置一个时直接显示当前 Agent",
|
|
2959
|
-
],
|
|
2960
|
-
},
|
|
2961
|
-
{
|
|
2962
|
-
title: "系统",
|
|
2963
|
-
lines: [
|
|
2964
|
-
"**/status [序号或任务 ID]** 查看当前或指定任务的详细状态",
|
|
2965
|
-
"**/restart [--force]** 默认安全重启;--force 立即重启",
|
|
2966
|
-
"**/help** 显示本帮助",
|
|
2967
|
-
],
|
|
2968
|
-
},
|
|
2969
|
-
];
|
|
2970
|
-
await this.outbound.sendInteractiveCard(contextKey, this.cardRenderer.renderSectionsCard("Agent Bot 使用帮助", sections));
|
|
3041
|
+
const sections = HELP_COMMAND_SECTIONS.map((section) => ({
|
|
3042
|
+
title: section.title,
|
|
3043
|
+
commands: section.commands.map((command) => ({
|
|
3044
|
+
text: command.command,
|
|
3045
|
+
...(command.requiresArgument
|
|
3046
|
+
? {}
|
|
3047
|
+
: {
|
|
3048
|
+
action: {
|
|
3049
|
+
text: command.command,
|
|
3050
|
+
value: {
|
|
3051
|
+
action: "help_command",
|
|
3052
|
+
command: command.command,
|
|
3053
|
+
contextKey,
|
|
3054
|
+
},
|
|
3055
|
+
},
|
|
3056
|
+
}),
|
|
3057
|
+
...(command.usage ? { usage: command.usage } : {}),
|
|
3058
|
+
description: command.description,
|
|
3059
|
+
})),
|
|
3060
|
+
}));
|
|
3061
|
+
await this.outbound.sendInteractiveCard(contextKey, this.cardRenderer.renderHelpCard("Agent Bot 使用帮助", [
|
|
3062
|
+
"直接发送消息即可继续当前任务;执行中发送的新消息会追加到本次任务。",
|
|
3063
|
+
"点击命令按钮可执行默认形式;有必填参数的命令需要手动发送。",
|
|
3064
|
+
"> 命令前缀示例:/sess 等同于 /sessions。",
|
|
3065
|
+
"> 命令缩写示例:/fg 等同于 /forkgroup。",
|
|
3066
|
+
"前缀或缩写匹配多个命令时,需要输入更长的形式。",
|
|
3067
|
+
"**[参数]** 可选 **<参数>** 必填",
|
|
3068
|
+
], sections));
|
|
2971
3069
|
}
|
|
2972
3070
|
ensureAgent(agentName) {
|
|
2973
3071
|
const agent = this.config.agents[agentName];
|