botmux 1.0.0
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/.env.example +24 -0
- package/LICENSE +21 -0
- package/README.en.md +267 -0
- package/README.md +267 -0
- package/dist/adapters/backend/pty-backend.d.ts +13 -0
- package/dist/adapters/backend/pty-backend.d.ts.map +1 -0
- package/dist/adapters/backend/pty-backend.js +39 -0
- package/dist/adapters/backend/pty-backend.js.map +1 -0
- package/dist/adapters/backend/tmux-backend.d.ts +20 -0
- package/dist/adapters/backend/tmux-backend.d.ts.map +1 -0
- package/dist/adapters/backend/tmux-backend.js +30 -0
- package/dist/adapters/backend/tmux-backend.js.map +1 -0
- package/dist/adapters/backend/types.d.ts +19 -0
- package/dist/adapters/backend/types.d.ts.map +1 -0
- package/dist/adapters/backend/types.js +2 -0
- package/dist/adapters/backend/types.js.map +1 -0
- package/dist/adapters/cli/aiden.d.ts +4 -0
- package/dist/adapters/cli/aiden.d.ts.map +1 -0
- package/dist/adapters/cli/aiden.js +63 -0
- package/dist/adapters/cli/aiden.js.map +1 -0
- package/dist/adapters/cli/claude-code.d.ts +4 -0
- package/dist/adapters/cli/claude-code.d.ts.map +1 -0
- package/dist/adapters/cli/claude-code.js +59 -0
- package/dist/adapters/cli/claude-code.js.map +1 -0
- package/dist/adapters/cli/coco.d.ts +4 -0
- package/dist/adapters/cli/coco.d.ts.map +1 -0
- package/dist/adapters/cli/coco.js +46 -0
- package/dist/adapters/cli/coco.js.map +1 -0
- package/dist/adapters/cli/codex.d.ts +4 -0
- package/dist/adapters/cli/codex.d.ts.map +1 -0
- package/dist/adapters/cli/codex.js +47 -0
- package/dist/adapters/cli/codex.js.map +1 -0
- package/dist/adapters/cli/registry.d.ts +13 -0
- package/dist/adapters/cli/registry.d.ts.map +1 -0
- package/dist/adapters/cli/registry.js +42 -0
- package/dist/adapters/cli/registry.js.map +1 -0
- package/dist/adapters/cli/types.d.ts +39 -0
- package/dist/adapters/cli/types.d.ts.map +1 -0
- package/dist/adapters/cli/types.js +2 -0
- package/dist/adapters/cli/types.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +245 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +39 -0
- package/dist/config.js.map +1 -0
- package/dist/core/command-handler.d.ts +11 -0
- package/dist/core/command-handler.d.ts.map +1 -0
- package/dist/core/command-handler.js +322 -0
- package/dist/core/command-handler.js.map +1 -0
- package/dist/core/cost-calculator.d.ts +12 -0
- package/dist/core/cost-calculator.d.ts.map +1 -0
- package/dist/core/cost-calculator.js +61 -0
- package/dist/core/cost-calculator.js.map +1 -0
- package/dist/core/scheduler.d.ts +38 -0
- package/dist/core/scheduler.d.ts.map +1 -0
- package/dist/core/scheduler.js +221 -0
- package/dist/core/scheduler.js.map +1 -0
- package/dist/core/session-manager.d.ts +13 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +125 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/types.d.ts +29 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/worker-pool.d.ts +26 -0
- package/dist/core/worker-pool.d.ts.map +1 -0
- package/dist/core/worker-pool.js +261 -0
- package/dist/core/worker-pool.js.map +1 -0
- package/dist/daemon.d.ts +3 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +344 -0
- package/dist/daemon.js.map +1 -0
- package/dist/im/lark/card-builder.d.ts +18 -0
- package/dist/im/lark/card-builder.d.ts.map +1 -0
- package/dist/im/lark/card-builder.js +194 -0
- package/dist/im/lark/card-builder.js.map +1 -0
- package/dist/im/lark/card-handler.d.ts +9 -0
- package/dist/im/lark/card-handler.d.ts.map +1 -0
- package/dist/im/lark/card-handler.js +131 -0
- package/dist/im/lark/card-handler.js.map +1 -0
- package/dist/im/lark/client.d.ts +23 -0
- package/dist/im/lark/client.d.ts.map +1 -0
- package/dist/im/lark/client.js +259 -0
- package/dist/im/lark/client.js.map +1 -0
- package/dist/im/lark/event-dispatcher.d.ts +34 -0
- package/dist/im/lark/event-dispatcher.d.ts.map +1 -0
- package/dist/im/lark/event-dispatcher.js +195 -0
- package/dist/im/lark/event-dispatcher.js.map +1 -0
- package/dist/im/lark/message-parser.d.ts +45 -0
- package/dist/im/lark/message-parser.d.ts.map +1 -0
- package/dist/im/lark/message-parser.js +132 -0
- package/dist/im/lark/message-parser.js.map +1 -0
- package/dist/im/types.d.ts +78 -0
- package/dist/im/types.d.ts.map +1 -0
- package/dist/im/types.js +2 -0
- package/dist/im/types.js.map +1 -0
- package/dist/index-daemon.d.ts +3 -0
- package/dist/index-daemon.d.ts.map +1 -0
- package/dist/index-daemon.js +21 -0
- package/dist/index-daemon.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/scheduler.d.ts +38 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +221 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +23 -0
- package/dist/server.js.map +1 -0
- package/dist/services/lark-client.d.ts +22 -0
- package/dist/services/lark-client.d.ts.map +1 -0
- package/dist/services/lark-client.js +238 -0
- package/dist/services/lark-client.js.map +1 -0
- package/dist/services/lark-ws.d.ts +5 -0
- package/dist/services/lark-ws.d.ts.map +1 -0
- package/dist/services/lark-ws.js +79 -0
- package/dist/services/lark-ws.js.map +1 -0
- package/dist/services/message-queue.d.ts +9 -0
- package/dist/services/message-queue.d.ts.map +1 -0
- package/dist/services/message-queue.js +77 -0
- package/dist/services/message-queue.js.map +1 -0
- package/dist/services/message-router.d.ts +8 -0
- package/dist/services/message-router.d.ts.map +1 -0
- package/dist/services/message-router.js +73 -0
- package/dist/services/message-router.js.map +1 -0
- package/dist/services/project-scanner.d.ts +12 -0
- package/dist/services/project-scanner.d.ts.map +1 -0
- package/dist/services/project-scanner.js +109 -0
- package/dist/services/project-scanner.js.map +1 -0
- package/dist/services/schedule-store.d.ts +14 -0
- package/dist/services/schedule-store.d.ts.map +1 -0
- package/dist/services/schedule-store.js +89 -0
- package/dist/services/schedule-store.js.map +1 -0
- package/dist/services/session-store.d.ts +8 -0
- package/dist/services/session-store.d.ts.map +1 -0
- package/dist/services/session-store.js +93 -0
- package/dist/services/session-store.js.map +1 -0
- package/dist/tools/close-session.d.ts +22 -0
- package/dist/tools/close-session.d.ts.map +1 -0
- package/dist/tools/close-session.js +38 -0
- package/dist/tools/close-session.js.map +1 -0
- package/dist/tools/create-session.d.ts +28 -0
- package/dist/tools/create-session.d.ts.map +1 -0
- package/dist/tools/create-session.js +40 -0
- package/dist/tools/create-session.js.map +1 -0
- package/dist/tools/get-thread-messages.d.ts +26 -0
- package/dist/tools/get-thread-messages.d.ts.map +1 -0
- package/dist/tools/get-thread-messages.js +33 -0
- package/dist/tools/get-thread-messages.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +10 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/react-to-message.d.ts +41 -0
- package/dist/tools/react-to-message.d.ts.map +1 -0
- package/dist/tools/react-to-message.js +30 -0
- package/dist/tools/react-to-message.js.map +1 -0
- package/dist/tools/send-to-thread.d.ts +24 -0
- package/dist/tools/send-to-thread.d.ts.map +1 -0
- package/dist/tools/send-to-thread.js +83 -0
- package/dist/tools/send-to-thread.js.map +1 -0
- package/dist/tools/wait-for-reply.d.ts +17 -0
- package/dist/tools/wait-for-reply.d.ts.map +1 -0
- package/dist/tools/wait-for-reply.js +65 -0
- package/dist/tools/wait-for-reply.js.map +1 -0
- package/dist/types.d.ts +85 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/card-builder.d.ts +16 -0
- package/dist/utils/card-builder.d.ts.map +1 -0
- package/dist/utils/card-builder.js +183 -0
- package/dist/utils/card-builder.js.map +1 -0
- package/dist/utils/idle-detector.d.ts +21 -0
- package/dist/utils/idle-detector.d.ts.map +1 -0
- package/dist/utils/idle-detector.js +95 -0
- package/dist/utils/idle-detector.js.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +22 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/message-parser.d.ts +45 -0
- package/dist/utils/message-parser.d.ts.map +1 -0
- package/dist/utils/message-parser.js +132 -0
- package/dist/utils/message-parser.js.map +1 -0
- package/dist/utils/terminal-renderer.d.ts +39 -0
- package/dist/utils/terminal-renderer.d.ts.map +1 -0
- package/dist/utils/terminal-renderer.js +186 -0
- package/dist/utils/terminal-renderer.js.map +1 -0
- package/dist/worker.d.ts +3 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +411 -0
- package/dist/worker.js.map +1 -0
- package/ecosystem.config.cjs +15 -0
- package/package.json +60 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ProjectInfo } from '../../services/project-scanner.js';
|
|
2
|
+
import type { CliId } from '../../adapters/cli/types.js';
|
|
3
|
+
export declare function getCliDisplayName(cliId: CliId): string;
|
|
4
|
+
/**
|
|
5
|
+
* Build a Feishu interactive card with terminal link + restart/close buttons.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildSessionCard(sessionId: string, rootId: string, terminalUrl: string, title: string, cliId?: CliId): string;
|
|
8
|
+
/**
|
|
9
|
+
* Build a Feishu streaming card that shows live terminal output + controls.
|
|
10
|
+
* This card is PATCHed in-place as Claude works.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildStreamingCard(sessionId: string, rootId: string, terminalUrl: string, title: string, screenContent: string, status: 'starting' | 'working' | 'idle', cliId?: CliId): string;
|
|
13
|
+
/**
|
|
14
|
+
* Build a Feishu interactive card with a dropdown selector for projects.
|
|
15
|
+
* Returns a JSON string suitable for msg_type: 'interactive'.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildRepoSelectCard(projects: ProjectInfo[], currentPath?: string, rootMessageId?: string): string;
|
|
18
|
+
//# sourceMappingURL=card-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-builder.d.ts","sourceRoot":"","sources":["../../../src/im/lark/card-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AASzD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAEtD;AAOD;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,KAAK,GACZ,MAAM,CAqDR;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,EACvC,KAAK,CAAC,EAAE,KAAK,GACZ,MAAM,CA4DR;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAyDjH"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
const cliDisplayNames = {
|
|
2
|
+
'claude-code': 'Claude',
|
|
3
|
+
'aiden': 'Aiden',
|
|
4
|
+
'coco': 'CoCo',
|
|
5
|
+
'codex': 'Codex',
|
|
6
|
+
};
|
|
7
|
+
export function getCliDisplayName(cliId) {
|
|
8
|
+
return cliDisplayNames[cliId] ?? cliId;
|
|
9
|
+
}
|
|
10
|
+
/** Escape Lark markdown special characters in user-controlled strings. */
|
|
11
|
+
function escapeMd(s) {
|
|
12
|
+
return s.replace(/[*_~`\[\]\\]/g, c => `\\${c}`);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build a Feishu interactive card with terminal link + restart/close buttons.
|
|
16
|
+
*/
|
|
17
|
+
export function buildSessionCard(sessionId, rootId, terminalUrl, title, cliId) {
|
|
18
|
+
const cliName = getCliDisplayName(cliId ?? 'claude-code');
|
|
19
|
+
const card = {
|
|
20
|
+
config: { wide_screen_mode: true },
|
|
21
|
+
header: {
|
|
22
|
+
title: { tag: 'plain_text', content: `🖥️ ${escapeMd(title)}` },
|
|
23
|
+
template: 'blue',
|
|
24
|
+
},
|
|
25
|
+
elements: [
|
|
26
|
+
{
|
|
27
|
+
tag: 'div',
|
|
28
|
+
text: {
|
|
29
|
+
tag: 'lark_md',
|
|
30
|
+
content: `**终端地址:** [${terminalUrl}](${terminalUrl})`,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
tag: 'action',
|
|
35
|
+
actions: [
|
|
36
|
+
{
|
|
37
|
+
tag: 'button',
|
|
38
|
+
text: { tag: 'plain_text', content: '🖥️ 打开终端' },
|
|
39
|
+
type: 'primary',
|
|
40
|
+
multi_url: {
|
|
41
|
+
url: terminalUrl,
|
|
42
|
+
pc_url: terminalUrl,
|
|
43
|
+
android_url: terminalUrl,
|
|
44
|
+
ios_url: terminalUrl,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
tag: 'button',
|
|
49
|
+
text: { tag: 'plain_text', content: '🔑 获取操作链接' },
|
|
50
|
+
type: 'default',
|
|
51
|
+
value: { action: 'get_write_link', root_id: rootId, session_id: sessionId },
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
tag: 'button',
|
|
55
|
+
text: { tag: 'plain_text', content: `🔄 重启 ${cliName}` },
|
|
56
|
+
type: 'default',
|
|
57
|
+
value: { action: 'restart', root_id: rootId, session_id: sessionId },
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
tag: 'button',
|
|
61
|
+
text: { tag: 'plain_text', content: '❌ 关闭会话' },
|
|
62
|
+
type: 'danger',
|
|
63
|
+
value: { action: 'close', root_id: rootId, session_id: sessionId },
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
return JSON.stringify(card);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Build a Feishu streaming card that shows live terminal output + controls.
|
|
73
|
+
* This card is PATCHed in-place as Claude works.
|
|
74
|
+
*/
|
|
75
|
+
export function buildStreamingCard(sessionId, rootId, terminalUrl, title, screenContent, status, cliId) {
|
|
76
|
+
const cliName = getCliDisplayName(cliId ?? 'claude-code');
|
|
77
|
+
const templateMap = { starting: 'yellow', working: 'blue', idle: 'green' };
|
|
78
|
+
const statusMap = { starting: '启动中…', working: '工作中', idle: '就绪' };
|
|
79
|
+
const displayContent = screenContent || '(等待输出…)';
|
|
80
|
+
const card = {
|
|
81
|
+
config: { wide_screen_mode: true },
|
|
82
|
+
header: {
|
|
83
|
+
title: { tag: 'plain_text', content: `🖥️ ${escapeMd(title)} — ${statusMap[status]}` },
|
|
84
|
+
template: templateMap[status],
|
|
85
|
+
},
|
|
86
|
+
elements: [
|
|
87
|
+
{
|
|
88
|
+
tag: 'markdown',
|
|
89
|
+
content: displayContent,
|
|
90
|
+
},
|
|
91
|
+
{ tag: 'hr' },
|
|
92
|
+
{
|
|
93
|
+
tag: 'markdown',
|
|
94
|
+
content: `**终端:** [${terminalUrl}](${terminalUrl})`,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
tag: 'action',
|
|
98
|
+
actions: [
|
|
99
|
+
{
|
|
100
|
+
tag: 'button',
|
|
101
|
+
text: { tag: 'plain_text', content: '🖥️ 打开终端' },
|
|
102
|
+
type: 'primary',
|
|
103
|
+
multi_url: {
|
|
104
|
+
url: terminalUrl,
|
|
105
|
+
pc_url: terminalUrl,
|
|
106
|
+
android_url: terminalUrl,
|
|
107
|
+
ios_url: terminalUrl,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
tag: 'button',
|
|
112
|
+
text: { tag: 'plain_text', content: '🔑 获取操作链接' },
|
|
113
|
+
type: 'default',
|
|
114
|
+
value: { action: 'get_write_link', root_id: rootId, session_id: sessionId },
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
tag: 'button',
|
|
118
|
+
text: { tag: 'plain_text', content: `🔄 重启 ${cliName}` },
|
|
119
|
+
type: 'default',
|
|
120
|
+
value: { action: 'restart', root_id: rootId, session_id: sessionId },
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
tag: 'button',
|
|
124
|
+
text: { tag: 'plain_text', content: '❌ 关闭会话' },
|
|
125
|
+
type: 'danger',
|
|
126
|
+
value: { action: 'close', root_id: rootId, session_id: sessionId },
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
};
|
|
132
|
+
return JSON.stringify(card);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Build a Feishu interactive card with a dropdown selector for projects.
|
|
136
|
+
* Returns a JSON string suitable for msg_type: 'interactive'.
|
|
137
|
+
*/
|
|
138
|
+
export function buildRepoSelectCard(projects, currentPath, rootMessageId) {
|
|
139
|
+
const options = projects.map((p, i) => {
|
|
140
|
+
const currentTag = p.path === currentPath ? ' ← 当前' : '';
|
|
141
|
+
const typeTag = p.type === 'worktree' ? ' [worktree]' : '';
|
|
142
|
+
return {
|
|
143
|
+
text: { tag: 'plain_text', content: `${i + 1}. ${p.name} (${p.branch})${typeTag}${currentTag}` },
|
|
144
|
+
value: p.path,
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
const card = {
|
|
148
|
+
config: { wide_screen_mode: true },
|
|
149
|
+
header: {
|
|
150
|
+
template: 'blue',
|
|
151
|
+
title: { tag: 'plain_text', content: '📁 项目仓库管理' },
|
|
152
|
+
},
|
|
153
|
+
elements: [
|
|
154
|
+
{
|
|
155
|
+
tag: 'div',
|
|
156
|
+
text: {
|
|
157
|
+
tag: 'lark_md',
|
|
158
|
+
content: `当前活跃项目:**${escapeMd(currentPath ?? 'N/A')}**`,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
tag: 'hr',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
tag: 'action',
|
|
166
|
+
actions: [
|
|
167
|
+
{
|
|
168
|
+
tag: 'select_static',
|
|
169
|
+
placeholder: { tag: 'plain_text', content: '选择仓库并切换' },
|
|
170
|
+
options,
|
|
171
|
+
value: { key: 'repo_switch', root_id: rootMessageId ?? '' },
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
tag: 'button',
|
|
175
|
+
text: { tag: 'plain_text', content: '▶️ 直接开启会话' },
|
|
176
|
+
type: 'primary',
|
|
177
|
+
value: { action: 'skip_repo', root_id: rootMessageId ?? '' },
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
tag: 'note',
|
|
183
|
+
elements: [
|
|
184
|
+
{
|
|
185
|
+
tag: 'lark_md',
|
|
186
|
+
content: '也可以回复 `/repo <编号>` 切换,例如:`/repo 1`',
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
};
|
|
192
|
+
return JSON.stringify(card);
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=card-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-builder.js","sourceRoot":"","sources":["../../../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,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE;SACnD;QACD,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,KAAK;gBACV,IAAI,EAAE;oBACJ,GAAG,EAAE,SAAS;oBACd,OAAO,EAAE,YAAY,QAAQ,CAAC,WAAW,IAAI,KAAK,CAAC,IAAI;iBACxD;aACF;YACD;gBACE,GAAG,EAAE,IAAI;aACV;YACD;gBACE,GAAG,EAAE,QAAQ;gBACb,OAAO,EAAE;oBACP;wBACE,GAAG,EAAE,eAAe;wBACpB,WAAW,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE;wBACtD,OAAO;wBACP,KAAK,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,IAAI,EAAE,EAAE;qBAC5D;oBACD;wBACE,GAAG,EAAE,QAAQ;wBACb,IAAI,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE;wBACjD,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,IAAI,EAAE,EAAE;qBAC7D;iBACF;aACF;YACD;gBACE,GAAG,EAAE,MAAM;gBACX,QAAQ,EAAE;oBACR;wBACE,GAAG,EAAE,SAAS;wBACd,OAAO,EAAE,oCAAoC;qBAC9C;iBACF;aACF;SACF;KACF,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DaemonSession } from '../../core/types.js';
|
|
2
|
+
import type { ProjectInfo } from '../../services/project-scanner.js';
|
|
3
|
+
export interface CardHandlerDeps {
|
|
4
|
+
activeSessions: Map<string, DaemonSession>;
|
|
5
|
+
sessionReply: (rootId: string, content: string, msgType?: string) => Promise<string>;
|
|
6
|
+
lastRepoScan: Map<string, ProjectInfo[]>;
|
|
7
|
+
}
|
|
8
|
+
export declare function handleCardAction(data: any, deps: CardHandlerDeps): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=card-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-handler.d.ts","sourceRoot":"","sources":["../../../src/im/lark/card-handler.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAIrE,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3C,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrF,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;CAC1C;AAUD,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA0ItF"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lark card action handler — processes button clicks and dropdown selections
|
|
3
|
+
* from Feishu interactive cards.
|
|
4
|
+
* Extracted from daemon.ts for modularity.
|
|
5
|
+
*/
|
|
6
|
+
import { config } from '../../config.js';
|
|
7
|
+
import { sendUserMessage } from './client.js';
|
|
8
|
+
import { buildSessionCard, getCliDisplayName } from './card-builder.js';
|
|
9
|
+
import { logger } from '../../utils/logger.js';
|
|
10
|
+
import * as sessionStore from '../../services/session-store.js';
|
|
11
|
+
import { forkWorker, killWorker } from '../../core/worker-pool.js';
|
|
12
|
+
import { getSessionWorkingDir, buildNewTopicPrompt } from '../../core/session-manager.js';
|
|
13
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────
|
|
14
|
+
function tag(ds) {
|
|
15
|
+
return ds.session.sessionId.substring(0, 8);
|
|
16
|
+
}
|
|
17
|
+
// ─── Main handler ─────────────────────────────────────────────────────────
|
|
18
|
+
export async function handleCardAction(data, deps) {
|
|
19
|
+
const { activeSessions, sessionReply, lastRepoScan } = deps;
|
|
20
|
+
const action = data?.action;
|
|
21
|
+
const value = action?.value;
|
|
22
|
+
// Check ALLOWED_USERS for sensitive actions
|
|
23
|
+
const operatorOpenId = data?.operator?.open_id;
|
|
24
|
+
const allowedUsers = config.daemon.allowedUsers;
|
|
25
|
+
const isSensitive = value?.action && ['restart', 'close', 'skip_repo', 'get_write_link'].includes(value.action);
|
|
26
|
+
if (isSensitive && allowedUsers.length > 0) {
|
|
27
|
+
if (!operatorOpenId || !allowedUsers.includes(operatorOpenId)) {
|
|
28
|
+
logger.info(`Card action "${value.action}" blocked for non-allowed user: ${operatorOpenId}`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Handle session card button actions (restart/close)
|
|
33
|
+
if (value?.action) {
|
|
34
|
+
const { action: actionType, root_id: rootId } = value;
|
|
35
|
+
const ds = activeSessions.get(rootId);
|
|
36
|
+
if (actionType === 'restart' && ds) {
|
|
37
|
+
if (ds.worker) {
|
|
38
|
+
// Worker alive — tell it to restart Claude
|
|
39
|
+
logger.info(`[${tag(ds)}] Restart via card button`);
|
|
40
|
+
ds.worker.send({ type: 'restart' });
|
|
41
|
+
const cliName = getCliDisplayName(config.daemon.cliId);
|
|
42
|
+
await sessionReply(rootId, `🔄 已重启 ${cliName}`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// Worker gone (e.g. after daemon restart) — re-fork
|
|
46
|
+
logger.info(`[${tag(ds)}] Re-forking worker via card button`);
|
|
47
|
+
forkWorker(ds, '', ds.hasHistory);
|
|
48
|
+
const cliName = getCliDisplayName(config.daemon.cliId);
|
|
49
|
+
await sessionReply(rootId, `🔄 已重新启动 ${cliName}`);
|
|
50
|
+
// DM card will be sent by the ready handler when worker starts
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (actionType === 'close' && ds) {
|
|
54
|
+
killWorker(ds);
|
|
55
|
+
sessionStore.closeSession(ds.session.sessionId);
|
|
56
|
+
activeSessions.delete(rootId);
|
|
57
|
+
await sessionReply(rootId, '✅ 会话已关闭');
|
|
58
|
+
logger.info(`[${tag(ds)}] Closed via card button`);
|
|
59
|
+
}
|
|
60
|
+
if (actionType === 'get_write_link' && ds && operatorOpenId) {
|
|
61
|
+
if (ds.workerPort && ds.workerToken) {
|
|
62
|
+
const writeUrl = `http://${config.web.externalHost}:${ds.workerPort}?token=${ds.workerToken}`;
|
|
63
|
+
const dmCardJson = buildSessionCard(ds.session.sessionId, ds.session.rootMessageId, writeUrl, ds.session.title || 'Claude Code', config.daemon.cliId);
|
|
64
|
+
sendUserMessage(operatorOpenId, dmCardJson, 'interactive').catch(err => logger.warn(`[${tag(ds)}] Failed to DM write link: ${err}`));
|
|
65
|
+
logger.info(`[${tag(ds)}] Sent write link via DM to ${operatorOpenId}`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
await sessionReply(rootId, '⚠️ 终端尚未就绪,请稍后再试。');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (actionType === 'skip_repo' && ds && ds.pendingRepo) {
|
|
72
|
+
// Skip repo selection — spawn Claude with default working dir
|
|
73
|
+
ds.pendingRepo = false;
|
|
74
|
+
const prompt = buildNewTopicPrompt(ds.pendingPrompt ?? '', ds.session.sessionId, ds.pendingAttachments);
|
|
75
|
+
ds.pendingPrompt = undefined;
|
|
76
|
+
ds.pendingAttachments = undefined;
|
|
77
|
+
forkWorker(ds, prompt);
|
|
78
|
+
const cwd = getSessionWorkingDir(ds);
|
|
79
|
+
await sessionReply(rootId, `▶️ 已直接开启会话(工作目录:${cwd})`);
|
|
80
|
+
logger.info(`[${tag(ds)}] Skip repo, spawning Claude in ${cwd}`);
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Handle repo select card (option-based dropdown)
|
|
85
|
+
const option = action?.option;
|
|
86
|
+
if (!option) {
|
|
87
|
+
logger.warn('Card action received but no option or action value');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const selectedPath = option;
|
|
91
|
+
const rootId = action?.value?.root_id;
|
|
92
|
+
logger.info(`Card action: repo switch to ${selectedPath} (root_id: ${rootId})`);
|
|
93
|
+
if (!rootId) {
|
|
94
|
+
logger.warn('Card action: no root_id in action value');
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const targetDs = activeSessions.get(rootId);
|
|
98
|
+
if (!targetDs) {
|
|
99
|
+
logger.warn(`Card action: no active session found for root ${rootId}`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// Resolve the project name from cached scan
|
|
103
|
+
const cached = lastRepoScan.get(targetDs.chatId);
|
|
104
|
+
const project = cached?.find(p => p.path === selectedPath);
|
|
105
|
+
const displayName = project ? `${project.name} (${project.branch})` : selectedPath;
|
|
106
|
+
targetDs.workingDir = selectedPath;
|
|
107
|
+
targetDs.session.workingDir = selectedPath;
|
|
108
|
+
sessionStore.updateSession(targetDs.session);
|
|
109
|
+
if (targetDs.pendingRepo) {
|
|
110
|
+
// First-time repo selection — now spawn Claude with the original prompt
|
|
111
|
+
targetDs.pendingRepo = false;
|
|
112
|
+
const prompt = buildNewTopicPrompt(targetDs.pendingPrompt ?? '', targetDs.session.sessionId, targetDs.pendingAttachments);
|
|
113
|
+
targetDs.pendingPrompt = undefined;
|
|
114
|
+
targetDs.pendingAttachments = undefined;
|
|
115
|
+
forkWorker(targetDs, prompt);
|
|
116
|
+
await sessionReply(rootId, `✅ 已选择 ${displayName}`);
|
|
117
|
+
logger.info(`[${tag(targetDs)}] Repo selected: ${selectedPath}, spawning Claude`);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// Mid-session repo switch — close old session, start fresh
|
|
121
|
+
killWorker(targetDs);
|
|
122
|
+
sessionStore.closeSession(targetDs.session.sessionId);
|
|
123
|
+
const session = sessionStore.createSession(targetDs.chatId, rootId, displayName, targetDs.chatType);
|
|
124
|
+
targetDs.session = session;
|
|
125
|
+
targetDs.hasHistory = false;
|
|
126
|
+
forkWorker(targetDs, '', false);
|
|
127
|
+
await sessionReply(rootId, `🔄 已切换到 ${displayName}\n旧会话已关闭,新会话已创建。`);
|
|
128
|
+
logger.info(`[${tag(targetDs)}] Repo switched to ${selectedPath}, new session created`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=card-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-handler.js","sourceRoot":"","sources":["../../../src/im/lark/card-handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAa1F,6EAA6E;AAE7E,SAAS,GAAG,CAAC,EAAiB;IAC5B,OAAO,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,6EAA6E;AAE7E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAS,EAAE,IAAqB;IACrE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC5D,MAAM,MAAM,GAAG,IAAI,EA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C5B,CAAC;QACF,QAAQ,CAAC,aAAa,GAAG,SAAS,CAAC;QACnC,QAAQ,CAAC,kBAAkB,GAAG,SAAS,CAAC;QACxC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7B,MAAM,YAAY,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,oBAAoB,YAAY,mBAAmB,CAAC,CAAC;IACpF,CAAC;SAAM,CAAC;QACN,2DAA2D;QAC3D,UAAU,CAAC,QAAQ,CAAC,CAAC;QACrB,YAAY,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACtD,MAAM,OAAO,GAAG,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpG,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,QAAQ,CAAC,UAAU,GAAG,KAAK,CAAC;QAC5B,UAAU,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;QAChC,MAAM,YAAY,CAAC,MAAM,EAAE,WAAW,WAAW,kBAAkB,CAAC,CAAC;QACrE,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,sBAAsB,YAAY,uBAAuB,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as Lark from '@larksuiteoapi/node-sdk';
|
|
2
|
+
export declare function getLarkClient(): Lark.Client;
|
|
3
|
+
export declare function sendMessage(chatId: string, content: string, msgType?: string): Promise<string>;
|
|
4
|
+
export declare function replyMessage(messageId: string, content: string, msgType?: string, replyInThread?: boolean): Promise<string>;
|
|
5
|
+
export declare function addReaction(messageId: string, emojiType: string): Promise<string>;
|
|
6
|
+
export declare function removeReaction(messageId: string, reactionId: string): Promise<void>;
|
|
7
|
+
export declare function sendUserMessage(openId: string, content: string, msgType?: string): Promise<string>;
|
|
8
|
+
export declare function getChatInfo(chatId: string): Promise<{
|
|
9
|
+
userCount: number;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function updateMessage(messageId: string, cardJson: string): Promise<void>;
|
|
12
|
+
export declare function getMessageDetail(messageId: string): Promise<any>;
|
|
13
|
+
export declare function downloadMessageResource(messageId: string, fileKey: string, type: 'image' | 'file', savePath: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve email prefixes (e.g. "john.doe") to Lark open_ids via batch user lookup.
|
|
16
|
+
* Accepts mixed input: items starting with "ou_" are kept as-is; everything else
|
|
17
|
+
* is treated as an email and looked up. If no "@" is present, `LARK_EMAIL_DOMAIN`
|
|
18
|
+
* env var is used as the default domain (e.g. `john.doe` → `john.doe@example.com`).
|
|
19
|
+
* Returns an array of open_ids (unresolvable entries are dropped with a warning).
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveAllowedUsers(raw: string[]): Promise<string[]>;
|
|
22
|
+
export declare function listThreadMessages(chatId: string, rootMessageId: string, pageSize?: number): Promise<any[]>;
|
|
23
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/im/lark/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAQhD,wBAAgB,aAAa,IAAI,IAAI,CAAC,MAAM,CAmB3C;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAqB5G;AAED,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAe,EAAE,aAAa,GAAE,OAAe,GAAG,OAAO,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