chatccc 0.2.196 → 0.2.197
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/agent-prompts/cursor_specific.md +13 -13
- package/bin/cccagent.mjs +17 -17
- package/config.sample.json +27 -27
- package/package.json +1 -1
- package/src/__tests__/agent-reload-config-rpc.test.ts +99 -0
- package/src/__tests__/builtin-chat-session.test.ts +277 -181
- 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 -196
- package/src/__tests__/builtin-session-select.test.ts +116 -116
- package/src/__tests__/builtin-sigint.test.ts +56 -56
- package/src/__tests__/cards.test.ts +109 -109
- package/src/__tests__/ccc-adapter.test.ts +114 -113
- 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-raw-stream-log.test.ts +87 -0
- package/src/__tests__/codex-raw-stream-log.test.ts +120 -0
- 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 +113 -113
- package/src/__tests__/feishu-avatar.test.ts +40 -40
- package/src/__tests__/orchestrator.test.ts +181 -154
- package/src/__tests__/raw-stream-log.test.ts +106 -106
- package/src/__tests__/session.test.ts +40 -40
- package/src/__tests__/sim-platform.test.ts +12 -12
- package/src/__tests__/web-ui.test.ts +209 -209
- package/src/adapters/ccc-adapter.ts +121 -119
- package/src/adapters/claude-adapter.ts +603 -566
- package/src/adapters/codex-adapter.ts +57 -32
- package/src/adapters/cursor-adapter.ts +264 -264
- package/src/adapters/raw-stream-log.ts +124 -124
- package/src/agent-reload-config-rpc.ts +34 -0
- package/src/builtin/cli.ts +473 -461
- package/src/builtin/context.ts +323 -323
- package/src/builtin/file-tools.ts +1072 -915
- package/src/builtin/index.ts +404 -353
- package/src/builtin/session-select.ts +48 -48
- package/src/builtin/sigint.ts +50 -50
- package/src/cards.ts +195 -195
- 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/config.ts +125 -125
- package/src/feishu-api.ts +49 -49
- package/src/index.ts +8 -13
- package/src/orchestrator.ts +166 -145
- package/src/runtime-reload.ts +34 -0
- package/src/session.ts +141 -141
- package/src/web-ui.ts +205 -205
|
@@ -1,566 +1,603 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { delimiter, dirname, join } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
getSessionInfo as sdkGetSessionInfo,
|
|
8
|
-
unstable_v2_createSession,
|
|
9
|
-
unstable_v2_resumeSession,
|
|
10
|
-
type SDKMessage,
|
|
11
|
-
type SDKSession,
|
|
12
|
-
type SDKSessionOptions,
|
|
13
|
-
type EffortLevel,
|
|
14
|
-
} from "@anthropic-ai/claude-agent-sdk";
|
|
15
|
-
|
|
16
|
-
import type {
|
|
17
|
-
CreateSessionResult,
|
|
18
|
-
SessionInfo,
|
|
19
|
-
ToolAdapter,
|
|
20
|
-
ToolPromptOptions,
|
|
21
|
-
UnifiedBlock,
|
|
22
|
-
UnifiedStreamMessage,
|
|
23
|
-
} from "./adapter-interface.ts";
|
|
24
|
-
import { parseUserCommand } from "./adapter-interface.ts";
|
|
25
|
-
import { CHATCCC_PORT } from "../config.ts";
|
|
26
|
-
import {
|
|
27
|
-
defaultClaudeSessionMetaStore,
|
|
28
|
-
type ClaudeSessionMetaStore,
|
|
29
|
-
} from "./claude-session-meta-store.ts";
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
delete env.
|
|
101
|
-
delete env.
|
|
102
|
-
delete env.
|
|
103
|
-
delete env.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
if (!
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (!
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return null;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
if (!
|
|
361
|
-
options.
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
return
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
return
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
);
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { delimiter, dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
getSessionInfo as sdkGetSessionInfo,
|
|
8
|
+
unstable_v2_createSession,
|
|
9
|
+
unstable_v2_resumeSession,
|
|
10
|
+
type SDKMessage,
|
|
11
|
+
type SDKSession,
|
|
12
|
+
type SDKSessionOptions,
|
|
13
|
+
type EffortLevel,
|
|
14
|
+
} from "@anthropic-ai/claude-agent-sdk";
|
|
15
|
+
|
|
16
|
+
import type {
|
|
17
|
+
CreateSessionResult,
|
|
18
|
+
SessionInfo,
|
|
19
|
+
ToolAdapter,
|
|
20
|
+
ToolPromptOptions,
|
|
21
|
+
UnifiedBlock,
|
|
22
|
+
UnifiedStreamMessage,
|
|
23
|
+
} from "./adapter-interface.ts";
|
|
24
|
+
import { parseUserCommand } from "./adapter-interface.ts";
|
|
25
|
+
import { CHATCCC_PORT, config, RAW_STREAM_LOGS_DIR } from "../config.ts";
|
|
26
|
+
import {
|
|
27
|
+
defaultClaudeSessionMetaStore,
|
|
28
|
+
type ClaudeSessionMetaStore,
|
|
29
|
+
} from "./claude-session-meta-store.ts";
|
|
30
|
+
import {
|
|
31
|
+
createRawStreamLog,
|
|
32
|
+
type RawStreamLogHandle,
|
|
33
|
+
} from "./raw-stream-log.ts";
|
|
34
|
+
|
|
35
|
+
const PROJECT_ROOT = dirname(dirname(dirname(fileURLToPath(import.meta.url))));
|
|
36
|
+
const CLAUDE_SPECIFIC_PROMPT_PATH = join(
|
|
37
|
+
PROJECT_ROOT,
|
|
38
|
+
"agent-prompts",
|
|
39
|
+
"claude_specific.md",
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
type SettingSource = "user" | "project" | "local";
|
|
43
|
+
|
|
44
|
+
interface SdkContentBlock {
|
|
45
|
+
type: string;
|
|
46
|
+
text?: string;
|
|
47
|
+
thinking?: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
input?: unknown;
|
|
50
|
+
tool_use_id?: string;
|
|
51
|
+
content?: unknown;
|
|
52
|
+
is_error?: boolean;
|
|
53
|
+
query?: string;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface SdkMessageLike {
|
|
58
|
+
type?: string;
|
|
59
|
+
subtype?: string;
|
|
60
|
+
message?: { content?: SdkContentBlock[] };
|
|
61
|
+
compact_metadata?: {
|
|
62
|
+
trigger?: "manual" | "auto";
|
|
63
|
+
pre_tokens?: number;
|
|
64
|
+
post_tokens?: number;
|
|
65
|
+
};
|
|
66
|
+
session_id?: string;
|
|
67
|
+
model?: string;
|
|
68
|
+
cwd?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ClaudeAdapterOptions {
|
|
72
|
+
model: string;
|
|
73
|
+
subagentModel?: string;
|
|
74
|
+
effort: string;
|
|
75
|
+
apiKey?: string;
|
|
76
|
+
baseUrl?: string;
|
|
77
|
+
isEmpty: (value: string) => boolean;
|
|
78
|
+
metaStore?: ClaudeSessionMetaStore;
|
|
79
|
+
maxTurn?: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function buildSdkEnv(
|
|
83
|
+
subagentModel: string | undefined,
|
|
84
|
+
apiKey: string | undefined,
|
|
85
|
+
baseUrl: string | undefined,
|
|
86
|
+
): Record<string, string | undefined> | undefined {
|
|
87
|
+
const subagentModelTrim = (subagentModel ?? "").trim();
|
|
88
|
+
const apiKeyTrim = (apiKey ?? "").trim();
|
|
89
|
+
const baseUrlTrim = (baseUrl ?? "").trim();
|
|
90
|
+
|
|
91
|
+
const env: Record<string, string | undefined> = { ...process.env };
|
|
92
|
+
let mutated = preferGitBashOnWindows(env);
|
|
93
|
+
|
|
94
|
+
// Claude Code 2.1.136+ 会在每次请求中注入 x-anthropic-billing-header,
|
|
95
|
+
// 导致 prompt 前缀变化、缓存命中率急剧下降。设为 0 关闭。
|
|
96
|
+
env.CLAUDE_CODE_ATTRIBUTION_HEADER = "0";
|
|
97
|
+
mutated = true;
|
|
98
|
+
|
|
99
|
+
if (subagentModelTrim || apiKeyTrim || baseUrlTrim) {
|
|
100
|
+
delete env.ANTHROPIC_AUTH_TOKEN;
|
|
101
|
+
delete env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
102
|
+
delete env.ANTHROPIC_MODEL;
|
|
103
|
+
delete env.ANTHROPIC_DEFAULT_OPUS_MODEL;
|
|
104
|
+
delete env.ANTHROPIC_DEFAULT_SONNET_MODEL;
|
|
105
|
+
delete env.ANTHROPIC_DEFAULT_HAIKU_MODEL;
|
|
106
|
+
delete env.CLAUDE_CODE_EFFORT_LEVEL;
|
|
107
|
+
delete env.CLAUDE_CODE_SUBAGENT_MODEL;
|
|
108
|
+
mutated = true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (subagentModelTrim) env.CLAUDE_CODE_SUBAGENT_MODEL = subagentModelTrim;
|
|
112
|
+
if (apiKeyTrim) env.ANTHROPIC_API_KEY = apiKeyTrim;
|
|
113
|
+
if (baseUrlTrim) env.ANTHROPIC_BASE_URL = baseUrlTrim;
|
|
114
|
+
|
|
115
|
+
return mutated ? env : undefined;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function preferGitBashOnWindows(env: Record<string, string | undefined>): boolean {
|
|
119
|
+
if (process.platform !== "win32") return false;
|
|
120
|
+
|
|
121
|
+
const pathKey = Object.keys(env).find((key) => key.toLowerCase() === "path") ?? "PATH";
|
|
122
|
+
const rawPath = env[pathKey];
|
|
123
|
+
if (!rawPath) return false;
|
|
124
|
+
|
|
125
|
+
const parts = rawPath.split(delimiter).filter((part) => part && part !== "%PATH%");
|
|
126
|
+
const preferred = findPreferredGitBashPath(parts);
|
|
127
|
+
if (!preferred) {
|
|
128
|
+
const nextPath = parts.join(delimiter);
|
|
129
|
+
if (nextPath !== rawPath) {
|
|
130
|
+
env[pathKey] = nextPath;
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const preferredLower = preferred.toLowerCase();
|
|
137
|
+
const reordered = [
|
|
138
|
+
preferred,
|
|
139
|
+
...parts.filter((part) => part.toLowerCase() !== preferredLower),
|
|
140
|
+
];
|
|
141
|
+
const nextPath = reordered.join(delimiter);
|
|
142
|
+
if (nextPath === rawPath) return false;
|
|
143
|
+
env[pathKey] = nextPath;
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function findPreferredGitBashPath(pathParts: string[]): string | undefined {
|
|
148
|
+
const programFilesGit = join(
|
|
149
|
+
process.env.ProgramFiles ?? "C:\\Program Files",
|
|
150
|
+
"Git",
|
|
151
|
+
"usr",
|
|
152
|
+
"bin",
|
|
153
|
+
);
|
|
154
|
+
if (existsSync(join(programFilesGit, "bash.exe"))) return programFilesGit;
|
|
155
|
+
|
|
156
|
+
return pathParts.find((part) => {
|
|
157
|
+
if (!/(\\|\/)(Git)(\\|\/)usr(\\|\/)bin$/i.test(part) &&
|
|
158
|
+
!/(\\|\/)Fork(\\|\/)gitInstance(\\|\/)[^\\/]+(\\|\/)bin$/i.test(part)) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return existsSync(join(part, "bash.exe"));
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function readMcpServersConfig(): Record<string, unknown> | undefined {
|
|
166
|
+
const settingsPath = join(homedir(), ".claude", "settings.json");
|
|
167
|
+
try {
|
|
168
|
+
if (!existsSync(settingsPath)) return undefined;
|
|
169
|
+
const raw = readFileSync(settingsPath, "utf-8");
|
|
170
|
+
const settings = JSON.parse(raw) as { mcpServers?: Record<string, unknown> };
|
|
171
|
+
const mcpServers = settings.mcpServers;
|
|
172
|
+
if (!mcpServers || Object.keys(mcpServers).length === 0) return undefined;
|
|
173
|
+
return mcpServers;
|
|
174
|
+
} catch {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function logMcpConfig(): void {
|
|
180
|
+
const settingsPath = join(homedir(), ".claude", "settings.json");
|
|
181
|
+
const ts = new Date().toISOString();
|
|
182
|
+
try {
|
|
183
|
+
if (!existsSync(settingsPath)) {
|
|
184
|
+
console.log(`[${ts}] [MCP-DIAG] settings.json not found at ${settingsPath}`);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const raw = readFileSync(settingsPath, "utf-8");
|
|
188
|
+
const settings = JSON.parse(raw) as { mcpServers?: Record<string, unknown> };
|
|
189
|
+
const mcpServers = settings.mcpServers;
|
|
190
|
+
if (!mcpServers || Object.keys(mcpServers).length === 0) {
|
|
191
|
+
console.log(`[${ts}] [MCP-DIAG] No mcpServers configured in settings.json`);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
console.log(`[${ts}] [MCP-DIAG] mcpServers found: ${JSON.stringify(Object.keys(mcpServers))}`);
|
|
195
|
+
for (const [name, cfg] of Object.entries(mcpServers)) {
|
|
196
|
+
const item = cfg as { type?: string; command?: string; args?: string[] };
|
|
197
|
+
console.log(`[${ts}] [MCP-DIAG] ${name}: type=${item.type}, command=${item.command}, args=${JSON.stringify(item.args)}`);
|
|
198
|
+
}
|
|
199
|
+
} catch (err) {
|
|
200
|
+
console.log(`[${ts}] [MCP-DIAG] Failed to read settings.json: ${(err as Error).message}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function normalizeSdkMessage(msg: SdkMessageLike): UnifiedStreamMessage | null {
|
|
205
|
+
if (
|
|
206
|
+
(msg.type === "assistant" || msg.type === "user") &&
|
|
207
|
+
msg.message?.content
|
|
208
|
+
) {
|
|
209
|
+
const blocks: UnifiedBlock[] = [];
|
|
210
|
+
for (const block of msg.message.content) {
|
|
211
|
+
if (block.type === "thinking" && block.thinking) {
|
|
212
|
+
blocks.push({ type: "thinking", thinking: block.thinking });
|
|
213
|
+
} else if (block.type === "tool_use") {
|
|
214
|
+
blocks.push({
|
|
215
|
+
type: "tool_use",
|
|
216
|
+
id: (block as { id?: string }).id,
|
|
217
|
+
name: block.name ?? "unknown",
|
|
218
|
+
input: block.input,
|
|
219
|
+
});
|
|
220
|
+
} else if (block.type === "tool_result") {
|
|
221
|
+
blocks.push({
|
|
222
|
+
type: "tool_result",
|
|
223
|
+
tool_use_id: block.tool_use_id ?? "",
|
|
224
|
+
content: block.content,
|
|
225
|
+
is_error: block.is_error,
|
|
226
|
+
});
|
|
227
|
+
} else if (block.type === "redacted_thinking") {
|
|
228
|
+
blocks.push({ type: "redacted_thinking" });
|
|
229
|
+
} else if (block.type === "search_result") {
|
|
230
|
+
blocks.push({
|
|
231
|
+
type: "search_result",
|
|
232
|
+
query: block.query ?? "",
|
|
233
|
+
});
|
|
234
|
+
} else if (block.type === "text" && block.text) {
|
|
235
|
+
if (msg.type === "user") continue;
|
|
236
|
+
blocks.push({ type: "text", text: block.text });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return { type: msg.type, blocks };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (msg.type === "system" && msg.subtype === "compact_boundary") {
|
|
243
|
+
const meta = msg.compact_metadata;
|
|
244
|
+
if (!meta) return null;
|
|
245
|
+
return {
|
|
246
|
+
type: "system",
|
|
247
|
+
blocks: [
|
|
248
|
+
{
|
|
249
|
+
type: "compact_boundary",
|
|
250
|
+
trigger: meta.trigger ?? "auto",
|
|
251
|
+
pre_tokens: meta.pre_tokens ?? 0,
|
|
252
|
+
post_tokens: meta.post_tokens,
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export function readClaudeSpecificInjectionPrompt(): string | null {
|
|
262
|
+
try {
|
|
263
|
+
if (!existsSync(CLAUDE_SPECIFIC_PROMPT_PATH)) return null;
|
|
264
|
+
const prompt = readFileSync(CLAUDE_SPECIFIC_PROMPT_PATH, "utf-8").trim();
|
|
265
|
+
return prompt.length > 0 ? prompt : null;
|
|
266
|
+
} catch {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function buildClaudePromptText(
|
|
272
|
+
userText: string,
|
|
273
|
+
injectionPrompt: string | null = readClaudeSpecificInjectionPrompt(),
|
|
274
|
+
sessionId?: string,
|
|
275
|
+
): string {
|
|
276
|
+
let prompt = injectionPrompt?.trim();
|
|
277
|
+
if (!prompt) return userText;
|
|
278
|
+
|
|
279
|
+
// 动态替换注入提示词中的占位符(端口、session_id 等)
|
|
280
|
+
if (sessionId) {
|
|
281
|
+
prompt = prompt
|
|
282
|
+
.replace(/\{\{stop_stuck_url\}\}/g, `http://127.0.0.1:${CHATCCC_PORT}/api/agent/stop-stuck-loop`)
|
|
283
|
+
.replace(/\{\{session_id\}\}/g, sessionId);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return [
|
|
287
|
+
"[ChatCCC Claude-specific injection prompt]",
|
|
288
|
+
prompt,
|
|
289
|
+
"[/ChatCCC Claude-specific injection prompt]",
|
|
290
|
+
"",
|
|
291
|
+
userText,
|
|
292
|
+
].join("\n");
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
type ClaudeSdkSessionOptions = Omit<SDKSessionOptions, "model"> & {
|
|
296
|
+
model?: string;
|
|
297
|
+
abortController?: AbortController;
|
|
298
|
+
autoCompactEnabled?: boolean;
|
|
299
|
+
effort?: EffortLevel | number;
|
|
300
|
+
maxTurns?: number;
|
|
301
|
+
mcpServers?: Record<string, unknown>;
|
|
302
|
+
skills?: "all";
|
|
303
|
+
stderr?: (data: string) => void;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
function buildSdkOptions(args: {
|
|
307
|
+
cwd: string;
|
|
308
|
+
model: string;
|
|
309
|
+
effort: string;
|
|
310
|
+
isEmpty: (value: string) => boolean;
|
|
311
|
+
subagentModel?: string;
|
|
312
|
+
apiKey?: string;
|
|
313
|
+
baseUrl?: string;
|
|
314
|
+
maxTurn: number;
|
|
315
|
+
abortController?: AbortController;
|
|
316
|
+
userText: string;
|
|
317
|
+
}): ClaudeSdkSessionOptions {
|
|
318
|
+
const {
|
|
319
|
+
cwd,
|
|
320
|
+
model,
|
|
321
|
+
effort,
|
|
322
|
+
isEmpty,
|
|
323
|
+
subagentModel,
|
|
324
|
+
apiKey,
|
|
325
|
+
baseUrl,
|
|
326
|
+
maxTurn,
|
|
327
|
+
abortController,
|
|
328
|
+
userText,
|
|
329
|
+
} = args;
|
|
330
|
+
|
|
331
|
+
const cmd = parseUserCommand(userText);
|
|
332
|
+
const limited = cmd.mode !== null;
|
|
333
|
+
|
|
334
|
+
const options: ClaudeSdkSessionOptions = {
|
|
335
|
+
cwd,
|
|
336
|
+
abortController,
|
|
337
|
+
settingSources: ["user", "project", "local"] as SettingSource[],
|
|
338
|
+
permissionMode: limited ? "default" : "bypassPermissions",
|
|
339
|
+
autoCompactEnabled: true,
|
|
340
|
+
maxTurns: maxTurn,
|
|
341
|
+
skills: "all",
|
|
342
|
+
...(limited ? {
|
|
343
|
+
settings: {
|
|
344
|
+
permissions: {
|
|
345
|
+
allow: [
|
|
346
|
+
"Read",
|
|
347
|
+
`Bash(curl -s -X POST http://127.0.0.1:${CHATCCC_PORT}/api/agent/stop-stuck-loop *)`,
|
|
348
|
+
],
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
} : {}),
|
|
352
|
+
stderr: (data) => {
|
|
353
|
+
const trimmed = data.trim();
|
|
354
|
+
if (!trimmed) return;
|
|
355
|
+
const ts = new Date().toISOString();
|
|
356
|
+
console.log(`[${ts}] [CLAUDE-STDERR] ${trimmed.slice(0, 2000)}`);
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
if (!limited) {
|
|
361
|
+
options.allowDangerouslySkipPermissions = true;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (!isEmpty(model)) {
|
|
365
|
+
options.model = model;
|
|
366
|
+
}
|
|
367
|
+
if (!isEmpty(effort)) {
|
|
368
|
+
options.effort = effort as ClaudeSdkSessionOptions["effort"];
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const env = buildSdkEnv(subagentModel, apiKey, baseUrl);
|
|
372
|
+
if (env) {
|
|
373
|
+
options.env = env;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const mcpServers = readMcpServersConfig();
|
|
377
|
+
if (mcpServers) {
|
|
378
|
+
options.mcpServers = mcpServers;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return options;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function toMessageLike(message: SDKMessage): SdkMessageLike {
|
|
385
|
+
return message as unknown as SdkMessageLike;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function safeRawStreamJson(value: unknown): string {
|
|
389
|
+
try {
|
|
390
|
+
return JSON.stringify(value) ?? "null";
|
|
391
|
+
} catch (err) {
|
|
392
|
+
return JSON.stringify({
|
|
393
|
+
type: "chatccc_raw_stream_log_serialize_error",
|
|
394
|
+
error: err instanceof Error ? err.message : String(err),
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function bridgeAbortSignal(
|
|
400
|
+
signal: AbortSignal | undefined,
|
|
401
|
+
controller: AbortController,
|
|
402
|
+
): (() => void) | undefined {
|
|
403
|
+
if (!signal) return undefined;
|
|
404
|
+
const onAbort = () => controller.abort();
|
|
405
|
+
if (signal.aborted) {
|
|
406
|
+
controller.abort();
|
|
407
|
+
return undefined;
|
|
408
|
+
}
|
|
409
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
410
|
+
return () => signal.removeEventListener("abort", onAbort);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function closeSdkSession(session: SDKSession): void {
|
|
414
|
+
session.close();
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function toSdkSessionOptions(options: ClaudeSdkSessionOptions): SDKSessionOptions {
|
|
418
|
+
return options as SDKSessionOptions;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
class ClaudeAdapter implements ToolAdapter {
|
|
422
|
+
readonly displayName = "Claude Code";
|
|
423
|
+
readonly sessionDescPrefix = "Claude Code Session:";
|
|
424
|
+
private model: string;
|
|
425
|
+
private effort: string;
|
|
426
|
+
private subagentModel: string | undefined;
|
|
427
|
+
private apiKey: string | undefined;
|
|
428
|
+
private baseUrl: string | undefined;
|
|
429
|
+
private isEmpty: (value: string) => boolean;
|
|
430
|
+
private metaStore: ClaudeSessionMetaStore;
|
|
431
|
+
private maxTurn: number;
|
|
432
|
+
|
|
433
|
+
constructor(options: ClaudeAdapterOptions) {
|
|
434
|
+
this.model = options.model;
|
|
435
|
+
this.effort = options.effort;
|
|
436
|
+
this.subagentModel = options.subagentModel;
|
|
437
|
+
this.apiKey = options.apiKey;
|
|
438
|
+
this.baseUrl = options.baseUrl;
|
|
439
|
+
this.isEmpty = options.isEmpty;
|
|
440
|
+
this.metaStore = options.metaStore ?? defaultClaudeSessionMetaStore;
|
|
441
|
+
this.maxTurn = options.maxTurn ?? 0;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async createSession(cwd: string): Promise<CreateSessionResult> {
|
|
445
|
+
logMcpConfig();
|
|
446
|
+
const abortController = new AbortController();
|
|
447
|
+
let sessionId: string | undefined;
|
|
448
|
+
const session = unstable_v2_createSession(
|
|
449
|
+
toSdkSessionOptions(buildSdkOptions({
|
|
450
|
+
cwd,
|
|
451
|
+
model: this.model,
|
|
452
|
+
effort: this.effort,
|
|
453
|
+
isEmpty: this.isEmpty,
|
|
454
|
+
subagentModel: this.subagentModel,
|
|
455
|
+
apiKey: this.apiKey,
|
|
456
|
+
baseUrl: this.baseUrl,
|
|
457
|
+
maxTurn: this.maxTurn,
|
|
458
|
+
abortController,
|
|
459
|
+
userText: "",
|
|
460
|
+
})),
|
|
461
|
+
);
|
|
462
|
+
|
|
463
|
+
try {
|
|
464
|
+
await session.send("ok");
|
|
465
|
+
for await (const raw of session.stream()) {
|
|
466
|
+
const msg = toMessageLike(raw);
|
|
467
|
+
if (msg.session_id && !sessionId) {
|
|
468
|
+
sessionId = msg.session_id;
|
|
469
|
+
await this.metaStore.set(sessionId, {
|
|
470
|
+
cwd: msg.cwd ?? cwd,
|
|
471
|
+
model: msg.model,
|
|
472
|
+
}).catch(() => {});
|
|
473
|
+
const ts = new Date().toISOString();
|
|
474
|
+
console.log(`[${ts}] [CLAUDE-SDK] createSession: ${sessionId}`);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
} finally {
|
|
478
|
+
closeSdkSession(session);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (sessionId) return { sessionId };
|
|
482
|
+
throw new Error("No session ID in Claude init event");
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
async *prompt(
|
|
486
|
+
sessionId: string,
|
|
487
|
+
userText: string,
|
|
488
|
+
cwd: string,
|
|
489
|
+
signal?: AbortSignal,
|
|
490
|
+
options?: ToolPromptOptions,
|
|
491
|
+
): AsyncIterable<UnifiedStreamMessage> {
|
|
492
|
+
const abortController = new AbortController();
|
|
493
|
+
const removeAbortListener = bridgeAbortSignal(signal, abortController);
|
|
494
|
+
if (abortController.signal.aborted) return;
|
|
495
|
+
let aborted = false;
|
|
496
|
+
let completed = false;
|
|
497
|
+
const rawLogConfig = config.rawStreamLogs.claude;
|
|
498
|
+
let rawLog: RawStreamLogHandle | null = null;
|
|
499
|
+
|
|
500
|
+
const session = unstable_v2_resumeSession(
|
|
501
|
+
sessionId,
|
|
502
|
+
toSdkSessionOptions(buildSdkOptions({
|
|
503
|
+
cwd,
|
|
504
|
+
model: this.model,
|
|
505
|
+
effort: this.effort,
|
|
506
|
+
isEmpty: this.isEmpty,
|
|
507
|
+
subagentModel: this.subagentModel,
|
|
508
|
+
apiKey: this.apiKey,
|
|
509
|
+
baseUrl: this.baseUrl,
|
|
510
|
+
maxTurn: this.maxTurn,
|
|
511
|
+
abortController,
|
|
512
|
+
userText,
|
|
513
|
+
})),
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
options?.onSessionCreated?.(() => session.close());
|
|
517
|
+
|
|
518
|
+
try {
|
|
519
|
+
try {
|
|
520
|
+
rawLog = await createRawStreamLog({
|
|
521
|
+
enabled: rawLogConfig.enabled,
|
|
522
|
+
rootDir: RAW_STREAM_LOGS_DIR,
|
|
523
|
+
tool: "claude",
|
|
524
|
+
sessionId,
|
|
525
|
+
label: "prompt",
|
|
526
|
+
maxBytesPerTurn: rawLogConfig.maxBytesPerTurn,
|
|
527
|
+
retentionDays: rawLogConfig.retentionDays,
|
|
528
|
+
});
|
|
529
|
+
} catch (err) {
|
|
530
|
+
console.error(`[Claude raw stream log] create failed: ${(err as Error).message}`);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
await session.send(buildClaudePromptText(userText, undefined, sessionId));
|
|
534
|
+
for await (const raw of session.stream()) {
|
|
535
|
+
if (abortController.signal.aborted) {
|
|
536
|
+
aborted = true;
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const msg = toMessageLike(raw);
|
|
541
|
+
rawLog?.writeLine(safeRawStreamJson(msg));
|
|
542
|
+
if (msg.type === "system" && msg.subtype === "init" && msg.session_id) {
|
|
543
|
+
const meta: { cwd?: string; model?: string } = {};
|
|
544
|
+
if (msg.cwd) meta.cwd = msg.cwd;
|
|
545
|
+
if (msg.model) meta.model = msg.model;
|
|
546
|
+
if (Object.keys(meta).length > 0) {
|
|
547
|
+
this.metaStore.set(msg.session_id, meta).catch(() => {});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const normalized = normalizeSdkMessage(msg);
|
|
552
|
+
if (normalized) yield normalized;
|
|
553
|
+
}
|
|
554
|
+
completed = !aborted && !abortController.signal.aborted;
|
|
555
|
+
} finally {
|
|
556
|
+
removeAbortListener?.();
|
|
557
|
+
if (aborted || abortController.signal.aborted) {
|
|
558
|
+
abortController.abort();
|
|
559
|
+
}
|
|
560
|
+
closeSdkSession(session);
|
|
561
|
+
await rawLog?.close({
|
|
562
|
+
keep: rawLogConfig.keepCompleted || abortController.signal.aborted || !completed,
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
async getSessionInfo(sessionId: string): Promise<SessionInfo | undefined> {
|
|
568
|
+
const meta = await this.metaStore.get(sessionId);
|
|
569
|
+
|
|
570
|
+
try {
|
|
571
|
+
const sdkInfo = await sdkGetSessionInfo(
|
|
572
|
+
sessionId,
|
|
573
|
+
meta?.cwd ? { dir: meta.cwd } : undefined,
|
|
574
|
+
);
|
|
575
|
+
if (sdkInfo) {
|
|
576
|
+
return {
|
|
577
|
+
sessionId: sdkInfo.sessionId,
|
|
578
|
+
cwd: sdkInfo.cwd ?? meta?.cwd,
|
|
579
|
+
summary: sdkInfo.summary,
|
|
580
|
+
lastModified: sdkInfo.lastModified,
|
|
581
|
+
model: meta?.model,
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
} catch {
|
|
585
|
+
// Fall back to the local meta store below.
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
if (!meta) return { sessionId };
|
|
589
|
+
return meta.model
|
|
590
|
+
? { sessionId, cwd: meta.cwd, model: meta.model }
|
|
591
|
+
: { sessionId, cwd: meta.cwd };
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
async closeSession(_sessionId: string): Promise<void> {
|
|
595
|
+
// SDK query streams are request scoped and are closed in prompt/createSession.
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export function createClaudeAdapter(
|
|
600
|
+
options: ClaudeAdapterOptions,
|
|
601
|
+
): ToolAdapter {
|
|
602
|
+
return new ClaudeAdapter(options);
|
|
603
|
+
}
|