@t2000/cli 0.19.0 → 0.19.2

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 = 8e4;
26087
- var COMPACTION_THRESHOLD = 0.8;
26088
- var MIN_RECENT_PAIRS = 5;
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() {
@@ -26157,6 +26157,13 @@ You manage their bank accounts on the Sui blockchain:
26157
26157
 
26158
26158
  You have ${toolCount} tools. Use them to check balances, execute transactions, manage investments, and optimize yield.
26159
26159
 
26160
+ TOOL USAGE \u2014 be thorough, not lazy:
26161
+ - Call MULTIPLE read-only tools in one turn when the query needs a complete picture
26162
+ - For greetings / "how's my account?" / overview requests: call t2000_balance + t2000_portfolio + t2000_earnings together, then present a briefing with actionable items
26163
+ - For "what if" / scenario questions: call t2000_balance + t2000_portfolio (and t2000_strategy if relevant), then present a before/after comparison showing what changes
26164
+ - For investment questions: always check t2000_balance first \u2014 if funds are insufficient, show where money needs to come from (withdraw from savings, etc.)
26165
+ - NEVER answer a question about balances, positions, or portfolio from memory or context injection alone \u2014 always call the tools for fresh data
26166
+
26160
26167
  RULES:
26161
26168
  - Always confirm before state-changing actions (send, save, invest, borrow, etc.)
26162
26169
  - Show what you'll do and ask "should I proceed?"
@@ -26184,32 +26191,46 @@ PERSONALITY:
26184
26191
 
26185
26192
  RESPONSE EXAMPLES \u2014 match this style:
26186
26193
 
26187
- When showing balances:
26188
- \u{1F4B3} Checking: **$52.67**
26189
- \u{1F3E6} Savings: **$19.24** (earning 4.2%)
26190
- \u{1F4B8} Debt: **-$2.01**
26191
- \u{1F4C8} Investment: **$0.05**
26194
+ When greeting / account overview (call balance + portfolio + earnings):
26195
+ \u2600\uFE0F **Morning briefing**
26196
+
26197
+ \u{1F4B3} Checking: **$69.60**
26198
+ \u{1F3E6} Savings: **$9.26** \xB7 4.15% APY
26199
+ \u{1F4B8} Credit: **-$1.00**
26200
+ \u{1F4C8} Investment: **$5.01** \xB7 +0.1%
26201
+
26202
+ Net worth: **$82.87**
26203
+
26204
+ \u{1F4CB} **Action items:**
26205
+ - $69.60 idle in checking \u2014 consider sweeping to savings
26206
+ - Repay $1.00 credit to stop accruing 7.67% interest
26207
+ - Claimable rewards available \u2014 say "claim rewards"
26192
26208
 
26193
- Net: **$70.95**
26209
+ When showing a "what if" / scenario (call balance + portfolio + strategy):
26210
+ \u{1F4CA} **Scenario: Invest $200 in all-weather**
26211
+ BTC 30% \xB7 ETH 20% \xB7 SUI 20% \xB7 GOLD 30%
26194
26212
 
26195
- Your debt ($2.01) costs more than it earns. Pay it off from checking? Just say "repay all."
26213
+ - Checking: $69.60 \u2192 **-$130.40**
26214
+ - Investment: $5.01 \u2192 **$205.01**
26215
+ - Allocation: 6% invested \u2192 71% invested
26216
+
26217
+ \u26A0\uFE0F You'd need to withdraw $130.40 from savings to cover this. That drops your savings buffer. Consider **$50** instead \u2014 keeps savings intact.
26196
26218
 
26197
26219
  When showing a transaction receipt:
26198
26220
  \u2705 Saved **$80.00**
26199
26221
 
26200
- Protocol: NAVI
26201
- APY: 5.57%
26222
+ Protocol: NAVI \xB7 APY: 5.57%
26202
26223
  Monthly yield: ~$3.71
26203
26224
  [View on explorer](https://suiscan.xyz/testnet/tx/abc123)
26204
26225
 
26205
- Savings balance: **$99.24** (+$80.00)
26226
+ Savings: **$99.24** (+$80.00)
26206
26227
 
26207
- When showing portfolio:
26208
- Your portfolio: **$152.30** (+2.3%)
26228
+ When showing portfolio (call portfolio + earnings):
26229
+ \u{1F4C8} Portfolio: **$152.30** (+2.3%)
26209
26230
 
26210
- \u{1F4C8} **SUI** \u2014 45.2 tokens ($48.00, +3.1%) \u2014 earning 2.6% on Suilend
26211
- \u{1F4C8} **BTC** \u2014 0.0012 ($89.30, +1.8%)
26212
- \u{1F4C9} **ETH** \u2014 0.025 ($15.00, -0.5%)
26231
+ - **SUI** \u2014 45.2 tokens ($48.00, +3.1%) \u2014 earning 2.6% on Suilend
26232
+ - **BTC** \u2014 0.0012 ($89.30, +1.8%)
26233
+ - **ETH** \u2014 0.025 ($15.00, -0.5%)
26213
26234
 
26214
26235
  \u{1F4A1} ETH is the only position losing. Rebalance into SUI?
26215
26236
 
@@ -26394,7 +26415,7 @@ ${contextData}`
26394
26415
  allToolCalls.push({ name: tc.name, arguments: tc.arguments, result, dryRun: false });
26395
26416
  this.context.addMessage({
26396
26417
  role: "tool",
26397
- content: JSON.stringify(result),
26418
+ content: this.truncateResult(result),
26398
26419
  toolCallId: tc.id
26399
26420
  });
26400
26421
  } catch (err) {
@@ -26457,6 +26478,11 @@ ${contextData}`
26457
26478
  this.context.clear();
26458
26479
  this.pendingConfirmation = null;
26459
26480
  }
26481
+ truncateResult(result, maxLen = 2e3) {
26482
+ const json = JSON.stringify(result);
26483
+ if (json.length <= maxLen) return json;
26484
+ return json.slice(0, maxLen) + "...[truncated]";
26485
+ }
26460
26486
  };
