@bridgenode/llm 0.1.0 → 0.2.1
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 +46 -1406
- package/dist/index.cjs +72 -80
- package/dist/index.d.cts +86 -96
- package/dist/index.d.ts +86 -96
- package/dist/index.js +72 -77
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -32,8 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
APIError: () => APIError,
|
|
34
34
|
AnthropicClient: () => AnthropicClient,
|
|
35
|
-
|
|
36
|
-
BridgeNodeClient: () => BlockrunClient,
|
|
35
|
+
BridgeNodeClient: () => BridgeNodeClient,
|
|
37
36
|
BridgeNodeError: () => BridgeNodeError,
|
|
38
37
|
ImageClient: () => ImageClient,
|
|
39
38
|
KNOWN_PROVIDERS: () => KNOWN_PROVIDERS,
|
|
@@ -56,8 +55,6 @@ __export(index_exports, {
|
|
|
56
55
|
SolanaLLMClient: () => SolanaLLMClient,
|
|
57
56
|
SpeechClient: () => SpeechClient,
|
|
58
57
|
SurfClient: () => SurfClient,
|
|
59
|
-
USDC_BASE: () => USDC_BASE,
|
|
60
|
-
USDC_BASE_CONTRACT: () => USDC_BASE_CONTRACT,
|
|
61
58
|
USDC_SOLANA: () => USDC_SOLANA,
|
|
62
59
|
VideoClient: () => VideoClient,
|
|
63
60
|
VoiceClient: () => VoiceClient,
|
|
@@ -140,8 +137,6 @@ var APIError = class extends BridgeNodeError {
|
|
|
140
137
|
|
|
141
138
|
// src/x402.ts
|
|
142
139
|
var import_accounts = require("viem/accounts");
|
|
143
|
-
var BASE_CHAIN_ID = 8453;
|
|
144
|
-
var USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
145
140
|
var SOLANA_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
146
141
|
var USDC_SOLANA = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
147
142
|
var DEFAULT_COMPUTE_UNIT_PRICE_MICROLAMPORTS = 1;
|
|
@@ -149,8 +144,8 @@ var DEFAULT_COMPUTE_UNIT_LIMIT = 8e3;
|
|
|
149
144
|
var USDC_DOMAIN = {
|
|
150
145
|
name: "USD Coin",
|
|
151
146
|
version: "2",
|
|
152
|
-
chainId:
|
|
153
|
-
verifyingContract:
|
|
147
|
+
chainId: 8453,
|
|
148
|
+
verifyingContract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
154
149
|
};
|
|
155
150
|
var TRANSFER_TYPES = {
|
|
156
151
|
TransferWithAuthorization: [
|
|
@@ -177,7 +172,7 @@ function withBuilderCodeServiceCode(extensions) {
|
|
|
177
172
|
};
|
|
178
173
|
return merged;
|
|
179
174
|
}
|
|
180
|
-
async function createPaymentPayload(privateKey, fromAddress, recipient, amount, network =
|
|
175
|
+
async function createPaymentPayload(privateKey, fromAddress, recipient, amount, network = SOLANA_NETWORK, options = {}) {
|
|
181
176
|
const now = Math.floor(Date.now() / 1e3);
|
|
182
177
|
const validAfter = now - 600;
|
|
183
178
|
const validBefore = now + (options.maxTimeoutSeconds || 300);
|
|
@@ -208,7 +203,7 @@ async function createPaymentPayload(privateKey, fromAddress, recipient, amount,
|
|
|
208
203
|
scheme: "exact",
|
|
209
204
|
network,
|
|
210
205
|
amount,
|
|
211
|
-
asset:
|
|
206
|
+
asset: USDC_SOLANA,
|
|
212
207
|
payTo: recipient,
|
|
213
208
|
maxTimeoutSeconds: options.maxTimeoutSeconds || 300,
|
|
214
209
|
extra: { name: "USD Coin", version: "2" }
|
|
@@ -585,16 +580,16 @@ var LLMClient = class _LLMClient {
|
|
|
585
580
|
preAuthCache = /* @__PURE__ */ new Map();
|
|
586
581
|
static PRE_AUTH_TTL_MS = 36e5;
|
|
587
582
|
/**
|
|
588
|
-
* Initialize the
|
|
583
|
+
* Initialize the BridgeNode LLM client.
|
|
589
584
|
*
|
|
590
|
-
* @param options - Client configuration options (optional if
|
|
585
|
+
* @param options - Client configuration options (optional if BRIDGENODE_WALLET_KEY env var is set)
|
|
591
586
|
*/
|
|
592
587
|
constructor(options = {}) {
|
|
593
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.
|
|
588
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
594
589
|
const privateKey = options.privateKey || envKey;
|
|
595
590
|
if (!privateKey) {
|
|
596
591
|
throw new Error(
|
|
597
|
-
"Private key required. Pass privateKey in options or set
|
|
592
|
+
"Private key required. Pass privateKey in options or set BRIDGENODE_WALLET_KEY environment variable."
|
|
598
593
|
);
|
|
599
594
|
}
|
|
600
595
|
validatePrivateKey(privateKey);
|
|
@@ -926,13 +921,13 @@ var LLMClient = class _LLMClient {
|
|
|
926
921
|
this.account.address,
|
|
927
922
|
details.recipient,
|
|
928
923
|
details.amount,
|
|
929
|
-
details.network ||
|
|
924
|
+
details.network || SOLANA_NETWORK,
|
|
930
925
|
{
|
|
931
926
|
resourceUrl: validateResourceUrl(
|
|
932
927
|
details.resource?.url || `${this.apiUrl}/v1/chat/completions`,
|
|
933
928
|
this.apiUrl
|
|
934
929
|
),
|
|
935
|
-
resourceDescription: details.resource?.description || "
|
|
930
|
+
resourceDescription: details.resource?.description || "BridgeNode AI API call",
|
|
936
931
|
maxTimeoutSeconds: details.maxTimeoutSeconds || 300,
|
|
937
932
|
extra: details.extra,
|
|
938
933
|
extensions
|
|
@@ -1011,13 +1006,13 @@ var LLMClient = class _LLMClient {
|
|
|
1011
1006
|
this.account.address,
|
|
1012
1007
|
details.recipient,
|
|
1013
1008
|
details.amount,
|
|
1014
|
-
details.network ||
|
|
1009
|
+
details.network || SOLANA_NETWORK,
|
|
1015
1010
|
{
|
|
1016
1011
|
resourceUrl: validateResourceUrl(
|
|
1017
1012
|
details.resource?.url || `${this.apiUrl}/v1/chat/completions`,
|
|
1018
1013
|
this.apiUrl
|
|
1019
1014
|
),
|
|
1020
|
-
resourceDescription: details.resource?.description || "
|
|
1015
|
+
resourceDescription: details.resource?.description || "BridgeNode AI API call",
|
|
1021
1016
|
maxTimeoutSeconds: details.maxTimeoutSeconds || 300,
|
|
1022
1017
|
extra: details.extra,
|
|
1023
1018
|
extensions
|
|
@@ -1202,13 +1197,13 @@ var LLMClient = class _LLMClient {
|
|
|
1202
1197
|
this.account.address,
|
|
1203
1198
|
details.recipient,
|
|
1204
1199
|
details.amount,
|
|
1205
|
-
details.network ||
|
|
1200
|
+
details.network || SOLANA_NETWORK,
|
|
1206
1201
|
{
|
|
1207
1202
|
resourceUrl: validateResourceUrl(
|
|
1208
1203
|
details.resource?.url || url,
|
|
1209
1204
|
this.apiUrl
|
|
1210
1205
|
),
|
|
1211
|
-
resourceDescription: details.resource?.description || "
|
|
1206
|
+
resourceDescription: details.resource?.description || "BridgeNode AI API call",
|
|
1212
1207
|
maxTimeoutSeconds: details.maxTimeoutSeconds || 300,
|
|
1213
1208
|
extra: details.extra,
|
|
1214
1209
|
extensions
|
|
@@ -1349,13 +1344,13 @@ var LLMClient = class _LLMClient {
|
|
|
1349
1344
|
this.account.address,
|
|
1350
1345
|
details.recipient,
|
|
1351
1346
|
details.amount,
|
|
1352
|
-
details.network ||
|
|
1347
|
+
details.network || SOLANA_NETWORK,
|
|
1353
1348
|
{
|
|
1354
1349
|
resourceUrl: validateResourceUrl(
|
|
1355
1350
|
details.resource?.url || url,
|
|
1356
1351
|
this.apiUrl
|
|
1357
1352
|
),
|
|
1358
|
-
resourceDescription: details.resource?.description || "
|
|
1353
|
+
resourceDescription: details.resource?.description || "BridgeNode AI API call",
|
|
1359
1354
|
maxTimeoutSeconds: details.maxTimeoutSeconds || 300,
|
|
1360
1355
|
extra: details.extra,
|
|
1361
1356
|
extensions
|
|
@@ -1811,7 +1806,7 @@ var LLMClient = class _LLMClient {
|
|
|
1811
1806
|
// 0x DEX (swap quotes + gasless) — free passthrough
|
|
1812
1807
|
// ============================================================
|
|
1813
1808
|
/**
|
|
1814
|
-
* Query the 0x Swap / Gasless APIs (free — no x402 payment;
|
|
1809
|
+
* Query the 0x Swap / Gasless APIs (free — no x402 payment; BridgeNode
|
|
1815
1810
|
* takes an on-chain affiliate fee on executed swaps instead).
|
|
1816
1811
|
*
|
|
1817
1812
|
* @param path - "price", "quote", "gasless/price", "gasless/quote",
|
|
@@ -1925,12 +1920,12 @@ var ImageClient = class {
|
|
|
1925
1920
|
sessionTotalUsd = 0;
|
|
1926
1921
|
sessionCalls = 0;
|
|
1927
1922
|
/**
|
|
1928
|
-
* Initialize the
|
|
1923
|
+
* Initialize the BridgeNode Image client.
|
|
1929
1924
|
*
|
|
1930
1925
|
* @param options - Client configuration options
|
|
1931
1926
|
*/
|
|
1932
1927
|
constructor(options = {}) {
|
|
1933
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
1928
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
1934
1929
|
const privateKey = options.privateKey || envKey;
|
|
1935
1930
|
if (!privateKey) {
|
|
1936
1931
|
throw new Error(
|
|
@@ -2094,7 +2089,7 @@ var ImageClient = class {
|
|
|
2094
2089
|
this.account.address,
|
|
2095
2090
|
details.recipient,
|
|
2096
2091
|
details.amount,
|
|
2097
|
-
details.network ||
|
|
2092
|
+
details.network || SOLANA_NETWORK,
|
|
2098
2093
|
{
|
|
2099
2094
|
resourceUrl: validateResourceUrl(
|
|
2100
2095
|
details.resource?.url || `${this.apiUrl}/v1/images/generations`,
|
|
@@ -2243,7 +2238,7 @@ var MusicClient = class {
|
|
|
2243
2238
|
sessionTotalUsd = 0;
|
|
2244
2239
|
sessionCalls = 0;
|
|
2245
2240
|
constructor(options = {}) {
|
|
2246
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
2241
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
2247
2242
|
const privateKey = options.privateKey || envKey;
|
|
2248
2243
|
if (!privateKey) {
|
|
2249
2244
|
throw new Error(
|
|
@@ -2333,7 +2328,7 @@ var MusicClient = class {
|
|
|
2333
2328
|
this.account.address,
|
|
2334
2329
|
details.recipient,
|
|
2335
2330
|
details.amount,
|
|
2336
|
-
details.network ||
|
|
2331
|
+
details.network || SOLANA_NETWORK,
|
|
2337
2332
|
{
|
|
2338
2333
|
resourceUrl: details.resource?.url || `${this.apiUrl}/v1/audio/generations`,
|
|
2339
2334
|
resourceDescription: details.resource?.description || "BridgeNode Music Generation",
|
|
@@ -2399,7 +2394,7 @@ var SpeechClient = class {
|
|
|
2399
2394
|
sessionTotalUsd = 0;
|
|
2400
2395
|
sessionCalls = 0;
|
|
2401
2396
|
constructor(options = {}) {
|
|
2402
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
2397
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
2403
2398
|
const privateKey = options.privateKey || envKey;
|
|
2404
2399
|
if (!privateKey) {
|
|
2405
2400
|
throw new Error(
|
|
@@ -2426,7 +2421,7 @@ var SpeechClient = class {
|
|
|
2426
2421
|
* @returns SpeechResponse with audio URL, format, and character count
|
|
2427
2422
|
*
|
|
2428
2423
|
* @example
|
|
2429
|
-
* const result = await client.generate('Welcome to
|
|
2424
|
+
* const result = await client.generate('Welcome to BridgeNode.', { voice: 'george' });
|
|
2430
2425
|
* console.log(result.data[0].url); // audio URL (mp3 by default)
|
|
2431
2426
|
*/
|
|
2432
2427
|
async generate(input, options) {
|
|
@@ -2531,7 +2526,7 @@ var SpeechClient = class {
|
|
|
2531
2526
|
this.account.address,
|
|
2532
2527
|
details.recipient,
|
|
2533
2528
|
details.amount,
|
|
2534
|
-
details.network ||
|
|
2529
|
+
details.network || SOLANA_NETWORK,
|
|
2535
2530
|
{
|
|
2536
2531
|
resourceUrl: details.resource?.url || `${this.apiUrl}${endpoint}`,
|
|
2537
2532
|
resourceDescription: details.resource?.description || "BridgeNode Voice",
|
|
@@ -2601,7 +2596,7 @@ var VideoClient = class {
|
|
|
2601
2596
|
sessionTotalUsd = 0;
|
|
2602
2597
|
sessionCalls = 0;
|
|
2603
2598
|
constructor(options = {}) {
|
|
2604
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
2599
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
2605
2600
|
const privateKey = options.privateKey || envKey;
|
|
2606
2601
|
if (!privateKey) {
|
|
2607
2602
|
throw new Error(
|
|
@@ -2839,7 +2834,7 @@ var VideoClient = class {
|
|
|
2839
2834
|
this.account.address,
|
|
2840
2835
|
details.recipient,
|
|
2841
2836
|
details.amount,
|
|
2842
|
-
details.network ||
|
|
2837
|
+
details.network || SOLANA_NETWORK,
|
|
2843
2838
|
{
|
|
2844
2839
|
resourceUrl: details.resource?.url || fallbackUrl,
|
|
2845
2840
|
resourceDescription: details.resource?.description || "BridgeNode Video Generation",
|
|
@@ -2911,7 +2906,7 @@ var VoiceClient = class {
|
|
|
2911
2906
|
sessionTotalUsd = 0;
|
|
2912
2907
|
sessionCalls = 0;
|
|
2913
2908
|
constructor(options = {}) {
|
|
2914
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
2909
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
2915
2910
|
const privateKey = options.privateKey || envKey;
|
|
2916
2911
|
if (!privateKey) {
|
|
2917
2912
|
throw new Error(
|
|
@@ -3046,7 +3041,7 @@ var VoiceClient = class {
|
|
|
3046
3041
|
this.account.address,
|
|
3047
3042
|
details.recipient,
|
|
3048
3043
|
details.amount,
|
|
3049
|
-
details.network ||
|
|
3044
|
+
details.network || SOLANA_NETWORK,
|
|
3050
3045
|
{
|
|
3051
3046
|
resourceUrl: details.resource?.url || `${this.apiUrl}/v1/voice/call`,
|
|
3052
3047
|
resourceDescription: details.resource?.description || "BridgeNode Voice Call",
|
|
@@ -3130,7 +3125,7 @@ var PhoneClient = class {
|
|
|
3130
3125
|
sessionTotalUsd = 0;
|
|
3131
3126
|
sessionCalls = 0;
|
|
3132
3127
|
constructor(options = {}) {
|
|
3133
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3128
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3134
3129
|
const privateKey = options.privateKey || envKey;
|
|
3135
3130
|
if (!privateKey) {
|
|
3136
3131
|
throw new Error(
|
|
@@ -3260,7 +3255,7 @@ var PhoneClient = class {
|
|
|
3260
3255
|
this.account.address,
|
|
3261
3256
|
details.recipient,
|
|
3262
3257
|
details.amount,
|
|
3263
|
-
details.network ||
|
|
3258
|
+
details.network || SOLANA_NETWORK,
|
|
3264
3259
|
{
|
|
3265
3260
|
resourceUrl: details.resource?.url || url,
|
|
3266
3261
|
resourceDescription: details.resource?.description || "BridgeNode Phone",
|
|
@@ -3330,7 +3325,7 @@ var PortraitClient = class {
|
|
|
3330
3325
|
sessionTotalUsd = 0;
|
|
3331
3326
|
sessionCalls = 0;
|
|
3332
3327
|
constructor(options = {}) {
|
|
3333
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3328
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3334
3329
|
const privateKey = options.privateKey || envKey;
|
|
3335
3330
|
if (!privateKey) {
|
|
3336
3331
|
throw new Error(
|
|
@@ -3412,10 +3407,10 @@ var PortraitClient = class {
|
|
|
3412
3407
|
this.account.address,
|
|
3413
3408
|
details.recipient,
|
|
3414
3409
|
details.amount,
|
|
3415
|
-
details.network ||
|
|
3410
|
+
details.network || SOLANA_NETWORK,
|
|
3416
3411
|
{
|
|
3417
3412
|
resourceUrl: details.resource?.url || url,
|
|
3418
|
-
resourceDescription: details.resource?.description || "
|
|
3413
|
+
resourceDescription: details.resource?.description || "BridgeNode Virtual Portrait",
|
|
3419
3414
|
maxTimeoutSeconds: details.maxTimeoutSeconds || 300,
|
|
3420
3415
|
extra: details.extra
|
|
3421
3416
|
}
|
|
@@ -3481,7 +3476,7 @@ var SearchClient = class {
|
|
|
3481
3476
|
apiUrl;
|
|
3482
3477
|
timeout;
|
|
3483
3478
|
constructor(options = {}) {
|
|
3484
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3479
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3485
3480
|
const privateKey = options.privateKey || envKey;
|
|
3486
3481
|
if (!privateKey) {
|
|
3487
3482
|
throw new Error(
|
|
@@ -3559,7 +3554,7 @@ var SearchClient = class {
|
|
|
3559
3554
|
this.account.address,
|
|
3560
3555
|
details.recipient,
|
|
3561
3556
|
details.amount,
|
|
3562
|
-
details.network ||
|
|
3557
|
+
details.network || SOLANA_NETWORK,
|
|
3563
3558
|
{
|
|
3564
3559
|
resourceUrl: details.resource?.url || url,
|
|
3565
3560
|
resourceDescription: details.resource?.description || "BridgeNode Search",
|
|
@@ -3617,7 +3612,7 @@ var PriceClient = class {
|
|
|
3617
3612
|
apiUrl;
|
|
3618
3613
|
timeout;
|
|
3619
3614
|
constructor(options = {}) {
|
|
3620
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3615
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3621
3616
|
const privateKey = options.privateKey || envKey;
|
|
3622
3617
|
const requireWallet = options.requireWallet ?? true;
|
|
3623
3618
|
if (!privateKey && requireWallet) {
|
|
@@ -3749,7 +3744,7 @@ var PriceClient = class {
|
|
|
3749
3744
|
this.account.address,
|
|
3750
3745
|
details.recipient,
|
|
3751
3746
|
details.amount,
|
|
3752
|
-
details.network ||
|
|
3747
|
+
details.network || SOLANA_NETWORK,
|
|
3753
3748
|
{
|
|
3754
3749
|
resourceUrl: details.resource?.url || url,
|
|
3755
3750
|
resourceDescription: details.resource?.description || "BridgeNode Price Data",
|
|
@@ -3822,7 +3817,7 @@ var SurfClient = class {
|
|
|
3822
3817
|
apiUrl;
|
|
3823
3818
|
timeout;
|
|
3824
3819
|
constructor(options = {}) {
|
|
3825
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3820
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3826
3821
|
const privateKey = options.privateKey || envKey;
|
|
3827
3822
|
if (!privateKey) {
|
|
3828
3823
|
throw new Error(
|
|
@@ -3911,7 +3906,7 @@ var SurfClient = class {
|
|
|
3911
3906
|
this.account.address,
|
|
3912
3907
|
details.recipient,
|
|
3913
3908
|
details.amount,
|
|
3914
|
-
details.network ||
|
|
3909
|
+
details.network || SOLANA_NETWORK,
|
|
3915
3910
|
{
|
|
3916
3911
|
resourceUrl: details.resource?.url || url,
|
|
3917
3912
|
resourceDescription: details.resource?.description || "BridgeNode Surf",
|
|
@@ -4052,7 +4047,7 @@ var RpcClient = class {
|
|
|
4052
4047
|
sessionTotalUsd = 0;
|
|
4053
4048
|
sessionCalls = 0;
|
|
4054
4049
|
constructor(options = {}) {
|
|
4055
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
4050
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
4056
4051
|
const privateKey = options.privateKey || envKey;
|
|
4057
4052
|
if (!privateKey) {
|
|
4058
4053
|
throw new Error(
|
|
@@ -4169,7 +4164,7 @@ var RpcClient = class {
|
|
|
4169
4164
|
this.account.address,
|
|
4170
4165
|
details.recipient,
|
|
4171
4166
|
details.amount,
|
|
4172
|
-
details.network ||
|
|
4167
|
+
details.network || SOLANA_NETWORK,
|
|
4173
4168
|
{
|
|
4174
4169
|
resourceUrl: details.resource?.url || `${this.apiUrl}${endpoint}`,
|
|
4175
4170
|
resourceDescription: details.resource?.description || "BridgeNode Multi-chain RPC",
|
|
@@ -4219,14 +4214,14 @@ var RpcClient = class {
|
|
|
4219
4214
|
}
|
|
4220
4215
|
};
|
|
4221
4216
|
|
|
4222
|
-
// src/
|
|
4217
|
+
// src/bridgenode.ts
|
|
4223
4218
|
var import_accounts14 = require("viem/accounts");
|
|
4224
4219
|
var DEFAULT_API_URL13 = "https://bridgenode.cc/api";
|
|
4225
4220
|
var DEFAULT_TIMEOUT13 = 6e4;
|
|
4226
4221
|
var DEFAULT_POLL_INTERVAL_MS = 5e3;
|
|
4227
4222
|
var DEFAULT_POLL_BUDGET_MS = 3e5;
|
|
4228
4223
|
var MAX_SIGNED_AUTH_SECONDS = 600;
|
|
4229
|
-
var
|
|
4224
|
+
var BridgeNodeClient = class {
|
|
4230
4225
|
account;
|
|
4231
4226
|
privateKey;
|
|
4232
4227
|
apiUrl;
|
|
@@ -4234,7 +4229,7 @@ var BlockrunClient = class {
|
|
|
4234
4229
|
sessionTotalUsd = 0;
|
|
4235
4230
|
sessionCalls = 0;
|
|
4236
4231
|
constructor(options = {}) {
|
|
4237
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
4232
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
4238
4233
|
const privateKey = options.privateKey || envKey;
|
|
4239
4234
|
if (!privateKey) {
|
|
4240
4235
|
throw new Error(
|
|
@@ -4250,7 +4245,7 @@ var BlockrunClient = class {
|
|
|
4250
4245
|
this.timeout = options.timeout || DEFAULT_TIMEOUT13;
|
|
4251
4246
|
}
|
|
4252
4247
|
/**
|
|
4253
|
-
* GET a
|
|
4248
|
+
* GET a BridgeNode endpoint. `path` is everything after `/api` (a leading
|
|
4254
4249
|
* `/api` is tolerated and stripped). Query params are URL-encoded; arrays
|
|
4255
4250
|
* become repeated keys (`?a=1&a=2`); undefined/null are dropped.
|
|
4256
4251
|
*/
|
|
@@ -4259,7 +4254,7 @@ var BlockrunClient = class {
|
|
|
4259
4254
|
return this.requestWithPayment(url, "GET");
|
|
4260
4255
|
}
|
|
4261
4256
|
/**
|
|
4262
|
-
* POST a
|
|
4257
|
+
* POST a BridgeNode endpoint with a JSON body.
|
|
4263
4258
|
*/
|
|
4264
4259
|
async post(path5, body) {
|
|
4265
4260
|
const url = this.buildUrl(path5);
|
|
@@ -4540,7 +4535,7 @@ var BlockrunClient = class {
|
|
|
4540
4535
|
this.account.address,
|
|
4541
4536
|
details.recipient,
|
|
4542
4537
|
details.amount,
|
|
4543
|
-
details.network ||
|
|
4538
|
+
details.network || SOLANA_NETWORK,
|
|
4544
4539
|
{
|
|
4545
4540
|
resourceUrl: details.resource?.url || url,
|
|
4546
4541
|
resourceDescription: details.resource?.description || opts.description,
|
|
@@ -4603,7 +4598,7 @@ var fs2 = __toESM(require("fs"), 1);
|
|
|
4603
4598
|
var path2 = __toESM(require("path"), 1);
|
|
4604
4599
|
var os2 = __toESM(require("os"), 1);
|
|
4605
4600
|
var USDC_BASE_CONTRACT = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
4606
|
-
var
|
|
4601
|
+
var BASE_CHAIN_ID = "8453";
|
|
4607
4602
|
var WALLET_DIR = path2.join(os2.homedir(), ".bridgenode");
|
|
4608
4603
|
var WALLET_FILE = path2.join(WALLET_DIR, ".session");
|
|
4609
4604
|
function createWallet() {
|
|
@@ -4716,12 +4711,12 @@ function formatWalletMigrationNotice(newAddress) {
|
|
|
4716
4711
|
if (addresses.length === 0) return null;
|
|
4717
4712
|
const found = addresses.map((addr) => ` ${addr}`).join("\n");
|
|
4718
4713
|
return `
|
|
4719
|
-
NOTICE:
|
|
4714
|
+
NOTICE: BridgeNode created a new wallet, but also found existing wallet(s)
|
|
4720
4715
|
belonging to other applications on this system:
|
|
4721
4716
|
|
|
4722
4717
|
${found}
|
|
4723
4718
|
|
|
4724
|
-
|
|
4719
|
+
BridgeNode now uses only its own wallet:
|
|
4725
4720
|
|
|
4726
4721
|
${newAddress}
|
|
4727
4722
|
|
|
@@ -4731,7 +4726,7 @@ do not control.
|
|
|
4731
4726
|
|
|
4732
4727
|
If an address above is yours and holds your USDC, adopt it deliberately:
|
|
4733
4728
|
|
|
4734
|
-
import { importWallet } from '@
|
|
4729
|
+
import { importWallet } from '@bridgenode/llm';
|
|
4735
4730
|
importWallet("<address-from-the-list-above>");
|
|
4736
4731
|
|
|
4737
4732
|
Your current wallet is backed up first. You can also set
|
|
@@ -4739,7 +4734,7 @@ BRIDGENODE_WALLET_KEY=<private-key> for a single run without changing anything.
|
|
|
4739
4734
|
`;
|
|
4740
4735
|
}
|
|
4741
4736
|
function getOrCreateWallet() {
|
|
4742
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
4737
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
4743
4738
|
if (envKey) {
|
|
4744
4739
|
const account = (0, import_accounts15.privateKeyToAccount)(envKey);
|
|
4745
4740
|
return { address: account.address, privateKey: envKey, isNew: false };
|
|
@@ -4754,7 +4749,7 @@ function getOrCreateWallet() {
|
|
|
4754
4749
|
return { address, privateKey, isNew: true };
|
|
4755
4750
|
}
|
|
4756
4751
|
function getWalletAddress() {
|
|
4757
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
4752
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
4758
4753
|
if (envKey) {
|
|
4759
4754
|
return (0, import_accounts15.privateKeyToAccount)(envKey).address;
|
|
4760
4755
|
}
|
|
@@ -4766,26 +4761,26 @@ function getWalletAddress() {
|
|
|
4766
4761
|
}
|
|
4767
4762
|
function getEip681Uri(address, amountUsdc = 1) {
|
|
4768
4763
|
const amountWei = Math.floor(amountUsdc * 1e6);
|
|
4769
|
-
return `ethereum:${USDC_BASE_CONTRACT}@${
|
|
4764
|
+
return `ethereum:${USDC_BASE_CONTRACT}@${BASE_CHAIN_ID}/transfer?address=${address}&uint256=${amountWei}`;
|
|
4770
4765
|
}
|
|
4771
4766
|
function getPaymentLinks(address) {
|
|
4772
4767
|
return {
|
|
4773
4768
|
basescan: `https://basescan.org/address/${address}`,
|
|
4774
|
-
walletLink: `ethereum:${USDC_BASE_CONTRACT}@${
|
|
4775
|
-
ethereum: `ethereum:${address}@${
|
|
4769
|
+
walletLink: `ethereum:${USDC_BASE_CONTRACT}@${BASE_CHAIN_ID}/transfer?address=${address}`,
|
|
4770
|
+
ethereum: `ethereum:${address}@${BASE_CHAIN_ID}`,
|
|
4776
4771
|
bridgenode: `https://bridgenode.cc/fund?address=${address}`
|
|
4777
4772
|
};
|
|
4778
4773
|
}
|
|
4779
4774
|
function formatWalletCreatedMessage(address) {
|
|
4780
4775
|
const links = getPaymentLinks(address);
|
|
4781
4776
|
return `
|
|
4782
|
-
I'm your
|
|
4777
|
+
I'm your BridgeNode Agent! I can access GPT-4, Grok, image generation, and more.
|
|
4783
4778
|
|
|
4784
|
-
Please send $1-5 USDC
|
|
4779
|
+
Please send $1-5 Solana USDC to start:
|
|
4785
4780
|
|
|
4786
4781
|
${address}
|
|
4787
4782
|
|
|
4788
|
-
What is
|
|
4783
|
+
What is Solana? Solana is a high-performance's blockchain network.
|
|
4789
4784
|
You can buy USDC on Coinbase and send it directly to me.
|
|
4790
4785
|
|
|
4791
4786
|
What $1 USDC gets you:
|
|
@@ -4806,7 +4801,7 @@ Your private key never leaves your machine - only signatures are sent.
|
|
|
4806
4801
|
function formatNeedsFundingMessage(address) {
|
|
4807
4802
|
const links = getPaymentLinks(address);
|
|
4808
4803
|
return `
|
|
4809
|
-
I've run out of funds! Please send more USDC
|
|
4804
|
+
I've run out of funds! Please send more Solana USDC to continue helping you.
|
|
4810
4805
|
|
|
4811
4806
|
Send to my address:
|
|
4812
4807
|
${address}
|
|
@@ -4821,7 +4816,7 @@ Your private key never leaves your machine - only signatures are sent.
|
|
|
4821
4816
|
}
|
|
4822
4817
|
function formatFundingMessageCompact(address) {
|
|
4823
4818
|
const links = getPaymentLinks(address);
|
|
4824
|
-
return `I need a little top-up to keep helping you! Send USDC
|
|
4819
|
+
return `I need a little top-up to keep helping you! Send Solana USDC to: ${address}
|
|
4825
4820
|
Check my balance: ${links.basescan}`;
|
|
4826
4821
|
}
|
|
4827
4822
|
var WALLET_FILE_PATH = WALLET_FILE;
|
|
@@ -4970,12 +4965,12 @@ async function formatSolanaWalletMigrationNotice(newAddress) {
|
|
|
4970
4965
|
if (addresses.length === 0) return null;
|
|
4971
4966
|
const found = addresses.map((addr) => ` ${addr}`).join("\n");
|
|
4972
4967
|
return `
|
|
4973
|
-
NOTICE:
|
|
4968
|
+
NOTICE: BridgeNode created a new Solana wallet, but also found existing
|
|
4974
4969
|
wallet(s) belonging to other applications on this system:
|
|
4975
4970
|
|
|
4976
4971
|
${found}
|
|
4977
4972
|
|
|
4978
|
-
|
|
4973
|
+
BridgeNode now uses only its own wallet:
|
|
4979
4974
|
|
|
4980
4975
|
${newAddress}
|
|
4981
4976
|
|
|
@@ -4985,7 +4980,7 @@ do not control.
|
|
|
4985
4980
|
|
|
4986
4981
|
If an address above is yours and holds your USDC, adopt it deliberately:
|
|
4987
4982
|
|
|
4988
|
-
import { importSolanaWallet } from '@
|
|
4983
|
+
import { importSolanaWallet } from '@bridgenode/llm';
|
|
4989
4984
|
await importSolanaWallet("<address-from-the-list-above>");
|
|
4990
4985
|
|
|
4991
4986
|
Your current wallet is backed up first. You can also set
|
|
@@ -5258,7 +5253,7 @@ var SolanaLLMClient = class {
|
|
|
5258
5253
|
// 0x DEX (swap quotes + gasless) — free passthrough
|
|
5259
5254
|
// ============================================================
|
|
5260
5255
|
/**
|
|
5261
|
-
* Query the 0x Swap / Gasless APIs (free — no x402 payment;
|
|
5256
|
+
* Query the 0x Swap / Gasless APIs (free — no x402 payment; BridgeNode
|
|
5262
5257
|
* takes an on-chain affiliate fee on executed swaps instead).
|
|
5263
5258
|
*
|
|
5264
5259
|
* @param path - "price", "quote", "gasless/price", "gasless/quote",
|
|
@@ -5379,7 +5374,7 @@ var SolanaLLMClient = class {
|
|
|
5379
5374
|
const details = extractPaymentDetails(paymentRequired, SOLANA_NETWORK);
|
|
5380
5375
|
if (!details.network?.startsWith("solana:")) {
|
|
5381
5376
|
throw new PaymentError(
|
|
5382
|
-
`Expected Solana payment network, got: ${details.network}. Use LLMClient for
|
|
5377
|
+
`Expected Solana payment network, got: ${details.network}. Use LLMClient for Solana payments.`
|
|
5383
5378
|
);
|
|
5384
5379
|
}
|
|
5385
5380
|
const feePayer = details.extra?.feePayer;
|
|
@@ -5471,7 +5466,7 @@ var SolanaLLMClient = class {
|
|
|
5471
5466
|
const details = extractPaymentDetails(paymentRequired, SOLANA_NETWORK);
|
|
5472
5467
|
if (!details.network?.startsWith("solana:")) {
|
|
5473
5468
|
throw new PaymentError(
|
|
5474
|
-
`Expected Solana payment network, got: ${details.network}. Use LLMClient for
|
|
5469
|
+
`Expected Solana payment network, got: ${details.network}. Use LLMClient for Solana payments.`
|
|
5475
5470
|
);
|
|
5476
5471
|
}
|
|
5477
5472
|
const feePayer = details.extra?.feePayer;
|
|
@@ -5563,7 +5558,7 @@ var SolanaLLMClient = class {
|
|
|
5563
5558
|
const details = extractPaymentDetails(paymentRequired, SOLANA_NETWORK);
|
|
5564
5559
|
if (!details.network?.startsWith("solana:")) {
|
|
5565
5560
|
throw new PaymentError(
|
|
5566
|
-
`Expected Solana payment network, got: ${details.network}. Use LLMClient for
|
|
5561
|
+
`Expected Solana payment network, got: ${details.network}. Use LLMClient for Solana payments.`
|
|
5567
5562
|
);
|
|
5568
5563
|
}
|
|
5569
5564
|
const feePayer = details.extra?.feePayer;
|
|
@@ -5829,7 +5824,7 @@ function setupAgentWallet(options) {
|
|
|
5829
5824
|
`
|
|
5830
5825
|
BridgeNode Agent Wallet Created!
|
|
5831
5826
|
Address: ${address}
|
|
5832
|
-
Send USDC on
|
|
5827
|
+
Send USDC on Solana to get started.
|
|
5833
5828
|
`
|
|
5834
5829
|
);
|
|
5835
5830
|
}
|
|
@@ -6073,7 +6068,7 @@ var AnthropicClient = class {
|
|
|
6073
6068
|
this._account.address,
|
|
6074
6069
|
details.recipient,
|
|
6075
6070
|
details.amount,
|
|
6076
|
-
details.network ||
|
|
6071
|
+
details.network || SOLANA_NETWORK,
|
|
6077
6072
|
{
|
|
6078
6073
|
resourceUrl: validateResourceUrl(
|
|
6079
6074
|
details.resource?.url || `${this._apiUrl}/v1/messages`,
|
|
@@ -6123,7 +6118,6 @@ var AnthropicClient = class {
|
|
|
6123
6118
|
0 && (module.exports = {
|
|
6124
6119
|
APIError,
|
|
6125
6120
|
AnthropicClient,
|
|
6126
|
-
BASE_CHAIN_ID,
|
|
6127
6121
|
BridgeNodeClient,
|
|
6128
6122
|
BridgeNodeError,
|
|
6129
6123
|
ImageClient,
|
|
@@ -6147,8 +6141,6 @@ var AnthropicClient = class {
|
|
|
6147
6141
|
SolanaLLMClient,
|
|
6148
6142
|
SpeechClient,
|
|
6149
6143
|
SurfClient,
|
|
6150
|
-
USDC_BASE,
|
|
6151
|
-
USDC_BASE_CONTRACT,
|
|
6152
6144
|
USDC_SOLANA,
|
|
6153
6145
|
VideoClient,
|
|
6154
6146
|
VoiceClient,
|