chatccc 0.2.252 → 0.2.254
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 +10 -1
- package/bin/cccagent.mjs +12 -3
- package/bin/chatccc.mjs +15 -6
- package/config.sample.json +2 -1
- package/deepccc-agent/README.md +40 -35
- package/deepccc-agent/os-prompts/darwin.md +8 -8
- package/deepccc-agent/os-prompts/linux.md +8 -8
- package/deepccc-agent/os-prompts/win32.md +11 -11
- package/deepccc-agent/package.json +65 -65
- package/dist/deepccc-agent/src/cli.js +634 -0
- package/dist/deepccc-agent/src/config.js +81 -0
- package/dist/deepccc-agent/src/context.js +348 -0
- package/dist/deepccc-agent/src/file-log.js +34 -0
- package/dist/deepccc-agent/src/file-tools.js +1208 -0
- package/dist/deepccc-agent/src/index.js +601 -0
- package/dist/deepccc-agent/src/permissions.js +170 -0
- package/dist/deepccc-agent/src/privacy.js +124 -0
- package/dist/deepccc-agent/src/proc-tree-kill.js +60 -0
- package/dist/deepccc-agent/src/progress/cards-helpers.js +70 -0
- package/dist/deepccc-agent/src/progress/reducer.js +102 -0
- package/dist/deepccc-agent/src/progress/terminal-renderer.js +264 -0
- package/dist/deepccc-agent/src/progress/view.js +30 -0
- package/dist/deepccc-agent/src/raw-stream-log.js +106 -0
- package/dist/deepccc-agent/src/session-search.js +276 -0
- package/dist/deepccc-agent/src/session-select.js +23 -0
- package/dist/deepccc-agent/src/sigint.js +26 -0
- package/dist/deepccc-agent/src/skills.js +178 -0
- package/dist/deepccc-agent/src/web-tools.js +246 -0
- package/dist/src/adapters/adapter-interface.js +19 -0
- package/dist/src/adapters/ccc-adapter.js +112 -0
- package/dist/src/adapters/claude-adapter.js +497 -0
- package/dist/src/adapters/claude-session-meta-store.js +92 -0
- package/dist/src/adapters/codex-adapter.js +279 -0
- package/dist/src/adapters/codex-session-meta-store.js +94 -0
- package/dist/src/adapters/cursor-adapter.js +491 -0
- package/dist/src/adapters/cursor-session-meta-store.js +116 -0
- package/dist/src/adapters/jsonl-stream.js +104 -0
- package/{src/adapters/proc-tree-kill.ts → dist/src/adapters/proc-tree-kill.js} +94 -97
- package/dist/src/adapters/raw-stream-log.js +106 -0
- package/dist/src/adapters/resource-monitor.js +113 -0
- package/dist/src/agent-activity.js +133 -0
- package/dist/src/agent-delegate-task-rpc.js +129 -0
- package/dist/src/agent-delegate-task.js +48 -0
- package/dist/src/agent-file-rpc.js +152 -0
- package/dist/src/agent-image-rpc.js +148 -0
- package/dist/src/agent-platform-routing.js +13 -0
- package/dist/src/agent-reload-config-rpc.js +23 -0
- package/dist/src/agent-rpc-body.js +87 -0
- package/dist/src/agent-stop-stuck.js +110 -0
- package/dist/src/agent-team/application/board-service.js +142 -0
- package/dist/src/agent-team/application/main-agent-service.js +151 -0
- package/dist/src/agent-team/domain/board.js +69 -0
- package/dist/src/agent-team/http/board-routes.js +213 -0
- package/dist/src/agent-team/infrastructure/filesystem-browser.js +112 -0
- package/dist/src/agent-team/infrastructure/main-agent-session-runtime.js +30 -0
- package/dist/src/agent-team/main-agent-bootstrap.js +15 -0
- package/dist/src/agent-team/repositories/board-repository.js +10 -0
- package/dist/src/agent-team/repositories/feishu-p2p-contact-store.js +64 -0
- package/dist/src/agent-team/repositories/json-board-repository.js +209 -0
- package/dist/src/agent-team/repositories/main-agent-binding-repository.js +84 -0
- package/dist/src/agent-team/sync/board-sync-adapter.js +1 -0
- package/dist/src/agent-team/web/agent-team-page.js +219 -0
- package/dist/src/agent-tool.js +10 -0
- package/dist/src/card-action-routing.js +7 -0
- package/dist/src/card-plain-text.js +101 -0
- package/dist/src/cardkit.js +158 -0
- package/dist/src/cards.js +573 -0
- package/dist/src/chatgpt-subscription-rpc.js +18 -0
- package/dist/src/chatgpt-subscription.js +199 -0
- package/dist/src/chrome-devtools-guard.js +238 -0
- package/dist/src/claude-sdk-installer.js +249 -0
- package/dist/src/codex-reset-actions.js +143 -0
- package/dist/src/config-utils.js +149 -0
- package/dist/src/config.js +808 -0
- package/dist/src/cursor-usage.js +77 -0
- package/dist/src/exit-banner.js +28 -0
- package/dist/src/feishu-api.js +1404 -0
- package/dist/src/feishu-message-ingress.js +137 -0
- package/dist/src/feishu-platform.js +97 -0
- package/dist/src/format-message.js +252 -0
- package/dist/src/git-command.js +155 -0
- package/dist/src/im-skills.js +121 -0
- package/dist/src/index.js +835 -0
- package/dist/src/litellm-proxy.js +300 -0
- package/dist/src/orchestrator.js +2096 -0
- package/dist/src/package-root.js +26 -0
- package/dist/src/platform-adapter.js +7 -0
- package/dist/src/platform-startup.js +6 -0
- package/dist/src/privacy.js +100 -0
- package/dist/src/progress/reducer.js +102 -0
- package/dist/src/progress/terminal-renderer.js +264 -0
- package/dist/src/progress/view.js +30 -0
- package/dist/src/response-stall.js +14 -0
- package/dist/src/runtime-entry.js +13 -0
- package/dist/src/runtime-reload.js +19 -0
- package/dist/src/session-chat-binding.js +183 -0
- package/dist/src/session-name.js +7 -0
- package/dist/src/session.js +2147 -0
- package/dist/src/shared-prefix.js +16 -0
- package/dist/src/shared.js +493 -0
- package/dist/src/sim-agent.js +105 -0
- package/dist/src/sim-platform.js +142 -0
- package/dist/src/sim-store.js +231 -0
- package/dist/src/simplify.js +99 -0
- package/dist/src/startup-lifecycle.js +209 -0
- package/dist/src/stream-state.js +141 -0
- package/dist/src/terminal-error.js +100 -0
- package/dist/src/trace.js +50 -0
- package/dist/src/turn-cards.js +92 -0
- package/dist/src/update-command-guard.js +114 -0
- package/{src/web-ui.ts → dist/src/web-ui.js} +753 -839
- package/dist/src/wechat-platform.js +545 -0
- package/package.json +76 -74
- package/deepccc-agent/LICENSE +0 -201
- package/deepccc-agent/bin/deepccc.mjs +0 -26
- package/deepccc-agent/docs/cache-hit-rate-1.jpg +0 -0
- package/deepccc-agent/docs/cache-hit-rate-2.jpg +0 -0
- package/deepccc-agent/package-lock.json +0 -2027
- package/deepccc-agent/src/__tests__/chat-session.test.ts +0 -877
- package/deepccc-agent/src/__tests__/cli-json.test.ts +0 -49
- package/deepccc-agent/src/__tests__/config.test.ts +0 -34
- package/deepccc-agent/src/__tests__/context.test.ts +0 -341
- package/deepccc-agent/src/__tests__/file-tools.test.ts +0 -240
- package/deepccc-agent/src/__tests__/permissions.test.ts +0 -199
- package/deepccc-agent/src/__tests__/privacy.test.ts +0 -318
- package/deepccc-agent/src/__tests__/progress-reducer.test.ts +0 -121
- package/deepccc-agent/src/__tests__/session-search.test.ts +0 -262
- package/deepccc-agent/src/__tests__/session-select.test.ts +0 -116
- package/deepccc-agent/src/__tests__/sigint.test.ts +0 -56
- package/deepccc-agent/src/__tests__/skills.test.ts +0 -284
- package/deepccc-agent/src/__tests__/terminal-renderer.test.ts +0 -247
- package/deepccc-agent/src/__tests__/web-tools.test.ts +0 -220
- package/deepccc-agent/src/cli.ts +0 -682
- package/deepccc-agent/src/config.ts +0 -101
- package/deepccc-agent/src/context.ts +0 -465
- package/deepccc-agent/src/file-log.ts +0 -38
- package/deepccc-agent/src/file-tools.ts +0 -1493
- package/deepccc-agent/src/index.ts +0 -710
- package/deepccc-agent/src/permissions.ts +0 -226
- package/deepccc-agent/src/privacy.ts +0 -141
- package/deepccc-agent/src/proc-tree-kill.ts +0 -61
- package/deepccc-agent/src/progress/cards-helpers.ts +0 -76
- package/deepccc-agent/src/progress/reducer.ts +0 -113
- package/deepccc-agent/src/progress/terminal-renderer.ts +0 -294
- package/deepccc-agent/src/progress/view.ts +0 -77
- package/deepccc-agent/src/raw-stream-log.ts +0 -124
- package/deepccc-agent/src/session-search.ts +0 -370
- package/deepccc-agent/src/session-select.ts +0 -48
- package/deepccc-agent/src/sigint.ts +0 -50
- package/deepccc-agent/src/skills.ts +0 -205
- package/deepccc-agent/src/web-tools.ts +0 -313
- package/deepccc-agent/tsconfig.build.json +0 -13
- package/deepccc-agent/tsconfig.json +0 -13
- package/deepccc-agent/vitest.config.ts +0 -7
- package/src/__tests__/adapter-interface.test.ts +0 -152
- package/src/__tests__/agent-activity.test.ts +0 -86
- package/src/__tests__/agent-delegate-task-rpc.test.ts +0 -165
- package/src/__tests__/agent-image-rpc.test.ts +0 -34
- package/src/__tests__/agent-platform-routing.test.ts +0 -26
- package/src/__tests__/agent-reload-config-rpc.test.ts +0 -99
- package/src/__tests__/agent-rpc-body.test.ts +0 -42
- package/src/__tests__/builtin-chat-session.test.ts +0 -532
- package/src/__tests__/builtin-cli-json.test.ts +0 -39
- package/src/__tests__/builtin-config.test.ts +0 -26
- package/src/__tests__/builtin-context.test.ts +0 -319
- package/src/__tests__/builtin-file-tools.test.ts +0 -240
- package/src/__tests__/builtin-permissions.test.ts +0 -219
- package/src/__tests__/builtin-session-search.test.ts +0 -262
- package/src/__tests__/builtin-session-select.test.ts +0 -116
- package/src/__tests__/builtin-sigint.test.ts +0 -56
- package/src/__tests__/builtin-skills.test.ts +0 -284
- package/src/__tests__/builtin-web-tools.test.ts +0 -220
- package/src/__tests__/card-action-routing.test.ts +0 -18
- package/src/__tests__/card-plain-text.test.ts +0 -45
- package/src/__tests__/cardkit.test.ts +0 -60
- package/src/__tests__/cards.test.ts +0 -607
- package/src/__tests__/ccc-adapter.test.ts +0 -194
- package/src/__tests__/chatgpt-subscription-rpc.test.ts +0 -89
- package/src/__tests__/chatgpt-subscription.test.ts +0 -135
- package/src/__tests__/chrome-devtools-guard.test.ts +0 -165
- package/src/__tests__/claude-adapter.test.ts +0 -614
- package/src/__tests__/claude-raw-stream-log.test.ts +0 -96
- package/src/__tests__/claude-sdk-installer.test.ts +0 -285
- package/src/__tests__/codex-adapter.test.ts +0 -331
- package/src/__tests__/codex-raw-stream-log.test.ts +0 -170
- package/src/__tests__/codex-reset-actions.test.ts +0 -146
- package/src/__tests__/config-reload.test.ts +0 -284
- package/src/__tests__/config-sample.test.ts +0 -97
- package/src/__tests__/config-utils.test.ts +0 -40
- package/src/__tests__/config.test.ts +0 -395
- package/src/__tests__/crash-logging.test.ts +0 -360
- package/src/__tests__/cursor-adapter.test.ts +0 -890
- package/src/__tests__/cursor-session-meta-store.test.ts +0 -212
- package/src/__tests__/feishu-api.test.ts +0 -60
- package/src/__tests__/feishu-avatar.test.ts +0 -504
- package/src/__tests__/feishu-message-ingress.test.ts +0 -138
- package/src/__tests__/feishu-platform.test.ts +0 -75
- package/src/__tests__/fixtures/codex_simple_text.jsonl +0 -4
- package/src/__tests__/fixtures/codex_with_tool.jsonl +0 -6
- package/src/__tests__/fixtures/cursor_partial_only.jsonl +0 -5
- package/src/__tests__/fixtures/cursor_partial_with_final.jsonl +0 -13
- package/src/__tests__/fixtures/cursor_with_tool_call.jsonl +0 -12
- package/src/__tests__/format-message.test.ts +0 -316
- package/src/__tests__/git-command.test.ts +0 -288
- package/src/__tests__/im-skills.test.ts +0 -125
- package/src/__tests__/jsonl-stream.test.ts +0 -79
- package/src/__tests__/orchestrator.test.ts +0 -1268
- package/src/__tests__/package-files.test.ts +0 -24
- package/src/__tests__/platform-startup.test.ts +0 -19
- package/src/__tests__/privacy.test.ts +0 -198
- package/src/__tests__/proc-tree-kill.test.ts +0 -108
- package/src/__tests__/progress-reducer.test.ts +0 -121
- package/src/__tests__/raw-stream-log.test.ts +0 -106
- package/src/__tests__/response-stall.test.ts +0 -49
- package/src/__tests__/restart.test.ts +0 -232
- package/src/__tests__/session-ccc-config.test.ts +0 -66
- package/src/__tests__/session.test.ts +0 -3004
- package/src/__tests__/shared-prefix.test.ts +0 -36
- package/src/__tests__/sim-agent.test.ts +0 -174
- package/src/__tests__/sim-platform.test.ts +0 -93
- package/src/__tests__/sim-store.test.ts +0 -214
- package/src/__tests__/simplify.test.ts +0 -283
- package/src/__tests__/startup-lifecycle.test.ts +0 -231
- package/src/__tests__/stop-session.test.ts +0 -162
- package/src/__tests__/stream-state.test.ts +0 -164
- package/src/__tests__/terminal-error.test.ts +0 -54
- package/src/__tests__/terminal-renderer.test.ts +0 -247
- package/src/__tests__/update-command-guard.test.ts +0 -144
- package/src/__tests__/web-ui.test.ts +0 -438
- package/src/__tests__/wechat-platform.test.ts +0 -111
- package/src/adapters/adapter-interface.ts +0 -217
- package/src/adapters/ccc-adapter.ts +0 -150
- package/src/adapters/claude-adapter.ts +0 -673
- package/src/adapters/claude-session-meta-store.ts +0 -120
- package/src/adapters/codex-adapter.ts +0 -426
- package/src/adapters/codex-session-meta-store.ts +0 -131
- package/src/adapters/cursor-adapter.ts +0 -681
- package/src/adapters/cursor-session-meta-store.ts +0 -154
- package/src/adapters/jsonl-stream.ts +0 -157
- package/src/adapters/raw-stream-log.ts +0 -124
- package/src/adapters/resource-monitor.ts +0 -141
- package/src/agent-activity.ts +0 -175
- package/src/agent-delegate-task-rpc.ts +0 -153
- package/src/agent-delegate-task.ts +0 -91
- package/src/agent-file-rpc.ts +0 -172
- package/src/agent-image-rpc.ts +0 -168
- package/src/agent-platform-routing.ts +0 -28
- package/src/agent-reload-config-rpc.ts +0 -34
- package/src/agent-rpc-body.ts +0 -92
- package/src/agent-stop-stuck.ts +0 -129
- package/src/card-action-routing.ts +0 -14
- package/src/card-plain-text.ts +0 -108
- package/src/cardkit.ts +0 -179
- package/src/cards.ts +0 -684
- package/src/chatgpt-subscription-rpc.ts +0 -27
- package/src/chatgpt-subscription.ts +0 -299
- package/src/chrome-devtools-guard.ts +0 -318
- package/src/claude-sdk-installer.ts +0 -324
- package/src/codex-reset-actions.ts +0 -184
- package/src/config-utils.ts +0 -211
- package/src/config.ts +0 -1063
- package/src/cursor-usage.ts +0 -128
- package/src/exit-banner.ts +0 -33
- package/src/feishu-api.ts +0 -1616
- package/src/feishu-message-ingress.ts +0 -195
- package/src/feishu-platform.ts +0 -159
- package/src/format-message.ts +0 -293
- package/src/git-command.ts +0 -202
- package/src/im-skills.ts +0 -149
- package/src/index.ts +0 -1089
- package/src/litellm-proxy.ts +0 -374
- package/src/orchestrator.ts +0 -2543
- package/src/platform-adapter.ts +0 -70
- package/src/platform-startup.ts +0 -16
- package/src/privacy.ts +0 -118
- package/src/progress/reducer.ts +0 -113
- package/src/progress/terminal-renderer.ts +0 -294
- package/src/progress/view.ts +0 -77
- package/src/response-stall.ts +0 -28
- package/src/runtime-reload.ts +0 -34
- package/src/session-chat-binding.ts +0 -292
- package/src/session-name.ts +0 -8
- package/src/session.ts +0 -2659
- package/src/shared-prefix.ts +0 -29
- package/src/shared.ts +0 -552
- package/src/sim-agent.ts +0 -167
- package/src/sim-platform.ts +0 -177
- package/src/sim-store.ts +0 -317
- package/src/simplify.ts +0 -120
- package/src/startup-lifecycle.ts +0 -250
- package/src/stream-state.ts +0 -177
- package/src/terminal-error.ts +0 -129
- package/src/trace.ts +0 -51
- package/src/turn-cards.ts +0 -118
- package/src/update-command-guard.ts +0 -165
- package/src/wechat-platform.ts +0 -680
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { Readable } from "node:stream";
|
|
2
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
3
|
-
|
|
4
|
-
import type { PlatformAdapter } from "../platform-adapter.ts";
|
|
5
|
-
|
|
6
|
-
const mockDelegateAgentTask = vi.hoisted(() => vi.fn());
|
|
7
|
-
|
|
8
|
-
vi.mock("../agent-delegate-task.ts", () => ({
|
|
9
|
-
delegateAgentTask: mockDelegateAgentTask,
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
AGENT_DELEGATE_TASK_PATH,
|
|
14
|
-
buildAgentDelegateTaskCapabilityPrompt,
|
|
15
|
-
handleAgentDelegateTaskRequest,
|
|
16
|
-
} from "../agent-delegate-task-rpc.ts";
|
|
17
|
-
import { ABD_APPEND_PROMPT } from "../shared-prefix.ts";
|
|
18
|
-
|
|
19
|
-
function request(body: unknown, path = AGENT_DELEGATE_TASK_PATH, method = "POST"): Readable & {
|
|
20
|
-
url?: string;
|
|
21
|
-
method?: string;
|
|
22
|
-
headers: Record<string, string>;
|
|
23
|
-
} {
|
|
24
|
-
const req = Readable.from([Buffer.from(JSON.stringify(body), "utf8")]) as Readable & {
|
|
25
|
-
url?: string;
|
|
26
|
-
method?: string;
|
|
27
|
-
headers: Record<string, string>;
|
|
28
|
-
};
|
|
29
|
-
req.url = path;
|
|
30
|
-
req.method = method;
|
|
31
|
-
req.headers = { "content-type": "application/json; charset=utf-8" };
|
|
32
|
-
return req;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function response() {
|
|
36
|
-
const res = {
|
|
37
|
-
statusCode: 0,
|
|
38
|
-
headers: {} as Record<string, string>,
|
|
39
|
-
body: "",
|
|
40
|
-
writeHead(status: number, headers: Record<string, string>) {
|
|
41
|
-
this.statusCode = status;
|
|
42
|
-
this.headers = headers;
|
|
43
|
-
return this;
|
|
44
|
-
},
|
|
45
|
-
end(chunk?: string) {
|
|
46
|
-
this.body += chunk ?? "";
|
|
47
|
-
return this;
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
return res;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function platform(kind: "feishu" | "wechat" = "feishu"): PlatformAdapter {
|
|
54
|
-
return {
|
|
55
|
-
kind,
|
|
56
|
-
sendText: vi.fn(async () => true),
|
|
57
|
-
sendCard: vi.fn(async () => true),
|
|
58
|
-
sendRawCard: vi.fn(async () => true),
|
|
59
|
-
createGroup: vi.fn(async () => "chat-id"),
|
|
60
|
-
updateChatInfo: vi.fn(async () => {}),
|
|
61
|
-
getChatInfo: vi.fn(async () => ({ name: "chat", description: "" })),
|
|
62
|
-
disbandChat: vi.fn(async () => {}),
|
|
63
|
-
setChatAvatar: vi.fn(async () => {}),
|
|
64
|
-
extractSessionInfo: vi.fn(() => null),
|
|
65
|
-
cardCreate: vi.fn(async () => "card-id"),
|
|
66
|
-
cardSend: vi.fn(async () => "message-id"),
|
|
67
|
-
cardUpdate: vi.fn(async () => {}),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
describe("agent delegate task RPC", () => {
|
|
72
|
-
beforeEach(() => {
|
|
73
|
-
mockDelegateAgentTask.mockReset();
|
|
74
|
-
mockDelegateAgentTask.mockResolvedValue({
|
|
75
|
-
chatId: "chat-new",
|
|
76
|
-
sessionId: "sid-new",
|
|
77
|
-
tool: "codex",
|
|
78
|
-
cwd: "F:\\repo",
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("delegates a task through the local API", async () => {
|
|
83
|
-
const req = request({
|
|
84
|
-
tool: "codex",
|
|
85
|
-
cwd: "F:\\repo",
|
|
86
|
-
open_id: "ou-user",
|
|
87
|
-
prompt: "帮我分析日志",
|
|
88
|
-
});
|
|
89
|
-
const res = response();
|
|
90
|
-
|
|
91
|
-
await handleAgentDelegateTaskRequest(req as never, res as never, platform());
|
|
92
|
-
|
|
93
|
-
expect(res.statusCode).toBe(200);
|
|
94
|
-
expect(JSON.parse(res.body)).toMatchObject({
|
|
95
|
-
ok: true,
|
|
96
|
-
chat_id: "chat-new",
|
|
97
|
-
session_id: "sid-new",
|
|
98
|
-
tool: "codex",
|
|
99
|
-
});
|
|
100
|
-
expect(mockDelegateAgentTask).toHaveBeenCalledWith(expect.objectContaining({
|
|
101
|
-
tool: "codex",
|
|
102
|
-
cwd: expect.stringContaining("repo"),
|
|
103
|
-
promptText: "帮我分析日志",
|
|
104
|
-
openIds: ["ou-user"],
|
|
105
|
-
chatNamePrefix: "帮我分析日志",
|
|
106
|
-
}));
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("applies the shared ABD prefix to API prompts", async () => {
|
|
110
|
-
const req = request({
|
|
111
|
-
tool: "claude",
|
|
112
|
-
cwd: "F:\\repo",
|
|
113
|
-
openIds: ["ou-user"],
|
|
114
|
-
prompt: "/abd帮我分析",
|
|
115
|
-
});
|
|
116
|
-
const res = response();
|
|
117
|
-
|
|
118
|
-
await handleAgentDelegateTaskRequest(req as never, res as never, platform());
|
|
119
|
-
|
|
120
|
-
expect(res.statusCode).toBe(200);
|
|
121
|
-
expect(mockDelegateAgentTask).toHaveBeenCalledWith(expect.objectContaining({
|
|
122
|
-
promptText: `帮我分析\n\n---\n${ABD_APPEND_PROMPT}`,
|
|
123
|
-
chatNamePrefix: "帮我分析",
|
|
124
|
-
}));
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("rejects non-Feishu platforms", async () => {
|
|
128
|
-
const req = request({
|
|
129
|
-
tool: "codex",
|
|
130
|
-
cwd: "F:\\repo",
|
|
131
|
-
open_id: "ou-user",
|
|
132
|
-
prompt: "task",
|
|
133
|
-
});
|
|
134
|
-
const res = response();
|
|
135
|
-
|
|
136
|
-
await handleAgentDelegateTaskRequest(req as never, res as never, platform("wechat"));
|
|
137
|
-
|
|
138
|
-
expect(res.statusCode).toBe(409);
|
|
139
|
-
expect(mockDelegateAgentTask).not.toHaveBeenCalled();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it("rejects missing required parameters", async () => {
|
|
143
|
-
const req = request({ tool: "codex", cwd: "F:\\repo", prompt: "task" });
|
|
144
|
-
const res = response();
|
|
145
|
-
|
|
146
|
-
await handleAgentDelegateTaskRequest(req as never, res as never, platform());
|
|
147
|
-
|
|
148
|
-
expect(res.statusCode).toBe(400);
|
|
149
|
-
expect(JSON.parse(res.body).error).toContain("open_id");
|
|
150
|
-
expect(mockDelegateAgentTask).not.toHaveBeenCalled();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("builds prompt instructions for the delegate endpoint", () => {
|
|
154
|
-
const prompt = buildAgentDelegateTaskCapabilityPrompt({
|
|
155
|
-
url: `http://127.0.0.1:18080${AGENT_DELEGATE_TASK_PATH}`,
|
|
156
|
-
cwd: "F:/repo",
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
expect(prompt).toContain("POST http://127.0.0.1:18080/api/agent/delegate-task");
|
|
160
|
-
expect(prompt).toContain('"tool":"codex|claude|cursor"');
|
|
161
|
-
expect(prompt).toContain('"cwd":"absolute working directory"');
|
|
162
|
-
expect(prompt).toContain("project prompt injection and IM skills still apply");
|
|
163
|
-
expect(prompt).toContain("Current working directory: F:/repo");
|
|
164
|
-
});
|
|
165
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
AGENT_SEND_IMAGE_PATH,
|
|
5
|
-
buildAgentImageCapabilityPrompt,
|
|
6
|
-
} from "../agent-image-rpc.ts";
|
|
7
|
-
|
|
8
|
-
describe("agent image RPC", () => {
|
|
9
|
-
it("builds prompt instructions with session_id", () => {
|
|
10
|
-
const prompt = buildAgentImageCapabilityPrompt({
|
|
11
|
-
url: `http://127.0.0.1:18080${AGENT_SEND_IMAGE_PATH}`,
|
|
12
|
-
sessionId: "sid-test",
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
expect(prompt).toContain("POST http://127.0.0.1:18080/api/agent/send-image");
|
|
16
|
-
expect(prompt).toContain('"session_id":"sid-test"');
|
|
17
|
-
expect(prompt).toContain("Content-Type: application/json; charset=utf-8");
|
|
18
|
-
expect(prompt).toContain("UTF-8 encoded JSON bytes");
|
|
19
|
-
expect(prompt).toContain('"path"');
|
|
20
|
-
expect(prompt).not.toContain("Authorization: Bearer");
|
|
21
|
-
expect(prompt).not.toContain("CHATCCC_SEND_IMAGE_URL");
|
|
22
|
-
expect(prompt).not.toContain("CHATCCC_SEND_IMAGE_TOKEN");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("builds prompt with cwd hint", () => {
|
|
26
|
-
const prompt = buildAgentImageCapabilityPrompt({
|
|
27
|
-
url: `http://127.0.0.1:18080${AGENT_SEND_IMAGE_PATH}`,
|
|
28
|
-
sessionId: "sid-1",
|
|
29
|
-
cwd: "F:/repo",
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
expect(prompt).toContain("Current working directory: F:/repo");
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { splitFeishuTargetChats } from "../agent-platform-routing.ts";
|
|
4
|
-
|
|
5
|
-
describe("agent platform routing", () => {
|
|
6
|
-
it("keeps Feishu-compatible chats and skips WeChat chats for Feishu RPC", () => {
|
|
7
|
-
const result = splitFeishuTargetChats(["fs-1", "wx-1", "unknown-1"], (chatId) => {
|
|
8
|
-
if (chatId.startsWith("wx")) return "wechat";
|
|
9
|
-
if (chatId.startsWith("fs")) return "feishu";
|
|
10
|
-
return undefined;
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
expect(result.targetChatIds).toEqual(["fs-1", "unknown-1"]);
|
|
14
|
-
expect(result.skippedUnsupported).toEqual([{ chatId: "wx-1", platformKind: "wechat" }]);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("reports no Feishu targets when every bound chat is WeChat", () => {
|
|
18
|
-
const result = splitFeishuTargetChats(["wx-1", "wx-2"], () => "wechat");
|
|
19
|
-
|
|
20
|
-
expect(result.targetChatIds).toEqual([]);
|
|
21
|
-
expect(result.skippedUnsupported).toEqual([
|
|
22
|
-
{ chatId: "wx-1", platformKind: "wechat" },
|
|
23
|
-
{ chatId: "wx-2", platformKind: "wechat" },
|
|
24
|
-
]);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Readable } from "node:stream";
|
|
2
|
-
import { describe, expect, it, vi } from "vitest";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
AGENT_RELOAD_CONFIG_PATH,
|
|
6
|
-
handleAgentReloadConfigRequest,
|
|
7
|
-
} from "../agent-reload-config-rpc.ts";
|
|
8
|
-
|
|
9
|
-
function request(path = AGENT_RELOAD_CONFIG_PATH, method = "POST"): Readable & {
|
|
10
|
-
url?: string;
|
|
11
|
-
method?: string;
|
|
12
|
-
headers: Record<string, string>;
|
|
13
|
-
} {
|
|
14
|
-
const req = Readable.from([]) as Readable & {
|
|
15
|
-
url?: string;
|
|
16
|
-
method?: string;
|
|
17
|
-
headers: Record<string, string>;
|
|
18
|
-
};
|
|
19
|
-
req.url = path;
|
|
20
|
-
req.method = method;
|
|
21
|
-
req.headers = {};
|
|
22
|
-
return req;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function response() {
|
|
26
|
-
const res = {
|
|
27
|
-
statusCode: 0,
|
|
28
|
-
headers: {} as Record<string, string>,
|
|
29
|
-
body: "",
|
|
30
|
-
writeHead(status: number, headers: Record<string, string>) {
|
|
31
|
-
this.statusCode = status;
|
|
32
|
-
this.headers = headers;
|
|
33
|
-
return this;
|
|
34
|
-
},
|
|
35
|
-
end(chunk?: string) {
|
|
36
|
-
this.body += chunk ?? "";
|
|
37
|
-
return this;
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
return res;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
describe("agent reload config RPC", () => {
|
|
44
|
-
it("reloads runtime config for POST requests", async () => {
|
|
45
|
-
const reload = vi.fn(async () => ({
|
|
46
|
-
configPath: "C:\\Users\\me\\.chatccc\\config.json",
|
|
47
|
-
defaultAgent: "codex" as const,
|
|
48
|
-
reloadedAt: "2026-07-02T05:00:00.000Z",
|
|
49
|
-
}));
|
|
50
|
-
const res = response();
|
|
51
|
-
|
|
52
|
-
await expect(handleAgentReloadConfigRequest(request() as never, res as never, reload)).resolves.toBe(true);
|
|
53
|
-
|
|
54
|
-
expect(reload).toHaveBeenCalledWith("agent-reload-api");
|
|
55
|
-
expect(res.statusCode).toBe(200);
|
|
56
|
-
expect(JSON.parse(res.body)).toEqual({
|
|
57
|
-
ok: true,
|
|
58
|
-
configPath: "C:\\Users\\me\\.chatccc\\config.json",
|
|
59
|
-
defaultAgent: "codex",
|
|
60
|
-
reloadedAt: "2026-07-02T05:00:00.000Z",
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("rejects non-POST requests without reloading", async () => {
|
|
65
|
-
const reload = vi.fn();
|
|
66
|
-
const res = response();
|
|
67
|
-
|
|
68
|
-
await expect(handleAgentReloadConfigRequest(request(AGENT_RELOAD_CONFIG_PATH, "GET") as never, res as never, reload)).resolves.toBe(true);
|
|
69
|
-
|
|
70
|
-
expect(reload).not.toHaveBeenCalled();
|
|
71
|
-
expect(res.statusCode).toBe(405);
|
|
72
|
-
expect(JSON.parse(res.body)).toMatchObject({ ok: false, error: "Method not allowed" });
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("does not handle other paths", async () => {
|
|
76
|
-
const res = response();
|
|
77
|
-
|
|
78
|
-
await expect(handleAgentReloadConfigRequest(request("/api/other") as never, res as never, vi.fn())).resolves.toBe(false);
|
|
79
|
-
|
|
80
|
-
expect(res.body).toBe("");
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("returns a visible error when reload fails", async () => {
|
|
84
|
-
const res = response();
|
|
85
|
-
|
|
86
|
-
await expect(
|
|
87
|
-
handleAgentReloadConfigRequest(
|
|
88
|
-
request() as never,
|
|
89
|
-
res as never,
|
|
90
|
-
vi.fn(async () => {
|
|
91
|
-
throw new Error("bad config");
|
|
92
|
-
}),
|
|
93
|
-
),
|
|
94
|
-
).resolves.toBe(true);
|
|
95
|
-
|
|
96
|
-
expect(res.statusCode).toBe(500);
|
|
97
|
-
expect(JSON.parse(res.body)).toEqual({ ok: false, error: "bad config" });
|
|
98
|
-
});
|
|
99
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage } from "node:http";
|
|
2
|
-
import { Readable } from "node:stream";
|
|
3
|
-
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
|
|
6
|
-
import { getRequestCharset, readUtf8JsonBody } from "../agent-rpc-body.ts";
|
|
7
|
-
|
|
8
|
-
function requestFrom(body: Buffer, contentType?: string): IncomingMessage {
|
|
9
|
-
const req = Readable.from([body]) as IncomingMessage;
|
|
10
|
-
req.headers = {};
|
|
11
|
-
if (contentType) req.headers["content-type"] = contentType;
|
|
12
|
-
return req;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
describe("agent RPC body parsing", () => {
|
|
16
|
-
it("defaults JSON requests to UTF-8 and preserves Unicode captions", async () => {
|
|
17
|
-
const caption = "\u4e2d\u6587 caption";
|
|
18
|
-
const body = Buffer.from(JSON.stringify({ caption }), "utf8");
|
|
19
|
-
const req = requestFrom(body, "application/json");
|
|
20
|
-
|
|
21
|
-
await expect(readUtf8JsonBody(req, 1024)).resolves.toEqual({ caption });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("reads charset from content-type", () => {
|
|
25
|
-
const req = requestFrom(Buffer.from("{}"), 'application/json; charset="utf-8"');
|
|
26
|
-
|
|
27
|
-
expect(getRequestCharset(req)).toBe("utf-8");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("rejects non UTF-8 charsets", async () => {
|
|
31
|
-
const req = requestFrom(Buffer.from("{}"), "application/json; charset=gbk");
|
|
32
|
-
|
|
33
|
-
await expect(readUtf8JsonBody(req, 1024)).rejects.toThrow("Unsupported charset");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("replaces invalid UTF-8 bytes instead of rejecting", async () => {
|
|
37
|
-
const req = requestFrom(Buffer.from([0xff, 0xfe]), "application/json; charset=utf-8");
|
|
38
|
-
|
|
39
|
-
// 无效 UTF-8 字节被替换为 U+FFFD,不再直接抛错
|
|
40
|
-
await expect(readUtf8JsonBody(req, 1024)).rejects.toThrow();
|
|
41
|
-
});
|
|
42
|
-
});
|