@blockrun/clawrouter 0.12.8 → 0.12.10

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.d.ts CHANGED
@@ -1284,6 +1284,12 @@ declare function getStats(days?: number): Promise<AggregatedStats>;
1284
1284
  * Format stats as ASCII table for terminal display.
1285
1285
  */
1286
1286
  declare function formatStatsAscii(stats: AggregatedStats): string;
1287
+ /**
1288
+ * Delete all usage log files, resetting stats to zero.
1289
+ */
1290
+ declare function clearStats(): Promise<{
1291
+ deletedFiles: number;
1292
+ }>;
1287
1293
 
1288
1294
  /**
1289
1295
  * Partner Service Registry
@@ -1381,4 +1387,4 @@ declare function buildPartnerTools(proxyBaseUrl: string): PartnerToolDefinition[
1381
1387
 
1382
1388
  declare const plugin: OpenClawPluginDefinition;
1383
1389
 
1384
- export { type AggregatedStats, BALANCE_THRESHOLDS, BLOCKRUN_MODELS, type BalanceInfo, BalanceMonitor, type CachedLLMResponse, type CachedResponse, type CheckResult, DEFAULT_RETRY_CONFIG, DEFAULT_ROUTING_CONFIG, DEFAULT_SESSION_CONFIG, type DailyStats, type DerivedKeys, EmptyWalletError, FileSpendControlStorage, InMemorySpendControlStorage, InsufficientFundsError, type InsufficientFundsInfo, type LowBalanceInfo, MODEL_ALIASES, OPENCLAW_MODELS, PARTNER_SERVICES, type PartnerServiceDefinition, type PartnerToolDefinition, type PaymentChain, type ProxyHandle, type ProxyOptions, RequestDeduplicator, ResponseCache, type ResponseCacheConfig, type RetryConfig, type RoutingConfig, type RoutingDecision, RpcError, type SessionConfig, type SessionEntry, SessionStore, type SolanaBalanceInfo, SolanaBalanceMonitor, SpendControl, type SpendControlOptions, type SpendControlStorage, type SpendLimits, type SpendRecord, type SpendWindow, type SpendingStatus, type SufficiencyResult, type SweepError, type SweepResult, type Tier, type UsageEntry, type WalletConfig, type WalletResolution, blockrunProvider, buildPartnerTools, buildProviderModels, calculateModelCost, plugin as default, deriveAllKeys, deriveEvmKey, deriveSolanaKeyBytes, deriveSolanaKeyBytesLegacy, fetchWithRetry, formatDuration, formatStatsAscii, generateWalletMnemonic, getAgenticModels, getFallbackChain, getFallbackChainFiltered, getModelContextWindow, getPartnerService, getProxyPort, getSessionId, getStats, hashRequestContent, isAgenticModel, isBalanceError, isEmptyWalletError, isInsufficientFundsError, isRetryable, isRpcError, isValidMnemonic, loadPaymentChain, logUsage, resolveModelAlias, resolvePaymentChain, route, savePaymentChain, setupSolana, startProxy, sweepSolanaWallet };
1390
+ export { type AggregatedStats, BALANCE_THRESHOLDS, BLOCKRUN_MODELS, type BalanceInfo, BalanceMonitor, type CachedLLMResponse, type CachedResponse, type CheckResult, DEFAULT_RETRY_CONFIG, DEFAULT_ROUTING_CONFIG, DEFAULT_SESSION_CONFIG, type DailyStats, type DerivedKeys, EmptyWalletError, FileSpendControlStorage, InMemorySpendControlStorage, InsufficientFundsError, type InsufficientFundsInfo, type LowBalanceInfo, MODEL_ALIASES, OPENCLAW_MODELS, PARTNER_SERVICES, type PartnerServiceDefinition, type PartnerToolDefinition, type PaymentChain, type ProxyHandle, type ProxyOptions, RequestDeduplicator, ResponseCache, type ResponseCacheConfig, type RetryConfig, type RoutingConfig, type RoutingDecision, RpcError, type SessionConfig, type SessionEntry, SessionStore, type SolanaBalanceInfo, SolanaBalanceMonitor, SpendControl, type SpendControlOptions, type SpendControlStorage, type SpendLimits, type SpendRecord, type SpendWindow, type SpendingStatus, type SufficiencyResult, type SweepError, type SweepResult, type Tier, type UsageEntry, type WalletConfig, type WalletResolution, blockrunProvider, buildPartnerTools, buildProviderModels, calculateModelCost, clearStats, plugin as default, deriveAllKeys, deriveEvmKey, deriveSolanaKeyBytes, deriveSolanaKeyBytesLegacy, fetchWithRetry, formatDuration, formatStatsAscii, generateWalletMnemonic, getAgenticModels, getFallbackChain, getFallbackChainFiltered, getModelContextWindow, getPartnerService, getProxyPort, getSessionId, getStats, hashRequestContent, isAgenticModel, isBalanceError, isEmptyWalletError, isInsufficientFundsError, isRetryable, isRpcError, isValidMnemonic, loadPaymentChain, logUsage, resolveModelAlias, resolvePaymentChain, route, savePaymentChain, setupSolana, startProxy, sweepSolanaWallet };
package/dist/index.js CHANGED
@@ -1323,8 +1323,7 @@ var BLOCKRUN_MODELS = [
1323
1323
  outputPrice: 3,
1324
1324
  contextWindow: 1e6,
1325
1325
  maxOutput: 65536,
1326
- vision: true,
1327
- toolCalling: true
1326
+ vision: true
1328
1327
  },
1329
1328
  {
1330
1329
  id: "google/gemini-2.5-pro",
@@ -3306,7 +3305,7 @@ async function logUsage(entry) {
3306
3305
  }
3307
3306
 
3308
3307
  // src/stats.ts
3309
- import { readdir } from "fs/promises";
3308
+ import { readdir, unlink } from "fs/promises";
3310
3309
 
3311
3310
  // src/fs-read.ts
3312
3311
  import { open } from "fs/promises";
@@ -3546,6 +3545,16 @@ function formatStatsAscii(stats) {
3546
3545
  lines.push("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D");
3547
3546
  return lines.join("\n");
3548
3547
  }
3548
+ async function clearStats() {
3549
+ try {
3550
+ const files = await readdir(LOG_DIR2);
3551
+ const logFiles = files.filter((f) => f.startsWith("usage-") && f.endsWith(".jsonl"));
3552
+ await Promise.all(logFiles.map((f) => unlink(join3(LOG_DIR2, f))));
3553
+ return { deletedFiles: logFiles.length };
3554
+ } catch {
3555
+ return { deletedFiles: 0 };
3556
+ }
3557
+ }
3549
3558
 
3550
3559
  // src/dedup.ts
3551
3560
  import { createHash } from "crypto";
@@ -6132,6 +6141,21 @@ async function startProxy(options) {
6132
6141
  res.end(JSON.stringify(stats, null, 2));
6133
6142
  return;
6134
6143
  }
6144
+ if (req.url === "/stats" && req.method === "DELETE") {
6145
+ try {
6146
+ const result = await clearStats();
6147
+ res.writeHead(200, { "Content-Type": "application/json" });
6148
+ res.end(JSON.stringify({ cleared: true, deletedFiles: result.deletedFiles }));
6149
+ } catch (err) {
6150
+ res.writeHead(500, { "Content-Type": "application/json" });
6151
+ res.end(
6152
+ JSON.stringify({
6153
+ error: `Failed to clear stats: ${err instanceof Error ? err.message : String(err)}`
6154
+ })
6155
+ );
6156
+ }
6157
+ return;
6158
+ }
6135
6159
  if (req.url === "/stats" || req.url?.startsWith("/stats?")) {
6136
6160
  try {
6137
6161
  const url = new URL(req.url, "http://localhost");
@@ -7129,7 +7153,11 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
7129
7153
  `[ClawRouter] Tool-calling filter: excluded ${toolExcluded.join(", ")} (no structured function call support)`
7130
7154
  );
7131
7155
  }
7132
- const TOOL_NONCOMPLIANT_MODELS = ["google/gemini-2.5-flash-lite"];
7156
+ const TOOL_NONCOMPLIANT_MODELS = [
7157
+ "google/gemini-2.5-flash-lite",
7158
+ "google/gemini-3-pro-preview",
7159
+ "google/gemini-3.1-pro"
7160
+ ];
7133
7161
  if (hasTools && toolFiltered.length > 1) {
7134
7162
  const compliant = toolFiltered.filter((m) => !TOOL_NONCOMPLIANT_MODELS.includes(m));
7135
7163
  if (compliant.length > 0 && compliant.length < toolFiltered.length) {
@@ -8290,6 +8318,19 @@ async function createStatsCommand() {
8290
8318
  requireAuth: false,
8291
8319
  handler: async (ctx) => {
8292
8320
  const arg = ctx.args?.trim().toLowerCase() || "7";
8321
+ if (arg === "clear" || arg === "reset") {
8322
+ try {
8323
+ const { deletedFiles } = await clearStats();
8324
+ return {
8325
+ text: `Stats cleared \u2014 ${deletedFiles} log file(s) deleted. Fresh start!`
8326
+ };
8327
+ } catch (err) {
8328
+ return {
8329
+ text: `Failed to clear stats: ${err instanceof Error ? err.message : String(err)}`,
8330
+ isError: true
8331
+ };
8332
+ }
8333
+ }
8293
8334
  const days = parseInt(arg, 10) || 7;
8294
8335
  try {
8295
8336
  const stats = await getStats(Math.min(days, 30));
@@ -8758,6 +8799,7 @@ export {
8758
8799
  buildPartnerTools,
8759
8800
  buildProviderModels,
8760
8801
  calculateModelCost,
8802
+ clearStats,
8761
8803
  index_default as default,
8762
8804
  deriveAllKeys,
8763
8805
  deriveEvmKey,