26461
26487
  var HeartbeatScheduler = class {
26462
26488
  tasks = [];
@@ -27036,7 +27062,8 @@ var Gateway = class _Gateway {
27036
27062
  } catch (err) {
27037
27063
  const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
27038
27064
  const friendlyMsg = this.friendlyError(err);
27039
- this.logger.error(`${channel.id} \xB7 "${queryPreview}" \u2192 error (${elapsed}s): ${err instanceof Error ? err.message : String(err)}`);
27065
+ const logMsg = this.cleanErrorForLog(err);
27066
+ this.logger.error(`${channel.id} \xB7 "${queryPreview}" \u2192 ${logMsg} (${elapsed}s)`);
27040
27067
  await channel.send(msg.userId, friendlyMsg);
27041
27068
  }
27042
27069
  }
@@ -27044,7 +27071,7 @@ var Gateway = class _Gateway {
27044
27071
  if (!(err instanceof Error)) return "Something went wrong. Try again?";
27045
27072
  const msg = err.message.toLowerCase();
27046
27073
  if (msg.includes("rate limit") || msg.includes("429") || msg.includes("overloaded")) {
27047
- return "AI is busy. Try again in a moment.";
27074
+ return "\u23F3 AI rate limit hit \u2014 wait a minute and try again.";
27048
27075
  }
27049
27076
  if (msg.includes("api") || msg.includes("500") || msg.includes("503") || msg.includes("timeout")) {
27050
27077
  return "AI is temporarily unavailable. Please try again in a moment.";
@@ -27073,6 +27100,19 @@ var Gateway = class _Gateway {
27073
27100
  }
27074
27101
  return `Something went wrong: ${err.message}`;
27075
27102
  }
27103
+ cleanErrorForLog(err) {
27104
+ if (!(err instanceof Error)) return "unknown error";
27105
+ const msg = err.message;
27106
+ if (msg.includes("rate_limit") || msg.includes("429")) {
27107
+ const limitMatch = msg.match(/(\d[\d,]+)\s*input tokens per minute/);
27108
+ return limitMatch ? `rate limited (${limitMatch[1]} tokens/min)` : "rate limited";
27109
+ }
27110
+ if (msg.includes("overloaded") || msg.includes("503")) return "API overloaded";
27111
+ if (msg.includes("timeout")) return "timeout";
27112
+ if (msg.includes("500")) return "API error (500)";
27113
+ const short = msg.length > 80 ? msg.slice(0, 80) + "..." : msg;
27114
+ return short;
27115
+ }
27076
27116
  estimateCost(usage) {
27077
27117
  if (this.llm.id === "anthropic") {
27078
27118
  return (usage.inputTokens * 3 + usage.outputTokens * 15) / 1e6;
@@ -27109,4 +27149,4 @@ humanize-ms/index.js:
27109
27149
  * MIT Licensed
27110
27150
  *)
27111
27151
  */
27112
- //# sourceMappingURL=dist-UYIQ42TA.js.map
27152
+ //# sourceMappingURL=dist-PJEEL7WQ.js.map