@t2000/cli 0.18.9 → 0.19.1
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.
|
@@ -24882,7 +24882,7 @@ var AnthropicProvider = class {
|
|
|
24882
24882
|
client;
|
|
24883
24883
|
constructor(apiKey, model) {
|
|
24884
24884
|
this.model = model ?? "claude-sonnet-4-20250514";
|
|
24885
|
-
this.client = new sdk_default({ apiKey });
|
|
24885
|
+
this.client = new sdk_default({ apiKey, maxRetries: 3 });
|
|
24886
24886
|
}
|
|
24887
24887
|
async chat(params) {
|
|
24888
24888
|
const systemMessage = params.messages.find((m) => m.role === "system");
|
|
@@ -24977,7 +24977,7 @@ var OpenAIProvider = class {
|
|
|
24977
24977
|
client;
|
|
24978
24978
|
constructor(apiKey, model) {
|
|
24979
24979
|
this.model = model ?? "gpt-4o";
|
|
24980
|
-
this.client = new openai_default({ apiKey });
|
|
24980
|
+
this.client = new openai_default({ apiKey, maxRetries: 3 });
|
|
24981
24981
|
}
|
|
24982
24982
|
async chat(params) {
|
|
24983
24983
|
const messages = params.messages.map((m) => this.toOpenAIMessage(m));
|
|
@@ -25467,10 +25467,11 @@ var TelegramChannel = class {
|
|
|
25467
25467
|
this.setupHandlers();
|
|
25468
25468
|
}
|
|
25469
25469
|
async start() {
|
|
25470
|
-
|
|
25471
|
-
|
|
25472
|
-
|
|
25473
|
-
|
|
25470
|
+
return new Promise((resolve2) => {
|
|
25471
|
+
this.bot.start({
|
|
25472
|
+
onStart: () => resolve2(),
|
|
25473
|
+
drop_pending_updates: true
|
|
25474
|
+
});
|
|
25474
25475
|
});
|
|
25475
25476
|
}
|
|
25476
25477
|
async stop() {
|
|
@@ -26082,9 +26083,9 @@ function getDryRunHandler(tool) {
|
|
|
26082
26083
|
return dryRunHandlers[tool.name] ?? null;
|
|
26083
26084
|
}
|
|
26084
26085
|
var ESTIMATED_TOKENS_PER_CHAR = 0.25;
|
|
26085
|
-
var MAX_TOKEN_BUDGET =
|
|
26086
|
-
var COMPACTION_THRESHOLD = 0.
|
|
26087
|
-
var MIN_RECENT_PAIRS =
|
|
26086
|
+
var MAX_TOKEN_BUDGET = 2e4;
|
|
26087
|
+
var COMPACTION_THRESHOLD = 0.75;
|
|
26088
|
+
var MIN_RECENT_PAIRS = 3;
|
|
26088
26089
|
var ContextManager = class {
|
|
26089
26090
|
history = [];
|
|
26090
26091
|
getHistory() {
|
|
@@ -26393,7 +26394,7 @@ ${contextData}`
|
|
|
26393
26394
|
allToolCalls.push({ name: tc.name, arguments: tc.arguments, result, dryRun: false });
|
|
26394
26395
|
this.context.addMessage({
|
|
26395
26396
|
role: "tool",
|
|
26396
|
-
content:
|
|
26397
|
+
content: this.truncateResult(result),
|
|
26397
26398
|
toolCallId: tc.id
|
|
26398
26399
|
});
|
|
26399
26400
|
} catch (err) {
|
|
@@ -26456,6 +26457,11 @@ ${contextData}`
|
|
|
26456
26457
|
this.context.clear();
|
|
26457
26458
|
this.pendingConfirmation = null;
|
|
26458
26459
|
}
|
|
26460
|
+
truncateResult(result, maxLen = 2e3) {
|
|
26461
|
+
const json = JSON.stringify(result);
|
|
26462
|
+
if (json.length <= maxLen) return json;
|
|
26463
|
+
return json.slice(0, maxLen) + "...[truncated]";
|
|
26464
|
+
}
|
|
26459
26465
|
};
|
|
26460
26466
|
var HeartbeatScheduler = class {
|
|
26461
26467
|
tasks = [];
|
|
@@ -26881,9 +26887,7 @@ var Gateway = class _Gateway {
|
|
|
26881
26887
|
}
|
|
26882
26888
|
}
|
|
26883
26889
|
if (!this.options.noTelegram && this.config.channels.telegram?.enabled && this.config.channels.telegram.botToken) {
|
|
26884
|
-
this.startTelegram(tools, toolDefs, results)
|
|
26885
|
-
this.logger.error(`Telegram startup error: ${err instanceof Error ? err.message : String(err)}`);
|
|
26886
|
-
});
|
|
26890
|
+
await this.startTelegram(tools, toolDefs, results);
|
|
26887
26891
|
}
|
|
26888
26892
|
if (!this.options.noHeartbeat) {
|
|
26889
26893
|
const getUsage = () => {
|
|
@@ -27037,7 +27041,8 @@ var Gateway = class _Gateway {
|
|
|
27037
27041
|
} catch (err) {
|
|
27038
27042
|
const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
27039
27043
|
const friendlyMsg = this.friendlyError(err);
|
|
27040
|
-
|
|
27044
|
+
const logMsg = this.cleanErrorForLog(err);
|
|
27045
|
+
this.logger.error(`${channel.id} \xB7 "${queryPreview}" \u2192 ${logMsg} (${elapsed}s)`);
|
|
27041
27046
|
await channel.send(msg.userId, friendlyMsg);
|
|
27042
27047
|
}
|
|
27043
27048
|
}
|
|
@@ -27045,7 +27050,7 @@ var Gateway = class _Gateway {
|
|
|
27045
27050
|
if (!(err instanceof Error)) return "Something went wrong. Try again?";
|
|
27046
27051
|
const msg = err.message.toLowerCase();
|
|
27047
27052
|
if (msg.includes("rate limit") || msg.includes("429") || msg.includes("overloaded")) {
|
|
27048
|
-
return "AI
|
|
27053
|
+
return "\u23F3 AI rate limit hit \u2014 wait a minute and try again.";
|
|
27049
27054
|
}
|
|
27050
27055
|
if (msg.includes("api") || msg.includes("500") || msg.includes("503") || msg.includes("timeout")) {
|
|
27051
27056
|
return "AI is temporarily unavailable. Please try again in a moment.";
|
|
@@ -27074,6 +27079,19 @@ var Gateway = class _Gateway {
|
|
|
27074
27079
|
}
|
|
27075
27080
|
return `Something went wrong: ${err.message}`;
|
|
27076
27081
|
}
|
|
27082
|
+
cleanErrorForLog(err) {
|
|
27083
|
+
if (!(err instanceof Error)) return "unknown error";
|
|
27084
|
+
const msg = err.message;
|
|
27085
|
+
if (msg.includes("rate_limit") || msg.includes("429")) {
|
|
27086
|
+
const limitMatch = msg.match(/(\d[\d,]+)\s*input tokens per minute/);
|
|
27087
|
+
return limitMatch ? `rate limited (${limitMatch[1]} tokens/min)` : "rate limited";
|
|
27088
|
+
}
|
|
27089
|
+
if (msg.includes("overloaded") || msg.includes("503")) return "API overloaded";
|
|
27090
|
+
if (msg.includes("timeout")) return "timeout";
|
|
27091
|
+
if (msg.includes("500")) return "API error (500)";
|
|
27092
|
+
const short = msg.length > 80 ? msg.slice(0, 80) + "..." : msg;
|
|
27093
|
+
return short;
|
|
27094
|
+
}
|
|
27077
27095
|
estimateCost(usage) {
|
|
27078
27096
|
if (this.llm.id === "anthropic") {
|
|
27079
27097
|
return (usage.inputTokens * 3 + usage.outputTokens * 15) / 1e6;
|
|
@@ -27110,4 +27128,4 @@ humanize-ms/index.js:
|
|
|
27110
27128
|
* MIT Licensed
|
|
27111
27129
|
*)
|
|
27112
27130
|
*/
|
|
27113
|
-
//# sourceMappingURL=dist-
|
|
27131
|
+
//# sourceMappingURL=dist-JTC2LTDE.js.map
|