@blockrun/clawrouter 0.12.56 → 0.12.61
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/README.md +93 -51
- package/dist/cli.js +456 -68
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +34 -0
- package/dist/index.js +601 -84
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/reinstall.sh +96 -17
- package/scripts/update.sh +93 -17
package/dist/index.d.ts
CHANGED
|
@@ -522,6 +522,7 @@ type SessionEntry = {
|
|
|
522
522
|
recentHashes: string[];
|
|
523
523
|
strikes: number;
|
|
524
524
|
escalated: boolean;
|
|
525
|
+
sessionCostMicros: bigint;
|
|
525
526
|
};
|
|
526
527
|
type SessionConfig = {
|
|
527
528
|
/** Enable session persistence (default: false) */
|
|
@@ -590,6 +591,17 @@ declare class SessionStore {
|
|
|
590
591
|
model: string;
|
|
591
592
|
tier: string;
|
|
592
593
|
} | null;
|
|
594
|
+
/**
|
|
595
|
+
* Add cost to a session's running total for maxCostPerRun tracking.
|
|
596
|
+
* Cost is in USDC 6-decimal units (micros).
|
|
597
|
+
* Creates a cost-tracking-only entry if none exists (e.g., explicit model requests
|
|
598
|
+
* that never go through the routing path).
|
|
599
|
+
*/
|
|
600
|
+
addSessionCost(sessionId: string, additionalMicros: bigint): void;
|
|
601
|
+
/**
|
|
602
|
+
* Get the total accumulated cost for a session in USD.
|
|
603
|
+
*/
|
|
604
|
+
getSessionCostUsd(sessionId: string): number;
|
|
593
605
|
/**
|
|
594
606
|
* Stop the cleanup interval.
|
|
595
607
|
*/
|
|
@@ -669,6 +681,8 @@ type ProxyOptions = {
|
|
|
669
681
|
requestTimeoutMs?: number;
|
|
670
682
|
/** Skip balance checks (for testing only). Default: false */
|
|
671
683
|
skipBalanceCheck?: boolean;
|
|
684
|
+
/** Override the balance monitor with a mock (for testing only). */
|
|
685
|
+
_balanceMonitorOverride?: AnyBalanceMonitor;
|
|
672
686
|
/**
|
|
673
687
|
* Session persistence config. When enabled, maintains model selection
|
|
674
688
|
* across requests within a session to prevent mid-task model switching.
|
|
@@ -693,6 +707,24 @@ type ProxyOptions = {
|
|
|
693
707
|
* Default: enabled with 10 minute TTL, 200 max entries.
|
|
694
708
|
*/
|
|
695
709
|
cacheConfig?: ResponseCacheConfig;
|
|
710
|
+
/**
|
|
711
|
+
* Maximum total spend (in USD) per session run.
|
|
712
|
+
* Default: undefined (no limit). Example: 0.5 = $0.50 per session.
|
|
713
|
+
*/
|
|
714
|
+
maxCostPerRunUsd?: number;
|
|
715
|
+
/**
|
|
716
|
+
* How to enforce the per-run cost cap.
|
|
717
|
+
* - 'graceful' (default): when budget runs low, downgrade to cheaper models; use free model
|
|
718
|
+
* as last resort. Only hard-stops when no model can serve the request.
|
|
719
|
+
* - 'strict': immediately return 429 once the session spend reaches the cap.
|
|
720
|
+
*/
|
|
721
|
+
maxCostPerRunMode?: "graceful" | "strict";
|
|
722
|
+
/**
|
|
723
|
+
* Set of model IDs to exclude from routing.
|
|
724
|
+
* Excluded models are filtered out of fallback chains.
|
|
725
|
+
* Loaded from ~/.openclaw/blockrun/exclude-models.json
|
|
726
|
+
*/
|
|
727
|
+
excludeModels?: Set<string>;
|
|
696
728
|
onReady?: (port: number) => void;
|
|
697
729
|
onError?: (error: Error) => void;
|
|
698
730
|
onPayment?: (info: {
|
|
@@ -889,6 +921,8 @@ type UsageEntry = {
|
|
|
889
921
|
latencyMs: number;
|
|
890
922
|
/** Input (prompt) tokens reported by the provider */
|
|
891
923
|
inputTokens?: number;
|
|
924
|
+
/** Output (completion) tokens reported by the provider */
|
|
925
|
+
outputTokens?: number;
|
|
892
926
|
/** Partner service ID (e.g., "x_users_lookup") — only set for partner API calls */
|
|
893
927
|
partnerId?: string;
|
|
894
928
|
/** Partner service name (e.g., "AttentionVC") — only set for partner API calls */
|