chatccc 0.2.61 → 0.2.63
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/config.sample.json +3 -2
- package/im-skills/feishu-skill/download-video.mjs +17 -10
- package/im-skills/wechat-file-skill/receive-send-file.md +42 -0
- package/im-skills/wechat-file-skill/send-file.mjs +101 -0
- package/im-skills/wechat-file-skill/skill.md +11 -0
- package/im-skills/{wechat-skill → wechat-image-skill}/receive-send-image.md +39 -39
- package/im-skills/{wechat-skill → wechat-image-skill}/send-image.mjs +84 -80
- package/im-skills/{wechat-skill → wechat-image-skill}/skill.md +11 -11
- package/im-skills/wechat-video-skill/receive-send-video.md +41 -0
- package/im-skills/wechat-video-skill/send-video.mjs +84 -0
- package/im-skills/wechat-video-skill/skill.md +11 -0
- package/package.json +59 -59
- package/src/__tests__/im-skills.test.ts +57 -2
- package/src/__tests__/orchestrator.test.ts +1 -1
- package/src/__tests__/wechat-platform.test.ts +65 -0
- package/src/config.ts +24 -2
- package/src/index.ts +5 -2
- package/src/orchestrator.ts +4 -3
- package/src/session.ts +7 -3
- package/src/web-ui.ts +26 -3
- package/src/wechat-platform.ts +170 -30
package/package.json
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "chatccc",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Feishu bot bridge for Claude Code",
|
|
5
|
-
"license": "Apache-2.0",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./src/index.ts",
|
|
8
|
-
"bin": {
|
|
9
|
-
"chatccc": "bin/chatccc.mjs"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"src/",
|
|
13
|
-
"bin/",
|
|
14
|
-
"demo/ilink_echo_probe.ts",
|
|
15
|
-
"im-skills/",
|
|
16
|
-
"images/img_readme_*.jpg",
|
|
17
|
-
"images/img_readme_*.png",
|
|
18
|
-
"images/avatars/status_*.png",
|
|
19
|
-
"images/avatars/badges/",
|
|
20
|
-
"package.json",
|
|
21
|
-
"README.md",
|
|
22
|
-
"config.sample.json"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"dev": "tsx src/index.ts",
|
|
26
|
-
"chatccc": "tsx src/index.ts",
|
|
27
|
-
"start": "tsx src/index.ts",
|
|
28
|
-
"demo:bot-test": "tsx demo/bot_test.ts",
|
|
29
|
-
"demo:bot-test:local": "tsx demo/bot_test.ts --local",
|
|
30
|
-
"demo:create-group": "tsx src/index.ts",
|
|
31
|
-
"demo:create-group:local": "tsx src/index.ts --local",
|
|
32
|
-
"demo:permission-check": "tsx demo/permission_check.ts",
|
|
33
|
-
"demo:claude-hi": "tsx demo/claude_say_hi.ts",
|
|
34
|
-
"demo:codex-hi": "tsx demo/codex_say_hi.ts",
|
|
35
|
-
"demo:ilink-echo": "tsx demo/ilink_echo_probe.ts",
|
|
36
|
-
"test": "vitest run",
|
|
37
|
-
"test:watch": "vitest"
|
|
38
|
-
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.133",
|
|
41
|
-
"@larksuiteoapi/node-sdk": "^1.59.0",
|
|
42
|
-
"@openilink/openilink-sdk-node": "^0.6.0",
|
|
43
|
-
"nodemailer": "^8.0.7",
|
|
44
|
-
"qrcode-terminal": "^0.12.0",
|
|
45
|
-
"sharp": "^0.34.5",
|
|
46
|
-
"tsx": "^4.0.0",
|
|
47
|
-
"ws": "^8.18.0"
|
|
48
|
-
},
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"@types/node": "^20.0.0",
|
|
51
|
-
"@types/qrcode-terminal": "^0.12.2",
|
|
52
|
-
"@types/ws": "^8.18.1",
|
|
53
|
-
"typescript": "^5.0.0",
|
|
54
|
-
"vitest": "^4.1.5"
|
|
55
|
-
},
|
|
56
|
-
"engines": {
|
|
57
|
-
"node": ">=20"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "chatccc",
|
|
3
|
+
"version": "0.2.63",
|
|
4
|
+
"description": "Feishu bot bridge for Claude Code",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./src/index.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"chatccc": "bin/chatccc.mjs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src/",
|
|
13
|
+
"bin/",
|
|
14
|
+
"demo/ilink_echo_probe.ts",
|
|
15
|
+
"im-skills/",
|
|
16
|
+
"images/img_readme_*.jpg",
|
|
17
|
+
"images/img_readme_*.png",
|
|
18
|
+
"images/avatars/status_*.png",
|
|
19
|
+
"images/avatars/badges/",
|
|
20
|
+
"package.json",
|
|
21
|
+
"README.md",
|
|
22
|
+
"config.sample.json"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"dev": "tsx src/index.ts",
|
|
26
|
+
"chatccc": "tsx src/index.ts",
|
|
27
|
+
"start": "tsx src/index.ts",
|
|
28
|
+
"demo:bot-test": "tsx demo/bot_test.ts",
|
|
29
|
+
"demo:bot-test:local": "tsx demo/bot_test.ts --local",
|
|
30
|
+
"demo:create-group": "tsx src/index.ts",
|
|
31
|
+
"demo:create-group:local": "tsx src/index.ts --local",
|
|
32
|
+
"demo:permission-check": "tsx demo/permission_check.ts",
|
|
33
|
+
"demo:claude-hi": "tsx demo/claude_say_hi.ts",
|
|
34
|
+
"demo:codex-hi": "tsx demo/codex_say_hi.ts",
|
|
35
|
+
"demo:ilink-echo": "tsx demo/ilink_echo_probe.ts",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:watch": "vitest"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.133",
|
|
41
|
+
"@larksuiteoapi/node-sdk": "^1.59.0",
|
|
42
|
+
"@openilink/openilink-sdk-node": "^0.6.0",
|
|
43
|
+
"nodemailer": "^8.0.7",
|
|
44
|
+
"qrcode-terminal": "^0.12.0",
|
|
45
|
+
"sharp": "^0.34.5",
|
|
46
|
+
"tsx": "^4.0.0",
|
|
47
|
+
"ws": "^8.18.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
51
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
52
|
+
"@types/ws": "^8.18.1",
|
|
53
|
+
"typescript": "^5.0.0",
|
|
54
|
+
"vitest": "^4.1.5"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=20"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
|
|
1
|
+
import { mkdtemp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { afterEach, describe, expect, it } from "vitest";
|
|
5
5
|
|
|
6
|
-
import { buildImSkillsPrompt } from "../im-skills.ts";
|
|
6
|
+
import { buildImSkillsPrompt, exportSkillSubDocs } from "../im-skills.ts";
|
|
7
7
|
|
|
8
8
|
let tempRoot: string | null = null;
|
|
9
9
|
|
|
@@ -43,4 +43,59 @@ describe("IM skills prompt rendering", () => {
|
|
|
43
43
|
expect(prompt).toContain("cwd=C:/work");
|
|
44
44
|
expect(prompt).not.toContain("{{");
|
|
45
45
|
});
|
|
46
|
+
|
|
47
|
+
it("renders separate WeChat image, file, and video capability docs", async () => {
|
|
48
|
+
tempRoot = await mkdtemp(join(tmpdir(), "chatccc-im-skills-cache-"));
|
|
49
|
+
const prompt = await buildImSkillsPrompt({
|
|
50
|
+
variables: {
|
|
51
|
+
cwd: "C:/work",
|
|
52
|
+
im_skills_cache_dir: tempRoot,
|
|
53
|
+
wechat_send_image_script: "C:/work/im-skills/wechat-image-skill/send-image.mjs",
|
|
54
|
+
wechat_send_file_script: "C:/work/im-skills/wechat-file-skill/send-file.mjs",
|
|
55
|
+
wechat_send_video_script: "C:/work/im-skills/wechat-video-skill/send-video.mjs",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const exported = await exportSkillSubDocs(
|
|
60
|
+
{
|
|
61
|
+
variables: {
|
|
62
|
+
cwd: "C:/work",
|
|
63
|
+
im_skills_cache_dir: tempRoot,
|
|
64
|
+
wechat_send_image_script: "C:/work/im-skills/wechat-image-skill/send-image.mjs",
|
|
65
|
+
wechat_send_file_script: "C:/work/im-skills/wechat-file-skill/send-file.mjs",
|
|
66
|
+
wechat_send_video_script: "C:/work/im-skills/wechat-video-skill/send-video.mjs",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
tempRoot,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
expect(prompt).toContain("[ChatCCC IM skill: wechat-image-skill]");
|
|
73
|
+
expect(prompt).toContain("[ChatCCC IM skill: wechat-file-skill]");
|
|
74
|
+
expect(prompt).toContain("[ChatCCC IM skill: wechat-video-skill]");
|
|
75
|
+
expect(prompt).not.toContain("[ChatCCC IM skill: wechat-skill]");
|
|
76
|
+
expect(prompt).toContain("Receive images");
|
|
77
|
+
expect(prompt).toContain("Send images");
|
|
78
|
+
expect(prompt).toContain("Receive files");
|
|
79
|
+
expect(prompt).toContain("Send files");
|
|
80
|
+
expect(prompt).toContain("Receive videos");
|
|
81
|
+
expect(prompt).toContain("Send videos");
|
|
82
|
+
expect(prompt).toContain("receive-send-image.md");
|
|
83
|
+
expect(prompt).toContain("receive-send-file.md");
|
|
84
|
+
expect(prompt).toContain("receive-send-video.md");
|
|
85
|
+
expect(prompt).not.toContain("{{wechat_send_image_script}}");
|
|
86
|
+
expect(prompt).not.toContain("{{wechat_send_file_script}}");
|
|
87
|
+
expect(prompt).not.toContain("{{wechat_send_video_script}}");
|
|
88
|
+
expect(exported.some((file) => file.endsWith(join("wechat-image-skill", "receive-send-image.md")))).toBe(true);
|
|
89
|
+
expect(exported.some((file) => file.endsWith(join("wechat-file-skill", "receive-send-file.md")))).toBe(true);
|
|
90
|
+
expect(exported.some((file) => file.endsWith(join("wechat-video-skill", "receive-send-video.md")))).toBe(true);
|
|
91
|
+
await expect(readFile(join(tempRoot, "wechat-image-skill", "receive-send-image.md"), "utf8")).resolves.toContain(
|
|
92
|
+
"send-image.mjs",
|
|
93
|
+
);
|
|
94
|
+
await expect(readFile(join(tempRoot, "wechat-file-skill", "receive-send-file.md"), "utf8")).resolves.toContain(
|
|
95
|
+
"send-file.mjs",
|
|
96
|
+
);
|
|
97
|
+
await expect(readFile(join(tempRoot, "wechat-video-skill", "receive-send-video.md"), "utf8")).resolves.toContain(
|
|
98
|
+
"send-video.mjs",
|
|
99
|
+
);
|
|
100
|
+
});
|
|
46
101
|
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
2
5
|
|
|
3
6
|
import { buildHelpCard } from "../cards.ts";
|
|
4
7
|
import {
|
|
8
|
+
_downloadWechatMediaAttachmentsForTest,
|
|
5
9
|
_resetWechatClawStateForTest,
|
|
6
10
|
_setWxMinSendIntervalMsForTest,
|
|
7
11
|
createWechatAdapter,
|
|
@@ -109,3 +113,64 @@ describe("createWechatAdapter", () => {
|
|
|
109
113
|
);
|
|
110
114
|
});
|
|
111
115
|
});
|
|
116
|
+
|
|
117
|
+
describe("WeChat media receive helpers", () => {
|
|
118
|
+
it("downloads image, file, and video items and returns message attachment paths", async () => {
|
|
119
|
+
const tempRoot = await mkdtemp(join(tmpdir(), "chatccc-wx-media-"));
|
|
120
|
+
const imageDir = join(tempRoot, "images");
|
|
121
|
+
const fileDir = join(tempRoot, "files");
|
|
122
|
+
const videoDir = join(tempRoot, "videos");
|
|
123
|
+
try {
|
|
124
|
+
const imageMedia = { aes_key: "image-key-1234567890", encrypt_query_param: "image" };
|
|
125
|
+
const fileMedia = { aes_key: "file-key-1234567890", encrypt_query_param: "file" };
|
|
126
|
+
const videoMedia = { aes_key: "video-key-1234567890", encrypt_query_param: "video" };
|
|
127
|
+
const wire = {
|
|
128
|
+
downloadMedia: vi.fn(async (media: unknown) => {
|
|
129
|
+
if (media === imageMedia) return Buffer.from("image-data");
|
|
130
|
+
if (media === fileMedia) return Buffer.from("file-data");
|
|
131
|
+
if (media === videoMedia) return Buffer.from("video-data");
|
|
132
|
+
throw new Error("unexpected media");
|
|
133
|
+
}),
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const result = await _downloadWechatMediaAttachmentsForTest(
|
|
137
|
+
{
|
|
138
|
+
message_id: 123,
|
|
139
|
+
item_list: [
|
|
140
|
+
{ image_item: { media: imageMedia } },
|
|
141
|
+
{
|
|
142
|
+
file_item: {
|
|
143
|
+
media: fileMedia,
|
|
144
|
+
file_name: "report.txt",
|
|
145
|
+
md5: "1234567890abcdef1234567890abcdef",
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
video_item: {
|
|
150
|
+
media: videoMedia,
|
|
151
|
+
video_md5: "abcdef1234567890abcdef",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
{ wire, imageDir, fileDir, videoDir },
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
expect(result.imagePaths).toHaveLength(1);
|
|
160
|
+
expect(result.filePaths).toHaveLength(1);
|
|
161
|
+
expect(result.videoPaths).toHaveLength(1);
|
|
162
|
+
expect(result.messageLines[0]).toMatch(/^\[图片\] /);
|
|
163
|
+
expect(result.messageLines[1]).toMatch(/^\[文件\] /);
|
|
164
|
+
expect(result.messageLines[2]).toMatch(/^\[视频\] /);
|
|
165
|
+
expect(result.imagePaths[0]).toContain(join("images", "wx_image-key-123456.png"));
|
|
166
|
+
expect(result.filePaths[0]).toContain(join("files", "wx_1234567890abcdef_report.txt"));
|
|
167
|
+
expect(result.videoPaths[0]).toContain(join("videos", "wx_abcdef1234567890.mp4"));
|
|
168
|
+
await expect(readFile(result.imagePaths[0], "utf8")).resolves.toBe("image-data");
|
|
169
|
+
await expect(readFile(result.filePaths[0], "utf8")).resolves.toBe("file-data");
|
|
170
|
+
await expect(readFile(result.videoPaths[0], "utf8")).resolves.toBe("video-data");
|
|
171
|
+
expect(wire.downloadMedia).toHaveBeenCalledTimes(3);
|
|
172
|
+
} finally {
|
|
173
|
+
await rm(tempRoot, { recursive: true, force: true });
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
});
|
package/src/config.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { dirname, join } from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { appendFile, cp, mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
7
7
|
|
|
8
|
+
import { Domain } from "@larksuiteoapi/node-sdk";
|
|
9
|
+
|
|
8
10
|
import { printServiceDidNotStart } from "./exit-banner.ts";
|
|
9
11
|
import { appendStartupTrace, setupFileLogging } from "./shared.ts";
|
|
10
12
|
import {
|
|
@@ -90,9 +92,25 @@ export interface CodexConfig {
|
|
|
90
92
|
effort: string;
|
|
91
93
|
}
|
|
92
94
|
|
|
95
|
+
export type FeishuDomain = "feishu" | "lark";
|
|
96
|
+
|
|
93
97
|
export interface FeishuConfig {
|
|
94
98
|
appId: string;
|
|
95
99
|
appSecret: string;
|
|
100
|
+
/** "feishu" (默认) → https://open.feishu.cn, "lark" → https://open.larksuite.com */
|
|
101
|
+
domain?: FeishuDomain;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** 用户配置的 domain 字符串 → SDK Domain 枚举 */
|
|
105
|
+
export function feishuDomainToSdkDomain(domain?: FeishuDomain): Domain {
|
|
106
|
+
return domain === "lark" ? Domain.Lark : Domain.Feishu;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** 用户配置的 domain 字符串 → REST API base URL */
|
|
110
|
+
export function feishuDomainToBaseUrl(domain?: FeishuDomain): string {
|
|
111
|
+
return domain === "lark"
|
|
112
|
+
? "https://open.larksuite.com/open-apis"
|
|
113
|
+
: "https://open.feishu.cn/open-apis";
|
|
96
114
|
}
|
|
97
115
|
|
|
98
116
|
export interface PlatformConfig {
|
|
@@ -298,7 +316,7 @@ function autofillToolPathsAfterSampleCopy(configFile: string): void {
|
|
|
298
316
|
|
|
299
317
|
function loadConfig(): AppConfig {
|
|
300
318
|
const defaults: AppConfig = {
|
|
301
|
-
feishu: { appId: "", appSecret: "" },
|
|
319
|
+
feishu: { appId: "", appSecret: "", domain: "feishu" },
|
|
302
320
|
platforms: { feishu: { enabled: true }, ilink: { enabled: true } },
|
|
303
321
|
port: 18080,
|
|
304
322
|
gitTimeoutSeconds: 180,
|
|
@@ -358,6 +376,8 @@ function loadConfig(): AppConfig {
|
|
|
358
376
|
}
|
|
359
377
|
|
|
360
378
|
const feishu = parsed.feishu ?? { appId: "", appSecret: "" };
|
|
379
|
+
const feishuDomain: FeishuDomain =
|
|
380
|
+
(feishu as { domain?: unknown }).domain === "lark" ? "lark" : "feishu";
|
|
361
381
|
const claude = parsed.claude ?? {} as Partial<ClaudeConfig>;
|
|
362
382
|
const cursorRaw = (parsed.cursor ?? {}) as NonNullable<typeof parsed.cursor>;
|
|
363
383
|
const codexRaw = (parsed.codex ?? {}) as NonNullable<typeof parsed.codex>;
|
|
@@ -420,6 +440,7 @@ function loadConfig(): AppConfig {
|
|
|
420
440
|
feishu: {
|
|
421
441
|
appId: feishu.appId ?? "",
|
|
422
442
|
appSecret: feishu.appSecret ?? "",
|
|
443
|
+
domain: feishuDomain,
|
|
423
444
|
},
|
|
424
445
|
platforms: {
|
|
425
446
|
feishu: {
|
|
@@ -497,7 +518,7 @@ export let APP_SECRET = config.feishu.appSecret;
|
|
|
497
518
|
export let FEISHU_ENABLED = config.platforms.feishu.enabled;
|
|
498
519
|
export let ILINK_ENABLED = config.platforms.ilink.enabled;
|
|
499
520
|
export let ILINK_REUSE_TOKEN_ON_START = config.platforms.ilink.reuseTokenOnStart ?? true;
|
|
500
|
-
export
|
|
521
|
+
export let BASE_URL = feishuDomainToBaseUrl(config.feishu.domain);
|
|
501
522
|
export const CHATCCC_PORT = config.port;
|
|
502
523
|
|
|
503
524
|
/** 与 CHATCCC_PORT 一致,供 --local 连接本机中继 */
|
|
@@ -576,6 +597,7 @@ export function applyLoadedConfig(next: AppConfig): void {
|
|
|
576
597
|
|
|
577
598
|
APP_ID = next.feishu.appId;
|
|
578
599
|
APP_SECRET = next.feishu.appSecret;
|
|
600
|
+
BASE_URL = feishuDomainToBaseUrl(next.feishu.domain);
|
|
579
601
|
FEISHU_ENABLED = next.platforms.feishu.enabled;
|
|
580
602
|
ILINK_ENABLED = next.platforms.ilink.enabled;
|
|
581
603
|
ILINK_REUSE_TOKEN_ON_START = next.platforms.ilink.reuseTokenOnStart ?? true;
|
package/src/index.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import { createServer, type IncomingMessage, type Server, type ServerResponse } from "node:http";
|
|
26
26
|
|
|
27
|
-
import { WSClient, EventDispatcher } from "@larksuiteoapi/node-sdk";
|
|
27
|
+
import { WSClient, EventDispatcher, Domain } from "@larksuiteoapi/node-sdk";
|
|
28
28
|
import WebSocket from "ws";
|
|
29
29
|
|
|
30
30
|
import { appendStartupTrace, attachRelayWebSocket, ensureSingleInstance, freeRelayListenPort, installCrashLogging, waitForPortFree } from "./shared.ts";
|
|
@@ -50,6 +50,8 @@ import {
|
|
|
50
50
|
maskAppId,
|
|
51
51
|
resolveDefaultAgentTool,
|
|
52
52
|
toolDisplayName,
|
|
53
|
+
config,
|
|
54
|
+
feishuDomainToSdkDomain,
|
|
53
55
|
ts,
|
|
54
56
|
} from "./config.ts";
|
|
55
57
|
import { printServiceDidNotStart, printServiceRunningHint } from "./exit-banner.ts";
|
|
@@ -403,7 +405,7 @@ async function startBotServiceCore(): Promise<void> {
|
|
|
403
405
|
console.error(` 接口: POST ${BASE_URL}/auth/v3/tenant_access_token/internal`);
|
|
404
406
|
console.error(" 常见原因:");
|
|
405
407
|
console.error(
|
|
406
|
-
|
|
408
|
+
` - 本机网络无法访问 ${new URL(BASE_URL).hostname}(可尝试:关闭系统/终端代理、检查防火墙;Windows 可管理员运行 netsh winsock reset 后重启)`,
|
|
407
409
|
);
|
|
408
410
|
console.error(" - App ID / App Secret 与开放平台「凭证与基础信息」不一致");
|
|
409
411
|
console.error(" - 自建应用尚未创建/发布可用版本");
|
|
@@ -594,6 +596,7 @@ async function startBotServiceCore(): Promise<void> {
|
|
|
594
596
|
const wsClient = new WSClient({
|
|
595
597
|
appId: APP_ID,
|
|
596
598
|
appSecret: APP_SECRET,
|
|
599
|
+
domain: feishuDomainToSdkDomain(config.feishu.domain),
|
|
597
600
|
onReady: async () => {
|
|
598
601
|
await rebuildBindingsFromRegistry().catch((err) =>
|
|
599
602
|
console.error(`[${ts()}] [SDK READY] rebuild bindings failed: ${(err as Error).message}`)
|
package/src/orchestrator.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
setDefaultCwd,
|
|
22
22
|
getRecentDirs,
|
|
23
23
|
addRecentDir,
|
|
24
|
+
resolveDefaultAgentTool,
|
|
24
25
|
sessionPrefixForTool,
|
|
25
26
|
toolDisplayName,
|
|
26
27
|
ts,
|
|
@@ -240,7 +241,7 @@ export async function handleCommand(
|
|
|
240
241
|
|
|
241
242
|
if (textLower === "/new" || textLower.startsWith("/new ")) {
|
|
242
243
|
const toolArg = text.slice(5).trim().toLowerCase();
|
|
243
|
-
const tool = toolArg ||
|
|
244
|
+
const tool = toolArg || resolveDefaultAgentTool();
|
|
244
245
|
logTrace(tid, "BRANCH", { cmd: "/new", tool });
|
|
245
246
|
const validTools = ["claude", "cursor", "codex"];
|
|
246
247
|
if (!validTools.includes(tool)) {
|
|
@@ -888,7 +889,7 @@ export async function handleCommand(
|
|
|
888
889
|
|
|
889
890
|
const targetToolLabel = toolDisplayName(target.tool);
|
|
890
891
|
const busyNote = isSessionRunning(target.sessionId)
|
|
891
|
-
? "\n\n⚠️
|
|
892
|
+
? "\n\n⚠️ 该会话当前正在生成中,请等待完成后再发送消息。如需中断生成,请发送 /stop 指令。"
|
|
892
893
|
: "";
|
|
893
894
|
await platform.sendCard(
|
|
894
895
|
chatId,
|
|
@@ -990,7 +991,7 @@ export async function handleCommand(
|
|
|
990
991
|
await platform.sendCard(
|
|
991
992
|
chatId,
|
|
992
993
|
"生成中",
|
|
993
|
-
"
|
|
994
|
+
"该会话正在生成回复中,请等待完成后再发送新消息。如需中断生成,请发送 /stop 指令。",
|
|
994
995
|
"yellow",
|
|
995
996
|
);
|
|
996
997
|
return;
|
package/src/session.ts
CHANGED
|
@@ -675,7 +675,7 @@ export async function runAgentSession(
|
|
|
675
675
|
const isWechatBusy = platform.kind === "wechat";
|
|
676
676
|
const busyMsg = isWechatBusy
|
|
677
677
|
? "当前正在生成回复中,请等待完成后再发送消息。如需中断生成,请发送 /stop 指令。"
|
|
678
|
-
: "
|
|
678
|
+
: "该会话正在生成回复中,请等待完成后再发送消息。如需中断生成,请发送 /stop 指令。";
|
|
679
679
|
await platform.sendText(_chatId, busyMsg).catch(() => {});
|
|
680
680
|
return;
|
|
681
681
|
}
|
|
@@ -705,7 +705,9 @@ export async function runAgentSession(
|
|
|
705
705
|
|
|
706
706
|
// 构建 IM skills prompt(sessionId 方式,无 token)
|
|
707
707
|
const feishuSkillDir = join(PROJECT_ROOT, "im-skills", "feishu-skill");
|
|
708
|
-
const
|
|
708
|
+
const wechatImageSkillDir = join(PROJECT_ROOT, "im-skills", "wechat-image-skill");
|
|
709
|
+
const wechatFileSkillDir = join(PROJECT_ROOT, "im-skills", "wechat-file-skill");
|
|
710
|
+
const wechatVideoSkillDir = join(PROJECT_ROOT, "im-skills", "wechat-video-skill");
|
|
709
711
|
const imSkillsCacheDir = join(USER_DATA_DIR, "im-skills");
|
|
710
712
|
const skillVariables = {
|
|
711
713
|
cwd,
|
|
@@ -716,7 +718,9 @@ export async function runAgentSession(
|
|
|
716
718
|
send_image_script: join(feishuSkillDir, "send-image.mjs"),
|
|
717
719
|
send_file_script: join(feishuSkillDir, "send-file.mjs"),
|
|
718
720
|
download_video_script: join(feishuSkillDir, "download-video.mjs"),
|
|
719
|
-
wechat_send_image_script: join(
|
|
721
|
+
wechat_send_image_script: join(wechatImageSkillDir, "send-image.mjs"),
|
|
722
|
+
wechat_send_file_script: join(wechatFileSkillDir, "send-file.mjs"),
|
|
723
|
+
wechat_send_video_script: join(wechatVideoSkillDir, "send-video.mjs"),
|
|
720
724
|
};
|
|
721
725
|
var imSkillsPrompt = await buildImSkillsPrompt({ variables: skillVariables });
|
|
722
726
|
await exportSkillSubDocs({ variables: skillVariables }, imSkillsCacheDir);
|
package/src/web-ui.ts
CHANGED
|
@@ -342,6 +342,9 @@ export function unflattenConfig(flat: Record<string, unknown>): Record<string, u
|
|
|
342
342
|
} else if (key === "CHATCCC_APP_SECRET") {
|
|
343
343
|
result.feishu = result.feishu || {};
|
|
344
344
|
(result.feishu as Record<string, unknown>).appSecret = val;
|
|
345
|
+
} else if (key === "CHATCCC_FEISHU_DOMAIN") {
|
|
346
|
+
result.feishu = result.feishu || {};
|
|
347
|
+
(result.feishu as Record<string, unknown>).domain = val;
|
|
345
348
|
} else if (key === "CHATCCC_FEISHU_ENABLED") {
|
|
346
349
|
result.platforms = result.platforms || {};
|
|
347
350
|
(result.platforms as Record<string, unknown>).feishu = (result.platforms as Record<string, unknown>).feishu || {};
|
|
@@ -639,6 +642,14 @@ header .badge{font-size:13px;padding:4px 12px;border-radius:12px;font-weight:500
|
|
|
639
642
|
<input type="password" id="field-CHATCCC_APP_SECRET" placeholder="...">
|
|
640
643
|
<div class="hint">飞书开放平台「凭证与基础信息」→ App Secret</div>
|
|
641
644
|
</div>
|
|
645
|
+
<div class="form-group">
|
|
646
|
+
<label>平台域名</label>
|
|
647
|
+
<select id="field-CHATCCC_FEISHU_DOMAIN">
|
|
648
|
+
<option value="feishu">飞书 (open.feishu.cn)</option>
|
|
649
|
+
<option value="lark">Lark (open.larksuite.com)</option>
|
|
650
|
+
</select>
|
|
651
|
+
<div class="hint">国际版 Lark 用户请选择 Lark</div>
|
|
652
|
+
</div>
|
|
642
653
|
</div>
|
|
643
654
|
</div>
|
|
644
655
|
|
|
@@ -826,6 +837,7 @@ header .badge{font-size:13px;padding:4px 12px;border-radius:12px;font-weight:500
|
|
|
826
837
|
</div>
|
|
827
838
|
<div class="config-row"><span class="key">App ID</span><span class="val" id="cfg-APP_ID">-</span></div>
|
|
828
839
|
<div class="config-row"><span class="key">App Secret</span><span class="val" id="cfg-APP_SECRET">-</span></div>
|
|
840
|
+
<div class="config-row"><span class="key">平台域名</span><span class="val" id="cfg-FEISHU_DOMAIN">-</span></div>
|
|
829
841
|
<button class="btn btn-outline" style="margin-top:8px" onclick="editSection('feishu')">编辑</button>
|
|
830
842
|
</div>
|
|
831
843
|
</details>
|
|
@@ -926,7 +938,7 @@ const AGENT_FIELDS = {
|
|
|
926
938
|
cursor: ['CHATCCC_CURSOR_PATH','CHATCCC_CURSOR_MODEL'],
|
|
927
939
|
codex: ['CHATCCC_CODEX_PATH','CHATCCC_CODEX_MODEL','CHATCCC_CODEX_EFFORT']
|
|
928
940
|
};
|
|
929
|
-
const FEISHU_FIELDS = ['CHATCCC_APP_ID','CHATCCC_APP_SECRET'];
|
|
941
|
+
const FEISHU_FIELDS = ['CHATCCC_APP_ID','CHATCCC_APP_SECRET','CHATCCC_FEISHU_DOMAIN'];
|
|
930
942
|
|
|
931
943
|
// 当前选中的 Claude API 模式("official" / "thirdparty")
|
|
932
944
|
// Wizard / Dashboard 都通过这个变量驱动 UI 显隐和提交时的 mode 字段
|
|
@@ -1197,6 +1209,7 @@ function renderStep1() {
|
|
|
1197
1209
|
var f = c.feishu || {};
|
|
1198
1210
|
prefillNested('field-CHATCCC_APP_ID', f.appId);
|
|
1199
1211
|
prefillNested('field-CHATCCC_APP_SECRET', f.appSecret);
|
|
1212
|
+
prefillNested('field-CHATCCC_FEISHU_DOMAIN', f.domain || 'feishu');
|
|
1200
1213
|
// 平台开关:按已有 config 回填;首次配置(无飞书凭证)时默认关闭飞书、开启微信
|
|
1201
1214
|
var hasExistingCreds = Boolean(c.feishu?.appId?.trim() && c.feishu?.appSecret?.trim());
|
|
1202
1215
|
var feishuEnabled = hasExistingCreds
|
|
@@ -1349,6 +1362,7 @@ function renderStep3() {
|
|
|
1349
1362
|
if (state.platformsEnabled.feishu) {
|
|
1350
1363
|
lines.push('<div class="config-row"><span class="key">CHATCCC_APP_ID</span><span class="val">' + (vars.CHATCCC_APP_ID || '<span style="color:#ef4444">未填写</span>') + '</span></div>');
|
|
1351
1364
|
lines.push('<div class="config-row"><span class="key">CHATCCC_APP_SECRET</span><span class="val">' + (vars.CHATCCC_APP_SECRET ? '***已设置***' : '<span style="color:#ef4444">未填写</span>') + '</span></div>');
|
|
1365
|
+
lines.push('<div class="config-row"><span class="key">平台域名</span><span class="val">' + ((vars.CHATCCC_FEISHU_DOMAIN === 'lark') ? 'Lark (open.larksuite.com)' : '飞书 (open.feishu.cn)') + '</span></div>');
|
|
1352
1366
|
}
|
|
1353
1367
|
|
|
1354
1368
|
lines.push('<h3 style="margin:16px 0 8px">微信 iLink</h3>');
|
|
@@ -1534,6 +1548,7 @@ function updateDashboardUI() {
|
|
|
1534
1548
|
state.platformsEnabled.feishu = feishuEnabled;
|
|
1535
1549
|
document.getElementById('cfg-APP_ID').textContent = c.feishu && c.feishu.appId ? c.feishu.appId.slice(0,8) + '...' + c.feishu.appId.slice(-4) : '-';
|
|
1536
1550
|
document.getElementById('cfg-APP_SECRET').textContent = c.feishu && c.feishu.appSecret ? '***已设置***' : '-';
|
|
1551
|
+
document.getElementById('cfg-FEISHU_DOMAIN').textContent = (c.feishu && c.feishu.domain === 'lark') ? 'Lark (open.larksuite.com)' : '飞书 (open.feishu.cn)';
|
|
1537
1552
|
|
|
1538
1553
|
// 只显示已启用的 Agent 卡片(按 enabled 字段;缺省时退回到"任一字段非空"兼容旧 config)
|
|
1539
1554
|
var claudeOn = isAgentEnabled(c.claude, CLAUDE_FALLBACK_KEYS);
|
|
@@ -1636,7 +1651,7 @@ function editSection(section) {
|
|
|
1636
1651
|
|
|
1637
1652
|
var html = '';
|
|
1638
1653
|
var labelMap = {
|
|
1639
|
-
'CHATCCC_APP_ID': 'App ID', 'CHATCCC_APP_SECRET': 'App Secret',
|
|
1654
|
+
'CHATCCC_APP_ID': 'App ID', 'CHATCCC_APP_SECRET': 'App Secret', 'CHATCCC_FEISHU_DOMAIN': '平台域名',
|
|
1640
1655
|
'CLAUDE_API_KEY': 'API Key', 'CLAUDE_BASE_URL': 'Base URL',
|
|
1641
1656
|
'CHATCCC_ANTHROPIC_MODEL': '模型', 'CHATCCC_ANTHROPIC_SUBAGENT_MODEL': 'Subagent 模型', 'CHATCCC_ANTHROPIC_EFFORT': 'Effort',
|
|
1642
1657
|
'CHATCCC_CURSOR_PATH': 'CLI 路径', 'CHATCCC_CURSOR_MODEL': '模型',
|
|
@@ -1673,6 +1688,7 @@ function editSection(section) {
|
|
|
1673
1688
|
if (section === 'feishu') {
|
|
1674
1689
|
if (key === 'CHATCCC_APP_ID' && state.config.feishu) val = state.config.feishu.appId || '';
|
|
1675
1690
|
else if (key === 'CHATCCC_APP_SECRET' && state.config.feishu) val = state.config.feishu.appSecret || '';
|
|
1691
|
+
else if (key === 'CHATCCC_FEISHU_DOMAIN' && state.config.feishu) val = state.config.feishu.domain || 'feishu';
|
|
1676
1692
|
} else if (section === 'claude' && state.config.claude) {
|
|
1677
1693
|
if (key === 'CLAUDE_API_KEY') val = state.config.claude.apiKey || '';
|
|
1678
1694
|
else if (key === 'CLAUDE_BASE_URL') val = state.config.claude.baseUrl || '';
|
|
@@ -1707,7 +1723,14 @@ function editSection(section) {
|
|
|
1707
1723
|
var groupClass = 'form-group' + (isClaudeSubagentField && claudeApiMode !== 'thirdparty' ? ' hidden' : '');
|
|
1708
1724
|
var subagentAttr = isClaudeSubagentField ? ' data-claude-subagent-field="1"' : '';
|
|
1709
1725
|
html += '<div class="' + groupClass + '"' + subagentAttr + '><label>' + (labelMap[key] || key) + '</label>';
|
|
1710
|
-
|
|
1726
|
+
if (key === 'CHATCCC_FEISHU_DOMAIN') {
|
|
1727
|
+
html += '<select id="edit-' + key + '">';
|
|
1728
|
+
html += '<option value="feishu"' + (val === 'lark' ? '' : ' selected') + '>飞书 (open.feishu.cn)</option>';
|
|
1729
|
+
html += '<option value="lark"' + (val === 'lark' ? ' selected' : '') + '>Lark (open.larksuite.com)</option>';
|
|
1730
|
+
html += '</select>';
|
|
1731
|
+
} else {
|
|
1732
|
+
html += '<input type="' + (isSecret ? 'password' : 'text') + '" id="edit-' + key + '" value="' + String(val).replace(/"/g,'"') + '">';
|
|
1733
|
+
}
|
|
1711
1734
|
html += '</div>';
|
|
1712
1735
|
});
|
|
1713
1736
|
|