@t2000/cli 0.19.0 → 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));
|
|
@@ -26083,9 +26083,9 @@ function getDryRunHandler(tool) {
|
|
|
26083
26083
|
return dryRunHandlers[tool.name] ?? null;
|
|
26084
26084
|
}
|
|
26085
26085
|
var ESTIMATED_TOKENS_PER_CHAR = 0.25;
|
|
26086
|
-
var MAX_TOKEN_BUDGET =
|
|
26087
|
-
var COMPACTION_THRESHOLD = 0.
|
|
26088
|
-
var MIN_RECENT_PAIRS =
|
|
26086
|
+
var MAX_TOKEN_BUDGET = 2e4;
|
|
26087
|
+
var COMPACTION_THRESHOLD = 0.75;
|
|
26088
|
+
var MIN_RECENT_PAIRS = 3;
|
|
26089
26089
|
var ContextManager = class {
|
|
26090
26090
|
history = [];
|
|
26091
26091
|
getHistory() {
|
|
@@ -26394,7 +26394,7 @@ ${contextData}`
|
|
|
26394
26394
|
allToolCalls.push({ name: tc.name, arguments: tc.arguments, result, dryRun: false });
|
|
26395
26395
|
this.context.addMessage({
|
|
26396
26396
|
role: "tool",
|
|
26397
|
-
content:
|
|
26397
|
+
content: this.truncateResult(result),
|
|
26398
26398
|
toolCallId: tc.id
|
|
26399
26399
|
});
|
|
26400
26400
|
} catch (err) {
|
|
@@ -26457,6 +26457,11 @@ ${contextData}`
|
|
|
26457
26457
|
this.context.clear();
|
|
26458
26458
|
this.pendingConfirmation = null;
|
|
26459
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
|
+
}
|
|
26460
26465
|
};
|
|
26461
26466
|
var HeartbeatScheduler = class {
|
|
26462
26467
|
tasks = [];
|
|
@@ -27036,7 +27041,8 @@ var Gateway = class _Gateway {
|
|
|
27036
27041
|
} catch (err) {
|
|
27037
27042
|
const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
27038
27043
|
const friendlyMsg = this.friendlyError(err);
|
|
27039
|
-
|
|
27044
|
+
const logMsg = this.cleanErrorForLog(err);
|
|
27045
|
+
this.logger.error(`${channel.id} \xB7 "${queryPreview}" \u2192 ${logMsg} (${elapsed}s)`);
|
|
27040
27046
|
await channel.send(msg.userId, friendlyMsg);
|
|
27041
27047
|
}
|
|
27042
27048
|
}
|
|
@@ -27044,7 +27050,7 @@ var Gateway = class _Gateway {
|
|
|
27044
27050
|
if (!(err instanceof Error)) return "Something went wrong. Try again?";
|
|
27045
27051
|
const msg = err.message.toLowerCase();
|
|
27046
27052
|
if (msg.includes("rate limit") || msg.includes("429") || msg.includes("overloaded")) {
|
|
27047
|
-
return "AI
|
|
27053
|
+
return "\u23F3 AI rate limit hit \u2014 wait a minute and try again.";
|
|
27048
27054
|
}
|
|
27049
27055
|
if (msg.includes("api") || msg.includes("500") || msg.includes("503") || msg.includes("timeout")) {
|
|
27050
27056
|
return "AI is temporarily unavailable. Please try again in a moment.";
|
|
@@ -27073,6 +27079,19 @@ var Gateway = class _Gateway {
|
|
|
27073
27079
|
}
|
|
27074
27080
|
return `Something went wrong: ${err.message}`;
|
|
27075
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
|
+
}
|
|
27076
27095
|
estimateCost(usage) {
|
|
27077
27096
|
if (this.llm.id === "anthropic") {
|
|
27078
27097
|
return (usage.inputTokens * 3 + usage.outputTokens * 15) / 1e6;
|
|
@@ -27109,4 +27128,4 @@ humanize-ms/index.js:
|
|
|
27109
27128
|
* MIT Licensed
|
|
27110
27129
|
*)
|
|
27111
27130
|
*/
|
|
27112
|
-
//# sourceMappingURL=dist-
|
|
27131
|
+
//# sourceMappingURL=dist-JTC2LTDE.js.map
|