@ekay/claude-im 0.1.0 → 0.2.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/dist/index.js +15 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -578,6 +578,8 @@ function createEventState() {
|
|
|
578
578
|
currentToolName: "",
|
|
579
579
|
sessionId: "",
|
|
580
580
|
error: null,
|
|
581
|
+
inputTokens: 0,
|
|
582
|
+
outputTokens: 0,
|
|
581
583
|
isComplete: false
|
|
582
584
|
};
|
|
583
585
|
}
|
|
@@ -606,6 +608,8 @@ function processEvent(state, event) {
|
|
|
606
608
|
const result = event;
|
|
607
609
|
state.sessionId = result.session_id ?? "";
|
|
608
610
|
state.error = result.error ?? null;
|
|
611
|
+
state.inputTokens = result.usage?.input_tokens ?? 0;
|
|
612
|
+
state.outputTokens = result.usage?.output_tokens ?? 0;
|
|
609
613
|
state.isComplete = true;
|
|
610
614
|
}
|
|
611
615
|
}
|
|
@@ -636,7 +640,9 @@ async function runAgent(input, onEvent) {
|
|
|
636
640
|
sessionId: state.sessionId,
|
|
637
641
|
thinkingLength: state.thinkingLength,
|
|
638
642
|
toolCallCount: state.toolCallCount,
|
|
639
|
-
error: state.error
|
|
643
|
+
error: state.error,
|
|
644
|
+
inputTokens: state.inputTokens,
|
|
645
|
+
outputTokens: state.outputTokens
|
|
640
646
|
};
|
|
641
647
|
}
|
|
642
648
|
var init_agent = __esm({
|
|
@@ -812,7 +818,9 @@ async function runClaudeReply(config, adapter, msg, prompt2) {
|
|
|
812
818
|
await ctrl.complete(result.text || "(\u7A7A\u56DE\u590D)", {
|
|
813
819
|
elapsed: Date.now() - t0,
|
|
814
820
|
tools: result.toolCallCount,
|
|
815
|
-
thinking: result.thinkingLength
|
|
821
|
+
thinking: result.thinkingLength,
|
|
822
|
+
inputTokens: result.inputTokens,
|
|
823
|
+
outputTokens: result.outputTokens
|
|
816
824
|
});
|
|
817
825
|
if (result.sessionId) setSession(config.profile, result.sessionId, msg.chatId);
|
|
818
826
|
}
|
|
@@ -1109,6 +1117,10 @@ var FlushController = class {
|
|
|
1109
1117
|
};
|
|
1110
1118
|
|
|
1111
1119
|
// src/adapters/feishu/stream.ts
|
|
1120
|
+
function fmtTokens(n) {
|
|
1121
|
+
if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
|
|
1122
|
+
return String(n);
|
|
1123
|
+
}
|
|
1112
1124
|
var CardKitStreamController = class {
|
|
1113
1125
|
/** 当前控制器状态 */
|
|
1114
1126
|
state = "idle";
|
|
@@ -1199,7 +1211,7 @@ var CardKitStreamController = class {
|
|
|
1199
1211
|
const statsText = stats ? `
|
|
1200
1212
|
|
|
1201
1213
|
---
|
|
1202
|
-
\u23F1 ${(stats.elapsed / 1e3).toFixed(1)}s \xB7 \u{1F527} ${stats.tools} tools \xB7 \u{1F4AD} ${stats.thinking} chars` : "";
|
|
1214
|
+
\u23F1 ${(stats.elapsed / 1e3).toFixed(1)}s \xB7 \u{1F527} ${stats.tools} tools \xB7 \u{1F4AD} ${stats.thinking} chars \xB7 \u{1FA99} ${fmtTokens(stats.inputTokens)}/${fmtTokens(stats.outputTokens)} tokens` : "";
|
|
1203
1215
|
try {
|
|
1204
1216
|
await this.client.im.message.patch({
|
|
1205
1217
|
path: { message_id: this._messageId },
|