@iletai/nzb 1.1.6 โ 1.1.7
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/copilot/orchestrator.js +5 -1
- package/dist/telegram/bot.js +12 -3
- package/package.json +1 -1
|
@@ -292,10 +292,14 @@ async function executeOnSession(prompt, callback, onToolEvent, onUsage) {
|
|
|
292
292
|
const unsubUsage = session.on("assistant.usage", (event) => {
|
|
293
293
|
const inputTokens = event?.data?.inputTokens || 0;
|
|
294
294
|
const outputTokens = event?.data?.outputTokens || 0;
|
|
295
|
-
|
|
295
|
+
const model = event?.data?.model || undefined;
|
|
296
|
+
const duration = event?.data?.duration || undefined;
|
|
297
|
+
onUsage?.({ inputTokens, outputTokens, model, duration });
|
|
296
298
|
});
|
|
297
299
|
try {
|
|
298
300
|
const result = await session.sendAndWait({ prompt }, 60_000);
|
|
301
|
+
// Allow late-arriving events (e.g. assistant.usage) to be processed
|
|
302
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
299
303
|
const finalContent = result?.data?.content || accumulated || "(No response)";
|
|
300
304
|
return finalContent;
|
|
301
305
|
}
|
package/dist/telegram/bot.js
CHANGED
|
@@ -281,9 +281,9 @@ export function createBot() {
|
|
|
281
281
|
let usageInfo;
|
|
282
282
|
let finalized = false;
|
|
283
283
|
let editChain = Promise.resolve();
|
|
284
|
-
const EDIT_INTERVAL_MS =
|
|
284
|
+
const EDIT_INTERVAL_MS = 3000;
|
|
285
285
|
// Minimum character delta before sending an edit โ avoids wasting API calls on tiny changes
|
|
286
|
-
const MIN_EDIT_DELTA =
|
|
286
|
+
const MIN_EDIT_DELTA = 50;
|
|
287
287
|
// Minimum time before showing the first placeholder, so user sees "typing" first
|
|
288
288
|
const FIRST_PLACEHOLDER_DELAY_MS = 1500;
|
|
289
289
|
const handlerStartTime = Date.now();
|
|
@@ -399,7 +399,16 @@ export function createBot() {
|
|
|
399
399
|
}
|
|
400
400
|
let textWithMeta = text;
|
|
401
401
|
if (usageInfo) {
|
|
402
|
-
|
|
402
|
+
const fmtTokens = (n) => n >= 1000 ? `${(n / 1000).toFixed(1)}K` : String(n);
|
|
403
|
+
const parts = [];
|
|
404
|
+
if (usageInfo.model)
|
|
405
|
+
parts.push(usageInfo.model);
|
|
406
|
+
parts.push(`โฌ${fmtTokens(usageInfo.inputTokens)} โฌ${fmtTokens(usageInfo.outputTokens)}`);
|
|
407
|
+
const totalTokens = usageInfo.inputTokens + usageInfo.outputTokens;
|
|
408
|
+
parts.push(`ฮฃ${fmtTokens(totalTokens)}`);
|
|
409
|
+
if (usageInfo.duration)
|
|
410
|
+
parts.push(`${(usageInfo.duration / 1000).toFixed(1)}s`);
|
|
411
|
+
textWithMeta += `\n\n๐ ${parts.join(" ยท ")}`;
|
|
403
412
|
}
|
|
404
413
|
const formatted = toTelegramMarkdown(textWithMeta);
|
|
405
414
|
let fullFormatted = formatted;
|