chatccc 0.2.200 → 0.2.202
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/README.md +17 -15
- package/agent-prompts/claude_specific.md +45 -45
- package/agent-prompts/codex_specific.md +2 -2
- package/agent-prompts/cursor_specific.md +13 -13
- package/bin/cccagent.mjs +17 -17
- package/config.sample.json +27 -27
- package/im-skills/feishu-skill/receive-send-file.md +63 -63
- package/im-skills/feishu-skill/receive-send-image.md +24 -24
- package/im-skills/feishu-skill/skill.md +3 -3
- package/im-skills/wechat-file-skill/receive-send-file.md +38 -38
- package/im-skills/wechat-file-skill/send-file.mjs +83 -83
- package/im-skills/wechat-file-skill/skill.md +10 -10
- package/im-skills/wechat-image-skill/skill.md +10 -10
- package/im-skills/wechat-video-skill/receive-send-video.md +38 -38
- package/im-skills/wechat-video-skill/send-video.mjs +79 -79
- package/im-skills/wechat-video-skill/skill.md +10 -10
- package/package.json +1 -1
- package/scripts/postinstall-sharp-check.mjs +58 -58
- package/src/__tests__/agent-delegate-task-rpc.test.ts +165 -165
- package/src/__tests__/agent-reload-config-rpc.test.ts +99 -99
- package/src/__tests__/builtin-chat-session.test.ts +277 -277
- package/src/__tests__/builtin-cli-json.test.ts +39 -39
- package/src/__tests__/builtin-config.test.ts +33 -33
- package/src/__tests__/builtin-context.test.ts +163 -163
- package/src/__tests__/builtin-file-tools.test.ts +224 -224
- package/src/__tests__/builtin-session-select.test.ts +116 -116
- package/src/__tests__/builtin-sigint.test.ts +56 -56
- package/src/__tests__/card-plain-text.test.ts +5 -5
- package/src/__tests__/cardkit.test.ts +60 -60
- package/src/__tests__/cards.test.ts +133 -122
- package/src/__tests__/ccc-adapter.test.ts +114 -114
- package/src/__tests__/chatgpt-subscription-rpc.test.ts +89 -89
- package/src/__tests__/chatgpt-subscription.test.ts +135 -135
- package/src/__tests__/chrome-devtools-guard.test.ts +165 -165
- package/src/__tests__/claude-adapter.test.ts +592 -592
- package/src/__tests__/claude-raw-stream-log.test.ts +87 -87
- package/src/__tests__/codex-raw-stream-log.test.ts +163 -163
- package/src/__tests__/codex-reset-actions.test.ts +146 -146
- package/src/__tests__/config-reload.test.ts +10 -10
- package/src/__tests__/config-sample.test.ts +18 -18
- package/src/__tests__/cursor-adapter.test.ts +226 -226
- package/src/__tests__/feishu-api.test.ts +60 -60
- package/src/__tests__/feishu-avatar.test.ts +90 -90
- package/src/__tests__/feishu-platform.test.ts +22 -22
- package/src/__tests__/format-message.test.ts +47 -47
- package/src/__tests__/jsonl-stream.test.ts +79 -79
- package/src/__tests__/orchestrator.test.ts +464 -301
- package/src/__tests__/privacy.test.ts +198 -198
- package/src/__tests__/raw-stream-log.test.ts +106 -106
- package/src/__tests__/session.test.ts +46 -44
- package/src/__tests__/shared-prefix.test.ts +36 -36
- package/src/__tests__/sim-platform.test.ts +12 -12
- package/src/__tests__/stream-state.test.ts +42 -42
- package/src/__tests__/web-ui.test.ts +209 -209
- package/src/adapters/ccc-adapter.ts +121 -121
- package/src/adapters/claude-adapter.ts +603 -603
- package/src/adapters/claude-session-meta-store.ts +120 -120
- package/src/adapters/codex-adapter.ts +380 -380
- package/src/adapters/cursor-adapter.ts +673 -673
- package/src/adapters/jsonl-stream.ts +157 -157
- package/src/adapters/raw-stream-log.ts +124 -124
- package/src/adapters/resource-monitor.ts +140 -140
- package/src/agent-delegate-task-rpc.ts +153 -153
- package/src/agent-delegate-task.ts +81 -81
- package/src/agent-reload-config-rpc.ts +34 -34
- package/src/agent-stop-stuck.ts +129 -129
- package/src/builtin/cli.ts +473 -473
- package/src/builtin/context.ts +323 -323
- package/src/builtin/file-tools.ts +1072 -1072
- package/src/builtin/index.ts +404 -404
- package/src/builtin/session-select.ts +48 -48
- package/src/builtin/sigint.ts +50 -50
- package/src/cards.ts +222 -210
- package/src/chatgpt-subscription-rpc.ts +27 -27
- package/src/chatgpt-subscription.ts +299 -299
- package/src/chrome-devtools-guard.ts +318 -318
- package/src/codex-reset-actions.ts +184 -184
- package/src/config.ts +125 -125
- package/src/feishu-api.ts +118 -118
- package/src/feishu-platform.ts +20 -20
- package/src/format-message.ts +293 -293
- package/src/litellm-proxy.ts +374 -374
- package/src/orchestrator.ts +348 -329
- package/src/privacy.ts +118 -118
- package/src/runtime-reload.ts +34 -34
- package/src/session-chat-binding.ts +6 -6
- package/src/session-name.ts +8 -8
- package/src/session.ts +177 -169
- package/src/shared-prefix.ts +29 -29
- package/src/sim-platform.ts +20 -20
- package/src/turn-cards.ts +117 -117
- package/src/web-ui.ts +205 -205
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_BUILTIN_CONTEXT_DIR,
|
|
3
|
-
getBuiltinContextSession,
|
|
4
|
-
latestBuiltinSessionForCwd,
|
|
5
|
-
newBuiltinSessionId,
|
|
6
|
-
normalizeBuiltinSessionId,
|
|
7
|
-
} from "./context.js";
|
|
8
|
-
|
|
9
|
-
export type BuiltinResumeRequest = true | string | undefined;
|
|
10
|
-
|
|
11
|
-
export interface ResolveBuiltinSessionOptions {
|
|
12
|
-
cwd: string;
|
|
13
|
-
contextDir?: string;
|
|
14
|
-
resume?: BuiltinResumeRequest;
|
|
15
|
-
now?: Date;
|
|
16
|
-
randomSuffix?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface ResolvedBuiltinSession {
|
|
20
|
-
mode: "new" | "resumed";
|
|
21
|
-
sessionId: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function resolveBuiltinSession(options: ResolveBuiltinSessionOptions): ResolvedBuiltinSession {
|
|
25
|
-
const contextDir = options.contextDir ?? DEFAULT_BUILTIN_CONTEXT_DIR;
|
|
26
|
-
|
|
27
|
-
if (options.resume === true) {
|
|
28
|
-
const latest = latestBuiltinSessionForCwd(options.cwd, contextDir);
|
|
29
|
-
if (!latest) {
|
|
30
|
-
throw new Error(`未找到当前目录可恢复的 ccc 会话: ${options.cwd}`);
|
|
31
|
-
}
|
|
32
|
-
return { mode: "resumed", sessionId: latest.sessionId };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (typeof options.resume === "string") {
|
|
36
|
-
const sessionId = normalizeBuiltinSessionId(options.resume);
|
|
37
|
-
const existing = getBuiltinContextSession(sessionId, contextDir);
|
|
38
|
-
if (!existing) {
|
|
39
|
-
throw new Error(`未找到 ccc 会话: ${sessionId}`);
|
|
40
|
-
}
|
|
41
|
-
return { mode: "resumed", sessionId };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
mode: "new",
|
|
46
|
-
sessionId: newBuiltinSessionId(options.now, options.randomSuffix),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_BUILTIN_CONTEXT_DIR,
|
|
3
|
+
getBuiltinContextSession,
|
|
4
|
+
latestBuiltinSessionForCwd,
|
|
5
|
+
newBuiltinSessionId,
|
|
6
|
+
normalizeBuiltinSessionId,
|
|
7
|
+
} from "./context.js";
|
|
8
|
+
|
|
9
|
+
export type BuiltinResumeRequest = true | string | undefined;
|
|
10
|
+
|
|
11
|
+
export interface ResolveBuiltinSessionOptions {
|
|
12
|
+
cwd: string;
|
|
13
|
+
contextDir?: string;
|
|
14
|
+
resume?: BuiltinResumeRequest;
|
|
15
|
+
now?: Date;
|
|
16
|
+
randomSuffix?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ResolvedBuiltinSession {
|
|
20
|
+
mode: "new" | "resumed";
|
|
21
|
+
sessionId: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function resolveBuiltinSession(options: ResolveBuiltinSessionOptions): ResolvedBuiltinSession {
|
|
25
|
+
const contextDir = options.contextDir ?? DEFAULT_BUILTIN_CONTEXT_DIR;
|
|
26
|
+
|
|
27
|
+
if (options.resume === true) {
|
|
28
|
+
const latest = latestBuiltinSessionForCwd(options.cwd, contextDir);
|
|
29
|
+
if (!latest) {
|
|
30
|
+
throw new Error(`未找到当前目录可恢复的 ccc 会话: ${options.cwd}`);
|
|
31
|
+
}
|
|
32
|
+
return { mode: "resumed", sessionId: latest.sessionId };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof options.resume === "string") {
|
|
36
|
+
const sessionId = normalizeBuiltinSessionId(options.resume);
|
|
37
|
+
const existing = getBuiltinContextSession(sessionId, contextDir);
|
|
38
|
+
if (!existing) {
|
|
39
|
+
throw new Error(`未找到 ccc 会话: ${sessionId}`);
|
|
40
|
+
}
|
|
41
|
+
return { mode: "resumed", sessionId };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
mode: "new",
|
|
46
|
+
sessionId: newBuiltinSessionId(options.now, options.randomSuffix),
|
|
47
|
+
};
|
|
48
|
+
}
|
package/src/builtin/sigint.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
export const CTRL_C_CONFIRM_WINDOW_MS = 2000;
|
|
2
|
-
|
|
3
|
-
export type CtrlCAction =
|
|
4
|
-
| "arm-interrupt"
|
|
5
|
-
| "interrupt"
|
|
6
|
-
| "arm-exit"
|
|
7
|
-
| "exit";
|
|
8
|
-
|
|
9
|
-
type PendingCtrlCAction = "interrupt" | "exit";
|
|
10
|
-
|
|
11
|
-
export interface CtrlCStateOptions {
|
|
12
|
-
windowMs?: number;
|
|
13
|
-
now?: () => number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface CtrlCState {
|
|
17
|
-
press(isGenerating: boolean): CtrlCAction;
|
|
18
|
-
reset(): void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function createCtrlCState(options: CtrlCStateOptions = {}): CtrlCState {
|
|
22
|
-
const windowMs = options.windowMs ?? CTRL_C_CONFIRM_WINDOW_MS;
|
|
23
|
-
const now = options.now ?? Date.now;
|
|
24
|
-
|
|
25
|
-
let pending: PendingCtrlCAction | null = null;
|
|
26
|
-
let lastPressAt = 0;
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
press(isGenerating: boolean): CtrlCAction {
|
|
30
|
-
const action: PendingCtrlCAction = isGenerating ? "interrupt" : "exit";
|
|
31
|
-
const current = now();
|
|
32
|
-
const isConfirmed = pending === action && current - lastPressAt <= windowMs;
|
|
33
|
-
|
|
34
|
-
if (isConfirmed) {
|
|
35
|
-
pending = null;
|
|
36
|
-
lastPressAt = 0;
|
|
37
|
-
return action;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
pending = action;
|
|
41
|
-
lastPressAt = current;
|
|
42
|
-
return isGenerating ? "arm-interrupt" : "arm-exit";
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
reset(): void {
|
|
46
|
-
pending = null;
|
|
47
|
-
lastPressAt = 0;
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
1
|
+
export const CTRL_C_CONFIRM_WINDOW_MS = 2000;
|
|
2
|
+
|
|
3
|
+
export type CtrlCAction =
|
|
4
|
+
| "arm-interrupt"
|
|
5
|
+
| "interrupt"
|
|
6
|
+
| "arm-exit"
|
|
7
|
+
| "exit";
|
|
8
|
+
|
|
9
|
+
type PendingCtrlCAction = "interrupt" | "exit";
|
|
10
|
+
|
|
11
|
+
export interface CtrlCStateOptions {
|
|
12
|
+
windowMs?: number;
|
|
13
|
+
now?: () => number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CtrlCState {
|
|
17
|
+
press(isGenerating: boolean): CtrlCAction;
|
|
18
|
+
reset(): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createCtrlCState(options: CtrlCStateOptions = {}): CtrlCState {
|
|
22
|
+
const windowMs = options.windowMs ?? CTRL_C_CONFIRM_WINDOW_MS;
|
|
23
|
+
const now = options.now ?? Date.now;
|
|
24
|
+
|
|
25
|
+
let pending: PendingCtrlCAction | null = null;
|
|
26
|
+
let lastPressAt = 0;
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
press(isGenerating: boolean): CtrlCAction {
|
|
30
|
+
const action: PendingCtrlCAction = isGenerating ? "interrupt" : "exit";
|
|
31
|
+
const current = now();
|
|
32
|
+
const isConfirmed = pending === action && current - lastPressAt <= windowMs;
|
|
33
|
+
|
|
34
|
+
if (isConfirmed) {
|
|
35
|
+
pending = null;
|
|
36
|
+
lastPressAt = 0;
|
|
37
|
+
return action;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
pending = action;
|
|
41
|
+
lastPressAt = current;
|
|
42
|
+
return isGenerating ? "arm-interrupt" : "arm-exit";
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
reset(): void {
|
|
46
|
+
pending = null;
|
|
47
|
+
lastPressAt = 0;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|