deepccc 0.1.24 → 0.1.25
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 +8 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.js +2 -0
- package/dist/context.d.ts +9 -1
- package/dist/context.js +8 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,6 +77,7 @@ $env:DEEPCCC_STREAMING="true"
|
|
|
77
77
|
"model": "deepseek-v4-pro",
|
|
78
78
|
"effort": "",
|
|
79
79
|
"streaming": true,
|
|
80
|
+
"contextWindow": 1048576,
|
|
80
81
|
"rawStreamLogs": {
|
|
81
82
|
"enabled": true,
|
|
82
83
|
"maxBytesPerTurn": 1048576,
|
|
@@ -90,11 +91,17 @@ $env:DEEPCCC_STREAMING="true"
|
|
|
90
91
|
`DEEPCCC_PROVIDER` 或命令行 `--provider` 覆盖:
|
|
91
92
|
|
|
92
93
|
- `openai` 使用 OpenAI-compatible Chat Completions 协议,兼容 DeepSeek、OpenAI、LiteLLM、vLLM 等服务。
|
|
93
|
-
- `anthropic` 使用 Anthropic Messages 协议。配置中的 `baseURL`
|
|
94
|
+
- `anthropic` 使用 Anthropic Messages 协议。配置中的 `baseURL` **完全按填写值使用,不自动补 `/v1`**,请填写到完整版本化地址,例如 DeepSeek 官方 Anthropic 端点为 `https://api.deepseek.com/anthropic/v1`(官方 Anthropic SDK 使用的 `https://api.deepseek.com/anthropic` 基址会拼接为 `.../anthropic/v1/messages`)。`effort` 是 OpenAI/DeepSeek 扩展参数,在 Anthropic 模式下不会发送。
|
|
94
95
|
|
|
95
96
|
`streaming` 控制主对话是否使用流式请求,默认 `true`;也可以通过
|
|
96
97
|
`DEEPCCC_STREAMING=true|false` 覆盖。关闭后,终端会在整条模型响应完成后一次性显示结果。
|
|
97
98
|
|
|
99
|
+
`contextWindow` 是模型上下文窗口(token),默认 `1048576`(1M,DeepSeek V4 Pro/Flash
|
|
100
|
+
原生规格);上下文压缩阈值自动 = `contextWindow × 0.8`(超出即把较早消息压缩为摘要)。
|
|
101
|
+
可通过 `DEEPCCC_CONTEXT_WINDOW` 环境变量覆盖。⚠️ 超过模型/服务端实际上限时请求会被
|
|
102
|
+
API 拒绝(context length exceeded),实际窗口以模型与所用服务端为准(如 litellm 的
|
|
103
|
+
`max_input_tokens`)。
|
|
104
|
+
|
|
98
105
|
`rawStreamLogs.enabled` 默认 `true`,通过 `DEEPCCC_RAW_STREAM_LOGS` 环境变量或配置 JSON 关闭。
|
|
99
106
|
开启时,每次对话的原始流按 gzip JSONL 落到 `~/.deepccc/raw-stream-logs/`,供
|
|
100
107
|
`session_search` 工具在会话被压缩后找回被压缩消息的精确原文(检索时设置
|
package/dist/config.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export interface DeepCccConfig {
|
|
|
9
9
|
effort: string;
|
|
10
10
|
/** 主对话是否使用流式请求;默认开启 */
|
|
11
11
|
streaming: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 模型上下文窗口(token),默认 1048576(1M,DeepSeek V4 Pro/Flash 原生规格)。
|
|
14
|
+
* 上下文压缩阈值自动 = contextWindow × 0.8;超过模型/服务端实际上限会被 API 拒绝。
|
|
15
|
+
*/
|
|
16
|
+
contextWindow: number;
|
|
12
17
|
rawStreamLogs: {
|
|
13
18
|
enabled: boolean;
|
|
14
19
|
maxBytesPerTurn: number;
|
package/dist/config.js
CHANGED
|
@@ -14,6 +14,7 @@ export const DEFAULT_CONFIG = {
|
|
|
14
14
|
model: "deepseek-v4-pro",
|
|
15
15
|
effort: "",
|
|
16
16
|
streaming: true,
|
|
17
|
+
contextWindow: 1_048_576,
|
|
17
18
|
rawStreamLogs: {
|
|
18
19
|
// 默认开启:压缩后可通过 session_search(include_raw_logs=true)找回原文。
|
|
19
20
|
// 如需关闭,在 ~/.deepccc/config.json 中设置 rawStreamLogs.enabled=false。
|
|
@@ -67,6 +68,7 @@ function loadConfig() {
|
|
|
67
68
|
model: env("DEEPCCC_MODEL") ?? env("DEEPSEEK_MODEL") ?? file.model ?? DEFAULT_CONFIG.model,
|
|
68
69
|
effort: env("DEEPCCC_EFFORT") ?? env("DEEPSEEK_EFFORT") ?? file.effort ?? DEFAULT_CONFIG.effort,
|
|
69
70
|
streaming: boolEnv("DEEPCCC_STREAMING") ?? file.streaming ?? DEFAULT_CONFIG.streaming,
|
|
71
|
+
contextWindow: numberEnv("DEEPCCC_CONTEXT_WINDOW") ?? file.contextWindow ?? DEFAULT_CONFIG.contextWindow,
|
|
70
72
|
rawStreamLogs: {
|
|
71
73
|
enabled: boolEnv("DEEPCCC_RAW_STREAM_LOGS") ?? rawLogs.enabled ?? DEFAULT_CONFIG.rawStreamLogs.enabled,
|
|
72
74
|
maxBytesPerTurn: numberEnv("DEEPCCC_RAW_STREAM_MAX_BYTES") ?? rawLogs.maxBytesPerTurn ?? DEFAULT_CONFIG.rawStreamLogs.maxBytesPerTurn,
|
package/dist/context.d.ts
CHANGED
|
@@ -48,11 +48,19 @@ export interface BuiltinContextOptions {
|
|
|
48
48
|
contextDir?: string;
|
|
49
49
|
sessionId?: string;
|
|
50
50
|
cwd?: string;
|
|
51
|
+
/** 模型上下文窗口(token)。缺省时压缩阈值 = contextWindow × 0.8。 */
|
|
52
|
+
contextWindow?: number;
|
|
53
|
+
/** 直接指定压缩阈值(token),优先于 contextWindow 的 80% 派生。 */
|
|
51
54
|
compactAtTokens?: number;
|
|
52
55
|
keepRecentMessages?: number;
|
|
53
56
|
}
|
|
54
57
|
export declare const DEFAULT_BUILTIN_CONTEXT_DIR: string;
|
|
55
|
-
|
|
58
|
+
/** 默认模型上下文窗口:1M(DeepSeek V4 Pro/Flash 原生规格)。 */
|
|
59
|
+
export declare const DEFAULT_CONTEXT_WINDOW_TOKENS = 1048576;
|
|
60
|
+
/** 压缩阈值 = 窗口 × 0.8(业界惯例:在窗口接近上限前主动压缩,留出安全余量)。 */
|
|
61
|
+
export declare const COMPACTION_THRESHOLD_RATIO = 0.8;
|
|
62
|
+
/** 默认压缩阈值 = 1M × 0.8。 */
|
|
63
|
+
export declare const DEFAULT_COMPACT_AT_TOKENS: number;
|
|
56
64
|
export declare const DEFAULT_KEEP_RECENT_MESSAGES = 16;
|
|
57
65
|
export declare function normalizeBuiltinSessionId(value: string): string;
|
|
58
66
|
export declare function defaultBuiltinSessionId(cwd?: string): string;
|
package/dist/context.js
CHANGED
|
@@ -3,7 +3,12 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFile
|
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
export const DEFAULT_BUILTIN_CONTEXT_DIR = join(homedir(), ".deepccc", "sessions");
|
|
6
|
-
|
|
6
|
+
/** 默认模型上下文窗口:1M(DeepSeek V4 Pro/Flash 原生规格)。 */
|
|
7
|
+
export const DEFAULT_CONTEXT_WINDOW_TOKENS = 1_048_576;
|
|
8
|
+
/** 压缩阈值 = 窗口 × 0.8(业界惯例:在窗口接近上限前主动压缩,留出安全余量)。 */
|
|
9
|
+
export const COMPACTION_THRESHOLD_RATIO = 0.8;
|
|
10
|
+
/** 默认压缩阈值 = 1M × 0.8。 */
|
|
11
|
+
export const DEFAULT_COMPACT_AT_TOKENS = Math.floor(DEFAULT_CONTEXT_WINDOW_TOKENS * COMPACTION_THRESHOLD_RATIO);
|
|
7
12
|
export const DEFAULT_KEEP_RECENT_MESSAGES = 16;
|
|
8
13
|
const RECENT_CONTEXT_BUDGET_RATIO = 0.6;
|
|
9
14
|
const MAX_COMPACTION_SUMMARY_CHARS = 8_000;
|
|
@@ -247,7 +252,8 @@ export class BuiltinContextManager {
|
|
|
247
252
|
this.contextDir = options.contextDir ?? DEFAULT_BUILTIN_CONTEXT_DIR;
|
|
248
253
|
this.sessionId = normalizeBuiltinSessionId(options.sessionId ?? defaultBuiltinSessionId());
|
|
249
254
|
this.cwd = options.cwd;
|
|
250
|
-
this.compactAtTokens = options.compactAtTokens
|
|
255
|
+
this.compactAtTokens = options.compactAtTokens
|
|
256
|
+
?? Math.floor((options.contextWindow ?? DEFAULT_CONTEXT_WINDOW_TOKENS) * COMPACTION_THRESHOLD_RATIO);
|
|
251
257
|
this.keepRecentMessages = Math.max(1, options.keepRecentMessages ?? DEFAULT_KEEP_RECENT_MESSAGES);
|
|
252
258
|
this.state = this.load();
|
|
253
259
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,11 @@ export interface ChatSessionOptions {
|
|
|
47
47
|
sessionId?: string;
|
|
48
48
|
/** Compact older context when the rough token estimate exceeds this value. */
|
|
49
49
|
compactAtTokens?: number;
|
|
50
|
+
/**
|
|
51
|
+
* 模型上下文窗口(token),默认 1048576(1M)。压缩阈值自动 = contextWindow × 0.8;
|
|
52
|
+
* 显式 compactAtTokens 优先于该派生值。
|
|
53
|
+
*/
|
|
54
|
+
contextWindow?: number;
|
|
50
55
|
/** Number of recent raw messages retained after compaction. */
|
|
51
56
|
keepRecentMessages?: number;
|
|
52
57
|
/** Hard deadline for all context-compaction passes in one turn. */
|
package/dist/index.js
CHANGED
|
@@ -210,8 +210,10 @@ function normalizeMaxSteps(value) {
|
|
|
210
210
|
return value;
|
|
211
211
|
}
|
|
212
212
|
function normalizeAnthropicBaseURL(baseURL) {
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
// 完全按用户填写的地址使用,不自动补 /v1(AI SDK 仅对官方 api.anthropic.com
|
|
214
|
+
// 特判补一次 /v1,其他地址原样拼接 /messages)。
|
|
215
|
+
// DeepSeek Anthropic 端点示例:https://api.deepseek.com/anthropic/v1。
|
|
216
|
+
return baseURL.trim().replace(/\/+$/, "");
|
|
215
217
|
}
|
|
216
218
|
export class ChatSession {
|
|
217
219
|
model;
|
|
@@ -265,6 +267,7 @@ export class ChatSession {
|
|
|
265
267
|
contextDir: options.contextDir,
|
|
266
268
|
sessionId: options.sessionId ?? defaultBuiltinSessionId(this.cwd),
|
|
267
269
|
cwd: this.cwd,
|
|
270
|
+
contextWindow: options.contextWindow ?? appConfig.contextWindow,
|
|
268
271
|
compactAtTokens: options.compactAtTokens,
|
|
269
272
|
keepRecentMessages: options.keepRecentMessages,
|
|
270
273
|
});
|