chatccc 0.2.231 → 0.2.232

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.
Files changed (127) hide show
  1. package/.agents/skills/create-chatccc-feishu-app/SKILL.md +85 -85
  2. package/.claude/skills/create-chatccc-feishu-app/SKILL.md +85 -85
  3. package/.cursor/skills/create-chatccc-feishu-app/SKILL.md +85 -85
  4. package/README.md +90 -90
  5. package/agent-prompts/claude_specific.md +45 -45
  6. package/agent-prompts/codex_specific.md +2 -2
  7. package/agent-prompts/cursor_specific.md +13 -13
  8. package/bin/cccagent.mjs +17 -17
  9. package/im-skills/feishu-skill/receive-send-file.md +63 -63
  10. package/im-skills/feishu-skill/receive-send-image.md +24 -24
  11. package/im-skills/feishu-skill/skill.md +3 -3
  12. package/im-skills/wechat-file-skill/receive-send-file.md +38 -38
  13. package/im-skills/wechat-file-skill/send-file.mjs +83 -83
  14. package/im-skills/wechat-file-skill/skill.md +10 -10
  15. package/im-skills/wechat-image-skill/skill.md +10 -10
  16. package/im-skills/wechat-video-skill/receive-send-video.md +38 -38
  17. package/im-skills/wechat-video-skill/send-video.mjs +79 -79
  18. package/im-skills/wechat-video-skill/skill.md +10 -10
  19. package/package.json +1 -1
  20. package/scripts/postinstall-sharp-check.mjs +58 -58
  21. package/src/__tests__/agent-activity.test.ts +86 -86
  22. package/src/__tests__/agent-delegate-task-rpc.test.ts +165 -165
  23. package/src/__tests__/agent-reload-config-rpc.test.ts +99 -99
  24. package/src/__tests__/builtin-chat-session.test.ts +449 -393
  25. package/src/__tests__/builtin-cli-json.test.ts +39 -39
  26. package/src/__tests__/builtin-config.test.ts +26 -26
  27. package/src/__tests__/builtin-context.test.ts +319 -202
  28. package/src/__tests__/builtin-file-tools.test.ts +240 -240
  29. package/src/__tests__/builtin-permissions.test.ts +211 -211
  30. package/src/__tests__/builtin-session-search.test.ts +228 -0
  31. package/src/__tests__/builtin-session-select.test.ts +116 -116
  32. package/src/__tests__/builtin-sigint.test.ts +56 -56
  33. package/src/__tests__/builtin-skills.test.ts +284 -284
  34. package/src/__tests__/builtin-web-tools.test.ts +220 -220
  35. package/src/__tests__/card-action-routing.test.ts +18 -18
  36. package/src/__tests__/cardkit.test.ts +60 -60
  37. package/src/__tests__/ccc-adapter.test.ts +170 -170
  38. package/src/__tests__/chatgpt-subscription-rpc.test.ts +89 -89
  39. package/src/__tests__/chatgpt-subscription.test.ts +135 -135
  40. package/src/__tests__/chrome-devtools-guard.test.ts +165 -165
  41. package/src/__tests__/claude-adapter.test.ts +614 -614
  42. package/src/__tests__/claude-raw-stream-log.test.ts +87 -87
  43. package/src/__tests__/codex-adapter.test.ts +58 -58
  44. package/src/__tests__/codex-raw-stream-log.test.ts +170 -170
  45. package/src/__tests__/codex-reset-actions.test.ts +146 -146
  46. package/src/__tests__/cursor-adapter.test.ts +268 -268
  47. package/src/__tests__/feishu-api.test.ts +60 -60
  48. package/src/__tests__/feishu-avatar.test.ts +164 -164
  49. package/src/__tests__/feishu-message-ingress.test.ts +138 -138
  50. package/src/__tests__/feishu-platform.test.ts +22 -22
  51. package/src/__tests__/format-message.test.ts +47 -47
  52. package/src/__tests__/jsonl-stream.test.ts +79 -79
  53. package/src/__tests__/package-files.test.ts +24 -24
  54. package/src/__tests__/privacy.test.ts +198 -198
  55. package/src/__tests__/progress-reducer.test.ts +121 -121
  56. package/src/__tests__/raw-stream-log.test.ts +106 -106
  57. package/src/__tests__/response-stall.test.ts +49 -49
  58. package/src/__tests__/restart.test.ts +132 -132
  59. package/src/__tests__/session.test.ts +199 -199
  60. package/src/__tests__/shared-prefix.test.ts +36 -36
  61. package/src/__tests__/sim-platform.test.ts +16 -16
  62. package/src/__tests__/startup-lifecycle.test.ts +231 -231
  63. package/src/__tests__/stop-session.test.ts +34 -34
  64. package/src/__tests__/stream-state.test.ts +42 -42
  65. package/src/__tests__/terminal-error.test.ts +54 -54
  66. package/src/__tests__/terminal-renderer.test.ts +247 -247
  67. package/src/__tests__/update-command-guard.test.ts +144 -144
  68. package/src/__tests__/web-ui.test.ts +326 -326
  69. package/src/adapters/adapter-interface.ts +33 -33
  70. package/src/adapters/ccc-adapter.ts +141 -141
  71. package/src/adapters/claude-adapter.ts +620 -620
  72. package/src/adapters/claude-session-meta-store.ts +120 -120
  73. package/src/adapters/codex-adapter.ts +426 -426
  74. package/src/adapters/cursor-adapter.ts +681 -681
  75. package/src/adapters/jsonl-stream.ts +157 -157
  76. package/src/adapters/raw-stream-log.ts +124 -124
  77. package/src/adapters/resource-monitor.ts +140 -140
  78. package/src/agent-activity.ts +175 -175
  79. package/src/agent-delegate-task-rpc.ts +153 -153
  80. package/src/agent-delegate-task.ts +91 -91
  81. package/src/agent-reload-config-rpc.ts +34 -34
  82. package/src/agent-stop-stuck.ts +129 -129
  83. package/src/builtin/cli.ts +6 -0
  84. package/src/builtin/config.ts +84 -84
  85. package/src/builtin/context.ts +465 -391
  86. package/src/builtin/file-log.ts +38 -38
  87. package/src/builtin/file-tools.ts +34 -0
  88. package/src/builtin/index.ts +24 -23
  89. package/src/builtin/proc-tree-kill.ts +61 -61
  90. package/src/builtin/progress/cards-helpers.ts +76 -76
  91. package/src/builtin/progress/reducer.ts +113 -113
  92. package/src/builtin/progress/terminal-renderer.ts +294 -294
  93. package/src/builtin/progress/view.ts +77 -77
  94. package/src/builtin/raw-stream-log.ts +124 -124
  95. package/src/builtin/session-search.ts +363 -0
  96. package/src/builtin/session-select.ts +48 -48
  97. package/src/builtin/sigint.ts +50 -50
  98. package/src/builtin/skills.ts +205 -205
  99. package/src/builtin/web-tools.ts +313 -313
  100. package/src/card-action-routing.ts +14 -14
  101. package/src/chatgpt-subscription-rpc.ts +27 -27
  102. package/src/chatgpt-subscription.ts +299 -299
  103. package/src/chrome-devtools-guard.ts +318 -318
  104. package/src/codex-reset-actions.ts +184 -184
  105. package/src/feishu-api.ts +193 -193
  106. package/src/feishu-message-ingress.ts +195 -195
  107. package/src/feishu-platform.ts +20 -20
  108. package/src/format-message.ts +293 -293
  109. package/src/litellm-proxy.ts +374 -374
  110. package/src/orchestrator.ts +2494 -2494
  111. package/src/platform-adapter.ts +6 -6
  112. package/src/privacy.ts +118 -118
  113. package/src/progress/reducer.ts +113 -113
  114. package/src/progress/terminal-renderer.ts +294 -294
  115. package/src/progress/view.ts +77 -77
  116. package/src/response-stall.ts +28 -28
  117. package/src/runtime-reload.ts +34 -34
  118. package/src/session-chat-binding.ts +82 -82
  119. package/src/session-name.ts +8 -8
  120. package/src/session.ts +201 -201
  121. package/src/shared-prefix.ts +29 -29
  122. package/src/sim-platform.ts +20 -20
  123. package/src/startup-lifecycle.ts +250 -250
  124. package/src/stream-state.ts +21 -21
  125. package/src/terminal-error.ts +129 -129
  126. package/src/turn-cards.ts +117 -117
  127. package/src/update-command-guard.ts +165 -165
