deepccc 0.1.20 → 0.1.21
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/dist/index.js +29 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -60,6 +60,10 @@ const SUMMARY_SYSTEM_PROMPT = [
|
|
|
60
60
|
].join("\n");
|
|
61
61
|
export const DEFAULT_COMPACTION_TIMEOUT_MS = 90 * 1000;
|
|
62
62
|
const MAX_COMPACTION_OUTPUT_TOKENS = 16_384;
|
|
63
|
+
const ANTHROPIC_TOOL_JSON_COMPATIBILITY_NOTE = [
|
|
64
|
+
"[Protocol compatibility note]",
|
|
65
|
+
"tool-call arguments use JSON encoding; the final reply does not need to be JSON unless the user requests it.",
|
|
66
|
+
].join("\n");
|
|
63
67
|
// ---------------------------------------------------------------------------
|
|
64
68
|
// 类型定义
|
|
65
69
|
// ---------------------------------------------------------------------------
|
|
@@ -100,6 +104,26 @@ function buildRuntimeWorkspacePrompt(cwd) {
|
|
|
100
104
|
"文件工具通过 DeepCCC 在本地执行。可行时优先使用带 SHA-256 前置条件的受保护编辑,避免覆盖并发用户修改。",
|
|
101
105
|
].join("\n");
|
|
102
106
|
}
|
|
107
|
+
function addAnthropicToolJsonCompatibilityNote(messages) {
|
|
108
|
+
let lastUserIndex = -1;
|
|
109
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
110
|
+
if (messages[index]?.role === "user") {
|
|
111
|
+
lastUserIndex = index;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (lastUserIndex < 0)
|
|
116
|
+
return messages;
|
|
117
|
+
// 部分 Anthropic→OpenAI/Ark 转换器会用 response_format=json_object
|
|
118
|
+
// 实现工具调用,却只在 messages 中校验 JSON 关键词、不读取顶层 system。
|
|
119
|
+
// 这里仅声明工具参数的编码方式,并明确不要求普通最终回复输出 JSON。
|
|
120
|
+
return messages.map((message, index) => (index === lastUserIndex
|
|
121
|
+
? {
|
|
122
|
+
...message,
|
|
123
|
+
content: `${message.content}\n\n${ANTHROPIC_TOOL_JSON_COMPATIBILITY_NOTE}`,
|
|
124
|
+
}
|
|
125
|
+
: message));
|
|
126
|
+
}
|
|
103
127
|
/**
|
|
104
128
|
* 各操作系统特有的命令行指引(文本资产,维护在 os-prompts/ 目录,而非硬编码):
|
|
105
129
|
*
|
|
@@ -277,6 +301,10 @@ export class ChatSession {
|
|
|
277
301
|
const skills = await scanSkillsDirs(this.skillDirs);
|
|
278
302
|
const system = this.buildSystemPrompt(skills);
|
|
279
303
|
this.systemPrompt = system;
|
|
304
|
+
const contextMessages = this.context.buildModelMessages();
|
|
305
|
+
const modelMessages = this.provider === "anthropic"
|
|
306
|
+
? addAnthropicToolJsonCompatibilityNote(contextMessages)
|
|
307
|
+
: contextMessages;
|
|
280
308
|
// effort 按协议映射:
|
|
281
309
|
// - OpenAI 兼容:providerOptions.deepseek.reasoningEffort 由 @ai-sdk/openai-compatible
|
|
282
310
|
// 自动映射为请求体 reasoning_effort 字段(DeepSeek 原生支持);
|
|
@@ -291,7 +319,7 @@ export class ChatSession {
|
|
|
291
319
|
const generationOptions = {
|
|
292
320
|
model: this.model,
|
|
293
321
|
system,
|
|
294
|
-
messages:
|
|
322
|
+
messages: modelMessages,
|
|
295
323
|
tools: createBuiltinFileTools(this.cwd, { permissionGate: this.permissionGate }),
|
|
296
324
|
stopWhen: maxSteps !== undefined ? stepCountIs(maxSteps) : isLoopFinished(),
|
|
297
325
|
abortSignal: signal,
|