chatccc 0.2.229 → 0.2.231

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 (120) 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 -76
  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 +65 -1
  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 +202 -163
  28. package/src/__tests__/builtin-permissions.test.ts +211 -211
  29. package/src/__tests__/builtin-session-select.test.ts +116 -116
  30. package/src/__tests__/builtin-sigint.test.ts +56 -56
  31. package/src/__tests__/builtin-web-tools.test.ts +220 -220
  32. package/src/__tests__/card-action-routing.test.ts +18 -18
  33. package/src/__tests__/cardkit.test.ts +60 -60
  34. package/src/__tests__/ccc-adapter.test.ts +170 -136
  35. package/src/__tests__/chatgpt-subscription-rpc.test.ts +89 -89
  36. package/src/__tests__/chatgpt-subscription.test.ts +135 -135
  37. package/src/__tests__/chrome-devtools-guard.test.ts +165 -165
  38. package/src/__tests__/claude-adapter.test.ts +614 -614
  39. package/src/__tests__/claude-raw-stream-log.test.ts +87 -87
  40. package/src/__tests__/codex-adapter.test.ts +58 -58
  41. package/src/__tests__/codex-raw-stream-log.test.ts +170 -170
  42. package/src/__tests__/codex-reset-actions.test.ts +146 -146
  43. package/src/__tests__/cursor-adapter.test.ts +268 -268
  44. package/src/__tests__/feishu-api.test.ts +60 -60
  45. package/src/__tests__/feishu-avatar.test.ts +164 -164
  46. package/src/__tests__/feishu-message-ingress.test.ts +138 -138
  47. package/src/__tests__/feishu-platform.test.ts +22 -22
  48. package/src/__tests__/format-message.test.ts +47 -47
  49. package/src/__tests__/jsonl-stream.test.ts +79 -79
  50. package/src/__tests__/package-files.test.ts +24 -24
  51. package/src/__tests__/privacy.test.ts +198 -198
  52. package/src/__tests__/progress-reducer.test.ts +121 -110
  53. package/src/__tests__/raw-stream-log.test.ts +106 -106
  54. package/src/__tests__/response-stall.test.ts +49 -49
  55. package/src/__tests__/session.test.ts +174 -16
  56. package/src/__tests__/shared-prefix.test.ts +36 -36
  57. package/src/__tests__/sim-platform.test.ts +16 -16
  58. package/src/__tests__/startup-lifecycle.test.ts +231 -231
  59. package/src/__tests__/stop-session.test.ts +34 -34
  60. package/src/__tests__/stream-state.test.ts +42 -42
  61. package/src/__tests__/terminal-error.test.ts +54 -0
  62. package/src/__tests__/terminal-renderer.test.ts +247 -247
  63. package/src/__tests__/update-command-guard.test.ts +144 -144
  64. package/src/__tests__/web-ui.test.ts +326 -326
  65. package/src/adapters/adapter-interface.ts +24 -18
  66. package/src/adapters/ccc-adapter.ts +141 -131
  67. package/src/adapters/claude-adapter.ts +620 -620
  68. package/src/adapters/claude-session-meta-store.ts +120 -120
  69. package/src/adapters/codex-adapter.ts +426 -426
  70. package/src/adapters/cursor-adapter.ts +681 -681
  71. package/src/adapters/jsonl-stream.ts +157 -157
  72. package/src/adapters/raw-stream-log.ts +124 -124
  73. package/src/adapters/resource-monitor.ts +140 -140
  74. package/src/agent-activity.ts +175 -170
  75. package/src/agent-delegate-task-rpc.ts +153 -153
  76. package/src/agent-delegate-task.ts +91 -91
  77. package/src/agent-reload-config-rpc.ts +34 -34
  78. package/src/agent-stop-stuck.ts +129 -129
  79. package/src/builtin/cli.ts +9 -2
  80. package/src/builtin/config.ts +84 -84
  81. package/src/builtin/context.ts +62 -4
  82. package/src/builtin/file-log.ts +38 -38
  83. package/src/builtin/index.ts +83 -19
  84. package/src/builtin/proc-tree-kill.ts +61 -61
  85. package/src/builtin/progress/cards-helpers.ts +76 -76
  86. package/src/builtin/progress/reducer.ts +113 -108
  87. package/src/builtin/progress/terminal-renderer.ts +294 -294
  88. package/src/builtin/progress/view.ts +77 -77
  89. package/src/builtin/raw-stream-log.ts +124 -124
  90. package/src/builtin/session-select.ts +48 -48
  91. package/src/builtin/sigint.ts +50 -50
  92. package/src/builtin/web-tools.ts +313 -313
  93. package/src/card-action-routing.ts +14 -14
  94. package/src/chatgpt-subscription-rpc.ts +27 -27
  95. package/src/chatgpt-subscription.ts +299 -299
  96. package/src/chrome-devtools-guard.ts +318 -318
  97. package/src/codex-reset-actions.ts +184 -184
  98. package/src/feishu-api.ts +193 -193
  99. package/src/feishu-message-ingress.ts +195 -195
  100. package/src/feishu-platform.ts +20 -20
  101. package/src/format-message.ts +293 -293
  102. package/src/litellm-proxy.ts +374 -374
  103. package/src/orchestrator.ts +8 -3
  104. package/src/platform-adapter.ts +6 -6
  105. package/src/privacy.ts +118 -118
  106. package/src/progress/reducer.ts +113 -108
  107. package/src/progress/terminal-renderer.ts +294 -294
  108. package/src/progress/view.ts +77 -77
  109. package/src/response-stall.ts +28 -28
  110. package/src/runtime-reload.ts +34 -34
  111. package/src/session-chat-binding.ts +82 -82
  112. package/src/session-name.ts +8 -8
  113. package/src/session.ts +149 -26
  114. package/src/shared-prefix.ts +29 -29
  115. package/src/sim-platform.ts +20 -20
  116. package/src/startup-lifecycle.ts +250 -250
  117. package/src/stream-state.ts +21 -18
  118. package/src/terminal-error.ts +129 -0
  119. package/src/turn-cards.ts +117 -117
  120. package/src/update-command-guard.ts +165 -165
