@blockrun/clawrouter 0.12.45 → 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 +77 -51
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -42
- package/dist/index.js +93 -382
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/benchmark.py +100 -178
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,63 +2928,74 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
3157
2928
|
confidenceThreshold: 0.7
|
|
3158
2929
|
},
|
|
3159
2930
|
// Auto (balanced) tier configs - current default smart routing
|
|
2931
|
+
// Benchmark-tuned 2026-03-16: balancing quality (retention) + latency
|
|
3160
2932
|
tiers: {
|
|
3161
2933
|
SIMPLE: {
|
|
3162
|
-
primary: "
|
|
3163
|
-
//
|
|
2934
|
+
primary: "google/gemini-2.5-flash",
|
|
2935
|
+
// 1,238ms, 60% retention (best) — fast AND quality
|
|
3164
2936
|
fallback: [
|
|
3165
|
-
"google/gemini-2.5-flash",
|
|
3166
|
-
// 60% retention (best), fast growth (+800%)
|
|
3167
|
-
"google/gemini-2.5-flash-lite",
|
|
3168
|
-
// 1M context, ultra cheap ($0.10/$0.40)
|
|
3169
2937
|
"deepseek/deepseek-chat",
|
|
3170
|
-
// 41% retention
|
|
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
|
|
3171
2945
|
"nvidia/gpt-oss-120b"
|
|
3172
|
-
// FREE fallback
|
|
2946
|
+
// 1,252ms, FREE fallback
|
|
3173
2947
|
]
|
|
3174
2948
|
},
|
|
3175
2949
|
MEDIUM: {
|
|
3176
2950
|
primary: "moonshot/kimi-k2.5",
|
|
3177
|
-
// $0.
|
|
2951
|
+
// 1,646ms, $0.60/$3.00 — strong tool use, quality output
|
|
3178
2952
|
fallback: [
|
|
3179
2953
|
"deepseek/deepseek-chat",
|
|
3180
|
-
// 41% retention
|
|
2954
|
+
// 1,431ms, 41% retention
|
|
3181
2955
|
"google/gemini-2.5-flash",
|
|
3182
|
-
// 60% retention
|
|
2956
|
+
// 1,238ms, 60% retention
|
|
3183
2957
|
"google/gemini-2.5-flash-lite",
|
|
3184
|
-
// 1M context
|
|
3185
|
-
"xai/grok-4-1-fast-non-reasoning"
|
|
3186
|
-
//
|
|
2958
|
+
// 1,353ms, 1M context ($0.10/$0.40)
|
|
2959
|
+
"xai/grok-4-1-fast-non-reasoning",
|
|
2960
|
+
// 1,244ms, fast fallback
|
|
2961
|
+
"xai/grok-3-mini"
|
|
2962
|
+
// 1,202ms, $0.30/$0.50
|
|
3187
2963
|
]
|
|
3188
2964
|
},
|
|
3189
2965
|
COMPLEX: {
|
|
3190
2966
|
primary: "google/gemini-3.1-pro",
|
|
3191
|
-
//
|
|
2967
|
+
// 1,609ms — fast flagship quality
|
|
3192
2968
|
fallback: [
|
|
3193
2969
|
"google/gemini-2.5-flash",
|
|
3194
|
-
//
|
|
2970
|
+
// 1,238ms, cheap failsafe before expensive models
|
|
3195
2971
|
"google/gemini-2.5-flash-lite",
|
|
3196
|
-
//
|
|
2972
|
+
// 1,353ms, 1M context, ultra-cheap failsafe ($0.10/$0.40)
|
|
3197
2973
|
"google/gemini-3-pro-preview",
|
|
3198
|
-
//
|
|
2974
|
+
// 1,352ms
|
|
3199
2975
|
"google/gemini-2.5-pro",
|
|
3200
|
-
|
|
2976
|
+
// 1,294ms
|
|
3201
2977
|
"xai/grok-4-0709",
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
"anthropic/claude-sonnet-4.6"
|
|
2978
|
+
// 1,348ms
|
|
2979
|
+
"deepseek/deepseek-chat",
|
|
2980
|
+
// 1,431ms
|
|
2981
|
+
"anthropic/claude-sonnet-4.6",
|
|
2982
|
+
// 2,110ms — quality fallback
|
|
2983
|
+
"openai/gpt-5.4"
|
|
2984
|
+
// 6,213ms — slowest but highest quality
|
|
3206
2985
|
]
|
|
3207
2986
|
},
|
|
3208
2987
|
REASONING: {
|
|
3209
2988
|
primary: "xai/grok-4-1-fast-reasoning",
|
|
3210
|
-
//
|
|
2989
|
+
// 1,454ms, $0.20/$0.50
|
|
3211
2990
|
fallback: [
|
|
2991
|
+
"xai/grok-4-fast-reasoning",
|
|
2992
|
+
// 1,298ms, $0.20/$0.50
|
|
3212
2993
|
"deepseek/deepseek-reasoner",
|
|
3213
|
-
//
|
|
2994
|
+
// 1,454ms, cheap reasoning
|
|
3214
2995
|
"openai/o4-mini",
|
|
3215
|
-
//
|
|
2996
|
+
// 2,328ms ($1.10/$4.40)
|
|
3216
2997
|
"openai/o3"
|
|
2998
|
+
// 2,862ms
|
|
3217
2999
|
]
|
|
3218
3000
|
}
|
|
3219
3001
|
},
|
|
@@ -3221,27 +3003,30 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
3221
3003
|
ecoTiers: {
|
|
3222
3004
|
SIMPLE: {
|
|
3223
3005
|
primary: "nvidia/gpt-oss-120b",
|
|
3224
|
-
// FREE! $0.00/$0.00
|
|
3006
|
+
// 1,252ms, FREE! $0.00/$0.00
|
|
3225
3007
|
fallback: [
|
|
3226
3008
|
"google/gemini-2.5-flash-lite",
|
|
3227
|
-
|
|
3228
|
-
"
|
|
3009
|
+
// 1,353ms, $0.10/$0.40
|
|
3010
|
+
"xai/grok-4-fast-non-reasoning",
|
|
3011
|
+
// 1,143ms, $0.20/$0.50
|
|
3012
|
+
"google/gemini-2.5-flash"
|
|
3013
|
+
// 1,238ms
|
|
3229
3014
|
]
|
|
3230
3015
|
},
|
|
3231
3016
|
MEDIUM: {
|
|
3232
3017
|
primary: "google/gemini-2.5-flash-lite",
|
|
3233
|
-
// $0.10/$0.40 - cheapest capable with 1M context
|
|
3234
|
-
fallback: ["google/gemini-2.5-flash", "deepseek/deepseek-chat", "nvidia/gpt-oss-120b"]
|
|
3018
|
+
// 1,353ms, $0.10/$0.40 - cheapest capable with 1M context
|
|
3019
|
+
fallback: ["xai/grok-4-fast-non-reasoning", "google/gemini-2.5-flash", "deepseek/deepseek-chat", "nvidia/gpt-oss-120b"]
|
|
3235
3020
|
},
|
|
3236
3021
|
COMPLEX: {
|
|
3237
3022
|
primary: "google/gemini-2.5-flash-lite",
|
|
3238
|
-
// $0.10/$0.40 - 1M context handles complexity
|
|
3239
|
-
fallback: ["google/gemini-2.5-flash", "deepseek/deepseek-chat"
|
|
3023
|
+
// 1,353ms, $0.10/$0.40 - 1M context handles complexity
|
|
3024
|
+
fallback: ["xai/grok-4-0709", "google/gemini-2.5-flash", "deepseek/deepseek-chat"]
|
|
3240
3025
|
},
|
|
3241
3026
|
REASONING: {
|
|
3242
3027
|
primary: "xai/grok-4-1-fast-reasoning",
|
|
3243
|
-
// $0.20/$0.50
|
|
3244
|
-
fallback: ["deepseek/deepseek-reasoner"]
|
|
3028
|
+
// 1,454ms, $0.20/$0.50
|
|
3029
|
+
fallback: ["xai/grok-4-fast-reasoning", "deepseek/deepseek-reasoner"]
|
|
3245
3030
|
}
|
|
3246
3031
|
},
|
|
3247
3032
|
// Premium tier configs - best quality (blockrun/premium)
|
|
@@ -3287,14 +3072,16 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
3287
3072
|
},
|
|
3288
3073
|
REASONING: {
|
|
3289
3074
|
primary: "anthropic/claude-sonnet-4.6",
|
|
3290
|
-
// $3/$15 - best for reasoning/instructions
|
|
3075
|
+
// 2,110ms, $3/$15 - best for reasoning/instructions
|
|
3291
3076
|
fallback: [
|
|
3292
3077
|
"anthropic/claude-opus-4.6",
|
|
3293
|
-
|
|
3078
|
+
// 2,139ms
|
|
3079
|
+
"xai/grok-4-1-fast-reasoning",
|
|
3080
|
+
// 1,454ms, cheap fast reasoning
|
|
3294
3081
|
"openai/o4-mini",
|
|
3295
|
-
//
|
|
3296
|
-
"openai/o3"
|
|
3297
|
-
|
|
3082
|
+
// 2,328ms ($1.10/$4.40)
|
|
3083
|
+
"openai/o3"
|
|
3084
|
+
// 2,862ms
|
|
3298
3085
|
]
|
|
3299
3086
|
}
|
|
3300
3087
|
},
|
|
@@ -3305,41 +3092,51 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
3305
3092
|
// $0.15/$0.60 - best tool compliance at lowest cost
|
|
3306
3093
|
fallback: [
|
|
3307
3094
|
"moonshot/kimi-k2.5",
|
|
3095
|
+
// 1,646ms, strong tool use quality
|
|
3308
3096
|
"anthropic/claude-haiku-4.5",
|
|
3097
|
+
// 2,305ms
|
|
3309
3098
|
"xai/grok-4-1-fast-non-reasoning"
|
|
3099
|
+
// 1,244ms, fast fallback
|
|
3310
3100
|
]
|
|
3311
3101
|
},
|
|
3312
3102
|
MEDIUM: {
|
|
3313
3103
|
primary: "moonshot/kimi-k2.5",
|
|
3314
|
-
// $0.
|
|
3104
|
+
// 1,646ms, $0.60/$3.00 - strong tool use, proper function calls
|
|
3315
3105
|
fallback: [
|
|
3106
|
+
"xai/grok-4-1-fast-non-reasoning",
|
|
3107
|
+
// 1,244ms, fast fallback
|
|
3316
3108
|
"openai/gpt-4o-mini",
|
|
3317
|
-
//
|
|
3109
|
+
// 2,764ms, reliable tool calling
|
|
3318
3110
|
"anthropic/claude-haiku-4.5",
|
|
3319
|
-
|
|
3320
|
-
"
|
|
3111
|
+
// 2,305ms
|
|
3112
|
+
"deepseek/deepseek-chat"
|
|
3113
|
+
// 1,431ms
|
|
3321
3114
|
]
|
|
3322
3115
|
},
|
|
3323
3116
|
COMPLEX: {
|
|
3324
3117
|
primary: "anthropic/claude-sonnet-4.6",
|
|
3118
|
+
// 2,110ms — best agentic quality
|
|
3325
3119
|
fallback: [
|
|
3326
3120
|
"anthropic/claude-opus-4.6",
|
|
3327
|
-
//
|
|
3328
|
-
"openai/gpt-5.4",
|
|
3329
|
-
// Newest flagship
|
|
3121
|
+
// 2,139ms — top quality
|
|
3330
3122
|
"google/gemini-3.1-pro",
|
|
3331
|
-
//
|
|
3332
|
-
"
|
|
3333
|
-
|
|
3123
|
+
// 1,609ms
|
|
3124
|
+
"xai/grok-4-0709",
|
|
3125
|
+
// 1,348ms
|
|
3126
|
+
"openai/gpt-5.4"
|
|
3127
|
+
// 6,213ms — slow but highest quality fallback
|
|
3334
3128
|
]
|
|
3335
3129
|
},
|
|
3336
3130
|
REASONING: {
|
|
3337
3131
|
primary: "anthropic/claude-sonnet-4.6",
|
|
3338
|
-
//
|
|
3132
|
+
// 2,110ms — strong tool use + reasoning
|
|
3339
3133
|
fallback: [
|
|
3340
3134
|
"anthropic/claude-opus-4.6",
|
|
3135
|
+
// 2,139ms
|
|
3341
3136
|
"xai/grok-4-1-fast-reasoning",
|
|
3137
|
+
// 1,454ms
|
|
3342
3138
|
"deepseek/deepseek-reasoner"
|
|
3139
|
+
// 1,454ms
|
|
3343
3140
|
]
|
|
3344
3141
|
}
|
|
3345
3142
|
},
|
|
@@ -6203,8 +6000,8 @@ async function startProxy(options) {
|
|
|
6203
6000
|
}
|
|
6204
6001
|
let reuseSolanaAddress;
|
|
6205
6002
|
if (solanaPrivateKeyBytes) {
|
|
6206
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
6207
|
-
const solanaSigner = await
|
|
6003
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
6004
|
+
const solanaSigner = await createKeyPairSignerFromPrivateKeyBytes(solanaPrivateKeyBytes);
|
|
6208
6005
|
reuseSolanaAddress = solanaSigner.address;
|
|
6209
6006
|
}
|
|
6210
6007
|
let balanceMonitor2;
|
|
@@ -6233,8 +6030,8 @@ async function startProxy(options) {
|
|
|
6233
6030
|
let solanaAddress;
|
|
6234
6031
|
if (solanaPrivateKeyBytes) {
|
|
6235
6032
|
const { registerExactSvmScheme } = await import("@x402/svm/exact/client");
|
|
6236
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
6237
|
-
const solanaSigner = await
|
|
6033
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
6034
|
+
const solanaSigner = await createKeyPairSignerFromPrivateKeyBytes(solanaPrivateKeyBytes);
|
|
6238
6035
|
solanaAddress = solanaSigner.address;
|
|
6239
6036
|
registerExactSvmScheme(x402, { signer: solanaSigner });
|
|
6240
6037
|
console.log(`[ClawRouter] Solana wallet: ${solanaAddress}`);
|
|
@@ -8502,7 +8299,6 @@ function formatDuration(seconds) {
|
|
|
8502
8299
|
|
|
8503
8300
|
// src/index.ts
|
|
8504
8301
|
init_wallet();
|
|
8505
|
-
init_solana_sweep();
|
|
8506
8302
|
|
|
8507
8303
|
// src/retry.ts
|
|
8508
8304
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -8962,8 +8758,8 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
8962
8758
|
hasMnemonic = true;
|
|
8963
8759
|
const { deriveSolanaKeyBytes: deriveSolanaKeyBytes2 } = await Promise.resolve().then(() => (init_wallet(), wallet_exports));
|
|
8964
8760
|
const solKeyBytes = deriveSolanaKeyBytes2(mnemonic);
|
|
8965
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
8966
|
-
const signer = await
|
|
8761
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
8762
|
+
const signer = await createKeyPairSignerFromPrivateKeyBytes(solKeyBytes);
|
|
8967
8763
|
lines.push(
|
|
8968
8764
|
"",
|
|
8969
8765
|
"**Solana:**",
|
|
@@ -9004,8 +8800,8 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
9004
8800
|
await savePaymentChain("solana");
|
|
9005
8801
|
const { deriveSolanaKeyBytes: deriveSolanaKeyBytes2 } = await Promise.resolve().then(() => (init_wallet(), wallet_exports));
|
|
9006
8802
|
const solKeyBytes = deriveSolanaKeyBytes2(existingMnemonic);
|
|
9007
|
-
const { createKeyPairSignerFromPrivateKeyBytes:
|
|
9008
|
-
const signer2 = await
|
|
8803
|
+
const { createKeyPairSignerFromPrivateKeyBytes: createKeyPairSignerFromPrivateKeyBytes2 } = await import("@solana/kit");
|
|
8804
|
+
const signer2 = await createKeyPairSignerFromPrivateKeyBytes2(solKeyBytes);
|
|
9009
8805
|
solanaAddr = signer2.address;
|
|
9010
8806
|
return {
|
|
9011
8807
|
text: [
|
|
@@ -9019,8 +8815,8 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
9019
8815
|
}
|
|
9020
8816
|
const { solanaPrivateKeyBytes } = await setupSolana();
|
|
9021
8817
|
await savePaymentChain("solana");
|
|
9022
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
9023
|
-
const signer = await
|
|
8818
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
8819
|
+
const signer = await createKeyPairSignerFromPrivateKeyBytes(solanaPrivateKeyBytes);
|
|
9024
8820
|
return {
|
|
9025
8821
|
text: [
|
|
9026
8822
|
"**Solana Wallet Set Up**",
|
|
@@ -9041,88 +8837,6 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
9041
8837
|
};
|
|
9042
8838
|
}
|
|
9043
8839
|
}
|
|
9044
|
-
if (subcommand === "migrate-solana") {
|
|
9045
|
-
try {
|
|
9046
|
-
if (!existsSync3(MNEMONIC_FILE)) {
|
|
9047
|
-
return {
|
|
9048
|
-
text: "No mnemonic file found. Solana wallet not set up \u2014 nothing to migrate.",
|
|
9049
|
-
isError: true
|
|
9050
|
-
};
|
|
9051
|
-
}
|
|
9052
|
-
const mnemonic = readTextFileSync(MNEMONIC_FILE).trim();
|
|
9053
|
-
if (!mnemonic) {
|
|
9054
|
-
return { text: "Mnemonic file is empty.", isError: true };
|
|
9055
|
-
}
|
|
9056
|
-
const { deriveSolanaKeyBytes: deriveSolanaKeyBytes2, deriveSolanaKeyBytesLegacy: deriveSolanaKeyBytesLegacy2 } = await Promise.resolve().then(() => (init_wallet(), wallet_exports));
|
|
9057
|
-
const { createKeyPairSignerFromPrivateKeyBytes: createKeyPairSignerFromPrivateKeyBytes2 } = await import("@solana/kit");
|
|
9058
|
-
const legacyKeyBytes = deriveSolanaKeyBytesLegacy2(mnemonic);
|
|
9059
|
-
const newKeyBytes = deriveSolanaKeyBytes2(mnemonic);
|
|
9060
|
-
const [oldSigner, newSigner] = await Promise.all([
|
|
9061
|
-
createKeyPairSignerFromPrivateKeyBytes2(legacyKeyBytes),
|
|
9062
|
-
createKeyPairSignerFromPrivateKeyBytes2(newKeyBytes)
|
|
9063
|
-
]);
|
|
9064
|
-
if (oldSigner.address === newSigner.address) {
|
|
9065
|
-
return { text: "Legacy and new Solana addresses are the same. No migration needed." };
|
|
9066
|
-
}
|
|
9067
|
-
let oldUsdcText = "unknown";
|
|
9068
|
-
try {
|
|
9069
|
-
const { SolanaBalanceMonitor: SolanaBalanceMonitor2 } = await Promise.resolve().then(() => (init_solana_balance(), solana_balance_exports));
|
|
9070
|
-
const monitor = new SolanaBalanceMonitor2(oldSigner.address);
|
|
9071
|
-
const balance = await monitor.checkBalance();
|
|
9072
|
-
oldUsdcText = balance.balanceUSD;
|
|
9073
|
-
if (balance.isEmpty) {
|
|
9074
|
-
return {
|
|
9075
|
-
text: [
|
|
9076
|
-
"**Solana Migration Status**",
|
|
9077
|
-
"",
|
|
9078
|
-
`Old wallet (secp256k1): \`${oldSigner.address}\``,
|
|
9079
|
-
` USDC: $0.00`,
|
|
9080
|
-
"",
|
|
9081
|
-
`New wallet (SLIP-10): \`${newSigner.address}\``,
|
|
9082
|
-
"",
|
|
9083
|
-
"No USDC in old wallet. Nothing to sweep.",
|
|
9084
|
-
"Your new SLIP-10 address is Phantom/Solflare compatible."
|
|
9085
|
-
].join("\n")
|
|
9086
|
-
};
|
|
9087
|
-
}
|
|
9088
|
-
} catch {
|
|
9089
|
-
}
|
|
9090
|
-
const { sweepSolanaWallet: sweepSolanaWallet2 } = await Promise.resolve().then(() => (init_solana_sweep(), solana_sweep_exports));
|
|
9091
|
-
const result = await sweepSolanaWallet2(legacyKeyBytes, newKeyBytes);
|
|
9092
|
-
if ("error" in result) {
|
|
9093
|
-
return {
|
|
9094
|
-
text: [
|
|
9095
|
-
"**Solana Migration Failed**",
|
|
9096
|
-
"",
|
|
9097
|
-
`Old wallet: \`${result.oldAddress}\` (USDC: ${oldUsdcText})`,
|
|
9098
|
-
`New wallet: \`${result.newAddress || newSigner.address}\``,
|
|
9099
|
-
"",
|
|
9100
|
-
`Error: ${result.error}`
|
|
9101
|
-
].join("\n"),
|
|
9102
|
-
isError: true
|
|
9103
|
-
};
|
|
9104
|
-
}
|
|
9105
|
-
return {
|
|
9106
|
-
text: [
|
|
9107
|
-
"**Solana Migration Complete**",
|
|
9108
|
-
"",
|
|
9109
|
-
`Swept **${result.transferred}** USDC from old to new wallet.`,
|
|
9110
|
-
"",
|
|
9111
|
-
`Old wallet: \`${result.oldAddress}\``,
|
|
9112
|
-
`New wallet: \`${result.newAddress}\``,
|
|
9113
|
-
`TX: https://solscan.io/tx/${result.txSignature}`,
|
|
9114
|
-
"",
|
|
9115
|
-
"Your new SLIP-10 address is Phantom/Solflare compatible.",
|
|
9116
|
-
"You can recover it from your 24-word mnemonic in any standard wallet."
|
|
9117
|
-
].join("\n")
|
|
9118
|
-
};
|
|
9119
|
-
} catch (err) {
|
|
9120
|
-
return {
|
|
9121
|
-
text: `Migration failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
9122
|
-
isError: true
|
|
9123
|
-
};
|
|
9124
|
-
}
|
|
9125
|
-
}
|
|
9126
8840
|
if (subcommand === "base") {
|
|
9127
8841
|
try {
|
|
9128
8842
|
await savePaymentChain("base");
|
|
@@ -9151,8 +8865,8 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
9151
8865
|
const mnemonic = readTextFileSync(MNEMONIC_FILE).trim();
|
|
9152
8866
|
if (mnemonic) {
|
|
9153
8867
|
const solKeyBytes = deriveSolanaKeyBytes2(mnemonic);
|
|
9154
|
-
const { createKeyPairSignerFromPrivateKeyBytes
|
|
9155
|
-
const signer = await
|
|
8868
|
+
const { createKeyPairSignerFromPrivateKeyBytes } = await import("@solana/kit");
|
|
8869
|
+
const signer = await createKeyPairSignerFromPrivateKeyBytes(solKeyBytes);
|
|
9156
8870
|
const solAddr = signer.address;
|
|
9157
8871
|
let solBalanceText = "Balance: (checking...)";
|
|
9158
8872
|
try {
|
|
@@ -9194,8 +8908,7 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
9194
8908
|
"\u2022 `/wallet export` - Export private key for backup",
|
|
9195
8909
|
!solanaSection ? "\u2022 `/wallet solana` - Enable Solana payments" : "",
|
|
9196
8910
|
solanaSection ? "\u2022 `/wallet base` - Switch to Base (EVM)" : "",
|
|
9197
|
-
solanaSection ? "\u2022 `/wallet solana` - Switch to Solana" : ""
|
|
9198
|
-
solanaSection ? "\u2022 `/wallet migrate-solana` - Sweep funds from old Solana wallet" : ""
|
|
8911
|
+
solanaSection ? "\u2022 `/wallet solana` - Switch to Solana" : ""
|
|
9199
8912
|
].filter(Boolean).join("\n")
|
|
9200
8913
|
};
|
|
9201
8914
|
}
|
|
@@ -9372,7 +9085,6 @@ export {
|
|
|
9372
9085
|
deriveAllKeys,
|
|
9373
9086
|
deriveEvmKey,
|
|
9374
9087
|
deriveSolanaKeyBytes,
|
|
9375
|
-
deriveSolanaKeyBytesLegacy,
|
|
9376
9088
|
fetchWithRetry,
|
|
9377
9089
|
formatDuration,
|
|
9378
9090
|
formatStatsAscii,
|
|
@@ -9400,8 +9112,7 @@ export {
|
|
|
9400
9112
|
route,
|
|
9401
9113
|
savePaymentChain,
|
|
9402
9114
|
setupSolana,
|
|
9403
|
-
startProxy
|
|
9404
|
-
sweepSolanaWallet
|
|
9115
|
+
startProxy
|
|
9405
9116
|
};
|
|
9406
9117
|
/*! Bundled license information:
|
|
9407
9118
|
|