evolclaw 3.2.0 → 3.3.0
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/CHANGELOG.md +17 -0
- package/README.md +1 -2
- package/dist/agents/{resolve.js → baseagent.js} +34 -5
- package/dist/agents/claude-runner.js +120 -27
- package/dist/agents/codex-app-server-client.js +364 -0
- package/dist/agents/codex-runner.js +1069 -141
- package/dist/agents/gemini-runner.js +2 -2
- package/dist/agents/runner-types.js +28 -0
- package/dist/aun/aid/store.js +1 -1
- package/dist/aun/storage/download.js +1 -1
- package/dist/aun/storage/upload.js +13 -1
- package/dist/channels/aun.js +406 -293
- package/dist/channels/dingtalk.js +77 -140
- package/dist/channels/feishu.js +97 -150
- package/dist/channels/qqbot.js +75 -138
- package/dist/channels/wechat.js +75 -136
- package/dist/channels/wecom.js +75 -138
- package/dist/cli/agent.js +8 -5
- package/dist/cli/index.js +177 -44
- package/dist/cli/init.js +33 -6
- package/dist/cli/model.js +1 -1
- package/dist/cli/stats.js +558 -0
- package/dist/cli/version.js +87 -0
- package/dist/cli/watch-msg.js +5 -2
- package/dist/config-store.js +12 -6
- package/dist/core/channel-loader.js +84 -82
- package/dist/core/command-handler.js +473 -114
- package/dist/core/evolagent-registry.js +1 -0
- package/dist/core/evolagent.js +1 -1
- package/dist/core/interaction-router.js +8 -0
- package/dist/core/message/command-handler-agent-control.js +63 -1
- package/dist/core/message/im-renderer.js +35 -13
- package/dist/core/message/items-formatter.js +9 -1
- package/dist/core/message/message-bridge.js +49 -21
- package/dist/core/message/message-log.js +1 -0
- package/dist/core/message/message-processor.js +295 -35
- package/dist/core/message/message-queue.js +2 -2
- package/dist/core/message/pending-hints.js +232 -0
- package/dist/core/message/response-depth.js +56 -0
- package/dist/core/model/model-catalog.js +1 -1
- package/dist/core/model/model-scope.js +2 -2
- package/dist/core/permission.js +9 -12
- package/dist/core/relation/peer-identity.js +16 -1
- package/dist/core/session/adapters/codex-session-file-adapter.js +4 -2
- package/dist/core/session/session-manager.js +27 -13
- package/dist/core/session/session-title.js +26 -0
- package/dist/core/stats/billing.js +151 -0
- package/dist/core/stats/budget.js +93 -0
- package/dist/core/stats/db.js +314 -0
- package/dist/core/stats/eck-vars.js +84 -0
- package/dist/core/stats/index.js +10 -0
- package/dist/core/stats/normalizer.js +78 -0
- package/dist/core/stats/query.js +760 -0
- package/dist/core/stats/writer.js +115 -0
- package/dist/core/trigger/manager.js +34 -0
- package/dist/core/trigger/parser.js +9 -3
- package/dist/core/trigger/scheduler.js +20 -17
- package/dist/{agents → eck}/manifest-engine.js +20 -1
- package/dist/{agents → eck}/message-renderer.js +24 -1
- package/dist/index.js +130 -8
- package/dist/ipc.js +17 -1
- package/dist/utils/cross-platform.js +23 -5
- package/dist/utils/ecweb-pair.js +20 -0
- package/dist/utils/stats.js +14 -0
- package/kits/docs/evolclaw/INDEX.md +3 -1
- package/kits/docs/evolclaw/fs-architecture.md +1215 -0
- package/kits/docs/evolclaw/fs.md +131 -0
- package/kits/docs/evolclaw/group-fs.md +209 -0
- package/kits/docs/evolclaw/stats.md +70 -0
- package/kits/docs/venues/aun-group.md +29 -6
- package/kits/docs/venues/group.md +5 -4
- package/kits/eck_manifest.json +12 -0
- package/kits/eck_message_manifest.json +30 -3
- package/kits/rules/05-venue.md +1 -1
- package/kits/templates/message-fragments/inject-default.md +2 -0
- package/kits/templates/system-fragments/response-depth.md +16 -0
- package/package.json +4 -4
- package/dist/agents/baseagent-normalize.js +0 -19
- package/dist/core/relation/peer-key.js +0 -16
- package/dist/evolclaw-config.js +0 -11
- package/dist/utils/channel-helpers.js +0 -46
- /package/dist/core/{cache/file-cache.js → daemon-file-cache.js} +0 -0
- /package/dist/{agents → eck}/kit-renderer.js +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* normalizer.ts — 各模型 raw usage 字段 → 归一化 UsageEvent,同时推断 billing_fn。
|
|
3
|
+
* 按实际有什么字段智能探测,不假设接入方式。
|
|
4
|
+
*/
|
|
5
|
+
export function normalizeUsage(raw, meta) {
|
|
6
|
+
let billing_fn;
|
|
7
|
+
let input_tokens = 0;
|
|
8
|
+
let output_tokens = 0;
|
|
9
|
+
let cache_creation_tokens = 0;
|
|
10
|
+
let cache_read_tokens = 0;
|
|
11
|
+
let cache_hit_tokens;
|
|
12
|
+
let cache_miss_tokens;
|
|
13
|
+
let image_tokens;
|
|
14
|
+
let total_context_tokens;
|
|
15
|
+
if (raw.cache_hit_tokens != null || raw.cache_miss_tokens != null) {
|
|
16
|
+
// DeepSeek 口径
|
|
17
|
+
billing_fn = 'per_token_deepseek_v1';
|
|
18
|
+
output_tokens = raw.output_tokens ?? raw.completion_tokens ?? 0;
|
|
19
|
+
cache_hit_tokens = raw.cache_hit_tokens ?? 0;
|
|
20
|
+
cache_miss_tokens = raw.cache_miss_tokens ?? 0;
|
|
21
|
+
input_tokens = cache_miss_tokens; // 未命中部分才算 input(计费口径)
|
|
22
|
+
// 实际上下文长度 = 命中 + 未命中(total KV cache input)
|
|
23
|
+
total_context_tokens = cache_hit_tokens + cache_miss_tokens;
|
|
24
|
+
}
|
|
25
|
+
else if (raw.promptTokenCount != null || raw.candidatesTokenCount != null) {
|
|
26
|
+
// Gemini 原生
|
|
27
|
+
billing_fn = 'per_token_tiered_v1';
|
|
28
|
+
input_tokens = raw.promptTokenCount ?? 0;
|
|
29
|
+
output_tokens = raw.candidatesTokenCount ?? 0;
|
|
30
|
+
cache_read_tokens = raw.cachedContentTokenCount ?? 0;
|
|
31
|
+
total_context_tokens = raw.totalTokenCount ?? (input_tokens + output_tokens);
|
|
32
|
+
}
|
|
33
|
+
else if (raw.image_tokens != null) {
|
|
34
|
+
// 视觉模型(Qwen-VL 等)
|
|
35
|
+
billing_fn = 'per_token_image_v1';
|
|
36
|
+
input_tokens = raw.input_tokens ?? raw.prompt_tokens ?? 0;
|
|
37
|
+
output_tokens = raw.output_tokens ?? raw.completion_tokens ?? 0;
|
|
38
|
+
image_tokens = raw.image_tokens;
|
|
39
|
+
}
|
|
40
|
+
else if (raw.cache_creation_input_tokens != null || raw.cache_read_input_tokens != null) {
|
|
41
|
+
// Anthropic / Claude 原生
|
|
42
|
+
billing_fn = 'per_token_v1';
|
|
43
|
+
input_tokens = raw.input_tokens ?? 0;
|
|
44
|
+
output_tokens = raw.output_tokens ?? 0;
|
|
45
|
+
cache_creation_tokens = raw.cache_creation_input_tokens ?? 0;
|
|
46
|
+
cache_read_tokens = raw.cache_read_input_tokens ?? 0;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// OpenAI 兼容降级(Kimi / MiniMax / 截断网关等)
|
|
50
|
+
billing_fn = 'per_token_v1';
|
|
51
|
+
input_tokens = raw.input_tokens ?? raw.prompt_tokens ?? 0;
|
|
52
|
+
output_tokens = raw.output_tokens ?? raw.completion_tokens ?? 0;
|
|
53
|
+
cache_read_tokens = raw.prompt_tokens_details?.cached_tokens ?? 0;
|
|
54
|
+
}
|
|
55
|
+
if (total_context_tokens == null) {
|
|
56
|
+
total_context_tokens = input_tokens + output_tokens + cache_creation_tokens + cache_read_tokens || undefined;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
ts: meta.ts,
|
|
60
|
+
agent_aid: meta.agent_aid,
|
|
61
|
+
peer_key: meta.peer_key,
|
|
62
|
+
peer_type: meta.peer_type,
|
|
63
|
+
session_id: meta.session_id,
|
|
64
|
+
model: meta.model,
|
|
65
|
+
billing_fn,
|
|
66
|
+
input_tokens,
|
|
67
|
+
output_tokens,
|
|
68
|
+
cache_creation_tokens,
|
|
69
|
+
cache_read_tokens,
|
|
70
|
+
cache_hit_tokens,
|
|
71
|
+
cache_miss_tokens,
|
|
72
|
+
image_tokens,
|
|
73
|
+
total_context_tokens,
|
|
74
|
+
turns: meta.turns ?? 1,
|
|
75
|
+
duration_ms: meta.duration_ms,
|
|
76
|
+
context_window_pct: meta.context_window_pct,
|
|
77
|
+
};
|
|
78
|
+
}
|