@@ -1,60 +1,60 @@
1
- import { afterEach, describe, expect, it, vi } from "vitest";
2
-
3
- import { updateCardKitCard } from "../cardkit.ts";
4
-
5
- function abortError(): Error {
6
- const err = new Error("aborted");
7
- err.name = "AbortError";
8
- return err;
9
- }
10
-
11
- describe("CardKit request timeout", () => {
12
- afterEach(() => {
13
- vi.useRealTimers();
14
- vi.restoreAllMocks();
15
- vi.unstubAllGlobals();
16
- });
17
-
18
- it("aborts a hung card update so display.cardBusy can be released", async () => {
19
- vi.useFakeTimers();
20
- vi.spyOn(console, "error").mockImplementation(() => {});
21
-
22
- const fetchMock = vi.fn((_url: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) => (
23
- new Promise<Response>((_resolve, reject) => {
24
- init?.signal?.addEventListener("abort", () => reject(abortError()));
25
- })
26
- ));
27
- vi.stubGlobal("fetch", fetchMock);
28
-
29
- const update = expect(updateCardKitCard("token", "card-1", "{}", 7))
30
- .rejects.toThrow("updateCard cardId=card-1 seq=7 timeout after 15000ms");
31
- await vi.advanceTimersByTimeAsync(15_000);
32
-
33
- await update;
34
- expect(fetchMock).toHaveBeenCalledWith(
35
- expect.stringContaining("/cardkit/v1/cards/card-1"),
36
- expect.objectContaining({ signal: expect.any(AbortSignal) }),
37
- );
38
- });
39
-
40
- it("also aborts when response body reading hangs", async () => {
41
- vi.useFakeTimers();
42
- vi.spyOn(console, "error").mockImplementation(() => {});
43
-
44
- const fetchMock = vi.fn((_url: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) => (
45
- Promise.resolve({
46
- status: 200,
47
- text: () => new Promise<string>((_resolve, reject) => {
48
- init?.signal?.addEventListener("abort", () => reject(abortError()));
49
- }),
50
- } as Response)
51
- ));
52
- vi.stubGlobal("fetch", fetchMock);
53
-
54
- const update = expect(updateCardKitCard("token", "card-2", "{}", 8))
55
- .rejects.toThrow("updateCard cardId=card-2 seq=8 timeout after 15000ms");
56
- await vi.advanceTimersByTimeAsync(15_000);
57
-
58
- await update;
59
- });
60
- });
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+
3
+ import { updateCardKitCard } from "../cardkit.ts";
4
+
5
+ function abortError(): Error {
6
+ const err = new Error("aborted");
7
+ err.name = "AbortError";
8
+ return err;
9
+ }
10
+
11
+ describe("CardKit request timeout", () => {
12
+ afterEach(() => {
13
+ vi.useRealTimers();
14
+ vi.restoreAllMocks();
15
+ vi.unstubAllGlobals();
16
+ });
17
+
18
+ it("aborts a hung card update so display.cardBusy can be released", async () => {
19
+ vi.useFakeTimers();
20
+ vi.spyOn(console, "error").mockImplementation(() => {});
21
+
22
+ const fetchMock = vi.fn((_url: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) => (
23
+ new Promise<Response>((_resolve, reject) => {
24
+ init?.signal?.addEventListener("abort", () => reject(abortError()));
25
+ })
26
+ ));
27
+ vi.stubGlobal("fetch", fetchMock);
28
+
29
+ const update = expect(updateCardKitCard("token", "card-1", "{}", 7))
30
+ .rejects.toThrow("updateCard cardId=card-1 seq=7 timeout after 15000ms");
31
+ await vi.advanceTimersByTimeAsync(15_000);
32
+
33
+ await update;
34
+ expect(fetchMock).toHaveBeenCalledWith(
35
+ expect.stringContaining("/cardkit/v1/cards/card-1"),
36
+ expect.objectContaining({ signal: expect.any(AbortSignal) }),
37
+ );
38
+ });
39
+
40
+ it("also aborts when response body reading hangs", async () => {
41
+ vi.useFakeTimers();
42
+ vi.spyOn(console, "error").mockImplementation(() => {});
43
+
44
+ const fetchMock = vi.fn((_url: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) => (
45
+ Promise.resolve({
46
+ status: 200,
47
+ text: () => new Promise<string>((_resolve, reject) => {
48
+ init?.signal?.addEventListener("abort", () => reject(abortError()));
49
+ }),
50
+ } as Response)
51
+ ));
52
+ vi.stubGlobal("fetch", fetchMock);
53
+
54
+ const update = expect(updateCardKitCard("token", "card-2", "{}", 8))
55
+ .rejects.toThrow("updateCard cardId=card-2 seq=8 timeout after 15000ms");
56
+ await vi.advanceTimersByTimeAsync(15_000);
57
+
58
+ await update;
59
+ });
60
+ });
@@ -1,136 +1,170 @@
1
- import { mkdtemp } from "node:fs/promises";
2
- import { tmpdir } from "node:os";
3
- import { join } from "node:path";
4
-
5
- import { afterEach, describe, expect, it, vi } from "vitest";
6
-
7
- const streamTextMock = vi.fn();
8
- const generateTextMock = vi.fn();
9
-
10
- vi.mock("@ai-sdk/openai-compatible", () => ({
11
- createOpenAICompatible: vi.fn(() => (modelId: string) => ({ modelId })),
12
- }));
13
-
14
- vi.mock("ai", () => ({
15
- streamText: streamTextMock,
16
- generateText: generateTextMock,
17
- isLoopFinished: vi.fn(() => ({ loopFinished: true })),
18
- stepCountIs: vi.fn((count: number) => ({ count })),
19
- jsonSchema: vi.fn((schema: unknown) => schema),
20
- tool: vi.fn((definition: unknown) => definition),
21
- }));
22
-
23
- async function* textStream(...chunks: string[]): AsyncIterable<string> {
24
- for (const chunk of chunks) yield chunk;
25
- }
26
-
27
- async function* fullStream(...parts: unknown[]): AsyncIterable<unknown> {
28
- for (const part of parts) yield part;
29
- }
30
-
31
- afterEach(() => {
32
- streamTextMock.mockReset();
33
- generateTextMock.mockReset();
34
- });
35
-
36
- describe("createCccAdapter", () => {
37
- it("creates a persisted ccc session and exposes model/cwd metadata", async () => {
38
- const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
39
- const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-meta-"));
40
- const adapter = createCccAdapter({
41
- apiKey: "sk-test",
42
- contextDir,
43
- model: "deepseek-v4-pro",
44
- });
45
-
46
- const created = await adapter.createSession("F:\\repo");
47
- const info = await adapter.getSessionInfo(created.sessionId);
48
-
49
- expect(created.sessionId).toMatch(/^session-\d{8}-\d{6}-[a-f0-9]{6}$/);
50
- expect(info).toEqual(expect.objectContaining({
51
- sessionId: created.sessionId,
52
- cwd: "F:\\repo",
53
- model: "deepseek-v4-pro",
54
- }));
55
- });
56
-
57
- it("maps ChatSession text chunks to unified assistant text blocks", async () => {
58
- const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
59
- const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-stream-"));
60
- const adapter = createCccAdapter({
61
- apiKey: "sk-test",
62
- contextDir,
63
- model: "deepseek-v4-flash",
64
- });
65
- const { sessionId } = await adapter.createSession("F:\\repo");
66
- streamTextMock.mockReturnValueOnce({ textStream: textStream("hello", " world") });
67
-
68
- const messages = [];
69
- for await (const message of adapter.prompt(sessionId, "hi", "F:\\repo")) {
70
- messages.push(message);
71
- }
72
-
73
- expect(messages).toEqual([
74
- { type: "assistant", blocks: [{ type: "text", text: "hello" }] },
75
- { type: "assistant", blocks: [{ type: "text", text: " world" }] },
76
- { type: "assistant", blocks: [], isFinalResponse: true },
77
- ]);
78
- expect(streamTextMock).toHaveBeenCalledWith(expect.objectContaining({
79
- model: { modelId: "deepseek-v4-flash" },
80
- }));
81
- });
82
-
83
- it("maps ChatSession tool events to unified tool blocks", async () => {
84
- const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
85
- const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-tools-"));
86
- const adapter = createCccAdapter({
87
- apiKey: "sk-test",
88
- contextDir,
89
- model: "deepseek-v4-flash",
90
- });
91
- const { sessionId } = await adapter.createSession("F:\\repo");
92
- streamTextMock.mockReturnValueOnce({
93
- fullStream: fullStream(
94
- { type: "tool-call", toolCallId: "call-1", toolName: "read_file", input: { path: "README.md" } },
95
- { type: "tool-result", toolCallId: "call-1", toolName: "read_file", output: { content: "hello" } },
96
- ),
97
- });
98
-
99
- const messages = [];
100
- for await (const message of adapter.prompt(sessionId, "read", "F:\\repo")) {
101
- messages.push(message);
102
- }
103
-
104
- expect(messages).toEqual([
105
- {
106
- type: "assistant",
107
- blocks: [{ type: "tool_use", id: "call-1", name: "read_file", input: { path: "README.md" } }],
108
- },
109
- {
110
- type: "assistant",
111
- blocks: [{ type: "tool_result", tool_use_id: "call-1", content: { content: "hello" }, is_error: false }],
112
- },
113
- { type: "assistant", blocks: [], isFinalResponse: true },
114
- ]);
115
- });
116
-
117
- it("passes effort into ChatSession so streamText receives reasoningEffort", async () => {
118
- const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
119
- const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-effort-"));
120
- const adapter = createCccAdapter({
121
- apiKey: "sk-test",
122
- contextDir,
123
- effort: "xhigh",
124
- });
125
- const { sessionId } = await adapter.createSession("F:\\repo");
126
- streamTextMock.mockReturnValueOnce({ textStream: textStream("ok") });
127
-
128
- for await (const _message of adapter.prompt(sessionId, "hi", "F:\\repo")) {
129
- // drain
130
- }
131
-
132
- expect(streamTextMock).toHaveBeenLastCalledWith(expect.objectContaining({
133
- providerOptions: { deepseek: { reasoningEffort: "xhigh" } },
134
- }));
135
- });
136
- });
1
+ import { mkdtemp } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+
5
+ import { afterEach, describe, expect, it, vi } from "vitest";
6
+
7
+ const streamTextMock = vi.fn();
8
+ const generateTextMock = vi.fn();
9
+
10
+ vi.mock("@ai-sdk/openai-compatible", () => ({
11
+ createOpenAICompatible: vi.fn(() => (modelId: string) => ({ modelId })),
12
+ }));
13
+
14
+ vi.mock("ai", () => ({
15
+ streamText: streamTextMock,
16
+ generateText: generateTextMock,
17
+ isLoopFinished: vi.fn(() => ({ loopFinished: true })),
18
+ stepCountIs: vi.fn((count: number) => ({ count })),
19
+ jsonSchema: vi.fn((schema: unknown) => schema),
20
+ tool: vi.fn((definition: unknown) => definition),
21
+ }));
22
+
23
+ async function* textStream(...chunks: string[]): AsyncIterable<string> {
24
+ for (const chunk of chunks) yield chunk;
25
+ }
26
+
27
+ async function* fullStream(...parts: unknown[]): AsyncIterable<unknown> {
28
+ for (const part of parts) yield part;
29
+ }
30
+
31
+ afterEach(() => {
32
+ streamTextMock.mockReset();
33
+ generateTextMock.mockReset();
34
+ });
35
+
36
+ describe("createCccAdapter", () => {
37
+ it("creates a persisted ccc session and exposes model/cwd metadata", async () => {
38
+ const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
39
+ const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-meta-"));
40
+ const adapter = createCccAdapter({
41
+ apiKey: "sk-test",
42
+ contextDir,
43
+ model: "deepseek-v4-pro",
44
+ });
45
+
46
+ const created = await adapter.createSession("F:\\repo");
47
+ const info = await adapter.getSessionInfo(created.sessionId);
48
+
49
+ expect(created.sessionId).toMatch(/^session-\d{8}-\d{6}-[a-f0-9]{6}$/);
50
+ expect(info).toEqual(expect.objectContaining({
51
+ sessionId: created.sessionId,
52
+ cwd: "F:\\repo",
53
+ model: "deepseek-v4-pro",
54
+ }));
55
+ });
56
+
57
+ it("maps ChatSession text chunks to unified assistant text blocks", async () => {
58
+ const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
59
+ const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-stream-"));
60
+ const adapter = createCccAdapter({
61
+ apiKey: "sk-test",
62
+ contextDir,
63
+ model: "deepseek-v4-flash",
64
+ });
65
+ const { sessionId } = await adapter.createSession("F:\\repo");
66
+ streamTextMock.mockReturnValueOnce({ textStream: textStream("hello", " world") });
67
+
68
+ const messages = [];
69
+ for await (const message of adapter.prompt(sessionId, "hi", "F:\\repo")) {
70
+ messages.push(message);
71
+ }
72
+
73
+ expect(messages).toEqual([
74
+ { type: "assistant", blocks: [{ type: "agent_status", status: "responding" }] },
75
+ { type: "assistant", blocks: [{ type: "text", text: "hello" }] },
76
+ { type: "assistant", blocks: [{ type: "text", text: " world" }] },
77
+ { type: "assistant", blocks: [], isFinalResponse: true },
78
+ ]);
79
+ expect(streamTextMock).toHaveBeenCalledWith(expect.objectContaining({
80
+ model: { modelId: "deepseek-v4-flash" },
81
+ }));
82
+ });
83
+
84
+ it("maps ChatSession tool events to unified tool blocks", async () => {
85
+ const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
86
+ const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-tools-"));
87
+ const adapter = createCccAdapter({
88
+ apiKey: "sk-test",
89
+ contextDir,
90
+ model: "deepseek-v4-flash",
91
+ });
92
+ const { sessionId } = await adapter.createSession("F:\\repo");
93
+ streamTextMock.mockReturnValueOnce({
94
+ fullStream: fullStream(
95
+ { type: "tool-call", toolCallId: "call-1", toolName: "read_file", input: { path: "README.md" } },
96
+ { type: "tool-result", toolCallId: "call-1", toolName: "read_file", output: { content: "hello" } },
97
+ ),
98
+ });
99
+
100
+ const messages = [];
101
+ for await (const message of adapter.prompt(sessionId, "read", "F:\\repo")) {
102
+ messages.push(message);
103
+ }
104
+
105
+ expect(messages).toEqual([
106
+ { type: "assistant", blocks: [{ type: "agent_status", status: "responding" }] },
107
+ {
108
+ type: "assistant",
109
+ blocks: [{ type: "tool_use", id: "call-1", name: "read_file", input: { path: "README.md" } }],
110
+ },
111
+ {
112
+ type: "assistant",
113
+ blocks: [{ type: "tool_result", tool_use_id: "call-1", content: { content: "hello" }, is_error: false }],
114
+ },
115
+ { type: "assistant", blocks: [], isFinalResponse: true },
116
+ ]);
117
+ });
118
+
119
+ it("maps DeepCCC compaction and generation phases to unified activity blocks", async () => {
120
+ const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
121
+ const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-status-"));
122
+ const adapter = createCccAdapter({
123
+ apiKey: "sk-test",
124
+ contextDir,
125
+ compactAtTokens: 1,
126
+ keepRecentMessages: 1,
127
+ });
128
+ const { sessionId } = await adapter.createSession("F:\\repo");
129
+ streamTextMock.mockReturnValueOnce({ textStream: textStream("old") });
130
+ for await (const _message of adapter.prompt(sessionId, "old question", "F:\\repo")) {
131
+ // drain
132
+ }
133
+
134
+ generateTextMock.mockResolvedValueOnce({ text: "summary" });
135
+ streamTextMock.mockReturnValueOnce({ textStream: textStream("new") });
136
+ const messages = [];
137
+ for await (const message of adapter.prompt(sessionId, "new question", "F:\\repo")) {
138
+ messages.push(message);
139
+ }
140
+
141
+ expect(messages[0]).toEqual({
142
+ type: "assistant",
143
+ blocks: [{ type: "agent_status", status: "compacting" }],
144
+ });
145
+ expect(messages).toContainEqual({
146
+ type: "assistant",
147
+ blocks: [{ type: "agent_status", status: "responding" }],
148
+ });
149
+ });
150
+
151
+ it("passes effort into ChatSession so streamText receives reasoningEffort", async () => {
152
+ const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
153
+ const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-effort-"));
154
+ const adapter = createCccAdapter({
155
+ apiKey: "sk-test",
156
+ contextDir,
157
+ effort: "xhigh",
158
+ });
159
+ const { sessionId } = await adapter.createSession("F:\\repo");
160
+ streamTextMock.mockReturnValueOnce({ textStream: textStream("ok") });
161
+
162
+ for await (const _message of adapter.prompt(sessionId, "hi", "F:\\repo")) {
163
+ // drain
164
+ }
165
+
166
+ expect(streamTextMock).toHaveBeenLastCalledWith(expect.objectContaining({
167
+ providerOptions: { deepseek: { reasoningEffort: "xhigh" } },
168
+ }));
169
+ });
170
+ });
@@ -1,89 +1,89 @@
1
- import { Readable } from "node:stream";
2
- import { beforeEach, describe, expect, it, vi } from "vitest";
3
-
4
- const mockGetChatGptSubscriptionStatus = vi.hoisted(() => vi.fn());
5
-
6
- vi.mock("../chatgpt-subscription.ts", () => ({
7
- getChatGptSubscriptionStatus: mockGetChatGptSubscriptionStatus,
8
- }));
9
-
10
- import {
11
- CHATGPT_SUBSCRIPTION_PATH,
12
- handleChatGptSubscriptionRequest,
13
- } from "../chatgpt-subscription-rpc.ts";
14
-
15
- function request(path = CHATGPT_SUBSCRIPTION_PATH, method = "POST"): Readable & {
16
- url?: string;
17
- method?: string;
18
- headers: Record<string, string>;
19
- } {
20
- const req = Readable.from([]) as Readable & {
21
- url?: string;
22
- method?: string;
23
- headers: Record<string, string>;
24
- };
25
- req.url = path;
26
- req.method = method;
27
- req.headers = {};
28
- return req;
29
- }
30
-
31
- function response() {
32
- const res = {
33
- statusCode: 0,
34
- headers: {} as Record<string, string>,
35
- body: "",
36
- writeHead(status: number, headers: Record<string, string>) {
37
- this.statusCode = status;
38
- this.headers = headers;
39
- return this;
40
- },
41
- end(chunk?: string) {
42
- this.body += chunk ?? "";
43
- return this;
44
- },
45
- };
46
- return res;
47
- }
48
-
49
- describe("ChatGPT subscription RPC", () => {
50
- beforeEach(() => {
51
- mockGetChatGptSubscriptionStatus.mockReset();
52
- mockGetChatGptSubscriptionStatus.mockResolvedValue({
53
- ok: false,
54
- code: "chrome_cdp_disabled",
55
- reason: "Chrome CDP guard is disabled in ChatCCC config.",
56
- chromeCdp: { enabled: false, port: 15166, status: "skipped" },
57
- });
58
- });
59
-
60
- it("returns the structured subscription lookup JSON", async () => {
61
- const req = request();
62
- const res = response();
63
-
64
- await expect(handleChatGptSubscriptionRequest(req as never, res as never)).resolves.toBe(true);
65
-
66
- expect(res.statusCode).toBe(200);
67
- expect(JSON.parse(res.body)).toEqual({
68
- ok: false,
69
- code: "chrome_cdp_disabled",
70
- reason: "Chrome CDP guard is disabled in ChatCCC config.",
71
- chromeCdp: { enabled: false, port: 15166, status: "skipped" },
72
- });
73
- });
74
-
75
- it("does not handle other paths", async () => {
76
- const res = response();
77
-
78
- await expect(handleChatGptSubscriptionRequest(request("/api/other") as never, res as never)).resolves.toBe(false);
79
- expect(res.body).toBe("");
80
- });
81
-
82
- it("rejects non-POST methods", async () => {
83
- const res = response();
84
-
85
- await expect(handleChatGptSubscriptionRequest(request(CHATGPT_SUBSCRIPTION_PATH, "GET") as never, res as never)).resolves.toBe(true);
86
- expect(res.statusCode).toBe(405);
87
- expect(JSON.parse(res.body)).toMatchObject({ ok: false, code: "method_not_allowed" });
88
- });
89
- });
1
+ import { Readable } from "node:stream";
2
+ import { beforeEach, describe, expect, it, vi } from "vitest";
3
+
4
+ const mockGetChatGptSubscriptionStatus = vi.hoisted(() => vi.fn());
5
+
6
+ vi.mock("../chatgpt-subscription.ts", () => ({
7
+ getChatGptSubscriptionStatus: mockGetChatGptSubscriptionStatus,
8
+ }));
9
+
10
+ import {
11
+ CHATGPT_SUBSCRIPTION_PATH,
12
+ handleChatGptSubscriptionRequest,
13
+ } from "../chatgpt-subscription-rpc.ts";
14
+
15
+ function request(path = CHATGPT_SUBSCRIPTION_PATH, method = "POST"): Readable & {
16
+ url?: string;
17
+ method?: string;
18
+ headers: Record<string, string>;
19
+ } {
20
+ const req = Readable.from([]) as Readable & {
21
+ url?: string;
22
+ method?: string;
23
+ headers: Record<string, string>;
24
+ };
25
+ req.url = path;
26
+ req.method = method;
27
+ req.headers = {};
28
+ return req;
29
+ }
30
+
31
+ function response() {
32
+ const res = {
33
+ statusCode: 0,
34
+ headers: {} as Record<string, string>,
35
+ body: "",
36
+ writeHead(status: number, headers: Record<string, string>) {
37
+ this.statusCode = status;
38
+ this.headers = headers;
39
+ return this;
40
+ },
41
+ end(chunk?: string) {
42
+ this.body += chunk ?? "";
43
+ return this;
44
+ },
45
+ };
46
+ return res;
47
+ }
48
+
49
+ describe("ChatGPT subscription RPC", () => {
50
+ beforeEach(() => {
51
+ mockGetChatGptSubscriptionStatus.mockReset();
52
+ mockGetChatGptSubscriptionStatus.mockResolvedValue({
53
+ ok: false,
54
+ code: "chrome_cdp_disabled",
55
+ reason: "Chrome CDP guard is disabled in ChatCCC config.",
56
+ chromeCdp: { enabled: false, port: 15166, status: "skipped" },
57
+ });
58
+ });
59
+
60
+ it("returns the structured subscription lookup JSON", async () => {
61
+ const req = request();
62
+ const res = response();
63
+
64
+ await expect(handleChatGptSubscriptionRequest(req as never, res as never)).resolves.toBe(true);
65
+
66
+ expect(res.statusCode).toBe(200);
67
+ expect(JSON.parse(res.body)).toEqual({
68
+ ok: false,
69
+ code: "chrome_cdp_disabled",
70
+ reason: "Chrome CDP guard is disabled in ChatCCC config.",
71
+ chromeCdp: { enabled: false, port: 15166, status: "skipped" },
72
+ });
73
+ });
74
+
75
+ it("does not handle other paths", async () => {
76
+ const res = response();
77
+
78
+ await expect(handleChatGptSubscriptionRequest(request("/api/other") as never, res as never)).resolves.toBe(false);
79
+ expect(res.body).toBe("");
80
+ });
81
+
82
+ it("rejects non-POST methods", async () => {
83
+ const res = response();
84
+
85
+ await expect(handleChatGptSubscriptionRequest(request(CHATGPT_SUBSCRIPTION_PATH, "GET") as never, res as never)).resolves.toBe(true);
86
+ expect(res.statusCode).toBe(405);
87
+ expect(JSON.parse(res.body)).toMatchObject({ ok: false, code: "method_not_allowed" });
88
+ });
89
+ });