chatccc 0.2.155 → 0.2.156

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.
@@ -4,7 +4,7 @@
4
4
  "appSecret": ""
5
5
  },
6
6
  "platforms": {
7
- "feishu": { "enabled": true },
7
+ "feishu": { "enabled": true, "platformType": "feishu" },
8
8
  "ilink": { "enabled": true, "reuseTokenOnStart": true }
9
9
  },
10
10
  "port": 18080,
@@ -18,7 +18,7 @@
18
18
  "effort": "",
19
19
  "apiKey": "",
20
20
  "baseUrl": "",
21
- "maxTurn": 0
21
+ "maxTurn": 0
22
22
  },
23
23
  "cursor": {
24
24
  "enabled": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatccc",
3
- "version": "0.2.155",
3
+ "version": "0.2.156",
4
4
  "description": "Feishu bot bridge for Claude Code",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -459,6 +459,29 @@ describe("buildClaudePromptText", () => {
459
459
  expect(result.endsWith("[User message]\nhello\n[/User message]")).toBe(true);
460
460
  });
461
461
 
462
+ it("prepends the Claude-specific injection prompt on every resumed prompt", () => {
463
+ const first = buildClaudePromptText(
464
+ "[ChatCCC IM skill: feishu-skill]\ncapabilities\n[/ChatCCC IM skill: feishu-skill]\n\n[User message]\nfirst\n[/User message]",
465
+ "Never repeat successful commands for {{session_id}}.",
466
+ "sid-resume",
467
+ );
468
+ const second = buildClaudePromptText(
469
+ "[ChatCCC IM skill: feishu-skill]\ncapabilities\n[/ChatCCC IM skill: feishu-skill]\n\n[User message]\nsecond\n[/User message]",
470
+ "Never repeat successful commands for {{session_id}}.",
471
+ "sid-resume",
472
+ );
473
+
474
+ for (const result of [first, second]) {
475
+ expect(result).toContain("[ChatCCC Claude-specific injection prompt]");
476
+ expect(result).toContain("Never repeat successful commands for sid-resume.");
477
+ expect(result).toContain("[/ChatCCC Claude-specific injection prompt]");
478
+ expect(result).toContain("[ChatCCC IM skill: feishu-skill]");
479
+ expect(result).toContain("[/ChatCCC IM skill: feishu-skill]");
480
+ }
481
+ expect(first).toContain("[User message]\nfirst\n[/User message]");
482
+ expect(second).toContain("[User message]\nsecond\n[/User message]");
483
+ });
484
+
462
485
  it("leaves user text unchanged when the injection prompt is empty", () => {
463
486
  expect(buildClaudePromptText("hello", " ")).toBe("hello");
464
487
  expect(buildClaudePromptText("hello", null)).toBe("hello");
@@ -9,9 +9,9 @@ const mockStreamStates = new Map<string, {
9
9
  finalReply: string;
10
10
  status?: "running" | "done" | "stopped" | "error";
11
11
  turnCount?: number;
12
- finalReplySentTurn?: number;
13
- finalReplySentAt?: number;
14
- }>();
12
+ finalReplySentTurn?: number;
13
+ finalReplySentAt?: number;
14
+ }>();
15
15
  vi.mock("../stream-state.ts", () => ({
16
16
  readStreamState: async (sid: string) => {
17
17
  const state = mockStreamStates.get(sid);
@@ -20,9 +20,9 @@ vi.mock("../stream-state.ts", () => ({
20
20
  sessionId: sid,
21
21
  accumulatedContent: state.accumulatedContent,
22
22
  finalReply: state.finalReply,
23
- finalReplySentTurn: state.finalReplySentTurn,
24
- finalReplySentAt: state.finalReplySentAt,
25
- status: state.status ?? "running",
23
+ finalReplySentTurn: state.finalReplySentTurn,
24
+ finalReplySentAt: state.finalReplySentAt,
25
+ status: state.status ?? "running",
26
26
  chunkCount: 0,
27
27
  turnCount: state.turnCount ?? 0,
28
28
  contextTokens: 0,
@@ -37,18 +37,18 @@ vi.mock("../stream-state.ts", () => ({
37
37
  finalReply: string;
38
38
  status?: "running" | "done" | "stopped" | "error";
39
39
  turnCount?: number;
40
- finalReplySentTurn?: number;
41
- finalReplySentAt?: number;
42
- }) => {
40
+ finalReplySentTurn?: number;
41
+ finalReplySentAt?: number;
42
+ }) => {
43
43
  mockStreamStates.set(state.sessionId, {
44
44
  accumulatedContent: state.accumulatedContent,
45
45
  finalReply: state.finalReply,
46
46
  status: state.status,
47
47
  turnCount: state.turnCount,
48
- finalReplySentTurn: state.finalReplySentTurn,
49
- finalReplySentAt: state.finalReplySentAt,
50
- });
51
- },
48
+ finalReplySentTurn: state.finalReplySentTurn,
49
+ finalReplySentAt: state.finalReplySentAt,
50
+ });
51
+ },
52
52
  createEmptyStreamState: (sid: string, cwd: string, tool: string, turnCount: number) => ({
53
53
  sessionId: sid, status: "running" as const, accumulatedContent: "", finalReply: "", chunkCount: 0, turnCount, contextTokens: 0, updatedAt: Date.now(), cwd, tool,
54
54
  }),
@@ -396,8 +396,44 @@ describe("runAgentSession process monitor", () => {
396
396
  expect.stringContaining("进程异常结束"),
397
397
  );
398
398
  });
399
- });
400
-
399
+ it("re-injects IM skill capabilities for each resumed Claude prompt", async () => {
400
+ const platform = mockPlatform("feishu");
401
+ setSessionPlatform(platform);
402
+ bindChatToSession("sid-resume", "chat-resume");
403
+ recordLastActiveChat("sid-resume", "chat-resume");
404
+
405
+ const sentTexts: string[] = [];
406
+ const adapter: ToolAdapter = {
407
+ displayName: "Claude Code",
408
+ sessionDescPrefix: "Claude Code Session:",
409
+ createSession: async () => ({ sessionId: "sid-resume" }),
410
+ getSessionInfo: async (sid) => ({ sessionId: sid, cwd: "F:\\repo" }),
411
+ closeSession: async () => {},
412
+ prompt: async function* (_sid: string, text: string) {
413
+ sentTexts.push(text);
414
+ yield { type: "assistant", blocks: [{ type: "text", text: "done" }] };
415
+ },
416
+ };
417
+ _setAdapterForToolForTest("claude", adapter);
418
+
419
+ await runAgentSession("sid-resume", "first prompt", platform, "chat-resume", Date.now(), "claude");
420
+ await runAgentSession("sid-resume", "second prompt", platform, "chat-resume", Date.now(), "claude");
421
+
422
+ expect(sentTexts).toHaveLength(2);
423
+ for (const text of sentTexts) {
424
+ expect(text).toContain("[ChatCCC IM skill: feishu-skill]");
425
+ expect(text).toContain("[/ChatCCC IM skill: feishu-skill]");
426
+ expect(text).toContain('"session_id":"sid-resume"');
427
+ expect(text).toContain("http://127.0.0.1:");
428
+ expect(text).toContain("/api/agent/send-image");
429
+ expect(text).toContain("[User message]");
430
+ expect(text).toContain("[/User message]");
431
+ }
432
+ expect(sentTexts[0]).toContain("first prompt");
433
+ expect(sentTexts[1]).toContain("second prompt");
434
+ });
435
+ });
436
+
401
437
  describe("unified display loop WeChat delta", () => {
402
438
  beforeEach(() => {
403
439
  vi.useFakeTimers();
@@ -114,4 +114,4 @@ export async function handleAgentStopStuckRequest(
114
114
 
115
115
  jsonReply(res, 200, { ok: true });
116
116
  return true;
117
- }
117
+ }
package/src/config.ts CHANGED
@@ -102,6 +102,8 @@ export interface FeishuConfig {
102
102
  export interface PlatformConfig {
103
103
  enabled: boolean;
104
104
  reuseTokenOnStart?: boolean;
105
+ /** 飞书平台类型:feishu(国内飞书)或 lark(国际版);缺省按 feishu */
106
+ platformType?: "feishu" | "lark";
105
107
  }
106
108
 
107
109
  export interface PlatformsConfig {
@@ -319,6 +321,11 @@ function autofillToolPathsAfterSampleCopy(configFile: string): void {
319
321
  }
320
322
  }
321
323
 
324
+ function normalizePlatformType(raw: string): "feishu" | "lark" {
325
+ if (raw === "lark") return "lark";
326
+ return "feishu";
327
+ }
328
+
322
329
  function loadConfig(): AppConfig {
323
330
  const defaults: AppConfig = {
324
331
  feishu: { appId: "", appSecret: "" },
@@ -449,6 +456,11 @@ function loadConfig(): AppConfig {
449
456
  enabled: typeof (parsed.platforms as unknown as Record<string, unknown> | undefined)?.feishu === "object"
450
457
  ? Boolean(((parsed.platforms as unknown as Record<string, unknown>).feishu as Record<string, unknown>).enabled ?? true)
451
458
  : true,
459
+ platformType: normalizePlatformType(
460
+ typeof (parsed.platforms as unknown as Record<string, unknown> | undefined)?.feishu === "object"
461
+ ? String(((parsed.platforms as unknown as Record<string, unknown>).feishu as Record<string, unknown>).platformType ?? "feishu")
462
+ : "feishu",
463
+ ),
452
464
  },
453
465
  ilink: {
454
466
  enabled: typeof (parsed.platforms as unknown as Record<string, unknown> | undefined)?.ilink === "object"
@@ -517,7 +529,14 @@ export let APP_SECRET = config.feishu.appSecret;
517
529
  export let FEISHU_ENABLED = config.platforms.feishu.enabled;
518
530
  export let ILINK_ENABLED = config.platforms.ilink.enabled;
519
531
  export let ILINK_REUSE_TOKEN_ON_START = config.platforms.ilink.reuseTokenOnStart ?? true;
520
- export const BASE_URL = "https://open.feishu.cn/open-apis";
532
+
533
+ function computeBaseUrl(platformType?: string): string {
534
+ if (platformType === "lark") return "https://open.larksuite.com/open-apis";
535
+ return "https://open.feishu.cn/open-apis";
536
+ }
537
+
538
+ export let BASE_URL = computeBaseUrl(config.platforms.feishu.platformType);
539
+ export let FEISHU_PLATFORM_TYPE: "feishu" | "lark" = config.platforms.feishu.platformType === "lark" ? "lark" : "feishu";
521
540
  export const CHATCCC_PORT = config.port;
522
541
 
523
542
  /** 与 CHATCCC_PORT 一致,供 --local 连接本机中继 */
@@ -603,11 +622,13 @@ export function applyLoadedConfig(next: AppConfig): void {
603
622
  FEISHU_ENABLED = next.platforms.feishu.enabled;
604
623
  ILINK_ENABLED = next.platforms.ilink.enabled;
605
624
  ILINK_REUSE_TOKEN_ON_START = next.platforms.ilink.reuseTokenOnStart ?? true;
625
+ FEISHU_PLATFORM_TYPE = next.platforms.feishu.platformType === "lark" ? "lark" : "feishu";
626
+ BASE_URL = computeBaseUrl(FEISHU_PLATFORM_TYPE);
606
627
  CLAUDE_MODEL = next.claude.model;
607
628
  CLAUDE_SUBAGENT_MODEL = next.claude.subagentModel;
608
- CLAUDE_EFFORT = next.claude.effort;
609
- CLAUDE_MAX_TURN = next.claude.maxTurn;
610
- CLAUDE_API_KEY = next.claude.apiKey;
629
+ CLAUDE_EFFORT = next.claude.effort;
630
+ CLAUDE_MAX_TURN = next.claude.maxTurn;
631
+ CLAUDE_API_KEY = next.claude.apiKey;
611
632
  CLAUDE_BASE_URL = next.claude.baseUrl;
612
633
  GIT_TIMEOUT_SECONDS = next.gitTimeoutSeconds;
613
634
  GIT_TIMEOUT_MS = GIT_TIMEOUT_SECONDS * 1000;
@@ -738,6 +759,9 @@ export function reportEnvironmentVariableReadout(): void {
738
759
  APP_SECRET.trim() ? "已读入(内容不在日志中显示)" : "未读入或为空"
739
760
  );
740
761
 
762
+ console.log(` [默认] [可选] platforms.feishu.platformType`);
763
+ console.log(` 平台类型: ${FEISHU_PLATFORM_TYPE === "lark" ? "Lark (open.larksuite.com)" : "飞书 (open.feishu.cn)"}`);
764
+
741
765
  console.log(` [默认] [可选] port`);
742
766
  console.log(` 监听端口: ${CHATCCC_PORT}`);
743
767
 
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";
@@ -36,6 +36,7 @@ import {
36
36
  APP_ID,
37
37
  APP_SECRET,
38
38
  FEISHU_ENABLED,
39
+ FEISHU_PLATFORM_TYPE,
39
40
  ILINK_ENABLED,
40
41
  ILINK_REUSE_TOKEN_ON_START,
41
42
  BASE_URL,
@@ -212,7 +213,7 @@ function parseCardAction(data: unknown): CardActionResult | null {
212
213
  }
213
214
  if (!cmd) return null;
214
215
 
215
- const CMD_MAP: Record<string, string> = { stop: "/stop", cancel: "/cancel", new: "/new", "new claude": "/new claude", "new cursor": "/new cursor", "new codex": "/new codex", restart: "/restart", state: "/state", cd: "/cd", sessions: "/sessions", newh: "/newh" };
216
+ const CMD_MAP: Record<string, string> = { stop: "/stop", cancel: "/cancel", new: "/new", "new claude": "/new claude", "new cursor": "/new cursor", "new codex": "/new codex", restart: "/restart", state: "/state", cd: "/cd", sessions: "/sessions", newh: "/newh" };
216
217
  let text = CMD_MAP[cmd] ?? "";
217
218
  if (cmd === "cd" && typeof action.value === "object" && action.value !== null) {
218
219
  const path = (action.value as Record<string, string>).path;
@@ -348,9 +349,10 @@ async function startBotServiceCore(): Promise<void> {
348
349
  const msg = err instanceof Error ? err.message : String(err);
349
350
  console.error(" 失败:无法获取 tenant_access_token。");
350
351
  console.error(` 接口: POST ${BASE_URL}/auth/v3/tenant_access_token/internal`);
352
+ const apiHost = BASE_URL.replace("https://", "").replace("/open-apis", "");
351
353
  console.error(" 常见原因:");
352
354
  console.error(
353
- " - 本机网络无法访问 open.feishu.cn(可尝试:关闭系统/终端代理、检查防火墙;Windows 可管理员运行 netsh winsock reset 后重启)",
355
+ ` - 本机网络无法访问 ${apiHost}(可尝试:关闭系统/终端代理、检查防火墙;Windows 可管理员运行 netsh winsock reset 后重启)`,
354
356
  );
355
357
  console.error(" - App ID / App Secret 与开放平台「凭证与基础信息」不一致");
356
358
  console.error(" - 自建应用尚未创建/发布可用版本");
@@ -542,6 +544,7 @@ async function startBotServiceCore(): Promise<void> {
542
544
  const wsClient = new WSClient({
543
545
  appId: APP_ID,
544
546
  appSecret: APP_SECRET,
547
+ domain: FEISHU_PLATFORM_TYPE === "lark" ? Domain.Lark : Domain.Feishu,
545
548
  onReady: async () => {
546
549
  await rebuildBindingsFromRegistry().catch((err) =>
547
550
  console.error(`[${ts()}] [SDK READY] rebuild bindings failed: ${(err as Error).message}`)
@@ -71,11 +71,11 @@ export interface ActivePrompt {
71
71
  /** Set when the watchdog detects that the CLI process disappeared before stream finalization. */
72
72
  abnormalExit?: boolean;
73
73
  abnormalExitNotified?: boolean;
74
- /** Set when the resource monitor detects CPU + memory unchanged for 3 minutes. */
75
- resourceStuck?: boolean;
76
- /** Adapter-provided callback to close the underlying SDK session / subprocess.
77
- * Called by stop-stuck-loop before controller.abort() to terminate the CLI
78
- * process immediately, rather than waiting for the async generator to unblock. */
74
+ /** Set when the resource monitor detects CPU + memory unchanged for 3 minutes. */
75
+ resourceStuck?: boolean;
76
+ /** Adapter-provided callback to close the underlying SDK session / subprocess.
77
+ * Called by stop-stuck-loop before controller.abort() to terminate the CLI
78
+ * process immediately, rather than waiting for the async generator to unblock. */
79
79
  closeSession?: () => void;
80
80
  }
81
81
 
@@ -228,4 +228,4 @@ export function resetBindingState(): void {
228
228
  clearInterval(unifiedDisplayLoopHandle);
229
229
  unifiedDisplayLoopHandle = null;
230
230
  }
231
- }
231
+ }
package/src/session.ts CHANGED
@@ -1161,11 +1161,11 @@ export async function runAgentSession(
1161
1161
  // 标记 prompt 结束
1162
1162
  resourceMonitor.off("stuck", onResourceStuck);
1163
1163
  const prompt = activePrompts.get(sessionId);
1164
- const wasStopped = prompt?.stopped ?? false;
1165
- const wasAbnormalExit = prompt?.abnormalExit ?? false;
1166
- const wasResourceStuck = prompt?.resourceStuck ?? false;
1167
- clearPromptProcessMonitor(sessionId);
1168
- activePrompts.delete(sessionId);
1164
+ const wasStopped = prompt?.stopped ?? false;
1165
+ const wasAbnormalExit = prompt?.abnormalExit ?? false;
1166
+ const wasResourceStuck = prompt?.resourceStuck ?? false;
1167
+ clearPromptProcessMonitor(sessionId);
1168
+ activePrompts.delete(sessionId);
1169
1169
 
1170
1170
  // 先写最终状态(done/stopped),确保 display loop 在下一轮消费前
1171
1171
  // 读到新状态并终结旧卡片。否则 setImmediate 在 CHECK 阶段先于
@@ -1176,13 +1176,13 @@ export async function runAgentSession(
1176
1176
 
1177
1177
  // stop-stuck-loop 接口可能在 fire-and-forget 中已写入带 final_reply 的
1178
1178
  // stream state,finally 不应覆盖它。
1179
- let finalReplyToWrite = finalReply;
1180
- try {
1181
- const existing = await readStreamState(sessionId);
1182
- if (existing && existing.finalReply.length > finalReply.length) {
1183
- finalReplyToWrite = existing.finalReply;
1184
- }
1185
- } catch {}
1179
+ let finalReplyToWrite = finalReply;
1180
+ try {
1181
+ const existing = await readStreamState(sessionId);
1182
+ if (existing && existing.finalReply.length > finalReply.length) {
1183
+ finalReplyToWrite = existing.finalReply;
1184
+ }
1185
+ } catch {}
1186
1186
 
1187
1187
  await writeStreamState({
1188
1188
  sessionId,
@@ -1191,11 +1191,11 @@ export async function runAgentSession(
1191
1191
  finalReply: finalReplyToWrite,
1192
1192
  chunkCount: state.chunkCount,
1193
1193
  turnCount: nextTurnCount,
1194
- contextTokens: existingInfo?.lastContextTokens ?? 0,
1195
- updatedAt: Date.now(),
1196
- cwd,
1197
- tool,
1198
- });
1194
+ contextTokens: existingInfo?.lastContextTokens ?? 0,
1195
+ updatedAt: Date.now(),
1196
+ cwd,
1197
+ tool,
1198
+ });
1199
1199
 
1200
1200
  // 消费队列中的缓存消息(异步,不阻塞后续清理)
1201
1201
  // 用户 /stop 后应丢弃队列消息,避免用户停止后又自动开始新轮
package/src/web-ui.ts CHANGED
@@ -296,6 +296,10 @@ export function unflattenConfig(flat: Record<string, unknown>): Record<string, u
296
296
  result.platforms = result.platforms || {};
297
297
  (result.platforms as Record<string, unknown>).feishu = (result.platforms as Record<string, unknown>).feishu || {};
298
298
  ((result.platforms as Record<string, unknown>).feishu as Record<string, unknown>).enabled = val === true || val === "true";
299
+ } else if (key === "CHATCCC_FEISHU_PLATFORM_TYPE") {
300
+ result.platforms = result.platforms || {};
301
+ (result.platforms as Record<string, unknown>).feishu = (result.platforms as Record<string, unknown>).feishu || {};
302
+ ((result.platforms as Record<string, unknown>).feishu as Record<string, unknown>).platformType = val;
299
303
  } else if (key === "CHATCCC_ILINK_ENABLED") {
300
304
  result.platforms = result.platforms || {};
301
305
  (result.platforms as Record<string, unknown>).ilink = (result.platforms as Record<string, unknown>).ilink || {};
@@ -582,6 +586,14 @@ header .badge{font-size:13px;padding:4px 12px;border-radius:12px;font-weight:500
582
586
  <input type="checkbox" class="agent-toggle" id="platform-enable-feishu" checked onchange="onWizardPlatformToggle('feishu', this.checked)">
583
587
  </div>
584
588
  <div id="feishu-cred-fields" style="margin-top:12px;padding-top:12px;border-top:1px solid #e2e8f0">
589
+ <div class="form-group" style="margin-bottom:10px">
590
+ <label>平台类型</label>
591
+ <select id="field-CHATCCC_FEISHU_PLATFORM_TYPE" style="width:100%;padding:8px 12px;border:1px solid #cbd5e1;border-radius:8px;font-size:14px;outline:none">
592
+ <option value="feishu">飞书 (open.feishu.cn)</option>
593
+ <option value="lark">Lark (open.larksuite.com)</option>
594
+ </select>
595
+ <div class="hint">飞书或 Lark 国际版,决定 API 服务器地址</div>
596
+ </div>
585
597
  <div class="form-group" style="margin-bottom:10px">
586
598
  <label>CHATCCC_APP_ID *</label>
587
599
  <input type="text" id="field-CHATCCC_APP_ID" placeholder="cli_xxxxxxxxxxxx">
@@ -759,6 +771,7 @@ header .badge{font-size:13px;padding:4px 12px;border-radius:12px;font-weight:500
759
771
  </div>
760
772
  <div class="config-row"><span class="key">App ID</span><span class="val" id="cfg-APP_ID">-</span></div>
761
773
  <div class="config-row"><span class="key">App Secret</span><span class="val" id="cfg-APP_SECRET">-</span></div>
774
+ <div class="config-row"><span class="key">平台类型</span><span class="val" id="cfg-FEISHU_PLATFORM_TYPE">-</span></div>
762
775
  <button class="btn btn-outline" style="margin-top:8px" onclick="editSection('feishu')">编辑</button>
763
776
  </div>
764
777
  </details>
@@ -1058,6 +1071,8 @@ function renderStep1() {
1058
1071
  var f = c.feishu || {};
1059
1072
  prefillNested('field-CHATCCC_APP_ID', f.appId);
1060
1073
  prefillNested('field-CHATCCC_APP_SECRET', f.appSecret);
1074
+ var pf = (c.platforms && c.platforms.feishu) || {};
1075
+ prefillNested('field-CHATCCC_FEISHU_PLATFORM_TYPE', pf.platformType || 'feishu');
1061
1076
  // 平台开关:按已有 config 回填;首次配置(无飞书凭证)时默认关闭飞书、开启微信
1062
1077
  var hasExistingCreds = Boolean(c.feishu?.appId?.trim() && c.feishu?.appSecret?.trim());
1063
1078
  var feishuEnabled = hasExistingCreds
@@ -1156,6 +1171,9 @@ function collectAllFields() {
1156
1171
  var el = document.getElementById('field-' + key);
1157
1172
  if (el && el.value.trim()) vars[key] = el.value.trim();
1158
1173
  });
1174
+ // 平台类型(下拉选择框,始终发送以保持与服务端同步)
1175
+ var ptEl = document.getElementById('field-CHATCCC_FEISHU_PLATFORM_TYPE');
1176
+ if (ptEl && ptEl.value.trim()) vars['CHATCCC_FEISHU_PLATFORM_TYPE'] = ptEl.value.trim();
1159
1177
  vars.CHATCCC_FEISHU_ENABLED = !!state.platformsEnabled.feishu;
1160
1178
  vars.CHATCCC_ILINK_ENABLED = !!state.platformsEnabled.ilink;
1161
1179
  vars.CHATCCC_CLAUDE_ENABLED = !!state.agentsEnabled.claude;
@@ -1197,6 +1215,8 @@ function renderStep3() {
1197
1215
  if (state.platformsEnabled.feishu) {
1198
1216
  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>');
1199
1217
  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>');
1218
+ var ptLabel = vars.CHATCCC_FEISHU_PLATFORM_TYPE === 'lark' ? 'Lark (open.larksuite.com)' : '飞书 (open.feishu.cn)';
1219
+ lines.push('<div class="config-row"><span class="key">平台类型</span><span class="val">' + ptLabel + '</span></div>');
1200
1220
  }
1201
1221
 
1202
1222
  lines.push('<h3 style="margin:16px 0 8px">微信 iLink</h3>');
@@ -1368,6 +1388,8 @@ function updateDashboardUI() {
1368
1388
  state.platformsEnabled.feishu = feishuEnabled;
1369
1389
  document.getElementById('cfg-APP_ID').textContent = c.feishu && c.feishu.appId ? c.feishu.appId.slice(0,8) + '...' + c.feishu.appId.slice(-4) : '-';
1370
1390
  document.getElementById('cfg-APP_SECRET').textContent = c.feishu && c.feishu.appSecret ? '***已设置***' : '-';
1391
+ var pt = (c.platforms && c.platforms.feishu && c.platforms.feishu.platformType === 'lark') ? 'Lark (open.larksuite.com)' : '飞书 (open.feishu.cn)';
1392
+ document.getElementById('cfg-FEISHU_PLATFORM_TYPE').textContent = pt;
1371
1393
 
1372
1394
  // 只显示已启用的 Agent 卡片(按 enabled 字段;缺省时退回到"任一字段非空"兼容旧 config)
1373
1395
  var claudeOn = isAgentEnabled(c.claude, CLAUDE_FALLBACK_KEYS);
@@ -1497,6 +1519,16 @@ function editSection(section) {
1497
1519
  html += '<input type="' + (isSecret ? 'password' : 'text') + '" id="edit-' + key + '" value="' + String(val).replace(/"/g,'&quot;') + '">';
1498
1520
  html += '</div>';
1499
1521
  });
1522
+ // 平台类型:feishu 编辑时额外渲染下拉选择框
1523
+ if (section === 'feishu') {
1524
+ var ptVal = (state.config.platforms && state.config.platforms.feishu && state.config.platforms.feishu.platformType) || 'feishu';
1525
+ html += '<div class="form-group"><label>平台类型</label>';
1526
+ html += '<select id="edit-CHATCCC_FEISHU_PLATFORM_TYPE" style="width:100%;padding:8px 12px;border:1px solid #cbd5e1;border-radius:8px;font-size:14px;outline:none">';
1527
+ html += '<option value="feishu"' + (ptVal === 'feishu' ? ' selected' : '') + '>飞书 (open.feishu.cn)</option>';
1528
+ html += '<option value="lark"' + (ptVal === 'lark' ? ' selected' : '') + '>Lark (open.larksuite.com)</option>';
1529
+ html += '</select></div>';
1530
+ }
1531
+ document.getElementById('edit-modal-fields').innerHTML = html;
1500
1532
  }
1501
1533
 
1502
1534
  function closeEditModal() {
@@ -1515,6 +1547,11 @@ async function saveEdit() {
1515
1547
  var el = document.getElementById('edit-' + key);
1516
1548
  if (el) vars[key] = el.value.trim();
1517
1549
  });
1550
+ // 平台类型:feishu 编辑时额外采集下拉选择框的值
1551
+ if (editSectionType === 'feishu') {
1552
+ var ptEl = document.getElementById('edit-CHATCCC_FEISHU_PLATFORM_TYPE');
1553
+ if (ptEl && ptEl.value.trim()) vars['CHATCCC_FEISHU_PLATFORM_TYPE'] = ptEl.value.trim();
1554
+ }
1518
1555
  await saveConfig(vars);
1519
1556
  closeEditModal();
1520
1557
  updateDashboardUI();