@blockrun/clawrouter 0.12.46 → 0.12.47
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/cli.js +18 -18
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -42
- package/dist/index.js +34 -349
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1087,52 +1087,11 @@ declare function deriveEvmKey(mnemonic: string): {
|
|
|
1087
1087
|
* 3. Final IL (32 bytes) = Ed25519 private key seed
|
|
1088
1088
|
*/
|
|
1089
1089
|
declare function deriveSolanaKeyBytes(mnemonic: string): Uint8Array;
|
|
1090
|
-
/**
|
|
1091
|
-
* Legacy Solana key derivation using secp256k1 BIP-32 (incorrect for Solana).
|
|
1092
|
-
* Kept for migration: sweeping funds from wallets derived with the old method.
|
|
1093
|
-
*/
|
|
1094
|
-
declare function deriveSolanaKeyBytesLegacy(mnemonic: string): Uint8Array;
|
|
1095
1090
|
/**
|
|
1096
1091
|
* Derive both EVM and Solana keys from a single mnemonic.
|
|
1097
1092
|
*/
|
|
1098
1093
|
declare function deriveAllKeys(mnemonic: string): DerivedKeys;
|
|
1099
1094
|
|
|
1100
|
-
/**
|
|
1101
|
-
* Solana Wallet Sweep — migrate USDC from legacy (secp256k1) to new (SLIP-10) wallet.
|
|
1102
|
-
*
|
|
1103
|
-
* Used when upgrading from the old BIP-32 secp256k1 derivation to correct
|
|
1104
|
-
* SLIP-10 Ed25519 derivation. Transfers all USDC from the old address to the new one.
|
|
1105
|
-
*
|
|
1106
|
-
* Uses raw instruction encoding to avoid @solana-program/token dependency.
|
|
1107
|
-
*/
|
|
1108
|
-
type SweepResult = {
|
|
1109
|
-
transferred: string;
|
|
1110
|
-
transferredMicros: bigint;
|
|
1111
|
-
txSignature: string;
|
|
1112
|
-
oldAddress: string;
|
|
1113
|
-
newAddress: string;
|
|
1114
|
-
};
|
|
1115
|
-
type SweepError = {
|
|
1116
|
-
error: string;
|
|
1117
|
-
oldAddress: string;
|
|
1118
|
-
newAddress?: string;
|
|
1119
|
-
solBalance?: bigint;
|
|
1120
|
-
usdcBalance?: bigint;
|
|
1121
|
-
};
|
|
1122
|
-
/**
|
|
1123
|
-
* Sweep all USDC from old (legacy secp256k1) wallet to new (SLIP-10) wallet.
|
|
1124
|
-
*
|
|
1125
|
-
* The NEW wallet pays gas fees (not the old one). Users can't access the old
|
|
1126
|
-
* wallet from Phantom/Solflare, so they can't send SOL to it. Instead they
|
|
1127
|
-
* fund the new (Phantom-compatible) wallet with a tiny bit of SOL for gas.
|
|
1128
|
-
*
|
|
1129
|
-
* @param oldKeyBytes - 32-byte private key from legacy derivation
|
|
1130
|
-
* @param newKeyBytes - 32-byte private key from SLIP-10 derivation (pays gas)
|
|
1131
|
-
* @param rpcUrl - Optional RPC URL override
|
|
1132
|
-
* @returns SweepResult on success, SweepError on failure
|
|
1133
|
-
*/
|
|
1134
|
-
declare function sweepSolanaWallet(oldKeyBytes: Uint8Array, newKeyBytes: Uint8Array, rpcUrl?: string): Promise<SweepResult | SweepError>;
|
|
1135
|
-
|
|
1136
1095
|
/**
|
|
1137
1096
|
* Typed Error Classes for ClawRouter
|
|
1138
1097
|
*
|
|
@@ -1384,4 +1343,4 @@ declare function buildPartnerTools(proxyBaseUrl: string): PartnerToolDefinition[
|
|
|
1384
1343
|
|
|
1385
1344
|
declare const plugin: OpenClawPluginDefinition;
|
|
1386
1345
|
|
|
1387
|
-
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
|
|
1346
|
+
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 Tier, type UsageEntry, type WalletConfig, type WalletResolution, blockrunProvider, buildPartnerTools, buildProviderModels, calculateModelCost, clearStats, plugin as default, deriveAllKeys, deriveEvmKey, deriveSolanaKeyBytes, 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 };
|
package/dist/index.js
CHANGED
|
@@ -547,7 +547,6 @@ __export(wallet_exports, {
|
|
|
547
547
|
deriveAllKeys: () => deriveAllKeys,
|
|
548
548
|
deriveEvmKey: () => deriveEvmKey,
|
|
549
549
|
deriveSolanaKeyBytes: () => deriveSolanaKeyBytes,
|
|
550
|
-
deriveSolanaKeyBytesLegacy: () => deriveSolanaKeyBytesLegacy,
|
|
551
550
|
generateWalletMnemonic: () => generateWalletMnemonic,
|
|
552
551
|
getSolanaAddress: () => getSolanaAddress,
|
|
553
552
|
isValidMnemonic: () => isValidMnemonic
|
|
@@ -590,21 +589,14 @@ function deriveSolanaKeyBytes(mnemonic) {
|
|
|
590
589
|
}
|
|
591
590
|
return new Uint8Array(key);
|
|
592
591
|
}
|
|
593
|
-
function deriveSolanaKeyBytesLegacy(mnemonic) {
|
|
594
|
-
const seed = mnemonicToSeedSync(mnemonic);
|
|
595
|
-
const hdKey = HDKey.fromMasterSeed(seed);
|
|
596
|
-
const derived = hdKey.derive("m/44'/501'/0'/0'");
|
|
597
|
-
if (!derived.privateKey) throw new Error("Failed to derive legacy Solana private key");
|
|
598
|
-
return new Uint8Array(derived.privateKey);
|
|
599
|
-
}
|
|
600
592
|
function deriveAllKeys(mnemonic) {
|
|
601
593
|
const { privateKey: evmPrivateKey, address: evmAddress } = deriveEvmKey(mnemonic);
|
|
602
594
|
const solanaPrivateKeyBytes = deriveSolanaKeyBytes(mnemonic);
|
|
603
595
|
return { mnemonic, evmPrivateKey, evmAddress, solanaPrivateKeyBytes };
|
|
604
596
|
}
|
|
605
597
|
async function getSolanaAddress(privateKeyBytes) {
|
|
606
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
607
|
-
const signer = await
|
|
598
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
599
|
+
const signer = await createKeyPairSignerFromPrivateKeyBytes(privateKeyBytes);
|
|
608
600
|
return signer.address;
|
|
609
601
|
}
|
|
610
602
|
var ETH_DERIVATION_PATH, SOLANA_HARDENED_INDICES;
|
|
@@ -737,227 +729,6 @@ var init_solana_balance = __esm({
|
|
|
737
729
|
}
|
|
738
730
|
});
|
|
739
731
|
|
|
740
|
-
// src/solana-sweep.ts
|
|
741
|
-
var solana_sweep_exports = {};
|
|
742
|
-
__export(solana_sweep_exports, {
|
|
743
|
-
sweepSolanaWallet: () => sweepSolanaWallet
|
|
744
|
-
});
|
|
745
|
-
import {
|
|
746
|
-
address as solAddress2,
|
|
747
|
-
createSolanaRpc as createSolanaRpc2,
|
|
748
|
-
createSolanaRpcSubscriptions,
|
|
749
|
-
createKeyPairSignerFromPrivateKeyBytes,
|
|
750
|
-
pipe,
|
|
751
|
-
createTransactionMessage,
|
|
752
|
-
setTransactionMessageFeePayer,
|
|
753
|
-
setTransactionMessageLifetimeUsingBlockhash,
|
|
754
|
-
appendTransactionMessageInstructions,
|
|
755
|
-
signTransactionMessageWithSigners,
|
|
756
|
-
addSignersToTransactionMessage,
|
|
757
|
-
getSignatureFromTransaction,
|
|
758
|
-
sendAndConfirmTransactionFactory,
|
|
759
|
-
getProgramDerivedAddress,
|
|
760
|
-
getAddressEncoder
|
|
761
|
-
} from "@solana/kit";
|
|
762
|
-
async function getAssociatedTokenAddress(owner, mint) {
|
|
763
|
-
const encoder = getAddressEncoder();
|
|
764
|
-
const [ata] = await getProgramDerivedAddress({
|
|
765
|
-
programAddress: ASSOCIATED_TOKEN_PROGRAM,
|
|
766
|
-
seeds: [encoder.encode(owner), encoder.encode(TOKEN_PROGRAM), encoder.encode(mint)]
|
|
767
|
-
});
|
|
768
|
-
return ata;
|
|
769
|
-
}
|
|
770
|
-
function buildCreateAtaIdempotentInstruction(payer, ata, owner, mint) {
|
|
771
|
-
return {
|
|
772
|
-
programAddress: ASSOCIATED_TOKEN_PROGRAM,
|
|
773
|
-
accounts: [
|
|
774
|
-
{
|
|
775
|
-
address: payer,
|
|
776
|
-
role: 3
|
|
777
|
-
/* writable signer */
|
|
778
|
-
},
|
|
779
|
-
{
|
|
780
|
-
address: ata,
|
|
781
|
-
role: 1
|
|
782
|
-
/* writable */
|
|
783
|
-
},
|
|
784
|
-
{
|
|
785
|
-
address: owner,
|
|
786
|
-
role: 0
|
|
787
|
-
/* readonly */
|
|
788
|
-
},
|
|
789
|
-
{
|
|
790
|
-
address: mint,
|
|
791
|
-
role: 0
|
|
792
|
-
/* readonly */
|
|
793
|
-
},
|
|
794
|
-
{
|
|
795
|
-
address: SYSTEM_PROGRAM,
|
|
796
|
-
role: 0
|
|
797
|
-
/* readonly */
|
|
798
|
-
},
|
|
799
|
-
{
|
|
800
|
-
address: TOKEN_PROGRAM,
|
|
801
|
-
role: 0
|
|
802
|
-
/* readonly */
|
|
803
|
-
}
|
|
804
|
-
],
|
|
805
|
-
data: new Uint8Array([1])
|
|
806
|
-
// instruction index 1 = CreateIdempotent
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
function buildTokenTransferInstruction(source, destination, authority, amount) {
|
|
810
|
-
const data = new Uint8Array(9);
|
|
811
|
-
data[0] = 3;
|
|
812
|
-
const view = new DataView(data.buffer, data.byteOffset);
|
|
813
|
-
view.setBigUint64(1, amount, true);
|
|
814
|
-
return {
|
|
815
|
-
programAddress: TOKEN_PROGRAM,
|
|
816
|
-
accounts: [
|
|
817
|
-
{
|
|
818
|
-
address: source,
|
|
819
|
-
role: 1
|
|
820
|
-
/* writable */
|
|
821
|
-
},
|
|
822
|
-
{
|
|
823
|
-
address: destination,
|
|
824
|
-
role: 1
|
|
825
|
-
/* writable */
|
|
826
|
-
},
|
|
827
|
-
{
|
|
828
|
-
address: authority,
|
|
829
|
-
role: 2
|
|
830
|
-
/* signer */
|
|
831
|
-
}
|
|
832
|
-
],
|
|
833
|
-
data
|
|
834
|
-
};
|
|
835
|
-
}
|
|
836
|
-
async function sweepSolanaWallet(oldKeyBytes, newKeyBytes, rpcUrl) {
|
|
837
|
-
const url = rpcUrl || process["env"].CLAWROUTER_SOLANA_RPC_URL || SOLANA_DEFAULT_RPC2;
|
|
838
|
-
const rpc = createSolanaRpc2(url);
|
|
839
|
-
const [oldSigner, newSigner] = await Promise.all([
|
|
840
|
-
createKeyPairSignerFromPrivateKeyBytes(oldKeyBytes),
|
|
841
|
-
createKeyPairSignerFromPrivateKeyBytes(newKeyBytes)
|
|
842
|
-
]);
|
|
843
|
-
const oldAddress = oldSigner.address;
|
|
844
|
-
const newAddress = newSigner.address;
|
|
845
|
-
const mint = solAddress2(SOLANA_USDC_MINT2);
|
|
846
|
-
let newSolBalance;
|
|
847
|
-
try {
|
|
848
|
-
const solResp = await rpc.getBalance(solAddress2(newAddress)).send();
|
|
849
|
-
newSolBalance = solResp.value;
|
|
850
|
-
} catch (err) {
|
|
851
|
-
return {
|
|
852
|
-
error: `Failed to check SOL balance: ${err instanceof Error ? err.message : String(err)}`,
|
|
853
|
-
oldAddress,
|
|
854
|
-
newAddress
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
|
-
let usdcBalance = 0n;
|
|
858
|
-
const oldTokenAccounts = [];
|
|
859
|
-
try {
|
|
860
|
-
const response = await rpc.getTokenAccountsByOwner(solAddress2(oldAddress), { mint }, { encoding: "jsonParsed" }).send();
|
|
861
|
-
if (response.value.length > 0) {
|
|
862
|
-
for (const account of response.value) {
|
|
863
|
-
const parsed = account.account.data;
|
|
864
|
-
const amount = BigInt(parsed.parsed.info.tokenAmount.amount);
|
|
865
|
-
if (amount > 0n) {
|
|
866
|
-
usdcBalance += amount;
|
|
867
|
-
oldTokenAccounts.push({ pubkey: account.pubkey, amount });
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
} catch (err) {
|
|
872
|
-
return {
|
|
873
|
-
error: `Failed to check USDC balance: ${err instanceof Error ? err.message : String(err)}`,
|
|
874
|
-
oldAddress,
|
|
875
|
-
newAddress
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
if (usdcBalance === 0n) {
|
|
879
|
-
return {
|
|
880
|
-
error: "No USDC found in old wallet. Nothing to sweep.",
|
|
881
|
-
oldAddress,
|
|
882
|
-
newAddress,
|
|
883
|
-
solBalance: newSolBalance,
|
|
884
|
-
usdcBalance: 0n
|
|
885
|
-
};
|
|
886
|
-
}
|
|
887
|
-
const MIN_SOL_FOR_GAS = 5000000n;
|
|
888
|
-
if (newSolBalance < MIN_SOL_FOR_GAS) {
|
|
889
|
-
const needed = Number(MIN_SOL_FOR_GAS - newSolBalance) / 1e9;
|
|
890
|
-
return {
|
|
891
|
-
error: `Insufficient SOL for transaction fees in your new wallet. Send ~${needed.toFixed(4)} SOL to ${newAddress} (your new Phantom-compatible address) to cover gas. Current SOL balance: ${(Number(newSolBalance) / 1e9).toFixed(6)} SOL`,
|
|
892
|
-
oldAddress,
|
|
893
|
-
newAddress,
|
|
894
|
-
solBalance: newSolBalance,
|
|
895
|
-
usdcBalance
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
try {
|
|
899
|
-
const newAta = await getAssociatedTokenAddress(solAddress2(newAddress), mint);
|
|
900
|
-
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
901
|
-
const createAtaIx = buildCreateAtaIdempotentInstruction(
|
|
902
|
-
newSigner.address,
|
|
903
|
-
// new wallet pays for ATA creation
|
|
904
|
-
newAta,
|
|
905
|
-
solAddress2(newAddress),
|
|
906
|
-
mint
|
|
907
|
-
);
|
|
908
|
-
const transferIxs = oldTokenAccounts.map(
|
|
909
|
-
(acct) => buildTokenTransferInstruction(
|
|
910
|
-
solAddress2(acct.pubkey),
|
|
911
|
-
newAta,
|
|
912
|
-
oldSigner.address,
|
|
913
|
-
// old wallet authorizes the token transfer
|
|
914
|
-
acct.amount
|
|
915
|
-
)
|
|
916
|
-
);
|
|
917
|
-
const txMessage = pipe(
|
|
918
|
-
createTransactionMessage({ version: 0 }),
|
|
919
|
-
(msg) => setTransactionMessageFeePayer(newSigner.address, msg),
|
|
920
|
-
// new wallet pays gas
|
|
921
|
-
(msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg),
|
|
922
|
-
(msg) => appendTransactionMessageInstructions([createAtaIx, ...transferIxs], msg)
|
|
923
|
-
);
|
|
924
|
-
const txMessageWithSigners = addSignersToTransactionMessage([newSigner, oldSigner], txMessage);
|
|
925
|
-
const signedTx = await signTransactionMessageWithSigners(txMessageWithSigners);
|
|
926
|
-
const txSignature = getSignatureFromTransaction(signedTx);
|
|
927
|
-
const wsUrl = url.replace("https://", "wss://").replace("http://", "ws://");
|
|
928
|
-
const rpcSubscriptions = createSolanaRpcSubscriptions(wsUrl);
|
|
929
|
-
const sendAndConfirm = sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions });
|
|
930
|
-
await sendAndConfirm(signedTx, { commitment: "confirmed" });
|
|
931
|
-
const dollars = Number(usdcBalance) / 1e6;
|
|
932
|
-
return {
|
|
933
|
-
transferred: `$${dollars.toFixed(2)}`,
|
|
934
|
-
transferredMicros: usdcBalance,
|
|
935
|
-
txSignature,
|
|
936
|
-
oldAddress,
|
|
937
|
-
newAddress
|
|
938
|
-
};
|
|
939
|
-
} catch (err) {
|
|
940
|
-
return {
|
|
941
|
-
error: `Transaction failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
942
|
-
oldAddress,
|
|
943
|
-
newAddress,
|
|
944
|
-
solBalance: newSolBalance,
|
|
945
|
-
usdcBalance
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
var SOLANA_USDC_MINT2, SOLANA_DEFAULT_RPC2, TOKEN_PROGRAM, ASSOCIATED_TOKEN_PROGRAM, SYSTEM_PROGRAM;
|
|
950
|
-
var init_solana_sweep = __esm({
|
|
951
|
-
"src/solana-sweep.ts"() {
|
|
952
|
-
"use strict";
|
|
953
|
-
SOLANA_USDC_MINT2 = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
954
|
-
SOLANA_DEFAULT_RPC2 = "https://api.mainnet-beta.solana.com";
|
|
955
|
-
TOKEN_PROGRAM = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
956
|
-
ASSOCIATED_TOKEN_PROGRAM = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
957
|
-
SYSTEM_PROGRAM = "11111111111111111111111111111111";
|
|
958
|
-
}
|
|
959
|
-
});
|
|
960
|
-
|
|
961
732
|
// src/models.ts
|
|
962
733
|
var MODEL_ALIASES = {
|
|
963
734
|
// Claude - use newest versions (4.6)
|
|
@@ -3157,36 +2928,36 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
3157
2928
|
confidenceThreshold: 0.7
|
|
3158
2929
|
},
|
|
3159
2930
|
// Auto (balanced) tier configs - current default smart routing
|
|
3160
|
-
// Benchmark-tuned 2026-03-16:
|
|
2931
|
+
// Benchmark-tuned 2026-03-16: balancing quality (retention) + latency
|
|
3161
2932
|
tiers: {
|
|
3162
2933
|
SIMPLE: {
|
|
3163
|
-
primary: "
|
|
3164
|
-
// 1,
|
|
2934
|
+
primary: "google/gemini-2.5-flash",
|
|
2935
|
+
// 1,238ms, 60% retention (best) — fast AND quality
|
|
3165
2936
|
fallback: [
|
|
3166
|
-
"xai/grok-3-mini",
|
|
3167
|
-
// 1,202ms, $0.30/$0.50
|
|
3168
|
-
"google/gemini-2.5-flash",
|
|
3169
|
-
// 1,238ms, 60% retention (best)
|
|
3170
|
-
"google/gemini-2.5-flash-lite",
|
|
3171
|
-
// 1,353ms, 1M context, ultra cheap ($0.10/$0.40)
|
|
3172
2937
|
"deepseek/deepseek-chat",
|
|
3173
2938
|
// 1,431ms, 41% retention
|
|
2939
|
+
"moonshot/kimi-k2.5",
|
|
2940
|
+
// 1,646ms, strong quality
|
|
2941
|
+
"google/gemini-2.5-flash-lite",
|
|
2942
|
+
// 1,353ms, 1M context, ultra cheap ($0.10/$0.40)
|
|
2943
|
+
"xai/grok-4-fast-non-reasoning",
|
|
2944
|
+
// 1,143ms, $0.20/$0.50 — fast fallback
|
|
3174
2945
|
"nvidia/gpt-oss-120b"
|
|
3175
2946
|
// 1,252ms, FREE fallback
|
|
3176
2947
|
]
|
|
3177
2948
|
},
|
|
3178
2949
|
MEDIUM: {
|
|
3179
|
-
primary: "
|
|
3180
|
-
// 1,
|
|
2950
|
+
primary: "moonshot/kimi-k2.5",
|
|
2951
|
+
// 1,646ms, $0.60/$3.00 — strong tool use, quality output
|
|
3181
2952
|
fallback: [
|
|
3182
2953
|
"deepseek/deepseek-chat",
|
|
3183
2954
|
// 1,431ms, 41% retention
|
|
3184
|
-
"moonshot/kimi-k2.5",
|
|
3185
|
-
// 1,646ms, strong tool use quality
|
|
3186
2955
|
"google/gemini-2.5-flash",
|
|
3187
2956
|
// 1,238ms, 60% retention
|
|
3188
2957
|
"google/gemini-2.5-flash-lite",
|
|
3189
2958
|
// 1,353ms, 1M context ($0.10/$0.40)
|
|
2959
|
+
"xai/grok-4-1-fast-non-reasoning",
|
|
2960
|
+
// 1,244ms, fast fallback
|
|
3190
2961
|
"xai/grok-3-mini"
|
|
3191
2962
|
// 1,202ms, $0.30/$0.50
|
|
3192
2963
|
]
|
|
@@ -3317,15 +3088,15 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
3317
3088
|
// Agentic tier configs - models that excel at multi-step autonomous tasks
|
|
3318
3089
|
agenticTiers: {
|
|
3319
3090
|
SIMPLE: {
|
|
3320
|
-
primary: "
|
|
3321
|
-
//
|
|
3091
|
+
primary: "openai/gpt-4o-mini",
|
|
3092
|
+
// $0.15/$0.60 - best tool compliance at lowest cost
|
|
3322
3093
|
fallback: [
|
|
3323
|
-
"openai/gpt-4o-mini",
|
|
3324
|
-
// 2,764ms, $0.15/$0.60 - reliable tool compliance
|
|
3325
3094
|
"moonshot/kimi-k2.5",
|
|
3326
3095
|
// 1,646ms, strong tool use quality
|
|
3327
|
-
"anthropic/claude-haiku-4.5"
|
|
3096
|
+
"anthropic/claude-haiku-4.5",
|
|
3328
3097
|
// 2,305ms
|
|
3098
|
+
"xai/grok-4-1-fast-non-reasoning"
|
|
3099
|
+
// 1,244ms, fast fallback
|
|
3329
3100
|
]
|
|
3330
3101
|
},
|
|
3331
3102
|
MEDIUM: {
|
|
@@ -6229,8 +6000,8 @@ async function startProxy(options) {
|
|
|
6229
6000
|
}
|
|
6230
6001
|
let reuseSolanaAddress;
|
|
6231
6002
|
if (solanaPrivateKeyBytes) {
|
|
6232
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
6233
|
-
const solanaSigner = await
|
|
6003
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
6004
|
+
const solanaSigner = await createKeyPairSignerFromPrivateKeyBytes(solanaPrivateKeyBytes);
|
|
6234
6005
|
reuseSolanaAddress = solanaSigner.address;
|
|
6235
6006
|
}
|
|
6236
6007
|
let balanceMonitor2;
|
|
@@ -6259,8 +6030,8 @@ async function startProxy(options) {
|
|
|
6259
6030
|
let solanaAddress;
|
|
6260
6031
|
if (solanaPrivateKeyBytes) {
|
|
6261
6032
|
const { registerExactSvmScheme } = await import("@x402/svm/exact/client");
|
|
6262
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
6263
|
-
const solanaSigner = await
|
|
6033
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
6034
|
+
const solanaSigner = await createKeyPairSignerFromPrivateKeyBytes(solanaPrivateKeyBytes);
|
|
6264
6035
|
solanaAddress = solanaSigner.address;
|
|
6265
6036
|
registerExactSvmScheme(x402, { signer: solanaSigner });
|
|
6266
6037
|
console.log(`[ClawRouter] Solana wallet: ${solanaAddress}`);
|
|
@@ -8528,7 +8299,6 @@ function formatDuration(seconds) {
|
|
|
8528
8299
|
|
|
8529
8300
|
// src/index.ts
|
|
8530
8301
|
init_wallet();
|
|
8531
|
-
init_solana_sweep();
|
|
8532
8302
|
|
|
8533
8303
|
// src/retry.ts
|
|
8534
8304
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -8988,8 +8758,8 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
8988
8758
|
hasMnemonic = true;
|
|
8989
8759
|
const { deriveSolanaKeyBytes: deriveSolanaKeyBytes2 } = await Promise.resolve().then(() => (init_wallet(), wallet_exports));
|
|
8990
8760
|
const solKeyBytes = deriveSolanaKeyBytes2(mnemonic);
|
|
8991
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
8992
|
-
const signer = await
|
|
8761
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
8762
|
+
const signer = await createKeyPairSignerFromPrivateKeyBytes(solKeyBytes);
|
|
8993
8763
|
lines.push(
|
|
8994
8764
|
"",
|
|
8995
8765
|
"**Solana:**",
|
|
@@ -9030,8 +8800,8 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
9030
8800
|
await savePaymentChain("solana");
|
|
9031
8801
|
const { deriveSolanaKeyBytes: deriveSolanaKeyBytes2 } = await Promise.resolve().then(() => (init_wallet(), wallet_exports));
|
|
9032
8802
|
const solKeyBytes = deriveSolanaKeyBytes2(existingMnemonic);
|
|
9033
|
-
const { createKeyPairSignerFromPrivateKeyBytes:
|
|
9034
|
-
const signer2 = await
|
|
8803
|
+
const { createKeyPairSignerFromPrivateKeyBytes: createKeyPairSignerFromPrivateKeyBytes2 } = await import("@solana/kit");
|
|
8804
|
+
const signer2 = await createKeyPairSignerFromPrivateKeyBytes2(solKeyBytes);
|
|
9035
8805
|
solanaAddr = signer2.address;
|
|
9036
8806
|
return {
|
|
9037
8807
|
text: [
|
|
@@ -9045,8 +8815,8 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
9045
8815
|
}
|
|
9046
8816
|
const { solanaPrivateKeyBytes } = await setupSolana();
|
|
9047
8817
|
await savePaymentChain("solana");
|
|
9048
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
9049
|
-
const signer = await
|
|
8818
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
8819
|
+
const signer = await createKeyPairSignerFromPrivateKeyBytes(solanaPrivateKeyBytes);
|
|
9050
8820
|
return {
|
|
9051
8821
|
text: [
|
|
9052
8822
|
"**Solana Wallet Set Up**",
|
|
@@ -9067,88 +8837,6 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
9067
8837
|
};
|
|
9068
8838
|
}
|
|
9069
8839
|
}
|
|
9070
|
-
if (subcommand === "migrate-solana") {
|
|
9071
|
-
try {
|
|
9072
|
-
if (!existsSync3(MNEMONIC_FILE)) {
|
|
9073
|
-
return {
|
|
9074
|
-
text: "No mnemonic file found. Solana wallet not set up \u2014 nothing to migrate.",
|
|
9075
|
-
isError: true
|
|
9076
|
-
};
|
|
9077
|
-
}
|
|
9078
|
-
const mnemonic = readTextFileSync(MNEMONIC_FILE).trim();
|
|
9079
|
-
if (!mnemonic) {
|
|
9080
|
-
return { text: "Mnemonic file is empty.", isError: true };
|
|
9081
|
-
}
|
|
9082
|
-
const { deriveSolanaKeyBytes: deriveSolanaKeyBytes2, deriveSolanaKeyBytesLegacy: deriveSolanaKeyBytesLegacy2 } = await Promise.resolve().then(() => (init_wallet(), wallet_exports));
|
|
9083
|
-
const { createKeyPairSignerFromPrivateKeyBytes: createKeyPairSignerFromPrivateKeyBytes2 } = await import("@solana/kit");
|
|
9084
|
-
const legacyKeyBytes = deriveSolanaKeyBytesLegacy2(mnemonic);
|
|
9085
|
-
const newKeyBytes = deriveSolanaKeyBytes2(mnemonic);
|
|
9086
|
-
const [oldSigner, newSigner] = await Promise.all([
|
|
9087
|
-
createKeyPairSignerFromPrivateKeyBytes2(legacyKeyBytes),
|
|
9088
|
-
createKeyPairSignerFromPrivateKeyBytes2(newKeyBytes)
|
|
9089
|
-
]);
|
|
9090
|
-
if (oldSigner.address === newSigner.address) {
|
|
9091
|
-
return { text: "Legacy and new Solana addresses are the same. No migration needed." };
|
|
9092
|
-
}
|
|
9093
|
-
let oldUsdcText = "unknown";
|
|
9094
|
-
try {
|
|
9095
|
-
const { SolanaBalanceMonitor: SolanaBalanceMonitor2 } = await Promise.resolve().then(() => (init_solana_balance(), solana_balance_exports));
|
|
9096
|
-
const monitor = new SolanaBalanceMonitor2(oldSigner.address);
|
|
9097
|
-
const balance = await monitor.checkBalance();
|
|
9098
|
-
oldUsdcText = balance.balanceUSD;
|
|
9099
|
-
if (balance.isEmpty) {
|
|
9100
|
-
return {
|
|
9101
|
-
text: [
|
|
9102
|
-
"**Solana Migration Status**",
|
|
9103
|
-
"",
|
|
9104
|
-
`Old wallet (secp256k1): \`${oldSigner.address}\``,
|
|
9105
|
-
` USDC: $0.00`,
|
|
9106
|
-
"",
|
|
9107
|
-
`New wallet (SLIP-10): \`${newSigner.address}\``,
|
|
9108
|
-
"",
|
|
9109
|
-
"No USDC in old wallet. Nothing to sweep.",
|
|
9110
|
-
"Your new SLIP-10 address is Phantom/Solflare compatible."
|
|
9111
|
-
].join("\n")
|
|
9112
|
-
};
|
|
9113
|
-
}
|
|
9114
|
-
} catch {
|
|
9115
|
-
}
|
|
9116
|
-
const { sweepSolanaWallet: sweepSolanaWallet2 } = await Promise.resolve().then(() => (init_solana_sweep(), solana_sweep_exports));
|
|
9117
|
-
const result = await sweepSolanaWallet2(legacyKeyBytes, newKeyBytes);
|
|
9118
|
-
if ("error" in result) {
|
|
9119
|
-
return {
|
|
9120
|
-
text: [
|
|
9121
|
-
"**Solana Migration Failed**",
|
|
9122
|
-
"",
|
|
9123
|
-
`Old wallet: \`${result.oldAddress}\` (USDC: ${oldUsdcText})`,
|
|
9124
|
-
`New wallet: \`${result.newAddress || newSigner.address}\``,
|
|
9125
|
-
"",
|
|
9126
|
-
`Error: ${result.error}`
|
|
9127
|
-
].join("\n"),
|
|
9128
|
-
isError: true
|
|
9129
|
-
};
|
|
9130
|
-
}
|
|
9131
|
-
return {
|
|
9132
|
-
text: [
|
|
9133
|
-
"**Solana Migration Complete**",
|
|
9134
|
-
"",
|
|
9135
|
-
`Swept **${result.transferred}** USDC from old to new wallet.`,
|
|
9136
|
-
"",
|
|
9137
|
-
`Old wallet: \`${result.oldAddress}\``,
|
|
9138
|
-
`New wallet: \`${result.newAddress}\``,
|
|
9139
|
-
`TX: https://solscan.io/tx/${result.txSignature}`,
|
|
9140
|
-
"",
|
|
9141
|
-
"Your new SLIP-10 address is Phantom/Solflare compatible.",
|
|
9142
|
-
"You can recover it from your 24-word mnemonic in any standard wallet."
|
|
9143
|
-
].join("\n")
|
|
9144
|
-
};
|
|
9145
|
-
} catch (err) {
|
|
9146
|
-
return {
|
|
9147
|
-
text: `Migration failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
9148
|
-
isError: true
|
|
9149
|
-
};
|
|
9150
|
-
}
|
|
9151
|
-
}
|
|
9152
8840
|
if (subcommand === "base") {
|
|
9153
8841
|
try {
|
|
9154
8842
|
await savePaymentChain("base");
|
|
@@ -9177,8 +8865,8 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
9177
8865
|
const mnemonic = readTextFileSync(MNEMONIC_FILE).trim();
|
|
9178
8866
|
if (mnemonic) {
|
|
9179
8867
|
const solKeyBytes = deriveSolanaKeyBytes2(mnemonic);
|
|
9180
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
9181
|
-
const signer = await
|
|
8868
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
8869
|
+
const signer = await createKeyPairSignerFromPrivateKeyBytes(solKeyBytes);
|
|
9182
8870
|
const solAddr = signer.address;
|
|
9183
8871
|
let solBalanceText = "Balance: (checking...)";
|
|
9184
8872
|
try {
|
|
@@ -9220,8 +8908,7 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
9220
8908
|
"\u2022 `/wallet export` - Export private key for backup",
|
|
9221
8909
|
!solanaSection ? "\u2022 `/wallet solana` - Enable Solana payments" : "",
|
|
9222
8910
|
solanaSection ? "\u2022 `/wallet base` - Switch to Base (EVM)" : "",
|
|
9223
|
-
solanaSection ? "\u2022 `/wallet solana` - Switch to Solana" : ""
|
|
9224
|
-
solanaSection ? "\u2022 `/wallet migrate-solana` - Sweep funds from old Solana wallet" : ""
|
|
8911
|
+
solanaSection ? "\u2022 `/wallet solana` - Switch to Solana" : ""
|
|
9225
8912
|
].filter(Boolean).join("\n")
|
|
9226
8913
|
};
|
|
9227
8914
|
}
|
|
@@ -9398,7 +9085,6 @@ export {
|
|
|
9398
9085
|
deriveAllKeys,
|
|
9399
9086
|
deriveEvmKey,
|
|
9400
9087
|
deriveSolanaKeyBytes,
|
|
9401
|
-
deriveSolanaKeyBytesLegacy,
|
|
9402
9088
|
fetchWithRetry,
|
|
9403
9089
|
formatDuration,
|
|
9404
9090
|
formatStatsAscii,
|
|
@@ -9426,8 +9112,7 @@ export {
|
|
|
9426
9112
|
route,
|
|
9427
9113
|
savePaymentChain,
|
|
9428
9114
|
setupSolana,
|
|
9429
|
-
startProxy
|
|
9430
|
-
sweepSolanaWallet
|
|
9115
|
+
startProxy
|
|
9431
9116
|
};
|
|
9432
9117
|
/*! Bundled license information:
|
|
9433
9118
|
|