@@ -66,21 +66,21 @@ export interface UnifiedSearchResultBlock {
66
66
  query: string;
67
67
  }
68
68
 
69
- export interface UnifiedCompactBoundaryBlock {
70
- type: "compact_boundary";
71
- trigger: "manual" | "auto";
72
- pre_tokens: number;
73
- post_tokens?: number;
74
- }
75
-
76
- export interface UnifiedAgentStatusBlock {
77
- type: "agent_status";
78
- status: "compacting" | "responding";
79
- }
80
-
81
- export type UnifiedBlock =
82
- | UnifiedAgentStatusBlock
83
- | UnifiedThinkingBlock
69
+ export interface UnifiedCompactBoundaryBlock {
70
+ type: "compact_boundary";
71
+ trigger: "manual" | "auto";
72
+ pre_tokens: number;
73
+ post_tokens?: number;
74
+ }
75
+
76
+ export interface UnifiedAgentStatusBlock {
77
+ type: "agent_status";
78
+ status: "compacting" | "responding";
79
+ }
80
+
81
+ export type UnifiedBlock =
82
+ | UnifiedAgentStatusBlock
83
+ | UnifiedThinkingBlock
84
84
  | UnifiedTextBlock
85
85
  | UnifiedTextFinalBlock
86
86
  | UnifiedToolUseBlock
