chatccc 0.2.103 → 0.2.107
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 +6 -3
- package/config.sample.json +1 -2
- package/package.json +63 -63
- package/src/__tests__/claude-adapter.test.ts +442 -912
- package/src/__tests__/config-reload.test.ts +6 -6
- package/src/__tests__/web-ui.test.ts +83 -195
- package/src/adapters/claude-adapter.ts +455 -372
- package/src/adapters/claude-session-meta-store.ts +120 -0
- package/src/cards.ts +0 -31
- package/src/config.ts +5 -17
- package/src/orchestrator.ts +0 -134
- package/src/session.ts +1 -1
- package/src/web-ui.ts +43 -285
|
@@ -48,8 +48,8 @@ const baseAppConfig: AppConfig = {
|
|
|
48
48
|
model: "initial-model",
|
|
49
49
|
subagentModel: "initial-subagent-model",
|
|
50
50
|
effort: "initial-effort",
|
|
51
|
-
apiKey: "
|
|
52
|
-
baseUrl: "
|
|
51
|
+
apiKey: "",
|
|
52
|
+
baseUrl: "",
|
|
53
53
|
},
|
|
54
54
|
cursor: { enabled: true, defaultAgent: false, path: "/initial/cursor", model: "initial-cursor-model" },
|
|
55
55
|
codex: { enabled: true, defaultAgent: false, path: "/initial/codex", model: "initial-codex-model", effort: "initial-codex-effort" },
|
|
@@ -89,16 +89,16 @@ describe("applyLoadedConfig — 刷新 export let 常量", () => {
|
|
|
89
89
|
model: "claude-sonnet-4-6",
|
|
90
90
|
subagentModel: "claude-haiku-4-5-20251001",
|
|
91
91
|
effort: "high",
|
|
92
|
-
apiKey: "sk-
|
|
93
|
-
baseUrl: "https://
|
|
92
|
+
apiKey: "sk-test",
|
|
93
|
+
baseUrl: "https://api.example.com",
|
|
94
94
|
},
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
expect(CLAUDE_MODEL).toBe("claude-sonnet-4-6");
|
|
98
98
|
expect(CLAUDE_SUBAGENT_MODEL).toBe("claude-haiku-4-5-20251001");
|
|
99
99
|
expect(CLAUDE_EFFORT).toBe("high");
|
|
100
|
-
expect(CLAUDE_API_KEY).toBe("sk-
|
|
101
|
-
expect(CLAUDE_BASE_URL).toBe("https://
|
|
100
|
+
expect(CLAUDE_API_KEY).toBe("sk-test");
|
|
101
|
+
expect(CLAUDE_BASE_URL).toBe("https://api.example.com");
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
it("更新 GIT_TIMEOUT_SECONDS 与 GIT_TIMEOUT_MS(毫秒派生值同步刷新)", () => {
|
|
@@ -1,195 +1,83 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("mode=thirdparty 时原样保留前端值", () => {
|
|
85
|
-
const out = applyClaudeApiMode(
|
|
86
|
-
{
|
|
87
|
-
CLAUDE_API_KEY: "sk-test",
|
|
88
|
-
CLAUDE_BASE_URL: "https://gw/anthropic",
|
|
89
|
-
},
|
|
90
|
-
"thirdparty",
|
|
91
|
-
);
|
|
92
|
-
expect(out).toEqual({
|
|
93
|
-
CLAUDE_API_KEY: "sk-test",
|
|
94
|
-
CLAUDE_BASE_URL: "https://gw/anthropic",
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("mode=thirdparty 时保留前端主动提交的 ''(允许局部清空)", () => {
|
|
99
|
-
const out = applyClaudeApiMode(
|
|
100
|
-
{ CLAUDE_API_KEY: "", CLAUDE_BASE_URL: "https://gw/anthropic" },
|
|
101
|
-
"thirdparty",
|
|
102
|
-
);
|
|
103
|
-
expect(out.CLAUDE_API_KEY).toBe("");
|
|
104
|
-
expect(out.CLAUDE_BASE_URL).toBe("https://gw/anthropic");
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("mode 未传(undefined) → 按 official 兌底清空", () => {
|
|
108
|
-
const out = applyClaudeApiMode(
|
|
109
|
-
{ CLAUDE_API_KEY: "sk-x" },
|
|
110
|
-
undefined,
|
|
111
|
-
);
|
|
112
|
-
expect(out.CLAUDE_API_KEY).toBe("");
|
|
113
|
-
expect(out.CLAUDE_BASE_URL).toBe("");
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("mode 是未知字符串 → 按 official 兌底清空", () => {
|
|
117
|
-
const out = applyClaudeApiMode(
|
|
118
|
-
{ CLAUDE_API_KEY: "sk-x" },
|
|
119
|
-
"garbage-mode",
|
|
120
|
-
);
|
|
121
|
-
expect(out.CLAUDE_API_KEY).toBe("");
|
|
122
|
-
expect(out.CLAUDE_BASE_URL).toBe("");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("不修改入参对象(返回新对象)", () => {
|
|
126
|
-
const input = { CLAUDE_API_KEY: "sk-x" };
|
|
127
|
-
const out = applyClaudeApiMode(input, "official");
|
|
128
|
-
expect(input).toEqual({ CLAUDE_API_KEY: "sk-x" }); // 原对象未变
|
|
129
|
-
expect(out).not.toBe(input);
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe("unflattenConfig", () => {
|
|
134
|
-
it("maps Claude subagent model into claude.subagentModel", () => {
|
|
135
|
-
expect(
|
|
136
|
-
unflattenConfig({
|
|
137
|
-
CHATCCC_ANTHROPIC_MODEL: "claude-sonnet-4-6",
|
|
138
|
-
CHATCCC_ANTHROPIC_SUBAGENT_MODEL: "claude-haiku-4-5-20251001",
|
|
139
|
-
}),
|
|
140
|
-
).toEqual({
|
|
141
|
-
claude: {
|
|
142
|
-
model: "claude-sonnet-4-6",
|
|
143
|
-
subagentModel: "claude-haiku-4-5-20251001",
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// ---------------------------------------------------------------------------
|
|
150
|
-
// chooseStartPath — /api/start 的路径选择
|
|
151
|
-
// 关键护栏:
|
|
152
|
-
// - setup 模式(hasInplaceActivateHook=true)下 isServiceRunning 永远为 true
|
|
153
|
-
// (setup 进程自己占着 PID 文件),必须无条件走 inplace;否则用户点
|
|
154
|
-
// "保存并启动"将永远拿到 "Service is already running"。
|
|
155
|
-
// - dashboard 模式 + service 已运行(通常就是当前进程自己)→ "reload":
|
|
156
|
-
// 用户点"保存并启动"想让新 config 生效,但服务正在跑——不真重启,仅
|
|
157
|
-
// 调用 reloadConfigFromDisk() 刷新进程内 export let 常量。绝不能再
|
|
158
|
-
// 返回"already running"挡用户路。
|
|
159
|
-
// - dashboard 模式 + service 未运行 → spawn 一个新的(旧 service 退出后场景)。
|
|
160
|
-
// ---------------------------------------------------------------------------
|
|
161
|
-
|
|
162
|
-
describe("chooseStartPath", () => {
|
|
163
|
-
it("setup 模式(注入 inplace hook)→ inplace(不管 PID 文件状态)", () => {
|
|
164
|
-
expect(
|
|
165
|
-
chooseStartPath({
|
|
166
|
-
hasInplaceActivateHook: true,
|
|
167
|
-
isServiceRunning: true,
|
|
168
|
-
}),
|
|
169
|
-
).toBe("inplace");
|
|
170
|
-
expect(
|
|
171
|
-
chooseStartPath({
|
|
172
|
-
hasInplaceActivateHook: true,
|
|
173
|
-
isServiceRunning: false,
|
|
174
|
-
}),
|
|
175
|
-
).toBe("inplace");
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it("dashboard 模式 + service 已运行 → reload(仅刷新 config,不真重启)", () => {
|
|
179
|
-
expect(
|
|
180
|
-
chooseStartPath({
|
|
181
|
-
hasInplaceActivateHook: false,
|
|
182
|
-
isServiceRunning: true,
|
|
183
|
-
}),
|
|
184
|
-
).toBe("reload");
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("dashboard 模式 + service 未运行 → spawn", () => {
|
|
188
|
-
expect(
|
|
189
|
-
chooseStartPath({
|
|
190
|
-
hasInplaceActivateHook: false,
|
|
191
|
-
isServiceRunning: false,
|
|
192
|
-
}),
|
|
193
|
-
).toBe("spawn");
|
|
194
|
-
});
|
|
195
|
-
});
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
chooseStartPath,
|
|
4
|
+
unflattenConfig,
|
|
5
|
+
} from "../web-ui.ts";
|
|
6
|
+
|
|
7
|
+
describe("unflattenConfig", () => {
|
|
8
|
+
it("maps Claude subagent model into claude.subagentModel", () => {
|
|
9
|
+
expect(
|
|
10
|
+
unflattenConfig({
|
|
11
|
+
CHATCCC_ANTHROPIC_MODEL: "claude-sonnet-4-6",
|
|
12
|
+
CHATCCC_ANTHROPIC_SUBAGENT_MODEL: "claude-haiku-4-5-20251001",
|
|
13
|
+
}),
|
|
14
|
+
).toEqual({
|
|
15
|
+
claude: {
|
|
16
|
+
model: "claude-sonnet-4-6",
|
|
17
|
+
subagentModel: "claude-haiku-4-5-20251001",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("maps Claude apiKey and baseUrl into claude config", () => {
|
|
23
|
+
expect(
|
|
24
|
+
unflattenConfig({
|
|
25
|
+
CHATCCC_ANTHROPIC_API_KEY: "sk-test-key",
|
|
26
|
+
CHATCCC_ANTHROPIC_BASE_URL: "https://api.example.com",
|
|
27
|
+
}),
|
|
28
|
+
).toEqual({
|
|
29
|
+
claude: {
|
|
30
|
+
apiKey: "sk-test-key",
|
|
31
|
+
baseUrl: "https://api.example.com",
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// chooseStartPath — /api/start 的路径选择
|
|
39
|
+
// 关键护栏:
|
|
40
|
+
// - setup 模式(hasInplaceActivateHook=true)下 isServiceRunning 永远为 true
|
|
41
|
+
// (setup 进程自己占着 PID 文件),必须无条件走 inplace;否则用户点
|
|
42
|
+
// "保存并启动"将永远拿到 "Service is already running"。
|
|
43
|
+
// - dashboard 模式 + service 已运行(通常就是当前进程自己)→ "reload":
|
|
44
|
+
// 用户点"保存并启动"想让新 config 生效,但服务正在跑——不真重启,仅
|
|
45
|
+
// 调用 reloadConfigFromDisk() 刷新进程内 export let 常量。绝不能再
|
|
46
|
+
// 返回"already running"挡用户路。
|
|
47
|
+
// - dashboard 模式 + service 未运行 → spawn 一个新的(旧 service 退出后场景)。
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
describe("chooseStartPath", () => {
|
|
51
|
+
it("setup 模式(注入 inplace hook)→ inplace(不管 PID 文件状态)", () => {
|
|
52
|
+
expect(
|
|
53
|
+
chooseStartPath({
|
|
54
|
+
hasInplaceActivateHook: true,
|
|
55
|
+
isServiceRunning: true,
|
|
56
|
+
}),
|
|
57
|
+
).toBe("inplace");
|
|
58
|
+
expect(
|
|
59
|
+
chooseStartPath({
|
|
60
|
+
hasInplaceActivateHook: true,
|
|
61
|
+
isServiceRunning: false,
|
|
62
|
+
}),
|
|
63
|
+
).toBe("inplace");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("dashboard 模式 + service 已运行 → reload(仅刷新 config,不真重启)", () => {
|
|
67
|
+
expect(
|
|
68
|
+
chooseStartPath({
|
|
69
|
+
hasInplaceActivateHook: false,
|
|
70
|
+
isServiceRunning: true,
|
|
71
|
+
}),
|
|
72
|
+
).toBe("reload");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("dashboard 模式 + service 未运行 → spawn", () => {
|
|
76
|
+
expect(
|
|
77
|
+
chooseStartPath({
|
|
78
|
+
hasInplaceActivateHook: false,
|
|
79
|
+
isServiceRunning: false,
|
|
80
|
+
}),
|
|
81
|
+
).toBe("spawn");
|
|
82
|
+
});
|
|
83
|
+
});
|