@@ -93,17 +93,17 @@ export type UnifiedBlock =
93
93
  // UnifiedStreamMessage — 一次 SDK/CLI 事件对应的归一化消息
94
94
  // ---------------------------------------------------------------------------
95
95
 
96
- export interface UnifiedStreamMessage {
97
- type: "assistant" | "user" | "system";
98
- blocks: UnifiedBlock[];
99
- /**
100
- * 适配器确认本事件代表一条完整、权威的最终回复,而不是流式文本片段。
101
- *
102
- * response-stall 终止与最终事件可能在同一事件循环边界竞态;只有该标记
103
- * 为 true 时,上层才允许把已经触发的超时改判为正常完成。
104
- */
105
- isFinalResponse?: boolean;
106
- }
96
+ export interface UnifiedStreamMessage {
97
+ type: "assistant" | "user" | "system";
98
+ blocks: UnifiedBlock[];
99
+ /**
100
+ * 适配器确认本事件代表一条完整、权威的最终回复,而不是流式文本片段。
101
+ *
102
+ * response-stall 终止与最终事件可能在同一事件循环边界竞态;只有该标记
103
+ * 为 true 时,上层才允许把已经触发的超时改判为正常完成。
104
+ */
105
+ isFinalResponse?: boolean;
106
+ }
107
107
 
108
108
  // ---------------------------------------------------------------------------
109
109
  // CreateSessionResult
@@ -158,12 +158,12 @@ export interface ToolAdapter {
158
158
  /** 群描述中会话 ID 的前缀,如 "Claude Session:" */
159
159
  readonly sessionDescPrefix: string;
160
160
 
161
- /**
162
- * 创建新会话,返回会话 ID。
163
- * 适配器内部需处理后台流消费(静默消费 stream 中除 init 外的所有事件)。
164
- * signal 用于上层在长期收不到 init 事件时终止底层 SDK/CLI。
165
- */
166
- createSession(cwd: string, signal?: AbortSignal): Promise<CreateSessionResult>;
161
+ /**
162
+ * 创建新会话,返回会话 ID。
163
+ * 适配器内部需处理后台流消费(静默消费 stream 中除 init 外的所有事件)。
164
+ * signal 用于上层在长期收不到 init 事件时终止底层 SDK/CLI。
165
+ */
166
+ createSession(cwd: string, signal?: AbortSignal): Promise<CreateSessionResult>;
167
167
 
168
168
  /**
169
169
  * 向已有会话发送提示文本,返回归一化消息的异步迭代器。
@@ -208,4 +208,4 @@ export function parseUserCommand(userText: string): UserCommand {
208
208
  if (original.startsWith("/plan")) return { original, mode: "plan" };
209
209
  if (original.startsWith("/ask")) return { original, mode: "ask" };
210
210
  return { original, mode: null };
211
- }
211
+ }
@@ -1,141 +1,141 @@
1
- import { ChatSession, type ChatSessionConfig, type ChatSessionOptions } from "../builtin/index.ts";
2
- import {
3
- getBuiltinContextSession,
4
- newBuiltinSessionId,
5
- normalizeBuiltinSessionId,
6
- } from "../builtin/context.ts";
7
- import { config, CCC_SESSION_PREFIX } from "../config.ts";
8
- import type {
9
- CreateSessionResult,
10
- SessionInfo,
11
- ToolAdapter,
12
- ToolPromptOptions,
13
- UnifiedStreamMessage,
14
- } from "./adapter-interface.ts";
15
-
16
- export interface CccAdapterOptions extends ChatSessionConfig {
17
- contextDir?: string;
18
- compactAtTokens?: number;
19
- keepRecentMessages?: number;
20
- compactionTimeoutMs?: number;
21
- maxSteps?: number;
22
- }
23
-
24
- function toChatSessionOptions(
25
- sessionId: string,
26
- cwd: string,
27
- options: CccAdapterOptions,
28
- ): ChatSessionOptions {
29
- return {
30
- cwd,
31
- persist: true,
32
- sessionId,
33
- contextDir: options.contextDir,
34
- compactAtTokens: options.compactAtTokens,
35
- keepRecentMessages: options.keepRecentMessages,
36
- compactionTimeoutMs: options.compactionTimeoutMs,
37
- maxSteps: options.maxSteps,
38
- // chatccc 无终端可交互,且对齐 claude/codex 适配器的 bypass 模式:
39
- // 高危命令不询问,全部放行(与独立 deepccc CLI 的 ask 模式不同)
40
- permissionMode: "bypass",
41
- };
42
- }
43
-
44
- export function createCccAdapter(options: CccAdapterOptions = {}): ToolAdapter {
45
- const chatConfig: ChatSessionConfig = {
46
- ...(options.apiKey !== undefined ? { apiKey: options.apiKey } : {}),
47
- ...(options.baseURL !== undefined ? { baseURL: options.baseURL } : {}),
48
- ...(options.model !== undefined ? { model: options.model } : {}),
49
- ...(options.effort !== undefined ? { effort: options.effort } : {}),
50
- };
51
-
52
- return {
53
- displayName: "CCC Agent",
54
- sessionDescPrefix: CCC_SESSION_PREFIX,
55
-
56
- async createSession(cwd: string): Promise<CreateSessionResult> {
57
- const sessionId = newBuiltinSessionId();
58
- const session = new ChatSession(
59
- chatConfig,
60
- toChatSessionOptions(sessionId, cwd, options),
61
- );
62
- session.reset();
63
- return { sessionId };
64
- },
65
-
66
- async *prompt(
67
- sessionId: string,
68
- userText: string,
69
- cwd: string,
70
- signal?: AbortSignal,
71
- _promptOptions?: ToolPromptOptions,
72
- ): AsyncIterable<UnifiedStreamMessage> {
73
- const normalizedSessionId = normalizeBuiltinSessionId(sessionId);
74
- const session = new ChatSession(
75
- chatConfig,
76
- toChatSessionOptions(normalizedSessionId, cwd, options),
77
- );
78
-
79
- for await (const event of session.chat(userText, signal)) {
80
- if (event.type === "status") {
81
- yield {
82
- type: "assistant",
83
- blocks: [{
84
- type: "agent_status",
85
- status: event.phase === "compacting" ? "compacting" : "responding",
86
- }],
87
- };
88
- } else if (event.type === "text") {
89
- yield {
90
- type: "assistant",
91
- blocks: [{ type: "text", text: event.text }],
92
- };
93
- } else if (event.type === "tool_use") {
94
- yield {
95
- type: "assistant",
96
- blocks: [{
97
- type: "tool_use",
98
- id: event.id,
99
- name: event.name,
100
- input: event.input,
101
- }],
102
- };
103
- } else if (event.type === "tool_result") {
104
- yield {
105
- type: "assistant",
106
- blocks: [{
107
- type: "tool_result",
108
- tool_use_id: event.tool_use_id,
109
- content: event.content,
110
- is_error: event.is_error,
111
- }],
112
- };
113
- } else if (event.type === "done" && !signal?.aborted) {
114
- yield {
115
- type: "assistant",
116
- blocks: [],
117
- isFinalResponse: true,
118
- };
119
- } else if (event.type === "error") {
120
- throw new Error(event.message);
121
- }
122
- }
123
- },
124
-
125
- async getSessionInfo(sessionId: string): Promise<SessionInfo | undefined> {
126
- const normalizedSessionId = normalizeBuiltinSessionId(sessionId);
127
- const info = getBuiltinContextSession(normalizedSessionId, options.contextDir);
128
- if (!info) return undefined;
129
- return {
130
- sessionId: info.sessionId,
131
- cwd: info.cwd,
132
- lastModified: info.updatedAt,
133
- model: options.model ?? config.ccc.model,
134
- };
135
- },
136
-
137
- async closeSession(_sessionId: string): Promise<void> {
138
- // ChatSession uses one request-scoped stream per prompt. AbortSignal handles cancellation.
139
- },
140
- };
141
- }
1
+ import { ChatSession, type ChatSessionConfig, type ChatSessionOptions } from "../builtin/index.ts";
2
+ import {
3
+ getBuiltinContextSession,
4
+ newBuiltinSessionId,
5
+ normalizeBuiltinSessionId,
6
+ } from "../builtin/context.ts";
7
+ import { config, CCC_SESSION_PREFIX } from "../config.ts";
8
+ import type {
9
+ CreateSessionResult,
10
+ SessionInfo,
11
+ ToolAdapter,
12
+ ToolPromptOptions,
13
+ UnifiedStreamMessage,
14
+ } from "./adapter-interface.ts";
15
+
16
+ export interface CccAdapterOptions extends ChatSessionConfig {
17
+ contextDir?: string;
18
+ compactAtTokens?: number;
19
+ keepRecentMessages?: number;
20
+ compactionTimeoutMs?: number;
21
+ maxSteps?: number;
22
+ }
23
+
24
+ function toChatSessionOptions(
25
+ sessionId: string,
26
+ cwd: string,
27
+ options: CccAdapterOptions,
28
+ ): ChatSessionOptions {
29
+ return {
30
+ cwd,
31
+ persist: true,
32
+ sessionId,
33
+ contextDir: options.contextDir,
34
+ compactAtTokens: options.compactAtTokens,
35
+ keepRecentMessages: options.keepRecentMessages,
36
+ compactionTimeoutMs: options.compactionTimeoutMs,
37
+ maxSteps: options.maxSteps,
38
+ // chatccc 无终端可交互,且对齐 claude/codex 适配器的 bypass 模式:
39
+ // 高危命令不询问,全部放行(与独立 deepccc CLI 的 ask 模式不同)
40
+ permissionMode: "bypass",
41
+ };
42
+ }
43
+
44
+ export function createCccAdapter(options: CccAdapterOptions = {}): ToolAdapter {
45
+ const chatConfig: ChatSessionConfig = {
46
+ ...(options.apiKey !== undefined ? { apiKey: options.apiKey } : {}),
47
+ ...(options.baseURL !== undefined ? { baseURL: options.baseURL } : {}),
48
+ ...(options.model !== undefined ? { model: options.model } : {}),
49
+ ...(options.effort !== undefined ? { effort: options.effort } : {}),
50
+ };
51
+
52
+ return {
53
+ displayName: "CCC Agent",
54
+ sessionDescPrefix: CCC_SESSION_PREFIX,
55
+
56
+ async createSession(cwd: string): Promise<CreateSessionResult> {
57
+ const sessionId = newBuiltinSessionId();
58
+ const session = new ChatSession(
59
+ chatConfig,
60
+ toChatSessionOptions(sessionId, cwd, options),
61
+ );
62
+ session.reset();
63
+ return { sessionId };
64
+ },
65
+
66
+ async *prompt(
67
+ sessionId: string,
68
+ userText: string,
69
+ cwd: string,
70
+ signal?: AbortSignal,
71
+ _promptOptions?: ToolPromptOptions,
72
+ ): AsyncIterable<UnifiedStreamMessage> {
73
+ const normalizedSessionId = normalizeBuiltinSessionId(sessionId);
74
+ const session = new ChatSession(
75
+ chatConfig,
76
+ toChatSessionOptions(normalizedSessionId, cwd, options),
77
+ );
78
+
79
+ for await (const event of session.chat(userText, signal)) {
80
+ if (event.type === "status") {
81
+ yield {
82
+ type: "assistant",
83
+ blocks: [{
84
+ type: "agent_status",
85
+ status: event.phase === "compacting" ? "compacting" : "responding",
86
+ }],
87
+ };
88
+ } else if (event.type === "text") {
89
+ yield {
90
+ type: "assistant",
91
+ blocks: [{ type: "text", text: event.text }],
92
+ };
93
+ } else if (event.type === "tool_use") {
94
+ yield {
95
+ type: "assistant",
96
+ blocks: [{
97
+ type: "tool_use",
98
+ id: event.id,
99
+ name: event.name,
100
+ input: event.input,
101
+ }],
102
+ };
103
+ } else if (event.type === "tool_result") {
104
+ yield {
105
+ type: "assistant",
106
+ blocks: [{
107
+ type: "tool_result",
108
+ tool_use_id: event.tool_use_id,
109
+ content: event.content,
110
+ is_error: event.is_error,
111
+ }],
112
+ };
113
+ } else if (event.type === "done" && !signal?.aborted) {
114
+ yield {
115
+ type: "assistant",
116
+ blocks: [],
117
+ isFinalResponse: true,
118
+ };
119
+ } else if (event.type === "error") {
120
+ throw new Error(event.message);
121
+ }
122
+ }
123
+ },
124
+
125
+ async getSessionInfo(sessionId: string): Promise<SessionInfo | undefined> {
126
+ const normalizedSessionId = normalizeBuiltinSessionId(sessionId);
127
+ const info = getBuiltinContextSession(normalizedSessionId, options.contextDir);
128
+ if (!info) return undefined;
129
+ return {
130
+ sessionId: info.sessionId,
131
+ cwd: info.cwd,
132
+ lastModified: info.updatedAt,
133
+ model: options.model ?? config.ccc.model,
134
+ };
135
+ },
136
+
137
+ async closeSession(_sessionId: string): Promise<void> {
138
+ // ChatSession uses one request-scoped stream per prompt. AbortSignal handles cancellation.
139
+ },
140
+ };
141
+ }